@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.
- package/LICENSE +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
// What a SWF's AVM1 module calls (docs/avm1.md, "Compiling"): its factory
|
|
2
|
+
// takes the runtime, asks it for the operations of the SWF's version,
|
|
3
|
+
// `V`, once, and each region of each block takes its activation, `cx`.
|
|
4
|
+
import { Activation } from "./activation.js";
|
|
5
|
+
import { callFrame, cloneSprite, frameLoaded, frameLoaded2, getProperty, gotoFrame, gotoFrame2, gotoLabel, nextFrame, prevFrame, removeSprite, setProperty, setTarget, setTarget2, startDrag, targetPathOf, } from "./clips.js";
|
|
6
|
+
import { caught, enterTry, enterWith, leave, returned, scopes } from "./control.js";
|
|
7
|
+
import { Avm1Throw, BASE_REMOVED, Disabled, Halt, NotYet, TimedOut } from "./errors.js";
|
|
8
|
+
import { Avm1Super, argumentsOf, ScriptFunction, superOf } from "./functions.js";
|
|
9
|
+
import { extend, implementsOp, instanceOf } from "./inheritance.js";
|
|
10
|
+
import { Avm1Function, Avm1Object, foundDepth, get, invoke, keys, nameOf, READ_ONLY, removeOwn, set, VERSION_BITS, } from "./objects.js";
|
|
11
|
+
import { add2, charOf, extract, firstCode, lessThan, looselyEquals, strictlyEquals, toInt32, wellFormed, } from "./operators.js";
|
|
12
|
+
import { BUDGET, Realm } from "./realm.js";
|
|
13
|
+
import { defineLocal, defineLocal2, deleteVariable, foundLocal, foundOn, getVariable, resolve, resolveCallable, SCOPE_Target, Scope, setVariable, } from "./scope.js";
|
|
14
|
+
import { getUrl, getUrl2 } from "./urls.js";
|
|
15
|
+
import { isPrimitive, stringOf, toBoolean, toNumber, typeOf, } from "./values.js";
|
|
16
|
+
export { Activation, Avm1Throw, Disabled, Halt, NotYet, TimedOut, };
|
|
17
|
+
/** The most timers a pass fires, as Ruffle's MAX_TICKS: a timer far behind catches up over frames. */
|
|
18
|
+
const MAX_TICKS = 10;
|
|
19
|
+
function operations(version) {
|
|
20
|
+
/** Whether strings are bytes, up to SWF 5, which the MB actions read as a single-byte locale's. */
|
|
21
|
+
const bytes = version < 6;
|
|
22
|
+
// Flash's log writes half a surrogate pair as U+FFFD (adl a low half followed by more as three).
|
|
23
|
+
const written = bytes ? bytesAsUtf8 : wellFormed;
|
|
24
|
+
const byZero = version < 5 ? () => "#ERROR#" : divideByZero;
|
|
25
|
+
const stringLength = (a) => stringOf(a, version).length;
|
|
26
|
+
const stringExtract = (count, index, s) => {
|
|
27
|
+
const n = toInt32(count, version);
|
|
28
|
+
const i = toInt32(index, version);
|
|
29
|
+
const text = extract(stringOf(s, version), i, n);
|
|
30
|
+
return bytes ? text : wellFormed(text);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A member's name, as GetMember, SetMember and Delete take it: in a SWF
|
|
34
|
+
* 7, a NaN names element 0 ("0"), as Windows' Flash Player and AIR read,
|
|
35
|
+
* write and delete it (avm1-nan-names-swf7); SWF 6's and 8's, and any
|
|
36
|
+
* name a method converts (hasOwnProperty's), name it "NaN".
|
|
37
|
+
*/
|
|
38
|
+
const memberName = version === 7
|
|
39
|
+
? (name) => typeof name === "number" && Number.isNaN(name) ? "0" : nameOf(name, version)
|
|
40
|
+
: (name) => nameOf(name, version);
|
|
41
|
+
return {
|
|
42
|
+
version,
|
|
43
|
+
constantPool(cx, pool) {
|
|
44
|
+
cx.pool = pool;
|
|
45
|
+
},
|
|
46
|
+
// undefined traces as "undefined" whatever the version, which converts it to "" up to SWF 6;
|
|
47
|
+
// a SWF 5 string's bytes are UTF-8, as Flash's log writes them.
|
|
48
|
+
// A toString that throws gives what an object without one does, and
|
|
49
|
+
// the value is thrown once the trace is written (adl).
|
|
50
|
+
trace(cx, value) {
|
|
51
|
+
let text;
|
|
52
|
+
try {
|
|
53
|
+
text = value === undefined ? "undefined" : stringOf(value, version);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (!(error instanceof Avm1Throw)) {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
cx.host.trace(value instanceof Avm1Function ? "[type Function]" : "[type Object]");
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
cx.host.trace(written(text));
|
|
63
|
+
},
|
|
64
|
+
toBoolean: (value) => toBoolean(value, version),
|
|
65
|
+
toString: (value) => stringOf(value, version),
|
|
66
|
+
toNumber: (value) => toNumber(value, version),
|
|
67
|
+
toInteger: (value) => toInt32(value, version),
|
|
68
|
+
typeOf,
|
|
69
|
+
add: (a, b) => toNumber(b, version) + toNumber(a, version),
|
|
70
|
+
add2: (a, b) => add2(a, b, version),
|
|
71
|
+
subtract(a, b) {
|
|
72
|
+
const x = toNumber(a, version);
|
|
73
|
+
return toNumber(b, version) - x;
|
|
74
|
+
},
|
|
75
|
+
multiply: (a, b) => toNumber(b, version) * toNumber(a, version),
|
|
76
|
+
divide(a, b) {
|
|
77
|
+
const x = toNumber(a, version);
|
|
78
|
+
const y = toNumber(b, version);
|
|
79
|
+
return x === 0 ? byZero(y) : y / x;
|
|
80
|
+
},
|
|
81
|
+
modulo(a, b) {
|
|
82
|
+
const x = toNumber(a, version);
|
|
83
|
+
return toNumber(b, version) % x;
|
|
84
|
+
},
|
|
85
|
+
increment: (a) => toNumber(a, version) + 1,
|
|
86
|
+
decrement: (a) => toNumber(a, version) - 1,
|
|
87
|
+
equals(a, b) {
|
|
88
|
+
const x = toNumber(a, version);
|
|
89
|
+
return toNumber(b, version) === x;
|
|
90
|
+
},
|
|
91
|
+
equals2: (a, b) => looselyEquals(b, a, version),
|
|
92
|
+
strictEquals: strictlyEquals,
|
|
93
|
+
less(a, b) {
|
|
94
|
+
return toNumber(b, version) < toNumber(a, version);
|
|
95
|
+
},
|
|
96
|
+
less2: (a, b) => lessThan(b, a, version),
|
|
97
|
+
greater: (a, b) => lessThan(a, b, version),
|
|
98
|
+
and(a, b) {
|
|
99
|
+
return toBoolean(b, version) && toBoolean(a, version);
|
|
100
|
+
},
|
|
101
|
+
or(a, b) {
|
|
102
|
+
return toBoolean(b, version) || toBoolean(a, version);
|
|
103
|
+
},
|
|
104
|
+
not: (a) => !toBoolean(a, version),
|
|
105
|
+
bitAnd: (a, b) => toInt32(a, version) & toInt32(b, version),
|
|
106
|
+
bitOr: (a, b) => toInt32(a, version) | toInt32(b, version),
|
|
107
|
+
bitXor: (a, b) => toInt32(a, version) ^ toInt32(b, version),
|
|
108
|
+
bitLShift(a, b) {
|
|
109
|
+
const n = toInt32(a, version);
|
|
110
|
+
return toInt32(b, version) << n;
|
|
111
|
+
},
|
|
112
|
+
bitRShift(a, b) {
|
|
113
|
+
const n = toInt32(a, version);
|
|
114
|
+
return toInt32(b, version) >> n;
|
|
115
|
+
},
|
|
116
|
+
bitURShift: version === 8 || version === 9
|
|
117
|
+
? (a, b) => {
|
|
118
|
+
const n = toInt32(a, version);
|
|
119
|
+
return (toInt32(b, version) >>> n) | 0;
|
|
120
|
+
}
|
|
121
|
+
: (a, b) => {
|
|
122
|
+
const n = toInt32(a, version);
|
|
123
|
+
return toInt32(b, version) >>> n;
|
|
124
|
+
},
|
|
125
|
+
stringAdd(a, b) {
|
|
126
|
+
const x = stringOf(a, version);
|
|
127
|
+
return stringOf(b, version) + x;
|
|
128
|
+
},
|
|
129
|
+
stringEquals(a, b) {
|
|
130
|
+
const x = stringOf(a, version);
|
|
131
|
+
return stringOf(b, version) === x;
|
|
132
|
+
},
|
|
133
|
+
stringLess(a, b) {
|
|
134
|
+
const x = stringOf(a, version);
|
|
135
|
+
const y = stringOf(b, version);
|
|
136
|
+
return bytes && againstHighByte(y, x) ? false : y < x;
|
|
137
|
+
},
|
|
138
|
+
stringGreater(a, b) {
|
|
139
|
+
const x = stringOf(a, version);
|
|
140
|
+
const y = stringOf(b, version);
|
|
141
|
+
return bytes && againstHighByte(y, x) ? true : y > x;
|
|
142
|
+
},
|
|
143
|
+
stringLength,
|
|
144
|
+
mbStringLength: stringLength,
|
|
145
|
+
stringExtract,
|
|
146
|
+
mbStringExtract: stringExtract,
|
|
147
|
+
charToAscii: (a) => firstCode(stringOf(a, version)),
|
|
148
|
+
// Up to SWF 5 a string is bytes: AsciiToChar takes the code's low
|
|
149
|
+
// byte, MBAsciiToChar writes a code past 0xFF as two, high first, and
|
|
150
|
+
// the MB actions read one, as in a single-byte locale such as adl's.
|
|
151
|
+
asciiToChar: bytes
|
|
152
|
+
? (a) => charOf(toInt32(a, version) & 0xff, false)
|
|
153
|
+
: (a) => charOf(toInt32(a, version) & 0xffff, true),
|
|
154
|
+
mbCharToAscii: bytes
|
|
155
|
+
? (a) => stringOf(a, version).charCodeAt(0) & 0xff
|
|
156
|
+
: (a) => firstCode(stringOf(a, version)),
|
|
157
|
+
mbAsciiToChar: bytes
|
|
158
|
+
? (a) => {
|
|
159
|
+
const code = toInt32(a, version) & 0xffff;
|
|
160
|
+
return code > 0xff
|
|
161
|
+
? charOf(code >> 8, false) + charOf(code & 0xff, false)
|
|
162
|
+
: charOf(code, false);
|
|
163
|
+
}
|
|
164
|
+
: (a) => charOf(toInt32(a, version) & 0xffff, true),
|
|
165
|
+
// A SWF 4's variables hold no display objects (Ruffle's as_swf4_variable).
|
|
166
|
+
getVariable: version <= 4
|
|
167
|
+
? (cx, name) => {
|
|
168
|
+
const value = getVariable(cx, nameOf(name, version), version);
|
|
169
|
+
return value instanceof Avm1Object && value.display !== null ? undefined : value;
|
|
170
|
+
}
|
|
171
|
+
: (cx, name) => getVariable(cx, nameOf(name, version), version),
|
|
172
|
+
setVariable(cx, value, name) {
|
|
173
|
+
setVariable(cx, nameOf(name, version), value, version);
|
|
174
|
+
},
|
|
175
|
+
defineLocal(cx, value, name) {
|
|
176
|
+
defineLocal(cx, nameOf(name, version), value, version);
|
|
177
|
+
},
|
|
178
|
+
defineLocal2(cx, name) {
|
|
179
|
+
defineLocal2(cx, nameOf(name, version), version);
|
|
180
|
+
},
|
|
181
|
+
getMember(cx, name, object) {
|
|
182
|
+
// An array's element by its number, as loops read them: no name made.
|
|
183
|
+
if (typeof name === "number" && object instanceof Avm1Object && object.elems !== null) {
|
|
184
|
+
const p = name >= 0 && name < object.elems.length ? object.elems[name] : undefined;
|
|
185
|
+
if (p !== undefined && p.get === null && (p.flags & VERSION_BITS) === 0) {
|
|
186
|
+
return p.value;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const key = memberName(name);
|
|
190
|
+
if (object instanceof Avm1Super) {
|
|
191
|
+
return get(object, key, version, object.self);
|
|
192
|
+
}
|
|
193
|
+
if (object instanceof Avm1Object) {
|
|
194
|
+
const live = object.display === null ? object : object.display.live();
|
|
195
|
+
return live === null ? undefined : get(live, key, version);
|
|
196
|
+
}
|
|
197
|
+
return object === undefined || object === null
|
|
198
|
+
? undefined
|
|
199
|
+
: cx.realm.primitiveMember(object, key, version);
|
|
200
|
+
},
|
|
201
|
+
setMember(cx, value, name, object) {
|
|
202
|
+
if (typeof name === "number" &&
|
|
203
|
+
object instanceof Avm1Object &&
|
|
204
|
+
object.elems !== null &&
|
|
205
|
+
object.watchers === null) {
|
|
206
|
+
const p = name >= 0 && name < object.elems.length ? object.elems[name] : undefined;
|
|
207
|
+
if (p !== undefined && p.get === null && (p.flags & (READ_ONLY | VERSION_BITS)) === 0) {
|
|
208
|
+
p.value = value;
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const key = memberName(name);
|
|
213
|
+
if (object instanceof Avm1Super) {
|
|
214
|
+
set(object.self, key, value, version);
|
|
215
|
+
}
|
|
216
|
+
else if (object instanceof Avm1Object) {
|
|
217
|
+
const live = object.display === null ? object : object.display.live();
|
|
218
|
+
if (live !== null) {
|
|
219
|
+
set(live, key, value, version);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if (object !== undefined && object !== null) {
|
|
223
|
+
set(cx.realm.box(object, version), key, value, version);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
deleteMember(_, name, object) {
|
|
227
|
+
const key = memberName(name);
|
|
228
|
+
const o = live(object);
|
|
229
|
+
return o instanceof Avm1Object && removeOwn(o, key, version);
|
|
230
|
+
},
|
|
231
|
+
deleteVariable: (cx, name) => deleteVariable(cx, nameOf(name, version), version),
|
|
232
|
+
initObject(cx) {
|
|
233
|
+
const st = cx.st;
|
|
234
|
+
const n = countOf(st.pop(), version);
|
|
235
|
+
if (n < 0) {
|
|
236
|
+
st.push(undefined);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
// Pairs past the stack's are all undefined, which set the same name each time: one does.
|
|
240
|
+
const object = cx.realm.newObject(version);
|
|
241
|
+
const pairs = Math.min(n, (st.length >> 1) + 2);
|
|
242
|
+
for (let i = 0; i < pairs; i++) {
|
|
243
|
+
const value = st.pop();
|
|
244
|
+
set(object, nameOf(st.pop(), version), value, version);
|
|
245
|
+
}
|
|
246
|
+
st.push(object);
|
|
247
|
+
},
|
|
248
|
+
initArray(cx) {
|
|
249
|
+
const st = cx.st;
|
|
250
|
+
const n = countOf(st.pop(), version);
|
|
251
|
+
if (n < 0) {
|
|
252
|
+
st.push(undefined);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// Past the stack's values, undefined ones; a count far past it is cut short, as no
|
|
256
|
+
// compiler writes one and Flash would make billions of elements.
|
|
257
|
+
const count = Math.min(n, st.length + 0x10000);
|
|
258
|
+
const elements = new Array(count);
|
|
259
|
+
for (let i = 0; i < count; i++) {
|
|
260
|
+
elements[i] = st.pop();
|
|
261
|
+
}
|
|
262
|
+
st.push(cx.realm.newArray(elements, version));
|
|
263
|
+
},
|
|
264
|
+
enumerate(cx, name) {
|
|
265
|
+
enumerate(cx, getVariable(cx, nameOf(name, version), version), version);
|
|
266
|
+
},
|
|
267
|
+
enumerate2(cx, object) {
|
|
268
|
+
enumerate(cx, live(object), version);
|
|
269
|
+
},
|
|
270
|
+
callFunction(cx) {
|
|
271
|
+
const st = cx.st;
|
|
272
|
+
const name = nameOf(st.pop(), version);
|
|
273
|
+
const args = popArgs(st, version);
|
|
274
|
+
const fn = resolveCallable(cx, name, version);
|
|
275
|
+
// `this` is what had the name, a function's activation object too,
|
|
276
|
+
// but in a SWF 5, which takes the target's clip for it (adl).
|
|
277
|
+
const self = foundOn === undefined || (version < 6 && foundLocal) ? cx.clip : foundOn;
|
|
278
|
+
// `super(...)` called by name runs the class above's constructor, as CallMethod of it does.
|
|
279
|
+
st.push(fn instanceof Avm1Super
|
|
280
|
+
? superCall(fn, "", args, version)
|
|
281
|
+
: invoke(fn, self, args, version));
|
|
282
|
+
if (fn instanceof ScriptFunction) {
|
|
283
|
+
cx.host.returned?.();
|
|
284
|
+
}
|
|
285
|
+
returnIfRemoved(cx);
|
|
286
|
+
},
|
|
287
|
+
callMethod(cx) {
|
|
288
|
+
// A method of undefined or null is no call: its code goes on (Ruffle).
|
|
289
|
+
if (callMethod(cx, version)) {
|
|
290
|
+
returnIfRemoved(cx);
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
newObject(cx) {
|
|
294
|
+
const st = cx.st;
|
|
295
|
+
const name = nameOf(st.pop(), version);
|
|
296
|
+
const args = popArgs(st, version);
|
|
297
|
+
st.push(cx.realm.construct(resolve(cx, name, version), args, version));
|
|
298
|
+
returnIfRemoved(cx);
|
|
299
|
+
},
|
|
300
|
+
newMethod(cx) {
|
|
301
|
+
if (newMethod(cx, version)) {
|
|
302
|
+
returnIfRemoved(cx);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
defineFunction(cx, region, name, params) {
|
|
306
|
+
defineFunction(cx, region, name, params, 0, version);
|
|
307
|
+
},
|
|
308
|
+
defineFunction2(cx, region, name, params, flags) {
|
|
309
|
+
defineFunction(cx, region, name, params, flags, version);
|
|
310
|
+
},
|
|
311
|
+
extends(cx, superclass, subclass) {
|
|
312
|
+
extend(cx, superclass, subclass, version);
|
|
313
|
+
},
|
|
314
|
+
instanceOf: (cx, constr, object) => instanceOf(cx.realm, object, constr, version),
|
|
315
|
+
castOp(cx, object, constr) {
|
|
316
|
+
// Flash boxes a primitive first, for nothing: a class replaced on _global sees it.
|
|
317
|
+
if (object !== undefined && object !== null && isPrimitive(object)) {
|
|
318
|
+
cx.realm.box(object, version);
|
|
319
|
+
}
|
|
320
|
+
return instanceOf(cx.realm, object, constr, version) ? object : null;
|
|
321
|
+
},
|
|
322
|
+
implementsOp(cx) {
|
|
323
|
+
implementsOp(cx, version);
|
|
324
|
+
},
|
|
325
|
+
randomNumber(max) {
|
|
326
|
+
// Rust's cast of the max: saturated, NaN 0.
|
|
327
|
+
const n = toNumber(max, version);
|
|
328
|
+
const m = Number.isNaN(n) ? 0 : Math.trunc(Math.min(Math.max(n, -2147483648), 2147483647));
|
|
329
|
+
return m > 0 ? Math.floor(Math.random() * 0x80000000) % m : 0;
|
|
330
|
+
},
|
|
331
|
+
argumentsOf: (cx, args) => argumentsOf(cx, args, version),
|
|
332
|
+
superOf: (cx, self) => superOf(cx, self, version),
|
|
333
|
+
root: (cx) => cx.host.root?.(cx.base),
|
|
334
|
+
parentOf: (cx) => cx.host.parent?.(cx.clip),
|
|
335
|
+
with: (cx, object, from, to) => enterWith(cx, object, from, to, version),
|
|
336
|
+
try: enterTry,
|
|
337
|
+
throw(value) {
|
|
338
|
+
throw new Avm1Throw(value);
|
|
339
|
+
},
|
|
340
|
+
caught,
|
|
341
|
+
leave,
|
|
342
|
+
scopes,
|
|
343
|
+
ret: returned,
|
|
344
|
+
play(cx) {
|
|
345
|
+
if (cx.target !== null) {
|
|
346
|
+
cx.host.play(cx.target);
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
stop(cx) {
|
|
350
|
+
if (cx.target !== null) {
|
|
351
|
+
cx.host.stop(cx.target);
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
setTarget(cx, name) {
|
|
355
|
+
setTarget(cx, name, version);
|
|
356
|
+
},
|
|
357
|
+
setTarget2(cx, target) {
|
|
358
|
+
setTarget2(cx, target, version);
|
|
359
|
+
},
|
|
360
|
+
getProperty: (cx, index, path) => getProperty(cx, index, path, version),
|
|
361
|
+
setProperty(cx, value, index, path) {
|
|
362
|
+
setProperty(cx, value, index, path, version);
|
|
363
|
+
},
|
|
364
|
+
gotoFrame,
|
|
365
|
+
gotoLabel,
|
|
366
|
+
gotoFrame2(cx, frame, play, bias) {
|
|
367
|
+
gotoFrame2(cx, frame, play, bias, version);
|
|
368
|
+
},
|
|
369
|
+
nextFrame,
|
|
370
|
+
prevFrame,
|
|
371
|
+
frameLoaded: (_, frame) => frameLoaded(frame),
|
|
372
|
+
frameLoaded2: (_, frame) => frameLoaded2(frame, version),
|
|
373
|
+
targetPath: (_, value) => targetPathOf(value),
|
|
374
|
+
callFrame(cx, frame) {
|
|
375
|
+
callFrame(cx, frame, version);
|
|
376
|
+
returnIfRemoved(cx);
|
|
377
|
+
},
|
|
378
|
+
stopSounds(cx) {
|
|
379
|
+
cx.host.stopSounds?.();
|
|
380
|
+
},
|
|
381
|
+
toggleQuality(cx) {
|
|
382
|
+
cx.host.toggleQuality?.();
|
|
383
|
+
},
|
|
384
|
+
getTime: (cx) => cx.host.time?.() ?? 0,
|
|
385
|
+
cloneSprite(cx, depth, name, source) {
|
|
386
|
+
cloneSprite(cx, depth, name, source, version);
|
|
387
|
+
},
|
|
388
|
+
removeSprite(cx, target) {
|
|
389
|
+
removeSprite(cx, target, version);
|
|
390
|
+
},
|
|
391
|
+
startDrag(cx) {
|
|
392
|
+
startDrag(cx, version);
|
|
393
|
+
},
|
|
394
|
+
stopDrag(cx) {
|
|
395
|
+
cx.host.stopDrag?.();
|
|
396
|
+
},
|
|
397
|
+
getUrl,
|
|
398
|
+
getUrl2(cx, target, url, flags) {
|
|
399
|
+
getUrl2(cx, target, url, flags, version);
|
|
400
|
+
},
|
|
401
|
+
budget: BUDGET,
|
|
402
|
+
timeout(cx) {
|
|
403
|
+
this.budget = BUDGET;
|
|
404
|
+
cx.realm.timeout();
|
|
405
|
+
},
|
|
406
|
+
far(cx, at, end, bound, five) {
|
|
407
|
+
const code = cx.code;
|
|
408
|
+
const units = cx.realm.units.get(code);
|
|
409
|
+
if (units === undefined) {
|
|
410
|
+
throw new Error("swf2es: AVM1 code whose SWF has no units");
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
for (;;) {
|
|
414
|
+
// Each unit may be where a loop goes round.
|
|
415
|
+
if (--this.budget < 0) {
|
|
416
|
+
this.timeout(cx);
|
|
417
|
+
}
|
|
418
|
+
const unit = units.unit(at, end, bound, five);
|
|
419
|
+
cx.code = unit;
|
|
420
|
+
const next = unit[0](cx);
|
|
421
|
+
if (next < 0) {
|
|
422
|
+
return next === -2 ? cx.ret : undefined;
|
|
423
|
+
}
|
|
424
|
+
if (next >= end) {
|
|
425
|
+
return undefined;
|
|
426
|
+
}
|
|
427
|
+
at = next;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
finally {
|
|
431
|
+
cx.code = code;
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
halt(cx) {
|
|
435
|
+
cx.host.halt();
|
|
436
|
+
throw new Halt("the SWF stopped at an action Flash cannot read");
|
|
437
|
+
},
|
|
438
|
+
tooLarge() {
|
|
439
|
+
throw new Error("an AVM1 block too large to compile");
|
|
440
|
+
},
|
|
441
|
+
notYet(name) {
|
|
442
|
+
throw new NotYet(name);
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* CallMethod, which pops its operands and pushes what the method gives:
|
|
448
|
+
* false where there was no object to call it on.
|
|
449
|
+
*/
|
|
450
|
+
function callMethod(cx, version) {
|
|
451
|
+
const st = cx.st;
|
|
452
|
+
const name = st.pop();
|
|
453
|
+
const object = live(st.pop());
|
|
454
|
+
const args = popArgs(st, version);
|
|
455
|
+
if (object === undefined || object === null) {
|
|
456
|
+
st.push(undefined);
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
const key = name === undefined ? "" : nameOf(name, version);
|
|
460
|
+
if (object instanceof Avm1Super) {
|
|
461
|
+
st.push(superCall(object, key, args, version));
|
|
462
|
+
}
|
|
463
|
+
else if (key === "") {
|
|
464
|
+
st.push(invoke(object, undefined, args, version));
|
|
465
|
+
}
|
|
466
|
+
else if (!(object instanceof Avm1Object)) {
|
|
467
|
+
const method = cx.realm.primitiveMember(object, key, version);
|
|
468
|
+
st.push(invoke(method, object, args, version, 1));
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
// A method found on the object itself is called as if found on its
|
|
472
|
+
// prototype; up to SWF 6 wherever it was found (adl).
|
|
473
|
+
const method = get(object, key, version);
|
|
474
|
+
st.push(invoke(method, object, args, version, version < 7 ? 1 : Math.max(foundDepth, 1)));
|
|
475
|
+
if (method instanceof ScriptFunction) {
|
|
476
|
+
cx.host.returned?.();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
/** NewMethod: `new object[name](args)`, `new object(args)` for an empty name; false for no object. */
|
|
482
|
+
function newMethod(cx, version) {
|
|
483
|
+
const st = cx.st;
|
|
484
|
+
const name = st.pop();
|
|
485
|
+
const object = st.pop();
|
|
486
|
+
const args = popArgs(st, version);
|
|
487
|
+
if (object === undefined || object === null) {
|
|
488
|
+
st.push(undefined);
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
const key = name === undefined ? "" : nameOf(name, version);
|
|
492
|
+
const boxed = cx.realm.box(object, version);
|
|
493
|
+
const constr = key === "" ? boxed : get(boxed, key, version);
|
|
494
|
+
st.push(cx.realm.construct(constr, args, version));
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* After a call: where it removed the clip whose code made it, that code
|
|
499
|
+
* returns, as Flash's does. The clip is looked at only where a clip was
|
|
500
|
+
* removed since the code last looked.
|
|
501
|
+
*/
|
|
502
|
+
function returnIfRemoved(cx) {
|
|
503
|
+
const removals = cx.realm.removals;
|
|
504
|
+
if (removals !== cx.removals) {
|
|
505
|
+
cx.removals = removals;
|
|
506
|
+
if (cx.host.removed?.(cx.base)) {
|
|
507
|
+
throw BASE_REMOVED;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/** A value as a reference reaches it now: a clip's AVM1 object the one at its path, undefined for none. */
|
|
512
|
+
function live(value) {
|
|
513
|
+
if (value instanceof Avm1Object && value.display !== null) {
|
|
514
|
+
return value.display.live() ?? undefined;
|
|
515
|
+
}
|
|
516
|
+
return value;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Whether one of two SWF 5 strings is empty and the other starts with a
|
|
520
|
+
* byte from 0x80: adl's StringLess has neither less than the other, and
|
|
521
|
+
* its StringGreater each greater.
|
|
522
|
+
*/
|
|
523
|
+
function againstHighByte(x, y) {
|
|
524
|
+
return (x === "" && y.charCodeAt(0) >= 0x80) || (y === "" && x.charCodeAt(0) >= 0x80);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* A division by zero from SWF 5, whose sign the zero does not change, as
|
|
528
|
+
* adl divides: 1 / -0 is Infinity.
|
|
529
|
+
*/
|
|
530
|
+
function divideByZero(n) {
|
|
531
|
+
if (n > 0) {
|
|
532
|
+
return Number.POSITIVE_INFINITY;
|
|
533
|
+
}
|
|
534
|
+
return n < 0 ? Number.NEGATIVE_INFINITY : Number.NaN;
|
|
535
|
+
}
|
|
536
|
+
/** Text that is the same as bytes and as UTF-8, as most is. */
|
|
537
|
+
const ascii = /^[ -~\t\n\r]*$/;
|
|
538
|
+
const encoder = new TextEncoder();
|
|
539
|
+
const decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
540
|
+
/**
|
|
541
|
+
* A SWF 5 string, its bytes, as Flash's log writes it: read as UTF-8, what
|
|
542
|
+
* is not UTF-8 as U+FFFD, as the encoding standard's decoder has it (adl's
|
|
543
|
+
* replacements agree). A character past a byte, from code of a later
|
|
544
|
+
* version, is its UTF-8.
|
|
545
|
+
*/
|
|
546
|
+
function bytesAsUtf8(text) {
|
|
547
|
+
if (ascii.test(text)) {
|
|
548
|
+
return text;
|
|
549
|
+
}
|
|
550
|
+
const bytes = [];
|
|
551
|
+
for (const c of text) {
|
|
552
|
+
const code = c.codePointAt(0);
|
|
553
|
+
if (code <= 0xff) {
|
|
554
|
+
bytes.push(code);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
bytes.push(...encoder.encode(c));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return decoder.decode(new Uint8Array(bytes));
|
|
561
|
+
}
|
|
562
|
+
/** InitObject's and InitArray's count: truncated, then -1 where it is not an int from 0 (adl). */
|
|
563
|
+
function countOf(value, version) {
|
|
564
|
+
const n = Math.trunc(toNumber(value, version));
|
|
565
|
+
return n >= 0 && n <= 0x7fffffff ? n : -1;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* A call's arguments, their count on top and the first argument under it:
|
|
569
|
+
* as many as the stack has, the count taken as a u32.
|
|
570
|
+
*/
|
|
571
|
+
function popArgs(st, version) {
|
|
572
|
+
const n = Math.min(toNumber(st.pop(), version) >>> 0, st.length);
|
|
573
|
+
const args = new Array(n);
|
|
574
|
+
for (let i = 0; i < n; i++) {
|
|
575
|
+
args[i] = st.pop();
|
|
576
|
+
}
|
|
577
|
+
return args;
|
|
578
|
+
}
|
|
579
|
+
function defineFunction(cx, region, name, params, flags, version) {
|
|
580
|
+
const fn = cx.realm.newFunction(cx, cx.code[region], params, flags, version);
|
|
581
|
+
const key = nameOf(name, version);
|
|
582
|
+
if (key === "") {
|
|
583
|
+
cx.st.push(fn);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
// A SWF 5 function's named function is its clip's, not a local variable (adl).
|
|
587
|
+
if (version < 6 && cx.callee !== null) {
|
|
588
|
+
let s = cx.scope;
|
|
589
|
+
while (s !== null && s.kind !== SCOPE_Target) {
|
|
590
|
+
s = s.parent;
|
|
591
|
+
}
|
|
592
|
+
if (s !== null) {
|
|
593
|
+
set(s.object, key, fn, version);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
defineLocal(cx, key, fn, version);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* CallMethod of `super`: `super()` its prototype's `__constructor__` on
|
|
601
|
+
* `this`, `super.name()` the method above the one running, with its `this`.
|
|
602
|
+
*/
|
|
603
|
+
function superCall(zuper, key, args, version) {
|
|
604
|
+
if (key === "") {
|
|
605
|
+
let base = zuper.self;
|
|
606
|
+
for (let i = 0; i < zuper.depth && base instanceof Avm1Object; i++) {
|
|
607
|
+
base = base.protoFor(version);
|
|
608
|
+
}
|
|
609
|
+
if (!(base instanceof Avm1Object)) {
|
|
610
|
+
return undefined;
|
|
611
|
+
}
|
|
612
|
+
const constr = get(base, "__constructor__", version, base, false);
|
|
613
|
+
if (constr instanceof Avm1Function) {
|
|
614
|
+
return constr.callConstructor(zuper.self, args, version, zuper.depth + 1);
|
|
615
|
+
}
|
|
616
|
+
return undefined;
|
|
617
|
+
}
|
|
618
|
+
const proto = zuper.proto;
|
|
619
|
+
if (!(proto instanceof Avm1Object)) {
|
|
620
|
+
return undefined;
|
|
621
|
+
}
|
|
622
|
+
const method = get(proto, key, version, zuper.self);
|
|
623
|
+
// Up to SWF 6 the method's `super` is one above this one's, wherever it was found (adl).
|
|
624
|
+
const depth = zuper.depth + (version < 7 ? 0 : foundDepth) + 1;
|
|
625
|
+
return invoke(method, zuper.self, args, version, depth);
|
|
626
|
+
}
|
|
627
|
+
/** Enumerate's and Enumerate2's pushes: a terminator, then the names, the first to visit on top. */
|
|
628
|
+
function enumerate(cx, object, version) {
|
|
629
|
+
const st = cx.st;
|
|
630
|
+
st.push(undefined);
|
|
631
|
+
if (object instanceof Avm1Object) {
|
|
632
|
+
const names = keys(object, version);
|
|
633
|
+
for (let i = names.length - 1; i >= 0; i--) {
|
|
634
|
+
st.push(names[i]);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Whether `error` is the engine's own stack running out: V8's and
|
|
640
|
+
* JavaScriptCore's RangeError, SpiderMonkey's InternalError. Any other
|
|
641
|
+
* RangeError, such as a string grown past the engine's longest, is an
|
|
642
|
+
* error like the rest.
|
|
643
|
+
*/
|
|
644
|
+
function stackOverflow(error) {
|
|
645
|
+
return (error instanceof Error &&
|
|
646
|
+
(error.name === "RangeError" || error.name === "InternalError") &&
|
|
647
|
+
/call stack|recursion/i.test(error.message));
|
|
648
|
+
}
|
|
649
|
+
/** Units of a region alone, by the numbers V.far is called with. */
|
|
650
|
+
export class OwnUnits {
|
|
651
|
+
byEnd = new Map();
|
|
652
|
+
get(at, end, bound, five) {
|
|
653
|
+
return this.byEnd
|
|
654
|
+
.get(end)
|
|
655
|
+
?.get(bound)
|
|
656
|
+
?.get(at * 2 + (five ? 1 : 0));
|
|
657
|
+
}
|
|
658
|
+
set(at, end, bound, five, unit) {
|
|
659
|
+
let byBound = this.byEnd.get(end);
|
|
660
|
+
if (byBound === undefined) {
|
|
661
|
+
byBound = new Map();
|
|
662
|
+
this.byEnd.set(end, byBound);
|
|
663
|
+
}
|
|
664
|
+
let byAt = byBound.get(bound);
|
|
665
|
+
if (byAt === undefined) {
|
|
666
|
+
byAt = new Map();
|
|
667
|
+
byBound.set(bound, byAt);
|
|
668
|
+
}
|
|
669
|
+
byAt.set(at * 2 + (five ? 1 : 0), unit);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
/** The operations of each version asked for, made once and shared by every runtime. */
|
|
673
|
+
const versions = new Map();
|
|
674
|
+
/** A player's AVM1 runtime, which its SWFs' modules are loaded into. */
|
|
675
|
+
export class Runtime {
|
|
676
|
+
/** The builtins and `_global`, which every SWF the player runs shares. */
|
|
677
|
+
realm = new Realm();
|
|
678
|
+
/**
|
|
679
|
+
* Whether the movie's actions are disabled, as Flash disables them past
|
|
680
|
+
* its recursion limit: no action of it runs again, its timelines play on.
|
|
681
|
+
*/
|
|
682
|
+
disabled = false;
|
|
683
|
+
/** Whether that was the script timeout's doing. */
|
|
684
|
+
timedOut = false;
|
|
685
|
+
/** How deep function calls may go: a SWF's ScriptLimits sets it (Flash's default 1000, adl's). */
|
|
686
|
+
get maxRecursion() {
|
|
687
|
+
return this.realm.maxCalls;
|
|
688
|
+
}
|
|
689
|
+
set maxRecursion(depth) {
|
|
690
|
+
this.realm.maxCalls = depth;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* How long, in seconds, a frame's actions may run before Flash offers to
|
|
694
|
+
* stop them: a SWF's ScriptLimits sets it (Flash's default 15). Past
|
|
695
|
+
* it, the movie's actions are disabled, as Flash's are once stopped.
|
|
696
|
+
*/
|
|
697
|
+
get scriptTimeout() {
|
|
698
|
+
return this.timeout;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Set while scripts run, as a ScriptLimits their gotos reach is, it
|
|
702
|
+
* counts from when they began, not from now: gotos that enter its
|
|
703
|
+
* frame again and again still run into it.
|
|
704
|
+
*/
|
|
705
|
+
set scriptTimeout(seconds) {
|
|
706
|
+
this.timeout = seconds;
|
|
707
|
+
if (this.realm.deadline !== Number.POSITIVE_INFINITY) {
|
|
708
|
+
this.realm.deadline = this.began + seconds * 1000;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
timeout = 15;
|
|
712
|
+
/** When the scripts running began, on the player's clock. */
|
|
713
|
+
began = 0;
|
|
714
|
+
/**
|
|
715
|
+
* The player starts running scripts, a frame's or its timers', at `now`
|
|
716
|
+
* on its clock, `clock`: they have the script timeout from there.
|
|
717
|
+
*/
|
|
718
|
+
begin(now, clock) {
|
|
719
|
+
this.began = now;
|
|
720
|
+
this.realm.clock = clock;
|
|
721
|
+
this.realm.deadline = now + this.timeout * 1000;
|
|
722
|
+
}
|
|
723
|
+
/** The player's scripts are done until it begins again. */
|
|
724
|
+
end() {
|
|
725
|
+
this.realm.deadline = Number.POSITIVE_INFINITY;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* A module's blocks, as its default export gave them, and the units its
|
|
729
|
+
* `units` export gave, if it has them: V.far finds their units there.
|
|
730
|
+
*/
|
|
731
|
+
adoptUnits(blocks, table) {
|
|
732
|
+
// By numbers, as V.far asks, not by the keys' text.
|
|
733
|
+
const first = new Map();
|
|
734
|
+
const own = new OwnUnits();
|
|
735
|
+
const known = this.realm.units;
|
|
736
|
+
for (const key in table) {
|
|
737
|
+
const entry = table[key];
|
|
738
|
+
const [at, a, b, c] = key.split(",").map(Number);
|
|
739
|
+
if (b === undefined) {
|
|
740
|
+
first.set(at * 2 + a, entry);
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
own.set(at, a, b, c !== 0, entry[0]);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const units = {
|
|
747
|
+
blocks,
|
|
748
|
+
unit(at, end, bound, five) {
|
|
749
|
+
const entry = first.get(at * 2 + (five ? 1 : 0));
|
|
750
|
+
if (entry !== undefined && entry[1] >= 0 && entry[1] <= end && entry[2] <= bound) {
|
|
751
|
+
return entry[0];
|
|
752
|
+
}
|
|
753
|
+
const regions = own.get(at, end, bound, five);
|
|
754
|
+
if (regions === undefined) {
|
|
755
|
+
throw new Error(`swf2es: no AVM1 unit at ${at}`);
|
|
756
|
+
}
|
|
757
|
+
return regions;
|
|
758
|
+
},
|
|
759
|
+
};
|
|
760
|
+
for (const regions of blocks) {
|
|
761
|
+
known.set(regions, units);
|
|
762
|
+
}
|
|
763
|
+
for (const key in table) {
|
|
764
|
+
known.set(table[key][0], units);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Run a block's own region, `regions[0]`, in `cx`. A value thrown and
|
|
769
|
+
* not caught ends the block, as Flash ends it, writing nothing. Past the
|
|
770
|
+
* recursion limit or the script timeout, or where JavaScript's own stack
|
|
771
|
+
* runs out first, the movie's actions are disabled from there.
|
|
772
|
+
*/
|
|
773
|
+
run(regions, cx) {
|
|
774
|
+
if (regions.length === 0) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
cx.code = regions;
|
|
778
|
+
this.call(cx, () => regions[0](cx));
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Run `body` in `cx`, as a block runs: what the player calls into AVM1
|
|
782
|
+
* other than a block, an event's method, a class's constructor, a
|
|
783
|
+
* timer's callback, which the limits and an uncaught throw end alike.
|
|
784
|
+
*/
|
|
785
|
+
call(cx, body) {
|
|
786
|
+
if (this.disabled) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
// The block is a level of the limit itself: a depth of 1 or 0 runs nothing (adl).
|
|
790
|
+
const realm = this.realm;
|
|
791
|
+
if (realm.maxCalls <= 1) {
|
|
792
|
+
this.disabled = true;
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
const outer = realm.current;
|
|
796
|
+
const calls = realm.calls;
|
|
797
|
+
realm.current = cx;
|
|
798
|
+
try {
|
|
799
|
+
body();
|
|
800
|
+
}
|
|
801
|
+
catch (error) {
|
|
802
|
+
if (error instanceof Avm1Throw || error === BASE_REMOVED) {
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
if (!(error instanceof Disabled || stackOverflow(error))) {
|
|
806
|
+
throw error;
|
|
807
|
+
}
|
|
808
|
+
this.disabled = true;
|
|
809
|
+
this.timedOut ||= error instanceof TimedOut;
|
|
810
|
+
}
|
|
811
|
+
finally {
|
|
812
|
+
realm.current = outer;
|
|
813
|
+
realm.calls = calls;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* `object`'s method `name` called with `args`, as Flash calls an event's
|
|
818
|
+
* (`onEnterFrame`...) and a timer's: found without `__resolve`, nothing
|
|
819
|
+
* where it is no function.
|
|
820
|
+
*/
|
|
821
|
+
callMethod(cx, object, name, args, version) {
|
|
822
|
+
this.call(cx, () => {
|
|
823
|
+
const method = get(object, name, version, object, false);
|
|
824
|
+
invoke(method, object, args, version, Math.max(foundDepth, 1));
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Fire the timers due by `time` on the player's clock, the earliest
|
|
829
|
+
* first, at most `MAX_TICKS` of them, each in the activation `cx` gives
|
|
830
|
+
* (the root's), `after` running what each queued; while one runs, the
|
|
831
|
+
* clock reads its time.
|
|
832
|
+
*/
|
|
833
|
+
fireTimers(time, version, cx, after, removed) {
|
|
834
|
+
const timers = this.realm.timers;
|
|
835
|
+
for (let ticks = 0; ticks < MAX_TICKS && !this.disabled; ticks++) {
|
|
836
|
+
const timer = timers.due(time);
|
|
837
|
+
if (timer === null) {
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
timers.now = timer.due;
|
|
841
|
+
timers.fired(timer);
|
|
842
|
+
// A method's object a removed clip: the timer stops, as Ruffle has it.
|
|
843
|
+
if (timer.method !== null && removed(timer.callback)) {
|
|
844
|
+
timers.remove(timer.id);
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
const activation = cx();
|
|
848
|
+
if (activation !== null) {
|
|
849
|
+
if (timer.method === null) {
|
|
850
|
+
this.call(activation, () => {
|
|
851
|
+
invoke(timer.callback, undefined, timer.args, version);
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
this.callMethod(activation, timer.callback, timer.method, timer.args, version);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
after();
|
|
859
|
+
}
|
|
860
|
+
timers.now = time;
|
|
861
|
+
}
|
|
862
|
+
/** A new object, as `{}` makes one: what the player gives a clip until clips have their class. */
|
|
863
|
+
newObject() {
|
|
864
|
+
return new Avm1Object(this.realm.objectProto);
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* An activation of a timeline's code: `clip`, the target's AVM1 object,
|
|
868
|
+
* above `_global` on the scope chain, and `this`.
|
|
869
|
+
*/
|
|
870
|
+
activation(st, pool, target, clip, host) {
|
|
871
|
+
return new Activation(st, pool, target, host, this.realm, new Scope(this.realm.globalScope, SCOPE_Target, clip), clip, clip);
|
|
872
|
+
}
|
|
873
|
+
/** The operations of SWF version `version`. */
|
|
874
|
+
version(version) {
|
|
875
|
+
let ops = versions.get(version);
|
|
876
|
+
if (!ops) {
|
|
877
|
+
ops = operations(version);
|
|
878
|
+
versions.set(version, ops);
|
|
879
|
+
}
|
|
880
|
+
return ops;
|
|
881
|
+
}
|
|
882
|
+
}
|