@swf2es/player-hosts 0.0.0-stage → 0.1.1

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,77 @@
1
+ // flash.text.TextRenderer: settings for advanced anti-aliasing, kept for the
2
+ // SWF to read back, with the values adl takes and ignores, and the tables
3
+ // of cutoffs a font's advanced text is drawn by (text/csm.ts).
4
+ import { avm2 } from "../../../../runtime/index.js";
5
+ import { setCsmTable } from "../../../text/csm.js";
6
+ export function textRendererNatives(s) {
7
+ const natives = {};
8
+ let displayMode = "default";
9
+ let maxLevel = 4;
10
+ let antiAliasType = "default";
11
+ class TextRendererNatives {
12
+ /** "default" reads as the mode it stands for, "crt" in adl. */
13
+ static get displayMode() {
14
+ return displayMode === "default" ? "crt" : displayMode;
15
+ }
16
+ /** "lcd" and "crt" set; null leaves it, anything else is "default". */
17
+ static set displayMode(v) {
18
+ if (v === null || v === undefined) {
19
+ return;
20
+ }
21
+ const mode = s.rt.toString(v);
22
+ displayMode = mode === "lcd" || mode === "crt" ? mode : "default";
23
+ }
24
+ static get maxLevel() {
25
+ return maxLevel;
26
+ }
27
+ /** Only 3, 4 and 7 are levels; others leave it. */
28
+ static set maxLevel(v) {
29
+ const level = s.rt.toInt(v);
30
+ if (level === 3 || level === 4 || level === 7) {
31
+ maxLevel = level;
32
+ }
33
+ }
34
+ static get antiAliasType() {
35
+ return antiAliasType;
36
+ }
37
+ /** "on" and "default" set, anything else is "off"; null TypeError #2007. */
38
+ static set antiAliasType(v) {
39
+ if (v === null || v === undefined) {
40
+ // adl spells the parameter so.
41
+ throw s.rt.error("TypeError", 2007, "antialiasType");
42
+ }
43
+ const type = s.rt.toString(v);
44
+ antiAliasType = type === "on" || type === "default" ? type : "off";
45
+ }
46
+ /** Checked as adl checks it; then the font's table, for its light and dark text alike, as adl takes it. */
47
+ static setAdvancedAntiAliasingTable(fontName, fontStyle, colorType, table) {
48
+ for (const [name, v] of [
49
+ ["fontName", fontName],
50
+ ["fontStyle", fontStyle],
51
+ ["colorType", colorType],
52
+ ]) {
53
+ if (v === null || v === undefined) {
54
+ throw s.rt.error("TypeError", 2007, name);
55
+ }
56
+ }
57
+ const entries = table?.$a;
58
+ if (!entries) {
59
+ return;
60
+ }
61
+ const settings = s.rt.classNamed("flash.text::CSMSettings");
62
+ for (const entry of entries) {
63
+ if (!s.rt.isInstance(entry, settings)) {
64
+ throw s.rt.error("TypeError", 2005, 4, "CSMSettings");
65
+ }
66
+ }
67
+ const read = (entry, k) => s.rt.toNumber(s.rt.getProperty(entry, s.rt.publicName(k)));
68
+ setCsmTable(s.rt.toString(fontName), s.rt.toString(fontStyle), entries.map((entry) => [
69
+ read(entry, "fontSize"),
70
+ read(entry, "insideCutoff"),
71
+ read(entry, "outsideCutoff"),
72
+ ]));
73
+ }
74
+ }
75
+ avm2.registerNativeClass(natives, "flash.text::TextRenderer", TextRendererNatives);
76
+ return natives;
77
+ }
@@ -0,0 +1,141 @@
1
+ import { avm2 } from "../../../../../runtime/index.js";
2
+ import { deviceMetrics } from "../../../../text/fonts.js";
3
+ const accepted = {
4
+ fontWeight: ["normal", "bold"],
5
+ fontPosture: ["normal", "italic"],
6
+ fontLookup: ["device", "embeddedCFF"],
7
+ renderingMode: ["normal", "cff"],
8
+ cffHinting: ["none", "horizontalStem"],
9
+ };
10
+ function data(o) {
11
+ if (!o.$fontDescription) {
12
+ o.$fontDescription = {
13
+ fontName: "_serif",
14
+ fontWeight: "normal",
15
+ fontPosture: "normal",
16
+ fontLookup: "device",
17
+ renderingMode: "cff",
18
+ cffHinting: "horizontalStem",
19
+ locked: false,
20
+ };
21
+ }
22
+ return o.$fontDescription;
23
+ }
24
+ export function fontDescriptionNatives(s) {
25
+ const natives = {};
26
+ const checked = (value, name) => {
27
+ if (value === null || value === undefined) {
28
+ throw s.rt.error("TypeError", 2007, name);
29
+ }
30
+ const string = s.rt.toString(value);
31
+ if (accepted[name] && !accepted[name].includes(string)) {
32
+ throw s.rt.error("ArgumentError", 2008, name);
33
+ }
34
+ return string;
35
+ };
36
+ const set = (o, name, value) => {
37
+ const state = data(o);
38
+ if (state.locked) {
39
+ throw s.rt.error("Error", 2185);
40
+ }
41
+ state[name] = checked(value, name);
42
+ };
43
+ const compatible = (name, weight, posture, device) => {
44
+ if (!device && (name === null || name === undefined)) {
45
+ return false;
46
+ }
47
+ const fontName = checked(name, "fontName");
48
+ const fontWeight = checked(weight, "fontWeight");
49
+ const fontPosture = checked(posture, "fontPosture");
50
+ const bold = fontWeight === "bold";
51
+ const italic = fontPosture === "italic";
52
+ if (!device) {
53
+ const fonts = [
54
+ ...(s.code.codeLibrary()?.characters.values() ?? []),
55
+ ...s.symbols.registeredFonts.values(),
56
+ ];
57
+ return fonts.some((font) => font.type === "fontCff" &&
58
+ font.name.toLowerCase() === fontName.toLowerCase() &&
59
+ font.bold === bold &&
60
+ font.italic === italic);
61
+ }
62
+ if (["_sans", "_serif", "_typewriter"].includes(fontName.toLowerCase())) {
63
+ return false;
64
+ }
65
+ // A missing face resolves to the same fallback metrics on every sample.
66
+ const font = deviceMetrics(fontName, 48, bold, italic);
67
+ const sample = ["M", "W", "i", "1", "@"];
68
+ if (s.platform.os === "Linux") {
69
+ const substitutes = {
70
+ arial: "Liberation Sans",
71
+ "times new roman": "Liberation Serif",
72
+ "courier new": "Liberation Mono",
73
+ };
74
+ const substitute = substitutes[fontName.toLowerCase()];
75
+ if (substitute) {
76
+ const mapped = deviceMetrics(substitute, 48, bold, italic);
77
+ if (sample.every((char) => font.advance(char) === mapped.advance(char))) {
78
+ return false;
79
+ }
80
+ }
81
+ }
82
+ const fallback = deviceMetrics("__swf2es_missing_font__", 48, bold, italic);
83
+ return sample.some((char) => font.advance(char) !== fallback.advance(char));
84
+ };
85
+ class FontDescriptionNatives {
86
+ get fontName() {
87
+ return data(this).fontName;
88
+ }
89
+ set fontName(value) {
90
+ set(this, "fontName", value);
91
+ }
92
+ get fontWeight() {
93
+ return data(this).fontWeight;
94
+ }
95
+ set fontWeight(value) {
96
+ set(this, "fontWeight", value);
97
+ }
98
+ get fontPosture() {
99
+ return data(this).fontPosture;
100
+ }
101
+ set fontPosture(value) {
102
+ set(this, "fontPosture", value);
103
+ }
104
+ get fontLookup() {
105
+ return data(this).fontLookup;
106
+ }
107
+ set fontLookup(value) {
108
+ set(this, "fontLookup", value);
109
+ }
110
+ get renderingMode() {
111
+ return data(this).renderingMode;
112
+ }
113
+ set renderingMode(value) {
114
+ set(this, "renderingMode", value);
115
+ }
116
+ get cffHinting() {
117
+ return data(this).cffHinting;
118
+ }
119
+ set cffHinting(value) {
120
+ set(this, "cffHinting", value);
121
+ }
122
+ get locked() {
123
+ return data(this).locked;
124
+ }
125
+ set locked(value) {
126
+ const state = data(this);
127
+ if (state.locked) {
128
+ throw s.rt.error("Error", 2185);
129
+ }
130
+ state.locked = !!value;
131
+ }
132
+ static isFontCompatible(name, weight, posture) {
133
+ return compatible(name, weight, posture, false);
134
+ }
135
+ static isDeviceFontCompatible(name, weight, posture) {
136
+ return compatible(name, weight, posture, true);
137
+ }
138
+ }
139
+ avm2.registerNativeClass(natives, "flash.text.engine::FontDescription", FontDescriptionNatives);
140
+ return natives;
141
+ }
@@ -0,0 +1,46 @@
1
+ import { avm2 } from "../../../../../runtime/index.js";
2
+ function data(o) {
3
+ if (!o.$tabStop) {
4
+ o.$tabStop = { alignment: "start", position: 0, decimalAlignmentToken: "" };
5
+ }
6
+ return o.$tabStop;
7
+ }
8
+ export function tabStopNatives(s) {
9
+ const natives = {};
10
+ class TabStopNatives {
11
+ get alignment() {
12
+ return data(this).alignment;
13
+ }
14
+ set alignment(value) {
15
+ if (value === null || value === undefined) {
16
+ throw s.rt.error("TypeError", 2007, "alignment");
17
+ }
18
+ const alignment = s.rt.toString(value);
19
+ if (!["start", "center", "end", "decimal"].includes(alignment)) {
20
+ throw s.rt.error("ArgumentError", 2008, "alignment");
21
+ }
22
+ data(this).alignment = alignment;
23
+ }
24
+ get position() {
25
+ return data(this).position;
26
+ }
27
+ set position(value) {
28
+ const position = Number(value);
29
+ if (position < 0) {
30
+ throw s.rt.error("ArgumentError", 2004);
31
+ }
32
+ data(this).position = position;
33
+ }
34
+ get decimalAlignmentToken() {
35
+ return data(this).decimalAlignmentToken;
36
+ }
37
+ set decimalAlignmentToken(value) {
38
+ if (value === null || value === undefined) {
39
+ throw s.rt.error("TypeError", 2007, "decimalAlignmentToken");
40
+ }
41
+ data(this).decimalAlignmentToken = s.rt.toString(value);
42
+ }
43
+ }
44
+ avm2.registerNativeClass(natives, "flash.text.engine::TabStop", TabStopNatives);
45
+ return natives;
46
+ }
@@ -0,0 +1,17 @@
1
+ // Release Flash Player does not expose its trace listener or levels to SWFs.
2
+ import { avm2 } from "../../../../runtime/index.js";
3
+ export function traceNatives() {
4
+ const natives = {};
5
+ class TraceNatives {
6
+ static setLevel(_level, _target) { }
7
+ static getLevel(_target) {
8
+ return 0;
9
+ }
10
+ static setListener(_listener) { }
11
+ static getListener() {
12
+ return null;
13
+ }
14
+ }
15
+ avm2.registerNativeClass(natives, "flash.trace::Trace", TraceNatives);
16
+ return natives;
17
+ }
@@ -0,0 +1,17 @@
1
+ // flash.ui.ContextMenu: AS3 keeps the items; input/context-menu.ts snapshots them on opening.
2
+ // Links are kept for readback; link-specific built-in actions are not offered yet.
3
+ import { avm2 } from "../../../../runtime/index.js";
4
+ import { coerceArgument } from "../display/InteractiveObject.js";
5
+ export function contextMenuNatives(s) {
6
+ const natives = {};
7
+ class ContextMenuNatives {
8
+ get link() {
9
+ return this.$link ?? null;
10
+ }
11
+ set link(v) {
12
+ this.$link = coerceArgument(s, v, "flash.net::URLRequest");
13
+ }
14
+ }
15
+ avm2.registerNativeClass(natives, "flash.ui::ContextMenu", ContextMenuNatives);
16
+ return natives;
17
+ }
@@ -0,0 +1,19 @@
1
+ // flash.ui.GameInput without game controllers: none are found, so there is
2
+ // no device to get, RangeError 1506 as Flash's for an index past them.
3
+ import { avm2 } from "../../../../runtime/index.js";
4
+ export function gameInputNatives(s) {
5
+ const natives = {};
6
+ class GameInputNatives {
7
+ static get isSupported() {
8
+ return false;
9
+ }
10
+ static get numDevices() {
11
+ return 0;
12
+ }
13
+ static getDeviceAt(_index) {
14
+ throw s.rt.error("RangeError", 1506);
15
+ }
16
+ }
17
+ avm2.registerNativeClass(natives, "flash.ui::GameInput", GameInputNatives);
18
+ return natives;
19
+ }
@@ -0,0 +1,27 @@
1
+ // flash.ui.Keyboard's statics of the keyboard itself: a desktop's,
2
+ // alphanumeric, not virtual, its locks reported off, as a browser keeps
3
+ // their state from a page until a key event carries it.
4
+ import { avm2 } from "../../../../runtime/index.js";
5
+ export function keyboardNatives() {
6
+ const natives = {};
7
+ class KeyboardNatives {
8
+ static get capsLock() {
9
+ return false;
10
+ }
11
+ static get numLock() {
12
+ return false;
13
+ }
14
+ static get hasVirtualKeyboard() {
15
+ return false;
16
+ }
17
+ static get physicalKeyboardType() {
18
+ return "alphanumeric";
19
+ }
20
+ /** Whether the keys may be read: no screen reader is in the way. */
21
+ static isAccessible() {
22
+ return true;
23
+ }
24
+ }
25
+ avm2.registerNativeClass(natives, "flash.ui::Keyboard", KeyboardNatives);
26
+ return natives;
27
+ }
@@ -0,0 +1,127 @@
1
+ // flash.ui.Mouse controls the cursor the host shows: whether it shows one,
2
+ // which of Flash's own it forces, and bitmap cursors registered by name.
3
+ // MouseCursorData holds a cursor's frames, hot spot and frame rate.
4
+ import { avm2 } from "../../../../runtime/index.js";
5
+ import { encodePng } from "../../../bitmap/png.js";
6
+ import { storeOf } from "../display/BitmapData.js";
7
+ /** The names Mouse.cursor takes besides registered ones, as flash.ui.MouseCursor has them. */
8
+ const BUILT_IN = new Set(["auto", "arrow", "button", "hand", "ibeam"]);
9
+ /** The largest cursor Flash takes, a side. */
10
+ const MAX_SIZE = 32;
11
+ export function mouseNatives(s) {
12
+ const natives = {};
13
+ class MouseNatives {
14
+ static hide() {
15
+ s.mouseVisible = false;
16
+ s.pointer?.updateCursor();
17
+ }
18
+ static show() {
19
+ s.mouseVisible = true;
20
+ s.pointer?.updateCursor();
21
+ }
22
+ // Desktop Flash Player and AIR report both.
23
+ static get supportsCursor() {
24
+ return true;
25
+ }
26
+ static get supportsNativeCursor() {
27
+ return true;
28
+ }
29
+ static get cursor() {
30
+ return s.mouseCursor;
31
+ }
32
+ static set cursor(value) {
33
+ if (value === null || value === undefined) {
34
+ throw s.rt.error("TypeError", 2007, "cursor");
35
+ }
36
+ const name = s.rt.toString(value);
37
+ if (!BUILT_IN.has(name) && !s.cursors.has(name)) {
38
+ throw s.rt.error("ArgumentError", 2008, "cursor");
39
+ }
40
+ s.mouseCursor = name;
41
+ s.pointer?.updateCursor();
42
+ }
43
+ static registerCursor(name, cursorData) {
44
+ if (cursorData === null || cursorData === undefined) {
45
+ throw s.rt.error("TypeError", 2007, "cursorData");
46
+ }
47
+ if (name === null || name === undefined) {
48
+ throw s.rt.error("TypeError", 2007, "name");
49
+ }
50
+ // Flash registers nothing, and says nothing, for data never set.
51
+ const d = cursorData;
52
+ const data = d.$cursorFrames;
53
+ if (!data) {
54
+ return;
55
+ }
56
+ const frames = data.$a;
57
+ if (frames.length === 0) {
58
+ throw s.rt.error("ArgumentError", 2008, "cursorData");
59
+ }
60
+ // Within the largest cursor's pixels, whatever its frames' sizes.
61
+ const x = d.$cursorHotX ?? 0;
62
+ const y = d.$cursorHotY ?? 0;
63
+ if (x < 0 || x > MAX_SIZE - 1 || y < 0 || y > MAX_SIZE - 1) {
64
+ throw s.rt.error("ArgumentError", 2008, "hotSpot");
65
+ }
66
+ for (const frame of frames) {
67
+ if (frame === null || frame === undefined) {
68
+ throw s.rt.error("ArgumentError", 2004);
69
+ }
70
+ const store = storeOf(s, frame);
71
+ if (store.width > MAX_SIZE || store.height > MAX_SIZE) {
72
+ throw s.rt.error("ArgumentError", 2004);
73
+ }
74
+ }
75
+ // The first frame alone: a CSS cursor does not animate.
76
+ const first = storeOf(s, frames[0]);
77
+ const png = encodePng(first, { x: 0, y: 0, width: first.width, height: first.height }, true);
78
+ // A hot spot past the image would make the browser refuse the cursor.
79
+ const hotX = Math.min(Math.floor(x) || 0, first.width - 1);
80
+ const hotY = Math.min(Math.floor(y) || 0, first.height - 1);
81
+ const url = `data:image/png;base64,${btoa(String.fromCharCode(...png))}`;
82
+ s.cursors.set(s.rt.toString(name), `url("${url}") ${hotX} ${hotY}, default`);
83
+ s.pointer?.updateCursor();
84
+ }
85
+ static unregisterCursor(name) {
86
+ if (name === null || name === undefined) {
87
+ throw s.rt.error("TypeError", 2007, "name");
88
+ }
89
+ const key = s.rt.toString(name);
90
+ if (s.cursors.delete(key) && s.mouseCursor === key) {
91
+ s.mouseCursor = "auto";
92
+ }
93
+ s.pointer?.updateCursor();
94
+ }
95
+ }
96
+ class MouseCursorDataNatives {
97
+ get data() {
98
+ return this.$cursorFrames ?? null;
99
+ }
100
+ set data(value) {
101
+ this.$cursorFrames = value;
102
+ }
103
+ // A copy each way, as Flash keeps the values and not the Point.
104
+ get hotSpot() {
105
+ return s.rt.construct(s.rt.classNamed("flash.geom::Point"), this.$cursorHotX ?? 0, this.$cursorHotY ?? 0);
106
+ }
107
+ set hotSpot(value) {
108
+ if (value === null || value === undefined) {
109
+ throw s.rt.error("TypeError", 2007, "hotSpot");
110
+ }
111
+ const p = value;
112
+ this.$cursorHotX = s.rt.toNumber(s.rt.getProperty(p, s.rt.publicName("x")));
113
+ this.$cursorHotY = s.rt.toNumber(s.rt.getProperty(p, s.rt.publicName("y")));
114
+ }
115
+ get frameRate() {
116
+ return this.$cursorFrameRate ?? 0;
117
+ }
118
+ // A negative rate is 0; NaN stays.
119
+ set frameRate(value) {
120
+ const rate = s.rt.toNumber(value);
121
+ this.$cursorFrameRate = rate < 0 ? 0 : rate;
122
+ }
123
+ }
124
+ avm2.registerNativeClass(natives, "flash.ui::Mouse", MouseNatives);
125
+ avm2.registerNativeClass(natives, "flash.ui::MouseCursorData", MouseCursorDataNatives);
126
+ return natives;
127
+ }
@@ -0,0 +1,46 @@
1
+ // flash.ui.Multitouch: the host's touch screen, and how the player hands
2
+ // its touches to scripts (input/touch.ts). Gestures are not recognized, so
3
+ // the player reports none, as Flash does where the system has none.
4
+ import { avm2 } from "../../../../runtime/index.js";
5
+ const MODES = new Set(["none", "gesture", "touchPoint"]);
6
+ export function multitouchNatives(s) {
7
+ const natives = {};
8
+ class MultitouchNatives {
9
+ static get inputMode() {
10
+ return s.inputMode;
11
+ }
12
+ // Flash checks the value, then keeps "none" where the system has no touch screen.
13
+ static set inputMode(value) {
14
+ if (value === null || value === undefined) {
15
+ throw s.rt.error("TypeError", 2007, "inputMode");
16
+ }
17
+ const mode = s.rt.toString(value);
18
+ if (!MODES.has(mode)) {
19
+ throw s.rt.error("ArgumentError", 2008, "inputMode");
20
+ }
21
+ if (s.maxTouchPoints > 0) {
22
+ s.inputMode = mode;
23
+ }
24
+ }
25
+ static get supportsTouchEvents() {
26
+ return s.maxTouchPoints > 0;
27
+ }
28
+ static get supportsGestureEvents() {
29
+ return false;
30
+ }
31
+ static get supportedGestures() {
32
+ return null;
33
+ }
34
+ static get maxTouchPoints() {
35
+ return s.maxTouchPoints;
36
+ }
37
+ static get mapTouchToMouse() {
38
+ return s.mapTouchToMouse;
39
+ }
40
+ static set mapTouchToMouse(value) {
41
+ s.mapTouchToMouse = !!value;
42
+ }
43
+ }
44
+ avm2.registerNativeClass(natives, "flash.ui::Multitouch", MultitouchNatives);
45
+ return natives;
46
+ }
@@ -0,0 +1,155 @@
1
+ // The player supplies charset decoding where avmshell has a stub.
2
+ // Instances of a subclass bound to DefineBinaryData start with shared data
3
+ // at position 0, each seeing the others' writes until resized. Crossbridge
4
+ // keeps a C program's initialized data so, one subclass per data section.
5
+ import { avm2 } from "../../../../runtime/index.js";
6
+ // AIR retains BOMs here, unlike readUTFBytes. Bound the cache for SWF-supplied labels.
7
+ const decoders = new Map();
8
+ let fallback;
9
+ function decoderFor(name) {
10
+ let decoder = decoders.get(name);
11
+ if (decoder) {
12
+ return decoder;
13
+ }
14
+ try {
15
+ // Windows Flash does not accept these web-only labels or trim encoding names.
16
+ if (name !== name.trim() || name === "utf8" || name === "euc-kr") {
17
+ throw new RangeError();
18
+ }
19
+ decoder = new TextDecoder(name === "cn-gb" ? "gbk" : name, { ignoreBOM: true });
20
+ }
21
+ catch {
22
+ // A browser has no system code page. Use the Western Windows Flash default.
23
+ fallback ??= new TextDecoder("windows-1252");
24
+ decoder = fallback;
25
+ }
26
+ if (name.length <= 64) {
27
+ if (decoders.size === 32) {
28
+ decoders.delete(decoders.keys().next().value);
29
+ }
30
+ decoders.set(name, decoder);
31
+ }
32
+ return decoder;
33
+ }
34
+ function singleByte(bytes, ascii) {
35
+ if (ascii) {
36
+ const end = bytes.findIndex((byte) => byte >= 0x80);
37
+ if (end >= 0) {
38
+ bytes = bytes.subarray(0, end);
39
+ }
40
+ }
41
+ const parts = [];
42
+ for (let i = 0; i < bytes.length; i += 4096) {
43
+ parts.push(String.fromCharCode(...bytes.subarray(i, i + 4096)));
44
+ }
45
+ return parts.join("");
46
+ }
47
+ function utf16(bytes, little) {
48
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
49
+ const parts = [];
50
+ const units = [];
51
+ for (let i = 0; i < bytes.length; i += 2) {
52
+ const unit = view.getUint16(i, little);
53
+ if (unit === 0) {
54
+ break;
55
+ }
56
+ units.push(unit);
57
+ if (units.length === 4096) {
58
+ parts.push(String.fromCharCode(...units));
59
+ units.length = 0;
60
+ }
61
+ }
62
+ parts.push(String.fromCharCode(...units));
63
+ return parts.join("");
64
+ }
65
+ // Windows Flash uses CP932's replacement and private-use characters for invalid Shift-JIS.
66
+ function shiftJisFallback(bytes, decoder) {
67
+ const parts = [];
68
+ for (let i = 0; i < bytes.length; i++) {
69
+ const byte = bytes[i];
70
+ if ((byte >= 0x81 && byte <= 0x9f) || (byte >= 0xe0 && byte <= 0xfc)) {
71
+ const next = bytes[++i];
72
+ if (next === undefined || next < 0x40 || next === 0x7f || next > 0xfc) {
73
+ parts.push("\u30fb");
74
+ }
75
+ else {
76
+ parts.push(decoder.decode(bytes.subarray(i - 1, i + 1)).replaceAll("\ufffd", "\u30fb"));
77
+ }
78
+ }
79
+ else if (byte === 0x80) {
80
+ parts.push("\u0080");
81
+ }
82
+ else if (byte === 0xa0 || byte >= 0xfd) {
83
+ parts.push(String.fromCharCode(byte === 0xa0 ? 0xf8f0 : 0xf8f1 + byte - 0xfd));
84
+ }
85
+ else {
86
+ parts.push(decoder.decode(bytes.subarray(i, i + 1)));
87
+ }
88
+ }
89
+ return parts.join("");
90
+ }
91
+ export function byteArrayNatives(s) {
92
+ const read = (b, length, charset) => {
93
+ const rt = s.rt;
94
+ if (charset === null || charset === undefined) {
95
+ throw rt.error("TypeError", 2007, "charSet");
96
+ }
97
+ const count = rt.toUint(length);
98
+ b.checkEOF(count);
99
+ const name = rt.toString(charset).toLowerCase();
100
+ switch (name) {
101
+ case "utf-16":
102
+ case "utf-16le":
103
+ case "unicode":
104
+ return utf16(b.readView(count - (count % 2)), true);
105
+ case "utf-16be":
106
+ case "unicodefffe":
107
+ return utf16(b.readView(count - (count % 2)), false);
108
+ }
109
+ let bytes = b.readView(count);
110
+ const nul = bytes.indexOf(0);
111
+ if (nul >= 0) {
112
+ bytes = bytes.subarray(0, nul);
113
+ }
114
+ switch (name) {
115
+ case "iso-8859-1":
116
+ case "iso_8859-1":
117
+ case "latin1":
118
+ return singleByte(bytes, false);
119
+ case "ascii":
120
+ case "us-ascii":
121
+ return singleByte(bytes, true);
122
+ }
123
+ const decoder = decoderFor(name);
124
+ const text = decoder.decode(bytes);
125
+ return decoder.encoding === "shift_jis" && text.includes("\ufffd")
126
+ ? shiftJisFallback(bytes, decoder)
127
+ : text;
128
+ };
129
+ return {
130
+ "flash.utils::ByteArray#readMultiByte": avm2.plain(function (length, charset) {
131
+ return read(avm2.bytesOf(s.rt, this), length, charset);
132
+ }),
133
+ "flash.utils::ObjectInput#readMultiByte": avm2.plain(function (length, charset) {
134
+ return read(this.$amf.bytes, length, charset);
135
+ }),
136
+ };
137
+ }
138
+ export function byteArrayHooks(s) {
139
+ return {
140
+ "flash.utils::ByteArray": {
141
+ ...avm2.byteArrayHook,
142
+ create: (traits, rt) => {
143
+ const o = avm2.byteArrayHook.create(traits, rt);
144
+ const data = s.symbols.binarySymbol(traits);
145
+ if (data) {
146
+ const b = avm2.bytesOf(rt, o);
147
+ b.buffer = data;
148
+ b.view = new DataView(data.buffer);
149
+ b.length = data.length;
150
+ }
151
+ return o;
152
+ },
153
+ },
154
+ };
155
+ }