@swf2es/player-hosts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,334 @@
|
|
|
1
|
+
import { PRIMITIVE } from "./inheritance.js";
|
|
2
|
+
import { Avm1Object } from "./objects.js";
|
|
3
|
+
import { toInt32 } from "./operators.js";
|
|
4
|
+
import { SCOPE_Target, Scope, stoppedAtPrimitive, targetPath } from "./scope.js";
|
|
5
|
+
import { stringOf, toBoolean, toNumber } from "./values.js";
|
|
6
|
+
/** The target, or where SetTarget found none, the root: where GotoFrame2 and a function's `this` go. */
|
|
7
|
+
export function targetOrRoot(cx) {
|
|
8
|
+
if (cx.target !== null) {
|
|
9
|
+
return cx.target;
|
|
10
|
+
}
|
|
11
|
+
const root = cx.host.root?.(cx.base);
|
|
12
|
+
return (root instanceof Avm1Object ? cx.host.clipOf?.(root) : undefined) ?? cx.base;
|
|
13
|
+
}
|
|
14
|
+
/** The target's timeline, where it is a clip. */
|
|
15
|
+
const timelineOf = (cx, target) => target === null ? null : (cx.host.timeline?.(target) ?? null);
|
|
16
|
+
/** `scope` with its timeline's scope, a clip's, now `object`'s, as tellTarget makes it. */
|
|
17
|
+
function retarget(scope, object) {
|
|
18
|
+
if (scope.kind === SCOPE_Target) {
|
|
19
|
+
return new Scope(scope.parent, SCOPE_Target, object, scope.depth);
|
|
20
|
+
}
|
|
21
|
+
return scope.parent === null
|
|
22
|
+
? scope
|
|
23
|
+
: new Scope(retarget(scope.parent, object), scope.kind, scope.object, scope.depth);
|
|
24
|
+
}
|
|
25
|
+
/** The target `target` from here on: names resolve on its clip, or the root's where there is none. */
|
|
26
|
+
function setTargetClip(cx, target) {
|
|
27
|
+
cx.target = target !== null && cx.host.removed?.(target) ? null : target;
|
|
28
|
+
const clip = cx.host.objectOf?.(targetOrRoot(cx));
|
|
29
|
+
if (clip !== undefined) {
|
|
30
|
+
cx.clip = clip;
|
|
31
|
+
cx.scope = retarget(cx.scope, clip);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** The display object a path from `start`'s AVM1 object names, null for none or no display object. */
|
|
35
|
+
export function pathTarget(cx, start, path, version) {
|
|
36
|
+
const from = cx.host.objectOf?.(start);
|
|
37
|
+
if (from === undefined) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const object = targetPath(cx, from, path, true, false, version);
|
|
41
|
+
if (object === null && stoppedAtPrimitive && version >= 5) {
|
|
42
|
+
cx.host.trace(PRIMITIVE);
|
|
43
|
+
}
|
|
44
|
+
return object === null ? null : (cx.host.clipOf?.(object) ?? null);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* SetTarget: the clip `path` names from the code's own clip, that clip
|
|
48
|
+
* for "", none where it names none or the code's clip is gone.
|
|
49
|
+
*/
|
|
50
|
+
export function setTarget(cx, path, version) {
|
|
51
|
+
if (path === "") {
|
|
52
|
+
setTargetClip(cx, cx.base);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const removed = cx.host.removed?.(cx.base) ?? false;
|
|
56
|
+
setTargetClip(cx, removed ? null : pathTarget(cx, cx.base, path, version));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* SetTarget2: as SetTarget of the value as a string, but undefined is the
|
|
60
|
+
* code's own clip up to SWF 6 and none from 7; nothing where that clip is
|
|
61
|
+
* gone.
|
|
62
|
+
*/
|
|
63
|
+
export function setTarget2(cx, value, version) {
|
|
64
|
+
if (cx.host.removed?.(cx.base)) {
|
|
65
|
+
cx.target = null;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (value === undefined) {
|
|
69
|
+
if (version > 6) {
|
|
70
|
+
cx.target = null;
|
|
71
|
+
const clip = cx.host.objectOf?.(cx.base);
|
|
72
|
+
if (clip !== undefined) {
|
|
73
|
+
cx.clip = cx.host.objectOf?.(targetOrRoot(cx)) ?? clip;
|
|
74
|
+
cx.scope = retarget(cx.scope, clip);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
setTargetClip(cx, cx.base);
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setTarget(cx, stringOf(value, version), version);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The display object a GetProperty or SetProperty names: a clip's AVM1
|
|
86
|
+
* object itself, else the path it converts to, from `start`; the empty
|
|
87
|
+
* path is `start` where `empty`, else none.
|
|
88
|
+
*/
|
|
89
|
+
function displayOf(cx, start, value, empty, version) {
|
|
90
|
+
if (value instanceof Avm1Object && value.display !== null) {
|
|
91
|
+
return value.display.target;
|
|
92
|
+
}
|
|
93
|
+
const path = stringOf(value, version);
|
|
94
|
+
if (!empty && path === "") {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return pathTarget(cx, start, path, version);
|
|
98
|
+
}
|
|
99
|
+
/** What GetProperty and SetProperty act on: from the target, or from the code's clip where there is none. */
|
|
100
|
+
const propertyTarget = (cx, path, version) => cx.target !== null
|
|
101
|
+
? displayOf(cx, cx.target, path, true, version)
|
|
102
|
+
: displayOf(cx, cx.base, path, false, version);
|
|
103
|
+
/** A property's index: the number truncated, none for NaN, an infinity or -1 and below. */
|
|
104
|
+
function indexOf(index, version) {
|
|
105
|
+
const n = toNumber(index, version);
|
|
106
|
+
return Number.isFinite(n) && n > -1 ? Math.trunc(n) : -1;
|
|
107
|
+
}
|
|
108
|
+
/** GetProperty: property `index` of the clip `path` names, undefined for none. */
|
|
109
|
+
export function getProperty(cx, index, path, version) {
|
|
110
|
+
const i = indexOf(index, version);
|
|
111
|
+
const target = propertyTarget(cx, path, version);
|
|
112
|
+
if (target === null || i < 0) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return cx.host.objectOf?.(target).display?.property(i, version);
|
|
116
|
+
}
|
|
117
|
+
/** SetProperty: property `index` of the clip `path` names set to `value`. */
|
|
118
|
+
export function setProperty(cx, value, index, path, version) {
|
|
119
|
+
const i = indexOf(index, version);
|
|
120
|
+
const target = propertyTarget(cx, path, version);
|
|
121
|
+
if (target === null) {
|
|
122
|
+
// The value is converted all the same (Ruffle's action_property_coerce).
|
|
123
|
+
coerceFor(i, value, version);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (i >= 0) {
|
|
127
|
+
cx.host.objectOf?.(target).display?.setProperty(i, value, version);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* What a property's set converts its value to before it finds the target
|
|
132
|
+
* read-only or missing: a number for 0 to 12 but `_target` (11), a string
|
|
133
|
+
* for `_name` and `_quality`, a number for the rest but `_focusrect`.
|
|
134
|
+
*/
|
|
135
|
+
function coerceFor(index, value, version) {
|
|
136
|
+
if (index < 0 || index === 11 || index === 14 || index === 15 || index === 17) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (index <= 12) {
|
|
140
|
+
if (value !== undefined && value !== null) {
|
|
141
|
+
toNumber(value, version);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (index === 13 || index === 19) {
|
|
145
|
+
stringOf(value, version);
|
|
146
|
+
}
|
|
147
|
+
else if (index <= 21) {
|
|
148
|
+
toNumber(value, version);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** GotoFrame: frame `frame` (0 the first) of the target, which stops. */
|
|
152
|
+
export function gotoFrame(cx, frame) {
|
|
153
|
+
timelineOf(cx, cx.target)?.goto(frame + 1, false);
|
|
154
|
+
}
|
|
155
|
+
/** GotoLabel: the frame of `label`, if the target has it, which stops. */
|
|
156
|
+
export function gotoLabel(cx, label) {
|
|
157
|
+
const timeline = timelineOf(cx, cx.target);
|
|
158
|
+
const frame = timeline?.labelFrame(label);
|
|
159
|
+
if (frame !== undefined) {
|
|
160
|
+
timeline?.goto(frame, false);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** GotoFrame2: as `goto` on the target, or the root where there is none, `bias` frames on. */
|
|
164
|
+
export function gotoFrame2(cx, frame, play, bias, version) {
|
|
165
|
+
const target = targetOrRoot(cx);
|
|
166
|
+
if (timelineOf(cx, target) !== null) {
|
|
167
|
+
goto(cx, target, frame, play, bias, version);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** A string as Rust reads an f64: digits with a sign, a point and an exponent, or inf and NaN; null for anything else. */
|
|
171
|
+
function parseNumber(s) {
|
|
172
|
+
if (/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(s)) {
|
|
173
|
+
return Number(s);
|
|
174
|
+
}
|
|
175
|
+
if (/^[+-]?(inf|infinity)$/i.test(s)) {
|
|
176
|
+
return s.startsWith("-") ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
|
|
177
|
+
}
|
|
178
|
+
return /^[+-]?nan$/i.test(s) ? Number.NaN : null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The clip and the frame a goto's or CallFrame's value names from clip
|
|
182
|
+
* `start`: a whole number its frame; anything else as a string, a path to
|
|
183
|
+
* a clip and a frame, `/a/b:3` or `a.b.label`, the frame a number or a
|
|
184
|
+
* label; null where it names none.
|
|
185
|
+
*/
|
|
186
|
+
function frameOf(cx, start, value, version) {
|
|
187
|
+
if (typeof value === "number" && Number.isInteger(value)) {
|
|
188
|
+
return [start, toInt32(value, version)];
|
|
189
|
+
}
|
|
190
|
+
const path = stringOf(value, version);
|
|
191
|
+
let clip = start;
|
|
192
|
+
let frame = path;
|
|
193
|
+
const separator = Math.max(path.lastIndexOf(":"), path.lastIndexOf("."));
|
|
194
|
+
if (separator >= 0) {
|
|
195
|
+
clip = null;
|
|
196
|
+
for (let s = cx.scope; s !== null && clip === null; s = s.parent) {
|
|
197
|
+
const object = targetPath(cx, s.object, path.slice(0, separator), true, true, version);
|
|
198
|
+
if (object !== null) {
|
|
199
|
+
clip = cx.host.clipOf?.(object) ?? null;
|
|
200
|
+
// Not a clip: none, as Ruffle's resolve_variable_path finds an object first.
|
|
201
|
+
if (clip === null) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
frame = path.slice(separator + 1);
|
|
207
|
+
}
|
|
208
|
+
const timeline = clip === null ? null : timelineOf(cx, clip);
|
|
209
|
+
if (clip === null || timeline === null) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
const n = parseNumber(frame);
|
|
213
|
+
if (n !== null) {
|
|
214
|
+
return [clip, toInt32(n, version)];
|
|
215
|
+
}
|
|
216
|
+
const labelled = timeline.labelFrame(frame);
|
|
217
|
+
return labelled === undefined ? null : [clip, labelled];
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* A goto of `frame` on clip `target`, gotoAndPlay's and gotoAndStop's and
|
|
221
|
+
* GotoFrame2's: the frame `frameOf` names, `bias` frames on, if that is
|
|
222
|
+
* from 1; as a u16, where the timeline clamps it.
|
|
223
|
+
*/
|
|
224
|
+
export function goto(cx, target, frame, play, bias, version) {
|
|
225
|
+
const found = frameOf(cx, target, frame, version);
|
|
226
|
+
if (found === null) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const n = Math.min(((found[1] - 1) | 0) + bias + 1, 0x7fffffff);
|
|
230
|
+
if (n > 0) {
|
|
231
|
+
timelineOf(cx, found[0])?.goto(Math.max(1, n & 0xffff), play);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/** NextFrame: the target's next frame, if it has one, where it stops. */
|
|
235
|
+
export function nextFrame(cx) {
|
|
236
|
+
const timeline = timelineOf(cx, cx.target);
|
|
237
|
+
if (timeline !== null && timeline.currentFrame < timeline.totalFrames) {
|
|
238
|
+
timeline.goto(timeline.currentFrame + 1, false);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/** PrevFrame: the target's previous frame, if it has one, where it stops. */
|
|
242
|
+
export function prevFrame(cx) {
|
|
243
|
+
const timeline = timelineOf(cx, cx.target);
|
|
244
|
+
if (timeline !== null && timeline.currentFrame > 1) {
|
|
245
|
+
timeline.goto(timeline.currentFrame - 1, false);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* WaitForFrame: whether frame `frame` (0 the first) is loaded, which in a
|
|
250
|
+
* SWF the player has whole every frame is, up to Flash's 16000.
|
|
251
|
+
*/
|
|
252
|
+
export const frameLoaded = (frame) => frame <= 16000;
|
|
253
|
+
/** WaitForFrame2: as WaitForFrame of the value's frame, 1 the first, read as Ruffle reads it. */
|
|
254
|
+
export function frameLoaded2(value, version) {
|
|
255
|
+
let n = 0;
|
|
256
|
+
if (typeof value === "number" && Number.isInteger(value)) {
|
|
257
|
+
n = toInt32(value, version);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const parsed = parseNumber(stringOf(value, version));
|
|
261
|
+
n = parsed !== null && Number.isInteger(parsed) ? toInt32(parsed, version) : 0;
|
|
262
|
+
}
|
|
263
|
+
// Less one, wrapping, and one more, saturating.
|
|
264
|
+
const frame = Math.min(((n - 1) | 0) + 1, 0x7fffffff);
|
|
265
|
+
return frame <= 16001;
|
|
266
|
+
}
|
|
267
|
+
/** TargetPath: a clip's path, `_level0.a`, undefined for anything else. */
|
|
268
|
+
export function targetPathOf(value) {
|
|
269
|
+
if (!(value instanceof Avm1Object) || value.display === null) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
const live = value.display.live();
|
|
273
|
+
return live?.display?.path() ?? undefined;
|
|
274
|
+
}
|
|
275
|
+
/** CallFrame: the actions of the frame the value names, on the target or the root, run now. */
|
|
276
|
+
export function callFrame(cx, value, version) {
|
|
277
|
+
const target = targetOrRoot(cx);
|
|
278
|
+
const found = typeof value === "number"
|
|
279
|
+
? [target, toInt32(value, version) >>> 0]
|
|
280
|
+
: frameOf(cx, target, value, version);
|
|
281
|
+
if (found !== null && found[1] <= 0xffff) {
|
|
282
|
+
timelineOf(cx, found[0])?.call(found[1]);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* CloneSprite: the display object `source` names from the target, or the
|
|
287
|
+
* root's where there is none, duplicated as `name` at timeline depth
|
|
288
|
+
* `depth`, which compilers bias as duplicateMovieClip's own depth is.
|
|
289
|
+
*/
|
|
290
|
+
export function cloneSprite(cx, depth, name, source, version) {
|
|
291
|
+
const d = toInt32(depth, version);
|
|
292
|
+
const n = stringOf(name, version);
|
|
293
|
+
const target = displayOf(cx, targetOrRoot(cx), source, true, version);
|
|
294
|
+
if (target !== null) {
|
|
295
|
+
cx.host.duplicate?.(target, n, d);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* StartDrag, its operands on the stack: the target, whether to lock the
|
|
300
|
+
* centre, whether to constrain, and if so the bounds' right-to-left
|
|
301
|
+
* bottom, right, top and left. The display object the target names, from
|
|
302
|
+
* the code's target or the root, is dragged; an empty one is that target.
|
|
303
|
+
*/
|
|
304
|
+
export function startDrag(cx, version) {
|
|
305
|
+
const st = cx.st;
|
|
306
|
+
const value = st.pop();
|
|
307
|
+
const lockCenter = toBoolean(st.pop(), version);
|
|
308
|
+
let bounds = null;
|
|
309
|
+
if (toBoolean(st.pop(), version)) {
|
|
310
|
+
const bottom = toNumber(st.pop(), version);
|
|
311
|
+
const right = toNumber(st.pop(), version);
|
|
312
|
+
const top = toNumber(st.pop(), version);
|
|
313
|
+
const left = toNumber(st.pop(), version);
|
|
314
|
+
bounds = [left, top, right, bottom];
|
|
315
|
+
}
|
|
316
|
+
const target = displayOf(cx, targetOrRoot(cx), value, true, version);
|
|
317
|
+
if (target !== null) {
|
|
318
|
+
cx.host.startDrag?.(target, lockCenter, bounds);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* RemoveSprite: the display object `value` names from the target, or the
|
|
323
|
+
* root's, removed; a target it removes gives way to the code's own clip.
|
|
324
|
+
*/
|
|
325
|
+
export function removeSprite(cx, value, version) {
|
|
326
|
+
const target = displayOf(cx, targetOrRoot(cx), value, true, version);
|
|
327
|
+
if (target === null) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
cx.host.remove?.(target);
|
|
331
|
+
if (cx.target !== null && cx.host.removed?.(cx.target)) {
|
|
332
|
+
setTargetClip(cx, cx.base);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { Avm1Throw } from "./errors.js";
|
|
2
|
+
import { Avm1Object } from "./objects.js";
|
|
3
|
+
import { MAX_SCOPES, SCOPE_With, Scope } from "./scope.js";
|
|
4
|
+
/** A With's object, or a catch's variable, on the scope chain. */
|
|
5
|
+
const HELD_Scope = 0;
|
|
6
|
+
const HELD_Try = 1;
|
|
7
|
+
/** A finally reached by a throw: `value` is thrown again as control leaves it. */
|
|
8
|
+
const HELD_Thrown = 2;
|
|
9
|
+
/** A finally reached by a Return, whose value is on the stack: it returns as control leaves it. */
|
|
10
|
+
const HELD_Returned = 3;
|
|
11
|
+
/** A Try's catch that a throw does not land in. */
|
|
12
|
+
const NO_CATCH = -2;
|
|
13
|
+
export class Held {
|
|
14
|
+
kind;
|
|
15
|
+
from;
|
|
16
|
+
to;
|
|
17
|
+
value;
|
|
18
|
+
constructor(kind,
|
|
19
|
+
/** The blocks it holds over, from `from` to `to`, excluded. */
|
|
20
|
+
from, to,
|
|
21
|
+
/** A finally's thrown value. */
|
|
22
|
+
value = undefined) {
|
|
23
|
+
this.kind = kind;
|
|
24
|
+
this.from = from;
|
|
25
|
+
this.to = to;
|
|
26
|
+
this.value = value;
|
|
27
|
+
}
|
|
28
|
+
holds(block) {
|
|
29
|
+
return this.from <= block && block < this.to;
|
|
30
|
+
}
|
|
31
|
+
/** Whether a scope holds as control goes to `block`: one of its body's, or the first past it. */
|
|
32
|
+
admits(block) {
|
|
33
|
+
return this.from <= block && block <= this.to;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const isScope = (h) => h.kind === HELD_Scope;
|
|
37
|
+
/** A scope: the chain it made, and the chain under it, which it gives back as it comes off. */
|
|
38
|
+
class ScopeHeld extends Held {
|
|
39
|
+
chain;
|
|
40
|
+
below;
|
|
41
|
+
constructor(from, to, chain, below) {
|
|
42
|
+
super(HELD_Scope, from, to);
|
|
43
|
+
this.chain = chain;
|
|
44
|
+
this.below = below;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** A Try's handlers, held over its try and catch bodies. */
|
|
48
|
+
class TryHeld extends Held {
|
|
49
|
+
catchFrom;
|
|
50
|
+
finallyFrom;
|
|
51
|
+
finallyTo;
|
|
52
|
+
catchAt;
|
|
53
|
+
into;
|
|
54
|
+
height;
|
|
55
|
+
constructor(from,
|
|
56
|
+
/** Where the catch body starts: before it, a throw is the catch's. */
|
|
57
|
+
catchFrom,
|
|
58
|
+
/** The finally body's blocks, none where it has none. */
|
|
59
|
+
finallyFrom, finallyTo,
|
|
60
|
+
/** Where a throw lands for the catch, -1 for the region's exit, NO_CATCH for none. */
|
|
61
|
+
catchAt,
|
|
62
|
+
/** The catch's variable, or its register. */
|
|
63
|
+
into,
|
|
64
|
+
/** The operand stack's height as the Try ran, which a throw cuts it back to. */
|
|
65
|
+
height) {
|
|
66
|
+
super(HELD_Try, from, finallyFrom);
|
|
67
|
+
this.catchFrom = catchFrom;
|
|
68
|
+
this.finallyFrom = finallyFrom;
|
|
69
|
+
this.finallyTo = finallyTo;
|
|
70
|
+
this.catchAt = catchAt;
|
|
71
|
+
this.into = into;
|
|
72
|
+
this.height = height;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function heldOf(cx) {
|
|
76
|
+
let held = cx.held;
|
|
77
|
+
if (held === null) {
|
|
78
|
+
held = [];
|
|
79
|
+
cx.held = held;
|
|
80
|
+
}
|
|
81
|
+
return held;
|
|
82
|
+
}
|
|
83
|
+
/** `object` on top of the scope chain, held over the blocks from `from` to `to`. */
|
|
84
|
+
function pushScope(cx, object, from, to) {
|
|
85
|
+
const below = cx.scope;
|
|
86
|
+
cx.scope = new Scope(below, SCOPE_With, object);
|
|
87
|
+
heldOf(cx).push(new ScopeHeld(from, to, cx.scope, below));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Keeps of `held`, from index `from` up, the entries `keep` says, and the
|
|
91
|
+
* scope chain as the scopes kept make it: the top one's, or with none
|
|
92
|
+
* kept, the chain under the first one taken off.
|
|
93
|
+
*/
|
|
94
|
+
function keepFrom(cx, held, from, keep) {
|
|
95
|
+
let n = from;
|
|
96
|
+
let top = null;
|
|
97
|
+
let base = null;
|
|
98
|
+
for (let i = from; i < held.length; i++) {
|
|
99
|
+
const h = held[i];
|
|
100
|
+
if (keep(h)) {
|
|
101
|
+
held[n++] = h;
|
|
102
|
+
if (h instanceof ScopeHeld) {
|
|
103
|
+
top = h.chain;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (h instanceof ScopeHeld && base === null) {
|
|
107
|
+
base = h.below;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
held.length = n;
|
|
111
|
+
if (top !== null) {
|
|
112
|
+
cx.scope = top;
|
|
113
|
+
}
|
|
114
|
+
else if (base !== null) {
|
|
115
|
+
cx.scope = base;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Control going to the start of block `at`: the scopes on top that do not
|
|
120
|
+
* hold there come off at once, as adl looks only at the top one.
|
|
121
|
+
*/
|
|
122
|
+
function reach(cx, held, at) {
|
|
123
|
+
let n = held.length;
|
|
124
|
+
while (n > 0 && held[n - 1].kind === HELD_Scope && !held[n - 1].admits(at)) {
|
|
125
|
+
n--;
|
|
126
|
+
}
|
|
127
|
+
if (n < held.length) {
|
|
128
|
+
keepFrom(cx, held, n, () => false);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function cut(st, height) {
|
|
132
|
+
if (st.length > height) {
|
|
133
|
+
st.length = height;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* With: `value`, a primitive boxed, on the scope chain over the body's
|
|
138
|
+
* blocks; false, the body skipped, for undefined and null, and where the
|
|
139
|
+
* chain holds MAX_SCOPES already (adl).
|
|
140
|
+
*/
|
|
141
|
+
export function enterWith(cx, value, from, to, version) {
|
|
142
|
+
if (value === undefined || value === null || cx.scope.depth >= MAX_SCOPES) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
pushScope(cx, cx.realm.box(value, version), from, to);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
/** Try: its handlers, held over its try and catch bodies. */
|
|
149
|
+
export function enterTry(cx, from, catchFrom, finallyFrom, finallyTo, catchAt, into) {
|
|
150
|
+
heldOf(cx).push(new TryHeld(from, catchFrom, finallyFrom, finallyTo, catchAt, into, cx.st.length));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Where control goes from the block `at`, where `error` was thrown: the
|
|
154
|
+
* catch of the first Try whose try body holds it, its variable set, or the
|
|
155
|
+
* finally of the first whose try or catch body does, which throws the
|
|
156
|
+
* value again as control leaves it. The stack is cut back to its height
|
|
157
|
+
* as that Try ran. Another error, a bug's or the host's, a recursion
|
|
158
|
+
* limit's, passes through, as does a value no Try catches.
|
|
159
|
+
*/
|
|
160
|
+
export function caught(cx, error, at) {
|
|
161
|
+
const held = cx.held;
|
|
162
|
+
if (!(error instanceof Avm1Throw) || held === null) {
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
cx.into = -1;
|
|
166
|
+
for (let i = held.length - 1; i >= 0; i--) {
|
|
167
|
+
const h = held[i];
|
|
168
|
+
if (!(h instanceof TryHeld) || !h.holds(at)) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (at < h.catchFrom && h.catchAt !== NO_CATCH) {
|
|
172
|
+
// The scopes where it was thrown hold over the catch body too, under
|
|
173
|
+
// its variable's (adl).
|
|
174
|
+
const from = h.catchFrom;
|
|
175
|
+
const to = h.finallyFrom;
|
|
176
|
+
keepFrom(cx, held, i + 1, isScope);
|
|
177
|
+
for (let j = i + 1; j < held.length; j++) {
|
|
178
|
+
held[j].from = from;
|
|
179
|
+
held[j].to = to;
|
|
180
|
+
}
|
|
181
|
+
cut(cx.st, h.height);
|
|
182
|
+
const into = h.into;
|
|
183
|
+
if (typeof into === "number") {
|
|
184
|
+
cx.into = into;
|
|
185
|
+
cx.thrown = error.value;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const scope = new Avm1Object();
|
|
189
|
+
scope.add(into, error.value, 0);
|
|
190
|
+
pushScope(cx, scope, from, to);
|
|
191
|
+
}
|
|
192
|
+
return h.catchAt;
|
|
193
|
+
}
|
|
194
|
+
if (h.finallyFrom < h.finallyTo) {
|
|
195
|
+
// The finally's mark goes under the scopes, which come off as control goes there.
|
|
196
|
+
held[i] = new Held(HELD_Thrown, h.finallyFrom, h.finallyTo, error.value);
|
|
197
|
+
keepFrom(cx, held, i + 1, isScope);
|
|
198
|
+
cut(cx.st, h.height);
|
|
199
|
+
reach(cx, held, h.finallyFrom);
|
|
200
|
+
return h.finallyFrom;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Control going to block `to` (-1: the exit) across the bounds of a body:
|
|
207
|
+
* the Trys that do not hold over it come off, and a finally that a throw
|
|
208
|
+
* or a Return reached throws or returns as control leaves it, even by a
|
|
209
|
+
* jump. The scopes on top that do not hold there come off; those whose
|
|
210
|
+
* body it is the first block past, after its first action (V.scopes).
|
|
211
|
+
*/
|
|
212
|
+
export function leave(cx, to) {
|
|
213
|
+
const held = cx.held;
|
|
214
|
+
if (held !== null) {
|
|
215
|
+
for (let i = held.length - 1; i >= 0; i--) {
|
|
216
|
+
const h = held[i];
|
|
217
|
+
if (h.holds(to)) {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
if (h.kind === HELD_Scope) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
held.splice(i, 1);
|
|
224
|
+
if (h.kind === HELD_Thrown) {
|
|
225
|
+
throw new Avm1Throw(h.value);
|
|
226
|
+
}
|
|
227
|
+
if (h.kind === HELD_Returned) {
|
|
228
|
+
return returned(cx);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (to < 0) {
|
|
233
|
+
cx.ret = undefined;
|
|
234
|
+
}
|
|
235
|
+
else if (held !== null) {
|
|
236
|
+
reach(cx, held, to);
|
|
237
|
+
}
|
|
238
|
+
return to;
|
|
239
|
+
}
|
|
240
|
+
/** The scopes that do not hold over block `at`, where control is, come off. */
|
|
241
|
+
export function scopes(cx, at) {
|
|
242
|
+
const held = cx.held;
|
|
243
|
+
if (held === null) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
let n = held.length;
|
|
247
|
+
while (n > 0 && held[n - 1].kind === HELD_Scope && !held[n - 1].holds(at)) {
|
|
248
|
+
n--;
|
|
249
|
+
}
|
|
250
|
+
if (n < held.length) {
|
|
251
|
+
keepFrom(cx, held, n, () => false);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Return, its value on top of the stack: the finally of the first Try
|
|
256
|
+
* whose try or catch body holds control runs first, the stack cut back to
|
|
257
|
+
* its height as that Try ran with the value left on top, and the value is
|
|
258
|
+
* popped as control leaves it, the stack's top then (adl); a finally's own
|
|
259
|
+
* throw or Return gives way to this one.
|
|
260
|
+
*/
|
|
261
|
+
export function returned(cx) {
|
|
262
|
+
const held = cx.held;
|
|
263
|
+
if (held !== null) {
|
|
264
|
+
for (let i = held.length - 1; i >= 0; i--) {
|
|
265
|
+
const h = held[i];
|
|
266
|
+
if (h instanceof TryHeld && h.finallyFrom < h.finallyTo) {
|
|
267
|
+
const st = cx.st;
|
|
268
|
+
const value = st.pop();
|
|
269
|
+
cut(st, h.height);
|
|
270
|
+
st.push(value);
|
|
271
|
+
held[i] = new Held(HELD_Returned, h.finallyFrom, h.finallyTo);
|
|
272
|
+
keepFrom(cx, held, i + 1, isScope);
|
|
273
|
+
reach(cx, held, h.finallyFrom);
|
|
274
|
+
return h.finallyFrom;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
cx.ret = cx.st.pop();
|
|
279
|
+
return -1;
|
|
280
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** An action the runtime does not do yet: it ends the block it is in. */
|
|
2
|
+
export class NotYet extends Error {
|
|
3
|
+
name = "Avm1NotYet";
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Thrown once the host has stopped the SWF at an action Flash cannot read,
|
|
7
|
+
* to end whatever runs; the player takes it for no error.
|
|
8
|
+
*/
|
|
9
|
+
export class Halt extends Error {
|
|
10
|
+
name = "Avm1Halt";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown after a call, a `new` or a CallFrame that took the clip whose
|
|
14
|
+
* code runs off the display list: that code's activation returns there,
|
|
15
|
+
* a function's with undefined, and the code that called it goes on to its
|
|
16
|
+
* own check (adl; Ruffle's continue_if_base_clip_exists). One instance,
|
|
17
|
+
* thrown as a signal and never shown.
|
|
18
|
+
*/
|
|
19
|
+
export class BaseRemoved extends Error {
|
|
20
|
+
name = "Avm1BaseRemoved";
|
|
21
|
+
}
|
|
22
|
+
export const BASE_REMOVED = new BaseRemoved("the clip whose code runs was removed");
|
|
23
|
+
/**
|
|
24
|
+
* Thrown past Flash's recursion limit: Flash disables every action of the
|
|
25
|
+
* movie from there, and its timelines play on.
|
|
26
|
+
*/
|
|
27
|
+
export class Disabled extends Error {
|
|
28
|
+
name = "Avm1Disabled";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Thrown as scripts run past the script timeout, Flash's 15 seconds or a
|
|
32
|
+
* ScriptLimits tag's: Flash asks whether to stop them, and stopped, the
|
|
33
|
+
* movie's actions are disabled as past the recursion limit (Ruffle halts
|
|
34
|
+
* its AVM1 so too).
|
|
35
|
+
*/
|
|
36
|
+
export class TimedOut extends Disabled {
|
|
37
|
+
name = "Avm1TimedOut";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A value AVM1 code throws (Throw), which a Try's catch or finally takes
|
|
41
|
+
* and which, caught by none, ends the block as Flash ends it, silently.
|
|
42
|
+
*/
|
|
43
|
+
export class Avm1Throw extends Error {
|
|
44
|
+
value;
|
|
45
|
+
name = "Avm1Throw";
|
|
46
|
+
constructor(value) {
|
|
47
|
+
super("an AVM1 value thrown and not caught");
|
|
48
|
+
this.value = value;
|
|
49
|
+
}
|
|
50
|
+
}
|