batman-rails-flo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +29 -0
  3. data/Rakefile +2 -0
  4. data/lib/batman-rails-flo.rb +5 -0
  5. data/lib/batman_rails_flo/railtie.rb +9 -0
  6. data/lib/batman_rails_flo/tasks.rake +14 -0
  7. data/lib/batman_rails_flo/version.rb +3 -0
  8. data/vendor/assets/javascripts/batman_rails_flo/flo_server.js +67 -0
  9. data/vendor/assets/javascripts/batman_rails_flo/live_reload.js.coffee +129 -0
  10. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CNAME +1 -0
  11. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CONTRIBUTING.md +9 -0
  12. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/LICENSE +22 -0
  13. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/README +50 -0
  14. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/cake +7 -0
  15. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/coffee +7 -0
  16. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/browser.js +134 -0
  17. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/cake.js +112 -0
  18. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/coffee-script.js +335 -0
  19. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/command.js +569 -0
  20. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/grammar.js +631 -0
  21. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/helpers.js +252 -0
  22. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
  23. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/lexer.js +926 -0
  24. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/nodes.js +3158 -0
  25. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/optparse.js +139 -0
  26. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/parser.js +724 -0
  27. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/register.js +66 -0
  28. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/repl.js +163 -0
  29. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/rewriter.js +475 -0
  30. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
  31. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/sourcemap.js +161 -0
  32. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/LICENSE +21 -0
  33. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/examples/pow.js +6 -0
  34. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/index.js +82 -0
  35. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/package.json +34 -0
  36. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/readme.markdown +63 -0
  37. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/chmod.js +38 -0
  38. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/clobber.js +37 -0
  39. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/mkdirp.js +28 -0
  40. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm.js +32 -0
  41. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm_sync.js +39 -0
  42. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/race.js +41 -0
  43. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/rel.js +32 -0
  44. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return.js +25 -0
  45. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return_sync.js +24 -0
  46. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/root.js +18 -0
  47. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/sync.js +32 -0
  48. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask.js +28 -0
  49. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask_sync.js +32 -0
  50. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/package.json +50 -0
  51. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/register.js +1 -0
  52. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/LICENSE +30 -0
  53. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/PATENTS +23 -0
  54. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/README.md +124 -0
  55. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/bin/flo +26 -0
  56. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.html +57 -0
  57. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.js +205 -0
  58. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/style.css +334 -0
  59. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/connection.js +235 -0
  60. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/devtools.html +12 -0
  61. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/index.js +323 -0
  62. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logger.js +42 -0
  63. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logo.png +0 -0
  64. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/manifest.json +13 -0
  65. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/session.js +305 -0
  66. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/index.js +10 -0
  67. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/flo.js +226 -0
  68. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/server.js +94 -0
  69. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/README.md +66 -0
  70. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/index.js +437 -0
  71. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/LICENSE +23 -0
  72. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/README.md +218 -0
  73. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/minimatch.js +1055 -0
  74. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
  75. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
  76. 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
  77. 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
  78. 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
  79. 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
  80. 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
  81. 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
  82. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
  83. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
  84. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
  85. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/package.json +42 -0
  86. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
  87. 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
  88. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/package.json +40 -0
  89. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/basic.js +399 -0
  90. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/brace-expand.js +33 -0
  91. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/caching.js +14 -0
  92. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/defaults.js +274 -0
  93. 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
  94. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/lib/walker.js +111 -0
  95. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/license +13 -0
  96. 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
  97. 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
  98. 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
  99. 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
  100. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/package.json +34 -0
  101. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/readme.md +77 -0
  102. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/package.json +36 -0
  103. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/readme.md +52 -0
  104. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/LICENSE +55 -0
  105. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/main.js +128 -0
  106. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/package.json +34 -0
  107. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/readme.mkd +72 -0
  108. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/d/t +0 -0
  109. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/t +0 -0
  110. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitor.js +31 -0
  111. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitorRootDirectory.js +28 -0
  112. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_watchTree.js +20 -0
  113. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/package.json +45 -0
  114. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/test/test.js +243 -0
  115. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/CHANGELOG.md +81 -0
  116. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/LICENSE +177 -0
  117. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/Makefile +11 -0
  118. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/README.md +245 -0
  119. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/binding.gyp +14 -0
  120. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Makefile +355 -0
  121. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/linker.lock +0 -0
  122. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/validation/src/validation.o +0 -0
  123. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/xor/src/xor.o +0 -0
  124. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/validation.node +0 -0
  125. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/xor.node +0 -0
  126. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/binding.Makefile +6 -0
  127. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/config.gypi +115 -0
  128. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/gyp-mac-tool +512 -0
  129. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/validation.target.mk +154 -0
  130. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/xor.target.mk +154 -0
  131. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/index.js +1 -0
  132. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/install.js +31 -0
  133. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Constants.js +23 -0
  134. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Deprecation.js +38 -0
  135. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.fallback.js +12 -0
  136. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.js +18 -0
  137. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketClient.js +359 -0
  138. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketConnection.js +717 -0
  139. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketFrame.js +282 -0
  140. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRequest.js +478 -0
  141. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouter.js +154 -0
  142. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouterRequest.js +59 -0
  143. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketServer.js +216 -0
  144. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/utils.js +7 -0
  145. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/websocket.js +11 -0
  146. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.fallback.js +13 -0
  147. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.js +18 -0
  148. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/package.json +43 -0
  149. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/validation.cc +144 -0
  150. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/xor.cpp +86 -0
  151. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/FastBufferList.js +192 -0
  152. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/LICENSE +18 -0
  153. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/ctio-faster.js +1126 -0
  154. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/package.json +25 -0
  155. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/browser_websocket.js +63 -0
  156. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/connection_test.js +57 -0
  157. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/logger_mock.js +15 -0
  158. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/session_test.js +194 -0
  159. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/server/flo_test.js +211 -0
  160. data/vendor/assets/javascripts/batman_rails_flo/package.json +15 -0
  161. data/vendor/assets/javascripts/batman_rails_flo/reload_event_handler.js.coffee +56 -0
  162. metadata +232 -0
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "fb-flo",
3
+ "version": "0.2.1",
4
+ "description": "Modify running web apps without reloading",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "mocha test/**/*_test.js --bail"
8
+ },
9
+ "author": "",
10
+ "license": "BSD-2-Clause",
11
+ "dependencies": {
12
+ "websocket": "~1.0.8",
13
+ "sane": "~0.5.1"
14
+ },
15
+ "devDependencies": {
16
+ "mocha": "~1.17.1"
17
+ },
18
+ "bin": {
19
+ "fb-flo": "./bin/flo"
20
+ },
21
+ "readme": "fb-flo\n---\n\nfb-flo is a Chrome extension that lets you modify running apps without reloading. It's easy to integrate with your build system, dev environment, and can be used with your favorite editor.\n\n## Usage\n\nfb-flo is made up of a server and client component. This will guide through configuring your server for your project and installing the Chrome extension.\n\n### 1. Configure fb-flo server\n\n```\n$ npm install fb-flo\n```\n\nfb-flo exports a single `fb-flo` function to start the server. Here is an example where you have your source JavaScript and CSS files in the root directory and your build step involves bundling both into a respective `bundle.js`, `bundle.css`.\n\n```js\nvar flo = require('fb-flo'),\n path = require('path'),\n fs = require('fs');\n\nvar server = flo(\n sourceDirToWatch,\n {\n port: 8888,\n host: 'localhost',\n verbose: false,\n glob: [\n // All JS files in `sourceDirToWatch` and subdirectories\n '**/*.js',\n // All CSS files in `sourceDirToWatch` and subdirectories\n '**/*.css'\n ]\n },\n function resolver(filepath, callback) {\n // 1. Call into your compiler / bundler.\n // 2. Assuming that `bundle.js` is your output file, update `bundle.js`\n // and `bundle.css` when a JS or CSS file changes.\n callback({\n resourceURL: 'bundle.js' + path.extname(filepath),\n // any string-ish value is acceptable. i.e. strings, Buffers etc.\n contents: fs.readFileSync(filepath)\n });\n }\n);\n```\n\n`flo` takes the following arguments.\n\n* `sourceDirToWatch`: absolute or relative path to the directory to watch that contains the source code that will be built.\n* `options` hash of options:\n * `port` port to start the server on (defaults to 8888).\n * `host` to listen on.\n * `verbose` `true` or `false` value indicating if flo should be noisy.\n * `glob` a glob string or array of globs to match against the files to watch.\n * `useFilePolling` some platforms that do not support native file watching, you can force the file watcher to work in polling mode.\n * `pollingInterval` if in polling mode (useFilePolling) then you can set the interval at which to poll for file changes.\n* `resolver` a function to map between files and resources.\n\nThe resolver callback is called with two arguments:\n\n* `filepath` path to the file that changed relative to the watched directory.\n* `callback` called to update a resource file in the browser. Should be called with an object with the following properties:\n * `resourceURL` used as the resource identifier in the browser.\n * `contents` any string-ish value representing the source of the updated file. i.e. strings, Buffers etc.\n * `reload` (optional) forces a full page reload. Use this if you're sure the changed code cannot be hotswapped.\n * `match` (optional, defaults to: indexOf) identifies the matching function to be performed on the resource URL in the browser. Could be one of the following:\n * `\"equal\"` test the updated resource `resourceURL` against existing browser resources using an equality check.\n * `\"indexOf\"` use `String.prototype.indexOf` check\n * `/regexp/` a regexp object to exec.\n\n### 2. Install the Chrome Extension\n\nGrab the [fb-flo Chrome extension](https://chrome.google.com/webstore/detail/ahkfhobdidabddlalamkkiafpipdfchp). This will add a new tab in your Chrome DevTools called 'flo'.\n\n### 3. Activate fb-flo\n\nTo activate fb-flo from the browser:\n\n* Open Chrome DevTools.\n* Click on the new 'fb-flo' pane.\n* Click on 'Activate for this site'\n\nSee screenshot:\n\n![](http://i.imgur.com/SamY32i.png)\n\n### Example\n\nSay you have a Makefile program that builds your JavaScript and CSS into `build/build.js` and `build/build.css` respectively, this how you'd configure your fb-flo server:\n\n```js\nvar flo = require('fb-flo');\nvar fs = require('fs');\nvar exec = require('child_process').exec;\n\nvar server = flo('./lib/', {\n port: 8888,\n dir: './lib/',\n glob: ['./lib/**/*.js', './lib/**/*.css']\n}, resolver);\n\nserver.once('ready', function() {\n console.log('Ready!');\n});\n\nfunction resolver(filepath, callback) {\n exec('make', function (err) {\n if (err) throw err;\n if (filepath.match(/\\.js$/)) {\n callback({\n resourceURL: 'build/build.js',\n contents: fs.readFileSync('build/build.js').toString()\n })\n } else {\n callback({\n resourceURL: 'build/build.css',\n contents: fs.readFileSync('build/build.css').toString()\n })\n }\n });\n}\n```\n",
22
+ "readmeFilename": "README.md",
23
+ "_id": "fb-flo@0.2.1",
24
+ "_from": "fb-flo@"
25
+ }
@@ -0,0 +1,63 @@
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
+ var WebSocketClient = require('websocket').client;
11
+
12
+ function WebSocket(url) {
13
+ this.readyState = 0;
14
+ var client = new WebSocketClient();
15
+ this.onconnect = this.onconnect.bind(this);
16
+ client.once('connect', this.onconnect);
17
+ client.once('connectFailed', this.emit.bind(this, 'close'));
18
+ client.connect(url);
19
+ }
20
+
21
+ WebSocket.prototype.onconnect = function(connection) {
22
+ this.readyState = 1;
23
+ this.socket = connection;
24
+ this.socket.on('error', this.emit.bind(this, 'close'));
25
+ this.socket.on('close', function() {
26
+ this.readyState = 3;
27
+ this.emit('close', {});
28
+ }.bind(this));
29
+ this.socket.on('message', function(msg) {
30
+ var data = msg.utf8Data;
31
+ this.emit('message', {data: data});
32
+ }.bind(this));
33
+ this.emit('open');
34
+ };
35
+
36
+ WebSocket.prototype.send = function(arg) {
37
+ this.socket.sendUTF(arg);
38
+ };
39
+
40
+ WebSocket.prototype.close = function() {
41
+ this.readyState = 2;
42
+ this.socket.close();
43
+ };
44
+
45
+ WebSocket.prototype.emit = function(event) {
46
+ var handler = this['on' + event];
47
+ if (typeof handler === 'function') {
48
+ handler.apply(this, [].slice.call(arguments, 1));
49
+ }
50
+ };
51
+
52
+ var states = {
53
+ CONNECTING: 0,
54
+ OPEN: 1,
55
+ CLOSING: 2,
56
+ CLOSED: 3
57
+ };
58
+
59
+ Object.keys(states).forEach(function(state) {
60
+ WebSocket.prototype[state] = states[state];
61
+ });
62
+
63
+ module.exports = WebSocket;
@@ -0,0 +1,57 @@
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
+ var assert = require('assert');
11
+ var Connection = require('../../client/connection');
12
+ var Server = require('../../lib/server');
13
+ var WebSocket = require('./browser_websocket');
14
+ var mockLogger = require('./logger_mock');
15
+ global.WebSocket = WebSocket;
16
+
17
+ describe('Connection', function() {
18
+ var port = 8543;
19
+ var server;
20
+ afterEach(function() {
21
+ server.close();
22
+ con.disconnect();
23
+ });
24
+
25
+ it('should connect to server', function(done) {
26
+ server = new Server({
27
+ port: port
28
+ });
29
+ con = new Connection('localhost', port, mockLogger)
30
+ .onopen(function() {
31
+ server.broadcast({hi: 1});
32
+ })
33
+ .onmessage(function(msg) {
34
+ assert.deepEqual(msg, {
35
+ hi: 1
36
+ });
37
+ done();
38
+ })
39
+ .onerror(done)
40
+ .connect();
41
+ });
42
+
43
+ it('should retry to connect', function(done) {
44
+ con = new Connection('localhost', port, mockLogger)
45
+ .onopen(function() {
46
+ done();
47
+ })
48
+ .onretry(function(){
49
+ server = new Server({
50
+ port: port
51
+ });
52
+ })
53
+ .onerror(done)
54
+ .connect();
55
+ });
56
+
57
+ });
@@ -0,0 +1,15 @@
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
+ module.exports = function loggerMock() {
11
+ return {
12
+ error: function(){},
13
+ log: function() {}
14
+ }
15
+ }
@@ -0,0 +1,194 @@
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
+ var assert = require('assert');
11
+ var Server = require('../../lib/server');
12
+ var Session = require('../../client/session');
13
+ var WebSocket = require('./browser_websocket')
14
+ var Connection = require('../../client/connection');
15
+ var mockLogger = require('./logger_mock');
16
+
17
+ global.Connection = Connection;
18
+ global.WebSocket = WebSocket;
19
+
20
+ var nop = function() {};
21
+
22
+ describe('Session', function() {
23
+
24
+ beforeEach(function() {
25
+ this.server = new Server({ port: port });
26
+ global.chrome = {
27
+ devtools: {
28
+ inspectedWindow: {
29
+ getResources: function(callback) {
30
+ callback();
31
+ },
32
+ onResourceAdded: {
33
+ addListener: nop,
34
+ removeListener: nop
35
+ }
36
+ },
37
+ network: {
38
+ onNavigated: {
39
+ addListener: nop,
40
+ removeListener: nop
41
+ }
42
+ }
43
+ },
44
+ };
45
+ });
46
+ afterEach(function() {
47
+ this.server.close();
48
+ this.session.destroy();
49
+ });
50
+
51
+ var port = 8543;
52
+ it('should start', function(done) {
53
+ var i = 0;
54
+ function status(state) {
55
+ if (++i == 1) {
56
+ assert.equal(state, 'connecting');
57
+ } else if (i == 2) {
58
+ assert.equal(state, 'connected');
59
+ } else {
60
+ assert.equal(state, 'started');
61
+ done();
62
+ }
63
+ }
64
+ this.session = new Session('localhost', port, status, mockLogger);
65
+ this.session.start();
66
+ });
67
+
68
+ it('should clean properly', function() {
69
+ var status = function(state) {
70
+ if (state !== 'started') return;
71
+ var called = 0;
72
+ chrome.devtools.inspectedWindow.onResourceAdded.removeListener =
73
+ chrome.devtools.network.onNavigated.removeListener =
74
+ function() { called++; };
75
+
76
+ this.session.destroy(function() {
77
+ assert(!this.server.connections.length);
78
+ assert.equal(called, 2);
79
+ }.bind(this));
80
+ }.bind(this);
81
+
82
+ this.session = new Session('localhost', port, status, mockLogger);
83
+ this.session.start();
84
+ });
85
+
86
+ describe('resource manipulation', function() {
87
+ beforeEach(function() {
88
+ chrome.devtools.inspectedWindow.getResources = function(callback) {
89
+ callback([{
90
+ url: 'http://wat',
91
+ setContent: function() {
92
+ this.setContent.apply(this, arguments)
93
+ }.bind(this)
94
+ }]);
95
+ }.bind(this);
96
+ this.session = new Session('localhost', port, function(state) {
97
+ if (state === 'started') this.started();
98
+ }.bind(this), mockLogger);
99
+ this.session.start();
100
+ });
101
+
102
+ it('should change resources using equal matcher', function(done) {
103
+ this.started = function() {
104
+ this.server.broadcast({
105
+ resourceURL: 'http://wat',
106
+ match: 'equal',
107
+ contents: 'foo'
108
+ });
109
+ }.bind(this);
110
+ this.setContent = function(contents, callback) {
111
+ assert.equal(contents, 'foo');
112
+ done();
113
+ };
114
+ });
115
+
116
+ it('should change resource using regexp matcher', function(done) {
117
+ this.started = function() {
118
+ this.server.broadcast({
119
+ resourceURL: 'http://wat',
120
+ match: {
121
+ type: 'regexp',
122
+ source: 'waT',
123
+ ignoreCase: true
124
+ },
125
+ contents: 'foo'
126
+ });
127
+ }.bind(this);
128
+
129
+ this.setContent = function(contents, callback) {
130
+ assert.equal(contents, 'foo');
131
+ done();
132
+ };
133
+ });
134
+
135
+ it('should change resource using regexp matcher', function(done) {
136
+ this.started = function() {
137
+ this.server.broadcast({
138
+ resourceURL: 'http://wat',
139
+ match: {
140
+ type: 'regexp',
141
+ source: 'waT',
142
+ ignoreCase: true
143
+ },
144
+ contents: 'foo'
145
+ });
146
+ }.bind(this);
147
+
148
+ this.setContent = function(contents, callback) {
149
+ assert.equal(contents, 'foo');
150
+ done();
151
+ };
152
+ });
153
+
154
+ it('should change resource using indexOf matcher', function(done) {
155
+ this.started = function() {
156
+ this.server.broadcast({
157
+ resourceURL: 'http://w',
158
+ match: 'indexOf',
159
+ contents: 'foo'
160
+ });
161
+ }.bind(this);
162
+
163
+ this.setContent = function(contents, callback) {
164
+ assert.equal(contents, 'foo');
165
+ done();
166
+ };
167
+ });
168
+
169
+ it('should trigger an event when matched', function(done) {
170
+ chrome.devtools.inspectedWindow.eval = function(expr) {
171
+ assert(expr.match(/var event = new Event\('fb-flo-reload'\);/),
172
+ "event creation");
173
+ assert(expr.match(/event.data = \{"url":"http:\/\/w","contents":"foo"}/),
174
+ "event data");
175
+ assert(expr.match(/window.dispatchEvent\(event\);/),
176
+ "event dispatch");
177
+ done();
178
+ };
179
+
180
+ this.setContent = function(contents, bool, callback) {
181
+ callback({ code: 'OK' });
182
+ };
183
+
184
+ this.started = function() {
185
+ this.server.broadcast({
186
+ resourceURL: 'http://w',
187
+ match: 'indexOf',
188
+ contents: 'foo'
189
+ });
190
+ }.bind(this);
191
+ });
192
+ });
193
+
194
+ });
@@ -0,0 +1,211 @@
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
+ var os = require('os');
11
+ var fs = require('fs');
12
+ var flo = require('../../');
13
+ var assert = require('assert');
14
+ var WebSocketClient = require('websocket').client;
15
+ var path = require('path');
16
+
17
+ var tmpDir = os.tmpDir();
18
+ var testDir = path.join(tmpDir, 'flo_test');
19
+
20
+ function client(connectFailed, connect, message) {
21
+ var client = new WebSocketClient();
22
+ client.connect('ws://localhost:8888/');
23
+ client.on('connectFailed', connectFailed);
24
+ client.on('connect', function (connection) {
25
+ if (connect) connect(connection);
26
+ connection.on('message', function (msg) {
27
+ var data = msg.utf8Data;
28
+ data = JSON.parse(data);
29
+ if (message) message(data);
30
+ });
31
+ });
32
+ return client;
33
+ }
34
+
35
+ describe('flo(dir)', function() {
36
+ var f;
37
+
38
+ beforeEach(function(done) {
39
+ fs.mkdir(testDir, function (err) {
40
+ fs.writeFileSync(path.join(testDir,'foo.js'), 'alert("wow")');
41
+ setTimeout(done, 300);
42
+ });
43
+ });
44
+
45
+ afterEach(function() {
46
+ f.close();
47
+ });
48
+
49
+ it('should start a server', function(done) {
50
+ f = flo(testDir);
51
+ f.on('added', console.log)
52
+ f.on('ready', function () {
53
+ var c = client(
54
+ done.bind(null, new Error('Failed to connect')),
55
+ done.bind(null, null)
56
+ );
57
+ });
58
+ });
59
+
60
+ it('should send resource to the client when changed', function(done) {
61
+ f = flo(testDir);
62
+ f.on('ready', function () {
63
+ var c = client(
64
+ done.bind(null, new Error('Failed to connect')),
65
+ null,
66
+ function (msg) {
67
+ assert.deepEqual(msg, {
68
+ contents: 'alert("hi")',
69
+ resourceURL: 'foo.js',
70
+ match: 'indexOf'
71
+ });
72
+ done();
73
+ }
74
+ );
75
+ fs.writeFileSync(path.join(testDir,'foo.js'), 'alert("hi")');
76
+ });
77
+ });
78
+
79
+ it('should work with css', function(done) {
80
+ fs.writeFileSync(path.join(testDir,'bar.css'), 'bar {color: red}');
81
+ f = flo(testDir);
82
+ f.on('ready', function () {
83
+ var c = client(
84
+ done.bind(null, new Error('Failed to connect')),
85
+ null,
86
+ function(msg) {
87
+ assert.deepEqual(msg, {
88
+ contents: 'bar {color: blue}',
89
+ resourceURL: 'bar.css',
90
+ match: 'indexOf'
91
+ });
92
+ done();
93
+ }
94
+ );
95
+ fs.writeFileSync(path.join(testDir,'bar.css'), 'bar {color: blue}');
96
+ });
97
+ });
98
+
99
+ it('should send resource to multiple clients when changed', function(done) {
100
+ f = flo(testDir);
101
+ f.on('ready', function () {
102
+ var i = 0;
103
+ function handler(connection) {
104
+ connection.on('message', function(msg) {
105
+ var data = msg.utf8Data;
106
+ var msg = JSON.parse(data);
107
+ assert.deepEqual(msg, {
108
+ contents: 'alert("hi")',
109
+ resourceURL: 'foo.js',
110
+ match: 'indexOf'
111
+ });
112
+ if (++i == 2) {
113
+ done();
114
+ } else {
115
+ // make sure we handle disconnects.
116
+ connection.close();
117
+ }
118
+ });
119
+ }
120
+
121
+ var c1 = client(
122
+ done.bind(null, new Error('Failed to connect')),
123
+ handler
124
+ );
125
+ var c2 = client(
126
+ done.bind(null, new Error('Failed to connect')),
127
+ handler
128
+ );
129
+
130
+ fs.writeFileSync(path.join(testDir,'foo.js'), 'alert("hi")');
131
+ });
132
+ });
133
+ });
134
+
135
+ describe('flo(dir, resolver)', function() {
136
+ var f;
137
+
138
+ beforeEach(function(done) {
139
+ fs.mkdir(testDir, function (err) {
140
+ fs.writeFileSync(path.join(testDir,'foo.js'), 'alert("wow")');
141
+ setTimeout(done, 300);
142
+ });
143
+ });
144
+
145
+ afterEach(function() {
146
+ f.close();
147
+ });
148
+
149
+ it('should work with a custom resolver', function(done) {
150
+ f = flo(testDir, function (filepath, callback) {
151
+ assert.equal(filepath, 'foo.js');
152
+ callback({
153
+ contents: 'foobar',
154
+ resourceURL: path.sep === '\\' ? 'custom\\url' : 'custom/url'
155
+ });
156
+ });
157
+
158
+ f.on('ready', function() {
159
+ var c = client(
160
+ done.bind(null, new Error('Failed to connect')),
161
+ null,
162
+ function(msg) {
163
+ assert.deepEqual(msg, {
164
+ contents: 'foobar',
165
+ resourceURL: 'custom/url',
166
+ match: 'indexOf'
167
+ });
168
+ done();
169
+ }
170
+ );
171
+
172
+ fs.writeFileSync(path.join(testDir,'foo.js'), 'hmmmm');
173
+ });
174
+ });
175
+
176
+ describe('resolver match property', function() {
177
+ it('should serialize regexp objects', function(done) {
178
+ f = flo(testDir, function (filepath, callback) {
179
+ assert.equal(filepath, 'foo.js');
180
+ callback({
181
+ contents: 'foobar',
182
+ resourceURL: 'customurl',
183
+ match: /a(b)+/gi
184
+ });
185
+ });
186
+
187
+ f.on('ready', function() {
188
+ var c = client(
189
+ done.bind(null, new Error('Failed to connect')),
190
+ null,
191
+ function(msg) {
192
+ assert.deepEqual(msg, {
193
+ contents: 'foobar',
194
+ resourceURL: 'customurl',
195
+ match: {
196
+ type: 'regexp',
197
+ global: true,
198
+ ignoreCase: true,
199
+ multiline: false,
200
+ source: 'a(b)+'
201
+ }
202
+ });
203
+ done();
204
+ }
205
+ );
206
+
207
+ fs.writeFileSync(path.join(testDir,'foo.js'), 'hmmmm');
208
+ });
209
+ });
210
+ });
211
+ });