2014-12-30 08:51:07 +00:00
|
|
|
|
(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;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2015-01-01 03:41:45 +00:00
|
|
|
|
// 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:
|
|
|
|
|
len = arguments.length;
|
|
|
|
|
args = new Array(len - 1);
|
|
|
|
|
for (i = 1; i < len; i++)
|
|
|
|
|
args[i - 1] = arguments[i];
|
|
|
|
|
handler.apply(this, args);
|
|
|
|
|
}
|
|
|
|
|
} else if (isObject(handler)) {
|
|
|
|
|
len = arguments.length;
|
|
|
|
|
args = new Array(len - 1);
|
|
|
|
|
for (i = 1; i < len; i++)
|
|
|
|
|
args[i - 1] = arguments[i];
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
var m;
|
|
|
|
|
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 {
|
|
|
|
|
// 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.listenerCount = function(emitter, type) {
|
|
|
|
|
var ret;
|
|
|
|
|
if (!emitter._events || !emitter._events[type])
|
|
|
|
|
ret = 0;
|
|
|
|
|
else if (isFunction(emitter._events[type]))
|
|
|
|
|
ret = 1;
|
|
|
|
|
else
|
|
|
|
|
ret = emitter._events[type].length;
|
|
|
|
|
return ret;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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){
|
2014-12-31 05:14:17 +00:00
|
|
|
|
var $ = require("jquery");
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var _ = require("lodash");
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var AppDispatcher = require("./dispatcher.js").AppDispatcher;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var 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 = {
|
|
|
|
|
ADD: "add",
|
|
|
|
|
UPDATE: "update",
|
|
|
|
|
REMOVE: "remove",
|
|
|
|
|
RESET: "reset"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var ConnectionActions = {
|
|
|
|
|
open: function () {
|
|
|
|
|
AppDispatcher.dispatchViewAction({
|
|
|
|
|
type: ActionTypes.CONNECTION_OPEN
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
close: function () {
|
|
|
|
|
AppDispatcher.dispatchViewAction({
|
|
|
|
|
type: ActionTypes.CONNECTION_CLOSE
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
error: function () {
|
|
|
|
|
AppDispatcher.dispatchViewAction({
|
|
|
|
|
type: ActionTypes.CONNECTION_ERROR
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var SettingsActions = {
|
|
|
|
|
update: function (settings) {
|
|
|
|
|
|
2014-12-31 05:14:17 +00:00
|
|
|
|
$.ajax({
|
2014-12-30 08:51:07 +00:00
|
|
|
|
type: "PUT",
|
|
|
|
|
url: "/settings",
|
2015-03-22 23:24:56 +00:00
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
data: JSON.stringify(settings)
|
2014-12-30 08:51:07 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
//Facebook Flux: We do an optimistic update on the client already.
|
|
|
|
|
AppDispatcher.dispatchViewAction({
|
|
|
|
|
type: ActionTypes.SETTINGS_STORE,
|
|
|
|
|
cmd: StoreCmds.UPDATE,
|
|
|
|
|
data: settings
|
|
|
|
|
});
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var EventLogActions_event_id = 0;
|
|
|
|
|
var EventLogActions = {
|
|
|
|
|
add_event: function (message) {
|
|
|
|
|
AppDispatcher.dispatchViewAction({
|
|
|
|
|
type: ActionTypes.EVENT_STORE,
|
|
|
|
|
cmd: StoreCmds.ADD,
|
|
|
|
|
data: {
|
|
|
|
|
message: message,
|
|
|
|
|
level: "web",
|
|
|
|
|
id: "viewAction-" + EventLogActions_event_id++
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var FlowActions = {
|
|
|
|
|
accept: function (flow) {
|
2014-12-31 05:14:17 +00:00
|
|
|
|
$.post("/flows/" + flow.id + "/accept");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
|
|
|
|
accept_all: function(){
|
2014-12-31 05:14:17 +00:00
|
|
|
|
$.post("/flows/accept");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
|
|
|
|
"delete": function(flow){
|
2014-12-31 05:14:17 +00:00
|
|
|
|
$.ajax({
|
2014-12-30 08:51:07 +00:00
|
|
|
|
type:"DELETE",
|
|
|
|
|
url: "/flows/" + flow.id
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
duplicate: function(flow){
|
2014-12-31 05:14:17 +00:00
|
|
|
|
$.post("/flows/" + flow.id + "/duplicate");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
|
|
|
|
replay: function(flow){
|
2014-12-31 05:14:17 +00:00
|
|
|
|
$.post("/flows/" + flow.id + "/replay");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
|
|
|
|
revert: function(flow){
|
2014-12-31 05:14:17 +00:00
|
|
|
|
$.post("/flows/" + flow.id + "/revert");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
2015-03-22 23:24:56 +00:00
|
|
|
|
update: function (flow, nextProps) {
|
|
|
|
|
/*
|
|
|
|
|
//Facebook Flux: We do an optimistic update on the client already.
|
|
|
|
|
var nextFlow = _.cloneDeep(flow);
|
|
|
|
|
_.merge(nextFlow, nextProps);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
AppDispatcher.dispatchViewAction({
|
|
|
|
|
type: ActionTypes.FLOW_STORE,
|
|
|
|
|
cmd: StoreCmds.UPDATE,
|
2015-03-22 23:24:56 +00:00
|
|
|
|
data: nextFlow
|
|
|
|
|
});
|
|
|
|
|
*/
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "PUT",
|
|
|
|
|
url: "/flows/" + flow.id,
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
data: JSON.stringify(nextProps)
|
2014-12-30 08:51:07 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
clear: function(){
|
2015-03-22 23:24:56 +00:00
|
|
|
|
$.post("/flows/" + flow.id);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-15 21:05:50 +00:00
|
|
|
|
var Query = {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
FILTER: "f",
|
|
|
|
|
HIGHLIGHT: "h",
|
|
|
|
|
SHOW_EVENTLOG: "e"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
ActionTypes: ActionTypes,
|
2014-12-30 09:12:26 +00:00
|
|
|
|
ConnectionActions: ConnectionActions,
|
|
|
|
|
FlowActions: FlowActions,
|
2015-03-15 21:05:50 +00:00
|
|
|
|
StoreCmds: StoreCmds,
|
2015-03-21 20:55:02 +00:00
|
|
|
|
SettingsActions: SettingsActions,
|
2015-03-22 14:19:35 +00:00
|
|
|
|
EventLogActions: EventLogActions,
|
2015-03-15 21:05:50 +00:00
|
|
|
|
Query: Query
|
2014-12-30 08:51:07 +00:00
|
|
|
|
};
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
},{"./dispatcher.js":19,"jquery":"jquery","lodash":"lodash"}],3:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
var React = require("react");
|
|
|
|
|
var ReactRouter = require("react-router");
|
|
|
|
|
var $ = require("jquery");
|
|
|
|
|
var Connection = require("./connection");
|
2015-01-01 02:37:42 +00:00
|
|
|
|
var proxyapp = require("./components/proxyapp.js");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
window.ws = new Connection("/updates");
|
|
|
|
|
|
2015-03-15 21:05:50 +00:00
|
|
|
|
ReactRouter.run(proxyapp.routes, function (Handler, state) {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
React.render(React.createElement(Handler, null), document.body);
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-01-02 22:46:51 +00:00
|
|
|
|
|
|
|
|
|
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"./components/proxyapp.js":16,"./connection":18,"jquery":"jquery","react":"react","react-router":"react-router"}],4:[function(require,module,exports){
|
2014-12-31 05:14:17 +00:00
|
|
|
|
var React = require("react");
|
2015-01-01 07:49:32 +00:00
|
|
|
|
var ReactRouter = require("react-router");
|
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
|
|
|
|
// http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html (also contains inverse example)
|
|
|
|
|
var AutoScrollMixin = {
|
|
|
|
|
componentWillUpdate: function () {
|
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
|
this._shouldScrollBottom = (
|
|
|
|
|
node.scrollTop !== 0 &&
|
|
|
|
|
node.scrollTop + node.clientHeight === node.scrollHeight
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
componentDidUpdate: function () {
|
|
|
|
|
if (this._shouldScrollBottom) {
|
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
|
node.scrollTop = node.scrollHeight;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var StickyHeadMixin = {
|
|
|
|
|
adjustHead: function () {
|
|
|
|
|
// Abusing CSS transforms to set the element
|
|
|
|
|
// referenced as head into some kind of position:sticky.
|
|
|
|
|
var head = this.refs.head.getDOMNode();
|
|
|
|
|
head.style.transform = "translate(0," + this.getDOMNode().scrollTop + "px)";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var ChildFocus = {
|
|
|
|
|
contextTypes: {
|
|
|
|
|
returnFocus: React.PropTypes.func
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2015-01-01 07:49:32 +00:00
|
|
|
|
var Navigation = _.extend({}, ReactRouter.Navigation, {
|
|
|
|
|
setQuery: function (dict) {
|
2015-03-22 13:33:42 +00:00
|
|
|
|
var q = this.context.router.getCurrentQuery();
|
2015-01-01 07:49:32 +00:00
|
|
|
|
for(var i in dict){
|
|
|
|
|
if(dict.hasOwnProperty(i)){
|
|
|
|
|
q[i] = dict[i] || undefined; //falsey values shall be removed.
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-15 21:05:50 +00:00
|
|
|
|
q._ = "_"; // workaround for https://github.com/rackt/react-router/pull/957
|
2015-03-22 13:33:42 +00:00
|
|
|
|
this.replaceWith(this.context.router.getCurrentPath(), this.context.router.getCurrentParams(), q);
|
2015-01-01 07:49:32 +00:00
|
|
|
|
},
|
|
|
|
|
replaceWith: function(routeNameOrPath, params, query) {
|
|
|
|
|
if(routeNameOrPath === undefined){
|
2015-03-22 13:33:42 +00:00
|
|
|
|
routeNameOrPath = this.context.router.getCurrentPath();
|
2015-01-01 07:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
if(params === undefined){
|
2015-03-22 13:33:42 +00:00
|
|
|
|
params = this.context.router.getCurrentParams();
|
2015-01-01 07:49:32 +00:00
|
|
|
|
}
|
2015-03-15 21:05:50 +00:00
|
|
|
|
if(query === undefined) {
|
2015-03-22 13:33:42 +00:00
|
|
|
|
query = this.context.router.getCurrentQuery();
|
2015-01-01 07:49:32 +00:00
|
|
|
|
}
|
2015-03-15 21:05:50 +00:00
|
|
|
|
|
2015-03-22 13:33:42 +00:00
|
|
|
|
// FIXME: react-router is just broken,
|
|
|
|
|
// we hopefully just need to wait for the next release with https://github.com/rackt/react-router/pull/957.
|
|
|
|
|
this.context.router.replaceWith(routeNameOrPath, params, query);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// react-router is fairly good at changing its API regularly.
|
|
|
|
|
// We keep the old method for now - if it should turn out that their changes are permanent,
|
|
|
|
|
// we may remove this mixin and access react-router directly again.
|
|
|
|
|
var State = _.extend({}, ReactRouter.State, {
|
|
|
|
|
getQuery: function(){
|
|
|
|
|
return this.context.router.getCurrentQuery();
|
|
|
|
|
},
|
|
|
|
|
getParams: function(){
|
|
|
|
|
return this.context.router.getCurrentParams();
|
2015-01-01 07:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var Splitter = React.createClass({displayName: "Splitter",
|
|
|
|
|
getDefaultProps: function () {
|
|
|
|
|
return {
|
|
|
|
|
axis: "x"
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
applied: false,
|
|
|
|
|
startX: false,
|
|
|
|
|
startY: false
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
onMouseDown: function (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 () {
|
|
|
|
|
this.getDOMNode().style.transform = "";
|
|
|
|
|
window.removeEventListener("dragend", this.onDragEnd);
|
|
|
|
|
window.removeEventListener("mouseup", this.onMouseUp);
|
|
|
|
|
window.removeEventListener("mousemove", this.onMouseMove);
|
|
|
|
|
},
|
|
|
|
|
onMouseUp: function (e) {
|
|
|
|
|
this.onDragEnd();
|
|
|
|
|
|
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
|
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 (e) {
|
|
|
|
|
var dX = 0, dY = 0;
|
|
|
|
|
if (this.props.axis === "x") {
|
|
|
|
|
dX = e.pageX - this.state.startX;
|
|
|
|
|
} else {
|
|
|
|
|
dY = e.pageY - this.state.startY;
|
|
|
|
|
}
|
|
|
|
|
this.getDOMNode().style.transform = "translate(" + dX + "px," + dY + "px)";
|
|
|
|
|
},
|
|
|
|
|
onResize: function () {
|
|
|
|
|
// 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 (willUnmount) {
|
|
|
|
|
if (!this.state.applied) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
|
var prev = node.previousElementSibling;
|
|
|
|
|
var next = node.nextElementSibling;
|
|
|
|
|
|
|
|
|
|
prev.style.flex = "";
|
|
|
|
|
next.style.flex = "";
|
|
|
|
|
|
|
|
|
|
if (!willUnmount) {
|
|
|
|
|
this.setState({
|
|
|
|
|
applied: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.onResize();
|
|
|
|
|
},
|
|
|
|
|
componentWillUnmount: function () {
|
|
|
|
|
this.reset(true);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var className = "splitter";
|
|
|
|
|
if (this.props.axis === "x") {
|
|
|
|
|
className += " splitter-x";
|
|
|
|
|
} else {
|
|
|
|
|
className += " splitter-y";
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", {className: className},
|
|
|
|
|
React.createElement("div", {onMouseDown: this.onMouseDown, draggable: "true"})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
ChildFocus: ChildFocus,
|
2015-03-22 13:33:42 +00:00
|
|
|
|
State: State,
|
2015-01-01 07:49:32 +00:00
|
|
|
|
Navigation: Navigation,
|
|
|
|
|
StickyHeadMixin: StickyHeadMixin,
|
|
|
|
|
AutoScrollMixin: AutoScrollMixin,
|
|
|
|
|
Splitter: Splitter
|
2015-03-15 21:05:50 +00:00
|
|
|
|
};
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-01-02 22:46:51 +00:00
|
|
|
|
},{"lodash":"lodash","react":"react","react-router":"react-router"}],5:[function(require,module,exports){
|
2015-01-01 07:49:32 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
var common = require("./common.js");
|
2015-03-15 21:05:50 +00:00
|
|
|
|
var Query = require("../actions.js").Query;
|
2015-01-01 02:37:42 +00:00
|
|
|
|
var VirtualScrollMixin = require("./virtualscroll.js");
|
2014-12-31 05:14:17 +00:00
|
|
|
|
var views = require("../store/view.js");
|
2015-03-21 20:55:02 +00:00
|
|
|
|
var _ = require("lodash");
|
2014-12-31 05:14:17 +00:00
|
|
|
|
|
|
|
|
|
var LogMessage = React.createClass({displayName: "LogMessage",
|
|
|
|
|
render: function () {
|
|
|
|
|
var entry = this.props.entry;
|
|
|
|
|
var indicator;
|
|
|
|
|
switch (entry.level) {
|
|
|
|
|
case "web":
|
|
|
|
|
indicator = React.createElement("i", {className: "fa fa-fw fa-html5"});
|
|
|
|
|
break;
|
|
|
|
|
case "debug":
|
|
|
|
|
indicator = React.createElement("i", {className: "fa fa-fw fa-bug"});
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
indicator = React.createElement("i", {className: "fa fa-fw fa-info"});
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", null,
|
2015-03-27 14:30:19 +00:00
|
|
|
|
indicator, " ", entry.message
|
2014-12-31 05:14:17 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
shouldComponentUpdate: function () {
|
|
|
|
|
return false; // log entries are immutable.
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var EventLogContents = React.createClass({displayName: "EventLogContents",
|
2015-01-01 07:49:32 +00:00
|
|
|
|
mixins: [common.AutoScrollMixin, VirtualScrollMixin],
|
2014-12-31 05:14:17 +00:00
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
log: []
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
componentWillMount: function () {
|
|
|
|
|
this.openView(this.props.eventStore);
|
|
|
|
|
},
|
|
|
|
|
componentWillUnmount: function () {
|
|
|
|
|
this.closeView();
|
|
|
|
|
},
|
|
|
|
|
openView: function (store) {
|
|
|
|
|
var view = new views.StoreView(store, function (entry) {
|
|
|
|
|
return this.props.filter[entry.level];
|
|
|
|
|
}.bind(this));
|
|
|
|
|
this.setState({
|
|
|
|
|
view: view
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-05 20:03:52 +00:00
|
|
|
|
view.addListener("add", this.onEventLogChange);
|
|
|
|
|
view.addListener("recalculate", this.onEventLogChange);
|
2014-12-31 05:14:17 +00:00
|
|
|
|
},
|
|
|
|
|
closeView: function () {
|
|
|
|
|
this.state.view.close();
|
|
|
|
|
},
|
|
|
|
|
onEventLogChange: function () {
|
|
|
|
|
this.setState({
|
|
|
|
|
log: this.state.view.list
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
componentWillReceiveProps: function (nextProps) {
|
|
|
|
|
if (nextProps.filter !== this.props.filter) {
|
|
|
|
|
this.props.filter = nextProps.filter; // Dirty: Make sure that view filter sees the update.
|
|
|
|
|
this.state.view.recalculate();
|
|
|
|
|
}
|
|
|
|
|
if (nextProps.eventStore !== this.props.eventStore) {
|
|
|
|
|
this.closeView();
|
|
|
|
|
this.openView(nextProps.eventStore);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getDefaultProps: function () {
|
|
|
|
|
return {
|
|
|
|
|
rowHeight: 45,
|
|
|
|
|
rowHeightMin: 15,
|
|
|
|
|
placeholderTagName: "div"
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
renderRow: function (elem) {
|
|
|
|
|
return React.createElement(LogMessage, {key: elem.id, entry: elem});
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var rows = this.renderRows(this.state.log);
|
|
|
|
|
|
|
|
|
|
return React.createElement("pre", {onScroll: this.onScroll},
|
|
|
|
|
this.getPlaceholderTop(this.state.log.length),
|
|
|
|
|
rows,
|
|
|
|
|
this.getPlaceholderBottom(this.state.log.length)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var ToggleFilter = React.createClass({displayName: "ToggleFilter",
|
|
|
|
|
toggle: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
return this.props.toggleLevel(this.props.name);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var className = "label ";
|
|
|
|
|
if (this.props.active) {
|
|
|
|
|
className += "label-primary";
|
|
|
|
|
} else {
|
|
|
|
|
className += "label-default";
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("a", {
|
|
|
|
|
href: "#",
|
|
|
|
|
className: className,
|
|
|
|
|
onClick: this.toggle},
|
|
|
|
|
this.props.name
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var EventLog = React.createClass({displayName: "EventLog",
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
filter: {
|
|
|
|
|
"debug": false,
|
|
|
|
|
"info": true,
|
|
|
|
|
"web": true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
close: function () {
|
|
|
|
|
var d = {};
|
|
|
|
|
d[Query.SHOW_EVENTLOG] = undefined;
|
|
|
|
|
this.setQuery(d);
|
|
|
|
|
},
|
|
|
|
|
toggleLevel: function (level) {
|
|
|
|
|
var filter = _.extend({}, this.state.filter);
|
|
|
|
|
filter[level] = !filter[level];
|
|
|
|
|
this.setState({filter: filter});
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", {className: "eventlog"},
|
|
|
|
|
React.createElement("div", null,
|
|
|
|
|
"Eventlog",
|
|
|
|
|
React.createElement("div", {className: "pull-right"},
|
|
|
|
|
React.createElement(ToggleFilter, {name: "debug", active: this.state.filter.debug, toggleLevel: this.toggleLevel}),
|
|
|
|
|
React.createElement(ToggleFilter, {name: "info", active: this.state.filter.info, toggleLevel: this.toggleLevel}),
|
|
|
|
|
React.createElement(ToggleFilter, {name: "web", active: this.state.filter.web, toggleLevel: this.toggleLevel}),
|
|
|
|
|
React.createElement("i", {onClick: this.close, className: "fa fa-close"})
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
React.createElement(EventLogContents, {filter: this.state.filter, eventStore: this.props.eventStore})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = EventLog;
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../actions.js":2,"../store/view.js":23,"./common.js":4,"./virtualscroll.js":17,"lodash":"lodash","react":"react"}],6:[function(require,module,exports){
|
2014-12-30 09:12:26 +00:00
|
|
|
|
var React = require("react");
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var RequestUtils = require("../flow/utils.js").RequestUtils;
|
|
|
|
|
var ResponseUtils = require("../flow/utils.js").ResponseUtils;
|
|
|
|
|
var utils = require("../utils.js");
|
2014-12-30 09:12:26 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var TLSColumn = React.createClass({displayName: "TLSColumn",
|
|
|
|
|
statics: {
|
|
|
|
|
Title: React.createClass({displayName: "Title",
|
|
|
|
|
render: function(){
|
|
|
|
|
return React.createElement("th", React.__spread({}, this.props, {className: "col-tls " + (this.props.className || "") }));
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
sortKeyFun: function(flow){
|
|
|
|
|
return flow.request.scheme;
|
|
|
|
|
}
|
2014-12-30 09:12:26 +00:00
|
|
|
|
},
|
|
|
|
|
render: function () {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var flow = this.props.flow;
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var ssl = (flow.request.scheme === "https");
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var classes;
|
|
|
|
|
if (ssl) {
|
|
|
|
|
classes = "col-tls col-tls-https";
|
|
|
|
|
} else {
|
|
|
|
|
classes = "col-tls col-tls-http";
|
|
|
|
|
}
|
|
|
|
|
return React.createElement("td", {className: classes});
|
2014-12-30 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
|
|
|
|
|
var IconColumn = React.createClass({displayName: "IconColumn",
|
|
|
|
|
statics: {
|
|
|
|
|
Title: React.createClass({displayName: "Title",
|
|
|
|
|
render: function(){
|
|
|
|
|
return React.createElement("th", React.__spread({}, this.props, {className: "col-icon " + (this.props.className || "") }));
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2014-12-30 09:12:26 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var icon;
|
|
|
|
|
if (flow.response) {
|
|
|
|
|
var contentType = ResponseUtils.getContentType(flow.response);
|
2014-12-30 09:12:26 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
//TODO: We should assign a type to the flow somewhere else.
|
2015-03-22 23:24:56 +00:00
|
|
|
|
if (flow.response.code === 304) {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
icon = "resource-icon-not-modified";
|
|
|
|
|
} else if (300 <= flow.response.code && flow.response.code < 400) {
|
|
|
|
|
icon = "resource-icon-redirect";
|
|
|
|
|
} else if (contentType && contentType.indexOf("image") >= 0) {
|
|
|
|
|
icon = "resource-icon-image";
|
|
|
|
|
} else if (contentType && contentType.indexOf("javascript") >= 0) {
|
|
|
|
|
icon = "resource-icon-js";
|
|
|
|
|
} else if (contentType && contentType.indexOf("css") >= 0) {
|
|
|
|
|
icon = "resource-icon-css";
|
|
|
|
|
} else if (contentType && contentType.indexOf("html") >= 0) {
|
|
|
|
|
icon = "resource-icon-document";
|
|
|
|
|
}
|
2014-12-30 09:12:26 +00:00
|
|
|
|
}
|
2015-03-21 21:49:51 +00:00
|
|
|
|
if (!icon) {
|
|
|
|
|
icon = "resource-icon-plain";
|
2014-12-30 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
|
|
|
|
|
icon += " resource-icon";
|
|
|
|
|
return React.createElement("td", {className: "col-icon"},
|
|
|
|
|
React.createElement("div", {className: icon})
|
2014-12-30 09:12:26 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var PathColumn = React.createClass({displayName: "PathColumn",
|
|
|
|
|
statics: {
|
|
|
|
|
Title: React.createClass({displayName: "Title",
|
|
|
|
|
render: function(){
|
|
|
|
|
return React.createElement("th", React.__spread({}, this.props, {className: "col-path " + (this.props.className || "") }), "Path");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
sortKeyFun: function(flow){
|
|
|
|
|
return RequestUtils.pretty_url(flow.request);
|
|
|
|
|
}
|
|
|
|
|
},
|
2014-12-30 09:12:26 +00:00
|
|
|
|
render: function () {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
return React.createElement("td", {className: "col-path"},
|
|
|
|
|
flow.request.is_replay ? React.createElement("i", {className: "fa fa-fw fa-repeat pull-right"}) : null,
|
|
|
|
|
flow.intercepted ? React.createElement("i", {className: "fa fa-fw fa-pause pull-right"}) : null,
|
|
|
|
|
RequestUtils.pretty_url(flow.request)
|
2014-12-30 09:12:26 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
|
|
|
|
|
var MethodColumn = React.createClass({displayName: "MethodColumn",
|
|
|
|
|
statics: {
|
|
|
|
|
Title: React.createClass({displayName: "Title",
|
|
|
|
|
render: function(){
|
|
|
|
|
return React.createElement("th", React.__spread({}, this.props, {className: "col-method " + (this.props.className || "") }), "Method");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
sortKeyFun: function(flow){
|
|
|
|
|
return flow.request.method;
|
|
|
|
|
}
|
|
|
|
|
},
|
2014-12-30 09:12:26 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
2015-03-21 21:49:51 +00:00
|
|
|
|
return React.createElement("td", {className: "col-method"}, flow.request.method);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var StatusColumn = React.createClass({displayName: "StatusColumn",
|
|
|
|
|
statics: {
|
|
|
|
|
Title: React.createClass({displayName: "Title",
|
|
|
|
|
render: function(){
|
|
|
|
|
return React.createElement("th", React.__spread({}, this.props, {className: "col-status " + (this.props.className || "") }), "Status");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
sortKeyFun: function(flow){
|
|
|
|
|
return flow.response ? flow.response.code : undefined;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
var status;
|
|
|
|
|
if (flow.response) {
|
|
|
|
|
status = flow.response.code;
|
2014-12-30 09:12:26 +00:00
|
|
|
|
} else {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
status = null;
|
2014-12-30 09:12:26 +00:00
|
|
|
|
}
|
2015-03-21 21:49:51 +00:00
|
|
|
|
return React.createElement("td", {className: "col-status"}, status);
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-30 09:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var SizeColumn = React.createClass({displayName: "SizeColumn",
|
|
|
|
|
statics: {
|
|
|
|
|
Title: React.createClass({displayName: "Title",
|
|
|
|
|
render: function(){
|
|
|
|
|
return React.createElement("th", React.__spread({}, this.props, {className: "col-size " + (this.props.className || "") }), "Size");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
sortKeyFun: function(flow){
|
|
|
|
|
var total = flow.request.contentLength;
|
|
|
|
|
if (flow.response) {
|
|
|
|
|
total += flow.response.contentLength || 0;
|
|
|
|
|
}
|
|
|
|
|
return total;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
|
|
|
|
|
var total = flow.request.contentLength;
|
|
|
|
|
if (flow.response) {
|
|
|
|
|
total += flow.response.contentLength || 0;
|
|
|
|
|
}
|
|
|
|
|
var size = utils.formatSize(total);
|
|
|
|
|
return React.createElement("td", {className: "col-size"}, size);
|
2014-12-30 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
|
|
|
|
|
var TimeColumn = React.createClass({displayName: "TimeColumn",
|
|
|
|
|
statics: {
|
|
|
|
|
Title: React.createClass({displayName: "Title",
|
|
|
|
|
render: function(){
|
|
|
|
|
return React.createElement("th", React.__spread({}, this.props, {className: "col-time " + (this.props.className || "") }), "Time");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
sortKeyFun: function(flow){
|
|
|
|
|
if(flow.response) {
|
|
|
|
|
return flow.response.timestamp_end - flow.request.timestamp_start;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2014-12-30 09:12:26 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var time;
|
|
|
|
|
if (flow.response) {
|
|
|
|
|
time = utils.formatTimeDelta(1000 * (flow.response.timestamp_end - flow.request.timestamp_start));
|
2014-12-30 09:12:26 +00:00
|
|
|
|
} else {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
time = "...";
|
2014-12-30 09:12:26 +00:00
|
|
|
|
}
|
2015-03-21 21:49:51 +00:00
|
|
|
|
return React.createElement("td", {className: "col-time"}, time);
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-30 09:12:26 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
|
|
|
|
|
var all_columns = [
|
|
|
|
|
TLSColumn,
|
|
|
|
|
IconColumn,
|
|
|
|
|
PathColumn,
|
|
|
|
|
MethodColumn,
|
|
|
|
|
StatusColumn,
|
|
|
|
|
SizeColumn,
|
|
|
|
|
TimeColumn
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
module.exports = all_columns;
|
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../flow/utils.js":21,"../utils.js":24,"react":"react"}],7:[function(require,module,exports){
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
var common = require("./common.js");
|
|
|
|
|
var utils = require("../utils.js");
|
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
|
|
|
|
var VirtualScrollMixin = require("./virtualscroll.js");
|
|
|
|
|
var flowtable_columns = require("./flowtable-columns.js");
|
|
|
|
|
|
|
|
|
|
var FlowRow = React.createClass({displayName: "FlowRow",
|
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
var columns = this.props.columns.map(function (Column) {
|
|
|
|
|
return React.createElement(Column, {key: Column.displayName, flow: flow});
|
|
|
|
|
}.bind(this));
|
|
|
|
|
var className = "";
|
|
|
|
|
if (this.props.selected) {
|
|
|
|
|
className += " selected";
|
|
|
|
|
}
|
|
|
|
|
if (this.props.highlighted) {
|
|
|
|
|
className += " highlighted";
|
|
|
|
|
}
|
|
|
|
|
if (flow.intercepted) {
|
|
|
|
|
className += " intercepted";
|
|
|
|
|
}
|
|
|
|
|
if (flow.request) {
|
|
|
|
|
className += " has-request";
|
|
|
|
|
}
|
|
|
|
|
if (flow.response) {
|
|
|
|
|
className += " has-response";
|
|
|
|
|
}
|
2014-12-30 09:12:26 +00:00
|
|
|
|
|
|
|
|
|
return (
|
2015-03-21 21:49:51 +00:00
|
|
|
|
React.createElement("tr", {className: className, onClick: this.props.selectFlow.bind(null, flow)},
|
|
|
|
|
columns
|
|
|
|
|
));
|
|
|
|
|
},
|
|
|
|
|
shouldComponentUpdate: function (nextProps) {
|
|
|
|
|
return true;
|
|
|
|
|
// Further optimization could be done here
|
|
|
|
|
// by calling forceUpdate on flow updates, selection changes and column changes.
|
|
|
|
|
//return (
|
|
|
|
|
//(this.props.columns.length !== nextProps.columns.length) ||
|
|
|
|
|
//(this.props.selected !== nextProps.selected)
|
|
|
|
|
//);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var FlowTableHead = React.createClass({displayName: "FlowTableHead",
|
|
|
|
|
getInitialState: function(){
|
|
|
|
|
return {
|
|
|
|
|
sortColumn: undefined,
|
|
|
|
|
sortDesc: false
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
onClick: function(Column){
|
|
|
|
|
var sortDesc = this.state.sortDesc;
|
|
|
|
|
var hasSort = Column.sortKeyFun;
|
|
|
|
|
if(Column === this.state.sortColumn){
|
|
|
|
|
sortDesc = !sortDesc;
|
|
|
|
|
this.setState({
|
|
|
|
|
sortDesc: sortDesc
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.setState({
|
|
|
|
|
sortColumn: hasSort && Column,
|
|
|
|
|
sortDesc: false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
var sortKeyFun;
|
|
|
|
|
if(!sortDesc){
|
|
|
|
|
sortKeyFun = Column.sortKeyFun;
|
|
|
|
|
} else {
|
|
|
|
|
sortKeyFun = hasSort && function(){
|
|
|
|
|
var k = Column.sortKeyFun.apply(this, arguments);
|
|
|
|
|
if(_.isString(k)){
|
|
|
|
|
return utils.reverseString(""+k);
|
|
|
|
|
} else {
|
|
|
|
|
return -k;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.props.setSortKeyFun(sortKeyFun);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var columns = this.props.columns.map(function (Column) {
|
|
|
|
|
var onClick = this.onClick.bind(this, Column);
|
|
|
|
|
var className;
|
|
|
|
|
if(this.state.sortColumn === Column) {
|
|
|
|
|
if(this.state.sortDesc){
|
|
|
|
|
className = "sort-desc";
|
|
|
|
|
} else {
|
|
|
|
|
className = "sort-asc";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return React.createElement(Column.Title, {
|
|
|
|
|
key: Column.displayName,
|
|
|
|
|
onClick: onClick,
|
|
|
|
|
className: className});
|
|
|
|
|
}.bind(this));
|
|
|
|
|
return React.createElement("thead", null,
|
|
|
|
|
React.createElement("tr", null, columns)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ROW_HEIGHT = 32;
|
|
|
|
|
|
|
|
|
|
var FlowTable = React.createClass({displayName: "FlowTable",
|
|
|
|
|
mixins: [common.StickyHeadMixin, common.AutoScrollMixin, VirtualScrollMixin],
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
columns: flowtable_columns
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
_listen: function(view){
|
|
|
|
|
if(!view){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
view.addListener("add", this.onChange);
|
|
|
|
|
view.addListener("update", this.onChange);
|
|
|
|
|
view.addListener("remove", this.onChange);
|
|
|
|
|
view.addListener("recalculate", this.onChange);
|
|
|
|
|
},
|
|
|
|
|
componentWillMount: function () {
|
|
|
|
|
this._listen(this.props.view);
|
|
|
|
|
},
|
|
|
|
|
componentWillReceiveProps: function (nextProps) {
|
|
|
|
|
if (nextProps.view !== this.props.view) {
|
|
|
|
|
if (this.props.view) {
|
|
|
|
|
this.props.view.removeListener("add");
|
|
|
|
|
this.props.view.removeListener("update");
|
|
|
|
|
this.props.view.removeListener("remove");
|
|
|
|
|
this.props.view.removeListener("recalculate");
|
|
|
|
|
}
|
|
|
|
|
this._listen(nextProps.view);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getDefaultProps: function () {
|
|
|
|
|
return {
|
|
|
|
|
rowHeight: ROW_HEIGHT
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
onScrollFlowTable: function () {
|
|
|
|
|
this.adjustHead();
|
|
|
|
|
this.onScroll();
|
|
|
|
|
},
|
|
|
|
|
onChange: function () {
|
|
|
|
|
this.forceUpdate();
|
|
|
|
|
},
|
|
|
|
|
scrollIntoView: function (flow) {
|
|
|
|
|
this.scrollRowIntoView(
|
|
|
|
|
this.props.view.index(flow),
|
|
|
|
|
this.refs.body.getDOMNode().offsetTop
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
renderRow: function (flow) {
|
|
|
|
|
var selected = (flow === this.props.selected);
|
|
|
|
|
var highlighted =
|
|
|
|
|
(
|
|
|
|
|
this.props.view._highlight &&
|
|
|
|
|
this.props.view._highlight[flow.id]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return React.createElement(FlowRow, {key: flow.id,
|
|
|
|
|
ref: flow.id,
|
|
|
|
|
flow: flow,
|
|
|
|
|
columns: this.state.columns,
|
|
|
|
|
selected: selected,
|
|
|
|
|
highlighted: highlighted,
|
|
|
|
|
selectFlow: this.props.selectFlow}
|
2014-12-30 09:12:26 +00:00
|
|
|
|
);
|
2015-03-21 21:49:51 +00:00
|
|
|
|
},
|
2014-12-30 09:12:26 +00:00
|
|
|
|
render: function () {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
//console.log("render flowtable", this.state.start, this.state.stop, this.props.selected);
|
|
|
|
|
var flows = this.props.view ? this.props.view.list : [];
|
|
|
|
|
|
|
|
|
|
var rows = this.renderRows(flows);
|
|
|
|
|
|
2014-12-30 09:12:26 +00:00
|
|
|
|
return (
|
2015-03-21 21:49:51 +00:00
|
|
|
|
React.createElement("div", {className: "flow-table", onScroll: this.onScrollFlowTable},
|
|
|
|
|
React.createElement("table", null,
|
|
|
|
|
React.createElement(FlowTableHead, {ref: "head",
|
|
|
|
|
columns: this.state.columns,
|
|
|
|
|
setSortKeyFun: this.props.setSortKeyFun}),
|
|
|
|
|
React.createElement("tbody", {ref: "body"},
|
|
|
|
|
this.getPlaceholderTop(flows.length),
|
|
|
|
|
rows,
|
|
|
|
|
this.getPlaceholderBottom(flows.length)
|
2014-12-30 09:12:26 +00:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
module.exports = FlowTable;
|
|
|
|
|
|
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../utils.js":24,"./common.js":4,"./flowtable-columns.js":6,"./virtualscroll.js":17,"lodash":"lodash","react":"react"}],8:[function(require,module,exports){
|
|
|
|
|
var React = require("react");
|
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
|
|
|
|
var MessageUtils = require("../../flow/utils.js").MessageUtils;
|
|
|
|
|
var utils = require("../../utils.js");
|
|
|
|
|
|
|
|
|
|
var image_regex = /^image\/(png|jpe?g|gif|vnc.microsoft.icon|x-icon)$/i;
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var ViewImage = React.createClass({displayName: "ViewImage",
|
2015-03-21 23:21:38 +00:00
|
|
|
|
statics: {
|
|
|
|
|
matches: function (message) {
|
|
|
|
|
return image_regex.test(MessageUtils.getContentType(message));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
2015-03-22 01:25:47 +00:00
|
|
|
|
var url = MessageUtils.getContentURL(this.props.flow, this.props.message);
|
2015-03-21 23:21:38 +00:00
|
|
|
|
return React.createElement("div", {className: "flowview-image"},
|
|
|
|
|
React.createElement("img", {src: url, alt: "preview", className: "img-thumbnail"})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-22 01:25:47 +00:00
|
|
|
|
var RawMixin = {
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
content: undefined,
|
|
|
|
|
request: undefined
|
2015-03-22 01:25:47 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
requestContent: function (nextProps) {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
if (this.state.request) {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
this.state.request.abort();
|
|
|
|
|
}
|
2015-03-22 01:25:47 +00:00
|
|
|
|
var request = MessageUtils.getContent(nextProps.flow, nextProps.message);
|
2015-03-22 14:19:35 +00:00
|
|
|
|
this.setState({
|
|
|
|
|
content: undefined,
|
|
|
|
|
request: request
|
|
|
|
|
});
|
2015-03-22 01:25:47 +00:00
|
|
|
|
request.done(function (data) {
|
|
|
|
|
this.setState({content: data});
|
|
|
|
|
}.bind(this)).fail(function (jqXHR, textStatus, errorThrown) {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
if (textStatus === "abort") {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.setState({content: "AJAX Error: " + textStatus + "\r\n" + errorThrown});
|
2015-03-22 23:24:56 +00:00
|
|
|
|
}.bind(this)).always(function () {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
this.setState({request: undefined});
|
2015-03-22 01:25:47 +00:00
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
componentWillMount: function () {
|
|
|
|
|
this.requestContent(this.props);
|
|
|
|
|
},
|
|
|
|
|
componentWillReceiveProps: function (nextProps) {
|
|
|
|
|
if (nextProps.message !== this.props.message) {
|
|
|
|
|
this.requestContent(nextProps);
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-03-22 23:24:56 +00:00
|
|
|
|
componentWillUnmount: function () {
|
|
|
|
|
if (this.state.request) {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
this.state.request.abort();
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-03-22 01:25:47 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
if (!this.state.content) {
|
|
|
|
|
return React.createElement("div", {className: "text-center"},
|
|
|
|
|
React.createElement("i", {className: "fa fa-spinner fa-spin"})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return this.renderContent();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var ViewRaw = React.createClass({displayName: "ViewRaw",
|
2015-03-22 01:25:47 +00:00
|
|
|
|
mixins: [RawMixin],
|
2015-03-21 23:21:38 +00:00
|
|
|
|
statics: {
|
|
|
|
|
matches: function (message) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-03-22 01:25:47 +00:00
|
|
|
|
renderContent: function () {
|
|
|
|
|
return React.createElement("pre", null, this.state.content);
|
2015-03-21 23:21:38 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var json_regex = /^application\/json$/i;
|
|
|
|
|
var ViewJSON = React.createClass({displayName: "ViewJSON",
|
|
|
|
|
mixins: [RawMixin],
|
|
|
|
|
statics: {
|
|
|
|
|
matches: function (message) {
|
|
|
|
|
return json_regex.test(MessageUtils.getContentType(message));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
renderContent: function () {
|
|
|
|
|
var json = this.state.content;
|
|
|
|
|
try {
|
|
|
|
|
json = JSON.stringify(JSON.parse(json), null, 2);
|
2015-03-22 23:24:56 +00:00
|
|
|
|
} catch (e) {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
return React.createElement("pre", null, json);
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-03-21 23:21:38 +00:00
|
|
|
|
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var ViewAuto = React.createClass({displayName: "ViewAuto",
|
2015-03-21 23:21:38 +00:00
|
|
|
|
statics: {
|
|
|
|
|
matches: function () {
|
|
|
|
|
return false; // don't match itself
|
|
|
|
|
},
|
|
|
|
|
findView: function (message) {
|
|
|
|
|
for (var i = 0; i < all.length; i++) {
|
|
|
|
|
if (all[i].matches(message)) {
|
|
|
|
|
return all[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return all[all.length - 1];
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var View = ViewAuto.findView(this.props.message);
|
2015-03-21 23:21:38 +00:00
|
|
|
|
return React.createElement(View, React.__spread({}, this.props));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var all = [ViewAuto, ViewImage, ViewJSON, ViewRaw];
|
2015-03-21 23:21:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ContentEmpty = React.createClass({displayName: "ContentEmpty",
|
|
|
|
|
render: function () {
|
|
|
|
|
var message_name = this.props.flow.request === this.props.message ? "request" : "response";
|
|
|
|
|
return React.createElement("div", {className: "alert alert-info"}, "No ", message_name, " content.");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var ContentMissing = React.createClass({displayName: "ContentMissing",
|
|
|
|
|
render: function () {
|
|
|
|
|
var message_name = this.props.flow.request === this.props.message ? "Request" : "Response";
|
|
|
|
|
return React.createElement("div", {className: "alert alert-info"}, message_name, " content missing.");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var TooLarge = React.createClass({displayName: "TooLarge",
|
2015-03-22 14:19:35 +00:00
|
|
|
|
statics: {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
isTooLarge: function (message) {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var max_mb = ViewImage.matches(message) ? 10 : 0.2;
|
|
|
|
|
return message.contentLength > 1024 * 1024 * max_mb;
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-03-21 23:21:38 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
var size = utils.formatSize(this.props.message.contentLength);
|
|
|
|
|
return React.createElement("div", {className: "alert alert-warning"},
|
|
|
|
|
React.createElement("button", {onClick: this.props.onClick, className: "btn btn-xs btn-warning pull-right"}, "Display anyway"),
|
|
|
|
|
size, " content size."
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var ViewSelector = React.createClass({displayName: "ViewSelector",
|
|
|
|
|
render: function () {
|
|
|
|
|
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;
|
2015-03-22 14:19:35 +00:00
|
|
|
|
if (view === ViewAuto) {
|
|
|
|
|
text = "auto: " + ViewAuto.findView(this.props.message).displayName.toLowerCase().replace("view", "");
|
2015-03-21 23:21:38 +00:00
|
|
|
|
} else {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
text = view.displayName.toLowerCase().replace("view", "");
|
2015-03-21 23:21:38 +00:00
|
|
|
|
}
|
|
|
|
|
views.push(
|
|
|
|
|
React.createElement("button", {
|
|
|
|
|
key: view.displayName,
|
|
|
|
|
onClick: this.props.selectView.bind(null, view),
|
|
|
|
|
className: className},
|
|
|
|
|
text
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return React.createElement("div", {className: "view-selector btn-group btn-group-xs"}, views);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var ContentView = React.createClass({displayName: "ContentView",
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
displayLarge: false,
|
2015-03-22 14:19:35 +00:00
|
|
|
|
View: ViewAuto
|
2015-03-21 23:21:38 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
propTypes: {
|
|
|
|
|
// It may seem a bit weird at the first glance:
|
|
|
|
|
// Every view takes the flow and the message as props, e.g.
|
|
|
|
|
// <Auto flow={flow} message={flow.request}/>
|
|
|
|
|
flow: React.PropTypes.object.isRequired,
|
|
|
|
|
message: React.PropTypes.object.isRequired,
|
|
|
|
|
},
|
|
|
|
|
selectView: function (view) {
|
|
|
|
|
this.setState({
|
|
|
|
|
View: view
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
displayLarge: function () {
|
|
|
|
|
this.setState({displayLarge: true});
|
|
|
|
|
},
|
|
|
|
|
componentWillReceiveProps: function (nextProps) {
|
|
|
|
|
if (nextProps.message !== this.props.message) {
|
|
|
|
|
this.setState(this.getInitialState());
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var message = this.props.message;
|
|
|
|
|
if (message.contentLength === 0) {
|
|
|
|
|
return React.createElement(ContentEmpty, React.__spread({}, this.props));
|
|
|
|
|
} else if (message.contentLength === null) {
|
|
|
|
|
return React.createElement(ContentMissing, React.__spread({}, this.props));
|
2015-03-22 14:19:35 +00:00
|
|
|
|
} else if (!this.state.displayLarge && TooLarge.isTooLarge(message)) {
|
2015-03-21 23:21:38 +00:00
|
|
|
|
return React.createElement(TooLarge, React.__spread({}, this.props, {onClick: this.displayLarge}));
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-22 14:29:55 +00:00
|
|
|
|
var downloadUrl = MessageUtils.getContentURL(this.props.flow, message);
|
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
return React.createElement("div", null,
|
|
|
|
|
React.createElement(this.state.View, React.__spread({}, this.props)),
|
2015-03-22 14:29:55 +00:00
|
|
|
|
React.createElement("div", {className: "view-options text-center"},
|
|
|
|
|
React.createElement(ViewSelector, {selectView: this.selectView, active: this.state.View, message: message}),
|
2015-03-22 23:24:56 +00:00
|
|
|
|
" ",
|
|
|
|
|
React.createElement("a", {className: "btn btn-default btn-xs", href: downloadUrl},
|
|
|
|
|
React.createElement("i", {className: "fa fa-download"})
|
|
|
|
|
)
|
2015-03-21 23:21:38 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = ContentView;
|
|
|
|
|
|
|
|
|
|
},{"../../flow/utils.js":21,"../../utils.js":24,"lodash":"lodash","react":"react"}],9:[function(require,module,exports){
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
|
|
|
|
var utils = require("../../utils.js");
|
|
|
|
|
|
2014-12-30 09:12:26 +00:00
|
|
|
|
var TimeStamp = React.createClass({displayName: "TimeStamp",
|
|
|
|
|
render: function () {
|
|
|
|
|
|
|
|
|
|
if (!this.props.t) {
|
|
|
|
|
//should be return null, but that triggers a React bug.
|
|
|
|
|
return React.createElement("tr", null);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var ts = utils.formatTimeStamp(this.props.t);
|
2014-12-30 09:12:26 +00:00
|
|
|
|
|
|
|
|
|
var delta;
|
|
|
|
|
if (this.props.deltaTo) {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
delta = utils.formatTimeDelta(1000 * (this.props.t - this.props.deltaTo));
|
2014-12-30 09:12:26 +00:00
|
|
|
|
delta = React.createElement("span", {className: "text-muted"}, "(" + delta + ")");
|
|
|
|
|
} else {
|
|
|
|
|
delta = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return React.createElement("tr", null,
|
|
|
|
|
React.createElement("td", null, this.props.title + ":"),
|
|
|
|
|
React.createElement("td", null, ts, " ", delta)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var ConnectionInfo = React.createClass({displayName: "ConnectionInfo",
|
|
|
|
|
|
|
|
|
|
render: function () {
|
|
|
|
|
var conn = this.props.conn;
|
|
|
|
|
var address = conn.address.address.join(":");
|
|
|
|
|
|
|
|
|
|
var sni = React.createElement("tr", {key: "sni"}); //should be null, but that triggers a React bug.
|
|
|
|
|
if (conn.sni) {
|
|
|
|
|
sni = React.createElement("tr", {key: "sni"},
|
|
|
|
|
React.createElement("td", null,
|
|
|
|
|
React.createElement("abbr", {title: "TLS Server Name Indication"}, "TLS SNI:")
|
|
|
|
|
),
|
|
|
|
|
React.createElement("td", null, conn.sni)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("table", {className: "connection-table"},
|
|
|
|
|
React.createElement("tbody", null,
|
|
|
|
|
React.createElement("tr", {key: "address"},
|
|
|
|
|
React.createElement("td", null, "Address:"),
|
|
|
|
|
React.createElement("td", null, address)
|
|
|
|
|
),
|
|
|
|
|
sni
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var CertificateInfo = React.createClass({displayName: "CertificateInfo",
|
|
|
|
|
render: function () {
|
|
|
|
|
//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 (
|
|
|
|
|
React.createElement("div", null,
|
|
|
|
|
client_conn.cert ? React.createElement("h4", null, "Client Certificate") : null,
|
|
|
|
|
client_conn.cert ? React.createElement("pre", {style: preStyle}, client_conn.cert) : null,
|
|
|
|
|
|
|
|
|
|
server_conn.cert ? React.createElement("h4", null, "Server Certificate") : null,
|
|
|
|
|
server_conn.cert ? React.createElement("pre", {style: preStyle}, server_conn.cert) : null
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var Timing = React.createClass({displayName: "Timing",
|
|
|
|
|
render: function () {
|
|
|
|
|
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 = _.sortBy(timestamps, 't');
|
|
|
|
|
|
|
|
|
|
var rows = timestamps.map(function (e) {
|
|
|
|
|
return React.createElement(TimeStamp, React.__spread({}, e));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", null,
|
|
|
|
|
React.createElement("h4", null, "Timing"),
|
|
|
|
|
React.createElement("table", {className: "timing-table"},
|
|
|
|
|
React.createElement("tbody", null,
|
|
|
|
|
rows
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var Details = React.createClass({displayName: "Details",
|
2014-12-30 09:12:26 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
var client_conn = flow.client_conn;
|
|
|
|
|
var server_conn = flow.server_conn;
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("section", null,
|
|
|
|
|
|
|
|
|
|
React.createElement("h4", null, "Client Connection"),
|
|
|
|
|
React.createElement(ConnectionInfo, {conn: client_conn}),
|
|
|
|
|
|
|
|
|
|
React.createElement("h4", null, "Server Connection"),
|
|
|
|
|
React.createElement(ConnectionInfo, {conn: server_conn}),
|
|
|
|
|
|
|
|
|
|
React.createElement(CertificateInfo, {flow: flow}),
|
|
|
|
|
|
|
|
|
|
React.createElement(Timing, {flow: flow})
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
module.exports = Details;
|
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../../utils.js":24,"lodash":"lodash","react":"react"}],10:[function(require,module,exports){
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
|
|
|
|
var common = require("../common.js");
|
|
|
|
|
var Nav = require("./nav.js");
|
|
|
|
|
var Messages = require("./messages.js");
|
|
|
|
|
var Details = require("./details.js");
|
|
|
|
|
|
2014-12-30 09:12:26 +00:00
|
|
|
|
var allTabs = {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
request: Messages.Request,
|
|
|
|
|
response: Messages.Response,
|
|
|
|
|
error: Messages.Error,
|
|
|
|
|
details: Details
|
2014-12-30 09:12:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var FlowView = React.createClass({displayName: "FlowView",
|
2015-01-01 07:49:32 +00:00
|
|
|
|
mixins: [common.StickyHeadMixin, common.Navigation, common.State],
|
2014-12-30 09:12:26 +00:00
|
|
|
|
getTabs: function (flow) {
|
|
|
|
|
var tabs = [];
|
|
|
|
|
["request", "response", "error"].forEach(function (e) {
|
|
|
|
|
if (flow[e]) {
|
|
|
|
|
tabs.push(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
tabs.push("details");
|
|
|
|
|
return tabs;
|
|
|
|
|
},
|
|
|
|
|
nextTab: function (i) {
|
|
|
|
|
var tabs = this.getTabs(this.props.flow);
|
|
|
|
|
var currentIndex = tabs.indexOf(this.getParams().detailTab);
|
|
|
|
|
// 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 (panel) {
|
|
|
|
|
this.replaceWith(
|
|
|
|
|
"flow",
|
|
|
|
|
{
|
|
|
|
|
flowId: this.getParams().flowId,
|
|
|
|
|
detailTab: panel
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
var tabs = this.getTabs(flow);
|
|
|
|
|
var active = this.getParams().detailTab;
|
|
|
|
|
|
|
|
|
|
if (!_.contains(tabs, active)) {
|
|
|
|
|
if (active === "response" && flow.error) {
|
|
|
|
|
active = "error";
|
|
|
|
|
} else if (active === "error" && flow.response) {
|
|
|
|
|
active = "response";
|
|
|
|
|
} else {
|
|
|
|
|
active = tabs[0];
|
|
|
|
|
}
|
|
|
|
|
this.selectTab(active);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var Tab = allTabs[active];
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", {className: "flow-detail", onScroll: this.adjustHead},
|
2015-03-21 21:49:51 +00:00
|
|
|
|
React.createElement(Nav, {ref: "head",
|
2014-12-30 09:12:26 +00:00
|
|
|
|
flow: flow,
|
|
|
|
|
tabs: tabs,
|
|
|
|
|
active: active,
|
|
|
|
|
selectTab: this.selectTab}),
|
|
|
|
|
React.createElement(Tab, {flow: flow})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
module.exports = FlowView;
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../common.js":4,"./details.js":9,"./messages.js":11,"./nav.js":12,"lodash":"lodash","react":"react"}],11:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var React = require("react");
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var _ = require("lodash");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var common = require("../common.js");
|
|
|
|
|
var actions = require("../../actions.js");
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var flowutils = require("../../flow/utils.js");
|
|
|
|
|
var utils = require("../../utils.js");
|
2015-03-21 23:21:38 +00:00
|
|
|
|
var ContentView = require("./contentview.js");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var Headers = React.createClass({displayName: "Headers",
|
2015-03-27 14:30:19 +00:00
|
|
|
|
propTypes: {
|
|
|
|
|
onChange: React.PropTypes.func.isRequired,
|
|
|
|
|
message: React.PropTypes.object.isRequired
|
|
|
|
|
},
|
|
|
|
|
onChange: function (row, col, val) {
|
|
|
|
|
var nextHeaders = _.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);
|
|
|
|
|
},
|
|
|
|
|
onTab: function (row, col, e) {
|
|
|
|
|
var headers = this.props.message.headers;
|
|
|
|
|
if (row === headers.length - 1 && col === 1) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
var nextHeaders = _.cloneDeep(this.props.message.headers);
|
|
|
|
|
nextHeaders.push(["Name", "Value"]);
|
|
|
|
|
this.props.onChange(nextHeaders);
|
|
|
|
|
this._nextSel = (row + 1) + "-key";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
componentDidUpdate: function () {
|
|
|
|
|
if (this._nextSel && this.refs[this._nextSel]) {
|
|
|
|
|
this.refs[this._nextSel].focus();
|
|
|
|
|
this._nextSel = undefined;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onRemove: function (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();
|
|
|
|
|
}
|
|
|
|
|
},
|
2014-12-30 08:51:07 +00:00
|
|
|
|
render: function () {
|
2015-03-27 14:30:19 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var rows = this.props.message.headers.map(function (header, i) {
|
2015-03-27 14:30:19 +00:00
|
|
|
|
|
|
|
|
|
var kEdit = React.createElement(HeaderInlineInput, {
|
|
|
|
|
ref: i + "-key",
|
|
|
|
|
content: header[0],
|
|
|
|
|
onChange: this.onChange.bind(null, i, 0),
|
|
|
|
|
onRemove: this.onRemove.bind(null, i, 0),
|
|
|
|
|
onTab: this.onTab.bind(null, i, 0)});
|
|
|
|
|
var vEdit = React.createElement(HeaderInlineInput, {
|
|
|
|
|
ref: i + "-value",
|
|
|
|
|
content: header[1],
|
|
|
|
|
onChange: this.onChange.bind(null, i, 1),
|
|
|
|
|
onRemove: this.onRemove.bind(null, i, 1),
|
|
|
|
|
onTab: this.onTab.bind(null, i, 1)});
|
2015-03-21 21:49:51 +00:00
|
|
|
|
return (
|
|
|
|
|
React.createElement("tr", {key: i},
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement("td", {className: "header-name"}, kEdit, ":"),
|
|
|
|
|
React.createElement("td", {className: "header-value"}, vEdit)
|
2015-03-21 21:49:51 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
2015-03-27 14:30:19 +00:00
|
|
|
|
}.bind(this));
|
2015-03-21 21:49:51 +00:00
|
|
|
|
return (
|
|
|
|
|
React.createElement("table", {className: "header-table"},
|
|
|
|
|
React.createElement("tbody", null,
|
|
|
|
|
rows
|
|
|
|
|
)
|
|
|
|
|
)
|
2014-12-30 08:51:07 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-27 14:30:19 +00:00
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var InlineInput = React.createClass({displayName: "InlineInput",
|
|
|
|
|
mixins: [common.ChildFocus],
|
2015-03-27 14:30:19 +00:00
|
|
|
|
propTypes: {
|
|
|
|
|
content: React.PropTypes.string.isRequired, //must be string to match strict equality.
|
|
|
|
|
onChange: React.PropTypes.func.isRequired,
|
|
|
|
|
},
|
2015-03-22 23:24:56 +00:00
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
editable: false
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var Tag = this.props.tag || "span";
|
|
|
|
|
var className = "inline-input " + (this.props.className || "");
|
|
|
|
|
var html = {__html: _.escape(this.props.content)};
|
|
|
|
|
return React.createElement(Tag, React.__spread({},
|
|
|
|
|
this.props,
|
|
|
|
|
{tabIndex: "0",
|
|
|
|
|
className: className,
|
|
|
|
|
contentEditable: this.state.editable || undefined,
|
|
|
|
|
onInput: this.onInput,
|
|
|
|
|
onFocus: this.onFocus,
|
|
|
|
|
onBlur: this.onBlur,
|
|
|
|
|
onKeyDown: this.onKeyDown,
|
|
|
|
|
dangerouslySetInnerHTML: html})
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onKeyDown: function (e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
switch (e.keyCode) {
|
|
|
|
|
case utils.Key.ESC:
|
|
|
|
|
this.blur();
|
|
|
|
|
break;
|
|
|
|
|
case utils.Key.ENTER:
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (!e.ctrlKey) {
|
|
|
|
|
this.blur();
|
|
|
|
|
} else {
|
|
|
|
|
this.props.onDone && this.props.onDone();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2015-03-27 14:30:19 +00:00
|
|
|
|
this.props.onKeyDown && this.props.onKeyDown(e);
|
2015-03-22 23:24:56 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-03-27 14:30:19 +00:00
|
|
|
|
blur: function () {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
this.getDOMNode().blur();
|
|
|
|
|
this.context.returnFocus && this.context.returnFocus();
|
|
|
|
|
},
|
|
|
|
|
selectContents: function () {
|
|
|
|
|
var range = document.createRange();
|
|
|
|
|
range.selectNodeContents(this.getDOMNode());
|
|
|
|
|
var sel = window.getSelection();
|
|
|
|
|
sel.removeAllRanges();
|
|
|
|
|
sel.addRange(range);
|
|
|
|
|
},
|
|
|
|
|
onFocus: function () {
|
|
|
|
|
this.setState({editable: true}, this.selectContents);
|
|
|
|
|
},
|
|
|
|
|
onBlur: function (e) {
|
|
|
|
|
this.setState({editable: false});
|
|
|
|
|
this.handleChange();
|
|
|
|
|
this.props.onDone && this.props.onDone();
|
|
|
|
|
},
|
|
|
|
|
onInput: function () {
|
|
|
|
|
this.handleChange();
|
|
|
|
|
},
|
|
|
|
|
handleChange: function () {
|
|
|
|
|
var content = this.getDOMNode().textContent;
|
|
|
|
|
if (content !== this.props.content) {
|
|
|
|
|
this.props.onChange(content);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-27 14:30:19 +00:00
|
|
|
|
var HeaderInlineInput = React.createClass({displayName: "HeaderInlineInput",
|
|
|
|
|
render: function () {
|
|
|
|
|
return React.createElement(InlineInput, React.__spread({ref: "input"}, this.props, {onKeyDown: this.onKeyDown}));
|
|
|
|
|
},
|
|
|
|
|
focus: function () {
|
|
|
|
|
this.getDOMNode().focus();
|
|
|
|
|
},
|
|
|
|
|
onKeyDown: function (e) {
|
|
|
|
|
switch (e.keyCode) {
|
|
|
|
|
case utils.Key.BACKSPACE:
|
|
|
|
|
var s = window.getSelection().getRangeAt(0);
|
|
|
|
|
if (s.startOffset === 0 && s.endOffset === 0) {
|
|
|
|
|
this.props.onRemove(e);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case utils.Key.TAB:
|
|
|
|
|
if(!e.shiftKey){
|
|
|
|
|
this.props.onTab(e);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var ValidateInlineInput = React.createClass({displayName: "ValidateInlineInput",
|
2015-03-27 14:30:19 +00:00
|
|
|
|
propTypes: {
|
|
|
|
|
onChange: React.PropTypes.func.isRequired,
|
|
|
|
|
isValid: React.PropTypes.func.isRequired,
|
|
|
|
|
immediate: React.PropTypes.bool
|
|
|
|
|
},
|
2015-03-22 23:24:56 +00:00
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
2015-03-27 14:30:19 +00:00
|
|
|
|
content: this.props.content,
|
|
|
|
|
originalContent: this.props.content
|
2015-03-22 23:24:56 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
onChange: function (val) {
|
|
|
|
|
this.setState({
|
|
|
|
|
content: val
|
|
|
|
|
});
|
2015-03-27 14:30:19 +00:00
|
|
|
|
if (this.props.immediate && val !== this.state.originalContent && this.props.isValid(val)) {
|
|
|
|
|
this.props.onChange(val);
|
|
|
|
|
}
|
2015-03-22 23:24:56 +00:00
|
|
|
|
},
|
|
|
|
|
onDone: function () {
|
|
|
|
|
if (this.state.content === this.state.originalContent) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (this.props.isValid(this.state.content)) {
|
|
|
|
|
this.props.onChange(this.state.content);
|
|
|
|
|
} else {
|
|
|
|
|
this.setState({
|
|
|
|
|
content: this.state.originalContent
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
componentWillReceiveProps: function (nextProps) {
|
|
|
|
|
if (nextProps.content !== this.state.content) {
|
|
|
|
|
this.setState({
|
2015-03-27 14:30:19 +00:00
|
|
|
|
content: nextProps.content,
|
|
|
|
|
originalContent: nextProps.content
|
2015-03-22 23:24:56 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var className = this.props.className || "";
|
|
|
|
|
if (this.props.isValid(this.state.content)) {
|
|
|
|
|
className += " has-success";
|
|
|
|
|
} else {
|
|
|
|
|
className += " has-warning"
|
|
|
|
|
}
|
|
|
|
|
return React.createElement(InlineInput, React.__spread({}, this.props,
|
|
|
|
|
{className: className,
|
|
|
|
|
content: this.state.content,
|
|
|
|
|
onChange: this.onChange,
|
|
|
|
|
onDone: this.onDone})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var RequestLine = React.createClass({displayName: "RequestLine",
|
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
var url = flowutils.RequestUtils.pretty_url(flow.request);
|
|
|
|
|
var httpver = "HTTP/" + flow.request.httpversion.join(".");
|
|
|
|
|
|
|
|
|
|
return React.createElement("div", {className: "first-line request-line"},
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement(InlineInput, {content: flow.request.method, onChange: this.onMethodChange}),
|
2015-03-22 23:24:56 +00:00
|
|
|
|
" ",
|
|
|
|
|
React.createElement(ValidateInlineInput, {content: url, onChange: this.onUrlChange, isValid: this.isValidUrl}),
|
|
|
|
|
" ",
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement(ValidateInlineInput, {immediate: true, content: httpver, onChange: this.onHttpVersionChange, isValid: flowutils.isValidHttpVersion})
|
2015-03-22 23:24:56 +00:00
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
isValidUrl: function (url) {
|
|
|
|
|
var u = flowutils.parseUrl(url);
|
|
|
|
|
return !!u.host;
|
|
|
|
|
},
|
|
|
|
|
onMethodChange: function (nextMethod) {
|
|
|
|
|
actions.FlowActions.update(
|
|
|
|
|
this.props.flow,
|
|
|
|
|
{request: {method: nextMethod}}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onUrlChange: function (nextUrl) {
|
|
|
|
|
var props = flowutils.parseUrl(nextUrl);
|
|
|
|
|
props.path = props.path || "";
|
|
|
|
|
actions.FlowActions.update(
|
|
|
|
|
this.props.flow,
|
|
|
|
|
{request: props}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onHttpVersionChange: function (nextVer) {
|
|
|
|
|
var ver = flowutils.parseHttpVersion(nextVer);
|
|
|
|
|
actions.FlowActions.update(
|
|
|
|
|
this.props.flow,
|
|
|
|
|
{request: {httpversion: ver}}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var ResponseLine = React.createClass({displayName: "ResponseLine",
|
2014-12-30 08:51:07 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var httpver = "HTTP/" + flow.response.httpversion.join(".");
|
|
|
|
|
return React.createElement("div", {className: "first-line response-line"},
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement(ValidateInlineInput, {immediate: true, content: httpver, onChange: this.onHttpVersionChange, isValid: flowutils.isValidHttpVersion}),
|
2015-03-22 23:24:56 +00:00
|
|
|
|
" ",
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement(ValidateInlineInput, {immediate: true, content: flow.response.code + "", onChange: this.onCodeChange, isValid: this.isValidCode}),
|
2015-03-22 23:24:56 +00:00
|
|
|
|
" ",
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement(InlineInput, {content: flow.response.msg, onChange: this.onMsgChange})
|
2015-03-17 02:05:59 +00:00
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
isValidCode: function (code) {
|
|
|
|
|
return /^\d+$/.test(code);
|
|
|
|
|
},
|
|
|
|
|
onHttpVersionChange: function (nextVer) {
|
|
|
|
|
var ver = flowutils.parseHttpVersion(nextVer);
|
|
|
|
|
actions.FlowActions.update(
|
|
|
|
|
this.props.flow,
|
|
|
|
|
{response: {httpversion: ver}}
|
|
|
|
|
);
|
|
|
|
|
},
|
2015-03-27 14:30:19 +00:00
|
|
|
|
onMsgChange: function (nextMsg) {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
actions.FlowActions.update(
|
|
|
|
|
this.props.flow,
|
|
|
|
|
{response: {msg: nextMsg}}
|
|
|
|
|
);
|
|
|
|
|
},
|
2015-03-27 14:30:19 +00:00
|
|
|
|
onCodeChange: function (nextCode) {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
nextCode = parseInt(nextCode);
|
|
|
|
|
actions.FlowActions.update(
|
|
|
|
|
this.props.flow,
|
|
|
|
|
{response: {code: nextCode}}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var Request = React.createClass({displayName: "Request",
|
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
2015-03-21 21:49:51 +00:00
|
|
|
|
return (
|
2015-03-22 23:24:56 +00:00
|
|
|
|
React.createElement("section", {className: "request"},
|
|
|
|
|
React.createElement(RequestLine, {flow: flow}),
|
|
|
|
|
/*<ResponseLine flow={flow}/>*/
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement(Headers, {message: flow.request, onChange: this.onHeaderChange}),
|
2015-03-21 21:49:51 +00:00
|
|
|
|
React.createElement("hr", null),
|
2015-03-21 23:21:38 +00:00
|
|
|
|
React.createElement(ContentView, {flow: flow, message: flow.request})
|
2015-03-21 21:49:51 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
2015-03-27 14:30:19 +00:00
|
|
|
|
},
|
|
|
|
|
onHeaderChange: function (nextHeaders) {
|
|
|
|
|
actions.FlowActions.update(this.props.flow, {
|
|
|
|
|
request: {
|
|
|
|
|
headers: nextHeaders
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-03-21 21:49:51 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var Response = React.createClass({displayName: "Response",
|
2014-12-30 08:51:07 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
return (
|
2015-03-22 23:24:56 +00:00
|
|
|
|
React.createElement("section", {className: "response"},
|
|
|
|
|
/*<RequestLine flow={flow}/>*/
|
|
|
|
|
React.createElement(ResponseLine, {flow: flow}),
|
2015-03-27 14:30:19 +00:00
|
|
|
|
React.createElement(Headers, {message: flow.response, onChange: this.onHeaderChange}),
|
2015-03-21 21:49:51 +00:00
|
|
|
|
React.createElement("hr", null),
|
2015-03-21 23:21:38 +00:00
|
|
|
|
React.createElement(ContentView, {flow: flow, message: flow.response})
|
2015-03-21 21:49:51 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
2015-03-27 14:30:19 +00:00
|
|
|
|
},
|
|
|
|
|
onHeaderChange: function (nextHeaders) {
|
|
|
|
|
actions.FlowActions.update(this.props.flow, {
|
|
|
|
|
response: {
|
|
|
|
|
headers: nextHeaders
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var Error = React.createClass({displayName: "Error",
|
2014-12-30 08:51:07 +00:00
|
|
|
|
render: function () {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var flow = this.props.flow;
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("section", null,
|
|
|
|
|
React.createElement("div", {className: "alert alert-warning"},
|
|
|
|
|
flow.error.msg,
|
|
|
|
|
React.createElement("div", null,
|
|
|
|
|
React.createElement("small", null, utils.formatTimeStamp(flow.error.timestamp) )
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
2014-12-30 08:51:07 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
module.exports = {
|
|
|
|
|
Request: Request,
|
|
|
|
|
Response: Response,
|
|
|
|
|
Error: Error
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
},{"../../actions.js":2,"../../flow/utils.js":21,"../../utils.js":24,"../common.js":4,"./contentview.js":8,"lodash":"lodash","react":"react"}],12:[function(require,module,exports){
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var React = require("react");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var actions = require("../../actions.js");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var NavAction = React.createClass({displayName: "NavAction",
|
|
|
|
|
onClick: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.props.onClick();
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
2015-03-21 21:49:51 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("a", {title: this.props.title,
|
|
|
|
|
href: "#",
|
|
|
|
|
className: "nav-action",
|
|
|
|
|
onClick: this.onClick},
|
|
|
|
|
React.createElement("i", {className: "fa fa-fw " + this.props.icon})
|
|
|
|
|
)
|
2014-12-30 08:51:07 +00:00
|
|
|
|
);
|
2015-03-21 21:49:51 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var Nav = React.createClass({displayName: "Nav",
|
2014-12-30 08:51:07 +00:00
|
|
|
|
render: function () {
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var flow = this.props.flow;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
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 React.createElement("a", {key: e,
|
|
|
|
|
href: "#",
|
|
|
|
|
className: className,
|
|
|
|
|
onClick: onClick}, str);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
|
|
var acceptButton = null;
|
|
|
|
|
if(flow.intercepted){
|
|
|
|
|
acceptButton = React.createElement(NavAction, {title: "[a]ccept intercepted flow", icon: "fa-play", onClick: actions.FlowActions.accept.bind(null, flow)});
|
|
|
|
|
}
|
|
|
|
|
var revertButton = null;
|
|
|
|
|
if(flow.modified){
|
|
|
|
|
revertButton = React.createElement(NavAction, {title: "revert changes to flow [V]", icon: "fa-history", onClick: actions.FlowActions.revert.bind(null, flow)});
|
|
|
|
|
}
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
return (
|
2015-03-21 21:49:51 +00:00
|
|
|
|
React.createElement("nav", {ref: "head", className: "nav-tabs nav-tabs-sm"},
|
|
|
|
|
tabs,
|
|
|
|
|
React.createElement(NavAction, {title: "[d]elete flow", icon: "fa-trash", onClick: actions.FlowActions.delete.bind(null, flow)}),
|
|
|
|
|
React.createElement(NavAction, {title: "[D]uplicate flow", icon: "fa-copy", onClick: actions.FlowActions.duplicate.bind(null, flow)}),
|
|
|
|
|
React.createElement(NavAction, {disabled: true, title: "[r]eplay flow", icon: "fa-repeat", onClick: actions.FlowActions.replay.bind(null, flow)}),
|
|
|
|
|
acceptButton,
|
|
|
|
|
revertButton
|
2014-12-30 08:51:07 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
module.exports = Nav;
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../../actions.js":2,"react":"react"}],13:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
|
|
|
|
|
var Footer = React.createClass({displayName: "Footer",
|
|
|
|
|
render: function () {
|
|
|
|
|
var mode = this.props.settings.mode;
|
|
|
|
|
var intercept = this.props.settings.intercept;
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("footer", null,
|
|
|
|
|
mode != "regular" ? React.createElement("span", {className: "label label-success"}, mode, " mode") : null,
|
|
|
|
|
" ",
|
|
|
|
|
intercept ? React.createElement("span", {className: "label label-success"}, "Intercept: ", intercept) : null
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = Footer;
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"react":"react"}],14:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
2015-01-02 22:46:51 +00:00
|
|
|
|
var Filt = require("../filt/filt.js");
|
|
|
|
|
var utils = require("../utils.js");
|
2015-01-01 07:49:32 +00:00
|
|
|
|
var common = require("./common.js");
|
2015-03-06 08:54:18 +00:00
|
|
|
|
var actions = require("../actions.js");
|
2015-03-15 21:05:50 +00:00
|
|
|
|
var Query = require("../actions.js").Query;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
var FilterDocs = React.createClass({displayName: "FilterDocs",
|
|
|
|
|
statics: {
|
|
|
|
|
xhr: false,
|
|
|
|
|
doc: false
|
|
|
|
|
},
|
|
|
|
|
componentWillMount: function () {
|
|
|
|
|
if (!FilterDocs.doc) {
|
|
|
|
|
FilterDocs.xhr = $.getJSON("/filter-help").done(function (doc) {
|
|
|
|
|
FilterDocs.doc = doc;
|
|
|
|
|
FilterDocs.xhr = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (FilterDocs.xhr) {
|
|
|
|
|
FilterDocs.xhr.done(function () {
|
|
|
|
|
this.forceUpdate();
|
|
|
|
|
}.bind(this));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
if (!FilterDocs.doc) {
|
|
|
|
|
return React.createElement("i", {className: "fa fa-spinner fa-spin"});
|
|
|
|
|
} else {
|
|
|
|
|
var commands = FilterDocs.doc.commands.map(function (c) {
|
2015-03-15 21:05:50 +00:00
|
|
|
|
return React.createElement("tr", {key: c[1]},
|
2014-12-30 08:51:07 +00:00
|
|
|
|
React.createElement("td", null, c[0].replace(" ", '\u00a0')),
|
|
|
|
|
React.createElement("td", null, c[1])
|
|
|
|
|
);
|
|
|
|
|
});
|
2015-03-15 21:05:50 +00:00
|
|
|
|
commands.push(React.createElement("tr", {key: "docs-link"},
|
2014-12-30 08:51:07 +00:00
|
|
|
|
React.createElement("td", {colSpan: "2"},
|
|
|
|
|
React.createElement("a", {href: "https://mitmproxy.org/doc/features/filters.html",
|
|
|
|
|
target: "_blank"},
|
|
|
|
|
React.createElement("i", {className: "fa fa-external-link"}),
|
|
|
|
|
" mitmproxy docs")
|
|
|
|
|
)
|
|
|
|
|
));
|
|
|
|
|
return React.createElement("table", {className: "table table-condensed"},
|
|
|
|
|
React.createElement("tbody", null, commands)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
var FilterInput = React.createClass({displayName: "FilterInput",
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
// Consider both focus and mouseover for showing/hiding the tooltip,
|
|
|
|
|
// because onBlur of the input is triggered before the click on the tooltip
|
|
|
|
|
// finalized, hiding the tooltip just as the user clicks on it.
|
|
|
|
|
return {
|
|
|
|
|
value: this.props.value,
|
|
|
|
|
focus: false,
|
|
|
|
|
mousefocus: false
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
componentWillReceiveProps: function (nextProps) {
|
|
|
|
|
this.setState({value: nextProps.value});
|
|
|
|
|
},
|
|
|
|
|
onChange: function (e) {
|
|
|
|
|
var nextValue = e.target.value;
|
|
|
|
|
this.setState({
|
|
|
|
|
value: nextValue
|
|
|
|
|
});
|
|
|
|
|
// Only propagate valid filters upwards.
|
|
|
|
|
if (this.isValid(nextValue)) {
|
|
|
|
|
this.props.onChange(nextValue);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
isValid: function (filt) {
|
|
|
|
|
try {
|
|
|
|
|
Filt.parse(filt || this.state.value);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getDesc: function () {
|
|
|
|
|
var desc;
|
|
|
|
|
try {
|
|
|
|
|
desc = Filt.parse(this.state.value).desc;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
desc = "" + e;
|
|
|
|
|
}
|
|
|
|
|
if (desc !== "true") {
|
|
|
|
|
return desc;
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
React.createElement(FilterDocs, null)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onFocus: function () {
|
|
|
|
|
this.setState({focus: true});
|
|
|
|
|
},
|
|
|
|
|
onBlur: function () {
|
|
|
|
|
this.setState({focus: false});
|
|
|
|
|
},
|
|
|
|
|
onMouseEnter: function () {
|
|
|
|
|
this.setState({mousefocus: true});
|
|
|
|
|
},
|
|
|
|
|
onMouseLeave: function () {
|
|
|
|
|
this.setState({mousefocus: false});
|
|
|
|
|
},
|
|
|
|
|
onKeyDown: function (e) {
|
2015-01-02 22:46:51 +00:00
|
|
|
|
if (e.keyCode === utils.Key.ESC || e.keyCode === utils.Key.ENTER) {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.blur();
|
|
|
|
|
// If closed using ESC/ENTER, hide the tooltip.
|
|
|
|
|
this.setState({mousefocus: false});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
blur: function () {
|
|
|
|
|
this.refs.input.getDOMNode().blur();
|
|
|
|
|
},
|
|
|
|
|
focus: function () {
|
|
|
|
|
this.refs.input.getDOMNode().select();
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var isValid = this.isValid();
|
|
|
|
|
var icon = "fa fa-fw fa-" + this.props.type;
|
|
|
|
|
var groupClassName = "filter-input input-group" + (isValid ? "" : " has-error");
|
|
|
|
|
|
|
|
|
|
var popover;
|
|
|
|
|
if (this.state.focus || this.state.mousefocus) {
|
|
|
|
|
popover = (
|
|
|
|
|
React.createElement("div", {className: "popover bottom", onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave},
|
|
|
|
|
React.createElement("div", {className: "arrow"}),
|
|
|
|
|
React.createElement("div", {className: "popover-content"},
|
|
|
|
|
this.getDesc()
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", {className: groupClassName},
|
|
|
|
|
React.createElement("span", {className: "input-group-addon"},
|
|
|
|
|
React.createElement("i", {className: icon, style: {color: this.props.color}})
|
|
|
|
|
),
|
|
|
|
|
React.createElement("input", {type: "text", placeholder: this.props.placeholder, className: "form-control",
|
|
|
|
|
ref: "input",
|
|
|
|
|
onChange: this.onChange,
|
|
|
|
|
onFocus: this.onFocus,
|
|
|
|
|
onBlur: this.onBlur,
|
|
|
|
|
onKeyDown: this.onKeyDown,
|
|
|
|
|
value: this.state.value}),
|
|
|
|
|
popover
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var MainMenu = React.createClass({displayName: "MainMenu",
|
2015-01-01 07:49:32 +00:00
|
|
|
|
mixins: [common.Navigation, common.State],
|
2014-12-30 08:51:07 +00:00
|
|
|
|
statics: {
|
|
|
|
|
title: "Start",
|
|
|
|
|
route: "flows"
|
|
|
|
|
},
|
|
|
|
|
onFilterChange: function (val) {
|
|
|
|
|
var d = {};
|
|
|
|
|
d[Query.FILTER] = val;
|
|
|
|
|
this.setQuery(d);
|
|
|
|
|
},
|
|
|
|
|
onHighlightChange: function (val) {
|
|
|
|
|
var d = {};
|
|
|
|
|
d[Query.HIGHLIGHT] = val;
|
|
|
|
|
this.setQuery(d);
|
|
|
|
|
},
|
|
|
|
|
onInterceptChange: function (val) {
|
2015-03-21 20:55:02 +00:00
|
|
|
|
actions.SettingsActions.update({intercept: val});
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var filter = this.getQuery()[Query.FILTER] || "";
|
|
|
|
|
var highlight = this.getQuery()[Query.HIGHLIGHT] || "";
|
|
|
|
|
var intercept = this.props.settings.intercept || "";
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", null,
|
|
|
|
|
React.createElement("div", {className: "menu-row"},
|
|
|
|
|
React.createElement(FilterInput, {
|
|
|
|
|
placeholder: "Filter",
|
|
|
|
|
type: "filter",
|
|
|
|
|
color: "black",
|
|
|
|
|
value: filter,
|
|
|
|
|
onChange: this.onFilterChange}),
|
|
|
|
|
React.createElement(FilterInput, {
|
|
|
|
|
placeholder: "Highlight",
|
|
|
|
|
type: "tag",
|
|
|
|
|
color: "hsl(48, 100%, 50%)",
|
|
|
|
|
value: highlight,
|
|
|
|
|
onChange: this.onHighlightChange}),
|
|
|
|
|
React.createElement(FilterInput, {
|
|
|
|
|
placeholder: "Intercept",
|
|
|
|
|
type: "pause",
|
|
|
|
|
color: "hsl(208, 56%, 53%)",
|
|
|
|
|
value: intercept,
|
|
|
|
|
onChange: this.onInterceptChange})
|
|
|
|
|
),
|
|
|
|
|
React.createElement("div", {className: "clearfix"})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ViewMenu = React.createClass({displayName: "ViewMenu",
|
|
|
|
|
statics: {
|
|
|
|
|
title: "View",
|
|
|
|
|
route: "flows"
|
|
|
|
|
},
|
2015-01-01 07:49:32 +00:00
|
|
|
|
mixins: [common.Navigation, common.State],
|
2014-12-30 08:51:07 +00:00
|
|
|
|
toggleEventLog: function () {
|
|
|
|
|
var d = {};
|
|
|
|
|
|
|
|
|
|
if (this.getQuery()[Query.SHOW_EVENTLOG]) {
|
|
|
|
|
d[Query.SHOW_EVENTLOG] = undefined;
|
|
|
|
|
} else {
|
|
|
|
|
d[Query.SHOW_EVENTLOG] = "t"; // any non-false value will do it, keep it short
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setQuery(d);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var showEventLog = this.getQuery()[Query.SHOW_EVENTLOG];
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", null,
|
|
|
|
|
React.createElement("button", {
|
|
|
|
|
className: "btn " + (showEventLog ? "btn-primary" : "btn-default"),
|
|
|
|
|
onClick: this.toggleEventLog},
|
|
|
|
|
React.createElement("i", {className: "fa fa-database"}),
|
|
|
|
|
" Show Eventlog"
|
|
|
|
|
),
|
|
|
|
|
React.createElement("span", null, " ")
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ReportsMenu = React.createClass({displayName: "ReportsMenu",
|
|
|
|
|
statics: {
|
|
|
|
|
title: "Visualization",
|
|
|
|
|
route: "reports"
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
return React.createElement("div", null, "Reports Menu");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var FileMenu = React.createClass({displayName: "FileMenu",
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
showFileMenu: false
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
handleFileClick: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (!this.state.showFileMenu) {
|
|
|
|
|
var close = function () {
|
|
|
|
|
this.setState({showFileMenu: false});
|
|
|
|
|
document.removeEventListener("click", close);
|
|
|
|
|
}.bind(this);
|
|
|
|
|
document.addEventListener("click", close);
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
showFileMenu: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleNewClick: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (confirm("Delete all flows?")) {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.clear();
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleOpenClick: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
console.error("unimplemented: handleOpenClick");
|
|
|
|
|
},
|
|
|
|
|
handleSaveClick: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
console.error("unimplemented: handleSaveClick");
|
|
|
|
|
},
|
|
|
|
|
handleShutdownClick: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
console.error("unimplemented: handleShutdownClick");
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var fileMenuClass = "dropdown pull-left" + (this.state.showFileMenu ? " open" : "");
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", {className: fileMenuClass},
|
2015-01-01 07:44:45 +00:00
|
|
|
|
React.createElement("a", {href: "#", className: "special", onClick: this.handleFileClick}, " mitmproxy "),
|
2014-12-30 08:51:07 +00:00
|
|
|
|
React.createElement("ul", {className: "dropdown-menu", role: "menu"},
|
|
|
|
|
React.createElement("li", null,
|
|
|
|
|
React.createElement("a", {href: "#", onClick: this.handleNewClick},
|
|
|
|
|
React.createElement("i", {className: "fa fa-fw fa-file"}),
|
|
|
|
|
"New"
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
React.createElement("li", {role: "presentation", className: "divider"}),
|
|
|
|
|
React.createElement("li", null,
|
|
|
|
|
React.createElement("a", {href: "http://mitm.it/", target: "_blank"},
|
|
|
|
|
React.createElement("i", {className: "fa fa-fw fa-external-link"}),
|
|
|
|
|
"Install Certificates..."
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
/*
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#" onClick={this.handleOpenClick}>
|
|
|
|
|
<i className="fa fa-fw fa-folder-open"></i>
|
|
|
|
|
Open
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#" onClick={this.handleSaveClick}>
|
|
|
|
|
<i className="fa fa-fw fa-save"></i>
|
|
|
|
|
Save
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li role="presentation" className="divider"></li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#" onClick={this.handleShutdownClick}>
|
|
|
|
|
<i className="fa fa-fw fa-plug"></i>
|
|
|
|
|
Shutdown
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
*/
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var header_entries = [MainMenu, ViewMenu /*, ReportsMenu */];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Header = React.createClass({displayName: "Header",
|
2015-01-01 07:49:32 +00:00
|
|
|
|
mixins: [common.Navigation],
|
2014-12-30 08:51:07 +00:00
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
active: header_entries[0]
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
handleClick: function (active, e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.replaceWith(active.route);
|
|
|
|
|
this.setState({active: active});
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var header = header_entries.map(function (entry, i) {
|
2015-03-22 13:33:42 +00:00
|
|
|
|
var className;
|
|
|
|
|
if(entry === this.state.active){
|
|
|
|
|
className = "active";
|
|
|
|
|
} else {
|
|
|
|
|
className = "";
|
|
|
|
|
}
|
2014-12-30 08:51:07 +00:00
|
|
|
|
return (
|
|
|
|
|
React.createElement("a", {key: i,
|
|
|
|
|
href: "#",
|
2015-03-22 13:33:42 +00:00
|
|
|
|
className: className,
|
|
|
|
|
onClick: this.handleClick.bind(this, entry)},
|
2014-12-30 08:51:07 +00:00
|
|
|
|
entry.title
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("header", null,
|
|
|
|
|
React.createElement("nav", {className: "nav-tabs nav-tabs-lg"},
|
|
|
|
|
React.createElement(FileMenu, null),
|
|
|
|
|
header
|
|
|
|
|
),
|
|
|
|
|
React.createElement("div", {className: "menu"},
|
|
|
|
|
React.createElement(this.state.active, {settings: this.props.settings})
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
Header: Header
|
|
|
|
|
}
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../actions.js":2,"../filt/filt.js":20,"../utils.js":24,"./common.js":4,"jquery":"jquery","react":"react"}],15:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
|
2015-01-01 07:49:32 +00:00
|
|
|
|
var common = require("./common.js");
|
2015-03-06 08:54:18 +00:00
|
|
|
|
var actions = require("../actions.js");
|
2015-03-15 21:05:50 +00:00
|
|
|
|
var Query = require("../actions.js").Query;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
var toputils = require("../utils.js");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var views = require("../store/view.js");
|
|
|
|
|
var Filt = require("../filt/filt.js");
|
2015-01-01 02:37:42 +00:00
|
|
|
|
FlowTable = require("./flowtable.js");
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var FlowView = require("./flowview/index.js");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
var MainView = React.createClass({displayName: "MainView",
|
2015-01-01 07:49:32 +00:00
|
|
|
|
mixins: [common.Navigation, common.State],
|
2015-03-22 23:24:56 +00:00
|
|
|
|
childContextTypes: {
|
|
|
|
|
returnFocus: React.PropTypes.func.isRequired
|
|
|
|
|
},
|
|
|
|
|
getChildContext: function() {
|
|
|
|
|
return { returnFocus: this.returnFocus };
|
|
|
|
|
},
|
|
|
|
|
returnFocus: function(){
|
|
|
|
|
this.getDOMNode().focus();
|
|
|
|
|
},
|
2014-12-30 08:51:07 +00:00
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
2015-03-17 02:05:59 +00:00
|
|
|
|
flows: [],
|
|
|
|
|
sortKeyFun: false
|
2014-12-30 08:51:07 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
getViewFilt: function () {
|
|
|
|
|
try {
|
|
|
|
|
var filt = Filt.parse(this.getQuery()[Query.FILTER] || "");
|
|
|
|
|
var highlightStr = this.getQuery()[Query.HIGHLIGHT];
|
|
|
|
|
var highlight = highlightStr ? Filt.parse(highlightStr) : false;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Error when processing filter: " + e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function filter_and_highlight(flow) {
|
|
|
|
|
if (!this._highlight) {
|
|
|
|
|
this._highlight = {};
|
|
|
|
|
}
|
|
|
|
|
this._highlight[flow.id] = highlight && highlight(flow);
|
|
|
|
|
return filt(flow);
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
componentWillReceiveProps: function (nextProps) {
|
|
|
|
|
if (nextProps.flowStore !== this.props.flowStore) {
|
|
|
|
|
this.closeView();
|
|
|
|
|
this.openView(nextProps.flowStore);
|
|
|
|
|
}
|
2015-03-15 21:05:50 +00:00
|
|
|
|
|
|
|
|
|
var filterChanged = (this.props.query[Query.FILTER] !== nextProps.query[Query.FILTER]);
|
|
|
|
|
var highlightChanged = (this.props.query[Query.HIGHLIGHT] !== nextProps.query[Query.HIGHLIGHT]);
|
|
|
|
|
if (filterChanged || highlightChanged) {
|
2015-03-17 02:05:59 +00:00
|
|
|
|
this.state.view.recalculate(this.getViewFilt(), this.state.sortKeyFun);
|
2015-03-15 21:05:50 +00:00
|
|
|
|
}
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
|
|
|
|
openView: function (store) {
|
2015-03-17 02:05:59 +00:00
|
|
|
|
var view = new views.StoreView(store, this.getViewFilt(), this.state.sortKeyFun);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.setState({
|
|
|
|
|
view: view
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
view.addListener("recalculate", this.onRecalculate);
|
2015-03-05 20:03:52 +00:00
|
|
|
|
view.addListener("add", this.onUpdate);
|
|
|
|
|
view.addListener("update", this.onUpdate);
|
|
|
|
|
view.addListener("remove", this.onUpdate);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
view.addListener("remove", this.onRemove);
|
|
|
|
|
},
|
|
|
|
|
onRecalculate: function () {
|
|
|
|
|
this.forceUpdate();
|
|
|
|
|
var selected = this.getSelected();
|
|
|
|
|
if (selected) {
|
|
|
|
|
this.refs.flowTable.scrollIntoView(selected);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onUpdate: function (flow) {
|
|
|
|
|
if (flow.id === this.getParams().flowId) {
|
|
|
|
|
this.forceUpdate();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onRemove: function (flow_id, index) {
|
|
|
|
|
if (flow_id === this.getParams().flowId) {
|
2015-03-15 21:05:50 +00:00
|
|
|
|
var flow_to_select = this.state.view.list[Math.min(index, this.state.view.list.length - 1)];
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlow(flow_to_select);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
closeView: function () {
|
|
|
|
|
this.state.view.close();
|
|
|
|
|
},
|
|
|
|
|
componentWillMount: function () {
|
|
|
|
|
this.openView(this.props.flowStore);
|
|
|
|
|
},
|
|
|
|
|
componentWillUnmount: function () {
|
|
|
|
|
this.closeView();
|
|
|
|
|
},
|
2015-03-17 02:05:59 +00:00
|
|
|
|
setSortKeyFun: function(sortKeyFun){
|
|
|
|
|
this.setState({
|
|
|
|
|
sortKeyFun: sortKeyFun
|
|
|
|
|
});
|
|
|
|
|
this.state.view.recalculate(this.getViewFilt(), sortKeyFun);
|
|
|
|
|
},
|
2014-12-30 08:51:07 +00:00
|
|
|
|
selectFlow: function (flow) {
|
|
|
|
|
if (flow) {
|
|
|
|
|
this.replaceWith(
|
|
|
|
|
"flow",
|
|
|
|
|
{
|
|
|
|
|
flowId: flow.id,
|
|
|
|
|
detailTab: this.getParams().detailTab || "request"
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
this.refs.flowTable.scrollIntoView(flow);
|
|
|
|
|
} else {
|
|
|
|
|
this.replaceWith("flows", {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
selectFlowRelative: function (shift) {
|
|
|
|
|
var flows = this.state.view.list;
|
|
|
|
|
var index;
|
|
|
|
|
if (!this.getParams().flowId) {
|
|
|
|
|
if (shift > 0) {
|
|
|
|
|
index = flows.length - 1;
|
|
|
|
|
} else {
|
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
var currFlowId = this.getParams().flowId;
|
|
|
|
|
var i = flows.length;
|
|
|
|
|
while (i--) {
|
|
|
|
|
if (flows[i].id === currFlowId) {
|
|
|
|
|
index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
index = Math.min(
|
|
|
|
|
Math.max(0, index + shift),
|
|
|
|
|
flows.length - 1);
|
|
|
|
|
}
|
|
|
|
|
this.selectFlow(flows[index]);
|
|
|
|
|
},
|
|
|
|
|
onKeyDown: function (e) {
|
|
|
|
|
var flow = this.getSelected();
|
|
|
|
|
if (e.ctrlKey) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
switch (e.keyCode) {
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.K:
|
|
|
|
|
case toputils.Key.UP:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlowRelative(-1);
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.J:
|
|
|
|
|
case toputils.Key.DOWN:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlowRelative(+1);
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.SPACE:
|
|
|
|
|
case toputils.Key.PAGE_DOWN:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlowRelative(+10);
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.PAGE_UP:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlowRelative(-10);
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.END:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlowRelative(+1e10);
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.HOME:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlowRelative(-1e10);
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.ESC:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.selectFlow(null);
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.H:
|
|
|
|
|
case toputils.Key.LEFT:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
if (this.refs.flowDetails) {
|
|
|
|
|
this.refs.flowDetails.nextTab(-1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.L:
|
|
|
|
|
case toputils.Key.TAB:
|
|
|
|
|
case toputils.Key.RIGHT:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
if (this.refs.flowDetails) {
|
|
|
|
|
this.refs.flowDetails.nextTab(+1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.C:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
if (e.shiftKey) {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.clear();
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.D:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
if (flow) {
|
|
|
|
|
if (e.shiftKey) {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.duplicate(flow);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
} else {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.delete(flow);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.A:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
if (e.shiftKey) {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.accept_all();
|
2014-12-30 08:51:07 +00:00
|
|
|
|
} else if (flow && flow.intercepted) {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.accept(flow);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.R:
|
2014-12-30 08:51:07 +00:00
|
|
|
|
if (!e.shiftKey && flow) {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.replay(flow);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2014-12-31 05:14:17 +00:00
|
|
|
|
case toputils.Key.V:
|
2015-03-15 21:05:50 +00:00
|
|
|
|
if (e.shiftKey && flow && flow.modified) {
|
2015-03-06 08:54:18 +00:00
|
|
|
|
actions.FlowActions.revert(flow);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2015-03-21 20:55:02 +00:00
|
|
|
|
case toputils.Key.SHIFT:
|
|
|
|
|
break;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
default:
|
|
|
|
|
console.debug("keydown", e.keyCode);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
},
|
|
|
|
|
getSelected: function () {
|
|
|
|
|
return this.props.flowStore.get(this.getParams().flowId);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var selected = this.getSelected();
|
|
|
|
|
|
|
|
|
|
var details;
|
|
|
|
|
if (selected) {
|
|
|
|
|
details = [
|
2015-01-01 07:49:32 +00:00
|
|
|
|
React.createElement(common.Splitter, {key: "splitter"}),
|
2015-03-21 21:49:51 +00:00
|
|
|
|
React.createElement(FlowView, {key: "flowDetails", ref: "flowDetails", flow: selected})
|
2014-12-30 08:51:07 +00:00
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
details = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", {className: "main-view", onKeyDown: this.onKeyDown, tabIndex: "0"},
|
|
|
|
|
React.createElement(FlowTable, {ref: "flowTable",
|
|
|
|
|
view: this.state.view,
|
|
|
|
|
selectFlow: this.selectFlow,
|
2015-03-17 02:05:59 +00:00
|
|
|
|
setSortKeyFun: this.setSortKeyFun,
|
2014-12-30 08:51:07 +00:00
|
|
|
|
selected: selected}),
|
|
|
|
|
details
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = MainView;
|
|
|
|
|
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../actions.js":2,"../filt/filt.js":20,"../store/view.js":23,"../utils.js":24,"./common.js":4,"./flowtable.js":7,"./flowview/index.js":10,"react":"react"}],16:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
var ReactRouter = require("react-router");
|
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
2015-01-01 07:49:32 +00:00
|
|
|
|
var common = require("./common.js");
|
2015-01-01 02:37:42 +00:00
|
|
|
|
var MainView = require("./mainview.js");
|
|
|
|
|
var Footer = require("./footer.js");
|
|
|
|
|
var header = require("./header.js");
|
|
|
|
|
var EventLog = require("./eventlog.js");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var store = require("../store/store.js");
|
2015-03-15 21:05:50 +00:00
|
|
|
|
var Query = require("../actions.js").Query;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Move out of here, just a stub.
|
|
|
|
|
var Reports = React.createClass({displayName: "Reports",
|
|
|
|
|
render: function () {
|
|
|
|
|
return React.createElement("div", null, "ReportEditor");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ProxyAppMain = React.createClass({displayName: "ProxyAppMain",
|
2015-01-01 07:49:32 +00:00
|
|
|
|
mixins: [common.State],
|
2014-12-30 08:51:07 +00:00
|
|
|
|
getInitialState: function () {
|
|
|
|
|
var eventStore = new store.EventLogStore();
|
|
|
|
|
var flowStore = new store.FlowStore();
|
|
|
|
|
var settings = new store.SettingsStore();
|
|
|
|
|
|
|
|
|
|
// Default Settings before fetch
|
|
|
|
|
_.extend(settings.dict,{
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
settings: settings,
|
|
|
|
|
flowStore: flowStore,
|
|
|
|
|
eventStore: eventStore
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
componentDidMount: function () {
|
|
|
|
|
this.state.settings.addListener("recalculate", this.onSettingsChange);
|
|
|
|
|
window.app = this;
|
|
|
|
|
},
|
|
|
|
|
componentWillUnmount: function () {
|
|
|
|
|
this.state.settings.removeListener("recalculate", this.onSettingsChange);
|
|
|
|
|
},
|
|
|
|
|
onSettingsChange: function(){
|
|
|
|
|
this.setState({
|
|
|
|
|
settings: this.state.settings
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
var eventlog;
|
|
|
|
|
if (this.getQuery()[Query.SHOW_EVENTLOG]) {
|
|
|
|
|
eventlog = [
|
2015-01-01 07:49:32 +00:00
|
|
|
|
React.createElement(common.Splitter, {key: "splitter", axis: "y"}),
|
2014-12-30 08:51:07 +00:00
|
|
|
|
React.createElement(EventLog, {key: "eventlog", eventStore: this.state.eventStore})
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
eventlog = null;
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
React.createElement("div", {id: "container"},
|
|
|
|
|
React.createElement(header.Header, {settings: this.state.settings.dict}),
|
2015-03-15 21:05:50 +00:00
|
|
|
|
React.createElement(RouteHandler, {
|
|
|
|
|
settings: this.state.settings.dict,
|
|
|
|
|
flowStore: this.state.flowStore,
|
|
|
|
|
query: this.getQuery()}),
|
2014-12-30 08:51:07 +00:00
|
|
|
|
eventlog,
|
|
|
|
|
React.createElement(Footer, {settings: this.state.settings.dict})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Route = ReactRouter.Route;
|
|
|
|
|
var RouteHandler = ReactRouter.RouteHandler;
|
|
|
|
|
var Redirect = ReactRouter.Redirect;
|
|
|
|
|
var DefaultRoute = ReactRouter.DefaultRoute;
|
|
|
|
|
var NotFoundRoute = ReactRouter.NotFoundRoute;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var routes = (
|
|
|
|
|
React.createElement(Route, {path: "/", handler: ProxyAppMain},
|
|
|
|
|
React.createElement(Route, {name: "flows", path: "flows", handler: MainView}),
|
|
|
|
|
React.createElement(Route, {name: "flow", path: "flows/:flowId/:detailTab", handler: MainView}),
|
|
|
|
|
React.createElement(Route, {name: "reports", handler: Reports}),
|
|
|
|
|
React.createElement(Redirect, {path: "/", to: "flows"})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
routes: routes
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../actions.js":2,"../store/store.js":22,"./common.js":4,"./eventlog.js":5,"./footer.js":13,"./header.js":14,"./mainview.js":15,"lodash":"lodash","react":"react","react-router":"react-router"}],17:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var React = require("react");
|
|
|
|
|
|
|
|
|
|
var VirtualScrollMixin = {
|
|
|
|
|
getInitialState: function () {
|
|
|
|
|
return {
|
|
|
|
|
start: 0,
|
|
|
|
|
stop: 0
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
componentWillMount: function () {
|
|
|
|
|
if (!this.props.rowHeight) {
|
|
|
|
|
console.warn("VirtualScrollMixin: No rowHeight specified", this);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getPlaceholderTop: function (total) {
|
|
|
|
|
var Tag = this.props.placeholderTagName || "tr";
|
|
|
|
|
// 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.
|
|
|
|
|
var style = {
|
|
|
|
|
height: Math.min(this.state.start, total) * this.props.rowHeight
|
|
|
|
|
};
|
|
|
|
|
var spacer = React.createElement(Tag, {key: "placeholder-top", style: style});
|
|
|
|
|
|
|
|
|
|
if (this.state.start % 2 === 1) {
|
|
|
|
|
// fix even/odd rows
|
|
|
|
|
return [spacer, React.createElement(Tag, {key: "placeholder-top-2"})];
|
|
|
|
|
} else {
|
|
|
|
|
return spacer;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getPlaceholderBottom: function (total) {
|
|
|
|
|
var Tag = this.props.placeholderTagName || "tr";
|
|
|
|
|
var style = {
|
|
|
|
|
height: Math.max(0, total - this.state.stop) * this.props.rowHeight
|
|
|
|
|
};
|
|
|
|
|
return React.createElement(Tag, {key: "placeholder-bottom", style: style});
|
|
|
|
|
},
|
|
|
|
|
componentDidMount: function () {
|
|
|
|
|
this.onScroll();
|
|
|
|
|
window.addEventListener('resize', this.onScroll);
|
|
|
|
|
},
|
|
|
|
|
componentWillUnmount: function(){
|
|
|
|
|
window.removeEventListener('resize', this.onScroll);
|
|
|
|
|
},
|
|
|
|
|
onScroll: function () {
|
|
|
|
|
var viewport = this.getDOMNode();
|
|
|
|
|
var top = viewport.scrollTop;
|
|
|
|
|
var height = viewport.offsetHeight;
|
|
|
|
|
var start = Math.floor(top / this.props.rowHeight);
|
|
|
|
|
var stop = start + Math.ceil(height / (this.props.rowHeightMin || this.props.rowHeight));
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
start: start,
|
|
|
|
|
stop: stop
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
renderRows: function (elems) {
|
|
|
|
|
var rows = [];
|
|
|
|
|
var max = Math.min(elems.length, this.state.stop);
|
|
|
|
|
|
|
|
|
|
for (var i = this.state.start; i < max; i++) {
|
|
|
|
|
var elem = elems[i];
|
|
|
|
|
rows.push(this.renderRow(elem));
|
|
|
|
|
}
|
|
|
|
|
return rows;
|
|
|
|
|
},
|
|
|
|
|
scrollRowIntoView: function (index, head_height) {
|
|
|
|
|
|
|
|
|
|
var row_top = (index * this.props.rowHeight) + head_height;
|
|
|
|
|
var row_bottom = row_top + this.props.rowHeight;
|
|
|
|
|
|
|
|
|
|
var viewport = this.getDOMNode();
|
|
|
|
|
var viewport_top = viewport.scrollTop;
|
|
|
|
|
var viewport_bottom = viewport_top + viewport.offsetHeight;
|
|
|
|
|
|
|
|
|
|
// Account for pinned thead
|
|
|
|
|
if (row_top - head_height < viewport_top) {
|
|
|
|
|
viewport.scrollTop = row_top - head_height;
|
|
|
|
|
} else if (row_bottom > viewport_bottom) {
|
|
|
|
|
viewport.scrollTop = row_bottom - viewport.offsetHeight;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = VirtualScrollMixin;
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"react":"react"}],18:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
var actions = require("./actions.js");
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var AppDispatcher = require("./dispatcher.js").AppDispatcher;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
function Connection(url) {
|
|
|
|
|
if (url[0] === "/") {
|
|
|
|
|
url = location.origin.replace("http", "ws") + url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ws = new WebSocket(url);
|
|
|
|
|
ws.onopen = function () {
|
|
|
|
|
actions.ConnectionActions.open();
|
|
|
|
|
};
|
|
|
|
|
ws.onmessage = function (message) {
|
|
|
|
|
var m = JSON.parse(message.data);
|
|
|
|
|
AppDispatcher.dispatchServerAction(m);
|
|
|
|
|
};
|
|
|
|
|
ws.onerror = function () {
|
|
|
|
|
actions.ConnectionActions.error();
|
2015-03-22 14:19:35 +00:00
|
|
|
|
actions.EventLogActions.add_event("WebSocket connection error.");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
};
|
|
|
|
|
ws.onclose = function () {
|
|
|
|
|
actions.ConnectionActions.close();
|
2015-03-22 14:19:35 +00:00
|
|
|
|
actions.EventLogActions.add_event("WebSocket connection closed.");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
};
|
|
|
|
|
return ws;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = Connection;
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-22 14:19:35 +00:00
|
|
|
|
},{"./actions.js":2,"./dispatcher.js":19}],19:[function(require,module,exports){
|
2015-01-01 03:59:58 +00:00
|
|
|
|
|
|
|
|
|
var flux = require("flux");
|
|
|
|
|
|
2014-12-30 08:51:07 +00:00
|
|
|
|
const PayloadSources = {
|
|
|
|
|
VIEW: "view",
|
|
|
|
|
SERVER: "server"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var AppDispatcher = new flux.Dispatcher();
|
2014-12-30 08:51:07 +00:00
|
|
|
|
AppDispatcher.dispatchViewAction = function (action) {
|
|
|
|
|
action.source = PayloadSources.VIEW;
|
|
|
|
|
this.dispatch(action);
|
|
|
|
|
};
|
|
|
|
|
AppDispatcher.dispatchServerAction = function (action) {
|
|
|
|
|
action.source = PayloadSources.SERVER;
|
|
|
|
|
this.dispatch(action);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
AppDispatcher: AppDispatcher
|
|
|
|
|
};
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"flux":"flux"}],20:[function(require,module,exports){
|
2015-01-02 22:46:51 +00:00
|
|
|
|
module.exports = (function() {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
/*
|
|
|
|
|
* Generated by PEG.js 0.8.0.
|
|
|
|
|
*
|
|
|
|
|
* http://pegjs.majda.cz/
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function peg$subclass(child, parent) {
|
|
|
|
|
function ctor() { this.constructor = child; }
|
|
|
|
|
ctor.prototype = parent.prototype;
|
|
|
|
|
child.prototype = new ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SyntaxError(message, expected, found, offset, line, column) {
|
|
|
|
|
this.message = message;
|
|
|
|
|
this.expected = expected;
|
|
|
|
|
this.found = found;
|
|
|
|
|
this.offset = offset;
|
|
|
|
|
this.line = line;
|
|
|
|
|
this.column = column;
|
|
|
|
|
|
|
|
|
|
this.name = "SyntaxError";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
peg$subclass(SyntaxError, Error);
|
|
|
|
|
|
|
|
|
|
function parse(input) {
|
|
|
|
|
var options = arguments.length > 1 ? arguments[1] : {},
|
|
|
|
|
|
|
|
|
|
peg$FAILED = {},
|
|
|
|
|
|
|
|
|
|
peg$startRuleFunctions = { start: peg$parsestart },
|
|
|
|
|
peg$startRuleFunction = peg$parsestart,
|
|
|
|
|
|
|
|
|
|
peg$c0 = { type: "other", description: "filter expression" },
|
|
|
|
|
peg$c1 = peg$FAILED,
|
|
|
|
|
peg$c2 = function(orExpr) { return orExpr; },
|
|
|
|
|
peg$c3 = [],
|
|
|
|
|
peg$c4 = function() {return trueFilter; },
|
|
|
|
|
peg$c5 = { type: "other", description: "whitespace" },
|
|
|
|
|
peg$c6 = /^[ \t\n\r]/,
|
|
|
|
|
peg$c7 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
|
|
|
|
|
peg$c8 = { type: "other", description: "control character" },
|
|
|
|
|
peg$c9 = /^[|&!()~"]/,
|
|
|
|
|
peg$c10 = { type: "class", value: "[|&!()~\"]", description: "[|&!()~\"]" },
|
|
|
|
|
peg$c11 = { type: "other", description: "optional whitespace" },
|
|
|
|
|
peg$c12 = "|",
|
|
|
|
|
peg$c13 = { type: "literal", value: "|", description: "\"|\"" },
|
|
|
|
|
peg$c14 = function(first, second) { return or(first, second); },
|
|
|
|
|
peg$c15 = "&",
|
|
|
|
|
peg$c16 = { type: "literal", value: "&", description: "\"&\"" },
|
|
|
|
|
peg$c17 = function(first, second) { return and(first, second); },
|
|
|
|
|
peg$c18 = "!",
|
|
|
|
|
peg$c19 = { type: "literal", value: "!", description: "\"!\"" },
|
|
|
|
|
peg$c20 = function(expr) { return not(expr); },
|
|
|
|
|
peg$c21 = "(",
|
|
|
|
|
peg$c22 = { type: "literal", value: "(", description: "\"(\"" },
|
|
|
|
|
peg$c23 = ")",
|
|
|
|
|
peg$c24 = { type: "literal", value: ")", description: "\")\"" },
|
|
|
|
|
peg$c25 = function(expr) { return binding(expr); },
|
|
|
|
|
peg$c26 = "~a",
|
|
|
|
|
peg$c27 = { type: "literal", value: "~a", description: "\"~a\"" },
|
|
|
|
|
peg$c28 = function() { return assetFilter; },
|
|
|
|
|
peg$c29 = "~e",
|
|
|
|
|
peg$c30 = { type: "literal", value: "~e", description: "\"~e\"" },
|
|
|
|
|
peg$c31 = function() { return errorFilter; },
|
|
|
|
|
peg$c32 = "~q",
|
|
|
|
|
peg$c33 = { type: "literal", value: "~q", description: "\"~q\"" },
|
|
|
|
|
peg$c34 = function() { return noResponseFilter; },
|
|
|
|
|
peg$c35 = "~s",
|
|
|
|
|
peg$c36 = { type: "literal", value: "~s", description: "\"~s\"" },
|
|
|
|
|
peg$c37 = function() { return responseFilter; },
|
|
|
|
|
peg$c38 = "true",
|
|
|
|
|
peg$c39 = { type: "literal", value: "true", description: "\"true\"" },
|
|
|
|
|
peg$c40 = function() { return trueFilter; },
|
|
|
|
|
peg$c41 = "false",
|
|
|
|
|
peg$c42 = { type: "literal", value: "false", description: "\"false\"" },
|
|
|
|
|
peg$c43 = function() { return falseFilter; },
|
|
|
|
|
peg$c44 = "~c",
|
|
|
|
|
peg$c45 = { type: "literal", value: "~c", description: "\"~c\"" },
|
|
|
|
|
peg$c46 = function(s) { return responseCode(s); },
|
|
|
|
|
peg$c47 = "~d",
|
|
|
|
|
peg$c48 = { type: "literal", value: "~d", description: "\"~d\"" },
|
|
|
|
|
peg$c49 = function(s) { return domain(s); },
|
|
|
|
|
peg$c50 = "~h",
|
|
|
|
|
peg$c51 = { type: "literal", value: "~h", description: "\"~h\"" },
|
|
|
|
|
peg$c52 = function(s) { return header(s); },
|
|
|
|
|
peg$c53 = "~hq",
|
|
|
|
|
peg$c54 = { type: "literal", value: "~hq", description: "\"~hq\"" },
|
|
|
|
|
peg$c55 = function(s) { return requestHeader(s); },
|
|
|
|
|
peg$c56 = "~hs",
|
|
|
|
|
peg$c57 = { type: "literal", value: "~hs", description: "\"~hs\"" },
|
|
|
|
|
peg$c58 = function(s) { return responseHeader(s); },
|
|
|
|
|
peg$c59 = "~m",
|
|
|
|
|
peg$c60 = { type: "literal", value: "~m", description: "\"~m\"" },
|
|
|
|
|
peg$c61 = function(s) { return method(s); },
|
|
|
|
|
peg$c62 = "~t",
|
|
|
|
|
peg$c63 = { type: "literal", value: "~t", description: "\"~t\"" },
|
|
|
|
|
peg$c64 = function(s) { return contentType(s); },
|
|
|
|
|
peg$c65 = "~tq",
|
|
|
|
|
peg$c66 = { type: "literal", value: "~tq", description: "\"~tq\"" },
|
|
|
|
|
peg$c67 = function(s) { return requestContentType(s); },
|
|
|
|
|
peg$c68 = "~ts",
|
|
|
|
|
peg$c69 = { type: "literal", value: "~ts", description: "\"~ts\"" },
|
|
|
|
|
peg$c70 = function(s) { return responseContentType(s); },
|
|
|
|
|
peg$c71 = "~u",
|
|
|
|
|
peg$c72 = { type: "literal", value: "~u", description: "\"~u\"" },
|
|
|
|
|
peg$c73 = function(s) { return url(s); },
|
|
|
|
|
peg$c74 = { type: "other", description: "integer" },
|
|
|
|
|
peg$c75 = null,
|
|
|
|
|
peg$c76 = /^['"]/,
|
|
|
|
|
peg$c77 = { type: "class", value: "['\"]", description: "['\"]" },
|
|
|
|
|
peg$c78 = /^[0-9]/,
|
|
|
|
|
peg$c79 = { type: "class", value: "[0-9]", description: "[0-9]" },
|
|
|
|
|
peg$c80 = function(digits) { return parseInt(digits.join(""), 10); },
|
|
|
|
|
peg$c81 = { type: "other", description: "string" },
|
|
|
|
|
peg$c82 = "\"",
|
|
|
|
|
peg$c83 = { type: "literal", value: "\"", description: "\"\\\"\"" },
|
|
|
|
|
peg$c84 = function(chars) { return chars.join(""); },
|
|
|
|
|
peg$c85 = "'",
|
|
|
|
|
peg$c86 = { type: "literal", value: "'", description: "\"'\"" },
|
|
|
|
|
peg$c87 = void 0,
|
|
|
|
|
peg$c88 = /^["\\]/,
|
|
|
|
|
peg$c89 = { type: "class", value: "[\"\\\\]", description: "[\"\\\\]" },
|
|
|
|
|
peg$c90 = { type: "any", description: "any character" },
|
|
|
|
|
peg$c91 = function(char) { return char; },
|
|
|
|
|
peg$c92 = "\\",
|
|
|
|
|
peg$c93 = { type: "literal", value: "\\", description: "\"\\\\\"" },
|
|
|
|
|
peg$c94 = /^['\\]/,
|
|
|
|
|
peg$c95 = { type: "class", value: "['\\\\]", description: "['\\\\]" },
|
|
|
|
|
peg$c96 = /^['"\\]/,
|
|
|
|
|
peg$c97 = { type: "class", value: "['\"\\\\]", description: "['\"\\\\]" },
|
|
|
|
|
peg$c98 = "n",
|
|
|
|
|
peg$c99 = { type: "literal", value: "n", description: "\"n\"" },
|
|
|
|
|
peg$c100 = function() { return "\n"; },
|
|
|
|
|
peg$c101 = "r",
|
|
|
|
|
peg$c102 = { type: "literal", value: "r", description: "\"r\"" },
|
|
|
|
|
peg$c103 = function() { return "\r"; },
|
|
|
|
|
peg$c104 = "t",
|
|
|
|
|
peg$c105 = { type: "literal", value: "t", description: "\"t\"" },
|
|
|
|
|
peg$c106 = function() { return "\t"; },
|
|
|
|
|
|
|
|
|
|
peg$currPos = 0,
|
|
|
|
|
peg$reportedPos = 0,
|
|
|
|
|
peg$cachedPos = 0,
|
|
|
|
|
peg$cachedPosDetails = { 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$reportedPos, peg$currPos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function offset() {
|
|
|
|
|
return peg$reportedPos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function line() {
|
|
|
|
|
return peg$computePosDetails(peg$reportedPos).line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function column() {
|
|
|
|
|
return peg$computePosDetails(peg$reportedPos).column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function expected(description) {
|
|
|
|
|
throw peg$buildException(
|
|
|
|
|
null,
|
|
|
|
|
[{ type: "other", description: description }],
|
|
|
|
|
peg$reportedPos
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function error(message) {
|
|
|
|
|
throw peg$buildException(message, null, peg$reportedPos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$computePosDetails(pos) {
|
|
|
|
|
function advance(details, startPos, endPos) {
|
|
|
|
|
var p, ch;
|
|
|
|
|
|
|
|
|
|
for (p = startPos; p < endPos; p++) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (peg$cachedPos !== pos) {
|
|
|
|
|
if (peg$cachedPos > pos) {
|
|
|
|
|
peg$cachedPos = 0;
|
|
|
|
|
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
|
|
|
|
|
}
|
|
|
|
|
advance(peg$cachedPosDetails, peg$cachedPos, pos);
|
|
|
|
|
peg$cachedPos = pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return peg$cachedPosDetails;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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, pos) {
|
|
|
|
|
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(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
|
|
|
|
|
.replace(/[\u1080-\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.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var posDetails = peg$computePosDetails(pos),
|
|
|
|
|
found = pos < input.length ? input.charAt(pos) : null;
|
|
|
|
|
|
|
|
|
|
if (expected !== null) {
|
|
|
|
|
cleanupExpected(expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new SyntaxError(
|
|
|
|
|
message !== null ? message : buildMessage(expected, found),
|
|
|
|
|
expected,
|
|
|
|
|
found,
|
|
|
|
|
pos,
|
|
|
|
|
posDetails.line,
|
|
|
|
|
posDetails.column
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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$reportedPos = s0;
|
|
|
|
|
s1 = peg$c2(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
s1 = [];
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c4();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
}
|
|
|
|
|
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$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$parsecc() {
|
|
|
|
|
var s0, s1;
|
|
|
|
|
|
|
|
|
|
peg$silentFails++;
|
|
|
|
|
if (peg$c9.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s0 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s0 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c10); }
|
|
|
|
|
}
|
|
|
|
|
peg$silentFails--;
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c8); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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$c11); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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$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$parseOrExpr();
|
|
|
|
|
if (s5 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c14(s1, s5);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c15;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s3 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c16); }
|
|
|
|
|
}
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
s4 = peg$parse__();
|
|
|
|
|
if (s4 !== peg$FAILED) {
|
|
|
|
|
s5 = peg$parseAndExpr();
|
|
|
|
|
if (s5 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c17(s1, s5);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseAndExpr();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c17(s1, s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$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$parseNotExpr();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c20(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c21;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c22); }
|
|
|
|
|
}
|
|
|
|
|
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$c23;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s5 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
|
|
|
|
}
|
|
|
|
|
if (s5 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c25(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c26) {
|
|
|
|
|
s1 = peg$c26;
|
|
|
|
|
peg$currPos += 2;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c27); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = 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$reportedPos = 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$reportedPos = s0;
|
|
|
|
|
s1 = peg$c34();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 2) === peg$c35) {
|
|
|
|
|
s1 = peg$c35;
|
|
|
|
|
peg$currPos += 2;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c36); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c37();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$parseBooleanLiteral() {
|
|
|
|
|
var s0, s1;
|
|
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 4) === peg$c38) {
|
|
|
|
|
s1 = peg$c38;
|
|
|
|
|
peg$currPos += 4;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c39); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c40();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 5) === peg$c41) {
|
|
|
|
|
s1 = peg$c41;
|
|
|
|
|
peg$currPos += 5;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c42); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c43();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$parseUnaryExpr() {
|
|
|
|
|
var s0, s1, s2, s3;
|
|
|
|
|
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseIntegerLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c46(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c49(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 2) === peg$c50) {
|
|
|
|
|
s1 = peg$c50;
|
|
|
|
|
peg$currPos += 2;
|
|
|
|
|
} 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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c52(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c55(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 3) === peg$c56) {
|
|
|
|
|
s1 = peg$c56;
|
|
|
|
|
peg$currPos += 3;
|
|
|
|
|
} 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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c58(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c61(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 2) === peg$c62) {
|
|
|
|
|
s1 = peg$c62;
|
|
|
|
|
peg$currPos += 2;
|
|
|
|
|
} 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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c64(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c67(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 3) === peg$c68) {
|
|
|
|
|
s1 = peg$c68;
|
|
|
|
|
peg$currPos += 3;
|
|
|
|
|
} 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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c70(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.substr(peg$currPos, 2) === peg$c71) {
|
|
|
|
|
s1 = peg$c71;
|
|
|
|
|
peg$currPos += 2;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c72); }
|
|
|
|
|
}
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
s3 = peg$parseStringLiteral();
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c73(s3);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
s1 = peg$parseStringLiteral();
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c73(s1);
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$parseIntegerLiteral() {
|
|
|
|
|
var s0, s1, s2, s3;
|
|
|
|
|
|
|
|
|
|
peg$silentFails++;
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (peg$c76.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s1 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c77); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 === peg$FAILED) {
|
|
|
|
|
s1 = peg$c75;
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
s2 = [];
|
|
|
|
|
if (peg$c78.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s3 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s3 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c79); }
|
|
|
|
|
}
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
while (s3 !== peg$FAILED) {
|
|
|
|
|
s2.push(s3);
|
|
|
|
|
if (peg$c78.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s3 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s3 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c79); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
s2 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
if (peg$c76.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s3 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s3 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c77); }
|
|
|
|
|
}
|
|
|
|
|
if (s3 === peg$FAILED) {
|
|
|
|
|
s3 = peg$c75;
|
|
|
|
|
}
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c80(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
peg$silentFails--;
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c74); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$parseStringLiteral() {
|
|
|
|
|
var s0, s1, s2, s3;
|
|
|
|
|
|
|
|
|
|
peg$silentFails++;
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 34) {
|
|
|
|
|
s1 = peg$c82;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c83); }
|
|
|
|
|
}
|
|
|
|
|
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$c82;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s3 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c83); }
|
|
|
|
|
}
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c84(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 39) {
|
|
|
|
|
s1 = peg$c85;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c86); }
|
|
|
|
|
}
|
|
|
|
|
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$c85;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s3 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c86); }
|
|
|
|
|
}
|
|
|
|
|
if (s3 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c84(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
s1 = peg$currPos;
|
|
|
|
|
peg$silentFails++;
|
|
|
|
|
s2 = peg$parsecc();
|
|
|
|
|
peg$silentFails--;
|
|
|
|
|
if (s2 === peg$FAILED) {
|
|
|
|
|
s1 = peg$c87;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s1;
|
|
|
|
|
s1 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c84(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
peg$silentFails--;
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c81); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$parseDoubleStringChar() {
|
|
|
|
|
var s0, s1, s2;
|
|
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
s1 = peg$currPos;
|
|
|
|
|
peg$silentFails++;
|
|
|
|
|
if (peg$c88.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s2 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s2 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c89); }
|
|
|
|
|
}
|
|
|
|
|
peg$silentFails--;
|
|
|
|
|
if (s2 === peg$FAILED) {
|
|
|
|
|
s1 = peg$c87;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s1;
|
|
|
|
|
s1 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c90); }
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c91(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 92) {
|
|
|
|
|
s1 = peg$c92;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c93); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
s2 = peg$parseEscapeSequence();
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c91(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$parseSingleStringChar() {
|
|
|
|
|
var s0, s1, s2;
|
|
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
s1 = peg$currPos;
|
|
|
|
|
peg$silentFails++;
|
|
|
|
|
if (peg$c94.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s2 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s2 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c95); }
|
|
|
|
|
}
|
|
|
|
|
peg$silentFails--;
|
|
|
|
|
if (s2 === peg$FAILED) {
|
|
|
|
|
s1 = peg$c87;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s1;
|
|
|
|
|
s1 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c90); }
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c91(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 92) {
|
|
|
|
|
s1 = peg$c92;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c93); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
s2 = peg$parseEscapeSequence();
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c91(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = peg$c87;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s1;
|
|
|
|
|
s1 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
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$c90); }
|
|
|
|
|
}
|
|
|
|
|
if (s2 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c91(s2);
|
|
|
|
|
s0 = s1;
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
peg$currPos = s0;
|
|
|
|
|
s0 = peg$c1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function peg$parseEscapeSequence() {
|
|
|
|
|
var s0, s1;
|
|
|
|
|
|
|
|
|
|
if (peg$c96.test(input.charAt(peg$currPos))) {
|
|
|
|
|
s0 = input.charAt(peg$currPos);
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s0 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c97); }
|
|
|
|
|
}
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 110) {
|
|
|
|
|
s1 = peg$c98;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c99); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c100();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 114) {
|
|
|
|
|
s1 = peg$c101;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c102); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c103();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
if (s0 === peg$FAILED) {
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 116) {
|
|
|
|
|
s1 = peg$c104;
|
|
|
|
|
peg$currPos++;
|
|
|
|
|
} else {
|
|
|
|
|
s1 = peg$FAILED;
|
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c105); }
|
|
|
|
|
}
|
|
|
|
|
if (s1 !== peg$FAILED) {
|
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
|
s1 = peg$c106();
|
|
|
|
|
}
|
|
|
|
|
s0 = s1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-01-02 22:46:51 +00:00
|
|
|
|
var flowutils = require("../flow/utils.js");
|
|
|
|
|
|
2014-12-30 08:51:07 +00:00
|
|
|
|
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) {
|
2015-01-02 22:46:51 +00:00
|
|
|
|
var ct = flowutils.ResponseUtils.getContentType(flow.response);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
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.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 (
|
2015-01-02 22:46:51 +00:00
|
|
|
|
(flow.request && flowutils.RequestUtils.match_header(flow.request, regex))
|
2014-12-30 08:51:07 +00:00
|
|
|
|
||
|
2015-01-02 22:46:51 +00:00
|
|
|
|
(flow.response && flowutils.ResponseUtils.match_header(flow.response, regex))
|
2014-12-30 08:51:07 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
headerFilter.desc = "header matches " + regex;
|
|
|
|
|
return headerFilter;
|
|
|
|
|
}
|
|
|
|
|
function requestHeader(regex){
|
|
|
|
|
regex = new RegExp(regex, "i");
|
|
|
|
|
function requestHeaderFilter(flow){
|
2015-01-02 22:46:51 +00:00
|
|
|
|
return (flow.request && flowutils.RequestUtils.match_header(flow.request, regex));
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
requestHeaderFilter.desc = "req. header matches " + regex;
|
|
|
|
|
return requestHeaderFilter;
|
|
|
|
|
}
|
|
|
|
|
function responseHeader(regex){
|
|
|
|
|
regex = new RegExp(regex, "i");
|
|
|
|
|
function responseHeaderFilter(flow){
|
2015-01-02 22:46:51 +00:00
|
|
|
|
return (flow.response && flowutils.ResponseUtils.match_header(flow.response, regex));
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
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 (
|
2015-01-02 22:46:51 +00:00
|
|
|
|
(flow.request && regex.test(flowutils.RequestUtils.getContentType(flow.request)))
|
2014-12-30 08:51:07 +00:00
|
|
|
|
||
|
2015-01-02 22:46:51 +00:00
|
|
|
|
(flow.response && regex.test(flowutils.ResponseUtils.getContentType(flow.response)))
|
2014-12-30 08:51:07 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
contentTypeFilter.desc = "content type matches " + regex;
|
|
|
|
|
return contentTypeFilter;
|
|
|
|
|
}
|
|
|
|
|
function requestContentType(regex){
|
|
|
|
|
regex = new RegExp(regex, "i");
|
|
|
|
|
function requestContentTypeFilter(flow){
|
2015-01-02 22:46:51 +00:00
|
|
|
|
return flow.request && regex.test(flowutils.RequestUtils.getContentType(flow.request));
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
requestContentTypeFilter.desc = "req. content type matches " + regex;
|
|
|
|
|
return requestContentTypeFilter;
|
|
|
|
|
}
|
|
|
|
|
function responseContentType(regex){
|
|
|
|
|
regex = new RegExp(regex, "i");
|
|
|
|
|
function responseContentTypeFilter(flow){
|
2015-01-02 22:46:51 +00:00
|
|
|
|
return flow.response && regex.test(flowutils.ResponseUtils.getContentType(flow.response));
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
responseContentTypeFilter.desc = "resp. content type matches " + regex;
|
|
|
|
|
return responseContentTypeFilter;
|
|
|
|
|
}
|
|
|
|
|
function url(regex){
|
|
|
|
|
regex = new RegExp(regex, "i");
|
|
|
|
|
function urlFilter(flow){
|
2015-01-02 22:46:51 +00:00
|
|
|
|
return flow.request && regex.test(flowutils.RequestUtils.pretty_url(flow.request));
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
SyntaxError: SyntaxError,
|
|
|
|
|
parse: parse
|
|
|
|
|
};
|
|
|
|
|
})();
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../flow/utils.js":21}],21:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var _ = require("lodash");
|
2015-03-22 01:25:47 +00:00
|
|
|
|
var $ = require("jquery");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var defaultPorts = {
|
|
|
|
|
"http": 80,
|
|
|
|
|
"https": 443
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var MessageUtils = {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
getContentType: function (message) {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var ct = this.get_first_header(message, /^Content-Type$/i);
|
|
|
|
|
if(ct){
|
|
|
|
|
return ct.split(";")[0].trim();
|
|
|
|
|
}
|
2014-12-30 08:51:07 +00:00
|
|
|
|
},
|
|
|
|
|
get_first_header: function (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 (message, regex) {
|
|
|
|
|
var headers = message.headers;
|
|
|
|
|
var i = headers.length;
|
|
|
|
|
while (i--) {
|
|
|
|
|
if (regex.test(headers[i].join(" "))) {
|
|
|
|
|
return headers[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2015-03-22 01:25:47 +00:00
|
|
|
|
},
|
2015-03-22 23:24:56 +00:00
|
|
|
|
getContentURL: function (flow, message) {
|
|
|
|
|
if (message === flow.request) {
|
2015-03-22 01:25:47 +00:00
|
|
|
|
message = "request";
|
2015-03-22 23:24:56 +00:00
|
|
|
|
} else if (message === flow.response) {
|
2015-03-22 01:25:47 +00:00
|
|
|
|
message = "response";
|
|
|
|
|
}
|
|
|
|
|
return "/flows/" + flow.id + "/" + message + "/content";
|
|
|
|
|
},
|
2015-03-22 23:24:56 +00:00
|
|
|
|
getContent: function (flow, message) {
|
2015-03-22 01:25:47 +00:00
|
|
|
|
var url = MessageUtils.getContentURL(flow, message);
|
|
|
|
|
return $.get(url);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var RequestUtils = _.extend(MessageUtils, {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
pretty_host: function (request) {
|
|
|
|
|
//FIXME: Add hostheader
|
|
|
|
|
return request.host;
|
|
|
|
|
},
|
|
|
|
|
pretty_url: function (request) {
|
|
|
|
|
var port = "";
|
|
|
|
|
if (defaultPorts[request.scheme] !== request.port) {
|
|
|
|
|
port = ":" + request.port;
|
|
|
|
|
}
|
|
|
|
|
return request.scheme + "://" + this.pretty_host(request) + port + request.path;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-21 21:49:51 +00:00
|
|
|
|
var ResponseUtils = _.extend(MessageUtils, {});
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
var parseUrl_regex = /^(?:(https?):\/\/)?([^\/:]+)?(?::(\d+))?(\/.*)?$/i;
|
|
|
|
|
var parseUrl = function (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);
|
2015-03-27 14:30:19 +00:00
|
|
|
|
if(!parts){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-22 23:24:56 +00:00
|
|
|
|
|
|
|
|
|
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 = function (httpVersion) {
|
|
|
|
|
return isValidHttpVersion_regex.test(httpVersion);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var parseHttpVersion = function (httpVersion) {
|
|
|
|
|
httpVersion = httpVersion.replace("HTTP/", "").split(".");
|
|
|
|
|
return _.map(httpVersion, function (x) {
|
|
|
|
|
return parseInt(x);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-30 08:51:07 +00:00
|
|
|
|
module.exports = {
|
2014-12-30 09:12:26 +00:00
|
|
|
|
ResponseUtils: ResponseUtils,
|
2015-03-21 21:49:51 +00:00
|
|
|
|
RequestUtils: RequestUtils,
|
2015-03-22 23:24:56 +00:00
|
|
|
|
MessageUtils: MessageUtils,
|
|
|
|
|
parseUrl: parseUrl,
|
|
|
|
|
parseHttpVersion: parseHttpVersion,
|
|
|
|
|
isValidHttpVersion: isValidHttpVersion
|
2015-03-21 21:49:51 +00:00
|
|
|
|
};
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-22 01:25:47 +00:00
|
|
|
|
},{"jquery":"jquery","lodash":"lodash"}],22:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
var $ = require("jquery");
|
2015-01-01 03:41:45 +00:00
|
|
|
|
var EventEmitter = require('events').EventEmitter;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
var utils = require("../utils.js");
|
|
|
|
|
var actions = require("../actions.js");
|
|
|
|
|
var dispatcher = require("../dispatcher.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ListStore() {
|
2015-01-01 03:41:45 +00:00
|
|
|
|
EventEmitter.call(this);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.reset();
|
|
|
|
|
}
|
2015-01-01 03:41:45 +00:00
|
|
|
|
_.extend(ListStore.prototype, EventEmitter.prototype, {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
add: function (elem) {
|
|
|
|
|
if (elem.id in this._pos_map) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._pos_map[elem.id] = this.list.length;
|
|
|
|
|
this.list.push(elem);
|
|
|
|
|
this.emit("add", elem);
|
|
|
|
|
},
|
|
|
|
|
update: function (elem) {
|
|
|
|
|
if (!(elem.id in this._pos_map)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.list[this._pos_map[elem.id]] = elem;
|
|
|
|
|
this.emit("update", elem);
|
|
|
|
|
},
|
|
|
|
|
remove: function (elem_id) {
|
|
|
|
|
if (!(elem_id in this._pos_map)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.list.splice(this._pos_map[elem_id], 1);
|
|
|
|
|
this._build_map();
|
|
|
|
|
this.emit("remove", elem_id);
|
|
|
|
|
},
|
|
|
|
|
reset: function (elems) {
|
|
|
|
|
this.list = elems || [];
|
|
|
|
|
this._build_map();
|
|
|
|
|
this.emit("recalculate");
|
|
|
|
|
},
|
|
|
|
|
_build_map: function () {
|
|
|
|
|
this._pos_map = {};
|
|
|
|
|
for (var i = 0; i < this.list.length; i++) {
|
|
|
|
|
var elem = this.list[i];
|
|
|
|
|
this._pos_map[elem.id] = i;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
get: function (elem_id) {
|
|
|
|
|
return this.list[this._pos_map[elem_id]];
|
|
|
|
|
},
|
|
|
|
|
index: function (elem_id) {
|
|
|
|
|
return this._pos_map[elem_id];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function DictStore() {
|
2015-01-01 03:41:45 +00:00
|
|
|
|
EventEmitter.call(this);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.reset();
|
|
|
|
|
}
|
2015-01-01 03:41:45 +00:00
|
|
|
|
_.extend(DictStore.prototype, EventEmitter.prototype, {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
update: function (dict) {
|
|
|
|
|
_.merge(this.dict, dict);
|
|
|
|
|
this.emit("recalculate");
|
|
|
|
|
},
|
|
|
|
|
reset: function (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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_.extend(LiveStoreMixin.prototype, {
|
|
|
|
|
handle: function (event) {
|
|
|
|
|
if (event.type === actions.ActionTypes.CONNECTION_OPEN) {
|
|
|
|
|
return this.fetch();
|
|
|
|
|
}
|
|
|
|
|
if (event.type === this.type) {
|
2014-12-30 09:12:26 +00:00
|
|
|
|
if (event.cmd === actions.StoreCmds.RESET) {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
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 () {
|
|
|
|
|
dispatcher.AppDispatcher.unregister(this.handle);
|
|
|
|
|
},
|
|
|
|
|
fetch: function (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 = $.getJSON("/" + this.type)
|
|
|
|
|
.done(function (message) {
|
|
|
|
|
this.handle_fetch(message.data);
|
|
|
|
|
}.bind(this))
|
|
|
|
|
.fail(function () {
|
|
|
|
|
EventLogActions.add_event("Could not fetch " + this.type);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handle_fetch: function (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 LiveListStore(type) {
|
|
|
|
|
ListStore.call(this);
|
|
|
|
|
LiveStoreMixin.call(this, type);
|
|
|
|
|
}
|
|
|
|
|
_.extend(LiveListStore.prototype, ListStore.prototype, LiveStoreMixin.prototype);
|
|
|
|
|
|
|
|
|
|
function LiveDictStore(type) {
|
|
|
|
|
DictStore.call(this);
|
|
|
|
|
LiveStoreMixin.call(this, type);
|
|
|
|
|
}
|
|
|
|
|
_.extend(LiveDictStore.prototype, DictStore.prototype, LiveStoreMixin.prototype);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function FlowStore() {
|
|
|
|
|
return new LiveListStore(actions.ActionTypes.FLOW_STORE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SettingsStore() {
|
|
|
|
|
return new LiveDictStore(actions.ActionTypes.SETTINGS_STORE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EventLogStore() {
|
|
|
|
|
LiveListStore.call(this, actions.ActionTypes.EVENT_STORE);
|
|
|
|
|
}
|
|
|
|
|
_.extend(EventLogStore.prototype, LiveListStore.prototype, {
|
|
|
|
|
fetch: function(){
|
|
|
|
|
LiveListStore.prototype.fetch.apply(this, arguments);
|
|
|
|
|
|
|
|
|
|
// Make sure to display updates even if fetching all events failed.
|
|
|
|
|
// This way, we can send "fetch failed" log messages to the log.
|
|
|
|
|
if(this._fetchxhr){
|
|
|
|
|
this._fetchxhr.fail(function(){
|
|
|
|
|
this.handle_fetch(null);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
EventLogStore: EventLogStore,
|
|
|
|
|
SettingsStore: SettingsStore,
|
|
|
|
|
FlowStore: FlowStore
|
|
|
|
|
};
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../actions.js":2,"../dispatcher.js":19,"../utils.js":24,"events":1,"jquery":"jquery","lodash":"lodash"}],23:[function(require,module,exports){
|
2015-01-01 03:41:45 +00:00
|
|
|
|
var EventEmitter = require('events').EventEmitter;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
|
|
|
|
var utils = require("../utils.js");
|
|
|
|
|
|
|
|
|
|
function SortByStoreOrder(elem) {
|
|
|
|
|
return this.store.index(elem.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var default_sort = SortByStoreOrder;
|
2015-03-15 21:05:50 +00:00
|
|
|
|
var default_filt = function (elem) {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function StoreView(store, filt, sortfun) {
|
2015-01-01 03:41:45 +00:00
|
|
|
|
EventEmitter.call(this);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
|
|
|
|
this.store = store;
|
|
|
|
|
|
|
|
|
|
this.add = this.add.bind(this);
|
|
|
|
|
this.update = this.update.bind(this);
|
|
|
|
|
this.remove = this.remove.bind(this);
|
|
|
|
|
this.recalculate = this.recalculate.bind(this);
|
|
|
|
|
this.store.addListener("add", this.add);
|
|
|
|
|
this.store.addListener("update", this.update);
|
|
|
|
|
this.store.addListener("remove", this.remove);
|
|
|
|
|
this.store.addListener("recalculate", this.recalculate);
|
|
|
|
|
|
|
|
|
|
this.recalculate(filt, sortfun);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-01 03:41:45 +00:00
|
|
|
|
_.extend(StoreView.prototype, EventEmitter.prototype, {
|
2014-12-30 08:51:07 +00:00
|
|
|
|
close: function () {
|
|
|
|
|
this.store.removeListener("add", this.add);
|
|
|
|
|
this.store.removeListener("update", this.update);
|
|
|
|
|
this.store.removeListener("remove", this.remove);
|
|
|
|
|
this.store.removeListener("recalculate", this.recalculate);
|
2015-03-15 21:05:50 +00:00
|
|
|
|
},
|
|
|
|
|
recalculate: function (filt, sortfun) {
|
2015-03-21 20:55:02 +00:00
|
|
|
|
filt = filt || this.filt || default_filt;
|
|
|
|
|
sortfun = sortfun || this.sortfun || default_sort;
|
2015-03-17 02:05:59 +00:00
|
|
|
|
filt = filt.bind(this);
|
2015-03-21 20:55:02 +00:00
|
|
|
|
sortfun = sortfun.bind(this);
|
2015-03-17 02:05:59 +00:00
|
|
|
|
this.filt = filt;
|
|
|
|
|
this.sortfun = sortfun;
|
|
|
|
|
|
|
|
|
|
this.list = this.store.list.filter(filt);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.list.sort(function (a, b) {
|
2015-03-17 02:05:59 +00:00
|
|
|
|
var akey = sortfun(a);
|
|
|
|
|
var bkey = sortfun(b);
|
|
|
|
|
if(akey < bkey){
|
|
|
|
|
return -1;
|
|
|
|
|
} else if(akey > bkey){
|
|
|
|
|
return 1;
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-30 08:51:07 +00:00
|
|
|
|
this.emit("recalculate");
|
|
|
|
|
},
|
|
|
|
|
index: function (elem) {
|
|
|
|
|
return _.sortedIndex(this.list, elem, this.sortfun);
|
|
|
|
|
},
|
|
|
|
|
add: function (elem) {
|
|
|
|
|
if (this.filt(elem)) {
|
|
|
|
|
var idx = this.index(elem);
|
|
|
|
|
if (idx === this.list.length) { //happens often, .push is way faster.
|
|
|
|
|
this.list.push(elem);
|
|
|
|
|
} else {
|
|
|
|
|
this.list.splice(idx, 0, elem);
|
|
|
|
|
}
|
|
|
|
|
this.emit("add", elem, idx);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
update: function (elem) {
|
|
|
|
|
var idx;
|
|
|
|
|
var i = this.list.length;
|
|
|
|
|
// Search from the back, we usually update the latest entries.
|
|
|
|
|
while (i--) {
|
|
|
|
|
if (this.list[i].id === elem.id) {
|
|
|
|
|
idx = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (idx === -1) { //not contained in list
|
|
|
|
|
this.add(elem);
|
|
|
|
|
} else if (!this.filt(elem)) {
|
|
|
|
|
this.remove(elem.id);
|
|
|
|
|
} else {
|
|
|
|
|
if (this.sortfun(this.list[idx]) !== this.sortfun(elem)) { //sortpos has changed
|
|
|
|
|
this.remove(this.list[idx]);
|
|
|
|
|
this.add(elem);
|
|
|
|
|
} else {
|
|
|
|
|
this.list[idx] = elem;
|
|
|
|
|
this.emit("update", elem, idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
remove: function (elem_id) {
|
|
|
|
|
var idx = this.list.length;
|
|
|
|
|
while (idx--) {
|
|
|
|
|
if (this.list[idx].id === elem_id) {
|
|
|
|
|
this.list.splice(idx, 1);
|
|
|
|
|
this.emit("remove", elem_id, idx);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
StoreView: StoreView
|
|
|
|
|
};
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-21 23:21:38 +00:00
|
|
|
|
},{"../utils.js":24,"events":1,"lodash":"lodash"}],24:[function(require,module,exports){
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var $ = require("jquery");
|
2015-03-17 02:05:59 +00:00
|
|
|
|
var _ = require("lodash");
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var actions = require("./actions.js");
|
2014-12-30 08:51:07 +00:00
|
|
|
|
|
2015-03-22 23:24:56 +00:00
|
|
|
|
//debug
|
|
|
|
|
window.$ = $;
|
|
|
|
|
window._ = _;
|
|
|
|
|
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var 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,
|
2015-03-21 20:55:02 +00:00
|
|
|
|
SHIFT: 16
|
2014-12-30 08:51:07 +00:00
|
|
|
|
};
|
|
|
|
|
// Add A-Z
|
|
|
|
|
for (var i = 65; i <= 90; i++) {
|
|
|
|
|
Key[String.fromCharCode(i)] = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var formatSize = function (bytes) {
|
2015-01-02 02:29:51 +00:00
|
|
|
|
if (bytes === 0)
|
|
|
|
|
return "0";
|
|
|
|
|
var prefix = ["b", "kb", "mb", "gb", "tb"];
|
2015-03-22 23:24:56 +00:00
|
|
|
|
for (var i = 0; i < prefix.length; i++) {
|
|
|
|
|
if (Math.pow(1024, i + 1) > bytes) {
|
2015-01-02 02:29:51 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
2015-01-02 02:29:51 +00:00
|
|
|
|
var precision;
|
2015-03-22 23:24:56 +00:00
|
|
|
|
if (bytes % Math.pow(1024, i) === 0)
|
2015-01-02 02:29:51 +00:00
|
|
|
|
precision = 0;
|
|
|
|
|
else
|
|
|
|
|
precision = 1;
|
2015-03-22 23:24:56 +00:00
|
|
|
|
return (bytes / Math.pow(1024, i)).toFixed(precision) + prefix[i];
|
2014-12-30 08:51:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var formatTimeDelta = function (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 = function (seconds) {
|
|
|
|
|
var ts = (new Date(seconds * 1000)).toISOString();
|
|
|
|
|
return ts.replace("T", " ").replace("Z", "");
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-17 02:05:59 +00:00
|
|
|
|
// 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);
|
2015-03-22 23:24:56 +00:00
|
|
|
|
function reverseString(s) {
|
2015-03-17 02:05:59 +00:00
|
|
|
|
return String.fromCharCode.apply(String,
|
2015-03-22 23:24:56 +00:00
|
|
|
|
_.map(s.split(""), function (c) {
|
|
|
|
|
return 0xffff - c.charCodeAt(0);
|
|
|
|
|
})
|
|
|
|
|
) + end;
|
2015-03-17 02:05:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-30 08:51:07 +00:00
|
|
|
|
function getCookie(name) {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
var r = document.cookie.match(new RegExp("\\b" + name + "=([^;]*)\\b"));
|
2014-12-30 08:51:07 +00:00
|
|
|
|
return r ? r[1] : undefined;
|
|
|
|
|
}
|
|
|
|
|
var xsrf = $.param({_xsrf: getCookie("_xsrf")});
|
|
|
|
|
|
|
|
|
|
//Tornado XSRF Protection.
|
|
|
|
|
$.ajaxPrefilter(function (options) {
|
|
|
|
|
if (["post", "put", "delete"].indexOf(options.type.toLowerCase()) >= 0 && options.url[0] === "/") {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
if(options.url.indexOf("?") === -1){
|
|
|
|
|
options.url += "?" + xsrf;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
} else {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
options.url += "&" + xsrf;
|
2014-12-30 08:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// Log AJAX Errors
|
|
|
|
|
$(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
|
2015-03-22 23:24:56 +00:00
|
|
|
|
if (thrownError === "abort") {
|
2015-03-22 14:19:35 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-30 08:51:07 +00:00
|
|
|
|
var message = jqXHR.responseText;
|
2015-03-22 14:19:35 +00:00
|
|
|
|
console.error(thrownError, message, arguments);
|
|
|
|
|
actions.EventLogActions.add_event(thrownError + ": " + message);
|
2015-03-22 23:24:56 +00:00
|
|
|
|
alert(message);
|
2014-12-30 08:51:07 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
formatSize: formatSize,
|
|
|
|
|
formatTimeDelta: formatTimeDelta,
|
2014-12-31 05:14:17 +00:00
|
|
|
|
formatTimeStamp: formatTimeStamp,
|
2015-03-17 02:05:59 +00:00
|
|
|
|
reverseString: reverseString,
|
2015-03-22 23:24:56 +00:00
|
|
|
|
Key: Key,
|
2014-12-30 08:51:07 +00:00
|
|
|
|
};
|
2015-03-05 00:52:47 +00:00
|
|
|
|
|
2015-03-22 14:19:35 +00:00
|
|
|
|
},{"./actions.js":2,"jquery":"jquery","lodash":"lodash"}]},{},[3])
|
2015-03-06 20:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//# sourceMappingURL=app.js.map
|