react 0.3.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/.npmignore +2 -1
  2. package/.travis.yml +4 -0
  3. package/Jakefile.js +34 -3
  4. package/README.md +34 -174
  5. package/browser-test/dist.html +90 -0
  6. package/browser-test/index.html +86 -0
  7. package/browser-test/min.html +90 -0
  8. package/dist/react.js +3291 -0
  9. package/dist/react.min.js +1 -0
  10. package/doc/advanced.md +166 -0
  11. package/doc/color-def.graffle +938 -0
  12. package/doc/color-def.png +0 -0
  13. package/doc/simple.dot +25 -0
  14. package/doc/simple.png +0 -0
  15. package/examples/{default1.js → longer-example.js} +0 -0
  16. package/examples/{default-simple.js → simple.js} +0 -0
  17. package/examples/{ast1.js → using-ast-directly.js} +4 -0
  18. package/examples/{default-events1.js → using-events1.js} +1 -1
  19. package/examples/{default-log-events.js → using-log-events.js} +1 -1
  20. package/lib/base-task.js +116 -110
  21. package/lib/cb-task.js +71 -67
  22. package/lib/core.js +120 -109
  23. package/lib/dsl.js +120 -115
  24. package/lib/error.js +44 -36
  25. package/lib/event-collector.js +81 -0
  26. package/lib/event-manager.js +66 -55
  27. package/lib/eventemitter.js +20 -0
  28. package/lib/finalcb-first-task.js +56 -53
  29. package/lib/finalcb-task.js +55 -51
  30. package/lib/id.js +18 -6
  31. package/lib/input-parser.js +49 -41
  32. package/lib/log-events.js +81 -60
  33. package/lib/parse.js +34 -25
  34. package/lib/promise-resolve.js +50 -0
  35. package/lib/promise-task.js +78 -74
  36. package/lib/react.js +59 -0
  37. package/lib/ret-task.js +59 -55
  38. package/lib/sprintf.js +18 -0
  39. package/lib/status.js +11 -2
  40. package/lib/task.js +219 -213
  41. package/lib/track-tasks.js +67 -110
  42. package/lib/validate.js +136 -136
  43. package/lib/vcon.js +78 -69
  44. package/lib/when-task.js +69 -65
  45. package/package.json +11 -9
  46. package/src/dist.build.requirejs +20 -0
  47. package/test/ast.mocha.js +136 -0
  48. package/test/cb-task.mocha.js +220 -0
  49. package/test/core-deferred.mocha.js +143 -0
  50. package/test/core-when.mocha.js +96 -0
  51. package/test/core.mocha.js +589 -0
  52. package/test/dsl.mocha.js +350 -0
  53. package/test/event-manager.mocha.js +119 -0
  54. package/test/exec-options.mocha.js +48 -0
  55. package/test/finalcb-task.mocha.js +58 -0
  56. package/test/input-parser.mocha.js +86 -0
  57. package/test/mocha.opts +2 -0
  58. package/test/module-use.mocha.js +147 -0
  59. package/test/promise-auto-resolve.mocha.js +68 -0
  60. package/test/ret-task.mocha.js +220 -0
  61. package/test/task.mocha.js +42 -0
  62. package/test/validate-cb-task.mocha.js +100 -0
  63. package/test/validate-ret-task.mocha.js +110 -0
  64. package/test/validate.mocha.js +324 -0
  65. package/test/vcon.mocha.js +193 -0
  66. package/vendor/chai/chai.js +2038 -0
  67. package/vendor/jquery/jquery-1.7.1.js +9266 -0
  68. package/vendor/jquery/jquery-1.7.1.min.js +4 -0
  69. package/vendor/mocha/mocha.css +135 -0
  70. package/vendor/mocha/mocha.js +3589 -0
  71. package/vendor/node/util.js +531 -0
  72. package/vendor/requirejs/require.js +2053 -0
  73. package/vendor/requirejs/require.min.js +33 -0
  74. package/doc/alternate-dsls.md +0 -103
  75. package/doc/default-simple.dot +0 -19
  76. package/doc/default-simple.dot.png +0 -0
  77. package/dsl/chain.js +0 -150
  78. package/dsl/fstr.js +0 -121
  79. package/dsl/pcode.js +0 -175
  80. package/examples/chain-events1.js +0 -55
  81. package/examples/chain1.js +0 -19
  82. package/examples/fstr-events1.js +0 -38
  83. package/examples/fstr1.js +0 -37
  84. package/examples/pcode1.js +0 -22
  85. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia.html +0 -675
  86. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/37px-Wiktionary-logo-en.svg.png +0 -0
  87. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/closewindow.png +0 -0
  88. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/index(1).php +0 -407
  89. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/index.php +0 -130
  90. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(1).php +0 -3
  91. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(10).php +0 -89
  92. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(2).php +0 -23
  93. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(3).php +0 -153
  94. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(4).php +0 -6
  95. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(5).php +0 -3
  96. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(6).php +0 -96
  97. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(7).php +0 -16
  98. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(8).php +0 -14
  99. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load(9).php +0 -123
  100. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/load.php +0 -3
  101. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/poweredby_mediawiki_88x31.png +0 -0
  102. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/saved_resource +0 -1
  103. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/search-ltr.png +0 -0
  104. package/externalDocs/Dataflow - Wikipedia, the free encyclopedia_files/wikimedia-button.png +0 -0
  105. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's.html +0 -1369
  106. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/121911_DobbsDigest_Cover.jpg +0 -0
  107. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/160-x-600-IMU Impact 2012.jpg +0 -0
  108. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp= +0 -68
  109. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=(1) +0 -67
  110. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=(2) +0 -2
  111. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=(3) +0 -2
  112. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=(4) +0 -8
  113. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=(5) +0 -2
  114. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461 +0 -2
  115. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(1) +0 -2
  116. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(2) +0 -2
  117. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(3) +0 -2
  118. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(4) +0 -2
  119. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(5) +0 -431
  120. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(6) +0 -2
  121. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(7) +0 -431
  122. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(8) +0 -2
  123. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/231400148;kvarticleid=231400148;kauthor=Jim Falgout;loc=100;target=_blank;grp=500202461(9) +0 -2
  124. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/Ad0St1Sz6Sq0V0Id20628317.gif +0 -0
  125. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/Ad2331174St1Sz225Sq20825250V0Id4.gif +0 -0
  126. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/AdTracImage.gif +0 -0
  127. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/Default_Size_16_1x1.gif +0 -0
  128. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/FB.Share +0 -9
  129. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/addthis_widget.js +0 -2
  130. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/adlink_5242_1183459_0_154_AdId=2355270;BnId=1;itime=820768810;key=231400148+_database_231400148;link= +0 -11
  131. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/beacon.js +0 -7
  132. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/checkauth.js +0 -18
  133. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/colorbox.css +0 -49
  134. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/convert_data.js +0 -1
  135. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/count(1).js +0 -5
  136. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/count.js +0 -5
  137. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/count.json +0 -1
  138. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/dataflow1.gif +0 -0
  139. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/def.html +0 -126
  140. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/defaults.css +0 -1
  141. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/detect.js +0 -91
  142. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/devtest_left-col-slim.css +0 -30
  143. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/disqus.js +0 -327
  144. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/disqusHints.css +0 -34
  145. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/disqusHints.js +0 -8
  146. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/disqusLoggedOff(1).css +0 -24
  147. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/disqusLoggedOff.css +0 -24
  148. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/dobbs_disqus_logo.gif +0 -0
  149. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/dsqcd10c7f376188a4a2ca3e8fea2c03aeb.css +0 -1
  150. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/dsqcd10c7f376188a4a2ca3e8fea2c03aeb.js +0 -1
  151. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/elqCfg.js +0 -55
  152. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/elqImg.js +0 -12
  153. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/embed.js +0 -76
  154. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/experience_util.js +0 -636
  155. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/fastbutton.html +0 -11
  156. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/ga.js +0 -51
  157. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/h-facebook_sm.png +0 -0
  158. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/h-nav.css +0 -798
  159. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/h-twitter_sm.png +0 -0
  160. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/h_s_code_remote.js +0 -377
  161. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/hintbox_info.jpg +0 -0
  162. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/hub.1326407570.html +0 -3
  163. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/in.js +0 -76
  164. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/insight.min.js +0 -55
  165. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/jquery-1.2.6.min.js +0 -32
  166. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/jquery-1.4.2.min.js +0 -154
  167. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/jquery-ui-1.8rc3.custom.min.js +0 -374
  168. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/jquery.colorbox-min.js +0 -4
  169. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/jquery.min.js +0 -154
  170. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/lib.js +0 -212
  171. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/like.html +0 -214
  172. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/noavatar32.png +0 -0
  173. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/nodetag.js +0 -18
  174. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/nonSecureAnonymousFramework +0 -2913
  175. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/p.json +0 -1
  176. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/plusone.js +0 -32
  177. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/popwindow.js +0 -24
  178. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/q4OyybLB0-A.js +0 -91
  179. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/quant.js +0 -28
  180. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/qxvZoiHdpAF.css +0 -192
  181. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/reply.html +0 -160
  182. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/rss.gif +0 -0
  183. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/s.js +0 -1
  184. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/saved_resource +0 -421
  185. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/saved_resource(1) +0 -1
  186. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/saved_resource(2) +0 -341
  187. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/saved_resource(3) +0 -127
  188. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/script84.js +0 -113
  189. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/scripts.js +0 -30
  190. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/sh72.html +0 -5
  191. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shAutoloader.js +0 -17
  192. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushAS3.js +0 -59
  193. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushAppleScript.js +0 -75
  194. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushBash.js +0 -59
  195. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushCSharp.js +0 -65
  196. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushColdFusion.js +0 -100
  197. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushCpp.js +0 -97
  198. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushCss.js +0 -91
  199. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushDelphi.js +0 -55
  200. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushDiff.js +0 -41
  201. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushErlang.js +0 -52
  202. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushGroovy.js +0 -67
  203. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushJScript.js +0 -52
  204. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushJava.js +0 -57
  205. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushJavaFX.js +0 -58
  206. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushPerl.js +0 -72
  207. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushPhp.js +0 -88
  208. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushPlain.js +0 -33
  209. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushPowerShell.js +0 -74
  210. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushPython.js +0 -64
  211. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushRuby.js +0 -55
  212. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushSass.js +0 -94
  213. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushScala.js +0 -51
  214. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushSql.js +0 -66
  215. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushVb.js +0 -56
  216. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shBrushXml.js +0 -69
  217. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shCore.css +0 -226
  218. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shCoreDefault.css +0 -333
  219. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shCore_new.js +0 -17
  220. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shLegacy.js +0 -17
  221. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/shThemeDefault.css +0 -117
  222. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/share-button-css +0 -67
  223. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/share_email_icon.gif +0 -0
  224. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/share_print_icon.gif +0 -0
  225. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/sidebar.js +0 -88
  226. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/superfooter_936.css +0 -186
  227. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/svrGP.aspx +0 -0
  228. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/t.gif +0 -0
  229. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/thickbox.js +0 -343
  230. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/thread.js +0 -128
  231. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/togglediv.js +0 -15
  232. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/tweet_button.html +0 -3
  233. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/ubmtechweb_logo_sm.gif +0 -0
  234. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/upload.html +0 -91
  235. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/welcome.js +0 -7
  236. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/widget74.css +0 -1
  237. package/externalDocs/Dataflow Programming Handling Huge Data Loads Without Adding Complexity Dr Dobb's_files/widgets.js +0 -40
  238. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia.html +0 -904
  239. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/50px-Question_book-new.svg.png +0 -0
  240. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/closewindow.png +0 -0
  241. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/index(1).php +0 -407
  242. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/index.php +0 -130
  243. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(1).php +0 -3
  244. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(10).php +0 -89
  245. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(2).php +0 -23
  246. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(3).php +0 -153
  247. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(4).php +0 -6
  248. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(5).php +0 -3
  249. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(6).php +0 -96
  250. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(7).php +0 -16
  251. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(8).php +0 -14
  252. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load(9).php +0 -123
  253. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/load.php +0 -3
  254. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/poweredby_mediawiki_88x31.png +0 -0
  255. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/saved_resource +0 -1
  256. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/search-ltr.png +0 -0
  257. package/externalDocs/Reactive programming - Wikipedia, the free encyclopedia_files/wikimedia-button.png +0 -0
  258. package/externalDocs/The Step of the Conductor - How To Node - NodeJS.html +0 -113
  259. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/6654_111305815684_541245684_2583159_5383291_n_normal.jpg +0 -0
  260. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/MARC3_normal.jpg +0 -2
  261. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/beacon.js +0 -7
  262. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/c953ddd239707998340e1a6fbb3eeb46 +0 -0
  263. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/c953ddd239707998340e1a6fbb3eeb46_normal.jpeg +0 -0
  264. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/clouds2_normal.jpg +0 -0
  265. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/count.json +0 -1
  266. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/def.html +0 -126
  267. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/defaults.css +0 -1
  268. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/disqus.js +0 -327
  269. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/dsq7884a9652e94555c70f96b6be63be216.css +0 -1
  270. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/dsq7884a9652e94555c70f96b6be63be216.js +0 -66
  271. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/embed.js +0 -76
  272. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/example1.dot +0 -0
  273. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/ga.js +0 -51
  274. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/get_num_replies.js +0 -79
  275. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/hub.1326407570.html +0 -3
  276. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/lib.js +0 -212
  277. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/noavatar32.png +0 -0
  278. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/quant.js +0 -28
  279. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/reply.html +0 -160
  280. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/t.gif +0 -0
  281. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/thread.js +0 -128
  282. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/tweet_button.1326407570.html +0 -3
  283. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/twitter_normal.jpg +0 -2
  284. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/upload.html +0 -91
  285. package/externalDocs/The Step of the Conductor - How To Node - NodeJS_files/widgets.js +0 -40
  286. package/jake-tasks/jake-test.js +0 -64
  287. package/promise-resolve.js +0 -35
  288. package/react.js +0 -8
  289. package/test/ast.test.js +0 -69
  290. package/test/cb-task.test.js +0 -197
  291. package/test/core-deferred.test.js +0 -134
  292. package/test/core-promised.test.js +0 -132
  293. package/test/core-when.test.js +0 -84
  294. package/test/core.test.js +0 -568
  295. package/test/dsl.test.js +0 -330
  296. package/test/dsl/chain.test.js +0 -324
  297. package/test/dsl/fstr.test.js +0 -300
  298. package/test/dsl/pcode.test.js +0 -448
  299. package/test/event-manager.test.js +0 -102
  300. package/test/exec-options.test.js +0 -33
  301. package/test/finalcb-task.test.js +0 -38
  302. package/test/input-parser.test.js +0 -66
  303. package/test/module-use.test.js +0 -131
  304. package/test/promise-auto-resolve.test.js +0 -51
  305. package/test/ret-task.test.js +0 -199
  306. package/test/task.test.js +0 -21
  307. package/test/validate-cb-task.test.js +0 -74
  308. package/test/validate-ret-task.test.js +0 -83
  309. package/test/validate.test.js +0 -295
  310. package/test/vcon.test.js +0 -173
@@ -0,0 +1,90 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <title>Mocha Tests</title>
5
+ <link rel="stylesheet" href="../vendor/mocha/mocha.css" />
6
+ <script type="text/javascript" src="../vendor/jquery/jquery-1.7.1.js"></script>
7
+ <script type="text/javascript" src="../vendor/chai/chai.js"></script>
8
+ <script type="text/javascript" src="../vendor/mocha/mocha.js"></script>
9
+ <script>mocha.setup('qunit')</script>
10
+ <script src="../vendor/requirejs/require.min.js"></script>
11
+ <script type="text/javascript">
12
+ require.config({
13
+ baseUrl: "..",
14
+ packages: [
15
+ {
16
+ name: "react",
17
+ location: "dist",
18
+ main: "react.min"
19
+ }
20
+ ],
21
+ paths: {
22
+ jQuery: "vendor/jquery/jquery-1.7.1.min",
23
+ eventemitter2: "dist/react.min",
24
+ util: "dist/react.min",
25
+ sprint: "dist/react.min",
26
+ "ensure-array": "dist/react.min",
27
+ test: "test"
28
+ }
29
+ });
30
+
31
+ require(["react", "jQuery"],
32
+ function (react, jquery) {
33
+
34
+ require(["react/sprintf", "react/validate", "react/task", "react/cb-task",
35
+ "react/vcon", "react/event-manager", "react/input-parser",
36
+ "react/base-task", "react/ret-task", "util"],
37
+ function (sprintf, validate, taskUtil, CbTask,
38
+ VContext, EventManager, inputParser,
39
+ BaseTask, RetTask, util) {
40
+ // save refs on window for these
41
+ window.react = react;
42
+ window.sprintf = sprintf;
43
+ window.util = util;
44
+ window.validate = validate;
45
+ window.taskUtil = taskUtil;
46
+ window.CbTask = CbTask;
47
+ window.VContext = VContext;
48
+ window.EventManager = EventManager;
49
+ window.inputParser = inputParser;
50
+ window.BaseTask = BaseTask;
51
+ window.RetTask = RetTask;
52
+ window.validate = validate;
53
+ window.Deferred = jQuery.Deferred;
54
+ window.Deferred.when = jQuery.when;
55
+ var testFiles = [
56
+ "test/ast.mocha",
57
+ "test/cb-task.mocha",
58
+ "test/core-deferred.mocha",
59
+ "test/core-when.mocha",
60
+ "test/core.mocha",
61
+ "test/dsl.mocha",
62
+ "test/event-manager.mocha",
63
+ "test/exec-options.mocha",
64
+ "test/finalcb-task.mocha",
65
+ "test/input-parser.mocha",
66
+ "test/module-use.mocha",
67
+ "test/promise-auto-resolve.mocha",
68
+ "test/ret-task.mocha",
69
+ "test/task.mocha",
70
+ "test/validate-cb-task.mocha",
71
+ "test/validate-ret-task.mocha",
72
+ "test/validate.mocha",
73
+ "test/vcon.mocha"
74
+ ];
75
+ require(testFiles, function () {
76
+ var runner = mocha.run().on('end', function () {
77
+ console.log('mocha finished');
78
+ jQuery("#mocha-result").text('completed');
79
+ });
80
+ //mocha.reporters.TAP(runner);
81
+ });
82
+ });
83
+ });
84
+ </script>
85
+ </head>
86
+ <body>
87
+ <div id="mocha"></div>
88
+ <div id="mocha-result"></div>
89
+ </body>
90
+ </html>
package/dist/react.js ADDED
@@ -0,0 +1,3291 @@
1
+
2
+ ;!function(exports, undefined) {
3
+
4
+ var isArray = Array.isArray ? Array.isArray : function _isArray(obj) {
5
+ return Object.prototype.toString.call(obj) === "[object Array]";
6
+ };
7
+ var defaultMaxListeners = 10;
8
+
9
+ function init() {
10
+ this._events = new Object;
11
+ }
12
+
13
+ function configure(conf) {
14
+ if (conf) {
15
+ conf.delimiter && (this.delimiter = conf.delimiter);
16
+ conf.wildcard && (this.wildcard = conf.wildcard);
17
+ if (this.wildcard) {
18
+ this.listenerTree = new Object;
19
+ }
20
+ }
21
+ }
22
+
23
+ function EventEmitter(conf) {
24
+ this._events = new Object;
25
+ configure.call(this, conf);
26
+ }
27
+
28
+ //
29
+ // Attention, function return type now is array, always !
30
+ // It has zero elements if no any matches found and one or more
31
+ // elements (leafs) if there are matches
32
+ //
33
+ function searchListenerTree(handlers, type, tree, i) {
34
+ if (!tree) {
35
+ return [];
36
+ }
37
+ var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached,
38
+ typeLength = type.length, currentType = type[i], nextType = type[i+1];
39
+ if (i === typeLength && tree._listeners) {
40
+ //
41
+ // If at the end of the event(s) list and the tree has listeners
42
+ // invoke those listeners.
43
+ //
44
+ if (typeof tree._listeners === 'function') {
45
+ handlers && handlers.push(tree._listeners);
46
+ return [tree];
47
+ } else {
48
+ for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) {
49
+ handlers && handlers.push(tree._listeners[leaf]);
50
+ }
51
+ return [tree];
52
+ }
53
+ }
54
+
55
+ if ((currentType === '*' || currentType === '**') || tree[currentType]) {
56
+ //
57
+ // If the event emitted is '*' at this part
58
+ // or there is a concrete match at this patch
59
+ //
60
+ if (currentType === '*') {
61
+ for (branch in tree) {
62
+ if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
63
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1));
64
+ }
65
+ }
66
+ return listeners;
67
+ } else if(currentType === '**') {
68
+ endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*'));
69
+ if(endReached && tree._listeners) {
70
+ // The next element has a _listeners, add it to the handlers.
71
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength));
72
+ }
73
+
74
+ for (branch in tree) {
75
+ if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
76
+ if(branch === '*' || branch === '**') {
77
+ if(tree[branch]._listeners && !endReached) {
78
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength));
79
+ }
80
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
81
+ } else if(branch === nextType) {
82
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2));
83
+ } else {
84
+ // No match on this one, shift into the tree but not in the type array.
85
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
86
+ }
87
+ }
88
+ }
89
+ return listeners;
90
+ }
91
+
92
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1));
93
+ }
94
+
95
+ xTree = tree['*'];
96
+ if (xTree) {
97
+ //
98
+ // If the listener tree will allow any match for this part,
99
+ // then recursively explore all branches of the tree
100
+ //
101
+ searchListenerTree(handlers, type, xTree, i+1);
102
+ }
103
+
104
+ xxTree = tree['**'];
105
+ if(xxTree) {
106
+ if(i < typeLength) {
107
+ if(xxTree._listeners) {
108
+ // If we have a listener on a '**', it will catch all, so add its handler.
109
+ searchListenerTree(handlers, type, xxTree, typeLength);
110
+ }
111
+
112
+ // Build arrays of matching next branches and others.
113
+ for(branch in xxTree) {
114
+ if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) {
115
+ if(branch === nextType) {
116
+ // We know the next element will match, so jump twice.
117
+ searchListenerTree(handlers, type, xxTree[branch], i+2);
118
+ } else if(branch === currentType) {
119
+ // Current node matches, move into the tree.
120
+ searchListenerTree(handlers, type, xxTree[branch], i+1);
121
+ } else {
122
+ isolatedBranch = {};
123
+ isolatedBranch[branch] = xxTree[branch];
124
+ searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1);
125
+ }
126
+ }
127
+ }
128
+ } else if(xxTree._listeners) {
129
+ // We have reached the end and still on a '**'
130
+ searchListenerTree(handlers, type, xxTree, typeLength);
131
+ } else if(xxTree['*'] && xxTree['*']._listeners) {
132
+ searchListenerTree(handlers, type, xxTree['*'], typeLength);
133
+ }
134
+ }
135
+
136
+ return listeners;
137
+ }
138
+
139
+ function growListenerTree(type, listener) {
140
+
141
+ type = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
142
+
143
+ //
144
+ // Looks for two consecutive '**', if so, don't add the event at all.
145
+ //
146
+ for(var i = 0, len = type.length; i+1 < len; i++) {
147
+ if(type[i] === '**' && type[i+1] === '**') {
148
+ return;
149
+ }
150
+ }
151
+
152
+ var tree = this.listenerTree;
153
+ var name = type.shift();
154
+
155
+ while (name) {
156
+
157
+ if (!tree[name]) {
158
+ tree[name] = new Object;
159
+ }
160
+
161
+ tree = tree[name];
162
+
163
+ if (type.length === 0) {
164
+
165
+ if (!tree._listeners) {
166
+ tree._listeners = listener;
167
+ }
168
+ else if(typeof tree._listeners === 'function') {
169
+ tree._listeners = [tree._listeners, listener];
170
+ }
171
+ else if (isArray(tree._listeners)) {
172
+
173
+ tree._listeners.push(listener);
174
+
175
+ if (!tree._listeners.warned) {
176
+
177
+ var m = defaultMaxListeners;
178
+
179
+ if (typeof this._events.maxListeners !== 'undefined') {
180
+ m = this._events.maxListeners;
181
+ }
182
+
183
+ if (m > 0 && tree._listeners.length > m) {
184
+
185
+ tree._listeners.warned = true;
186
+ console.error('(node) warning: possible EventEmitter memory ' +
187
+ 'leak detected. %d listeners added. ' +
188
+ 'Use emitter.setMaxListeners() to increase limit.',
189
+ tree._listeners.length);
190
+ console.trace();
191
+ }
192
+ }
193
+ }
194
+ return true;
195
+ }
196
+ name = type.shift();
197
+ }
198
+ return true;
199
+ };
200
+
201
+ // By default EventEmitters will print a warning if more than
202
+ // 10 listeners are added to it. This is a useful default which
203
+ // helps finding memory leaks.
204
+ //
205
+ // Obviously not all Emitters should be limited to 10. This function allows
206
+ // that to be increased. Set to zero for unlimited.
207
+
208
+ EventEmitter.prototype.delimiter = '.';
209
+
210
+ EventEmitter.prototype.setMaxListeners = function(n) {
211
+ this._events || init.call(this);
212
+ this._events.maxListeners = n;
213
+ };
214
+
215
+ EventEmitter.prototype.event = '';
216
+
217
+ EventEmitter.prototype.once = function(event, fn) {
218
+ this.many(event, 1, fn);
219
+ return this;
220
+ };
221
+
222
+ EventEmitter.prototype.many = function(event, ttl, fn) {
223
+ var self = this;
224
+
225
+ if (typeof fn !== 'function') {
226
+ throw new Error('many only accepts instances of Function');
227
+ }
228
+
229
+ function listener() {
230
+ if (--ttl === 0) {
231
+ self.off(event, listener);
232
+ }
233
+ fn.apply(this, arguments);
234
+ };
235
+
236
+ listener._origin = fn;
237
+
238
+ this.on(event, listener);
239
+
240
+ return self;
241
+ };
242
+
243
+ EventEmitter.prototype.emit = function() {
244
+ this._events || init.call(this);
245
+
246
+ var type = arguments[0];
247
+
248
+ if (type === 'newListener') {
249
+ if (!this._events.newListener) { return false; }
250
+ }
251
+
252
+ // Loop through the *_all* functions and invoke them.
253
+ if (this._all) {
254
+ var l = arguments.length;
255
+ var args = new Array(l - 1);
256
+ for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
257
+ for (i = 0, l = this._all.length; i < l; i++) {
258
+ this.event = type;
259
+ this._all[i].apply(this, args);
260
+ }
261
+ }
262
+
263
+ // If there is no 'error' event listener then throw.
264
+ if (type === 'error') {
265
+
266
+ if (!this._all &&
267
+ !this._events.error &&
268
+ !(this.wildcard && this.listenerTree.error)) {
269
+
270
+ if (arguments[1] instanceof Error) {
271
+ throw arguments[1]; // Unhandled 'error' event
272
+ } else {
273
+ throw new Error("Uncaught, unspecified 'error' event.");
274
+ }
275
+ return false;
276
+ }
277
+ }
278
+
279
+ var handler;
280
+
281
+ if(this.wildcard) {
282
+ handler = [];
283
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
284
+ searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
285
+ }
286
+ else {
287
+ handler = this._events[type];
288
+ }
289
+
290
+ if (typeof handler === 'function') {
291
+ this.event = type;
292
+ if (arguments.length === 1) {
293
+ handler.call(this);
294
+ }
295
+ else if (arguments.length > 1)
296
+ switch (arguments.length) {
297
+ case 2:
298
+ handler.call(this, arguments[1]);
299
+ break;
300
+ case 3:
301
+ handler.call(this, arguments[1], arguments[2]);
302
+ break;
303
+ // slower
304
+ default:
305
+ var l = arguments.length;
306
+ var args = new Array(l - 1);
307
+ for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
308
+ handler.apply(this, args);
309
+ }
310
+ return true;
311
+ }
312
+ else if (handler) {
313
+ var l = arguments.length;
314
+ var args = new Array(l - 1);
315
+ for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
316
+
317
+ var listeners = handler.slice();
318
+ for (var i = 0, l = listeners.length; i < l; i++) {
319
+ this.event = type;
320
+ listeners[i].apply(this, args);
321
+ }
322
+ return (listeners.length > 0) || this._all;
323
+ }
324
+ else {
325
+ return this._all;
326
+ }
327
+
328
+ };
329
+
330
+ EventEmitter.prototype.on = function(type, listener) {
331
+
332
+ if (typeof type === 'function') {
333
+ this.onAny(type);
334
+ return this;
335
+ }
336
+
337
+ if (typeof listener !== 'function') {
338
+ throw new Error('on only accepts instances of Function');
339
+ }
340
+ this._events || init.call(this);
341
+
342
+ // To avoid recursion in the case that type == "newListeners"! Before
343
+ // adding it to the listeners, first emit "newListeners".
344
+ this.emit('newListener', type, listener);
345
+
346
+ if(this.wildcard) {
347
+ growListenerTree.call(this, type, listener);
348
+ return this;
349
+ }
350
+
351
+ if (!this._events[type]) {
352
+ // Optimize the case of one listener. Don't need the extra array object.
353
+ this._events[type] = listener;
354
+ }
355
+ else if(typeof this._events[type] === 'function') {
356
+ // Adding the second element, need to change to array.
357
+ this._events[type] = [this._events[type], listener];
358
+ }
359
+ else if (isArray(this._events[type])) {
360
+ // If we've already got an array, just append.
361
+ this._events[type].push(listener);
362
+
363
+ // Check for listener leak
364
+ if (!this._events[type].warned) {
365
+
366
+ var m = defaultMaxListeners;
367
+
368
+ if (typeof this._events.maxListeners !== 'undefined') {
369
+ m = this._events.maxListeners;
370
+ }
371
+
372
+ if (m > 0 && this._events[type].length > m) {
373
+
374
+ this._events[type].warned = true;
375
+ console.error('(node) warning: possible EventEmitter memory ' +
376
+ 'leak detected. %d listeners added. ' +
377
+ 'Use emitter.setMaxListeners() to increase limit.',
378
+ this._events[type].length);
379
+ console.trace();
380
+ }
381
+ }
382
+ }
383
+ return this;
384
+ };
385
+
386
+ EventEmitter.prototype.onAny = function(fn) {
387
+
388
+ if(!this._all) {
389
+ this._all = [];
390
+ }
391
+
392
+ if (typeof fn !== 'function') {
393
+ throw new Error('onAny only accepts instances of Function');
394
+ }
395
+
396
+ // Add the function to the event listener collection.
397
+ this._all.push(fn);
398
+ return this;
399
+ };
400
+
401
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
402
+
403
+ EventEmitter.prototype.off = function(type, listener) {
404
+ if (typeof listener !== 'function') {
405
+ throw new Error('removeListener only takes instances of Function');
406
+ }
407
+
408
+ var handlers,leafs=[];
409
+
410
+ if(this.wildcard) {
411
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
412
+ leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
413
+ }
414
+ else {
415
+ // does not use listeners(), so no side effect of creating _events[type]
416
+ if (!this._events[type]) return this;
417
+ handlers = this._events[type];
418
+ leafs.push({_listeners:handlers});
419
+ }
420
+
421
+ for (var iLeaf=0; iLeaf<leafs.length; iLeaf++) {
422
+ var leaf = leafs[iLeaf];
423
+ handlers = leaf._listeners;
424
+ if (isArray(handlers)) {
425
+
426
+ var position = -1;
427
+
428
+ for (var i = 0, length = handlers.length; i < length; i++) {
429
+ if (handlers[i] === listener ||
430
+ (handlers[i].listener && handlers[i].listener === listener) ||
431
+ (handlers[i]._origin && handlers[i]._origin === listener)) {
432
+ position = i;
433
+ break;
434
+ }
435
+ }
436
+
437
+ if (position < 0) {
438
+ return this;
439
+ }
440
+
441
+ if(this.wildcard) {
442
+ leaf._listeners.splice(position, 1)
443
+ }
444
+ else {
445
+ this._events[type].splice(position, 1);
446
+ }
447
+
448
+ if (handlers.length === 0) {
449
+ if(this.wildcard) {
450
+ delete leaf._listeners;
451
+ }
452
+ else {
453
+ delete this._events[type];
454
+ }
455
+ }
456
+ }
457
+ else if (handlers === listener ||
458
+ (handlers.listener && handlers.listener === listener) ||
459
+ (handlers._origin && handlers._origin === listener)) {
460
+ if(this.wildcard) {
461
+ delete leaf._listeners;
462
+ }
463
+ else {
464
+ delete this._events[type];
465
+ }
466
+ }
467
+ }
468
+
469
+ return this;
470
+ };
471
+
472
+ EventEmitter.prototype.offAny = function(fn) {
473
+ var i = 0, l = 0, fns;
474
+ if (fn && this._all && this._all.length > 0) {
475
+ fns = this._all;
476
+ for(i = 0, l = fns.length; i < l; i++) {
477
+ if(fn === fns[i]) {
478
+ fns.splice(i, 1);
479
+ return this;
480
+ }
481
+ }
482
+ } else {
483
+ this._all = [];
484
+ }
485
+ return this;
486
+ };
487
+
488
+ EventEmitter.prototype.removeListener = EventEmitter.prototype.off;
489
+
490
+ EventEmitter.prototype.removeAllListeners = function(type) {
491
+ if (arguments.length === 0) {
492
+ !this._events || init.call(this);
493
+ return this;
494
+ }
495
+
496
+ if(this.wildcard) {
497
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
498
+ var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
499
+
500
+ for (var iLeaf=0; iLeaf<leafs.length; iLeaf++) {
501
+ var leaf = leafs[iLeaf];
502
+ leaf._listeners = null;
503
+ }
504
+ }
505
+ else {
506
+ if (!this._events[type]) return this;
507
+ this._events[type] = null;
508
+ }
509
+ return this;
510
+ };
511
+
512
+ EventEmitter.prototype.listeners = function(type) {
513
+ if(this.wildcard) {
514
+ var handlers = [];
515
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
516
+ searchListenerTree.call(this, handlers, ns, this.listenerTree, 0);
517
+ return handlers;
518
+ }
519
+
520
+ this._events || init.call(this);
521
+
522
+ if (!this._events[type]) this._events[type] = [];
523
+ if (!isArray(this._events[type])) {
524
+ this._events[type] = [this._events[type]];
525
+ }
526
+ return this._events[type];
527
+ };
528
+
529
+ EventEmitter.prototype.listenersAny = function() {
530
+
531
+ if(this._all) {
532
+ return this._all;
533
+ }
534
+ else {
535
+ return [];
536
+ }
537
+
538
+ };
539
+
540
+ if (typeof define === 'function' && define.amd) {
541
+ define('eventemitter2',[],function() {
542
+ return EventEmitter;
543
+ });
544
+ } else {
545
+ exports.EventEmitter2 = EventEmitter;
546
+ }
547
+
548
+ }(typeof process !== 'undefined' && typeof process.title !== 'undefined' && typeof exports !== 'undefined' ? exports : window);
549
+
550
+
551
+ /*global define:true EventEmitter2:true */
552
+
553
+
554
+
555
+ define('react/eventemitter',['eventemitter2'], function (EventEmitterMod) {
556
+
557
+ /**
558
+ Abstract the details of getting an EventEmitter
559
+ */
560
+
561
+ // EventEmitter doesn't return itself in browser so need to get the global
562
+ // EventEmitter api changed, so accomodate which ever version is available
563
+ var EventEmitter = (EventEmitterMod) ?
564
+ ((EventEmitterMod.EventEmitter2) ? EventEmitterMod.EventEmitter2 : EventEmitterMod) : EventEmitter2;
565
+ return EventEmitter;
566
+
567
+ });
568
+ /*global define:true */
569
+
570
+
571
+
572
+ // Copyright Joyent, Inc. and other Node contributors.
573
+ //
574
+ // Permission is hereby granted, free of charge, to any person obtaining a
575
+ // copy of this software and associated documentation files (the
576
+ // "Software"), to deal in the Software without restriction, including
577
+ // without limitation the rights to use, copy, modify, merge, publish,
578
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
579
+ // persons to whom the Software is furnished to do so, subject to the
580
+ // following conditions:
581
+ //
582
+ // The above copyright notice and this permission notice shall be included
583
+ // in all copies or substantial portions of the Software.
584
+ //
585
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
586
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
587
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
588
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
589
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
590
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
591
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
592
+
593
+ define('util',['require','exports','module'],function (require, exports, module) {
594
+ /*jshint white:false */
595
+
596
+ var formatRegExp = /%[sdj%]/g;
597
+ exports.format = function(f) {
598
+ if (typeof f !== 'string') {
599
+ var objects = [];
600
+ for (var j = 0; j < arguments.length; j++) {
601
+ objects.push(inspect(arguments[j]));
602
+ }
603
+ return objects.join(' ');
604
+ }
605
+
606
+ var i = 1;
607
+ var args = arguments;
608
+ var len = args.length;
609
+ var str = String(f).replace(formatRegExp, function(x) {
610
+ if (x === '%%') return '%';
611
+ if (i >= len) return x;
612
+ switch (x) {
613
+ case '%s': return String(args[i++]);
614
+ case '%d': return Number(args[i++]);
615
+ case '%j': return JSON.stringify(args[i++]);
616
+ default:
617
+ return x;
618
+ }
619
+ });
620
+ for (var x = args[i]; i < len; x = args[++i]) {
621
+ if (x === null || typeof x !== 'object') {
622
+ str += ' ' + x;
623
+ } else {
624
+ str += ' ' + inspect(x);
625
+ }
626
+ }
627
+ return str;
628
+ };
629
+
630
+
631
+ exports.print = function() {
632
+ for (var i = 0, len = arguments.length; i < len; ++i) {
633
+ process.stdout.write(String(arguments[i]));
634
+ }
635
+ };
636
+
637
+
638
+ exports.puts = function() {
639
+ for (var i = 0, len = arguments.length; i < len; ++i) {
640
+ process.stdout.write(arguments[i] + '\n');
641
+ }
642
+ };
643
+
644
+
645
+ exports.debug = function(x) {
646
+ process.stderr.write('DEBUG: ' + x + '\n');
647
+ };
648
+
649
+
650
+ var error = exports.error = function(x) {
651
+ for (var i = 0, len = arguments.length; i < len; ++i) {
652
+ process.stderr.write(arguments[i] + '\n');
653
+ }
654
+ };
655
+
656
+
657
+ /**
658
+ * Echos the value of a value. Trys to print the value out
659
+ * in the best way possible given the different types.
660
+ *
661
+ * @param {Object} obj The object to print out.
662
+ * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
663
+ * properties of objects.
664
+ * @param {Number} depth Depth in which to descend in object. Default is 2.
665
+ * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
666
+ * output. Default is false (no coloring).
667
+ */
668
+ function inspect(obj, showHidden, depth, colors) {
669
+ var ctx = {
670
+ showHidden: showHidden,
671
+ seen: [],
672
+ stylize: colors ? stylizeWithColor : stylizeNoColor
673
+ };
674
+ return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
675
+ }
676
+ exports.inspect = inspect;
677
+
678
+
679
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
680
+ var colors = {
681
+ 'bold' : [1, 22],
682
+ 'italic' : [3, 23],
683
+ 'underline' : [4, 24],
684
+ 'inverse' : [7, 27],
685
+ 'white' : [37, 39],
686
+ 'grey' : [90, 39],
687
+ 'black' : [30, 39],
688
+ 'blue' : [34, 39],
689
+ 'cyan' : [36, 39],
690
+ 'green' : [32, 39],
691
+ 'magenta' : [35, 39],
692
+ 'red' : [31, 39],
693
+ 'yellow' : [33, 39]
694
+ };
695
+
696
+ // Don't use 'blue' not visible on cmd.exe
697
+ var styles = {
698
+ 'special': 'cyan',
699
+ 'number': 'yellow',
700
+ 'boolean': 'yellow',
701
+ 'undefined': 'grey',
702
+ 'null': 'bold',
703
+ 'string': 'green',
704
+ 'date': 'magenta',
705
+ // "name": intentionally not styling
706
+ 'regexp': 'red'
707
+ };
708
+
709
+
710
+ function stylizeWithColor(str, styleType) {
711
+ var style = styles[styleType];
712
+
713
+ if (style) {
714
+ return '\033[' + colors[style][0] + 'm' + str +
715
+ '\033[' + colors[style][1] + 'm';
716
+ } else {
717
+ return str;
718
+ }
719
+ }
720
+
721
+
722
+ function stylizeNoColor(str, styleType) {
723
+ return str;
724
+ }
725
+
726
+
727
+ function formatValue(ctx, value, recurseTimes) {
728
+ // Provide a hook for user-specified inspect functions.
729
+ // Check that value is an object with an inspect function on it
730
+ if (value && typeof value.inspect === 'function' &&
731
+ // Filter out the util module, it's inspect function is special
732
+ value.inspect !== exports.inspect &&
733
+ // Also filter out any prototype objects using the circular check.
734
+ !(value.constructor && value.constructor.prototype === value)) {
735
+ return value.inspect(recurseTimes);
736
+ }
737
+
738
+ // Primitive types cannot have properties
739
+ var primitive = formatPrimitive(ctx, value);
740
+ if (primitive) {
741
+ return primitive;
742
+ }
743
+
744
+ // Look up the keys of the object.
745
+ var visibleKeys = Object.keys(value);
746
+ var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
747
+
748
+ // Some type of object without properties can be shortcutted.
749
+ if (keys.length === 0) {
750
+ if (typeof value === 'function') {
751
+ var name = value.name ? ': ' + value.name : '';
752
+ return ctx.stylize('[Function' + name + ']', 'special');
753
+ }
754
+ if (isRegExp(value)) {
755
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
756
+ }
757
+ if (isDate(value)) {
758
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
759
+ }
760
+ if (isError(value)) {
761
+ return formatError(value);
762
+ }
763
+ }
764
+
765
+ var base = '', array = false, braces = ['{', '}'];
766
+
767
+ // Make Array say that they are Array
768
+ if (isArray(value)) {
769
+ array = true;
770
+ braces = ['[', ']'];
771
+ }
772
+
773
+ // Make functions say that they are functions
774
+ if (typeof value === 'function') {
775
+ var n = value.name ? ': ' + value.name : '';
776
+ base = ' [Function' + n + ']';
777
+ }
778
+
779
+ // Make RegExps say that they are RegExps
780
+ if (isRegExp(value)) {
781
+ base = ' ' + RegExp.prototype.toString.call(value);
782
+ }
783
+
784
+ // Make dates with properties first say the date
785
+ if (isDate(value)) {
786
+ base = ' ' + Date.prototype.toUTCString.call(value);
787
+ }
788
+
789
+ // Make error with message first say the error
790
+ if (isError(value)) {
791
+ base = ' ' + formatError(value);
792
+ }
793
+
794
+ if (keys.length === 0 && (!array || value.length === 0)) {
795
+ return braces[0] + base + braces[1];
796
+ }
797
+
798
+ if (recurseTimes < 0) {
799
+ if (isRegExp(value)) {
800
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
801
+ } else {
802
+ return ctx.stylize('[Object]', 'special');
803
+ }
804
+ }
805
+
806
+ ctx.seen.push(value);
807
+
808
+ var output;
809
+ if (array) {
810
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
811
+ } else {
812
+ output = keys.map(function(key) {
813
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
814
+ });
815
+ }
816
+
817
+ ctx.seen.pop();
818
+
819
+ return reduceToSingleString(output, base, braces);
820
+ }
821
+
822
+
823
+ function formatPrimitive(ctx, value) {
824
+ switch (typeof value) {
825
+ case 'undefined':
826
+ return ctx.stylize('undefined', 'undefined');
827
+
828
+ case 'string':
829
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
830
+ .replace(/'/g, "\\'")
831
+ .replace(/\\"/g, '"') + '\'';
832
+ return ctx.stylize(simple, 'string');
833
+
834
+ case 'number':
835
+ return ctx.stylize('' + value, 'number');
836
+
837
+ case 'boolean':
838
+ return ctx.stylize('' + value, 'boolean');
839
+ }
840
+ // For some reason typeof null is "object", so special case here.
841
+ if (value === null) {
842
+ return ctx.stylize('null', 'null');
843
+ }
844
+ }
845
+
846
+
847
+ function formatError(value) {
848
+ return '[' + Error.prototype.toString.call(value) + ']';
849
+ }
850
+
851
+
852
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
853
+ var output = [];
854
+ for (var i = 0, l = value.length; i < l; ++i) {
855
+ if (Object.prototype.hasOwnProperty.call(value, String(i))) {
856
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
857
+ String(i), true));
858
+ } else {
859
+ output.push('');
860
+ }
861
+ }
862
+ keys.forEach(function(key) {
863
+ if (!key.match(/^\d+$/)) {
864
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
865
+ key, true));
866
+ }
867
+ });
868
+ return output;
869
+ }
870
+
871
+
872
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
873
+ var name, str, desc;
874
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
875
+ if (desc.get) {
876
+ if (desc.set) {
877
+ str = ctx.stylize('[Getter/Setter]', 'special');
878
+ } else {
879
+ str = ctx.stylize('[Getter]', 'special');
880
+ }
881
+ } else {
882
+ if (desc.set) {
883
+ str = ctx.stylize('[Setter]', 'special');
884
+ }
885
+ }
886
+ if (visibleKeys.indexOf(key) < 0) {
887
+ name = '[' + key + ']';
888
+ }
889
+ if (!str) {
890
+ if (ctx.seen.indexOf(desc.value) < 0) {
891
+ if (recurseTimes === null) {
892
+ str = formatValue(ctx, desc.value, null);
893
+ } else {
894
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
895
+ }
896
+ if (str.indexOf('\n') > -1) {
897
+ if (array) {
898
+ str = str.split('\n').map(function(line) {
899
+ return ' ' + line;
900
+ }).join('\n').substr(2);
901
+ } else {
902
+ str = '\n' + str.split('\n').map(function(line) {
903
+ return ' ' + line;
904
+ }).join('\n');
905
+ }
906
+ }
907
+ } else {
908
+ str = ctx.stylize('[Circular]', 'special');
909
+ }
910
+ }
911
+ if (typeof name === 'undefined') {
912
+ if (array && key.match(/^\d+$/)) {
913
+ return str;
914
+ }
915
+ name = JSON.stringify('' + key);
916
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
917
+ name = name.substr(1, name.length - 2);
918
+ name = ctx.stylize(name, 'name');
919
+ } else {
920
+ name = name.replace(/'/g, "\\'")
921
+ .replace(/\\"/g, '"')
922
+ .replace(/(^"|"$)/g, "'");
923
+ name = ctx.stylize(name, 'string');
924
+ }
925
+ }
926
+
927
+ return name + ': ' + str;
928
+ }
929
+
930
+
931
+ function reduceToSingleString(output, base, braces) {
932
+ var numLinesEst = 0;
933
+ var length = output.reduce(function(prev, cur) {
934
+ numLinesEst++;
935
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
936
+ return prev + cur.length + 1;
937
+ }, 0);
938
+
939
+ if (length > 60) {
940
+ return braces[0] +
941
+ (base === '' ? '' : base + '\n ') +
942
+ ' ' +
943
+ output.join(',\n ') +
944
+ ' ' +
945
+ braces[1];
946
+ }
947
+
948
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
949
+ }
950
+
951
+
952
+ // NOTE: These type checking functions intentionally don't use `instanceof`
953
+ // because it is fragile and can be easily faked with `Object.create()`.
954
+ function isArray(ar) {
955
+ return Array.isArray(ar) ||
956
+ (typeof ar === 'object' && objectToString(ar) === '[object Array]');
957
+ }
958
+ exports.isArray = isArray;
959
+
960
+
961
+ function isRegExp(re) {
962
+ return typeof re === 'object' && objectToString(re) === '[object RegExp]';
963
+ }
964
+ exports.isRegExp = isRegExp;
965
+
966
+
967
+ function isDate(d) {
968
+ return typeof d === 'object' && objectToString(d) === '[object Date]';
969
+ }
970
+ exports.isDate = isDate;
971
+
972
+
973
+ function isError(e) {
974
+ return typeof e === 'object' && objectToString(e) === '[object Error]';
975
+ }
976
+ exports.isError = isError;
977
+
978
+
979
+ function objectToString(o) {
980
+ return Object.prototype.toString.call(o);
981
+ }
982
+
983
+
984
+ // exports.p = function() {
985
+ // for (var i = 0, len = arguments.length; i < len; ++i) {
986
+ // error(exports.inspect(arguments[i]));
987
+ // }
988
+ // };
989
+ // module.deprecate('p', 'Use `util.puts(util.inspect())` instead.');
990
+
991
+
992
+ function pad(n) {
993
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
994
+ }
995
+
996
+
997
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
998
+ 'Oct', 'Nov', 'Dec'];
999
+
1000
+ // 26 Feb 16:19:34
1001
+ function timestamp() {
1002
+ var d = new Date();
1003
+ var time = [pad(d.getHours()),
1004
+ pad(d.getMinutes()),
1005
+ pad(d.getSeconds())].join(':');
1006
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
1007
+ }
1008
+
1009
+
1010
+ exports.log = function(msg) {
1011
+ exports.puts(timestamp() + ' - ' + msg.toString());
1012
+ };
1013
+
1014
+
1015
+ // exports.exec = function() {
1016
+ // return require('child_process').exec.apply(this, arguments);
1017
+ // };
1018
+ // module.deprecate('exec', 'It is now called `child_process.exec`.');
1019
+
1020
+
1021
+ exports.pump = function(readStream, writeStream, callback) {
1022
+ var callbackCalled = false;
1023
+
1024
+ function call(a, b, c) {
1025
+ if (callback && !callbackCalled) {
1026
+ callback(a, b, c);
1027
+ callbackCalled = true;
1028
+ }
1029
+ }
1030
+
1031
+ readStream.addListener('data', function(chunk) {
1032
+ if (writeStream.write(chunk) === false) readStream.pause();
1033
+ });
1034
+
1035
+ writeStream.addListener('drain', function() {
1036
+ readStream.resume();
1037
+ });
1038
+
1039
+ readStream.addListener('end', function() {
1040
+ writeStream.end();
1041
+ });
1042
+
1043
+ readStream.addListener('close', function() {
1044
+ call();
1045
+ });
1046
+
1047
+ readStream.addListener('error', function(err) {
1048
+ writeStream.end();
1049
+ call(err);
1050
+ });
1051
+
1052
+ writeStream.addListener('error', function(err) {
1053
+ readStream.destroy();
1054
+ call(err);
1055
+ });
1056
+ };
1057
+
1058
+
1059
+ /**
1060
+ * Inherit the prototype methods from one constructor into another.
1061
+ *
1062
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
1063
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
1064
+ * during bootstrapping this function needs to be rewritten using some native
1065
+ * functions as prototype setup using normal JavaScript does not work as
1066
+ * expected during bootstrapping (see mirror.js in r114903).
1067
+ *
1068
+ * @param {function} ctor Constructor function which needs to inherit the
1069
+ * prototype.
1070
+ * @param {function} superCtor Constructor function to inherit prototype from.
1071
+ */
1072
+ exports.inherits = function(ctor, superCtor) {
1073
+ ctor.super_ = superCtor;
1074
+ ctor.prototype = Object.create(superCtor.prototype, {
1075
+ constructor: {
1076
+ value: ctor,
1077
+ enumerable: false,
1078
+ writable: true,
1079
+ configurable: true
1080
+ }
1081
+ });
1082
+ };
1083
+
1084
+ exports._extend = function(origin, add) {
1085
+ // Don't do anything if add isn't an object
1086
+ if (!add) return origin;
1087
+
1088
+ var keys = Object.keys(add);
1089
+ var i = keys.length;
1090
+ while (i--) {
1091
+ origin[keys[i]] = add[keys[i]];
1092
+ }
1093
+ return origin;
1094
+ };
1095
+
1096
+ });
1097
+
1098
+ /*global define:true */
1099
+
1100
+
1101
+
1102
+ define('react/error',['util'], function (util) {
1103
+
1104
+ function ensureStackTraceLimitSet(stackTraceLimit) {
1105
+ if (!Error.stackTraceLimit || Error.stackTraceLimit < stackTraceLimit) {
1106
+ Error.stackTraceLimit = stackTraceLimit;
1107
+ }
1108
+ }
1109
+
1110
+ function fName(fn) {
1111
+ if (!fn) return 'undefined';
1112
+ return (fn && fn.name) ? fn.name : fn;
1113
+ }
1114
+
1115
+ function formatErrorMeta(err) {
1116
+ if (!err.meta) return;
1117
+ var vcon = err.meta.vcon;
1118
+ var task = err.meta.task;
1119
+ var errString = '\n\n';
1120
+ if (task && task.f && task.a) {
1121
+ errString += ('Error occurs in Task function: ' + fName(task.f) + '(' + task.a.join(',') + ')\n\n');
1122
+ }
1123
+ if (vcon) {
1124
+ errString += 'Variable Context: \n';
1125
+ errString += util.inspect(vcon);
1126
+ errString += '\n\n';
1127
+ }
1128
+ if (task && task.f) {
1129
+ errString += 'Task Source:\n\n';
1130
+ errString += task.f.toString(); //TODO need to pretty print function, gets collapsed
1131
+ errString += '\n\n';
1132
+ }
1133
+ return errString;
1134
+ }
1135
+
1136
+ function augmentError(err, meta) {
1137
+ if (typeof(err) === 'string') { err = new Error(err); } //props will be lost on non-objects
1138
+ var origMsg = err.toString();
1139
+ err.meta = meta;
1140
+ err.toString = function () { return origMsg + formatErrorMeta(err); };
1141
+ return err;
1142
+ }
1143
+
1144
+ return {
1145
+ ensureStackTraceLimitSet: ensureStackTraceLimitSet,
1146
+ augmentError: augmentError
1147
+ };
1148
+
1149
+ });
1150
+ (function (root, factory) {
1151
+ /*global define:true */
1152
+
1153
+ if (typeof exports === 'object') {
1154
+ // Node. Does not work with strict CommonJS, but
1155
+ // only CommonJS-like enviroments that support module.exports,
1156
+ // like Node.
1157
+ module.exports = factory();
1158
+ } else if (typeof define === 'function' && define.amd) {
1159
+ // AMD. Register as an anonymous module.
1160
+ define('ensure-array',[], factory);
1161
+ } else {
1162
+ // Browser globals
1163
+ root.ensureArray = factory();
1164
+ }
1165
+ }(this, function () {
1166
+
1167
+
1168
+ function ensureArray(a, b, n) {
1169
+ if (arguments.length === 0) return []; //no args, ret []
1170
+ if (arguments.length === 1) { //single argument
1171
+ if (a === undefined || a === null) return []; // undefined or null, ret []
1172
+ if (Array.isArray(a)) return a; // isArray, return it
1173
+ }
1174
+ return Array.prototype.slice.call(arguments); //return array with copy of all arguments
1175
+ }
1176
+
1177
+ return ensureArray;
1178
+ }));
1179
+
1180
+
1181
+
1182
+ /*global define:true */
1183
+
1184
+
1185
+
1186
+ define('react/status',[], function () {
1187
+
1188
+ var STATUS = { READY: 'ready', RUNNING: 'running', ERRORED: 'errored', COMPLETE: 'complete' };
1189
+
1190
+ return STATUS;
1191
+
1192
+ });
1193
+
1194
+ /*global define:true */
1195
+
1196
+
1197
+
1198
+ define('react/vcon',[], function () {
1199
+
1200
+ var LAST_RESULTS_KEY = ':LAST_RESULTS';
1201
+
1202
+ function VContext() {
1203
+ }
1204
+
1205
+ VContext.prototype.getLastResults = function () { return this.getVar(LAST_RESULTS_KEY); };
1206
+ VContext.prototype.setLastResults = function (args) { this.setVar(LAST_RESULTS_KEY, args); };
1207
+
1208
+ VContext.prototype.getVar = function (name) { //name might be simple or obj.prop, also literals
1209
+ /*jshint regexp: false */
1210
+ var vConValues = this.values;
1211
+ if (typeof(name) !== 'string') return name; // literal boolean or number
1212
+ name = name.trim();
1213
+ // literal checks need to match what is in validate.js
1214
+ if (name === 'true') return true;
1215
+ if (name === 'false') return false;
1216
+ if (name === 'null') return null;
1217
+ if (/^-?[0-9]+$/.test(name)) return parseInt(name, 10); //int
1218
+ if (/^-?[0-9.]+$/.test(name)) return parseFloat(name); //float
1219
+ var m = /^("|')([^\1]*)\1$/.exec(name); //check for quoted string " or '
1220
+ if (m) return m[2]; // if is quoted str, return inside of the quotes
1221
+ var nameAndProps = name.split('.');
1222
+ return nameAndProps.reduce(function (accObj, prop) {
1223
+ if (accObj === undefined || accObj === null) return undefined; // prevent exception
1224
+ return accObj[prop];
1225
+ }, vConValues); // vCon['foo']['bar']
1226
+ };
1227
+
1228
+ /**
1229
+ Saves all the results from a task as a unit, also sets special
1230
+ variable :LAST_RESULTS which keeps an array of the last values
1231
+ which can be used for chaining and testing last results, etc.
1232
+ */
1233
+ VContext.prototype.saveResults = function (paramArr, valuesArr) { // set values for params
1234
+ var self = this;
1235
+ paramArr.forEach(function (k, idx) { //save values to v context
1236
+ self.setVar(k, (valuesArr[idx] !== undefined) ? valuesArr[idx] : null); //upgrade any undefined to null
1237
+ });
1238
+ this.setLastResults(valuesArr);
1239
+ };
1240
+
1241
+ VContext.prototype.setVar = function (name, value) { //name might be simple or obj.prop
1242
+ if (!name) return; // if name is undefined or null, then discard
1243
+ var vConValues = this.values;
1244
+ var nameAndProps = name.split('.');
1245
+ var lastProp = nameAndProps.pop();
1246
+ var obj = nameAndProps.reduce(function (accObj, prop) {
1247
+ var o = accObj[prop];
1248
+ if (o === undefined || o === null) { // if doesn't exist create it
1249
+ o = accObj[prop] = { };
1250
+ }
1251
+ return o;
1252
+ }, vConValues); // vCon['foo']['bar']
1253
+ obj[lastProp] = value;
1254
+ };
1255
+
1256
+
1257
+ /**
1258
+ Create Variable Context using arguments passed in.
1259
+ Ignore extra arguments passed in. Locals can be
1260
+ passed into seed the VContext otherwise empty {}
1261
+ will be used
1262
+ @param self used to pass 'this' context in
1263
+ */
1264
+ VContext.create = function (args, inParams, locals, self) {
1265
+ var initValues = {};
1266
+ if (self) initValues['this'] = self;
1267
+ if (locals) Object.keys(locals).forEach(function (k) { initValues[k] = locals[k]; }); // copy over keys
1268
+ var vContext = new VContext();
1269
+ vContext.values = args.reduce(function (vcon, x, idx) { // create vCon start with input args
1270
+ var param = inParams[idx];
1271
+ if (param) vcon[param] = (x !== undefined) ? x : null; // upgrade undefined to null
1272
+ return vcon;
1273
+ }, initValues);
1274
+ return vContext;
1275
+ };
1276
+
1277
+
1278
+ return VContext;
1279
+
1280
+ });
1281
+
1282
+ /*global define:true process:false*/
1283
+
1284
+
1285
+
1286
+ define('react/event-manager',['./eventemitter'], function (EventEmitter) {
1287
+
1288
+ var EVENT_EMITTER2_CONFIG = {
1289
+ wildcard: true, // should the event emitter use wildcards.
1290
+ delimiter: '.', // the delimiter used to segment namespaces, defaults to `.`.
1291
+ maxListeners: 30 // the max number of listeners that can be assigned to an event, defaults to 10.
1292
+ };
1293
+
1294
+ var PASS_EVENTS_PROCESS_RE = /^ast.defined$/; // events to pass up to global process
1295
+
1296
+ var TYPES = {
1297
+ // Flow monitoring events and their params
1298
+ AST_DEFINED: 'ast.defined', // ast
1299
+ FLOW_BEGIN: 'flow.begin', // env
1300
+ TASK_BEGIN: 'task.begin', // task
1301
+ TASK_COMPLETE: 'task.complete', // task
1302
+ TASK_ERRORED: 'task.errored', // task
1303
+ FLOW_COMPLETE: 'flow.complete', // env
1304
+ FLOW_ERRORED: 'flow.errored', // env
1305
+
1306
+ // Internal Hooks
1307
+ EXEC_FLOW_START: 'exec.flow.start', // env
1308
+ EXEC_INPUT_PREPROCESS: 'exec.input.preprocess', // parsedInput
1309
+ EXEC_TASKS_PRECREATE: 'exec.tasks.precreate', // env
1310
+ EXEC_OUTTASK_CREATE: 'exec.outTask.create', // outTaskOptions
1311
+ EXEC_TASK_START: 'exec.task.start', // task
1312
+ EXEC_TASK_COMPLETE: 'exec.task.complete', // task
1313
+ EXEC_TASK_ERRORED: 'exec.task.errored', // task
1314
+ EXEC_FLOW_COMPLETE: 'exec.flow.complete', // env
1315
+ EXEC_FLOW_ERRORED: 'exec.flow.errored' // env
1316
+ };
1317
+
1318
+ /**
1319
+ Event manager which emits events up to its parent if exists.
1320
+ Allows a hierarchy of emitters, which communicate up the
1321
+ chain.
1322
+ */
1323
+ function EventManager() {
1324
+ }
1325
+
1326
+ EventManager.create = function () { return new EventManager(); };
1327
+
1328
+ EventManager.TYPES = TYPES;
1329
+ EventManager.prototype.TYPES = TYPES;
1330
+
1331
+ EventManager.prototype.isEnabled = function () { // if has listener or an ancestor has listener
1332
+ return !!(this.emitter || (this.parent && this.parent.isEnabled()));
1333
+ };
1334
+
1335
+ /**
1336
+ Add listener. Wildcard events are allowed like 'foo.*'
1337
+ Use '*' to listen to any event
1338
+ */
1339
+ EventManager.prototype.on = function (event, listener) {
1340
+ if (!this.emitter) this.emitter = new EventEmitter(EVENT_EMITTER2_CONFIG);
1341
+ if (event === '*') this.emitter.onAny(listener);
1342
+ else this.emitter.on(event, listener);
1343
+ };
1344
+
1345
+ EventManager.prototype.emit = function (event, arg1, arg2, argN) {
1346
+ if (event === undefined) throw new Error('event is undefined');
1347
+ if (this.emitter) this.emitter.emit.apply(this.emitter, arguments);
1348
+ if (this.parent && this.parent.isEnabled()) this.parent.emit.apply(this.parent, arguments);
1349
+ if (PASS_EVENTS_PROCESS_RE.test(event) && process && process.emit) process.emit.apply(process, arguments); // pass some to process
1350
+ };
1351
+
1352
+ EventManager.prototype.removeListener = function (event, listener) {
1353
+ if (this.emitter) this.emitter.removeListener.apply(this.emitter, arguments);
1354
+ };
1355
+
1356
+
1357
+ EventManager.global = EventManager.create(); // create one top level emitter
1358
+ return EventManager;
1359
+
1360
+ });
1361
+
1362
+ /*global define:true */
1363
+
1364
+
1365
+
1366
+ define('react/base-task',['ensure-array', './status', './event-manager'],
1367
+ function (array, STATUS, EventManager) {
1368
+
1369
+ function BaseTask() {
1370
+ }
1371
+
1372
+ /**
1373
+ Getter Fn to retrieveAn array of the output param names for this task.
1374
+ */
1375
+ BaseTask.prototype.getOutParams = function () {
1376
+ return array(this.out); // ensure array
1377
+ };
1378
+
1379
+ BaseTask.prototype.isComplete = function () {
1380
+ return (this.status === STATUS.COMPLETE);
1381
+ };
1382
+
1383
+ BaseTask.prototype.start = function (args) { // mark task as started with args and note time
1384
+ /*jshint validthis: true */
1385
+ this.args = args;
1386
+ this.env.currentTask = this;
1387
+ this.env.flowEmitter.emit(EventManager.TYPES.EXEC_TASK_START, this);
1388
+ };
1389
+
1390
+ BaseTask.prototype.complete = function (args) { //args that were used are available
1391
+ /*jshint validthis: true */
1392
+ this.status = STATUS.COMPLETE;
1393
+ this.results = args;
1394
+ this.env.currentTask = this;
1395
+ this.env.flowEmitter.emit(EventManager.TYPES.EXEC_TASK_COMPLETE, this);
1396
+ };
1397
+
1398
+ BaseTask.prototype.functionExists = function (vCon) {
1399
+ var fn = this.f;
1400
+ if (!fn) return false;
1401
+ if (fn instanceof Function) return true;
1402
+ if (typeof(fn) === 'string') {
1403
+ var f = vCon.getVar(fn); // fn/method by string
1404
+ if (f && f instanceof Function) return true;
1405
+ }
1406
+ return false;
1407
+ };
1408
+
1409
+ BaseTask.prototype.areAllDepArgsDefined = function (vCon) {
1410
+ return this.a.every(function (k) { return (vCon.getVar(k) !== undefined); });
1411
+ };
1412
+
1413
+ BaseTask.prototype.depTasksAreDone = function (tasksByName) {
1414
+ return (!this.after || !this.after.length || // no dep tasks OR
1415
+ this.after.every(function (n) { return tasksByName[n].isComplete(); })); //all done
1416
+ };
1417
+
1418
+ function isObjProperty(str) { return (str.indexOf('.') !== -1); }
1419
+
1420
+ /**
1421
+ check that obj parent is def and not null so writing to obj.prop
1422
+ will not fail. ex: 'b.c' checks that b is def and not null.
1423
+ Also returns true if not obj.prop but simple var ex: 'b'.
1424
+ Tasks will implement outParentsExist() passing each out str
1425
+ to this if they want to do this check.
1426
+ */
1427
+ BaseTask.prototype.parentExists = function (objPropStr, vCon) {
1428
+ if (!isObjProperty(objPropStr)) return true; // NOT obj prop, just simple arg, ret true
1429
+ var nameAndProps = objPropStr.split('.');
1430
+ nameAndProps.pop(); // pop off final prop
1431
+ var parent = nameAndProps.reduce(function (accObj, prop) {
1432
+ if (accObj === undefined || accObj === null) return undefined; // prevent exception
1433
+ return accObj[prop];
1434
+ }, vCon.values); // vCon['foo']['bar']
1435
+ return (parent !== undefined && parent !== null);
1436
+ };
1437
+
1438
+ /**
1439
+ If params are obj property writes make sure the dst objects
1440
+ are defined and not null. cb: ['b.c'] -> b is def and not null.
1441
+ If null is specified then param is valid and will be ignored.
1442
+ @returns true if all obj prop parents are def and non null
1443
+ */
1444
+ BaseTask.prototype.outParentsExist = function (vCon) {
1445
+ var self = this;
1446
+ return this.getOutParams().every(function (x) {
1447
+ if (x === null) return true;
1448
+ return self.parentExists(x, vCon);
1449
+ });
1450
+ };
1451
+
1452
+ BaseTask.prototype.isReady = function (vCon, tasksByName) {
1453
+ return !this.status && // not started AND
1454
+ this.functionExists(vCon) && // function/method exists AND
1455
+ this.areAllDepArgsDefined(vCon) && // all dep vars defined AND
1456
+ this.depTasksAreDone(tasksByName) && // all dep tasks are done AND
1457
+ (!this.outParentsExist || // (task does not implement outParentsExist method OR
1458
+ this.outParentsExist(vCon)); // output parents exists (for obj property writes)
1459
+ };
1460
+
1461
+ BaseTask.prototype.isMethodCall = function () {
1462
+ /*jshint regexp: false */
1463
+ return (typeof(this.f) === 'string' && /^.*\..*$/.test(this.f)); //str contains .
1464
+ };
1465
+
1466
+ BaseTask.prototype.getMethodObj = function (vCon) { //obj.prop.prop2, returns obj.prop or undefined
1467
+ var name = this.f;
1468
+ if (!name) return undefined;
1469
+ var nameAndProps = name.split('.');
1470
+ nameAndProps.pop(); // pop off last one
1471
+ if (!nameAndProps.length) return undefined;
1472
+ var result = nameAndProps.reduce(function (accObj, prop) {
1473
+ if (accObj === undefined || accObj === null) return undefined; // prevent exception
1474
+ return accObj[prop];
1475
+ }, vCon.values); // vCon['foo']['bar']
1476
+ return result;
1477
+ };
1478
+
1479
+ return BaseTask;
1480
+
1481
+ });
1482
+
1483
+ /*global define:true */
1484
+
1485
+
1486
+
1487
+ define('react/input-parser',['./event-manager'], function (EventManager) {
1488
+
1489
+ var defaultExecOptions = {
1490
+ reactExecOptions: true,
1491
+ outputStyle: 'cb',
1492
+ };
1493
+
1494
+ var OUTPUT_STYLES = {
1495
+ CALLBACK: 'cb',
1496
+ NONE: 'none'
1497
+ };
1498
+
1499
+ function isExecOptions(x) { return (x && x.reactExecOptions); }
1500
+ function execOptionsFilter(x) { return isExecOptions(x); }
1501
+ function nonExecOptionsFilter(x) { return !isExecOptions(x); }
1502
+ function mergeExecOptions(accum, options) {
1503
+ Object.keys(options).forEach(function (k) { accum[k] = options[k]; });
1504
+ return accum;
1505
+ }
1506
+
1507
+ function splitArgs(args, inParams, style) {
1508
+ var result = { };
1509
+ result.args = inParams.map(function (p) { return args.shift(); }); // take args for input params first
1510
+ if (style === OUTPUT_STYLES.CALLBACK && args.length) result.cb = args.shift(); // next take the cb
1511
+ result.extra = args; // these remaining were after the callback
1512
+ return result;
1513
+ }
1514
+
1515
+ function inputParser(inputArgs, ast) {
1516
+ var parsedInput = { };
1517
+ var execOptionsArr = inputArgs.filter(execOptionsFilter);
1518
+ execOptionsArr.unshift(defaultExecOptions);
1519
+ parsedInput.options = execOptionsArr.reduce(mergeExecOptions, {});
1520
+
1521
+ var args = inputArgs.filter(nonExecOptionsFilter);
1522
+ var splitResult = splitArgs(args, ast.inParams, parsedInput.options.outputStyle);
1523
+ parsedInput.args = splitResult.args;
1524
+ parsedInput.cb = splitResult.cb;
1525
+ if (splitResult.outputStyle) parsedInput.options.outputStyle = splitResult.outputStyle;
1526
+ if (splitResult.extra) parsedInput.extraArgs = splitResult.extra;
1527
+ EventManager.global.emit(EventManager.TYPES.EXEC_INPUT_PREPROCESS, parsedInput); // hook
1528
+ return parsedInput;
1529
+ }
1530
+
1531
+
1532
+ inputParser.defaultExecOptions = defaultExecOptions;
1533
+ return inputParser;
1534
+
1535
+ });
1536
+
1537
+ /*global define:true */
1538
+
1539
+
1540
+
1541
+ define('react/id',[], function () {
1542
+
1543
+ var startingId = 0;
1544
+
1545
+ function createUniqueId() {
1546
+ startingId += 1;
1547
+ if (startingId === Number.MAX_VALUE) startingId = 0; // if hits this start over //TODO need something better?
1548
+ return startingId;
1549
+ }
1550
+
1551
+ return {
1552
+ createUniqueId: createUniqueId
1553
+ };
1554
+
1555
+ });
1556
+ (function() {
1557
+ var errorMessage, format, intSizeTable, sprint, _ref,
1558
+ __slice = Array.prototype.slice,
1559
+ __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
1560
+
1561
+ format = /%(\d+[$])?((?:[+\x20\-#0])*)((?:[*](?:\d+[$])?)?v)?(\d*|[*](?:\d+[$])?)(?:[.](\d+|[*](?:\d+[$])?))?(hh?|ll?|[Lzjtq]|I(?:32|64)?)?([diuDUfFeEgGxXoOscpnbB])|%%/g;
1562
+
1563
+ errorMessage = "64-bit numbers aren't supported by sprint()!";
1564
+
1565
+ intSizeTable = {
1566
+ h: 2,
1567
+ hh: 1,
1568
+ l: 4,
1569
+ ll: new RangeError(errorMessage),
1570
+ L: 4,
1571
+ z: 4,
1572
+ j: 4,
1573
+ t: 4,
1574
+ I: 4,
1575
+ I32: 4,
1576
+ I64: new RangeError(errorMessage),
1577
+ q: new RangeError(errorMessage)
1578
+ };
1579
+
1580
+ sprint = function() {
1581
+ var arrayObjects, i, padString, string, toString, values, _ref;
1582
+ string = arguments[0], values = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
1583
+ arrayObjects = ['[object Array]', '[object Arguments]'];
1584
+ toString = Object.prototype.toString;
1585
+ if ((_ref = toString.call(values[0]), __indexOf.call(arrayObjects, _ref) >= 0) && values.length === 1) {
1586
+ values = values[0];
1587
+ }
1588
+ i = -1;
1589
+ padString = function(string, length, joiner, leftPad) {
1590
+ string = "" + string;
1591
+ if (string.length > length) {
1592
+ return string;
1593
+ } else if (leftPad) {
1594
+ return "" + string + (new Array(length - string.length + 1).join(joiner));
1595
+ } else {
1596
+ return "" + (new Array(length - string.length + 1).join(joiner)) + string;
1597
+ }
1598
+ };
1599
+ return ("" + string).replace(format, function() {
1600
+ var abs, alignCharacter, argument, character, defaultPrecision, flags, intSize, leftPad, length, letter, matches, padInteger, precision, prefix, result, special, string, toExponential, type, vector;
1601
+ string = arguments[0], matches = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
1602
+ argument = matches[0], flags = matches[1], vector = matches[2], length = matches[3], precision = matches[4], intSize = matches[5], type = matches[6];
1603
+ if (intSize == null) intSize = 'L';
1604
+ if (string === '%%') return '%';
1605
+ leftPad = __indexOf.call(flags, '-') >= 0;
1606
+ alignCharacter = __indexOf.call(flags, '0') >= 0 && !leftPad ? '0' : ' ';
1607
+ abs = function(int, signed) {
1608
+ var bits, entry, highValue;
1609
+ if (signed == null) signed = false;
1610
+ if (intSize === 'L' && (int >= 0 || signed)) return parseInt(int, 10);
1611
+ entry = intSizeTable[intSize];
1612
+ if (entry instanceof Error) throw entry;
1613
+ bits = entry * 8;
1614
+ int = parseInt(int, 10) % Math.pow(2, bits);
1615
+ highValue = Math.pow(2, bits) - 1;
1616
+ if (signed && int >= Math.pow(2, bits - 1)) int = -Math.pow(2, bits) + int;
1617
+ if (signed) {
1618
+ return int;
1619
+ } else {
1620
+ return int >>> 0;
1621
+ }
1622
+ };
1623
+ toExponential = function() {
1624
+ argument = (+argument).toExponential(precision);
1625
+ if (special && __indexOf.call(argument, '.') < 0) {
1626
+ argument = argument.replace('e', '.e');
1627
+ }
1628
+ return argument.toLowerCase().replace(/\d+$/, function(string) {
1629
+ return padString(string, 3, 0);
1630
+ });
1631
+ };
1632
+ padInteger = function(string) {
1633
+ if (+string === 0 && +precision === 0) {
1634
+ return '';
1635
+ } else if (defaultPrecision) {
1636
+ return string;
1637
+ } else {
1638
+ alignCharacter = ' ';
1639
+ return padString(string, precision, '0');
1640
+ }
1641
+ };
1642
+ if (vector) {
1643
+ character = vector[0] === '*' ? vector.length > 2 ? values[parseInt(vector.slice(1), 10) - 1] : values[++i] : '.';
1644
+ }
1645
+ length = length[0] === '*' ? length.length === 1 ? values[++i] : values[parseInt(length.slice(1)) - 1] : !length ? 0 : length;
1646
+ precision = precision && precision[0] === '*' ? precision.length === 1 ? values[++i] : values[parseInt(precision.slice(1), 10) - 1] : !precision ? (defaultPrecision = true, 6) : precision;
1647
+ argument = values[(parseInt(argument, 10) || ++i + 1) - 1];
1648
+ if (argument === 0) if (1 / argument === -Infinity) argument = '-0';
1649
+ argument = argument != null ? "" + argument : '';
1650
+ special = __indexOf.call(flags, '#') >= 0;
1651
+ arguments = (function() {
1652
+ var _i, _len, _results;
1653
+ if (vector) {
1654
+ _results = [];
1655
+ for (_i = 0, _len = argument.length; _i < _len; _i++) {
1656
+ letter = argument[_i];
1657
+ _results.push(letter.charCodeAt(0));
1658
+ }
1659
+ return _results;
1660
+ } else {
1661
+ return [argument];
1662
+ }
1663
+ })();
1664
+ result = (function() {
1665
+ var _i, _len, _results;
1666
+ _results = [];
1667
+ for (_i = 0, _len = arguments.length; _i < _len; _i++) {
1668
+ argument = arguments[_i];
1669
+ argument = (function() {
1670
+ var _ref2;
1671
+ switch (type) {
1672
+ case 'd':
1673
+ case 'i':
1674
+ case 'D':
1675
+ return padInteger(abs(argument, true));
1676
+ case 'u':
1677
+ case 'U':
1678
+ return padInteger(abs(argument));
1679
+ case 'f':
1680
+ case 'F':
1681
+ argument = (+argument).toFixed(precision).toLowerCase();
1682
+ if (special && __indexOf.call(argument, '.') < 0 && !/^-?[a-z]+$/.test(argument)) {
1683
+ argument += '.';
1684
+ }
1685
+ return argument;
1686
+ case 'e':
1687
+ case 'E':
1688
+ return toExponential();
1689
+ case 'g':
1690
+ case 'G':
1691
+ if (+argument === 0 || (0.0001 <= (_ref2 = Math.abs(argument)) && _ref2 < Math.pow(10, precision))) {
1692
+ argument = ("" + argument).substr(0, +precision + 1);
1693
+ if (special) {
1694
+ return argument.replace(/[.]?$/, '.');
1695
+ } else {
1696
+ return argument.replace(/[.]$/, '');
1697
+ }
1698
+ } else {
1699
+ return toExponential().replace(/[.]?0+e/, 'e');
1700
+ }
1701
+ break;
1702
+ case 'x':
1703
+ case 'X':
1704
+ prefix = special && +argument !== 0 ? '0x' : '';
1705
+ return "" + prefix + (padInteger(abs(argument).toString(16)));
1706
+ case 'b':
1707
+ case 'B':
1708
+ prefix = special && +argument !== 0 ? '0b' : '';
1709
+ return "" + prefix + (padInteger(abs(argument).toString(2)));
1710
+ case 'o':
1711
+ case 'O':
1712
+ prefix = special ? '0' : '';
1713
+ return "" + prefix + (padInteger(abs(argument).toString(8)));
1714
+ case 's':
1715
+ if (defaultPrecision) {
1716
+ return argument;
1717
+ } else {
1718
+ return argument.substr(0, precision);
1719
+ }
1720
+ break;
1721
+ case 'c':
1722
+ return String.fromCharCode(argument);
1723
+ default:
1724
+ throw new Exception("Unrecognized %type (?). Shouldn't happen.");
1725
+ }
1726
+ })();
1727
+ argument = "" + argument;
1728
+ if (type === type.toUpperCase()) argument = argument.toUpperCase();
1729
+ if (argument[0] !== '-') {
1730
+ if (__indexOf.call(flags, '+') >= 0) {
1731
+ argument = "+" + argument;
1732
+ } else if (__indexOf.call(flags, ' ') >= 0) {
1733
+ argument = " " + argument;
1734
+ }
1735
+ }
1736
+ _results.push(padString(argument, length, alignCharacter, leftPad));
1737
+ }
1738
+ return _results;
1739
+ }).apply(this, arguments);
1740
+ return result.join(character);
1741
+ });
1742
+ };
1743
+
1744
+ if ((typeof module !== "undefined" && module !== null ? module.exports : void 0) != null) {
1745
+ module.exports = sprint;
1746
+ }
1747
+
1748
+ ((_ref = typeof module !== "undefined" && module !== null ? module.exports : void 0) != null ? _ref : this).sprint = sprint;
1749
+
1750
+ }).call(this);
1751
+
1752
+ define("sprint", function(){});
1753
+
1754
+
1755
+ /*global define:true sprint:true */
1756
+
1757
+
1758
+
1759
+ define('react/sprintf',['sprint'], function (sprintfMod) {
1760
+
1761
+ /**
1762
+ Abstract the details of getting a sprintf function
1763
+ */
1764
+
1765
+ // Sprint doesn't return itself in browser so need to get the global
1766
+ var sprintf = (sprintfMod) ? sprintfMod : sprint;
1767
+ return sprintf;
1768
+
1769
+ });
1770
+
1771
+ /*global define:true */
1772
+
1773
+
1774
+
1775
+ define('react/cb-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
1776
+
1777
+ function format_error(errmsg, obj) {
1778
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
1779
+ }
1780
+
1781
+ var REQ = 'cbTask requires f, a, out';
1782
+ var FN_REQ = 'cbTask requires f to be a function or string';
1783
+ var A_REQ = 'cbTask requires a to be an array of string param names';
1784
+ var CB_REQ = 'cbTask requires out to be an array of string param names';
1785
+
1786
+ function CbTask(taskDef) {
1787
+ var self = this;
1788
+ Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
1789
+ }
1790
+
1791
+ CbTask.prototype = new BaseTask();
1792
+ CbTask.prototype.constructor = CbTask;
1793
+
1794
+ CbTask.validate = function (taskDef) {
1795
+ var errors = [];
1796
+ if (!taskDef.f || !taskDef.a || !taskDef.out) {
1797
+ errors.push(format_error(REQ, taskDef));
1798
+ } else {
1799
+ var ftype = typeof(taskDef.f);
1800
+ if (! ((taskDef.f instanceof Function) || (ftype === 'string'))) {
1801
+ errors.push(format_error(FN_REQ, taskDef));
1802
+ }
1803
+ if (! (Array.isArray(taskDef.a) &&
1804
+ taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
1805
+ errors.push(format_error(A_REQ, taskDef));
1806
+ }
1807
+ if (! (Array.isArray(taskDef.out) &&
1808
+ taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
1809
+ errors.push(format_error(CB_REQ, taskDef));
1810
+ }
1811
+ }
1812
+ return errors;
1813
+ };
1814
+
1815
+ CbTask.prototype.prepare = function prepare(handleTaskError, vCon, contExec) {
1816
+ var self = this;
1817
+ this.cbFun = function (err, arg0, arg1, argn) {
1818
+ var args = Array.prototype.slice.call(arguments, 1);
1819
+ if (err) { handleTaskError(self, err); return; } //handle error and return, we are done
1820
+
1821
+ //no error, save callback args to vCon context, then continue execution
1822
+ vCon.saveResults(self.out, args);
1823
+ self.complete(args);
1824
+ contExec();
1825
+ };
1826
+ };
1827
+
1828
+ CbTask.prototype.exec = function exec(vCon, handleError, contExec) {
1829
+ try {
1830
+ var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
1831
+ //console.error('CbTask.exec.args=', args);
1832
+ //console.error('CbTask.exec.vCon=', vCon);
1833
+ this.start(args); //note the start time, args
1834
+ args.push(this.cbFun); // push callback fn on end
1835
+ var func = this.f;
1836
+ var bindObj = vCon.getVar('this'); //global space or the original this
1837
+ if (this.isMethodCall()) { //if method call then reset func and bindObj
1838
+ func = vCon.getVar(this.f);
1839
+ bindObj = this.getMethodObj(vCon);
1840
+ } else if (typeof(func) === 'string') {
1841
+ func = vCon.getVar(func); // we want the actual fn from this string
1842
+ }
1843
+ func.apply(bindObj, args);
1844
+ } catch (err) { //catch and handle the task error, calling final cb
1845
+ handleError(this, err);
1846
+ }
1847
+ };
1848
+
1849
+ return CbTask;
1850
+
1851
+ });
1852
+
1853
+
1854
+ /*global define:true */
1855
+
1856
+
1857
+
1858
+ define('react/promise-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
1859
+
1860
+ /**
1861
+ PromiseTask is a task which executes a fn that returns a promise
1862
+ and when it completes it sets the values in vCon
1863
+ */
1864
+
1865
+ function format_error(errmsg, obj) {
1866
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
1867
+ }
1868
+
1869
+ var REQ = 'promiseTask requires f, a, out';
1870
+ var FN_REQ = 'promiseTask requires f to be a function or string';
1871
+ var A_REQ = 'promiseTask requires a to be an array of string param names';
1872
+ var OUT_REQ = 'promiseTask requires out to be an array[1] of string param names';
1873
+
1874
+ function PromiseTask(taskDef) {
1875
+ var self = this;
1876
+ Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
1877
+ }
1878
+
1879
+ PromiseTask.prototype = new BaseTask();
1880
+ PromiseTask.prototype.constructor = PromiseTask;
1881
+
1882
+ PromiseTask.validate = function (taskDef) {
1883
+ var errors = [];
1884
+ if (!taskDef.f || !taskDef.a || !taskDef.out) {
1885
+ errors.push(format_error(REQ, taskDef));
1886
+ } else {
1887
+ var ftype = typeof(taskDef.f);
1888
+ if (! ((taskDef.f instanceof Function) || (ftype === 'string'))) {
1889
+ errors.push(format_error(FN_REQ, taskDef));
1890
+ }
1891
+ if (! (Array.isArray(taskDef.a) &&
1892
+ taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
1893
+ errors.push(format_error(A_REQ, taskDef));
1894
+ }
1895
+ if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
1896
+ taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
1897
+ errors.push(format_error(OUT_REQ, taskDef));
1898
+ }
1899
+ }
1900
+ return errors;
1901
+ };
1902
+
1903
+ PromiseTask.prototype.prepare = function prepare(handleTaskError, vCon, contExec) {
1904
+ var self = this;
1905
+ this.nextFn = function (arg) {
1906
+ var args = Array.prototype.slice.call(arguments);
1907
+ vCon.saveResults(self.out, args);
1908
+ self.complete(args);
1909
+ contExec();
1910
+ };
1911
+ this.failFn = function (err) {
1912
+ handleTaskError(self, err);
1913
+ };
1914
+ };
1915
+
1916
+ PromiseTask.prototype.exec = function exec(vCon, handleError, contExec) {
1917
+ try {
1918
+ var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
1919
+ //console.error('PromiseTask.exec.args=', args);
1920
+ //console.error('PromiseTask.exec.vCon=', vCon);
1921
+ this.start(args); //note the start time, args
1922
+ var func = this.f;
1923
+ var bindObj = vCon.getVar('this'); //global space or the original this
1924
+ if (this.isMethodCall()) { //if method call then reset func and bindObj
1925
+ func = vCon.getVar(this.f);
1926
+ bindObj = this.getMethodObj(vCon);
1927
+ } else if (typeof(func) === 'string') {
1928
+ func = vCon.getVar(func); // we want the actual fn from this string
1929
+ }
1930
+ var retValue = func.apply(bindObj, args);
1931
+ if (retValue && typeof(retValue.then) === 'function') { // is a promise
1932
+ retValue.then(this.nextFn, this.failFn);
1933
+ } else { // just a value, proceed now
1934
+ this.nextFn(retValue);
1935
+ }
1936
+ } catch (err) { //catch and handle the task error, calling final cb
1937
+ handleError(this, err);
1938
+ }
1939
+ };
1940
+
1941
+ return PromiseTask;
1942
+
1943
+ });
1944
+
1945
+ /*global define:true */
1946
+
1947
+
1948
+
1949
+ define('react/ret-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
1950
+
1951
+ function format_error(errmsg, obj) {
1952
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
1953
+ }
1954
+
1955
+ var REQ = 'retTask requires f, a, out';
1956
+ var FN_REQ = 'retTask requires f to be a function or string';
1957
+ var A_REQ = 'retTask requires a to be an array of string param names';
1958
+ var RET_REQ = 'retTask requires out to be an array with single string param name or []';
1959
+
1960
+ function RetTask(taskDef) {
1961
+ var self = this;
1962
+ Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
1963
+ }
1964
+
1965
+ RetTask.prototype = new BaseTask();
1966
+ RetTask.prototype.constructor = RetTask;
1967
+
1968
+ RetTask.validate = function (taskDef) {
1969
+ var errors = [];
1970
+ if (!taskDef.f || !taskDef.a || !taskDef.out) {
1971
+ errors.push(format_error(REQ, taskDef));
1972
+ } else {
1973
+ var ftype = typeof(taskDef.f);
1974
+ if (! ((taskDef.f instanceof Function) || (ftype === 'string'))) {
1975
+ errors.push(format_error(FN_REQ, taskDef));
1976
+ }
1977
+ if (! (Array.isArray(taskDef.a) &&
1978
+ taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
1979
+ errors.push(format_error(A_REQ, taskDef));
1980
+ }
1981
+
1982
+ if (! (Array.isArray(taskDef.out) &&
1983
+ (taskDef.out.length === 0 ||
1984
+ (taskDef.out.length === 1 && typeof(taskDef.out[0] === 'string'))))) {
1985
+ errors.push(format_error(RET_REQ, taskDef));
1986
+ }
1987
+ }
1988
+ return errors;
1989
+ };
1990
+
1991
+ RetTask.prototype.exec = function exec(vCon, handleError, contExec) {
1992
+ try {
1993
+ var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
1994
+ this.start(args); //note the start time, args
1995
+ var func = this.f;
1996
+ var bindObj = vCon.getVar('this'); //global space or the original this
1997
+ if (this.isMethodCall()) { //if method call then reset func and bindObj
1998
+ func = vCon.getVar(this.f);
1999
+ bindObj = this.getMethodObj(vCon);
2000
+ } else if (typeof(func) === 'string') {
2001
+ func = vCon.getVar(func); // we want the actual fn from this string
2002
+ }
2003
+ var results = [func.apply(bindObj, args)];
2004
+ vCon.saveResults(this.out, results); // save retval, takes arrays
2005
+ this.complete(results);
2006
+ contExec(); // continue since no callback to run this
2007
+ } catch (err) { handleError(this, err); } // catch and handle the task error, calling final cb
2008
+ };
2009
+
2010
+ return RetTask;
2011
+
2012
+ });
2013
+
2014
+ /*global define:true */
2015
+
2016
+
2017
+
2018
+ define('react/when-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
2019
+
2020
+ /**
2021
+ When task which checks if is a promise (has a then method)
2022
+ and waits for it to resolve.
2023
+
2024
+ If argument does not have a then method, it resolves immediately
2025
+ */
2026
+
2027
+ function format_error(errmsg, obj) {
2028
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
2029
+ }
2030
+
2031
+ var REQ = 'whenTask requires a, out';
2032
+ var A_REQ = 'whenTask requires a to be an array[1] of string param names';
2033
+ var OUT_REQ = 'whenTask requires out to be an array[1] of string param names';
2034
+
2035
+ function WhenTask(taskDef) {
2036
+ var self = this;
2037
+ Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
2038
+ }
2039
+
2040
+ WhenTask.prototype = new BaseTask();
2041
+ WhenTask.prototype.constructor = WhenTask;
2042
+
2043
+ WhenTask.prototype.f = function when() { // just here to keep validations happy
2044
+ }
2045
+
2046
+ WhenTask.validate = function (taskDef) {
2047
+ var errors = [];
2048
+ if (!taskDef.a || !taskDef.out) {
2049
+ errors.push(format_error(REQ, taskDef));
2050
+ } else {
2051
+ if (! (Array.isArray(taskDef.a) && taskDef.a.length === 1 &&
2052
+ taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
2053
+ errors.push(format_error(A_REQ, taskDef));
2054
+ }
2055
+ if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
2056
+ taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
2057
+ errors.push(format_error(OUT_REQ, taskDef));
2058
+ }
2059
+ }
2060
+ return errors;
2061
+ };
2062
+
2063
+ WhenTask.prototype.prepare = function prepare(handleTaskError, vCon, contExec) {
2064
+ var self = this;
2065
+ this.nextFn = function (arg) {
2066
+ var args = Array.prototype.slice.call(arguments);
2067
+ vCon.saveResults(self.out, args);
2068
+ self.complete(args);
2069
+ contExec();
2070
+ };
2071
+ this.failFn = function (err) {
2072
+ handleTaskError(self, err);
2073
+ };
2074
+ };
2075
+
2076
+ WhenTask.prototype.exec = function exec(vCon, handleError, contExec) {
2077
+ try {
2078
+ var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
2079
+ //console.error('WhenTask.exec.args=', args);
2080
+ //console.error('WhenTask.exec.vCon=', vCon);
2081
+ this.start(args); //note the start time, args
2082
+ var arg = args[0]; // one value allowed
2083
+ if (arg && typeof(arg.then) === 'function') { // is a promise
2084
+ arg.then(this.nextFn, this.failFn);
2085
+ } else { // not a promise continue immediately
2086
+ this.nextFn(arg);
2087
+ }
2088
+ } catch (err) { //catch and handle the task error, calling final cb
2089
+ handleError(this, err);
2090
+ }
2091
+ };
2092
+
2093
+ return WhenTask;
2094
+
2095
+ });
2096
+
2097
+ /*global define:true */
2098
+
2099
+
2100
+
2101
+ define('react/finalcb-task',['./sprintf', 'util', './status', './event-manager'],
2102
+ function (sprintf, util, STATUS, EventManager) {
2103
+
2104
+ var OUTTASK_A_REQ = 'ast.outTask.a should be an array of string param names';
2105
+
2106
+ function FinalCbTask(outTaskOptions) {
2107
+ var taskDef = outTaskOptions.taskDef;
2108
+ if (typeof(outTaskOptions.cbFunc) !== 'function') throw new Error('callback is not a function');
2109
+ var self = this;
2110
+ for (var k in taskDef) {
2111
+ if (true) self[k] = taskDef[k]; // if to make jshint happy
2112
+ }
2113
+ this.f = outTaskOptions.cbFunc;
2114
+ this.tasks = outTaskOptions.tasks;
2115
+ this.vCon = outTaskOptions.vCon;
2116
+ this.retValue = outTaskOptions.retValue;
2117
+ this.execOptions = outTaskOptions.execOptions;
2118
+ this.env = outTaskOptions.env;
2119
+ }
2120
+
2121
+ function format_error(errmsg, obj) {
2122
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
2123
+ }
2124
+
2125
+
2126
+ FinalCbTask.validate = function (taskDef) {
2127
+ var errors = [];
2128
+ if (! (Array.isArray(taskDef.a) &&
2129
+ taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
2130
+ errors.push(format_error(OUTTASK_A_REQ, taskDef));
2131
+ }
2132
+ return errors;
2133
+ };
2134
+
2135
+ FinalCbTask.prototype.isReady = function () {
2136
+ return (this.tasks.every(function (t) { return (t.status === STATUS.COMPLETE); }));
2137
+ };
2138
+
2139
+ FinalCbTask.prototype.exec = function (err) {
2140
+ if (!this.f) return; //must have already been called
2141
+ if (err) {
2142
+ this.env.error = err;
2143
+ this.env.flowEmitter.emit(EventManager.TYPES.EXEC_FLOW_ERRORED, this.env);
2144
+ this.f.call(null, err); //call the final callback with the first error hit
2145
+ } else { // no error, call with args
2146
+ var vCon = this.vCon;
2147
+ var finalArgs = this.a.map(function (k) { return vCon.getVar(k); });
2148
+ finalArgs.unshift(null); //unshift err=null to front
2149
+ this.env.results = finalArgs;
2150
+ this.env.flowEmitter.emit(EventManager.TYPES.EXEC_FLOW_COMPLETE, this.env);
2151
+ this.f.apply(null, finalArgs);
2152
+ }
2153
+ this.f = null; // prevent multiple calls
2154
+ };
2155
+
2156
+ return FinalCbTask;
2157
+
2158
+ });
2159
+
2160
+ /*global define:true */
2161
+
2162
+
2163
+
2164
+ define('react/finalcb-first-task',['./sprintf', 'util', './status', './vcon', './event-manager'],
2165
+ function (sprintf, util, STATUS, VContext, EventManager) {
2166
+
2167
+ var OUTTASK_A_REQ = 'ast.outTask.a should be an array of string param names';
2168
+
2169
+ function FinalCbFirstSuccTask(outTaskOptions) {
2170
+ var taskDef = outTaskOptions.taskDef;
2171
+ if (typeof(outTaskOptions.cbFunc) !== 'function') throw new Error('callback is not a function');
2172
+ var self = this;
2173
+ for (var k in taskDef) {
2174
+ if (true) self[k] = taskDef[k]; // if to make jshint happy
2175
+ }
2176
+ this.f = outTaskOptions.cbFunc;
2177
+ this.tasks = outTaskOptions.tasks;
2178
+ this.vCon = outTaskOptions.vCon;
2179
+ this.retValue = outTaskOptions.retValue;
2180
+ this.env = outTaskOptions.env;
2181
+ }
2182
+
2183
+ function format_error(errmsg, obj) {
2184
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
2185
+ }
2186
+
2187
+ FinalCbFirstSuccTask.validate = function (taskDef) {
2188
+ var errors = [];
2189
+ if (! (Array.isArray(taskDef.a) &&
2190
+ taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
2191
+ errors.push(format_error(OUTTASK_A_REQ, taskDef));
2192
+ }
2193
+ return errors;
2194
+ };
2195
+
2196
+ /**
2197
+ is ready to exit when any task comes back with non-null defined value
2198
+ */
2199
+ FinalCbFirstSuccTask.prototype.isReady = function () {
2200
+ var lastres = this.vCon.getLastResults();
2201
+ if (!lastres) return false; // no results yet
2202
+ return (lastres.some(function (v) { return (v !== undefined && v !== null); }));
2203
+ };
2204
+
2205
+ FinalCbFirstSuccTask.prototype.exec = function (err) {
2206
+ if (!this.f) return; //must have already been called
2207
+ if (err) {
2208
+ this.env.error = err;
2209
+ this.env.flowEmitter.emit(EventManager.TYPES.EXEC_FLOW_ERRORED, this.env);
2210
+ this.f.call(null, err); //call the final callback with the first error hit
2211
+ } else { // no error, call with args
2212
+ var vCon = this.vCon;
2213
+ var finalArgs = this.a.map(function (k) { return vCon.getVar(k); });
2214
+ finalArgs.unshift(null); //unshift err=null to front
2215
+ this.env.results = finalArgs;
2216
+ this.env.flowEmitter.emit(EventManager.TYPES.EXEC_FLOW_COMPLETE, this.env);
2217
+ this.f.apply(null, finalArgs);
2218
+ }
2219
+ this.f = null; // prevent multiple calls
2220
+ };
2221
+
2222
+ return FinalCbFirstSuccTask;
2223
+
2224
+ });
2225
+
2226
+ /*global define:true */
2227
+
2228
+
2229
+
2230
+ define('react/task',['util', './sprintf', 'ensure-array', './cb-task', './promise-task',
2231
+ './ret-task', './when-task', './finalcb-task', './finalcb-first-task',
2232
+ './status', './error', './vcon', './event-manager'],
2233
+ function (util, sprintf, array, CbTask, PromiseTask,
2234
+ RetTask, WhenTask, FinalCbTask, FinalCbFirstSuccTask,
2235
+ STATUS, error, VContext, EventManager) {
2236
+
2237
+ var TASK_TYPES = {
2238
+ cb: CbTask,
2239
+ ret: RetTask,
2240
+ promise: PromiseTask,
2241
+ when: WhenTask
2242
+ };
2243
+
2244
+ var DEFAULT_TASK_NAME = 'task_%s'; // for unnamed tasks use task_idx, like task_0
2245
+
2246
+ function taskTypeKeys() { return Object.keys(TASK_TYPES); }
2247
+
2248
+ var OUT_TASK_TYPES = {
2249
+ finalcb: FinalCbTask, //first task is the default if no type specified in taskDef
2250
+ finalcbFirst: FinalCbFirstSuccTask
2251
+ };
2252
+ function outTaskTypeKeys() { return Object.keys(OUT_TASK_TYPES); }
2253
+
2254
+ var LOCAL_FN_MISSING = 'function: %s not found in locals or input params - task[%s]';
2255
+ var TASKDEF_IS_OBJECT = 'task must be an object';
2256
+ var NO_TASKS_RUNNING_WONT_COMPLETE = 'no tasks running, flow will not complete, remaining tasks: %s';
2257
+ var TASK_TYPE_SHOULD_MATCH = 'task.type should match one of ' +
2258
+ Object.keys(TASK_TYPES).join(', ');
2259
+
2260
+ var validateTaskType, validateTask, create;
2261
+
2262
+
2263
+ function format_error(errmsg, obj) {
2264
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
2265
+ }
2266
+
2267
+ /**
2268
+ guess the missing types from params.
2269
+ Augments in place but also returns taskDef.
2270
+ If not specified then is 'cb'
2271
+ */
2272
+ function setMissingType(taskDef) {
2273
+ if (taskDef.type) return taskDef; //already set, return
2274
+ taskDef.type = 'cb';
2275
+ return taskDef;
2276
+ }
2277
+
2278
+ function setMissingOutTaskType(taskDef) {
2279
+ if (!taskDef.type) taskDef.type = Object.keys(OUT_TASK_TYPES)[0]; //use first outTask type as default
2280
+ }
2281
+
2282
+ function ensureAfterArrStrings(taskDef) { // convert any fn to str, and make sure is array
2283
+ if (!taskDef.after) return;
2284
+ var afterArr = array(taskDef.after); // ensure is array, null becomes []
2285
+ afterArr = afterArr.map(function (a) { return (typeof(a) === 'function') ? a.name : a; });
2286
+ taskDef.after = afterArr;
2287
+ }
2288
+
2289
+ /**
2290
+ @returns array of errors for taskDef, could be empty
2291
+ */
2292
+ function validate(taskDef) {
2293
+ if (!taskDef || typeof(taskDef) !== 'object') {
2294
+ return [format_error(TASKDEF_IS_OBJECT, taskDef)];
2295
+ }
2296
+ setMissingType(taskDef);
2297
+ ensureAfterArrStrings(taskDef);
2298
+ var errors = [];
2299
+ errors = errors.concat(validateTaskType(taskDef));
2300
+ errors = errors.concat(validateTask(taskDef));
2301
+ return errors;
2302
+ }
2303
+
2304
+ function validateTaskType(taskDef) {
2305
+ var errors = [];
2306
+ if (!Object.keys(TASK_TYPES).some(
2307
+ function (type) { return (taskDef.type === type); })) {
2308
+ errors.push(format_error(TASK_TYPE_SHOULD_MATCH, taskDef));
2309
+ }
2310
+ return errors;
2311
+ }
2312
+
2313
+ function validateTask(taskDef) {
2314
+ var errors = [];
2315
+ var taskCons = TASK_TYPES[taskDef.type];
2316
+ if (taskCons) {
2317
+ errors = errors.concat(taskCons.validate(taskDef));
2318
+ }
2319
+ return errors;
2320
+ }
2321
+
2322
+ function validateOutTask(taskDef) {
2323
+ var errors = [];
2324
+ setMissingOutTaskType(taskDef);
2325
+ var taskCons = OUT_TASK_TYPES[taskDef.type];
2326
+ errors = errors.concat(taskCons.validate(taskDef));
2327
+ return errors;
2328
+ }
2329
+
2330
+
2331
+ function validateLocalFunctions(inParams, taskDefs, locals) {
2332
+ var errors = [];
2333
+ function foo() { } //used to mock args as fns for validation check
2334
+ var mock_args = inParams.map(function (p) { return foo; }); //mock args with fns
2335
+ var vCon = VContext.create(mock_args, inParams, locals);
2336
+ var tasks = taskDefs.map(create);
2337
+ var tasksWFunctions = tasks.filter(function (t) { return (t.type !== 'when'); }); // non-when tasks need f
2338
+ tasksWFunctions.forEach(function (t, idx) {
2339
+ if (!t.functionExists(vCon)) { // error if function doesnt exist AND
2340
+ if (!t.isMethodCall()) errors.push(sprintf(LOCAL_FN_MISSING, t.f, idx)); // not method OR
2341
+ else {
2342
+ var obj = t.getMethodObj(vCon);
2343
+ if (obj && obj !== foo) { // (has parent but not our mock)
2344
+ errors.push(sprintf(LOCAL_FN_MISSING, t.f, idx));
2345
+ }
2346
+ }
2347
+ }
2348
+ });
2349
+ return errors;
2350
+ }
2351
+
2352
+ function fName(fn) {
2353
+ if (typeof(fn) === 'function') {
2354
+ return fn.name;
2355
+ }
2356
+ return (fn) ? fn : '';
2357
+ }
2358
+
2359
+ /**
2360
+ Name tasks that are not already named. Prenamed task uniquness validation
2361
+ will be done in validate.
2362
+
2363
+ This modifies the tasks with the new names.
2364
+
2365
+ @returns map of names to tasks
2366
+ */
2367
+ function nameTasks(tasks) { //name tasks that are not already named, validation done elsewhere, ret map
2368
+ var namesMap = tasks.reduce(function (map, t) {
2369
+ if (t.name) { map[t.name] = t; }
2370
+ return map;
2371
+ }, {});
2372
+ tasks.forEach(function (t, idx) {
2373
+ if (!t.name) { //not already named
2374
+ var name = fName(t.f);
2375
+ if (!name) name = sprintf(DEFAULT_TASK_NAME, idx);
2376
+ if (!name || namesMap[name]) {
2377
+ name = sprintf('%s_%s', name, idx); //if empty or already used, postfix with _idx
2378
+ }
2379
+ t.name = name;
2380
+ namesMap[name] = t;
2381
+ }
2382
+ });
2383
+ return namesMap;
2384
+ }
2385
+
2386
+ function create(taskDef) {
2387
+ var TaskConstructor = TASK_TYPES[taskDef.type];
2388
+ return new TaskConstructor(taskDef);
2389
+ }
2390
+
2391
+ function createOutTask(taskDef, cbFunc, tasks, vCon, execOptions, env) {
2392
+ setMissingOutTaskType(taskDef);
2393
+ var outTaskOptions = {
2394
+ taskDef: taskDef,
2395
+ cbFunc: cbFunc,
2396
+ tasks: tasks,
2397
+ vCon: vCon,
2398
+ execOptions: execOptions,
2399
+ env: env,
2400
+ TaskConstructor: OUT_TASK_TYPES[taskDef.type]
2401
+ };
2402
+ EventManager.global.emit(EventManager.TYPES.EXEC_OUTTASK_CREATE, outTaskOptions); // hook
2403
+ var TaskConstructor = outTaskOptions.TaskConstructor; // hook could have changed
2404
+ return new TaskConstructor(outTaskOptions);
2405
+ }
2406
+
2407
+ function createErrorHandler(vCon, outTask) {
2408
+ return function handleError(task, err) {
2409
+ task.status = STATUS.ERRORED;
2410
+ task.error = err;
2411
+ outTask.env.currentTask = task;
2412
+ outTask.env.flowEmitter.emit(EventManager.TYPES.EXEC_TASK_ERRORED, task);
2413
+ var errWithMeta = error.augmentError(err, {task: task, vcon: vCon});
2414
+ outTask.exec(errWithMeta); //call the final callback with the first error hit
2415
+ };
2416
+ }
2417
+
2418
+ function findTasksReady(vCon, tasks, tasksByName) {
2419
+ return tasks.filter(function (t) { return t.isReady(vCon, tasksByName); });
2420
+ }
2421
+
2422
+ function execTasks(tasksReady, vCon, handleError, contExec) {
2423
+ tasksReady.forEach(function (t) { t.status = STATUS.READY; }); //set ready first, no double exec
2424
+ tasksReady.forEach(function (t) { t.exec(vCon, handleError, contExec); });
2425
+ }
2426
+
2427
+ /**
2428
+ this will be called if there are no tasks found to run,
2429
+ and it will check if there are still tasks running or ready
2430
+ (which means they will be running shortly), in which
2431
+ case everything is fine. If no tasks are running then
2432
+ call handleError since this will never complete.
2433
+ */
2434
+ function checkIfTasksRunning(vCon, tasks, handleError, env) {
2435
+ var tasksRunning = tasks.filter(function (t) {
2436
+ return (t.status === STATUS.RUNNING || t.status === STATUS.READY);
2437
+ });
2438
+ if (!tasksRunning.length) {
2439
+ var remainingTasks = tasks.filter(function (t) { return (!t.status); });
2440
+ var remainingTNames = remainingTasks.map(function (t) { return t.name; });
2441
+ var errMsg = sprintf(NO_TASKS_RUNNING_WONT_COMPLETE, remainingTNames.join(', '));
2442
+ var emptyTask = { env: env };
2443
+ handleError(emptyTask, new Error(errMsg));
2444
+ }
2445
+ }
2446
+
2447
+ function findReadyAndExec(vCon, tasks, tasksByName, handleError, contExec, env) {
2448
+ var tasksReady = findTasksReady(vCon, tasks, tasksByName);
2449
+ if (!tasksReady.length) checkIfTasksRunning(vCon, tasks, handleError, env); // no tasks to run, check if ok
2450
+ execTasks(tasksReady, vCon, handleError, contExec);
2451
+ }
2452
+
2453
+ function serializeTasks(tasks) { // conveniently set after for each task idx > 0
2454
+ nameTasks(tasks);
2455
+ tasks.forEach(function (t, idx, arr) { if (idx !== 0) t.after = [arr[idx - 1].name]; });
2456
+ return tasks;
2457
+ }
2458
+
2459
+ return {
2460
+ serializeTasks: serializeTasks,
2461
+ TASK_TYPES: TASK_TYPES,
2462
+ taskTypeKeys: taskTypeKeys,
2463
+ OUT_TASK_TYPES: OUT_TASK_TYPES,
2464
+ outTaskTypeKeys: outTaskTypeKeys,
2465
+ setMissingType: setMissingType,
2466
+ validate: validate,
2467
+ validateOutTask: validateOutTask,
2468
+ validateLocalFunctions: validateLocalFunctions,
2469
+ nameTasks: nameTasks,
2470
+ create: create,
2471
+ createOutTask: createOutTask,
2472
+ createErrorHandler: createErrorHandler,
2473
+ findReadyAndExec: findReadyAndExec
2474
+ };
2475
+
2476
+ });
2477
+
2478
+ /*global define:true */
2479
+
2480
+
2481
+
2482
+ define('react/validate',['util', './sprintf', 'ensure-array', './task'], function (util, sprintf, array, taskUtil) {
2483
+ /*jshint latedef:false */
2484
+
2485
+ var AST_IS_OBJECT = 'ast must be an object with inParams, tasks, and outTask';
2486
+ var INPARAMS_ARR_STR = 'ast.inParams must be an array of strings';
2487
+ var TASKS_ARR = 'ast.tasks must be an array of tasks';
2488
+ var NAMES_UNIQUE = 'ast.tasks that specify name need to be unique, duplicate:';
2489
+ var LOCALS_NOTNULL = 'ast.locals should not be null';
2490
+ var DUP_OUTPUTS = 'multiple tasks output the same param, must be unique. param';
2491
+ var MISSING_INPUTS = 'missing or mispelled variable referenced in flow definition: %s';
2492
+
2493
+ // match any of our literals true, false, int, float, quoted strings, or is property (has dot), match vcon.js
2494
+ var LITERAL_OR_PROP_RE = /^(true|false|this|null|\-?[0-9\.]+)$|'|"|\./i;
2495
+
2496
+ function format_error(errmsg, obj) {
2497
+ return sprintf('%s - %s', errmsg, util.inspect(obj));
2498
+ }
2499
+
2500
+ /**
2501
+ true if is a literal name
2502
+ */
2503
+ function isLiteralOrProp(name) { // need to match what is in vcon.js, TODO consolidate?
2504
+ return LITERAL_OR_PROP_RE.test(name);
2505
+ }
2506
+
2507
+ /**
2508
+ validate the AST return Errors
2509
+ @example
2510
+ var validate = require('./validate');
2511
+ var errors = validate(ast);
2512
+ @returns array of errors, could be empty
2513
+ */
2514
+ function validate(ast) {
2515
+ if (!ast || !ast.inParams || !ast.tasks || !ast.outTask) return [AST_IS_OBJECT];
2516
+ var errors = [];
2517
+ errors = errors.concat(validateInParams(ast.inParams));
2518
+ errors = errors.concat(validateTasks(ast.tasks));
2519
+ errors = errors.concat(validateTaskNamesUnique(ast.tasks));
2520
+ errors = errors.concat(taskUtil.validateOutTask(ast.outTask));
2521
+ errors = errors.concat(validateLocals(ast.locals));
2522
+ if (errors.length === 0) { // if no errors do additional validation
2523
+ if (ast.outTask.type !== 'finalcbFirst') errors = errors.concat(validateOuputsUnique(ast.tasks));
2524
+ errors = errors.concat(taskUtil.validateLocalFunctions(ast.inParams, ast.tasks, ast.locals));
2525
+ errors = errors.concat(validateNoMissingNames(ast));
2526
+ }
2527
+ return errors;
2528
+ }
2529
+
2530
+ /**
2531
+ @returns array of errors, could be empty
2532
+ */
2533
+ function validateInParams(inParams) {
2534
+ if (!Array.isArray(inParams) ||
2535
+ !inParams.every(function (x) { return (typeof(x) === 'string'); })) {
2536
+ return [INPARAMS_ARR_STR];
2537
+ }
2538
+ return [];
2539
+ }
2540
+
2541
+ /**
2542
+ @returns array of errors, could be empty
2543
+ */
2544
+ function validateTasks(tasks) {
2545
+ if (!Array.isArray(tasks)) return [TASKS_ARR];
2546
+ var errors = [];
2547
+ tasks.forEach(function (t) {
2548
+ errors = errors.concat(taskUtil.validate(t));
2549
+ });
2550
+ return errors;
2551
+ }
2552
+
2553
+ function validateTaskNamesUnique(tasks) {
2554
+ if (!Array.isArray(tasks)) return [];
2555
+ var errors = [];
2556
+ var namedTasks = tasks.filter(function (t) { return (t.name); });
2557
+ var names = namedTasks.map(function (t) { return t.name; });
2558
+ names.reduce(function (accum, name) {
2559
+ if (accum[name]) errors.push(sprintf('%s %s', NAMES_UNIQUE, name));
2560
+ else accum[name] = true;
2561
+ return accum;
2562
+ }, {});
2563
+ return errors;
2564
+ }
2565
+
2566
+ function validateLocals(locals) {
2567
+ var errors = [];
2568
+ if (locals === null) errors.push(LOCALS_NOTNULL);
2569
+ return errors;
2570
+ }
2571
+
2572
+ function getOutputParams(taskDef) {
2573
+ return array(taskDef.out); //ensure array
2574
+ }
2575
+
2576
+ function validateOuputsUnique(taskDefs) {
2577
+ var errors = [];
2578
+ taskDefs.reduce(function (accum, t) {
2579
+ getOutputParams(t).forEach(function (param) {
2580
+ if (accum[param] !== undefined) errors.push(sprintf('%s: %s', DUP_OUTPUTS, param));
2581
+ else accum[param] = true;
2582
+ });
2583
+ return accum;
2584
+ }, {});
2585
+ return errors;
2586
+ }
2587
+
2588
+
2589
+ /**
2590
+ validate there are no missing or mispelled param names in any task inputs
2591
+ or the final task output
2592
+
2593
+ @return array of errors, or empty array if none
2594
+ */
2595
+ function validateNoMissingNames(ast) {
2596
+ var errors = [];
2597
+ var names = {};
2598
+ if (ast.locals) {
2599
+ names = Object.keys(ast.locals).reduce(function (accum, k) { // start with locals
2600
+ accum[k] = true;
2601
+ return accum;
2602
+ }, names);
2603
+ }
2604
+ ast.inParams.reduce(function (accum, p) { // add input params
2605
+ accum[p] = true;
2606
+ return accum;
2607
+ }, names);
2608
+ ast.tasks.reduce(function (accum, t) { // add task outputs
2609
+ return t.out.reduce(function (innerAccum, p) {
2610
+ innerAccum[p] = true;
2611
+ return innerAccum;
2612
+ }, accum);
2613
+ }, names);
2614
+
2615
+ // now we have all possible provided vars, check task inputs are accounted for
2616
+ ast.tasks.reduce(function (accum, t) { // for all tasks
2617
+ return t.a.reduce(function (innerAccum, p) { // for all in params, except property
2618
+ if (!isLiteralOrProp(p) && !names[p]) innerAccum.push(sprintf(MISSING_INPUTS, p)); // add error if missing
2619
+ return innerAccum;
2620
+ }, accum);
2621
+ }, errors);
2622
+
2623
+ // now check the final task outputs
2624
+ ast.outTask.a.reduce(function (accum, p) { // for final task out params
2625
+ if (!isLiteralOrProp(p) && !names[p]) accum.push(sprintf(MISSING_INPUTS, p)); // add error if missing
2626
+ return accum;
2627
+ }, errors);
2628
+ return errors;
2629
+ }
2630
+
2631
+ return validate;
2632
+
2633
+ });
2634
+
2635
+ /*global define:true */
2636
+
2637
+
2638
+
2639
+ define('react/core',['./eventemitter', './error', './validate', './task', './status',
2640
+ './vcon', './event-manager', './input-parser', './id', './sprintf'],
2641
+ function (EventEmitter, error, validate, taskUtil, STATUS,
2642
+ VContext, EventManager, inputParser, idGenerator, sprintf) {
2643
+
2644
+ var reactOptions = {
2645
+ stackTraceLimitMin: 30
2646
+ };
2647
+
2648
+ var reactEmitter = EventManager.global; // the top emitter
2649
+
2650
+ /**
2651
+ merge global react options with parsed options
2652
+ */
2653
+ function mergeOptions(parsedOptions) {
2654
+ return Object.keys(reactOptions).reduce(function (accum, k) {
2655
+ if (!accum[k]) accum[k] = reactOptions[k];
2656
+ return accum;
2657
+ }, parsedOptions);
2658
+ }
2659
+
2660
+ /**
2661
+ generate a flow name when one is not provided
2662
+ */
2663
+ function generateFlowName() {
2664
+ return sprintf('flow_%s', idGenerator.createUniqueId());
2665
+ }
2666
+
2667
+ /**
2668
+ Creates react function which the AST can be manipulated and then
2669
+ is ready to be executed. Can be used directly or a DSL can wrap this
2670
+ to provide the AST.
2671
+
2672
+ @example
2673
+ var react = require('react');
2674
+ var fn = react();
2675
+ var valid2 = fn.setAndValidateAST({
2676
+ name: 'optionalName',
2677
+ inParams: ['a', 'b'],
2678
+ tasks: [
2679
+ { type: 'cb', f: multiply, a: ['a', 'b'], out: ['c'] }
2680
+ ],
2681
+ outTask: { a: ['c'] }
2682
+ });
2683
+ console.log(fn.ast); // view
2684
+ fn(123, 456, cb);
2685
+ */
2686
+ function reactFactory() {
2687
+ if (arguments.length) throw new Error('react() takes no args, check API');
2688
+
2689
+ error.ensureStackTraceLimitSet(reactOptions.stackTraceLimitMin);
2690
+ var flowEmitter = EventManager.create();
2691
+ flowEmitter.parent = reactEmitter;
2692
+
2693
+ var ast = {
2694
+ name: undefined,
2695
+ inParams: [],
2696
+ tasks: [],
2697
+ outTask: {},
2698
+ locals: {}
2699
+ };
2700
+
2701
+ function setAndValidateAST(newAST) { //set AST then validate, ret error[]
2702
+ Object.keys(newAST).forEach(function (k) { ast[k] = newAST[k]; }); // copy all properties
2703
+ var errors = validate(ast);
2704
+ if (!errors.length) {
2705
+ if (!ast.name) ast.name = generateFlowName();
2706
+ taskUtil.nameTasks(ast.tasks); //run this so names can be checked in ast
2707
+ }
2708
+ if (Object.freeze) { //lets freeze the AST so plugin writers don't accidentally manip the ast
2709
+ Object.keys(newAST).forEach(function (k) {
2710
+ if (typeof(newAST[k]) === 'object') Object.freeze(newAST[k]);
2711
+ });
2712
+ Object.freeze(newAST);
2713
+ }
2714
+ flowEmitter.emit(EventManager.TYPES.AST_DEFINED, ast);
2715
+ return errors;
2716
+ }
2717
+
2718
+ function exec(arg1, arg2, argN, cb) { // called to execute the flow
2719
+ /*jshint validthis: true */
2720
+ var args = Array.prototype.slice.call(arguments);
2721
+ var env = {
2722
+ execId: idGenerator.createUniqueId(),
2723
+ args: args,
2724
+ ast: ast,
2725
+ flowEmitter: flowEmitter
2726
+ };
2727
+ env.name = ast.name || env.execId;
2728
+ flowEmitter.emit(EventManager.TYPES.EXEC_FLOW_START, env); // hook
2729
+ var parsedInput = inputParser(args, ast);
2730
+ var vCon = VContext.create(parsedInput.args, ast.inParams, ast.locals, this); // create var ctx with in args & locals
2731
+
2732
+ env.parsedInput = parsedInput;
2733
+ env.options = mergeOptions(parsedInput.options);
2734
+ env.vCon = vCon;
2735
+ env.taskDefs = ast.tasks.slice(); // create copy
2736
+ env.outTaskDef = Object.create(ast.outTask); // create copy
2737
+ reactEmitter.emit(EventManager.TYPES.EXEC_TASKS_PRECREATE, env); // hook
2738
+
2739
+ var tasks = env.taskDefs.map(taskUtil.create);
2740
+ var tasksByName = taskUtil.nameTasks(tasks); // map names to working tasks
2741
+ var outTask = taskUtil.createOutTask(env.outTaskDef, parsedInput.cb, tasks, vCon, env.options, env);
2742
+ var handleError = taskUtil.createErrorHandler(vCon, outTask);
2743
+
2744
+ function contExec() {
2745
+ if (!outTask.f) { return; } //stop execution, we already hit an error, f was cleared
2746
+ if (outTask.isReady()) return outTask.exec(); // all tasks done, exec cb, return
2747
+ taskUtil.findReadyAndExec(vCon, tasks, tasksByName, handleError, contExec, env); //exec tasks that ready to run
2748
+ }
2749
+
2750
+ tasks.forEach(function (t) {
2751
+ t.id = idGenerator.createUniqueId();
2752
+ t.env = env;
2753
+ if (t.prepare) t.prepare(handleError, vCon, contExec, flowEmitter);
2754
+ }); // create callbacks
2755
+ contExec(); // start things off
2756
+ return outTask.retValue; // could return promise
2757
+ }
2758
+
2759
+ var reactFn = exec; // make the exec() the function returned
2760
+ reactFn.ast = ast; // put AST hanging off the fn so it can be inspected
2761
+ reactFn.setAndValidateAST = setAndValidateAST; // call to set AST and then validate
2762
+ reactFn.events = flowEmitter; // used to listen to execution events for this flow
2763
+ return reactFn;
2764
+ }
2765
+
2766
+ reactFactory.options = reactOptions; // global react options
2767
+ reactFactory.events = reactEmitter; // global react emitter
2768
+ return reactFactory; // module returns reactFactory to create a react fn
2769
+ });
2770
+
2771
+ /*global define:true */
2772
+
2773
+
2774
+
2775
+ define('react/parse',['./sprintf'], function (sprintf) {
2776
+
2777
+ function splitTrimFilterArgs(commaSepArgs) { //parse 'one, two' into ['one', 'two']
2778
+ if (!commaSepArgs) return [];
2779
+ return commaSepArgs.split(',') //split on commas
2780
+ .map(function (s) { return s.trim(); }) //trim
2781
+ .filter(function (s) { return (s); }); //filter out empty strings
2782
+ }
2783
+
2784
+ /**
2785
+ @param patternFn regex + fn or splitStr + fn
2786
+ */
2787
+ function parseReduce(accum, patternFn) {
2788
+ if (typeof(accum) !== 'string') return accum; // already matched
2789
+ var m = (patternFn.regex) ? patternFn.regex.exec(accum) : accum.split(patternFn.splitStr);
2790
+ if (m) return patternFn.fn(m, accum); // pass in matches and origStr, return result obj
2791
+ return accum; // no match, return str, will try next matcher
2792
+ }
2793
+
2794
+ function parseStr(str, parseMatchers, errStr) {
2795
+ var result = parseMatchers.reduce(parseReduce, str);
2796
+ if (typeof(result) !== 'string') { // matched
2797
+ return result;
2798
+ } else { // no match
2799
+ throw new Error(sprintf(errStr, str));
2800
+ }
2801
+ }
2802
+
2803
+ return {
2804
+ splitTrimFilterArgs: splitTrimFilterArgs,
2805
+ parseStr: parseStr
2806
+ };
2807
+
2808
+ });
2809
+
2810
+
2811
+ /*global define:true */
2812
+
2813
+
2814
+
2815
+ define('react/dsl',['./sprintf', './core', './parse', './task'],
2816
+ function (sprintf, core, parse, taskUtil) {
2817
+ /*jshint regexp: false */
2818
+
2819
+ var MISSING_NAME = 'first flow parameter should be the flow name, but found in/out def: %s';
2820
+ var INOUT_PARAMS_NO_MATCH = 'params in wrong format, wanted "foo, bar, cb -> err, baz" - found: %s';
2821
+ var MISSING_ERR = 'callback specified, but first out param was not "err", use for clarity. Found in/out def: %s';
2822
+ var MISSING_CB = 'found err param, but cb/callback is not specified, is this cb-style async or sync function? Found in/out def: %s';
2823
+ var EXTRA_TASKARG = 'extra unmatched task arg: %s';
2824
+
2825
+ var INOUT_RE = /\->/; // used to detect missing name, in/out as first arg
2826
+ var CB_NAMES_RE = /^cb|callback$/i; //cb, Cb, CB, callback, Callback
2827
+ var ERR_NAMES_RE = /^err$/i; // err, ERR, Err, ...
2828
+
2829
+ function filterOutTrailingCbParam(args) { // if has trailing cb | callback param, filter it out
2830
+ if (args.length && args[args.length - 1].match(CB_NAMES_RE)) args.pop();
2831
+ return args;
2832
+ }
2833
+
2834
+ function filterOutLeadingErrParam(args) { // if leading err param, filter it out
2835
+ if (args.length && args[0].match(ERR_NAMES_RE)) args.shift();
2836
+ return args;
2837
+ }
2838
+
2839
+ var inOutDefParse = {
2840
+ splitStr: '->',
2841
+ fn: function (m, origStr) {
2842
+ var inParams = parse.splitTrimFilterArgs(m[0]);
2843
+ var lastParam = inParams[inParams.length - 1];
2844
+ var type = (lastParam && CB_NAMES_RE.test(lastParam)) ? 'cb' : 'ret';
2845
+ var outParams = parse.splitTrimFilterArgs(m[1]);
2846
+ var firstOutParam = outParams[0];
2847
+ if (type === 'cb' && (!firstOutParam || !ERR_NAMES_RE.test(firstOutParam))) {
2848
+ throw new Error(sprintf(MISSING_ERR, origStr)); // found cb, but no err param
2849
+ } else if (type === 'ret' && firstOutParam && ERR_NAMES_RE.test(firstOutParam)) {
2850
+ throw new Error(sprintf(MISSING_CB, origStr)); // found err but not cb param
2851
+ }
2852
+ return {
2853
+ type: type,
2854
+ inDef: filterOutTrailingCbParam(inParams),
2855
+ outDef: filterOutLeadingErrParam(outParams)
2856
+ };
2857
+ }
2858
+ };
2859
+
2860
+ function parseInOutParams(str) {
2861
+ var objDef = parse.parseStr(str, [inOutDefParse], INOUT_PARAMS_NO_MATCH);
2862
+ objDef.inDef = filterOutTrailingCbParam(objDef.inDef);
2863
+ return objDef;
2864
+ }
2865
+
2866
+ function parseTasks(arr) {
2867
+ var tasks = [];
2868
+ var fn, obj, result;
2869
+ while (arr.length >= 2) {
2870
+ obj = {};
2871
+ fn = arr.shift();
2872
+ result = parseInOutParams(arr.shift());
2873
+ if (typeof(arr[0]) === 'object') obj = arr.shift(); // has options, use as obj
2874
+ obj.f = fn;
2875
+ obj.a = result.inDef;
2876
+ var type = result.type;
2877
+ obj.out = result.outDef;
2878
+ obj.type = type;
2879
+ tasks.push(obj);
2880
+ }
2881
+ if (arr.length) throw new Error(sprintf(EXTRA_TASKARG, arr[0]));
2882
+ return tasks;
2883
+ }
2884
+
2885
+ /**
2886
+ Parse the variable arguments into in/out params, options, tasks
2887
+ */
2888
+ function parseVargs(vargs) {
2889
+ var inOutParamStr = vargs.shift() || '';
2890
+ // if next arg is object, shift it off as options
2891
+ var options = (vargs.length && typeof(vargs[0]) === 'object') ? vargs.shift() : { };
2892
+ var taskDefArr = vargs; // rest are for the tasks
2893
+ var defObj = {
2894
+ inOutParamStr: inOutParamStr,
2895
+ taskDefArr: taskDefArr,
2896
+ options: options
2897
+ };
2898
+ return defObj;
2899
+ }
2900
+
2901
+
2902
+ function dslDefine(name, arg1, arg2, argN) {
2903
+ var reactFn = core();
2904
+ if (name && INOUT_RE.test(name)) throw new Error(sprintf(MISSING_NAME, name));
2905
+ var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
2906
+ var inOutDef = parseInOutParams(defObj.inOutParamStr);
2907
+ var ast = {
2908
+ name: name,
2909
+ inParams: inOutDef.inDef,
2910
+ tasks: parseTasks(defObj.taskDefArr),
2911
+ outTask: { a: inOutDef.outDef }
2912
+ };
2913
+ if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
2914
+ var errors = reactFn.setAndValidateAST(ast);
2915
+ if (errors.length) {
2916
+ var errorStr = errors.join('\n');
2917
+ throw new Error(errorStr);
2918
+ }
2919
+ return reactFn;
2920
+ }
2921
+
2922
+ function selectFirst(name, arg1, arg2, argN) {
2923
+ var reactFn = core();
2924
+ var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
2925
+ var inOutDef = parseInOutParams(defObj.inOutParamStr);
2926
+ var tasks = taskUtil.serializeTasks(parseTasks(defObj.taskDefArr));
2927
+ var ast = {
2928
+ name: name,
2929
+ inParams: inOutDef.inDef,
2930
+ tasks: tasks,
2931
+ outTask: { type: 'finalcbFirst', a: inOutDef.outDef },
2932
+ };
2933
+ if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
2934
+ var errors = reactFn.setAndValidateAST(ast);
2935
+ if (errors.length) {
2936
+ var errorStr = errors.join('\n');
2937
+ throw new Error(errorStr);
2938
+ }
2939
+ return reactFn;
2940
+ }
2941
+
2942
+ dslDefine.selectFirst = selectFirst;
2943
+ return dslDefine;
2944
+
2945
+ });
2946
+
2947
+ /*global define:true */
2948
+
2949
+
2950
+
2951
+ define('react/track-tasks',[], function () {
2952
+
2953
+ /**
2954
+ Track the tasks, start, complete, args, results, elapsed time
2955
+ Emits events that can be monitored
2956
+
2957
+ - track start and complete
2958
+ - record args each task was called with
2959
+ - record results at completion
2960
+ - record start, end, and calc elapsed time
2961
+ - emits flow.begin with flowEnv
2962
+ - emits task.begin with task
2963
+ - emits task.complete with task
2964
+ - emits flow complete with flowEnv
2965
+ - emits flow errored with flowEnv
2966
+
2967
+ @example
2968
+ var react = require('react');
2969
+ react.trackTasks(); // enable task and flow tracking
2970
+ */
2971
+
2972
+
2973
+ var trackingTasks = false;
2974
+
2975
+ function trackTasks(react) {
2976
+ if (trackingTasks) return; // already tracking
2977
+ trackingTasks = true;
2978
+
2979
+ react.events.on(react.events.TYPES.EXEC_FLOW_START, function (env) {
2980
+ env.startTime = Date.now();
2981
+ env.flowEmitter.emit(react.events.TYPES.FLOW_BEGIN, env); //fire public ev
2982
+ });
2983
+
2984
+ react.events.on(react.events.TYPES.EXEC_TASK_START, function (task) {
2985
+ task.startTime = Date.now();
2986
+ task.env.flowEmitter.emit(react.events.TYPES.TASK_BEGIN, task); //fire public ev
2987
+ });
2988
+
2989
+ react.events.on(react.events.TYPES.EXEC_TASK_COMPLETE, function (task) {
2990
+ task.endTime = Date.now();
2991
+ task.elapsedTime = task.endTime - task.startTime;
2992
+ task.env.flowEmitter.emit(react.events.TYPES.TASK_COMPLETE, task); // fire public ev
2993
+ });
2994
+
2995
+ react.events.on(react.events.TYPES.EXEC_TASK_ERRORED, function (task) {
2996
+ task.endTime = Date.now();
2997
+ task.elapsedTime = task.endTime - task.startTime;
2998
+ task.env.flowEmitter.emit(react.events.TYPES.TASK_ERRORED, task); // fire public ev
2999
+ });
3000
+
3001
+ react.events.on(react.events.TYPES.EXEC_FLOW_COMPLETE, function (env) {
3002
+ env.endTime = Date.now();
3003
+ env.elapsedTime = env.endTime - env.startTime;
3004
+ env.flowEmitter.emit(react.events.TYPES.FLOW_COMPLETE, env); //fire public ev
3005
+ });
3006
+
3007
+ react.events.on(react.events.TYPES.EXEC_FLOW_ERRORED, function (env) {
3008
+ env.endTime = Date.now();
3009
+ env.elapsedTime = env.endTime - env.startTime;
3010
+ env.flowEmitter.emit(react.events.TYPES.FLOW_ERRORED, env); //fire public ev
3011
+ });
3012
+
3013
+ }
3014
+
3015
+ return trackTasks;
3016
+
3017
+ });
3018
+
3019
+ /*global define:true */
3020
+
3021
+
3022
+
3023
+ define('react/log-events',['util'], function (util) { // TODO replace util.inspect with something portable to browser
3024
+
3025
+ var logEventsMod = { };
3026
+
3027
+ /**
3028
+ Log events to console.error
3029
+
3030
+ @example
3031
+ var react = require('react');
3032
+ react.logEvents(); // log all task and flow events on all react functions
3033
+ react.logEvents('task.*'); // log all task events on all react functions
3034
+ react.logEvents(flowFn); // log all task and flow events on flowFn only
3035
+ react.logEvents(flowFn, 'flow.*'); // log all flow events on flowFn only
3036
+ */
3037
+
3038
+ var ALL_FLOW_EVENTS = 'flow.*';
3039
+ var ALL_TASK_EVENTS = 'task.*';
3040
+ var FLOW_RE = /^flow\./;
3041
+
3042
+ function flowLog(obj) {
3043
+ /*jshint validthis: true */
3044
+ var time = new Date();
3045
+ time.setTime(obj.time);
3046
+ var argsNoCb = obj.args.filter(function (a) { return (typeof(a) !== 'function'); });
3047
+ var eventTimeStr = time.toISOString();
3048
+ if (this.event === 'flow.complete') {
3049
+ var env = obj;
3050
+ console.error('%s: %s \tmsecs: %s \n\targs: %s \n\tresults: %s\n',
3051
+ this.event, env.name, env.elapsedTime, util.inspect(argsNoCb), util.inspect(env.results));
3052
+ } else {
3053
+ var name = obj.name;
3054
+ var args = obj.args;
3055
+ console.error('%s: %s \n\targs: %s\n', this.event, name, util.inspect(argsNoCb));
3056
+ }
3057
+ }
3058
+
3059
+ function taskLog(obj) {
3060
+ /*jshint validthis: true */
3061
+ var time = new Date();
3062
+ time.setTime(obj.time);
3063
+ var argsNoCb = obj.args.filter(function (a) { return (typeof(a) !== 'function'); });
3064
+ var eventTimeStr = time.toISOString();
3065
+ if (this.event === 'task.complete') {
3066
+ var task = obj;
3067
+ console.error('%s: %s:%s \tmsecs: %s \n\targs: %s \n\tresults: %s\n',
3068
+ this.event, task.env.name, task.name, task.elapsedTime, util.inspect(argsNoCb), util.inspect(task.results));
3069
+ } else {
3070
+ var name = obj.name;
3071
+ var args = obj.args;
3072
+ console.error('%s: %s:%s \n\targs: %s\n', this.event, obj.env.name, obj.name, util.inspect(argsNoCb));
3073
+ }
3074
+
3075
+ }
3076
+
3077
+ /**
3078
+ Log flow and task events for a flowFn or all of react.
3079
+ If called multiple times, remove previous listener (if any) before
3080
+ adding.
3081
+
3082
+ @example
3083
+ var react = require('react');
3084
+ react.logEvents(flowFn, eventWildcard); //log events on flowfn matching wildcard
3085
+
3086
+ @param flowFn Flow function or global react object
3087
+ @param eventWildcard wildcarded event type, if not provided use flow.* and task.*
3088
+ */
3089
+ function logEvents(flowFn, eventWildcard) {
3090
+ if (!flowFn) throw new Error('flowFn is required');
3091
+ if (eventWildcard && eventWildcard !== '*') {
3092
+ var logFn = (FLOW_RE.test(eventWildcard)) ? flowLog : taskLog;
3093
+ flowFn.events.removeListener(eventWildcard, logFn);
3094
+ flowFn.events.on(eventWildcard, logFn);
3095
+ } else { // none provided, use flow.* and task.*
3096
+ //output events as tasks start and complete
3097
+ flowFn.events.removeListener(ALL_FLOW_EVENTS, flowLog);
3098
+ flowFn.events.on(ALL_FLOW_EVENTS, flowLog);
3099
+ flowFn.events.removeListener(ALL_TASK_EVENTS, taskLog);
3100
+ flowFn.events.on(ALL_TASK_EVENTS, taskLog);
3101
+ }
3102
+ }
3103
+
3104
+ logEventsMod.logEvents = logEvents;
3105
+ return logEventsMod;
3106
+
3107
+ });
3108
+
3109
+ /*global define:true */
3110
+
3111
+
3112
+
3113
+ define('react/promise-resolve',[], function () {
3114
+
3115
+ /**
3116
+ Auto resolve promises passed in as arguments to the flow
3117
+
3118
+ - Detects promises by checking for .then()
3119
+ - Create promise name for param (param__promise)
3120
+ - moves existing vCon promise into the param__promise
3121
+ - creates WhenTask which resolves param__promise into param
3122
+ */
3123
+
3124
+
3125
+ var PROMISE_SUFFIX = '__promise'; // added to param names that are promises
3126
+
3127
+ var resolvingPromises = false;
3128
+
3129
+ function resolvePromises(react) {
3130
+ if (resolvingPromises) return; // already resolving
3131
+ resolvingPromises = true;
3132
+
3133
+ react.events.on(react.events.TYPES.EXEC_TASKS_PRECREATE, function (env) {
3134
+ var vConValues = env.vCon.values;
3135
+ var promiseParams = env.ast.inParams.filter(function (p) {
3136
+ var value = vConValues[p];
3137
+ return (value && typeof(value.then) === 'function');
3138
+ });
3139
+ promiseParams.forEach(function (p) {
3140
+ var promiseName = p + PROMISE_SUFFIX;
3141
+ vConValues[promiseName] = vConValues[p];
3142
+ vConValues[p] = undefined;
3143
+ env.taskDefs.push({
3144
+ type: 'when',
3145
+ a: [promiseName],
3146
+ out: [p]
3147
+ });
3148
+ });
3149
+ });
3150
+
3151
+ }
3152
+
3153
+ return resolvePromises;
3154
+
3155
+ });
3156
+
3157
+ /*global define:true */
3158
+
3159
+
3160
+
3161
+ define('react/event-collector',[], function () {
3162
+
3163
+ /**
3164
+ create an instance of the event collector
3165
+ */
3166
+ function instantiate(react) {
3167
+ react.trackTasks(); // enable task tracking
3168
+
3169
+ var AST_EVENTS_RE = /^ast\./;
3170
+ var TASK_EVENTS_RE = /^task\./;
3171
+ var FLOW_EVENTS_RE = /^flow\./;
3172
+
3173
+ /**
3174
+ Accumulator to make it easy to capture events
3175
+
3176
+ @example
3177
+ var react = require('react');
3178
+ var collector = react.createEventCollector();
3179
+ collector.capture(); // capture all flow and task events for all react flows
3180
+ collector.capture('flow.*'); // capture all flow events for all react flows
3181
+ collector.capture(flowFn, 'task.*'); // capture task events on a flow
3182
+ collector.capture(flowFn, 'flow.*'); // add capture flow events on a flow
3183
+ var events = collector.list(); // retrieve the list of events
3184
+ collector.clear(); // clear the list of events;
3185
+ */
3186
+ function EventCollector() {
3187
+ this.events = [];
3188
+ }
3189
+
3190
+ /**
3191
+ register listener to capture events for a specific flow
3192
+ @param flowFn the react flow function or can pass global react
3193
+ @param eventId event id or wildcarded id
3194
+ */
3195
+ EventCollector.prototype.capture = function (flowFn, eventId) {
3196
+ /*jshint validthis: true */
3197
+ if (!eventId && typeof(flowFn) === 'string') { // only eventId provided
3198
+ eventId = flowFn;
3199
+ flowFn = react; // global react
3200
+ } else if (!flowFn) flowFn = react; // global react
3201
+ if (!eventId) eventId = '*'; // default to all
3202
+ var emitter = flowFn.events;
3203
+ var self = this;
3204
+ function accumEvents(obj) {
3205
+ var eventObject = {
3206
+ event: this.event,
3207
+ time: Date.now()
3208
+ };
3209
+ if (FLOW_EVENTS_RE.test(this.event)) {
3210
+ eventObject.env = obj;
3211
+ } else if (TASK_EVENTS_RE.test(this.event)) {
3212
+ eventObject.task = obj;
3213
+ } else if (AST_EVENTS_RE.test(this.event)) {
3214
+ eventObject.ast = obj;
3215
+ }
3216
+ self.events.push(eventObject);
3217
+ }
3218
+ emitter.on(eventId, accumEvents);
3219
+ };
3220
+
3221
+ EventCollector.prototype.list = function () {
3222
+ return this.events;
3223
+ };
3224
+
3225
+ EventCollector.prototype.clear = function () {
3226
+ this.events = []; // clear
3227
+ };
3228
+
3229
+ return new EventCollector();
3230
+ }
3231
+
3232
+ return instantiate; // return the factory for creating EventCollector
3233
+
3234
+ });
3235
+
3236
+ /*global define:true */
3237
+
3238
+
3239
+
3240
+ define('react',['./core', './dsl', './track-tasks', './log-events', './promise-resolve', './event-collector'],
3241
+ function (core, dsl, trackTasksFn, logEventsMod, resolvePromisesFn, eventCollectorFactory) {
3242
+
3243
+ var react = dsl; // core + default dsl
3244
+
3245
+ /**
3246
+ Enable detection of promises and resolution
3247
+ */
3248
+ function resolvePromises() {
3249
+ resolvePromisesFn(react);
3250
+ }
3251
+
3252
+ /**
3253
+ Enable tracking of tasks and flow execution, emitting events and
3254
+ tracking start, end, elapsed time
3255
+ */
3256
+ function trackTasks() {
3257
+ trackTasksFn(react);
3258
+ }
3259
+
3260
+ /**
3261
+ If called, load the built-in plugin for log events and invoke
3262
+
3263
+ @param flowFn [function] if not provided uses global react
3264
+ @param eventWildcard [string] pattern to log events for
3265
+ */
3266
+ function logEvents(flowFn, eventWildcard) {
3267
+ if (!eventWildcard && typeof(flowFn) === 'string') { // only wildcard provided
3268
+ eventWildcard = flowFn;
3269
+ flowFn = undefined;
3270
+ }
3271
+ if (!flowFn) flowFn = react; // use global
3272
+ trackTasks();
3273
+ return logEventsMod.logEvents(flowFn, eventWildcard);
3274
+ }
3275
+
3276
+ /**
3277
+ Instantiate an event collector
3278
+ */
3279
+ function createEventCollector() {
3280
+ return eventCollectorFactory(react);
3281
+ }
3282
+
3283
+ react.options = core.options; // global react options
3284
+ react.events = core.events; // global react event emitter
3285
+ react.logEvents = logEvents; // enable event logging
3286
+ react.resolvePromises = resolvePromises; // enable promise resolution
3287
+ react.trackTasks = trackTasks; // enable tracking of tasks
3288
+ react.createEventCollector = createEventCollector; // create instance of EventCollector
3289
+ return react;
3290
+
3291
+ });