batman-rails-flo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/batman-rails-flo.rb +5 -0
- data/lib/batman_rails_flo/railtie.rb +9 -0
- data/lib/batman_rails_flo/tasks.rake +14 -0
- data/lib/batman_rails_flo/version.rb +3 -0
- data/vendor/assets/javascripts/batman_rails_flo/flo_server.js +67 -0
- data/vendor/assets/javascripts/batman_rails_flo/live_reload.js.coffee +129 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CNAME +1 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CONTRIBUTING.md +9 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/LICENSE +22 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/README +50 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/cake +7 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/coffee +7 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/browser.js +134 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/cake.js +112 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/coffee-script.js +335 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/command.js +569 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/grammar.js +631 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/helpers.js +252 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/lexer.js +926 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/nodes.js +3158 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/optparse.js +139 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/parser.js +724 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/register.js +66 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/repl.js +163 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/rewriter.js +475 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/sourcemap.js +161 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/LICENSE +21 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/examples/pow.js +6 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/index.js +82 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/package.json +34 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/readme.markdown +63 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/chmod.js +38 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/clobber.js +37 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/mkdirp.js +28 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/race.js +41 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/rel.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return.js +25 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return_sync.js +24 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/root.js +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/sync.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask.js +28 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask_sync.js +32 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/package.json +50 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/register.js +1 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/LICENSE +30 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/PATENTS +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/README.md +124 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/bin/flo +26 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.html +57 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.js +205 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/style.css +334 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/connection.js +235 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/devtools.html +12 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/index.js +323 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logger.js +42 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logo.png +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/manifest.json +13 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/session.js +305 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/index.js +10 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/flo.js +226 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/server.js +94 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/README.md +66 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/index.js +437 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/LICENSE +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/README.md +218 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/minimatch.js +1055 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json +33 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/package.json +42 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/package.json +40 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/basic.js +399 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/brace-expand.js +33 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/caching.js +14 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/defaults.js +274 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/lib/walker.js +111 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/license +13 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/lib/makeerror.js +87 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/lib/tmpl.js +17 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/package.json +31 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/readme.md +10 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/package.json +34 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/readme.md +77 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/package.json +36 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/readme.md +52 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/LICENSE +55 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/main.js +128 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/package.json +34 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/readme.mkd +72 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/d/t +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/t +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitor.js +31 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitorRootDirectory.js +28 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_watchTree.js +20 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/package.json +45 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/test/test.js +243 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/CHANGELOG.md +81 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/LICENSE +177 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/Makefile +11 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/README.md +245 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/binding.gyp +14 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Makefile +355 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/linker.lock +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/validation/src/validation.o +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/xor/src/xor.o +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/validation.node +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/xor.node +0 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/binding.Makefile +6 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/config.gypi +115 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/gyp-mac-tool +512 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/validation.target.mk +154 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/xor.target.mk +154 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/index.js +1 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/install.js +31 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Constants.js +23 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Deprecation.js +38 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.fallback.js +12 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.js +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketClient.js +359 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketConnection.js +717 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketFrame.js +282 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRequest.js +478 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouter.js +154 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouterRequest.js +59 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketServer.js +216 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/utils.js +7 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/websocket.js +11 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.fallback.js +13 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.js +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/package.json +43 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/validation.cc +144 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/xor.cpp +86 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/FastBufferList.js +192 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/LICENSE +18 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/ctio-faster.js +1126 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/package.json +25 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/browser_websocket.js +63 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/connection_test.js +57 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/logger_mock.js +15 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/session_test.js +194 -0
- data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/server/flo_test.js +211 -0
- data/vendor/assets/javascripts/batman_rails_flo/package.json +15 -0
- data/vendor/assets/javascripts/batman_rails_flo/reload_event_handler.js.coffee +56 -0
- metadata +232 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<!-- Script order implies dependencies -->
|
5
|
+
<script src="logger.js"></script>
|
6
|
+
<script src="connection.js"></script>
|
7
|
+
<script src="session.js"></script>
|
8
|
+
<script src="index.js"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
</body>
|
12
|
+
</html>
|
@@ -0,0 +1,323 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2014, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/*global Session:false */
|
11
|
+
/* jshint evil:true */
|
12
|
+
|
13
|
+
(function() {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Flo client controller.
|
18
|
+
*
|
19
|
+
* @class FloClient
|
20
|
+
* @private
|
21
|
+
*/
|
22
|
+
|
23
|
+
function FloClient() {
|
24
|
+
this.config = loadConfig();
|
25
|
+
this.session = null;
|
26
|
+
this.panelWindow = null;
|
27
|
+
this.panelEventBuffer = [];
|
28
|
+
this.status = this.status.bind(this);
|
29
|
+
this.startNewSession = this.startNewSession.bind(this);
|
30
|
+
this.createLogger = Logger(this.triggerEvent.bind(this, 'log'));
|
31
|
+
this.loggger = this.createLogger('flo');
|
32
|
+
this.createPanel();
|
33
|
+
this.start();
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Save and optionally set new config.
|
38
|
+
*
|
39
|
+
* @param {object} config
|
40
|
+
* @private
|
41
|
+
*/
|
42
|
+
|
43
|
+
FloClient.prototype.saveConfig = function() {
|
44
|
+
localStorage.setItem('flo-config', JSON.stringify(this.config));
|
45
|
+
};
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Listen on the panel window for an event `type`, i.e. receive a message
|
49
|
+
* from the panel.
|
50
|
+
*
|
51
|
+
* @param {string} type
|
52
|
+
* @param {function} callback
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
|
56
|
+
FloClient.prototype.listenToPanel = function(type, callback) {
|
57
|
+
if (!this.panelWindow) {
|
58
|
+
throw new Error('Panel not found');
|
59
|
+
}
|
60
|
+
this.panelWindow.addEventListener('flo_' + type, callback.bind(this));
|
61
|
+
};
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Trigger an event on the panel window, i.e. send a message to the panel.
|
65
|
+
* If the panel wasn't instantiated yet, the event is buffered.
|
66
|
+
*
|
67
|
+
* @param {string} type
|
68
|
+
* @param {object} data
|
69
|
+
* @private
|
70
|
+
*/
|
71
|
+
|
72
|
+
FloClient.prototype.triggerEvent = function(type, data) {
|
73
|
+
var event = new Event('flo_' + type);
|
74
|
+
event.data = data;
|
75
|
+
// Save events for anytime we need to reinit the panel with prev state.
|
76
|
+
this.panelEventBuffer.push(event);
|
77
|
+
if (this.panelWindow) {
|
78
|
+
this.panelWindow.dispatchEvent(event);
|
79
|
+
}
|
80
|
+
return event;
|
81
|
+
};
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Create a new panel.
|
85
|
+
*
|
86
|
+
* @param {function} callback
|
87
|
+
* @private
|
88
|
+
*/
|
89
|
+
|
90
|
+
FloClient.prototype.createPanel = function(callback) {
|
91
|
+
var self = this;
|
92
|
+
chrome.devtools.panels.create(
|
93
|
+
'flo',
|
94
|
+
'',
|
95
|
+
'configure/configure.html',
|
96
|
+
function (panel) {
|
97
|
+
panel.onShown.addListener(function(panelWindow) {
|
98
|
+
if (!panelWindow.wasShown) {
|
99
|
+
self.panelWindow = panelWindow;
|
100
|
+
self.initPanel();
|
101
|
+
panelWindow.wasShown = true;
|
102
|
+
}
|
103
|
+
});
|
104
|
+
}
|
105
|
+
);
|
106
|
+
};
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Called after the panel is first created to listen on it's events.
|
110
|
+
* Will also trigger all buffered events on the panel.
|
111
|
+
*
|
112
|
+
* @param {object} config
|
113
|
+
* @private
|
114
|
+
*/
|
115
|
+
|
116
|
+
FloClient.prototype.initPanel = function() {
|
117
|
+
this.listenToPanel('config_changed', function(e) {
|
118
|
+
this.config = e.data;
|
119
|
+
this.saveConfig();
|
120
|
+
this.startNewSession();
|
121
|
+
});
|
122
|
+
this.listenToPanel('retry', this.startNewSession);
|
123
|
+
this.listenToPanel('enable_for_host', this.enableForHost);
|
124
|
+
this.panelEventBuffer.forEach(function(event) {
|
125
|
+
this.panelWindow.dispatchEvent(event);
|
126
|
+
}, this);
|
127
|
+
this.triggerEvent('load', this.config);
|
128
|
+
};
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Starts the flo client.
|
132
|
+
*
|
133
|
+
* @private
|
134
|
+
*/
|
135
|
+
|
136
|
+
FloClient.prototype.start = function() {
|
137
|
+
this.status('starting');
|
138
|
+
this.startNewSession();
|
139
|
+
};
|
140
|
+
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Stops flo client.
|
144
|
+
*
|
145
|
+
* @private
|
146
|
+
*/
|
147
|
+
|
148
|
+
FloClient.prototype.stop = function() {
|
149
|
+
this.session.destroy();
|
150
|
+
this.session = null;
|
151
|
+
};
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Get the url location of the inspected window.
|
155
|
+
*
|
156
|
+
* @param {function} callback
|
157
|
+
* @private
|
158
|
+
*/
|
159
|
+
|
160
|
+
FloClient.prototype.getLocation = function(callback) {
|
161
|
+
chrome.devtools.inspectedWindow['eval'](
|
162
|
+
'location.hostname',
|
163
|
+
callback.bind(this)
|
164
|
+
);
|
165
|
+
};
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Match config patterns against `host` and returns the matched site record.
|
169
|
+
*
|
170
|
+
* @param {string} host
|
171
|
+
* @return {object|null}
|
172
|
+
* @private
|
173
|
+
*/
|
174
|
+
|
175
|
+
FloClient.prototype.getSite = function(host) {
|
176
|
+
var config = this.config;
|
177
|
+
for (var i = 0; i < config.sites.length; i++) {
|
178
|
+
var site = config.sites[i];
|
179
|
+
var pattern = parsePattern(site.pattern);
|
180
|
+
var matched = false;
|
181
|
+
if (pattern instanceof RegExp) {
|
182
|
+
matched = pattern.exec(host);
|
183
|
+
} else {
|
184
|
+
matched = pattern === host;
|
185
|
+
}
|
186
|
+
if (matched) return site;
|
187
|
+
}
|
188
|
+
return null;
|
189
|
+
};
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Instantiates a new `session`.
|
193
|
+
*
|
194
|
+
* @private
|
195
|
+
*/
|
196
|
+
|
197
|
+
FloClient.prototype.startNewSession = function() {
|
198
|
+
if (this.session) {
|
199
|
+
this.stop();
|
200
|
+
}
|
201
|
+
|
202
|
+
this.getLocation(
|
203
|
+
function (host) {
|
204
|
+
var site = this.getSite(host);
|
205
|
+
if (site) {
|
206
|
+
this.session = new Session(
|
207
|
+
site.server || host,
|
208
|
+
site.port || this.config.port,
|
209
|
+
this.status,
|
210
|
+
this.createLogger
|
211
|
+
);
|
212
|
+
this.session.start();
|
213
|
+
} else {
|
214
|
+
this.status('disabled');
|
215
|
+
}
|
216
|
+
}
|
217
|
+
);
|
218
|
+
};
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Enables flo for the current inspected window host.
|
222
|
+
*
|
223
|
+
* @private
|
224
|
+
*/
|
225
|
+
|
226
|
+
FloClient.prototype.enableForHost = function() {
|
227
|
+
this.getLocation(function(host) {
|
228
|
+
if (!this.getSite(host)) {
|
229
|
+
this.config.sites.push({
|
230
|
+
pattern: host,
|
231
|
+
server: host
|
232
|
+
});
|
233
|
+
this.saveConfig();
|
234
|
+
this.triggerEvent('load', this.config);
|
235
|
+
this.startNewSession();
|
236
|
+
}
|
237
|
+
});
|
238
|
+
};
|
239
|
+
|
240
|
+
/**
|
241
|
+
* Reports status changes to panel.
|
242
|
+
*
|
243
|
+
* @param {string} status
|
244
|
+
* @param {object} aux
|
245
|
+
* @private
|
246
|
+
*/
|
247
|
+
|
248
|
+
FloClient.prototype.status = function(status, aux) {
|
249
|
+
var text, action;
|
250
|
+
switch (status) {
|
251
|
+
case 'starting':
|
252
|
+
text = 'Starting';
|
253
|
+
break;
|
254
|
+
case 'disabled':
|
255
|
+
text = 'Disabled for this site';
|
256
|
+
action = 'enable';
|
257
|
+
break;
|
258
|
+
case 'connecting':
|
259
|
+
text = 'Connecting';
|
260
|
+
break;
|
261
|
+
case 'connected':
|
262
|
+
text = 'Connected';
|
263
|
+
break;
|
264
|
+
case 'started':
|
265
|
+
text = 'Started';
|
266
|
+
break;
|
267
|
+
case 'retry':
|
268
|
+
text = 'Failed to connect, retrying in ' + (aux / 1000) + 's';
|
269
|
+
break;
|
270
|
+
case 'error':
|
271
|
+
text = 'Error connecting';
|
272
|
+
action = 'retry';
|
273
|
+
break;
|
274
|
+
default:
|
275
|
+
throw new Error('Unknown session status.');
|
276
|
+
}
|
277
|
+
|
278
|
+
this.triggerEvent('status_change', {
|
279
|
+
type: status,
|
280
|
+
text: text,
|
281
|
+
action: action
|
282
|
+
});
|
283
|
+
};
|
284
|
+
|
285
|
+
/**
|
286
|
+
* Loads config from localstorage.
|
287
|
+
*
|
288
|
+
* @private
|
289
|
+
*/
|
290
|
+
|
291
|
+
function loadConfig() {
|
292
|
+
var config = localStorage.getItem('flo-config');
|
293
|
+
try {
|
294
|
+
config = JSON.parse(config);
|
295
|
+
} catch (e) {} finally {
|
296
|
+
return config || {
|
297
|
+
sites: [],
|
298
|
+
port: 8888
|
299
|
+
};
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Optionally parses config from JSON to an object.
|
305
|
+
* Also, parses patterns into regexp.
|
306
|
+
*
|
307
|
+
* @private
|
308
|
+
* @return {object}
|
309
|
+
*/
|
310
|
+
|
311
|
+
function parsePattern(pattern) {
|
312
|
+
if (!pattern) return null;
|
313
|
+
var m = pattern.match(/^\/(.+)\/([gim]{0,3})$/);
|
314
|
+
if (m && m[1]) {
|
315
|
+
return new RegExp(m[1], m[2]);
|
316
|
+
}
|
317
|
+
return pattern;
|
318
|
+
}
|
319
|
+
|
320
|
+
// Start the app.
|
321
|
+
new FloClient();
|
322
|
+
|
323
|
+
})();
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2014, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* jshint evil:true */
|
11
|
+
|
12
|
+
this.Logger = (function() {
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
function Logger(log) {
|
16
|
+
return function(namespace) {
|
17
|
+
return {
|
18
|
+
error: createLogLevel('error'),
|
19
|
+
log: createLogLevel('log')
|
20
|
+
};
|
21
|
+
|
22
|
+
function createLogLevel(level) {
|
23
|
+
return function () {
|
24
|
+
var args = [].slice.call(arguments);
|
25
|
+
args[0] = '[' + namespace + '] ' + args[0];
|
26
|
+
return log([level, args]);
|
27
|
+
};
|
28
|
+
}
|
29
|
+
};
|
30
|
+
}
|
31
|
+
|
32
|
+
Logger.logInContext = function(arg, method) {
|
33
|
+
if (!method) {
|
34
|
+
method = 'log';
|
35
|
+
}
|
36
|
+
chrome.devtools.inspectedWindow['eval'](
|
37
|
+
'console.' + method + '("' + arg.toString() + '")'
|
38
|
+
);
|
39
|
+
};
|
40
|
+
|
41
|
+
return Logger;
|
42
|
+
})();
|
Binary file
|
@@ -0,0 +1,305 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2014, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/*global Connection:false */
|
11
|
+
|
12
|
+
(function () {
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Export to Node for testing and to global for production.
|
17
|
+
*/
|
18
|
+
|
19
|
+
if (typeof module === 'object' && typeof exports === 'object') {
|
20
|
+
module.exports = Session;
|
21
|
+
} else {
|
22
|
+
this.Session = Session;
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Manages a user sessios.
|
27
|
+
*
|
28
|
+
* @param {string} host
|
29
|
+
* @param {number} port
|
30
|
+
* @param {function} status
|
31
|
+
* @param {function} logger
|
32
|
+
* @class Session
|
33
|
+
* @public
|
34
|
+
*/
|
35
|
+
|
36
|
+
function Session(host, port, status, createLogger) {
|
37
|
+
this.host = host;
|
38
|
+
this.port = port;
|
39
|
+
this.status = status;
|
40
|
+
this.createLogger = createLogger;
|
41
|
+
this.logger = createLogger('session');
|
42
|
+
this.resources = null;
|
43
|
+
this.conn = null;
|
44
|
+
this.listeners = {};
|
45
|
+
this.messageHandler = this.messageHandler.bind(this);
|
46
|
+
this.started = this.started.bind(this);
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Registers the resources, connects to server and listens to events.
|
51
|
+
*
|
52
|
+
* @public
|
53
|
+
*/
|
54
|
+
|
55
|
+
Session.prototype.start = function() {
|
56
|
+
this.logger.log('Starting flo for host', this.host);
|
57
|
+
this.getResources(this.connect.bind(this, this.started));
|
58
|
+
};
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Similar to restart but does only what's needed to get flo started.
|
62
|
+
*
|
63
|
+
* @public
|
64
|
+
*/
|
65
|
+
|
66
|
+
Session.prototype.restart = function() {
|
67
|
+
this.logger.log('Restarting');
|
68
|
+
this.removeEventListeners();
|
69
|
+
if (this.conn.connected()) {
|
70
|
+
// No need to reconnect. We just refetch the resources.
|
71
|
+
this.getResources(this.started.bind(this));
|
72
|
+
} else {
|
73
|
+
this.start();
|
74
|
+
}
|
75
|
+
};
|
76
|
+
|
77
|
+
/**
|
78
|
+
* This method takes care of listening to events defined by the chrome api
|
79
|
+
* @see http://developer.chrome.com/extensions/events
|
80
|
+
* We also keep an internal map of events we're listening to so we can
|
81
|
+
* unsubscribe in the future.
|
82
|
+
*
|
83
|
+
* @param {object} object
|
84
|
+
* @param {string} event
|
85
|
+
* @param {function} listener
|
86
|
+
* @private
|
87
|
+
*/
|
88
|
+
|
89
|
+
Session.prototype.listen = function(obj, event, listener) {
|
90
|
+
listener = listener.bind(this);
|
91
|
+
obj[event].addListener(listener);
|
92
|
+
this.listeners[event] = {
|
93
|
+
obj: obj,
|
94
|
+
listener: listener
|
95
|
+
};
|
96
|
+
};
|
97
|
+
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Remove all event listeners.
|
101
|
+
*
|
102
|
+
* @private
|
103
|
+
*/
|
104
|
+
|
105
|
+
Session.prototype.removeEventListeners = function() {
|
106
|
+
Object.keys(this.listeners).forEach(function(event) {
|
107
|
+
var desc = this.listeners[event];
|
108
|
+
desc.obj[event].removeListener(desc.listener);
|
109
|
+
}, this);
|
110
|
+
};
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Registers the resources and listens to onResourceAdded events.
|
114
|
+
*
|
115
|
+
* @param {function} callback
|
116
|
+
* @private
|
117
|
+
*/
|
118
|
+
|
119
|
+
Session.prototype.getResources = function(callback) {
|
120
|
+
var self = this;
|
121
|
+
chrome.devtools.inspectedWindow.getResources(function (resources) {
|
122
|
+
self.resources = resources;
|
123
|
+
// After we register the current resources, we listen to the
|
124
|
+
// onResourceAdded event to push on more resources lazily fetched
|
125
|
+
// to our array.
|
126
|
+
self.listen(
|
127
|
+
chrome.devtools.inspectedWindow,
|
128
|
+
'onResourceAdded',
|
129
|
+
function (res) {
|
130
|
+
self.resources.push(res);
|
131
|
+
}
|
132
|
+
);
|
133
|
+
callback();
|
134
|
+
});
|
135
|
+
};
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Connect to server.
|
139
|
+
*
|
140
|
+
* @param {function} callback
|
141
|
+
* @private
|
142
|
+
*/
|
143
|
+
|
144
|
+
Session.prototype.connect = function(callback) {
|
145
|
+
callback = once(callback);
|
146
|
+
var self = this;
|
147
|
+
this.conn = new Connection(this.host, this.port, this.createLogger)
|
148
|
+
.onmessage(this.messageHandler)
|
149
|
+
.onerror(function () {
|
150
|
+
self.status('error');
|
151
|
+
})
|
152
|
+
.onopen(function () {
|
153
|
+
self.status('connected');
|
154
|
+
callback();
|
155
|
+
})
|
156
|
+
.onretry(function(delay) {
|
157
|
+
self.status('retry', delay);
|
158
|
+
})
|
159
|
+
.onconnecting(function() {
|
160
|
+
self.status('connecting');
|
161
|
+
})
|
162
|
+
.connect();
|
163
|
+
};
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Does whatever needs to be done after the session is started. Currenlty
|
167
|
+
* just listening to page refresh events.
|
168
|
+
*
|
169
|
+
* @param {function} callback
|
170
|
+
*/
|
171
|
+
|
172
|
+
Session.prototype.started = function() {
|
173
|
+
this.logger.log('Started');
|
174
|
+
this.status('started');
|
175
|
+
this.listen(
|
176
|
+
chrome.devtools.network,
|
177
|
+
'onNavigated',
|
178
|
+
this.restart
|
179
|
+
);
|
180
|
+
};
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Handler for messages from the server.
|
184
|
+
*
|
185
|
+
* @param {object} updatedResource
|
186
|
+
* @private
|
187
|
+
*/
|
188
|
+
|
189
|
+
Session.prototype.messageHandler = function(updatedResource) {
|
190
|
+
this.logger.log('Requested resource update', updatedResource.resourceURL);
|
191
|
+
|
192
|
+
if (updatedResource.reload) {
|
193
|
+
chrome.devtools.inspectedWindow.reload();
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
|
197
|
+
var match = updatedResource.match;
|
198
|
+
var matcher;
|
199
|
+
|
200
|
+
if (typeof match === 'string') {
|
201
|
+
if (match === 'indexOf') {
|
202
|
+
matcher = indexOfMatcher;
|
203
|
+
} else if (match === 'equal') {
|
204
|
+
matcher = equalMatcher;
|
205
|
+
} else {
|
206
|
+
this.logger.error('Unknown match string option', match);
|
207
|
+
return;
|
208
|
+
}
|
209
|
+
} else if (match && typeof match === 'object') {
|
210
|
+
if (match.type === 'regexp') {
|
211
|
+
var flags = '';
|
212
|
+
if (match.ignoreCase) {
|
213
|
+
flags += 'i';
|
214
|
+
}
|
215
|
+
if (match.multiline) {
|
216
|
+
flags += 'm';
|
217
|
+
}
|
218
|
+
if (match.global) {
|
219
|
+
flags += 'g';
|
220
|
+
}
|
221
|
+
var r = new RegExp(match.source, flags);
|
222
|
+
matcher = r.exec.bind(r);
|
223
|
+
} else {
|
224
|
+
this.logger.error('Unknown matcher object:', match);
|
225
|
+
return;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
var resource = this.resources.filter(function (res) {
|
230
|
+
return matcher(res.url, updatedResource.resourceURL);
|
231
|
+
})[0];
|
232
|
+
|
233
|
+
if (!resource) {
|
234
|
+
this.logger.error(
|
235
|
+
'Resource with the following URL is not on the page:',
|
236
|
+
updatedResource.resourceURL
|
237
|
+
);
|
238
|
+
return;
|
239
|
+
}
|
240
|
+
|
241
|
+
resource.setContent(updatedResource.contents, true, function (status) {
|
242
|
+
if (status.code === 'OK') {
|
243
|
+
this.logger.log('Resource update successful');
|
244
|
+
triggerReloadEvent(updatedResource);
|
245
|
+
} else {
|
246
|
+
this.logger.error(
|
247
|
+
'flo failed to update, this shouldn\'t happen please report it: ' +
|
248
|
+
JSON.stringify(status)
|
249
|
+
);
|
250
|
+
}
|
251
|
+
}.bind(this));
|
252
|
+
};
|
253
|
+
|
254
|
+
/**
|
255
|
+
* Destroys session.
|
256
|
+
*
|
257
|
+
* @public
|
258
|
+
*/
|
259
|
+
|
260
|
+
Session.prototype.destroy = function() {
|
261
|
+
this.removeEventListeners();
|
262
|
+
if (this.conn) this.conn.disconnect();
|
263
|
+
};
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Utility to ensure's a function is called only once.
|
267
|
+
*
|
268
|
+
* @param {function} cb
|
269
|
+
* @private
|
270
|
+
*/
|
271
|
+
|
272
|
+
function once(cb) {
|
273
|
+
var called = false;
|
274
|
+
return function() {
|
275
|
+
if (!called) {
|
276
|
+
called = true;
|
277
|
+
return cb.apply(this, arguments);
|
278
|
+
}
|
279
|
+
};
|
280
|
+
}
|
281
|
+
|
282
|
+
function triggerReloadEvent(resource) {
|
283
|
+
var data = {
|
284
|
+
url: resource.resourceURL,
|
285
|
+
contents: resource.contents
|
286
|
+
};
|
287
|
+
|
288
|
+
var script = '(function() {' +
|
289
|
+
'var event = new Event(\'fb-flo-reload\');' +
|
290
|
+
'event.data = ' + JSON.stringify(data) + ';' +
|
291
|
+
'window.dispatchEvent(event);' +
|
292
|
+
'})()';
|
293
|
+
|
294
|
+
chrome.devtools.inspectedWindow.eval(script);
|
295
|
+
}
|
296
|
+
|
297
|
+
function indexOfMatcher(val, resourceURL) {
|
298
|
+
return val.indexOf(resourceURL) > -1;
|
299
|
+
}
|
300
|
+
|
301
|
+
function equalMatcher(val, resourceURL) {
|
302
|
+
return resourceURL === val;
|
303
|
+
}
|
304
|
+
|
305
|
+
}).call(this);
|