diff --git a/mitmproxy/web/static/app.css b/mitmproxy/web/static/app.css index bd4b57be4..bc3f1a6a3 100644 --- a/mitmproxy/web/static/app.css +++ b/mitmproxy/web/static/app.css @@ -1,2 +1,435 @@ -html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}.resource-icon{width:32px;height:32px}.resource-icon-css{background-image:url(images/chrome-devtools/resourceCSSIcon.png)}.resource-icon-document{background-image:url(images/chrome-devtools/resourceDocumentIcon.png)}.resource-icon-js{background-image:url(images/chrome-devtools/resourceJSIcon.png)}.resource-icon-plain{background-image:url(images/chrome-devtools/resourcePlainIcon.png)}.resource-icon-executable{background-image:url(images/resourceExecutableIcon.png)}.resource-icon-flash{background-image:url(images/resourceFlashIcon.png)}.resource-icon-image{background-image:url(images/resourceImageIcon.png)}.resource-icon-java{background-image:url(images/resourceJavaIcon.png)}.resource-icon-not-modified{background-image:url(images/resourceNotModifiedIcon.png)}.resource-icon-redirect{background-image:url(images/resourceRedirectIcon.png)}#container,#mitmproxy,body,html{height:100%;margin:0;overflow:hidden}#container{display:flex;flex-direction:column;outline:0}#container>.eventlog,#container>footer,#container>header,.eventlog{flex:0 0 auto}.main-view{flex:1 1 auto;height:0;display:flex;flex-direction:row}.main-view.vertical{flex-direction:column}.main-view .flow-detail,.main-view .flow-table{flex:1 1 auto}.splitter{flex:0 0 1px;background-color:#aaa;position:relative}.splitter>div{position:absolute}.splitter.splitter-x{cursor:col-resize}.splitter.splitter-x>div{margin-left:-1px;width:4px;height:100%}.splitter.splitter-y{cursor:row-resize}.eventlog .label,.flow-table tr,.prompt-content .option{cursor:pointer}.splitter.splitter-y>div{margin-top:-1px;height:4px;width:100%}.nav-tabs{border-bottom:solid #a6a6a6 1px}.nav-tabs a{display:inline-block;border:1px solid transparent;text-decoration:none}.nav-tabs a.active{background-color:#fff;border-color:#a6a6a6 #a6a6a6 #fff}.nav-tabs a.special{color:#fff;background-color:#396cad;border-bottom-color:#396cad}.nav-tabs a.special:hover{background-color:#5386c6}.nav-tabs-lg a{padding:3px 14px;margin:0 2px -1px}.nav-tabs-sm a{padding:0 7px;margin:2px 2px -1px}.nav-tabs-sm a.nav-action{float:right;padding:0;margin:1px 0 0}header{padding-top:.5em;background-color:#fff}header .menu{padding:10px;border-bottom:solid #a6a6a6 1px}.menu-row{margin-left:-2px;margin-right:-3px}.filter-input{position:relative;min-height:1px;padding-left:2.5px;padding-right:2.5px;margin-bottom:5px}@media (min-width:768px){.filter-input{float:left;width:25%}}.filter-input .popover{top:27px;display:block;max-width:none;opacity:.9}.filter-input .popover .popover-content{max-height:500px;overflow-y:auto}.flow-table{width:100%;overflow-y:scroll;overflow-x:hidden}.flow-table table{width:100%;table-layout:fixed}.flow-table thead{background-color:#F2F2F2;line-height:23px}.flow-table th{font-weight:400;box-shadow:0 1px 0 #a6a6a6;position:relative!important;padding-left:1px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.prompt-content,footer{box-shadow:0 -1px 3px #d3d3d3}.flow-table th.sort-asc,.flow-table th.sort-desc{background-color:#fafafa}.flow-table th.sort-asc:after,.flow-table th.sort-desc:after{font:normal normal normal 14px/1 FontAwesome;position:absolute;right:3px;top:3px;padding:2px;background-color:rgba(250,250,250,.8)}.flow-detail .first-line,.flow-detail table{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;word-break:break-all}.prompt-content,.prompt-dialog{position:fixed;bottom:0;left:0;right:0}.flow-table th.sort-asc:after{content:"\f0de"}.flow-table th.sort-desc:after{content:"\f0dd"}.flow-table tr:nth-child(even){background-color:rgba(0,0,0,.05)}.flow-table tr.selected{background-color:rgba(193,215,235,.5)!important}.flow-table tr.highlighted{background-color:rgba(255,204,0,.4)}.flow-table tr.highlighted:nth-child(even){background-color:rgba(255,204,0,.5)}.flow-table td{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.flow-table tr.intercepted.has-response .col-size,.flow-table tr.intercepted.has-response .col-status,.flow-table tr.intercepted.has-response .col-time,.flow-table tr.intercepted:not(.has-response) .col-method,.flow-table tr.intercepted:not(.has-response) .col-path{color:#ff8000}.flow-table .fa{line-height:inherit}.flow-table .fa.pull-right{margin-left:0}.flow-table .col-tls{width:10px}.flow-table .col-tls-https{background-color:rgba(0,185,0,.5)}.flow-table .col-icon{width:32px}.flow-table .col-path .fa-repeat{color:green}.flow-table .col-path .fa-pause{color:#ff8000}.flow-table .col-method{width:60px}.flow-table .col-status{width:50px}.flow-table .col-size{width:70px}.flow-table .col-time{width:50px}.flow-table td.col-size,.flow-table td.col-time{text-align:right}.flow-detail{width:100%;overflow-x:auto;overflow-y:scroll}.flow-detail nav{background-color:#F2F2F2}.flow-detail section{padding:5px 12px}.flow-detail .first-line{background-color:#428bca;color:#fff;margin:0 -8px;padding:4px 8px;border-radius:5px;max-height:100px;overflow-y:auto}.flow-detail .request-line{margin-bottom:2px}.flow-detail hr{margin:0 0 5px}.inline-input{margin:0 -5px;padding:0 5px}.inline-input[contenteditable]{background-color:rgba(255,255,255,.2)}.inline-input[contenteditable].has-warning{color:#ffb8b8}.view-options{margin-top:10px}.flow-detail table{width:100%;table-layout:fixed}.flow-detail table tr:not(:first-child){border-top:1px solid #f7f7f7}.flow-detail table td{vertical-align:top}.connection-table td:first-child{width:50%;padding-right:1em}.header-table td{line-height:1.3em}.header-table .header-name{width:33%;padding-right:1em}.connection-table td,.timing-table td{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.flowview-image{text-align:center}.flowview-image img{max-width:100%;max-height:100%}.prompt-dialog{top:0;z-index:100;background-color:rgba(0,0,0,.1)}.prompt-content{height:25px;padding:2px 5px;background-color:#fff}.prompt-content .option:not(:last-child)::after{content:", "}.eventlog{height:200px;display:flex;flex-direction:column}.eventlog>div{background-color:#F2F2F2;padding:0 5px;flex:0 0 auto}.eventlog>pre{flex:1 1 auto;margin:0;border-radius:0;overflow-x:auto;overflow-y:scroll;background-color:#fcfcfc}.eventlog .fa-close{cursor:pointer;float:right;color:grey;padding:3px 0 3px 10px}.eventlog .fa-close:hover{color:#000}.eventlog .btn-toggle{margin-top:-2px;margin-left:3px;padding:2px;font-size:10px;line-height:10px;border-radius:2px}.eventlog .label{vertical-align:middle;display:inline-block;margin-top:-2px;margin-left:3px}footer{padding:0 10px 3px}footer .label{margin-right:3px} +html { + box-sizing: border-box; +} +*, +*:before, +*:after { + box-sizing: inherit; +} +.resource-icon { + width: 32px; + height: 32px; +} +.resource-icon-css { + background-image: url(images/chrome-devtools/resourceCSSIcon.png); +} +.resource-icon-document { + background-image: url(images/chrome-devtools/resourceDocumentIcon.png); +} +.resource-icon-js { + background-image: url(images/chrome-devtools/resourceJSIcon.png); +} +.resource-icon-plain { + background-image: url(images/chrome-devtools/resourcePlainIcon.png); +} +.resource-icon-executable { + background-image: url(images/resourceExecutableIcon.png); +} +.resource-icon-flash { + background-image: url(images/resourceFlashIcon.png); +} +.resource-icon-image { + background-image: url(images/resourceImageIcon.png); +} +.resource-icon-java { + background-image: url(images/resourceJavaIcon.png); +} +.resource-icon-not-modified { + background-image: url(images/resourceNotModifiedIcon.png); +} +.resource-icon-redirect { + background-image: url(images/resourceRedirectIcon.png); +} +html, +body, +#container, +#mitmproxy { + height: 100%; + margin: 0; + overflow: hidden; +} +#container { + display: flex; + flex-direction: column; + outline: none; +} +#container > header, +#container > footer, +#container > .eventlog { + flex: 0 0 auto; +} +.main-view { + flex: 1 1 auto; + height: 0; + display: flex; + flex-direction: row; +} +.main-view.vertical { + flex-direction: column; +} +.main-view .flow-detail, +.main-view .flow-table { + flex: 1 1 auto; +} +.splitter { + flex: 0 0 1px; + background-color: #aaa; + position: relative; +} +.splitter > div { + position: absolute; +} +.splitter.splitter-x { + cursor: col-resize; +} +.splitter.splitter-x > div { + margin-left: -1px; + width: 4px; + height: 100%; +} +.splitter.splitter-y { + cursor: row-resize; +} +.splitter.splitter-y > div { + margin-top: -1px; + height: 4px; + width: 100%; +} +.nav-tabs { + border-bottom: solid #a6a6a6 1px; +} +.nav-tabs a { + display: inline-block; + border: solid transparent 1px; + text-decoration: none; +} +.nav-tabs a.active { + background-color: white; + border-color: #a6a6a6; + border-bottom-color: white; +} +.nav-tabs a.special { + color: white; + background-color: #396cad; + border-bottom-color: #396cad; +} +.nav-tabs a.special:hover { + background-color: #5386c6; +} +.nav-tabs-lg a { + padding: 3px 14px; + margin: 0 2px -1px; +} +.nav-tabs-sm a { + padding: 0px 7px; + margin: 2px 2px -1px; +} +.nav-tabs-sm a.nav-action { + float: right; + padding: 0; + margin: 1px 0 0px; +} +header { + padding-top: 0.5em; + background-color: white; +} +header .menu { + padding: 10px; + border-bottom: solid #a6a6a6 1px; +} +.menu-row { + margin-left: -2px; + margin-right: -3px; +} +.filter-input { + position: relative; + min-height: 1px; + padding-left: 2.5px; + padding-right: 2.5px; + margin-bottom: 5px; +} +@media (min-width: 768px) { + .filter-input { + float: left; + width: 25%; + } +} +.filter-input .popover { + top: 27px; + display: block; + max-width: none; + opacity: 0.9; +} +.filter-input .popover .popover-content { + max-height: 500px; + overflow-y: auto; +} +.flow-table { + width: 100%; + overflow-y: scroll; + overflow-x: hidden; +} +.flow-table table { + width: 100%; + table-layout: fixed; +} +.flow-table thead { + background-color: #F2F2F2; + line-height: 23px; +} +.flow-table th { + font-weight: normal; + box-shadow: 0 1px 0 #a6a6a6; + position: relative !important; + padding-left: 1px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.flow-table th.sort-asc, +.flow-table th.sort-desc { + background-color: #fafafa; +} +.flow-table th.sort-asc:after, +.flow-table th.sort-desc:after { + font: normal normal normal 14px/1 FontAwesome; + position: absolute; + right: 3px; + top: 3px; + padding: 2px; + background-color: rgba(250, 250, 250, 0.8); +} +.flow-table th.sort-asc:after { + content: "\f0de"; +} +.flow-table th.sort-desc:after { + content: "\f0dd"; +} +.flow-table tr { + cursor: pointer; +} +.flow-table tr:nth-child(even) { + background-color: rgba(0, 0, 0, 0.05); +} +.flow-table tr.selected { + background-color: rgba(193, 215, 235, 0.5) !important; +} +.flow-table tr.highlighted { + background-color: rgba(255, 204, 0, 0.4); +} +.flow-table tr.highlighted:nth-child(even) { + background-color: rgba(255, 204, 0, 0.5); +} +.flow-table td { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +.flow-table tr.intercepted:not(.has-response) .col-path, +.flow-table tr.intercepted:not(.has-response) .col-method { + color: #ff8000; +} +.flow-table tr.intercepted.has-response .col-status, +.flow-table tr.intercepted.has-response .col-size, +.flow-table tr.intercepted.has-response .col-time { + color: #ff8000; +} +.flow-table .fa { + line-height: inherit; +} +.flow-table .fa.pull-right { + margin-left: 0; +} +.flow-table .col-tls { + width: 10px; +} +.flow-table .col-tls-https { + background-color: rgba(0, 185, 0, 0.5); +} +.flow-table .col-icon { + width: 32px; +} +.flow-table .col-path .fa-repeat { + color: green; +} +.flow-table .col-path .fa-pause { + color: #ff8000; +} +.flow-table .col-method { + width: 60px; +} +.flow-table .col-status { + width: 50px; +} +.flow-table .col-size { + width: 70px; +} +.flow-table .col-time { + width: 50px; +} +.flow-table td.col-time, +.flow-table td.col-size { + text-align: right; +} +.flow-detail { + width: 100%; + overflow-x: auto; + overflow-y: scroll; + /*.request .response-line, + .response .request-line { + opacity: 0.7; + }*/ +} +.flow-detail nav { + background-color: #F2F2F2; +} +.flow-detail section { + padding: 5px 12px; +} +.flow-detail .first-line { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + background-color: #428bca; + color: white; + margin: 0 -8px; + padding: 4px 8px; + border-radius: 5px; + word-break: break-all; + max-height: 100px; + overflow-y: auto; +} +.flow-detail .request-line { + margin-bottom: 2px; +} +.flow-detail hr { + margin: 0 0 5px; +} +.inline-input { + margin: 0 -5px; + padding: 0 5px; +} +.inline-input[contenteditable] { + background-color: rgba(255, 255, 255, 0.2); +} +.inline-input[contenteditable].has-warning { + color: #ffb8b8; +} +.view-options { + margin-top: 10px; +} +.flow-detail table { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + width: 100%; + table-layout: fixed; + word-break: break-all; +} +.flow-detail table tr:not(:first-child) { + border-top: 1px solid #f7f7f7; +} +.flow-detail table td { + vertical-align: top; +} +.connection-table td:first-child { + width: 50%; + padding-right: 1em; +} +.header-table td { + line-height: 1.3em; +} +.header-table .header-name { + width: 33%; + padding-right: 1em; +} +.connection-table td, +.timing-table td { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.flowview-image { + text-align: center; +} +.flowview-image img { + max-width: 100%; + max-height: 100%; +} +.prompt-dialog { + top: 0; + bottom: 0; + left: 0; + right: 0; + position: fixed; + z-index: 100; + background-color: rgba(0, 0, 0, 0.1); +} +.prompt-content { + position: fixed; + bottom: 0; + left: 0; + right: 0; + height: 25px; + padding: 2px 5px; + background-color: white; + box-shadow: 0 -1px 3px lightgray; +} +.prompt-content .option { + cursor: pointer; +} +.prompt-content .option:not(:last-child)::after { + content: ", "; +} +.eventlog { + height: 200px; + flex: 0 0 auto; + display: flex; + flex-direction: column; +} +.eventlog > div { + background-color: #F2F2F2; + padding: 0 5px; + flex: 0 0 auto; +} +.eventlog > pre { + flex: 1 1 auto; + margin: 0; + border-radius: 0; + overflow-x: auto; + overflow-y: scroll; + background-color: #fcfcfc; +} +.eventlog .fa-close { + cursor: pointer; + float: right; + color: grey; + padding: 3px 0; + padding-left: 10px; +} +.eventlog .fa-close:hover { + color: black; +} +.eventlog .btn-toggle { + margin-top: -2px; + margin-left: 3px; + padding: 2px 2px; + font-size: 10px; + line-height: 10px; + border-radius: 2px; +} +.eventlog .label { + cursor: pointer; + vertical-align: middle; + display: inline-block; + margin-top: -2px; + margin-left: 3px; +} +footer { + box-shadow: 0 -1px 3px lightgray; + padding: 0px 10px 3px; +} +footer .label { + margin-right: 3px; +} + /*# sourceMappingURL=app.css.map */ diff --git a/mitmproxy/web/static/app.js b/mitmproxy/web/static/app.js index 2fc1540b6..768236bee 100644 --- a/mitmproxy/web/static/app.js +++ b/mitmproxy/web/static/app.js @@ -1,125 +1,7887 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oe||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,i,n,s,r,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(i=this._events[e],isUndefined(i))return!1;if(isFunction(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),i.apply(this,s)}else if(isObject(i))for(s=Array.prototype.slice.call(arguments,1),o=i.slice(),n=o.length,r=0;n>r;r++)o[r].apply(this,s);return!0},EventEmitter.prototype.addListener=function(e,t){var i;if(!isFunction(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned&&(i=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},EventEmitter.prototype.removeListener=function(e,t){var i,n,s,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(i)){for(r=s;r-- >0;)if(i[r]===t||i[r].listener&&i[r].listener===t){n=r;break}if(0>n)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],isFunction(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(isFunction(t))return 1;if(t)return t.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)}; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } + throw TypeError('Uncaught, unspecified "error" event.'); + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} },{}],2:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Query=exports.FlowActions=exports.SettingsActions=exports.ConnectionActions=exports.StoreCmds=exports.ActionTypes=void 0;var _jquery=require("jquery"),_jquery2=_interopRequireDefault(_jquery),_dispatcher=require("./dispatcher.js"),_utils=require("./utils.js"),ActionTypes=exports.ActionTypes={CONNECTION_OPEN:"connection_open",CONNECTION_CLOSE:"connection_close",CONNECTION_ERROR:"connection_error",SETTINGS_STORE:"settings",EVENT_STORE:"events",FLOW_STORE:"flows"},StoreCmds=exports.StoreCmds={ADD:"add",UPDATE:"update",REMOVE:"remove",RESET:"reset"},ConnectionActions=exports.ConnectionActions={open:function(){_dispatcher.AppDispatcher.dispatchViewAction({type:ActionTypes.CONNECTION_OPEN})},close:function(){_dispatcher.AppDispatcher.dispatchViewAction({type:ActionTypes.CONNECTION_CLOSE})},error:function(){_dispatcher.AppDispatcher.dispatchViewAction({type:ActionTypes.CONNECTION_ERROR})}},SettingsActions=exports.SettingsActions={update:function(e){_jquery2["default"].ajax({type:"PUT",url:"/settings",contentType:"application/json",data:JSON.stringify(e)})}},FlowActions=exports.FlowActions={accept:function(e){_jquery2["default"].post("/flows/"+e.id+"/accept")},accept_all:function(){_jquery2["default"].post("/flows/accept")},"delete":function(e){_jquery2["default"].ajax({type:"DELETE",url:"/flows/"+e.id})},duplicate:function(e){_jquery2["default"].post("/flows/"+e.id+"/duplicate")},replay:function(e){_jquery2["default"].post("/flows/"+e.id+"/replay")},revert:function(e){_jquery2["default"].post("/flows/"+e.id+"/revert")},update:function(e,t){_jquery2["default"].ajax({type:"PUT",url:"/flows/"+e.id,contentType:"application/json",data:JSON.stringify(t)})},clear:function(){_jquery2["default"].post("/clear")},download:function(){return window.location="/flows/dump"},upload:function(e){var t=new FormData;t.append("file",e),(0,_utils.fetchApi)("/flows/dump",{method:"post",body:t})}},Query=exports.Query={SEARCH:"s",HIGHLIGHT:"h",SHOW_EVENTLOG:"e"}; +"use strict"; -},{"./dispatcher.js":31,"./utils.js":41,"jquery":"jquery"}],3:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}var _react=require("react"),_react2=_interopRequireDefault(_react),_reactDom=require("react-dom"),_redux=require("redux"),_reactRedux=require("react-redux"),_reduxLogger=require("redux-logger"),_reduxLogger2=_interopRequireDefault(_reduxLogger),_reduxThunk=require("redux-thunk"),_reduxThunk2=_interopRequireDefault(_reduxThunk),_reactRouter=require("react-router"),_connection=require("./connection"),_connection2=_interopRequireDefault(_connection),_ProxyApp=require("./components/ProxyApp"),_ProxyApp2=_interopRequireDefault(_ProxyApp),_MainView=require("./components/MainView"),_MainView2=_interopRequireDefault(_MainView),_index=require("./ducks/index"),_index2=_interopRequireDefault(_index),_eventLog=require("./ducks/eventLog"),store=(0,_redux.createStore)(_index2["default"],(0,_redux.applyMiddleware)(_reduxThunk2["default"],(0,_reduxLogger2["default"])()));window.addEventListener("error",function(e){store.dispatch((0,_eventLog.addLogEntry)(e))}),document.addEventListener("DOMContentLoaded",function(){window.ws=new _connection2["default"]("/updates",store.dispatch),(0,_reactDom.render)(_react2["default"].createElement(_reactRedux.Provider,{store:store},_react2["default"].createElement(_reactRouter.Router,{history:_reactRouter.hashHistory},_react2["default"].createElement(_reactRouter.Redirect,{from:"/",to:"/flows"}),_react2["default"].createElement(_reactRouter.Route,{path:"/",component:_ProxyApp2["default"]},_react2["default"].createElement(_reactRouter.Route,{path:"flows",component:_MainView2["default"]}),_react2["default"].createElement(_reactRouter.Route,{path:"flows/:flowId/:detailTab",component:_MainView2["default"]})))),document.getElementById("mitmproxy"))}); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Query = exports.FlowActions = exports.SettingsActions = exports.ConnectionActions = exports.StoreCmds = exports.ActionTypes = undefined; -},{"./components/MainView":18,"./components/ProxyApp":19,"./connection":30,"./ducks/eventLog":32,"./ducks/index":34,"react":"react","react-dom":"react-dom","react-redux":"react-redux","react-router":"react-router","redux":"redux","redux-logger":"redux-logger","redux-thunk":"redux-thunk"}],4:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function EventLog(e){var t=e.filters,r=e.events,n=e.onToggleFilter,o=e.onClose;return _react2["default"].createElement("div",{className:"eventlog"},_react2["default"].createElement("div",null,"Eventlog",_react2["default"].createElement("div",{className:"pull-right"},["debug","info","web"].map(function(e){return _react2["default"].createElement(_common.ToggleButton,{key:e,text:e,checked:t[e],onToggle:function(){return n(e)}})}),_react2["default"].createElement("i",{onClick:o,className:"fa fa-close"}))),_react2["default"].createElement(_EventList2["default"],{events:r}))}Object.defineProperty(exports,"__esModule",{value:!0});var _react=require("react"),_react2=_interopRequireDefault(_react),_redux=require("redux"),_reactRedux=require("react-redux"),_eventLog=require("../ducks/eventLog"),_common=require("./common"),_EventList=require("./EventLog/EventList"),_EventList2=_interopRequireDefault(_EventList);EventLog.propTypes={filters:_react.PropTypes.object.isRequired,events:_react.PropTypes.array.isRequired,onToggleFilter:_react.PropTypes.func.isRequired,onClose:_react.PropTypes.func.isRequired},exports["default"]=(0,_reactRedux.connect)(function(e){return{filters:e.eventLog.filter,events:e.eventLog.filteredEvents}},function(e){return(0,_redux.bindActionCreators)({onClose:_eventLog.toggleEventLogVisibility,onToggleFilter:_eventLog.toggleEventLogFilter},e)})(EventLog); +var _jquery = require("jquery"); -},{"../ducks/eventLog":32,"./EventLog/EventList":5,"./common":20,"react":"react","react-redux":"react-redux","redux":"redux"}],5:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function LogIcon(e){var t=e.event,r={web:"html5",debug:"bug"}[t.level]||"info";return _react2["default"].createElement("i",{className:"fa fa-fw fa-"+r})}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;rn-i?l.scrollTop=n-i:u>c+s&&(l.scrollTop=u-s)}}},{key:"componentWillReceiveProps",value:function(e){e.selected&&e.selected!==this.props.selected&&(this.shouldScrollIntoView=!0)}},{key:"onViewportUpdate",value:function(){var e=_reactDom2["default"].findDOMNode(this),t=e.scrollTop,o=(0,_VirtualScroll.calcVScroll)({viewportTop:t,viewportHeight:e.offsetHeight,itemCount:this.props.flows.length,rowHeight:this.props.rowHeight});this.state.viewportTop===t&&(0,_shallowequal2["default"])(this.state.vScroll,o)||this.setState({vScroll:o,viewportTop:t})}},{key:"render",value:function(){var e=this,t=this.state,o=t.vScroll,r=t.viewportTop,l=this.props,a=l.flows,i=l.selected,n=l.highlight,u=n?_filt2["default"].parse(n):function(){return!1};return _react2["default"].createElement("div",{className:"flow-table",onScroll:this.onViewportUpdate},_react2["default"].createElement("table",null,_react2["default"].createElement("thead",{ref:"head",style:{transform:"translateY("+r+"px)"}},_react2["default"].createElement(_FlowTableHead2["default"],null)),_react2["default"].createElement("tbody",null,_react2["default"].createElement("tr",{style:{height:o.paddingTop}}),a.slice(o.start,o.end).map(function(t){return _react2["default"].createElement(_FlowRow2["default"],{key:t.id,flow:t,selected:t===i,highlighted:u(t),onSelect:e.props.onSelect})}),_react2["default"].createElement("tr",{style:{height:o.paddingBottom}}))))}}]),t}(_react2["default"].Component);FlowTable.propTypes={onSelect:_react.PropTypes.func.isRequired,flows:_react.PropTypes.array.isRequired,rowHeight:_react.PropTypes.number,highlight:_react.PropTypes.string,selected:_react.PropTypes.object},FlowTable.defaultProps={rowHeight:32},exports["default"]=(0,_AutoScroll2["default"])(FlowTable); +var _dispatcher = require("./dispatcher.js"); -},{"../filt/filt":38,"./FlowTable/FlowRow":8,"./FlowTable/FlowTableHead":9,"./helpers/AutoScroll":27,"./helpers/VirtualScroll":28,"react":"react","react-dom":"react-dom","shallowequal":"shallowequal"}],7:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function TLSColumn(e){var t=e.flow;return _react2["default"].createElement("td",{className:(0,_classnames2["default"])("col-tls","https"===t.request.scheme?"col-tls-https":"col-tls-http")})}function IconColumn(e){var t=e.flow;return _react2["default"].createElement("td",{className:"col-icon"},_react2["default"].createElement("div",{className:(0,_classnames2["default"])("resource-icon",IconColumn.getIcon(t))}))}function PathColumn(e){var t=e.flow;return _react2["default"].createElement("td",{className:"col-path"},t.request.is_replay&&_react2["default"].createElement("i",{className:"fa fa-fw fa-repeat pull-right"}),t.intercepted&&_react2["default"].createElement("i",{className:"fa fa-fw fa-pause pull-right"}),_utils.RequestUtils.pretty_url(t.request))}function MethodColumn(e){var t=e.flow;return _react2["default"].createElement("td",{className:"col-method"},t.request.method)}function StatusColumn(e){var t=e.flow;return _react2["default"].createElement("td",{className:"col-status"},t.response&&t.response.status_code)}function SizeColumn(e){var t=e.flow;return _react2["default"].createElement("td",{className:"col-size"},(0,_utils2.formatSize)(SizeColumn.getTotalSize(t)))}function TimeColumn(e){var t=e.flow;return _react2["default"].createElement("td",{className:"col-time"},t.response?(0,_utils2.formatTimeDelta)(1e3*(t.response.timestamp_end-t.request.timestamp_start)):"...")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.TLSColumn=TLSColumn,exports.IconColumn=IconColumn,exports.PathColumn=PathColumn,exports.MethodColumn=MethodColumn,exports.StatusColumn=StatusColumn,exports.SizeColumn=SizeColumn,exports.TimeColumn=TimeColumn;var _react=require("react"),_react2=_interopRequireDefault(_react),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_utils=require("../../flow/utils.js"),_utils2=require("../../utils.js");TLSColumn.sortKeyFun=function(e){return e.request.scheme},TLSColumn.headerClass="col-tls",TLSColumn.headerName="",IconColumn.headerClass="col-icon",IconColumn.headerName="",IconColumn.getIcon=function(e){if(!e.response)return"resource-icon-plain";var t=_utils.ResponseUtils.getContentType(e.response)||"";return 304===e.response.status_code?"resource-icon-not-modified":300<=e.response.status_code&&e.response.status_code<400?"resource-icon-redirect":t.indexOf("image")>=0?"resource-icon-image":t.indexOf("javascript")>=0?"resource-icon-js":t.indexOf("css")>=0?"resource-icon-css":t.indexOf("html")>=0?"resource-icon-document":"resource-icon-plain"},PathColumn.sortKeyFun=function(e){return _utils.RequestUtils.pretty_url(e.request)},PathColumn.headerClass="col-path",PathColumn.headerName="Path",MethodColumn.sortKeyFun=function(e){return e.request.method},MethodColumn.headerClass="col-method",MethodColumn.headerName="Method",StatusColumn.sortKeyFun=function(e){return e.response&&e.response.status_code},StatusColumn.headerClass="col-status",StatusColumn.headerName="Status",SizeColumn.sortKeyFun=function(e){var t=e.request.contentLength;return e.response&&(t+=e.response.contentLength||0),t},SizeColumn.getTotalSize=SizeColumn.sortKeyFun,SizeColumn.headerClass="col-size",SizeColumn.headerName="Size",TimeColumn.sortKeyFun=function(e){return e.response&&e.response.timestamp_end-e.request.timestamp_start},TimeColumn.headerClass="col-time",TimeColumn.headerName="Time",exports["default"]=[TLSColumn,IconColumn,PathColumn,MethodColumn,StatusColumn,SizeColumn,TimeColumn]; +var _utils = require("./utils.js"); -},{"../../flow/utils.js":39,"../../utils.js":41,"classnames":"classnames","react":"react"}],8:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function FlowRow(e){var t=e.flow,r=e.selected,l=e.highlighted,o=e.onSelect,s=(0,_classnames2["default"])({selected:r,highlighted:l,intercepted:t.intercepted,"has-request":t.request,"has-response":t.response});return _react2["default"].createElement("tr",{className:s,onClick:function(){return o(t)}},_FlowColumns2["default"].map(function(e){return _react2["default"].createElement(e,{key:e.name,flow:t})}))}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=FlowRow;var _react=require("react"),_react2=_interopRequireDefault(_react),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_FlowColumns=require("./FlowColumns"),_FlowColumns2=_interopRequireDefault(_FlowColumns);FlowRow.propTypes={onSelect:_react.PropTypes.func.isRequired,flow:_react.PropTypes.object.isRequired,highlighted:_react.PropTypes.bool,selected:_react.PropTypes.bool}; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var ActionTypes = exports.ActionTypes = { + // Connection + CONNECTION_OPEN: "connection_open", + CONNECTION_CLOSE: "connection_close", + CONNECTION_ERROR: "connection_error", + + // Stores + SETTINGS_STORE: "settings", + EVENT_STORE: "events", + FLOW_STORE: "flows" +}; + +var StoreCmds = exports.StoreCmds = { + ADD: "add", + UPDATE: "update", + REMOVE: "remove", + RESET: "reset" +}; + +var ConnectionActions = exports.ConnectionActions = { + open: function open() { + _dispatcher.AppDispatcher.dispatchViewAction({ + type: ActionTypes.CONNECTION_OPEN + }); + }, + close: function close() { + _dispatcher.AppDispatcher.dispatchViewAction({ + type: ActionTypes.CONNECTION_CLOSE + }); + }, + error: function error() { + _dispatcher.AppDispatcher.dispatchViewAction({ + type: ActionTypes.CONNECTION_ERROR + }); + } +}; + +var SettingsActions = exports.SettingsActions = { + update: function update(settings) { + + _jquery2.default.ajax({ + type: "PUT", + url: "/settings", + contentType: 'application/json', + data: JSON.stringify(settings) + }); + + /* + //Facebook Flux: We do an optimistic update on the client already. + AppDispatcher.dispatchViewAction({ + type: ActionTypes.SETTINGS_STORE, + cmd: StoreCmds.UPDATE, + data: settings + }); + */ + } +}; + +var FlowActions = exports.FlowActions = { + accept: function accept(flow) { + _jquery2.default.post("/flows/" + flow.id + "/accept"); + }, + accept_all: function accept_all() { + _jquery2.default.post("/flows/accept"); + }, + "delete": function _delete(flow) { + _jquery2.default.ajax({ + type: "DELETE", + url: "/flows/" + flow.id + }); + }, + duplicate: function duplicate(flow) { + _jquery2.default.post("/flows/" + flow.id + "/duplicate"); + }, + replay: function replay(flow) { + _jquery2.default.post("/flows/" + flow.id + "/replay"); + }, + revert: function revert(flow) { + _jquery2.default.post("/flows/" + flow.id + "/revert"); + }, + update: function update(flow, nextProps) { + /* + //Facebook Flux: We do an optimistic update on the client already. + var nextFlow = _.cloneDeep(flow); + _.merge(nextFlow, nextProps); + AppDispatcher.dispatchViewAction({ + type: ActionTypes.FLOW_STORE, + cmd: StoreCmds.UPDATE, + data: nextFlow + }); + */ + _jquery2.default.ajax({ + type: "PUT", + url: "/flows/" + flow.id, + contentType: 'application/json', + data: JSON.stringify(nextProps) + }); + }, + clear: function clear() { + _jquery2.default.post("/clear"); + }, + download: function download() { + return window.location = "/flows/dump"; + }, + + upload: function upload(file) { + var data = new FormData(); + data.append('file', file); + (0, _utils.fetchApi)("/flows/dump", { + method: 'post', + body: data + }); + } +}; + +var Query = exports.Query = { + SEARCH: "s", + HIGHLIGHT: "h", + SHOW_EVENTLOG: "e" +}; + +},{"./dispatcher.js":32,"./utils.js":43,"jquery":"jquery"}],3:[function(require,module,exports){ +'use strict'; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require('react-dom'); + +var _redux = require('redux'); + +var _reactRedux = require('react-redux'); + +var _reduxLogger = require('redux-logger'); + +var _reduxLogger2 = _interopRequireDefault(_reduxLogger); + +var _reduxThunk = require('redux-thunk'); + +var _reduxThunk2 = _interopRequireDefault(_reduxThunk); + +var _reactRouter = require('react-router'); + +var _connection = require('./connection'); + +var _connection2 = _interopRequireDefault(_connection); + +var _ProxyApp = require('./components/ProxyApp'); + +var _ProxyApp2 = _interopRequireDefault(_ProxyApp); + +var _MainView = require('./components/MainView'); + +var _MainView2 = _interopRequireDefault(_MainView); + +var _index = require('./ducks/index'); + +var _index2 = _interopRequireDefault(_index); + +var _eventLog = require('./ducks/eventLog'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// logger must be last +var store = (0, _redux.createStore)(_index2.default, (0, _redux.applyMiddleware)(_reduxThunk2.default, (0, _reduxLogger2.default)())); + +window.addEventListener('error', function (msg) { + store.dispatch((0, _eventLog.addLogEntry)(msg)); +}); + +// @todo remove this +document.addEventListener('DOMContentLoaded', function () { + window.ws = new _connection2.default("/updates", store.dispatch); + + (0, _reactDom.render)(_react2.default.createElement( + _reactRedux.Provider, + { store: store }, + _react2.default.createElement( + _reactRouter.Router, + { history: _reactRouter.hashHistory }, + _react2.default.createElement(_reactRouter.Redirect, { from: '/', to: '/flows' }), + _react2.default.createElement( + _reactRouter.Route, + { path: '/', component: _ProxyApp2.default }, + _react2.default.createElement(_reactRouter.Route, { path: 'flows', component: _MainView2.default }), + _react2.default.createElement(_reactRouter.Route, { path: 'flows/:flowId/:detailTab', component: _MainView2.default }) + ) + ) + ), document.getElementById("mitmproxy")); +}); + +},{"./components/MainView":19,"./components/ProxyApp":20,"./connection":31,"./ducks/eventLog":33,"./ducks/index":35,"react":"react","react-dom":"react-dom","react-redux":"react-redux","react-router":"react-router","redux":"redux","redux-logger":"redux-logger","redux-thunk":"redux-thunk"}],4:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _redux = require('redux'); + +var _reactRedux = require('react-redux'); + +var _eventLog = require('../ducks/eventLog'); + +var _common = require('./common'); + +var _EventList = require('./EventLog/EventList'); + +var _EventList2 = _interopRequireDefault(_EventList); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +EventLog.propTypes = { + filters: _react.PropTypes.object.isRequired, + events: _react.PropTypes.array.isRequired, + onToggleFilter: _react.PropTypes.func.isRequired, + onClose: _react.PropTypes.func.isRequired +}; + +function EventLog(_ref) { + var filters = _ref.filters; + var events = _ref.events; + var onToggleFilter = _ref.onToggleFilter; + var onClose = _ref.onClose; + + return _react2.default.createElement( + 'div', + { className: 'eventlog' }, + _react2.default.createElement( + 'div', + null, + 'Eventlog', + _react2.default.createElement( + 'div', + { className: 'pull-right' }, + ['debug', 'info', 'web'].map(function (type) { + return _react2.default.createElement(_common.ToggleButton, { key: type, text: type, checked: filters[type], onToggle: function onToggle() { + return onToggleFilter(type); + } }); + }), + _react2.default.createElement('i', { onClick: onClose, className: 'fa fa-close' }) + ) + ), + _react2.default.createElement(_EventList2.default, { events: events }) + ); +} + +exports.default = (0, _reactRedux.connect)(function (state) { + return { + filters: state.eventLog.filter, + events: state.eventLog.filteredEvents + }; +}, function (dispatch) { + return (0, _redux.bindActionCreators)({ + onClose: _eventLog.toggleEventLogVisibility, + onToggleFilter: _eventLog.toggleEventLogFilter + }, dispatch); +})(EventLog); + +},{"../ducks/eventLog":33,"./EventLog/EventList":5,"./common":21,"react":"react","react-redux":"react-redux","redux":"redux"}],5:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require('react-dom'); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _shallowequal = require('shallowequal'); + +var _shallowequal2 = _interopRequireDefault(_shallowequal); + +var _AutoScroll = require('../helpers/AutoScroll'); + +var _AutoScroll2 = _interopRequireDefault(_AutoScroll); + +var _VirtualScroll = require('../helpers/VirtualScroll'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var EventLogList = function (_Component) { + _inherits(EventLogList, _Component); + + function EventLogList(props) { + _classCallCheck(this, EventLogList); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(EventLogList).call(this, props)); + + _this.heights = {}; + _this.state = { vScroll: (0, _VirtualScroll.calcVScroll)() }; + + _this.onViewportUpdate = _this.onViewportUpdate.bind(_this); + return _this; + } + + _createClass(EventLogList, [{ + key: 'componentDidMount', + value: function componentDidMount() { + window.addEventListener('resize', this.onViewportUpdate); + this.onViewportUpdate(); + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + window.removeEventListener('resize', this.onViewportUpdate); + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate() { + this.onViewportUpdate(); + } + }, { + key: 'onViewportUpdate', + value: function onViewportUpdate() { + var _this2 = this; + + var viewport = _reactDom2.default.findDOMNode(this); + + var vScroll = (0, _VirtualScroll.calcVScroll)({ + itemCount: this.props.events.length, + rowHeight: this.props.rowHeight, + viewportTop: viewport.scrollTop, + viewportHeight: viewport.offsetHeight, + itemHeights: this.props.events.map(function (entry) { + return _this2.heights[entry.id]; + }) + }); + + if (!(0, _shallowequal2.default)(this.state.vScroll, vScroll)) { + this.setState({ vScroll: vScroll }); + } + } + }, { + key: 'setHeight', + value: function setHeight(id, node) { + if (node && !this.heights[id]) { + var height = node.offsetHeight; + if (this.heights[id] !== height) { + this.heights[id] = height; + this.onViewportUpdate(); + } + } + } + }, { + key: 'render', + value: function render() { + var _this3 = this; + + var vScroll = this.state.vScroll; + var events = this.props.events; + + + return _react2.default.createElement( + 'pre', + { onScroll: this.onViewportUpdate }, + _react2.default.createElement('div', { style: { height: vScroll.paddingTop } }), + events.slice(vScroll.start, vScroll.end).map(function (event) { + return _react2.default.createElement( + 'div', + { key: event.id, ref: function ref(node) { + return _this3.setHeight(event.id, node); + } }, + _react2.default.createElement(LogIcon, { event: event }), + event.message + ); + }), + _react2.default.createElement('div', { style: { height: vScroll.paddingBottom } }) + ); + } + }]); + + return EventLogList; +}(_react.Component); + +EventLogList.propTypes = { + events: _react.PropTypes.array.isRequired, + rowHeight: _react.PropTypes.number +}; +EventLogList.defaultProps = { + rowHeight: 18 +}; + + +function LogIcon(_ref) { + var event = _ref.event; + + var icon = { web: 'html5', debug: 'bug' }[event.level] || 'info'; + return _react2.default.createElement('i', { className: 'fa fa-fw fa-' + icon }); +} + +exports.default = (0, _AutoScroll2.default)(EventLogList); + +},{"../helpers/AutoScroll":28,"../helpers/VirtualScroll":29,"react":"react","react-dom":"react-dom","shallowequal":"shallowequal"}],6:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require('react-dom'); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _shallowequal = require('shallowequal'); + +var _shallowequal2 = _interopRequireDefault(_shallowequal); + +var _AutoScroll = require('./helpers/AutoScroll'); + +var _AutoScroll2 = _interopRequireDefault(_AutoScroll); + +var _VirtualScroll = require('./helpers/VirtualScroll'); + +var _FlowTableHead = require('./FlowTable/FlowTableHead'); + +var _FlowTableHead2 = _interopRequireDefault(_FlowTableHead); + +var _FlowRow = require('./FlowTable/FlowRow'); + +var _FlowRow2 = _interopRequireDefault(_FlowRow); + +var _filt = require('../filt/filt'); + +var _filt2 = _interopRequireDefault(_filt); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var FlowTable = function (_React$Component) { + _inherits(FlowTable, _React$Component); + + function FlowTable(props, context) { + _classCallCheck(this, FlowTable); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(FlowTable).call(this, props, context)); + + _this.state = { vScroll: (0, _VirtualScroll.calcVScroll)() }; + _this.onViewportUpdate = _this.onViewportUpdate.bind(_this); + return _this; + } + + _createClass(FlowTable, [{ + key: 'componentWillMount', + value: function componentWillMount() { + window.addEventListener('resize', this.onViewportUpdate); + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + window.removeEventListener('resize', this.onViewportUpdate); + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate() { + this.onViewportUpdate(); + + if (!this.shouldScrollIntoView) { + return; + } + + this.shouldScrollIntoView = false; + + var _props = this.props; + var rowHeight = _props.rowHeight; + var flows = _props.flows; + var selected = _props.selected; + + var viewport = _reactDom2.default.findDOMNode(this); + var head = _reactDom2.default.findDOMNode(this.refs.head); + + var headHeight = head ? head.offsetHeight : 0; + + var rowTop = flows.indexOf(selected) * rowHeight + headHeight; + var rowBottom = rowTop + rowHeight; + + var viewportTop = viewport.scrollTop; + var viewportHeight = viewport.offsetHeight; + + // Account for pinned thead + if (rowTop - headHeight < viewportTop) { + viewport.scrollTop = rowTop - headHeight; + } else if (rowBottom > viewportTop + viewportHeight) { + viewport.scrollTop = rowBottom - viewportHeight; + } + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + if (nextProps.selected && nextProps.selected !== this.props.selected) { + this.shouldScrollIntoView = true; + } + } + }, { + key: 'onViewportUpdate', + value: function onViewportUpdate() { + var viewport = _reactDom2.default.findDOMNode(this); + var viewportTop = viewport.scrollTop; + + var vScroll = (0, _VirtualScroll.calcVScroll)({ + viewportTop: viewportTop, + viewportHeight: viewport.offsetHeight, + itemCount: this.props.flows.length, + rowHeight: this.props.rowHeight + }); + + if (this.state.viewportTop !== viewportTop || !(0, _shallowequal2.default)(this.state.vScroll, vScroll)) { + this.setState({ vScroll: vScroll, viewportTop: viewportTop }); + } + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _state = this.state; + var vScroll = _state.vScroll; + var viewportTop = _state.viewportTop; + var _props2 = this.props; + var flows = _props2.flows; + var selected = _props2.selected; + var highlight = _props2.highlight; + + var isHighlighted = highlight ? _filt2.default.parse(highlight) : function () { + return false; + }; + + return _react2.default.createElement( + 'div', + { className: 'flow-table', onScroll: this.onViewportUpdate }, + _react2.default.createElement( + 'table', + null, + _react2.default.createElement( + 'thead', + { ref: 'head', style: { transform: 'translateY(' + viewportTop + 'px)' } }, + _react2.default.createElement(_FlowTableHead2.default, null) + ), + _react2.default.createElement( + 'tbody', + null, + _react2.default.createElement('tr', { style: { height: vScroll.paddingTop } }), + flows.slice(vScroll.start, vScroll.end).map(function (flow) { + return _react2.default.createElement(_FlowRow2.default, { + key: flow.id, + flow: flow, + selected: flow === selected, + highlighted: isHighlighted(flow), + onSelect: _this2.props.onSelect + }); + }), + _react2.default.createElement('tr', { style: { height: vScroll.paddingBottom } }) + ) + ) + ); + } + }]); + + return FlowTable; +}(_react2.default.Component); + +FlowTable.propTypes = { + onSelect: _react.PropTypes.func.isRequired, + flows: _react.PropTypes.array.isRequired, + rowHeight: _react.PropTypes.number, + highlight: _react.PropTypes.string, + selected: _react.PropTypes.object +}; +FlowTable.defaultProps = { + rowHeight: 32 +}; +exports.default = (0, _AutoScroll2.default)(FlowTable); + +},{"../filt/filt":40,"./FlowTable/FlowRow":8,"./FlowTable/FlowTableHead":9,"./helpers/AutoScroll":28,"./helpers/VirtualScroll":29,"react":"react","react-dom":"react-dom","shallowequal":"shallowequal"}],7:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.TLSColumn = TLSColumn; +exports.IconColumn = IconColumn; +exports.PathColumn = PathColumn; +exports.MethodColumn = MethodColumn; +exports.StatusColumn = StatusColumn; +exports.SizeColumn = SizeColumn; +exports.TimeColumn = TimeColumn; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _classnames = require('classnames'); + +var _classnames2 = _interopRequireDefault(_classnames); + +var _utils = require('../../flow/utils.js'); + +var _utils2 = require('../../utils.js'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function TLSColumn(_ref) { + var flow = _ref.flow; + + return _react2.default.createElement('td', { className: (0, _classnames2.default)('col-tls', flow.request.scheme === 'https' ? 'col-tls-https' : 'col-tls-http') }); +} + +TLSColumn.sortKeyFun = function (flow) { + return flow.request.scheme; +}; +TLSColumn.headerClass = 'col-tls'; +TLSColumn.headerName = ''; + +function IconColumn(_ref2) { + var flow = _ref2.flow; + + return _react2.default.createElement( + 'td', + { className: 'col-icon' }, + _react2.default.createElement('div', { className: (0, _classnames2.default)('resource-icon', IconColumn.getIcon(flow)) }) + ); +} + +IconColumn.headerClass = 'col-icon'; +IconColumn.headerName = ''; + +IconColumn.getIcon = function (flow) { + if (!flow.response) { + return 'resource-icon-plain'; + } + + var contentType = _utils.ResponseUtils.getContentType(flow.response) || ''; + + // @todo We should assign a type to the flow somewhere else. + if (flow.response.status_code === 304) { + return 'resource-icon-not-modified'; + } + if (300 <= flow.response.status_code && flow.response.status_code < 400) { + return 'resource-icon-redirect'; + } + if (contentType.indexOf('image') >= 0) { + return 'resource-icon-image'; + } + if (contentType.indexOf('javascript') >= 0) { + return 'resource-icon-js'; + } + if (contentType.indexOf('css') >= 0) { + return 'resource-icon-css'; + } + if (contentType.indexOf('html') >= 0) { + return 'resource-icon-document'; + } + + return 'resource-icon-plain'; +}; + +function PathColumn(_ref3) { + var flow = _ref3.flow; + + return _react2.default.createElement( + 'td', + { className: 'col-path' }, + flow.request.is_replay && _react2.default.createElement('i', { className: 'fa fa-fw fa-repeat pull-right' }), + flow.intercepted && _react2.default.createElement('i', { className: 'fa fa-fw fa-pause pull-right' }), + _utils.RequestUtils.pretty_url(flow.request) + ); +} + +PathColumn.sortKeyFun = function (flow) { + return _utils.RequestUtils.pretty_url(flow.request); +}; +PathColumn.headerClass = 'col-path'; +PathColumn.headerName = 'Path'; + +function MethodColumn(_ref4) { + var flow = _ref4.flow; + + return _react2.default.createElement( + 'td', + { className: 'col-method' }, + flow.request.method + ); +} + +MethodColumn.sortKeyFun = function (flow) { + return flow.request.method; +}; +MethodColumn.headerClass = 'col-method'; +MethodColumn.headerName = 'Method'; + +function StatusColumn(_ref5) { + var flow = _ref5.flow; + + return _react2.default.createElement( + 'td', + { className: 'col-status' }, + flow.response && flow.response.status_code + ); +} + +StatusColumn.sortKeyFun = function (flow) { + return flow.response && flow.response.status_code; +}; +StatusColumn.headerClass = 'col-status'; +StatusColumn.headerName = 'Status'; + +function SizeColumn(_ref6) { + var flow = _ref6.flow; + + return _react2.default.createElement( + 'td', + { className: 'col-size' }, + (0, _utils2.formatSize)(SizeColumn.getTotalSize(flow)) + ); +} + +SizeColumn.sortKeyFun = function (flow) { + var total = flow.request.contentLength; + if (flow.response) { + total += flow.response.contentLength || 0; + } + return total; +}; + +SizeColumn.getTotalSize = SizeColumn.sortKeyFun; +SizeColumn.headerClass = 'col-size'; +SizeColumn.headerName = 'Size'; + +function TimeColumn(_ref7) { + var flow = _ref7.flow; + + return _react2.default.createElement( + 'td', + { className: 'col-time' }, + flow.response ? (0, _utils2.formatTimeDelta)(1000 * (flow.response.timestamp_end - flow.request.timestamp_start)) : '...' + ); +} + +TimeColumn.sortKeyFun = function (flow) { + return flow.response && flow.response.timestamp_end - flow.request.timestamp_start; +}; +TimeColumn.headerClass = 'col-time'; +TimeColumn.headerName = 'Time'; + +exports.default = [TLSColumn, IconColumn, PathColumn, MethodColumn, StatusColumn, SizeColumn, TimeColumn]; + +},{"../../flow/utils.js":41,"../../utils.js":43,"classnames":"classnames","react":"react"}],8:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = FlowRow; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _classnames = require('classnames'); + +var _classnames2 = _interopRequireDefault(_classnames); + +var _FlowColumns = require('./FlowColumns'); + +var _FlowColumns2 = _interopRequireDefault(_FlowColumns); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +FlowRow.propTypes = { + onSelect: _react.PropTypes.func.isRequired, + flow: _react.PropTypes.object.isRequired, + highlighted: _react.PropTypes.bool, + selected: _react.PropTypes.bool +}; + +function FlowRow(_ref) { + var flow = _ref.flow; + var selected = _ref.selected; + var highlighted = _ref.highlighted; + var onSelect = _ref.onSelect; + + var className = (0, _classnames2.default)({ + 'selected': selected, + 'highlighted': highlighted, + 'intercepted': flow.intercepted, + 'has-request': flow.request, + 'has-response': flow.response + }); + + return _react2.default.createElement( + 'tr', + { className: className, onClick: function onClick() { + return onSelect(flow); + } }, + _FlowColumns2.default.map(function (Column) { + return _react2.default.createElement(Column, { key: Column.name, flow: flow }); + }) + ); +} },{"./FlowColumns":7,"classnames":"classnames","react":"react"}],9:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function FlowTableHead(e){function r(e){s({sortColumn:e.name,sortDesc:e.name!==t?!1:!o})}var t=e.sortColumn,o=e.sortDesc,s=e.onSort,u=o?"sort-desc":"sort-asc";return _react2["default"].createElement("tr",null,_FlowColumns2["default"].map(function(e){return _react2["default"].createElement("th",{className:(0,_classnames2["default"])(e.headerClass,t===e.name&&u),key:e.name,onClick:function(){return r(e)}},e.headerName)}))}Object.defineProperty(exports,"__esModule",{value:!0});var _react=require("react"),_react2=_interopRequireDefault(_react),_redux=require("redux"),_reactRedux=require("react-redux"),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_FlowColumns=require("./FlowColumns"),_FlowColumns2=_interopRequireDefault(_FlowColumns),_flows=require("../../ducks/flows");FlowTableHead.propTypes={onSort:_react.PropTypes.func.isRequired,sortDesc:_react2["default"].PropTypes.bool.isRequired,sortColumn:_react2["default"].PropTypes.string},exports["default"]=(0,_reactRedux.connect)(function(e){return{sortDesc:e.flows.sort.sortDesc,sortColumn:e.flows.sort.sortColumn}},function(e){return(0,_redux.bindActionCreators)({onSort:_flows.setSort},e)})(FlowTableHead); +'use strict'; -},{"../../ducks/flows":33,"./FlowColumns":7,"classnames":"classnames","react":"react","react-redux":"react-redux","redux":"redux"}],10:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function Footer(e){var a=e.settings;return _react2["default"].createElement("footer",null,a.mode&&"regular"!=a.mode&&_react2["default"].createElement("span",{className:"label label-success"},a.mode," mode"),a.intercept&&_react2["default"].createElement("span",{className:"label label-success"},"Intercept: ",a.intercept),a.showhost&&_react2["default"].createElement("span",{className:"label label-success"},"showhost"),a.no_upstream_cert&&_react2["default"].createElement("span",{className:"label label-success"},"no-upstream-cert"),a.rawtcp&&_react2["default"].createElement("span",{className:"label label-success"},"raw-tcp"),!a.http2&&_react2["default"].createElement("span",{className:"label label-success"},"no-http2"),a.anticache&&_react2["default"].createElement("span",{className:"label label-success"},"anticache"),a.anticomp&&_react2["default"].createElement("span",{className:"label label-success"},"anticomp"),a.stickyauth&&_react2["default"].createElement("span",{className:"label label-success"},"stickyauth: ",a.stickyauth),a.stickycookie&&_react2["default"].createElement("span",{className:"label label-success"},"stickycookie: ",a.stickycookie),a.stream&&_react2["default"].createElement("span",{className:"label label-success"},"stream: ",(0,_utils.formatSize)(a.stream)))}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=Footer;var _react=require("react"),_react2=_interopRequireDefault(_react),_utils=require("../utils.js"),_common=require("./common.js");Footer.propTypes={settings:_react2["default"].PropTypes.object.isRequired}; +Object.defineProperty(exports, "__esModule", { + value: true +}); -},{"../utils.js":41,"./common.js":20,"react":"react"}],11:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var n=0;n0&&(_actions.FlowActions.upload(e.target.files[0]),this.fileInput.value="")}},{key:"onSaveClick",value:function(e){e.preventDefault(),_actions.FlowActions.download()}},{key:"render",value:function(){var e=this;return _react2["default"].createElement("div",{className:(0,_classnames2["default"])("dropdown pull-left",{open:this.state.show})},_react2["default"].createElement("a",{href:"#",className:"special",onClick:this.onFileClick},"mitmproxy"),_react2["default"].createElement("ul",{className:"dropdown-menu",role:"menu"},_react2["default"].createElement("li",null,_react2["default"].createElement("a",{href:"#",onClick:this.onNewClick},_react2["default"].createElement("i",{className:"fa fa-fw fa-file"}),"New")),_react2["default"].createElement("li",null,_react2["default"].createElement("a",{href:"#",onClick:this.onOpenClick},_react2["default"].createElement("i",{className:"fa fa-fw fa-folder-open"}),"Open..."),_react2["default"].createElement("input",{ref:function(t){return e.fileInput=t},className:"hidden",type:"file",onChange:this.onOpenFile})),_react2["default"].createElement("li",null,_react2["default"].createElement("a",{href:"#",onClick:this.onSaveClick},_react2["default"].createElement("i",{className:"fa fa-fw fa-floppy-o"}),"Save...")),_react2["default"].createElement("li",{role:"presentation",className:"divider"}),_react2["default"].createElement("li",null,_react2["default"].createElement("a",{href:"http://mitm.it/",target:"_blank"},_react2["default"].createElement("i",{className:"fa fa-fw fa-external-link"}),"Install Certificates..."))))}}]),t}(_react.Component);exports["default"]=FileMenu; +var _react2 = _interopRequireDefault(_react); + +var _redux = require('redux'); + +var _reactRedux = require('react-redux'); + +var _classnames = require('classnames'); + +var _classnames2 = _interopRequireDefault(_classnames); + +var _FlowColumns = require('./FlowColumns'); + +var _FlowColumns2 = _interopRequireDefault(_FlowColumns); + +var _flows = require('../../ducks/flows'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +FlowTableHead.propTypes = { + onSort: _react.PropTypes.func.isRequired, + sortDesc: _react2.default.PropTypes.bool.isRequired, + sortColumn: _react2.default.PropTypes.string +}; + +function FlowTableHead(_ref) { + var sortColumn = _ref.sortColumn; + var sortDesc = _ref.sortDesc; + var onSort = _ref.onSort; + + var sortType = sortDesc ? 'sort-desc' : 'sort-asc'; + + return _react2.default.createElement( + 'tr', + null, + _FlowColumns2.default.map(function (Column) { + return _react2.default.createElement( + 'th', + { className: (0, _classnames2.default)(Column.headerClass, sortColumn === Column.name && sortType), + key: Column.name, + onClick: function onClick() { + return _onClick(Column); + } }, + Column.headerName + ); + }) + ); + + function _onClick(Column) { + onSort({ sortColumn: Column.name, sortDesc: Column.name !== sortColumn ? false : !sortDesc }); + } +} + +exports.default = (0, _reactRedux.connect)(function (state) { + return { + sortDesc: state.flows.sort.sortDesc, + sortColumn: state.flows.sort.sortColumn + }; +}, function (dispatch) { + return (0, _redux.bindActionCreators)({ + onSort: _flows.setSort + }, dispatch); +})(FlowTableHead); + +},{"../../ducks/flows":34,"./FlowColumns":7,"classnames":"classnames","react":"react","react-redux":"react-redux","redux":"redux"}],10:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Footer; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _utils = require('../utils.js'); + +var _common = require('./common.js'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +Footer.propTypes = { + settings: _react2.default.PropTypes.object.isRequired +}; + +function Footer(_ref) { + var settings = _ref.settings; + + return _react2.default.createElement( + 'footer', + null, + settings.mode && settings.mode != "regular" && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + settings.mode, + ' mode' + ), + settings.intercept && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'Intercept: ', + settings.intercept + ), + settings.showhost && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'showhost' + ), + settings.no_upstream_cert && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'no-upstream-cert' + ), + settings.rawtcp && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'raw-tcp' + ), + !settings.http2 && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'no-http2' + ), + settings.anticache && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'anticache' + ), + settings.anticomp && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'anticomp' + ), + settings.stickyauth && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'stickyauth: ', + settings.stickyauth + ), + settings.stickycookie && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'stickycookie: ', + settings.stickycookie + ), + settings.stream && _react2.default.createElement( + 'span', + { className: 'label label-success' }, + 'stream: ', + (0, _utils.formatSize)(settings.stream) + ) + ); +} + +},{"../utils.js":43,"./common.js":21,"react":"react"}],11:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _reactRedux = require('react-redux'); + +var _redux = require('redux'); + +var _classnames = require('classnames'); + +var _classnames2 = _interopRequireDefault(_classnames); + +var _eventLog = require('../ducks/eventLog'); + +var _MainMenu = require('./Header/MainMenu'); + +var _MainMenu2 = _interopRequireDefault(_MainMenu); + +var _ViewMenu = require('./Header/ViewMenu'); + +var _ViewMenu2 = _interopRequireDefault(_ViewMenu); + +var _OptionMenu = require('./Header/OptionMenu'); + +var _OptionMenu2 = _interopRequireDefault(_OptionMenu); + +var _FileMenu = require('./Header/FileMenu'); + +var _FileMenu2 = _interopRequireDefault(_FileMenu); + +var _FlowMenu = require('./Header/FlowMenu'); + +var _FlowMenu2 = _interopRequireDefault(_FlowMenu); + +var _ui = require('../ducks/ui.js'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Header = function (_Component) { + _inherits(Header, _Component); + + function Header() { + _classCallCheck(this, Header); + + return _possibleConstructorReturn(this, Object.getPrototypeOf(Header).apply(this, arguments)); + } + + _createClass(Header, [{ + key: 'handleClick', + value: function handleClick(active, e) { + e.preventDefault(); + this.props.setActiveMenu(active.title); + // this.props.updateLocation(active.route) + // this.setState({ active }) + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props; + var settings = _props.settings; + var updateLocation = _props.updateLocation; + var query = _props.query; + var selectedFlow = _props.selectedFlow; + var active_menu = _props.active_menu; + + + var entries = [].concat(_toConsumableArray(Header.entries)); + if (selectedFlow) entries.push(_FlowMenu2.default); + + var Active = _.find(entries, function (e) { + return e.title == active_menu; + }); + + return _react2.default.createElement( + 'header', + null, + _react2.default.createElement( + 'nav', + { className: 'nav-tabs nav-tabs-lg' }, + _react2.default.createElement(_FileMenu2.default, null), + entries.map(function (Entry) { + return _react2.default.createElement( + 'a', + { key: Entry.title, + href: '#', + className: (0, _classnames2.default)({ active: Entry === Active }), + onClick: function onClick(e) { + return _this2.handleClick(Entry, e); + } }, + Entry.title + ); + }) + ), + _react2.default.createElement( + 'div', + { className: 'menu' }, + _react2.default.createElement(Active, { + settings: settings, + updateLocation: updateLocation, + query: query + }) + ) + ); + } + }]); + + return Header; +}(_react.Component); + +Header.entries = [_MainMenu2.default, _ViewMenu2.default, _OptionMenu2.default]; +Header.propTypes = { + settings: _react.PropTypes.object.isRequired +}; +exports.default = (0, _reactRedux.connect)(function (state) { + return { + selectedFlow: state.flows.selected[0], + active_menu: state.ui.active_menu + }; +}, function (dispatch) { + return (0, _redux.bindActionCreators)({ + setActiveMenu: _ui.setActiveMenu + }, dispatch); +})(Header); + +},{"../ducks/eventLog":33,"../ducks/ui.js":36,"./Header/FileMenu":12,"./Header/FlowMenu":15,"./Header/MainMenu":16,"./Header/OptionMenu":17,"./Header/ViewMenu":18,"classnames":"classnames","react":"react","react-redux":"react-redux","redux":"redux"}],12:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _classnames = require('classnames'); + +var _classnames2 = _interopRequireDefault(_classnames); + +var _actions = require('../../actions.js'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var FileMenu = function (_Component) { + _inherits(FileMenu, _Component); + + function FileMenu(props, context) { + _classCallCheck(this, FileMenu); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(FileMenu).call(this, props, context)); + + _this.state = { show: false }; + + _this.close = _this.close.bind(_this); + _this.onFileClick = _this.onFileClick.bind(_this); + _this.onNewClick = _this.onNewClick.bind(_this); + _this.onOpenClick = _this.onOpenClick.bind(_this); + _this.onOpenFile = _this.onOpenFile.bind(_this); + _this.onSaveClick = _this.onSaveClick.bind(_this); + return _this; + } + + _createClass(FileMenu, [{ + key: 'close', + value: function close() { + this.setState({ show: false }); + document.removeEventListener('click', this.close); + } + }, { + key: 'onFileClick', + value: function onFileClick(e) { + e.preventDefault(); + + if (this.state.show) { + return; + } + + document.addEventListener('click', this.close); + this.setState({ show: true }); + } + }, { + key: 'onNewClick', + value: function onNewClick(e) { + e.preventDefault(); + if (confirm('Delete all flows?')) { + _actions.FlowActions.clear(); + } + } + }, { + key: 'onOpenClick', + value: function onOpenClick(e) { + e.preventDefault(); + this.fileInput.click(); + } + }, { + key: 'onOpenFile', + value: function onOpenFile(e) { + e.preventDefault(); + if (e.target.files.length > 0) { + _actions.FlowActions.upload(e.target.files[0]); + this.fileInput.value = ''; + } + } + }, { + key: 'onSaveClick', + value: function onSaveClick(e) { + e.preventDefault(); + _actions.FlowActions.download(); + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + return _react2.default.createElement( + 'div', + { className: (0, _classnames2.default)('dropdown pull-left', { open: this.state.show }) }, + _react2.default.createElement( + 'a', + { href: '#', className: 'special', onClick: this.onFileClick }, + 'mitmproxy' + ), + _react2.default.createElement( + 'ul', + { className: 'dropdown-menu', role: 'menu' }, + _react2.default.createElement( + 'li', + null, + _react2.default.createElement( + 'a', + { href: '#', onClick: this.onNewClick }, + _react2.default.createElement('i', { className: 'fa fa-fw fa-file' }), + 'New' + ) + ), + _react2.default.createElement( + 'li', + null, + _react2.default.createElement( + 'a', + { href: '#', onClick: this.onOpenClick }, + _react2.default.createElement('i', { className: 'fa fa-fw fa-folder-open' }), + 'Open...' + ), + _react2.default.createElement('input', { + ref: function ref(_ref) { + return _this2.fileInput = _ref; + }, + className: 'hidden', + type: 'file', + onChange: this.onOpenFile + }) + ), + _react2.default.createElement( + 'li', + null, + _react2.default.createElement( + 'a', + { href: '#', onClick: this.onSaveClick }, + _react2.default.createElement('i', { className: 'fa fa-fw fa-floppy-o' }), + 'Save...' + ) + ), + _react2.default.createElement('li', { role: 'presentation', className: 'divider' }), + _react2.default.createElement( + 'li', + null, + _react2.default.createElement( + 'a', + { href: 'http://mitm.it/', target: '_blank' }, + _react2.default.createElement('i', { className: 'fa fa-fw fa-external-link' }), + 'Install Certificates...' + ) + ) + ) + ); + } + }]); + + return FileMenu; +}(_react.Component); + +exports.default = FileMenu; },{"../../actions.js":2,"classnames":"classnames","react":"react"}],13:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;re&&(o=s.length-1),this.selectFlow(s[o])}},{key:"onMainKeyDown",value:function(e){var t=this.props.selectedFlow;if(!e.ctrlKey){switch(e.keyCode){case _utils.Key.K:case _utils.Key.UP:this.selectFlowRelative(-1);break;case _utils.Key.J:case _utils.Key.DOWN:this.selectFlowRelative(1);break;case _utils.Key.SPACE:case _utils.Key.PAGE_DOWN:this.selectFlowRelative(10);break;case _utils.Key.PAGE_UP:this.selectFlowRelative(-10);break;case _utils.Key.END:this.selectFlowRelative(1e10);break;case _utils.Key.HOME:this.selectFlowRelative(-1e10);break;case _utils.Key.ESC:this.selectFlow(null);break;case _utils.Key.H:case _utils.Key.LEFT:this.refs.flowDetails&&this.refs.flowDetails.nextTab(-1);break;case _utils.Key.L:case _utils.Key.TAB:case _utils.Key.RIGHT:this.refs.flowDetails&&this.refs.flowDetails.nextTab(1);break;case _utils.Key.C:e.shiftKey&&_actions.FlowActions.clear();break;case _utils.Key.D:t&&(e.shiftKey?_actions.FlowActions.duplicate(t):_actions.FlowActions["delete"](t));break;case _utils.Key.A:e.shiftKey?_actions.FlowActions.accept_all():t&&t.intercepted&&_actions.FlowActions.accept(t);break;case _utils.Key.R:!e.shiftKey&&t&&_actions.FlowActions.replay(t);break;case _utils.Key.V:e.shiftKey&&t&&t.modified&&_actions.FlowActions.revert(t);break;case _utils.Key.E:this.refs.flowDetails&&this.refs.flowDetails.promptEdit();break;case _utils.Key.SHIFT:break;default:return void console.debug("keydown",e.keyCode)}e.preventDefault()}}},{key:"render",value:function(){var e=this,t=this.props,s=t.flows,i=t.selectedFlow,l=t.highlight;t.sort;return _react2["default"].createElement("div",{className:"main-view"},_react2["default"].createElement(_FlowTable2["default"],{ref:"flowTable",flows:s,selected:i,highlight:l,onSelect:function(t){return e.selectFlow(t)}}),i&&[_react2["default"].createElement(_common.Splitter,{key:"splitter"}),_react2["default"].createElement(_index2["default"],{key:"flowDetails",ref:"flowDetails",tab:this.props.routeParams.detailTab,query:this.props.query,updateLocation:this.props.updateLocation,flow:i})])}}]),t}(_react.Component);MainView.propTypes={highlight:_react.PropTypes.string,sort:_react.PropTypes.object},exports["default"]=(0,_reactRedux.connect)(function(e){return{flows:e.flows.view,filter:e.flows.filter,sort:e.flows.sort,highlight:e.flows.highlight,selectedFlow:e.flows.all.byId[e.flows.selected[0]]}},function(e){return(0,_redux.bindActionCreators)({selectFlow:_flows.selectFlow,setFilter:_flows.setFilter,setHighlight:_flows.setHighlight},e)},void 0,{withRef:!0})(MainView); +var _react2 = _interopRequireDefault(_react); -},{"../actions.js":2,"../ducks/flows":33,"../utils.js":41,"./FlowTable":6,"./common.js":20,"./flowview/index.js":24,"react":"react","react-redux":"react-redux","redux":"redux"}],19:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r0)e=o.getRangeAt(0);else if(document.caretPositionFromPoint&&t.clientX&&t.clientY){var n=document.caretPositionFromPoint(t.clientX,t.clientY);e=document.createRange(),e.setStart(n.offsetNode,n.offset)}else document.caretRangeFromPoint&&t.clientX&&t.clientY?e=document.caretRangeFromPoint(t.clientX,t.clientY):(e=document.createRange(),e.selectNodeContents(_reactDom2["default"].findDOMNode(this)));this._ignore_events=!0,this.setState({editable:!0},function(){var t=_reactDom2["default"].findDOMNode(this);t.blur(),t.focus(),this._ignore_events=!1})}},stop:function(){_reactDom2["default"].findDOMNode(this).blur(),this.props.onStop&&this.props.onStop()},_stop:function(t){if(!this._ignore_events){console.log("_stop",_.extend({},t)),window.getSelection().removeAllRanges();var e=_reactDom2["default"].findDOMNode(this),o=this.props.nodeToContent(e);this.setState({editable:!1}),this.props.onDone(o),this.props.onBlur&&this.props.onBlur(t)}},reset:function(){_reactDom2["default"].findDOMNode(this).innerHTML=this.props.contentToHtml(this.props.content)},onKeyDown:function(t){switch(t.stopPropagation(),t.keyCode){case _utils.Key.ESC:t.preventDefault(),this.reset(),this.stop();break;case _utils.Key.ENTER:this.props.submitOnEnter&&!t.shiftKey&&(t.preventDefault(),this.stop())}},onInput:function(){var t=_reactDom2["default"].findDOMNode(this),e=this.props.nodeToContent(t);this.props.onInput&&this.props.onInput(e)}}),ValidateEditor=_react2["default"].createClass({displayName:"ValidateEditor",propTypes:{content:_react2["default"].PropTypes.string.isRequired,onDone:_react2["default"].PropTypes.func.isRequired,onInput:_react2["default"].PropTypes.func,isValid:_react2["default"].PropTypes.func,className:_react2["default"].PropTypes.string},getInitialState:function(){return{currentContent:this.props.content}},componentWillReceiveProps:function(){this.setState({currentContent:this.props.content})},onInput:function(t){this.setState({currentContent:t}),this.props.onInput&&this.props.onInput(t)},render:function(){var t=this.props.className||"";return this.props.isValid&&(t+=this.props.isValid(this.state.currentContent)?" has-success":" has-warning"),_react2["default"].createElement(EditorBase,_extends({},this.props,{ref:"editor",className:t,onDone:this.onDone,onInput:this.onInput}))},onDone:function(t){this.props.isValid&&!this.props.isValid(t)&&(this.refs.editor.reset(),t=this.props.content),this.props.onDone(t)}}),ValueEditor=exports.ValueEditor=_react2["default"].createClass({displayName:"ValueEditor",contextTypes:{returnFocus:_react2["default"].PropTypes.func},propTypes:{content:_react2["default"].PropTypes.string.isRequired,onDone:_react2["default"].PropTypes.func.isRequired,inline:_react2["default"].PropTypes.bool},render:function(){var t=this.props.inline?"span":"div";return _react2["default"].createElement(ValidateEditor,_extends({},this.props,{onStop:this.onStop,tag:t}))},focus:function(){_reactDom2["default"].findDOMNode(this).focus()},onStop:function(){this.context.returnFocus()}}); +var _classnames = require('classnames'); -},{"../utils.js":41,"react":"react","react-dom":"react-dom"}],22:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=Object.assign||function(e){for(var t=1;t1048576*t}},render:function(){var e=(0,_utils2.formatSize)(this.props.message.contentLength);return _react2["default"].createElement("div",{className:"alert alert-warning"},_react2["default"].createElement("button",{onClick:this.props.onClick,className:"btn btn-xs btn-warning pull-right"},"Display anyway"),e," content size.")}}),ViewSelector=_react2["default"].createClass({displayName:"ViewSelector",render:function(){for(var e=[],t=0;t0&&(r.preventDefault(),this.refs[e-1+"-value"].focus())},render:function(){var e=this.props.message.headers.map(function(e,t){var r=_react2["default"].createElement(HeaderEditor,{ref:t+"-key",content:e[0],onDone:this.onChange.bind(null,t,0),onRemove:this.onRemove.bind(null,t,0),onTab:this.onTab.bind(null,t,0)}),s=_react2["default"].createElement(HeaderEditor,{ref:t+"-value",content:e[1],onDone:this.onChange.bind(null,t,1),onRemove:this.onRemove.bind(null,t,1),onTab:this.onTab.bind(null,t,1)});return _react2["default"].createElement("tr",{key:t},_react2["default"].createElement("td",{className:"header-name"},r,":"),_react2["default"].createElement("td",{className:"header-value"},s))}.bind(this));return _react2["default"].createElement("table",{className:"header-table"},_react2["default"].createElement("tbody",null,e))}}),HeaderEditor=_react2["default"].createClass({displayName:"HeaderEditor",render:function(){return _react2["default"].createElement(_editor.ValueEditor,_extends({ref:"input"},this.props,{onKeyDown:this.onKeyDown,inline:!0}))},focus:function(){_reactDom2["default"].findDOMNode(this).focus()},onKeyDown:function(e){switch(e.keyCode){case _utils2.Key.BACKSPACE:var t=window.getSelection().getRangeAt(0);0===t.startOffset&&0===t.endOffset&&this.props.onRemove(e);break;case _utils2.Key.TAB:e.shiftKey||this.props.onTab(e)}}}),RequestLine=_react2["default"].createClass({displayName:"RequestLine",render:function(){var e=this.props.flow,t=_utils.RequestUtils.pretty_url(e.request),r=e.request.http_version;return _react2["default"].createElement("div",{className:"first-line request-line"},_react2["default"].createElement(_editor.ValueEditor,{ref:"method",content:e.request.method,onDone:this.onMethodChange,inline:!0})," ",_react2["default"].createElement(_editor.ValueEditor,{ref:"url",content:t,onDone:this.onUrlChange,isValid:this.isValidUrl,inline:!0})," ",_react2["default"].createElement(_editor.ValueEditor,{ref:"httpVersion",content:r,onDone:this.onHttpVersionChange,isValid:_utils.isValidHttpVersion,inline:!0}))},isValidUrl:function(e){var t=(0,_utils.parseUrl)(e);return!!t.host},onMethodChange:function(e){_actions.FlowActions.update(this.props.flow,{request:{method:e}})},onUrlChange:function(e){var t=(0,_utils.parseUrl)(e);t.path=t.path||"",_actions.FlowActions.update(this.props.flow,{request:t})},onHttpVersionChange:function(e){var t=(0,_utils.parseHttpVersion)(e);_actions.FlowActions.update(this.props.flow,{request:{http_version:t}})}}),ResponseLine=_react2["default"].createClass({displayName:"ResponseLine",render:function(){var e=this.props.flow,t=e.response.http_version;return _react2["default"].createElement("div",{className:"first-line response-line"},_react2["default"].createElement(_editor.ValueEditor,{ref:"httpVersion",content:t,onDone:this.onHttpVersionChange,isValid:_utils.isValidHttpVersion,inline:!0})," ",_react2["default"].createElement(_editor.ValueEditor,{ref:"code",content:e.response.status_code+"",onDone:this.onCodeChange,isValid:this.isValidCode,inline:!0})," ",_react2["default"].createElement(_editor.ValueEditor,{ref:"msg",content:e.response.reason,onDone:this.onMsgChange,inline:!0}))},isValidCode:function(e){return/^\d+$/.test(e)},onHttpVersionChange:function(e){var t=(0,_utils.parseHttpVersion)(e);_actions.FlowActions.update(this.props.flow,{response:{http_version:t}})},onMsgChange:function(e){_actions.FlowActions.update(this.props.flow,{response:{msg:e}})},onCodeChange:function(e){e=parseInt(e),_actions.FlowActions.update(this.props.flow,{response:{code:e}})}}),Request=exports.Request=_react2["default"].createClass({displayName:"Request",render:function(){var e=this.props.flow;return _react2["default"].createElement("section",{className:"request"},_react2["default"].createElement(RequestLine,{ref:"requestLine",flow:e}),_react2["default"].createElement(Headers,{ref:"headers",message:e.request,onChange:this.onHeaderChange}),_react2["default"].createElement("hr",null),_react2["default"].createElement(_contentview2["default"],{flow:e,message:e.request}))},edit:function(e){switch(e){case"m":this.refs.requestLine.refs.method.focus();break;case"u":this.refs.requestLine.refs.url.focus();break;case"v":this.refs.requestLine.refs.httpVersion.focus();break;case"h":this.refs.headers.edit();break;default:throw"Unimplemented: "+e}},onHeaderChange:function(e){_actions.FlowActions.update(this.props.flow,{request:{headers:e}})}}),Response=exports.Response=_react2["default"].createClass({displayName:"Response",render:function(){var e=this.props.flow;return _react2["default"].createElement("section",{className:"response"},_react2["default"].createElement(ResponseLine,{ref:"responseLine",flow:e}),_react2["default"].createElement(Headers,{ref:"headers",message:e.response,onChange:this.onHeaderChange}),_react2["default"].createElement("hr",null),_react2["default"].createElement(_contentview2["default"],{flow:e,message:e.response}))},edit:function(e){switch(e){case"c":this.refs.responseLine.refs.status_code.focus();break;case"m":this.refs.responseLine.refs.msg.focus();break;case"v":this.refs.responseLine.refs.httpVersion.focus();break;case"h":this.refs.headers.edit();break;default:throw"Unimplemented: "+e}},onHeaderChange:function(e){_actions.FlowActions.update(this.props.flow,{response:{headers:e}})}}),Error=exports.Error=_react2["default"].createClass({displayName:"Error",render:function(){var e=this.props.flow;return _react2["default"].createElement("section",null,_react2["default"].createElement("div",{className:"alert alert-warning"},e.error.msg,_react2["default"].createElement("div",null,_react2["default"].createElement("small",null,(0,_utils2.formatTimeStamp)(e.error.timestamp)))))}}); +var _filt2 = _interopRequireDefault(_filt); -},{"../../actions.js":2,"../../flow/utils.js":39,"../../utils.js":41,"../editor.js":21,"./contentview.js":22,"lodash":"lodash","react":"react","react-dom":"react-dom"}],26:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(exports,"__esModule",{value:!0});var _react=require("react"),_react2=_interopRequireDefault(_react),_actions=require("../../actions.js"),NavAction=_react2["default"].createClass({displayName:"NavAction",onClick:function(e){e.preventDefault(),this.props.onClick()},render:function(){return _react2["default"].createElement("a",{title:this.props.title,href:"#",className:"nav-action",onClick:this.onClick},_react2["default"].createElement("i",{className:"fa fa-fw "+this.props.icon}))}}),Nav=_react2["default"].createClass({displayName:"Nav",render:function(){var e=this.props.flow,t=this.props.tabs.map(function(e){var t=e.charAt(0).toUpperCase()+e.slice(1),a=this.props.active===e?"active":"",c=function(t){this.props.selectTab(e),t.preventDefault()}.bind(this);return _react2["default"].createElement("a",{key:e,href:"#",className:a,onClick:c},t)}.bind(this)),a=null;e.intercepted&&(a=_react2["default"].createElement(NavAction,{title:"[a]ccept intercepted flow",icon:"fa-play",onClick:_actions.FlowActions.accept.bind(null,e)}));var c=null;return e.modified&&(c=_react2["default"].createElement(NavAction,{title:"revert changes to flow [V]",icon:"fa-history",onClick:_actions.FlowActions.revert.bind(null,e)})),_react2["default"].createElement("nav",{ref:"head",className:"nav-tabs nav-tabs-sm"},t,_react2["default"].createElement(NavAction,{title:"[d]elete flow",icon:"fa-trash",onClick:_actions.FlowActions["delete"].bind(null,e)}),_react2["default"].createElement(NavAction,{title:"[D]uplicate flow",icon:"fa-copy",onClick:_actions.FlowActions.duplicate.bind(null,e)}),_react2["default"].createElement(NavAction,{disabled:!0,title:"[r]eplay flow",icon:"fa-repeat",onClick:_actions.FlowActions.replay.bind(null,e)}),a,c)}});exports["default"]=Nav; +var _FilterDocs = require('./FilterDocs'); -},{"../../actions.js":2,"react":"react"}],27:[function(require,module,exports){ -"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{"default":t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var o=0;oh;h++){var m=i[h]||o;r>=s&&h%2===0&&(d=s,n=h),l>=s?c=h+1:p+=m,s+=m}else n=-2&Math.max(0,Math.floor(r/o)-1),c=Math.min(e,n+Math.ceil(a/o)+2),d=Math.min(n,e)*o,p=Math.max(0,e-c)*o;return{start:n,end:c,paddingTop:d,paddingBottom:p}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.calcVScroll=calcVScroll; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -},{}],29:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(exports,"__esModule",{value:!0});var _react=require("react"),_react2=_interopRequireDefault(_react),_reactDom=require("react-dom"),_reactDom2=_interopRequireDefault(_reactDom),_lodash=require("lodash"),_lodash2=_interopRequireDefault(_lodash),_utils=require("../utils.js"),Prompt=_react2["default"].createClass({displayName:"Prompt",contextTypes:{returnFocus:_react2["default"].PropTypes.func},propTypes:{options:_react2["default"].PropTypes.array.isRequired,done:_react2["default"].PropTypes.func.isRequired,prompt:_react2["default"].PropTypes.string},componentDidMount:function(){_reactDom2["default"].findDOMNode(this).focus()},onKeyDown:function(e){e.stopPropagation(),e.preventDefault();for(var t=this.getOptions(),r=0;r0&&t(n[0]);)n=n.substr(1);o={text:o,key:n[0]}}if(!o.text||!o.key||t(o.key))throw"invalid options";e.push(o)}return e},render:function(){var e=this.getOptions();return e=_lodash2["default"].map(e,function(e){var t,r,o=e.text.indexOf(e.key);-1!==o?(t=e.text.substring(0,o),r=e.text.substring(o+1)):(t=e.text+" (",r=")");var n=function(t){this.done(e.key),t.stopPropagation()}.bind(this);return _react2["default"].createElement("span",{key:e.key,className:"option",onClick:n},t,_react2["default"].createElement("strong",{className:"text-primary"},e.key),r)}.bind(this)),_react2["default"].createElement("div",{tabIndex:"0",onKeyDown:this.onKeyDown,onClick:this.onClick,className:"prompt-dialog"},_react2["default"].createElement("div",{className:"prompt-content"},this.props.prompt||_react2["default"].createElement("strong",null,"Select: "),e))}});exports["default"]=Prompt; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -},{"../utils.js":41,"lodash":"lodash","react":"react","react-dom":"react-dom"}],30:[function(require,module,exports){ -"use strict";function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o["default"]=e,o}function Connection(e,o){"/"===e[0]&&(e=location.origin.replace("http","ws")+e);var n=new WebSocket(e);return n.onopen=function(){o(webSocketActions.connected()),o(flowActions.fetchFlows()).then(function(){console.log("flows are loaded now"),_actions.ConnectionActions.open()}),o(eventLogActions.fetchLogEntries())},n.onmessage=function(e){var n=JSON.parse(e.data);switch(_dispatcher.AppDispatcher.dispatchServerAction(n),n.type){case eventLogActions.UPDATE_LOG:return o(eventLogActions.updateLogEntries(n));case flowActions.UPDATE_FLOWS:return o(flowActions.updateFlows(n));default:console.warn("unknown message",n)}},n.onerror=function(){_actions.ConnectionActions.error(),o(eventLogActions.addLogEntry("WebSocket connection error."))},n.onclose=function(){_actions.ConnectionActions.close(),o(eventLogActions.addLogEntry("WebSocket connection closed.")),o(webSocketActions.disconnected())},n}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=Connection;var _actions=require("./actions.js"),_dispatcher=require("./dispatcher.js"),_websocket=require("./ducks/websocket"),webSocketActions=_interopRequireWildcard(_websocket),_eventLog=require("./ducks/eventLog"),eventLogActions=_interopRequireWildcard(_eventLog),_flows=require("./ducks/flows"),flowActions=_interopRequireWildcard(_flows); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -},{"./actions.js":2,"./dispatcher.js":31,"./ducks/eventLog":32,"./ducks/flows":33,"./ducks/websocket":37}],31:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppDispatcher=void 0;var _flux=require("flux"),_flux2=_interopRequireDefault(_flux),PayloadSources={VIEW:"view",SERVER:"server"},AppDispatcher=exports.AppDispatcher=new _flux2["default"].Dispatcher;AppDispatcher.dispatchViewAction=function(e){e.source=PayloadSources.VIEW,this.dispatch(e)},AppDispatcher.dispatchServerAction=function(e){e.source=PayloadSources.SERVER,this.dispatch(e)}; +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -},{"flux":"flux"}],32:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function reducer(){var e=arguments.length<=0||void 0===arguments[0]?defaultState:arguments[0],t=arguments[1];switch(t.type){case TOGGLE_FILTER:var i=_extends({},e.filter,_defineProperty({},t.filter,!e.filter[t.filter]));return _extends({},e,{filter:i,filteredEvents:(0,_view.updateViewFilter)(e.events,function(e){return i[e.level]})});case TOGGLE_VISIBILITY:return _extends({},e,{visible:!e.visible});case UPDATE_LOG:var r=reduceList(e.events,t);return _extends({},e,{events:r,filteredEvents:(0,_view.updateViewList)(e.filteredEvents,e.events,r,t,function(t){return e.filter[t.level]})});default:return e}}function toggleEventLogFilter(e){return{type:TOGGLE_FILTER,filter:e}}function toggleEventLogVisibility(){return{type:TOGGLE_VISIBILITY}}function addLogEntry(e){var t=arguments.length<=1||void 0===arguments[1]?"web":arguments[1];return addItem({message:e,level:t,id:"log-"+id++})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.fetchLogEntries=exports.updateLogEntries=exports.UPDATE_LOG=void 0;var _extends=Object.assign||function(e){for(var t=1;tn;)u=n+o>>>1,r(e[u])n?-1:n>o?1:0};return t},sortedInsert=function(e,t,r){var n=[].concat(_toConsumableArray(e),[r]);n.indexOf=function(e){return sortedIndexOf(n,e,t)};var o=makeCompareFn(t);return t&&o(e[e.length-1],r)>0&&(console.debug("sorting view..."),n.sort(o)),n},sortedRemove=function(e,t,r){var n=r.id,o=e.filter(function(e){return e.id!==n});return o.indexOf=function(e){return sortedIndexOf(o,e,t)},o}; + _this.state = { value: _this.props.value, focus: false, mousefocus: false }; -},{"./list":35}],37:[function(require,module,exports){ -"use strict";function reducer(){var e=arguments.length<=0||void 0===arguments[0]?defaultState:arguments[0],t=arguments[1];switch(t.type){case CONNECTED:return{connected:!0};case DISCONNECTED:return{connected:!1};default:return e}}function connected(){return{type:CONNECTED}}function disconnected(){return{type:DISCONNECTED}}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=reducer,exports.connected=connected,exports.disconnected=disconnected;var CONNECTED="WEBSOCKET_CONNECTED",DISCONNECTED="WEBSOCKET_DISCONNECTED",defaultState={connected:!1}; + _this.onChange = _this.onChange.bind(_this); + _this.onFocus = _this.onFocus.bind(_this); + _this.onBlur = _this.onBlur.bind(_this); + _this.onKeyDown = _this.onKeyDown.bind(_this); + _this.onMouseEnter = _this.onMouseEnter.bind(_this); + _this.onMouseLeave = _this.onMouseLeave.bind(_this); + return _this; + } -},{}],38:[function(require,module,exports){ -"use strict";module.exports=function(){function e(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function t(e,r,n,i){this.message=e,this.expected=r,this.found=n,this.location=i,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}function r(e){function r(t){var r,n,i=Ot[t];if(i)return i;for(r=t-1;!Ot[r];)r--;for(i=Ot[r],i={line:i.line,column:i.column,seenCR:i.seenCR};t>r;)n=e.charAt(r),"\n"===n?(i.seenCR||i.line++,i.column=1,i.seenCR=!1):"\r"===n||"\u2028"===n||"\u2029"===n?(i.line++,i.column=1,i.seenCR=!0):(i.column++,i.seenCR=!1),r++;return Ot[t]=i,i}function n(e,t){var n=r(e),i=r(t);return{start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}}}function i(e){Pt>Mt||(Mt>Pt&&(Pt=Mt,Qt=[]),Qt.push(e))}function s(e,r,n,i){function s(e){var t=1;for(e.sort(function(e,t){return e.descriptiont.description?1:0});t1?u.slice(0,-1).join(", ")+" or "+u[e.length-1]:u[0],i=t?'"'+r(t)+'"':"end of input","Expected "+n+" but "+i+" found."}return null!==r&&s(r),new t(null!==e?e:u(r,n),r,n,i)}function u(){var e,t,r,n;return Vt++,e=Mt,t=a(),t!==P?(r=l(),r!==P?(n=a(),n!==P?(Nt=e,t=X(r),e=t):(Mt=e,e=P)):(Mt=e,e=P)):(Mt=e,e=P),Vt--,e===P&&(t=P,0===Vt&&i(W)),e}function c(){var t,r;return Vt++,Z.test(e.charAt(Mt))?(t=e.charAt(Mt),Mt++):(t=P,0===Vt&&i($)),Vt--,t===P&&(r=P,0===Vt&&i(Y)),t}function o(){var t,r;return Vt++,te.test(e.charAt(Mt))?(t=e.charAt(Mt),Mt++):(t=P,0===Vt&&i(re)),Vt--,t===P&&(r=P,0===Vt&&i(ee)),t}function a(){var e,t;for(Vt++,e=[],t=c();t!==P;)e.push(t),t=c();return Vt--,e===P&&(t=P,0===Vt&&i(ne)),e}function l(){var t,r,n,s,u,c;return t=Mt,r=p(),r!==P?(n=a(),n!==P?(124===e.charCodeAt(Mt)?(s=ie,Mt++):(s=P,0===Vt&&i(se)),s!==P?(u=a(),u!==P?(c=l(),c!==P?(Nt=t,r=ue(r,c),t=r):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P),t===P&&(t=p()),t}function p(){var t,r,n,s,u,o;if(t=Mt,r=f(),r!==P?(n=a(),n!==P?(38===e.charCodeAt(Mt)?(s=ce,Mt++):(s=P,0===Vt&&i(oe)),s!==P?(u=a(),u!==P?(o=p(),o!==P?(Nt=t,r=ae(r,o),t=r):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P),t===P){if(t=Mt,r=f(),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=p(),s!==P?(Nt=t,r=ae(r,s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;t===P&&(t=f())}return t}function f(){var t,r,n,s;return t=Mt,33===e.charCodeAt(Mt)?(r=le,Mt++):(r=P,0===Vt&&i(pe)),r!==P?(n=a(),n!==P?(s=f(),s!==P?(Nt=t,r=fe(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P),t===P&&(t=h()),t}function h(){var t,r,n,s,u,c;return t=Mt,40===e.charCodeAt(Mt)?(r=he,Mt++):(r=P,0===Vt&&i(de)),r!==P?(n=a(),n!==P?(s=l(),s!==P?(u=a(),u!==P?(41===e.charCodeAt(Mt)?(c=ve,Mt++):(c=P,0===Vt&&i(ye)),c!==P?(Nt=t,r=ge(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P)):(Mt=t,t=P),t===P&&(t=d()),t}function d(){var e;return e=v(),e===P&&(e=g()),e}function v(){var t,r;return t=y(),t===P&&(t=Mt,e.substr(Mt,2)===Ae?(r=Ae,Mt+=2):(r=P,0===Vt&&i(xe)),r!==P&&(Nt=t,r=Re()),t=r,t===P&&(t=Mt,e.substr(Mt,2)===me?(r=me,Mt+=2):(r=P,0===Vt&&i(qe)),r!==P&&(Nt=t,r=Ce()),t=r,t===P&&(t=Mt,e.substr(Mt,2)===we?(r=we,Mt+=2):(r=P,0===Vt&&i(Ee)),r!==P&&(Nt=t,r=be()),t=r,t===P&&(t=Mt,e.substr(Mt,2)===Fe?(r=Fe,Mt+=2):(r=P,0===Vt&&i(Ue)),r!==P&&(Nt=t,r=je()),t=r)))),t}function y(){var t,r;return t=Mt,e.substr(Mt,4)===Te?(r=Te,Mt+=4):(r=P,0===Vt&&i(_e)),r!==P&&(Nt=t,r=Se()),t=r,t===P&&(t=Mt,e.substr(Mt,5)===ke?(r=ke,Mt+=5):(r=P,0===Vt&&i(Be)),r!==P&&(Nt=t,r=Ie()),t=r),t}function g(){var t,r,n,s;if(t=Mt,e.substr(Mt,2)===ze?(r=ze,Mt+=2):(r=P,0===Vt&&i(De)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=A(),s!==P?(Nt=t,r=Ge(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,2)===He?(r=He,Mt+=2):(r=P,0===Vt&&i(Je)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=Ke(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,2)===Le?(r=Le,Mt+=2):(r=P,0===Vt&&i(Me)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=Ne(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,3)===Oe?(r=Oe,Mt+=3):(r=P,0===Vt&&i(Pe)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=Qe(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,3)===Ve?(r=Ve,Mt+=3):(r=P,0===Vt&&i(We)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=Xe(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,2)===Ye?(r=Ye,Mt+=2):(r=P,0===Vt&&i(Ze)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=$e(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,2)===et?(r=et,Mt+=2):(r=P,0===Vt&&i(tt)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=rt(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,3)===nt?(r=nt,Mt+=3):(r=P,0===Vt&&i(it)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=st(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,3)===ut?(r=ut,Mt+=3):(r=P,0===Vt&&i(ct)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=ot(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,e.substr(Mt,2)===at?(r=at,Mt+=2):(r=P,0===Vt&&i(lt)),r!==P){if(n=[],s=c(),s!==P)for(;s!==P;)n.push(s),s=c();else n=P;n!==P?(s=x(),s!==P?(Nt=t,r=pt(s),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;t===P&&(t=Mt,r=x(),r!==P&&(Nt=t,r=pt(r)),t=r)}}}}}}}}}return t}function A(){var t,r,n,s;if(Vt++,t=Mt,ht.test(e.charAt(Mt))?(r=e.charAt(Mt),Mt++):(r=P,0===Vt&&i(dt)),r===P&&(r=null),r!==P){if(n=[],vt.test(e.charAt(Mt))?(s=e.charAt(Mt),Mt++):(s=P,0===Vt&&i(yt)),s!==P)for(;s!==P;)n.push(s),vt.test(e.charAt(Mt))?(s=e.charAt(Mt),Mt++):(s=P,0===Vt&&i(yt));else n=P;n!==P?(ht.test(e.charAt(Mt))?(s=e.charAt(Mt),Mt++):(s=P,0===Vt&&i(dt)),s===P&&(s=null),s!==P?(Nt=t,r=gt(n),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;return Vt--,t===P&&(r=P,0===Vt&&i(ft)),t}function x(){var t,r,n,s;if(Vt++,t=Mt,34===e.charCodeAt(Mt)?(r=xt,Mt++):(r=P,0===Vt&&i(Rt)),r!==P){for(n=[],s=R();s!==P;)n.push(s),s=R();n!==P?(34===e.charCodeAt(Mt)?(s=xt,Mt++):(s=P,0===Vt&&i(Rt)),s!==P?(Nt=t,r=mt(n),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P){if(t=Mt,39===e.charCodeAt(Mt)?(r=qt,Mt++):(r=P,0===Vt&&i(Ct)),r!==P){for(n=[],s=m();s!==P;)n.push(s),s=m();n!==P?(39===e.charCodeAt(Mt)?(s=qt,Mt++):(s=P,0===Vt&&i(Ct)),s!==P?(Nt=t,r=mt(n),t=r):(Mt=t,t=P)):(Mt=t,t=P)}else Mt=t,t=P;if(t===P)if(t=Mt,r=Mt,Vt++,n=o(),Vt--,n===P?r=void 0:(Mt=r,r=P),r!==P){if(n=[],s=q(),s!==P)for(;s!==P;)n.push(s),s=q();else n=P;n!==P?(Nt=t,r=mt(n),t=r):(Mt=t,t=P)}else Mt=t,t=P}return Vt--,t===P&&(r=P,0===Vt&&i(At)),t}function R(){var t,r,n;return t=Mt,r=Mt,Vt++,wt.test(e.charAt(Mt))?(n=e.charAt(Mt),Mt++):(n=P,0===Vt&&i(Et)),Vt--,n===P?r=void 0:(Mt=r,r=P),r!==P?(e.length>Mt?(n=e.charAt(Mt),Mt++):(n=P,0===Vt&&i(bt)),n!==P?(Nt=t,r=Ft(n),t=r):(Mt=t,t=P)):(Mt=t,t=P),t===P&&(t=Mt,92===e.charCodeAt(Mt)?(r=Ut,Mt++):(r=P,0===Vt&&i(jt)),r!==P?(n=C(),n!==P?(Nt=t,r=Ft(n),t=r):(Mt=t,t=P)):(Mt=t,t=P)),t}function m(){var t,r,n;return t=Mt,r=Mt,Vt++,Tt.test(e.charAt(Mt))?(n=e.charAt(Mt),Mt++):(n=P,0===Vt&&i(_t)),Vt--,n===P?r=void 0:(Mt=r,r=P),r!==P?(e.length>Mt?(n=e.charAt(Mt),Mt++):(n=P,0===Vt&&i(bt)),n!==P?(Nt=t,r=Ft(n),t=r):(Mt=t,t=P)):(Mt=t,t=P),t===P&&(t=Mt,92===e.charCodeAt(Mt)?(r=Ut,Mt++):(r=P,0===Vt&&i(jt)),r!==P?(n=C(),n!==P?(Nt=t,r=Ft(n),t=r):(Mt=t,t=P)):(Mt=t,t=P)),t}function q(){var t,r,n;return t=Mt,r=Mt,Vt++,n=c(),Vt--,n===P?r=void 0:(Mt=r,r=P),r!==P?(e.length>Mt?(n=e.charAt(Mt),Mt++):(n=P,0===Vt&&i(bt)),n!==P?(Nt=t,r=Ft(n),t=r):(Mt=t,t=P)):(Mt=t,t=P),t}function C(){var t,r;return St.test(e.charAt(Mt))?(t=e.charAt(Mt),Mt++):(t=P,0===Vt&&i(kt)),t===P&&(t=Mt,110===e.charCodeAt(Mt)?(r=Bt,Mt++):(r=P,0===Vt&&i(It)),r!==P&&(Nt=t,r=zt()),t=r,t===P&&(t=Mt,114===e.charCodeAt(Mt)?(r=Dt,Mt++):(r=P,0===Vt&&i(Gt)),r!==P&&(Nt=t,r=Ht()),t=r,t===P&&(t=Mt,116===e.charCodeAt(Mt)?(r=Jt,Mt++):(r=P,0===Vt&&i(Kt)),r!==P&&(Nt=t,r=Lt()),t=r))),t}function w(e,t){function r(){return e.apply(this,arguments)||t.apply(this,arguments)}return r.desc=e.desc+" or "+t.desc,r}function E(e,t){function r(){return e.apply(this,arguments)&&t.apply(this,arguments)}return r.desc=e.desc+" and "+t.desc,r}function b(e){function t(){return!e.apply(this,arguments)}return t.desc="not "+e.desc,t}function F(e){function t(){return e.apply(this,arguments)}return t.desc="("+e.desc+")",t}function U(e){return!0}function j(e){return!1}function T(e){if(e.response)for(var t=Wt.ResponseUtils.getContentType(e.response),r=Xt.length;r--;)if(Xt[r].test(t))return!0;return!1}function _(e){function t(t){return t.response&&t.response.status_code===e}return t.desc="resp. code is "+e,t}function S(e){function t(t){return t.request&&e.test(t.request.host)}return e=new RegExp(e,"i"),t.desc="domain matches "+e,t}function k(e){return!!e.error}function B(e){function t(t){return t.request&&Wt.RequestUtils.match_header(t.request,e)||t.response&&Wt.ResponseUtils.match_header(t.response,e)}return e=new RegExp(e,"i"),t.desc="header matches "+e,t}function I(e){function t(t){return t.request&&Wt.RequestUtils.match_header(t.request,e)}return e=new RegExp(e,"i"),t.desc="req. header matches "+e,t}function z(e){function t(t){return t.response&&Wt.ResponseUtils.match_header(t.response,e)}return e=new RegExp(e,"i"),t.desc="resp. header matches "+e,t}function D(e){function t(t){return t.request&&e.test(t.request.method)}return e=new RegExp(e,"i"),t.desc="method matches "+e,t}function G(e){return e.request&&!e.response}function H(e){return!!e.response}function J(e){function t(t){return t.request&&e.test(Wt.RequestUtils.getContentType(t.request))||t.response&&e.test(Wt.ResponseUtils.getContentType(t.response))}return e=new RegExp(e,"i"),t.desc="content type matches "+e,t}function K(e){function t(t){return t.request&&e.test(Wt.RequestUtils.getContentType(t.request))}return e=new RegExp(e,"i"),t.desc="req. content type matches "+e,t}function L(e){function t(t){return t.response&&e.test(Wt.ResponseUtils.getContentType(t.response))}return e=new RegExp(e,"i"),t.desc="resp. content type matches "+e,t}function M(e){function t(t){return t.request&&e.test(Wt.RequestUtils.pretty_url(t.request))}return e=new RegExp(e,"i"),t.desc="url matches "+e,t}var N,O=arguments.length>1?arguments[1]:{},P={},Q={start:u},V=u,W={type:"other",description:"filter expression"},X=function(e){return e},Y={type:"other",description:"whitespace"},Z=/^[ \t\n\r]/,$={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},ee={type:"other",description:"control character"},te=/^[|&!()~"]/,re={type:"class",value:'[|&!()~"]',description:'[|&!()~"]'},ne={type:"other",description:"optional whitespace"},ie="|",se={type:"literal",value:"|",description:'"|"'},ue=function(e,t){return w(e,t)},ce="&",oe={type:"literal",value:"&",description:'"&"'},ae=function(e,t){return E(e,t)},le="!",pe={type:"literal",value:"!",description:'"!"'},fe=function(e){return b(e)},he="(",de={type:"literal",value:"(",description:'"("'},ve=")",ye={type:"literal",value:")",description:'")"'},ge=function(e){return F(e)},Ae="~a",xe={type:"literal",value:"~a",description:'"~a"'},Re=function(){return T},me="~e",qe={type:"literal",value:"~e",description:'"~e"'},Ce=function(){return k},we="~q",Ee={type:"literal",value:"~q",description:'"~q"'},be=function(){return G},Fe="~s",Ue={type:"literal",value:"~s",description:'"~s"'},je=function(){return H},Te="true",_e={type:"literal",value:"true",description:'"true"'},Se=function(){return U},ke="false",Be={type:"literal",value:"false",description:'"false"'},Ie=function(){return j},ze="~c",De={type:"literal",value:"~c",description:'"~c"'},Ge=function(e){return _(e)},He="~d",Je={type:"literal",value:"~d",description:'"~d"'},Ke=function(e){return S(e)},Le="~h",Me={type:"literal",value:"~h",description:'"~h"'},Ne=function(e){return B(e)},Oe="~hq",Pe={type:"literal",value:"~hq",description:'"~hq"'},Qe=function(e){return I(e)},Ve="~hs",We={type:"literal",value:"~hs",description:'"~hs"'},Xe=function(e){return z(e)},Ye="~m",Ze={type:"literal",value:"~m",description:'"~m"'},$e=function(e){return D(e)},et="~t",tt={type:"literal",value:"~t",description:'"~t"'},rt=function(e){return J(e)},nt="~tq",it={type:"literal",value:"~tq",description:'"~tq"'},st=function(e){return K(e)},ut="~ts",ct={type:"literal",value:"~ts",description:'"~ts"'},ot=function(e){return L(e)},at="~u",lt={type:"literal",value:"~u",description:'"~u"'},pt=function(e){return M(e)},ft={type:"other",description:"integer"},ht=/^['"]/,dt={type:"class",value:"['\"]",description:"['\"]"},vt=/^[0-9]/,yt={type:"class",value:"[0-9]",description:"[0-9]"},gt=function(e){return parseInt(e.join(""),10)},At={type:"other",description:"string"},xt='"',Rt={type:"literal",value:'"',description:'"\\""'},mt=function(e){return e.join("")},qt="'",Ct={type:"literal",value:"'",description:'"\'"'},wt=/^["\\]/,Et={type:"class",value:'["\\\\]',description:'["\\\\]'},bt={type:"any",description:"any character"},Ft=function(e){return e},Ut="\\",jt={type:"literal",value:"\\",description:'"\\\\"'},Tt=/^['\\]/,_t={type:"class",value:"['\\\\]",description:"['\\\\]"},St=/^['"\\]/,kt={type:"class",value:"['\"\\\\]",description:"['\"\\\\]"},Bt="n",It={type:"literal",value:"n",description:'"n"'},zt=function(){return"\n"},Dt="r",Gt={type:"literal",value:"r",description:'"r"'},Ht=function(){return"\r"},Jt="t",Kt={type:"literal",value:"t",description:'"t"'},Lt=function(){return" "},Mt=0,Nt=0,Ot=[{line:1,column:1,seenCR:!1}],Pt=0,Qt=[],Vt=0;if("startRule"in O){if(!(O.startRule in Q))throw new Error("Can't start parsing from rule \""+O.startRule+'".');V=Q[O.startRule]}var Wt=require("../flow/utils.js");U.desc="true",j.desc="false";var Xt=[new RegExp("text/javascript"),new RegExp("application/x-javascript"),new RegExp("application/javascript"),new RegExp("text/css"),new RegExp("image/.*"),new RegExp("application/x-shockwave-flash")];if(T.desc="is asset",k.desc="has error",G.desc="has no response",H.desc="has response",N=V(),N!==P&&Mt===e.length)return N;throw N!==P&&Mt=i;i++)Key[String.fromCharCode(i)]=i;var formatSize=exports.formatSize=function(e){if(0===e)return"0";for(var r=["b","kb","mb","gb","tb"],t=0;te);t++);var o;return o=e%Math.pow(1024,t)===0?0:1,(e/Math.pow(1024,t)).toFixed(o)+r[t]},formatTimeDelta=exports.formatTimeDelta=function(e){for(var r=e,t=["ms","s","min","h"],o=[1e3,60,60],a=0;Math.abs(r)>=o[a]&&a=0&&"/"===e.url[0]&&(-1===e.url.indexOf("?")?e.url+="?"+xsrf:e.url+="&"+xsrf)}),(0,_jquery2["default"])(document).ajaxError(function(e,r,t,o){if("abort"!==o){var a=r.responseText;console.error(o,a,arguments),alert(a)}}); + return FilterInput; +}(_react.Component); + +FilterInput.contextTypes = { + returnFocus: _react2.default.PropTypes.func +}; +exports.default = FilterInput; + +},{"../../filt/filt":40,"../../utils.js":43,"./FilterDocs":13,"classnames":"classnames","react":"react","react-dom":"react-dom"}],15:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _common = require('../common.js'); + +var _actions = require('../../actions.js'); + +var _utils = require('../../flow/utils.js'); + +var _reactRedux = require('react-redux'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +FlowMenu.title = "Flow"; + +FlowMenu.propTypes = { + flow: _react.PropTypes.object.isRequired +}; + +function FlowMenu(_ref) { + var flow = _ref.flow; + + + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'div', + { className: 'menu-row' }, + _react2.default.createElement(_common.Button, { disabled: true, title: '[r]eplay flow', text: 'Replay', icon: 'fa-repeat', onClick: _actions.FlowActions.replay.bind(null, flow) }), + _react2.default.createElement(_common.Button, { title: '[D]uplicate flow', text: 'Duplicate', icon: 'fa-copy', onClick: _actions.FlowActions.duplicate.bind(null, flow) }), + _react2.default.createElement(_common.Button, { title: '[d]elete flow', text: 'Delete', icon: 'fa-trash', onClick: _actions.FlowActions.delete.bind(null, flow) }), + _react2.default.createElement(_common.Button, { title: 'download', text: 'Download', icon: 'fa-download', onClick: function onClick() { + return window.location = _utils.MessageUtils.getContentURL(flow, flow.response); + } }) + ), + _react2.default.createElement('div', { className: 'clearfix' }) + ); +} + +exports.default = (0, _reactRedux.connect)(function (state) { + return { + flow: state.flows.all.byId[state.flows.selected[0]] + }; +})(FlowMenu); + +},{"../../actions.js":2,"../../flow/utils.js":41,"../common.js":21,"react":"react","react-redux":"react-redux"}],16:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _actions = require('../../actions.js'); + +var _FilterInput = require('./FilterInput'); + +var _FilterInput2 = _interopRequireDefault(_FilterInput); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var MainMenu = function (_Component) { + _inherits(MainMenu, _Component); + + function MainMenu(props, context) { + _classCallCheck(this, MainMenu); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(MainMenu).call(this, props, context)); + + _this.onSearchChange = _this.onSearchChange.bind(_this); + _this.onHighlightChange = _this.onHighlightChange.bind(_this); + _this.onInterceptChange = _this.onInterceptChange.bind(_this); + return _this; + } + + _createClass(MainMenu, [{ + key: 'onSearchChange', + value: function onSearchChange(val) { + this.props.updateLocation(undefined, _defineProperty({}, _actions.Query.SEARCH, val)); + } + }, { + key: 'onHighlightChange', + value: function onHighlightChange(val) { + this.props.updateLocation(undefined, _defineProperty({}, _actions.Query.HIGHLIGHT, val)); + } + }, { + key: 'onInterceptChange', + value: function onInterceptChange(val) { + _actions.SettingsActions.update({ intercept: val }); + } + }, { + key: 'render', + value: function render() { + var _props = this.props; + var query = _props.query; + var settings = _props.settings; + + + var search = query[_actions.Query.SEARCH] || ''; + var highlight = query[_actions.Query.HIGHLIGHT] || ''; + var intercept = settings.intercept || ''; + + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'div', + { className: 'menu-row' }, + _react2.default.createElement(_FilterInput2.default, { + ref: 'search', + placeholder: 'Search', + type: 'search', + color: 'black', + value: search, + onChange: this.onSearchChange + }), + _react2.default.createElement(_FilterInput2.default, { + ref: 'highlight', + placeholder: 'Highlight', + type: 'tag', + color: 'hsl(48, 100%, 50%)', + value: highlight, + onChange: this.onHighlightChange + }), + _react2.default.createElement(_FilterInput2.default, { + ref: 'intercept', + placeholder: 'Intercept', + type: 'pause', + color: 'hsl(208, 56%, 53%)', + value: intercept, + onChange: this.onInterceptChange + }) + ), + _react2.default.createElement('div', { className: 'clearfix' }) + ); + } + }]); + + return MainMenu; +}(_react.Component); + +MainMenu.title = 'Start'; +MainMenu.route = 'flows'; +MainMenu.propTypes = { + settings: _react2.default.PropTypes.object.isRequired +}; +exports.default = MainMenu; + +},{"../../actions.js":2,"./FilterInput":14,"react":"react"}],17:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = OptionMenu; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _common = require('../common.js'); + +var _actions = require('../../actions.js'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +OptionMenu.title = "Options"; + +OptionMenu.propTypes = { + settings: _react.PropTypes.object.isRequired +}; + +function OptionMenu(_ref) { + var settings = _ref.settings; + + // @todo use settings.map + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'div', + { className: 'menu-row' }, + _react2.default.createElement(_common.ToggleButton, { text: 'showhost', + checked: settings.showhost, + onToggle: function onToggle() { + return _actions.SettingsActions.update({ showhost: !settings.showhost }); + } + }), + _react2.default.createElement(_common.ToggleButton, { text: 'no_upstream_cert', + checked: settings.no_upstream_cert, + onToggle: function onToggle() { + return _actions.SettingsActions.update({ no_upstream_cert: !settings.no_upstream_cert }); + } + }), + _react2.default.createElement(_common.ToggleButton, { text: 'rawtcp', + checked: settings.rawtcp, + onToggle: function onToggle() { + return _actions.SettingsActions.update({ rawtcp: !settings.rawtcp }); + } + }), + _react2.default.createElement(_common.ToggleButton, { text: 'http2', + checked: settings.http2, + onToggle: function onToggle() { + return _actions.SettingsActions.update({ http2: !settings.http2 }); + } + }), + _react2.default.createElement(_common.ToggleButton, { text: 'anticache', + checked: settings.anticache, + onToggle: function onToggle() { + return _actions.SettingsActions.update({ anticache: !settings.anticache }); + } + }), + _react2.default.createElement(_common.ToggleButton, { text: 'anticomp', + checked: settings.anticomp, + onToggle: function onToggle() { + return _actions.SettingsActions.update({ anticomp: !settings.anticomp }); + } + }), + _react2.default.createElement(_common.ToggleInputButton, { name: 'stickyauth', placeholder: 'Sticky auth filter', + checked: !!settings.stickyauth, + txt: settings.stickyauth || '', + onToggleChanged: function onToggleChanged(txt) { + return _actions.SettingsActions.update({ stickyauth: !settings.stickyauth ? txt : null }); + } + }), + _react2.default.createElement(_common.ToggleInputButton, { name: 'stickycookie', placeholder: 'Sticky cookie filter', + checked: !!settings.stickycookie, + txt: settings.stickycookie || '', + onToggleChanged: function onToggleChanged(txt) { + return _actions.SettingsActions.update({ stickycookie: !settings.stickycookie ? txt : null }); + } + }), + _react2.default.createElement(_common.ToggleInputButton, { name: 'stream', placeholder: 'stream...', + checked: !!settings.stream, + txt: settings.stream || '', + inputType: 'number', + onToggleChanged: function onToggleChanged(txt) { + return _actions.SettingsActions.update({ stream: !settings.stream ? txt : null }); + } + }) + ), + _react2.default.createElement('div', { className: 'clearfix' }) + ); +} + +},{"../../actions.js":2,"../common.js":21,"react":"react"}],18:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _redux = require('redux'); + +var _reactRedux = require('react-redux'); + +var _common = require('../common.js'); + +var _eventLog = require('../../ducks/eventLog'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +ViewMenu.title = 'View'; +ViewMenu.route = 'flows'; + +ViewMenu.propTypes = { + visible: _react.PropTypes.bool.isRequired, + onToggle: _react.PropTypes.func.isRequired +}; + +function ViewMenu(_ref) { + var visible = _ref.visible; + var onToggle = _ref.onToggle; + + return _react2.default.createElement( + 'div', + null, + _react2.default.createElement( + 'div', + { className: 'menu-row' }, + _react2.default.createElement(_common.ToggleButton, { text: 'Show Event Log', checked: visible, onToggle: onToggle }) + ), + _react2.default.createElement('div', { className: 'clearfix' }) + ); +} + +exports.default = (0, _reactRedux.connect)(function (state) { + return { + visible: state.eventLog.visible + }; +}, function (dispatch) { + return (0, _redux.bindActionCreators)({ + onToggle: _eventLog.toggleEventLogVisibility + }, dispatch); +})(ViewMenu); + +},{"../../ducks/eventLog":33,"../common.js":21,"react":"react","react-redux":"react-redux","redux":"redux"}],19:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _reactRedux = require('react-redux'); + +var _redux = require('redux'); + +var _actions = require('../actions.js'); + +var _utils = require('../utils.js'); + +var _common = require('./common.js'); + +var _FlowTable = require('./FlowTable'); + +var _FlowTable2 = _interopRequireDefault(_FlowTable); + +var _index = require('./flowview/index.js'); + +var _index2 = _interopRequireDefault(_index); + +var _flows = require('../ducks/flows'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var MainView = function (_Component) { + _inherits(MainView, _Component); + + function MainView() { + _classCallCheck(this, MainView); + + return _possibleConstructorReturn(this, Object.getPrototypeOf(MainView).apply(this, arguments)); + } + + _createClass(MainView, [{ + key: 'componentWillReceiveProps', + + + /** + * @todo move to actions + * @todo replace with mapStateToProps + */ + value: function componentWillReceiveProps(nextProps) { + // Update redux store with route changes + if (nextProps.routeParams.flowId !== (nextProps.selectedFlow || {}).id) { + this.props.selectFlow(nextProps.routeParams.flowId); + } + if (nextProps.location.query[_actions.Query.SEARCH] !== nextProps.filter) { + this.props.setFilter(nextProps.location.query[_actions.Query.SEARCH], false); + } + if (nextProps.location.query[_actions.Query.HIGHLIGHT] !== nextProps.highlight) { + this.props.setHighlight(nextProps.location.query[_actions.Query.HIGHLIGHT], false); + } + } + + /** + * @todo move to actions + */ + + }, { + key: 'selectFlow', + value: function selectFlow(flow) { + if (flow) { + this.props.updateLocation('/flows/' + flow.id + '/' + (this.props.routeParams.detailTab || 'request')); + } else { + this.props.updateLocation('/flows'); + } + } + + /** + * @todo move to actions + */ + + }, { + key: 'selectFlowRelative', + value: function selectFlowRelative(shift) { + var _props = this.props; + var flows = _props.flows; + var routeParams = _props.routeParams; + var selectedFlow = _props.selectedFlow; + + var index = 0; + if (!routeParams.flowId) { + if (shift < 0) { + index = flows.length - 1; + } + } else { + index = Math.min(Math.max(0, flows.indexOf(selectedFlow) + shift), flows.length - 1); + } + this.selectFlow(flows[index]); + } + + /** + * @todo move to actions + */ + + }, { + key: 'onMainKeyDown', + value: function onMainKeyDown(e) { + var flow = this.props.selectedFlow; + if (e.ctrlKey) { + return; + } + switch (e.keyCode) { + case _utils.Key.K: + case _utils.Key.UP: + this.selectFlowRelative(-1); + break; + case _utils.Key.J: + case _utils.Key.DOWN: + this.selectFlowRelative(+1); + break; + case _utils.Key.SPACE: + case _utils.Key.PAGE_DOWN: + this.selectFlowRelative(+10); + break; + case _utils.Key.PAGE_UP: + this.selectFlowRelative(-10); + break; + case _utils.Key.END: + this.selectFlowRelative(+1e10); + break; + case _utils.Key.HOME: + this.selectFlowRelative(-1e10); + break; + case _utils.Key.ESC: + this.selectFlow(null); + break; + case _utils.Key.H: + case _utils.Key.LEFT: + if (this.refs.flowDetails) { + this.refs.flowDetails.nextTab(-1); + } + break; + case _utils.Key.L: + case _utils.Key.TAB: + case _utils.Key.RIGHT: + if (this.refs.flowDetails) { + this.refs.flowDetails.nextTab(+1); + } + break; + case _utils.Key.C: + if (e.shiftKey) { + _actions.FlowActions.clear(); + } + break; + case _utils.Key.D: + if (flow) { + if (e.shiftKey) { + _actions.FlowActions.duplicate(flow); + } else { + _actions.FlowActions.delete(flow); + } + } + break; + case _utils.Key.A: + if (e.shiftKey) { + _actions.FlowActions.accept_all(); + } else if (flow && flow.intercepted) { + _actions.FlowActions.accept(flow); + } + break; + case _utils.Key.R: + if (!e.shiftKey && flow) { + _actions.FlowActions.replay(flow); + } + break; + case _utils.Key.V: + if (e.shiftKey && flow && flow.modified) { + _actions.FlowActions.revert(flow); + } + break; + case _utils.Key.E: + if (this.refs.flowDetails) { + this.refs.flowDetails.promptEdit(); + } + break; + case _utils.Key.SHIFT: + break; + default: + console.debug('keydown', e.keyCode); + return; + } + e.preventDefault(); + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _props2 = this.props; + var flows = _props2.flows; + var selectedFlow = _props2.selectedFlow; + var highlight = _props2.highlight; + var sort = _props2.sort; + + return _react2.default.createElement( + 'div', + { className: 'main-view' }, + _react2.default.createElement(_FlowTable2.default, { + ref: 'flowTable', + flows: flows, + selected: selectedFlow, + highlight: highlight, + onSelect: function onSelect(flow) { + return _this2.selectFlow(flow); + } + }), + selectedFlow && [_react2.default.createElement(_common.Splitter, { key: 'splitter' }), _react2.default.createElement(_index2.default, { + key: 'flowDetails', + ref: 'flowDetails', + tab: this.props.routeParams.detailTab, + query: this.props.query, + updateLocation: this.props.updateLocation, + flow: selectedFlow + })] + ); + } + }]); + + return MainView; +}(_react.Component); + +MainView.propTypes = { + highlight: _react.PropTypes.string, + sort: _react.PropTypes.object +}; +exports.default = (0, _reactRedux.connect)(function (state) { + return { + flows: state.flows.view, + filter: state.flows.filter, + sort: state.flows.sort, + highlight: state.flows.highlight, + selectedFlow: state.flows.all.byId[state.flows.selected[0]] + }; +}, function (dispatch) { + return (0, _redux.bindActionCreators)({ + selectFlow: _flows.selectFlow, + setFilter: _flows.setFilter, + setHighlight: _flows.setHighlight + }, dispatch); +}, undefined, { withRef: true })(MainView); + +},{"../actions.js":2,"../ducks/flows":34,"../utils.js":43,"./FlowTable":6,"./common.js":21,"./flowview/index.js":25,"react":"react","react-redux":"react-redux","redux":"redux"}],20:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require("react-dom"); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _reactRedux = require("react-redux"); + +var _common = require("./common.js"); + +var _Header = require("./Header"); + +var _Header2 = _interopRequireDefault(_Header); + +var _EventLog = require("./EventLog"); + +var _EventLog2 = _interopRequireDefault(_EventLog); + +var _Footer = require("./Footer"); + +var _Footer2 = _interopRequireDefault(_Footer); + +var _store = require("../store/store.js"); + +var _utils = require("../utils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var ProxyAppMain = function (_Component) { + _inherits(ProxyAppMain, _Component); + + function ProxyAppMain(props, context) { + _classCallCheck(this, ProxyAppMain); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ProxyAppMain).call(this, props, context)); + + _this.settingsStore = new _store.SettingsStore(); + + // Default Settings before fetch + _lodash2.default.extend(_this.settingsStore.dict, {}); + + _this.state = { settings: _this.settingsStore.dict }; + + _this.focus = _this.focus.bind(_this); + _this.onKeyDown = _this.onKeyDown.bind(_this); + _this.updateLocation = _this.updateLocation.bind(_this); + _this.onSettingsChange = _this.onSettingsChange.bind(_this); + return _this; + } + + /** + * @todo move to actions + */ + + + _createClass(ProxyAppMain, [{ + key: "updateLocation", + value: function updateLocation(pathname, queryUpdate) { + if (pathname === undefined) { + pathname = this.props.location.pathname; + } + var query = this.props.location.query; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = Object.keys(queryUpdate || {})[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var key = _step.value; + + query[key] = queryUpdate[key] || undefined; + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + this.context.router.replace({ pathname: pathname, query: query }); + } + + /** + * @todo pass in with props + */ + + }, { + key: "getQuery", + value: function getQuery() { + // For whatever reason, react-router always returns the same object, which makes comparing + // the current props with nextProps impossible. As a workaround, we just clone the query object. + return _lodash2.default.clone(this.props.location.query); + } + + /** + * @todo remove settings store + * @todo connect websocket here + * @todo listen to window's key events + */ + + }, { + key: "componentDidMount", + value: function componentDidMount() { + this.focus(); + this.settingsStore.addListener("recalculate", this.onSettingsChange); + } + + /** + * @todo remove settings store + * @todo disconnect websocket here + * @todo stop listening to window's key events + */ + + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.settingsStore.removeListener("recalculate", this.onSettingsChange); + } + + /** + * @todo move to actions + */ + + }, { + key: "onSettingsChange", + value: function onSettingsChange() { + this.setState({ settings: this.settingsStore.dict }); + } + + /** + * @todo use props + */ + + }, { + key: "getChildContext", + value: function getChildContext() { + return { + returnFocus: this.focus, + location: this.props.location + }; + } + + /** + * @todo remove it + */ + + }, { + key: "focus", + value: function focus() { + document.activeElement.blur(); + window.getSelection().removeAllRanges(); + _reactDom2.default.findDOMNode(this).focus(); + } + + /** + * @todo move to actions + */ + + }, { + key: "onKeyDown", + value: function onKeyDown(e) { + var _this2 = this; + + var name = null; + + switch (e.keyCode) { + case _utils.Key.I: + name = "intercept"; + break; + case _utils.Key.L: + name = "search"; + break; + case _utils.Key.H: + name = "highlight"; + break; + default: + var main = this.refs.view; + if (this.refs.view.getWrappedInstance) { + main = this.refs.view.getWrappedInstance(); + } + if (main.onMainKeyDown) { + main.onMainKeyDown(e); + } + return; // don't prevent default then + } + + if (name) { + (function () { + var headerComponent = _this2.refs.header; + headerComponent.setState({ active: _Header2.default.entries.MainMenu }, function () { + headerComponent.refs.active.refs[name].select(); + }); + })(); + } + + e.preventDefault(); + } + }, { + key: "render", + value: function render() { + var _props = this.props; + var showEventLog = _props.showEventLog; + var location = _props.location; + var children = _props.children; + var settings = this.state.settings; + + var query = this.getQuery(); + return _react2.default.createElement( + "div", + { id: "container", tabIndex: "0", onKeyDown: this.onKeyDown }, + _react2.default.createElement(_Header2.default, { ref: "header", settings: settings, updateLocation: this.updateLocation, query: query }), + _react2.default.cloneElement(children, { ref: "view", location: location, query: query, updateLocation: this.updateLocation }), + showEventLog && [_react2.default.createElement(_common.Splitter, { key: "splitter", axis: "y" }), _react2.default.createElement(_EventLog2.default, { key: "eventlog" })], + _react2.default.createElement(_Footer2.default, { settings: settings }) + ); + } + }]); + + return ProxyAppMain; +}(_react.Component); + +ProxyAppMain.childContextTypes = { + returnFocus: _react.PropTypes.func.isRequired, + location: _react.PropTypes.object.isRequired +}; +ProxyAppMain.contextTypes = { + router: _react.PropTypes.object.isRequired +}; +exports.default = (0, _reactRedux.connect)(function (state) { + return { + showEventLog: state.eventLog.visible + }; +})(ProxyAppMain); + +},{"../store/store.js":42,"../utils.js":43,"./EventLog":4,"./Footer":10,"./Header":11,"./common.js":21,"lodash":"lodash","react":"react","react-dom":"react-dom","react-redux":"react-redux"}],21:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ToggleInputButton = exports.Button = exports.ToggleButton = exports.Splitter = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require("react-dom"); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _utils = require("../utils.js"); + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Splitter = exports.Splitter = _react2.default.createClass({ + displayName: "Splitter", + + getDefaultProps: function getDefaultProps() { + return { + axis: "x" + }; + }, + getInitialState: function getInitialState() { + return { + applied: false, + startX: false, + startY: false + }; + }, + onMouseDown: function onMouseDown(e) { + this.setState({ + startX: e.pageX, + startY: e.pageY + }); + window.addEventListener("mousemove", this.onMouseMove); + window.addEventListener("mouseup", this.onMouseUp); + // Occasionally, only a dragEnd event is triggered, but no mouseUp. + window.addEventListener("dragend", this.onDragEnd); + }, + onDragEnd: function onDragEnd() { + _reactDom2.default.findDOMNode(this).style.transform = ""; + window.removeEventListener("dragend", this.onDragEnd); + window.removeEventListener("mouseup", this.onMouseUp); + window.removeEventListener("mousemove", this.onMouseMove); + }, + onMouseUp: function onMouseUp(e) { + this.onDragEnd(); + + var node = _reactDom2.default.findDOMNode(this); + var prev = node.previousElementSibling; + var next = node.nextElementSibling; + + var dX = e.pageX - this.state.startX; + var dY = e.pageY - this.state.startY; + var flexBasis; + if (this.props.axis === "x") { + flexBasis = prev.offsetWidth + dX; + } else { + flexBasis = prev.offsetHeight + dY; + } + + prev.style.flex = "0 0 " + Math.max(0, flexBasis) + "px"; + next.style.flex = "1 1 auto"; + + this.setState({ + applied: true + }); + this.onResize(); + }, + onMouseMove: function onMouseMove(e) { + var dX = 0, + dY = 0; + if (this.props.axis === "x") { + dX = e.pageX - this.state.startX; + } else { + dY = e.pageY - this.state.startY; + } + _reactDom2.default.findDOMNode(this).style.transform = "translate(" + dX + "px," + dY + "px)"; + }, + onResize: function onResize() { + // Trigger a global resize event. This notifies components that employ virtual scrolling + // that their viewport may have changed. + window.setTimeout(function () { + window.dispatchEvent(new CustomEvent("resize")); + }, 1); + }, + reset: function reset(willUnmount) { + if (!this.state.applied) { + return; + } + var node = _reactDom2.default.findDOMNode(this); + var prev = node.previousElementSibling; + var next = node.nextElementSibling; + + prev.style.flex = ""; + next.style.flex = ""; + + if (!willUnmount) { + this.setState({ + applied: false + }); + } + this.onResize(); + }, + componentWillUnmount: function componentWillUnmount() { + this.reset(true); + }, + render: function render() { + var className = "splitter"; + if (this.props.axis === "x") { + className += " splitter-x"; + } else { + className += " splitter-y"; + } + return _react2.default.createElement( + "div", + { className: className }, + _react2.default.createElement("div", { onMouseDown: this.onMouseDown, draggable: "true" }) + ); + } +}); + +var ToggleButton = exports.ToggleButton = function ToggleButton(_ref) { + var checked = _ref.checked; + var onToggle = _ref.onToggle; + var text = _ref.text; + return _react2.default.createElement( + "div", + { className: "btn btn-toggle " + (checked ? "btn-primary" : "btn-default"), onClick: onToggle }, + _react2.default.createElement("i", { className: "fa fa-fw " + (checked ? "fa-check-square-o" : "fa-square-o") }), + " ", + text + ); +}; + +ToggleButton.propTypes = { + checked: _react2.default.PropTypes.bool.isRequired, + onToggle: _react2.default.PropTypes.func.isRequired, + text: _react2.default.PropTypes.string.isRequired +}; + +var Button = exports.Button = function Button(_ref2) { + var onClick = _ref2.onClick; + var text = _ref2.text; + var icon = _ref2.icon; + return _react2.default.createElement( + "div", + { className: "btn btn-default", onClick: onClick }, + _react2.default.createElement("i", { className: "fa fa-fw " + icon }), + " ", + text + ); +}; + +Button.propTypes = { + onClick: _react2.default.PropTypes.func.isRequired, + text: _react2.default.PropTypes.string.isRequired +}; + +var ToggleInputButton = exports.ToggleInputButton = function (_React$Component) { + _inherits(ToggleInputButton, _React$Component); + + function ToggleInputButton(props) { + _classCallCheck(this, ToggleInputButton); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ToggleInputButton).call(this, props)); + + _this.state = { txt: props.txt }; + return _this; + } + + _createClass(ToggleInputButton, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react2.default.createElement( + "div", + { className: "input-group toggle-input-btn" }, + _react2.default.createElement( + "span", + { + className: "input-group-btn", + onClick: function onClick() { + return _this2.props.onToggleChanged(_this2.state.txt); + } }, + _react2.default.createElement( + "div", + { className: "btn " + (this.props.checked ? "btn-primary" : "btn-default") }, + _react2.default.createElement("span", { className: "fa " + (this.props.checked ? "fa-check-square-o" : "fa-square-o") }), + " ", + this.props.name + ) + ), + _react2.default.createElement("input", { + className: "form-control", + placeholder: this.props.placeholder, + disabled: this.props.checked, + value: this.state.txt, + type: this.props.inputType, + onChange: function onChange(e) { + return _this2.setState({ txt: e.target.value }); + }, + onKeyDown: function onKeyDown(e) { + if (e.keyCode === _utils.Key.ENTER) _this2.props.onToggleChanged(_this2.state.txt);e.stopPropagation(); + } }) + ); + } + }]); + + return ToggleInputButton; +}(_react2.default.Component); + +ToggleInputButton.propTypes = { + name: _react2.default.PropTypes.string.isRequired, + txt: _react2.default.PropTypes.string.isRequired, + onToggleChanged: _react2.default.PropTypes.func.isRequired +}; + +},{"../utils.js":43,"lodash":"lodash","react":"react","react-dom":"react-dom"}],22:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ValueEditor = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require("react-dom"); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _utils = require("../utils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var contentToHtml = function contentToHtml(content) { + return _.escape(content); +}; +var nodeToContent = function nodeToContent(node) { + return node.textContent; +}; + +/* + Basic Editor Functionality + */ +var EditorBase = _react2.default.createClass({ + displayName: "EditorBase", + + propTypes: { + content: _react2.default.PropTypes.string.isRequired, + onDone: _react2.default.PropTypes.func.isRequired, + contentToHtml: _react2.default.PropTypes.func, + nodeToContent: _react2.default.PropTypes.func, // content === nodeToContent( Node ) + onStop: _react2.default.PropTypes.func, + submitOnEnter: _react2.default.PropTypes.bool, + className: _react2.default.PropTypes.string, + tag: _react2.default.PropTypes.string + }, + getDefaultProps: function getDefaultProps() { + return { + contentToHtml: contentToHtml, + nodeToContent: nodeToContent, + submitOnEnter: true, + className: "", + tag: "div" + }; + }, + getInitialState: function getInitialState() { + return { + editable: false + }; + }, + render: function render() { + var className = "inline-input " + this.props.className; + var html = { __html: this.props.contentToHtml(this.props.content) }; + var Tag = this.props.tag; + return _react2.default.createElement(Tag, _extends({}, this.props, { + tabIndex: "0", + className: className, + contentEditable: this.state.editable || undefined // workaround: use undef instead of false to remove attr + , onFocus: this.onFocus, + onMouseDown: this.onMouseDown, + onClick: this.onClick, + onBlur: this._stop, + onKeyDown: this.onKeyDown, + onInput: this.onInput, + onPaste: this.onPaste, + dangerouslySetInnerHTML: html + })); + }, + onPaste: function onPaste(e) { + e.preventDefault(); + var content = e.clipboardData.getData("text/plain"); + document.execCommand("insertHTML", false, content); + }, + onMouseDown: function onMouseDown(e) { + this._mouseDown = true; + window.addEventListener("mouseup", this.onMouseUp); + this.props.onMouseDown && this.props.onMouseDown(e); + }, + onMouseUp: function onMouseUp() { + if (this._mouseDown) { + this._mouseDown = false; + window.removeEventListener("mouseup", this.onMouseUp); + } + }, + onClick: function onClick(e) { + this.onMouseUp(); + this.onFocus(e); + }, + onFocus: function onFocus(e) { + console.log("onFocus", this._mouseDown, this._ignore_events, this.state.editable); + if (this._mouseDown || this._ignore_events || this.state.editable) { + return; + } + + //contenteditable in FireFox is more or less broken. + // - we need to blur() and then focus(), otherwise the caret is not shown. + // - blur() + focus() == we need to save the caret position before + // Firefox sometimes just doesn't set a caret position => use caretPositionFromPoint + var sel = window.getSelection(); + var range; + if (sel.rangeCount > 0) { + range = sel.getRangeAt(0); + } else if (document.caretPositionFromPoint && e.clientX && e.clientY) { + var pos = document.caretPositionFromPoint(e.clientX, e.clientY); + range = document.createRange(); + range.setStart(pos.offsetNode, pos.offset); + } else if (document.caretRangeFromPoint && e.clientX && e.clientY) { + range = document.caretRangeFromPoint(e.clientX, e.clientY); + } else { + range = document.createRange(); + range.selectNodeContents(_reactDom2.default.findDOMNode(this)); + } + + this._ignore_events = true; + this.setState({ editable: true }, function () { + var node = _reactDom2.default.findDOMNode(this); + node.blur(); + node.focus(); + this._ignore_events = false; + //sel.removeAllRanges(); + //sel.addRange(range); + }); + }, + stop: function stop() { + // a stop would cause a blur as a side-effect. + // but a blur event must trigger a stop as well. + // to fix this, make stop = blur and do the actual stop in the onBlur handler. + _reactDom2.default.findDOMNode(this).blur(); + this.props.onStop && this.props.onStop(); + }, + _stop: function _stop(e) { + if (this._ignore_events) { + return; + } + console.log("_stop", _.extend({}, e)); + window.getSelection().removeAllRanges(); //make sure that selection is cleared on blur + var node = _reactDom2.default.findDOMNode(this); + var content = this.props.nodeToContent(node); + this.setState({ editable: false }); + this.props.onDone(content); + this.props.onBlur && this.props.onBlur(e); + }, + reset: function reset() { + _reactDom2.default.findDOMNode(this).innerHTML = this.props.contentToHtml(this.props.content); + }, + onKeyDown: function onKeyDown(e) { + e.stopPropagation(); + switch (e.keyCode) { + case _utils.Key.ESC: + e.preventDefault(); + this.reset(); + this.stop(); + break; + case _utils.Key.ENTER: + if (this.props.submitOnEnter && !e.shiftKey) { + e.preventDefault(); + this.stop(); + } + break; + default: + break; + } + }, + onInput: function onInput() { + var node = _reactDom2.default.findDOMNode(this); + var content = this.props.nodeToContent(node); + this.props.onInput && this.props.onInput(content); + } +}); + +/* + Add Validation to EditorBase + */ +var ValidateEditor = _react2.default.createClass({ + displayName: "ValidateEditor", + + propTypes: { + content: _react2.default.PropTypes.string.isRequired, + onDone: _react2.default.PropTypes.func.isRequired, + onInput: _react2.default.PropTypes.func, + isValid: _react2.default.PropTypes.func, + className: _react2.default.PropTypes.string + }, + getInitialState: function getInitialState() { + return { + currentContent: this.props.content + }; + }, + componentWillReceiveProps: function componentWillReceiveProps() { + this.setState({ currentContent: this.props.content }); + }, + onInput: function onInput(content) { + this.setState({ currentContent: content }); + this.props.onInput && this.props.onInput(content); + }, + render: function render() { + var className = this.props.className || ""; + if (this.props.isValid) { + if (this.props.isValid(this.state.currentContent)) { + className += " has-success"; + } else { + className += " has-warning"; + } + } + return _react2.default.createElement(EditorBase, _extends({}, this.props, { + ref: "editor", + className: className, + onDone: this.onDone, + onInput: this.onInput + })); + }, + onDone: function onDone(content) { + if (this.props.isValid && !this.props.isValid(content)) { + this.refs.editor.reset(); + content = this.props.content; + } + this.props.onDone(content); + } +}); + +/* + Text Editor with mitmweb-specific convenience features + */ +var ValueEditor = exports.ValueEditor = _react2.default.createClass({ + displayName: "ValueEditor", + + contextTypes: { + returnFocus: _react2.default.PropTypes.func + }, + propTypes: { + content: _react2.default.PropTypes.string.isRequired, + onDone: _react2.default.PropTypes.func.isRequired, + inline: _react2.default.PropTypes.bool + }, + render: function render() { + var tag = this.props.inline ? "span" : "div"; + return _react2.default.createElement(ValidateEditor, _extends({}, this.props, { + onStop: this.onStop, + tag: tag + })); + }, + focus: function focus() { + _reactDom2.default.findDOMNode(this).focus(); + }, + onStop: function onStop() { + this.context.returnFocus(); + } +}); + +},{"../utils.js":43,"react":"react","react-dom":"react-dom"}],23:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _utils = require("../../flow/utils.js"); + +var _utils2 = require("../../utils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var ViewImage = _react2.default.createClass({ + displayName: "ViewImage", + + propTypes: { + flow: _react2.default.PropTypes.object.isRequired, + message: _react2.default.PropTypes.object.isRequired + }, + statics: { + regex: /^image\/(png|jpe?g|gif|vnc.microsoft.icon|x-icon)$/i, + matches: function matches(message) { + return ViewImage.regex.test(_utils.MessageUtils.getContentType(message)); + } + }, + render: function render() { + var url = _utils.MessageUtils.getContentURL(this.props.flow, this.props.message); + return _react2.default.createElement( + "div", + { className: "flowview-image" }, + _react2.default.createElement("img", { src: url, alt: "preview", className: "img-thumbnail" }) + ); + } +}); + +var ContentLoader = _react2.default.createClass({ + displayName: "ContentLoader", + + propTypes: { + flow: _react2.default.PropTypes.object.isRequired, + message: _react2.default.PropTypes.object.isRequired + }, + getInitialState: function getInitialState() { + return { + content: undefined, + request: undefined + }; + }, + requestContent: function requestContent(nextProps) { + if (this.state.request) { + this.state.request.abort(); + } + var request = _utils.MessageUtils.getContent(nextProps.flow, nextProps.message); + this.setState({ + content: undefined, + request: request + }); + request.done(function (data) { + this.setState({ content: data }); + }.bind(this)).fail(function (jqXHR, textStatus, errorThrown) { + if (textStatus === "abort") { + return; + } + this.setState({ content: "AJAX Error: " + textStatus + "\r\n" + errorThrown }); + }.bind(this)).always(function () { + this.setState({ request: undefined }); + }.bind(this)); + }, + componentWillMount: function componentWillMount() { + this.requestContent(this.props); + }, + componentWillReceiveProps: function componentWillReceiveProps(nextProps) { + if (nextProps.message !== this.props.message) { + this.requestContent(nextProps); + } + }, + componentWillUnmount: function componentWillUnmount() { + if (this.state.request) { + this.state.request.abort(); + } + }, + render: function render() { + if (!this.state.content) { + return _react2.default.createElement( + "div", + { className: "text-center" }, + _react2.default.createElement("i", { className: "fa fa-spinner fa-spin" }) + ); + } + return _react2.default.cloneElement(this.props.children, { + content: this.state.content + }); + } +}); + +var ViewRaw = _react2.default.createClass({ + displayName: "ViewRaw", + + propTypes: { + content: _react2.default.PropTypes.string.isRequired + }, + statics: { + textView: true, + matches: function matches(message) { + return true; + } + }, + render: function render() { + return _react2.default.createElement( + "pre", + null, + this.props.content + ); + } +}); + +var ViewJSON = _react2.default.createClass({ + displayName: "ViewJSON", + + propTypes: { + content: _react2.default.PropTypes.string.isRequired + }, + statics: { + textView: true, + regex: /^application\/json$/i, + matches: function matches(message) { + return ViewJSON.regex.test(_utils.MessageUtils.getContentType(message)); + } + }, + render: function render() { + var json = this.props.content; + try { + json = JSON.stringify(JSON.parse(json), null, 2); + } catch (e) { + // @noop + } + return _react2.default.createElement( + "pre", + null, + json + ); + } +}); + +var ViewAuto = _react2.default.createClass({ + displayName: "ViewAuto", + + propTypes: { + message: _react2.default.PropTypes.object.isRequired, + flow: _react2.default.PropTypes.object.isRequired + }, + statics: { + matches: function matches() { + return false; // don't match itself + }, + findView: function findView(message) { + for (var i = 0; i < all.length; i++) { + if (all[i].matches(message)) { + return all[i]; + } + } + return all[all.length - 1]; + } + }, + render: function render() { + var _props = this.props; + var message = _props.message; + var flow = _props.flow; + + var View = ViewAuto.findView(this.props.message); + if (View.textView) { + return _react2.default.createElement( + ContentLoader, + { message: message, flow: flow }, + _react2.default.createElement(View, { content: "" }) + ); + } else { + return _react2.default.createElement(View, { message: message, flow: flow }); + } + } +}); + +var all = [ViewAuto, ViewImage, ViewJSON, ViewRaw]; + +var ContentEmpty = _react2.default.createClass({ + displayName: "ContentEmpty", + + render: function render() { + var message_name = this.props.flow.request === this.props.message ? "request" : "response"; + return _react2.default.createElement( + "div", + { className: "alert alert-info" }, + "No ", + message_name, + " content." + ); + } +}); + +var ContentMissing = _react2.default.createClass({ + displayName: "ContentMissing", + + render: function render() { + var message_name = this.props.flow.request === this.props.message ? "Request" : "Response"; + return _react2.default.createElement( + "div", + { className: "alert alert-info" }, + message_name, + " content missing." + ); + } +}); + +var TooLarge = _react2.default.createClass({ + displayName: "TooLarge", + + statics: { + isTooLarge: function isTooLarge(message) { + var max_mb = ViewImage.matches(message) ? 10 : 0.2; + return message.contentLength > 1024 * 1024 * max_mb; + } + }, + render: function render() { + var size = (0, _utils2.formatSize)(this.props.message.contentLength); + return _react2.default.createElement( + "div", + { className: "alert alert-warning" }, + _react2.default.createElement( + "button", + { onClick: this.props.onClick, className: "btn btn-xs btn-warning pull-right" }, + "Display anyway" + ), + size, + " content size." + ); + } +}); + +var ViewSelector = _react2.default.createClass({ + displayName: "ViewSelector", + + render: function render() { + var views = []; + for (var i = 0; i < all.length; i++) { + var view = all[i]; + var className = "btn btn-default"; + if (view === this.props.active) { + className += " active"; + } + var text; + if (view === ViewAuto) { + text = "auto: " + ViewAuto.findView(this.props.message).displayName.toLowerCase().replace("view", ""); + } else { + text = view.displayName.toLowerCase().replace("view", ""); + } + views.push(_react2.default.createElement( + "button", + { + key: view.displayName, + onClick: this.props.selectView.bind(null, view), + className: className }, + text + )); + } + + return _react2.default.createElement( + "div", + { className: "view-selector btn-group btn-group-xs" }, + views + ); + } +}); + +var ContentView = _react2.default.createClass({ + displayName: "ContentView", + + getInitialState: function getInitialState() { + return { + displayLarge: false, + View: ViewAuto + }; + }, + propTypes: { + // It may seem a bit weird at the first glance: + // Every view takes the flow and the message as props, e.g. + // + flow: _react2.default.PropTypes.object.isRequired, + message: _react2.default.PropTypes.object.isRequired + }, + selectView: function selectView(view) { + this.setState({ + View: view + }); + }, + displayLarge: function displayLarge() { + this.setState({ displayLarge: true }); + }, + componentWillReceiveProps: function componentWillReceiveProps(nextProps) { + if (nextProps.message !== this.props.message) { + this.setState(this.getInitialState()); + } + }, + render: function render() { + var _props2 = this.props; + var flow = _props2.flow; + var message = _props2.message; + + var message = this.props.message; + if (message.contentLength === 0) { + return _react2.default.createElement(ContentEmpty, this.props); + } else if (message.contentLength === null) { + return _react2.default.createElement(ContentMissing, this.props); + } else if (!this.state.displayLarge && TooLarge.isTooLarge(message)) { + return _react2.default.createElement(TooLarge, _extends({}, this.props, { onClick: this.displayLarge })); + } + + var downloadUrl = _utils.MessageUtils.getContentURL(this.props.flow, message); + + return _react2.default.createElement( + "div", + null, + this.state.View.textView ? _react2.default.createElement( + ContentLoader, + { flow: flow, message: message }, + _react2.default.createElement(this.state.View, { content: "" }) + ) : _react2.default.createElement(this.state.View, { flow: flow, message: message }), + _react2.default.createElement( + "div", + { className: "view-options text-center" }, + _react2.default.createElement(ViewSelector, { selectView: this.selectView, active: this.state.View, message: message }), + " ", + _react2.default.createElement( + "a", + { className: "btn btn-default btn-xs", href: downloadUrl }, + _react2.default.createElement("i", { className: "fa fa-download" }) + ) + ) + ); + } +}); + +exports.default = ContentView; + +},{"../../flow/utils.js":41,"../../utils.js":43,"lodash":"lodash","react":"react"}],24:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _utils = require("../../utils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var TimeStamp = _react2.default.createClass({ + displayName: "TimeStamp", + + render: function render() { + + if (!this.props.t) { + //should be return null, but that triggers a React bug. + return _react2.default.createElement("tr", null); + } + + var ts = (0, _utils.formatTimeStamp)(this.props.t); + + var delta; + if (this.props.deltaTo) { + delta = (0, _utils.formatTimeDelta)(1000 * (this.props.t - this.props.deltaTo)); + delta = _react2.default.createElement( + "span", + { className: "text-muted" }, + "(" + delta + ")" + ); + } else { + delta = null; + } + + return _react2.default.createElement( + "tr", + null, + _react2.default.createElement( + "td", + null, + this.props.title + ":" + ), + _react2.default.createElement( + "td", + null, + ts, + " ", + delta + ) + ); + } +}); + +var ConnectionInfo = _react2.default.createClass({ + displayName: "ConnectionInfo", + + + render: function render() { + var conn = this.props.conn; + var address = conn.address.address.join(":"); + + var sni = _react2.default.createElement("tr", { key: "sni" }); //should be null, but that triggers a React bug. + if (conn.sni) { + sni = _react2.default.createElement( + "tr", + { key: "sni" }, + _react2.default.createElement( + "td", + null, + _react2.default.createElement( + "abbr", + { title: "TLS Server Name Indication" }, + "TLS SNI:" + ) + ), + _react2.default.createElement( + "td", + null, + conn.sni + ) + ); + } + return _react2.default.createElement( + "table", + { className: "connection-table" }, + _react2.default.createElement( + "tbody", + null, + _react2.default.createElement( + "tr", + { key: "address" }, + _react2.default.createElement( + "td", + null, + "Address:" + ), + _react2.default.createElement( + "td", + null, + address + ) + ), + sni + ) + ); + } +}); + +var CertificateInfo = _react2.default.createClass({ + displayName: "CertificateInfo", + + render: function render() { + //TODO: We should fetch human-readable certificate representation + // from the server + var flow = this.props.flow; + var client_conn = flow.client_conn; + var server_conn = flow.server_conn; + + var preStyle = { maxHeight: 100 }; + return _react2.default.createElement( + "div", + null, + client_conn.cert ? _react2.default.createElement( + "h4", + null, + "Client Certificate" + ) : null, + client_conn.cert ? _react2.default.createElement( + "pre", + { style: preStyle }, + client_conn.cert + ) : null, + server_conn.cert ? _react2.default.createElement( + "h4", + null, + "Server Certificate" + ) : null, + server_conn.cert ? _react2.default.createElement( + "pre", + { style: preStyle }, + server_conn.cert + ) : null + ); + } +}); + +var Timing = _react2.default.createClass({ + displayName: "Timing", + + render: function render() { + var flow = this.props.flow; + var sc = flow.server_conn; + var cc = flow.client_conn; + var req = flow.request; + var resp = flow.response; + + var timestamps = [{ + title: "Server conn. initiated", + t: sc.timestamp_start, + deltaTo: req.timestamp_start + }, { + title: "Server conn. TCP handshake", + t: sc.timestamp_tcp_setup, + deltaTo: req.timestamp_start + }, { + title: "Server conn. SSL handshake", + t: sc.timestamp_ssl_setup, + deltaTo: req.timestamp_start + }, { + title: "Client conn. established", + t: cc.timestamp_start, + deltaTo: req.timestamp_start + }, { + title: "Client conn. SSL handshake", + t: cc.timestamp_ssl_setup, + deltaTo: req.timestamp_start + }, { + title: "First request byte", + t: req.timestamp_start + }, { + title: "Request complete", + t: req.timestamp_end, + deltaTo: req.timestamp_start + }]; + + if (flow.response) { + timestamps.push({ + title: "First response byte", + t: resp.timestamp_start, + deltaTo: req.timestamp_start + }, { + title: "Response complete", + t: resp.timestamp_end, + deltaTo: req.timestamp_start + }); + } + + //Add unique key for each row. + timestamps.forEach(function (e) { + e.key = e.title; + }); + + timestamps = _lodash2.default.sortBy(timestamps, 't'); + + var rows = timestamps.map(function (e) { + return _react2.default.createElement(TimeStamp, e); + }); + + return _react2.default.createElement( + "div", + null, + _react2.default.createElement( + "h4", + null, + "Timing" + ), + _react2.default.createElement( + "table", + { className: "timing-table" }, + _react2.default.createElement( + "tbody", + null, + rows + ) + ) + ); + } +}); + +var Details = _react2.default.createClass({ + displayName: "Details", + + render: function render() { + var flow = this.props.flow; + var client_conn = flow.client_conn; + var server_conn = flow.server_conn; + return _react2.default.createElement( + "section", + null, + _react2.default.createElement( + "h4", + null, + "Client Connection" + ), + _react2.default.createElement(ConnectionInfo, { conn: client_conn }), + _react2.default.createElement( + "h4", + null, + "Server Connection" + ), + _react2.default.createElement(ConnectionInfo, { conn: server_conn }), + _react2.default.createElement(CertificateInfo, { flow: flow }), + _react2.default.createElement(Timing, { flow: flow }) + ); + } +}); + +exports.default = Details; + +},{"../../utils.js":43,"lodash":"lodash","react":"react"}],25:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _nav = require("./nav.js"); + +var _nav2 = _interopRequireDefault(_nav); + +var _messages = require("./messages.js"); + +var _details = require("./details.js"); + +var _details2 = _interopRequireDefault(_details); + +var _prompt = require("../prompt.js"); + +var _prompt2 = _interopRequireDefault(_prompt); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var allTabs = { + request: _messages.Request, + response: _messages.Response, + error: _messages.Error, + details: _details2.default +}; + +var FlowView = _react2.default.createClass({ + displayName: "FlowView", + + getInitialState: function getInitialState() { + return { + prompt: false + }; + }, + getTabs: function getTabs(flow) { + var tabs = []; + ["request", "response", "error"].forEach(function (e) { + if (flow[e]) { + tabs.push(e); + } + }); + tabs.push("details"); + return tabs; + }, + nextTab: function nextTab(i) { + var tabs = this.getTabs(this.props.flow); + var currentIndex = tabs.indexOf(this.props.tab); + // JS modulo operator doesn't correct negative numbers, make sure that we are positive. + var nextIndex = (currentIndex + i + tabs.length) % tabs.length; + this.selectTab(tabs[nextIndex]); + }, + selectTab: function selectTab(panel) { + this.props.updateLocation("/flows/" + this.props.flow.id + "/" + panel); + }, + promptEdit: function promptEdit() { + var options; + switch (this.props.tab) { + case "request": + options = ["method", "url", { text: "http version", key: "v" }, "header" + /*, "content"*/]; + break; + case "response": + options = [{ text: "http version", key: "v" }, "code", "message", "header" + /*, "content"*/]; + break; + case "details": + return; + default: + throw "Unknown tab for edit: " + this.props.tab; + } + + this.setState({ + prompt: { + done: function (k) { + this.setState({ prompt: false }); + if (k) { + this.refs.tab.edit(k); + } + }.bind(this), + options: options + } + }); + }, + render: function render() { + var flow = this.props.flow; + var tabs = this.getTabs(flow); + var active = this.props.tab; + + if (tabs.indexOf(active) < 0) { + if (active === "response" && flow.error) { + active = "error"; + } else if (active === "error" && flow.response) { + active = "response"; + } else { + active = tabs[0]; + } + } + + var prompt = null; + if (this.state.prompt) { + prompt = _react2.default.createElement(_prompt2.default, this.state.prompt); + } + + var Tab = allTabs[active]; + return _react2.default.createElement( + "div", + { className: "flow-detail", onScroll: this.adjustHead }, + _react2.default.createElement(_nav2.default, { ref: "head", + flow: flow, + tabs: tabs, + active: active, + selectTab: this.selectTab }), + _react2.default.createElement(Tab, { ref: "tab", flow: flow }), + prompt + ); + } +}); + +exports.default = FlowView; + +},{"../prompt.js":30,"./details.js":24,"./messages.js":26,"./nav.js":27,"react":"react"}],26:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Error = exports.Response = exports.Request = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require("react-dom"); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _actions = require("../../actions.js"); + +var _utils = require("../../flow/utils.js"); + +var _utils2 = require("../../utils.js"); + +var _contentview = require("./contentview.js"); + +var _contentview2 = _interopRequireDefault(_contentview); + +var _editor = require("../editor.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Headers = _react2.default.createClass({ + displayName: "Headers", + + propTypes: { + onChange: _react2.default.PropTypes.func.isRequired, + message: _react2.default.PropTypes.object.isRequired + }, + onChange: function onChange(row, col, val) { + var nextHeaders = _lodash2.default.cloneDeep(this.props.message.headers); + nextHeaders[row][col] = val; + if (!nextHeaders[row][0] && !nextHeaders[row][1]) { + // do not delete last row + if (nextHeaders.length === 1) { + nextHeaders[0][0] = "Name"; + nextHeaders[0][1] = "Value"; + } else { + nextHeaders.splice(row, 1); + // manually move selection target if this has been the last row. + if (row === nextHeaders.length) { + this._nextSel = row - 1 + "-value"; + } + } + } + this.props.onChange(nextHeaders); + }, + edit: function edit() { + this.refs["0-key"].focus(); + }, + onTab: function onTab(row, col, e) { + var headers = this.props.message.headers; + if (row === headers.length - 1 && col === 1) { + e.preventDefault(); + + var nextHeaders = _lodash2.default.cloneDeep(this.props.message.headers); + nextHeaders.push(["Name", "Value"]); + this.props.onChange(nextHeaders); + this._nextSel = row + 1 + "-key"; + } + }, + componentDidUpdate: function componentDidUpdate() { + if (this._nextSel && this.refs[this._nextSel]) { + this.refs[this._nextSel].focus(); + this._nextSel = undefined; + } + }, + onRemove: function onRemove(row, col, e) { + if (col === 1) { + e.preventDefault(); + this.refs[row + "-key"].focus(); + } else if (row > 0) { + e.preventDefault(); + this.refs[row - 1 + "-value"].focus(); + } + }, + render: function render() { + + var rows = this.props.message.headers.map(function (header, i) { + + var kEdit = _react2.default.createElement(HeaderEditor, { + ref: i + "-key", + content: header[0], + onDone: this.onChange.bind(null, i, 0), + onRemove: this.onRemove.bind(null, i, 0), + onTab: this.onTab.bind(null, i, 0) }); + var vEdit = _react2.default.createElement(HeaderEditor, { + ref: i + "-value", + content: header[1], + onDone: this.onChange.bind(null, i, 1), + onRemove: this.onRemove.bind(null, i, 1), + onTab: this.onTab.bind(null, i, 1) }); + return _react2.default.createElement( + "tr", + { key: i }, + _react2.default.createElement( + "td", + { className: "header-name" }, + kEdit, + ":" + ), + _react2.default.createElement( + "td", + { className: "header-value" }, + vEdit + ) + ); + }.bind(this)); + return _react2.default.createElement( + "table", + { className: "header-table" }, + _react2.default.createElement( + "tbody", + null, + rows + ) + ); + } +}); + +var HeaderEditor = _react2.default.createClass({ + displayName: "HeaderEditor", + + render: function render() { + return _react2.default.createElement(_editor.ValueEditor, _extends({ ref: "input" }, this.props, { onKeyDown: this.onKeyDown, inline: true })); + }, + focus: function focus() { + _reactDom2.default.findDOMNode(this).focus(); + }, + onKeyDown: function onKeyDown(e) { + switch (e.keyCode) { + case _utils2.Key.BACKSPACE: + var s = window.getSelection().getRangeAt(0); + if (s.startOffset === 0 && s.endOffset === 0) { + this.props.onRemove(e); + } + break; + case _utils2.Key.TAB: + if (!e.shiftKey) { + this.props.onTab(e); + } + break; + } + } +}); + +var RequestLine = _react2.default.createClass({ + displayName: "RequestLine", + + render: function render() { + var flow = this.props.flow; + var url = _utils.RequestUtils.pretty_url(flow.request); + var httpver = flow.request.http_version; + + return _react2.default.createElement( + "div", + { className: "first-line request-line" }, + _react2.default.createElement(_editor.ValueEditor, { + ref: "method", + content: flow.request.method, + onDone: this.onMethodChange, + inline: true }), + " ", + _react2.default.createElement(_editor.ValueEditor, { + ref: "url", + content: url, + onDone: this.onUrlChange, + isValid: this.isValidUrl, + inline: true }), + " ", + _react2.default.createElement(_editor.ValueEditor, { + ref: "httpVersion", + content: httpver, + onDone: this.onHttpVersionChange, + isValid: _utils.isValidHttpVersion, + inline: true }) + ); + }, + isValidUrl: function isValidUrl(url) { + var u = (0, _utils.parseUrl)(url); + return !!u.host; + }, + onMethodChange: function onMethodChange(nextMethod) { + _actions.FlowActions.update(this.props.flow, { request: { method: nextMethod } }); + }, + onUrlChange: function onUrlChange(nextUrl) { + var props = (0, _utils.parseUrl)(nextUrl); + props.path = props.path || ""; + _actions.FlowActions.update(this.props.flow, { request: props }); + }, + onHttpVersionChange: function onHttpVersionChange(nextVer) { + var ver = (0, _utils.parseHttpVersion)(nextVer); + _actions.FlowActions.update(this.props.flow, { request: { http_version: ver } }); + } +}); + +var ResponseLine = _react2.default.createClass({ + displayName: "ResponseLine", + + render: function render() { + var flow = this.props.flow; + var httpver = flow.response.http_version; + return _react2.default.createElement( + "div", + { className: "first-line response-line" }, + _react2.default.createElement(_editor.ValueEditor, { + ref: "httpVersion", + content: httpver, + onDone: this.onHttpVersionChange, + isValid: _utils.isValidHttpVersion, + inline: true }), + " ", + _react2.default.createElement(_editor.ValueEditor, { + ref: "code", + content: flow.response.status_code + "", + onDone: this.onCodeChange, + isValid: this.isValidCode, + inline: true }), + " ", + _react2.default.createElement(_editor.ValueEditor, { + ref: "msg", + content: flow.response.reason, + onDone: this.onMsgChange, + inline: true }) + ); + }, + isValidCode: function isValidCode(code) { + return (/^\d+$/.test(code) + ); + }, + onHttpVersionChange: function onHttpVersionChange(nextVer) { + var ver = (0, _utils.parseHttpVersion)(nextVer); + _actions.FlowActions.update(this.props.flow, { response: { http_version: ver } }); + }, + onMsgChange: function onMsgChange(nextMsg) { + _actions.FlowActions.update(this.props.flow, { response: { msg: nextMsg } }); + }, + onCodeChange: function onCodeChange(nextCode) { + nextCode = parseInt(nextCode); + _actions.FlowActions.update(this.props.flow, { response: { code: nextCode } }); + } +}); + +var Request = exports.Request = _react2.default.createClass({ + displayName: "Request", + + render: function render() { + var flow = this.props.flow; + return _react2.default.createElement( + "section", + { className: "request" }, + _react2.default.createElement(RequestLine, { ref: "requestLine", flow: flow }), + _react2.default.createElement(Headers, { ref: "headers", message: flow.request, onChange: this.onHeaderChange }), + _react2.default.createElement("hr", null), + _react2.default.createElement(_contentview2.default, { flow: flow, message: flow.request }) + ); + }, + edit: function edit(k) { + switch (k) { + case "m": + this.refs.requestLine.refs.method.focus(); + break; + case "u": + this.refs.requestLine.refs.url.focus(); + break; + case "v": + this.refs.requestLine.refs.httpVersion.focus(); + break; + case "h": + this.refs.headers.edit(); + break; + default: + throw "Unimplemented: " + k; + } + }, + onHeaderChange: function onHeaderChange(nextHeaders) { + _actions.FlowActions.update(this.props.flow, { + request: { + headers: nextHeaders + } + }); + } +}); + +var Response = exports.Response = _react2.default.createClass({ + displayName: "Response", + + render: function render() { + var flow = this.props.flow; + return _react2.default.createElement( + "section", + { className: "response" }, + _react2.default.createElement(ResponseLine, { ref: "responseLine", flow: flow }), + _react2.default.createElement(Headers, { ref: "headers", message: flow.response, onChange: this.onHeaderChange }), + _react2.default.createElement("hr", null), + _react2.default.createElement(_contentview2.default, { flow: flow, message: flow.response }) + ); + }, + edit: function edit(k) { + switch (k) { + case "c": + this.refs.responseLine.refs.status_code.focus(); + break; + case "m": + this.refs.responseLine.refs.msg.focus(); + break; + case "v": + this.refs.responseLine.refs.httpVersion.focus(); + break; + case "h": + this.refs.headers.edit(); + break; + default: + throw "Unimplemented: " + k; + } + }, + onHeaderChange: function onHeaderChange(nextHeaders) { + _actions.FlowActions.update(this.props.flow, { + response: { + headers: nextHeaders + } + }); + } +}); + +var Error = exports.Error = _react2.default.createClass({ + displayName: "Error", + + render: function render() { + var flow = this.props.flow; + return _react2.default.createElement( + "section", + null, + _react2.default.createElement( + "div", + { className: "alert alert-warning" }, + flow.error.msg, + _react2.default.createElement( + "div", + null, + _react2.default.createElement( + "small", + null, + (0, _utils2.formatTimeStamp)(flow.error.timestamp) + ) + ) + ) + ); + } +}); + +},{"../../actions.js":2,"../../flow/utils.js":41,"../../utils.js":43,"../editor.js":22,"./contentview.js":23,"lodash":"lodash","react":"react","react-dom":"react-dom"}],27:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _actions = require("../../actions.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var NavAction = _react2.default.createClass({ + displayName: "NavAction", + + onClick: function onClick(e) { + e.preventDefault(); + this.props.onClick(); + }, + render: function render() { + return _react2.default.createElement( + "a", + { title: this.props.title, + href: "#", + className: "nav-action", + onClick: this.onClick }, + _react2.default.createElement("i", { className: "fa fa-fw " + this.props.icon }) + ); + } +}); + +var Nav = _react2.default.createClass({ + displayName: "Nav", + + render: function render() { + var flow = this.props.flow; + + var tabs = this.props.tabs.map(function (e) { + var str = e.charAt(0).toUpperCase() + e.slice(1); + var className = this.props.active === e ? "active" : ""; + var onClick = function (event) { + this.props.selectTab(e); + event.preventDefault(); + }.bind(this); + return _react2.default.createElement( + "a", + { key: e, + href: "#", + className: className, + onClick: onClick }, + str + ); + }.bind(this)); + + var acceptButton = null; + if (flow.intercepted) { + acceptButton = _react2.default.createElement(NavAction, { title: "[a]ccept intercepted flow", icon: "fa-play", onClick: _actions.FlowActions.accept.bind(null, flow) }); + } + var revertButton = null; + if (flow.modified) { + revertButton = _react2.default.createElement(NavAction, { title: "revert changes to flow [V]", icon: "fa-history", onClick: _actions.FlowActions.revert.bind(null, flow) }); + } + + return _react2.default.createElement( + "nav", + { ref: "head", className: "nav-tabs nav-tabs-sm" }, + tabs, + _react2.default.createElement(NavAction, { title: "[d]elete flow", icon: "fa-trash", onClick: _actions.FlowActions.delete.bind(null, flow) }), + _react2.default.createElement(NavAction, { title: "[D]uplicate flow", icon: "fa-copy", onClick: _actions.FlowActions.duplicate.bind(null, flow) }), + _react2.default.createElement(NavAction, { disabled: true, title: "[r]eplay flow", icon: "fa-repeat", onClick: _actions.FlowActions.replay.bind(null, flow) }), + acceptButton, + revertButton + ); + } +}); + +exports.default = Nav; + +},{"../../actions.js":2,"react":"react"}],28:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require("react-dom"); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var symShouldStick = Symbol("shouldStick"); +var isAtBottom = function isAtBottom(v) { + return v.scrollTop + v.clientHeight === v.scrollHeight; +}; + +exports.default = function (Component) { + var _class, _temp; + + return Object.assign((_temp = _class = function (_Component) { + _inherits(AutoScrollWrapper, _Component); + + function AutoScrollWrapper() { + _classCallCheck(this, AutoScrollWrapper); + + return _possibleConstructorReturn(this, Object.getPrototypeOf(AutoScrollWrapper).apply(this, arguments)); + } + + _createClass(AutoScrollWrapper, [{ + key: "componentWillUpdate", + value: function componentWillUpdate() { + var viewport = _reactDom2.default.findDOMNode(this); + this[symShouldStick] = viewport.scrollTop && isAtBottom(viewport); + _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentWillUpdate", this) && _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentWillUpdate", this).call(this); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + var viewport = _reactDom2.default.findDOMNode(this); + if (this[symShouldStick] && !isAtBottom(viewport)) { + viewport.scrollTop = viewport.scrollHeight; + } + _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentDidUpdate", this) && _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentDidUpdate", this).call(this); + } + }]); + + return AutoScrollWrapper; + }(Component), _class.displayName = Component.name, _temp), Component); +}; + +},{"react":"react","react-dom":"react-dom"}],29:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.calcVScroll = calcVScroll; +/** + * Calculate virtual scroll stuffs + * + * @param {?Object} opts Options for calculation + * + * @returns {Object} result + * + * __opts__ should have following properties: + * - {number} itemCount + * - {number} rowHeight + * - {number} viewportTop + * - {number} viewportHeight + * - {Array} [itemHeights] + * + * __result__ have following properties: + * - {number} start + * - {number} end + * - {number} paddingTop + * - {number} paddingBottom + */ +function calcVScroll(opts) { + if (!opts) { + return { start: 0, end: 0, paddingTop: 0, paddingBottom: 0 }; + } + + var itemCount = opts.itemCount; + var rowHeight = opts.rowHeight; + var viewportTop = opts.viewportTop; + var viewportHeight = opts.viewportHeight; + var itemHeights = opts.itemHeights; + + var viewportBottom = viewportTop + viewportHeight; + + var start = 0; + var end = 0; + + var paddingTop = 0; + var paddingBottom = 0; + + if (itemHeights) { + + for (var i = 0, pos = 0; i < itemCount; i++) { + var height = itemHeights[i] || rowHeight; + + if (pos <= viewportTop && i % 2 === 0) { + paddingTop = pos; + start = i; + } + + if (pos <= viewportBottom) { + end = i + 1; + } else { + paddingBottom += height; + } + + pos += height; + } + } else { + + // Make sure that we start at an even row so that CSS `:nth-child(even)` is preserved + start = Math.max(0, Math.floor(viewportTop / rowHeight) - 1) & ~1; + end = Math.min(itemCount, start + Math.ceil(viewportHeight / rowHeight) + 2); + + // When a large trunk of elements is removed from the button, start may be far off the viewport. + // To make this issue less severe, limit the top placeholder to the total number of rows. + paddingTop = Math.min(start, itemCount) * rowHeight; + paddingBottom = Math.max(0, itemCount - end) * rowHeight; + } + + return { start: start, end: end, paddingTop: paddingTop, paddingBottom: paddingBottom }; +} + +},{}],30:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require("react"); + +var _react2 = _interopRequireDefault(_react); + +var _reactDom = require("react-dom"); + +var _reactDom2 = _interopRequireDefault(_reactDom); + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _utils = require("../utils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Prompt = _react2.default.createClass({ + displayName: "Prompt", + + contextTypes: { + returnFocus: _react2.default.PropTypes.func + }, + propTypes: { + options: _react2.default.PropTypes.array.isRequired, + done: _react2.default.PropTypes.func.isRequired, + prompt: _react2.default.PropTypes.string + }, + componentDidMount: function componentDidMount() { + _reactDom2.default.findDOMNode(this).focus(); + }, + onKeyDown: function onKeyDown(e) { + e.stopPropagation(); + e.preventDefault(); + var opts = this.getOptions(); + for (var i = 0; i < opts.length; i++) { + var k = opts[i].key; + if (_utils.Key[k.toUpperCase()] === e.keyCode) { + this.done(k); + return; + } + } + if (e.keyCode === _utils.Key.ESC || e.keyCode === _utils.Key.ENTER) { + this.done(false); + } + }, + onClick: function onClick(e) { + this.done(false); + }, + done: function done(ret) { + this.props.done(ret); + this.context.returnFocus(); + }, + getOptions: function getOptions() { + var opts = []; + + var keyTaken = function keyTaken(k) { + return _lodash2.default.includes(_lodash2.default.map(opts, "key"), k); + }; + + for (var i = 0; i < this.props.options.length; i++) { + var opt = this.props.options[i]; + if (_lodash2.default.isString(opt)) { + var str = opt; + while (str.length > 0 && keyTaken(str[0])) { + str = str.substr(1); + } + opt = { + text: opt, + key: str[0] + }; + } + if (!opt.text || !opt.key || keyTaken(opt.key)) { + throw "invalid options"; + } else { + opts.push(opt); + } + } + return opts; + }, + render: function render() { + var opts = this.getOptions(); + opts = _lodash2.default.map(opts, function (o) { + var prefix, suffix; + var idx = o.text.indexOf(o.key); + if (idx !== -1) { + prefix = o.text.substring(0, idx); + suffix = o.text.substring(idx + 1); + } else { + prefix = o.text + " ("; + suffix = ")"; + } + var onClick = function (e) { + this.done(o.key); + e.stopPropagation(); + }.bind(this); + return _react2.default.createElement( + "span", + { + key: o.key, + className: "option", + onClick: onClick }, + prefix, + _react2.default.createElement( + "strong", + { className: "text-primary" }, + o.key + ), + suffix + ); + }.bind(this)); + return _react2.default.createElement( + "div", + { tabIndex: "0", onKeyDown: this.onKeyDown, onClick: this.onClick, className: "prompt-dialog" }, + _react2.default.createElement( + "div", + { className: "prompt-content" }, + this.props.prompt || _react2.default.createElement( + "strong", + null, + "Select: " + ), + opts + ) + ); + } +}); + +exports.default = Prompt; + +},{"../utils.js":43,"lodash":"lodash","react":"react","react-dom":"react-dom"}],31:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Connection; + +var _actions = require("./actions.js"); + +var _dispatcher = require("./dispatcher.js"); + +var _websocket = require("./ducks/websocket"); + +var webSocketActions = _interopRequireWildcard(_websocket); + +var _eventLog = require("./ducks/eventLog"); + +var eventLogActions = _interopRequireWildcard(_eventLog); + +var _flows = require("./ducks/flows"); + +var flowActions = _interopRequireWildcard(_flows); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function Connection(url, dispatch) { + if (url[0] === "/") { + url = location.origin.replace("http", "ws") + url; + } + + var ws = new WebSocket(url); + ws.onopen = function () { + dispatch(webSocketActions.connected()); + dispatch(flowActions.fetchFlows()) + // workaround to make sure that our state is already available. + .then(function () { + console.log("flows are loaded now"); + _actions.ConnectionActions.open(); + }); + dispatch(eventLogActions.fetchLogEntries()); + }; + ws.onmessage = function (m) { + var message = JSON.parse(m.data); + _dispatcher.AppDispatcher.dispatchServerAction(message); + switch (message.type) { + case eventLogActions.UPDATE_LOG: + return dispatch(eventLogActions.updateLogEntries(message)); + case flowActions.UPDATE_FLOWS: + return dispatch(flowActions.updateFlows(message)); + default: + console.warn("unknown message", message); + } + }; + ws.onerror = function () { + _actions.ConnectionActions.error(); + dispatch(eventLogActions.addLogEntry("WebSocket connection error.")); + }; + ws.onclose = function () { + _actions.ConnectionActions.close(); + dispatch(eventLogActions.addLogEntry("WebSocket connection closed.")); + dispatch(webSocketActions.disconnected()); + }; + return ws; +} + +},{"./actions.js":2,"./dispatcher.js":32,"./ducks/eventLog":33,"./ducks/flows":34,"./ducks/websocket":39}],32:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.AppDispatcher = undefined; + +var _flux = require("flux"); + +var _flux2 = _interopRequireDefault(_flux); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var PayloadSources = { + VIEW: "view", + SERVER: "server" +}; + +var AppDispatcher = exports.AppDispatcher = new _flux2.default.Dispatcher(); +AppDispatcher.dispatchViewAction = function (action) { + action.source = PayloadSources.VIEW; + this.dispatch(action); +}; +AppDispatcher.dispatchServerAction = function (action) { + action.source = PayloadSources.SERVER; + this.dispatch(action); +}; + +},{"flux":"flux"}],33:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.fetchLogEntries = exports.updateLogEntries = exports.UPDATE_LOG = undefined; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.default = reducer; +exports.toggleEventLogFilter = toggleEventLogFilter; +exports.toggleEventLogVisibility = toggleEventLogVisibility; +exports.addLogEntry = addLogEntry; + +var _list = require("./utils/list"); + +var _list2 = _interopRequireDefault(_list); + +var _view = require("./utils/view"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var TOGGLE_FILTER = 'TOGGLE_EVENTLOG_FILTER'; +var TOGGLE_VISIBILITY = 'TOGGLE_EVENTLOG_VISIBILITY'; +var UPDATE_LOG = exports.UPDATE_LOG = "UPDATE_EVENTLOG"; + +var _makeList = (0, _list2.default)(UPDATE_LOG, "/events"); + +var reduceList = _makeList.reduceList; +var updateList = _makeList.updateList; +var fetchList = _makeList.fetchList; +var addItem = _makeList.addItem; + + +var defaultState = { + visible: false, + filter: { + "debug": false, + "info": true, + "web": true + }, + events: reduceList(), + filteredEvents: [] +}; + +function reducer() { + var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0]; + var action = arguments[1]; + + var _ret = function () { + switch (action.type) { + case TOGGLE_FILTER: + var filter = _extends({}, state.filter, _defineProperty({}, action.filter, !state.filter[action.filter])); + return { + v: _extends({}, state, { + filter: filter, + filteredEvents: (0, _view.updateViewFilter)(state.events, function (x) { + return filter[x.level]; + }) + }) + }; + case TOGGLE_VISIBILITY: + return { + v: _extends({}, state, { + visible: !state.visible + }) + }; + case UPDATE_LOG: + var events = reduceList(state.events, action); + return { + v: _extends({}, state, { + events: events, + filteredEvents: (0, _view.updateViewList)(state.filteredEvents, state.events, events, action, function (x) { + return state.filter[x.level]; + }) + }) + }; + default: + return { + v: state + }; + } + }(); + + if ((typeof _ret === "undefined" ? "undefined" : _typeof(_ret)) === "object") return _ret.v; +} + +function toggleEventLogFilter(filter) { + return { type: TOGGLE_FILTER, filter: filter }; +} +function toggleEventLogVisibility() { + return { type: TOGGLE_VISIBILITY }; +} +var id = 0; +function addLogEntry(message) { + var level = arguments.length <= 1 || arguments[1] === undefined ? "web" : arguments[1]; + + return addItem({ + message: message, + level: level, + id: "log-" + id++ + }); +} +exports.updateLogEntries = updateList; +exports.fetchLogEntries = fetchList; + +},{"./utils/list":37,"./utils/view":38}],34:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.fetchFlows = exports.updateFlows = exports.SELECT_FLOW = exports.SET_SORT = exports.SET_HIGHLIGHT = exports.SET_FILTER = exports.UPDATE_FLOWS = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.default = reducer; +exports.setFilter = setFilter; +exports.setHighlight = setHighlight; +exports.setSort = setSort; +exports.selectFlow = selectFlow; + +var _list = require("./utils/list"); + +var _list2 = _interopRequireDefault(_list); + +var _filt = require("../filt/filt"); + +var _filt2 = _interopRequireDefault(_filt); + +var _view = require("./utils/view"); + +var _utils = require("../utils.js"); + +var _FlowColumns = require("../components/FlowTable/FlowColumns"); + +var columns = _interopRequireWildcard(_FlowColumns); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var UPDATE_FLOWS = exports.UPDATE_FLOWS = "UPDATE_FLOWS"; +var SET_FILTER = exports.SET_FILTER = "SET_FLOW_FILTER"; +var SET_HIGHLIGHT = exports.SET_HIGHLIGHT = "SET_FLOW_HIGHLIGHT"; +var SET_SORT = exports.SET_SORT = "SET_FLOW_SORT"; +var SELECT_FLOW = exports.SELECT_FLOW = "SELECT_FLOW"; + +var _makeList = (0, _list2.default)(UPDATE_FLOWS, "/flows"); + +var reduceList = _makeList.reduceList; +var updateList = _makeList.updateList; +var fetchList = _makeList.fetchList; + + +var defaultState = { + all: reduceList(), + selected: [], + view: [], + filter: undefined, + highlight: undefined, + sort: { sortColumn: undefined, sortDesc: false } +}; + +function makeFilterFn(filter) { + return filter ? _filt2.default.parse(filter) : function () { + return true; + }; +} + +function makeSortFn(sort) { + var column = columns[sort.sortColumn]; + if (!column) return; + + var sortKeyFun = column.sortKeyFun; + if (sort.sortDesc) { + sortKeyFun = sortKeyFun && function (flow) { + var k = column.sortKeyFun(flow); + return _.isString(k) ? (0, _utils.reverseString)("" + k) : -k; + }; + } + return sortKeyFun; +} + +function reducer() { + var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0]; + var action = arguments[1]; + + switch (action.type) { + case UPDATE_FLOWS: + var all = reduceList(state.all, action); + return _extends({}, state, { + all: all, + view: (0, _view.updateViewList)(state.view, state.all, all, action, makeFilterFn(action.filter), makeSortFn(state.sort)) + }); + case SET_FILTER: + return _extends({}, state, { + filter: action.filter, + view: (0, _view.updateViewFilter)(state.all, makeFilterFn(action.filter), makeSortFn(state.sort)) + }); + case SET_HIGHLIGHT: + return _extends({}, state, { + highlight: action.highlight + }); + case SET_SORT: + return _extends({}, state, { + sort: action.sort, + view: (0, _view.updateViewSort)(state.view, makeSortFn(action.sort)) + }); + case SELECT_FLOW: + return _extends({}, state, { + selected: [action.flowId] + }); + default: + return state; + } +} + +function setFilter(filter) { + return { + type: SET_FILTER, + filter: filter + }; +} +function setHighlight(highlight) { + return { + type: SET_HIGHLIGHT, + highlight: highlight + }; +} +function setSort(sort) { + return { + type: SET_SORT, + sort: sort + }; +} +function selectFlow(flowId) { + return function (dispatch, getState) { + dispatch({ + type: SELECT_FLOW, + currentSelection: getState().flows.selected[0], + flowId: flowId + }); + }; +} + +exports.updateFlows = updateList; +exports.fetchFlows = fetchList; + +},{"../components/FlowTable/FlowColumns":7,"../filt/filt":40,"../utils.js":43,"./utils/list":37,"./utils/view":38}],35:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _redux = require('redux'); + +var _eventLog = require('./eventLog'); + +var _eventLog2 = _interopRequireDefault(_eventLog); + +var _websocket = require('./websocket'); + +var _websocket2 = _interopRequireDefault(_websocket); + +var _flows = require('./flows'); + +var _flows2 = _interopRequireDefault(_flows); + +var _ui = require('./ui.js'); + +var _ui2 = _interopRequireDefault(_ui); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var rootReducer = (0, _redux.combineReducers)({ + eventLog: _eventLog2.default, + websocket: _websocket2.default, + flows: _flows2.default, + ui: _ui2.default +}); + +exports.default = rootReducer; + +},{"./eventLog":33,"./flows":34,"./ui.js":36,"./websocket":39,"redux":"redux"}],36:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.default = reducer; +exports.setActiveMenu = setActiveMenu; + +var _reduxThunk = require('redux-thunk'); + +var _reduxThunk2 = _interopRequireDefault(_reduxThunk); + +var _flows = require('./flows'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var ACTIVE_MENU = 'SET_ACTIVE_MENU'; + +var defaultState = { + active_menu: 'Start' +}; +function reducer() { + var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0]; + var action = arguments[1]; + + switch (action.type) { + case ACTIVE_MENU: + return _extends({}, state, { + active_menu: action.active_menu + }); + case _flows.SELECT_FLOW: + var isNewSelection = action.flowId && !action.currentSelection; + if (isNewSelection) { + var wasFlowSelected = state.active_menu == 'Flow'; + return _extends({}, state, { + active_menu: action.flowId ? 'Flow' : wasFlowSelected ? 'Start' : state.active_menu + }); + } + return state; + default: + return state; + } +} + +function setActiveMenu(active_menu) { + return { + type: ACTIVE_MENU, + active_menu: active_menu + }; +} + +},{"./flows":34,"redux-thunk":"redux-thunk"}],37:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.RECEIVE_LIST = exports.REQUEST_LIST = exports.REMOVE = exports.UPDATE = exports.ADD = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.default = makeList; + +var _utils = require("../../utils"); + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var ADD = exports.ADD = "ADD"; +var UPDATE = exports.UPDATE = "UPDATE"; +var REMOVE = exports.REMOVE = "REMOVE"; +var REQUEST_LIST = exports.REQUEST_LIST = "REQUEST_LIST"; +var RECEIVE_LIST = exports.RECEIVE_LIST = "RECEIVE_LIST"; + +var defaultState = { + list: [], + isFetching: false, + actionsDuringFetch: [], + byId: {}, + indexOf: {} +}; + +function makeList(actionType, fetchURL) { + function reduceList() { + var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0]; + var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + + if (action.type !== actionType) { + return state; + } + + // Handle cases where we finished fetching or are still fetching. + if (action.cmd === RECEIVE_LIST) { + var s = { + isFetching: false, + actionsDuringFetch: [], + list: action.list, + byId: {}, + indexOf: {} + }; + for (var i = 0; i < action.list.length; i++) { + var item = action.list[i]; + s.byId[item.id] = item; + s.indexOf[item.id] = i; + } + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = state.actionsDuringFetch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + action = _step.value; + + s = reduceList(s, action); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return s; + } else if (state.isFetching) { + return _extends({}, state, { + actionsDuringFetch: [].concat(_toConsumableArray(state.actionsDuringFetch), [action]) + }); + } + + var list = void 0, + itemIndex = void 0; + switch (action.cmd) { + case ADD: + return { + list: [].concat(_toConsumableArray(state.list), [action.item]), + byId: _extends({}, state.byId, _defineProperty({}, action.item.id, action.item)), + indexOf: _extends({}, state.indexOf, _defineProperty({}, action.item.id, state.list.length)) + }; + + case UPDATE: + + list = [].concat(_toConsumableArray(state.list)); + itemIndex = state.indexOf[action.item.id]; + list[itemIndex] = action.item; + return _extends({}, state, { + list: list, + byId: _extends({}, state.byId, _defineProperty({}, action.item.id, action.item)) + }); + + case REMOVE: + list = [].concat(_toConsumableArray(state.list)); + itemIndex = state.indexOf[action.item.id]; + list.splice(itemIndex, 1); + return _extends({}, state, { + list: list, + byId: _extends({}, state.byId, _defineProperty({}, action.item.id, undefined)), + indexOf: _extends({}, state.indexOf, _defineProperty({}, action.item.id, undefined)) + }); + + case REQUEST_LIST: + return _extends({}, state, { + isFetching: true + }); + + default: + console.debug("unknown action", action); + return state; + } + } + + function addItem(item) { + return { + type: actionType, + cmd: ADD, + item: item + }; + } + + function updateItem(item) { + return { + type: actionType, + cmd: UPDATE, + item: item + }; + } + + function removeItem(item) { + return { + type: actionType, + cmd: REMOVE, + item: item + }; + } + + function updateList(event) { + /* This action creater takes all WebSocket events */ + return function (dispatch) { + switch (event.cmd) { + case "add": + return dispatch(addItem(event.data)); + case "update": + return dispatch(updateItem(event.data)); + case "remove": + return dispatch(removeItem(event.data)); + case "reset": + return dispatch(fetchList()); + default: + console.error("unknown list update", event); + } + }; + } + + function requestList() { + return { + type: actionType, + cmd: REQUEST_LIST + }; + } + + function receiveList(list) { + return { + type: actionType, + cmd: RECEIVE_LIST, + list: list + }; + } + + function fetchList() { + return function (dispatch) { + + dispatch(requestList()); + + return (0, _utils.fetchApi)(fetchURL).then(function (response) { + return response.json().then(function (json) { + dispatch(receiveList(json.data)); + }); + }); + }; + } + + return { reduceList: reduceList, updateList: updateList, fetchList: fetchList, addItem: addItem, updateItem: updateItem, removeItem: removeItem }; +} + +},{"../../utils":43}],38:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + +exports.sortedIndexOf = sortedIndexOf; +exports.updateViewList = updateViewList; +exports.updateViewFilter = updateViewFilter; +exports.updateViewSort = updateViewSort; + +var _list = require("./list"); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var defaultFilterFn = function defaultFilterFn(x) { + return true; +}; +var defaultSortFn = false; + +var makeCompareFn = function makeCompareFn(sortFn) { + var compareFn = function compareFn(a, b) { + var akey = sortFn(a), + bkey = sortFn(b); + if (akey < bkey) { + return -1; + } else if (akey > bkey) { + return 1; + } else { + return 0; + } + }; + // need to adjust sortedIndexOf as well + // if (sortFn.reverse) + // return (a, b) => compareFn(b, a) + return compareFn; +}; + +var sortedInsert = function sortedInsert(list, sortFn, item) { + var l = [].concat(_toConsumableArray(list), [item]); + l.indexOf = function (x) { + return sortedIndexOf(l, x, sortFn); + }; + var compareFn = makeCompareFn(sortFn); + + // only sort if sorting order is not correct yet + if (sortFn && compareFn(list[list.length - 1], item) > 0) { + // TODO: This is untested + console.debug("sorting view..."); + l.sort(compareFn); + } + return l; +}; + +var sortedRemove = function sortedRemove(list, sortFn, item) { + var itemId = item.id; + var l = list.filter(function (x) { + return x.id !== itemId; + }); + l.indexOf = function (x) { + return sortedIndexOf(l, x, sortFn); + }; + return l; +}; + +function sortedIndexOf(list, value, sortFn) { + if (!sortFn) { + sortFn = function sortFn(x) { + return 0; + }; // This triggers the linear search for flows that have the same sort value. + } + + var low = 0, + high = list.length, + val = sortFn(value), + mid = void 0; + while (low < high) { + mid = low + high >>> 1; + if (sortFn(list[mid]) < val) { + low = mid + 1; + } else { + high = mid; + } + } + + // Two flows may have the same sort value. + // we previously determined the leftmost flow with the same sort value, + // so no we need to scan linearly + while (list[low].id !== value.id && sortFn(list[low + 1]) === val) { + low++; + } + return low; +} + +// for when the list changes +function updateViewList(currentView, currentList, nextList, action) { + var filterFn = arguments.length <= 4 || arguments[4] === undefined ? defaultFilterFn : arguments[4]; + var sortFn = arguments.length <= 5 || arguments[5] === undefined ? defaultSortFn : arguments[5]; + + switch (action.cmd) { + case _list.REQUEST_LIST: + return currentView; + case _list.RECEIVE_LIST: + return updateViewFilter(nextList, filterFn, sortFn); + case _list.ADD: + if (filterFn(action.item)) { + return sortedInsert(currentView, sortFn, action.item); + } + return currentView; + case _list.UPDATE: + // let's determine if it's in the view currently and if it should be in the view. + var currentItemState = currentList.byId[action.item.id], + nextItemState = action.item, + isInView = filterFn(currentItemState), + shouldBeInView = filterFn(nextItemState); + + if (!isInView && shouldBeInView) return sortedInsert(currentView, sortFn, action.item); + if (isInView && !shouldBeInView) return sortedRemove(currentView, sortFn, action.item); + if (isInView && shouldBeInView) { + var _ret = function () { + var s = [].concat(_toConsumableArray(currentView)); + s.indexOf = function (x) { + return sortedIndexOf(s, x, sortFn); + }; + s[s.indexOf(currentItemState)] = nextItemState; + if (sortFn && sortFn(currentItemState) !== sortFn(nextItemState)) s.sort(makeCompareFn(sortFn)); + return { + v: s + }; + }(); + + if ((typeof _ret === "undefined" ? "undefined" : _typeof(_ret)) === "object") return _ret.v; + } + return currentView; + case _list.REMOVE: + var isInView_ = filterFn(currentList.byId[action.item.id]); + if (isInView_) { + return sortedRemove(currentView, sortFn, action.item); + } + return currentView; + default: + console.error("Unknown list action: ", action); + return currentView; + } +} + +function updateViewFilter(list) { + var filterFn = arguments.length <= 1 || arguments[1] === undefined ? defaultFilterFn : arguments[1]; + var sortFn = arguments.length <= 2 || arguments[2] === undefined ? defaultSortFn : arguments[2]; + + var filtered = list.list.filter(filterFn); + if (sortFn) { + filtered.sort(makeCompareFn(sortFn)); + } + filtered.indexOf = function (x) { + return sortedIndexOf(filtered, x, sortFn); + }; + + return filtered; +} + +function updateViewSort(list) { + var sortFn = arguments.length <= 1 || arguments[1] === undefined ? defaultSortFn : arguments[1]; + + var sorted = [].concat(_toConsumableArray(list)); + if (sortFn) { + sorted.sort(makeCompareFn(sortFn)); + } + sorted.indexOf = function (x) { + return sortedIndexOf(sorted, x, sortFn); + }; + + return sorted; +} + +},{"./list":37}],39:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = reducer; +exports.connected = connected; +exports.disconnected = disconnected; +var CONNECTED = 'WEBSOCKET_CONNECTED'; +var DISCONNECTED = 'WEBSOCKET_DISCONNECTED'; + +var defaultState = { + connected: false +}; +/* we may want to have an error message attribute here at some point */ +function reducer() { + var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0]; + var action = arguments[1]; + + switch (action.type) { + case CONNECTED: + return { + connected: true + }; + case DISCONNECTED: + return { + connected: false + }; + default: + return state; + } +} + +function connected() { + return { type: CONNECTED }; +} +function disconnected() { + return { type: DISCONNECTED }; +} + +},{}],40:[function(require,module,exports){ +"use strict"; + +module.exports = function () { + "use strict"; + + /* + * Generated by PEG.js 0.9.0. + * + * http://pegjs.org/ + */ + + function peg$subclass(child, parent) { + function ctor() { + this.constructor = child; + } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + } + + function peg$SyntaxError(message, expected, found, location) { + this.message = message; + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; + + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, peg$SyntaxError); + } + } + + peg$subclass(peg$SyntaxError, Error); + + function peg$parse(input) { + var options = arguments.length > 1 ? arguments[1] : {}, + parser = this, + peg$FAILED = {}, + peg$startRuleFunctions = { start: peg$parsestart }, + peg$startRuleFunction = peg$parsestart, + peg$c0 = { type: "other", description: "filter expression" }, + peg$c1 = function peg$c1(orExpr) { + return orExpr; + }, + peg$c2 = { type: "other", description: "whitespace" }, + peg$c3 = /^[ \t\n\r]/, + peg$c4 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" }, + peg$c5 = { type: "other", description: "control character" }, + peg$c6 = /^[|&!()~"]/, + peg$c7 = { type: "class", value: "[|&!()~\"]", description: "[|&!()~\"]" }, + peg$c8 = { type: "other", description: "optional whitespace" }, + peg$c9 = "|", + peg$c10 = { type: "literal", value: "|", description: "\"|\"" }, + peg$c11 = function peg$c11(first, second) { + return or(first, second); + }, + peg$c12 = "&", + peg$c13 = { type: "literal", value: "&", description: "\"&\"" }, + peg$c14 = function peg$c14(first, second) { + return and(first, second); + }, + peg$c15 = "!", + peg$c16 = { type: "literal", value: "!", description: "\"!\"" }, + peg$c17 = function peg$c17(expr) { + return not(expr); + }, + peg$c18 = "(", + peg$c19 = { type: "literal", value: "(", description: "\"(\"" }, + peg$c20 = ")", + peg$c21 = { type: "literal", value: ")", description: "\")\"" }, + peg$c22 = function peg$c22(expr) { + return binding(expr); + }, + peg$c23 = "~a", + peg$c24 = { type: "literal", value: "~a", description: "\"~a\"" }, + peg$c25 = function peg$c25() { + return assetFilter; + }, + peg$c26 = "~e", + peg$c27 = { type: "literal", value: "~e", description: "\"~e\"" }, + peg$c28 = function peg$c28() { + return errorFilter; + }, + peg$c29 = "~q", + peg$c30 = { type: "literal", value: "~q", description: "\"~q\"" }, + peg$c31 = function peg$c31() { + return noResponseFilter; + }, + peg$c32 = "~s", + peg$c33 = { type: "literal", value: "~s", description: "\"~s\"" }, + peg$c34 = function peg$c34() { + return responseFilter; + }, + peg$c35 = "true", + peg$c36 = { type: "literal", value: "true", description: "\"true\"" }, + peg$c37 = function peg$c37() { + return trueFilter; + }, + peg$c38 = "false", + peg$c39 = { type: "literal", value: "false", description: "\"false\"" }, + peg$c40 = function peg$c40() { + return falseFilter; + }, + peg$c41 = "~c", + peg$c42 = { type: "literal", value: "~c", description: "\"~c\"" }, + peg$c43 = function peg$c43(s) { + return responseCode(s); + }, + peg$c44 = "~d", + peg$c45 = { type: "literal", value: "~d", description: "\"~d\"" }, + peg$c46 = function peg$c46(s) { + return domain(s); + }, + peg$c47 = "~h", + peg$c48 = { type: "literal", value: "~h", description: "\"~h\"" }, + peg$c49 = function peg$c49(s) { + return header(s); + }, + peg$c50 = "~hq", + peg$c51 = { type: "literal", value: "~hq", description: "\"~hq\"" }, + peg$c52 = function peg$c52(s) { + return requestHeader(s); + }, + peg$c53 = "~hs", + peg$c54 = { type: "literal", value: "~hs", description: "\"~hs\"" }, + peg$c55 = function peg$c55(s) { + return responseHeader(s); + }, + peg$c56 = "~m", + peg$c57 = { type: "literal", value: "~m", description: "\"~m\"" }, + peg$c58 = function peg$c58(s) { + return method(s); + }, + peg$c59 = "~t", + peg$c60 = { type: "literal", value: "~t", description: "\"~t\"" }, + peg$c61 = function peg$c61(s) { + return contentType(s); + }, + peg$c62 = "~tq", + peg$c63 = { type: "literal", value: "~tq", description: "\"~tq\"" }, + peg$c64 = function peg$c64(s) { + return requestContentType(s); + }, + peg$c65 = "~ts", + peg$c66 = { type: "literal", value: "~ts", description: "\"~ts\"" }, + peg$c67 = function peg$c67(s) { + return responseContentType(s); + }, + peg$c68 = "~u", + peg$c69 = { type: "literal", value: "~u", description: "\"~u\"" }, + peg$c70 = function peg$c70(s) { + return url(s); + }, + peg$c71 = { type: "other", description: "integer" }, + peg$c72 = /^['"]/, + peg$c73 = { type: "class", value: "['\"]", description: "['\"]" }, + peg$c74 = /^[0-9]/, + peg$c75 = { type: "class", value: "[0-9]", description: "[0-9]" }, + peg$c76 = function peg$c76(digits) { + return parseInt(digits.join(""), 10); + }, + peg$c77 = { type: "other", description: "string" }, + peg$c78 = "\"", + peg$c79 = { type: "literal", value: "\"", description: "\"\\\"\"" }, + peg$c80 = function peg$c80(chars) { + return chars.join(""); + }, + peg$c81 = "'", + peg$c82 = { type: "literal", value: "'", description: "\"'\"" }, + peg$c83 = /^["\\]/, + peg$c84 = { type: "class", value: "[\"\\\\]", description: "[\"\\\\]" }, + peg$c85 = { type: "any", description: "any character" }, + peg$c86 = function peg$c86(char) { + return char; + }, + peg$c87 = "\\", + peg$c88 = { type: "literal", value: "\\", description: "\"\\\\\"" }, + peg$c89 = /^['\\]/, + peg$c90 = { type: "class", value: "['\\\\]", description: "['\\\\]" }, + peg$c91 = /^['"\\]/, + peg$c92 = { type: "class", value: "['\"\\\\]", description: "['\"\\\\]" }, + peg$c93 = "n", + peg$c94 = { type: "literal", value: "n", description: "\"n\"" }, + peg$c95 = function peg$c95() { + return "\n"; + }, + peg$c96 = "r", + peg$c97 = { type: "literal", value: "r", description: "\"r\"" }, + peg$c98 = function peg$c98() { + return "\r"; + }, + peg$c99 = "t", + peg$c100 = { type: "literal", value: "t", description: "\"t\"" }, + peg$c101 = function peg$c101() { + return "\t"; + }, + peg$currPos = 0, + peg$savedPos = 0, + peg$posDetailsCache = [{ line: 1, column: 1, seenCR: false }], + peg$maxFailPos = 0, + peg$maxFailExpected = [], + peg$silentFails = 0, + peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$savedPos, peg$currPos); + } + + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + + function expected(description) { + throw peg$buildException(null, [{ type: "other", description: description }], input.substring(peg$savedPos, peg$currPos), peg$computeLocation(peg$savedPos, peg$currPos)); + } + + function error(message) { + throw peg$buildException(message, null, input.substring(peg$savedPos, peg$currPos), peg$computeLocation(peg$savedPos, peg$currPos)); + } + + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos], + p, + ch; + + if (details) { + return details; + } else { + p = pos - 1; + while (!peg$posDetailsCache[p]) { + p--; + } + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column, + seenCR: details.seenCR + }; + + while (p < pos) { + ch = input.charAt(p); + if (ch === "\n") { + if (!details.seenCR) { + details.line++; + } + details.column = 1; + details.seenCR = false; + } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { + details.line++; + details.column = 1; + details.seenCR = true; + } else { + details.column++; + details.seenCR = false; + } + + p++; + } + + peg$posDetailsCache[pos] = details; + return details; + } + } + + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos), + endPosDetails = peg$computePosDetails(endPos); + + return { + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column + } + }; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { + return; + } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildException(message, expected, found, location) { + function cleanupExpected(expected) { + var i = 1; + + expected.sort(function (a, b) { + if (a.description < b.description) { + return -1; + } else if (a.description > b.description) { + return 1; + } else { + return 0; + } + }); + + while (i < expected.length) { + if (expected[i - 1] === expected[i]) { + expected.splice(i, 1); + } else { + i++; + } + } + } + + function buildMessage(expected, found) { + function stringEscape(s) { + function hex(ch) { + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + + return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\x08/g, '\\b').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\f/g, '\\f').replace(/\r/g, '\\r').replace(/[\x00-\x07\x0B\x0E\x0F]/g, function (ch) { + return '\\x0' + hex(ch); + }).replace(/[\x10-\x1F\x80-\xFF]/g, function (ch) { + return '\\x' + hex(ch); + }).replace(/[\u0100-\u0FFF]/g, function (ch) { + return "\\u0" + hex(ch); + }).replace(/[\u1000-\uFFFF]/g, function (ch) { + return "\\u" + hex(ch); + }); + } + + var expectedDescs = new Array(expected.length), + expectedDesc, + foundDesc, + i; + + for (i = 0; i < expected.length; i++) { + expectedDescs[i] = expected[i].description; + } + + expectedDesc = expected.length > 1 ? expectedDescs.slice(0, -1).join(", ") + " or " + expectedDescs[expected.length - 1] : expectedDescs[0]; + + foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; + + return "Expected " + expectedDesc + " but " + foundDesc + " found."; + } + + if (expected !== null) { + cleanupExpected(expected); + } + + return new peg$SyntaxError(message !== null ? message : buildMessage(expected, found), expected, found, location); + } + + function peg$parsestart() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parse__(); + if (s1 !== peg$FAILED) { + s2 = peg$parseOrExpr(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c1(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c0); + } + } + + return s0; + } + + function peg$parsews() { + var s0, s1; + + peg$silentFails++; + if (peg$c3.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c4); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c2); + } + } + + return s0; + } + + function peg$parsecc() { + var s0, s1; + + peg$silentFails++; + if (peg$c6.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c7); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c5); + } + } + + return s0; + } + + function peg$parse__() { + var s0, s1; + + peg$silentFails++; + s0 = []; + s1 = peg$parsews(); + while (s1 !== peg$FAILED) { + s0.push(s1); + s1 = peg$parsews(); + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c8); + } + } + + return s0; + } + + function peg$parseOrExpr() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseAndExpr(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 124) { + s3 = peg$c9; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c10); + } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + if (s4 !== peg$FAILED) { + s5 = peg$parseOrExpr(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$parseAndExpr(); + } + + return s0; + } + + function peg$parseAndExpr() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseNotExpr(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 38) { + s3 = peg$c12; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c13); + } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + if (s4 !== peg$FAILED) { + s5 = peg$parseAndExpr(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c14(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseNotExpr(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseAndExpr(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c14(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$parseNotExpr(); + } + } + + return s0; + } + + function peg$parseNotExpr() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 33) { + s1 = peg$c15; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c16); + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + s3 = peg$parseNotExpr(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c17(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$parseBindingExpr(); + } + + return s0; + } + + function peg$parseBindingExpr() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 40) { + s1 = peg$c18; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c19); + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + s3 = peg$parseOrExpr(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c20; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c21); + } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c22(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$parseExpr(); + } + + return s0; + } + + function peg$parseExpr() { + var s0; + + s0 = peg$parseNullaryExpr(); + if (s0 === peg$FAILED) { + s0 = peg$parseUnaryExpr(); + } + + return s0; + } + + function peg$parseNullaryExpr() { + var s0, s1; + + s0 = peg$parseBooleanLiteral(); + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c23) { + s1 = peg$c23; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c24); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c25(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c26) { + s1 = peg$c26; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c27); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c28(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c29) { + s1 = peg$c29; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c30); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c31(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c32) { + s1 = peg$c32; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c34(); + } + s0 = s1; + } + } + } + } + + return s0; + } + + function peg$parseBooleanLiteral() { + var s0, s1; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c35) { + s1 = peg$c35; + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c36); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c37(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c38) { + s1 = peg$c38; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c39); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c40(); + } + s0 = s1; + } + + return s0; + } + + function peg$parseUnaryExpr() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c41) { + s1 = peg$c41; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c42); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIntegerLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c43(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c44) { + s1 = peg$c44; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c45); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c46(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c47) { + s1 = peg$c47; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c48); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c49(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c50) { + s1 = peg$c50; + peg$currPos += 3; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c51); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c52(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c53) { + s1 = peg$c53; + peg$currPos += 3; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c54); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c55(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c56) { + s1 = peg$c56; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c57); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c58(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c59) { + s1 = peg$c59; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c60); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c61(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c62) { + s1 = peg$c62; + peg$currPos += 3; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c63); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c64(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c65) { + s1 = peg$c65; + peg$currPos += 3; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c66); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c67(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c68) { + s1 = peg$c68; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c69); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseStringLiteral(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c70(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseStringLiteral(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c70(s1); + } + s0 = s1; + } + } + } + } + } + } + } + } + } + } + + return s0; + } + + function peg$parseIntegerLiteral() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + if (peg$c72.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c73); + } + } + if (s1 === peg$FAILED) { + s1 = null; + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c74.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c75); + } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c74.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c75); + } + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + if (peg$c72.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c73); + } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c76(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c71); + } + } + + return s0; + } + + function peg$parseStringLiteral() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c78; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c79); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseDoubleStringChar(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseDoubleStringChar(); + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c78; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c79); + } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c80(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s1 = peg$c81; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c82); + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseSingleStringChar(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseSingleStringChar(); + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c81; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c82); + } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c80(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parsecc(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseUnquotedStringChar(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseUnquotedStringChar(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c80(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c77); + } + } + + return s0; + } + + function peg$parseDoubleStringChar() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + if (peg$c83.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c84); + } + } + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + if (input.length > peg$currPos) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c85); + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c86(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c87; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c88); + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseEscapeSequence(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c86(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseSingleStringChar() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + if (peg$c89.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c90); + } + } + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + if (input.length > peg$currPos) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c85); + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c86(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c87; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c88); + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseEscapeSequence(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c86(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseUnquotedStringChar() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parsews(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + if (input.length > peg$currPos) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c85); + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c86(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseEscapeSequence() { + var s0, s1; + + if (peg$c91.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c92); + } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 110) { + s1 = peg$c93; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c94); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c95(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 114) { + s1 = peg$c96; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c97); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c98(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 116) { + s1 = peg$c99; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c100); + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c101(); + } + s0 = s1; + } + } + } + + return s0; + } + + var flowutils = require("../flow/utils.js"); + + function or(first, second) { + // Add explicit function names to ease debugging. + function orFilter() { + return first.apply(this, arguments) || second.apply(this, arguments); + } + orFilter.desc = first.desc + " or " + second.desc; + return orFilter; + } + function and(first, second) { + function andFilter() { + return first.apply(this, arguments) && second.apply(this, arguments); + } + andFilter.desc = first.desc + " and " + second.desc; + return andFilter; + } + function not(expr) { + function notFilter() { + return !expr.apply(this, arguments); + } + notFilter.desc = "not " + expr.desc; + return notFilter; + } + function binding(expr) { + function bindingFilter() { + return expr.apply(this, arguments); + } + bindingFilter.desc = "(" + expr.desc + ")"; + return bindingFilter; + } + function trueFilter(flow) { + return true; + } + trueFilter.desc = "true"; + function falseFilter(flow) { + return false; + } + falseFilter.desc = "false"; + + var ASSET_TYPES = [new RegExp("text/javascript"), new RegExp("application/x-javascript"), new RegExp("application/javascript"), new RegExp("text/css"), new RegExp("image/.*"), new RegExp("application/x-shockwave-flash")]; + function assetFilter(flow) { + if (flow.response) { + var ct = flowutils.ResponseUtils.getContentType(flow.response); + var i = ASSET_TYPES.length; + while (i--) { + if (ASSET_TYPES[i].test(ct)) { + return true; + } + } + } + return false; + } + assetFilter.desc = "is asset"; + function responseCode(code) { + function responseCodeFilter(flow) { + return flow.response && flow.response.status_code === code; + } + responseCodeFilter.desc = "resp. code is " + code; + return responseCodeFilter; + } + function domain(regex) { + regex = new RegExp(regex, "i"); + function domainFilter(flow) { + return flow.request && regex.test(flow.request.host); + } + domainFilter.desc = "domain matches " + regex; + return domainFilter; + } + function errorFilter(flow) { + return !!flow.error; + } + errorFilter.desc = "has error"; + function header(regex) { + regex = new RegExp(regex, "i"); + function headerFilter(flow) { + return flow.request && flowutils.RequestUtils.match_header(flow.request, regex) || flow.response && flowutils.ResponseUtils.match_header(flow.response, regex); + } + headerFilter.desc = "header matches " + regex; + return headerFilter; + } + function requestHeader(regex) { + regex = new RegExp(regex, "i"); + function requestHeaderFilter(flow) { + return flow.request && flowutils.RequestUtils.match_header(flow.request, regex); + } + requestHeaderFilter.desc = "req. header matches " + regex; + return requestHeaderFilter; + } + function responseHeader(regex) { + regex = new RegExp(regex, "i"); + function responseHeaderFilter(flow) { + return flow.response && flowutils.ResponseUtils.match_header(flow.response, regex); + } + responseHeaderFilter.desc = "resp. header matches " + regex; + return responseHeaderFilter; + } + function method(regex) { + regex = new RegExp(regex, "i"); + function methodFilter(flow) { + return flow.request && regex.test(flow.request.method); + } + methodFilter.desc = "method matches " + regex; + return methodFilter; + } + function noResponseFilter(flow) { + return flow.request && !flow.response; + } + noResponseFilter.desc = "has no response"; + function responseFilter(flow) { + return !!flow.response; + } + responseFilter.desc = "has response"; + + function contentType(regex) { + regex = new RegExp(regex, "i"); + function contentTypeFilter(flow) { + return flow.request && regex.test(flowutils.RequestUtils.getContentType(flow.request)) || flow.response && regex.test(flowutils.ResponseUtils.getContentType(flow.response)); + } + contentTypeFilter.desc = "content type matches " + regex; + return contentTypeFilter; + } + function requestContentType(regex) { + regex = new RegExp(regex, "i"); + function requestContentTypeFilter(flow) { + return flow.request && regex.test(flowutils.RequestUtils.getContentType(flow.request)); + } + requestContentTypeFilter.desc = "req. content type matches " + regex; + return requestContentTypeFilter; + } + function responseContentType(regex) { + regex = new RegExp(regex, "i"); + function responseContentTypeFilter(flow) { + return flow.response && regex.test(flowutils.ResponseUtils.getContentType(flow.response)); + } + responseContentTypeFilter.desc = "resp. content type matches " + regex; + return responseContentTypeFilter; + } + function url(regex) { + regex = new RegExp(regex, "i"); + function urlFilter(flow) { + return flow.request && regex.test(flowutils.RequestUtils.pretty_url(flow.request)); + } + urlFilter.desc = "url matches " + regex; + return urlFilter; + } + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail({ type: "end", description: "end of input" }); + } + + throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)); + } + } + + return { + SyntaxError: peg$SyntaxError, + parse: peg$parse + }; +}(); + +},{"../flow/utils.js":41}],41:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.parseHttpVersion = exports.isValidHttpVersion = exports.parseUrl = exports.ResponseUtils = exports.RequestUtils = exports.MessageUtils = undefined; + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _jquery = require("jquery"); + +var _jquery2 = _interopRequireDefault(_jquery); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var defaultPorts = { + "http": 80, + "https": 443 +}; + +var MessageUtils = exports.MessageUtils = { + getContentType: function getContentType(message) { + var ct = this.get_first_header(message, /^Content-Type$/i); + if (ct) { + return ct.split(";")[0].trim(); + } + }, + get_first_header: function get_first_header(message, regex) { + //FIXME: Cache Invalidation. + if (!message._headerLookups) Object.defineProperty(message, "_headerLookups", { + value: {}, + configurable: false, + enumerable: false, + writable: false + }); + if (!(regex in message._headerLookups)) { + var header; + for (var i = 0; i < message.headers.length; i++) { + if (!!message.headers[i][0].match(regex)) { + header = message.headers[i]; + break; + } + } + message._headerLookups[regex] = header ? header[1] : undefined; + } + return message._headerLookups[regex]; + }, + match_header: function match_header(message, regex) { + var headers = message.headers; + var i = headers.length; + while (i--) { + if (regex.test(headers[i].join(" "))) { + return headers[i]; + } + } + return false; + }, + getContentURL: function getContentURL(flow, message) { + if (message === flow.request) { + message = "request"; + } else if (message === flow.response) { + message = "response"; + } + return "/flows/" + flow.id + "/" + message + "/content"; + }, + getContent: function getContent(flow, message) { + var url = MessageUtils.getContentURL(flow, message); + return _jquery2.default.get(url); + } +}; + +var RequestUtils = exports.RequestUtils = _lodash2.default.extend(MessageUtils, { + pretty_host: function pretty_host(request) { + //FIXME: Add hostheader + return request.host; + }, + pretty_url: function pretty_url(request) { + var port = ""; + if (defaultPorts[request.scheme] !== request.port) { + port = ":" + request.port; + } + return request.scheme + "://" + this.pretty_host(request) + port + request.path; + } +}); + +var ResponseUtils = exports.ResponseUtils = _lodash2.default.extend(MessageUtils, {}); + +var parseUrl_regex = /^(?:(https?):\/\/)?([^\/:]+)?(?::(\d+))?(\/.*)?$/i; +var parseUrl = exports.parseUrl = function parseUrl(url) { + //there are many correct ways to parse a URL, + //however, a mitmproxy user may also wish to generate a not-so-correct URL. ;-) + var parts = parseUrl_regex.exec(url); + if (!parts) { + return false; + } + + var scheme = parts[1], + host = parts[2], + port = parseInt(parts[3]), + path = parts[4]; + if (scheme) { + port = port || defaultPorts[scheme]; + } + var ret = {}; + if (scheme) { + ret.scheme = scheme; + } + if (host) { + ret.host = host; + } + if (port) { + ret.port = port; + } + if (path) { + ret.path = path; + } + return ret; +}; + +var isValidHttpVersion_regex = /^HTTP\/\d+(\.\d+)*$/i; +var isValidHttpVersion = exports.isValidHttpVersion = function isValidHttpVersion(httpVersion) { + return isValidHttpVersion_regex.test(httpVersion); +}; + +var parseHttpVersion = exports.parseHttpVersion = function parseHttpVersion(httpVersion) { + httpVersion = httpVersion.replace("HTTP/", "").split("."); + return _lodash2.default.map(httpVersion, function (x) { + return parseInt(x); + }); +}; + +},{"jquery":"jquery","lodash":"lodash"}],42:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.SettingsStore = SettingsStore; + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _jquery = require("jquery"); + +var _jquery2 = _interopRequireDefault(_jquery); + +var _events = require("events"); + +var _actions = require("../actions.js"); + +var _dispatcher = require("../dispatcher.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function DictStore() { + _events.EventEmitter.call(this); + this.reset(); +} +_lodash2.default.extend(DictStore.prototype, _events.EventEmitter.prototype, { + update: function update(dict) { + _lodash2.default.merge(this.dict, dict); + this.emit("recalculate"); + }, + reset: function reset(dict) { + this.dict = dict || {}; + this.emit("recalculate"); + } +}); + +function LiveStoreMixin(type) { + this.type = type; + + this._updates_before_fetch = undefined; + this._fetchxhr = false; + + this.handle = this.handle.bind(this); + _dispatcher.AppDispatcher.register(this.handle); + + // Avoid double-fetch on startup. + if (!(window.ws && window.ws.readyState === WebSocket.CONNECTING)) { + this.fetch(); + } +} +_lodash2.default.extend(LiveStoreMixin.prototype, { + handle: function handle(event) { + if (event.type === _actions.ActionTypes.CONNECTION_OPEN) { + return this.fetch(); + } + if (event.type === this.type) { + if (event.cmd === _actions.StoreCmds.RESET) { + this.fetch(event.data); + } else if (this._updates_before_fetch) { + console.log("defer update", event); + this._updates_before_fetch.push(event); + } else { + this[event.cmd](event.data); + } + } + }, + close: function close() { + _dispatcher.AppDispatcher.unregister(this.handle); + }, + fetch: function fetch(data) { + console.log("fetch " + this.type); + if (this._fetchxhr) { + this._fetchxhr.abort(); + } + this._updates_before_fetch = []; // (JS: empty array is true) + if (data) { + this.handle_fetch(data); + } else { + this._fetchxhr = _jquery2.default.getJSON("/" + this.type).done(function (message) { + this.handle_fetch(message.data); + }.bind(this)).fail(function () { + console.error("Could not fetch " + this.type); + }.bind(this)); + } + }, + handle_fetch: function handle_fetch(data) { + this._fetchxhr = false; + console.log(this.type + " fetched.", this._updates_before_fetch); + this.reset(data); + var updates = this._updates_before_fetch; + this._updates_before_fetch = false; + for (var i = 0; i < updates.length; i++) { + this.handle(updates[i]); + } + } +}); + +function LiveDictStore(type) { + DictStore.call(this); + LiveStoreMixin.call(this, type); +} +_lodash2.default.extend(LiveDictStore.prototype, DictStore.prototype, LiveStoreMixin.prototype); + +function SettingsStore() { + return new LiveDictStore(_actions.ActionTypes.SETTINGS_STORE); +} + +},{"../actions.js":2,"../dispatcher.js":32,"events":1,"jquery":"jquery","lodash":"lodash"}],43:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.formatTimeStamp = exports.formatTimeDelta = exports.formatSize = exports.Key = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.reverseString = reverseString; +exports.fetchApi = fetchApi; + +var _jquery = require("jquery"); + +var _jquery2 = _interopRequireDefault(_jquery); + +var _lodash = require("lodash"); + +var _lodash2 = _interopRequireDefault(_lodash); + +var _actions = require("./actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +window.$ = _jquery2.default; +window._ = _lodash2.default; +window.React = require("react"); + +var Key = exports.Key = { + UP: 38, + DOWN: 40, + PAGE_UP: 33, + PAGE_DOWN: 34, + HOME: 36, + END: 35, + LEFT: 37, + RIGHT: 39, + ENTER: 13, + ESC: 27, + TAB: 9, + SPACE: 32, + BACKSPACE: 8, + SHIFT: 16 +}; +// Add A-Z +for (var i = 65; i <= 90; i++) { + Key[String.fromCharCode(i)] = i; +} + +var formatSize = exports.formatSize = function formatSize(bytes) { + if (bytes === 0) return "0"; + var prefix = ["b", "kb", "mb", "gb", "tb"]; + for (var i = 0; i < prefix.length; i++) { + if (Math.pow(1024, i + 1) > bytes) { + break; + } + } + var precision; + if (bytes % Math.pow(1024, i) === 0) precision = 0;else precision = 1; + return (bytes / Math.pow(1024, i)).toFixed(precision) + prefix[i]; +}; + +var formatTimeDelta = exports.formatTimeDelta = function formatTimeDelta(milliseconds) { + var time = milliseconds; + var prefix = ["ms", "s", "min", "h"]; + var div = [1000, 60, 60]; + var i = 0; + while (Math.abs(time) >= div[i] && i < div.length) { + time = time / div[i]; + i++; + } + return Math.round(time) + prefix[i]; +}; + +var formatTimeStamp = exports.formatTimeStamp = function formatTimeStamp(seconds) { + var ts = new Date(seconds * 1000).toISOString(); + return ts.replace("T", " ").replace("Z", ""); +}; + +// At some places, we need to sort strings alphabetically descending, +// but we can only provide a key function. +// This beauty "reverses" a JS string. +var end = String.fromCharCode(0xffff); +function reverseString(s) { + return String.fromCharCode.apply(String, _lodash2.default.map(s.split(""), function (c) { + return 0xffff - c.charCodeAt(0); + })) + end; +} + +function getCookie(name) { + var r = document.cookie.match(new RegExp("\\b" + name + "=([^;]*)\\b")); + return r ? r[1] : undefined; +} +var xsrf = "_xsrf=" + getCookie("_xsrf"); + +//Tornado XSRF Protection. +_jquery2.default.ajaxPrefilter(function (options) { + if (["post", "put", "delete"].indexOf(options.type.toLowerCase()) >= 0 && options.url[0] === "/") { + if (options.url.indexOf("?") === -1) { + options.url += "?" + xsrf; + } else { + options.url += "&" + xsrf; + } + } +}); +// Log AJAX Errors +(0, _jquery2.default)(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) { + if (thrownError === "abort") { + return; + } + var message = jqXHR.responseText; + console.error(thrownError, message, arguments); + alert(message); +}); + +function fetchApi(url, options) { + if (url.indexOf("?") === -1) { + url += "?" + xsrf; + } else { + url += "&" + xsrf; + } + return fetch(url, _extends({}, options, { + credentials: 'same-origin' + })); +} },{"./actions.js":2,"jquery":"jquery","lodash":"lodash","react":"react"}]},{},[3]) diff --git a/mitmproxy/web/static/vendor.js b/mitmproxy/web/static/vendor.js index a02a645d4..5326c5520 100644 --- a/mitmproxy/web/static/vendor.js +++ b/mitmproxy/web/static/vendor.js @@ -1,1129 +1,54130 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0&&"number"!=typeof e[0]):!1}function objEquiv(e,t,r){var n,i;if(isUndefinedOrNull(e)||isUndefinedOrNull(t))return!1;if(e.prototype!==t.prototype)return!1;if(isArguments(e))return isArguments(t)?(e=pSlice.call(e),t=pSlice.call(t),deepEqual(e,t,r)):!1;if(isBuffer(e)){if(!isBuffer(t))return!1;if(e.length!==t.length)return!1;for(n=0;n=0;n--)if(u[n]!=o[n])return!1;for(n=u.length-1;n>=0;n--)if(i=u[n],!deepEqual(e[i],t[i],r))return!1;return typeof e==typeof t}var pSlice=Array.prototype.slice,objectKeys=require("./lib/keys.js"),isArguments=require("./lib/is_arguments.js"),deepEqual=module.exports=function(e,t,r){return r||(r={}),e===t?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():!e||!t||"object"!=typeof e&&"object"!=typeof t?r.strict?e===t:e==t:objEquiv(e,t,r)}; +var pSlice = Array.prototype.slice; +var objectKeys = require('./lib/keys.js'); +var isArguments = require('./lib/is_arguments.js'); + +var deepEqual = module.exports = function (actual, expected, opts) { + if (!opts) opts = {}; + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + + } else if (actual instanceof Date && expected instanceof Date) { + return actual.getTime() === expected.getTime(); + + // 7.3. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') { + return opts.strict ? actual === expected : actual == expected; + + // 7.4. For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else { + return objEquiv(actual, expected, opts); + } +} + +function isUndefinedOrNull(value) { + return value === null || value === undefined; +} + +function isBuffer (x) { + if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false; + if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { + return false; + } + if (x.length > 0 && typeof x[0] !== 'number') return false; + return true; +} + +function objEquiv(a, b, opts) { + var i, key; + if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) + return false; + // an identical 'prototype' property. + if (a.prototype !== b.prototype) return false; + //~~~I've managed to break Object.keys through screwy arguments passing. + // Converting to array solves the problem. + if (isArguments(a)) { + if (!isArguments(b)) { + return false; + } + a = pSlice.call(a); + b = pSlice.call(b); + return deepEqual(a, b, opts); + } + if (isBuffer(a)) { + if (!isBuffer(b)) { + return false; + } + if (a.length !== b.length) return false; + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) return false; + } + return true; + } + try { + var ka = objectKeys(a), + kb = objectKeys(b); + } catch (e) {//happens when one is a string literal and the other isn't + return false; + } + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length != kb.length) + return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] != kb[i]) + return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!deepEqual(a[key], b[key], opts)) return false; + } + return typeof a === typeof b; +} },{"./lib/is_arguments.js":2,"./lib/keys.js":3}],2:[function(require,module,exports){ -function supported(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function unsupported(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}var supportsArgumentsClass="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();exports=module.exports=supportsArgumentsClass?supported:unsupported,exports.supported=supported,exports.unsupported=unsupported; +var supportsArgumentsClass = (function(){ + return Object.prototype.toString.call(arguments) +})() == '[object Arguments]'; + +exports = module.exports = supportsArgumentsClass ? supported : unsupported; + +exports.supported = supported; +function supported(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; +}; + +exports.unsupported = unsupported; +function unsupported(object){ + return object && + typeof object == 'object' && + typeof object.length == 'number' && + Object.prototype.hasOwnProperty.call(object, 'callee') && + !Object.prototype.propertyIsEnumerable.call(object, 'callee') || + false; +}; },{}],3:[function(require,module,exports){ -function shim(e){var s=[];for(var t in e)s.push(t);return s}exports=module.exports="function"==typeof Object.keys?Object.keys:shim,exports.shim=shim; +exports = module.exports = typeof Object.keys === 'function' + ? Object.keys : shim; + +exports.shim = shim; +function shim (obj) { + var keys = []; + for (var key in obj) keys.push(key); + return keys; +} },{}],4:[function(require,module,exports){ (function (process){ -"use strict";var invariant=function(r,e,n,i,o,a,t,s){if("production"!==process.env.NODE_ENV&&void 0===e)throw new Error("invariant requires an error message argument");if(!r){var u;if(void 0===e)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var v=[n,i,o,a,t,s],d=0;u=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return v[d++]}))}throw u.framesToPop=1,u}};module.exports=invariant; +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule invariant + */ +"use strict"; + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var invariant = function (condition, format, a, b, c, d, e, f) { + if (process.env.NODE_ENV !== 'production') { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + } + + if (!condition) { + var error; + if (format === undefined) { + error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () { + return args[argIndex++]; + })); + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +}; + +module.exports = invariant; }).call(this,require('_process')) -},{"_process":32}],5:[function(require,module,exports){ +},{"_process":33}],5:[function(require,module,exports){ (function (process){ -"use strict";function _classCallCheck(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}exports.__esModule=!0;var invariant=require("fbjs/lib/invariant"),_prefix="ID_",Dispatcher=function(){function i(){_classCallCheck(this,i),this._callbacks={},this._isDispatching=!1,this._isHandled={},this._isPending={},this._lastID=1}return i.prototype.register=function(i){var t=_prefix+this._lastID++;return this._callbacks[t]=i,t},i.prototype.unregister=function(i){this._callbacks[i]?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"Dispatcher.unregister(...): `%s` does not map to a registered callback.",i):invariant(!1),delete this._callbacks[i]},i.prototype.waitFor=function(i){this._isDispatching?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"Dispatcher.waitFor(...): Must be invoked while dispatching."):invariant(!1);for(var t=0;tl&&e;)e=!1,i.call(this,l++,s,c);return n=!1,r?void t.apply(this,p):void(l>=o&&e&&(r=!0,t()))}}var l=0,r=!1,n=!1,e=!1,p=void 0;s()}exports.__esModule=!0;var _slice=Array.prototype.slice;exports.loopAsync=loopAsync; +"use strict"; +exports.__esModule = true; +var _slice = Array.prototype.slice; +exports.loopAsync = loopAsync; + +function loopAsync(turns, work, callback) { + var currentTurn = 0, + isDone = false; + var sync = false, + hasNext = false, + doneArgs = undefined; + + function done() { + isDone = true; + if (sync) { + // Iterate instead of recursing if possible. + doneArgs = [].concat(_slice.call(arguments)); + return; + } + + callback.apply(this, arguments); + } + + function next() { + if (isDone) { + return; + } + + hasNext = true; + if (sync) { + // Iterate instead of recursing if possible. + return; + } + + sync = true; + + while (!isDone && currentTurn < turns && hasNext) { + hasNext = false; + work.call(this, currentTurn++, next, done); + } + + sync = false; + + if (isDone) { + // This means the loop finished synchronously. + callback.apply(this, doneArgs); + return; + } + + if (currentTurn >= turns && hasNext) { + isDone = true; + callback(); + } + } + + next(); +} },{}],8:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function createKey(e){return KeyPrefix+e}function saveState(e,r){try{null==r?window.sessionStorage.removeItem(createKey(e)):window.sessionStorage.setItem(createKey(e),JSON.stringify(r))}catch(t){if(t.name===SecurityError)return void("production"!==process.env.NODE_ENV?_warning2["default"](!1,"[history] Unable to save state; sessionStorage is not available due to security settings"):void 0);if(QuotaExceededErrors.indexOf(t.name)>=0&&0===window.sessionStorage.length)return void("production"!==process.env.NODE_ENV?_warning2["default"](!1,"[history] Unable to save state; sessionStorage is not available in Safari private mode"):void 0);throw t}}function readState(e){var r=void 0;try{r=window.sessionStorage.getItem(createKey(e))}catch(t){if(t.name===SecurityError)return"production"!==process.env.NODE_ENV?_warning2["default"](!1,"[history] Unable to read state; sessionStorage is not available due to security settings"):void 0,null}if(r)try{return JSON.parse(r)}catch(t){}return null}exports.__esModule=!0,exports.saveState=saveState,exports.readState=readState;var _warning=require("warning"),_warning2=_interopRequireDefault(_warning),KeyPrefix="@@History/",QuotaExceededErrors=["QuotaExceededError","QUOTA_EXCEEDED_ERR"],SecurityError="SecurityError"; +/*eslint-disable no-empty */ +'use strict'; +exports.__esModule = true; +exports.saveState = saveState; +exports.readState = readState; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _warning = require('warning'); + +var _warning2 = _interopRequireDefault(_warning); + +var KeyPrefix = '@@History/'; +var QuotaExceededErrors = ['QuotaExceededError', 'QUOTA_EXCEEDED_ERR']; + +var SecurityError = 'SecurityError'; + +function createKey(key) { + return KeyPrefix + key; +} + +function saveState(key, state) { + try { + if (state == null) { + window.sessionStorage.removeItem(createKey(key)); + } else { + window.sessionStorage.setItem(createKey(key), JSON.stringify(state)); + } + } catch (error) { + if (error.name === SecurityError) { + // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any + // attempt to access window.sessionStorage. + process.env.NODE_ENV !== 'production' ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available due to security settings') : undefined; + + return; + } + + if (QuotaExceededErrors.indexOf(error.name) >= 0 && window.sessionStorage.length === 0) { + // Safari "private mode" throws QuotaExceededError. + process.env.NODE_ENV !== 'production' ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available in Safari private mode') : undefined; + + return; + } + + throw error; + } +} + +function readState(key) { + var json = undefined; + try { + json = window.sessionStorage.getItem(createKey(key)); + } catch (error) { + if (error.name === SecurityError) { + // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any + // attempt to access window.sessionStorage. + process.env.NODE_ENV !== 'production' ? _warning2['default'](false, '[history] Unable to read state; sessionStorage is not available due to security settings') : undefined; + + return null; + } + } + + if (json) { + try { + return JSON.parse(json); + } catch (error) { + // Ignore invalid JSON. + } + } + + return null; +} }).call(this,require('_process')) -},{"_process":32,"warning":250}],9:[function(require,module,exports){ -"use strict";function addEventListener(t,e,o){t.addEventListener?t.addEventListener(e,o,!1):t.attachEvent("on"+e,o)}function removeEventListener(t,e,o){t.removeEventListener?t.removeEventListener(e,o,!1):t.detachEvent("on"+e,o)}function getHashPath(){return window.location.href.split("#")[1]||""}function replaceHashPath(t){window.location.replace(window.location.pathname+window.location.search+"#"+t)}function getWindowPath(){return window.location.pathname+window.location.search+window.location.hash}function go(t){t&&window.history.go(t)}function getUserConfirmation(t,e){e(window.confirm(t))}function supportsHistory(){var t=navigator.userAgent;return-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone")?window.history&&"pushState"in window.history:!1}function supportsGoWithoutReloadUsingHash(){var t=navigator.userAgent;return-1===t.indexOf("Firefox")}exports.__esModule=!0,exports.addEventListener=addEventListener,exports.removeEventListener=removeEventListener,exports.getHashPath=getHashPath,exports.replaceHashPath=replaceHashPath,exports.getWindowPath=getWindowPath,exports.go=go,exports.getUserConfirmation=getUserConfirmation,exports.supportsHistory=supportsHistory,exports.supportsGoWithoutReloadUsingHash=supportsGoWithoutReloadUsingHash; +},{"_process":33,"warning":249}],9:[function(require,module,exports){ +'use strict'; +exports.__esModule = true; +exports.addEventListener = addEventListener; +exports.removeEventListener = removeEventListener; +exports.getHashPath = getHashPath; +exports.replaceHashPath = replaceHashPath; +exports.getWindowPath = getWindowPath; +exports.go = go; +exports.getUserConfirmation = getUserConfirmation; +exports.supportsHistory = supportsHistory; +exports.supportsGoWithoutReloadUsingHash = supportsGoWithoutReloadUsingHash; + +function addEventListener(node, event, listener) { + if (node.addEventListener) { + node.addEventListener(event, listener, false); + } else { + node.attachEvent('on' + event, listener); + } +} + +function removeEventListener(node, event, listener) { + if (node.removeEventListener) { + node.removeEventListener(event, listener, false); + } else { + node.detachEvent('on' + event, listener); + } +} + +function getHashPath() { + // We can't use window.location.hash here because it's not + // consistent across browsers - Firefox will pre-decode it! + return window.location.href.split('#')[1] || ''; +} + +function replaceHashPath(path) { + window.location.replace(window.location.pathname + window.location.search + '#' + path); +} + +function getWindowPath() { + return window.location.pathname + window.location.search + window.location.hash; +} + +function go(n) { + if (n) window.history.go(n); +} + +function getUserConfirmation(message, callback) { + callback(window.confirm(message)); +} + +/** + * Returns true if the HTML5 history API is supported. Taken from Modernizr. + * + * https://github.com/Modernizr/Modernizr/blob/master/LICENSE + * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + * changed to avoid false negatives for Windows Phones: https://github.com/rackt/react-router/issues/586 + */ + +function supportsHistory() { + var ua = navigator.userAgent; + if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) { + return false; + } + return window.history && 'pushState' in window.history; +} + +/** + * Returns false if using go(n) with hash history causes a full page reload. + */ + +function supportsGoWithoutReloadUsingHash() { + var ua = navigator.userAgent; + return ua.indexOf('Firefox') === -1; +} },{}],10:[function(require,module,exports){ -"use strict";exports.__esModule=!0;var canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement);exports.canUseDOM=canUseDOM; +'use strict'; +exports.__esModule = true; +var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); +exports.canUseDOM = canUseDOM; },{}],11:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{"default":t}}function extractPath(t){var e=t.match(/^https?:\/\/[^\/]*/);return null==e?t:t.substring(e[0].length)}function parsePath(t){var e=extractPath(t),r="",a="";"production"!==process.env.NODE_ENV?_warning2["default"](t===e,'A path must be pathname + search + hash only, not a fully qualified URL like "%s"',t):void 0;var n=e.indexOf("#");-1!==n&&(a=e.substring(n),e=e.substring(0,n));var s=e.indexOf("?");return-1!==s&&(r=e.substring(s),e=e.substring(0,s)),""===e&&(e="/"),{pathname:e,search:r,hash:a}}exports.__esModule=!0,exports.extractPath=extractPath,exports.parsePath=parsePath;var _warning=require("warning"),_warning2=_interopRequireDefault(_warning); +'use strict'; +exports.__esModule = true; +exports.extractPath = extractPath; +exports.parsePath = parsePath; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _warning = require('warning'); + +var _warning2 = _interopRequireDefault(_warning); + +function extractPath(string) { + var match = string.match(/^https?:\/\/[^\/]*/); + + if (match == null) return string; + + return string.substring(match[0].length); +} + +function parsePath(path) { + var pathname = extractPath(path); + var search = ''; + var hash = ''; + + process.env.NODE_ENV !== 'production' ? _warning2['default'](path === pathname, 'A path must be pathname + search + hash only, not a fully qualified URL like "%s"', path) : undefined; + + var hashIndex = pathname.indexOf('#'); + if (hashIndex !== -1) { + hash = pathname.substring(hashIndex); + pathname = pathname.substring(0, hashIndex); + } + + var searchIndex = pathname.indexOf('?'); + if (searchIndex !== -1) { + search = pathname.substring(searchIndex); + pathname = pathname.substring(0, searchIndex); + } + + if (pathname === '') pathname = '/'; + + return { + pathname: pathname, + search: search, + hash: hash + }; +} }).call(this,require('_process')) -},{"_process":32,"warning":250}],12:[function(require,module,exports){ +},{"_process":33,"warning":249}],12:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{"default":t}}function createBrowserHistory(){function t(t){try{t=t||window.history.state||{}}catch(e){t={}}var r=_DOMUtils.getWindowPath(),n=t,i=n.key,o=void 0;i?o=_DOMStateStorage.readState(i):(o=null,i=_.createKey(),c&&window.history.replaceState(_extends({},t,{key:i}),null));var a=_PathUtils.parsePath(r);return _.createLocation(_extends({},a,{state:o}),void 0,i)}function e(e){function r(e){void 0!==e.state&&n(t(e.state))}var n=e.transitionTo;return _DOMUtils.addEventListener(window,"popstate",r),function(){_DOMUtils.removeEventListener(window,"popstate",r)}}function r(t){var e=t.basename,r=t.pathname,n=t.search,i=t.hash,o=t.state,a=t.action,s=t.key;if(a!==_Actions.POP){_DOMStateStorage.saveState(s,o);var u=(e||"")+r+n+i,c={key:s};if(a===_Actions.PUSH){if(l)return window.location.href=u,!1;window.history.pushState(c,null,u)}else{if(l)return window.location.replace(u),!1;window.history.replaceState(c,null,u)}}}function n(t){1===++f&&(v=e(_));var r=_.listenBefore(t);return function(){r(),0===--f&&v()}}function i(t){1===++f&&(v=e(_));var r=_.listen(t);return function(){r(),0===--f&&v()}}function o(t){1===++f&&(v=e(_)),_.registerTransitionHook(t)}function a(t){_.unregisterTransitionHook(t),0===--f&&v()}var s=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];_ExecutionEnvironment.canUseDOM?void 0:"production"!==process.env.NODE_ENV?_invariant2["default"](!1,"Browser history needs a DOM"):_invariant2["default"](!1);var u=s.forceRefresh,c=_DOMUtils.supportsHistory(),l=!c||u,_=_createDOMHistory2["default"](_extends({},s,{getCurrentLocation:t,finishTransition:r,saveState:_DOMStateStorage.saveState})),f=0,v=void 0;return _extends({},_,{listenBefore:n,listen:i,registerTransitionHook:o,unregisterTransitionHook:a})}exports.__esModule=!0;var _extends=Object.assign||function(t){for(var e=1;e=0&&t=0&&f= 0 and < %s, was %s",c.length,f):_invariant2["default"](!1);var _=createStateStorage(c);return s}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;t= 0 && current < entries.length) ? process.env.NODE_ENV !== 'production' ? _invariant2['default'](false, 'Current index must be >= 0 and < %s, was %s', entries.length, current) : _invariant2['default'](false) : undefined; + } + + var storage = createStateStorage(entries); + + function saveState(key, state) { + storage[key] = state; + } + + function readState(key) { + return storage[key]; + } + + function getCurrentLocation() { + var entry = entries[current]; + var basename = entry.basename; + var pathname = entry.pathname; + var search = entry.search; + + var path = (basename || '') + pathname + (search || ''); + + var key = undefined, + state = undefined; + if (entry.key) { + key = entry.key; + state = readState(key); + } else { + key = history.createKey(); + state = null; + entry.key = key; + } + + var location = _PathUtils.parsePath(path); + + return history.createLocation(_extends({}, location, { state: state }), undefined, key); + } + + function canGo(n) { + var index = current + n; + return index >= 0 && index < entries.length; + } + + function go(n) { + if (n) { + if (!canGo(n)) { + process.env.NODE_ENV !== 'production' ? _warning2['default'](false, 'Cannot go(%s) there is not enough history', n) : undefined; + return; + } + + current += n; + + var currentLocation = getCurrentLocation(); + + // change action to POP + history.transitionTo(_extends({}, currentLocation, { action: _Actions.POP })); + } + } + + function finishTransition(location) { + switch (location.action) { + case _Actions.PUSH: + current += 1; + + // if we are not on the top of stack + // remove rest and push new + if (current < entries.length) entries.splice(current); + + entries.push(location); + saveState(location.key, location.state); + break; + case _Actions.REPLACE: + entries[current] = location; + saveState(location.key, location.state); + break; + } + } + + return history; +} + +exports['default'] = createMemoryHistory; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./Actions":6,"./PathUtils":11,"./createHistory":15,"_process":32,"invariant":23,"warning":250}],18:[function(require,module,exports){ +},{"./Actions":6,"./PathUtils":11,"./createHistory":15,"_process":33,"invariant":23,"warning":249}],18:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function deprecate(e,r){return function(){return"production"!==process.env.NODE_ENV?_warning2["default"](!1,"[history] "+r):void 0,e.apply(this,arguments)}}exports.__esModule=!0;var _warning=require("warning"),_warning2=_interopRequireDefault(_warning);exports["default"]=deprecate,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _warning = require('warning'); + +var _warning2 = _interopRequireDefault(_warning); + +function deprecate(fn, message) { + return function () { + process.env.NODE_ENV !== 'production' ? _warning2['default'](false, '[history] ' + message) : undefined; + return fn.apply(this, arguments); + }; +} + +exports['default'] = deprecate; +module.exports = exports['default']; }).call(this,require('_process')) -},{"_process":32,"warning":250}],19:[function(require,module,exports){ +},{"_process":33,"warning":249}],19:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(n){return n&&n.__esModule?n:{"default":n}}function runTransitionHook(n,e,r){var t=n(e,r);n.length<2?r(t):"production"!==process.env.NODE_ENV?_warning2["default"](void 0===t,'You should not "return" in a transition hook with a callback argument; call the callback instead'):void 0}exports.__esModule=!0;var _warning=require("warning"),_warning2=_interopRequireDefault(_warning);exports["default"]=runTransitionHook,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _warning = require('warning'); + +var _warning2 = _interopRequireDefault(_warning); + +function runTransitionHook(hook, location, callback) { + var result = hook(location, callback); + + if (hook.length < 2) { + // Assume the hook runs synchronously and automatically + // call the callback with the return value. + callback(result); + } else { + process.env.NODE_ENV !== 'production' ? _warning2['default'](result === undefined, 'You should not "return" in a transition hook with a callback argument; call the callback instead') : undefined; + } +} + +exports['default'] = runTransitionHook; +module.exports = exports['default']; }).call(this,require('_process')) -},{"_process":32,"warning":250}],20:[function(require,module,exports){ +},{"_process":33,"warning":249}],20:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function useBasename(e){return function(){function t(){if(!m){if(null==_&&_ExecutionEnvironment.canUseDOM){var e=document.getElementsByTagName("base")[0],t=e&&e.getAttribute("href");null!=t&&(_=t,"production"!==process.env.NODE_ENV?_warning2["default"](!1,"Automatically setting basename using is deprecated and will be removed in the next major release. The semantics of are subtly different from basename. Please pass the basename explicitly in the options to createHistory"):void 0)}m=!0}}function n(e){return t(),_&&null==e.basename&&(0===e.pathname.indexOf(_)?(e.pathname=e.pathname.substring(_.length),e.basename=_,""===e.pathname&&(e.pathname="/")):e.basename=""),e}function a(e){if(t(),!_)return e;"string"==typeof e&&(e=_PathUtils.parsePath(e));var n=e.pathname,a="/"===_.slice(-1)?_:_+"/",r="/"===n.charAt(0)?n.slice(1):n,i=a+r;return _extends({},e,{pathname:i})}function r(e){return h.listenBefore(function(t,a){_runTransitionHook2["default"](e,n(t),a)})}function i(e){return h.listen(function(t){e(n(t))})}function s(e){h.push(a(e))}function o(e){h.replace(a(e))}function u(e){return h.createPath(a(e))}function c(e){return h.createHref(a(e))}function l(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;t>i;i++)r[i-1]=arguments[i];return n(h.createLocation.apply(h,[a(e)].concat(r)))}function f(e,t){"string"==typeof t&&(t=_PathUtils.parsePath(t)),s(_extends({state:e},t))}function p(e,t){"string"==typeof t&&(t=_PathUtils.parsePath(t)),o(_extends({state:e},t))}var d=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],h=e(d),_=d.basename,m=!1;return _extends({},h,{listenBefore:r,listen:i,push:s,replace:o,createPath:u,createHref:c,createLocation:l,pushState:_deprecate2["default"](f,"pushState is deprecated; use push instead"),replaceState:_deprecate2["default"](p,"replaceState is deprecated; use replace instead")})}}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;t in HTML + // documents as basename if it's not explicitly given. + if (basename == null && _ExecutionEnvironment.canUseDOM) { + var base = document.getElementsByTagName('base')[0]; + var baseHref = base && base.getAttribute('href'); + + if (baseHref != null) { + basename = baseHref; + + process.env.NODE_ENV !== 'production' ? _warning2['default'](false, 'Automatically setting basename using is deprecated and will ' + 'be removed in the next major release. The semantics of are ' + 'subtly different from basename. Please pass the basename explicitly in ' + 'the options to createHistory') : undefined; + } + } + + checkedBaseHref = true; + } + + function addBasename(location) { + checkBaseHref(); + + if (basename && location.basename == null) { + if (location.pathname.indexOf(basename) === 0) { + location.pathname = location.pathname.substring(basename.length); + location.basename = basename; + + if (location.pathname === '') location.pathname = '/'; + } else { + location.basename = ''; + } + } + + return location; + } + + function prependBasename(location) { + checkBaseHref(); + + if (!basename) return location; + + if (typeof location === 'string') location = _PathUtils.parsePath(location); + + var pname = location.pathname; + var normalizedBasename = basename.slice(-1) === '/' ? basename : basename + '/'; + var normalizedPathname = pname.charAt(0) === '/' ? pname.slice(1) : pname; + var pathname = normalizedBasename + normalizedPathname; + + return _extends({}, location, { + pathname: pathname + }); + } + + // Override all read methods with basename-aware versions. + function listenBefore(hook) { + return history.listenBefore(function (location, callback) { + _runTransitionHook2['default'](hook, addBasename(location), callback); + }); + } + + function listen(listener) { + return history.listen(function (location) { + listener(addBasename(location)); + }); + } + + // Override all write methods with basename-aware versions. + function push(location) { + history.push(prependBasename(location)); + } + + function replace(location) { + history.replace(prependBasename(location)); + } + + function createPath(location) { + return history.createPath(prependBasename(location)); + } + + function createHref(location) { + return history.createHref(prependBasename(location)); + } + + function createLocation(location) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return addBasename(history.createLocation.apply(history, [prependBasename(location)].concat(args))); + } + + // deprecated + function pushState(state, path) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + push(_extends({ state: state }, path)); + } + + // deprecated + function replaceState(state, path) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + replace(_extends({ state: state }, path)); + } + + return _extends({}, history, { + listenBefore: listenBefore, + listen: listen, + push: push, + replace: replace, + createPath: createPath, + createHref: createHref, + createLocation: createLocation, + + pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), + replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') + }); + }; +} + +exports['default'] = useBasename; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./ExecutionEnvironment":10,"./PathUtils":11,"./deprecate":18,"./runTransitionHook":19,"_process":32,"warning":250}],21:[function(require,module,exports){ +},{"./ExecutionEnvironment":10,"./PathUtils":11,"./deprecate":18,"./runTransitionHook":19,"_process":33,"warning":249}],21:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function defaultStringifyQuery(e){return _queryString.stringify(e).replace(/%20/g,"+")}function isNestedObject(e){for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&"object"==typeof e[r]&&!Array.isArray(e[r])&&null!==e[r])return!0;return!1}function useQueries(e){return function(){function r(e){if(null==e.query){var r=e.search;e.query=_(r.substring(1)),e[SEARCH_BASE_KEY]={search:r,searchBase:""}}return e}function t(e,r){var t,n=e[SEARCH_BASE_KEY],a=r?y(r):"";if(!n&&!a)return e;"production"!==process.env.NODE_ENV?_warning2["default"](y!==defaultStringifyQuery||!isNestedObject(r),"useQueries does not stringify nested query objects by default; use a custom stringifyQuery function"):void 0,"string"==typeof e&&(e=_PathUtils.parsePath(e));var u=void 0;u=n&&e.search===n.search?n.searchBase:e.search||"";var i=u;return a&&(i+=(i?"&":"?")+a),_extends({},e,(t={search:i},t[SEARCH_BASE_KEY]={search:i,searchBase:u},t))}function n(e){return l.listenBefore(function(t,n){_runTransitionHook2["default"](e,r(t),n)})}function a(e){return l.listen(function(t){e(r(t))})}function u(e){l.push(t(e,e.query))}function i(e){l.replace(t(e,e.query))}function s(e,r){return"production"!==process.env.NODE_ENV?_warning2["default"](!r,"the query argument to createPath is deprecated; use a location descriptor instead"):void 0,l.createPath(t(e,r||e.query))}function o(e,r){return"production"!==process.env.NODE_ENV?_warning2["default"](!r,"the query argument to createHref is deprecated; use a location descriptor instead"):void 0,l.createHref(t(e,r||e.query))}function c(e){for(var n=arguments.length,a=Array(n>1?n-1:0),u=1;n>u;u++)a[u-1]=arguments[u];var i=l.createLocation.apply(l,[t(e,e.query)].concat(a));return e.query&&(i.query=e.query),r(i)}function f(e,r,t){"string"==typeof r&&(r=_PathUtils.parsePath(r)),u(_extends({state:e},r,{query:t}))}function p(e,r,t){"string"==typeof r&&(r=_PathUtils.parsePath(r)),i(_extends({state:e},r,{query:t}))}var d=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],l=e(d),y=d.stringifyQuery,_=d.parseQueryString;return"function"!=typeof y&&(y=defaultStringifyQuery),"function"!=typeof _&&(_=defaultParseQueryString),_extends({},l,{listenBefore:n,listen:a,push:u,replace:i,createPath:s,createHref:o,createLocation:c,pushState:_deprecate2["default"](f,"pushState is deprecated; use push instead"),replaceState:_deprecate2["default"](p,"replaceState is deprecated; use replace instead")})}}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var r=1;r 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var fullLocation = history.createLocation.apply(history, [appendQuery(location, location.query)].concat(args)); + if (location.query) { + fullLocation.query = location.query; + } + return addQuery(fullLocation); + } + + // deprecated + function pushState(state, path, query) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + push(_extends({ state: state }, path, { query: query })); + } + + // deprecated + function replaceState(state, path, query) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + replace(_extends({ state: state }, path, { query: query })); + } + + return _extends({}, history, { + listenBefore: listenBefore, + listen: listen, + push: push, + replace: replace, + createPath: createPath, + createHref: createHref, + createLocation: createLocation, + + pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), + replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') + }); + }; +} + +exports['default'] = useQueries; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./PathUtils":11,"./deprecate":18,"./runTransitionHook":19,"_process":32,"query-string":33,"warning":250}],22:[function(require,module,exports){ -"use strict";var REACT_STATICS={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},KNOWN_STATICS={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0};module.exports=function(t,e){if("string"!=typeof e)for(var r=Object.getOwnPropertyNames(e),p=0;p + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.3 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ + +/** `Object#toString` result references. */ +var funcTag = '[object Function]'; + +/** Used to detect host constructors (Safari > 5). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** + * Checks if `value` is object-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + */ +function isObjectLike(value) { + return !!value && typeof value == 'object'; +} + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var fnToString = Function.prototype.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; +} + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 equivalents which return 'object' for typed array constructors. + return isObject(value) && objToString.call(value) == funcTag; +} + +/** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(1); + * // => false + */ +function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); +} + +/** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ +function isNative(value) { + if (value == null) { + return false; + } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && reIsHostCtor.test(value); +} + +module.exports = getNative; },{}],25:[function(require,module,exports){ -function baseProperty(t){return function(e){return null==e?void 0:e[t]}}function isArguments(t){return isArrayLikeObject(t)&&hasOwnProperty.call(t,"callee")&&(!propertyIsEnumerable.call(t,"callee")||objectToString.call(t)==argsTag)}function isArrayLike(t){return null!=t&&isLength(getLength(t))&&!isFunction(t)}function isArrayLikeObject(t){return isObjectLike(t)&&isArrayLike(t)}function isFunction(t){var e=isObject(t)?objectToString.call(t):"";return e==funcTag||e==genTag}function isLength(t){return"number"==typeof t&&t>-1&&t%1==0&&MAX_SAFE_INTEGER>=t}function isObject(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function isObjectLike(t){return!!t&&"object"==typeof t}var MAX_SAFE_INTEGER=9007199254740991,argsTag="[object Arguments]",funcTag="[object Function]",genTag="[object GeneratorFunction]",objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,objectToString=objectProto.toString,propertyIsEnumerable=objectProto.propertyIsEnumerable,getLength=baseProperty("length");module.exports=isArguments; +/** + * lodash 3.0.8 (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright 2012-2016 The Dojo Foundation + * Based on Underscore.js 1.8.3 + * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]'; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objectToString = objectProto.toString; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable; + +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} + +/** + * Gets the "length" property value of `object`. + * + * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) + * that affects Safari on at least iOS 8.1-8.3 ARM64. + * + * @private + * @param {Object} object The object to query. + * @returns {*} Returns the "length" value. + */ +var getLength = baseProperty('length'); + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +function isArguments(value) { + // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. + return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && + (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); +} + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(getLength(value)) && !isFunction(value); +} + +/** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ +function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); +} + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 8 which returns 'object' for typed array and weak map constructors, + // and PhantomJS 1.9 which returns 'function' for `NodeList` instances. + var tag = isObject(value) ? objectToString.call(value) : ''; + return tag == funcTag || tag == genTag; +} + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +/** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return !!value && typeof value == 'object'; +} + +module.exports = isArguments; },{}],26:[function(require,module,exports){ -function isObjectLike(t){return!!t&&"object"==typeof t}function getNative(t,r){var e=null==t?void 0:t[r];return isNative(e)?e:void 0}function isLength(t){return"number"==typeof t&&t>-1&&t%1==0&&MAX_SAFE_INTEGER>=t}function isFunction(t){return isObject(t)&&objToString.call(t)==funcTag}function isObject(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}function isNative(t){return null==t?!1:isFunction(t)?reIsNative.test(fnToString.call(t)):isObjectLike(t)&&reIsHostCtor.test(t)}var arrayTag="[object Array]",funcTag="[object Function]",reIsHostCtor=/^\[object .+?Constructor\]$/,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nativeIsArray=getNative(Array,"isArray"),MAX_SAFE_INTEGER=9007199254740991,isArray=nativeIsArray||function(t){return isObjectLike(t)&&isLength(t.length)&&objToString.call(t)==arrayTag};module.exports=isArray; +/** + * lodash 3.0.4 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.3 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ + +/** `Object#toString` result references. */ +var arrayTag = '[object Array]', + funcTag = '[object Function]'; + +/** Used to detect host constructors (Safari > 5). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** + * Checks if `value` is object-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + */ +function isObjectLike(value) { + return !!value && typeof value == 'object'; +} + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var fnToString = Function.prototype.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsArray = getNative(Array, 'isArray'); + +/** + * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) + * of an array-like value. + */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; +} + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + */ +function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(function() { return arguments; }()); + * // => false + */ +var isArray = nativeIsArray || function(value) { + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; +}; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 equivalents which return 'object' for typed array constructors. + return isObject(value) && objToString.call(value) == funcTag; +} + +/** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(1); + * // => false + */ +function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); +} + +/** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ +function isNative(value) { + if (value == null) { + return false; + } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && reIsHostCtor.test(value); +} + +module.exports = isArray; },{}],27:[function(require,module,exports){ -function baseProperty(e){return function(t){return null==t?void 0:t[e]}}function isArrayLike(e){return null!=e&&isLength(getLength(e))}function isIndex(e,t){return e="number"==typeof e||reIsUint.test(e)?+e:-1,t=null==t?MAX_SAFE_INTEGER:t,e>-1&&e%1==0&&t>e}function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&MAX_SAFE_INTEGER>=e}function shimKeys(e){for(var t=keysIn(e),r=t.length,n=r&&e.length,s=!!n&&isLength(n)&&(isArray(e)||isArguments(e)),o=-1,i=[];++o0;++n + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.3 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var getNative = require('lodash._getnative'), + isArguments = require('lodash.isarguments'), + isArray = require('lodash.isarray'); + +/** Used to detect unsigned integer values. */ +var reIsUint = /^\d+$/; + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeKeys = getNative(Object, 'keys'); + +/** + * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) + * of an array-like value. + */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} + +/** + * Gets the "length" property value of `object`. + * + * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) + * that affects Safari on at least iOS 8.1-8.3 ARM64. + * + * @private + * @param {Object} object The object to query. + * @returns {*} Returns the "length" value. + */ +var getLength = baseProperty('length'); + +/** + * Checks if `value` is array-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + */ +function isArrayLike(value) { + return value != null && isLength(getLength(value)); +} + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; +} + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + */ +function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +/** + * A fallback implementation of `Object.keys` which creates an array of the + * own enumerable property names of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function shimKeys(object) { + var props = keysIn(object), + propsLength = props.length, + length = propsLength && object.length; + + var allowIndexes = !!length && isLength(length) && + (isArray(object) || isArguments(object)); + + var index = -1, + result = []; + + while (++index < propsLength) { + var key = props[index]; + if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { + result.push(key); + } + } + return result; +} + +/** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(1); + * // => false + */ +function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); +} + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) + * for more details. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +var keys = !nativeKeys ? shimKeys : function(object) { + var Ctor = object == null ? undefined : object.constructor; + if ((typeof Ctor == 'function' && Ctor.prototype === object) || + (typeof object != 'function' && isArrayLike(object))) { + return shimKeys(object); + } + return isObject(object) ? nativeKeys(object) : []; +}; + +/** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ +function keysIn(object) { + if (object == null) { + return []; + } + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + length = (length && isLength(length) && + (isArray(object) || isArguments(object)) && length) || 0; + + var Ctor = object.constructor, + index = -1, + isProto = typeof Ctor == 'function' && Ctor.prototype === object, + result = Array(length), + skipIndexes = length > 0; + + while (++index < length) { + result[index] = (index + ''); + } + for (var key in object) { + if (!(skipIndexes && isIndex(key, length)) && + !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + return result; +} + +module.exports = keys; },{"lodash._getnative":24,"lodash.isarguments":25,"lodash.isarray":26}],28:[function(require,module,exports){ -function getPrototype(t){return nativeGetPrototype(Object(t))}var nativeGetPrototype=Object.getPrototypeOf;module.exports=getPrototype; +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetPrototype = Object.getPrototypeOf; + +/** + * Gets the `[[Prototype]]` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {null|Object} Returns the `[[Prototype]]`. + */ +function getPrototype(value) { + return nativeGetPrototype(Object(value)); +} + +module.exports = getPrototype; },{}],29:[function(require,module,exports){ -function isHostObject(t){var o=!1;if(null!=t&&"function"!=typeof t.toString)try{o=!!(t+"")}catch(n){}return o}module.exports=isHostObject; +/** + * Checks if `value` is a host object in IE < 9. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + */ +function isHostObject(value) { + // Many host objects are `Object` objects that can coerce to strings + // despite having improperly defined `toString` methods. + var result = false; + if (value != null && typeof value.toString != 'function') { + try { + result = !!(value + ''); + } catch (e) {} + } + return result; +} + +module.exports = isHostObject; },{}],30:[function(require,module,exports){ -function isObjectLike(e){return!!e&&"object"==typeof e}module.exports=isObjectLike; +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return !!value && typeof value == 'object'; +} + +module.exports = isObjectLike; },{}],31:[function(require,module,exports){ -function isPlainObject(t){if(!isObjectLike(t)||objectToString.call(t)!=objectTag||isHostObject(t))return!1;var o=getPrototype(t);if(null===o)return!0;var e=hasOwnProperty.call(o,"constructor")&&o.constructor;return"function"==typeof e&&e instanceof e&&funcToString.call(e)==objectCtorString}var getPrototype=require("./_getPrototype"),isHostObject=require("./_isHostObject"),isObjectLike=require("./isObjectLike"),objectTag="[object Object]",objectProto=Object.prototype,funcToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objectCtorString=funcToString.call(Object),objectToString=objectProto.toString;module.exports=isPlainObject; +var getPrototype = require('./_getPrototype'), + isHostObject = require('./_isHostObject'), + isObjectLike = require('./isObjectLike'); + +/** `Object#toString` result references. */ +var objectTag = '[object Object]'; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = Function.prototype.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString.call(Object); + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objectToString = objectProto.toString; + +/** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, + * else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ +function isPlainObject(value) { + if (!isObjectLike(value) || + objectToString.call(value) != objectTag || isHostObject(value)) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; + return (typeof Ctor == 'function' && + Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); +} + +module.exports = isPlainObject; },{"./_getPrototype":28,"./_isHostObject":29,"./isObjectLike":30}],32:[function(require,module,exports){ -function cleanUpNextTick(){draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue()}function drainQueue(){if(!draining){var e=setTimeout(cleanUpNextTick);draining=!0;for(var n=queue.length;n;){for(currentQueue=queue,queue=[];++queueIndex1)for(var r=1;r 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + cachedSetTimeout(drainQueue, 0); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],34:[function(require,module,exports){ +'use strict'; +var strictUriEncode = require('strict-uri-encode'); + +exports.extract = function (str) { + return str.split('?')[1] || ''; +}; + +exports.parse = function (str) { + if (typeof str !== 'string') { + return {}; + } + + str = str.trim().replace(/^(\?|#|&)/, ''); + + if (!str) { + return {}; + } + + return str.split('&').reduce(function (ret, param) { + var parts = param.replace(/\+/g, ' ').split('='); + // Firefox (pre 40) decodes `%3D` to `=` + // https://github.com/sindresorhus/query-string/pull/37 + var key = parts.shift(); + var val = parts.length > 0 ? parts.join('=') : undefined; + + key = decodeURIComponent(key); + + // missing `=` should be `null`: + // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters + val = val === undefined ? null : decodeURIComponent(val); + + if (!ret.hasOwnProperty(key)) { + ret[key] = val; + } else if (Array.isArray(ret[key])) { + ret[key].push(val); + } else { + ret[key] = [ret[key], val]; + } + + return ret; + }, {}); +}; + +exports.stringify = function (obj) { + return obj ? Object.keys(obj).sort().map(function (key) { + var val = obj[key]; + + if (val === undefined) { + return ''; + } + + if (val === null) { + return key; + } + + if (Array.isArray(val)) { + return val.slice().sort().map(function (val2) { + return strictUriEncode(key) + '=' + strictUriEncode(val2); + }).join('&'); + } + + return strictUriEncode(key) + '=' + strictUriEncode(val); + }).filter(function (x) { + return x.length > 0; + }).join('&') : ''; +}; + +},{"strict-uri-encode":246}],35:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function warnAboutReceivingStore(){didWarnAboutReceivingStore||(didWarnAboutReceivingStore=!0,(0,_warning2["default"])(" does not support changing `store` on the fly. It is most likely that you see this error because you updated to Redux 2.x and React Redux 2.x which no longer hot reload reducers automatically. See https://github.com/reactjs/react-redux/releases/tag/v2.0.0 for the migration instructions."))}exports.__esModule=!0,exports["default"]=void 0;var _react=require("react"),_storeShape=require("../utils/storeShape"),_storeShape2=_interopRequireDefault(_storeShape),_warning=require("../utils/warning"),_warning2=_interopRequireDefault(_warning),didWarnAboutReceivingStore=!1,Provider=function(e){function t(r,o){_classCallCheck(this,t);var n=_possibleConstructorReturn(this,e.call(this,r,o));return n.store=r.store,n}return _inherits(t,e),t.prototype.getChildContext=function(){return{store:this.store}},t.prototype.render=function(){var e=this.props.children;return _react.Children.only(e)},t}(_react.Component);exports["default"]=Provider,"production"!==process.env.NODE_ENV&&(Provider.prototype.componentWillReceiveProps=function(e){var t=this.store,r=e.store;t!==r&&warnAboutReceivingStore()}),Provider.propTypes={store:_storeShape2["default"].isRequired,children:_react.PropTypes.element.isRequired},Provider.childContextTypes={store:_storeShape2["default"].isRequired}; +'use strict'; +exports.__esModule = true; +exports["default"] = undefined; + +var _react = require('react'); + +var _storeShape = require('../utils/storeShape'); + +var _storeShape2 = _interopRequireDefault(_storeShape); + +var _warning = require('../utils/warning'); + +var _warning2 = _interopRequireDefault(_warning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var didWarnAboutReceivingStore = false; +function warnAboutReceivingStore() { + if (didWarnAboutReceivingStore) { + return; + } + didWarnAboutReceivingStore = true; + + (0, _warning2["default"])(' does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reactjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.'); +} + +var Provider = function (_Component) { + _inherits(Provider, _Component); + + Provider.prototype.getChildContext = function getChildContext() { + return { store: this.store }; + }; + + function Provider(props, context) { + _classCallCheck(this, Provider); + + var _this = _possibleConstructorReturn(this, _Component.call(this, props, context)); + + _this.store = props.store; + return _this; + } + + Provider.prototype.render = function render() { + var children = this.props.children; + + return _react.Children.only(children); + }; + + return Provider; +}(_react.Component); + +exports["default"] = Provider; + +if (process.env.NODE_ENV !== 'production') { + Provider.prototype.componentWillReceiveProps = function (nextProps) { + var store = this.store; + var nextStore = nextProps.store; + + if (store !== nextStore) { + warnAboutReceivingStore(); + } + }; +} + +Provider.propTypes = { + store: _storeShape2["default"].isRequired, + children: _react.PropTypes.element.isRequired +}; +Provider.childContextTypes = { + store: _storeShape2["default"].isRequired +}; }).call(this,require('_process')) -},{"../utils/storeShape":37,"../utils/warning":38,"_process":32,"react":"react"}],35:[function(require,module,exports){ +},{"../utils/storeShape":38,"../utils/warning":39,"_process":33,"react":"react"}],36:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{"default":t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function getDisplayName(t){return t.displayName||t.name||"Component"}function tryCatch(t,e){try{return t.apply(e)}catch(r){return errorObject.value=r,errorObject}}function connect(t,e,r){var o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],s=Boolean(t),a=t||defaultMapStateToProps,n=void 0;n="function"==typeof e?e:e?(0,_wrapActionCreators2["default"])(e):defaultMapDispatchToProps;var i=r||defaultMergeProps,p=o.pure,u=void 0===p?!0:p,c=o.withRef,h=void 0===c?!1:c,l=u&&i!==defaultMergeProps,d=nextVersion++;return function(t){function e(t,e){(0,_isPlainObject2["default"])(t)||(0,_warning2["default"])(e+"() in "+o+" must return a plain object. "+("Instead received "+t+"."))}function r(t,r,o){var s=i(t,r,o);return"production"!==process.env.NODE_ENV&&e(s,"mergeProps"),s}var o="Connect("+getDisplayName(t)+")",p=function(i){function p(t,e){_classCallCheck(this,p);var r=_possibleConstructorReturn(this,i.call(this,t,e));r.version=d,r.store=t.store||e.store,(0,_invariant2["default"])(r.store,'Could not find "store" in either the context or '+('props of "'+o+'". ')+"Either wrap the root component in a , "+('or explicitly pass "store" as a prop to "'+o+'".'));var s=r.store.getState();return r.state={storeState:s},r.clearCache(),r}return _inherits(p,i),p.prototype.shouldComponentUpdate=function(){return!u||this.haveOwnPropsChanged||this.hasStoreStateChanged},p.prototype.computeStateProps=function(t,r){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,r);var o=t.getState(),s=this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(o,r):this.finalMapStateToProps(o);return"production"!==process.env.NODE_ENV&&e(s,"mapStateToProps"),s},p.prototype.configureFinalMapState=function(t,r){var o=a(t.getState(),r),s="function"==typeof o;return this.finalMapStateToProps=s?o:a,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,s?this.computeStateProps(t,r):("production"!==process.env.NODE_ENV&&e(o,"mapStateToProps"),o)},p.prototype.computeDispatchProps=function(t,r){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,r);var o=t.dispatch,s=this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(o,r):this.finalMapDispatchToProps(o);return"production"!==process.env.NODE_ENV&&e(s,"mapDispatchToProps"),s},p.prototype.configureFinalMapDispatch=function(t,r){var o=n(t.dispatch,r),s="function"==typeof o;return this.finalMapDispatchToProps=s?o:n,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,s?this.computeDispatchProps(t,r):("production"!==process.env.NODE_ENV&&e(o,"mapDispatchToProps"),o)},p.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return this.stateProps&&(0,_shallowEqual2["default"])(t,this.stateProps)?!1:(this.stateProps=t,!0)},p.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return this.dispatchProps&&(0,_shallowEqual2["default"])(t,this.dispatchProps)?!1:(this.dispatchProps=t,!0)},p.prototype.updateMergedPropsIfNeeded=function(){var t=r(this.stateProps,this.dispatchProps,this.props);return this.mergedProps&&l&&(0,_shallowEqual2["default"])(t,this.mergedProps)?!1:(this.mergedProps=t,!0)},p.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},p.prototype.trySubscribe=function(){s&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},p.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},p.prototype.componentDidMount=function(){this.trySubscribe()},p.prototype.componentWillReceiveProps=function(t){u&&(0,_shallowEqual2["default"])(t,this.props)||(this.haveOwnPropsChanged=!0)},p.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},p.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},p.prototype.handleChange=function(){if(this.unsubscribe){var t=this.store.getState(),e=this.state.storeState;if(!u||e!==t){if(u&&!this.doStatePropsDependOnOwnProps){var r=tryCatch(this.updateStatePropsIfNeeded,this);if(!r)return;r===errorObject&&(this.statePropsPrecalculationError=errorObject.value),this.haveStatePropsBeenPrecalculated=!0}this.hasStoreStateChanged=!0,this.setState({storeState:t})}}},p.prototype.getWrappedInstance=function(){return(0,_invariant2["default"])(h,"To access the wrapped instance, you need to specify { withRef: true } as the fourth argument of the connect() call."),this.refs.wrappedInstance},p.prototype.render=function(){var e=this.haveOwnPropsChanged,r=this.hasStoreStateChanged,o=this.haveStatePropsBeenPrecalculated,s=this.statePropsPrecalculationError,a=this.renderedElement;if(this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,s)throw s;var n=!0,i=!0;u&&a&&(n=r||e&&this.doStatePropsDependOnOwnProps,i=e&&this.doDispatchPropsDependOnOwnProps);var p=!1,c=!1;o?p=!0:n&&(p=this.updateStatePropsIfNeeded()),i&&(c=this.updateDispatchPropsIfNeeded());var l=!0;return l=p||c||e?this.updateMergedPropsIfNeeded():!1,!l&&a?a:(h?this.renderedElement=(0,_react.createElement)(t,_extends({},this.mergedProps,{ref:"wrappedInstance"})):this.renderedElement=(0,_react.createElement)(t,this.mergedProps),this.renderedElement)},p}(_react.Component);return p.displayName=o,p.WrappedComponent=t,p.contextTypes={store:_storeShape2["default"]},p.propTypes={store:_storeShape2["default"]},"production"!==process.env.NODE_ENV&&(p.prototype.componentWillUpdate=function(){this.version!==d&&(this.version=d,this.trySubscribe(),this.clearCache())}),(0,_hoistNonReactStatics2["default"])(p,t)}}var _extends=Object.assign||function(t){for(var e=1;e, ' + ('or explicitly pass "store" as a prop to "' + connectDisplayName + '".')); + + var storeState = _this.store.getState(); + _this.state = { storeState: storeState }; + _this.clearCache(); + return _this; + } + + Connect.prototype.computeStateProps = function computeStateProps(store, props) { + if (!this.finalMapStateToProps) { + return this.configureFinalMapState(store, props); + } + + var state = store.getState(); + var stateProps = this.doStatePropsDependOnOwnProps ? this.finalMapStateToProps(state, props) : this.finalMapStateToProps(state); + + if (process.env.NODE_ENV !== 'production') { + checkStateShape(stateProps, 'mapStateToProps'); + } + return stateProps; + }; + + Connect.prototype.configureFinalMapState = function configureFinalMapState(store, props) { + var mappedState = mapState(store.getState(), props); + var isFactory = typeof mappedState === 'function'; + + this.finalMapStateToProps = isFactory ? mappedState : mapState; + this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1; + + if (isFactory) { + return this.computeStateProps(store, props); + } + + if (process.env.NODE_ENV !== 'production') { + checkStateShape(mappedState, 'mapStateToProps'); + } + return mappedState; + }; + + Connect.prototype.computeDispatchProps = function computeDispatchProps(store, props) { + if (!this.finalMapDispatchToProps) { + return this.configureFinalMapDispatch(store, props); + } + + var dispatch = store.dispatch; + + var dispatchProps = this.doDispatchPropsDependOnOwnProps ? this.finalMapDispatchToProps(dispatch, props) : this.finalMapDispatchToProps(dispatch); + + if (process.env.NODE_ENV !== 'production') { + checkStateShape(dispatchProps, 'mapDispatchToProps'); + } + return dispatchProps; + }; + + Connect.prototype.configureFinalMapDispatch = function configureFinalMapDispatch(store, props) { + var mappedDispatch = mapDispatch(store.dispatch, props); + var isFactory = typeof mappedDispatch === 'function'; + + this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch; + this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1; + + if (isFactory) { + return this.computeDispatchProps(store, props); + } + + if (process.env.NODE_ENV !== 'production') { + checkStateShape(mappedDispatch, 'mapDispatchToProps'); + } + return mappedDispatch; + }; + + Connect.prototype.updateStatePropsIfNeeded = function updateStatePropsIfNeeded() { + var nextStateProps = this.computeStateProps(this.store, this.props); + if (this.stateProps && (0, _shallowEqual2["default"])(nextStateProps, this.stateProps)) { + return false; + } + + this.stateProps = nextStateProps; + return true; + }; + + Connect.prototype.updateDispatchPropsIfNeeded = function updateDispatchPropsIfNeeded() { + var nextDispatchProps = this.computeDispatchProps(this.store, this.props); + if (this.dispatchProps && (0, _shallowEqual2["default"])(nextDispatchProps, this.dispatchProps)) { + return false; + } + + this.dispatchProps = nextDispatchProps; + return true; + }; + + Connect.prototype.updateMergedPropsIfNeeded = function updateMergedPropsIfNeeded() { + var nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props); + if (this.mergedProps && checkMergedEquals && (0, _shallowEqual2["default"])(nextMergedProps, this.mergedProps)) { + return false; + } + + this.mergedProps = nextMergedProps; + return true; + }; + + Connect.prototype.isSubscribed = function isSubscribed() { + return typeof this.unsubscribe === 'function'; + }; + + Connect.prototype.trySubscribe = function trySubscribe() { + if (shouldSubscribe && !this.unsubscribe) { + this.unsubscribe = this.store.subscribe(this.handleChange.bind(this)); + this.handleChange(); + } + }; + + Connect.prototype.tryUnsubscribe = function tryUnsubscribe() { + if (this.unsubscribe) { + this.unsubscribe(); + this.unsubscribe = null; + } + }; + + Connect.prototype.componentDidMount = function componentDidMount() { + this.trySubscribe(); + }; + + Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { + if (!pure || !(0, _shallowEqual2["default"])(nextProps, this.props)) { + this.haveOwnPropsChanged = true; + } + }; + + Connect.prototype.componentWillUnmount = function componentWillUnmount() { + this.tryUnsubscribe(); + this.clearCache(); + }; + + Connect.prototype.clearCache = function clearCache() { + this.dispatchProps = null; + this.stateProps = null; + this.mergedProps = null; + this.haveOwnPropsChanged = true; + this.hasStoreStateChanged = true; + this.haveStatePropsBeenPrecalculated = false; + this.statePropsPrecalculationError = null; + this.renderedElement = null; + this.finalMapDispatchToProps = null; + this.finalMapStateToProps = null; + }; + + Connect.prototype.handleChange = function handleChange() { + if (!this.unsubscribe) { + return; + } + + var storeState = this.store.getState(); + var prevStoreState = this.state.storeState; + if (pure && prevStoreState === storeState) { + return; + } + + if (pure && !this.doStatePropsDependOnOwnProps) { + var haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this); + if (!haveStatePropsChanged) { + return; + } + if (haveStatePropsChanged === errorObject) { + this.statePropsPrecalculationError = errorObject.value; + } + this.haveStatePropsBeenPrecalculated = true; + } + + this.hasStoreStateChanged = true; + this.setState({ storeState: storeState }); + }; + + Connect.prototype.getWrappedInstance = function getWrappedInstance() { + (0, _invariant2["default"])(withRef, 'To access the wrapped instance, you need to specify ' + '{ withRef: true } as the fourth argument of the connect() call.'); + + return this.refs.wrappedInstance; + }; + + Connect.prototype.render = function render() { + var haveOwnPropsChanged = this.haveOwnPropsChanged; + var hasStoreStateChanged = this.hasStoreStateChanged; + var haveStatePropsBeenPrecalculated = this.haveStatePropsBeenPrecalculated; + var statePropsPrecalculationError = this.statePropsPrecalculationError; + var renderedElement = this.renderedElement; + + this.haveOwnPropsChanged = false; + this.hasStoreStateChanged = false; + this.haveStatePropsBeenPrecalculated = false; + this.statePropsPrecalculationError = null; + + if (statePropsPrecalculationError) { + throw statePropsPrecalculationError; + } + + var shouldUpdateStateProps = true; + var shouldUpdateDispatchProps = true; + if (pure && renderedElement) { + shouldUpdateStateProps = hasStoreStateChanged || haveOwnPropsChanged && this.doStatePropsDependOnOwnProps; + shouldUpdateDispatchProps = haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps; + } + + var haveStatePropsChanged = false; + var haveDispatchPropsChanged = false; + if (haveStatePropsBeenPrecalculated) { + haveStatePropsChanged = true; + } else if (shouldUpdateStateProps) { + haveStatePropsChanged = this.updateStatePropsIfNeeded(); + } + if (shouldUpdateDispatchProps) { + haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded(); + } + + var haveMergedPropsChanged = true; + if (haveStatePropsChanged || haveDispatchPropsChanged || haveOwnPropsChanged) { + haveMergedPropsChanged = this.updateMergedPropsIfNeeded(); + } else { + haveMergedPropsChanged = false; + } + + if (!haveMergedPropsChanged && renderedElement) { + return renderedElement; + } + + if (withRef) { + this.renderedElement = (0, _react.createElement)(WrappedComponent, _extends({}, this.mergedProps, { + ref: 'wrappedInstance' + })); + } else { + this.renderedElement = (0, _react.createElement)(WrappedComponent, this.mergedProps); + } + + return this.renderedElement; + }; + + return Connect; + }(_react.Component); + + Connect.displayName = connectDisplayName; + Connect.WrappedComponent = WrappedComponent; + Connect.contextTypes = { + store: _storeShape2["default"] + }; + Connect.propTypes = { + store: _storeShape2["default"] + }; + + if (process.env.NODE_ENV !== 'production') { + Connect.prototype.componentWillUpdate = function componentWillUpdate() { + if (this.version === version) { + return; + } + + // We are hot reloading! + this.version = version; + this.trySubscribe(); + this.clearCache(); + }; + } + + return (0, _hoistNonReactStatics2["default"])(Connect, WrappedComponent); + }; +} }).call(this,require('_process')) -},{"../utils/shallowEqual":36,"../utils/storeShape":37,"../utils/warning":38,"../utils/wrapActionCreators":39,"_process":32,"hoist-non-react-statics":22,"invariant":23,"lodash/isPlainObject":31,"react":"react"}],36:[function(require,module,exports){ -"use strict";function shallowEqual(e,t){if(e===t)return!0;var r=Object.keys(e),l=Object.keys(t);if(r.length!==l.length)return!1;for(var n=Object.prototype.hasOwnProperty,o=0;or&&p;)p=!1,o.call(this,r++,i,c);return s=!1,l?void t.apply(this,u):void(r>=n&&p&&(l=!0,t()))}}var r=0,l=!1,s=!1,p=!1,u=void 0;i()}function mapAsync(n,o,t){function c(n,o,c){l||(o?(l=!0,t(o)):(r[n]=c,l=++s===i,l&&t(null,r)))}var i=n.length,r=[];if(0===i)return t(null,r);var l=!1,s=0;n.forEach(function(n,t){o(n,t,function(n,o){c(t,n,o)})})}exports.__esModule=!0,exports.loopAsync=loopAsync,exports.mapAsync=mapAsync; + // Test for A's keys different from B. + var hasOwn = Object.prototype.hasOwnProperty; + for (var i = 0; i < keysA.length; i++) { + if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { + return false; + } + } -},{}],41:[function(require,module,exports){ + return true; +} +},{}],38:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _react = require('react'); + +exports["default"] = _react.PropTypes.shape({ + subscribe: _react.PropTypes.func.isRequired, + dispatch: _react.PropTypes.func.isRequired, + getState: _react.PropTypes.func.isRequired +}); +},{"react":"react"}],39:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports["default"] = warning; +/** + * Prints a warning in the console if it exists. + * + * @param {String} message The warning message. + * @returns {void} + */ +function warning(message) { + /* eslint-disable no-console */ + if (typeof console !== 'undefined' && typeof console.error === 'function') { + console.error(message); + } + /* eslint-enable no-console */ + try { + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + /* eslint-disable no-empty */ + } catch (e) {} + /* eslint-enable no-empty */ +} +},{}],40:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports["default"] = wrapActionCreators; + +var _redux = require('redux'); + +function wrapActionCreators(actionCreators) { + return function (dispatch) { + return (0, _redux.bindActionCreators)(actionCreators, dispatch); + }; +} +},{"redux":"redux"}],41:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; +exports.loopAsync = loopAsync; +exports.mapAsync = mapAsync; +function loopAsync(turns, work, callback) { + var currentTurn = 0, + isDone = false; + var sync = false, + hasNext = false, + doneArgs = void 0; + + function done() { + isDone = true; + if (sync) { + // Iterate instead of recursing if possible. + doneArgs = [].concat(Array.prototype.slice.call(arguments)); + return; + } + + callback.apply(this, arguments); + } + + function next() { + if (isDone) { + return; + } + + hasNext = true; + if (sync) { + // Iterate instead of recursing if possible. + return; + } + + sync = true; + + while (!isDone && currentTurn < turns && hasNext) { + hasNext = false; + work.call(this, currentTurn++, next, done); + } + + sync = false; + + if (isDone) { + // This means the loop finished synchronously. + callback.apply(this, doneArgs); + return; + } + + if (currentTurn >= turns && hasNext) { + isDone = true; + callback(); + } + } + + next(); +} + +function mapAsync(array, work, callback) { + var length = array.length; + var values = []; + + if (length === 0) return callback(null, values); + + var isDone = false, + doneCount = 0; + + function done(index, error, value) { + if (isDone) return; + + if (error) { + isDone = true; + callback(error); + } else { + values[index] = value; + + isDone = ++doneCount === length; + + if (isDone) callback(null, values); + } + } + + array.forEach(function (item, index) { + work(item, index, function (error, value) { + done(index, error, value); + }); + }); +} +},{}],42:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _routerWarning=require("./routerWarning"),_routerWarning2=_interopRequireDefault(_routerWarning),_InternalPropTypes=require("./InternalPropTypes"),History={contextTypes:{history:_InternalPropTypes.history},componentWillMount:function(){"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"the `History` mixin is deprecated, please access `context.router` with your own `contextTypes`. http://tiny.cc/router-historymixin"):void 0,this.history=this.context.history}};exports["default"]=History,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +var _InternalPropTypes = require('./InternalPropTypes'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * A mixin that adds the "history" instance variable to components. + */ +var History = { + + contextTypes: { + history: _InternalPropTypes.history + }, + + componentWillMount: function componentWillMount() { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, 'the `History` mixin is deprecated, please access `context.router` with your own `contextTypes`. http://tiny.cc/router-historymixin') : void 0; + this.history = this.context.history; + } +}; + +exports.default = History; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./InternalPropTypes":45,"./routerWarning":72,"_process":32}],42:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;t is used to link to an . + */ +var IndexLink = _react2.default.createClass({ + displayName: 'IndexLink', + render: function render() { + return _react2.default.createElement(_Link2.default, _extends({}, this.props, { onlyActiveOnIndex: true })); + } +}); + +exports.default = IndexLink; +module.exports = exports['default']; +},{"./Link":48,"react":"react"}],44:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _react=require("react"),_react2=_interopRequireDefault(_react),_routerWarning=require("./routerWarning"),_routerWarning2=_interopRequireDefault(_routerWarning),_invariant=require("invariant"),_invariant2=_interopRequireDefault(_invariant),_Redirect=require("./Redirect"),_Redirect2=_interopRequireDefault(_Redirect),_InternalPropTypes=require("./InternalPropTypes"),_React$PropTypes=_react2["default"].PropTypes,string=_React$PropTypes.string,object=_React$PropTypes.object,IndexRedirect=_react2["default"].createClass({displayName:"IndexRedirect",statics:{createRouteFromReactElement:function(e,r){r?r.indexRoute=_Redirect2["default"].createRouteFromReactElement(e):"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"An does not make sense at the root of your route config"):void 0}},propTypes:{to:string.isRequired,query:object,state:object,onEnter:_InternalPropTypes.falsy,children:_InternalPropTypes.falsy},render:function(){"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1," elements are for router configuration only and should not be rendered"):(0,_invariant2["default"])(!1)}});exports["default"]=IndexRedirect,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +var _invariant = require('invariant'); + +var _invariant2 = _interopRequireDefault(_invariant); + +var _Redirect = require('./Redirect'); + +var _Redirect2 = _interopRequireDefault(_Redirect); + +var _InternalPropTypes = require('./InternalPropTypes'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _React$PropTypes = _react2.default.PropTypes; +var string = _React$PropTypes.string; +var object = _React$PropTypes.object; + +/** + * An is used to redirect from an indexRoute. + */ + +var IndexRedirect = _react2.default.createClass({ + displayName: 'IndexRedirect', + + + statics: { + createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) { + /* istanbul ignore else: sanity check */ + if (parentRoute) { + parentRoute.indexRoute = _Redirect2.default.createRouteFromReactElement(element); + } else { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, 'An does not make sense at the root of your route config') : void 0; + } + } + }, + + propTypes: { + to: string.isRequired, + query: object, + state: object, + onEnter: _InternalPropTypes.falsy, + children: _InternalPropTypes.falsy + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + !false ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, ' elements are for router configuration only and should not be rendered') : (0, _invariant2.default)(false) : void 0; + } +}); + +exports.default = IndexRedirect; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./InternalPropTypes":45,"./Redirect":50,"./routerWarning":72,"_process":32,"invariant":76,"react":"react"}],44:[function(require,module,exports){ +},{"./InternalPropTypes":46,"./Redirect":51,"./routerWarning":73,"_process":33,"invariant":23,"react":"react"}],45:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _react=require("react"),_react2=_interopRequireDefault(_react),_routerWarning=require("./routerWarning"),_routerWarning2=_interopRequireDefault(_routerWarning),_invariant=require("invariant"),_invariant2=_interopRequireDefault(_invariant),_RouteUtils=require("./RouteUtils"),_InternalPropTypes=require("./InternalPropTypes"),func=_react2["default"].PropTypes.func,IndexRoute=_react2["default"].createClass({displayName:"IndexRoute",statics:{createRouteFromReactElement:function(e,t){t?t.indexRoute=(0,_RouteUtils.createRouteFromReactElement)(e):"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"An does not make sense at the root of your route config"):void 0}},propTypes:{path:_InternalPropTypes.falsy,component:_InternalPropTypes.component,components:_InternalPropTypes.components,getComponent:func,getComponents:func},render:function(){"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1," elements are for router configuration only and should not be rendered"):(0,_invariant2["default"])(!1)}});exports["default"]=IndexRoute,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +var _invariant = require('invariant'); + +var _invariant2 = _interopRequireDefault(_invariant); + +var _RouteUtils = require('./RouteUtils'); + +var _InternalPropTypes = require('./InternalPropTypes'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var func = _react2.default.PropTypes.func; + +/** + * An is used to specify its parent's in + * a JSX route config. + */ + +var IndexRoute = _react2.default.createClass({ + displayName: 'IndexRoute', + + + statics: { + createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) { + /* istanbul ignore else: sanity check */ + if (parentRoute) { + parentRoute.indexRoute = (0, _RouteUtils.createRouteFromReactElement)(element); + } else { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, 'An does not make sense at the root of your route config') : void 0; + } + } + }, + + propTypes: { + path: _InternalPropTypes.falsy, + component: _InternalPropTypes.component, + components: _InternalPropTypes.components, + getComponent: func, + getComponents: func + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + !false ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, ' elements are for router configuration only and should not be rendered') : (0, _invariant2.default)(false) : void 0; + } +}); + +exports.default = IndexRoute; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./InternalPropTypes":45,"./RouteUtils":53,"./routerWarning":72,"_process":32,"invariant":76,"react":"react"}],45:[function(require,module,exports){ -"use strict";function falsy(e,r,o){return e[r]?new Error("<"+o+'> should not have a "'+r+'" prop'):void 0}exports.__esModule=!0,exports.routes=exports.route=exports.components=exports.component=exports.history=void 0,exports.falsy=falsy;var _react=require("react"),func=_react.PropTypes.func,object=_react.PropTypes.object,arrayOf=_react.PropTypes.arrayOf,oneOfType=_react.PropTypes.oneOfType,element=_react.PropTypes.element,shape=_react.PropTypes.shape,string=_react.PropTypes.string,history=exports.history=shape({listen:func.isRequired,push:func.isRequired,replace:func.isRequired,go:func.isRequired,goBack:func.isRequired,goForward:func.isRequired}),component=exports.component=oneOfType([func,string]),components=exports.components=oneOfType([component,object]),route=exports.route=oneOfType([object,element]),routes=exports.routes=oneOfType([route,arrayOf(route)]); +},{"./InternalPropTypes":46,"./RouteUtils":54,"./routerWarning":73,"_process":33,"invariant":23,"react":"react"}],46:[function(require,module,exports){ +'use strict'; -},{"react":"react"}],46:[function(require,module,exports){ +exports.__esModule = true; +exports.routes = exports.route = exports.components = exports.component = exports.history = undefined; +exports.falsy = falsy; + +var _react = require('react'); + +var func = _react.PropTypes.func; +var object = _react.PropTypes.object; +var arrayOf = _react.PropTypes.arrayOf; +var oneOfType = _react.PropTypes.oneOfType; +var element = _react.PropTypes.element; +var shape = _react.PropTypes.shape; +var string = _react.PropTypes.string; +function falsy(props, propName, componentName) { + if (props[propName]) return new Error('<' + componentName + '> should not have a "' + propName + '" prop'); +} + +var history = exports.history = shape({ + listen: func.isRequired, + push: func.isRequired, + replace: func.isRequired, + go: func.isRequired, + goBack: func.isRequired, + goForward: func.isRequired +}); + +var component = exports.component = oneOfType([func, string]); +var components = exports.components = oneOfType([component, object]); +var route = exports.route = oneOfType([object, element]); +var routes = exports.routes = oneOfType([route, arrayOf(route)]); +},{"react":"react"}],47:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _routerWarning=require("./routerWarning"),_routerWarning2=_interopRequireDefault(_routerWarning),_react=require("react"),_react2=_interopRequireDefault(_react),_invariant=require("invariant"),_invariant2=_interopRequireDefault(_invariant),object=_react2["default"].PropTypes.object,Lifecycle={contextTypes:{history:object.isRequired,route:object},propTypes:{route:object},componentDidMount:function(){"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"the `Lifecycle` mixin is deprecated, please use `context.router.setRouteLeaveHook(route, hook)`. http://tiny.cc/router-lifecyclemixin"):void 0,this.routerWillLeave?void 0:"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1,"The Lifecycle mixin requires you to define a routerWillLeave method"):(0,_invariant2["default"])(!1);var e=this.props.route||this.context.route;e?void 0:"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1,"The Lifecycle mixin must be used on either a) a or b) a descendant of a that uses the RouteContext mixin"):(0,_invariant2["default"])(!1),this._unlistenBeforeLeavingRoute=this.context.history.listenBeforeLeavingRoute(e,this.routerWillLeave)},componentWillUnmount:function(){this._unlistenBeforeLeavingRoute&&this._unlistenBeforeLeavingRoute()}};exports["default"]=Lifecycle,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _invariant = require('invariant'); + +var _invariant2 = _interopRequireDefault(_invariant); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var object = _react2.default.PropTypes.object; + +/** + * The Lifecycle mixin adds the routerWillLeave lifecycle method to a + * component that may be used to cancel a transition or prompt the user + * for confirmation. + * + * On standard transitions, routerWillLeave receives a single argument: the + * location we're transitioning to. To cancel the transition, return false. + * To prompt the user for confirmation, return a prompt message (string). + * + * During the beforeunload event (assuming you're using the useBeforeUnload + * history enhancer), routerWillLeave does not receive a location object + * because it isn't possible for us to know the location we're transitioning + * to. In this case routerWillLeave must return a prompt message to prevent + * the user from closing the window/tab. + */ + +var Lifecycle = { + + contextTypes: { + history: object.isRequired, + // Nested children receive the route as context, either + // set by the route component using the RouteContext mixin + // or by some other ancestor. + route: object + }, + + propTypes: { + // Route components receive the route object as a prop. + route: object + }, + + componentDidMount: function componentDidMount() { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, 'the `Lifecycle` mixin is deprecated, please use `context.router.setRouteLeaveHook(route, hook)`. http://tiny.cc/router-lifecyclemixin') : void 0; + !this.routerWillLeave ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'The Lifecycle mixin requires you to define a routerWillLeave method') : (0, _invariant2.default)(false) : void 0; + + var route = this.props.route || this.context.route; + + !route ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'The Lifecycle mixin must be used on either a) a or ' + 'b) a descendant of a that uses the RouteContext mixin') : (0, _invariant2.default)(false) : void 0; + + this._unlistenBeforeLeavingRoute = this.context.history.listenBeforeLeavingRoute(route, this.routerWillLeave); + }, + componentWillUnmount: function componentWillUnmount() { + if (this._unlistenBeforeLeavingRoute) this._unlistenBeforeLeavingRoute(); + } +}; + +exports.default = Lifecycle; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./routerWarning":72,"_process":32,"invariant":76,"react":"react"}],47:[function(require,module,exports){ +},{"./routerWarning":73,"_process":33,"invariant":23,"react":"react"}],48:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _objectWithoutProperties(e,t){var r={};for(var a in e)t.indexOf(a)>=0||Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a]);return r}function isLeftClickEvent(e){return 0===e.button}function isModifiedEvent(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function isEmptyObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function createLocationDescriptor(e,t){var r=t.query,a=t.hash,o=t.state;return r||a||o?{pathname:e,query:r,hash:a,state:o}:e}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;t` are deprecated, use `. http://tiny.cc/router-isActivedeprecated"):void 0;var u=this.context.router;if(u){var p=createLocationDescriptor(t,{query:r,hash:a,state:o});c.href=u.createHref(p),(n||null!=s&&!isEmptyObject(s))&&u.isActive(p,i)&&(n&&(c.className?c.className+=" "+n:c.className=n),s&&(c.style=_extends({},c.style,s)))}return _react2["default"].createElement("a",_extends({},c,{onClick:this.handleClick}))}});exports["default"]=Link,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +var _PropTypes = require('./PropTypes'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +var _React$PropTypes = _react2.default.PropTypes; +var bool = _React$PropTypes.bool; +var object = _React$PropTypes.object; +var string = _React$PropTypes.string; +var func = _React$PropTypes.func; +var oneOfType = _React$PropTypes.oneOfType; + + +function isLeftClickEvent(event) { + return event.button === 0; +} + +function isModifiedEvent(event) { + return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); +} + +// TODO: De-duplicate against hasAnyProperties in createTransitionManager. +function isEmptyObject(object) { + for (var p in object) { + if (Object.prototype.hasOwnProperty.call(object, p)) return false; + }return true; +} + +function createLocationDescriptor(to, _ref) { + var query = _ref.query; + var hash = _ref.hash; + var state = _ref.state; + + if (query || hash || state) { + return { pathname: to, query: query, hash: hash, state: state }; + } + + return to; +} + +/** + * A is used to create an element that links to a route. + * When that route is active, the link gets the value of its + * activeClassName prop. + * + * For example, assuming you have the following route: + * + * + * + * You could use the following component to link to that route: + * + * + * + * Links may pass along location state and/or query string parameters + * in the state/query props, respectively. + * + * + */ +var Link = _react2.default.createClass({ + displayName: 'Link', + + + contextTypes: { + router: _PropTypes.routerShape + }, + + propTypes: { + to: oneOfType([string, object]).isRequired, + query: object, + hash: string, + state: object, + activeStyle: object, + activeClassName: string, + onlyActiveOnIndex: bool.isRequired, + onClick: func, + target: string + }, + + getDefaultProps: function getDefaultProps() { + return { + onlyActiveOnIndex: false, + style: {} + }; + }, + handleClick: function handleClick(event) { + var allowTransition = true; + + if (this.props.onClick) this.props.onClick(event); + + if (isModifiedEvent(event) || !isLeftClickEvent(event)) return; + + if (event.defaultPrevented === true) allowTransition = false; + + // If target prop is set (e.g. to "_blank") let browser handle link. + /* istanbul ignore if: untestable with Karma */ + if (this.props.target) { + if (!allowTransition) event.preventDefault(); + + return; + } + + event.preventDefault(); + + if (allowTransition) { + var _props = this.props; + var to = _props.to; + var query = _props.query; + var hash = _props.hash; + var state = _props.state; + + var location = createLocationDescriptor(to, { query: query, hash: hash, state: state }); + + this.context.router.push(location); + } + }, + render: function render() { + var _props2 = this.props; + var to = _props2.to; + var query = _props2.query; + var hash = _props2.hash; + var state = _props2.state; + var activeClassName = _props2.activeClassName; + var activeStyle = _props2.activeStyle; + var onlyActiveOnIndex = _props2.onlyActiveOnIndex; + + var props = _objectWithoutProperties(_props2, ['to', 'query', 'hash', 'state', 'activeClassName', 'activeStyle', 'onlyActiveOnIndex']); + + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(!(query || hash || state), 'the `query`, `hash`, and `state` props on `` are deprecated, use `. http://tiny.cc/router-isActivedeprecated') : void 0; + + // Ignore if rendered outside the context of router, simplifies unit testing. + var router = this.context.router; + + + if (router) { + var location = createLocationDescriptor(to, { query: query, hash: hash, state: state }); + props.href = router.createHref(location); + + if (activeClassName || activeStyle != null && !isEmptyObject(activeStyle)) { + if (router.isActive(location, onlyActiveOnIndex)) { + if (activeClassName) { + if (props.className) { + props.className += ' ' + activeClassName; + } else { + props.className = activeClassName; + } + } + + if (activeStyle) props.style = _extends({}, props.style, activeStyle); + } + } + } + + return _react2.default.createElement('a', _extends({}, props, { onClick: this.handleClick })); + } +}); + +exports.default = Link; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./PropTypes":49,"./routerWarning":72,"_process":32,"react":"react"}],48:[function(require,module,exports){ +},{"./PropTypes":50,"./routerWarning":73,"_process":33,"react":"react"}],49:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _compilePattern(e){for(var t="",a=[],r=[],n=void 0,i=0,s=/:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*\*|\*|\(|\)/g;n=s.exec(e);)n.index!==i&&(r.push(e.slice(i,n.index)),t+=escapeRegExp(e.slice(i,n.index))),n[1]?(t+="([^/]+)",a.push(n[1])):"**"===n[0]?(t+="(.*)",a.push("splat")):"*"===n[0]?(t+="(.*?)",a.push("splat")):"("===n[0]?t+="(?:":")"===n[0]&&(t+=")?"),r.push(n[0]),i=s.lastIndex;return i!==e.length&&(r.push(e.slice(i,e.length)),t+=escapeRegExp(e.slice(i,e.length))),{pattern:e,regexpSource:t,paramNames:a,tokens:r}}function compilePattern(e){return e in CompiledPatternsCache||(CompiledPatternsCache[e]=_compilePattern(e)),CompiledPatternsCache[e]}function matchPattern(e,t){"/"!==e.charAt(0)&&(e="/"+e);var a=compilePattern(e),r=a.regexpSource,n=a.paramNames,i=a.tokens;"/"!==e.charAt(e.length-1)&&(r+="/?"),"*"===i[i.length-1]&&(r+="$");var s=t.match(new RegExp("^"+r,"i"));if(null==s)return null;var o=s[0],l=t.substr(o.length);if(l){if("/"!==o.charAt(o.length-1))return null;l="/"+l}return{remainingPathname:l,paramNames:n,paramValues:s.slice(1).map(function(e){return e&&decodeURIComponent(e)})}}function getParamNames(e){return compilePattern(e).paramNames}function getParams(e,t){var a=matchPattern(e,t);if(!a)return null;var r=a.paramNames,n=a.paramValues,i={};return r.forEach(function(e,t){i[e]=n[t]}),i}function formatPattern(e,t){t=t||{};for(var a=compilePattern(e),r=a.tokens,n=0,i="",s=0,o=void 0,l=void 0,p=void 0,u=0,c=r.length;c>u;++u)o=r[u],"*"===o||"**"===o?(p=Array.isArray(t.splat)?t.splat[s++]:t.splat,null!=p||n>0?void 0:"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1,'Missing splat #%s for path "%s"',s,e):(0,_invariant2["default"])(!1),null!=p&&(i+=encodeURI(p))):"("===o?n+=1:")"===o?n-=1:":"===o.charAt(0)?(l=o.substring(1),p=t[l],null!=p||n>0?void 0:"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1,'Missing "%s" parameter for path "%s"',l,e):(0,_invariant2["default"])(!1),null!=p&&(i+=encodeURIComponent(p))):i+=o;return i.replace(/\/+/g,"/")}exports.__esModule=!0,exports.compilePattern=compilePattern,exports.matchPattern=matchPattern,exports.getParamNames=getParamNames,exports.getParams=getParams,exports.formatPattern=formatPattern;var _invariant=require("invariant"),_invariant2=_interopRequireDefault(_invariant),CompiledPatternsCache={}; +'use strict'; +exports.__esModule = true; +exports.compilePattern = compilePattern; +exports.matchPattern = matchPattern; +exports.getParamNames = getParamNames; +exports.getParams = getParams; +exports.formatPattern = formatPattern; + +var _invariant = require('invariant'); + +var _invariant2 = _interopRequireDefault(_invariant); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + +function _compilePattern(pattern) { + var regexpSource = ''; + var paramNames = []; + var tokens = []; + + var match = void 0, + lastIndex = 0, + matcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*\*|\*|\(|\)/g; + while (match = matcher.exec(pattern)) { + if (match.index !== lastIndex) { + tokens.push(pattern.slice(lastIndex, match.index)); + regexpSource += escapeRegExp(pattern.slice(lastIndex, match.index)); + } + + if (match[1]) { + regexpSource += '([^/]+)'; + paramNames.push(match[1]); + } else if (match[0] === '**') { + regexpSource += '(.*)'; + paramNames.push('splat'); + } else if (match[0] === '*') { + regexpSource += '(.*?)'; + paramNames.push('splat'); + } else if (match[0] === '(') { + regexpSource += '(?:'; + } else if (match[0] === ')') { + regexpSource += ')?'; + } + + tokens.push(match[0]); + + lastIndex = matcher.lastIndex; + } + + if (lastIndex !== pattern.length) { + tokens.push(pattern.slice(lastIndex, pattern.length)); + regexpSource += escapeRegExp(pattern.slice(lastIndex, pattern.length)); + } + + return { + pattern: pattern, + regexpSource: regexpSource, + paramNames: paramNames, + tokens: tokens + }; +} + +var CompiledPatternsCache = {}; + +function compilePattern(pattern) { + if (!(pattern in CompiledPatternsCache)) CompiledPatternsCache[pattern] = _compilePattern(pattern); + + return CompiledPatternsCache[pattern]; +} + +/** + * Attempts to match a pattern on the given pathname. Patterns may use + * the following special characters: + * + * - :paramName Matches a URL segment up to the next /, ?, or #. The + * captured string is considered a "param" + * - () Wraps a segment of the URL that is optional + * - * Consumes (non-greedy) all characters up to the next + * character in the pattern, or to the end of the URL if + * there is none + * - ** Consumes (greedy) all characters up to the next character + * in the pattern, or to the end of the URL if there is none + * + * The function calls callback(error, matched) when finished. + * The return value is an object with the following properties: + * + * - remainingPathname + * - paramNames + * - paramValues + */ +function matchPattern(pattern, pathname) { + // Ensure pattern starts with leading slash for consistency with pathname. + if (pattern.charAt(0) !== '/') { + pattern = '/' + pattern; + } + + var _compilePattern2 = compilePattern(pattern); + + var regexpSource = _compilePattern2.regexpSource; + var paramNames = _compilePattern2.paramNames; + var tokens = _compilePattern2.tokens; + + + if (pattern.charAt(pattern.length - 1) !== '/') { + regexpSource += '/?'; // Allow optional path separator at end. + } + + // Special-case patterns like '*' for catch-all routes. + if (tokens[tokens.length - 1] === '*') { + regexpSource += '$'; + } + + var match = pathname.match(new RegExp('^' + regexpSource, 'i')); + if (match == null) { + return null; + } + + var matchedPath = match[0]; + var remainingPathname = pathname.substr(matchedPath.length); + + if (remainingPathname) { + // Require that the match ends at a path separator, if we didn't match + // the full path, so any remaining pathname is a new path segment. + if (matchedPath.charAt(matchedPath.length - 1) !== '/') { + return null; + } + + // If there is a remaining pathname, treat the path separator as part of + // the remaining pathname for properly continuing the match. + remainingPathname = '/' + remainingPathname; + } + + return { + remainingPathname: remainingPathname, + paramNames: paramNames, + paramValues: match.slice(1).map(function (v) { + return v && decodeURIComponent(v); + }) + }; +} + +function getParamNames(pattern) { + return compilePattern(pattern).paramNames; +} + +function getParams(pattern, pathname) { + var match = matchPattern(pattern, pathname); + if (!match) { + return null; + } + + var paramNames = match.paramNames; + var paramValues = match.paramValues; + + var params = {}; + + paramNames.forEach(function (paramName, index) { + params[paramName] = paramValues[index]; + }); + + return params; +} + +/** + * Returns a version of the given pattern with params interpolated. Throws + * if there is a dynamic segment of the pattern for which there is no param. + */ +function formatPattern(pattern, params) { + params = params || {}; + + var _compilePattern3 = compilePattern(pattern); + + var tokens = _compilePattern3.tokens; + + var parenCount = 0, + pathname = '', + splatIndex = 0; + + var token = void 0, + paramName = void 0, + paramValue = void 0; + for (var i = 0, len = tokens.length; i < len; ++i) { + token = tokens[i]; + + if (token === '*' || token === '**') { + paramValue = Array.isArray(params.splat) ? params.splat[splatIndex++] : params.splat; + + !(paramValue != null || parenCount > 0) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'Missing splat #%s for path "%s"', splatIndex, pattern) : (0, _invariant2.default)(false) : void 0; + + if (paramValue != null) pathname += encodeURI(paramValue); + } else if (token === '(') { + parenCount += 1; + } else if (token === ')') { + parenCount -= 1; + } else if (token.charAt(0) === ':') { + paramName = token.substring(1); + paramValue = params[paramName]; + + !(paramValue != null || parenCount > 0) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'Missing "%s" parameter for path "%s"', paramName, pattern) : (0, _invariant2.default)(false) : void 0; + + if (paramValue != null) pathname += encodeURIComponent(paramValue); + } else { + pathname += token; + } + } + + return pathname.replace(/\/+/g, '/'); +} }).call(this,require('_process')) -},{"_process":32,"invariant":76}],49:[function(require,module,exports){ +},{"_process":33,"invariant":23}],50:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r["default"]=e,r}function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0,exports.router=exports.routes=exports.route=exports.components=exports.component=exports.location=exports.history=exports.falsy=exports.locationShape=exports.routerShape=void 0;var _react=require("react"),_deprecateObjectProperties=require("./deprecateObjectProperties"),_deprecateObjectProperties2=_interopRequireDefault(_deprecateObjectProperties),_InternalPropTypes=require("./InternalPropTypes"),InternalPropTypes=_interopRequireWildcard(_InternalPropTypes),_routerWarning=require("./routerWarning"),_routerWarning2=_interopRequireDefault(_routerWarning),func=_react.PropTypes.func,object=_react.PropTypes.object,shape=_react.PropTypes.shape,string=_react.PropTypes.string,routerShape=exports.routerShape=shape({push:func.isRequired,replace:func.isRequired,go:func.isRequired,goBack:func.isRequired,goForward:func.isRequired,setRouteLeaveHook:func.isRequired,isActive:func.isRequired}),locationShape=exports.locationShape=shape({pathname:string.isRequired,search:string.isRequired,state:object,action:string.isRequired,key:string}),falsy=exports.falsy=InternalPropTypes.falsy,history=exports.history=InternalPropTypes.history,location=exports.location=locationShape,component=exports.component=InternalPropTypes.component,components=exports.components=InternalPropTypes.components,route=exports.route=InternalPropTypes.route,routes=exports.routes=InternalPropTypes.routes,router=exports.router=routerShape;"production"!==process.env.NODE_ENV&&!function(){var e=function(e,r){return function(){return"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,r):void 0,e.apply(void 0,arguments)}},r=function(r){return e(r,"This prop type is not intended for external use, and was previously exported by mistake. These internal prop types are deprecated for external use, and will be removed in a later version.")},o=function(r,o){return e(r,"The `"+o+"` prop type is now exported as `"+o+"Shape` to avoid name conflicts. This export is deprecated and will be removed in a later version.")};exports.falsy=falsy=r(falsy),exports.history=history=r(history),exports.component=component=r(component),exports.components=components=r(components),exports.route=route=r(route),exports.routes=routes=r(routes),exports.location=location=o(location,"location"),exports.router=router=o(router,"router")}();var defaultExport={falsy:falsy,history:history,location:location,component:component,components:components,route:route,router:router};"production"!==process.env.NODE_ENV&&(defaultExport=(0,_deprecateObjectProperties2["default"])(defaultExport,"The default export from `react-router/lib/PropTypes` is deprecated. Please use the named exports instead.")),exports["default"]=defaultExport; +'use strict'; +exports.__esModule = true; +exports.router = exports.routes = exports.route = exports.components = exports.component = exports.location = exports.history = exports.falsy = exports.locationShape = exports.routerShape = undefined; + +var _react = require('react'); + +var _deprecateObjectProperties = require('./deprecateObjectProperties'); + +var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties); + +var _InternalPropTypes = require('./InternalPropTypes'); + +var InternalPropTypes = _interopRequireWildcard(_InternalPropTypes); + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var func = _react.PropTypes.func; +var object = _react.PropTypes.object; +var shape = _react.PropTypes.shape; +var string = _react.PropTypes.string; +var routerShape = exports.routerShape = shape({ + push: func.isRequired, + replace: func.isRequired, + go: func.isRequired, + goBack: func.isRequired, + goForward: func.isRequired, + setRouteLeaveHook: func.isRequired, + isActive: func.isRequired +}); + +var locationShape = exports.locationShape = shape({ + pathname: string.isRequired, + search: string.isRequired, + state: object, + action: string.isRequired, + key: string +}); + +// Deprecated stuff below: + +var falsy = exports.falsy = InternalPropTypes.falsy; +var history = exports.history = InternalPropTypes.history; +var location = exports.location = locationShape; +var component = exports.component = InternalPropTypes.component; +var components = exports.components = InternalPropTypes.components; +var route = exports.route = InternalPropTypes.route; +var routes = exports.routes = InternalPropTypes.routes; +var router = exports.router = routerShape; + +if (process.env.NODE_ENV !== 'production') { + (function () { + var deprecatePropType = function deprecatePropType(propType, message) { + return function () { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, message) : void 0; + return propType.apply(undefined, arguments); + }; + }; + + var deprecateInternalPropType = function deprecateInternalPropType(propType) { + return deprecatePropType(propType, 'This prop type is not intended for external use, and was previously exported by mistake. These internal prop types are deprecated for external use, and will be removed in a later version.'); + }; + + var deprecateRenamedPropType = function deprecateRenamedPropType(propType, name) { + return deprecatePropType(propType, 'The `' + name + '` prop type is now exported as `' + name + 'Shape` to avoid name conflicts. This export is deprecated and will be removed in a later version.'); + }; + + exports.falsy = falsy = deprecateInternalPropType(falsy); + exports.history = history = deprecateInternalPropType(history); + exports.component = component = deprecateInternalPropType(component); + exports.components = components = deprecateInternalPropType(components); + exports.route = route = deprecateInternalPropType(route); + exports.routes = routes = deprecateInternalPropType(routes); + + exports.location = location = deprecateRenamedPropType(location, 'location'); + exports.router = router = deprecateRenamedPropType(router, 'router'); + })(); +} + +var defaultExport = { + falsy: falsy, + history: history, + location: location, + component: component, + components: components, + route: route, + // For some reason, routes was never here. + router: router +}; + +if (process.env.NODE_ENV !== 'production') { + defaultExport = (0, _deprecateObjectProperties2.default)(defaultExport, 'The default export from `react-router/lib/PropTypes` is deprecated. Please use the named exports instead.'); +} + +exports.default = defaultExport; }).call(this,require('_process')) -},{"./InternalPropTypes":45,"./deprecateObjectProperties":65,"./routerWarning":72,"_process":32,"react":"react"}],50:[function(require,module,exports){ +},{"./InternalPropTypes":46,"./deprecateObjectProperties":66,"./routerWarning":73,"_process":33,"react":"react"}],51:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _react=require("react"),_react2=_interopRequireDefault(_react),_invariant=require("invariant"),_invariant2=_interopRequireDefault(_invariant),_RouteUtils=require("./RouteUtils"),_PatternUtils=require("./PatternUtils"),_InternalPropTypes=require("./InternalPropTypes"),_React$PropTypes=_react2["default"].PropTypes,string=_React$PropTypes.string,object=_React$PropTypes.object,Redirect=_react2["default"].createClass({displayName:"Redirect",statics:{createRouteFromReactElement:function(e){var t=(0,_RouteUtils.createRouteFromReactElement)(e);return t.from&&(t.path=t.from),t.onEnter=function(e,r){var a=e.location,n=e.params,o=void 0;if("/"===t.to.charAt(0))o=(0,_PatternUtils.formatPattern)(t.to,n);else if(t.to){var i=e.routes.indexOf(t),s=Redirect.getRoutePattern(e.routes,i-1),u=s.replace(/\/*$/,"/")+t.to;o=(0,_PatternUtils.formatPattern)(u,n)}else o=a.pathname;r({pathname:o,query:t.query||a.query,state:t.state||a.state})},t},getRoutePattern:function(e,t){for(var r="",a=t;a>=0;a--){var n=e[a],o=n.path||"";if(r=o.replace(/\/*$/,"/")+r,0===o.indexOf("/"))break}return"/"+r}},propTypes:{path:string,from:string,to:string.isRequired,query:object,state:object,onEnter:_InternalPropTypes.falsy,children:_InternalPropTypes.falsy},render:function(){"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1," elements are for router configuration only and should not be rendered"):(0,_invariant2["default"])(!1)}});exports["default"]=Redirect,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _invariant = require('invariant'); + +var _invariant2 = _interopRequireDefault(_invariant); + +var _RouteUtils = require('./RouteUtils'); + +var _PatternUtils = require('./PatternUtils'); + +var _InternalPropTypes = require('./InternalPropTypes'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _React$PropTypes = _react2.default.PropTypes; +var string = _React$PropTypes.string; +var object = _React$PropTypes.object; + +/** + * A is used to declare another URL path a client should + * be sent to when they request a given URL. + * + * Redirects are placed alongside routes in the route configuration + * and are traversed in the same manner. + */ + +var Redirect = _react2.default.createClass({ + displayName: 'Redirect', + + + statics: { + createRouteFromReactElement: function createRouteFromReactElement(element) { + var route = (0, _RouteUtils.createRouteFromReactElement)(element); + + if (route.from) route.path = route.from; + + route.onEnter = function (nextState, replace) { + var location = nextState.location; + var params = nextState.params; + + + var pathname = void 0; + if (route.to.charAt(0) === '/') { + pathname = (0, _PatternUtils.formatPattern)(route.to, params); + } else if (!route.to) { + pathname = location.pathname; + } else { + var routeIndex = nextState.routes.indexOf(route); + var parentPattern = Redirect.getRoutePattern(nextState.routes, routeIndex - 1); + var pattern = parentPattern.replace(/\/*$/, '/') + route.to; + pathname = (0, _PatternUtils.formatPattern)(pattern, params); + } + + replace({ + pathname: pathname, + query: route.query || location.query, + state: route.state || location.state + }); + }; + + return route; + }, + getRoutePattern: function getRoutePattern(routes, routeIndex) { + var parentPattern = ''; + + for (var i = routeIndex; i >= 0; i--) { + var route = routes[i]; + var pattern = route.path || ''; + + parentPattern = pattern.replace(/\/*$/, '/') + parentPattern; + + if (pattern.indexOf('/') === 0) break; + } + + return '/' + parentPattern; + } + }, + + propTypes: { + path: string, + from: string, // Alias for path + to: string.isRequired, + query: object, + state: object, + onEnter: _InternalPropTypes.falsy, + children: _InternalPropTypes.falsy + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + !false ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, ' elements are for router configuration only and should not be rendered') : (0, _invariant2.default)(false) : void 0; + } +}); + +exports.default = Redirect; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./InternalPropTypes":45,"./PatternUtils":48,"./RouteUtils":53,"_process":32,"invariant":76,"react":"react"}],51:[function(require,module,exports){ +},{"./InternalPropTypes":46,"./PatternUtils":49,"./RouteUtils":54,"_process":33,"invariant":23,"react":"react"}],52:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _react=require("react"),_react2=_interopRequireDefault(_react),_invariant=require("invariant"),_invariant2=_interopRequireDefault(_invariant),_RouteUtils=require("./RouteUtils"),_InternalPropTypes=require("./InternalPropTypes"),_React$PropTypes=_react2["default"].PropTypes,string=_React$PropTypes.string,func=_React$PropTypes.func,Route=_react2["default"].createClass({displayName:"Route",statics:{createRouteFromReactElement:_RouteUtils.createRouteFromReactElement},propTypes:{path:string,component:_InternalPropTypes.component,components:_InternalPropTypes.components,getComponent:func,getComponents:func},render:function(){"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1," elements are for router configuration only and should not be rendered"):(0,_invariant2["default"])(!1)}});exports["default"]=Route,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _invariant = require('invariant'); + +var _invariant2 = _interopRequireDefault(_invariant); + +var _RouteUtils = require('./RouteUtils'); + +var _InternalPropTypes = require('./InternalPropTypes'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _React$PropTypes = _react2.default.PropTypes; +var string = _React$PropTypes.string; +var func = _React$PropTypes.func; + +/** + * A is used to declare which components are rendered to the + * page when the URL matches a given pattern. + * + * Routes are arranged in a nested tree structure. When a new URL is + * requested, the tree is searched depth-first to find a route whose + * path matches the URL. When one is found, all routes in the tree + * that lead to it are considered "active" and their components are + * rendered into the DOM, nested in the same order as in the tree. + */ + +var Route = _react2.default.createClass({ + displayName: 'Route', + + + statics: { + createRouteFromReactElement: _RouteUtils.createRouteFromReactElement + }, + + propTypes: { + path: string, + component: _InternalPropTypes.component, + components: _InternalPropTypes.components, + getComponent: func, + getComponents: func + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + !false ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, ' elements are for router configuration only and should not be rendered') : (0, _invariant2.default)(false) : void 0; + } +}); + +exports.default = Route; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./InternalPropTypes":45,"./RouteUtils":53,"_process":32,"invariant":76,"react":"react"}],52:[function(require,module,exports){ +},{"./InternalPropTypes":46,"./RouteUtils":54,"_process":33,"invariant":23,"react":"react"}],53:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _routerWarning=require("./routerWarning"),_routerWarning2=_interopRequireDefault(_routerWarning),_react=require("react"),_react2=_interopRequireDefault(_react),object=_react2["default"].PropTypes.object,RouteContext={propTypes:{route:object.isRequired},childContextTypes:{route:object.isRequired},getChildContext:function(){return{route:this.props.route}},componentWillMount:function(){"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"The `RouteContext` mixin is deprecated. You can provide `this.props.route` on context with your own `contextTypes`. http://tiny.cc/router-routecontextmixin"):void 0}};exports["default"]=RouteContext,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var object = _react2.default.PropTypes.object; + +/** + * The RouteContext mixin provides a convenient way for route + * components to set the route in context. This is needed for + * routes that render elements that want to use the Lifecycle + * mixin to prevent transitions. + */ + +var RouteContext = { + + propTypes: { + route: object.isRequired + }, + + childContextTypes: { + route: object.isRequired + }, + + getChildContext: function getChildContext() { + return { + route: this.props.route + }; + }, + componentWillMount: function componentWillMount() { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, 'The `RouteContext` mixin is deprecated. You can provide `this.props.route` on context with your own `contextTypes`. http://tiny.cc/router-routecontextmixin') : void 0; + } +}; + +exports.default = RouteContext; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./routerWarning":72,"_process":32,"react":"react"}],53:[function(require,module,exports){ +},{"./routerWarning":73,"_process":33,"react":"react"}],54:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function isValidChild(e){return null==e||_react2["default"].isValidElement(e)}function isReactChildren(e){return isValidChild(e)||Array.isArray(e)&&e.every(isValidChild)}function checkPropTypes(e,r,t){e=e||"UnknownComponent";for(var a in r)if(Object.prototype.hasOwnProperty.call(r,a)){var n=r[a](t,a,e);n instanceof Error&&("production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,n.message):void 0)}}function createRoute(e,r){return _extends({},e,r)}function createRouteFromReactElement(e){var r=e.type,t=createRoute(r.defaultProps,e.props);if(r.propTypes&&checkPropTypes(r.displayName||r.name,r.propTypes,t),t.children){var a=createRoutesFromReactChildren(t.children,t);a.length&&(t.childRoutes=a),delete t.children}return t}function createRoutesFromReactChildren(e,r){var t=[];return _react2["default"].Children.forEach(e,function(e){if(_react2["default"].isValidElement(e))if(e.type.createRouteFromReactElement){var a=e.type.createRouteFromReactElement(e,r);a&&t.push(a)}else t.push(createRouteFromReactElement(e))}),t}function createRoutes(e){return isReactChildren(e)?e=createRoutesFromReactChildren(e):e&&!Array.isArray(e)&&(e=[e]),e}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var r=1;r + * + * + * + * ) + * + * Note: This method is automatically used when you provide children + * to a component. + */ +function createRoutesFromReactChildren(children, parentRoute) { + var routes = []; + + _react2.default.Children.forEach(children, function (element) { + if (_react2.default.isValidElement(element)) { + // Component classes may have a static create* method. + if (element.type.createRouteFromReactElement) { + var route = element.type.createRouteFromReactElement(element, parentRoute); + + if (route) routes.push(route); + } else { + routes.push(createRouteFromReactElement(element)); + } + } + }); + + return routes; +} + +/** + * Creates and returns an array of routes from the given object which + * may be a JSX route, a plain object route, or an array of either. + */ +function createRoutes(routes) { + if (isReactChildren(routes)) { + routes = createRoutesFromReactChildren(routes); + } else if (routes && !Array.isArray(routes)) { + routes = [routes]; + } + + return routes; +} }).call(this,require('_process')) -},{"./routerWarning":72,"_process":32,"react":"react"}],54:[function(require,module,exports){ +},{"./routerWarning":73,"_process":33,"react":"react"}],55:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _objectWithoutProperties(e,r){var t={};for(var o in e)r.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}function isDeprecatedHistory(e){return!e||!e.__v2_compatible__}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var r=1;r`, please use a history provided by React Router with `import { browserHistory } from 'react-router'` or `import { hashHistory } from 'react-router'`. If you are using a custom history please create it with `useRouterHistory`, see http://tiny.cc/router-usinghistory for details."):void 0,n=function(){return e}):("production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"`Router` no longer defaults the history prop to hash history. Please use the `hashHistory` singleton instead. http://tiny.cc/router-defaulthistory"):void 0,n=_createHashHistory2["default"]),(0,_useQueries2["default"])(n)({parseQueryString:t,stringifyQuery:o})},componentWillReceiveProps:function(e){"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(e.history===this.props.history,"You cannot change ; it will be ignored"):void 0,"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])((e.routes||e.children)===(this.props.routes||this.props.children),"You cannot change ; it will be ignored"):void 0},componentWillUnmount:function(){this._unlisten&&this._unlisten()},render:function e(){var r=this.state,t=r.location,o=r.routes,n=r.params,i=r.components,s=this.props,u=s.createElement,e=s.render,a=_objectWithoutProperties(s,["createElement","render"]);return null==t?null:(Object.keys(Router.propTypes).forEach(function(e){return delete a[e]}),e(_extends({},a,{history:this.history,router:this.router,location:t,routes:o,params:n,components:i,createElement:u})))}});exports["default"]=Router,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _createHashHistory = require('history/lib/createHashHistory'); + +var _createHashHistory2 = _interopRequireDefault(_createHashHistory); + +var _useQueries = require('history/lib/useQueries'); + +var _useQueries2 = _interopRequireDefault(_useQueries); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _createTransitionManager = require('./createTransitionManager'); + +var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); + +var _InternalPropTypes = require('./InternalPropTypes'); + +var _RouterContext = require('./RouterContext'); + +var _RouterContext2 = _interopRequireDefault(_RouterContext); + +var _RouteUtils = require('./RouteUtils'); + +var _RouterUtils = require('./RouterUtils'); + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +function isDeprecatedHistory(history) { + return !history || !history.__v2_compatible__; +} + +var _React$PropTypes = _react2.default.PropTypes; +var func = _React$PropTypes.func; +var object = _React$PropTypes.object; + +/** + * A is a high-level API for automatically setting up + * a router that renders a with all the props + * it needs each time the URL changes. + */ + +var Router = _react2.default.createClass({ + displayName: 'Router', + + + propTypes: { + history: object, + children: _InternalPropTypes.routes, + routes: _InternalPropTypes.routes, // alias for children + render: func, + createElement: func, + onError: func, + onUpdate: func, + + // PRIVATE: For client-side rehydration of server match. + matchContext: object + }, + + getDefaultProps: function getDefaultProps() { + return { + render: function render(props) { + return _react2.default.createElement(_RouterContext2.default, props); + } + }; + }, + getInitialState: function getInitialState() { + return { + location: null, + routes: null, + params: null, + components: null + }; + }, + handleError: function handleError(error) { + if (this.props.onError) { + this.props.onError.call(this, error); + } else { + // Throw errors by default so we don't silently swallow them! + throw error; // This error probably occurred in getChildRoutes or getComponents. + } + }, + componentWillMount: function componentWillMount() { + var _this = this; + + var _props = this.props; + var parseQueryString = _props.parseQueryString; + var stringifyQuery = _props.stringifyQuery; + + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(!(parseQueryString || stringifyQuery), '`parseQueryString` and `stringifyQuery` are deprecated. Please create a custom history. http://tiny.cc/router-customquerystring') : void 0; + + var _createRouterObjects = this.createRouterObjects(); + + var history = _createRouterObjects.history; + var transitionManager = _createRouterObjects.transitionManager; + var router = _createRouterObjects.router; + + + this._unlisten = transitionManager.listen(function (error, state) { + if (error) { + _this.handleError(error); + } else { + _this.setState(state, _this.props.onUpdate); + } + }); + + this.history = history; + this.router = router; + }, + createRouterObjects: function createRouterObjects() { + var matchContext = this.props.matchContext; + + if (matchContext) { + return matchContext; + } + + var history = this.props.history; + var _props2 = this.props; + var routes = _props2.routes; + var children = _props2.children; + + + if (isDeprecatedHistory(history)) { + history = this.wrapDeprecatedHistory(history); + } + + var transitionManager = (0, _createTransitionManager2.default)(history, (0, _RouteUtils.createRoutes)(routes || children)); + var router = (0, _RouterUtils.createRouterObject)(history, transitionManager); + var routingHistory = (0, _RouterUtils.createRoutingHistory)(history, transitionManager); + + return { history: routingHistory, transitionManager: transitionManager, router: router }; + }, + wrapDeprecatedHistory: function wrapDeprecatedHistory(history) { + var _props3 = this.props; + var parseQueryString = _props3.parseQueryString; + var stringifyQuery = _props3.stringifyQuery; + + + var createHistory = void 0; + if (history) { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, 'It appears you have provided a deprecated history object to ``, please use a history provided by ' + 'React Router with `import { browserHistory } from \'react-router\'` or `import { hashHistory } from \'react-router\'`. ' + 'If you are using a custom history please create it with `useRouterHistory`, see http://tiny.cc/router-usinghistory for details.') : void 0; + createHistory = function createHistory() { + return history; + }; + } else { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, '`Router` no longer defaults the history prop to hash history. Please use the `hashHistory` singleton instead. http://tiny.cc/router-defaulthistory') : void 0; + createHistory = _createHashHistory2.default; + } + + return (0, _useQueries2.default)(createHistory)({ parseQueryString: parseQueryString, stringifyQuery: stringifyQuery }); + }, + + + /* istanbul ignore next: sanity check */ + componentWillReceiveProps: function componentWillReceiveProps(nextProps) { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(nextProps.history === this.props.history, 'You cannot change ; it will be ignored') : void 0; + + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)((nextProps.routes || nextProps.children) === (this.props.routes || this.props.children), 'You cannot change ; it will be ignored') : void 0; + }, + componentWillUnmount: function componentWillUnmount() { + if (this._unlisten) this._unlisten(); + }, + render: function render() { + var _state = this.state; + var location = _state.location; + var routes = _state.routes; + var params = _state.params; + var components = _state.components; + var _props4 = this.props; + var createElement = _props4.createElement; + var render = _props4.render; + + var props = _objectWithoutProperties(_props4, ['createElement', 'render']); + + if (location == null) return null; // Async match + + // Only forward non-Router-specific props to routing context, as those are + // the only ones that might be custom routing context props. + Object.keys(Router.propTypes).forEach(function (propType) { + return delete props[propType]; + }); + + return render(_extends({}, props, { + history: this.history, + router: this.router, + location: location, + routes: routes, + params: params, + components: components, + createElement: createElement + })); + } +}); + +exports.default = Router; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./InternalPropTypes":45,"./RouteUtils":53,"./RouterContext":55,"./RouterUtils":56,"./createTransitionManager":64,"./routerWarning":72,"_process":32,"history/lib/createHashHistory":14,"history/lib/useQueries":21,"react":"react"}],55:[function(require,module,exports){ +},{"./InternalPropTypes":46,"./RouteUtils":54,"./RouterContext":56,"./RouterUtils":57,"./createTransitionManager":65,"./routerWarning":73,"_process":33,"history/lib/createHashHistory":14,"history/lib/useQueries":21,"react":"react"}],56:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_extends=Object.assign||function(e){for(var t=1;t` expects a `router` rather than a `history`"):void 0,t=_extends({},r,{setRouteLeaveHook:r.listenBeforeLeavingRoute}),delete t.listenBeforeLeavingRoute),"production"!==process.env.NODE_ENV&&(o=(0,_deprecateObjectProperties2["default"])(o,"`context.location` is deprecated, please use a route component's `props.location` instead. http://tiny.cc/router-accessinglocation")),{history:r,location:o,router:t}},createElement:function(e,t){return null==e?null:this.props.createElement(e,t)},render:function(){var e=this,t=this.props,r=t.history,o=t.location,n=t.routes,a=t.params,i=t.components,u=null;return i&&(u=i.reduceRight(function(t,i,u){if(null==i)return t;var s=n[u],c=(0,_getRouteParams2["default"])(s,a),l={history:r,location:o,params:a,route:s,routeParams:c,routes:n};if((0,_RouteUtils.isReactChildren)(t))l.children=t;else if(t)for(var p in t)Object.prototype.hasOwnProperty.call(t,p)&&(l[p]=t[p]);if("object"===("undefined"==typeof i?"undefined":_typeof(i))){var d={};for(var f in i)Object.prototype.hasOwnProperty.call(i,f)&&(d[f]=e.createElement(i[f],_extends({key:f},l)));return d}return e.createElement(i,l)},u)),null===u||u===!1||_react2["default"].isValidElement(u)?void 0:"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1,"The root route must render a single element"):(0,_invariant2["default"])(!1),u}});exports["default"]=RouterContext,module.exports=exports["default"]; +'use strict'; +exports.__esModule = true; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _invariant = require('invariant'); + +var _invariant2 = _interopRequireDefault(_invariant); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _deprecateObjectProperties = require('./deprecateObjectProperties'); + +var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties); + +var _getRouteParams = require('./getRouteParams'); + +var _getRouteParams2 = _interopRequireDefault(_getRouteParams); + +var _RouteUtils = require('./RouteUtils'); + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _React$PropTypes = _react2.default.PropTypes; +var array = _React$PropTypes.array; +var func = _React$PropTypes.func; +var object = _React$PropTypes.object; + +/** + * A renders the component tree for a given router state + * and sets the history object and the current location in context. + */ + +var RouterContext = _react2.default.createClass({ + displayName: 'RouterContext', + + + propTypes: { + history: object, + router: object.isRequired, + location: object.isRequired, + routes: array.isRequired, + params: object.isRequired, + components: array.isRequired, + createElement: func.isRequired + }, + + getDefaultProps: function getDefaultProps() { + return { + createElement: _react2.default.createElement + }; + }, + + + childContextTypes: { + history: object, + location: object.isRequired, + router: object.isRequired + }, + + getChildContext: function getChildContext() { + var _props = this.props; + var router = _props.router; + var history = _props.history; + var location = _props.location; + + if (!router) { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, '`` expects a `router` rather than a `history`') : void 0; + + router = _extends({}, history, { + setRouteLeaveHook: history.listenBeforeLeavingRoute + }); + delete router.listenBeforeLeavingRoute; + } + + if (process.env.NODE_ENV !== 'production') { + location = (0, _deprecateObjectProperties2.default)(location, '`context.location` is deprecated, please use a route component\'s `props.location` instead. http://tiny.cc/router-accessinglocation'); + } + + return { history: history, location: location, router: router }; + }, + createElement: function createElement(component, props) { + return component == null ? null : this.props.createElement(component, props); + }, + render: function render() { + var _this = this; + + var _props2 = this.props; + var history = _props2.history; + var location = _props2.location; + var routes = _props2.routes; + var params = _props2.params; + var components = _props2.components; + + var element = null; + + if (components) { + element = components.reduceRight(function (element, components, index) { + if (components == null) return element; // Don't create new children; use the grandchildren. + + var route = routes[index]; + var routeParams = (0, _getRouteParams2.default)(route, params); + var props = { + history: history, + location: location, + params: params, + route: route, + routeParams: routeParams, + routes: routes + }; + + if ((0, _RouteUtils.isReactChildren)(element)) { + props.children = element; + } else if (element) { + for (var prop in element) { + if (Object.prototype.hasOwnProperty.call(element, prop)) props[prop] = element[prop]; + } + } + + if ((typeof components === 'undefined' ? 'undefined' : _typeof(components)) === 'object') { + var elements = {}; + + for (var key in components) { + if (Object.prototype.hasOwnProperty.call(components, key)) { + // Pass through the key as a prop to createElement to allow + // custom createElement functions to know which named component + // they're rendering, for e.g. matching up to fetched data. + elements[key] = _this.createElement(components[key], _extends({ + key: key }, props)); + } + } + + return elements; + } + + return _this.createElement(components, props); + }, element); + } + + !(element === null || element === false || _react2.default.isValidElement(element)) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'The root route must render a single element') : (0, _invariant2.default)(false) : void 0; + + return element; + } +}); + +exports.default = RouterContext; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./RouteUtils":53,"./deprecateObjectProperties":65,"./getRouteParams":67,"./routerWarning":72,"_process":32,"invariant":76,"react":"react"}],56:[function(require,module,exports){ +},{"./RouteUtils":54,"./deprecateObjectProperties":66,"./getRouteParams":68,"./routerWarning":73,"_process":33,"invariant":23,"react":"react"}],57:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function createRouterObject(e,t){return _extends({},e,{setRouteLeaveHook:t.listenBeforeLeavingRoute,isActive:t.isActive})}function createRoutingHistory(e,t){return e=_extends({},e,t),"production"!==process.env.NODE_ENV&&(e=(0,_deprecateObjectProperties2["default"])(e,"`props.history` and `context.history` are deprecated. Please use `context.router`. http://tiny.cc/router-contextchanges")),e}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;tu;u++)t[u]=arguments[u];if(n.apply(e,t),n.lengthe;++e)n[e].onLeave&&n[e].onLeave.call(n[e])}exports.__esModule=!0,exports.runEnterHooks=runEnterHooks,exports.runChangeHooks=runChangeHooks,exports.runLeaveHooks=runLeaveHooks;var _AsyncUtils=require("./AsyncUtils"),_routerWarning=require("./routerWarning"),_routerWarning2=_interopRequireDefault(_routerWarning); +'use strict'; +exports.__esModule = true; +exports.runEnterHooks = runEnterHooks; +exports.runChangeHooks = runChangeHooks; +exports.runLeaveHooks = runLeaveHooks; + +var _AsyncUtils = require('./AsyncUtils'); + +var _routerWarning = require('./routerWarning'); + +var _routerWarning2 = _interopRequireDefault(_routerWarning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function createTransitionHook(hook, route, asyncArity) { + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + hook.apply(route, args); + + if (hook.length < asyncArity) { + var callback = args[args.length - 1]; + // Assume hook executes synchronously and + // automatically call the callback. + callback(); + } + }; +} + +function getEnterHooks(routes) { + return routes.reduce(function (hooks, route) { + if (route.onEnter) hooks.push(createTransitionHook(route.onEnter, route, 3)); + + return hooks; + }, []); +} + +function getChangeHooks(routes) { + return routes.reduce(function (hooks, route) { + if (route.onChange) hooks.push(createTransitionHook(route.onChange, route, 4)); + return hooks; + }, []); +} + +function runTransitionHooks(length, iter, callback) { + if (!length) { + callback(); + return; + } + + var redirectInfo = void 0; + function replace(location, deprecatedPathname, deprecatedQuery) { + if (deprecatedPathname) { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, '`replaceState(state, pathname, query) is deprecated; use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated') : void 0; + redirectInfo = { + pathname: deprecatedPathname, + query: deprecatedQuery, + state: location + }; + + return; + } + + redirectInfo = location; + } + + (0, _AsyncUtils.loopAsync)(length, function (index, next, done) { + iter(index, replace, function (error) { + if (error || redirectInfo) { + done(error, redirectInfo); // No need to continue. + } else { + next(); + } + }); + }, callback); +} + +/** + * Runs all onEnter hooks in the given array of routes in order + * with onEnter(nextState, replace, callback) and calls + * callback(error, redirectInfo) when finished. The first hook + * to use replace short-circuits the loop. + * + * If a hook needs to run asynchronously, it may use the callback + * function. However, doing so will cause the transition to pause, + * which could lead to a non-responsive UI if the hook is slow. + */ +function runEnterHooks(routes, nextState, callback) { + var hooks = getEnterHooks(routes); + return runTransitionHooks(hooks.length, function (index, replace, next) { + hooks[index](nextState, replace, next); + }, callback); +} + +/** + * Runs all onChange hooks in the given array of routes in order + * with onChange(prevState, nextState, replace, callback) and calls + * callback(error, redirectInfo) when finished. The first hook + * to use replace short-circuits the loop. + * + * If a hook needs to run asynchronously, it may use the callback + * function. However, doing so will cause the transition to pause, + * which could lead to a non-responsive UI if the hook is slow. + */ +function runChangeHooks(routes, state, nextState, callback) { + var hooks = getChangeHooks(routes); + return runTransitionHooks(hooks.length, function (index, replace, next) { + hooks[index](state, nextState, replace, next); + }, callback); +} + +/** + * Runs all onLeave hooks in the given array of routes in order. + */ +function runLeaveHooks(routes) { + for (var i = 0, len = routes.length; i < len; ++i) { + if (routes[i].onLeave) routes[i].onLeave.call(routes[i]); + } +} }).call(this,require('_process')) -},{"./AsyncUtils":40,"./routerWarning":72,"_process":32}],59:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;tr;r++)t[r]=arguments[r];var n=t.map(function(e){return e.renderRouterContext}).filter(function(e){return e}),u=t.map(function(e){return e.renderRouteComponent}).filter(function(e){return e}),o=function(){var e=arguments.length<=0||void 0===arguments[0]?_react.createElement:arguments[0];return function(t,r){return u.reduceRight(function(e,t){return t(e,r)},e(t,r))}};return function(e){return n.reduceRight(function(t,r){return r(t,e)},_react2["default"].createElement(_RouterContext2["default"],_extends({},e,{createElement:o(e.createElement)})))}},module.exports=exports["default"]; +},{"./AsyncUtils":41,"./routerWarning":73,"_process":33}],60:[function(require,module,exports){ +'use strict'; -},{"./RouterContext":55,"react":"react"}],60:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _createBrowserHistory=require("history/lib/createBrowserHistory"),_createBrowserHistory2=_interopRequireDefault(_createBrowserHistory),_createRouterHistory=require("./createRouterHistory"),_createRouterHistory2=_interopRequireDefault(_createRouterHistory);exports["default"]=(0,_createRouterHistory2["default"])(_createBrowserHistory2["default"]),module.exports=exports["default"]; +exports.__esModule = true; -},{"./createRouterHistory":63,"history/lib/createBrowserHistory":12}],61:[function(require,module,exports){ -"use strict";function routeParamsChanged(e,t,r){if(!e.path)return!1;var a=(0,_PatternUtils.getParamNames)(e.path);return a.some(function(e){return t.params[e]!==r.params[e]})}function computeChangedRoutes(e,t){var r=e&&e.routes,a=t.routes,u=void 0,n=void 0,o=void 0;return r?!function(){var s=!1;u=r.filter(function(r){if(s)return!0;var u=-1===a.indexOf(r)||routeParamsChanged(r,e,t);return u&&(s=!0),u}),u.reverse(),o=[],n=[],a.forEach(function(e){var t=-1===r.indexOf(e),a=-1!==u.indexOf(e);t||a?o.push(e):n.push(e)})}():(u=[],n=[],o=a),{leaveRoutes:u,changeRoutes:n,enterRoutes:o}}exports.__esModule=!0;var _PatternUtils=require("./PatternUtils");exports["default"]=computeChangedRoutes,module.exports=exports["default"]; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -},{"./PatternUtils":48}],62:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function createMemoryHistory(e){var r=(0,_createMemoryHistory2["default"])(e),t=function(){return r},u=(0,_useQueries2["default"])((0,_useBasename2["default"])(t))(e);return u.__v2_compatible__=!0,u}exports.__esModule=!0,exports["default"]=createMemoryHistory;var _useQueries=require("history/lib/useQueries"),_useQueries2=_interopRequireDefault(_useQueries),_useBasename=require("history/lib/useBasename"),_useBasename2=_interopRequireDefault(_useBasename),_createMemoryHistory=require("history/lib/createMemoryHistory"),_createMemoryHistory2=_interopRequireDefault(_createMemoryHistory);module.exports=exports["default"]; +var _react = require('react'); -},{"history/lib/createMemoryHistory":17,"history/lib/useBasename":20,"history/lib/useQueries":21}],63:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0,exports["default"]=function(e){var t=void 0;return canUseDOM&&(t=(0,_useRouterHistory2["default"])(e)()),t};var _useRouterHistory=require("./useRouterHistory"),_useRouterHistory2=_interopRequireDefault(_useRouterHistory),canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement);module.exports=exports["default"]; +var _react2 = _interopRequireDefault(_react); -},{"./useRouterHistory":73}],64:[function(require,module,exports){ +var _RouterContext = require('./RouterContext'); + +var _RouterContext2 = _interopRequireDefault(_RouterContext); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function () { + for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) { + middlewares[_key] = arguments[_key]; + } + + var withContext = middlewares.map(function (m) { + return m.renderRouterContext; + }).filter(function (f) { + return f; + }); + var withComponent = middlewares.map(function (m) { + return m.renderRouteComponent; + }).filter(function (f) { + return f; + }); + var makeCreateElement = function makeCreateElement() { + var baseCreateElement = arguments.length <= 0 || arguments[0] === undefined ? _react.createElement : arguments[0]; + return function (Component, props) { + return withComponent.reduceRight(function (previous, renderRouteComponent) { + return renderRouteComponent(previous, props); + }, baseCreateElement(Component, props)); + }; + }; + + return function (renderProps) { + return withContext.reduceRight(function (previous, renderRouterContext) { + return renderRouterContext(previous, renderProps); + }, _react2.default.createElement(_RouterContext2.default, _extends({}, renderProps, { + createElement: makeCreateElement(renderProps.createElement) + }))); + }; +}; + +module.exports = exports['default']; +},{"./RouterContext":56,"react":"react"}],61:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _createBrowserHistory = require('history/lib/createBrowserHistory'); + +var _createBrowserHistory2 = _interopRequireDefault(_createBrowserHistory); + +var _createRouterHistory = require('./createRouterHistory'); + +var _createRouterHistory2 = _interopRequireDefault(_createRouterHistory); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = (0, _createRouterHistory2.default)(_createBrowserHistory2.default); +module.exports = exports['default']; +},{"./createRouterHistory":64,"history/lib/createBrowserHistory":12}],62:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _PatternUtils = require('./PatternUtils'); + +function routeParamsChanged(route, prevState, nextState) { + if (!route.path) return false; + + var paramNames = (0, _PatternUtils.getParamNames)(route.path); + + return paramNames.some(function (paramName) { + return prevState.params[paramName] !== nextState.params[paramName]; + }); +} + +/** + * Returns an object of { leaveRoutes, changeRoutes, enterRoutes } determined by + * the change from prevState to nextState. We leave routes if either + * 1) they are not in the next state or 2) they are in the next state + * but their params have changed (i.e. /users/123 => /users/456). + * + * leaveRoutes are ordered starting at the leaf route of the tree + * we're leaving up to the common parent route. enterRoutes are ordered + * from the top of the tree we're entering down to the leaf route. + * + * changeRoutes are any routes that didn't leave or enter during + * the transition. + */ +function computeChangedRoutes(prevState, nextState) { + var prevRoutes = prevState && prevState.routes; + var nextRoutes = nextState.routes; + + var leaveRoutes = void 0, + changeRoutes = void 0, + enterRoutes = void 0; + if (prevRoutes) { + (function () { + var parentIsLeaving = false; + leaveRoutes = prevRoutes.filter(function (route) { + if (parentIsLeaving) { + return true; + } else { + var isLeaving = nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState); + if (isLeaving) parentIsLeaving = true; + return isLeaving; + } + }); + + // onLeave hooks start at the leaf route. + leaveRoutes.reverse(); + + enterRoutes = []; + changeRoutes = []; + + nextRoutes.forEach(function (route) { + var isNew = prevRoutes.indexOf(route) === -1; + var paramsChanged = leaveRoutes.indexOf(route) !== -1; + + if (isNew || paramsChanged) enterRoutes.push(route);else changeRoutes.push(route); + }); + })(); + } else { + leaveRoutes = []; + changeRoutes = []; + enterRoutes = nextRoutes; + } + + return { + leaveRoutes: leaveRoutes, + changeRoutes: changeRoutes, + enterRoutes: enterRoutes + }; +} + +exports.default = computeChangedRoutes; +module.exports = exports['default']; +},{"./PatternUtils":49}],63:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports.default = createMemoryHistory; + +var _useQueries = require('history/lib/useQueries'); + +var _useQueries2 = _interopRequireDefault(_useQueries); + +var _useBasename = require('history/lib/useBasename'); + +var _useBasename2 = _interopRequireDefault(_useBasename); + +var _createMemoryHistory = require('history/lib/createMemoryHistory'); + +var _createMemoryHistory2 = _interopRequireDefault(_createMemoryHistory); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function createMemoryHistory(options) { + // signatures and type checking differ between `useRoutes` and + // `createMemoryHistory`, have to create `memoryHistory` first because + // `useQueries` doesn't understand the signature + var memoryHistory = (0, _createMemoryHistory2.default)(options); + var createHistory = function createHistory() { + return memoryHistory; + }; + var history = (0, _useQueries2.default)((0, _useBasename2.default)(createHistory))(options); + history.__v2_compatible__ = true; + return history; +} +module.exports = exports['default']; +},{"history/lib/createMemoryHistory":17,"history/lib/useBasename":20,"history/lib/useQueries":21}],64:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +exports.default = function (createHistory) { + var history = void 0; + if (canUseDOM) history = (0, _useRouterHistory2.default)(createHistory)(); + return history; +}; + +var _useRouterHistory = require('./useRouterHistory'); + +var _useRouterHistory2 = _interopRequireDefault(_useRouterHistory); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + +module.exports = exports['default']; +},{"./useRouterHistory":74}],65:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function hasAnyProperties(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function createTransitionManager(e,t){function n(t){var n=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],o=arguments.length<=2||void 0===arguments[2]?null:arguments[2],r=void 0;return n&&n!==!0||null!==o?("production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"`isActive(pathname, query, indexOnly) is deprecated; use `isActive(location, indexOnly)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated"):void 0,t={pathname:t,query:n},r=o||!1):(t=e.createLocation(t),r=n),(0,_isActive3["default"])(t,r,_.location,_.routes,_.params)}function o(t){return e.createLocation(t,_Actions.REPLACE)}function r(e,n){p&&p.location===e?i(p,n):(0,_matchRoutes2["default"])(t,e,function(t,o){t?n(t):o?i(_extends({},o,{location:e}),n):n()})}function i(e,t){function n(n,o){return n||o?r(n,o):void(0,_getComponents2["default"])(e,function(n,o){n?t(n):t(null,null,_=_extends({},e,{components:o}))})}function r(e,n){e?t(e):t(null,o(n))}var i=(0,_computeChangedRoutes3["default"])(_,e),u=i.leaveRoutes,a=i.changeRoutes,s=i.enterRoutes;(0,_TransitionUtils.runLeaveHooks)(u),u.filter(function(e){return-1===s.indexOf(e)}).forEach(l),(0,_TransitionUtils.runChangeHooks)(a,_,e,function(t,o){return t||o?r(t,o):void(0,_TransitionUtils.runEnterHooks)(s,e,n)})}function u(e){var t=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return e.__id__||t&&(e.__id__=v++)}function a(e){return e.reduce(function(e,t){return e.push.apply(e,h[u(t)]),e},[])}function s(e,n){(0,_matchRoutes2["default"])(t,e,function(t,o){if(null==o)return void n();p=_extends({},o,{location:e});for(var r=a((0,_computeChangedRoutes3["default"])(_,p).leaveRoutes),i=void 0,u=0,s=r.length;null==i&&s>u;++u)i=r[u](e);n(i)})}function c(){if(_.routes){for(var e=a(_.routes),t=void 0,n=0,o=e.length;"string"!=typeof t&&o>n;++n)t=e[n]();return t}}function l(e){var t=u(e,!1);t&&(delete h[t],hasAnyProperties(h)||(g&&(g(),g=null),m&&(m(),m=null)))}function d(t,n){var o=u(t),r=h[o];if(r)-1===r.indexOf(n)&&("production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"adding multiple leave hooks for the same route is deprecated; manage multiple confirmations in your own code instead"):void 0,r.push(n));else{var i=!hasAnyProperties(h);h[o]=[n],i&&(g=e.listenBefore(s),e.listenBeforeUnload&&(m=e.listenBeforeUnload(c)))}return function(){var e=h[o];if(e){var r=e.filter(function(e){return e!==n});0===r.length?l(t):h[o]=r}}}function f(t){return e.listen(function(n){_.location===n?t(null,_):r(n,function(o,r,i){o?t(o):r?e.transitionTo(r):i?t(null,i):"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,'Location "%s" did not match any routes',n.pathname+n.search+n.hash):void 0})})}var _={},p=void 0,v=1,h=Object.create(null),g=void 0,m=void 0;return{isActive:n,match:r,listenBeforeLeavingRoute:d,listen:f}}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;ta;++a){var l=e[a],c=l.path||"";if("/"===c.charAt(0)&&(n=t,u=[],i=[]),null!==n&&c){var f=(0,_PatternUtils.matchPattern)(c,n);if(f?(n=f.remainingPathname,u=[].concat(u,f.paramNames),i=[].concat(i,f.paramValues)):n=null,""===n)return u.every(function(t,e){return String(i[e])===String(r[t])})}}return!1}function queryIsActive(t,e){return null==e?null==t:null==t?!0:deepEqual(t,e)}function isActive(t,e,r,n,u){var i=t.pathname,a=t.query;return null==r?!1:("/"!==i.charAt(0)&&(i="/"+i),pathIsActive(i,r.pathname)||!e&&routeIsActive(i,n,u)?queryIsActive(a,r.query):!1)}exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};exports["default"]=isActive;var _PatternUtils=require("./PatternUtils");module.exports=exports["default"]; +var _PatternUtils = require('./PatternUtils'); -},{"./PatternUtils":48}],70:[function(require,module,exports){ +/** + * Extracts an object of params the given route cares about from + * the given params object. + */ +function getRouteParams(route, params) { + var routeParams = {}; + + if (!route.path) return routeParams; + + var paramNames = (0, _PatternUtils.getParamNames)(route.path); + + for (var p in params) { + if (Object.prototype.hasOwnProperty.call(params, p) && paramNames.indexOf(p) !== -1) { + routeParams[p] = params[p]; + } + } + + return routeParams; +} + +exports.default = getRouteParams; +module.exports = exports['default']; +},{"./PatternUtils":49}],69:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _createHashHistory = require('history/lib/createHashHistory'); + +var _createHashHistory2 = _interopRequireDefault(_createHashHistory); + +var _createRouterHistory = require('./createRouterHistory'); + +var _createRouterHistory2 = _interopRequireDefault(_createRouterHistory); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = (0, _createRouterHistory2.default)(_createHashHistory2.default); +module.exports = exports['default']; +},{"./createRouterHistory":64,"history/lib/createHashHistory":14}],70:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + +exports.default = isActive; + +var _PatternUtils = require('./PatternUtils'); + +function deepEqual(a, b) { + if (a == b) return true; + + if (a == null || b == null) return false; + + if (Array.isArray(a)) { + return Array.isArray(b) && a.length === b.length && a.every(function (item, index) { + return deepEqual(item, b[index]); + }); + } + + if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object') { + for (var p in a) { + if (!Object.prototype.hasOwnProperty.call(a, p)) { + continue; + } + + if (a[p] === undefined) { + if (b[p] !== undefined) { + return false; + } + } else if (!Object.prototype.hasOwnProperty.call(b, p)) { + return false; + } else if (!deepEqual(a[p], b[p])) { + return false; + } + } + + return true; + } + + return String(a) === String(b); +} + +/** + * Returns true if the current pathname matches the supplied one, net of + * leading and trailing slash normalization. This is sufficient for an + * indexOnly route match. + */ +function pathIsActive(pathname, currentPathname) { + // Normalize leading slash for consistency. Leading slash on pathname has + // already been normalized in isActive. See caveat there. + if (currentPathname.charAt(0) !== '/') { + currentPathname = '/' + currentPathname; + } + + // Normalize the end of both path names too. Maybe `/foo/` shouldn't show + // `/foo` as active, but in this case, we would already have failed the + // match. + if (pathname.charAt(pathname.length - 1) !== '/') { + pathname += '/'; + } + if (currentPathname.charAt(currentPathname.length - 1) !== '/') { + currentPathname += '/'; + } + + return currentPathname === pathname; +} + +/** + * Returns true if the given pathname matches the active routes and params. + */ +function routeIsActive(pathname, routes, params) { + var remainingPathname = pathname, + paramNames = [], + paramValues = []; + + // for...of would work here but it's probably slower post-transpilation. + for (var i = 0, len = routes.length; i < len; ++i) { + var route = routes[i]; + var pattern = route.path || ''; + + if (pattern.charAt(0) === '/') { + remainingPathname = pathname; + paramNames = []; + paramValues = []; + } + + if (remainingPathname !== null && pattern) { + var matched = (0, _PatternUtils.matchPattern)(pattern, remainingPathname); + if (matched) { + remainingPathname = matched.remainingPathname; + paramNames = [].concat(paramNames, matched.paramNames); + paramValues = [].concat(paramValues, matched.paramValues); + } else { + remainingPathname = null; + } + + if (remainingPathname === '') { + // We have an exact match on the route. Just check that all the params + // match. + // FIXME: This doesn't work on repeated params. + return paramNames.every(function (paramName, index) { + return String(paramValues[index]) === String(params[paramName]); + }); + } + } + } + + return false; +} + +/** + * Returns true if all key/value pairs in the given query are + * currently active. + */ +function queryIsActive(query, activeQuery) { + if (activeQuery == null) return query == null; + + if (query == null) return true; + + return deepEqual(query, activeQuery); +} + +/** + * Returns true if a to the given pathname/query combination is + * currently active. + */ +function isActive(_ref, indexOnly, currentLocation, routes, params) { + var pathname = _ref.pathname; + var query = _ref.query; + + if (currentLocation == null) return false; + + // TODO: This is a bit ugly. It keeps around support for treating pathnames + // without preceding slashes as absolute paths, but possibly also works + // around the same quirks with basenames as in matchRoutes. + if (pathname.charAt(0) !== '/') { + pathname = '/' + pathname; + } + + if (!pathIsActive(pathname, currentLocation.pathname)) { + // The path check is necessary and sufficient for indexOnly, but otherwise + // we still need to check the routes. + if (indexOnly || !routeIsActive(pathname, routes, params)) { + return false; + } + } + + return queryIsActive(query, currentLocation.query); +} +module.exports = exports['default']; +},{"./PatternUtils":49}],71:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _objectWithoutProperties(e,t){var r={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}function match(e,t){var r=e.history,o=e.routes,a=e.location,i=_objectWithoutProperties(e,["history","routes","location"]);r||a?void 0:"production"!==process.env.NODE_ENV?(0,_invariant2["default"])(!1,"match needs a history or a location"):(0,_invariant2["default"])(!1),r=r?r:(0,_createMemoryHistory2["default"])(i);var n=(0,_createTransitionManager2["default"])(r,(0,_RouteUtils.createRoutes)(o)),u=void 0;a?a=r.createLocation(a):u=r.listen(function(e){a=e});var s=(0,_RouterUtils.createRouterObject)(r,n);r=(0,_RouterUtils.createRoutingHistory)(r,n),n.match(a,function(e,o,a){t(e,o,a&&_extends({},a,{history:r,router:s,matchContext:{history:r,transitionManager:n,router:s}})),u&&u()})}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;t= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +/** + * A high-level API to be used for server-side rendering. + * + * This function matches a location to a set of routes and calls + * callback(error, redirectLocation, renderProps) when finished. + * + * Note: You probably don't want to use this in a browser unless you're using + * server-side rendering with async routes. + */ +function match(_ref, callback) { + var history = _ref.history; + var routes = _ref.routes; + var location = _ref.location; + + var options = _objectWithoutProperties(_ref, ['history', 'routes', 'location']); + + !(history || location) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'match needs a history or a location') : (0, _invariant2.default)(false) : void 0; + + history = history ? history : (0, _createMemoryHistory2.default)(options); + var transitionManager = (0, _createTransitionManager2.default)(history, (0, _RouteUtils.createRoutes)(routes)); + + var unlisten = void 0; + + if (location) { + // Allow match({ location: '/the/path', ... }) + location = history.createLocation(location); + } else { + // Pick up the location from the history via synchronous history.listen + // call if needed. + unlisten = history.listen(function (historyLocation) { + location = historyLocation; + }); + } + + var router = (0, _RouterUtils.createRouterObject)(history, transitionManager); + history = (0, _RouterUtils.createRoutingHistory)(history, transitionManager); + + transitionManager.match(location, function (error, redirectLocation, nextState) { + callback(error, redirectLocation, nextState && _extends({}, nextState, { + history: history, + router: router, + matchContext: { history: history, transitionManager: transitionManager, router: router } + })); + + // Defer removing the listener to here to prevent DOM histories from having + // to unwind DOM event listeners unnecessarily, in case callback renders a + // and attaches another history listener. + if (unlisten) { + unlisten(); + } + }); +} + +exports.default = match; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./RouteUtils":53,"./RouterUtils":56,"./createMemoryHistory":62,"./createTransitionManager":64,"_process":32,"invariant":76}],71:[function(require,module,exports){ +},{"./RouteUtils":54,"./RouterUtils":57,"./createMemoryHistory":63,"./createTransitionManager":65,"_process":33,"invariant":23}],72:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{"default":t}}function getChildRoutes(t,e,n){if(t.childRoutes)return[null,t.childRoutes];if(!t.getChildRoutes)return[];var r=!0,o=void 0;return t.getChildRoutes(e,function(t,e){return e=!t&&(0,_RouteUtils.createRoutes)(e),r?void(o=[t,e]):void n(t,e)}),r=!1,o}function getIndexRoute(t,e,n){t.indexRoute?n(null,t.indexRoute):t.getIndexRoute?t.getIndexRoute(e,function(t,e){n(t,!t&&(0,_RouteUtils.createRoutes)(e)[0])}):t.childRoutes?!function(){var r=t.childRoutes.filter(function(t){return!t.path});(0,_AsyncUtils.loopAsync)(r.length,function(t,n,o){getIndexRoute(r[t],e,function(e,u){if(e||u){var a=[r[t]].concat(Array.isArray(u)?u:[u]);o(e,a)}else n()})},function(t,e){n(null,e)})}():n()}function assignParams(t,e,n){return e.reduce(function(t,e,r){var o=n&&n[r];return Array.isArray(t[e])?t[e].push(o):e in t?t[e]=[t[e],o]:t[e]=o,t},t)}function createParams(t,e){return assignParams({},t,e)}function matchRouteDeep(t,e,n,r,o,u){var a=t.path||"";if("/"===a.charAt(0)&&(n=e.pathname,r=[],o=[]),null!==n&&a){try{var i=(0,_PatternUtils.matchPattern)(a,n);i?(n=i.remainingPathname,r=[].concat(r,i.paramNames),o=[].concat(o,i.paramValues)):n=null}catch(s){u(s)}if(""===n){var l=function(){var n={routes:[t],params:createParams(r,o)};return getIndexRoute(t,e,function(t,e){if(t)u(t);else{if(Array.isArray(e)){var r;"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(e.every(function(t){return!t.path}),"Index routes should not have paths"):void 0,(r=n.routes).push.apply(r,e)}else e&&("production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!e.path,"Index routes should not have paths"):void 0,n.routes.push(e));u(null,n)}}),{v:void 0}}();if("object"===("undefined"==typeof l?"undefined":_typeof(l)))return l.v}}if(null!=n||t.childRoutes){var c=function(a,i){a?u(a):i?matchRoutes(i,e,function(e,n){e?u(e):n?(n.routes.unshift(t),u(null,n)):u()},n,r,o):u()},f=getChildRoutes(t,e,c);f&&c.apply(void 0,f)}else u()}function matchRoutes(t,e,n,r){var o=arguments.length<=4||void 0===arguments[4]?[]:arguments[4],u=arguments.length<=5||void 0===arguments[5]?[]:arguments[5];void 0===r&&("/"!==e.pathname.charAt(0)&&(e=_extends({},e,{pathname:"/"+e.pathname})),r=e.pathname),(0,_AsyncUtils.loopAsync)(t.length,function(n,a,i){matchRouteDeep(t[n],e,r,o,u,function(t,e){t||e?i(t,e):a()})},n)}exports.__esModule=!0;var _extends=Object.assign||function(t){for(var e=1;e2?n-2:0),a=2;n>a;a++)t[a-2]=arguments[a];_warning2["default"].apply(void 0,[e,r].concat(t))}function _resetWarned(){warned={}}exports.__esModule=!0,exports["default"]=routerWarning,exports._resetWarned=_resetWarned;var _warning=require("warning"),_warning2=_interopRequireDefault(_warning),warned={}; +},{"./AsyncUtils":41,"./PatternUtils":49,"./RouteUtils":54,"./routerWarning":73,"_process":33}],73:[function(require,module,exports){ +'use strict'; -},{"warning":250}],73:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function useRouterHistory(e){return function(u){var r=(0,_useQueries2["default"])((0,_useBasename2["default"])(e))(u);return r.__v2_compatible__=!0,r}}exports.__esModule=!0,exports["default"]=useRouterHistory;var _useQueries=require("history/lib/useQueries"),_useQueries2=_interopRequireDefault(_useQueries),_useBasename=require("history/lib/useBasename"),_useBasename2=_interopRequireDefault(_useBasename);module.exports=exports["default"]; +exports.__esModule = true; +exports.default = routerWarning; +exports._resetWarned = _resetWarned; -},{"history/lib/useBasename":20,"history/lib/useQueries":21}],74:[function(require,module,exports){ +var _warning = require('warning'); + +var _warning2 = _interopRequireDefault(_warning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var warned = {}; + +function routerWarning(falseToWarn, message) { + // Only issue deprecation warnings once. + if (message.indexOf('deprecated') !== -1) { + if (warned[message]) { + return; + } + + warned[message] = true; + } + + message = '[react-router] ' + message; + + for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + _warning2.default.apply(undefined, [falseToWarn, message].concat(args)); +} + +function _resetWarned() { + warned = {}; +} +},{"warning":249}],74:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports.default = useRouterHistory; + +var _useQueries = require('history/lib/useQueries'); + +var _useQueries2 = _interopRequireDefault(_useQueries); + +var _useBasename = require('history/lib/useBasename'); + +var _useBasename2 = _interopRequireDefault(_useBasename); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function useRouterHistory(createHistory) { + return function (options) { + var history = (0, _useQueries2.default)((0, _useBasename2.default)(createHistory))(options); + history.__v2_compatible__ = true; + return history; + }; +} +module.exports = exports['default']; +},{"history/lib/useBasename":20,"history/lib/useQueries":21}],75:[function(require,module,exports){ (function (process){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _objectWithoutProperties(e,r){var t={};for(var n in e)r.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}function useRoutes(e){return"production"!==process.env.NODE_ENV?(0,_routerWarning2["default"])(!1,"`useRoutes` is deprecated. Please use `createTransitionManager` instead."):void 0,function(){var r=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=r.routes,n=_objectWithoutProperties(r,["routes"]),u=(0,_useQueries2["default"])(e)(n),a=(0,_createTransitionManager2["default"])(u,t);return _extends({},u,a)}}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var r=1;r= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +/** + * Returns a new createHistory function that may be used to create + * history objects that know about routing. + * + * Enhances history objects with the following methods: + * + * - listen((error, nextState) => {}) + * - listenBeforeLeavingRoute(route, (nextLocation) => {}) + * - match(location, (error, redirectLocation, nextState) => {}) + * - isActive(pathname, query, indexOnly=false) + */ +function useRoutes(createHistory) { + process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, '`useRoutes` is deprecated. Please use `createTransitionManager` instead.') : void 0; + + return function () { + var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + var routes = _ref.routes; + + var options = _objectWithoutProperties(_ref, ['routes']); + + var history = (0, _useQueries2.default)(createHistory)(options); + var transitionManager = (0, _createTransitionManager2.default)(history, routes); + return _extends({}, history, transitionManager); + }; +} + +exports.default = useRoutes; +module.exports = exports['default']; }).call(this,require('_process')) -},{"./createTransitionManager":64,"./routerWarning":72,"_process":32,"history/lib/useQueries":21}],75:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function getDisplayName(e){return e.displayName||e.name||"Component"}function withRouter(e){var t=_react2["default"].createClass({displayName:"WithRouter",contextTypes:{router:_PropTypes.routerShape},render:function(){return _react2["default"].createElement(e,_extends({},this.props,{router:this.context.router}))}});return t.displayName="withRouter("+getDisplayName(e)+")",t.WrappedComponent=e,(0,_hoistNonReactStatics2["default"])(t,e)}exports.__esModule=!0;var _extends=Object.assign||function(e){for(var t=1;t8&&11>=documentMode),SPACEBAR_CODE=32,SPACEBAR_CHAR=String.fromCharCode(SPACEBAR_CODE),topLevelTypes=EventConstants.topLevelTypes,eventTypes={beforeInput:{phasedRegistrationNames:{bubbled:keyOf({onBeforeInput:null}),captured:keyOf({onBeforeInputCapture:null})},dependencies:[topLevelTypes.topCompositionEnd,topLevelTypes.topKeyPress,topLevelTypes.topTextInput,topLevelTypes.topPaste]},compositionEnd:{phasedRegistrationNames:{bubbled:keyOf({onCompositionEnd:null}),captured:keyOf({onCompositionEndCapture:null})},dependencies:[topLevelTypes.topBlur,topLevelTypes.topCompositionEnd,topLevelTypes.topKeyDown,topLevelTypes.topKeyPress,topLevelTypes.topKeyUp,topLevelTypes.topMouseDown]},compositionStart:{phasedRegistrationNames:{bubbled:keyOf({onCompositionStart:null}),captured:keyOf({onCompositionStartCapture:null})},dependencies:[topLevelTypes.topBlur,topLevelTypes.topCompositionStart,topLevelTypes.topKeyDown,topLevelTypes.topKeyPress,topLevelTypes.topKeyUp,topLevelTypes.topMouseDown]},compositionUpdate:{phasedRegistrationNames:{bubbled:keyOf({onCompositionUpdate:null}),captured:keyOf({onCompositionUpdateCapture:null})},dependencies:[topLevelTypes.topBlur,topLevelTypes.topCompositionUpdate,topLevelTypes.topKeyDown,topLevelTypes.topKeyPress,topLevelTypes.topKeyUp,topLevelTypes.topMouseDown]}},hasSpaceKeypress=!1,currentComposition=null,BeforeInputEventPlugin={eventTypes:eventTypes,extractEvents:function(e,t,o,n){return[extractCompositionEvent(e,t,o,n),extractBeforeInputEvent(e,t,o,n)]}};module.exports=BeforeInputEventPlugin; +/** + * Copyright 2013-present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule BeforeInputEventPlugin + */ +'use strict'; + +var EventConstants = require('./EventConstants'); +var EventPropagators = require('./EventPropagators'); +var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); +var FallbackCompositionState = require('./FallbackCompositionState'); +var SyntheticCompositionEvent = require('./SyntheticCompositionEvent'); +var SyntheticInputEvent = require('./SyntheticInputEvent'); + +var keyOf = require('fbjs/lib/keyOf'); + +var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space +var START_KEYCODE = 229; + +var canUseCompositionEvent = ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window; + +var documentMode = null; +if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) { + documentMode = document.documentMode; +} + +// Webkit offers a very useful `textInput` event that can be used to +// directly represent `beforeInput`. The IE `textinput` event is not as +// useful, so we don't use it. +var canUseTextInputEvent = ExecutionEnvironment.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto(); + +// In IE9+, we have access to composition events, but the data supplied +// by the native compositionend event may be incorrect. Japanese ideographic +// spaces, for instance (\u3000) are not recorded correctly. +var useFallbackCompositionData = ExecutionEnvironment.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); + +/** + * Opera <= 12 includes TextEvent in window, but does not fire + * text input events. Rely on keypress instead. + */ +function isPresto() { + var opera = window.opera; + return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12; +} + +var SPACEBAR_CODE = 32; +var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); + +var topLevelTypes = EventConstants.topLevelTypes; + +// Events and their corresponding property names. +var eventTypes = { + beforeInput: { + phasedRegistrationNames: { + bubbled: keyOf({ onBeforeInput: null }), + captured: keyOf({ onBeforeInputCapture: null }) + }, + dependencies: [topLevelTypes.topCompositionEnd, topLevelTypes.topKeyPress, topLevelTypes.topTextInput, topLevelTypes.topPaste] + }, + compositionEnd: { + phasedRegistrationNames: { + bubbled: keyOf({ onCompositionEnd: null }), + captured: keyOf({ onCompositionEndCapture: null }) + }, + dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionEnd, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown] + }, + compositionStart: { + phasedRegistrationNames: { + bubbled: keyOf({ onCompositionStart: null }), + captured: keyOf({ onCompositionStartCapture: null }) + }, + dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionStart, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown] + }, + compositionUpdate: { + phasedRegistrationNames: { + bubbled: keyOf({ onCompositionUpdate: null }), + captured: keyOf({ onCompositionUpdateCapture: null }) + }, + dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionUpdate, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown] + } +}; + +// Track whether we've ever handled a keypress on the space key. +var hasSpaceKeypress = false; + +/** + * Return whether a native keypress event is assumed to be a command. + * This is required because Firefox fires `keypress` events for key commands + * (cut, copy, select-all, etc.) even though no character is inserted. + */ +function isKeypressCommand(nativeEvent) { + return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && + // ctrlKey && altKey is equivalent to AltGr, and is not a command. + !(nativeEvent.ctrlKey && nativeEvent.altKey); +} + +/** + * Translate native top level events into event types. + * + * @param {string} topLevelType + * @return {object} + */ +function getCompositionEventType(topLevelType) { + switch (topLevelType) { + case topLevelTypes.topCompositionStart: + return eventTypes.compositionStart; + case topLevelTypes.topCompositionEnd: + return eventTypes.compositionEnd; + case topLevelTypes.topCompositionUpdate: + return eventTypes.compositionUpdate; + } +} + +/** + * Does our fallback best-guess model think this event signifies that + * composition has begun? + * + * @param {string} topLevelType + * @param {object} nativeEvent + * @return {boolean} + */ +function isFallbackCompositionStart(topLevelType, nativeEvent) { + return topLevelType === topLevelTypes.topKeyDown && nativeEvent.keyCode === START_KEYCODE; +} + +/** + * Does our fallback mode think that this event is the end of composition? + * + * @param {string} topLevelType + * @param {object} nativeEvent + * @return {boolean} + */ +function isFallbackCompositionEnd(topLevelType, nativeEvent) { + switch (topLevelType) { + case topLevelTypes.topKeyUp: + // Command keys insert or clear IME input. + return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; + case topLevelTypes.topKeyDown: + // Expect IME keyCode on each keydown. If we get any other + // code we must have exited earlier. + return nativeEvent.keyCode !== START_KEYCODE; + case topLevelTypes.topKeyPress: + case topLevelTypes.topMouseDown: + case topLevelTypes.topBlur: + // Events are not possible without cancelling IME. + return true; + default: + return false; + } +} + +/** + * Google Input Tools provides composition data via a CustomEvent, + * with the `data` property populated in the `detail` object. If this + * is available on the event object, use it. If not, this is a plain + * composition event and we have nothing special to extract. + * + * @param {object} nativeEvent + * @return {?string} + */ +function getDataFromCustomEvent(nativeEvent) { + var detail = nativeEvent.detail; + if (typeof detail === 'object' && 'data' in detail) { + return detail.data; + } + return null; +} + +// Track the current IME composition fallback object, if any. +var currentComposition = null; + +/** + * @return {?object} A SyntheticCompositionEvent. + */ +function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { + var eventType; + var fallbackData; + + if (canUseCompositionEvent) { + eventType = getCompositionEventType(topLevelType); + } else if (!currentComposition) { + if (isFallbackCompositionStart(topLevelType, nativeEvent)) { + eventType = eventTypes.compositionStart; + } + } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { + eventType = eventTypes.compositionEnd; + } + + if (!eventType) { + return null; + } + + if (useFallbackCompositionData) { + // The current composition is stored statically and must not be + // overwritten while composition continues. + if (!currentComposition && eventType === eventTypes.compositionStart) { + currentComposition = FallbackCompositionState.getPooled(nativeEventTarget); + } else if (eventType === eventTypes.compositionEnd) { + if (currentComposition) { + fallbackData = currentComposition.getData(); + } + } + } + + var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); + + if (fallbackData) { + // Inject data generated from fallback path into the synthetic event. + // This matches the property of native CompositionEventInterface. + event.data = fallbackData; + } else { + var customData = getDataFromCustomEvent(nativeEvent); + if (customData !== null) { + event.data = customData; + } + } + + EventPropagators.accumulateTwoPhaseDispatches(event); + return event; +} + +/** + * @param {string} topLevelType Record from `EventConstants`. + * @param {object} nativeEvent Native browser event. + * @return {?string} The string corresponding to this `beforeInput` event. + */ +function getNativeBeforeInputChars(topLevelType, nativeEvent) { + switch (topLevelType) { + case topLevelTypes.topCompositionEnd: + return getDataFromCustomEvent(nativeEvent); + case topLevelTypes.topKeyPress: + /** + * If native `textInput` events are available, our goal is to make + * use of them. However, there is a special case: the spacebar key. + * In Webkit, preventing default on a spacebar `textInput` event + * cancels character insertion, but it *also* causes the browser + * to fall back to its default spacebar behavior of scrolling the + * page. + * + * Tracking at: + * https://code.google.com/p/chromium/issues/detail?id=355103 + * + * To avoid this issue, use the keypress event as if no `textInput` + * event is available. + */ + var which = nativeEvent.which; + if (which !== SPACEBAR_CODE) { + return null; + } + + hasSpaceKeypress = true; + return SPACEBAR_CHAR; + + case topLevelTypes.topTextInput: + // Record the characters to be added to the DOM. + var chars = nativeEvent.data; + + // If it's a spacebar character, assume that we have already handled + // it at the keypress level and bail immediately. Android Chrome + // doesn't give us keycodes, so we need to blacklist it. + if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { + return null; + } + + return chars; + + default: + // For other native event types, do nothing. + return null; + } +} + +/** + * For browsers that do not provide the `textInput` event, extract the + * appropriate string to use for SyntheticInputEvent. + * + * @param {string} topLevelType Record from `EventConstants`. + * @param {object} nativeEvent Native browser event. + * @return {?string} The fallback string for this `beforeInput` event. + */ +function getFallbackBeforeInputChars(topLevelType, nativeEvent) { + // If we are currently composing (IME) and using a fallback to do so, + // try to extract the composed characters from the fallback object. + if (currentComposition) { + if (topLevelType === topLevelTypes.topCompositionEnd || isFallbackCompositionEnd(topLevelType, nativeEvent)) { + var chars = currentComposition.getData(); + FallbackCompositionState.release(currentComposition); + currentComposition = null; + return chars; + } + return null; + } + + switch (topLevelType) { + case topLevelTypes.topPaste: + // If a paste event occurs after a keypress, throw out the input + // chars. Paste events should not lead to BeforeInput events. + return null; + case topLevelTypes.topKeyPress: + /** + * As of v27, Firefox may fire keypress events even when no character + * will be inserted. A few possibilities: + * + * - `which` is `0`. Arrow keys, Esc key, etc. + * + * - `which` is the pressed key code, but no char is available. + * Ex: 'AltGr + d` in Polish. There is no modified character for + * this key combination and no character is inserted into the + * document, but FF fires the keypress for char code `100` anyway. + * No `input` event will occur. + * + * - `which` is the pressed key code, but a command combination is + * being used. Ex: `Cmd+C`. No character is inserted, and no + * `input` event will occur. + */ + if (nativeEvent.which && !isKeypressCommand(nativeEvent)) { + return String.fromCharCode(nativeEvent.which); + } + return null; + case topLevelTypes.topCompositionEnd: + return useFallbackCompositionData ? null : nativeEvent.data; + default: + return null; + } +} + +/** + * Extract a SyntheticInputEvent for `beforeInput`, based on either native + * `textInput` or fallback behavior. + * + * @return {?object} A SyntheticInputEvent. + */ +function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { + var chars; + + if (canUseTextInputEvent) { + chars = getNativeBeforeInputChars(topLevelType, nativeEvent); + } else { + chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); + } + + // If no characters are being inserted, no BeforeInput event should + // be fired. + if (!chars) { + return null; + } + + var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); + + event.data = chars; + EventPropagators.accumulateTwoPhaseDispatches(event); + return event; +} + +/** + * Create an `onBeforeInput` event to match + * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. + * + * This event plugin is based on the native `textInput` event + * available in Chrome, Safari, Opera, and IE. This event fires after + * `onKeyPress` and `onCompositionEnd`, but before `onInput`. + * + * `beforeInput` is spec'd but not implemented in any browsers, and + * the `input` event does not provide any useful information about what has + * actually been added, contrary to the spec. Thus, `textInput` is the best + * available event to identify the characters that have actually been inserted + * into the target node. + * + * This plugin is also responsible for emitting `composition` events, thus + * allowing us to share composition fallback code for both `beforeInput` and + * `composition` event types. + */ +var BeforeInputEventPlugin = { + + eventTypes: eventTypes, + + extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { + return [extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget)]; + } +}; + +module.exports = BeforeInputEventPlugin; },{"./EventConstants":92,"./EventPropagators":96,"./FallbackCompositionState":97,"./SyntheticCompositionEvent":172,"./SyntheticInputEvent":176,"fbjs/lib/ExecutionEnvironment":215,"fbjs/lib/keyOf":233}],79:[function(require,module,exports){ -"use strict";function prefixKey(o,r){return o+r.charAt(0).toUpperCase()+r.substring(1)}var isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},prefixes=["Webkit","ms","Moz","O"];Object.keys(isUnitlessNumber).forEach(function(o){prefixes.forEach(function(r){isUnitlessNumber[prefixKey(r,o)]=isUnitlessNumber[o]})});var shorthandPropertyExpansions={background:{backgroundAttachment:!0,backgroundColor:!0,backgroundImage:!0,backgroundPositionX:!0,backgroundPositionY:!0,backgroundRepeat:!0},backgroundPosition:{backgroundPositionX:!0,backgroundPositionY:!0},border:{borderWidth:!0,borderStyle:!0,borderColor:!0},borderBottom:{borderBottomWidth:!0,borderBottomStyle:!0,borderBottomColor:!0},borderLeft:{borderLeftWidth:!0,borderLeftStyle:!0,borderLeftColor:!0},borderRight:{borderRightWidth:!0,borderRightStyle:!0,borderRightColor:!0},borderTop:{borderTopWidth:!0,borderTopStyle:!0,borderTopColor:!0},font:{fontStyle:!0,fontVariant:!0,fontWeight:!0,fontSize:!0,lineHeight:!0,fontFamily:!0},outline:{outlineWidth:!0,outlineStyle:!0,outlineColor:!0}},CSSProperty={isUnitlessNumber:isUnitlessNumber,shorthandPropertyExpansions:shorthandPropertyExpansions};module.exports=CSSProperty; +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule CSSProperty + */ +'use strict'; + +/** + * CSS properties which accept numbers but are not in units of "px". + */ + +var isUnitlessNumber = { + animationIterationCount: true, + borderImageOutset: true, + borderImageSlice: true, + borderImageWidth: true, + boxFlex: true, + boxFlexGroup: true, + boxOrdinalGroup: true, + columnCount: true, + flex: true, + flexGrow: true, + flexPositive: true, + flexShrink: true, + flexNegative: true, + flexOrder: true, + gridRow: true, + gridColumn: true, + fontWeight: true, + lineClamp: true, + lineHeight: true, + opacity: true, + order: true, + orphans: true, + tabSize: true, + widows: true, + zIndex: true, + zoom: true, + + // SVG-related properties + fillOpacity: true, + floodOpacity: true, + stopOpacity: true, + strokeDasharray: true, + strokeDashoffset: true, + strokeMiterlimit: true, + strokeOpacity: true, + strokeWidth: true +}; + +/** + * @param {string} prefix vendor-specific prefix, eg: Webkit + * @param {string} key style name, eg: transitionDuration + * @return {string} style name prefixed with `prefix`, properly camelCased, eg: + * WebkitTransitionDuration + */ +function prefixKey(prefix, key) { + return prefix + key.charAt(0).toUpperCase() + key.substring(1); +} + +/** + * Support style names that may come passed in prefixed by adding permutations + * of vendor prefixes. + */ +var prefixes = ['Webkit', 'ms', 'Moz', 'O']; + +// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an +// infinite loop, because it iterates over the newly added props too. +Object.keys(isUnitlessNumber).forEach(function (prop) { + prefixes.forEach(function (prefix) { + isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; + }); +}); + +/** + * Most style properties can be unset by doing .style[prop] = '' but IE8 + * doesn't like doing that with shorthand properties so for the properties that + * IE8 breaks on, which are listed here, we instead unset each of the + * individual properties. See http://bugs.jquery.com/ticket/12385. + * The 4-value 'clock' properties like margin, padding, border-width seem to + * behave without any problems. Curiously, list-style works too without any + * special prodding. + */ +var shorthandPropertyExpansions = { + background: { + backgroundAttachment: true, + backgroundColor: true, + backgroundImage: true, + backgroundPositionX: true, + backgroundPositionY: true, + backgroundRepeat: true + }, + backgroundPosition: { + backgroundPositionX: true, + backgroundPositionY: true + }, + border: { + borderWidth: true, + borderStyle: true, + borderColor: true + }, + borderBottom: { + borderBottomWidth: true, + borderBottomStyle: true, + borderBottomColor: true + }, + borderLeft: { + borderLeftWidth: true, + borderLeftStyle: true, + borderLeftColor: true + }, + borderRight: { + borderRightWidth: true, + borderRightStyle: true, + borderRightColor: true + }, + borderTop: { + borderTopWidth: true, + borderTopStyle: true, + borderTopColor: true + }, + font: { + fontStyle: true, + fontVariant: true, + fontWeight: true, + fontSize: true, + lineHeight: true, + fontFamily: true + }, + outline: { + outlineWidth: true, + outlineStyle: true, + outlineColor: true + } +}; + +var CSSProperty = { + isUnitlessNumber: isUnitlessNumber, + shorthandPropertyExpansions: shorthandPropertyExpansions +}; + +module.exports = CSSProperty; },{}],80:[function(require,module,exports){ (function (process){ -"use strict";var CSSProperty=require("./CSSProperty"),ExecutionEnvironment=require("fbjs/lib/ExecutionEnvironment"),ReactInstrumentation=require("./ReactInstrumentation"),camelizeStyleName=require("fbjs/lib/camelizeStyleName"),dangerousStyleValue=require("./dangerousStyleValue"),hyphenateStyleName=require("fbjs/lib/hyphenateStyleName"),memoizeStringOnly=require("fbjs/lib/memoizeStringOnly"),warning=require("fbjs/lib/warning"),processStyleName=memoizeStringOnly(function(e){return hyphenateStyleName(e)}),hasShorthandPropertyBug=!1,styleFloatAccessor="cssFloat";if(ExecutionEnvironment.canUseDOM){var tempStyle=document.createElement("div").style;try{tempStyle.font=""}catch(e){hasShorthandPropertyBug=!0}void 0===document.documentElement.style.cssFloat&&(styleFloatAccessor="styleFloat")}if("production"!==process.env.NODE_ENV)var badVendoredStyleNamePattern=/^(?:webkit|moz|o)[A-Z]/,badStyleValueWithSemicolonPattern=/;\s*$/,warnedStyleNames={},warnedStyleValues={},warnedForNaNValue=!1,warnHyphenatedStyleName=function(e,r){warnedStyleNames.hasOwnProperty(e)&&warnedStyleNames[e]||(warnedStyleNames[e]=!0,"production"!==process.env.NODE_ENV?warning(!1,"Unsupported style property %s. Did you mean %s?%s",e,camelizeStyleName(e),checkRenderMessage(r)):void 0)},warnBadVendoredStyleName=function(e,r){warnedStyleNames.hasOwnProperty(e)&&warnedStyleNames[e]||(warnedStyleNames[e]=!0,"production"!==process.env.NODE_ENV?warning(!1,"Unsupported vendor-prefixed style property %s. Did you mean %s?%s",e,e.charAt(0).toUpperCase()+e.slice(1),checkRenderMessage(r)):void 0)},warnStyleValueWithSemicolon=function(e,r,t){warnedStyleValues.hasOwnProperty(r)&&warnedStyleValues[r]||(warnedStyleValues[r]=!0,"production"!==process.env.NODE_ENV?warning(!1,'Style property values shouldn\'t contain a semicolon.%s Try "%s: %s" instead.',checkRenderMessage(t),e,r.replace(badStyleValueWithSemicolonPattern,"")):void 0)},warnStyleValueIsNaN=function(e,r,t){warnedForNaNValue||(warnedForNaNValue=!0,"production"!==process.env.NODE_ENV?warning(!1,"`NaN` is an invalid value for the `%s` css style property.%s",e,checkRenderMessage(t)):void 0)},checkRenderMessage=function(e){if(e){var r=e.getName();if(r)return" Check the render method of `"+r+"`."}return""},warnValidStyle=function(e,r,t){var n;t&&(n=t._currentElement._owner),e.indexOf("-")>-1?warnHyphenatedStyleName(e,n):badVendoredStyleNamePattern.test(e)?warnBadVendoredStyleName(e,n):badStyleValueWithSemicolonPattern.test(r)&&warnStyleValueWithSemicolon(e,r,n),"number"==typeof r&&isNaN(r)&&warnStyleValueIsNaN(e,r,n)};var CSSPropertyOperations={createMarkupForStyles:function(e,r){var t="";for(var n in e)if(e.hasOwnProperty(n)){var a=e[n];"production"!==process.env.NODE_ENV&&warnValidStyle(n,a,r),null!=a&&(t+=processStyleName(n)+":",t+=dangerousStyleValue(n,a,r)+";")}return t||null},setValueForStyles:function(e,r,t){"production"!==process.env.NODE_ENV&&ReactInstrumentation.debugTool.onNativeOperation(t._debugID,"update styles",r);var n=e.style;for(var a in r)if(r.hasOwnProperty(a)){"production"!==process.env.NODE_ENV&&warnValidStyle(a,r[a],t);var o=dangerousStyleValue(a,r[a],t);if("float"!==a&&"cssFloat"!==a||(a=styleFloatAccessor),o)n[a]=o;else{var s=hasShorthandPropertyBug&&CSSProperty.shorthandPropertyExpansions[a];if(s)for(var l in s)n[l]="";else n[a]=""}}}};module.exports=CSSPropertyOperations; +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule CSSPropertyOperations + */ +'use strict'; + +var CSSProperty = require('./CSSProperty'); +var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); +var ReactInstrumentation = require('./ReactInstrumentation'); + +var camelizeStyleName = require('fbjs/lib/camelizeStyleName'); +var dangerousStyleValue = require('./dangerousStyleValue'); +var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName'); +var memoizeStringOnly = require('fbjs/lib/memoizeStringOnly'); +var warning = require('fbjs/lib/warning'); + +var processStyleName = memoizeStringOnly(function (styleName) { + return hyphenateStyleName(styleName); +}); + +var hasShorthandPropertyBug = false; +var styleFloatAccessor = 'cssFloat'; +if (ExecutionEnvironment.canUseDOM) { + var tempStyle = document.createElement('div').style; + try { + // IE8 throws "Invalid argument." if resetting shorthand style properties. + tempStyle.font = ''; + } catch (e) { + hasShorthandPropertyBug = true; + } + // IE8 only supports accessing cssFloat (standard) as styleFloat + if (document.documentElement.style.cssFloat === undefined) { + styleFloatAccessor = 'styleFloat'; + } +} + +if (process.env.NODE_ENV !== 'production') { + // 'msTransform' is correct, but the other prefixes should be capitalized + var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; + + // style values shouldn't contain a semicolon + var badStyleValueWithSemicolonPattern = /;\s*$/; + + var warnedStyleNames = {}; + var warnedStyleValues = {}; + var warnedForNaNValue = false; + + var warnHyphenatedStyleName = function (name, owner) { + if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { + return; + } + + warnedStyleNames[name] = true; + process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName(name), checkRenderMessage(owner)) : void 0; + }; + + var warnBadVendoredStyleName = function (name, owner) { + if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { + return; + } + + warnedStyleNames[name] = true; + process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), checkRenderMessage(owner)) : void 0; + }; + + var warnStyleValueWithSemicolon = function (name, value, owner) { + if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { + return; + } + + warnedStyleValues[value] = true; + process.env.NODE_ENV !== 'production' ? warning(false, 'Style property values shouldn\'t contain a semicolon.%s ' + 'Try "%s: %s" instead.', checkRenderMessage(owner), name, value.replace(badStyleValueWithSemicolonPattern, '')) : void 0; + }; + + var warnStyleValueIsNaN = function (name, value, owner) { + if (warnedForNaNValue) { + return; + } + + warnedForNaNValue = true; + process.env.NODE_ENV !== 'production' ? warning(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)) : void 0; + }; + + var checkRenderMessage = function (owner) { + if (owner) { + var name = owner.getName(); + if (name) { + return ' Check the render method of `' + name + '`.'; + } + } + return ''; + }; + + /** + * @param {string} name + * @param {*} value + * @param {ReactDOMComponent} component + */ + var warnValidStyle = function (name, value, component) { + var owner; + if (component) { + owner = component._currentElement._owner; + } + if (name.indexOf('-') > -1) { + warnHyphenatedStyleName(name, owner); + } else if (badVendoredStyleNamePattern.test(name)) { + warnBadVendoredStyleName(name, owner); + } else if (badStyleValueWithSemicolonPattern.test(value)) { + warnStyleValueWithSemicolon(name, value, owner); + } + + if (typeof value === 'number' && isNaN(value)) { + warnStyleValueIsNaN(name, value, owner); + } + }; +} + +/** + * Operations for dealing with CSS properties. + */ +var CSSPropertyOperations = { + + /** + * Serializes a mapping of style properties for use as inline styles: + * + * > createMarkupForStyles({width: '200px', height: 0}) + * "width:200px;height:0;" + * + * Undefined values are ignored so that declarative programming is easier. + * The result should be HTML-escaped before insertion into the DOM. + * + * @param {object} styles + * @param {ReactDOMComponent} component + * @return {?string} + */ + createMarkupForStyles: function (styles, component) { + var serialized = ''; + for (var styleName in styles) { + if (!styles.hasOwnProperty(styleName)) { + continue; + } + var styleValue = styles[styleName]; + if (process.env.NODE_ENV !== 'production') { + warnValidStyle(styleName, styleValue, component); + } + if (styleValue != null) { + serialized += processStyleName(styleName) + ':'; + serialized += dangerousStyleValue(styleName, styleValue, component) + ';'; + } + } + return serialized || null; + }, + + /** + * Sets the value for multiple styles on a node. If a value is specified as + * '' (empty string), the corresponding style property will be unset. + * + * @param {DOMElement} node + * @param {object} styles + * @param {ReactDOMComponent} component + */ + setValueForStyles: function (node, styles, component) { + if (process.env.NODE_ENV !== 'production') { + ReactInstrumentation.debugTool.onNativeOperation(component._debugID, 'update styles', styles); + } + + var style = node.style; + for (var styleName in styles) { + if (!styles.hasOwnProperty(styleName)) { + continue; + } + if (process.env.NODE_ENV !== 'production') { + warnValidStyle(styleName, styles[styleName], component); + } + var styleValue = dangerousStyleValue(styleName, styles[styleName], component); + if (styleName === 'float' || styleName === 'cssFloat') { + styleName = styleFloatAccessor; + } + if (styleValue) { + style[styleName] = styleValue; + } else { + var expansion = hasShorthandPropertyBug && CSSProperty.shorthandPropertyExpansions[styleName]; + if (expansion) { + // Shorthand property that IE8 won't like unsetting, so unset each + // component to placate it + for (var individualStyleName in expansion) { + style[individualStyleName] = ''; + } + } else { + style[styleName] = ''; + } + } + } + } + +}; + +module.exports = CSSPropertyOperations; }).call(this,require('_process')) -},{"./CSSProperty":79,"./ReactInstrumentation":146,"./dangerousStyleValue":189,"_process":32,"fbjs/lib/ExecutionEnvironment":215,"fbjs/lib/camelizeStyleName":217,"fbjs/lib/hyphenateStyleName":228,"fbjs/lib/memoizeStringOnly":235,"fbjs/lib/warning":239}],81:[function(require,module,exports){ +},{"./CSSProperty":79,"./ReactInstrumentation":146,"./dangerousStyleValue":189,"_process":33,"fbjs/lib/ExecutionEnvironment":215,"fbjs/lib/camelizeStyleName":217,"fbjs/lib/hyphenateStyleName":228,"fbjs/lib/memoizeStringOnly":235,"fbjs/lib/warning":239}],81:[function(require,module,exports){ (function (process){ -"use strict";function CallbackQueue(){this._callbacks=null,this._contexts=null}var _assign=require("object-assign"),PooledClass=require("./PooledClass"),invariant=require("fbjs/lib/invariant");_assign(CallbackQueue.prototype,{enqueue:function(t,l){this._callbacks=this._callbacks||[],this._contexts=this._contexts||[],this._callbacks.push(t),this._contexts.push(l)},notifyAll:function(){var t=this._callbacks,l=this._contexts;if(t){t.length!==l.length?"production"!==process.env.NODE_ENV?invariant(!1,"Mismatched list of contexts in callback queue"):invariant(!1):void 0,this._callbacks=null,this._contexts=null;for(var s=0;s8));var isInputEventSupported=!1;ExecutionEnvironment.canUseDOM&&(isInputEventSupported=isEventSupported("input")&&(!("documentMode"in document)||document.documentMode>11));var newValueProp={get:function(){return activeElementValueProp.get.call(this)},set:function(e){activeElementValue=""+e,activeElementValueProp.set.call(this,e)}},ChangeEventPlugin={eventTypes:eventTypes,extractEvents:function(e,t,n,a){var o,l,v=t?ReactDOMComponentTree.getNodeFromInstance(t):window;if(shouldUseChangeEvent(v)?doesChangeEventBubble?o=getTargetInstForChangeEvent:l=handleEventsForChangeEventIE8:isTextInputElement(v)?isInputEventSupported?o=getTargetInstForInputEvent:(o=getTargetInstForInputEventIE,l=handleEventsForInputEventIE):shouldUseClickEvent(v)&&(o=getTargetInstForClickEvent),o){var r=o(e,t);if(r){var p=SyntheticEvent.getPooled(eventTypes.change,r,n,a);return p.type="change",EventPropagators.accumulateTwoPhaseDispatches(p),p}}l&&l(e,v,t)}};module.exports=ChangeEventPlugin; +},{"./PooledClass":101,"_process":33,"fbjs/lib/invariant":229,"object-assign":32}],82:[function(require,module,exports){ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ChangeEventPlugin + */ +'use strict'; + +var EventConstants = require('./EventConstants'); +var EventPluginHub = require('./EventPluginHub'); +var EventPropagators = require('./EventPropagators'); +var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); +var ReactDOMComponentTree = require('./ReactDOMComponentTree'); +var ReactUpdates = require('./ReactUpdates'); +var SyntheticEvent = require('./SyntheticEvent'); + +var getEventTarget = require('./getEventTarget'); +var isEventSupported = require('./isEventSupported'); +var isTextInputElement = require('./isTextInputElement'); +var keyOf = require('fbjs/lib/keyOf'); + +var topLevelTypes = EventConstants.topLevelTypes; + +var eventTypes = { + change: { + phasedRegistrationNames: { + bubbled: keyOf({ onChange: null }), + captured: keyOf({ onChangeCapture: null }) + }, + dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange] + } +}; + +/** + * For IE shims + */ +var activeElement = null; +var activeElementInst = null; +var activeElementValue = null; +var activeElementValueProp = null; + +/** + * SECTION: handle `change` event + */ +function shouldUseChangeEvent(elem) { + var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); + return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; +} + +var doesChangeEventBubble = false; +if (ExecutionEnvironment.canUseDOM) { + // See `handleChange` comment below + doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8); +} + +function manualDispatchChangeEvent(nativeEvent) { + var event = SyntheticEvent.getPooled(eventTypes.change, activeElementInst, nativeEvent, getEventTarget(nativeEvent)); + EventPropagators.accumulateTwoPhaseDispatches(event); + + // If change and propertychange bubbled, we'd just bind to it like all the + // other events and have it go through ReactBrowserEventEmitter. Since it + // doesn't, we manually listen for the events and so we have to enqueue and + // process the abstract event manually. + // + // Batching is necessary here in order to ensure that all event handlers run + // before the next rerender (including event handlers attached to ancestor + // elements instead of directly on the input). Without this, controlled + // components don't work properly in conjunction with event bubbling because + // the component is rerendered and the value reverted before all the event + // handlers can run. See https://github.com/facebook/react/issues/708. + ReactUpdates.batchedUpdates(runEventInBatch, event); +} + +function runEventInBatch(event) { + EventPluginHub.enqueueEvents(event); + EventPluginHub.processEventQueue(false); +} + +function startWatchingForChangeEventIE8(target, targetInst) { + activeElement = target; + activeElementInst = targetInst; + activeElement.attachEvent('onchange', manualDispatchChangeEvent); +} + +function stopWatchingForChangeEventIE8() { + if (!activeElement) { + return; + } + activeElement.detachEvent('onchange', manualDispatchChangeEvent); + activeElement = null; + activeElementInst = null; +} + +function getTargetInstForChangeEvent(topLevelType, targetInst) { + if (topLevelType === topLevelTypes.topChange) { + return targetInst; + } +} +function handleEventsForChangeEventIE8(topLevelType, target, targetInst) { + if (topLevelType === topLevelTypes.topFocus) { + // stopWatching() should be a noop here but we call it just in case we + // missed a blur event somehow. + stopWatchingForChangeEventIE8(); + startWatchingForChangeEventIE8(target, targetInst); + } else if (topLevelType === topLevelTypes.topBlur) { + stopWatchingForChangeEventIE8(); + } +} + +/** + * SECTION: handle `input` event + */ +var isInputEventSupported = false; +if (ExecutionEnvironment.canUseDOM) { + // IE9 claims to support the input event but fails to trigger it when + // deleting text, so we ignore its input events. + // IE10+ fire input events to often, such when a placeholder + // changes or when an input with a placeholder is focused. + isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 11); +} + +/** + * (For IE <=11) Replacement getter/setter for the `value` property that gets + * set on the active element. + */ +var newValueProp = { + get: function () { + return activeElementValueProp.get.call(this); + }, + set: function (val) { + // Cast to a string so we can do equality checks. + activeElementValue = '' + val; + activeElementValueProp.set.call(this, val); + } +}; + +/** + * (For IE <=11) Starts tracking propertychange events on the passed-in element + * and override the value property so that we can distinguish user events from + * value changes in JS. + */ +function startWatchingForValueChange(target, targetInst) { + activeElement = target; + activeElementInst = targetInst; + activeElementValue = target.value; + activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value'); + + // Not guarded in a canDefineProperty check: IE8 supports defineProperty only + // on DOM elements + Object.defineProperty(activeElement, 'value', newValueProp); + if (activeElement.attachEvent) { + activeElement.attachEvent('onpropertychange', handlePropertyChange); + } else { + activeElement.addEventListener('propertychange', handlePropertyChange, false); + } +} + +/** + * (For IE <=11) Removes the event listeners from the currently-tracked element, + * if any exists. + */ +function stopWatchingForValueChange() { + if (!activeElement) { + return; + } + + // delete restores the original property definition + delete activeElement.value; + + if (activeElement.detachEvent) { + activeElement.detachEvent('onpropertychange', handlePropertyChange); + } else { + activeElement.removeEventListener('propertychange', handlePropertyChange, false); + } + + activeElement = null; + activeElementInst = null; + activeElementValue = null; + activeElementValueProp = null; +} + +/** + * (For IE <=11) Handles a propertychange event, sending a `change` event if + * the value of the active element has changed. + */ +function handlePropertyChange(nativeEvent) { + if (nativeEvent.propertyName !== 'value') { + return; + } + var value = nativeEvent.srcElement.value; + if (value === activeElementValue) { + return; + } + activeElementValue = value; + + manualDispatchChangeEvent(nativeEvent); +} + +/** + * If a `change` event should be fired, returns the target's ID. + */ +function getTargetInstForInputEvent(topLevelType, targetInst) { + if (topLevelType === topLevelTypes.topInput) { + // In modern browsers (i.e., not IE8 or IE9), the input event is exactly + // what we want so fall through here and trigger an abstract event + return targetInst; + } +} + +function handleEventsForInputEventIE(topLevelType, target, targetInst) { + if (topLevelType === topLevelTypes.topFocus) { + // In IE8, we can capture almost all .value changes by adding a + // propertychange handler and looking for events with propertyName + // equal to 'value' + // In IE9-11, propertychange fires for most input events but is buggy and + // doesn't fire when text is deleted, but conveniently, selectionchange + // appears to fire in all of the remaining cases so we catch those and + // forward the event if the value has changed + // In either case, we don't want to call the event handler if the value + // is changed from JS so we redefine a setter for `.value` that updates + // our activeElementValue variable, allowing us to ignore those changes + // + // stopWatching() should be a noop here but we call it just in case we + // missed a blur event somehow. + stopWatchingForValueChange(); + startWatchingForValueChange(target, targetInst); + } else if (topLevelType === topLevelTypes.topBlur) { + stopWatchingForValueChange(); + } +} + +// For IE8 and IE9. +function getTargetInstForInputEventIE(topLevelType, targetInst) { + if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) { + // On the selectionchange event, the target is just document which isn't + // helpful for us so just check activeElement instead. + // + // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire + // propertychange on the first input event after setting `value` from a + // script and fires only keydown, keypress, keyup. Catching keyup usually + // gets it and catching keydown lets us fire an event for the first + // keystroke if user does a key repeat (it'll be a little delayed: right + // before the second keystroke). Other input methods (e.g., paste) seem to + // fire selectionchange normally. + if (activeElement && activeElement.value !== activeElementValue) { + activeElementValue = activeElement.value; + return activeElementInst; + } + } +} + +/** + * SECTION: handle `click` event + */ +function shouldUseClickEvent(elem) { + // Use the `click` event to detect changes to checkbox and radio inputs. + // This approach works across all browsers, whereas `change` does not fire + // until `blur` in IE8. + return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); +} + +function getTargetInstForClickEvent(topLevelType, targetInst) { + if (topLevelType === topLevelTypes.topClick) { + return targetInst; + } +} + +/** + * This plugin creates an `onChange` event that normalizes change events + * across form elements. This event fires at a time when it's possible to + * change the element's value without seeing a flicker. + * + * Supported elements are: + * - input (see `isTextInputElement`) + * - textarea + * - select + */ +var ChangeEventPlugin = { + + eventTypes: eventTypes, + + extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { + var targetNode = targetInst ? ReactDOMComponentTree.getNodeFromInstance(targetInst) : window; + + var getTargetInstFunc, handleEventFunc; + if (shouldUseChangeEvent(targetNode)) { + if (doesChangeEventBubble) { + getTargetInstFunc = getTargetInstForChangeEvent; + } else { + handleEventFunc = handleEventsForChangeEventIE8; + } + } else if (isTextInputElement(targetNode)) { + if (isInputEventSupported) { + getTargetInstFunc = getTargetInstForInputEvent; + } else { + getTargetInstFunc = getTargetInstForInputEventIE; + handleEventFunc = handleEventsForInputEventIE; + } + } else if (shouldUseClickEvent(targetNode)) { + getTargetInstFunc = getTargetInstForClickEvent; + } + + if (getTargetInstFunc) { + var inst = getTargetInstFunc(topLevelType, targetInst); + if (inst) { + var event = SyntheticEvent.getPooled(eventTypes.change, inst, nativeEvent, nativeEventTarget); + event.type = 'change'; + EventPropagators.accumulateTwoPhaseDispatches(event); + return event; + } + } + + if (handleEventFunc) { + handleEventFunc(topLevelType, targetNode, targetInst); + } + } + +}; + +module.exports = ChangeEventPlugin; },{"./EventConstants":92,"./EventPluginHub":93,"./EventPropagators":96,"./ReactDOMComponentTree":117,"./ReactUpdates":165,"./SyntheticEvent":174,"./getEventTarget":197,"./isEventSupported":204,"./isTextInputElement":205,"fbjs/lib/ExecutionEnvironment":215,"fbjs/lib/keyOf":233}],83:[function(require,module,exports){ (function (process){ -"use strict";function getNodeAfter(e,t){return Array.isArray(t)&&(t=t[1]),t?t.nextSibling:e.firstChild}function insertLazyTreeChildAt(e,t,n){DOMLazyTree.insertTreeBefore(e,t,n)}function moveChild(e,t,n){Array.isArray(t)?moveDelimitedText(e,t[0],t[1],n):insertChildAt(e,t,n)}function removeChild(e,t){if(Array.isArray(t)){var n=t[1];t=t[0],removeDelimitedText(e,t,n),e.removeChild(n)}e.removeChild(t)}function moveDelimitedText(e,t,n,o){for(var r=t;;){var i=r.nextSibling;if(insertChildAt(e,r,o),r===n)break;r=i}}function removeDelimitedText(e,t,n){for(;;){var o=t.nextSibling;if(o===n)break;e.removeChild(o)}}function replaceDelimitedText(e,t,n){var o=e.parentNode,r=e.nextSibling;r===t?n&&insertChildAt(o,document.createTextNode(n),r):n?(setTextContent(r,n),removeDelimitedText(o,r,t)):removeDelimitedText(o,e,t),"production"!==process.env.NODE_ENV&&ReactInstrumentation.debugTool.onNativeOperation(ReactDOMComponentTree.getInstanceFromNode(e)._debugID,"replace text",n)}var DOMLazyTree=require("./DOMLazyTree"),Danger=require("./Danger"),ReactMultiChildUpdateTypes=require("./ReactMultiChildUpdateTypes"),ReactDOMComponentTree=require("./ReactDOMComponentTree"),ReactInstrumentation=require("./ReactInstrumentation"),createMicrosoftUnsafeLocalFunction=require("./createMicrosoftUnsafeLocalFunction"),setInnerHTML=require("./setInnerHTML"),setTextContent=require("./setTextContent"),insertChildAt=createMicrosoftUnsafeLocalFunction(function(e,t,n){e.insertBefore(t,n)}),dangerouslyReplaceNodeWithMarkup=Danger.dangerouslyReplaceNodeWithMarkup;"production"!==process.env.NODE_ENV&&(dangerouslyReplaceNodeWithMarkup=function(e,t,n){if(Danger.dangerouslyReplaceNodeWithMarkup(e,t),0!==n._debugID)ReactInstrumentation.debugTool.onNativeOperation(n._debugID,"replace with",t.toString());else{var o=ReactDOMComponentTree.getInstanceFromNode(t.node);0!==o._debugID&&ReactInstrumentation.debugTool.onNativeOperation(o._debugID,"mount",t.toString())}});var DOMChildrenOperations={dangerouslyReplaceNodeWithMarkup:dangerouslyReplaceNodeWithMarkup,replaceDelimitedText:replaceDelimitedText,processUpdates:function(e,t){if("production"!==process.env.NODE_ENV)var n=ReactDOMComponentTree.getInstanceFromNode(e)._debugID;for(var o=0;o} updates List of update configurations. + * @internal + */ + processUpdates: function (parentNode, updates) { + if (process.env.NODE_ENV !== 'production') { + var parentNodeDebugID = ReactDOMComponentTree.getInstanceFromNode(parentNode)._debugID; + } + + for (var k = 0; k < updates.length; k++) { + var update = updates[k]; + switch (update.type) { + case ReactMultiChildUpdateTypes.INSERT_MARKUP: + insertLazyTreeChildAt(parentNode, update.content, getNodeAfter(parentNode, update.afterNode)); + if (process.env.NODE_ENV !== 'production') { + ReactInstrumentation.debugTool.onNativeOperation(parentNodeDebugID, 'insert child', { toIndex: update.toIndex, content: update.content.toString() }); + } + break; + case ReactMultiChildUpdateTypes.MOVE_EXISTING: + moveChild(parentNode, update.fromNode, getNodeAfter(parentNode, update.afterNode)); + if (process.env.NODE_ENV !== 'production') { + ReactInstrumentation.debugTool.onNativeOperation(parentNodeDebugID, 'move child', { fromIndex: update.fromIndex, toIndex: update.toIndex }); + } + break; + case ReactMultiChildUpdateTypes.SET_MARKUP: + setInnerHTML(parentNode, update.content); + if (process.env.NODE_ENV !== 'production') { + ReactInstrumentation.debugTool.onNativeOperation(parentNodeDebugID, 'replace children', update.content.toString()); + } + break; + case ReactMultiChildUpdateTypes.TEXT_CONTENT: + setTextContent(parentNode, update.content); + if (process.env.NODE_ENV !== 'production') { + ReactInstrumentation.debugTool.onNativeOperation(parentNodeDebugID, 'replace text', update.content.toString()); + } + break; + case ReactMultiChildUpdateTypes.REMOVE_NODE: + removeChild(parentNode, update.fromNode); + if (process.env.NODE_ENV !== 'production') { + ReactInstrumentation.debugTool.onNativeOperation(parentNodeDebugID, 'remove child', { fromIndex: update.fromIndex }); + } + break; + } + } + } + +}; + +module.exports = DOMChildrenOperations; }).call(this,require('_process')) -},{"./DOMLazyTree":84,"./Danger":88,"./ReactDOMComponentTree":117,"./ReactInstrumentation":146,"./ReactMultiChildUpdateTypes":151,"./createMicrosoftUnsafeLocalFunction":188,"./setInnerHTML":209,"./setTextContent":210,"_process":32}],84:[function(require,module,exports){ -"use strict";function insertTreeChildren(e){if(enableLazy){var n=e.node,t=e.children;if(t.length)for(var r=0;r plugins (like Flash Player) will read + // nodes immediately upon insertion into the DOM, so + // must also be populated prior to insertion into the DOM. + if (tree.node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE || tree.node.nodeType === ELEMENT_NODE_TYPE && tree.node.nodeName.toLowerCase() === 'object' && (tree.node.namespaceURI == null || tree.node.namespaceURI === DOMNamespaces.html)) { + insertTreeChildren(tree); + parentNode.insertBefore(tree.node, referenceNode); + } else { + parentNode.insertBefore(tree.node, referenceNode); + insertTreeChildren(tree); + } +}); + +function replaceChildWithTree(oldNode, newTree) { + oldNode.parentNode.replaceChild(newTree.node, oldNode); + insertTreeChildren(newTree); +} + +function queueChild(parentTree, childTree) { + if (enableLazy) { + parentTree.children.push(childTree); + } else { + parentTree.node.appendChild(childTree.node); + } +} + +function queueHTML(tree, html) { + if (enableLazy) { + tree.html = html; + } else { + tree.node.innerHTML = html; + } +} + +function queueText(tree, text) { + if (enableLazy) { + tree.text = text; + } else { + setTextContent(tree.node, text); + } +} + +function toString() { + return this.node.nodeName; +} + +function DOMLazyTree(node) { + return { + node: node, + children: [], + html: null, + text: null, + toString: toString + }; +} + +DOMLazyTree.insertTreeBefore = insertTreeBefore; +DOMLazyTree.replaceChildWithTree = replaceChildWithTree; +DOMLazyTree.queueChild = queueChild; +DOMLazyTree.queueHTML = queueHTML; +DOMLazyTree.queueText = queueText; + +module.exports = DOMLazyTree; },{"./DOMNamespaces":85,"./createMicrosoftUnsafeLocalFunction":188,"./setTextContent":210}],85:[function(require,module,exports){ -"use strict";var DOMNamespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};module.exports=DOMNamespaces; +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule DOMNamespaces + */ +'use strict'; + +var DOMNamespaces = { + html: 'http://www.w3.org/1999/xhtml', + mathml: 'http://www.w3.org/1998/Math/MathML', + svg: 'http://www.w3.org/2000/svg' +}; + +module.exports = DOMNamespaces; },{}],86:[function(require,module,exports){ (function (process){ -"use strict";function checkMask(e,t){return(e&t)===t}var invariant=require("fbjs/lib/invariant"),DOMPropertyInjection={MUST_USE_PROPERTY:1,HAS_SIDE_EFFECTS:2,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,injectDOMPropertyConfig:function(e){var t=DOMPropertyInjection,r=e.Properties||{},o=e.DOMAttributeNamespaces||{},a=e.DOMAttributeNames||{},i=e.DOMPropertyNames||{},n=e.DOMMutationMethods||{};e.isCustomAttribute&&DOMProperty._isCustomAttributeFunctions.push(e.isCustomAttribute);for(var u in r){DOMProperty.properties.hasOwnProperty(u)?"production"!==process.env.NODE_ENV?invariant(!1,"injectDOMPropertyConfig(...): You're trying to inject DOM property '%s' which has already been injected. You may be accidentally injecting the same DOM property config twice, or you may be injecting two configs that have conflicting property names.",u):invariant(!1):void 0;var s=u.toLowerCase(),c=r[u],p={attributeName:s,attributeNamespace:null,propertyName:u,mutationMethod:null,mustUseProperty:checkMask(c,t.MUST_USE_PROPERTY),hasSideEffects:checkMask(c,t.HAS_SIDE_EFFECTS),hasBooleanValue:checkMask(c,t.HAS_BOOLEAN_VALUE),hasNumericValue:checkMask(c,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:checkMask(c,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:checkMask(c,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(!p.mustUseProperty&&p.hasSideEffects?"production"!==process.env.NODE_ENV?invariant(!1,"DOMProperty: Properties that have side effects must use property: %s",u):invariant(!1):void 0,p.hasBooleanValue+p.hasNumericValue+p.hasOverloadedBooleanValue<=1?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"DOMProperty: Value can be one of boolean, overloaded boolean, or numeric value, but not a combination: %s",u):invariant(!1),"production"!==process.env.NODE_ENV&&(DOMProperty.getPossibleStandardName[s]=u),a.hasOwnProperty(u)){var E=a[u];p.attributeName=E,"production"!==process.env.NODE_ENV&&(DOMProperty.getPossibleStandardName[E]=u)}o.hasOwnProperty(u)&&(p.attributeNamespace=o[u]),i.hasOwnProperty(u)&&(p.propertyName=i[u]),n.hasOwnProperty(u)&&(p.mutationMethod=n[u]),DOMProperty.properties[u]=p}}},ATTRIBUTE_NAME_START_CHAR=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",DOMProperty={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:ATTRIBUTE_NAME_START_CHAR,ATTRIBUTE_NAME_CHAR:ATTRIBUTE_NAME_START_CHAR+"\\-.0-9\\uB7\\u0300-\\u036F\\u203F-\\u2040",properties:{},getPossibleStandardName:"production"!==process.env.NODE_ENV?{}:null,_isCustomAttributeFunctions:[],isCustomAttribute:function(e){for(var t=0;t DOMProperty.isValid['id'] + * true + * > DOMProperty.isValid['foobar'] + * undefined + * + * Although this may be confusing, it performs better in general. + * + * @see http://jsperf.com/key-exists + * @see http://jsperf.com/key-missing + */ +var DOMProperty = { + + ID_ATTRIBUTE_NAME: 'data-reactid', + ROOT_ATTRIBUTE_NAME: 'data-reactroot', + + ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR, + ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\uB7\\u0300-\\u036F\\u203F-\\u2040', + + /** + * Map from property "standard name" to an object with info about how to set + * the property in the DOM. Each object contains: + * + * attributeName: + * Used when rendering markup or with `*Attribute()`. + * attributeNamespace + * propertyName: + * Used on DOM node instances. (This includes properties that mutate due to + * external factors.) + * mutationMethod: + * If non-null, used instead of the property or `setAttribute()` after + * initial render. + * mustUseProperty: + * Whether the property must be accessed and mutated as an object property. + * hasSideEffects: + * Whether or not setting a value causes side effects such as triggering + * resources to be loaded or text selection changes. If true, we read from + * the DOM before updating to ensure that the value is only set if it has + * changed. + * hasBooleanValue: + * Whether the property should be removed when set to a falsey value. + * hasNumericValue: + * Whether the property must be numeric or parse as a numeric and should be + * removed when set to a falsey value. + * hasPositiveNumericValue: + * Whether the property must be positive numeric or parse as a positive + * numeric and should be removed when set to a falsey value. + * hasOverloadedBooleanValue: + * Whether the property can be used as a flag as well as with a value. + * Removed when strictly equal to false; present without a value when + * strictly equal to true; present with a value otherwise. + */ + properties: {}, + + /** + * Mapping from lowercase property names to the properly cased version, used + * to warn in the case of missing properties. Available only in __DEV__. + * @type {Object} + */ + getPossibleStandardName: process.env.NODE_ENV !== 'production' ? {} : null, + + /** + * All of the isCustomAttribute() functions that have been injected. + */ + _isCustomAttributeFunctions: [], + + /** + * Checks whether a property name is a custom attribute. + * @method + */ + isCustomAttribute: function (attributeName) { + for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) { + var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i]; + if (isCustomAttributeFn(attributeName)) { + return true; + } + } + return false; + }, + + injection: DOMPropertyInjection +}; + +module.exports = DOMProperty; }).call(this,require('_process')) -},{"_process":32,"fbjs/lib/invariant":229}],87:[function(require,module,exports){ +},{"_process":33,"fbjs/lib/invariant":229}],87:[function(require,module,exports){ (function (process){ -"use strict";function isAttributeNameSafe(e){return validatedAttributeNameCache.hasOwnProperty(e)?!0:illegalAttributeNameCache.hasOwnProperty(e)?!1:VALID_ATTRIBUTE_NAME_REGEX.test(e)?(validatedAttributeNameCache[e]=!0,!0):(illegalAttributeNameCache[e]=!0,"production"!==process.env.NODE_ENV?warning(!1,"Invalid attribute name: `%s`",e):void 0,!1)}function shouldIgnoreValue(e,t){return null==t||e.hasBooleanValue&&!t||e.hasNumericValue&&isNaN(t)||e.hasPositiveNumericValue&&1>t||e.hasOverloadedBooleanValue&&t===!1}var DOMProperty=require("./DOMProperty"),ReactDOMComponentTree=require("./ReactDOMComponentTree"),ReactDOMInstrumentation=require("./ReactDOMInstrumentation"),ReactInstrumentation=require("./ReactInstrumentation"),quoteAttributeValueForBrowser=require("./quoteAttributeValueForBrowser"),warning=require("fbjs/lib/warning"),VALID_ATTRIBUTE_NAME_REGEX=new RegExp("^["+DOMProperty.ATTRIBUTE_NAME_START_CHAR+"]["+DOMProperty.ATTRIBUTE_NAME_CHAR+"]*$"),illegalAttributeNameCache={},validatedAttributeNameCache={},DOMPropertyOperations={createMarkupForID:function(e){return DOMProperty.ID_ATTRIBUTE_NAME+"="+quoteAttributeValueForBrowser(e)},setAttributeForID:function(e,t){e.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME,t)},createMarkupForRoot:function(){return DOMProperty.ROOT_ATTRIBUTE_NAME+'=""'},setAttributeForRoot:function(e){e.setAttribute(DOMProperty.ROOT_ATTRIBUTE_NAME,"")},createMarkupForProperty:function(e,t){"production"!==process.env.NODE_ENV&&ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(e,t);var r=DOMProperty.properties.hasOwnProperty(e)?DOMProperty.properties[e]:null;if(r){if(shouldIgnoreValue(r,t))return"";var o=r.attributeName;return r.hasBooleanValue||r.hasOverloadedBooleanValue&&t===!0?o+'=""':o+"="+quoteAttributeValueForBrowser(t)}return DOMProperty.isCustomAttribute(e)?null==t?"":e+"="+quoteAttributeValueForBrowser(t):null},createMarkupForCustomAttribute:function(e,t){return isAttributeNameSafe(e)&&null!=t?e+"="+quoteAttributeValueForBrowser(t):""},setValueForProperty:function(e,t,r){var o=DOMProperty.properties.hasOwnProperty(t)?DOMProperty.properties[t]:null;if(o){var a=o.mutationMethod;if(a)a(e,r);else{if(shouldIgnoreValue(o,r))return void this.deleteValueForProperty(e,t);if(o.mustUseProperty){var u=o.propertyName;o.hasSideEffects&&""+e[u]==""+r||(e[u]=r)}else{var n=o.attributeName,i=o.attributeNamespace;i?e.setAttributeNS(i,n,""+r):o.hasBooleanValue||o.hasOverloadedBooleanValue&&r===!0?e.setAttribute(n,""):e.setAttribute(n,""+r)}}}else if(DOMProperty.isCustomAttribute(t))return void DOMPropertyOperations.setValueForAttribute(e,t,r);if("production"!==process.env.NODE_ENV){ReactDOMInstrumentation.debugTool.onSetValueForProperty(e,t,r);var s={};s[t]=r,ReactInstrumentation.debugTool.onNativeOperation(ReactDOMComponentTree.getInstanceFromNode(e)._debugID,"update attribute",s)}},setValueForAttribute:function(e,t,r){if(isAttributeNameSafe(t)&&(null==r?e.removeAttribute(t):e.setAttribute(t,""+r),"production"!==process.env.NODE_ENV)){var o={};o[t]=r,ReactInstrumentation.debugTool.onNativeOperation(ReactDOMComponentTree.getInstanceFromNode(e)._debugID,"update attribute",o)}},deleteValueForProperty:function(e,t){var r=DOMProperty.properties.hasOwnProperty(t)?DOMProperty.properties[t]:null;if(r){var o=r.mutationMethod;if(o)o(e,void 0);else if(r.mustUseProperty){var a=r.propertyName;r.hasBooleanValue?e[a]=!1:r.hasSideEffects&&""+e[a]==""||(e[a]="")}else e.removeAttribute(r.attributeName)}else DOMProperty.isCustomAttribute(t)&&e.removeAttribute(t);"production"!==process.env.NODE_ENV&&(ReactDOMInstrumentation.debugTool.onDeleteValueForProperty(e,t),ReactInstrumentation.debugTool.onNativeOperation(ReactDOMComponentTree.getInstanceFromNode(e)._debugID,"remove attribute",t))}};module.exports=DOMPropertyOperations; +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule DOMPropertyOperations + */ +'use strict'; + +var DOMProperty = require('./DOMProperty'); +var ReactDOMComponentTree = require('./ReactDOMComponentTree'); +var ReactDOMInstrumentation = require('./ReactDOMInstrumentation'); +var ReactInstrumentation = require('./ReactInstrumentation'); + +var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser'); +var warning = require('fbjs/lib/warning'); + +var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$'); +var illegalAttributeNameCache = {}; +var validatedAttributeNameCache = {}; + +function isAttributeNameSafe(attributeName) { + if (validatedAttributeNameCache.hasOwnProperty(attributeName)) { + return true; + } + if (illegalAttributeNameCache.hasOwnProperty(attributeName)) { + return false; + } + if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { + validatedAttributeNameCache[attributeName] = true; + return true; + } + illegalAttributeNameCache[attributeName] = true; + process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : void 0; + return false; +} + +function shouldIgnoreValue(propertyInfo, value) { + return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false; +} + +/** + * Operations for dealing with DOM properties. + */ +var DOMPropertyOperations = { + + /** + * Creates markup for the ID property. + * + * @param {string} id Unescaped ID. + * @return {string} Markup string. + */ + createMarkupForID: function (id) { + return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id); + }, + + setAttributeForID: function (node, id) { + node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id); + }, + + createMarkupForRoot: function () { + return DOMProperty.ROOT_ATTRIBUTE_NAME + '=""'; + }, + + setAttributeForRoot: function (node) { + node.setAttribute(DOMProperty.ROOT_ATTRIBUTE_NAME, ''); + }, + + /** + * Creates markup for a property. + * + * @param {string} name + * @param {*} value + * @return {?string} Markup string, or null if the property was invalid. + */ + createMarkupForProperty: function (name, value) { + if (process.env.NODE_ENV !== 'production') { + ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(name, value); + } + var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null; + if (propertyInfo) { + if (shouldIgnoreValue(propertyInfo, value)) { + return ''; + } + var attributeName = propertyInfo.attributeName; + if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { + return attributeName + '=""'; + } + return attributeName + '=' + quoteAttributeValueForBrowser(value); + } else if (DOMProperty.isCustomAttribute(name)) { + if (value == null) { + return ''; + } + return name + '=' + quoteAttributeValueForBrowser(value); + } + return null; + }, + + /** + * Creates markup for a custom property. + * + * @param {string} name + * @param {*} value + * @return {string} Markup string, or empty string if the property was invalid. + */ + createMarkupForCustomAttribute: function (name, value) { + if (!isAttributeNameSafe(name) || value == null) { + return ''; + } + return name + '=' + quoteAttributeValueForBrowser(value); + }, + + /** + * Sets the value for a property on a node. + * + * @param {DOMElement} node + * @param {string} name + * @param {*} value + */ + setValueForProperty: function (node, name, value) { + var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null; + if (propertyInfo) { + var mutationMethod = propertyInfo.mutationMethod; + if (mutationMethod) { + mutationMethod(node, value); + } else if (shouldIgnoreValue(propertyInfo, value)) { + this.deleteValueForProperty(node, name); + return; + } else if (propertyInfo.mustUseProperty) { + var propName = propertyInfo.propertyName; + // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the + // property type before comparing; only `value` does and is string. + if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) { + // Contrary to `setAttribute`, object properties are properly + // `toString`ed by IE8/9. + node[propName] = value; + } + } else { + var attributeName = propertyInfo.attributeName; + var namespace = propertyInfo.attributeNamespace; + // `setAttribute` with objects becomes only `[object]` in IE8/9, + // ('' + value) makes it output the correct toString()-value. + if (namespace) { + node.setAttributeNS(namespace, attributeName, '' + value); + } else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { + node.setAttribute(attributeName, ''); + } else { + node.setAttribute(attributeName, '' + value); + } + } + } else if (DOMProperty.isCustomAttribute(name)) { + DOMPropertyOperations.setValueForAttribute(node, name, value); + return; + } + + if (process.env.NODE_ENV !== 'production') { + ReactDOMInstrumentation.debugTool.onSetValueForProperty(node, name, value); + var payload = {}; + payload[name] = value; + ReactInstrumentation.debugTool.onNativeOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'update attribute', payload); + } + }, + + setValueForAttribute: function (node, name, value) { + if (!isAttributeNameSafe(name)) { + return; + } + if (value == null) { + node.removeAttribute(name); + } else { + node.setAttribute(name, '' + value); + } + + if (process.env.NODE_ENV !== 'production') { + var payload = {}; + payload[name] = value; + ReactInstrumentation.debugTool.onNativeOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'update attribute', payload); + } + }, + + /** + * Deletes the value for a property on a node. + * + * @param {DOMElement} node + * @param {string} name + */ + deleteValueForProperty: function (node, name) { + var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null; + if (propertyInfo) { + var mutationMethod = propertyInfo.mutationMethod; + if (mutationMethod) { + mutationMethod(node, undefined); + } else if (propertyInfo.mustUseProperty) { + var propName = propertyInfo.propertyName; + if (propertyInfo.hasBooleanValue) { + // No HAS_SIDE_EFFECTS logic here, only `value` has it and is string. + node[propName] = false; + } else { + if (!propertyInfo.hasSideEffects || '' + node[propName] !== '') { + node[propName] = ''; + } + } + } else { + node.removeAttribute(propertyInfo.attributeName); + } + } else if (DOMProperty.isCustomAttribute(name)) { + node.removeAttribute(name); + } + + if (process.env.NODE_ENV !== 'production') { + ReactDOMInstrumentation.debugTool.onDeleteValueForProperty(node, name); + ReactInstrumentation.debugTool.onNativeOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'remove attribute', name); + } + } + +}; + +module.exports = DOMPropertyOperations; }).call(this,require('_process')) -},{"./DOMProperty":86,"./ReactDOMComponentTree":117,"./ReactDOMInstrumentation":125,"./ReactInstrumentation":146,"./quoteAttributeValueForBrowser":207,"_process":32,"fbjs/lib/warning":239}],88:[function(require,module,exports){ +},{"./DOMProperty":86,"./ReactDOMComponentTree":117,"./ReactDOMInstrumentation":125,"./ReactInstrumentation":146,"./quoteAttributeValueForBrowser":207,"_process":33,"fbjs/lib/warning":239}],88:[function(require,module,exports){ (function (process){ -"use strict";function getNodeName(e){return e.substring(1,e.indexOf(" "))}var DOMLazyTree=require("./DOMLazyTree"),ExecutionEnvironment=require("fbjs/lib/ExecutionEnvironment"),createNodesFromMarkup=require("fbjs/lib/createNodesFromMarkup"),emptyFunction=require("fbjs/lib/emptyFunction"),getMarkupWrap=require("fbjs/lib/getMarkupWrap"),invariant=require("fbjs/lib/invariant"),OPEN_TAG_NAME_EXP=/^(<[^ \/>]+)/,RESULT_INDEX_ATTR="data-danger-index",Danger={dangerouslyRenderMarkup:function(e){ExecutionEnvironment.canUseDOM?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"dangerouslyRenderMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString for server rendering."):invariant(!1);for(var r,n={},a=0;a node. This is because browser quirks make this unreliable and/or slow. If you want to render to the root you must use server rendering. See ReactDOMServer.renderToString()."):invariant(!1):void 0,"string"==typeof r){var n=createNodesFromMarkup(r,emptyFunction)[0];e.parentNode.replaceChild(n,e)}else DOMLazyTree.replaceChildWithTree(e,r)}};module.exports=Danger; +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Danger + */ +'use strict'; + +var DOMLazyTree = require('./DOMLazyTree'); +var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); + +var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup'); +var emptyFunction = require('fbjs/lib/emptyFunction'); +var getMarkupWrap = require('fbjs/lib/getMarkupWrap'); +var invariant = require('fbjs/lib/invariant'); + +var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/; +var RESULT_INDEX_ATTR = 'data-danger-index'; + +/** + * Extracts the `nodeName` from a string of markup. + * + * NOTE: Extracting the `nodeName` does not require a regular expression match + * because we make assumptions about React-generated markup (i.e. there are no + * spaces surrounding the opening tag and there is at least one attribute). + * + * @param {string} markup String of markup. + * @return {string} Node name of the supplied markup. + * @see http://jsperf.com/extract-nodename + */ +function getNodeName(markup) { + return markup.substring(1, markup.indexOf(' ')); +} + +var Danger = { + + /** + * Renders markup into an array of nodes. The markup is expected to render + * into a list of root nodes. Also, the length of `resultList` and + * `markupList` should be the same. + * + * @param {array} markupList List of markup strings to render. + * @return {array} List of rendered nodes. + * @internal + */ + dangerouslyRenderMarkup: function (markupList) { + !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : void 0; + var nodeName; + var markupByNodeName = {}; + // Group markup by `nodeName` if a wrap is necessary, else by '*'. + for (var i = 0; i < markupList.length; i++) { + !markupList[i] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : void 0; + nodeName = getNodeName(markupList[i]); + nodeName = getMarkupWrap(nodeName) ? nodeName : '*'; + markupByNodeName[nodeName] = markupByNodeName[nodeName] || []; + markupByNodeName[nodeName][i] = markupList[i]; + } + var resultList = []; + var resultListAssignmentCount = 0; + for (nodeName in markupByNodeName) { + if (!markupByNodeName.hasOwnProperty(nodeName)) { + continue; + } + var markupListByNodeName = markupByNodeName[nodeName]; + + // This for-in loop skips the holes of the sparse array. The order of + // iteration should follow the order of assignment, which happens to match + // numerical index order, but we don't rely on that. + var resultIndex; + for (resultIndex in markupListByNodeName) { + if (markupListByNodeName.hasOwnProperty(resultIndex)) { + var markup = markupListByNodeName[resultIndex]; + + // Push the requested markup with an additional RESULT_INDEX_ATTR + // attribute. If the markup does not start with a < character, it + // will be discarded below (with an appropriate console.error). + markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP, + // This index will be parsed back out below. + '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '); + } + } + + // Render each group of markup with similar wrapping `nodeName`. + var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with