traceur-rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +87 -0
  10. data/Rakefile +2 -0
  11. data/lib/js/compile.js +31 -0
  12. data/lib/traceur-rb.rb +1 -0
  13. data/lib/traceur.rb +43 -0
  14. data/lib/traceur/compilation_options.rb +65 -0
  15. data/lib/traceur/compiler.rb +33 -0
  16. data/lib/traceur/configuration.rb +47 -0
  17. data/lib/traceur/node.rb +26 -0
  18. data/lib/traceur/node/command_result.rb +28 -0
  19. data/lib/traceur/node/runner.rb +40 -0
  20. data/lib/traceur/version.rb +3 -0
  21. data/spec/examples/classes.js +12 -0
  22. data/spec/integration/examples_spec.rb +28 -0
  23. data/spec/spec_helper.rb +1 -0
  24. data/spec/traceur/compilation_options_spec.rb +31 -0
  25. data/spec/traceur/configuration_spec.rb +54 -0
  26. data/spec/traceur/node_spec.rb +15 -0
  27. data/traceur-rb.gemspec +25 -0
  28. data/vendor/node_modules/.bin/traceur +3 -0
  29. data/vendor/node_modules/traceur/README.md +40 -0
  30. data/vendor/node_modules/traceur/bin/traceur-runtime.js +2101 -0
  31. data/vendor/node_modules/traceur/bin/traceur.js +23034 -0
  32. data/vendor/node_modules/traceur/node_modules/.bin/semver +125 -0
  33. data/vendor/node_modules/traceur/node_modules/commander/Readme.md +208 -0
  34. data/vendor/node_modules/traceur/node_modules/commander/index.js +852 -0
  35. data/vendor/node_modules/traceur/node_modules/commander/package.json +40 -0
  36. data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +1 -0
  37. data/vendor/node_modules/traceur/node_modules/q-io/.travis.yml +3 -0
  38. data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +122 -0
  39. data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +19 -0
  40. data/vendor/node_modules/traceur/node_modules/q-io/README.md +928 -0
  41. data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +59 -0
  42. data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +44 -0
  43. data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +51 -0
  44. data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +307 -0
  45. data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +499 -0
  46. data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +547 -0
  47. data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +105 -0
  48. data/vendor/node_modules/traceur/node_modules/q-io/fs.js +355 -0
  49. data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +65 -0
  50. data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +152 -0
  51. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +24 -0
  52. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +93 -0
  53. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +154 -0
  54. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +178 -0
  55. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +417 -0
  56. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +58 -0
  57. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +78 -0
  58. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +120 -0
  59. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +27 -0
  60. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +209 -0
  61. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +125 -0
  62. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +175 -0
  63. data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +75 -0
  64. data/vendor/node_modules/traceur/node_modules/q-io/http.js +378 -0
  65. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +11 -0
  66. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.travis.yml +4 -0
  67. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +78 -0
  68. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +21 -0
  69. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +1285 -0
  70. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +22 -0
  71. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +142 -0
  72. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +57 -0
  73. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +183 -0
  74. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +261 -0
  75. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +186 -0
  76. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +55 -0
  77. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +59 -0
  78. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +236 -0
  79. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +371 -0
  80. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +435 -0
  81. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +247 -0
  82. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +147 -0
  83. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +448 -0
  84. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +139 -0
  85. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +79 -0
  86. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +142 -0
  87. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +60 -0
  88. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +41 -0
  89. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +12 -0
  90. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +7 -0
  91. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +48 -0
  92. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +590 -0
  93. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +49 -0
  94. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +173 -0
  95. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +274 -0
  96. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +59 -0
  97. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +538 -0
  98. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +14 -0
  99. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +6 -0
  100. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +49 -0
  101. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +51 -0
  102. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +269 -0
  103. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +61 -0
  104. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +736 -0
  105. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +40 -0
  106. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +1 -0
  107. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/LICENSE +19 -0
  108. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +66 -0
  109. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +114 -0
  110. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +35 -0
  111. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +84 -0
  112. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +1588 -0
  113. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +77 -0
  114. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +15 -0
  115. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +19 -0
  116. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +96 -0
  117. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +166 -0
  118. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +43 -0
  119. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +40 -0
  120. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +19 -0
  121. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +813 -0
  122. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +71 -0
  123. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +36 -0
  124. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +93 -0
  125. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +1937 -0
  126. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +35 -0
  127. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +6 -0
  128. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +36 -0
  129. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +7 -0
  130. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +38 -0
  131. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +32 -0
  132. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +39 -0
  133. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +2 -0
  134. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +123 -0
  135. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +19 -0
  136. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +3 -0
  137. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +3 -0
  138. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +128 -0
  139. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +53 -0
  140. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +61 -0
  141. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +856 -0
  142. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +1080 -0
  143. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +377 -0
  144. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +290 -0
  145. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
  146. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
  147. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +4 -0
  148. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +16 -0
  149. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +12 -0
  150. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +91 -0
  151. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +12 -0
  152. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +13 -0
  153. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +14 -0
  154. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +146 -0
  155. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
  156. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
  157. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +3 -0
  158. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +22 -0
  159. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +6 -0
  160. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +248 -0
  161. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +53 -0
  162. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +2 -0
  163. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +91 -0
  164. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +548 -0
  165. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +8 -0
  166. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +358 -0
  167. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +133 -0
  168. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +3 -0
  169. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.travis.yml +4 -0
  170. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +20 -0
  171. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +33 -0
  172. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +37 -0
  173. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +125 -0
  174. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +151 -0
  175. data/vendor/node_modules/traceur/node_modules/q-io/package.json +51 -0
  176. data/vendor/node_modules/traceur/node_modules/q-io/reader.js +133 -0
  177. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +47 -0
  178. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +11 -0
  179. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +1 -0
  180. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +33 -0
  181. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +92 -0
  182. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +41 -0
  183. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +57 -0
  184. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +1 -0
  185. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +70 -0
  186. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +109 -0
  187. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +67 -0
  188. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +219 -0
  189. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +20 -0
  190. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +26 -0
  191. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +40 -0
  192. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +37 -0
  193. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +39 -0
  194. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +32 -0
  195. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +26 -0
  196. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +86 -0
  197. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +31 -0
  198. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +73 -0
  199. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +23 -0
  200. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +1 -0
  201. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +22 -0
  202. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +25 -0
  203. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +45 -0
  204. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +38 -0
  205. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +52 -0
  206. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +86 -0
  207. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +1 -0
  208. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +1 -0
  209. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
  210. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
  211. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +49 -0
  212. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +47 -0
  213. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +186 -0
  214. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +82 -0
  215. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +110 -0
  216. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +96 -0
  217. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +96 -0
  218. data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +42 -0
  219. data/vendor/node_modules/traceur/node_modules/q-io/writer.js +111 -0
  220. data/vendor/node_modules/traceur/node_modules/semver/.npmignore +1 -0
  221. data/vendor/node_modules/traceur/node_modules/semver/LICENSE +27 -0
  222. data/vendor/node_modules/traceur/node_modules/semver/Makefile +24 -0
  223. data/vendor/node_modules/traceur/node_modules/semver/README.md +158 -0
  224. data/vendor/node_modules/traceur/node_modules/semver/bin/semver +125 -0
  225. data/vendor/node_modules/traceur/node_modules/semver/foot.js +6 -0
  226. data/vendor/node_modules/traceur/node_modules/semver/head.js +2 -0
  227. data/vendor/node_modules/traceur/node_modules/semver/package.json +31 -0
  228. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +1039 -0
  229. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
  230. data/vendor/node_modules/traceur/node_modules/semver/semver.js +1043 -0
  231. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -0
  232. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
  233. data/vendor/node_modules/traceur/node_modules/semver/test/amd.js +15 -0
  234. data/vendor/node_modules/traceur/node_modules/semver/test/gtr.js +173 -0
  235. data/vendor/node_modules/traceur/node_modules/semver/test/index.js +584 -0
  236. data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +174 -0
  237. data/vendor/node_modules/traceur/node_modules/semver/test/no-module.js +19 -0
  238. data/vendor/node_modules/traceur/package.json +64 -0
  239. data/vendor/node_modules/traceur/src/node/System.js +31 -0
  240. data/vendor/node_modules/traceur/src/node/api.js +124 -0
  241. data/vendor/node_modules/traceur/src/node/command.js +141 -0
  242. data/vendor/node_modules/traceur/src/node/compile-single-file.js +69 -0
  243. data/vendor/node_modules/traceur/src/node/compiler.js +116 -0
  244. data/vendor/node_modules/traceur/src/node/deferred.js +110 -0
  245. data/vendor/node_modules/traceur/src/node/file-util.js +73 -0
  246. data/vendor/node_modules/traceur/src/node/getopt.js +147 -0
  247. data/vendor/node_modules/traceur/src/node/inline-module.js +149 -0
  248. data/vendor/node_modules/traceur/src/node/interpreter.js +33 -0
  249. data/vendor/node_modules/traceur/src/node/nodeLoader.js +41 -0
  250. data/vendor/node_modules/traceur/src/node/require.js +85 -0
  251. data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +33 -0
  252. data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +33 -0
  253. data/vendor/node_modules/traceur/src/node/traceur.js +32 -0
  254. data/vendor/node_modules/traceur/traceur +3 -0
  255. metadata +359 -0
@@ -0,0 +1,247 @@
1
+ /*
2
+ Based in part on observable arrays from Motorola Mobility’s Montage
3
+ Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.
4
+ 3-Clause BSD License
5
+ https://github.com/motorola-mobility/montage/blob/master/LICENSE.md
6
+ */
7
+
8
+ /*
9
+ This module is responsible for observing changes to owned properties of
10
+ objects and changes to the content of arrays caused by method calls.
11
+ The interface for observing array content changes establishes the methods
12
+ necessary for any collection with observable content.
13
+ */
14
+
15
+ require("../shim");
16
+ var List = require("../list");
17
+ var WeakMap = require("weak-map");
18
+ var PropertyChanges = require("./property-changes");
19
+ var RangeChanges = require("./range-changes");
20
+ var MapChanges = require("./map-changes");
21
+
22
+ var array_splice = Array.prototype.splice;
23
+ var array_slice = Array.prototype.slice;
24
+ var array_reverse = Array.prototype.reverse;
25
+ var array_sort = Array.prototype.sort;
26
+
27
+ // use different strategies for making arrays observable between Internet
28
+ // Explorer and other browsers.
29
+ var protoIsSupported = {}.__proto__ === Object.prototype;
30
+ var array_makeObservable;
31
+ if (protoIsSupported) {
32
+ array_makeObservable = function () {
33
+ this.__proto__ = ChangeDispatchArray;
34
+ };
35
+ } else {
36
+ array_makeObservable = function () {
37
+ Object.defineProperties(this, observableArrayProperties);
38
+ };
39
+ }
40
+
41
+ Object.defineProperty(Array.prototype, "makeObservable", {
42
+ value: array_makeObservable,
43
+ writable: true,
44
+ configurable: true,
45
+ enumerable: false
46
+ });
47
+
48
+ function defineEach(prototype) {
49
+ for (var name in prototype) {
50
+ Object.defineProperty(Array.prototype, name, {
51
+ value: prototype[name],
52
+ writable: true,
53
+ configurable: true,
54
+ enumerable: false
55
+ });
56
+ }
57
+ }
58
+
59
+ defineEach(PropertyChanges.prototype);
60
+ defineEach(RangeChanges.prototype);
61
+ defineEach(MapChanges.prototype);
62
+
63
+ var observableArrayProperties = {
64
+
65
+ isObservable: {
66
+ value: true,
67
+ writable: true,
68
+ configurable: true
69
+ },
70
+
71
+ makeObservable: {
72
+ value: Function.noop, // idempotent
73
+ writable: true,
74
+ configurable: true
75
+ },
76
+
77
+ reverse: {
78
+ value: function reverse() {
79
+
80
+ var reversed = this.constructClone(this);
81
+ reversed.reverse();
82
+ this.swap(0, this.length, reversed);
83
+
84
+ return this;
85
+ },
86
+ writable: true,
87
+ configurable: true
88
+ },
89
+
90
+ sort: {
91
+ value: function sort() {
92
+
93
+ // dispatch before change events
94
+ this.dispatchBeforeRangeChange(this, this, 0);
95
+ for (var i = 0; i < this.length; i++) {
96
+ PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
97
+ this.dispatchBeforeMapChange(i, this[i]);
98
+ }
99
+
100
+ // actual work
101
+ array_sort.apply(this, arguments);
102
+
103
+ // dispatch after change events
104
+ for (var i = 0; i < this.length; i++) {
105
+ PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
106
+ this.dispatchMapChange(i, this[i]);
107
+ }
108
+ this.dispatchRangeChange(this, this, 0);
109
+
110
+ return this;
111
+ },
112
+ writable: true,
113
+ configurable: true
114
+ },
115
+
116
+ splice: {
117
+ value: function splice(start, length) {
118
+ var minus = array_slice.call(this, start, start + length);
119
+ var plus = array_slice.call(arguments, 2);
120
+ if (!minus.length && !plus.length)
121
+ return plus; // [], but spare us an instantiation
122
+ var diff = plus.length - minus.length;
123
+ var oldLength = this.length;
124
+ var newLength = Math.max(this.length + diff, start + plus.length);
125
+ var longest = Math.max(oldLength, newLength);
126
+
127
+ // dispatch before change events
128
+ if (diff) {
129
+ PropertyChanges.dispatchBeforeOwnPropertyChange(this, "length", this.length);
130
+ }
131
+ this.dispatchBeforeRangeChange(plus, minus, start);
132
+ if (diff === 0) { // substring replacement
133
+ for (var i = start; i < start + plus.length; i++) {
134
+ PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
135
+ this.dispatchBeforeMapChange(i, this[i]);
136
+ }
137
+ } else if (PropertyChanges.hasOwnPropertyChangeDescriptor(this)) {
138
+ // all subsequent values changed or shifted.
139
+ // avoid (longest - start) long walks if there are no
140
+ // registered descriptors.
141
+ for (var i = start; i < longest; i++) {
142
+ PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
143
+ this.dispatchBeforeMapChange(i, this[i]);
144
+ }
145
+ }
146
+
147
+ // actual work
148
+ if (start > oldLength) {
149
+ this.length = start;
150
+ }
151
+ var result = array_splice.apply(this, arguments);
152
+
153
+ // dispatch after change events
154
+ if (diff === 0) { // substring replacement
155
+ for (var i = start; i < start + plus.length; i++) {
156
+ PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
157
+ this.dispatchMapChange(i, this[i]);
158
+ }
159
+ } else if (PropertyChanges.hasOwnPropertyChangeDescriptor(this)) {
160
+ // all subsequent values changed or shifted.
161
+ // avoid (longest - start) long walks if there are no
162
+ // registered descriptors.
163
+ for (var i = start; i < longest; i++) {
164
+ PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
165
+ this.dispatchMapChange(i, this[i]);
166
+ }
167
+ }
168
+ this.dispatchRangeChange(plus, minus, start);
169
+ if (diff) {
170
+ PropertyChanges.dispatchOwnPropertyChange(this, "length", this.length);
171
+ }
172
+
173
+ return result;
174
+ },
175
+ writable: true,
176
+ configurable: true
177
+ },
178
+
179
+ // splice is the array content change utility belt. forward all other
180
+ // content changes to splice so we only have to write observer code in one
181
+ // place
182
+
183
+ set: {
184
+ value: function set(index, value) {
185
+ this.splice(index, 1, value);
186
+ return this;
187
+ },
188
+ writable: true,
189
+ configurable: true
190
+ },
191
+
192
+ shift: {
193
+ value: function shift() {
194
+ return this.splice(0, 1)[0];
195
+ },
196
+ writable: true,
197
+ configurable: true
198
+ },
199
+
200
+ pop: {
201
+ value: function pop() {
202
+ if (this.length) {
203
+ return this.splice(this.length - 1, 1)[0];
204
+ }
205
+ },
206
+ writable: true,
207
+ configurable: true
208
+ },
209
+
210
+ push: {
211
+ value: function push(arg) {
212
+ if (arguments.length === 1) {
213
+ return this.splice(this.length, 0, arg);
214
+ } else {
215
+ var args = array_slice.call(arguments);
216
+ return this.swap(this.length, 0, args);
217
+ }
218
+ },
219
+ writable: true,
220
+ configurable: true
221
+ },
222
+
223
+ unshift: {
224
+ value: function unshift(arg) {
225
+ if (arguments.length === 1) {
226
+ return this.splice(0, 0, arg);
227
+ } else {
228
+ var args = array_slice.call(arguments);
229
+ return this.swap(0, 0, args);
230
+ }
231
+ },
232
+ writable: true,
233
+ configurable: true
234
+ },
235
+
236
+ clear: {
237
+ value: function clear() {
238
+ return this.splice(0, this.length);
239
+ },
240
+ writable: true,
241
+ configurable: true
242
+ }
243
+
244
+ };
245
+
246
+ var ChangeDispatchArray = Object.create(Array.prototype, observableArrayProperties);
247
+
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+ var WeakMap = require("weak-map");
4
+ var List = require("../list");
5
+
6
+ module.exports = MapChanges;
7
+ function MapChanges() {
8
+ throw new Error("Can't construct. MapChanges is a mixin.");
9
+ }
10
+
11
+ var object_owns = Object.prototype.hasOwnProperty;
12
+
13
+ /*
14
+ Object map change descriptors carry information necessary for adding,
15
+ removing, dispatching, and shorting events to listeners for map changes
16
+ for a particular key on a particular object. These descriptors are used
17
+ here for shallow map changes.
18
+
19
+ {
20
+ willChangeListeners:Array(Function)
21
+ changeListeners:Array(Function)
22
+ }
23
+ */
24
+
25
+ var mapChangeDescriptors = new WeakMap();
26
+
27
+ MapChanges.prototype.getAllMapChangeDescriptors = function () {
28
+ var Dict = require("../dict");
29
+ if (!mapChangeDescriptors.has(this)) {
30
+ mapChangeDescriptors.set(this, Dict());
31
+ }
32
+ return mapChangeDescriptors.get(this);
33
+ };
34
+
35
+ MapChanges.prototype.getMapChangeDescriptor = function (token) {
36
+ var tokenChangeDescriptors = this.getAllMapChangeDescriptors();
37
+ token = token || "";
38
+ if (!tokenChangeDescriptors.has(token)) {
39
+ tokenChangeDescriptors.set(token, {
40
+ willChangeListeners: new List(),
41
+ changeListeners: new List()
42
+ });
43
+ }
44
+ return tokenChangeDescriptors.get(token);
45
+ };
46
+
47
+ MapChanges.prototype.addMapChangeListener = function (listener, token, beforeChange) {
48
+ if (!this.isObservable && this.makeObservable) {
49
+ // for Array
50
+ this.makeObservable();
51
+ }
52
+ var descriptor = this.getMapChangeDescriptor(token);
53
+ var listeners;
54
+ if (beforeChange) {
55
+ listeners = descriptor.willChangeListeners;
56
+ } else {
57
+ listeners = descriptor.changeListeners;
58
+ }
59
+ listeners.push(listener);
60
+ Object.defineProperty(this, "dispatchesMapChanges", {
61
+ value: true,
62
+ writable: true,
63
+ configurable: true,
64
+ enumerable: false
65
+ });
66
+
67
+ var self = this;
68
+ return function cancelMapChangeListener() {
69
+ if (!self) {
70
+ // TODO throw new Error("Can't remove map change listener again");
71
+ return;
72
+ }
73
+ self.removeMapChangeListener(listener, token, beforeChange);
74
+ self = null;
75
+ };
76
+ };
77
+
78
+ MapChanges.prototype.removeMapChangeListener = function (listener, token, beforeChange) {
79
+ var descriptor = this.getMapChangeDescriptor(token);
80
+
81
+ var listeners;
82
+ if (beforeChange) {
83
+ listeners = descriptor.willChangeListeners;
84
+ } else {
85
+ listeners = descriptor.changeListeners;
86
+ }
87
+
88
+ var node = listeners.findLast(listener);
89
+ if (!node) {
90
+ throw new Error("Can't remove listener: does not exist.");
91
+ }
92
+ node["delete"]();
93
+ };
94
+
95
+ MapChanges.prototype.dispatchMapChange = function (key, value, beforeChange) {
96
+ var descriptors = this.getAllMapChangeDescriptors();
97
+ var changeName = "Map" + (beforeChange ? "WillChange" : "Change");
98
+ descriptors.forEach(function (descriptor, token) {
99
+
100
+ if (descriptor.isActive) {
101
+ return;
102
+ } else {
103
+ descriptor.isActive = true;
104
+ }
105
+
106
+ var listeners;
107
+ if (beforeChange) {
108
+ listeners = descriptor.willChangeListeners;
109
+ } else {
110
+ listeners = descriptor.changeListeners;
111
+ }
112
+
113
+ var tokenName = "handle" + (
114
+ token.slice(0, 1).toUpperCase() +
115
+ token.slice(1)
116
+ ) + changeName;
117
+
118
+ try {
119
+ // dispatch to each listener
120
+ listeners.forEach(function (listener) {
121
+ if (listener[tokenName]) {
122
+ listener[tokenName](value, key, this);
123
+ } else if (listener.call) {
124
+ listener.call(listener, value, key, this);
125
+ } else {
126
+ throw new Error("Handler " + listener + " has no method " + tokenName + " and is not callable");
127
+ }
128
+ }, this);
129
+ } finally {
130
+ descriptor.isActive = false;
131
+ }
132
+
133
+ }, this);
134
+ };
135
+
136
+ MapChanges.prototype.addBeforeMapChangeListener = function (listener, token) {
137
+ return this.addMapChangeListener(listener, token, true);
138
+ };
139
+
140
+ MapChanges.prototype.removeBeforeMapChangeListener = function (listener, token) {
141
+ return this.removeMapChangeListener(listener, token, true);
142
+ };
143
+
144
+ MapChanges.prototype.dispatchBeforeMapChange = function (key, value) {
145
+ return this.dispatchMapChange(key, value, true);
146
+ };
147
+
@@ -0,0 +1,448 @@
1
+ /*
2
+ Based in part on observable arrays from Motorola Mobility’s Montage
3
+ Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.
4
+ 3-Clause BSD License
5
+ https://github.com/motorola-mobility/montage/blob/master/LICENSE.md
6
+ */
7
+
8
+ /*
9
+ This module is responsible for observing changes to owned properties of
10
+ objects and changes to the content of arrays caused by method calls.
11
+ The interface for observing array content changes establishes the methods
12
+ necessary for any collection with observable content.
13
+ */
14
+
15
+ require("../shim");
16
+ var WeakMap = require("weak-map");
17
+
18
+ var object_owns = Object.prototype.hasOwnProperty;
19
+
20
+ /*
21
+ Object property descriptors carry information necessary for adding,
22
+ removing, dispatching, and shorting events to listeners for property changes
23
+ for a particular key on a particular object. These descriptors are used
24
+ here for shallow property changes.
25
+
26
+ {
27
+ willChangeListeners:Array(Function)
28
+ changeListeners:Array(Function)
29
+ }
30
+ */
31
+ var propertyChangeDescriptors = new WeakMap();
32
+
33
+ // Maybe remove entries from this table if the corresponding object no longer
34
+ // has any property change listeners for any key. However, the cost of
35
+ // book-keeping is probably not warranted since it would be rare for an
36
+ // observed object to no longer be observed unless it was about to be disposed
37
+ // of or reused as an observable. The only benefit would be in avoiding bulk
38
+ // calls to dispatchOwnPropertyChange events on objects that have no listeners.
39
+
40
+ /*
41
+ To observe shallow property changes for a particular key of a particular
42
+ object, we install a property descriptor on the object that overrides the previous
43
+ descriptor. The overridden descriptors are stored in this weak map. The
44
+ weak map associates an object with another object that maps property names
45
+ to property descriptors.
46
+
47
+ overriddenObjectDescriptors.get(object)[key]
48
+
49
+ We retain the old descriptor for various purposes. For one, if the property
50
+ is no longer being observed by anyone, we revert the property descriptor to
51
+ the original. For "value" descriptors, we store the actual value of the
52
+ descriptor on the overridden descriptor, so when the property is reverted, it
53
+ retains the most recently set value. For "get" and "set" descriptors,
54
+ we observe then forward "get" and "set" operations to the original descriptor.
55
+ */
56
+ var overriddenObjectDescriptors = new WeakMap();
57
+
58
+ module.exports = PropertyChanges;
59
+
60
+ function PropertyChanges() {
61
+ throw new Error("This is an abstract interface. Mix it. Don't construct it");
62
+ }
63
+
64
+ PropertyChanges.debug = true;
65
+
66
+ PropertyChanges.prototype.getOwnPropertyChangeDescriptor = function (key) {
67
+ if (!propertyChangeDescriptors.has(this)) {
68
+ propertyChangeDescriptors.set(this, {});
69
+ }
70
+ var objectPropertyChangeDescriptors = propertyChangeDescriptors.get(this);
71
+ if (!object_owns.call(objectPropertyChangeDescriptors, key)) {
72
+ objectPropertyChangeDescriptors[key] = {
73
+ willChangeListeners: [],
74
+ changeListeners: []
75
+ };
76
+ }
77
+ return objectPropertyChangeDescriptors[key];
78
+ };
79
+
80
+ PropertyChanges.prototype.hasOwnPropertyChangeDescriptor = function (key) {
81
+ if (!propertyChangeDescriptors.has(this)) {
82
+ return false;
83
+ }
84
+ if (!key) {
85
+ return true;
86
+ }
87
+ var objectPropertyChangeDescriptors = propertyChangeDescriptors.get(this);
88
+ if (!object_owns.call(objectPropertyChangeDescriptors, key)) {
89
+ return false;
90
+ }
91
+ return true;
92
+ };
93
+
94
+ PropertyChanges.prototype.addOwnPropertyChangeListener = function (key, listener, beforeChange) {
95
+ if (this.makeObservable && !this.isObservable) {
96
+ this.makeObservable(); // particularly for observable arrays, for
97
+ // their length property
98
+ }
99
+ var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);
100
+ var listeners;
101
+ if (beforeChange) {
102
+ listeners = descriptor.willChangeListeners;
103
+ } else {
104
+ listeners = descriptor.changeListeners;
105
+ }
106
+ PropertyChanges.makePropertyObservable(this, key);
107
+ listeners.push(listener);
108
+
109
+ var self = this;
110
+ return function cancelOwnPropertyChangeListener() {
111
+ PropertyChanges.removeOwnPropertyChangeListener(self, key, listeners, beforeChange);
112
+ self = null;
113
+ };
114
+ };
115
+
116
+ PropertyChanges.prototype.addBeforeOwnPropertyChangeListener = function (key, listener) {
117
+ return PropertyChanges.addOwnPropertyChangeListener(this, key, listener, true);
118
+ };
119
+
120
+ PropertyChanges.prototype.removeOwnPropertyChangeListener = function (key, listener, beforeChange) {
121
+ var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);
122
+
123
+ var listeners;
124
+ if (beforeChange) {
125
+ listeners = descriptor.willChangeListeners;
126
+ } else {
127
+ listeners = descriptor.changeListeners;
128
+ }
129
+
130
+ var index = listeners.lastIndexOf(listener);
131
+ if (index === -1) {
132
+ throw new Error("Can't remove listener: does not exist.");
133
+ }
134
+ listeners.splice(index, 1);
135
+
136
+ if (descriptor.changeListeners.length + descriptor.willChangeListeners.length === 0) {
137
+ PropertyChanges.makePropertyUnobservable(this, key);
138
+ }
139
+ };
140
+
141
+ PropertyChanges.prototype.removeBeforeOwnPropertyChangeListener = function (key, listener) {
142
+ return PropertyChanges.removeOwnPropertyChangeListener(this, key, listener, true);
143
+ };
144
+
145
+ PropertyChanges.prototype.dispatchOwnPropertyChange = function (key, value, beforeChange) {
146
+ var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);
147
+
148
+ if (descriptor.isActive) {
149
+ return;
150
+ }
151
+ descriptor.isActive = true;
152
+
153
+ var listeners;
154
+ if (beforeChange) {
155
+ listeners = descriptor.willChangeListeners;
156
+ } else {
157
+ listeners = descriptor.changeListeners;
158
+ }
159
+
160
+ var changeName = (beforeChange ? "Will" : "") + "Change";
161
+ var genericHandlerName = "handleProperty" + changeName;
162
+ var propertyName = String(key);
163
+ propertyName = propertyName && propertyName[0].toUpperCase() + propertyName.slice(1);
164
+ var specificHandlerName = "handle" + propertyName + changeName;
165
+
166
+ try {
167
+ // dispatch to each listener
168
+ listeners.forEach(function (listener) {
169
+ var thisp = listener;
170
+ listener = (
171
+ listener[specificHandlerName] ||
172
+ listener[genericHandlerName] ||
173
+ listener
174
+ );
175
+ if (!listener.call) {
176
+ throw new Error("No event listener for " + specificHandlerName + " or " + genericHandlerName + " or call on " + listener);
177
+ }
178
+ listener.call(thisp, value, key, this);
179
+ }, this);
180
+ } finally {
181
+ descriptor.isActive = false;
182
+ }
183
+ };
184
+
185
+ PropertyChanges.prototype.dispatchBeforeOwnPropertyChange = function (key, listener) {
186
+ return PropertyChanges.dispatchOwnPropertyChange(this, key, listener, true);
187
+ };
188
+
189
+ PropertyChanges.prototype.makePropertyObservable = function (key) {
190
+ // arrays are special. we do not support direct setting of properties
191
+ // on an array. instead, call .set(index, value). this is observable.
192
+ // 'length' property is observable for all mutating methods because
193
+ // our overrides explicitly dispatch that change.
194
+ if (Array.isArray(this)) {
195
+ return;
196
+ }
197
+
198
+ if (!Object.isExtensible(this, key)) {
199
+ throw new Error("Can't make property " + JSON.stringify(key) + " observable on " + this + " because object is not extensible");
200
+ }
201
+
202
+ var state;
203
+ if (typeof this.__state__ === "object") {
204
+ state = this.__state__;
205
+ } else {
206
+ state = {};
207
+ if (Object.isExtensible(this, "__state__")) {
208
+ Object.defineProperty(this, "__state__", {
209
+ value: state,
210
+ writable: true,
211
+ enumerable: false
212
+ });
213
+ }
214
+ }
215
+ state[key] = this[key];
216
+
217
+ // memoize overridden property descriptor table
218
+ if (!overriddenObjectDescriptors.has(this)) {
219
+ overriddenPropertyDescriptors = {};
220
+ overriddenObjectDescriptors.set(this, overriddenPropertyDescriptors);
221
+ }
222
+ var overriddenPropertyDescriptors = overriddenObjectDescriptors.get(this);
223
+
224
+ if (object_owns.call(overriddenPropertyDescriptors, key)) {
225
+ // if we have already recorded an overridden property descriptor,
226
+ // we have already installed the observer, so short-here
227
+ return;
228
+ }
229
+
230
+ // walk up the prototype chain to find a property descriptor for
231
+ // the property name
232
+ var overriddenDescriptor;
233
+ var attached = this;
234
+ var formerDescriptor = Object.getOwnPropertyDescriptor(attached, key);
235
+ do {
236
+ overriddenDescriptor = Object.getOwnPropertyDescriptor(attached, key);
237
+ if (overriddenDescriptor) {
238
+ break;
239
+ }
240
+ attached = Object.getPrototypeOf(attached);
241
+ } while (attached);
242
+ // or default to an undefined value
243
+ overriddenDescriptor = overriddenDescriptor || {
244
+ value: undefined,
245
+ enumerable: true,
246
+ writable: true,
247
+ configurable: true
248
+ };
249
+
250
+ if (!overriddenDescriptor.configurable) {
251
+ throw new Error("Can't observe non-configurable properties");
252
+ }
253
+
254
+ // memoize the descriptor so we know not to install another layer,
255
+ // and so we can reuse the overridden descriptor when uninstalling
256
+ overriddenPropertyDescriptors[key] = overriddenDescriptor;
257
+
258
+ // give up *after* storing the overridden property descriptor so it
259
+ // can be restored by uninstall. Unwritable properties are
260
+ // silently not overriden. Since success is indistinguishable from
261
+ // failure, we let it pass but don't waste time on intercepting
262
+ // get/set.
263
+ if (!overriddenDescriptor.writable && !overriddenDescriptor.set) {
264
+ return;
265
+ }
266
+
267
+ // TODO reflect current value on a displayed property
268
+
269
+ var propertyListener;
270
+ // in both of these new descriptor variants, we reuse the overridden
271
+ // descriptor to either store the current value or apply getters
272
+ // and setters. this is handy since we can reuse the overridden
273
+ // descriptor if we uninstall the observer. We even preserve the
274
+ // assignment semantics, where we get the value from up the
275
+ // prototype chain, and set as an owned property.
276
+ if ('value' in overriddenDescriptor) {
277
+ propertyListener = {
278
+ get: function () {
279
+ return overriddenDescriptor.value
280
+ },
281
+ set: function (value) {
282
+ if (value === overriddenDescriptor.value) {
283
+ return value;
284
+ }
285
+ PropertyChanges.dispatchBeforeOwnPropertyChange(this, key, overriddenDescriptor.value);
286
+ overriddenDescriptor.value = value;
287
+ state[key] = value;
288
+ PropertyChanges.dispatchOwnPropertyChange(this, key, value);
289
+ return value;
290
+ },
291
+ enumerable: overriddenDescriptor.enumerable,
292
+ configurable: true
293
+ };
294
+ } else { // 'get' or 'set', but not necessarily both
295
+ propertyListener = {
296
+ get: function () {
297
+ if (overriddenDescriptor.get) {
298
+ return overriddenDescriptor.get.apply(this, arguments);
299
+ }
300
+ },
301
+ set: function (value) {
302
+ var formerValue;
303
+
304
+ // get the actual former value if possible
305
+ if (overriddenDescriptor.get) {
306
+ formerValue = overriddenDescriptor.get.apply(this, arguments);
307
+ }
308
+ // call through to actual setter
309
+ if (overriddenDescriptor.set) {
310
+ overriddenDescriptor.set.apply(this, arguments)
311
+ }
312
+ // use getter, if possible, to discover whether the set
313
+ // was successful
314
+ if (overriddenDescriptor.get) {
315
+ value = overriddenDescriptor.get.apply(this, arguments);
316
+ state[key] = value;
317
+ }
318
+ // if it has not changed, suppress a notification
319
+ if (value === formerValue) {
320
+ return value;
321
+ }
322
+ PropertyChanges.dispatchBeforeOwnPropertyChange(this, key, formerValue);
323
+
324
+ // dispatch the new value: the given value if there is
325
+ // no getter, or the actual value if there is one
326
+ PropertyChanges.dispatchOwnPropertyChange(this, key, value);
327
+ return value;
328
+ },
329
+ enumerable: overriddenDescriptor.enumerable,
330
+ configurable: true
331
+ };
332
+ }
333
+
334
+ Object.defineProperty(this, key, propertyListener);
335
+ };
336
+
337
+ PropertyChanges.prototype.makePropertyUnobservable = function (key) {
338
+ // arrays are special. we do not support direct setting of properties
339
+ // on an array. instead, call .set(index, value). this is observable.
340
+ // 'length' property is observable for all mutating methods because
341
+ // our overrides explicitly dispatch that change.
342
+ if (Array.isArray(this)) {
343
+ return;
344
+ }
345
+
346
+ if (!overriddenObjectDescriptors.has(this)) {
347
+ throw new Error("Can't uninstall observer on property");
348
+ }
349
+ var overriddenPropertyDescriptors = overriddenObjectDescriptors.get(this);
350
+
351
+ if (!overriddenPropertyDescriptors[key]) {
352
+ throw new Error("Can't uninstall observer on property");
353
+ }
354
+
355
+ var overriddenDescriptor = overriddenPropertyDescriptors[key];
356
+ delete overriddenPropertyDescriptors[key];
357
+
358
+ var state;
359
+ if (typeof this.__state__ === "object") {
360
+ state = this.__state__;
361
+ } else {
362
+ state = {};
363
+ if (Object.isExtensible(this, "__state__")) {
364
+ Object.defineProperty(this, "__state__", {
365
+ value: state,
366
+ writable: true,
367
+ enumerable: false
368
+ });
369
+ }
370
+ }
371
+ delete state[key];
372
+
373
+ Object.defineProperty(this, key, overriddenDescriptor);
374
+ };
375
+
376
+ // constructor functions
377
+
378
+ PropertyChanges.getOwnPropertyChangeDescriptor = function (object, key) {
379
+ if (object.getOwnPropertyChangeDescriptor) {
380
+ return object.getOwnPropertyChangeDescriptor(key);
381
+ } else {
382
+ return PropertyChanges.prototype.getOwnPropertyChangeDescriptor.call(object, key);
383
+ }
384
+ };
385
+
386
+ PropertyChanges.hasOwnPropertyChangeDescriptor = function (object, key) {
387
+ if (object.hasOwnPropertyChangeDescriptor) {
388
+ return object.hasOwnPropertyChangeDescriptor(key);
389
+ } else {
390
+ return PropertyChanges.prototype.hasOwnPropertyChangeDescriptor.call(object, key);
391
+ }
392
+ };
393
+
394
+ PropertyChanges.addOwnPropertyChangeListener = function (object, key, listener, beforeChange) {
395
+ if (!Object.isObject(object)) {
396
+ } else if (object.addOwnPropertyChangeListener) {
397
+ return object.addOwnPropertyChangeListener(key, listener, beforeChange);
398
+ } else {
399
+ return PropertyChanges.prototype.addOwnPropertyChangeListener.call(object, key, listener, beforeChange);
400
+ }
401
+ };
402
+
403
+ PropertyChanges.removeOwnPropertyChangeListener = function (object, key, listener, beforeChange) {
404
+ if (!Object.isObject(object)) {
405
+ } else if (object.removeOwnPropertyChangeListener) {
406
+ return object.removeOwnPropertyChangeListener(key, listener, beforeChange);
407
+ } else {
408
+ return PropertyChanges.prototype.removeOwnPropertyChangeListener.call(object, key, listener, beforeChange);
409
+ }
410
+ };
411
+
412
+ PropertyChanges.dispatchOwnPropertyChange = function (object, key, value, beforeChange) {
413
+ if (!Object.isObject(object)) {
414
+ } else if (object.dispatchOwnPropertyChange) {
415
+ return object.dispatchOwnPropertyChange(key, value, beforeChange);
416
+ } else {
417
+ return PropertyChanges.prototype.dispatchOwnPropertyChange.call(object, key, value, beforeChange);
418
+ }
419
+ };
420
+
421
+ PropertyChanges.addBeforeOwnPropertyChangeListener = function (object, key, listener) {
422
+ return PropertyChanges.addOwnPropertyChangeListener(object, key, listener, true);
423
+ };
424
+
425
+ PropertyChanges.removeBeforeOwnPropertyChangeListener = function (object, key, listener) {
426
+ return PropertyChanges.removeOwnPropertyChangeListener(object, key, listener, true);
427
+ };
428
+
429
+ PropertyChanges.dispatchBeforeOwnPropertyChange = function (object, key, value) {
430
+ return PropertyChanges.dispatchOwnPropertyChange(object, key, value, true);
431
+ };
432
+
433
+ PropertyChanges.makePropertyObservable = function (object, key) {
434
+ if (object.makePropertyObservable) {
435
+ return object.makePropertyObservable(key);
436
+ } else {
437
+ return PropertyChanges.prototype.makePropertyObservable.call(object, key);
438
+ }
439
+ };
440
+
441
+ PropertyChanges.makePropertyUnobservable = function (object, key) {
442
+ if (object.makePropertyUnobservable) {
443
+ return object.makePropertyUnobservable(key);
444
+ } else {
445
+ return PropertyChanges.prototype.makePropertyUnobservable.call(object, key);
446
+ }
447
+ };
448
+