discourse-ember-source 3.5.1.1 → 3.5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (741) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ember/version.rb +1 -1
  3. metadata +2 -740
  4. data/.gitignore +0 -9
  5. data/.travis.yml +0 -5
  6. data/Gemfile +0 -6
  7. data/LICENSE.txt +0 -21
  8. data/README +0 -18
  9. data/README.md +0 -39
  10. data/Rakefile +0 -27
  11. data/bin/console +0 -14
  12. data/bin/setup +0 -8
  13. data/discourse-ember-source-3.5.1.0.gem +0 -0
  14. data/dist/ember-all.debug.map +0 -1
  15. data/dist/ember-template-compiler.map +0 -1
  16. data/dist/ember-testing.map +0 -1
  17. data/dist/ember-tests.map +0 -1
  18. data/dist/ember-tests.prod.map +0 -1
  19. data/dist/ember.debug.map +0 -1
  20. data/dist/ember.min.map +0 -1
  21. data/dist/ember.prod.map +0 -1
  22. data/dist/es/@ember/application/globals-resolver.js +0 -425
  23. data/dist/es/@ember/application/index.js +0 -3
  24. data/dist/es/@ember/application/instance.js +0 -513
  25. data/dist/es/@ember/application/lib/application.js +0 -1139
  26. data/dist/es/@ember/application/lib/lazy_load.js +0 -69
  27. data/dist/es/@ember/application/lib/validate-type.js +0 -24
  28. data/dist/es/@ember/application/tests/application_instance_test.js +0 -230
  29. data/dist/es/@ember/application/tests/application_test.js +0 -470
  30. data/dist/es/@ember/application/tests/bootstrap-test.js +0 -28
  31. data/dist/es/@ember/application/tests/dependency_injection/custom_resolver_test.js +0 -32
  32. data/dist/es/@ember/application/tests/dependency_injection/default_resolver_test.js +0 -363
  33. data/dist/es/@ember/application/tests/dependency_injection/normalization_test.js +0 -70
  34. data/dist/es/@ember/application/tests/dependency_injection/to_string_test.js +0 -71
  35. data/dist/es/@ember/application/tests/dependency_injection_test.js +0 -93
  36. data/dist/es/@ember/application/tests/initializers_test.js +0 -391
  37. data/dist/es/@ember/application/tests/instance_initializers_test.js +0 -395
  38. data/dist/es/@ember/application/tests/lazy_load_test.js +0 -79
  39. data/dist/es/@ember/application/tests/logging_test.js +0 -179
  40. data/dist/es/@ember/application/tests/readiness_test.js +0 -138
  41. data/dist/es/@ember/application/tests/reset_test.js +0 -185
  42. data/dist/es/@ember/application/tests/visit_test.js +0 -783
  43. data/dist/es/@ember/canary-features/index.js +0 -76
  44. data/dist/es/@ember/controller/index.js +0 -50
  45. data/dist/es/@ember/controller/lib/controller_mixin.js +0 -42
  46. data/dist/es/@ember/controller/tests/controller_test.js +0 -209
  47. data/dist/es/@ember/debug/index.js +0 -264
  48. data/dist/es/@ember/debug/lib/deprecate.js +0 -198
  49. data/dist/es/@ember/debug/lib/handlers.js +0 -22
  50. data/dist/es/@ember/debug/lib/testing.js +0 -7
  51. data/dist/es/@ember/debug/lib/warn.js +0 -107
  52. data/dist/es/@ember/debug/tests/handlers-test.js +0 -144
  53. data/dist/es/@ember/debug/tests/main_test.js +0 -444
  54. data/dist/es/@ember/deprecated-features/index.js +0 -21
  55. data/dist/es/@ember/engine/index.js +0 -532
  56. data/dist/es/@ember/engine/instance.js +0 -228
  57. data/dist/es/@ember/engine/lib/engine-parent.js +0 -32
  58. data/dist/es/@ember/engine/tests/engine_initializers_test.js +0 -366
  59. data/dist/es/@ember/engine/tests/engine_instance_initializers_test.js +0 -409
  60. data/dist/es/@ember/engine/tests/engine_instance_test.js +0 -115
  61. data/dist/es/@ember/engine/tests/engine_parent_test.js +0 -20
  62. data/dist/es/@ember/engine/tests/engine_test.js +0 -121
  63. data/dist/es/@ember/error/index.js +0 -36
  64. data/dist/es/@ember/error/tests/index_test.js +0 -19
  65. data/dist/es/@ember/instrumentation/index.js +0 -240
  66. data/dist/es/@ember/instrumentation/tests/index-test.js +0 -214
  67. data/dist/es/@ember/map/index.js +0 -218
  68. data/dist/es/@ember/map/lib/ordered-set.js +0 -186
  69. data/dist/es/@ember/map/lib/utils.js +0 -29
  70. data/dist/es/@ember/map/tests/map_test.js +0 -578
  71. data/dist/es/@ember/map/with-default.js +0 -87
  72. data/dist/es/@ember/object/computed.js +0 -35
  73. data/dist/es/@ember/object/lib/computed/computed_macros.js +0 -742
  74. data/dist/es/@ember/object/lib/computed/reduce_computed_macros.js +0 -894
  75. data/dist/es/@ember/object/tests/computed/computed_macros_test.js +0 -533
  76. data/dist/es/@ember/object/tests/computed/reduce_computed_macros_test.js +0 -2243
  77. data/dist/es/@ember/polyfills/index.js +0 -3
  78. data/dist/es/@ember/polyfills/lib/assign.js +0 -43
  79. data/dist/es/@ember/polyfills/lib/merge.js +0 -35
  80. data/dist/es/@ember/polyfills/tests/assign_test.js +0 -64
  81. data/dist/es/@ember/runloop/index.js +0 -749
  82. data/dist/es/@ember/runloop/tests/debounce_test.js +0 -87
  83. data/dist/es/@ember/runloop/tests/later_test.js +0 -264
  84. data/dist/es/@ember/runloop/tests/next_test.js +0 -56
  85. data/dist/es/@ember/runloop/tests/once_test.js +0 -62
  86. data/dist/es/@ember/runloop/tests/onerror_test.js +0 -59
  87. data/dist/es/@ember/runloop/tests/run_bind_test.js +0 -59
  88. data/dist/es/@ember/runloop/tests/run_test.js +0 -28
  89. data/dist/es/@ember/runloop/tests/schedule_test.js +0 -86
  90. data/dist/es/@ember/runloop/tests/sync_test.js +0 -32
  91. data/dist/es/@ember/runloop/tests/unwind_test.js +0 -54
  92. data/dist/es/@ember/service/index.js +0 -57
  93. data/dist/es/@ember/string/index.js +0 -362
  94. data/dist/es/@ember/string/lib/string_registry.js +0 -13
  95. data/dist/es/@ember/string/tests/camelize_test.js +0 -53
  96. data/dist/es/@ember/string/tests/capitalize_test.js +0 -58
  97. data/dist/es/@ember/string/tests/classify_test.js +0 -79
  98. data/dist/es/@ember/string/tests/dasherize_test.js +0 -57
  99. data/dist/es/@ember/string/tests/decamelize_test.js +0 -51
  100. data/dist/es/@ember/string/tests/loc_test.js +0 -76
  101. data/dist/es/@ember/string/tests/underscore_test.js +0 -51
  102. data/dist/es/@ember/string/tests/w_test.js +0 -39
  103. data/dist/es/@glimmer/compiler.js +0 -1226
  104. data/dist/es/@glimmer/encoder.js +0 -39
  105. data/dist/es/@glimmer/low-level.js +0 -82
  106. data/dist/es/@glimmer/node.js +0 -112
  107. data/dist/es/@glimmer/opcode-compiler.js +0 -1999
  108. data/dist/es/@glimmer/program.js +0 -405
  109. data/dist/es/@glimmer/reference.js +0 -478
  110. data/dist/es/@glimmer/runtime.js +0 -4086
  111. data/dist/es/@glimmer/syntax.js +0 -1424
  112. data/dist/es/@glimmer/util.js +0 -189
  113. data/dist/es/@glimmer/vm.js +0 -27
  114. data/dist/es/@glimmer/wire-format.js +0 -56
  115. data/dist/es/backburner.js +0 -936
  116. data/dist/es/container/index.js +0 -8
  117. data/dist/es/container/lib/container.js +0 -437
  118. data/dist/es/container/lib/registry.js +0 -646
  119. data/dist/es/container/tests/container_test.js +0 -872
  120. data/dist/es/container/tests/owner_test.js +0 -20
  121. data/dist/es/container/tests/registry_test.js +0 -943
  122. data/dist/es/dag-map.js +0 -209
  123. data/dist/es/ember-browser-environment/index.js +0 -8
  124. data/dist/es/ember-browser-environment/lib/has-dom.js +0 -19
  125. data/dist/es/ember-console/index.js +0 -177
  126. data/dist/es/ember-environment/index.js +0 -3
  127. data/dist/es/ember-environment/lib/context.js +0 -20
  128. data/dist/es/ember-environment/lib/env.js +0 -185
  129. data/dist/es/ember-environment/lib/global.js +0 -14
  130. data/dist/es/ember-error-handling/index.js +0 -22
  131. data/dist/es/ember-extension-support/index.js +0 -2
  132. data/dist/es/ember-extension-support/lib/container_debug_adapter.js +0 -99
  133. data/dist/es/ember-extension-support/lib/data_adapter.js +0 -493
  134. data/dist/es/ember-extension-support/tests/container_debug_adapter_test.js +0 -73
  135. data/dist/es/ember-extension-support/tests/data_adapter_test.js +0 -301
  136. data/dist/es/ember-glimmer/index.js +0 -286
  137. data/dist/es/ember-glimmer/lib/compile-time-lookup.js +0 -37
  138. data/dist/es/ember-glimmer/lib/component-managers/abstract.js +0 -49
  139. data/dist/es/ember-glimmer/lib/component-managers/curly.js +0 -395
  140. data/dist/es/ember-glimmer/lib/component-managers/custom.js +0 -145
  141. data/dist/es/ember-glimmer/lib/component-managers/definition-state.js +0 -1
  142. data/dist/es/ember-glimmer/lib/component-managers/mount.js +0 -103
  143. data/dist/es/ember-glimmer/lib/component-managers/outlet.js +0 -114
  144. data/dist/es/ember-glimmer/lib/component-managers/render.js +0 -112
  145. data/dist/es/ember-glimmer/lib/component-managers/root.js +0 -74
  146. data/dist/es/ember-glimmer/lib/component-managers/template-only.js +0 -46
  147. data/dist/es/ember-glimmer/lib/component.js +0 -633
  148. data/dist/es/ember-glimmer/lib/components/checkbox.js +0 -57
  149. data/dist/es/ember-glimmer/lib/components/link-to.js +0 -777
  150. data/dist/es/ember-glimmer/lib/components/text_area.js +0 -236
  151. data/dist/es/ember-glimmer/lib/components/text_field.js +0 -145
  152. data/dist/es/ember-glimmer/lib/dom.js +0 -3
  153. data/dist/es/ember-glimmer/lib/environment.js +0 -102
  154. data/dist/es/ember-glimmer/lib/helper.js +0 -128
  155. data/dist/es/ember-glimmer/lib/helpers/-class.js +0 -23
  156. data/dist/es/ember-glimmer/lib/helpers/-html-safe.js +0 -9
  157. data/dist/es/ember-glimmer/lib/helpers/-input-type.js +0 -11
  158. data/dist/es/ember-glimmer/lib/helpers/-normalize-class.js +0 -22
  159. data/dist/es/ember-glimmer/lib/helpers/action.js +0 -360
  160. data/dist/es/ember-glimmer/lib/helpers/component.js +0 -135
  161. data/dist/es/ember-glimmer/lib/helpers/concat.js +0 -38
  162. data/dist/es/ember-glimmer/lib/helpers/each-in.js +0 -126
  163. data/dist/es/ember-glimmer/lib/helpers/get.js +0 -100
  164. data/dist/es/ember-glimmer/lib/helpers/hash.js +0 -44
  165. data/dist/es/ember-glimmer/lib/helpers/if-unless.js +0 -142
  166. data/dist/es/ember-glimmer/lib/helpers/loc.js +0 -40
  167. data/dist/es/ember-glimmer/lib/helpers/log.js +0 -25
  168. data/dist/es/ember-glimmer/lib/helpers/mut.js +0 -107
  169. data/dist/es/ember-glimmer/lib/helpers/query-param.js +0 -31
  170. data/dist/es/ember-glimmer/lib/helpers/readonly.js +0 -104
  171. data/dist/es/ember-glimmer/lib/helpers/unbound.js +0 -36
  172. data/dist/es/ember-glimmer/lib/modifiers/action.js +0 -185
  173. data/dist/es/ember-glimmer/lib/protocol-for-url.js +0 -48
  174. data/dist/es/ember-glimmer/lib/renderer.js +0 -371
  175. data/dist/es/ember-glimmer/lib/resolver.js +0 -290
  176. data/dist/es/ember-glimmer/lib/setup-registry.js +0 -77
  177. data/dist/es/ember-glimmer/lib/syntax.js +0 -73
  178. data/dist/es/ember-glimmer/lib/syntax/-text-area.js +0 -8
  179. data/dist/es/ember-glimmer/lib/syntax/input.js +0 -173
  180. data/dist/es/ember-glimmer/lib/syntax/let.js +0 -50
  181. data/dist/es/ember-glimmer/lib/syntax/mount.js +0 -101
  182. data/dist/es/ember-glimmer/lib/syntax/outlet.js +0 -120
  183. data/dist/es/ember-glimmer/lib/syntax/render.js +0 -140
  184. data/dist/es/ember-glimmer/lib/syntax/utils.js +0 -6
  185. data/dist/es/ember-glimmer/lib/template-compiler.js +0 -7
  186. data/dist/es/ember-glimmer/lib/template.js +0 -16
  187. data/dist/es/ember-glimmer/lib/template_registry.js +0 -18
  188. data/dist/es/ember-glimmer/lib/templates/component.js +0 -2
  189. data/dist/es/ember-glimmer/lib/templates/empty.js +0 -2
  190. data/dist/es/ember-glimmer/lib/templates/link-to.js +0 -2
  191. data/dist/es/ember-glimmer/lib/templates/outlet.js +0 -2
  192. data/dist/es/ember-glimmer/lib/templates/root.js +0 -2
  193. data/dist/es/ember-glimmer/lib/utils/bindings.js +0 -180
  194. data/dist/es/ember-glimmer/lib/utils/curly-component-state-bucket.js +0 -36
  195. data/dist/es/ember-glimmer/lib/utils/custom-component-manager.js +0 -20
  196. data/dist/es/ember-glimmer/lib/utils/debug-stack.js +0 -57
  197. data/dist/es/ember-glimmer/lib/utils/iterable.js +0 -358
  198. data/dist/es/ember-glimmer/lib/utils/outlet.js +0 -89
  199. data/dist/es/ember-glimmer/lib/utils/process-args.js +0 -40
  200. data/dist/es/ember-glimmer/lib/utils/references.js +0 -325
  201. data/dist/es/ember-glimmer/lib/utils/serialization-first-node-helpers.js +0 -1
  202. data/dist/es/ember-glimmer/lib/utils/string.js +0 -98
  203. data/dist/es/ember-glimmer/lib/utils/to-bool.js +0 -9
  204. data/dist/es/ember-glimmer/lib/views/outlet.js +0 -71
  205. data/dist/es/ember-glimmer/tests/integration/application/actions-test.js +0 -107
  206. data/dist/es/ember-glimmer/tests/integration/application/engine-test.js +0 -912
  207. data/dist/es/ember-glimmer/tests/integration/application/rendering-test.js +0 -530
  208. data/dist/es/ember-glimmer/tests/integration/components/angle-bracket-invocation-test.js +0 -852
  209. data/dist/es/ember-glimmer/tests/integration/components/append-test.js +0 -742
  210. data/dist/es/ember-glimmer/tests/integration/components/attribute-bindings-test.js +0 -999
  211. data/dist/es/ember-glimmer/tests/integration/components/attrs-lookup-test.js +0 -268
  212. data/dist/es/ember-glimmer/tests/integration/components/class-bindings-test.js +0 -849
  213. data/dist/es/ember-glimmer/tests/integration/components/contextual-components-test.js +0 -1493
  214. data/dist/es/ember-glimmer/tests/integration/components/curly-components-test.js +0 -3705
  215. data/dist/es/ember-glimmer/tests/integration/components/destroy-test.js +0 -33
  216. data/dist/es/ember-glimmer/tests/integration/components/dynamic-components-test.js +0 -896
  217. data/dist/es/ember-glimmer/tests/integration/components/error-handling-test.js +0 -164
  218. data/dist/es/ember-glimmer/tests/integration/components/fragment-components-test.js +0 -285
  219. data/dist/es/ember-glimmer/tests/integration/components/instrumentation-compile-test.js +0 -108
  220. data/dist/es/ember-glimmer/tests/integration/components/instrumentation-test.js +0 -157
  221. data/dist/es/ember-glimmer/tests/integration/components/life-cycle-test.js +0 -1653
  222. data/dist/es/ember-glimmer/tests/integration/components/link-to-test.js +0 -218
  223. data/dist/es/ember-glimmer/tests/integration/components/local-lookup-test.js +0 -414
  224. data/dist/es/ember-glimmer/tests/integration/components/namespaced-lookup-test.js +0 -185
  225. data/dist/es/ember-glimmer/tests/integration/components/render-to-element-test.js +0 -0
  226. data/dist/es/ember-glimmer/tests/integration/components/target-action-test.js +0 -779
  227. data/dist/es/ember-glimmer/tests/integration/components/template-only-components-test.js +0 -225
  228. data/dist/es/ember-glimmer/tests/integration/components/to-string-test.js +0 -27
  229. data/dist/es/ember-glimmer/tests/integration/components/utils-test.js +0 -401
  230. data/dist/es/ember-glimmer/tests/integration/components/web-component-fallback-test.js +0 -35
  231. data/dist/es/ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js +0 -40
  232. data/dist/es/ember-glimmer/tests/integration/content-test.js +0 -1759
  233. data/dist/es/ember-glimmer/tests/integration/custom-component-manager-test.js +0 -508
  234. data/dist/es/ember-glimmer/tests/integration/event-dispatcher-test.js +0 -607
  235. data/dist/es/ember-glimmer/tests/integration/helpers/-class-test.js +0 -76
  236. data/dist/es/ember-glimmer/tests/integration/helpers/closure-action-test.js +0 -1240
  237. data/dist/es/ember-glimmer/tests/integration/helpers/concat-test.js +0 -106
  238. data/dist/es/ember-glimmer/tests/integration/helpers/custom-helper-test.js +0 -672
  239. data/dist/es/ember-glimmer/tests/integration/helpers/element-action-test.js +0 -1595
  240. data/dist/es/ember-glimmer/tests/integration/helpers/get-test.js +0 -618
  241. data/dist/es/ember-glimmer/tests/integration/helpers/hash-test.js +0 -188
  242. data/dist/es/ember-glimmer/tests/integration/helpers/if-unless-test.js +0 -149
  243. data/dist/es/ember-glimmer/tests/integration/helpers/input-test.js +0 -827
  244. data/dist/es/ember-glimmer/tests/integration/helpers/loc-test.js +0 -103
  245. data/dist/es/ember-glimmer/tests/integration/helpers/log-test.js +0 -61
  246. data/dist/es/ember-glimmer/tests/integration/helpers/mut-test.js +0 -580
  247. data/dist/es/ember-glimmer/tests/integration/helpers/partial-test.js +0 -386
  248. data/dist/es/ember-glimmer/tests/integration/helpers/readonly-test.js +0 -293
  249. data/dist/es/ember-glimmer/tests/integration/helpers/render-test.js +0 -522
  250. data/dist/es/ember-glimmer/tests/integration/helpers/text-area-test.js +0 -166
  251. data/dist/es/ember-glimmer/tests/integration/helpers/unbound-test.js +0 -650
  252. data/dist/es/ember-glimmer/tests/integration/helpers/yield-test.js +0 -275
  253. data/dist/es/ember-glimmer/tests/integration/input-test.js +0 -242
  254. data/dist/es/ember-glimmer/tests/integration/mount-test.js +0 -424
  255. data/dist/es/ember-glimmer/tests/integration/outlet-test.js +0 -318
  256. data/dist/es/ember-glimmer/tests/integration/refinements-test.js +0 -74
  257. data/dist/es/ember-glimmer/tests/integration/render-settled-test.js +0 -72
  258. data/dist/es/ember-glimmer/tests/integration/svg-test.js +0 -158
  259. data/dist/es/ember-glimmer/tests/integration/syntax/each-in-test.js +0 -697
  260. data/dist/es/ember-glimmer/tests/integration/syntax/each-test.js +0 -1251
  261. data/dist/es/ember-glimmer/tests/integration/syntax/experimental-syntax-test.js +0 -42
  262. data/dist/es/ember-glimmer/tests/integration/syntax/if-unless-test.js +0 -108
  263. data/dist/es/ember-glimmer/tests/integration/syntax/in-element-test.js +0 -119
  264. data/dist/es/ember-glimmer/tests/integration/syntax/let-test.js +0 -390
  265. data/dist/es/ember-glimmer/tests/integration/syntax/with-dynamic-var-test.js +0 -36
  266. data/dist/es/ember-glimmer/tests/integration/syntax/with-test.js +0 -422
  267. data/dist/es/ember-glimmer/tests/unit/outlet-test.js +0 -48
  268. data/dist/es/ember-glimmer/tests/unit/runtime-resolver-cache-test.js +0 -263
  269. data/dist/es/ember-glimmer/tests/unit/template-factory-test.js +0 -67
  270. data/dist/es/ember-glimmer/tests/unit/utils/debug-stack-test.js +0 -38
  271. data/dist/es/ember-glimmer/tests/utils/abstract-test-case.js +0 -1
  272. data/dist/es/ember-glimmer/tests/utils/helpers.js +0 -15
  273. data/dist/es/ember-glimmer/tests/utils/shared-conditional-tests.js +0 -965
  274. data/dist/es/ember-glimmer/tests/utils/string-test.js +0 -47
  275. data/dist/es/ember-glimmer/tests/utils/test-case.js +0 -6
  276. data/dist/es/ember-glimmer/tests/utils/test-helpers.js +0 -1
  277. data/dist/es/ember-meta/index.js +0 -1
  278. data/dist/es/ember-meta/lib/meta.js +0 -623
  279. data/dist/es/ember-meta/tests/meta_test.js +0 -169
  280. data/dist/es/ember-metal/index.js +0 -33
  281. data/dist/es/ember-metal/lib/alias.js +0 -80
  282. data/dist/es/ember-metal/lib/array.js +0 -55
  283. data/dist/es/ember-metal/lib/array_events.js +0 -65
  284. data/dist/es/ember-metal/lib/chains.js +0 -315
  285. data/dist/es/ember-metal/lib/change_event.js +0 -4
  286. data/dist/es/ember-metal/lib/computed.js +0 -526
  287. data/dist/es/ember-metal/lib/computed_cache.js +0 -58
  288. data/dist/es/ember-metal/lib/dependent_keys.js +0 -34
  289. data/dist/es/ember-metal/lib/deprecate_property.js +0 -34
  290. data/dist/es/ember-metal/lib/descriptor.js +0 -28
  291. data/dist/es/ember-metal/lib/each_proxy.js +0 -106
  292. data/dist/es/ember-metal/lib/each_proxy_events.js +0 -13
  293. data/dist/es/ember-metal/lib/events.js +0 -174
  294. data/dist/es/ember-metal/lib/expand_properties.js +0 -64
  295. data/dist/es/ember-metal/lib/get_properties.js +0 -45
  296. data/dist/es/ember-metal/lib/injected_property.js +0 -53
  297. data/dist/es/ember-metal/lib/is_blank.js +0 -34
  298. data/dist/es/ember-metal/lib/is_empty.js +0 -63
  299. data/dist/es/ember-metal/lib/is_none.js +0 -27
  300. data/dist/es/ember-metal/lib/is_present.js +0 -38
  301. data/dist/es/ember-metal/lib/libraries.js +0 -80
  302. data/dist/es/ember-metal/lib/mixin.js +0 -646
  303. data/dist/es/ember-metal/lib/namespace_search.js +0 -166
  304. data/dist/es/ember-metal/lib/observer.js +0 -34
  305. data/dist/es/ember-metal/lib/observer_set.js +0 -48
  306. data/dist/es/ember-metal/lib/path_cache.js +0 -5
  307. data/dist/es/ember-metal/lib/properties.js +0 -192
  308. data/dist/es/ember-metal/lib/property_events.js +0 -198
  309. data/dist/es/ember-metal/lib/property_get.js +0 -160
  310. data/dist/es/ember-metal/lib/property_set.js +0 -157
  311. data/dist/es/ember-metal/lib/set_properties.js +0 -43
  312. data/dist/es/ember-metal/lib/tags.js +0 -81
  313. data/dist/es/ember-metal/lib/tracked.js +0 -201
  314. data/dist/es/ember-metal/lib/transaction.js +0 -137
  315. data/dist/es/ember-metal/lib/watch_key.js +0 -113
  316. data/dist/es/ember-metal/lib/watch_path.js +0 -24
  317. data/dist/es/ember-metal/lib/watching.js +0 -54
  318. data/dist/es/ember-metal/tests/accessors/get_path_test.js +0 -82
  319. data/dist/es/ember-metal/tests/accessors/get_properties_test.js +0 -36
  320. data/dist/es/ember-metal/tests/accessors/get_test.js +0 -335
  321. data/dist/es/ember-metal/tests/accessors/mandatory_setters_test.js +0 -470
  322. data/dist/es/ember-metal/tests/accessors/set_path_test.js +0 -97
  323. data/dist/es/ember-metal/tests/accessors/set_test.js +0 -128
  324. data/dist/es/ember-metal/tests/alias_test.js +0 -167
  325. data/dist/es/ember-metal/tests/chains_test.js +0 -210
  326. data/dist/es/ember-metal/tests/computed_test.js +0 -1040
  327. data/dist/es/ember-metal/tests/descriptor_test.js +0 -368
  328. data/dist/es/ember-metal/tests/events_test.js +0 -210
  329. data/dist/es/ember-metal/tests/expand_properties_test.js +0 -119
  330. data/dist/es/ember-metal/tests/injected_property_test.js +0 -76
  331. data/dist/es/ember-metal/tests/is_blank_test.js +0 -29
  332. data/dist/es/ember-metal/tests/is_empty_test.js +0 -55
  333. data/dist/es/ember-metal/tests/is_none_test.js +0 -23
  334. data/dist/es/ember-metal/tests/is_present_test.js +0 -30
  335. data/dist/es/ember-metal/tests/libraries_test.js +0 -99
  336. data/dist/es/ember-metal/tests/main_test.js +0 -31
  337. data/dist/es/ember-metal/tests/mixin/alias_method_test.js +0 -91
  338. data/dist/es/ember-metal/tests/mixin/apply_test.js +0 -40
  339. data/dist/es/ember-metal/tests/mixin/computed_test.js +0 -166
  340. data/dist/es/ember-metal/tests/mixin/concatenated_properties_test.js +0 -117
  341. data/dist/es/ember-metal/tests/mixin/detect_test.js +0 -40
  342. data/dist/es/ember-metal/tests/mixin/introspection_test.js +0 -75
  343. data/dist/es/ember-metal/tests/mixin/merged_properties_test.js +0 -200
  344. data/dist/es/ember-metal/tests/mixin/method_test.js +0 -252
  345. data/dist/es/ember-metal/tests/mixin/observer_test.js +0 -202
  346. data/dist/es/ember-metal/tests/mixin/reopen_test.js +0 -53
  347. data/dist/es/ember-metal/tests/mixin/without_test.js +0 -22
  348. data/dist/es/ember-metal/tests/namespace_search_test.js +0 -16
  349. data/dist/es/ember-metal/tests/observer_test.js +0 -961
  350. data/dist/es/ember-metal/tests/performance_test.js +0 -81
  351. data/dist/es/ember-metal/tests/properties_test.js +0 -120
  352. data/dist/es/ember-metal/tests/property_did_change_hook.js +0 -73
  353. data/dist/es/ember-metal/tests/set_properties_test.js +0 -49
  354. data/dist/es/ember-metal/tests/tracked/computed_test.js +0 -67
  355. data/dist/es/ember-metal/tests/tracked/get_test.js +0 -86
  356. data/dist/es/ember-metal/tests/tracked/set_test.js +0 -44
  357. data/dist/es/ember-metal/tests/tracked/support.js +0 -37
  358. data/dist/es/ember-metal/tests/tracked/validation_test.js +0 -233
  359. data/dist/es/ember-metal/tests/watching/is_watching_test.js +0 -97
  360. data/dist/es/ember-metal/tests/watching/unwatch_test.js +0 -109
  361. data/dist/es/ember-metal/tests/watching/watch_test.js +0 -255
  362. data/dist/es/ember-owner/index.js +0 -66
  363. data/dist/es/ember-routing/index.js +0 -21
  364. data/dist/es/ember-routing/lib/ext/controller.js +0 -222
  365. data/dist/es/ember-routing/lib/location/api.js +0 -118
  366. data/dist/es/ember-routing/lib/location/auto_location.js +0 -323
  367. data/dist/es/ember-routing/lib/location/hash_location.js +0 -171
  368. data/dist/es/ember-routing/lib/location/history_location.js +0 -298
  369. data/dist/es/ember-routing/lib/location/none_location.js +0 -122
  370. data/dist/es/ember-routing/lib/location/util.js +0 -114
  371. data/dist/es/ember-routing/lib/services/router.js +0 -243
  372. data/dist/es/ember-routing/lib/services/routing.js +0 -101
  373. data/dist/es/ember-routing/lib/system/cache.js +0 -40
  374. data/dist/es/ember-routing/lib/system/controller_for.js +0 -14
  375. data/dist/es/ember-routing/lib/system/dsl.js +0 -208
  376. data/dist/es/ember-routing/lib/system/generate_controller.js +0 -54
  377. data/dist/es/ember-routing/lib/system/query_params.js +0 -6
  378. data/dist/es/ember-routing/lib/system/route.js +0 -2476
  379. data/dist/es/ember-routing/lib/system/router.js +0 -1607
  380. data/dist/es/ember-routing/lib/system/router_state.js +0 -26
  381. data/dist/es/ember-routing/lib/system/transition.js +0 -153
  382. data/dist/es/ember-routing/lib/utils.js +0 -230
  383. data/dist/es/ember-routing/tests/ext/controller_test.js +0 -85
  384. data/dist/es/ember-routing/tests/location/auto_location_test.js +0 -379
  385. data/dist/es/ember-routing/tests/location/hash_location_test.js +0 -207
  386. data/dist/es/ember-routing/tests/location/history_location_test.js +0 -322
  387. data/dist/es/ember-routing/tests/location/none_location_test.js +0 -88
  388. data/dist/es/ember-routing/tests/location/util_test.js +0 -159
  389. data/dist/es/ember-routing/tests/system/cache_test.js +0 -54
  390. data/dist/es/ember-routing/tests/system/controller_for_test.js +0 -75
  391. data/dist/es/ember-routing/tests/system/dsl_test.js +0 -413
  392. data/dist/es/ember-routing/tests/system/route_test.js +0 -587
  393. data/dist/es/ember-routing/tests/system/router_test.js +0 -287
  394. data/dist/es/ember-routing/tests/utils_test.js +0 -37
  395. data/dist/es/ember-runtime/.gitignore +0 -1
  396. data/dist/es/ember-runtime/README +0 -12
  397. data/dist/es/ember-runtime/index.js +0 -35
  398. data/dist/es/ember-runtime/lib/compare.js +0 -149
  399. data/dist/es/ember-runtime/lib/copy.js +0 -106
  400. data/dist/es/ember-runtime/lib/ext/function.js +0 -154
  401. data/dist/es/ember-runtime/lib/ext/rsvp.js +0 -59
  402. data/dist/es/ember-runtime/lib/is-equal.js +0 -60
  403. data/dist/es/ember-runtime/lib/mixins/-proxy.js +0 -109
  404. data/dist/es/ember-runtime/lib/mixins/action_handler.js +0 -222
  405. data/dist/es/ember-runtime/lib/mixins/array.js +0 -1661
  406. data/dist/es/ember-runtime/lib/mixins/comparable.js +0 -38
  407. data/dist/es/ember-runtime/lib/mixins/container_proxy.js +0 -154
  408. data/dist/es/ember-runtime/lib/mixins/copyable.js +0 -34
  409. data/dist/es/ember-runtime/lib/mixins/enumerable.js +0 -16
  410. data/dist/es/ember-runtime/lib/mixins/evented.js +0 -149
  411. data/dist/es/ember-runtime/lib/mixins/mutable_enumerable.js +0 -18
  412. data/dist/es/ember-runtime/lib/mixins/observable.js +0 -482
  413. data/dist/es/ember-runtime/lib/mixins/promise_proxy.js +0 -224
  414. data/dist/es/ember-runtime/lib/mixins/registry_proxy.js +0 -265
  415. data/dist/es/ember-runtime/lib/mixins/target_action_support.js +0 -172
  416. data/dist/es/ember-runtime/lib/system/array_proxy.js +0 -298
  417. data/dist/es/ember-runtime/lib/system/core_object.js +0 -1037
  418. data/dist/es/ember-runtime/lib/system/namespace.js +0 -69
  419. data/dist/es/ember-runtime/lib/system/object.js +0 -73
  420. data/dist/es/ember-runtime/lib/system/object_proxy.js +0 -81
  421. data/dist/es/ember-runtime/lib/type-of.js +0 -107
  422. data/dist/es/ember-runtime/tests/array/any-test.js +0 -55
  423. data/dist/es/ember-runtime/tests/array/compact-test.js +0 -12
  424. data/dist/es/ember-runtime/tests/array/every-test.js +0 -82
  425. data/dist/es/ember-runtime/tests/array/filter-test.js +0 -123
  426. data/dist/es/ember-runtime/tests/array/find-test.js +0 -86
  427. data/dist/es/ember-runtime/tests/array/firstObject-test.js +0 -27
  428. data/dist/es/ember-runtime/tests/array/forEach-test.js +0 -68
  429. data/dist/es/ember-runtime/tests/array/includes-test.js +0 -46
  430. data/dist/es/ember-runtime/tests/array/indexOf-test.js +0 -27
  431. data/dist/es/ember-runtime/tests/array/invoke-test.js +0 -60
  432. data/dist/es/ember-runtime/tests/array/isAny-test.js +0 -53
  433. data/dist/es/ember-runtime/tests/array/lastIndexOf-test.js +0 -78
  434. data/dist/es/ember-runtime/tests/array/lastObject-test.js +0 -31
  435. data/dist/es/ember-runtime/tests/array/map-test.js +0 -68
  436. data/dist/es/ember-runtime/tests/array/mapBy-test.js +0 -16
  437. data/dist/es/ember-runtime/tests/array/objectAt-test.js +0 -34
  438. data/dist/es/ember-runtime/tests/array/reduce-test.js +0 -24
  439. data/dist/es/ember-runtime/tests/array/reject-test.js +0 -134
  440. data/dist/es/ember-runtime/tests/array/sortBy-test.js +0 -23
  441. data/dist/es/ember-runtime/tests/array/toArray-test.js +0 -11
  442. data/dist/es/ember-runtime/tests/array/uniq-test.js +0 -27
  443. data/dist/es/ember-runtime/tests/array/uniqBy-test.js +0 -33
  444. data/dist/es/ember-runtime/tests/array/without-test.js +0 -39
  445. data/dist/es/ember-runtime/tests/copyable-array/copy-test.js +0 -12
  446. data/dist/es/ember-runtime/tests/core/compare_test.js +0 -89
  447. data/dist/es/ember-runtime/tests/core/copy_test.js +0 -47
  448. data/dist/es/ember-runtime/tests/core/isEqual_test.js +0 -65
  449. data/dist/es/ember-runtime/tests/core/is_array_test.js +0 -59
  450. data/dist/es/ember-runtime/tests/core/is_empty_test.js +0 -15
  451. data/dist/es/ember-runtime/tests/core/type_of_test.js +0 -54
  452. data/dist/es/ember-runtime/tests/ext/function_test.js +0 -121
  453. data/dist/es/ember-runtime/tests/ext/rsvp_test.js +0 -269
  454. data/dist/es/ember-runtime/tests/helpers/array.js +0 -336
  455. data/dist/es/ember-runtime/tests/inject_test.js +0 -51
  456. data/dist/es/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js +0 -63
  457. data/dist/es/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js +0 -892
  458. data/dist/es/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js +0 -142
  459. data/dist/es/ember-runtime/tests/legacy_1x/system/object/base_test.js +0 -98
  460. data/dist/es/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js +0 -131
  461. data/dist/es/ember-runtime/tests/mixins/array_test.js +0 -400
  462. data/dist/es/ember-runtime/tests/mixins/comparable_test.js +0 -37
  463. data/dist/es/ember-runtime/tests/mixins/container_proxy_test.js +0 -48
  464. data/dist/es/ember-runtime/tests/mixins/enumerable_test.js +0 -17
  465. data/dist/es/ember-runtime/tests/mixins/evented_test.js +0 -23
  466. data/dist/es/ember-runtime/tests/mixins/mutable_enumerable_test.js +0 -17
  467. data/dist/es/ember-runtime/tests/mixins/observable_test.js +0 -137
  468. data/dist/es/ember-runtime/tests/mixins/promise_proxy_test.js +0 -593
  469. data/dist/es/ember-runtime/tests/mixins/target_action_support_test.js +0 -237
  470. data/dist/es/ember-runtime/tests/mutable-array/addObject-test.js +0 -76
  471. data/dist/es/ember-runtime/tests/mutable-array/clear-test.js +0 -64
  472. data/dist/es/ember-runtime/tests/mutable-array/insertAt-test.js +0 -216
  473. data/dist/es/ember-runtime/tests/mutable-array/popObject-test.js +0 -91
  474. data/dist/es/ember-runtime/tests/mutable-array/pushObject-test.js +0 -98
  475. data/dist/es/ember-runtime/tests/mutable-array/pushObjects-test.js +0 -12
  476. data/dist/es/ember-runtime/tests/mutable-array/removeAt-test.js +0 -187
  477. data/dist/es/ember-runtime/tests/mutable-array/removeObject-test.js +0 -77
  478. data/dist/es/ember-runtime/tests/mutable-array/removeObjects-test.js +0 -202
  479. data/dist/es/ember-runtime/tests/mutable-array/replace-test.js +0 -221
  480. data/dist/es/ember-runtime/tests/mutable-array/reverseObjects-test.js +0 -35
  481. data/dist/es/ember-runtime/tests/mutable-array/setObjects-test.js +0 -63
  482. data/dist/es/ember-runtime/tests/mutable-array/shiftObject-test.js +0 -105
  483. data/dist/es/ember-runtime/tests/mutable-array/unshiftObject-test.js +0 -99
  484. data/dist/es/ember-runtime/tests/mutable-array/unshiftObjects-test.js +0 -102
  485. data/dist/es/ember-runtime/tests/system/array_proxy/arranged_content_test.js +0 -275
  486. data/dist/es/ember-runtime/tests/system/array_proxy/array_observer_test.js +0 -51
  487. data/dist/es/ember-runtime/tests/system/array_proxy/content_change_test.js +0 -85
  488. data/dist/es/ember-runtime/tests/system/array_proxy/length_test.js +0 -201
  489. data/dist/es/ember-runtime/tests/system/array_proxy/watching_and_listening_test.js +0 -157
  490. data/dist/es/ember-runtime/tests/system/core_object_test.js +0 -114
  491. data/dist/es/ember-runtime/tests/system/namespace/base_test.js +0 -175
  492. data/dist/es/ember-runtime/tests/system/native_array/a_test.js +0 -16
  493. data/dist/es/ember-runtime/tests/system/native_array/copyable_suite_test.js +0 -19
  494. data/dist/es/ember-runtime/tests/system/native_array/replace_test.js +0 -17
  495. data/dist/es/ember-runtime/tests/system/object/computed_test.js +0 -352
  496. data/dist/es/ember-runtime/tests/system/object/create_test.js +0 -135
  497. data/dist/es/ember-runtime/tests/system/object/destroy_test.js +0 -146
  498. data/dist/es/ember-runtime/tests/system/object/detectInstance_test.js +0 -38
  499. data/dist/es/ember-runtime/tests/system/object/detect_test.js +0 -33
  500. data/dist/es/ember-runtime/tests/system/object/es-compatibility-test.js +0 -469
  501. data/dist/es/ember-runtime/tests/system/object/events_test.js +0 -156
  502. data/dist/es/ember-runtime/tests/system/object/extend_test.js +0 -153
  503. data/dist/es/ember-runtime/tests/system/object/observer_test.js +0 -216
  504. data/dist/es/ember-runtime/tests/system/object/reopenClass_test.js +0 -36
  505. data/dist/es/ember-runtime/tests/system/object/reopen_test.js +0 -48
  506. data/dist/es/ember-runtime/tests/system/object/strict-mode-test.js +0 -31
  507. data/dist/es/ember-runtime/tests/system/object/toString_test.js +0 -125
  508. data/dist/es/ember-runtime/tests/system/object_proxy_test.js +0 -314
  509. data/dist/es/ember-template-compiler/index.js +0 -26
  510. data/dist/es/ember-template-compiler/lib/compat.js +0 -16
  511. data/dist/es/ember-template-compiler/lib/plugins/assert-if-helper-without-arguments.js +0 -38
  512. data/dist/es/ember-template-compiler/lib/plugins/assert-input-helper-without-block.js +0 -20
  513. data/dist/es/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js +0 -26
  514. data/dist/es/ember-template-compiler/lib/plugins/assert-splattribute-expression.js +0 -27
  515. data/dist/es/ember-template-compiler/lib/plugins/deprecate-render-model.js +0 -38
  516. data/dist/es/ember-template-compiler/lib/plugins/deprecate-render.js +0 -41
  517. data/dist/es/ember-template-compiler/lib/plugins/deprecate-send-action.js +0 -42
  518. data/dist/es/ember-template-compiler/lib/plugins/index.js +0 -50
  519. data/dist/es/ember-template-compiler/lib/plugins/transform-action-syntax.js +0 -52
  520. data/dist/es/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js +0 -10
  521. data/dist/es/ember-template-compiler/lib/plugins/transform-attrs-into-args.js +0 -62
  522. data/dist/es/ember-template-compiler/lib/plugins/transform-dot-component-invocation.js +0 -88
  523. data/dist/es/ember-template-compiler/lib/plugins/transform-each-in-into-each.js +0 -48
  524. data/dist/es/ember-template-compiler/lib/plugins/transform-has-block-syntax.js +0 -46
  525. data/dist/es/ember-template-compiler/lib/plugins/transform-in-element.js +0 -83
  526. data/dist/es/ember-template-compiler/lib/plugins/transform-inline-link-to.js +0 -31
  527. data/dist/es/ember-template-compiler/lib/plugins/transform-input-type-syntax.js +0 -52
  528. data/dist/es/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js +0 -48
  529. data/dist/es/ember-template-compiler/lib/plugins/transform-old-class-binding-syntax.js +0 -102
  530. data/dist/es/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js +0 -34
  531. data/dist/es/ember-template-compiler/lib/plugins/transform-top-level-components.js +0 -41
  532. data/dist/es/ember-template-compiler/lib/system/bootstrap.js +0 -44
  533. data/dist/es/ember-template-compiler/lib/system/calculate-location-display.js +0 -20
  534. data/dist/es/ember-template-compiler/lib/system/compile-options.js +0 -71
  535. data/dist/es/ember-template-compiler/lib/system/compile.js +0 -28
  536. data/dist/es/ember-template-compiler/lib/system/dasherize-component-name.js +0 -13
  537. data/dist/es/ember-template-compiler/lib/system/initializer.js +0 -22
  538. data/dist/es/ember-template-compiler/lib/system/precompile.js +0 -18
  539. data/dist/es/ember-template-compiler/tests/plugins/assert-if-helper-without-arguments-test.js +0 -51
  540. data/dist/es/ember-template-compiler/tests/plugins/assert-input-helper-without-block-test.js +0 -17
  541. data/dist/es/ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js +0 -416
  542. data/dist/es/ember-template-compiler/tests/plugins/assert-splattribute-expression-test.js +0 -57
  543. data/dist/es/ember-template-compiler/tests/plugins/deprecate-render-model-test.js +0 -19
  544. data/dist/es/ember-template-compiler/tests/plugins/deprecate-render-test.js +0 -19
  545. data/dist/es/ember-template-compiler/tests/plugins/deprecate-send-action-test.js +0 -29
  546. data/dist/es/ember-template-compiler/tests/plugins/transform-dot-component-invocation-test.js +0 -27
  547. data/dist/es/ember-template-compiler/tests/plugins/transform-inline-link-to-test.js +0 -15
  548. data/dist/es/ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js +0 -25
  549. data/dist/es/ember-template-compiler/tests/system/bootstrap-test.js +0 -155
  550. data/dist/es/ember-template-compiler/tests/system/compile_options_test.js +0 -115
  551. data/dist/es/ember-template-compiler/tests/system/dasherize-component-name-test.js +0 -19
  552. data/dist/es/ember-testing/index.js +0 -10
  553. data/dist/es/ember-testing/lib/adapters/adapter.js +0 -58
  554. data/dist/es/ember-testing/lib/adapters/qunit.js +0 -47
  555. data/dist/es/ember-testing/lib/events.js +0 -136
  556. data/dist/es/ember-testing/lib/ext/application.js +0 -191
  557. data/dist/es/ember-testing/lib/ext/rsvp.js +0 -19
  558. data/dist/es/ember-testing/lib/helpers.js +0 -30
  559. data/dist/es/ember-testing/lib/helpers/-is-form-control.js +0 -16
  560. data/dist/es/ember-testing/lib/helpers/and_then.js +0 -3
  561. data/dist/es/ember-testing/lib/helpers/click.js +0 -36
  562. data/dist/es/ember-testing/lib/helpers/current_path.js +0 -27
  563. data/dist/es/ember-testing/lib/helpers/current_route_name.js +0 -25
  564. data/dist/es/ember-testing/lib/helpers/current_url.js +0 -27
  565. data/dist/es/ember-testing/lib/helpers/fill_in.js +0 -46
  566. data/dist/es/ember-testing/lib/helpers/find.js +0 -41
  567. data/dist/es/ember-testing/lib/helpers/find_with_assert.js +0 -34
  568. data/dist/es/ember-testing/lib/helpers/key_event.js +0 -36
  569. data/dist/es/ember-testing/lib/helpers/pause_test.js +0 -65
  570. data/dist/es/ember-testing/lib/helpers/trigger_event.js +0 -62
  571. data/dist/es/ember-testing/lib/helpers/visit.js +0 -42
  572. data/dist/es/ember-testing/lib/helpers/wait.js +0 -72
  573. data/dist/es/ember-testing/lib/initializers.js +0 -17
  574. data/dist/es/ember-testing/lib/setup_for_testing.js +0 -44
  575. data/dist/es/ember-testing/lib/support.js +0 -62
  576. data/dist/es/ember-testing/lib/test.js +0 -70
  577. data/dist/es/ember-testing/lib/test/adapter.js +0 -33
  578. data/dist/es/ember-testing/lib/test/helpers.js +0 -125
  579. data/dist/es/ember-testing/lib/test/on_inject_helpers.js +0 -38
  580. data/dist/es/ember-testing/lib/test/pending_requests.js +0 -24
  581. data/dist/es/ember-testing/lib/test/promise.js +0 -79
  582. data/dist/es/ember-testing/lib/test/run.js +0 -9
  583. data/dist/es/ember-testing/lib/test/waiters.js +0 -117
  584. data/dist/es/ember-testing/tests/acceptance_test.js +0 -478
  585. data/dist/es/ember-testing/tests/adapters/adapter_test.js +0 -31
  586. data/dist/es/ember-testing/tests/adapters/qunit_test.js +0 -50
  587. data/dist/es/ember-testing/tests/adapters_test.js +0 -405
  588. data/dist/es/ember-testing/tests/ext/rsvp_test.js +0 -124
  589. data/dist/es/ember-testing/tests/helper_registration_test.js +0 -98
  590. data/dist/es/ember-testing/tests/helpers_test.js +0 -1228
  591. data/dist/es/ember-testing/tests/integration_test.js +0 -106
  592. data/dist/es/ember-testing/tests/reexports_test.js +0 -26
  593. data/dist/es/ember-testing/tests/test/waiters-test.js +0 -145
  594. data/dist/es/ember-utils/index.js +0 -28
  595. data/dist/es/ember-utils/lib/cache.js +0 -36
  596. data/dist/es/ember-utils/lib/dictionary.js +0 -11
  597. data/dist/es/ember-utils/lib/guid.js +0 -120
  598. data/dist/es/ember-utils/lib/inspect.js +0 -112
  599. data/dist/es/ember-utils/lib/intern.js +0 -49
  600. data/dist/es/ember-utils/lib/invoke.js +0 -53
  601. data/dist/es/ember-utils/lib/is_proxy.js +0 -14
  602. data/dist/es/ember-utils/lib/lookup-descriptor.js +0 -11
  603. data/dist/es/ember-utils/lib/make-array.js +0 -7
  604. data/dist/es/ember-utils/lib/name.js +0 -9
  605. data/dist/es/ember-utils/lib/proxy-utils.js +0 -1
  606. data/dist/es/ember-utils/lib/spec.js +0 -14
  607. data/dist/es/ember-utils/lib/super.js +0 -83
  608. data/dist/es/ember-utils/lib/symbol-utils.js +0 -8
  609. data/dist/es/ember-utils/lib/symbol.js +0 -15
  610. data/dist/es/ember-utils/lib/to-string.js +0 -35
  611. data/dist/es/ember-utils/lib/weak_set.js +0 -18
  612. data/dist/es/ember-utils/tests/cache_test.js +0 -77
  613. data/dist/es/ember-utils/tests/can_invoke_test.js +0 -46
  614. data/dist/es/ember-utils/tests/checkHasSuper_test.js +0 -17
  615. data/dist/es/ember-utils/tests/generate_guid_test.js +0 -13
  616. data/dist/es/ember-utils/tests/guid_for_test.js +0 -101
  617. data/dist/es/ember-utils/tests/inspect_test.js +0 -146
  618. data/dist/es/ember-utils/tests/is_proxy_test.js +0 -18
  619. data/dist/es/ember-utils/tests/make_array_test.js +0 -41
  620. data/dist/es/ember-utils/tests/to-string-test.js +0 -32
  621. data/dist/es/ember-utils/tests/try_invoke_test.js +0 -48
  622. data/dist/es/ember-views/index.js +0 -28
  623. data/dist/es/ember-views/lib/compat/attrs.js +0 -3
  624. data/dist/es/ember-views/lib/compat/fallback-view-registry.js +0 -3
  625. data/dist/es/ember-views/lib/component_lookup.js +0 -27
  626. data/dist/es/ember-views/lib/mixins/action_support.js +0 -189
  627. data/dist/es/ember-views/lib/mixins/child_views_support.js +0 -27
  628. data/dist/es/ember-views/lib/mixins/class_names_support.js +0 -102
  629. data/dist/es/ember-views/lib/mixins/text_support.js +0 -333
  630. data/dist/es/ember-views/lib/mixins/view_state_support.js +0 -19
  631. data/dist/es/ember-views/lib/mixins/view_support.js +0 -452
  632. data/dist/es/ember-views/lib/system/action_manager.js +0 -14
  633. data/dist/es/ember-views/lib/system/event_dispatcher.js +0 -454
  634. data/dist/es/ember-views/lib/system/jquery.js +0 -29
  635. data/dist/es/ember-views/lib/system/jquery_event_deprecation.js +0 -61
  636. data/dist/es/ember-views/lib/system/lookup_partial.js +0 -55
  637. data/dist/es/ember-views/lib/system/utils.js +0 -201
  638. data/dist/es/ember-views/lib/utils/lookup-component.js +0 -58
  639. data/dist/es/ember-views/lib/views/core_view.js +0 -83
  640. data/dist/es/ember-views/lib/views/states.js +0 -48
  641. data/dist/es/ember-views/lib/views/states/default.js +0 -17
  642. data/dist/es/ember-views/lib/views/states/destroying.js +0 -16
  643. data/dist/es/ember-views/lib/views/states/has_element.js +0 -31
  644. data/dist/es/ember-views/lib/views/states/in_dom.js +0 -28
  645. data/dist/es/ember-views/lib/views/states/pre_render.js +0 -3
  646. data/dist/es/ember/index.js +0 -645
  647. data/dist/es/ember/tests/application_lifecycle_test.js +0 -188
  648. data/dist/es/ember/tests/component_context_test.js +0 -255
  649. data/dist/es/ember/tests/component_registration_test.js +0 -252
  650. data/dist/es/ember/tests/controller_test.js +0 -44
  651. data/dist/es/ember/tests/error_handler_test.js +0 -581
  652. data/dist/es/ember/tests/helpers/helper_registration_test.js +0 -103
  653. data/dist/es/ember/tests/helpers/link_to_test.js +0 -2103
  654. data/dist/es/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js +0 -342
  655. data/dist/es/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js +0 -694
  656. data/dist/es/ember/tests/homepage_example_test.js +0 -47
  657. data/dist/es/ember/tests/integration/multiple-app-test.js +0 -101
  658. data/dist/es/ember/tests/production_build_test.js +0 -34
  659. data/dist/es/ember/tests/reexports_test.js +0 -307
  660. data/dist/es/ember/tests/routing/decoupled_basic_test.js +0 -4506
  661. data/dist/es/ember/tests/routing/query_params_test.js +0 -1579
  662. data/dist/es/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js +0 -1117
  663. data/dist/es/ember/tests/routing/query_params_test/overlapping_query_params_test.js +0 -185
  664. data/dist/es/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js +0 -327
  665. data/dist/es/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js +0 -37
  666. data/dist/es/ember/tests/routing/query_params_test/shared_state_test.js +0 -84
  667. data/dist/es/ember/tests/routing/router_map_test.js +0 -46
  668. data/dist/es/ember/tests/routing/router_service_test/basic_test.js +0 -95
  669. data/dist/es/ember/tests/routing/router_service_test/currenturl_lifecycle_test.js +0 -149
  670. data/dist/es/ember/tests/routing/router_service_test/isActive_test.js +0 -113
  671. data/dist/es/ember/tests/routing/router_service_test/replaceWith_test.js +0 -144
  672. data/dist/es/ember/tests/routing/router_service_test/transitionTo_test.js +0 -370
  673. data/dist/es/ember/tests/routing/router_service_test/urlFor_test.js +0 -307
  674. data/dist/es/ember/tests/routing/substates_test.js +0 -1110
  675. data/dist/es/ember/tests/routing/toplevel_dom_test.js +0 -37
  676. data/dist/es/ember/tests/service_injection_test.js +0 -278
  677. data/dist/es/ember/tests/view_instrumentation_test.js +0 -47
  678. data/dist/es/ember/version.js +0 -1
  679. data/dist/es/handlebars.js +0 -1268
  680. data/dist/es/internal-test-helpers/index.js +0 -31
  681. data/dist/es/internal-test-helpers/lib/.gitkeep +0 -0
  682. data/dist/es/internal-test-helpers/lib/apply-mixins.js +0 -37
  683. data/dist/es/internal-test-helpers/lib/browser-detect.js +0 -4
  684. data/dist/es/internal-test-helpers/lib/build-owner.js +0 -49
  685. data/dist/es/internal-test-helpers/lib/confirm-export.js +0 -45
  686. data/dist/es/internal-test-helpers/lib/ember-dev/assertion.js +0 -87
  687. data/dist/es/internal-test-helpers/lib/ember-dev/containers.js +0 -34
  688. data/dist/es/internal-test-helpers/lib/ember-dev/debug.js +0 -47
  689. data/dist/es/internal-test-helpers/lib/ember-dev/deprecation.js +0 -71
  690. data/dist/es/internal-test-helpers/lib/ember-dev/index.js +0 -19
  691. data/dist/es/internal-test-helpers/lib/ember-dev/method-call-tracker.js +0 -127
  692. data/dist/es/internal-test-helpers/lib/ember-dev/namespaces.js +0 -34
  693. data/dist/es/internal-test-helpers/lib/ember-dev/run-loop.js +0 -28
  694. data/dist/es/internal-test-helpers/lib/ember-dev/setup-qunit.js +0 -26
  695. data/dist/es/internal-test-helpers/lib/ember-dev/utils.js +0 -33
  696. data/dist/es/internal-test-helpers/lib/ember-dev/warning.js +0 -71
  697. data/dist/es/internal-test-helpers/lib/equal-inner-html.js +0 -37
  698. data/dist/es/internal-test-helpers/lib/equal-tokens.js +0 -53
  699. data/dist/es/internal-test-helpers/lib/factory.js +0 -65
  700. data/dist/es/internal-test-helpers/lib/get-all-property-names.js +0 -12
  701. data/dist/es/internal-test-helpers/lib/get-text-of.js +0 -3
  702. data/dist/es/internal-test-helpers/lib/matchers.js +0 -167
  703. data/dist/es/internal-test-helpers/lib/module-for.js +0 -89
  704. data/dist/es/internal-test-helpers/lib/registry-check.js +0 -28
  705. data/dist/es/internal-test-helpers/lib/run.js +0 -11
  706. data/dist/es/internal-test-helpers/lib/strip.js +0 -12
  707. data/dist/es/internal-test-helpers/lib/system/synthetic-events.js +0 -183
  708. data/dist/es/internal-test-helpers/lib/test-cases/abstract-application.js +0 -70
  709. data/dist/es/internal-test-helpers/lib/test-cases/abstract-rendering.js +0 -203
  710. data/dist/es/internal-test-helpers/lib/test-cases/abstract.js +0 -222
  711. data/dist/es/internal-test-helpers/lib/test-cases/application.js +0 -39
  712. data/dist/es/internal-test-helpers/lib/test-cases/autoboot-application.js +0 -34
  713. data/dist/es/internal-test-helpers/lib/test-cases/default-resolver-application.js +0 -43
  714. data/dist/es/internal-test-helpers/lib/test-cases/node-query.js +0 -120
  715. data/dist/es/internal-test-helpers/lib/test-cases/query-param.js +0 -124
  716. data/dist/es/internal-test-helpers/lib/test-cases/rendering.js +0 -14
  717. data/dist/es/internal-test-helpers/lib/test-cases/router.js +0 -26
  718. data/dist/es/internal-test-helpers/lib/test-cases/test-resolver-application.js +0 -40
  719. data/dist/es/internal-test-helpers/lib/test-resolver.js +0 -86
  720. data/dist/es/internal-test-helpers/tests/index-test.js +0 -10
  721. data/dist/es/route-recognizer.js +0 -685
  722. data/dist/es/router.js +0 -2454
  723. data/dist/es/rsvp.js +0 -2394
  724. data/dist/es/simple-html-tokenizer.js +0 -638
  725. data/dist/jquery/jquery.js +0 -10364
  726. data/dist/node/app-boot-test.js +0 -146
  727. data/dist/node/build-info-test.js +0 -177
  728. data/dist/node/component-rendering-test.js +0 -34
  729. data/dist/node/helpers/app-module.js +0 -198
  730. data/dist/node/helpers/assert-html-matches.js +0 -25
  731. data/dist/node/helpers/build-owner.js +0 -28
  732. data/dist/node/helpers/component-module.js +0 -137
  733. data/dist/node/sourcemap-test.js +0 -27
  734. data/dist/node/template-compiler-test.js +0 -45
  735. data/dist/node/visit-test.js +0 -349
  736. data/dist/qunit/qunit.css +0 -436
  737. data/dist/qunit/qunit.js +0 -5188
  738. data/dist/tests/index.html +0 -254
  739. data/ember-source.gemspec +0 -28
  740. data/node_modules/.yarn-integrity +0 -10
  741. data/yarn.lock +0 -4
@@ -1,4086 +0,0 @@
1
- import { initializeGuid, fillNulls, unreachable, dict, Stack, LinkedList, EMPTY_ARRAY, ListSlice, isSerializationFirstNode } from '@glimmer/util';
2
- import { ConstReference, CachedReference, combineTagged, isConst, CONSTANT_TAG, isModified, ReferenceCache, isConstTag, ReferenceIterator, IteratorSynchronizer, combine, UpdatableTag, combineSlice, INITIAL } from '@glimmer/reference';
3
- import { Register } from '@glimmer/vm';
4
- import { Stack as Stack$1 } from '@glimmer/low-level';
5
-
6
- // these import bindings will be stripped from build
7
-
8
- class AppendOpcodes {
9
- constructor() {
10
- this.evaluateOpcode = fillNulls(98 /* Size */).slice();
11
- }
12
- add(name, evaluate, kind = 'syscall') {
13
- this.evaluateOpcode[name] = { syscall: kind === 'syscall', evaluate };
14
- }
15
- debugBefore(vm, opcode, type) {
16
- let sp;
17
- let state;
18
-
19
- return { sp: sp, state };
20
- }
21
- debugAfter(vm, opcode, type, pre) {
22
- let expectedChange;
23
- let { sp, state } = pre;
24
- let metadata = null;
25
- if (metadata !== null) {
26
- if (typeof metadata.stackChange === 'number') {
27
- expectedChange = metadata.stackChange;
28
- } else {
29
- expectedChange = metadata.stackChange({ opcode, constants: vm.constants, state });
30
- if (isNaN(expectedChange)) throw unreachable();
31
- }
32
- }
33
- }
34
- evaluate(vm, opcode, type) {
35
- let operation = this.evaluateOpcode[type];
36
- if (operation.syscall) {
37
-
38
- operation.evaluate(vm, opcode);
39
- } else {
40
-
41
- operation.evaluate(vm.inner, opcode);
42
- }
43
- }
44
- }
45
- const APPEND_OPCODES = new AppendOpcodes();
46
- class AbstractOpcode {
47
- constructor() {
48
- initializeGuid(this);
49
- }
50
- }
51
- class UpdatingOpcode extends AbstractOpcode {
52
- constructor() {
53
- super(...arguments);
54
- this.next = null;
55
- this.prev = null;
56
- }
57
- }
58
-
59
- class PrimitiveReference extends ConstReference {
60
- constructor(value) {
61
- super(value);
62
- }
63
- static create(value) {
64
- if (value === undefined) {
65
- return UNDEFINED_REFERENCE;
66
- } else if (value === null) {
67
- return NULL_REFERENCE;
68
- } else if (value === true) {
69
- return TRUE_REFERENCE;
70
- } else if (value === false) {
71
- return FALSE_REFERENCE;
72
- } else if (typeof value === 'number') {
73
- return new ValueReference(value);
74
- } else {
75
- return new StringReference(value);
76
- }
77
- }
78
- get(_key) {
79
- return UNDEFINED_REFERENCE;
80
- }
81
- }
82
- class StringReference extends PrimitiveReference {
83
- constructor() {
84
- super(...arguments);
85
- this.lengthReference = null;
86
- }
87
- get(key) {
88
- if (key === 'length') {
89
- let { lengthReference } = this;
90
- if (lengthReference === null) {
91
- lengthReference = this.lengthReference = new ValueReference(this.inner.length);
92
- }
93
- return lengthReference;
94
- } else {
95
- return super.get(key);
96
- }
97
- }
98
- }
99
- class ValueReference extends PrimitiveReference {
100
- constructor(value) {
101
- super(value);
102
- }
103
- }
104
- const UNDEFINED_REFERENCE = new ValueReference(undefined);
105
- const NULL_REFERENCE = new ValueReference(null);
106
- const TRUE_REFERENCE = new ValueReference(true);
107
- const FALSE_REFERENCE = new ValueReference(false);
108
- class ConditionalReference {
109
- constructor(inner) {
110
- this.inner = inner;
111
- this.tag = inner.tag;
112
- }
113
- value() {
114
- return this.toBool(this.inner.value());
115
- }
116
- toBool(value) {
117
- return !!value;
118
- }
119
- }
120
-
121
- class ConcatReference extends CachedReference {
122
- constructor(parts) {
123
- super();
124
- this.parts = parts;
125
- this.tag = combineTagged(parts);
126
- }
127
- compute() {
128
- let parts = new Array();
129
- for (let i = 0; i < this.parts.length; i++) {
130
- let value = this.parts[i].value();
131
- if (value !== null && value !== undefined) {
132
- parts[i] = castToString(value);
133
- }
134
- }
135
- if (parts.length > 0) {
136
- return parts.join('');
137
- }
138
- return null;
139
- }
140
- }
141
- function castToString(value) {
142
- if (typeof value.toString !== 'function') {
143
- return '';
144
- }
145
- return String(value);
146
- }
147
-
148
- APPEND_OPCODES.add(1 /* Helper */, (vm, { op1: handle }) => {
149
- let stack = vm.stack;
150
- let helper = vm.constants.resolveHandle(handle);
151
- let args = stack.pop();
152
- let value = helper(vm, args);
153
- vm.loadValue(Register.v0, value);
154
- });
155
- APPEND_OPCODES.add(6 /* GetVariable */, (vm, { op1: symbol }) => {
156
- let expr = vm.referenceForSymbol(symbol);
157
- vm.stack.push(expr);
158
- });
159
- APPEND_OPCODES.add(4 /* SetVariable */, (vm, { op1: symbol }) => {
160
- let expr = vm.stack.pop();
161
- vm.scope().bindSymbol(symbol, expr);
162
- });
163
- APPEND_OPCODES.add(5 /* SetBlock */, (vm, { op1: symbol }) => {
164
- let handle = vm.stack.pop();
165
- let scope = vm.stack.pop(); // FIXME(mmun): shouldn't need to cast this
166
- let table = vm.stack.pop();
167
- let block = table ? [handle, scope, table] : null;
168
- vm.scope().bindBlock(symbol, block);
169
- });
170
- APPEND_OPCODES.add(96 /* ResolveMaybeLocal */, (vm, { op1: _name }) => {
171
- let name = vm.constants.getString(_name);
172
- let locals = vm.scope().getPartialMap();
173
- let ref = locals[name];
174
- if (ref === undefined) {
175
- ref = vm.getSelf().get(name);
176
- }
177
- vm.stack.push(ref);
178
- });
179
- APPEND_OPCODES.add(20 /* RootScope */, (vm, { op1: symbols, op2: bindCallerScope }) => {
180
- vm.pushRootScope(symbols, !!bindCallerScope);
181
- });
182
- APPEND_OPCODES.add(7 /* GetProperty */, (vm, { op1: _key }) => {
183
- let key = vm.constants.getString(_key);
184
- let expr = vm.stack.pop();
185
- vm.stack.push(expr.get(key));
186
- });
187
- APPEND_OPCODES.add(8 /* GetBlock */, (vm, { op1: _block }) => {
188
- let { stack } = vm;
189
- let block = vm.scope().getBlock(_block);
190
- if (block) {
191
- stack.push(block[2]);
192
- stack.push(block[1]);
193
- stack.push(block[0]);
194
- } else {
195
- stack.push(null);
196
- stack.push(null);
197
- stack.push(null);
198
- }
199
- });
200
- APPEND_OPCODES.add(9 /* HasBlock */, (vm, { op1: _block }) => {
201
- let hasBlock = !!vm.scope().getBlock(_block);
202
- vm.stack.push(hasBlock ? TRUE_REFERENCE : FALSE_REFERENCE);
203
- });
204
- APPEND_OPCODES.add(10 /* HasBlockParams */, vm => {
205
- // FIXME(mmun): should only need to push the symbol table
206
- let block = vm.stack.pop();
207
- let scope = vm.stack.pop();
208
-
209
- let table = vm.stack.pop();
210
-
211
- let hasBlockParams = table && table.parameters.length;
212
- vm.stack.push(hasBlockParams ? TRUE_REFERENCE : FALSE_REFERENCE);
213
- });
214
- APPEND_OPCODES.add(11 /* Concat */, (vm, { op1: count }) => {
215
- let out = new Array(count);
216
- for (let i = count; i > 0; i--) {
217
- let offset = i - 1;
218
- out[offset] = vm.stack.pop();
219
- }
220
- vm.stack.push(new ConcatReference(out));
221
- });
222
-
223
- const CURRIED_COMPONENT_DEFINITION_BRAND = 'CURRIED COMPONENT DEFINITION [id=6f00feb9-a0ef-4547-99ea-ac328f80acea]';
224
- function isCurriedComponentDefinition(definition) {
225
- return !!(definition && definition[CURRIED_COMPONENT_DEFINITION_BRAND]);
226
- }
227
- function isComponentDefinition(definition) {
228
- return definition && definition[CURRIED_COMPONENT_DEFINITION_BRAND];
229
- }
230
- class CurriedComponentDefinition {
231
- /** @internal */
232
- constructor(inner, args) {
233
- this.inner = inner;
234
- this.args = args;
235
- this[CURRIED_COMPONENT_DEFINITION_BRAND] = true;
236
- }
237
- unwrap(args) {
238
- args.realloc(this.offset);
239
- let definition = this;
240
- while (true) {
241
- let { args: curriedArgs, inner } = definition;
242
- if (curriedArgs) {
243
- args.positional.prepend(curriedArgs.positional);
244
- args.named.merge(curriedArgs.named);
245
- }
246
- if (!isCurriedComponentDefinition(inner)) {
247
- return inner;
248
- }
249
- definition = inner;
250
- }
251
- }
252
- /** @internal */
253
- get offset() {
254
- let { inner, args } = this;
255
- let length = args ? args.positional.length : 0;
256
- return isCurriedComponentDefinition(inner) ? length + inner.offset : length;
257
- }
258
- }
259
- function curry(spec, args = null) {
260
- return new CurriedComponentDefinition(spec, args);
261
- }
262
-
263
- function normalizeStringValue(value) {
264
- if (isEmpty(value)) {
265
- return '';
266
- }
267
- return String(value);
268
- }
269
- function shouldCoerce(value) {
270
- return isString(value) || isEmpty(value) || typeof value === 'boolean' || typeof value === 'number';
271
- }
272
- function isEmpty(value) {
273
- return value === null || value === undefined || typeof value.toString !== 'function';
274
- }
275
- function isSafeString(value) {
276
- return typeof value === 'object' && value !== null && typeof value.toHTML === 'function';
277
- }
278
- function isNode(value) {
279
- return typeof value === 'object' && value !== null && typeof value.nodeType === 'number';
280
- }
281
- function isFragment(value) {
282
- return isNode(value) && value.nodeType === 11;
283
- }
284
- function isString(value) {
285
- return typeof value === 'string';
286
- }
287
-
288
- class DynamicTextContent extends UpdatingOpcode {
289
- constructor(node, reference, lastValue) {
290
- super();
291
- this.node = node;
292
- this.reference = reference;
293
- this.lastValue = lastValue;
294
- this.type = 'dynamic-text';
295
- this.tag = reference.tag;
296
- this.lastRevision = this.tag.value();
297
- }
298
- evaluate() {
299
- let { reference, tag } = this;
300
- if (!tag.validate(this.lastRevision)) {
301
- this.lastRevision = tag.value();
302
- this.update(reference.value());
303
- }
304
- }
305
- update(value) {
306
- let { lastValue } = this;
307
- if (value === lastValue) return;
308
- let normalized;
309
- if (isEmpty(value)) {
310
- normalized = '';
311
- } else if (isString(value)) {
312
- normalized = value;
313
- } else {
314
- normalized = String(value);
315
- }
316
- if (normalized !== lastValue) {
317
- let textNode = this.node;
318
- textNode.nodeValue = this.lastValue = normalized;
319
- }
320
- }
321
- }
322
-
323
- class IsCurriedComponentDefinitionReference extends ConditionalReference {
324
- static create(inner) {
325
- return new IsCurriedComponentDefinitionReference(inner);
326
- }
327
- toBool(value) {
328
- return isCurriedComponentDefinition(value);
329
- }
330
- }
331
- class ContentTypeReference {
332
- constructor(inner) {
333
- this.inner = inner;
334
- this.tag = inner.tag;
335
- }
336
- value() {
337
- let value = this.inner.value();
338
- if (shouldCoerce(value)) {
339
- return 1 /* String */;
340
- } else if (isComponentDefinition(value)) {
341
- return 0 /* Component */;
342
- } else if (isSafeString(value)) {
343
- return 3 /* SafeString */;
344
- } else if (isFragment(value)) {
345
- return 4 /* Fragment */;
346
- } else if (isNode(value)) {
347
- return 5 /* Node */;
348
- } else {
349
- return 1 /* String */;
350
- }
351
- }
352
- }
353
- APPEND_OPCODES.add(28 /* AppendHTML */, vm => {
354
- let reference = vm.stack.pop();
355
- let rawValue = reference.value();
356
- let value = isEmpty(rawValue) ? '' : String(rawValue);
357
- vm.elements().appendDynamicHTML(value);
358
- });
359
- APPEND_OPCODES.add(29 /* AppendSafeHTML */, vm => {
360
- let reference = vm.stack.pop();
361
- let rawValue = reference.value().toHTML();
362
- let value = isEmpty(rawValue) ? '' : rawValue;
363
- vm.elements().appendDynamicHTML(value);
364
- });
365
- APPEND_OPCODES.add(32 /* AppendText */, vm => {
366
- let reference = vm.stack.pop();
367
- let rawValue = reference.value();
368
- let value = isEmpty(rawValue) ? '' : String(rawValue);
369
- let node = vm.elements().appendDynamicText(value);
370
- if (!isConst(reference)) {
371
- vm.updateWith(new DynamicTextContent(node, reference, value));
372
- }
373
- });
374
- APPEND_OPCODES.add(30 /* AppendDocumentFragment */, vm => {
375
- let reference = vm.stack.pop();
376
- let value = reference.value();
377
- vm.elements().appendDynamicFragment(value);
378
- });
379
- APPEND_OPCODES.add(31 /* AppendNode */, vm => {
380
- let reference = vm.stack.pop();
381
- let value = reference.value();
382
- vm.elements().appendDynamicNode(value);
383
- });
384
-
385
- APPEND_OPCODES.add(22 /* ChildScope */, vm => vm.pushChildScope());
386
- APPEND_OPCODES.add(23 /* PopScope */, vm => vm.popScope());
387
- APPEND_OPCODES.add(44 /* PushDynamicScope */, vm => vm.pushDynamicScope());
388
- APPEND_OPCODES.add(45 /* PopDynamicScope */, vm => vm.popDynamicScope());
389
- APPEND_OPCODES.add(12 /* Constant */, (vm, { op1: other }) => {
390
- vm.stack.push(vm.constants.getOther(other));
391
- });
392
- APPEND_OPCODES.add(13 /* Primitive */, (vm, { op1: primitive }) => {
393
- let stack = vm.stack;
394
- let flag = primitive & 7; // 111
395
- let value = primitive >> 3;
396
- switch (flag) {
397
- case 0 /* NUMBER */:
398
- stack.push(value);
399
- break;
400
- case 1 /* FLOAT */:
401
- stack.push(vm.constants.getNumber(value));
402
- break;
403
- case 2 /* STRING */:
404
- stack.push(vm.constants.getString(value));
405
- break;
406
- case 3 /* BOOLEAN_OR_VOID */:
407
- stack.pushEncodedImmediate(primitive);
408
- break;
409
- case 4 /* NEGATIVE */:
410
- stack.push(vm.constants.getNumber(value));
411
- break;
412
- case 5 /* BIG_NUM */:
413
- stack.push(vm.constants.getNumber(value));
414
- break;
415
- }
416
- });
417
- APPEND_OPCODES.add(14 /* PrimitiveReference */, vm => {
418
- let stack = vm.stack;
419
- stack.push(PrimitiveReference.create(stack.pop()));
420
- });
421
- APPEND_OPCODES.add(15 /* ReifyU32 */, vm => {
422
- let stack = vm.stack;
423
- stack.push(stack.peek().value());
424
- });
425
- APPEND_OPCODES.add(16 /* Dup */, (vm, { op1: register, op2: offset }) => {
426
- let position = vm.fetchValue(register) - offset;
427
- vm.stack.dup(position);
428
- });
429
- APPEND_OPCODES.add(17 /* Pop */, (vm, { op1: count }) => {
430
- vm.stack.pop(count);
431
- });
432
- APPEND_OPCODES.add(18 /* Load */, (vm, { op1: register }) => {
433
- vm.load(register);
434
- });
435
- APPEND_OPCODES.add(19 /* Fetch */, (vm, { op1: register }) => {
436
- vm.fetch(register);
437
- });
438
- APPEND_OPCODES.add(43 /* BindDynamicScope */, (vm, { op1: _names }) => {
439
- let names = vm.constants.getArray(_names);
440
- vm.bindDynamicScope(names);
441
- });
442
- APPEND_OPCODES.add(61 /* Enter */, (vm, { op1: args }) => {
443
- vm.enter(args);
444
- });
445
- APPEND_OPCODES.add(62 /* Exit */, vm => {
446
- vm.exit();
447
- });
448
- APPEND_OPCODES.add(48 /* PushSymbolTable */, (vm, { op1: _table }) => {
449
- let stack = vm.stack;
450
- stack.push(vm.constants.getSerializable(_table));
451
- });
452
- APPEND_OPCODES.add(47 /* PushBlockScope */, vm => {
453
- let stack = vm.stack;
454
- stack.push(vm.scope());
455
- });
456
- APPEND_OPCODES.add(46 /* CompileBlock */, vm => {
457
- let stack = vm.stack;
458
- let block = stack.pop();
459
- if (block) {
460
- stack.pushSmi(block.compile());
461
- } else {
462
- stack.pushNull();
463
- }
464
- });
465
- APPEND_OPCODES.add(51 /* InvokeYield */, vm => {
466
- let { stack } = vm;
467
- let handle = stack.pop();
468
- let scope = stack.pop(); // FIXME(mmun): shouldn't need to cast this
469
- let table = stack.pop();
470
-
471
- let args = stack.pop();
472
- if (table === null) {
473
- // To balance the pop{Frame,Scope}
474
- vm.pushFrame();
475
- vm.pushScope(scope); // Could be null but it doesnt matter as it is immediatelly popped.
476
- return;
477
- }
478
- let invokingScope = scope;
479
- // If necessary, create a child scope
480
- {
481
- let locals = table.parameters;
482
- let localsCount = locals.length;
483
- if (localsCount > 0) {
484
- invokingScope = invokingScope.child();
485
- for (let i = 0; i < localsCount; i++) {
486
- invokingScope.bindSymbol(locals[i], args.at(i));
487
- }
488
- }
489
- }
490
- vm.pushFrame();
491
- vm.pushScope(invokingScope);
492
- vm.call(handle);
493
- });
494
- APPEND_OPCODES.add(53 /* JumpIf */, (vm, { op1: target }) => {
495
- let reference = vm.stack.pop();
496
- if (isConst(reference)) {
497
- if (reference.value()) {
498
- vm.goto(target);
499
- }
500
- } else {
501
- let cache = new ReferenceCache(reference);
502
- if (cache.peek()) {
503
- vm.goto(target);
504
- }
505
- vm.updateWith(new Assert(cache));
506
- }
507
- });
508
- APPEND_OPCODES.add(54 /* JumpUnless */, (vm, { op1: target }) => {
509
- let reference = vm.stack.pop();
510
- if (isConst(reference)) {
511
- if (!reference.value()) {
512
- vm.goto(target);
513
- }
514
- } else {
515
- let cache = new ReferenceCache(reference);
516
- if (!cache.peek()) {
517
- vm.goto(target);
518
- }
519
- vm.updateWith(new Assert(cache));
520
- }
521
- });
522
- APPEND_OPCODES.add(55 /* JumpEq */, (vm, { op1: target, op2: comparison }) => {
523
- let other = vm.stack.peek();
524
- if (other === comparison) {
525
- vm.goto(target);
526
- }
527
- });
528
- APPEND_OPCODES.add(56 /* AssertSame */, vm => {
529
- let reference = vm.stack.peek();
530
- if (!isConst(reference)) {
531
- vm.updateWith(Assert.initialize(new ReferenceCache(reference)));
532
- }
533
- });
534
- APPEND_OPCODES.add(63 /* ToBoolean */, vm => {
535
- let { env, stack } = vm;
536
- stack.push(env.toConditionalReference(stack.pop()));
537
- });
538
- class Assert extends UpdatingOpcode {
539
- constructor(cache) {
540
- super();
541
- this.type = 'assert';
542
- this.tag = cache.tag;
543
- this.cache = cache;
544
- }
545
- static initialize(cache) {
546
- let assert = new Assert(cache);
547
- cache.peek();
548
- return assert;
549
- }
550
- evaluate(vm) {
551
- let { cache } = this;
552
- if (isModified(cache.revalidate())) {
553
- vm.throw();
554
- }
555
- }
556
- }
557
- class JumpIfNotModifiedOpcode extends UpdatingOpcode {
558
- constructor(tag, target) {
559
- super();
560
- this.target = target;
561
- this.type = 'jump-if-not-modified';
562
- this.tag = tag;
563
- this.lastRevision = tag.value();
564
- }
565
- evaluate(vm) {
566
- let { tag, target, lastRevision } = this;
567
- if (!vm.alwaysRevalidate && tag.validate(lastRevision)) {
568
- vm.goto(target);
569
- }
570
- }
571
- didModify() {
572
- this.lastRevision = this.tag.value();
573
- }
574
- }
575
- class DidModifyOpcode extends UpdatingOpcode {
576
- constructor(target) {
577
- super();
578
- this.target = target;
579
- this.type = 'did-modify';
580
- this.tag = CONSTANT_TAG;
581
- }
582
- evaluate() {
583
- this.target.didModify();
584
- }
585
- }
586
- class LabelOpcode {
587
- constructor(label) {
588
- this.tag = CONSTANT_TAG;
589
- this.type = 'label';
590
- this.label = null;
591
- this.prev = null;
592
- this.next = null;
593
- initializeGuid(this);
594
- this.label = label;
595
- }
596
- evaluate() {}
597
- inspect() {
598
- return `${this.label} [${this._guid}]`;
599
- }
600
- }
601
-
602
- APPEND_OPCODES.add(26 /* Text */, (vm, { op1: text }) => {
603
- vm.elements().appendText(vm.constants.getString(text));
604
- });
605
- APPEND_OPCODES.add(27 /* Comment */, (vm, { op1: text }) => {
606
- vm.elements().appendComment(vm.constants.getString(text));
607
- });
608
- APPEND_OPCODES.add(33 /* OpenElement */, (vm, { op1: tag }) => {
609
- vm.elements().openElement(vm.constants.getString(tag));
610
- });
611
- APPEND_OPCODES.add(34 /* OpenDynamicElement */, vm => {
612
- let tagName = vm.stack.pop().value();
613
- vm.elements().openElement(tagName);
614
- });
615
- APPEND_OPCODES.add(41 /* PushRemoteElement */, vm => {
616
- let elementRef = vm.stack.pop();
617
- let nextSiblingRef = vm.stack.pop();
618
- let guidRef = vm.stack.pop();
619
- let element;
620
- let nextSibling;
621
- let guid = guidRef.value();
622
- if (isConst(elementRef)) {
623
- element = elementRef.value();
624
- } else {
625
- let cache = new ReferenceCache(elementRef);
626
- element = cache.peek();
627
- vm.updateWith(new Assert(cache));
628
- }
629
- if (isConst(nextSiblingRef)) {
630
- nextSibling = nextSiblingRef.value();
631
- } else {
632
- let cache = new ReferenceCache(nextSiblingRef);
633
- nextSibling = cache.peek();
634
- vm.updateWith(new Assert(cache));
635
- }
636
- vm.elements().pushRemoteElement(element, guid, nextSibling);
637
- });
638
- APPEND_OPCODES.add(42 /* PopRemoteElement */, vm => {
639
- vm.elements().popRemoteElement();
640
- });
641
- APPEND_OPCODES.add(38 /* FlushElement */, vm => {
642
- let operations = vm.fetchValue(Register.t0);
643
- if (operations) {
644
- operations.flush(vm);
645
- vm.loadValue(Register.t0, null);
646
- }
647
- vm.elements().flushElement();
648
- });
649
- APPEND_OPCODES.add(39 /* CloseElement */, vm => {
650
- vm.elements().closeElement();
651
- });
652
- APPEND_OPCODES.add(40 /* Modifier */, (vm, { op1: handle }) => {
653
- let manager = vm.constants.resolveHandle(handle);
654
- let stack = vm.stack;
655
- let args = stack.pop();
656
- let { constructing: element, updateOperations } = vm.elements();
657
- let dynamicScope = vm.dynamicScope();
658
- let modifier = manager.create(element, args, dynamicScope, updateOperations);
659
- vm.env.scheduleInstallModifier(modifier, manager);
660
- let destructor = manager.getDestructor(modifier);
661
- if (destructor) {
662
- vm.newDestroyable(destructor);
663
- }
664
- let tag = manager.getTag(modifier);
665
- if (!isConstTag(tag)) {
666
- vm.updateWith(new UpdateModifierOpcode(tag, manager, modifier));
667
- }
668
- });
669
- class UpdateModifierOpcode extends UpdatingOpcode {
670
- constructor(tag, manager, modifier) {
671
- super();
672
- this.tag = tag;
673
- this.manager = manager;
674
- this.modifier = modifier;
675
- this.type = 'update-modifier';
676
- this.lastUpdated = tag.value();
677
- }
678
- evaluate(vm) {
679
- let { manager, modifier, tag, lastUpdated } = this;
680
- if (!tag.validate(lastUpdated)) {
681
- vm.env.scheduleUpdateModifier(modifier, manager);
682
- this.lastUpdated = tag.value();
683
- }
684
- }
685
- }
686
- APPEND_OPCODES.add(35 /* StaticAttr */, (vm, { op1: _name, op2: _value, op3: _namespace }) => {
687
- let name = vm.constants.getString(_name);
688
- let value = vm.constants.getString(_value);
689
- let namespace = _namespace ? vm.constants.getString(_namespace) : null;
690
- vm.elements().setStaticAttribute(name, value, namespace);
691
- });
692
- APPEND_OPCODES.add(36 /* DynamicAttr */, (vm, { op1: _name, op2: trusting, op3: _namespace }) => {
693
- let name = vm.constants.getString(_name);
694
- let reference = vm.stack.pop();
695
- let value = reference.value();
696
- let namespace = _namespace ? vm.constants.getString(_namespace) : null;
697
- let attribute = vm.elements().setDynamicAttribute(name, value, !!trusting, namespace);
698
- if (!isConst(reference)) {
699
- vm.updateWith(new UpdateDynamicAttributeOpcode(reference, attribute));
700
- }
701
- });
702
- class UpdateDynamicAttributeOpcode extends UpdatingOpcode {
703
- constructor(reference, attribute) {
704
- super();
705
- this.reference = reference;
706
- this.attribute = attribute;
707
- this.type = 'patch-element';
708
- this.tag = reference.tag;
709
- this.lastRevision = this.tag.value();
710
- }
711
- evaluate(vm) {
712
- let { attribute, reference, tag } = this;
713
- if (!tag.validate(this.lastRevision)) {
714
- this.lastRevision = tag.value();
715
- attribute.update(reference.value(), vm.env);
716
- }
717
- }
718
- }
719
-
720
- function resolveComponent(resolver, name, meta) {
721
- let definition = resolver.lookupComponentDefinition(name, meta);
722
-
723
- return definition;
724
- }
725
-
726
- class CurryComponentReference {
727
- constructor(inner, resolver, meta, args) {
728
- this.inner = inner;
729
- this.resolver = resolver;
730
- this.meta = meta;
731
- this.args = args;
732
- this.tag = inner.tag;
733
- this.lastValue = null;
734
- this.lastDefinition = null;
735
- }
736
- value() {
737
- let { inner, lastValue } = this;
738
- let value = inner.value();
739
- if (value === lastValue) {
740
- return this.lastDefinition;
741
- }
742
- let definition = null;
743
- if (isCurriedComponentDefinition(value)) {
744
- definition = value;
745
- } else if (typeof value === 'string' && value) {
746
- let { resolver, meta } = this;
747
- definition = resolveComponent(resolver, value, meta);
748
- }
749
- definition = this.curry(definition);
750
- this.lastValue = value;
751
- this.lastDefinition = definition;
752
- return definition;
753
- }
754
- get() {
755
- return UNDEFINED_REFERENCE;
756
- }
757
- curry(definition) {
758
- let { args } = this;
759
- if (!args && isCurriedComponentDefinition(definition)) {
760
- return definition;
761
- } else if (!definition) {
762
- return null;
763
- } else {
764
- return new CurriedComponentDefinition(definition, args);
765
- }
766
- }
767
- }
768
-
769
- class ClassListReference {
770
- constructor(list) {
771
- this.list = list;
772
- this.tag = combineTagged(list);
773
- this.list = list;
774
- }
775
- value() {
776
- let ret = [];
777
- let { list } = this;
778
- for (let i = 0; i < list.length; i++) {
779
- let value = normalizeStringValue(list[i].value());
780
- if (value) ret.push(value);
781
- }
782
- return ret.length === 0 ? null : ret.join(' ');
783
- }
784
- }
785
-
786
- /**
787
- * Converts a ComponentCapabilities object into a 32-bit integer representation.
788
- */
789
- function capabilityFlagsFrom(capabilities) {
790
- return 0 | (capabilities.dynamicLayout ? 1 /* DynamicLayout */ : 0) | (capabilities.dynamicTag ? 2 /* DynamicTag */ : 0) | (capabilities.prepareArgs ? 4 /* PrepareArgs */ : 0) | (capabilities.createArgs ? 8 /* CreateArgs */ : 0) | (capabilities.attributeHook ? 16 /* AttributeHook */ : 0) | (capabilities.elementHook ? 32 /* ElementHook */ : 0) | (capabilities.dynamicScope ? 64 /* DynamicScope */ : 0) | (capabilities.createCaller ? 128 /* CreateCaller */ : 0) | (capabilities.updateHook ? 256 /* UpdateHook */ : 0) | (capabilities.createInstance ? 512 /* CreateInstance */ : 0);
791
- }
792
- function hasCapability(capabilities, capability) {
793
- return !!(capabilities & capability);
794
- }
795
-
796
- APPEND_OPCODES.add(69 /* IsComponent */, vm => {
797
- let stack = vm.stack;
798
- let ref = stack.pop();
799
- stack.push(IsCurriedComponentDefinitionReference.create(ref));
800
- });
801
- APPEND_OPCODES.add(70 /* ContentType */, vm => {
802
- let stack = vm.stack;
803
- let ref = stack.peek();
804
- stack.push(new ContentTypeReference(ref));
805
- });
806
- APPEND_OPCODES.add(71 /* CurryComponent */, (vm, { op1: _meta }) => {
807
- let stack = vm.stack;
808
- let definition = stack.pop();
809
- let capturedArgs = stack.pop();
810
- let meta = vm.constants.getSerializable(_meta);
811
- let resolver = vm.constants.resolver;
812
- vm.loadValue(Register.v0, new CurryComponentReference(definition, resolver, meta, capturedArgs));
813
- // expectStackChange(vm.stack, -args.length - 1, 'CurryComponent');
814
- });
815
- APPEND_OPCODES.add(72 /* PushComponentDefinition */, (vm, { op1: handle }) => {
816
- let definition = vm.constants.resolveHandle(handle);
817
-
818
- let { manager } = definition;
819
- let capabilities = capabilityFlagsFrom(manager.getCapabilities(definition.state));
820
- let instance = {
821
- definition,
822
- manager,
823
- capabilities,
824
- state: null,
825
- handle: null,
826
- table: null,
827
- lookup: null
828
- };
829
- vm.stack.push(instance);
830
- });
831
- APPEND_OPCODES.add(75 /* ResolveDynamicComponent */, (vm, { op1: _meta }) => {
832
- let stack = vm.stack;
833
- let component = stack.pop().value();
834
- let meta = vm.constants.getSerializable(_meta);
835
- vm.loadValue(Register.t1, null); // Clear the temp register
836
- let definition;
837
- if (typeof component === 'string') {
838
- let { constants: { resolver } } = vm;
839
- let resolvedDefinition = resolveComponent(resolver, component, meta);
840
- definition = resolvedDefinition;
841
- } else if (isCurriedComponentDefinition(component)) {
842
- definition = component;
843
- } else {
844
- throw unreachable();
845
- }
846
- stack.push(definition);
847
- });
848
- APPEND_OPCODES.add(73 /* PushDynamicComponentInstance */, vm => {
849
- let { stack } = vm;
850
- let definition = stack.pop();
851
- let capabilities, manager;
852
- if (isCurriedComponentDefinition(definition)) {
853
- manager = capabilities = null;
854
- } else {
855
- manager = definition.manager;
856
- capabilities = capabilityFlagsFrom(manager.getCapabilities(definition.state));
857
- }
858
- stack.push({ definition, capabilities, manager, state: null, handle: null, table: null });
859
- });
860
- APPEND_OPCODES.add(74 /* PushCurriedComponent */, (vm, { op1: _meta }) => {
861
- let stack = vm.stack;
862
- let component = stack.pop().value();
863
- let definition;
864
- if (isCurriedComponentDefinition(component)) {
865
- definition = component;
866
- } else {
867
- throw unreachable();
868
- }
869
- stack.push(definition);
870
- });
871
- APPEND_OPCODES.add(76 /* PushArgs */, (vm, { op1: _names, op2: flags }) => {
872
- let stack = vm.stack;
873
- let names = vm.constants.getStringArray(_names);
874
- let positionalCount = flags >> 4;
875
- let synthetic = flags & 0b1000;
876
- let blockNames = [];
877
- if (flags & 0b0100) blockNames.push('main');
878
- if (flags & 0b0010) blockNames.push('else');
879
- if (flags & 0b0001) blockNames.push('attrs');
880
- vm.args.setup(stack, names, blockNames, positionalCount, !!synthetic);
881
- stack.push(vm.args);
882
- });
883
- APPEND_OPCODES.add(77 /* PushEmptyArgs */, vm => {
884
- let { stack } = vm;
885
- stack.push(vm.args.empty(stack));
886
- });
887
- APPEND_OPCODES.add(80 /* CaptureArgs */, vm => {
888
- let stack = vm.stack;
889
- let args = stack.pop();
890
- let capturedArgs = args.capture();
891
- stack.push(capturedArgs);
892
- });
893
- APPEND_OPCODES.add(79 /* PrepareArgs */, (vm, { op1: _state }) => {
894
- let stack = vm.stack;
895
- let instance = vm.fetchValue(_state);
896
- let args = stack.pop();
897
- let { definition } = instance;
898
- if (isCurriedComponentDefinition(definition)) {
899
-
900
- definition = resolveCurriedComponentDefinition(instance, definition, args);
901
- }
902
- let { manager, state } = definition;
903
- let capabilities = instance.capabilities;
904
- if (hasCapability(capabilities, 4 /* PrepareArgs */) !== true) {
905
- stack.push(args);
906
- return;
907
- }
908
- let blocks = args.blocks.values;
909
- let blockNames = args.blocks.names;
910
- let preparedArgs = manager.prepareArgs(state, args);
911
- if (preparedArgs) {
912
- args.clear();
913
- for (let i = 0; i < blocks.length; i++) {
914
- stack.push(blocks[i]);
915
- }
916
- let { positional, named } = preparedArgs;
917
- let positionalCount = positional.length;
918
- for (let i = 0; i < positionalCount; i++) {
919
- stack.push(positional[i]);
920
- }
921
- let names = Object.keys(named);
922
- for (let i = 0; i < names.length; i++) {
923
- stack.push(named[names[i]]);
924
- }
925
- args.setup(stack, names, blockNames, positionalCount, true);
926
- }
927
- stack.push(args);
928
- });
929
- function resolveCurriedComponentDefinition(instance, definition, args) {
930
- let unwrappedDefinition = instance.definition = definition.unwrap(args);
931
- let { manager, state } = unwrappedDefinition;
932
-
933
- instance.manager = manager;
934
- instance.capabilities = capabilityFlagsFrom(manager.getCapabilities(state));
935
- return unwrappedDefinition;
936
- }
937
- APPEND_OPCODES.add(81 /* CreateComponent */, (vm, { op1: flags, op2: _state }) => {
938
- let instance = vm.fetchValue(_state);
939
- let { definition, manager } = instance;
940
- let capabilities = instance.capabilities = capabilityFlagsFrom(manager.getCapabilities(definition.state));
941
- let dynamicScope = null;
942
- if (hasCapability(capabilities, 64 /* DynamicScope */)) {
943
- dynamicScope = vm.dynamicScope();
944
- }
945
- let hasDefaultBlock = flags & 1;
946
- let args = null;
947
- if (hasCapability(capabilities, 8 /* CreateArgs */)) {
948
- args = vm.stack.peek();
949
- }
950
- let self = null;
951
- if (hasCapability(capabilities, 128 /* CreateCaller */)) {
952
- self = vm.getSelf();
953
- }
954
- let state = manager.create(vm.env, definition.state, args, dynamicScope, self, !!hasDefaultBlock);
955
- // We want to reuse the `state` POJO here, because we know that the opcodes
956
- // only transition at exactly one place.
957
- instance.state = state;
958
- let tag = manager.getTag(state);
959
- if (hasCapability(capabilities, 256 /* UpdateHook */) && !isConstTag(tag)) {
960
- vm.updateWith(new UpdateComponentOpcode(tag, state, manager, dynamicScope));
961
- }
962
- });
963
- APPEND_OPCODES.add(82 /* RegisterComponentDestructor */, (vm, { op1: _state }) => {
964
- let { manager, state } = vm.fetchValue(_state);
965
- let destructor = manager.getDestructor(state);
966
- if (destructor) vm.newDestroyable(destructor);
967
- });
968
- APPEND_OPCODES.add(91 /* BeginComponentTransaction */, vm => {
969
- vm.beginCacheGroup();
970
- vm.elements().pushSimpleBlock();
971
- });
972
- APPEND_OPCODES.add(83 /* PutComponentOperations */, vm => {
973
- vm.loadValue(Register.t0, new ComponentElementOperations());
974
- });
975
- APPEND_OPCODES.add(37 /* ComponentAttr */, (vm, { op1: _name, op2: trusting, op3: _namespace }) => {
976
- let name = vm.constants.getString(_name);
977
- let reference = vm.stack.pop();
978
- let namespace = _namespace ? vm.constants.getString(_namespace) : null;
979
- vm.fetchValue(Register.t0).setAttribute(name, reference, !!trusting, namespace);
980
- });
981
- class ComponentElementOperations {
982
- constructor() {
983
- this.attributes = dict();
984
- this.classes = [];
985
- }
986
- setAttribute(name, value, trusting, namespace) {
987
- let deferred = { value, namespace, trusting };
988
- if (name === 'class') {
989
- this.classes.push(value);
990
- }
991
- this.attributes[name] = deferred;
992
- }
993
- flush(vm) {
994
- for (let name in this.attributes) {
995
- let attr = this.attributes[name];
996
- let { value: reference, namespace, trusting } = attr;
997
- if (name === 'class') {
998
- reference = new ClassListReference(this.classes);
999
- }
1000
- if (name === 'type') {
1001
- continue;
1002
- }
1003
- let attribute = vm.elements().setDynamicAttribute(name, reference.value(), trusting, namespace);
1004
- if (!isConst(reference)) {
1005
- vm.updateWith(new UpdateDynamicAttributeOpcode(reference, attribute));
1006
- }
1007
- }
1008
- if ('type' in this.attributes) {
1009
- let type = this.attributes.type;
1010
- let { value: reference, namespace, trusting } = type;
1011
- let attribute = vm.elements().setDynamicAttribute('type', reference.value(), trusting, namespace);
1012
- if (!isConst(reference)) {
1013
- vm.updateWith(new UpdateDynamicAttributeOpcode(reference, attribute));
1014
- }
1015
- }
1016
- }
1017
- }
1018
- APPEND_OPCODES.add(93 /* DidCreateElement */, (vm, { op1: _state }) => {
1019
- let { definition, state } = vm.fetchValue(_state);
1020
- let { manager } = definition;
1021
- let operations = vm.fetchValue(Register.t0);
1022
- let action = 'DidCreateElementOpcode#evaluate';
1023
- manager.didCreateElement(state, vm.elements().expectConstructing(action), operations);
1024
- });
1025
- APPEND_OPCODES.add(84 /* GetComponentSelf */, (vm, { op1: _state }) => {
1026
- let { definition, state } = vm.fetchValue(_state);
1027
- let { manager } = definition;
1028
- vm.stack.push(manager.getSelf(state));
1029
- });
1030
- APPEND_OPCODES.add(85 /* GetComponentTagName */, (vm, { op1: _state }) => {
1031
- let { definition, state } = vm.fetchValue(_state);
1032
- let { manager } = definition;
1033
- vm.stack.push(manager.getTagName(state));
1034
- });
1035
- // Dynamic Invocation Only
1036
- APPEND_OPCODES.add(86 /* GetComponentLayout */, (vm, { op1: _state }) => {
1037
- let instance = vm.fetchValue(_state);
1038
- let { manager, definition } = instance;
1039
- let { constants: { resolver }, stack } = vm;
1040
- let { state: instanceState, capabilities } = instance;
1041
- let { state: definitionState } = definition;
1042
- let invoke;
1043
- if (hasStaticLayout(capabilities, manager)) {
1044
- invoke = manager.getLayout(definitionState, resolver);
1045
- } else if (hasDynamicLayout(capabilities, manager)) {
1046
- invoke = manager.getDynamicLayout(instanceState, resolver);
1047
- } else {
1048
- throw unreachable();
1049
- }
1050
- stack.push(invoke.symbolTable);
1051
- stack.push(invoke.handle);
1052
- });
1053
- function hasStaticLayout(capabilities, _manager) {
1054
- return hasCapability(capabilities, 1 /* DynamicLayout */) === false;
1055
- }
1056
- function hasDynamicLayout(capabilities, _manager) {
1057
- return hasCapability(capabilities, 1 /* DynamicLayout */) === true;
1058
- }
1059
- APPEND_OPCODES.add(68 /* Main */, (vm, { op1: register }) => {
1060
- let definition = vm.stack.pop();
1061
- let invocation = vm.stack.pop();
1062
- let { manager } = definition;
1063
- let capabilities = capabilityFlagsFrom(manager.getCapabilities(definition.state));
1064
- let state = {
1065
- definition,
1066
- manager,
1067
- capabilities,
1068
- state: null,
1069
- handle: invocation.handle,
1070
- table: invocation.symbolTable,
1071
- lookup: null
1072
- };
1073
- vm.loadValue(register, state);
1074
- });
1075
- APPEND_OPCODES.add(89 /* PopulateLayout */, (vm, { op1: _state }) => {
1076
- let { stack } = vm;
1077
- let handle = stack.pop();
1078
- let table = stack.pop();
1079
- let state = vm.fetchValue(_state);
1080
- state.handle = handle;
1081
- state.table = table;
1082
- });
1083
- APPEND_OPCODES.add(21 /* VirtualRootScope */, (vm, { op1: _state }) => {
1084
- let { symbols } = vm.fetchValue(_state).table;
1085
- vm.pushRootScope(symbols.length + 1, true);
1086
- });
1087
- APPEND_OPCODES.add(87 /* SetupForEval */, (vm, { op1: _state }) => {
1088
- let state = vm.fetchValue(_state);
1089
- if (state.table.hasEval) {
1090
- let lookup = state.lookup = dict();
1091
- vm.scope().bindEvalScope(lookup);
1092
- }
1093
- });
1094
- APPEND_OPCODES.add(2 /* SetNamedVariables */, (vm, { op1: _state }) => {
1095
- let state = vm.fetchValue(_state);
1096
- let scope = vm.scope();
1097
- let args = vm.stack.peek();
1098
- let callerNames = args.named.atNames;
1099
- for (let i = callerNames.length - 1; i >= 0; i--) {
1100
- let atName = callerNames[i];
1101
- let symbol = state.table.symbols.indexOf(callerNames[i]);
1102
- let value = args.named.get(atName, false);
1103
- if (symbol !== -1) scope.bindSymbol(symbol + 1, value);
1104
- if (state.lookup) state.lookup[atName] = value;
1105
- }
1106
- });
1107
- function bindBlock(symbolName, blockName, state, blocks, vm) {
1108
- let symbol = state.table.symbols.indexOf(symbolName);
1109
- let block = blocks.get(blockName);
1110
- if (symbol !== -1) {
1111
- vm.scope().bindBlock(symbol + 1, block);
1112
- }
1113
- if (state.lookup) state.lookup[symbolName] = block;
1114
- }
1115
- APPEND_OPCODES.add(3 /* SetBlocks */, (vm, { op1: _state }) => {
1116
- let state = vm.fetchValue(_state);
1117
- let { blocks } = vm.stack.peek();
1118
- bindBlock('&attrs', 'attrs', state, blocks, vm);
1119
- bindBlock('&inverse', 'else', state, blocks, vm);
1120
- bindBlock('&default', 'main', state, blocks, vm);
1121
- });
1122
- // Dynamic Invocation Only
1123
- APPEND_OPCODES.add(90 /* InvokeComponentLayout */, (vm, { op1: _state }) => {
1124
- let state = vm.fetchValue(_state);
1125
- vm.call(state.handle);
1126
- });
1127
- APPEND_OPCODES.add(94 /* DidRenderLayout */, (vm, { op1: _state }) => {
1128
- let { manager, state } = vm.fetchValue(_state);
1129
- let bounds = vm.elements().popBlock();
1130
- let mgr = manager;
1131
- mgr.didRenderLayout(state, bounds);
1132
- vm.env.didCreate(state, manager);
1133
- vm.updateWith(new DidUpdateLayoutOpcode(manager, state, bounds));
1134
- });
1135
- APPEND_OPCODES.add(92 /* CommitComponentTransaction */, vm => {
1136
- vm.commitCacheGroup();
1137
- });
1138
- class UpdateComponentOpcode extends UpdatingOpcode {
1139
- constructor(tag, component, manager, dynamicScope) {
1140
- super();
1141
- this.tag = tag;
1142
- this.component = component;
1143
- this.manager = manager;
1144
- this.dynamicScope = dynamicScope;
1145
- this.type = 'update-component';
1146
- }
1147
- evaluate(_vm) {
1148
- let { component, manager, dynamicScope } = this;
1149
- manager.update(component, dynamicScope);
1150
- }
1151
- }
1152
- class DidUpdateLayoutOpcode extends UpdatingOpcode {
1153
- constructor(manager, component, bounds) {
1154
- super();
1155
- this.manager = manager;
1156
- this.component = component;
1157
- this.bounds = bounds;
1158
- this.type = 'did-update-layout';
1159
- this.tag = CONSTANT_TAG;
1160
- }
1161
- evaluate(vm) {
1162
- let { manager, component, bounds } = this;
1163
- manager.didUpdateLayout(component, bounds);
1164
- vm.env.didUpdate(component, manager);
1165
- }
1166
- }
1167
-
1168
- /* tslint:disable */
1169
- function debugCallback(context, get) {
1170
- console.info('Use `context`, and `get(<path>)` to debug this template.');
1171
- // for example...
1172
- context === get('this');
1173
- debugger;
1174
- }
1175
- /* tslint:enable */
1176
- let callback = debugCallback;
1177
- // For testing purposes
1178
- function setDebuggerCallback(cb) {
1179
- callback = cb;
1180
- }
1181
- function resetDebuggerCallback() {
1182
- callback = debugCallback;
1183
- }
1184
- class ScopeInspector {
1185
- constructor(scope, symbols, evalInfo) {
1186
- this.scope = scope;
1187
- this.locals = dict();
1188
- for (let i = 0; i < evalInfo.length; i++) {
1189
- let slot = evalInfo[i];
1190
- let name = symbols[slot - 1];
1191
- let ref = scope.getSymbol(slot);
1192
- this.locals[name] = ref;
1193
- }
1194
- }
1195
- get(path) {
1196
- let { scope, locals } = this;
1197
- let parts = path.split('.');
1198
- let [head, ...tail] = path.split('.');
1199
- let evalScope = scope.getEvalScope();
1200
- let ref;
1201
- if (head === 'this') {
1202
- ref = scope.getSelf();
1203
- } else if (locals[head]) {
1204
- ref = locals[head];
1205
- } else if (head.indexOf('@') === 0 && evalScope[head]) {
1206
- ref = evalScope[head];
1207
- } else {
1208
- ref = this.scope.getSelf();
1209
- tail = parts;
1210
- }
1211
- return tail.reduce((r, part) => r.get(part), ref);
1212
- }
1213
- }
1214
- APPEND_OPCODES.add(97 /* Debugger */, (vm, { op1: _symbols, op2: _evalInfo }) => {
1215
- let symbols = vm.constants.getStringArray(_symbols);
1216
- let evalInfo = vm.constants.getArray(_evalInfo);
1217
- let inspector = new ScopeInspector(vm.scope(), symbols, evalInfo);
1218
- callback(vm.getSelf().value(), path => inspector.get(path).value());
1219
- });
1220
-
1221
- APPEND_OPCODES.add(95 /* InvokePartial */, (vm, { op1: _meta, op2: _symbols, op3: _evalInfo }) => {
1222
- let { constants, constants: { resolver }, stack } = vm;
1223
- let name = stack.pop().value();
1224
-
1225
- let meta = constants.getSerializable(_meta);
1226
- let outerSymbols = constants.getStringArray(_symbols);
1227
- let evalInfo = constants.getArray(_evalInfo);
1228
- let handle = resolver.lookupPartial(name, meta);
1229
-
1230
- let definition = resolver.resolve(handle);
1231
- let { symbolTable, handle: vmHandle } = definition.getPartial();
1232
- {
1233
- let partialSymbols = symbolTable.symbols;
1234
- let outerScope = vm.scope();
1235
- let partialScope = vm.pushRootScope(partialSymbols.length, false);
1236
- let evalScope = outerScope.getEvalScope();
1237
- partialScope.bindCallerScope(outerScope.getCallerScope());
1238
- partialScope.bindEvalScope(evalScope);
1239
- partialScope.bindSelf(outerScope.getSelf());
1240
- let locals = Object.create(outerScope.getPartialMap());
1241
- for (let i = 0; i < evalInfo.length; i++) {
1242
- let slot = evalInfo[i];
1243
- let name = outerSymbols[slot - 1];
1244
- let ref = outerScope.getSymbol(slot);
1245
- locals[name] = ref;
1246
- }
1247
- if (evalScope) {
1248
- for (let i = 0; i < partialSymbols.length; i++) {
1249
- let name = partialSymbols[i];
1250
- let symbol = i + 1;
1251
- let value = evalScope[name];
1252
- if (value !== undefined) partialScope.bind(symbol, value);
1253
- }
1254
- }
1255
- partialScope.bindPartialMap(locals);
1256
- vm.pushFrame(); // sp += 2
1257
- vm.call(vmHandle);
1258
- }
1259
- });
1260
-
1261
- class IterablePresenceReference {
1262
- constructor(artifacts) {
1263
- this.tag = artifacts.tag;
1264
- this.artifacts = artifacts;
1265
- }
1266
- value() {
1267
- return !this.artifacts.isEmpty();
1268
- }
1269
- }
1270
- APPEND_OPCODES.add(66 /* PutIterator */, vm => {
1271
- let stack = vm.stack;
1272
- let listRef = stack.pop();
1273
- let key = stack.pop();
1274
- let iterable = vm.env.iterableFor(listRef, key.value());
1275
- let iterator = new ReferenceIterator(iterable);
1276
- stack.push(iterator);
1277
- stack.push(new IterablePresenceReference(iterator.artifacts));
1278
- });
1279
- APPEND_OPCODES.add(64 /* EnterList */, (vm, { op1: relativeStart }) => {
1280
- vm.enterList(relativeStart);
1281
- });
1282
- APPEND_OPCODES.add(65 /* ExitList */, vm => {
1283
- vm.exitList();
1284
- });
1285
- APPEND_OPCODES.add(67 /* Iterate */, (vm, { op1: breaks }) => {
1286
- let stack = vm.stack;
1287
- let item = stack.peek().next();
1288
- if (item) {
1289
- let tryOpcode = vm.iterate(item.memo, item.value);
1290
- vm.enterItem(item.key, tryOpcode);
1291
- } else {
1292
- vm.goto(breaks);
1293
- }
1294
- });
1295
-
1296
- class Cursor {
1297
- constructor(element, nextSibling) {
1298
- this.element = element;
1299
- this.nextSibling = nextSibling;
1300
- }
1301
- }
1302
- class ConcreteBounds {
1303
- constructor(parentNode, first, last) {
1304
- this.parentNode = parentNode;
1305
- this.first = first;
1306
- this.last = last;
1307
- }
1308
- parentElement() {
1309
- return this.parentNode;
1310
- }
1311
- firstNode() {
1312
- return this.first;
1313
- }
1314
- lastNode() {
1315
- return this.last;
1316
- }
1317
- }
1318
- class SingleNodeBounds {
1319
- constructor(parentNode, node) {
1320
- this.parentNode = parentNode;
1321
- this.node = node;
1322
- }
1323
- parentElement() {
1324
- return this.parentNode;
1325
- }
1326
- firstNode() {
1327
- return this.node;
1328
- }
1329
- lastNode() {
1330
- return this.node;
1331
- }
1332
- }
1333
- function bounds(parent, first, last) {
1334
- return new ConcreteBounds(parent, first, last);
1335
- }
1336
- function single(parent, node) {
1337
- return new SingleNodeBounds(parent, node);
1338
- }
1339
- function move(bounds, reference) {
1340
- let parent = bounds.parentElement();
1341
- let first = bounds.firstNode();
1342
- let last = bounds.lastNode();
1343
- let node = first;
1344
- while (node) {
1345
- let next = node.nextSibling;
1346
- parent.insertBefore(node, reference);
1347
- if (node === last) return next;
1348
- node = next;
1349
- }
1350
- return null;
1351
- }
1352
- function clear(bounds) {
1353
- let parent = bounds.parentElement();
1354
- let first = bounds.firstNode();
1355
- let last = bounds.lastNode();
1356
- let node = first;
1357
- while (node) {
1358
- let next = node.nextSibling;
1359
- parent.removeChild(node);
1360
- if (node === last) return next;
1361
- node = next;
1362
- }
1363
- return null;
1364
- }
1365
-
1366
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1367
- // Patch: insertAdjacentHTML on SVG Fix
1368
- // Browsers: Safari, IE, Edge, Firefox ~33-34
1369
- // Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is
1370
- // present but throws an exception on IE and Edge. Old versions of
1371
- // Firefox create nodes in the incorrect namespace.
1372
- // Fix: Since IE and Edge silently fail to create SVG nodes using
1373
- // innerHTML, and because Firefox may create nodes in the incorrect
1374
- // namespace using innerHTML on SVG elements, an HTML-string wrapping
1375
- // approach is used. A pre/post SVG tag is added to the string, then
1376
- // that whole string is added to a div. The created nodes are plucked
1377
- // out and applied to the target location on DOM.
1378
- function applySVGInnerHTMLFix(document, DOMClass, svgNamespace) {
1379
- if (!document) return DOMClass;
1380
- if (!shouldApplyFix(document, svgNamespace)) {
1381
- return DOMClass;
1382
- }
1383
- let div = document.createElement('div');
1384
- return class DOMChangesWithSVGInnerHTMLFix extends DOMClass {
1385
- insertHTMLBefore(parent, nextSibling, html) {
1386
- if (parent.namespaceURI !== svgNamespace) {
1387
- return super.insertHTMLBefore(parent, nextSibling, html);
1388
- }
1389
- return fixSVG(parent, div, html, nextSibling);
1390
- }
1391
- };
1392
- }
1393
- function fixSVG(parent, div, html, reference) {
1394
- let source;
1395
- // This is important, because decendants of the <foreignObject> integration
1396
- // point are parsed in the HTML namespace
1397
- if (parent.tagName.toUpperCase() === 'FOREIGNOBJECT') {
1398
- // IE, Edge: also do not correctly support using `innerHTML` on SVG
1399
- // namespaced elements. So here a wrapper is used.
1400
- let wrappedHtml = '<svg><foreignObject>' + (html || '<!---->') + '</foreignObject></svg>';
1401
- div.innerHTML = wrappedHtml;
1402
- source = div.firstChild.firstChild;
1403
- } else {
1404
- // IE, Edge: also do not correctly support using `innerHTML` on SVG
1405
- // namespaced elements. So here a wrapper is used.
1406
- let wrappedHtml = '<svg>' + (html || '<!---->') + '</svg>';
1407
- div.innerHTML = wrappedHtml;
1408
- source = div.firstChild;
1409
- }
1410
- let [first, last] = moveNodesBefore(source, parent, reference);
1411
- return new ConcreteBounds(parent, first, last);
1412
- }
1413
- function shouldApplyFix(document, svgNamespace) {
1414
- let svg = document.createElementNS(svgNamespace, 'svg');
1415
- try {
1416
- svg['insertAdjacentHTML']('beforeend', '<circle></circle>');
1417
- } catch (e) {
1418
- // IE, Edge: Will throw, insertAdjacentHTML is unsupported on SVG
1419
- // Safari: Will throw, insertAdjacentHTML is not present on SVG
1420
- } finally {
1421
- // FF: Old versions will create a node in the wrong namespace
1422
- if (svg.childNodes.length === 1 && svg.firstChild.namespaceURI === SVG_NAMESPACE) {
1423
- // The test worked as expected, no fix required
1424
- return false;
1425
- }
1426
- return true;
1427
- }
1428
- }
1429
-
1430
- // Patch: Adjacent text node merging fix
1431
- // Browsers: IE, Edge, Firefox w/o inspector open
1432
- // Reason: These browsers will merge adjacent text nodes. For exmaple given
1433
- // <div>Hello</div> with div.insertAdjacentHTML(' world') browsers
1434
- // with proper behavior will populate div.childNodes with two items.
1435
- // These browsers will populate it with one merged node instead.
1436
- // Fix: Add these nodes to a wrapper element, then iterate the childNodes
1437
- // of that wrapper and move the nodes to their target location. Note
1438
- // that potential SVG bugs will have been handled before this fix.
1439
- // Note that this fix must only apply to the previous text node, as
1440
- // the base implementation of `insertHTMLBefore` already handles
1441
- // following text nodes correctly.
1442
- function applyTextNodeMergingFix(document, DOMClass) {
1443
- if (!document) return DOMClass;
1444
- if (!shouldApplyFix$1(document)) {
1445
- return DOMClass;
1446
- }
1447
- return class DOMChangesWithTextNodeMergingFix extends DOMClass {
1448
- constructor(document) {
1449
- super(document);
1450
- this.uselessComment = document.createComment('');
1451
- }
1452
- insertHTMLBefore(parent, nextSibling, html) {
1453
- let didSetUselessComment = false;
1454
- let nextPrevious = nextSibling ? nextSibling.previousSibling : parent.lastChild;
1455
- if (nextPrevious && nextPrevious instanceof Text) {
1456
- didSetUselessComment = true;
1457
- parent.insertBefore(this.uselessComment, nextSibling);
1458
- }
1459
- let bounds = super.insertHTMLBefore(parent, nextSibling, html);
1460
- if (didSetUselessComment) {
1461
- parent.removeChild(this.uselessComment);
1462
- }
1463
- return bounds;
1464
- }
1465
- };
1466
- }
1467
- function shouldApplyFix$1(document) {
1468
- let mergingTextDiv = document.createElement('div');
1469
- mergingTextDiv.innerHTML = 'first';
1470
- mergingTextDiv.insertAdjacentHTML('beforeend', 'second');
1471
- if (mergingTextDiv.childNodes.length === 2) {
1472
- // It worked as expected, no fix required
1473
- return false;
1474
- }
1475
- return true;
1476
- }
1477
-
1478
- const SVG_NAMESPACE$1 = 'http://www.w3.org/2000/svg';
1479
- // http://www.w3.org/TR/html/syntax.html#html-integration-point
1480
- const SVG_INTEGRATION_POINTS = { foreignObject: 1, desc: 1, title: 1 };
1481
- // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes
1482
- // TODO: Adjust SVG attributes
1483
- // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign
1484
- // TODO: Adjust SVG elements
1485
- // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign
1486
- const BLACKLIST_TABLE = Object.create(null);
1487
- ['b', 'big', 'blockquote', 'body', 'br', 'center', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'embed', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'i', 'img', 'li', 'listing', 'main', 'meta', 'nobr', 'ol', 'p', 'pre', 'ruby', 's', 'small', 'span', 'strong', 'strike', 'sub', 'sup', 'table', 'tt', 'u', 'ul', 'var'].forEach(tag => BLACKLIST_TABLE[tag] = 1);
1488
- const WHITESPACE = /[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;
1489
- let doc = typeof document === 'undefined' ? null : document;
1490
- function isWhitespace(string) {
1491
- return WHITESPACE.test(string);
1492
- }
1493
- function moveNodesBefore(source, target, nextSibling) {
1494
- let first = source.firstChild;
1495
- let last = null;
1496
- let current = first;
1497
- while (current) {
1498
- last = current;
1499
- current = current.nextSibling;
1500
- target.insertBefore(last, nextSibling);
1501
- }
1502
- return [first, last];
1503
- }
1504
- class DOMOperations {
1505
- constructor(document) {
1506
- this.document = document;
1507
- this.setupUselessElement();
1508
- }
1509
- // split into seperate method so that NodeDOMTreeConstruction
1510
- // can override it.
1511
- setupUselessElement() {
1512
- this.uselessElement = this.document.createElement('div');
1513
- }
1514
- createElement(tag, context) {
1515
- let isElementInSVGNamespace, isHTMLIntegrationPoint;
1516
- if (context) {
1517
- isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE$1 || tag === 'svg';
1518
- isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];
1519
- } else {
1520
- isElementInSVGNamespace = tag === 'svg';
1521
- isHTMLIntegrationPoint = false;
1522
- }
1523
- if (isElementInSVGNamespace && !isHTMLIntegrationPoint) {
1524
- // FIXME: This does not properly handle <font> with color, face, or
1525
- // size attributes, which is also disallowed by the spec. We should fix
1526
- // this.
1527
- if (BLACKLIST_TABLE[tag]) {
1528
- throw new Error(`Cannot create a ${tag} inside an SVG context`);
1529
- }
1530
- return this.document.createElementNS(SVG_NAMESPACE$1, tag);
1531
- } else {
1532
- return this.document.createElement(tag);
1533
- }
1534
- }
1535
- insertBefore(parent, node, reference) {
1536
- parent.insertBefore(node, reference);
1537
- }
1538
- insertHTMLBefore(_parent, nextSibling, html) {
1539
- return insertHTMLBefore(this.uselessElement, _parent, nextSibling, html);
1540
- }
1541
- createTextNode(text) {
1542
- return this.document.createTextNode(text);
1543
- }
1544
- createComment(data) {
1545
- return this.document.createComment(data);
1546
- }
1547
- }
1548
- var DOM;
1549
- (function (DOM) {
1550
- class TreeConstruction extends DOMOperations {
1551
- createElementNS(namespace, tag) {
1552
- return this.document.createElementNS(namespace, tag);
1553
- }
1554
- setAttribute(element, name, value, namespace = null) {
1555
- if (namespace) {
1556
- element.setAttributeNS(namespace, name, value);
1557
- } else {
1558
- element.setAttribute(name, value);
1559
- }
1560
- }
1561
- }
1562
- DOM.TreeConstruction = TreeConstruction;
1563
- let appliedTreeContruction = TreeConstruction;
1564
- appliedTreeContruction = applyTextNodeMergingFix(doc, appliedTreeContruction);
1565
- appliedTreeContruction = applySVGInnerHTMLFix(doc, appliedTreeContruction, SVG_NAMESPACE$1);
1566
- DOM.DOMTreeConstruction = appliedTreeContruction;
1567
- })(DOM || (DOM = {}));
1568
- class DOMChanges extends DOMOperations {
1569
- constructor(document) {
1570
- super(document);
1571
- this.document = document;
1572
- this.namespace = null;
1573
- }
1574
- setAttribute(element, name, value) {
1575
- element.setAttribute(name, value);
1576
- }
1577
- removeAttribute(element, name) {
1578
- element.removeAttribute(name);
1579
- }
1580
- insertAfter(element, node, reference) {
1581
- this.insertBefore(element, node, reference.nextSibling);
1582
- }
1583
- }
1584
- function insertHTMLBefore(useless, _parent, _nextSibling, _html) {
1585
- let parent = _parent;
1586
- let nextSibling = _nextSibling;
1587
- let prev = nextSibling ? nextSibling.previousSibling : parent.lastChild;
1588
- let last;
1589
- let html = _html || '<!---->';
1590
- if (nextSibling === null) {
1591
- parent.insertAdjacentHTML('beforeend', html);
1592
- last = parent.lastChild;
1593
- } else if (nextSibling instanceof HTMLElement) {
1594
- nextSibling.insertAdjacentHTML('beforebegin', html);
1595
- last = nextSibling.previousSibling;
1596
- } else {
1597
- // Non-element nodes do not support insertAdjacentHTML, so add an
1598
- // element and call it on that element. Then remove the element.
1599
- //
1600
- // This also protects Edge, IE and Firefox w/o the inspector open
1601
- // from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts
1602
- parent.insertBefore(useless, nextSibling);
1603
- useless.insertAdjacentHTML('beforebegin', html);
1604
- last = useless.previousSibling;
1605
- parent.removeChild(useless);
1606
- }
1607
- let first = prev ? prev.nextSibling : parent.firstChild;
1608
- return new ConcreteBounds(parent, first, last);
1609
- }
1610
- let helper = DOMChanges;
1611
- helper = applyTextNodeMergingFix(doc, helper);
1612
- helper = applySVGInnerHTMLFix(doc, helper, SVG_NAMESPACE$1);
1613
- var helper$1 = helper;
1614
- const DOMTreeConstruction = DOM.DOMTreeConstruction;
1615
-
1616
- const badProtocols = ['javascript:', 'vbscript:'];
1617
- const badTags = ['A', 'BODY', 'LINK', 'IMG', 'IFRAME', 'BASE', 'FORM'];
1618
- const badTagsForDataURI = ['EMBED'];
1619
- const badAttributes = ['href', 'src', 'background', 'action'];
1620
- const badAttributesForDataURI = ['src'];
1621
- function has(array, item) {
1622
- return array.indexOf(item) !== -1;
1623
- }
1624
- function checkURI(tagName, attribute) {
1625
- return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute);
1626
- }
1627
- function checkDataURI(tagName, attribute) {
1628
- if (tagName === null) return false;
1629
- return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute);
1630
- }
1631
- function requiresSanitization(tagName, attribute) {
1632
- return checkURI(tagName, attribute) || checkDataURI(tagName, attribute);
1633
- }
1634
- function sanitizeAttributeValue(env, element, attribute, value) {
1635
- let tagName = null;
1636
- if (value === null || value === undefined) {
1637
- return value;
1638
- }
1639
- if (isSafeString(value)) {
1640
- return value.toHTML();
1641
- }
1642
- if (!element) {
1643
- tagName = null;
1644
- } else {
1645
- tagName = element.tagName.toUpperCase();
1646
- }
1647
- let str = normalizeStringValue(value);
1648
- if (checkURI(tagName, attribute)) {
1649
- let protocol = env.protocolForURL(str);
1650
- if (has(badProtocols, protocol)) {
1651
- return `unsafe:${str}`;
1652
- }
1653
- }
1654
- if (checkDataURI(tagName, attribute)) {
1655
- return `unsafe:${str}`;
1656
- }
1657
- return str;
1658
- }
1659
-
1660
- /*
1661
- * @method normalizeProperty
1662
- * @param element {HTMLElement}
1663
- * @param slotName {String}
1664
- * @returns {Object} { name, type }
1665
- */
1666
- function normalizeProperty(element, slotName) {
1667
- let type, normalized;
1668
- if (slotName in element) {
1669
- normalized = slotName;
1670
- type = 'prop';
1671
- } else {
1672
- let lower = slotName.toLowerCase();
1673
- if (lower in element) {
1674
- type = 'prop';
1675
- normalized = lower;
1676
- } else {
1677
- type = 'attr';
1678
- normalized = slotName;
1679
- }
1680
- }
1681
- if (type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName, normalized))) {
1682
- type = 'attr';
1683
- }
1684
- return { normalized, type };
1685
- }
1686
- // properties that MUST be set as attributes, due to:
1687
- // * browser bug
1688
- // * strange spec outlier
1689
- const ATTR_OVERRIDES = {
1690
- INPUT: {
1691
- form: true,
1692
- // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false
1693
- // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false
1694
- // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true
1695
- autocorrect: true,
1696
- // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true
1697
- // Safari 9.1.3: 'list' in document.createElement('input') === false
1698
- list: true
1699
- },
1700
- // element.form is actually a legitimate readOnly property, that is to be
1701
- // mutated, but must be mutated by setAttribute...
1702
- SELECT: { form: true },
1703
- OPTION: { form: true },
1704
- TEXTAREA: { form: true },
1705
- LABEL: { form: true },
1706
- FIELDSET: { form: true },
1707
- LEGEND: { form: true },
1708
- OBJECT: { form: true },
1709
- BUTTON: { form: true }
1710
- };
1711
- function preferAttr(tagName, propName) {
1712
- let tag = ATTR_OVERRIDES[tagName.toUpperCase()];
1713
- return tag && tag[propName.toLowerCase()] || false;
1714
- }
1715
-
1716
- function dynamicAttribute(element, attr, namespace) {
1717
- let { tagName, namespaceURI } = element;
1718
- let attribute = { element, name: attr, namespace };
1719
- if (namespaceURI === SVG_NAMESPACE$1) {
1720
- return buildDynamicAttribute(tagName, attr, attribute);
1721
- }
1722
- let { type, normalized } = normalizeProperty(element, attr);
1723
- if (type === 'attr') {
1724
- return buildDynamicAttribute(tagName, normalized, attribute);
1725
- } else {
1726
- return buildDynamicProperty(tagName, normalized, attribute);
1727
- }
1728
- }
1729
- function buildDynamicAttribute(tagName, name, attribute) {
1730
- if (requiresSanitization(tagName, name)) {
1731
- return new SafeDynamicAttribute(attribute);
1732
- } else {
1733
- return new SimpleDynamicAttribute(attribute);
1734
- }
1735
- }
1736
- function buildDynamicProperty(tagName, name, attribute) {
1737
- if (requiresSanitization(tagName, name)) {
1738
- return new SafeDynamicProperty(name, attribute);
1739
- }
1740
- if (isUserInputValue(tagName, name)) {
1741
- return new InputValueDynamicAttribute(name, attribute);
1742
- }
1743
- if (isOptionSelected(tagName, name)) {
1744
- return new OptionSelectedDynamicAttribute(name, attribute);
1745
- }
1746
- return new DefaultDynamicProperty(name, attribute);
1747
- }
1748
- class DynamicAttribute {
1749
- constructor(attribute) {
1750
- this.attribute = attribute;
1751
- }
1752
- }
1753
- class SimpleDynamicAttribute extends DynamicAttribute {
1754
- set(dom, value, _env) {
1755
- let normalizedValue = normalizeValue(value);
1756
- if (normalizedValue !== null) {
1757
- let { name, namespace } = this.attribute;
1758
- dom.__setAttribute(name, normalizedValue, namespace);
1759
- }
1760
- }
1761
- update(value, _env) {
1762
- let normalizedValue = normalizeValue(value);
1763
- let { element, name } = this.attribute;
1764
- if (normalizedValue === null) {
1765
- element.removeAttribute(name);
1766
- } else {
1767
- element.setAttribute(name, normalizedValue);
1768
- }
1769
- }
1770
- }
1771
- class DefaultDynamicProperty extends DynamicAttribute {
1772
- constructor(normalizedName, attribute) {
1773
- super(attribute);
1774
- this.normalizedName = normalizedName;
1775
- }
1776
- set(dom, value, _env) {
1777
- if (value !== null && value !== undefined) {
1778
- this.value = value;
1779
- dom.__setProperty(this.normalizedName, value);
1780
- }
1781
- }
1782
- update(value, _env) {
1783
- let { element } = this.attribute;
1784
- if (this.value !== value) {
1785
- element[this.normalizedName] = this.value = value;
1786
- if (value === null || value === undefined) {
1787
- this.removeAttribute();
1788
- }
1789
- }
1790
- }
1791
- removeAttribute() {
1792
- // TODO this sucks but to preserve properties first and to meet current
1793
- // semantics we must do this.
1794
- let { element, namespace } = this.attribute;
1795
- if (namespace) {
1796
- element.removeAttributeNS(namespace, this.normalizedName);
1797
- } else {
1798
- element.removeAttribute(this.normalizedName);
1799
- }
1800
- }
1801
- }
1802
- class SafeDynamicProperty extends DefaultDynamicProperty {
1803
- set(dom, value, env) {
1804
- let { element, name } = this.attribute;
1805
- let sanitized = sanitizeAttributeValue(env, element, name, value);
1806
- super.set(dom, sanitized, env);
1807
- }
1808
- update(value, env) {
1809
- let { element, name } = this.attribute;
1810
- let sanitized = sanitizeAttributeValue(env, element, name, value);
1811
- super.update(sanitized, env);
1812
- }
1813
- }
1814
- class SafeDynamicAttribute extends SimpleDynamicAttribute {
1815
- set(dom, value, env) {
1816
- let { element, name } = this.attribute;
1817
- let sanitized = sanitizeAttributeValue(env, element, name, value);
1818
- super.set(dom, sanitized, env);
1819
- }
1820
- update(value, env) {
1821
- let { element, name } = this.attribute;
1822
- let sanitized = sanitizeAttributeValue(env, element, name, value);
1823
- super.update(sanitized, env);
1824
- }
1825
- }
1826
- class InputValueDynamicAttribute extends DefaultDynamicProperty {
1827
- set(dom, value) {
1828
- dom.__setProperty('value', normalizeStringValue(value));
1829
- }
1830
- update(value) {
1831
- let input = this.attribute.element;
1832
- let currentValue = input.value;
1833
- let normalizedValue = normalizeStringValue(value);
1834
- if (currentValue !== normalizedValue) {
1835
- input.value = normalizedValue;
1836
- }
1837
- }
1838
- }
1839
- class OptionSelectedDynamicAttribute extends DefaultDynamicProperty {
1840
- set(dom, value) {
1841
- if (value !== null && value !== undefined && value !== false) {
1842
- dom.__setProperty('selected', true);
1843
- }
1844
- }
1845
- update(value) {
1846
- let option = this.attribute.element;
1847
- if (value) {
1848
- option.selected = true;
1849
- } else {
1850
- option.selected = false;
1851
- }
1852
- }
1853
- }
1854
- function isOptionSelected(tagName, attribute) {
1855
- return tagName === 'OPTION' && attribute === 'selected';
1856
- }
1857
- function isUserInputValue(tagName, attribute) {
1858
- return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value';
1859
- }
1860
- function normalizeValue(value) {
1861
- if (value === false || value === undefined || value === null || typeof value.toString === 'undefined') {
1862
- return null;
1863
- }
1864
- if (value === true) {
1865
- return '';
1866
- }
1867
- // onclick function etc in SSR
1868
- if (typeof value === 'function') {
1869
- return null;
1870
- }
1871
- return String(value);
1872
- }
1873
-
1874
- class Scope {
1875
- constructor(
1876
- // the 0th slot is `self`
1877
- slots, callerScope,
1878
- // named arguments and blocks passed to a layout that uses eval
1879
- evalScope,
1880
- // locals in scope when the partial was invoked
1881
- partialMap) {
1882
- this.slots = slots;
1883
- this.callerScope = callerScope;
1884
- this.evalScope = evalScope;
1885
- this.partialMap = partialMap;
1886
- }
1887
- static root(self, size = 0) {
1888
- let refs = new Array(size + 1);
1889
- for (let i = 0; i <= size; i++) {
1890
- refs[i] = UNDEFINED_REFERENCE;
1891
- }
1892
- return new Scope(refs, null, null, null).init({ self });
1893
- }
1894
- static sized(size = 0) {
1895
- let refs = new Array(size + 1);
1896
- for (let i = 0; i <= size; i++) {
1897
- refs[i] = UNDEFINED_REFERENCE;
1898
- }
1899
- return new Scope(refs, null, null, null);
1900
- }
1901
- init({ self }) {
1902
- this.slots[0] = self;
1903
- return this;
1904
- }
1905
- getSelf() {
1906
- return this.get(0);
1907
- }
1908
- getSymbol(symbol) {
1909
- return this.get(symbol);
1910
- }
1911
- getBlock(symbol) {
1912
- let block = this.get(symbol);
1913
- return block === UNDEFINED_REFERENCE ? null : block;
1914
- }
1915
- getEvalScope() {
1916
- return this.evalScope;
1917
- }
1918
- getPartialMap() {
1919
- return this.partialMap;
1920
- }
1921
- bind(symbol, value) {
1922
- this.set(symbol, value);
1923
- }
1924
- bindSelf(self) {
1925
- this.set(0, self);
1926
- }
1927
- bindSymbol(symbol, value) {
1928
- this.set(symbol, value);
1929
- }
1930
- bindBlock(symbol, value) {
1931
- this.set(symbol, value);
1932
- }
1933
- bindEvalScope(map) {
1934
- this.evalScope = map;
1935
- }
1936
- bindPartialMap(map) {
1937
- this.partialMap = map;
1938
- }
1939
- bindCallerScope(scope) {
1940
- this.callerScope = scope;
1941
- }
1942
- getCallerScope() {
1943
- return this.callerScope;
1944
- }
1945
- child() {
1946
- return new Scope(this.slots.slice(), this.callerScope, this.evalScope, this.partialMap);
1947
- }
1948
- get(index) {
1949
- if (index >= this.slots.length) {
1950
- throw new RangeError(`BUG: cannot get $${index} from scope; length=${this.slots.length}`);
1951
- }
1952
- return this.slots[index];
1953
- }
1954
- set(index, value) {
1955
- if (index >= this.slots.length) {
1956
- throw new RangeError(`BUG: cannot get $${index} from scope; length=${this.slots.length}`);
1957
- }
1958
- this.slots[index] = value;
1959
- }
1960
- }
1961
- class Transaction {
1962
- constructor() {
1963
- this.scheduledInstallManagers = [];
1964
- this.scheduledInstallModifiers = [];
1965
- this.scheduledUpdateModifierManagers = [];
1966
- this.scheduledUpdateModifiers = [];
1967
- this.createdComponents = [];
1968
- this.createdManagers = [];
1969
- this.updatedComponents = [];
1970
- this.updatedManagers = [];
1971
- this.destructors = [];
1972
- }
1973
- didCreate(component, manager) {
1974
- this.createdComponents.push(component);
1975
- this.createdManagers.push(manager);
1976
- }
1977
- didUpdate(component, manager) {
1978
- this.updatedComponents.push(component);
1979
- this.updatedManagers.push(manager);
1980
- }
1981
- scheduleInstallModifier(modifier, manager) {
1982
- this.scheduledInstallManagers.push(manager);
1983
- this.scheduledInstallModifiers.push(modifier);
1984
- }
1985
- scheduleUpdateModifier(modifier, manager) {
1986
- this.scheduledUpdateModifierManagers.push(manager);
1987
- this.scheduledUpdateModifiers.push(modifier);
1988
- }
1989
- didDestroy(d) {
1990
- this.destructors.push(d);
1991
- }
1992
- commit() {
1993
- let { createdComponents, createdManagers } = this;
1994
- for (let i = 0; i < createdComponents.length; i++) {
1995
- let component = createdComponents[i];
1996
- let manager = createdManagers[i];
1997
- manager.didCreate(component);
1998
- }
1999
- let { updatedComponents, updatedManagers } = this;
2000
- for (let i = 0; i < updatedComponents.length; i++) {
2001
- let component = updatedComponents[i];
2002
- let manager = updatedManagers[i];
2003
- manager.didUpdate(component);
2004
- }
2005
- let { destructors } = this;
2006
- for (let i = 0; i < destructors.length; i++) {
2007
- destructors[i].destroy();
2008
- }
2009
- let { scheduledInstallManagers, scheduledInstallModifiers } = this;
2010
- for (let i = 0; i < scheduledInstallManagers.length; i++) {
2011
- let manager = scheduledInstallManagers[i];
2012
- let modifier = scheduledInstallModifiers[i];
2013
- manager.install(modifier);
2014
- }
2015
- let { scheduledUpdateModifierManagers, scheduledUpdateModifiers } = this;
2016
- for (let i = 0; i < scheduledUpdateModifierManagers.length; i++) {
2017
- let manager = scheduledUpdateModifierManagers[i];
2018
- let modifier = scheduledUpdateModifiers[i];
2019
- manager.update(modifier);
2020
- }
2021
- }
2022
- }
2023
- class Environment {
2024
- constructor({ appendOperations, updateOperations }) {
2025
- this._transaction = null;
2026
- this.appendOperations = appendOperations;
2027
- this.updateOperations = updateOperations;
2028
- }
2029
- toConditionalReference(reference) {
2030
- return new ConditionalReference(reference);
2031
- }
2032
- getAppendOperations() {
2033
- return this.appendOperations;
2034
- }
2035
- getDOM() {
2036
- return this.updateOperations;
2037
- }
2038
- begin() {
2039
-
2040
- this._transaction = new Transaction();
2041
- }
2042
- get transaction() {
2043
- return this._transaction;
2044
- }
2045
- didCreate(component, manager) {
2046
- this.transaction.didCreate(component, manager);
2047
- }
2048
- didUpdate(component, manager) {
2049
- this.transaction.didUpdate(component, manager);
2050
- }
2051
- scheduleInstallModifier(modifier, manager) {
2052
- this.transaction.scheduleInstallModifier(modifier, manager);
2053
- }
2054
- scheduleUpdateModifier(modifier, manager) {
2055
- this.transaction.scheduleUpdateModifier(modifier, manager);
2056
- }
2057
- didDestroy(d) {
2058
- this.transaction.didDestroy(d);
2059
- }
2060
- commit() {
2061
- let transaction = this.transaction;
2062
- this._transaction = null;
2063
- transaction.commit();
2064
- }
2065
- attributeFor(element, attr, _isTrusting, namespace = null) {
2066
- return dynamicAttribute(element, attr, namespace);
2067
- }
2068
- }
2069
- class DefaultEnvironment extends Environment {
2070
- constructor(options) {
2071
- if (!options) {
2072
- let document = window.document;
2073
- let appendOperations = new DOMTreeConstruction(document);
2074
- let updateOperations = new DOMChanges(document);
2075
- options = { appendOperations, updateOperations };
2076
- }
2077
- super(options);
2078
- }
2079
- }
2080
-
2081
- class LowLevelVM {
2082
- constructor(stack, heap, program, externs, pc = -1, ra = -1) {
2083
- this.stack = stack;
2084
- this.heap = heap;
2085
- this.program = program;
2086
- this.externs = externs;
2087
- this.pc = pc;
2088
- this.ra = ra;
2089
- this.currentOpSize = 0;
2090
- }
2091
- // Start a new frame and save $ra and $fp on the stack
2092
- pushFrame() {
2093
- this.stack.pushSmi(this.ra);
2094
- this.stack.pushSmi(this.stack.fp);
2095
- this.stack.fp = this.stack.sp - 1;
2096
- }
2097
- // Restore $ra, $sp and $fp
2098
- popFrame() {
2099
- this.stack.sp = this.stack.fp - 1;
2100
- this.ra = this.stack.getSmi(0);
2101
- this.stack.fp = this.stack.getSmi(1);
2102
- }
2103
- pushSmallFrame() {
2104
- this.stack.pushSmi(this.ra);
2105
- }
2106
- popSmallFrame() {
2107
- this.ra = this.stack.popSmi();
2108
- }
2109
- // Jump to an address in `program`
2110
- goto(offset) {
2111
- let addr = this.pc + offset - this.currentOpSize;
2112
- this.pc = addr;
2113
- }
2114
- // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS)
2115
- call(handle) {
2116
- this.ra = this.pc;
2117
- this.pc = this.heap.getaddr(handle);
2118
- }
2119
- // Put a specific `program` address in $ra
2120
- returnTo(offset) {
2121
- let addr = this.pc + offset - this.currentOpSize;
2122
- this.ra = addr;
2123
- }
2124
- // Return to the `program` address stored in $ra
2125
- return() {
2126
- this.pc = this.ra;
2127
- }
2128
- nextStatement() {
2129
- let { pc, program } = this;
2130
- if (pc === -1) {
2131
- return null;
2132
- }
2133
- // We have to save off the current operations size so that
2134
- // when we do a jump we can calculate the correct offset
2135
- // to where we are going. We can't simply ask for the size
2136
- // in a jump because we have have already incremented the
2137
- // program counter to the next instruction prior to executing.
2138
- let { size } = this.program.opcode(pc);
2139
- let operationSize = this.currentOpSize = size;
2140
- this.pc += operationSize;
2141
- return program.opcode(pc);
2142
- }
2143
- evaluateOuter(opcode, vm) {
2144
- {
2145
- this.evaluateInner(opcode, vm);
2146
- }
2147
- }
2148
- evaluateInner(opcode, vm) {
2149
- if (opcode.isMachine) {
2150
- this.evaluateMachine(opcode);
2151
- } else {
2152
- this.evaluateSyscall(opcode, vm);
2153
- }
2154
- }
2155
- evaluateMachine(opcode) {
2156
- switch (opcode.type) {
2157
- case 57 /* PushFrame */:
2158
- return this.pushFrame();
2159
- case 58 /* PopFrame */:
2160
- return this.popFrame();
2161
- case 59 /* PushSmallFrame */:
2162
- return this.pushSmallFrame();
2163
- case 60 /* PopSmallFrame */:
2164
- return this.popSmallFrame();
2165
- case 50 /* InvokeStatic */:
2166
- return this.call(opcode.op1);
2167
- case 49 /* InvokeVirtual */:
2168
- return this.call(this.stack.popSmi());
2169
- case 52 /* Jump */:
2170
- return this.goto(opcode.op1);
2171
- case 24 /* Return */:
2172
- return this.return();
2173
- case 25 /* ReturnTo */:
2174
- return this.returnTo(opcode.op1);
2175
- }
2176
- }
2177
- evaluateSyscall(opcode, vm) {
2178
- APPEND_OPCODES.evaluate(vm, opcode, opcode.type);
2179
- }
2180
- }
2181
-
2182
- class First {
2183
- constructor(node) {
2184
- this.node = node;
2185
- }
2186
- firstNode() {
2187
- return this.node;
2188
- }
2189
- }
2190
- class Last {
2191
- constructor(node) {
2192
- this.node = node;
2193
- }
2194
- lastNode() {
2195
- return this.node;
2196
- }
2197
- }
2198
- class NewElementBuilder {
2199
- constructor(env, parentNode, nextSibling) {
2200
- this.constructing = null;
2201
- this.operations = null;
2202
- this.cursorStack = new Stack();
2203
- this.blockStack = new Stack();
2204
- this.pushElement(parentNode, nextSibling);
2205
- this.env = env;
2206
- this.dom = env.getAppendOperations();
2207
- this.updateOperations = env.getDOM();
2208
- }
2209
- static forInitialRender(env, cursor) {
2210
- let builder = new this(env, cursor.element, cursor.nextSibling);
2211
- builder.pushSimpleBlock();
2212
- return builder;
2213
- }
2214
- static resume(env, tracker, nextSibling) {
2215
- let parentNode = tracker.parentElement();
2216
- let stack = new this(env, parentNode, nextSibling);
2217
- stack.pushSimpleBlock();
2218
- stack.pushBlockTracker(tracker);
2219
- return stack;
2220
- }
2221
- get element() {
2222
- return this.cursorStack.current.element;
2223
- }
2224
- get nextSibling() {
2225
- return this.cursorStack.current.nextSibling;
2226
- }
2227
- expectConstructing(method) {
2228
- return this.constructing;
2229
- }
2230
- block() {
2231
- return this.blockStack.current;
2232
- }
2233
- popElement() {
2234
- this.cursorStack.pop();
2235
- this.cursorStack.current;
2236
- }
2237
- pushSimpleBlock() {
2238
- return this.pushBlockTracker(new SimpleBlockTracker(this.element));
2239
- }
2240
- pushUpdatableBlock() {
2241
- return this.pushBlockTracker(new UpdatableBlockTracker(this.element));
2242
- }
2243
- pushBlockList(list) {
2244
- return this.pushBlockTracker(new BlockListTracker(this.element, list));
2245
- }
2246
- pushBlockTracker(tracker, isRemote = false) {
2247
- let current = this.blockStack.current;
2248
- if (current !== null) {
2249
- current.newDestroyable(tracker);
2250
- if (!isRemote) {
2251
- current.didAppendBounds(tracker);
2252
- }
2253
- }
2254
- this.__openBlock();
2255
- this.blockStack.push(tracker);
2256
- return tracker;
2257
- }
2258
- popBlock() {
2259
- this.block().finalize(this);
2260
- this.__closeBlock();
2261
- return this.blockStack.pop();
2262
- }
2263
- __openBlock() {}
2264
- __closeBlock() {}
2265
- // todo return seems unused
2266
- openElement(tag) {
2267
- let element = this.__openElement(tag);
2268
- this.constructing = element;
2269
- return element;
2270
- }
2271
- __openElement(tag) {
2272
- return this.dom.createElement(tag, this.element);
2273
- }
2274
- flushElement() {
2275
- let parent = this.element;
2276
- let element = this.constructing;
2277
- this.__flushElement(parent, element);
2278
- this.constructing = null;
2279
- this.operations = null;
2280
- this.pushElement(element, null);
2281
- this.didOpenElement(element);
2282
- }
2283
- __flushElement(parent, constructing) {
2284
- this.dom.insertBefore(parent, constructing, this.nextSibling);
2285
- }
2286
- closeElement() {
2287
- this.willCloseElement();
2288
- this.popElement();
2289
- }
2290
- pushRemoteElement(element, guid, nextSibling = null) {
2291
- this.__pushRemoteElement(element, guid, nextSibling);
2292
- }
2293
- __pushRemoteElement(element, _guid, nextSibling) {
2294
- this.pushElement(element, nextSibling);
2295
- let tracker = new RemoteBlockTracker(element);
2296
- this.pushBlockTracker(tracker, true);
2297
- }
2298
- popRemoteElement() {
2299
- this.popBlock();
2300
- this.popElement();
2301
- }
2302
- pushElement(element, nextSibling) {
2303
- this.cursorStack.push(new Cursor(element, nextSibling));
2304
- }
2305
- didAddDestroyable(d) {
2306
- this.block().newDestroyable(d);
2307
- }
2308
- didAppendBounds(bounds$$1) {
2309
- this.block().didAppendBounds(bounds$$1);
2310
- return bounds$$1;
2311
- }
2312
- didAppendNode(node) {
2313
- this.block().didAppendNode(node);
2314
- return node;
2315
- }
2316
- didOpenElement(element) {
2317
- this.block().openElement(element);
2318
- return element;
2319
- }
2320
- willCloseElement() {
2321
- this.block().closeElement();
2322
- }
2323
- appendText(string) {
2324
- return this.didAppendNode(this.__appendText(string));
2325
- }
2326
- __appendText(text) {
2327
- let { dom, element, nextSibling } = this;
2328
- let node = dom.createTextNode(text);
2329
- dom.insertBefore(element, node, nextSibling);
2330
- return node;
2331
- }
2332
- __appendNode(node) {
2333
- this.dom.insertBefore(this.element, node, this.nextSibling);
2334
- return node;
2335
- }
2336
- __appendFragment(fragment) {
2337
- let first = fragment.firstChild;
2338
- if (first) {
2339
- let ret = bounds(this.element, first, fragment.lastChild);
2340
- this.dom.insertBefore(this.element, fragment, this.nextSibling);
2341
- return ret;
2342
- } else {
2343
- return single(this.element, this.__appendComment(''));
2344
- }
2345
- }
2346
- __appendHTML(html) {
2347
- return this.dom.insertHTMLBefore(this.element, this.nextSibling, html);
2348
- }
2349
- appendDynamicHTML(value) {
2350
- let bounds$$1 = this.trustedContent(value);
2351
- this.didAppendBounds(bounds$$1);
2352
- }
2353
- appendDynamicText(value) {
2354
- let node = this.untrustedContent(value);
2355
- this.didAppendNode(node);
2356
- return node;
2357
- }
2358
- appendDynamicFragment(value) {
2359
- let bounds$$1 = this.__appendFragment(value);
2360
- this.didAppendBounds(bounds$$1);
2361
- }
2362
- appendDynamicNode(value) {
2363
- let node = this.__appendNode(value);
2364
- let bounds$$1 = single(this.element, node);
2365
- this.didAppendBounds(bounds$$1);
2366
- }
2367
- trustedContent(value) {
2368
- return this.__appendHTML(value);
2369
- }
2370
- untrustedContent(value) {
2371
- return this.__appendText(value);
2372
- }
2373
- appendComment(string) {
2374
- return this.didAppendNode(this.__appendComment(string));
2375
- }
2376
- __appendComment(string) {
2377
- let { dom, element, nextSibling } = this;
2378
- let node = dom.createComment(string);
2379
- dom.insertBefore(element, node, nextSibling);
2380
- return node;
2381
- }
2382
- __setAttribute(name, value, namespace) {
2383
- this.dom.setAttribute(this.constructing, name, value, namespace);
2384
- }
2385
- __setProperty(name, value) {
2386
- this.constructing[name] = value;
2387
- }
2388
- setStaticAttribute(name, value, namespace) {
2389
- this.__setAttribute(name, value, namespace);
2390
- }
2391
- setDynamicAttribute(name, value, trusting, namespace) {
2392
- let element = this.constructing;
2393
- let attribute = this.env.attributeFor(element, name, trusting, namespace);
2394
- attribute.set(this, value, this.env);
2395
- return attribute;
2396
- }
2397
- }
2398
- class SimpleBlockTracker {
2399
- constructor(parent) {
2400
- this.parent = parent;
2401
- this.first = null;
2402
- this.last = null;
2403
- this.destroyables = null;
2404
- this.nesting = 0;
2405
- }
2406
- destroy() {
2407
- let { destroyables } = this;
2408
- if (destroyables && destroyables.length) {
2409
- for (let i = 0; i < destroyables.length; i++) {
2410
- destroyables[i].destroy();
2411
- }
2412
- }
2413
- }
2414
- parentElement() {
2415
- return this.parent;
2416
- }
2417
- firstNode() {
2418
- return this.first && this.first.firstNode();
2419
- }
2420
- lastNode() {
2421
- return this.last && this.last.lastNode();
2422
- }
2423
- openElement(element) {
2424
- this.didAppendNode(element);
2425
- this.nesting++;
2426
- }
2427
- closeElement() {
2428
- this.nesting--;
2429
- }
2430
- didAppendNode(node) {
2431
- if (this.nesting !== 0) return;
2432
- if (!this.first) {
2433
- this.first = new First(node);
2434
- }
2435
- this.last = new Last(node);
2436
- }
2437
- didAppendBounds(bounds$$1) {
2438
- if (this.nesting !== 0) return;
2439
- if (!this.first) {
2440
- this.first = bounds$$1;
2441
- }
2442
- this.last = bounds$$1;
2443
- }
2444
- newDestroyable(d) {
2445
- this.destroyables = this.destroyables || [];
2446
- this.destroyables.push(d);
2447
- }
2448
- finalize(stack) {
2449
- if (this.first === null) {
2450
- stack.appendComment('');
2451
- }
2452
- }
2453
- }
2454
- class RemoteBlockTracker extends SimpleBlockTracker {
2455
- destroy() {
2456
- super.destroy();
2457
- clear(this);
2458
- }
2459
- }
2460
- class UpdatableBlockTracker extends SimpleBlockTracker {
2461
- reset(env) {
2462
- let { destroyables } = this;
2463
- if (destroyables && destroyables.length) {
2464
- for (let i = 0; i < destroyables.length; i++) {
2465
- env.didDestroy(destroyables[i]);
2466
- }
2467
- }
2468
- let nextSibling = clear(this);
2469
- this.first = null;
2470
- this.last = null;
2471
- this.destroyables = null;
2472
- this.nesting = 0;
2473
- return nextSibling;
2474
- }
2475
- }
2476
- class BlockListTracker {
2477
- constructor(parent, boundList) {
2478
- this.parent = parent;
2479
- this.boundList = boundList;
2480
- this.parent = parent;
2481
- this.boundList = boundList;
2482
- }
2483
- destroy() {
2484
- this.boundList.forEachNode(node => node.destroy());
2485
- }
2486
- parentElement() {
2487
- return this.parent;
2488
- }
2489
- firstNode() {
2490
- let head = this.boundList.head();
2491
- return head && head.firstNode();
2492
- }
2493
- lastNode() {
2494
- let tail = this.boundList.tail();
2495
- return tail && tail.lastNode();
2496
- }
2497
- openElement(_element) {
2498
- }
2499
- closeElement() {
2500
- }
2501
- didAppendNode(_node) {
2502
- }
2503
- didAppendBounds(_bounds) {}
2504
- newDestroyable(_d) {}
2505
- finalize(_stack) {}
2506
- }
2507
- function clientBuilder(env, cursor) {
2508
- return NewElementBuilder.forInitialRender(env, cursor);
2509
- }
2510
-
2511
- const HI = 0x80000000;
2512
- const MASK = 0x7fffffff;
2513
- class InnerStack {
2514
- constructor(inner = new Stack$1(), js = []) {
2515
- this.inner = inner;
2516
- this.js = js;
2517
- }
2518
- slice(start, end) {
2519
- let inner;
2520
- if (typeof start === 'number' && typeof end === 'number') {
2521
- inner = this.inner.slice(start, end);
2522
- } else if (typeof start === 'number' && end === undefined) {
2523
- inner = this.inner.sliceFrom(start);
2524
- } else {
2525
- inner = this.inner.clone();
2526
- }
2527
- return new InnerStack(inner, this.js.slice(start, end));
2528
- }
2529
- sliceInner(start, end) {
2530
- let out = [];
2531
- for (let i = start; i < end; i++) {
2532
- out.push(this.get(i));
2533
- }
2534
- return out;
2535
- }
2536
- copy(from, to) {
2537
- this.inner.copy(from, to);
2538
- }
2539
- write(pos, value) {
2540
- if (isImmediate(value)) {
2541
- this.inner.writeRaw(pos, encodeImmediate(value));
2542
- } else {
2543
- let idx = this.js.length;
2544
- this.js.push(value);
2545
- this.inner.writeRaw(pos, idx | HI);
2546
- }
2547
- }
2548
- writeSmi(pos, value) {
2549
- this.inner.writeSmi(pos, value);
2550
- }
2551
- writeImmediate(pos, value) {
2552
- this.inner.writeRaw(pos, value);
2553
- }
2554
- get(pos) {
2555
- let value = this.inner.getRaw(pos);
2556
- if (value & HI) {
2557
- return this.js[value & MASK];
2558
- } else {
2559
- return decodeImmediate(value);
2560
- }
2561
- }
2562
- getSmi(pos) {
2563
- return this.inner.getSmi(pos);
2564
- }
2565
- reset() {
2566
- this.inner.reset();
2567
- this.js.length = 0;
2568
- }
2569
- get length() {
2570
- return this.inner.len();
2571
- }
2572
- }
2573
- class EvaluationStack {
2574
- constructor(stack, fp, sp) {
2575
- this.stack = stack;
2576
- this.fp = fp;
2577
- this.sp = sp;
2578
- }
2579
- static empty() {
2580
- return new this(new InnerStack(), 0, -1);
2581
- }
2582
- static restore(snapshot) {
2583
- let stack = new InnerStack();
2584
- for (let i = 0; i < snapshot.length; i++) {
2585
- stack.write(i, snapshot[i]);
2586
- }
2587
- return new this(stack, 0, snapshot.length - 1);
2588
- }
2589
- push(value) {
2590
- this.stack.write(++this.sp, value);
2591
- }
2592
- pushSmi(value) {
2593
- this.stack.writeSmi(++this.sp, value);
2594
- }
2595
- pushImmediate(value) {
2596
- this.stack.writeImmediate(++this.sp, encodeImmediate(value));
2597
- }
2598
- pushEncodedImmediate(value) {
2599
- this.stack.writeImmediate(++this.sp, value);
2600
- }
2601
- pushNull() {
2602
- this.stack.writeImmediate(++this.sp, 19 /* Null */);
2603
- }
2604
- dup(position = this.sp) {
2605
- this.stack.copy(position, ++this.sp);
2606
- }
2607
- copy(from, to) {
2608
- this.stack.copy(from, to);
2609
- }
2610
- pop(n = 1) {
2611
- let top = this.stack.get(this.sp);
2612
- this.sp -= n;
2613
- return top;
2614
- }
2615
- popSmi() {
2616
- return this.stack.getSmi(this.sp--);
2617
- }
2618
- peek(offset = 0) {
2619
- return this.stack.get(this.sp - offset);
2620
- }
2621
- peekSmi(offset = 0) {
2622
- return this.stack.getSmi(this.sp - offset);
2623
- }
2624
- get(offset, base = this.fp) {
2625
- return this.stack.get(base + offset);
2626
- }
2627
- getSmi(offset, base = this.fp) {
2628
- return this.stack.getSmi(base + offset);
2629
- }
2630
- set(value, offset, base = this.fp) {
2631
- this.stack.write(base + offset, value);
2632
- }
2633
- slice(start, end) {
2634
- return this.stack.slice(start, end);
2635
- }
2636
- sliceArray(start, end) {
2637
- return this.stack.sliceInner(start, end);
2638
- }
2639
- capture(items) {
2640
- let end = this.sp + 1;
2641
- let start = end - items;
2642
- return this.stack.sliceInner(start, end);
2643
- }
2644
- reset() {
2645
- this.stack.reset();
2646
- }
2647
- toArray() {
2648
- return this.stack.sliceInner(this.fp, this.sp + 1);
2649
- }
2650
- }
2651
- function isImmediate(value) {
2652
- let type = typeof value;
2653
- if (value === null || value === undefined) return true;
2654
- switch (type) {
2655
- case 'boolean':
2656
- case 'undefined':
2657
- return true;
2658
- case 'number':
2659
- // not an integer
2660
- if (value % 1 !== 0) return false;
2661
- let abs = Math.abs(value);
2662
- // too big
2663
- if (abs > HI) return false;
2664
- return true;
2665
- default:
2666
- return false;
2667
- }
2668
- }
2669
- function encodeSmi(primitive) {
2670
- if (primitive < 0) {
2671
- return Math.abs(primitive) << 3 | 4 /* NEGATIVE */;
2672
- } else {
2673
- return primitive << 3 | 0 /* NUMBER */;
2674
- }
2675
- }
2676
- function encodeImmediate(primitive) {
2677
- switch (typeof primitive) {
2678
- case 'number':
2679
- return encodeSmi(primitive);
2680
- case 'boolean':
2681
- return primitive ? 11 /* True */ : 3 /* False */;
2682
- case 'object':
2683
- // assume null
2684
- return 19 /* Null */;
2685
- case 'undefined':
2686
- return 27 /* Undef */;
2687
- default:
2688
- throw unreachable();
2689
- }
2690
- }
2691
- function decodeSmi(smi) {
2692
- switch (smi & 0b111) {
2693
- case 0 /* NUMBER */:
2694
- return smi >> 3;
2695
- case 4 /* NEGATIVE */:
2696
- return -(smi >> 3);
2697
- default:
2698
- throw unreachable();
2699
- }
2700
- }
2701
- function decodeImmediate(immediate) {
2702
- switch (immediate) {
2703
- case 3 /* False */:
2704
- return false;
2705
- case 11 /* True */:
2706
- return true;
2707
- case 19 /* Null */:
2708
- return null;
2709
- case 27 /* Undef */:
2710
- return undefined;
2711
- default:
2712
- return decodeSmi(immediate);
2713
- }
2714
- }
2715
-
2716
- class UpdatingVM {
2717
- constructor(env, program, { alwaysRevalidate = false }) {
2718
- this.frameStack = new Stack();
2719
- this.env = env;
2720
- this.constants = program.constants;
2721
- this.dom = env.getDOM();
2722
- this.alwaysRevalidate = alwaysRevalidate;
2723
- }
2724
- execute(opcodes, handler) {
2725
- let { frameStack } = this;
2726
- this.try(opcodes, handler);
2727
- while (true) {
2728
- if (frameStack.isEmpty()) break;
2729
- let opcode = this.frame.nextStatement();
2730
- if (opcode === null) {
2731
- this.frameStack.pop();
2732
- continue;
2733
- }
2734
- opcode.evaluate(this);
2735
- }
2736
- }
2737
- get frame() {
2738
- return this.frameStack.current;
2739
- }
2740
- goto(op) {
2741
- this.frame.goto(op);
2742
- }
2743
- try(ops, handler) {
2744
- this.frameStack.push(new UpdatingVMFrame(ops, handler));
2745
- }
2746
- throw() {
2747
- this.frame.handleException();
2748
- this.frameStack.pop();
2749
- }
2750
- }
2751
- class BlockOpcode extends UpdatingOpcode {
2752
- constructor(start, state, runtime, bounds$$1, children) {
2753
- super();
2754
- this.start = start;
2755
- this.state = state;
2756
- this.runtime = runtime;
2757
- this.type = 'block';
2758
- this.next = null;
2759
- this.prev = null;
2760
- this.children = children;
2761
- this.bounds = bounds$$1;
2762
- }
2763
- parentElement() {
2764
- return this.bounds.parentElement();
2765
- }
2766
- firstNode() {
2767
- return this.bounds.firstNode();
2768
- }
2769
- lastNode() {
2770
- return this.bounds.lastNode();
2771
- }
2772
- evaluate(vm) {
2773
- vm.try(this.children, null);
2774
- }
2775
- destroy() {
2776
- this.bounds.destroy();
2777
- }
2778
- didDestroy() {
2779
- this.runtime.env.didDestroy(this.bounds);
2780
- }
2781
- }
2782
- class TryOpcode extends BlockOpcode {
2783
- constructor(start, state, runtime, bounds$$1, children) {
2784
- super(start, state, runtime, bounds$$1, children);
2785
- this.type = 'try';
2786
- this.tag = this._tag = UpdatableTag.create(CONSTANT_TAG);
2787
- }
2788
- didInitializeChildren() {
2789
- this._tag.inner.update(combineSlice(this.children));
2790
- }
2791
- evaluate(vm) {
2792
- vm.try(this.children, this);
2793
- }
2794
- handleException() {
2795
- let { state, bounds: bounds$$1, children, start, prev, next, runtime } = this;
2796
- children.clear();
2797
- let elementStack = NewElementBuilder.resume(runtime.env, bounds$$1, bounds$$1.reset(runtime.env));
2798
- let vm = VM.resume(state, runtime, elementStack);
2799
- let updating = new LinkedList();
2800
- vm.execute(start, vm => {
2801
- vm.stack = EvaluationStack.restore(state.stack);
2802
- vm.updatingOpcodeStack.push(updating);
2803
- vm.updateWith(this);
2804
- vm.updatingOpcodeStack.push(children);
2805
- });
2806
- this.prev = prev;
2807
- this.next = next;
2808
- }
2809
- }
2810
- class ListRevalidationDelegate {
2811
- constructor(opcode, marker) {
2812
- this.opcode = opcode;
2813
- this.marker = marker;
2814
- this.didInsert = false;
2815
- this.didDelete = false;
2816
- this.map = opcode.map;
2817
- this.updating = opcode['children'];
2818
- }
2819
- insert(key, item, memo, before) {
2820
- let { map, opcode, updating } = this;
2821
- let nextSibling = null;
2822
- let reference = null;
2823
- if (before) {
2824
- reference = map[before];
2825
- nextSibling = reference['bounds'].firstNode();
2826
- } else {
2827
- nextSibling = this.marker;
2828
- }
2829
- let vm = opcode.vmForInsertion(nextSibling);
2830
- let tryOpcode = null;
2831
- let { start } = opcode;
2832
- vm.execute(start, vm => {
2833
- map[key] = tryOpcode = vm.iterate(memo, item);
2834
- vm.updatingOpcodeStack.push(new LinkedList());
2835
- vm.updateWith(tryOpcode);
2836
- vm.updatingOpcodeStack.push(tryOpcode.children);
2837
- });
2838
- updating.insertBefore(tryOpcode, reference);
2839
- this.didInsert = true;
2840
- }
2841
- retain(_key, _item, _memo) {}
2842
- move(key, _item, _memo, before) {
2843
- let { map, updating } = this;
2844
- let entry = map[key];
2845
- let reference = map[before] || null;
2846
- if (before) {
2847
- move(entry, reference.firstNode());
2848
- } else {
2849
- move(entry, this.marker);
2850
- }
2851
- updating.remove(entry);
2852
- updating.insertBefore(entry, reference);
2853
- }
2854
- delete(key) {
2855
- let { map } = this;
2856
- let opcode = map[key];
2857
- opcode.didDestroy();
2858
- clear(opcode);
2859
- this.updating.remove(opcode);
2860
- delete map[key];
2861
- this.didDelete = true;
2862
- }
2863
- done() {
2864
- this.opcode.didInitializeChildren(this.didInsert || this.didDelete);
2865
- }
2866
- }
2867
- class ListBlockOpcode extends BlockOpcode {
2868
- constructor(start, state, runtime, bounds$$1, children, artifacts) {
2869
- super(start, state, runtime, bounds$$1, children);
2870
- this.type = 'list-block';
2871
- this.map = dict();
2872
- this.lastIterated = INITIAL;
2873
- this.artifacts = artifacts;
2874
- let _tag = this._tag = UpdatableTag.create(CONSTANT_TAG);
2875
- this.tag = combine([artifacts.tag, _tag]);
2876
- }
2877
- didInitializeChildren(listDidChange = true) {
2878
- this.lastIterated = this.artifacts.tag.value();
2879
- if (listDidChange) {
2880
- this._tag.inner.update(combineSlice(this.children));
2881
- }
2882
- }
2883
- evaluate(vm) {
2884
- let { artifacts, lastIterated } = this;
2885
- if (!artifacts.tag.validate(lastIterated)) {
2886
- let { bounds: bounds$$1 } = this;
2887
- let { dom } = vm;
2888
- let marker = dom.createComment('');
2889
- dom.insertAfter(bounds$$1.parentElement(), marker, bounds$$1.lastNode());
2890
- let target = new ListRevalidationDelegate(this, marker);
2891
- let synchronizer = new IteratorSynchronizer({ target, artifacts });
2892
- synchronizer.sync();
2893
- this.parentElement().removeChild(marker);
2894
- }
2895
- // Run now-updated updating opcodes
2896
- super.evaluate(vm);
2897
- }
2898
- vmForInsertion(nextSibling) {
2899
- let { bounds: bounds$$1, state, runtime } = this;
2900
- let elementStack = NewElementBuilder.forInitialRender(runtime.env, {
2901
- element: bounds$$1.parentElement(),
2902
- nextSibling
2903
- });
2904
- return VM.resume(state, runtime, elementStack);
2905
- }
2906
- }
2907
- class UpdatingVMFrame {
2908
- constructor(ops, exceptionHandler) {
2909
- this.ops = ops;
2910
- this.exceptionHandler = exceptionHandler;
2911
- this.current = ops.head();
2912
- }
2913
- goto(op) {
2914
- this.current = op;
2915
- }
2916
- nextStatement() {
2917
- let { current, ops } = this;
2918
- if (current) this.current = ops.nextNode(current);
2919
- return current;
2920
- }
2921
- handleException() {
2922
- if (this.exceptionHandler) {
2923
- this.exceptionHandler.handleException();
2924
- }
2925
- }
2926
- }
2927
-
2928
- class RenderResult {
2929
- constructor(env, program, updating, bounds$$1) {
2930
- this.env = env;
2931
- this.program = program;
2932
- this.updating = updating;
2933
- this.bounds = bounds$$1;
2934
- }
2935
- rerender({ alwaysRevalidate = false } = { alwaysRevalidate: false }) {
2936
- let { env, program, updating } = this;
2937
- let vm = new UpdatingVM(env, program, { alwaysRevalidate });
2938
- vm.execute(updating, this);
2939
- }
2940
- parentElement() {
2941
- return this.bounds.parentElement();
2942
- }
2943
- firstNode() {
2944
- return this.bounds.firstNode();
2945
- }
2946
- lastNode() {
2947
- return this.bounds.lastNode();
2948
- }
2949
- handleException() {
2950
- throw 'this should never happen';
2951
- }
2952
- destroy() {
2953
- this.bounds.destroy();
2954
- clear(this.bounds);
2955
- }
2956
- }
2957
-
2958
- class Arguments {
2959
- constructor() {
2960
- this.stack = null;
2961
- this.positional = new PositionalArguments();
2962
- this.named = new NamedArguments();
2963
- this.blocks = new BlockArguments();
2964
- }
2965
- empty(stack) {
2966
- let base = stack.sp + 1;
2967
- this.named.empty(stack, base);
2968
- this.positional.empty(stack, base);
2969
- this.blocks.empty(stack, base);
2970
- return this;
2971
- }
2972
- setup(stack, names, blockNames, positionalCount, synthetic) {
2973
- this.stack = stack;
2974
- /*
2975
- | ... | blocks | positional | named |
2976
- | ... | b0 b1 | p0 p1 p2 p3 | n0 n1 |
2977
- index | ... | 4/5/6 7/8/9 | 10 11 12 13 | 14 15 |
2978
- ^ ^ ^ ^
2979
- bbase pbase nbase sp
2980
- */
2981
- let named = this.named;
2982
- let namedCount = names.length;
2983
- let namedBase = stack.sp - namedCount + 1;
2984
- named.setup(stack, namedBase, namedCount, names, synthetic);
2985
- let positional = this.positional;
2986
- let positionalBase = namedBase - positionalCount;
2987
- positional.setup(stack, positionalBase, positionalCount);
2988
- let blocks = this.blocks;
2989
- let blocksCount = blockNames.length;
2990
- let blocksBase = positionalBase - blocksCount * 3;
2991
- blocks.setup(stack, blocksBase, blocksCount, blockNames);
2992
- }
2993
- get tag() {
2994
- return combineTagged([this.positional, this.named]);
2995
- }
2996
- get base() {
2997
- return this.blocks.base;
2998
- }
2999
- get length() {
3000
- return this.positional.length + this.named.length + this.blocks.length * 3;
3001
- }
3002
- at(pos) {
3003
- return this.positional.at(pos);
3004
- }
3005
- realloc(offset) {
3006
- let { stack } = this;
3007
- if (offset > 0 && stack !== null) {
3008
- let { positional, named } = this;
3009
- let newBase = positional.base + offset;
3010
- let length = positional.length + named.length;
3011
- for (let i = length - 1; i >= 0; i--) {
3012
- stack.copy(i + positional.base, i + newBase);
3013
- }
3014
- positional.base += offset;
3015
- named.base += offset;
3016
- stack.sp += offset;
3017
- }
3018
- }
3019
- capture() {
3020
- let positional = this.positional.length === 0 ? EMPTY_POSITIONAL : this.positional.capture();
3021
- let named = this.named.length === 0 ? EMPTY_NAMED : this.named.capture();
3022
- return {
3023
- tag: this.tag,
3024
- length: this.length,
3025
- positional,
3026
- named
3027
- };
3028
- }
3029
- clear() {
3030
- let { stack, length } = this;
3031
- if (length > 0 && stack !== null) stack.pop(length);
3032
- }
3033
- }
3034
- class PositionalArguments {
3035
- constructor() {
3036
- this.base = 0;
3037
- this.length = 0;
3038
- this.stack = null;
3039
- this._tag = null;
3040
- this._references = null;
3041
- }
3042
- empty(stack, base) {
3043
- this.stack = stack;
3044
- this.base = base;
3045
- this.length = 0;
3046
- this._tag = CONSTANT_TAG;
3047
- this._references = EMPTY_ARRAY;
3048
- }
3049
- setup(stack, base, length) {
3050
- this.stack = stack;
3051
- this.base = base;
3052
- this.length = length;
3053
- if (length === 0) {
3054
- this._tag = CONSTANT_TAG;
3055
- this._references = EMPTY_ARRAY;
3056
- } else {
3057
- this._tag = null;
3058
- this._references = null;
3059
- }
3060
- }
3061
- get tag() {
3062
- let tag = this._tag;
3063
- if (!tag) {
3064
- tag = this._tag = combineTagged(this.references);
3065
- }
3066
- return tag;
3067
- }
3068
- at(position) {
3069
- let { base, length, stack } = this;
3070
- if (position < 0 || position >= length) {
3071
- return UNDEFINED_REFERENCE;
3072
- }
3073
- return stack.get(position, base);
3074
- }
3075
- capture() {
3076
- return new CapturedPositionalArguments(this.tag, this.references);
3077
- }
3078
- prepend(other) {
3079
- let additions = other.length;
3080
- if (additions > 0) {
3081
- let { base, length, stack } = this;
3082
- this.base = base = base - additions;
3083
- this.length = length + additions;
3084
- for (let i = 0; i < additions; i++) {
3085
- stack.set(other.at(i), i, base);
3086
- }
3087
- this._tag = null;
3088
- this._references = null;
3089
- }
3090
- }
3091
- get references() {
3092
- let references = this._references;
3093
- if (!references) {
3094
- let { stack, base, length } = this;
3095
- references = this._references = stack.sliceArray(base, base + length);
3096
- }
3097
- return references;
3098
- }
3099
- }
3100
- class CapturedPositionalArguments {
3101
- constructor(tag, references, length = references.length) {
3102
- this.tag = tag;
3103
- this.references = references;
3104
- this.length = length;
3105
- }
3106
- static empty() {
3107
- return new CapturedPositionalArguments(CONSTANT_TAG, EMPTY_ARRAY, 0);
3108
- }
3109
- at(position) {
3110
- return this.references[position];
3111
- }
3112
- value() {
3113
- return this.references.map(this.valueOf);
3114
- }
3115
- get(name) {
3116
- let { references, length } = this;
3117
- if (name === 'length') {
3118
- return PrimitiveReference.create(length);
3119
- } else {
3120
- let idx = parseInt(name, 10);
3121
- if (idx < 0 || idx >= length) {
3122
- return UNDEFINED_REFERENCE;
3123
- } else {
3124
- return references[idx];
3125
- }
3126
- }
3127
- }
3128
- valueOf(reference) {
3129
- return reference.value();
3130
- }
3131
- }
3132
- class NamedArguments {
3133
- constructor() {
3134
- this.base = 0;
3135
- this.length = 0;
3136
- this._references = null;
3137
- this._names = EMPTY_ARRAY;
3138
- this._atNames = EMPTY_ARRAY;
3139
- }
3140
- empty(stack, base) {
3141
- this.stack = stack;
3142
- this.base = base;
3143
- this.length = 0;
3144
- this._references = EMPTY_ARRAY;
3145
- this._names = EMPTY_ARRAY;
3146
- this._atNames = EMPTY_ARRAY;
3147
- }
3148
- setup(stack, base, length, names, synthetic) {
3149
- this.stack = stack;
3150
- this.base = base;
3151
- this.length = length;
3152
- if (length === 0) {
3153
- this._references = EMPTY_ARRAY;
3154
- this._names = EMPTY_ARRAY;
3155
- this._atNames = EMPTY_ARRAY;
3156
- } else {
3157
- this._references = null;
3158
- if (synthetic) {
3159
- this._names = names;
3160
- this._atNames = null;
3161
- } else {
3162
- this._names = null;
3163
- this._atNames = names;
3164
- }
3165
- }
3166
- }
3167
- get tag() {
3168
- return combineTagged(this.references);
3169
- }
3170
- get names() {
3171
- let names = this._names;
3172
- if (!names) {
3173
- names = this._names = this._atNames.map(this.toSyntheticName);
3174
- }
3175
- return names;
3176
- }
3177
- get atNames() {
3178
- let atNames = this._atNames;
3179
- if (!atNames) {
3180
- atNames = this._atNames = this._names.map(this.toAtName);
3181
- }
3182
- return atNames;
3183
- }
3184
- has(name) {
3185
- return this.names.indexOf(name) !== -1;
3186
- }
3187
- get(name, synthetic = true) {
3188
- let { base, stack } = this;
3189
- let names = synthetic ? this.names : this.atNames;
3190
- let idx = names.indexOf(name);
3191
- if (idx === -1) {
3192
- return UNDEFINED_REFERENCE;
3193
- }
3194
- return stack.get(idx, base);
3195
- }
3196
- capture() {
3197
- return new CapturedNamedArguments(this.tag, this.names, this.references);
3198
- }
3199
- merge(other) {
3200
- let { length: extras } = other;
3201
- if (extras > 0) {
3202
- let { names, length, stack } = this;
3203
- let { names: extraNames } = other;
3204
- if (Object.isFrozen(names) && names.length === 0) {
3205
- names = [];
3206
- }
3207
- for (let i = 0; i < extras; i++) {
3208
- let name = extraNames[i];
3209
- let idx = names.indexOf(name);
3210
- if (idx === -1) {
3211
- length = names.push(name);
3212
- stack.push(other.references[i]);
3213
- }
3214
- }
3215
- this.length = length;
3216
- this._references = null;
3217
- this._names = names;
3218
- this._atNames = null;
3219
- }
3220
- }
3221
- get references() {
3222
- let references = this._references;
3223
- if (!references) {
3224
- let { base, length, stack } = this;
3225
- references = this._references = stack.sliceArray(base, base + length);
3226
- }
3227
- return references;
3228
- }
3229
- toSyntheticName(name) {
3230
- return name.slice(1);
3231
- }
3232
- toAtName(name) {
3233
- return `@${name}`;
3234
- }
3235
- }
3236
- class CapturedNamedArguments {
3237
- constructor(tag, names, references) {
3238
- this.tag = tag;
3239
- this.names = names;
3240
- this.references = references;
3241
- this.length = names.length;
3242
- this._map = null;
3243
- }
3244
- get map() {
3245
- let map = this._map;
3246
- if (!map) {
3247
- let { names, references } = this;
3248
- map = this._map = dict();
3249
- for (let i = 0; i < names.length; i++) {
3250
- let name = names[i];
3251
- map[name] = references[i];
3252
- }
3253
- }
3254
- return map;
3255
- }
3256
- has(name) {
3257
- return this.names.indexOf(name) !== -1;
3258
- }
3259
- get(name) {
3260
- let { names, references } = this;
3261
- let idx = names.indexOf(name);
3262
- if (idx === -1) {
3263
- return UNDEFINED_REFERENCE;
3264
- } else {
3265
- return references[idx];
3266
- }
3267
- }
3268
- value() {
3269
- let { names, references } = this;
3270
- let out = dict();
3271
- for (let i = 0; i < names.length; i++) {
3272
- let name = names[i];
3273
- out[name] = references[i].value();
3274
- }
3275
- return out;
3276
- }
3277
- }
3278
- class BlockArguments {
3279
- constructor() {
3280
- this.internalValues = null;
3281
- this.internalTag = null;
3282
- this.names = EMPTY_ARRAY;
3283
- this.length = 0;
3284
- this.base = 0;
3285
- }
3286
- empty(stack, base) {
3287
- this.stack = stack;
3288
- this.names = EMPTY_ARRAY;
3289
- this.base = base;
3290
- this.length = 0;
3291
- this.internalTag = CONSTANT_TAG;
3292
- this.internalValues = EMPTY_ARRAY;
3293
- }
3294
- setup(stack, base, length, names) {
3295
- this.stack = stack;
3296
- this.names = names;
3297
- this.base = base;
3298
- this.length = length;
3299
- if (length === 0) {
3300
- this.internalTag = CONSTANT_TAG;
3301
- this.internalValues = EMPTY_ARRAY;
3302
- } else {
3303
- this.internalTag = null;
3304
- this.internalValues = null;
3305
- }
3306
- }
3307
- get values() {
3308
- let values = this.internalValues;
3309
- if (!values) {
3310
- let { base, length, stack } = this;
3311
- values = this.internalValues = stack.sliceArray(base, base + length * 3);
3312
- }
3313
- return values;
3314
- }
3315
- has(name) {
3316
- return this.names.indexOf(name) !== -1;
3317
- }
3318
- get(name) {
3319
- let { base, stack, names } = this;
3320
- let idx = names.indexOf(name);
3321
- if (names.indexOf(name) === -1) {
3322
- return null;
3323
- }
3324
- let table = stack.get(idx * 3, base);
3325
- let scope = stack.get(idx * 3 + 1, base); // FIXME(mmun): shouldn't need to cast this
3326
- let handle = stack.get(idx * 3 + 2, base);
3327
- return handle === null ? null : [handle, scope, table];
3328
- }
3329
- capture() {
3330
- return new CapturedBlockArguments(this.names, this.values);
3331
- }
3332
- }
3333
- class CapturedBlockArguments {
3334
- constructor(names, values) {
3335
- this.names = names;
3336
- this.values = values;
3337
- this.length = names.length;
3338
- }
3339
- has(name) {
3340
- return this.names.indexOf(name) !== -1;
3341
- }
3342
- get(name) {
3343
- let idx = this.names.indexOf(name);
3344
- if (idx === -1) return null;
3345
- return [this.values[idx * 3 + 2], this.values[idx * 3 + 1], this.values[idx * 3]];
3346
- }
3347
- }
3348
- const EMPTY_NAMED = new CapturedNamedArguments(CONSTANT_TAG, EMPTY_ARRAY, EMPTY_ARRAY);
3349
- const EMPTY_POSITIONAL = new CapturedPositionalArguments(CONSTANT_TAG, EMPTY_ARRAY);
3350
- const EMPTY_ARGS = {
3351
- tag: CONSTANT_TAG,
3352
- length: 0,
3353
- positional: EMPTY_POSITIONAL,
3354
- named: EMPTY_NAMED
3355
- };
3356
-
3357
- class VM {
3358
- constructor(runtime, scope, dynamicScope, elementStack) {
3359
- this.runtime = runtime;
3360
- this.elementStack = elementStack;
3361
- this.dynamicScopeStack = new Stack();
3362
- this.scopeStack = new Stack();
3363
- this.updatingOpcodeStack = new Stack();
3364
- this.cacheGroups = new Stack();
3365
- this.listBlockStack = new Stack();
3366
- this.s0 = null;
3367
- this.s1 = null;
3368
- this.t0 = null;
3369
- this.t1 = null;
3370
- this.v0 = null;
3371
- this.heap = this.program.heap;
3372
- this.constants = this.program.constants;
3373
- this.elementStack = elementStack;
3374
- this.scopeStack.push(scope);
3375
- this.dynamicScopeStack.push(dynamicScope);
3376
- this.args = new Arguments();
3377
- this.inner = new LowLevelVM(EvaluationStack.empty(), this.heap, runtime.program, {
3378
- debugBefore: opcode => {
3379
- return APPEND_OPCODES.debugBefore(this, opcode, opcode.type);
3380
- },
3381
- debugAfter: (opcode, state) => {
3382
- APPEND_OPCODES.debugAfter(this, opcode, opcode.type, state);
3383
- }
3384
- });
3385
- }
3386
- get stack() {
3387
- return this.inner.stack;
3388
- }
3389
- set stack(value) {
3390
- this.inner.stack = value;
3391
- }
3392
- /* Registers */
3393
- set currentOpSize(value) {
3394
- this.inner.currentOpSize = value;
3395
- }
3396
- get currentOpSize() {
3397
- return this.inner.currentOpSize;
3398
- }
3399
- get pc() {
3400
- return this.inner.pc;
3401
- }
3402
- set pc(value) {
3403
-
3404
- this.inner.pc = value;
3405
- }
3406
- get ra() {
3407
- return this.inner.ra;
3408
- }
3409
- set ra(value) {
3410
- this.inner.ra = value;
3411
- }
3412
- get fp() {
3413
- return this.stack.fp;
3414
- }
3415
- set fp(fp) {
3416
- this.stack.fp = fp;
3417
- }
3418
- get sp() {
3419
- return this.stack.sp;
3420
- }
3421
- set sp(sp) {
3422
- this.stack.sp = sp;
3423
- }
3424
- // Fetch a value from a register onto the stack
3425
- fetch(register) {
3426
- this.stack.push(this[Register[register]]);
3427
- }
3428
- // Load a value from the stack into a register
3429
- load(register) {
3430
- this[Register[register]] = this.stack.pop();
3431
- }
3432
- // Fetch a value from a register
3433
- fetchValue(register) {
3434
- return this[Register[register]];
3435
- }
3436
- // Load a value into a register
3437
- loadValue(register, value) {
3438
- this[Register[register]] = value;
3439
- }
3440
- /**
3441
- * Migrated to Inner
3442
- */
3443
- // Start a new frame and save $ra and $fp on the stack
3444
- pushFrame() {
3445
- this.inner.pushFrame();
3446
- }
3447
- // Restore $ra, $sp and $fp
3448
- popFrame() {
3449
- this.inner.popFrame();
3450
- }
3451
- // Jump to an address in `program`
3452
- goto(offset) {
3453
- this.inner.goto(offset);
3454
- }
3455
- // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS)
3456
- call(handle) {
3457
- this.inner.call(handle);
3458
- }
3459
- // Put a specific `program` address in $ra
3460
- returnTo(offset) {
3461
- this.inner.returnTo(offset);
3462
- }
3463
- // Return to the `program` address stored in $ra
3464
- return() {
3465
- this.inner.return();
3466
- }
3467
- /**
3468
- * End of migrated.
3469
- */
3470
- static initial(program, env, self, dynamicScope, elementStack, handle) {
3471
- let scopeSize = program.heap.scopesizeof(handle);
3472
- let scope = Scope.root(self, scopeSize);
3473
- let vm = new VM({ program, env }, scope, dynamicScope, elementStack);
3474
- vm.pc = vm.heap.getaddr(handle);
3475
- vm.updatingOpcodeStack.push(new LinkedList());
3476
- return vm;
3477
- }
3478
- static empty(program, env, elementStack) {
3479
- let dynamicScope = {
3480
- get() {
3481
- return UNDEFINED_REFERENCE;
3482
- },
3483
- set() {
3484
- return UNDEFINED_REFERENCE;
3485
- },
3486
- child() {
3487
- return dynamicScope;
3488
- }
3489
- };
3490
- let vm = new VM({ program, env }, Scope.root(UNDEFINED_REFERENCE, 0), dynamicScope, elementStack);
3491
- vm.updatingOpcodeStack.push(new LinkedList());
3492
- return vm;
3493
- }
3494
- static resume({ scope, dynamicScope }, runtime, stack) {
3495
- return new VM(runtime, scope, dynamicScope, stack);
3496
- }
3497
- get program() {
3498
- return this.runtime.program;
3499
- }
3500
- get env() {
3501
- return this.runtime.env;
3502
- }
3503
- capture(args) {
3504
- return {
3505
- dynamicScope: this.dynamicScope(),
3506
- scope: this.scope(),
3507
- stack: this.stack.capture(args)
3508
- };
3509
- }
3510
- beginCacheGroup() {
3511
- this.cacheGroups.push(this.updating().tail());
3512
- }
3513
- commitCacheGroup() {
3514
- // JumpIfNotModified(END)
3515
- // (head)
3516
- // (....)
3517
- // (tail)
3518
- // DidModify
3519
- // END: Noop
3520
- let END = new LabelOpcode('END');
3521
- let opcodes = this.updating();
3522
- let marker = this.cacheGroups.pop();
3523
- let head = marker ? opcodes.nextNode(marker) : opcodes.head();
3524
- let tail = opcodes.tail();
3525
- let tag = combineSlice(new ListSlice(head, tail));
3526
- let guard = new JumpIfNotModifiedOpcode(tag, END);
3527
- opcodes.insertBefore(guard, head);
3528
- opcodes.append(new DidModifyOpcode(guard));
3529
- opcodes.append(END);
3530
- }
3531
- enter(args) {
3532
- let updating = new LinkedList();
3533
- let state = this.capture(args);
3534
- let tracker = this.elements().pushUpdatableBlock();
3535
- let tryOpcode = new TryOpcode(this.heap.gethandle(this.pc), state, this.runtime, tracker, updating);
3536
- this.didEnter(tryOpcode);
3537
- }
3538
- iterate(memo, value) {
3539
- let stack = this.stack;
3540
- stack.push(value);
3541
- stack.push(memo);
3542
- let state = this.capture(2);
3543
- let tracker = this.elements().pushUpdatableBlock();
3544
- // let ip = this.ip;
3545
- // this.ip = end + 4;
3546
- // this.frames.push(ip);
3547
- return new TryOpcode(this.heap.gethandle(this.pc), state, this.runtime, tracker, new LinkedList());
3548
- }
3549
- enterItem(key, opcode) {
3550
- this.listBlock().map[key] = opcode;
3551
- this.didEnter(opcode);
3552
- }
3553
- enterList(relativeStart) {
3554
- let updating = new LinkedList();
3555
- let state = this.capture(0);
3556
- let tracker = this.elements().pushBlockList(updating);
3557
- let artifacts = this.stack.peek().artifacts;
3558
- let addr = this.pc + relativeStart - this.currentOpSize;
3559
- let start = this.heap.gethandle(addr);
3560
- let opcode = new ListBlockOpcode(start, state, this.runtime, tracker, updating, artifacts);
3561
- this.listBlockStack.push(opcode);
3562
- this.didEnter(opcode);
3563
- }
3564
- didEnter(opcode) {
3565
- this.updateWith(opcode);
3566
- this.updatingOpcodeStack.push(opcode.children);
3567
- }
3568
- exit() {
3569
- this.elements().popBlock();
3570
- this.updatingOpcodeStack.pop();
3571
- let parent = this.updating().tail();
3572
- parent.didInitializeChildren();
3573
- }
3574
- exitList() {
3575
- this.exit();
3576
- this.listBlockStack.pop();
3577
- }
3578
- updateWith(opcode) {
3579
- this.updating().append(opcode);
3580
- }
3581
- listBlock() {
3582
- return this.listBlockStack.current;
3583
- }
3584
- updating() {
3585
- return this.updatingOpcodeStack.current;
3586
- }
3587
- elements() {
3588
- return this.elementStack;
3589
- }
3590
- scope() {
3591
- return this.scopeStack.current;
3592
- }
3593
- dynamicScope() {
3594
- return this.dynamicScopeStack.current;
3595
- }
3596
- pushChildScope() {
3597
- this.scopeStack.push(this.scope().child());
3598
- }
3599
- pushDynamicScope() {
3600
- let child = this.dynamicScope().child();
3601
- this.dynamicScopeStack.push(child);
3602
- return child;
3603
- }
3604
- pushRootScope(size, bindCaller) {
3605
- let scope = Scope.sized(size);
3606
- if (bindCaller) scope.bindCallerScope(this.scope());
3607
- this.scopeStack.push(scope);
3608
- return scope;
3609
- }
3610
- pushScope(scope) {
3611
- this.scopeStack.push(scope);
3612
- }
3613
- popScope() {
3614
- this.scopeStack.pop();
3615
- }
3616
- popDynamicScope() {
3617
- this.dynamicScopeStack.pop();
3618
- }
3619
- newDestroyable(d) {
3620
- this.elements().didAddDestroyable(d);
3621
- }
3622
- /// SCOPE HELPERS
3623
- getSelf() {
3624
- return this.scope().getSelf();
3625
- }
3626
- referenceForSymbol(symbol) {
3627
- return this.scope().getSymbol(symbol);
3628
- }
3629
- /// EXECUTION
3630
- execute(start, initialize) {
3631
- this.pc = this.heap.getaddr(start);
3632
- if (initialize) initialize(this);
3633
- let result;
3634
- while (true) {
3635
- result = this.next();
3636
- if (result.done) break;
3637
- }
3638
- return result.value;
3639
- }
3640
- next() {
3641
- let { env, program, updatingOpcodeStack, elementStack } = this;
3642
- let opcode = this.inner.nextStatement();
3643
- let result;
3644
- if (opcode !== null) {
3645
- this.inner.evaluateOuter(opcode, this);
3646
- result = { done: false, value: null };
3647
- } else {
3648
- // Unload the stack
3649
- this.stack.reset();
3650
- result = {
3651
- done: true,
3652
- value: new RenderResult(env, program, updatingOpcodeStack.pop(), elementStack.popBlock())
3653
- };
3654
- }
3655
- return result;
3656
- }
3657
- bindDynamicScope(names) {
3658
- let scope = this.dynamicScope();
3659
- for (let i = names.length - 1; i >= 0; i--) {
3660
- let name = this.constants.getString(names[i]);
3661
- scope.set(name, this.stack.pop());
3662
- }
3663
- }
3664
- }
3665
-
3666
- class TemplateIteratorImpl {
3667
- constructor(vm) {
3668
- this.vm = vm;
3669
- }
3670
- next() {
3671
- return this.vm.next();
3672
- }
3673
- }
3674
- function render(program, env, self, dynamicScope, builder, handle) {
3675
- let vm = VM.initial(program, env, self, dynamicScope, builder, handle);
3676
- return new TemplateIteratorImpl(vm);
3677
- }
3678
-
3679
- class DynamicVarReference {
3680
- constructor(scope, nameRef) {
3681
- this.scope = scope;
3682
- this.nameRef = nameRef;
3683
- let varTag = this.varTag = UpdatableTag.create(CONSTANT_TAG);
3684
- this.tag = combine([nameRef.tag, varTag]);
3685
- }
3686
- value() {
3687
- return this.getVar().value();
3688
- }
3689
- get(key) {
3690
- return this.getVar().get(key);
3691
- }
3692
- getVar() {
3693
- let name = String(this.nameRef.value());
3694
- let ref = this.scope.get(name);
3695
- this.varTag.inner.update(ref.tag);
3696
- return ref;
3697
- }
3698
- }
3699
- function getDynamicVar(vm, args) {
3700
- let scope = vm.dynamicScope();
3701
- let nameRef = args.positional.at(0);
3702
- return new DynamicVarReference(scope, nameRef);
3703
- }
3704
-
3705
- /** @internal */
3706
- const DEFAULT_CAPABILITIES = {
3707
- dynamicLayout: true,
3708
- dynamicTag: true,
3709
- prepareArgs: true,
3710
- createArgs: true,
3711
- attributeHook: false,
3712
- elementHook: false,
3713
- dynamicScope: true,
3714
- createCaller: false,
3715
- updateHook: true,
3716
- createInstance: true
3717
- };
3718
- const MINIMAL_CAPABILITIES = {
3719
- dynamicLayout: false,
3720
- dynamicTag: false,
3721
- prepareArgs: false,
3722
- createArgs: false,
3723
- attributeHook: false,
3724
- elementHook: false,
3725
- dynamicScope: false,
3726
- createCaller: false,
3727
- updateHook: false,
3728
- createInstance: false
3729
- };
3730
-
3731
- class RehydratingCursor extends Cursor {
3732
- constructor(element, nextSibling, startingBlockDepth) {
3733
- super(element, nextSibling);
3734
- this.startingBlockDepth = startingBlockDepth;
3735
- this.candidate = null;
3736
- this.injectedOmittedNode = false;
3737
- this.openBlockDepth = startingBlockDepth - 1;
3738
- }
3739
- }
3740
- class RehydrateBuilder extends NewElementBuilder {
3741
- // private candidate: Option<Simple.Node> = null;
3742
- constructor(env, parentNode, nextSibling) {
3743
- super(env, parentNode, nextSibling);
3744
- this.unmatchedAttributes = null;
3745
- this.blockDepth = 0;
3746
- if (nextSibling) throw new Error('Rehydration with nextSibling not supported');
3747
- let node = this.currentCursor.element.firstChild;
3748
- while (node !== null) {
3749
- if (isComment(node) && isSerializationFirstNode(node)) {
3750
- break;
3751
- }
3752
- node = node.nextSibling;
3753
- }
3754
-
3755
- this.candidate = node;
3756
- }
3757
- get currentCursor() {
3758
- return this.cursorStack.current;
3759
- }
3760
- get candidate() {
3761
- if (this.currentCursor) {
3762
- return this.currentCursor.candidate;
3763
- }
3764
- return null;
3765
- }
3766
- set candidate(node) {
3767
- this.currentCursor.candidate = node;
3768
- }
3769
- pushElement(element, nextSibling) {
3770
- let { blockDepth = 0 } = this;
3771
- let cursor = new RehydratingCursor(element, nextSibling, blockDepth);
3772
- let currentCursor = this.currentCursor;
3773
- if (currentCursor) {
3774
- if (currentCursor.candidate) {
3775
- /**
3776
- * <div> <--------------- currentCursor.element
3777
- * <!--%+b:1%-->
3778
- * <div> <--------------- currentCursor.candidate -> cursor.element
3779
- * <!--%+b:2%--> <- currentCursor.candidate.firstChild -> cursor.candidate
3780
- * Foo
3781
- * <!--%-b:2%-->
3782
- * </div>
3783
- * <!--%-b:1%--> <-- becomes currentCursor.candidate
3784
- */
3785
- // where to rehydrate from if we are in rehydration mode
3786
- cursor.candidate = element.firstChild;
3787
- // where to continue when we pop
3788
- currentCursor.candidate = element.nextSibling;
3789
- }
3790
- }
3791
- this.cursorStack.push(cursor);
3792
- }
3793
- clearMismatch(candidate) {
3794
- let current = candidate;
3795
- let currentCursor = this.currentCursor;
3796
- if (currentCursor !== null) {
3797
- let openBlockDepth = currentCursor.openBlockDepth;
3798
- if (openBlockDepth >= currentCursor.startingBlockDepth) {
3799
- while (current && !(isComment(current) && getCloseBlockDepth(current) === openBlockDepth)) {
3800
- current = this.remove(current);
3801
- }
3802
- } else {
3803
- while (current !== null) {
3804
- current = this.remove(current);
3805
- }
3806
- }
3807
- // current cursor parentNode should be openCandidate if element
3808
- // or openCandidate.parentNode if comment
3809
- currentCursor.nextSibling = current;
3810
- // disable rehydration until we popElement or closeBlock for openBlockDepth
3811
- currentCursor.candidate = null;
3812
- }
3813
- }
3814
- __openBlock() {
3815
- let { currentCursor } = this;
3816
- if (currentCursor === null) return;
3817
- let blockDepth = this.blockDepth;
3818
- this.blockDepth++;
3819
- let { candidate } = currentCursor;
3820
- if (candidate === null) return;
3821
- if (isComment(candidate) && getOpenBlockDepth(candidate) === blockDepth) {
3822
- currentCursor.candidate = this.remove(candidate);
3823
- currentCursor.openBlockDepth = blockDepth;
3824
- } else {
3825
- this.clearMismatch(candidate);
3826
- }
3827
- }
3828
- __closeBlock() {
3829
- let { currentCursor } = this;
3830
- if (currentCursor === null) return;
3831
- // openBlock is the last rehydrated open block
3832
- let openBlockDepth = currentCursor.openBlockDepth;
3833
- // this currently is the expected next open block depth
3834
- this.blockDepth--;
3835
- let { candidate } = currentCursor;
3836
- // rehydrating
3837
- if (candidate !== null) {
3838
-
3839
- if (isComment(candidate) && getCloseBlockDepth(candidate) === openBlockDepth) {
3840
- currentCursor.candidate = this.remove(candidate);
3841
- currentCursor.openBlockDepth--;
3842
- } else {
3843
- this.clearMismatch(candidate);
3844
- }
3845
- // if the openBlockDepth matches the blockDepth we just closed to
3846
- // then restore rehydration
3847
- }
3848
- if (currentCursor.openBlockDepth === this.blockDepth) {
3849
-
3850
- currentCursor.candidate = this.remove(currentCursor.nextSibling);
3851
- currentCursor.openBlockDepth--;
3852
- }
3853
- }
3854
- __appendNode(node) {
3855
- let { candidate } = this;
3856
- // This code path is only used when inserting precisely one node. It needs more
3857
- // comparison logic, but we can probably lean on the cases where this code path
3858
- // is actually used.
3859
- if (candidate) {
3860
- return candidate;
3861
- } else {
3862
- return super.__appendNode(node);
3863
- }
3864
- }
3865
- __appendHTML(html) {
3866
- let candidateBounds = this.markerBounds();
3867
- if (candidateBounds) {
3868
- let first = candidateBounds.firstNode();
3869
- let last = candidateBounds.lastNode();
3870
- let newBounds = bounds(this.element, first.nextSibling, last.previousSibling);
3871
- let possibleEmptyMarker = this.remove(first);
3872
- this.remove(last);
3873
- if (possibleEmptyMarker !== null && isEmpty$1(possibleEmptyMarker)) {
3874
- this.candidate = this.remove(possibleEmptyMarker);
3875
- if (this.candidate !== null) {
3876
- this.clearMismatch(this.candidate);
3877
- }
3878
- }
3879
- return newBounds;
3880
- } else {
3881
- return super.__appendHTML(html);
3882
- }
3883
- }
3884
- remove(node) {
3885
- let element = node.parentNode;
3886
- let next = node.nextSibling;
3887
- element.removeChild(node);
3888
- return next;
3889
- }
3890
- markerBounds() {
3891
- let _candidate = this.candidate;
3892
- if (_candidate && isMarker(_candidate)) {
3893
- let first = _candidate;
3894
- let last = first.nextSibling;
3895
- while (last && !isMarker(last)) {
3896
- last = last.nextSibling;
3897
- }
3898
- return bounds(this.element, first, last);
3899
- } else {
3900
- return null;
3901
- }
3902
- }
3903
- __appendText(string) {
3904
- let { candidate } = this;
3905
- if (candidate) {
3906
- if (isTextNode(candidate)) {
3907
- if (candidate.nodeValue !== string) {
3908
- candidate.nodeValue = string;
3909
- }
3910
- this.candidate = candidate.nextSibling;
3911
- return candidate;
3912
- } else if (candidate && (isSeparator(candidate) || isEmpty$1(candidate))) {
3913
- this.candidate = candidate.nextSibling;
3914
- this.remove(candidate);
3915
- return this.__appendText(string);
3916
- } else if (isEmpty$1(candidate)) {
3917
- let next = this.remove(candidate);
3918
- this.candidate = next;
3919
- let text = this.dom.createTextNode(string);
3920
- this.dom.insertBefore(this.element, text, next);
3921
- return text;
3922
- } else {
3923
- this.clearMismatch(candidate);
3924
- return super.__appendText(string);
3925
- }
3926
- } else {
3927
- return super.__appendText(string);
3928
- }
3929
- }
3930
- __appendComment(string) {
3931
- let _candidate = this.candidate;
3932
- if (_candidate && isComment(_candidate)) {
3933
- if (_candidate.nodeValue !== string) {
3934
- _candidate.nodeValue = string;
3935
- }
3936
- this.candidate = _candidate.nextSibling;
3937
- return _candidate;
3938
- } else if (_candidate) {
3939
- this.clearMismatch(_candidate);
3940
- }
3941
- return super.__appendComment(string);
3942
- }
3943
- __openElement(tag) {
3944
- let _candidate = this.candidate;
3945
- if (_candidate && isElement(_candidate) && isSameNodeType(_candidate, tag)) {
3946
- this.unmatchedAttributes = [].slice.call(_candidate.attributes);
3947
- return _candidate;
3948
- } else if (_candidate) {
3949
- if (isElement(_candidate) && _candidate.tagName === 'TBODY') {
3950
- this.pushElement(_candidate, null);
3951
- this.currentCursor.injectedOmittedNode = true;
3952
- return this.__openElement(tag);
3953
- }
3954
- this.clearMismatch(_candidate);
3955
- }
3956
- return super.__openElement(tag);
3957
- }
3958
- __setAttribute(name, value, namespace) {
3959
- let unmatched = this.unmatchedAttributes;
3960
- if (unmatched) {
3961
- let attr = findByName(unmatched, name);
3962
- if (attr) {
3963
- if (attr.value !== value) {
3964
- attr.value = value;
3965
- }
3966
- unmatched.splice(unmatched.indexOf(attr), 1);
3967
- return;
3968
- }
3969
- }
3970
- return super.__setAttribute(name, value, namespace);
3971
- }
3972
- __setProperty(name, value) {
3973
- let unmatched = this.unmatchedAttributes;
3974
- if (unmatched) {
3975
- let attr = findByName(unmatched, name);
3976
- if (attr) {
3977
- if (attr.value !== value) {
3978
- attr.value = value;
3979
- }
3980
- unmatched.splice(unmatched.indexOf(attr), 1);
3981
- return;
3982
- }
3983
- }
3984
- return super.__setProperty(name, value);
3985
- }
3986
- __flushElement(parent, constructing) {
3987
- let { unmatchedAttributes: unmatched } = this;
3988
- if (unmatched) {
3989
- for (let i = 0; i < unmatched.length; i++) {
3990
- this.constructing.removeAttribute(unmatched[i].name);
3991
- }
3992
- this.unmatchedAttributes = null;
3993
- } else {
3994
- super.__flushElement(parent, constructing);
3995
- }
3996
- }
3997
- willCloseElement() {
3998
- let { candidate, currentCursor } = this;
3999
- if (candidate !== null) {
4000
- this.clearMismatch(candidate);
4001
- }
4002
- if (currentCursor && currentCursor.injectedOmittedNode) {
4003
- this.popElement();
4004
- }
4005
- super.willCloseElement();
4006
- }
4007
- getMarker(element, guid) {
4008
- let marker = element.querySelector(`script[glmr="${guid}"]`);
4009
- if (marker) {
4010
- return marker;
4011
- }
4012
- throw new Error('Cannot find serialized cursor for `in-element`');
4013
- }
4014
- __pushRemoteElement(element, cursorId, nextSibling = null) {
4015
- let marker = this.getMarker(element, cursorId);
4016
- if (marker.parentNode === element) {
4017
- let currentCursor = this.currentCursor;
4018
- let candidate = currentCursor.candidate;
4019
- this.pushElement(element, nextSibling);
4020
- currentCursor.candidate = candidate;
4021
- this.candidate = this.remove(marker);
4022
- let tracker = new RemoteBlockTracker(element);
4023
- this.pushBlockTracker(tracker, true);
4024
- }
4025
- }
4026
- didAppendBounds(bounds$$1) {
4027
- super.didAppendBounds(bounds$$1);
4028
- if (this.candidate) {
4029
- let last = bounds$$1.lastNode();
4030
- this.candidate = last && last.nextSibling;
4031
- }
4032
- return bounds$$1;
4033
- }
4034
- }
4035
- function isTextNode(node) {
4036
- return node.nodeType === 3;
4037
- }
4038
- function isComment(node) {
4039
- return node.nodeType === 8;
4040
- }
4041
- function getOpenBlockDepth(node) {
4042
- let boundsDepth = node.nodeValue.match(/^%\+b:(\d+)%$/);
4043
- if (boundsDepth && boundsDepth[1]) {
4044
- return Number(boundsDepth[1]);
4045
- } else {
4046
- return null;
4047
- }
4048
- }
4049
- function getCloseBlockDepth(node) {
4050
- let boundsDepth = node.nodeValue.match(/^%\-b:(\d+)%$/);
4051
- if (boundsDepth && boundsDepth[1]) {
4052
- return Number(boundsDepth[1]);
4053
- } else {
4054
- return null;
4055
- }
4056
- }
4057
- function isElement(node) {
4058
- return node.nodeType === 1;
4059
- }
4060
- function isMarker(node) {
4061
- return node.nodeType === 8 && node.nodeValue === '%glmr%';
4062
- }
4063
- function isSeparator(node) {
4064
- return node.nodeType === 8 && node.nodeValue === '%|%';
4065
- }
4066
- function isEmpty$1(node) {
4067
- return node.nodeType === 8 && node.nodeValue === '% %';
4068
- }
4069
- function isSameNodeType(candidate, tag) {
4070
- if (candidate.namespaceURI === SVG_NAMESPACE$1) {
4071
- return candidate.tagName === tag;
4072
- }
4073
- return candidate.tagName === tag.toUpperCase();
4074
- }
4075
- function findByName(array, name) {
4076
- for (let i = 0; i < array.length; i++) {
4077
- let attr = array[i];
4078
- if (attr.name === name) return attr;
4079
- }
4080
- return undefined;
4081
- }
4082
- function rehydrationBuilder(env, cursor) {
4083
- return RehydrateBuilder.forInitialRender(env, cursor);
4084
- }
4085
-
4086
- export { render as renderMain, NULL_REFERENCE, UNDEFINED_REFERENCE, PrimitiveReference, ConditionalReference, setDebuggerCallback, resetDebuggerCallback, getDynamicVar, VM as LowLevelVM, UpdatingVM, RenderResult, SimpleDynamicAttribute, DynamicAttribute, EMPTY_ARGS, Scope, Environment, DefaultEnvironment, DEFAULT_CAPABILITIES, MINIMAL_CAPABILITIES, CurriedComponentDefinition, isCurriedComponentDefinition, curry, helper$1 as DOMChanges, SVG_NAMESPACE$1 as SVG_NAMESPACE, DOMChanges as IDOMChanges, DOMTreeConstruction, isWhitespace, insertHTMLBefore, normalizeProperty, NewElementBuilder, clientBuilder, rehydrationBuilder, RehydrateBuilder, ConcreteBounds, Cursor, capabilityFlagsFrom, hasCapability };