@swf2es/player-hosts 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/LICENSE +202 -0
  2. package/LICENSE.third-party +759 -0
  3. package/README.md +43 -2
  4. package/dist/indexeddb.d.ts +27 -0
  5. package/dist/indexeddb.d.ts.map +1 -0
  6. package/dist/indexeddb.js +170 -0
  7. package/dist/indexeddb.js.map +1 -0
  8. package/dist/node-worker.d.ts +2 -0
  9. package/dist/node-worker.d.ts.map +1 -0
  10. package/dist/node-worker.js +12 -0
  11. package/dist/node-worker.js.map +1 -0
  12. package/dist/node.d.ts +8 -0
  13. package/dist/node.d.ts.map +1 -0
  14. package/dist/node.js +43 -0
  15. package/dist/node.js.map +1 -0
  16. package/dist/precompiled.d.ts +31 -0
  17. package/dist/precompiled.d.ts.map +1 -0
  18. package/dist/precompiled.js +125 -0
  19. package/dist/precompiled.js.map +1 -0
  20. package/dist/stage3d.d.ts +13 -0
  21. package/dist/stage3d.d.ts.map +1 -0
  22. package/dist/stage3d.js +61 -0
  23. package/dist/stage3d.js.map +1 -0
  24. package/dist/thread/codegen/codegen.js +308 -0
  25. package/dist/thread/codegen/index.js +405 -0
  26. package/dist/thread/format/abc-names.js +126 -0
  27. package/dist/thread/format/actions.js +222 -0
  28. package/dist/thread/format/air-descriptor.js +63 -0
  29. package/dist/thread/format/api-versions.js +22 -0
  30. package/dist/thread/format/bitmap.js +199 -0
  31. package/dist/thread/format/button.js +60 -0
  32. package/dist/thread/format/compression.js +200 -0
  33. package/dist/thread/format/display.js +305 -0
  34. package/dist/thread/format/filters.js +136 -0
  35. package/dist/thread/format/font.js +168 -0
  36. package/dist/thread/format/index.js +26 -0
  37. package/dist/thread/format/pbj.js +484 -0
  38. package/dist/thread/format/shape.js +411 -0
  39. package/dist/thread/format/sound.js +91 -0
  40. package/dist/thread/format/swf.js +163 -0
  41. package/dist/thread/format/tags.js +58 -0
  42. package/dist/thread/format/text.js +135 -0
  43. package/dist/thread/format/zip.js +91 -0
  44. package/dist/thread/native/audio/binary.js +3 -0
  45. package/dist/thread/native/audio/index.js +72 -0
  46. package/dist/thread/native/base64.js +9 -0
  47. package/dist/thread/native/compress/binary.js +3 -0
  48. package/dist/thread/native/compress/index.js +145 -0
  49. package/dist/thread/native/instance.js +49 -0
  50. package/dist/thread/native/mp3/binary.js +3 -0
  51. package/dist/thread/native/mp3/index.js +48 -0
  52. package/dist/thread/native/render/binary.js +3 -0
  53. package/dist/thread/native/render/bitmap-kernel.js +591 -0
  54. package/dist/thread/native/render/draw-kernel.js +204 -0
  55. package/dist/thread/native/render/dxt-encoder.js +94 -0
  56. package/dist/thread/native/render/index.js +10 -0
  57. package/dist/thread/native/render/lines.js +122 -0
  58. package/dist/thread/native/render/module.js +26 -0
  59. package/dist/thread/native/render/pixel-ops.js +235 -0
  60. package/dist/thread/native/render/tessellator.js +250 -0
  61. package/dist/thread/player/avm1/amf.js +507 -0
  62. package/dist/thread/player/avm1/avm1.js +1304 -0
  63. package/dist/thread/player/avm1/bindings.js +214 -0
  64. package/dist/thread/player/avm1/classes.js +75 -0
  65. package/dist/thread/player/avm1/clips.js +229 -0
  66. package/dist/thread/player/avm1/compile.js +140 -0
  67. package/dist/thread/player/avm1/external.js +79 -0
  68. package/dist/thread/player/avm1/focus.js +278 -0
  69. package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
  70. package/dist/thread/player/avm1/globals/Button.js +31 -0
  71. package/dist/thread/player/avm1/globals/Color.js +115 -0
  72. package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
  73. package/dist/thread/player/avm1/globals/FileReference.js +217 -0
  74. package/dist/thread/player/avm1/globals/Key.js +60 -0
  75. package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
  76. package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
  77. package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
  78. package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
  79. package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
  80. package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
  81. package/dist/thread/player/avm1/globals/Selection.js +62 -0
  82. package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
  83. package/dist/thread/player/avm1/globals/Sound.js +238 -0
  84. package/dist/thread/player/avm1/globals/Stage.js +12 -0
  85. package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
  86. package/dist/thread/player/avm1/globals/TextField.js +396 -0
  87. package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
  88. package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
  89. package/dist/thread/player/avm1/globals/XML.js +396 -0
  90. package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
  91. package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
  92. package/dist/thread/player/avm1/globals/drawing.js +202 -0
  93. package/dist/thread/player/avm1/globals/filters.js +635 -0
  94. package/dist/thread/player/avm1/globals/geom.js +600 -0
  95. package/dist/thread/player/avm1/input.js +483 -0
  96. package/dist/thread/player/avm1/keyboard.js +113 -0
  97. package/dist/thread/player/avm1/loads.js +352 -0
  98. package/dist/thread/player/avm1/net.js +219 -0
  99. package/dist/thread/player/avm1/paths.js +104 -0
  100. package/dist/thread/player/avm1/pointer.js +512 -0
  101. package/dist/thread/player/avm1/queue.js +303 -0
  102. package/dist/thread/player/avm1/sound.js +106 -0
  103. package/dist/thread/player/avm1/swf.js +141 -0
  104. package/dist/thread/player/avm1/timers.js +113 -0
  105. package/dist/thread/player/bitmap/bitmap.js +627 -0
  106. package/dist/thread/player/bitmap/draw.js +68 -0
  107. package/dist/thread/player/bitmap/dxt.js +11 -0
  108. package/dist/thread/player/bitmap/filters.js +656 -0
  109. package/dist/thread/player/bitmap/images.js +240 -0
  110. package/dist/thread/player/bitmap/kernel.js +65 -0
  111. package/dist/thread/player/bitmap/ops.js +1239 -0
  112. package/dist/thread/player/bitmap/pixel-bender.js +911 -0
  113. package/dist/thread/player/bitmap/png.js +139 -0
  114. package/dist/thread/player/bitmap/turbulence.js +89 -0
  115. package/dist/thread/player/clock.js +182 -0
  116. package/dist/thread/player/display/bitmapobject.js +25 -0
  117. package/dist/thread/player/display/bounds.js +520 -0
  118. package/dist/thread/player/display/buttonobject.js +305 -0
  119. package/dist/thread/player/display/color.js +40 -0
  120. package/dist/thread/player/display/container.js +150 -0
  121. package/dist/thread/player/display/display.js +14 -0
  122. package/dist/thread/player/display/displayobject.js +664 -0
  123. package/dist/thread/player/display/drawing.js +613 -0
  124. package/dist/thread/player/display/filters.js +285 -0
  125. package/dist/thread/player/display/geometry.js +189 -0
  126. package/dist/thread/player/display/gradients.js +117 -0
  127. package/dist/thread/player/display/graphicsdata.js +592 -0
  128. package/dist/thread/player/display/instantiate.js +71 -0
  129. package/dist/thread/player/display/matrix3d.js +373 -0
  130. package/dist/thread/player/display/morph.js +226 -0
  131. package/dist/thread/player/display/movieclip.js +680 -0
  132. package/dist/thread/player/display/perspective.js +193 -0
  133. package/dist/thread/player/display/scale9.js +236 -0
  134. package/dist/thread/player/display/shapeobject.js +131 -0
  135. package/dist/thread/player/display/shapes.js +407 -0
  136. package/dist/thread/player/display/textobjects.js +222 -0
  137. package/dist/thread/player/display/timeline.js +471 -0
  138. package/dist/thread/player/display/value-lists.js +40 -0
  139. package/dist/thread/player/display/videoobject.js +6 -0
  140. package/dist/thread/player/display/walk.js +127 -0
  141. package/dist/thread/player/files.js +334 -0
  142. package/dist/thread/player/hosts.js +207 -0
  143. package/dist/thread/player/input/avm1.js +82 -0
  144. package/dist/thread/player/input/context-menu.js +63 -0
  145. package/dist/thread/player/input/keyboard.js +458 -0
  146. package/dist/thread/player/input/pointer.js +863 -0
  147. package/dist/thread/player/input/text-editor.js +319 -0
  148. package/dist/thread/player/input/touch.js +209 -0
  149. package/dist/thread/player/localconnection.js +90 -0
  150. package/dist/thread/player/media/audio.js +376 -0
  151. package/dist/thread/player/media/dynamic-sound.js +90 -0
  152. package/dist/thread/player/media/extract.js +135 -0
  153. package/dist/thread/player/media/mp3.js +152 -0
  154. package/dist/thread/player/media/sounds.js +507 -0
  155. package/dist/thread/player/media/streaming-audio.js +133 -0
  156. package/dist/thread/player/player.js +616 -0
  157. package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
  158. package/dist/thread/player/playerglobal/air-library.js +8 -0
  159. package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
  160. package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
  161. package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
  162. package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
  163. package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
  164. package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
  165. package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
  166. package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
  167. package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
  168. package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
  169. package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
  170. package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
  171. package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
  172. package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
  173. package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
  174. package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
  175. package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
  176. package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
  177. package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
  178. package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
  179. package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
  180. package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
  181. package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
  182. package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
  183. package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
  184. package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
  185. package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
  186. package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
  187. package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
  188. package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
  189. package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
  190. package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
  191. package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
  192. package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
  193. package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
  194. package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
  195. package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
  196. package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
  197. package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
  198. package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
  199. package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
  200. package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
  201. package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
  202. package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
  203. package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
  204. package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
  205. package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
  206. package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
  207. package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
  208. package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
  209. package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
  210. package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
  211. package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
  212. package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
  213. package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
  214. package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
  215. package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
  216. package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
  217. package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
  218. package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
  219. package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
  220. package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
  221. package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
  222. package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
  223. package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
  224. package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
  225. package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
  226. package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
  227. package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
  228. package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
  229. package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
  230. package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
  231. package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
  232. package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
  233. package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
  234. package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
  235. package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
  236. package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
  237. package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
  238. package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
  239. package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
  240. package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
  241. package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
  242. package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
  243. package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
  244. package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
  245. package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
  246. package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
  247. package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
  248. package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
  249. package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
  250. package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
  251. package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
  252. package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
  253. package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
  254. package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
  255. package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
  256. package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
  257. package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
  258. package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
  259. package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
  260. package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
  261. package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
  262. package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
  263. package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
  264. package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
  265. package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
  266. package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
  267. package/dist/thread/player/playerglobal/index.js +224 -0
  268. package/dist/thread/player/playerglobal/libraries.js +10 -0
  269. package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
  270. package/dist/thread/player/playerglobal/toplevel.js +122 -0
  271. package/dist/thread/player/scripting/clipboard.js +146 -0
  272. package/dist/thread/player/scripting/code.js +900 -0
  273. package/dist/thread/player/scripting/evaluate.js +144 -0
  274. package/dist/thread/player/scripting/events.js +172 -0
  275. package/dist/thread/player/scripting/handover.js +182 -0
  276. package/dist/thread/player/scripting/lazy.js +38 -0
  277. package/dist/thread/player/scripting/lifecycle.js +272 -0
  278. package/dist/thread/player/scripting/loads.js +860 -0
  279. package/dist/thread/player/scripting/sha256.js +95 -0
  280. package/dist/thread/player/scripting/symbols.js +348 -0
  281. package/dist/thread/player/scripting/timers.js +434 -0
  282. package/dist/thread/player/scripting/workers.js +923 -0
  283. package/dist/thread/player/scripting.js +1018 -0
  284. package/dist/thread/player/stage.js +4 -0
  285. package/dist/thread/player/text/csm.js +113 -0
  286. package/dist/thread/player/text/css.js +167 -0
  287. package/dist/thread/player/text/fonts.js +97 -0
  288. package/dist/thread/player/text/layout.js +393 -0
  289. package/dist/thread/player/text/static.js +109 -0
  290. package/dist/thread/player/text/text.js +431 -0
  291. package/dist/thread/player/workers/thread.js +159 -0
  292. package/dist/thread/player/workers/wire.js +198 -0
  293. package/dist/thread/player-hosts/web-worker.js +19 -0
  294. package/dist/thread/runtime/avm1/activation.js +89 -0
  295. package/dist/thread/runtime/avm1/case.js +249 -0
  296. package/dist/thread/runtime/avm1/clips.js +334 -0
  297. package/dist/thread/runtime/avm1/control.js +280 -0
  298. package/dist/thread/runtime/avm1/errors.js +50 -0
  299. package/dist/thread/runtime/avm1/functions.js +249 -0
  300. package/dist/thread/runtime/avm1/globals/array.js +549 -0
  301. package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
  302. package/dist/thread/runtime/avm1/globals/date.js +436 -0
  303. package/dist/thread/runtime/avm1/globals/global.js +344 -0
  304. package/dist/thread/runtime/avm1/globals/math.js +139 -0
  305. package/dist/thread/runtime/avm1/globals/number.js +93 -0
  306. package/dist/thread/runtime/avm1/globals/string.js +201 -0
  307. package/dist/thread/runtime/avm1/globals/timers.js +129 -0
  308. package/dist/thread/runtime/avm1/host.js +5 -0
  309. package/dist/thread/runtime/avm1/index.js +14 -0
  310. package/dist/thread/runtime/avm1/inheritance.js +132 -0
  311. package/dist/thread/runtime/avm1/numbers.js +298 -0
  312. package/dist/thread/runtime/avm1/objects.js +896 -0
  313. package/dist/thread/runtime/avm1/operators.js +170 -0
  314. package/dist/thread/runtime/avm1/realm.js +529 -0
  315. package/dist/thread/runtime/avm1/runtime.js +882 -0
  316. package/dist/thread/runtime/avm1/scope.js +385 -0
  317. package/dist/thread/runtime/avm1/urls.js +180 -0
  318. package/dist/thread/runtime/avm1/values.js +97 -0
  319. package/dist/thread/runtime/avm2/amf-classes.js +66 -0
  320. package/dist/thread/runtime/avm2/amf.js +801 -0
  321. package/dist/thread/runtime/avm2/array-conversion.js +100 -0
  322. package/dist/thread/runtime/avm2/builtin-library.js +21 -0
  323. package/dist/thread/runtime/avm2/cache-fill.js +86 -0
  324. package/dist/thread/runtime/avm2/classes.js +211 -0
  325. package/dist/thread/runtime/avm2/definitions.js +69 -0
  326. package/dist/thread/runtime/avm2/descriptors.js +5 -0
  327. package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
  328. package/dist/thread/runtime/avm2/domain-memory.js +75 -0
  329. package/dist/thread/runtime/avm2/domain.js +280 -0
  330. package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
  331. package/dist/thread/runtime/avm2/enumeration.js +393 -0
  332. package/dist/thread/runtime/avm2/errors.js +45 -0
  333. package/dist/thread/runtime/avm2/float-library.js +66 -0
  334. package/dist/thread/runtime/avm2/float.js +26 -0
  335. package/dist/thread/runtime/avm2/hooks.js +19 -0
  336. package/dist/thread/runtime/avm2/index.js +38 -0
  337. package/dist/thread/runtime/avm2/messages.js +177 -0
  338. package/dist/thread/runtime/avm2/method-factories.js +95 -0
  339. package/dist/thread/runtime/avm2/modules.js +105 -0
  340. package/dist/thread/runtime/avm2/names.js +248 -0
  341. package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
  342. package/dist/thread/runtime/avm2/natives/array.js +390 -0
  343. package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
  344. package/dist/thread/runtime/avm2/natives/case.js +88 -0
  345. package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
  346. package/dist/thread/runtime/avm2/natives/date.js +581 -0
  347. package/dist/thread/runtime/avm2/natives/define.js +130 -0
  348. package/dist/thread/runtime/avm2/natives/describe.js +351 -0
  349. package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
  350. package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
  351. package/dist/thread/runtime/avm2/natives/float.js +96 -0
  352. package/dist/thread/runtime/avm2/natives/index.js +64 -0
  353. package/dist/thread/runtime/avm2/natives/json.js +514 -0
  354. package/dist/thread/runtime/avm2/natives/number.js +162 -0
  355. package/dist/thread/runtime/avm2/natives/object.js +237 -0
  356. package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
  357. package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
  358. package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
  359. package/dist/thread/runtime/avm2/natives/shell.js +557 -0
  360. package/dist/thread/runtime/avm2/natives/sort.js +377 -0
  361. package/dist/thread/runtime/avm2/natives/string.js +132 -0
  362. package/dist/thread/runtime/avm2/natives/sync.js +821 -0
  363. package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
  364. package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
  365. package/dist/thread/runtime/avm2/natives/vector.js +406 -0
  366. package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
  367. package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
  368. package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
  369. package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
  370. package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
  371. package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
  372. package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
  373. package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
  374. package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
  375. package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
  376. package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
  377. package/dist/thread/runtime/avm2/number-strings.js +110 -0
  378. package/dist/thread/runtime/avm2/numbers.js +558 -0
  379. package/dist/thread/runtime/avm2/options.js +16 -0
  380. package/dist/thread/runtime/avm2/player-messages.js +550 -0
  381. package/dist/thread/runtime/avm2/property-cache.js +135 -0
  382. package/dist/thread/runtime/avm2/runtime.js +2644 -0
  383. package/dist/thread/runtime/avm2/traits.js +509 -0
  384. package/dist/thread/runtime/index.js +7 -0
  385. package/dist/web-worker.d.ts +2 -0
  386. package/dist/web-worker.d.ts.map +1 -0
  387. package/dist/web-worker.js +20 -0
  388. package/dist/web-worker.js.map +1 -0
  389. package/dist/websocket.d.ts +4 -0
  390. package/dist/websocket.d.ts.map +1 -0
  391. package/dist/websocket.js +27 -0
  392. package/dist/websocket.js.map +1 -0
  393. package/dist/workers.d.ts +35 -0
  394. package/dist/workers.d.ts.map +1 -0
  395. package/dist/workers.js +171 -0
  396. package/dist/workers.js.map +1 -0
  397. package/package.json +62 -3
  398. package/src/indexeddb.ts +227 -0
  399. package/src/node-worker.ts +13 -0
  400. package/src/node.ts +49 -0
  401. package/src/precompiled.ts +166 -0
  402. package/src/stage3d.ts +76 -0
  403. package/src/web-worker.ts +24 -0
  404. package/src/websocket.ts +32 -0
  405. package/src/workers.ts +255 -0
@@ -0,0 +1,130 @@
1
+ // What the natives share: how a native is made, and helpers several
2
+ // families of builtins use.
3
+ import { FloatValue } from "../float.js";
4
+ import { Namespace, publicNs, qname } from "../names.js";
5
+ export const AS3 = "http://adobe.com/AS3/2006/builtin";
6
+ /** Host lookups see every API version; this name keeps no property cache. */
7
+ export const LENGTH = qname(publicNs, "length");
8
+ /** `f` as a native, whatever the runtime. */
9
+ export const plain = (f) => (_rt) => f;
10
+ // What every prototype, and every function, has of its own: not natives.
11
+ // A prototype's `name` is a getter a class may well define, as DisplayObject's.
12
+ const PROTOTYPE_OWN = new Set(["constructor"]);
13
+ const FUNCTION_OWN = new Set(["length", "name", "prototype"]);
14
+ /**
15
+ * Register the members of `Class` as the natives of the AS3 class
16
+ * `qualified`, by the names the compiler binds them with: its prototype's
17
+ * own getters, setters and methods as "Class#get:x", "Class#set:x" and
18
+ * "Class#method", its own static ones as "Class.get:x" and "Class.method".
19
+ * A computed member name carries a name the convention cannot spell, such
20
+ * as `[\`${AS3}::push\`]`. The class is only how the natives are written:
21
+ * nothing makes an instance of it, the AS3 objects' prototypes are not
22
+ * touched, and each function is registered as plain() registers one, so it
23
+ * runs with the AS3 object as `this`. Its descriptors are read, never a
24
+ * getter run. A name registered twice is an error, not a replacement.
25
+ */
26
+ export function registerNativeClass(natives, qualified, Class) {
27
+ const sides = [
28
+ [`${qualified}#`, Class.prototype, PROTOTYPE_OWN],
29
+ [`${qualified}.`, Class, FUNCTION_OWN],
30
+ ];
31
+ for (const [prefix, members, skip] of sides) {
32
+ // Descriptors, not values: a getter must not run here.
33
+ for (const name of Object.getOwnPropertyNames(members)) {
34
+ if (skip.has(name)) {
35
+ continue;
36
+ }
37
+ const d = Object.getOwnPropertyDescriptor(members, name);
38
+ if (!d) {
39
+ continue;
40
+ }
41
+ if (d.get) {
42
+ add(natives, `${prefix}get:${name}`, d.get);
43
+ }
44
+ if (d.set) {
45
+ add(natives, `${prefix}set:${name}`, d.set);
46
+ }
47
+ if (typeof d.value === "function") {
48
+ add(natives, `${prefix}${name}`, d.value);
49
+ }
50
+ }
51
+ }
52
+ }
53
+ /** A native under `key`; a second one for the same key is a mistake, not a replacement. */
54
+ function add(natives, key, fn) {
55
+ if (key in natives) {
56
+ throw new Error(`native ${key} is registered twice`);
57
+ }
58
+ natives[key] = plain(fn);
59
+ }
60
+ /** The elements of an Array value, for natives that take one. */
61
+ export function elements(v) {
62
+ return v?.$a ?? [];
63
+ }
64
+ /** Whether `v` is an object to avmplus (AvmCore::isObject): not null, a primitive, a float or a Namespace. */
65
+ export const isObject = (v) => v !== null && typeof v === "object" && !(v instanceof FloatValue) && !(v instanceof Namespace);
66
+ /**
67
+ * As getUintProperty, element i of an Array, a Vector or any other object:
68
+ * from the elements' own storage when it holds i, else as the property the
69
+ * index names, so that an Array's hole finds the prototype's.
70
+ */
71
+ export function getElement(rt, o, i) {
72
+ // An element in storage first: a Vector's own hook gives the same, or
73
+ // throws its RangeError for what is not there.
74
+ const a = o.$a;
75
+ if (a !== undefined && i in a) {
76
+ return a[i];
77
+ }
78
+ const getIndex = o.$traits?.getIndex;
79
+ return getIndex ? getIndex(o, i, rt) : rt.getProperty(o, rt.publicName(i));
80
+ }
81
+ /**
82
+ * As getLengthProperty, the length Array's natives walk to: an Array's or
83
+ * a Vector's own, which nothing can override, else the length property's,
84
+ * through the getter an Array subclass may override, as a uint.
85
+ */
86
+ export function lengthOf(rt, o) {
87
+ const traits = o.$traits;
88
+ if (traits === rt.builtinClass("Array").$it || traits.cls?.$convert !== undefined) {
89
+ const n = o.$a.length;
90
+ return n;
91
+ }
92
+ return rt.toUint(rt.getProperty(o, LENGTH));
93
+ }
94
+ /**
95
+ * As ArrayClass's every, filter, forEach, map and some: `f` called with
96
+ * each element, its index and the receiver, up to the length at the start;
97
+ * `each` sees each result and the element, and a value it returns ends the
98
+ * walk with that value. What is not an object has no elements. A method
99
+ * closure takes no other receiver, but where `anyReceiver` (map's, and a
100
+ * Vector's map and filter, do not check).
101
+ */
102
+ export function eachElement(rt, o, f, receiver, each, anyReceiver = false) {
103
+ if (!isObject(o) || f === null || f === undefined) {
104
+ return undefined;
105
+ }
106
+ if (!anyReceiver && f.$closure && receiver !== null && receiver !== undefined) {
107
+ throw rt.error("TypeError", 1510);
108
+ }
109
+ const length = lengthOf(rt, o);
110
+ for (let i = 0; i < length; i++) {
111
+ const element = getElement(rt, o, i);
112
+ const done = each(rt.callValue(f, receiver, [element, i, o], null), element);
113
+ if (done !== undefined) {
114
+ return done;
115
+ }
116
+ }
117
+ return undefined;
118
+ }
119
+ /** A conversion of the builtin primitive classes, called or constructed. */
120
+ export const conversion = (convert) => ({
121
+ call: (rt, _cls, args) => convert(rt, args),
122
+ construct: (rt, _cls, args) => convert(rt, args),
123
+ });
124
+ /** Array storage for an instance of Array or a Vector, and its subclasses'. */
125
+ export const withStorage = (traits) => {
126
+ const o = Object.create(traits.proto);
127
+ o.$a = [];
128
+ o.$fixed = false;
129
+ return o;
130
+ };
@@ -0,0 +1,351 @@
1
+ // avmplus.describeTypeJSON, as avmplus' TypeDescriber (core/TypeDescriber.cpp)
2
+ // builds it: the object describeType and playerglobal's
3
+ // flash.utils.describeType turn into XML. The traits' bindings are walked
4
+ // from the root of the chain down, as addBindings adds them, so a derived
5
+ // class's binding stands over its base's; their order is the hashtable's
6
+ // in avmplus, keyed by string addresses, which nothing reproduces.
7
+ //
8
+ // Translated from avmplus' core/TypeDescriber.cpp, this file is subject to
9
+ // the Mozilla Public License, v. 2.0: http://mozilla.org/MPL/2.0/.
10
+ import { formatClassName, NS_Public } from "../names.js";
11
+ import { BIND_Const, BIND_Get, BIND_GetSet, BIND_Method, BIND_Set, BIND_Var, ClassRef, VectorRef, } from "../traits.js";
12
+ const HIDE_NSURI_METHODS = 0x0001;
13
+ const INCLUDE_BASES = 0x0002;
14
+ const INCLUDE_INTERFACES = 0x0004;
15
+ const INCLUDE_VARIABLES = 0x0008;
16
+ const INCLUDE_ACCESSORS = 0x0010;
17
+ const INCLUDE_METHODS = 0x0020;
18
+ const INCLUDE_METADATA = 0x0040;
19
+ const INCLUDE_CONSTRUCTOR = 0x0080;
20
+ const INCLUDE_TRAITS = 0x0100;
21
+ const USE_ITRAITS = 0x0200;
22
+ const HIDE_OBJECT = 0x0400;
23
+ export const describeNatives = {
24
+ "avmplus::describeTypeJSON": (rt) => (v, flags) => describeTypeJSON(rt, v, rt.toUint(flags)),
25
+ };
26
+ /**
27
+ * As TypeDescriber::describeType: the value's traits, or its class's
28
+ * instance traits with USE_ITRAITS, which a value that is no class has
29
+ * none of (null then), as { name, isDynamic, isFinal, isStatic, traits }.
30
+ * undefined and null have traits of their own, void's and null's, with
31
+ * nothing in them.
32
+ */
33
+ function describeTypeJSON(rt, v, flags) {
34
+ // A class object: its own traits are the class's statics, its $it its instances'.
35
+ const cls = v !== null && typeof v === "object" && v.$it ? v : null;
36
+ const traits = cls ? rt.traitsOf(cls) : chooseTraits(rt, v);
37
+ if (typeof traits === "string") {
38
+ // void or null: no traits object to walk, and no instance traits.
39
+ if (flags & USE_ITRAITS) {
40
+ return null;
41
+ }
42
+ return rt.newObject([
43
+ "name",
44
+ traits,
45
+ "isDynamic",
46
+ false,
47
+ "isFinal",
48
+ true,
49
+ "isStatic",
50
+ false,
51
+ "traits",
52
+ flags & INCLUDE_TRAITS ? emptyTraits(rt, flags) : null,
53
+ ]);
54
+ }
55
+ let t = traits;
56
+ let name = cls ? className(cls.$it) : className(t);
57
+ if (flags & USE_ITRAITS) {
58
+ if (!cls) {
59
+ return null;
60
+ }
61
+ t = cls.$it;
62
+ name = className(t);
63
+ }
64
+ return rt.newObject([
65
+ "name",
66
+ name,
67
+ "isDynamic",
68
+ t.dynamic,
69
+ "isFinal",
70
+ t.final,
71
+ "isStatic",
72
+ cls !== null && !(flags & USE_ITRAITS),
73
+ "traits",
74
+ flags & INCLUDE_TRAITS ? describeTraits(rt, t, flags) : null,
75
+ ]);
76
+ }
77
+ /**
78
+ * As TypeDescriber::chooseTraits: undefined is void, null is null, a
79
+ * number that is an int in avmplus' 29 bits is an int, and anything else
80
+ * is what it is; a class object's traits are its own, the class's.
81
+ */
82
+ function chooseTraits(rt, v) {
83
+ if (v === undefined) {
84
+ return "void";
85
+ }
86
+ if (v === null) {
87
+ return "null";
88
+ }
89
+ if (typeof v === "number" && (v | 0) === v && v >= -(1 << 28) && v < 1 << 28) {
90
+ return rt.traitsOfType("int");
91
+ }
92
+ return rt.traitsOf(v);
93
+ }
94
+ /** As Traits::formatClassName: the qualified name, a class's statics' without their trailing $. */
95
+ function className(t) {
96
+ return formatClassName(t.name);
97
+ }
98
+ /** A type's name as describeClassName gives it: * for none, else the class's qualified name. */
99
+ function typeName(rt, type) {
100
+ if (type === null) {
101
+ return "*";
102
+ }
103
+ if (typeof type === "string") {
104
+ return type;
105
+ }
106
+ if (type instanceof VectorRef) {
107
+ return `__AS3__.vec::Vector.<${typeName(rt, type.param)}>`;
108
+ }
109
+ if (type instanceof ClassRef) {
110
+ try {
111
+ return rt.traitsOfType(type).name;
112
+ }
113
+ catch {
114
+ return type.ns.uri ? `${type.ns.uri}::${type.name}` : type.name;
115
+ }
116
+ }
117
+ return "*";
118
+ }
119
+ /** The traits object of void and null: every array asked for empty, nothing else. */
120
+ function emptyTraits(rt, flags) {
121
+ return rt.newObject([
122
+ "bases",
123
+ flags & INCLUDE_BASES ? rt.array([]) : null,
124
+ "interfaces",
125
+ flags & INCLUDE_INTERFACES ? rt.array([]) : null,
126
+ "metadata",
127
+ flags & INCLUDE_METADATA ? rt.array([]) : null,
128
+ "accessors",
129
+ null,
130
+ "methods",
131
+ null,
132
+ "variables",
133
+ null,
134
+ "constructor",
135
+ null,
136
+ ]);
137
+ }
138
+ /** As TypeDescriber::describeTraits. */
139
+ function describeTraits(rt, t, flags) {
140
+ let bases = null;
141
+ if (flags & INCLUDE_BASES) {
142
+ const names = [];
143
+ for (let b = t.base; b; b = b.base) {
144
+ names.push(className(b));
145
+ }
146
+ bases = rt.array(names);
147
+ }
148
+ let interfaces = null;
149
+ if (flags & INCLUDE_INTERFACES) {
150
+ t.settleInterfaces();
151
+ interfaces = rt.array([...t.interfaces].map((i) => className(i)));
152
+ }
153
+ let ctor = null;
154
+ if (flags & INCLUDE_CONSTRUCTOR && t.ctor && t.ctor[0].length > 0) {
155
+ ctor = describeParams(rt, t.ctor[0], t.ctor[1]);
156
+ }
157
+ let metadata = null;
158
+ if (flags & INCLUDE_METADATA) {
159
+ metadata = rt.array(t.metadata ? t.metadata.map((m) => describeMetadata(rt, m)) : []);
160
+ }
161
+ const variables = [];
162
+ const accessors = [];
163
+ const methods = [];
164
+ if (flags & (INCLUDE_ACCESSORS | INCLUDE_METHODS | INCLUDE_VARIABLES)) {
165
+ const hidden = flags & HIDE_NSURI_METHODS ? uriNamespacesOfBases(t) : null;
166
+ for (const member of members(t, flags, rt.apiVersion)) {
167
+ if (member.ns.kind !== NS_Public || hidden?.has(namespaceKey(member.ns, member.version))) {
168
+ continue;
169
+ }
170
+ const kind = member.value & 7;
171
+ const id = member.value >> 3;
172
+ let v;
173
+ let own;
174
+ let other;
175
+ if (kind === BIND_Var || kind === BIND_Const) {
176
+ if (!(flags & INCLUDE_VARIABLES)) {
177
+ continue;
178
+ }
179
+ v = rt.newObject([
180
+ "access",
181
+ kind === BIND_Const ? "readonly" : "readwrite",
182
+ "type",
183
+ typeName(rt, member.owner.slotType(id)),
184
+ ]);
185
+ variables.push(v);
186
+ own = slotMetadataOf(member.owner, id);
187
+ }
188
+ else if (kind === BIND_Method) {
189
+ if (!(flags & INCLUDE_METHODS)) {
190
+ continue;
191
+ }
192
+ const [declaredBy, signature] = signatureOf(member.owner, id);
193
+ v = rt.newObject([
194
+ "declaredBy",
195
+ className(declaredBy),
196
+ "returnType",
197
+ typeName(rt, signature[0]),
198
+ "parameters",
199
+ describeParams(rt, signature[1], signature[2]),
200
+ ]);
201
+ methods.push(v);
202
+ own = methodMetadataOf(member.owner, id);
203
+ }
204
+ else {
205
+ if (!(flags & INCLUDE_ACCESSORS)) {
206
+ continue;
207
+ }
208
+ const getter = kind === BIND_Get || kind === BIND_GetSet;
209
+ const [declaredBy, signature] = signatureOf(member.owner, getter ? id : id + 1);
210
+ const type = getter ? signature[0] : signature[1].length ? signature[1][0] : null;
211
+ v = rt.newObject([
212
+ "declaredBy",
213
+ className(declaredBy),
214
+ "access",
215
+ kind === BIND_Get ? "readonly" : kind === BIND_Set ? "writeonly" : "readwrite",
216
+ "type",
217
+ typeName(rt, type),
218
+ ]);
219
+ accessors.push(v);
220
+ if (getter) {
221
+ own = methodMetadataOf(member.owner, id);
222
+ }
223
+ if (kind === BIND_Set || kind === BIND_GetSet) {
224
+ other = methodMetadataOf(member.owner, id + 1);
225
+ }
226
+ }
227
+ let md = null;
228
+ if (flags & INCLUDE_METADATA && (own || other)) {
229
+ md = rt.array([...(own ?? []), ...(other ?? [])].map((m) => describeMetadata(rt, m)));
230
+ }
231
+ v.$d.set("name", member.name);
232
+ v.$d.set("uri", member.ns.uri === "" ? null : member.ns.uri);
233
+ v.$d.set("metadata", md);
234
+ }
235
+ }
236
+ return rt.newObject([
237
+ "bases",
238
+ bases,
239
+ "interfaces",
240
+ interfaces,
241
+ "metadata",
242
+ metadata,
243
+ "accessors",
244
+ accessors.length ? rt.array(accessors) : null,
245
+ "methods",
246
+ methods.length ? rt.array(methods) : null,
247
+ "variables",
248
+ variables.length ? rt.array(variables) : null,
249
+ "constructor",
250
+ ctor,
251
+ ]);
252
+ }
253
+ /**
254
+ * The bindings of t and its bases, as addBindings gathers them: the
255
+ * root's first, each derived traits' over its base's for the same name
256
+ * and namespace, Object's own left out with HIDE_OBJECT unless t is an
257
+ * interface. The bindings a class gets in its interfaces' namespaces are
258
+ * no members of its own and do not show, as they do not in avmplus.
259
+ */
260
+ function members(t, flags, apiVersion) {
261
+ const chain = [];
262
+ for (let c = t; c; c = c.base) {
263
+ if (flags & HIDE_OBJECT && !c.base && !c.isInterface) {
264
+ break;
265
+ }
266
+ chain.unshift(c);
267
+ }
268
+ const found = new Map();
269
+ for (const owner of chain) {
270
+ owner.settleInterfaces();
271
+ // An interface's namespace has its qualified name as URI, pkg:Name where the traits say pkg::Name.
272
+ const interfaceNames = owner.isInterface
273
+ ? null
274
+ : new Set([...owner.interfaces].flatMap((i) => [i.name, i.name.replace("::", ":")]));
275
+ for (const [name, list] of owner.bindings) {
276
+ for (const b of list) {
277
+ if (b.version > apiVersion ||
278
+ (interfaceNames && b.ns.uri && interfaceNames.has(b.ns.uri))) {
279
+ continue;
280
+ }
281
+ const key = `${b.ns.kind}\u0000${b.ns.uri}\u0000${name}`;
282
+ found.set(key, { name, ns: b.ns, version: b.version, value: b.value, owner });
283
+ }
284
+ }
285
+ }
286
+ return [...found.values()];
287
+ }
288
+ /**
289
+ * The namespaces with a URI that t's bases bind names in, which
290
+ * HIDE_NSURI_METHODS hides: by identity in avmplus, where the builtins'
291
+ * AS3 namespace, versioned, is another than a script's of the same URI,
292
+ * so Object's AS3 methods hide under a class and a script's own AS3
293
+ * methods do not, until a class derives from it.
294
+ */
295
+ function uriNamespacesOfBases(t) {
296
+ const set = new Set();
297
+ for (let c = t.base; c; c = c.base) {
298
+ for (const list of c.bindings.values()) {
299
+ for (const b of list) {
300
+ if (b.ns.uri) {
301
+ set.add(namespaceKey(b.ns, b.version));
302
+ }
303
+ }
304
+ }
305
+ }
306
+ return set;
307
+ }
308
+ function namespaceKey(ns, version) {
309
+ return `${ns.kind}\u0000${ns.uri}\u0000${version}`;
310
+ }
311
+ /** The nearest traits from `owner` up that has the signature of dispatch id `d`, which declares the method, and the signature. */
312
+ function signatureOf(owner, d) {
313
+ for (let c = owner; c; c = c.base) {
314
+ const signature = c.signatures.get(d);
315
+ if (signature) {
316
+ return [c, signature];
317
+ }
318
+ }
319
+ return [owner, [null, [], 0]];
320
+ }
321
+ /** Slot `id`'s metadata, from the traits that declare it; undefined for none. */
322
+ function slotMetadataOf(owner, id) {
323
+ for (let c = owner; c; c = c.base) {
324
+ if (id in c.slotTypes) {
325
+ return c.slotMetadata?.get(id);
326
+ }
327
+ }
328
+ return undefined;
329
+ }
330
+ /** Dispatch id `d`'s metadata, the nearest traits' that has any, as getMethodMetadataPos finds it. */
331
+ function methodMetadataOf(owner, d) {
332
+ for (let c = owner; c; c = c.base) {
333
+ const entries = c.methodMetadata?.get(d);
334
+ if (entries) {
335
+ return entries;
336
+ }
337
+ }
338
+ return undefined;
339
+ }
340
+ /** As TypeDescriber::describeParams: each parameter's type, and whether it is optional. */
341
+ function describeParams(rt, params, required) {
342
+ return rt.array(params.map((type, i) => rt.newObject(["type", typeName(rt, type), "optional", i >= required])));
343
+ }
344
+ /** As describeMetadataInfo: { name, value: [{ key, value }] }. */
345
+ function describeMetadata(rt, [name, items]) {
346
+ const pairs = [];
347
+ for (let i = 0; i < items.length; i += 2) {
348
+ pairs.push(rt.newObject(["key", items[i], "value", items[i + 1]]));
349
+ }
350
+ return rt.newObject(["name", name, "value", rt.array(pairs)]);
351
+ }
@@ -0,0 +1,12 @@
1
+ import { DictionaryKeys } from "../dictionary-keys.js";
2
+ import { plain } from "./define.js";
3
+ export const dictionaryNatives = {
4
+ // As DictionaryObject: keyed by an object itself, in a Map of its own that
5
+ // property access looks in first, and by any other key as a name. Weak keys
6
+ // keep no key alive, as Flash's do not (dictionary-keys.ts): a registry
7
+ // of objects keyed weakly kept every one it had seen.
8
+ "flash.utils::Dictionary#flash.utils:Dictionary::init": plain(function (weakKeys) {
9
+ this.$keys = new DictionaryKeys(!!weakKeys);
10
+ this.$weakKeys = !!weakKeys;
11
+ }),
12
+ };
@@ -0,0 +1,81 @@
1
+ /** Float identity belongs to the vector; only values leaving it need a tag. */
2
+ export class FloatVector {
3
+ data;
4
+ count;
5
+ constructor(length = 0) {
6
+ this.data = new Float32Array(length);
7
+ this.count = length;
8
+ }
9
+ get length() {
10
+ return this.count;
11
+ }
12
+ set length(length) {
13
+ if (length === 0) {
14
+ this.data = new Float32Array(0);
15
+ }
16
+ else if (length > this.count) {
17
+ this.reserve(length);
18
+ this.data.fill(0, this.count, length);
19
+ }
20
+ this.count = length;
21
+ }
22
+ reserve(length) {
23
+ if (length <= this.data.length) {
24
+ return;
25
+ }
26
+ const data = new Float32Array(Math.max(length, this.data.length + Math.max(this.data.length >>> 1, 8)));
27
+ data.set(this.data.subarray(0, this.count));
28
+ this.data = data;
29
+ }
30
+ push(value) {
31
+ this.reserve(this.count + 1);
32
+ this.data[this.count++] = value;
33
+ return this.count;
34
+ }
35
+ pop() {
36
+ return this.count ? this.data[--this.count] : undefined;
37
+ }
38
+ shift() {
39
+ if (!this.count) {
40
+ return undefined;
41
+ }
42
+ const value = this.data[0];
43
+ this.data.copyWithin(0, 1, this.count--);
44
+ return value;
45
+ }
46
+ unshift(...items) {
47
+ const count = items.length;
48
+ this.reserve(this.count + count);
49
+ this.data.copyWithin(count, 0, this.count);
50
+ this.data.set(items);
51
+ this.count += count;
52
+ return this.count;
53
+ }
54
+ splice(start, remove, ...items) {
55
+ const at = start < 0 ? Math.max(0, this.count + start) : Math.min(start, this.count);
56
+ const deleted = Math.min(Math.max(remove, 0), this.count - at);
57
+ const result = Array.from(this.data.subarray(at, at + deleted));
58
+ const length = this.count - deleted + items.length;
59
+ this.reserve(length);
60
+ this.data.copyWithin(at + items.length, at + deleted, this.count);
61
+ this.data.set(items, at);
62
+ this.count = length;
63
+ return result;
64
+ }
65
+ reverse() {
66
+ this.data.subarray(0, this.count).reverse();
67
+ }
68
+ }
69
+ /** Conversion precedes this check: valueOf may change the vector's size or fixedness. */
70
+ export function setFloatElement(rt, o, i, value) {
71
+ const a = o.$a;
72
+ if (i >>> 0 !== i || i > a.length || (i === a.length && o.$fixed)) {
73
+ throw rt.error("RangeError", 1125, i, a.length);
74
+ }
75
+ if (i === a.length) {
76
+ a.push(value);
77
+ }
78
+ else {
79
+ a.data[i] = value;
80
+ }
81
+ }
@@ -0,0 +1,96 @@
1
+ import { numberToString } from "../number-strings.js";
2
+ import { convertDoubleToStringRadix } from "../numbers.js";
3
+ import { conversion } from "./define.js";
4
+ import { numberToExponential, numberToFixed, numberToPrecision } from "./number.js";
5
+ export const floatHooks = {
6
+ float: {
7
+ ...conversion((rt, args) => rt.float(args.length ? args[0] : 0)),
8
+ created: (rt, cls) => {
9
+ const constants = {
10
+ MAX_VALUE: 3.4028234663852886e38,
11
+ MIN_VALUE: 1.401298464324817e-45,
12
+ NaN,
13
+ POSITIVE_INFINITY: Infinity,
14
+ NEGATIVE_INFINITY: -Infinity,
15
+ E: Math.E,
16
+ LN10: Math.LN10,
17
+ LN2: Math.LN2,
18
+ LOG2E: Math.LOG2E,
19
+ PI: Math.PI,
20
+ SQRT1_2: Math.SQRT1_2,
21
+ SQRT2: Math.SQRT2,
22
+ };
23
+ for (const [, , name, binding] of cls.$desc.static.bindings) {
24
+ if (name in constants) {
25
+ cls[`$${binding >> 3}`] = rt.float(constants[name]);
26
+ }
27
+ }
28
+ },
29
+ },
30
+ };
31
+ export const floatNatives = {};
32
+ floatNatives["float.float::_toString"] = (rt) => (value, radix) => {
33
+ const n = rt.toNumber(value);
34
+ const base = rt.toInt(radix);
35
+ if (base === 10 || !Number.isFinite(n)) {
36
+ return numberToString(n);
37
+ }
38
+ if (base < 2 || base > 36) {
39
+ throw rt.error("RangeError", 1003, base);
40
+ }
41
+ return convertDoubleToStringRadix(n, base);
42
+ };
43
+ for (const [name, convert] of [
44
+ ["toFixed", numberToFixed],
45
+ ["toExponential", numberToExponential],
46
+ ["toPrecision", numberToPrecision],
47
+ ]) {
48
+ floatNatives[`float.float::_${name}`] = (rt) => (value, digits) => {
49
+ const n = rt.toInt(digits);
50
+ const min = name === "toPrecision" ? 1 : 0;
51
+ const max = name === "toPrecision" ? 21 : 20;
52
+ if (n < min || n > max) {
53
+ throw rt.error("RangeError", 1002, n, min, max);
54
+ }
55
+ return convert(rt.toNumber(value), n);
56
+ };
57
+ }
58
+ for (const name of [
59
+ "abs",
60
+ "acos",
61
+ "asin",
62
+ "atan",
63
+ "ceil",
64
+ "cos",
65
+ "exp",
66
+ "floor",
67
+ "log",
68
+ "sin",
69
+ "sqrt",
70
+ "tan",
71
+ ]) {
72
+ const fn = Math[name];
73
+ floatNatives[`float.${name}`] = (rt) => (value) => rt.float(fn(Math.fround(rt.toNumber(value))));
74
+ }
75
+ for (const name of ["atan2", "pow"]) {
76
+ const fn = Math[name];
77
+ floatNatives[`float.${name}`] = (rt) => (a, b) => rt.float(fn(Math.fround(rt.toNumber(a)), Math.fround(rt.toNumber(b))));
78
+ }
79
+ for (const name of ["max", "min"]) {
80
+ const fn = Math[name];
81
+ floatNatives[`float.${name}`] =
82
+ (rt) => (...args) => {
83
+ let result = name === "max" ? -Infinity : Infinity;
84
+ for (const arg of args) {
85
+ result = fn(result, Math.fround(rt.toNumber(arg)));
86
+ }
87
+ return rt.float(result);
88
+ };
89
+ }
90
+ floatNatives["float.random"] = (rt) => () => rt.float(Math.random());
91
+ floatNatives["float.round"] = (rt) => (value) => {
92
+ const rounded = Math.round(Math.fround(rt.toNumber(value)));
93
+ return rt.float(rounded === 0 ? 0 : rounded);
94
+ };
95
+ floatNatives["float.reciprocal"] = (rt) => (value) => rt.float(1 / Math.fround(rt.toNumber(value)));
96
+ floatNatives["float.rsqrt"] = (rt) => (value) => rt.float(1 / Math.sqrt(Math.fround(rt.toNumber(value))));