@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,385 @@
|
|
|
1
|
+
import { PRIMITIVE } from "./inheritance.js";
|
|
2
|
+
import { find, fold, foundValue, get, has, Avm1Object as ObjectClass, removeOwn, set, } from "./objects.js";
|
|
3
|
+
/** `_global`, at the bottom of every chain. */
|
|
4
|
+
export const SCOPE_Global = 0;
|
|
5
|
+
/** A clip whose timeline's code runs: where a variable set without one is made. */
|
|
6
|
+
export const SCOPE_Target = 1;
|
|
7
|
+
/** A function's activation object. */
|
|
8
|
+
export const SCOPE_Local = 2;
|
|
9
|
+
/** A `with`'s object. */
|
|
10
|
+
export const SCOPE_With = 3;
|
|
11
|
+
/**
|
|
12
|
+
* How many scopes a chain may hold, `_global` included: a With that would
|
|
13
|
+
* make it longer skips its body, as adl does (docs/avm1.md, "With and Try").
|
|
14
|
+
*/
|
|
15
|
+
export const MAX_SCOPES = 15;
|
|
16
|
+
export class Scope {
|
|
17
|
+
parent;
|
|
18
|
+
kind;
|
|
19
|
+
object;
|
|
20
|
+
depth;
|
|
21
|
+
constructor(parent, kind, object,
|
|
22
|
+
/** How many scopes the chain holds, as adl counts them for MAX_SCOPES. */
|
|
23
|
+
depth = parent === null ? 1 : parent.depth + 1) {
|
|
24
|
+
this.parent = parent;
|
|
25
|
+
this.kind = kind;
|
|
26
|
+
this.object = object;
|
|
27
|
+
this.depth = depth;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Whether `c` ends a path's object part: `:`, and `.` from SWF 5. */
|
|
31
|
+
const separates = (c, version) => c === 0x3a || (c === 0x2e && version >= 5);
|
|
32
|
+
/** Where a name's last `:` or `.` is, the variable after it, -1 for a name without a path. */
|
|
33
|
+
function lastSeparator(name, version) {
|
|
34
|
+
for (let i = name.length - 1; i >= 0; i--) {
|
|
35
|
+
if (separates(name.charCodeAt(i), version)) {
|
|
36
|
+
return i;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
/** Whether `a` and `b` are the same name for a SWF of `version`. */
|
|
42
|
+
const sameName = (a, b, version) => a === b || (version <= 6 && fold(a) === fold(b));
|
|
43
|
+
/** Whether `name` is `this`: case-insensitively up to SWF 6, in a function too (adl; Ruffle has a SWF 5 function's case-sensitive). */
|
|
44
|
+
function isThis(name, version) {
|
|
45
|
+
if (name.length !== 4 || version < 5) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (name === "this") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return version < 7 && fold(name) === "this";
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `_root`, `_parent`, `_global` (from SWF 6) and `_levelN`: what a name
|
|
55
|
+
* the scope chain lacks may still be.
|
|
56
|
+
*/
|
|
57
|
+
function pathProperty(cx, name, version) {
|
|
58
|
+
if (version < 5 || name.length < 5 || name.charCodeAt(0) !== 0x5f) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
if (sameName(name, "_root", version)) {
|
|
62
|
+
return cx.host.root?.(cx.base);
|
|
63
|
+
}
|
|
64
|
+
if (sameName(name, "_parent", version)) {
|
|
65
|
+
return cx.host.parent?.(cx.scope.object);
|
|
66
|
+
}
|
|
67
|
+
if (version >= 6 && sameName(name, "_global", version)) {
|
|
68
|
+
return cx.global;
|
|
69
|
+
}
|
|
70
|
+
return level(cx, name, version);
|
|
71
|
+
}
|
|
72
|
+
/** Whether `name` starts `_level` or `_flash`, a level's name whatever follows. */
|
|
73
|
+
function isLevel(name, version) {
|
|
74
|
+
const prefix = name.slice(0, 6);
|
|
75
|
+
return sameName(prefix, "_level", version) || sameName(prefix, "_flash", version);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* `_levelN` or `_flashN`: level N, if the host has it. N is a sign and the
|
|
79
|
+
* digits up to anything else, wrapping, none 0, as Ruffle's parse_level
|
|
80
|
+
* reads it: `_level0:x` and `_levelx` are level 0.
|
|
81
|
+
*/
|
|
82
|
+
function level(cx, name, version) {
|
|
83
|
+
if (!isLevel(name, version)) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const negative = name.charCodeAt(6) === 0x2d;
|
|
87
|
+
let n = 0;
|
|
88
|
+
for (let i = negative ? 7 : 6; i < name.length; i++) {
|
|
89
|
+
const d = name.charCodeAt(i) - 0x30;
|
|
90
|
+
if (d < 0 || d > 9) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
n = (Math.imul(n, 10) + d) | 0;
|
|
94
|
+
}
|
|
95
|
+
return cx.host.level?.(negative ? -n | 0 : n);
|
|
96
|
+
}
|
|
97
|
+
/** A name without a path along the scope chain, as GetVariable and NewObject find it. */
|
|
98
|
+
export function resolve(cx, name, version) {
|
|
99
|
+
if (isThis(name, version)) {
|
|
100
|
+
return cx.self;
|
|
101
|
+
}
|
|
102
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
103
|
+
const p = find(s.object, name, version);
|
|
104
|
+
if (p !== undefined) {
|
|
105
|
+
// The first property found is what get finds too, where its version sees it.
|
|
106
|
+
return foundValue(p, s.object, name, version);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return pathProperty(cx, name, version);
|
|
110
|
+
}
|
|
111
|
+
/** What `resolveCallable` found a function on, for CallFunction's `this`. */
|
|
112
|
+
export let foundOn;
|
|
113
|
+
/** Whether that was a function's activation object. */
|
|
114
|
+
export let foundLocal = false;
|
|
115
|
+
/** As `resolve`, setting `foundOn` to the object that had the name, undefined for none. */
|
|
116
|
+
export function resolveCallable(cx, name, version) {
|
|
117
|
+
foundOn = undefined;
|
|
118
|
+
foundLocal = false;
|
|
119
|
+
const separator = lastSeparator(name, version);
|
|
120
|
+
if (separator >= 0 || (version >= 5 && name.includes("/"))) {
|
|
121
|
+
return getVariable(cx, name, version);
|
|
122
|
+
}
|
|
123
|
+
if (isThis(name, version)) {
|
|
124
|
+
return cx.self;
|
|
125
|
+
}
|
|
126
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
127
|
+
if (has(s.object, name, version)) {
|
|
128
|
+
const value = get(s.object, name, version);
|
|
129
|
+
foundOn = s.object;
|
|
130
|
+
foundLocal = s.kind === SCOPE_Local;
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return pathProperty(cx, name, version);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* GetVariable: a name, or a path to an object and a name on it, the path
|
|
138
|
+
* tried from each scope in turn; a path without a variable is the object
|
|
139
|
+
* it names, from SWF 5.
|
|
140
|
+
*/
|
|
141
|
+
export function getVariable(cx, name, version) {
|
|
142
|
+
const separator = lastSeparator(name, version);
|
|
143
|
+
if (separator >= 0) {
|
|
144
|
+
if (separator === 0) {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
const path = name.slice(0, separator);
|
|
148
|
+
const variable = name.slice(separator + 1);
|
|
149
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
150
|
+
const object = targetPath(cx, s.object, path, true, true, version);
|
|
151
|
+
if (object !== null && has(object, variable, version)) {
|
|
152
|
+
// After the getter, which may call functions of its own.
|
|
153
|
+
const value = get(object, variable, version);
|
|
154
|
+
foundOn = object;
|
|
155
|
+
return value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
if (version >= 5 && name.includes("/")) {
|
|
161
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
162
|
+
const object = targetPath(cx, s.object, name, false, false, version);
|
|
163
|
+
if (object !== null) {
|
|
164
|
+
return object;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return resolve(cx, name, version);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* SetVariable: a path's object takes the name, the first a scope resolves
|
|
172
|
+
* it to; a name without one is set where the scope chain has it, else on
|
|
173
|
+
* the target's clip. `this` from SWF 5 sets the activation's `this`.
|
|
174
|
+
*/
|
|
175
|
+
export function setVariable(cx, name, value, version) {
|
|
176
|
+
if (name === "") {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (isThis(name, version)) {
|
|
180
|
+
cx.self = value;
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
// A path's separators are `:` and `.` here in every version, and its
|
|
184
|
+
// `this` is no object in a timeline's code (adl sets nothing for `this.x`
|
|
185
|
+
// there), but is in a function's (the corpus's `path_string`).
|
|
186
|
+
const separator = lastSeparator(name, 5);
|
|
187
|
+
if (separator >= 0) {
|
|
188
|
+
const path = name.slice(0, separator);
|
|
189
|
+
const variable = name.slice(separator + 1);
|
|
190
|
+
const handleThis = inLocalScope(cx);
|
|
191
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
192
|
+
const object = targetPath(cx, s.object, path, true, handleThis, version);
|
|
193
|
+
if (object !== null) {
|
|
194
|
+
set(object, variable, value, version);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
let s = cx.scope;
|
|
201
|
+
for (;;) {
|
|
202
|
+
if (s.kind === SCOPE_Target || has(s.object, name, version) || s.parent === null) {
|
|
203
|
+
set(s.object, name, value, version);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
s = s.parent;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** Whether the activation's chain reaches a function's scope before a clip's. */
|
|
210
|
+
function inLocalScope(cx) {
|
|
211
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
212
|
+
if (s.kind === SCOPE_Local) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
if (s.kind === SCOPE_Target) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
/** Whether a name has a `:` or a `.`, a path, in every version. */
|
|
222
|
+
const isPath = (name) => lastSeparator(name, 5) >= 0;
|
|
223
|
+
/** Set `name` on the top scope, or on the first below a `with` that lacks it. */
|
|
224
|
+
function defineOn(scope, name, value, version) {
|
|
225
|
+
let s = scope;
|
|
226
|
+
while (s.kind === SCOPE_With && s.parent !== null && s.object.own(name, version) === undefined) {
|
|
227
|
+
s = s.parent;
|
|
228
|
+
}
|
|
229
|
+
set(s.object, name, value, version);
|
|
230
|
+
}
|
|
231
|
+
/** DefineLocal: a variable of the activation's top scope; a path outside a function is set as SetVariable sets it. */
|
|
232
|
+
export function defineLocal(cx, name, value, version) {
|
|
233
|
+
if (!inLocalScope(cx) && isPath(name)) {
|
|
234
|
+
setVariable(cx, name, value, version);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
defineOn(cx.scope, name, value, version);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** DefineLocal2: as DefineLocal of undefined, where the variable is not there yet. */
|
|
241
|
+
export function defineLocal2(cx, name, version) {
|
|
242
|
+
if (!inLocalScope(cx) && isPath(name)) {
|
|
243
|
+
if (getVariable(cx, name, version) === undefined) {
|
|
244
|
+
setVariable(cx, name, undefined, version);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (!has(cx.scope.object, name, version)) {
|
|
248
|
+
defineOn(cx.scope, name, undefined, version);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/** Delete2: a path's variable on its object, or a name on the first scope that has it. */
|
|
252
|
+
export function deleteVariable(cx, name, version) {
|
|
253
|
+
const separator = lastSeparator(name, 5);
|
|
254
|
+
if (separator >= 0) {
|
|
255
|
+
const object = getVariable(cx, name.slice(0, separator), version);
|
|
256
|
+
// A primitive where the object would be writes Flash's line of it (the corpus's `delete2`).
|
|
257
|
+
if (!(object instanceof ObjectClass)) {
|
|
258
|
+
if (object !== undefined && object !== null && version >= 5) {
|
|
259
|
+
cx.host.trace(PRIMITIVE);
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
return removeOwn(object, name.slice(separator + 1), version);
|
|
264
|
+
}
|
|
265
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
266
|
+
if (has(s.object, name, version)) {
|
|
267
|
+
return removeOwn(s.object, name, version);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The object a target path names from `start`: names separated by `.`,
|
|
274
|
+
* `:` or `/`, `..` the parent, a leading `/` the root, `this`, `_root` and
|
|
275
|
+
* `_levelN` first; each name a clip's child, else a property. Null where a
|
|
276
|
+
* step is no object.
|
|
277
|
+
*/
|
|
278
|
+
export function targetPath(cx, start, path, firstElement, handleThis, version) {
|
|
279
|
+
stoppedAtPrimitive = false;
|
|
280
|
+
if (path === "") {
|
|
281
|
+
return start;
|
|
282
|
+
}
|
|
283
|
+
const swf5 = version >= 5;
|
|
284
|
+
let object = start;
|
|
285
|
+
let slash = false;
|
|
286
|
+
let i = 0;
|
|
287
|
+
/** The delimiter that ended the last step, 0 for none. */
|
|
288
|
+
let prev = 0;
|
|
289
|
+
if (path.charCodeAt(0) === 0x2f) {
|
|
290
|
+
i = 1;
|
|
291
|
+
prev = 0x2f;
|
|
292
|
+
firstElement = false;
|
|
293
|
+
slash = true;
|
|
294
|
+
object = cx.host.root?.(cx.base);
|
|
295
|
+
if (!(object instanceof ObjectClass)) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const n = path.length;
|
|
300
|
+
while (i < n) {
|
|
301
|
+
if (swf5) {
|
|
302
|
+
// A path that ends in one goes on to an empty name, as Ruffle's does: none.
|
|
303
|
+
while (i < n && path.charCodeAt(i) === 0x3a) {
|
|
304
|
+
i++;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
let value;
|
|
308
|
+
const c2 = path.charCodeAt(i + 2);
|
|
309
|
+
if (path.charCodeAt(i) === 0x2e &&
|
|
310
|
+
path.charCodeAt(i + 1) === 0x2e &&
|
|
311
|
+
(i + 2 >= n || c2 === 0x2f || (swf5 && c2 === 0x3a))) {
|
|
312
|
+
if (c2 === 0x2f) {
|
|
313
|
+
slash = true;
|
|
314
|
+
}
|
|
315
|
+
i += 3;
|
|
316
|
+
prev = c2;
|
|
317
|
+
value = cx.host.parent?.(object);
|
|
318
|
+
// A level's parent is the level, but where a slash follows (the corpus's `target_paths`).
|
|
319
|
+
if (value === undefined) {
|
|
320
|
+
if (c2 === 0x2f) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
value = object;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
let end = i;
|
|
328
|
+
for (; end < n; end++) {
|
|
329
|
+
const c = path.charCodeAt(end);
|
|
330
|
+
if ((c === 0x3a && swf5) || (c === 0x2e && swf5 && !slash)) {
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
if (c === 0x2f) {
|
|
334
|
+
slash = true;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const name = path.slice(i, end);
|
|
339
|
+
const after = prev;
|
|
340
|
+
prev = end < n ? path.charCodeAt(end) : 0;
|
|
341
|
+
i = end + 1;
|
|
342
|
+
// An empty name is nothing first, after a slash, or at the end after a
|
|
343
|
+
// colon, else no step at all (`//a`, `.a` and `a::` name nothing, `a:/`
|
|
344
|
+
// and `a..` name `a`: the corpus's `target_paths` and `path_string`).
|
|
345
|
+
if (name === "") {
|
|
346
|
+
if (after === 0x2f || after === 0 || (end >= n && after === 0x3a)) {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
value = object;
|
|
350
|
+
}
|
|
351
|
+
else if (swf5 && handleThis && sameName(name, "this", version)) {
|
|
352
|
+
value = cx.self;
|
|
353
|
+
}
|
|
354
|
+
else if (swf5 && firstElement && sameName(name, "_root", version)) {
|
|
355
|
+
value = cx.host.root?.(cx.base);
|
|
356
|
+
}
|
|
357
|
+
else if (version >= 6 && firstElement && sameName(name, "_global", version)) {
|
|
358
|
+
value = cx.global;
|
|
359
|
+
}
|
|
360
|
+
else if (firstElement && isLevel(name, version)) {
|
|
361
|
+
value = level(cx, name, version);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
const o = object;
|
|
365
|
+
value = cx.host.child?.(o, name, version > 6);
|
|
366
|
+
if (value === undefined) {
|
|
367
|
+
value = get(o, name, version);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
firstElement = false;
|
|
372
|
+
if (!(value instanceof ObjectClass)) {
|
|
373
|
+
stoppedAtPrimitive = value !== undefined && value !== null;
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
object = value;
|
|
377
|
+
}
|
|
378
|
+
return object;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Whether the last `targetPath` that named no object stopped at a
|
|
382
|
+
* primitive, which a clip's path taken as an object writes Flash's line
|
|
383
|
+
* of to the log for (the corpus's `target_paths`).
|
|
384
|
+
*/
|
|
385
|
+
export let stoppedAtPrimitive = false;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { pathTarget, targetOrRoot } from "./clips.js";
|
|
2
|
+
import { Avm1Throw } from "./errors.js";
|
|
3
|
+
import { Avm1Object, get, keys } from "./objects.js";
|
|
4
|
+
import { stringOf } from "./values.js";
|
|
5
|
+
/** GetURL2's flags past the method (decode.ts reads a method of 3 as none). */
|
|
6
|
+
const METHOD_MASK = 3;
|
|
7
|
+
const LOAD_TARGET = 0x40;
|
|
8
|
+
const LOAD_VARIABLES = 0x80;
|
|
9
|
+
/** The command of an `FSCommand:` URL, in any case; null for any other URL. */
|
|
10
|
+
function fsCommandOf(url) {
|
|
11
|
+
return url.length >= 10 && url.slice(0, 10).toLowerCase() === "fscommand:" ? url.slice(10) : null;
|
|
12
|
+
}
|
|
13
|
+
/** "blank" with or without its underscore, in any case, as "_blank"; any other window as given. */
|
|
14
|
+
function windowOf(target) {
|
|
15
|
+
return /^_?blank$/i.test(target) ? "_blank" : target;
|
|
16
|
+
}
|
|
17
|
+
/** A level's number as Rust's i32 parse reads it: a sign and digits only, in range, else null. */
|
|
18
|
+
function levelInt(text) {
|
|
19
|
+
if (!/^[+-]?\d+$/.test(text)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const n = Number(text);
|
|
23
|
+
return n >= -0x80000000 && n <= 0x7fffffff ? n : null;
|
|
24
|
+
}
|
|
25
|
+
/** A level's number as Rust's f64 parse reads it and `as i32` truncates it, saturated; null for no number. */
|
|
26
|
+
function levelFloat(text) {
|
|
27
|
+
if (!/^[+-]?(\d+\.?\d*([eE][+-]?\d+)?|\.\d+([eE][+-]?\d+)?|inf|infinity|nan)$/i.test(text)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const body = text.replace(/^[+-]/, "").toLowerCase();
|
|
31
|
+
const n = body === "inf" || body === "infinity" ? Infinity : Number(body);
|
|
32
|
+
if (Number.isNaN(n)) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
const signed = text.startsWith("-") ? -n : n;
|
|
36
|
+
return Math.max(-0x80000000, Math.min(0x7fffffff, Math.trunc(signed))) | 0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The variables a request with a method sends: the innermost scope's
|
|
40
|
+
* object's, as for..in lists them, each as a string; one whose getter
|
|
41
|
+
* throws is "undefined", as Ruffle has it.
|
|
42
|
+
*/
|
|
43
|
+
function formOf(cx, flags, version) {
|
|
44
|
+
const method = flags & METHOD_MASK;
|
|
45
|
+
if (method === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const object = cx.scope.object;
|
|
49
|
+
const vars = [];
|
|
50
|
+
for (const name of keys(object, version)) {
|
|
51
|
+
let text;
|
|
52
|
+
try {
|
|
53
|
+
text = stringOf(get(object, name, version), version);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (!(error instanceof Avm1Throw)) {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
text = "undefined";
|
|
60
|
+
}
|
|
61
|
+
vars.push([name, text]);
|
|
62
|
+
}
|
|
63
|
+
return { method: method === 1 ? "GET" : "POST", vars };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* GetURL: `FSCommand:` to the host's fscommand, the target the arguments;
|
|
67
|
+
* a target `_levelN` loads the URL into that level, or with an empty one
|
|
68
|
+
* unloads it, nothing where N is no number; any other target is a window
|
|
69
|
+
* the page opens in.
|
|
70
|
+
*/
|
|
71
|
+
export function getUrl(cx, url, target) {
|
|
72
|
+
if (target.startsWith("_level") && target.length > 6) {
|
|
73
|
+
const level = levelInt(target.slice(6));
|
|
74
|
+
if (level !== null) {
|
|
75
|
+
cx.host.loadMovie?.(level, url, null);
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const command = fsCommandOf(url);
|
|
80
|
+
if (command !== null) {
|
|
81
|
+
cx.host.fsCommand?.(command, target);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
cx.host.navigate?.(url, windowOf(target), null);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* MovieClip.getURL(url, window, method), from the code `cx` runs:
|
|
88
|
+
* `FSCommand:` as GetURL's, the window the arguments; else the page, with
|
|
89
|
+
* the scope's variables where the method is "GET" or "POST" in any case.
|
|
90
|
+
*/
|
|
91
|
+
export function getUrlMethod(cx, args, version) {
|
|
92
|
+
if (args.length === 0) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const url = stringOf(args[0], version);
|
|
96
|
+
const command = fsCommandOf(url);
|
|
97
|
+
if (command !== null) {
|
|
98
|
+
cx.host.fsCommand?.(command, stringOf(args[1], version));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const window = args.length > 1 ? stringOf(args[1], version) : "";
|
|
102
|
+
const method = typeof args[2] === "string" ? args[2].toLowerCase() : "";
|
|
103
|
+
const flags = method === "get" ? 1 : method === "post" ? 2 : 0;
|
|
104
|
+
cx.host.navigate?.(url, windowOf(window), formOf(cx, flags, version));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* GetURL2, its target popped first and converted first: `FSCommand:` as
|
|
108
|
+
* GetURL's; else by its flags, loadVariables into a clip or a level (or,
|
|
109
|
+
* named by a path but not the root, a page after all), loadMovie into a
|
|
110
|
+
* clip or a level, loadMovieNum into a level the target names, or the page
|
|
111
|
+
* a window opens; those of a method send the scope's variables, but
|
|
112
|
+
* loadMovieNum and a page without one.
|
|
113
|
+
*/
|
|
114
|
+
export function getUrl2(cx, targetValue, urlValue, flags, version) {
|
|
115
|
+
const target = stringOf(targetValue, version);
|
|
116
|
+
const url = stringOf(urlValue, version);
|
|
117
|
+
const command = fsCommandOf(url);
|
|
118
|
+
if (command !== null) {
|
|
119
|
+
cx.host.fsCommand?.(command, target);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
let level = -1;
|
|
123
|
+
if (target.startsWith("_level")) {
|
|
124
|
+
level = levelFloat(target.slice(6)) ?? (target.length === 6 ? 0 : -1);
|
|
125
|
+
}
|
|
126
|
+
const loadVariables = (flags & LOAD_VARIABLES) !== 0;
|
|
127
|
+
const loadTarget = (flags & LOAD_TARGET) !== 0;
|
|
128
|
+
let clip = null;
|
|
129
|
+
if (level > -1) {
|
|
130
|
+
clip = levelClip(cx, level);
|
|
131
|
+
}
|
|
132
|
+
else if (loadVariables || loadTarget) {
|
|
133
|
+
clip = clipOf(cx, targetValue, version);
|
|
134
|
+
}
|
|
135
|
+
if (loadVariables) {
|
|
136
|
+
let into = loadTarget || level > -1;
|
|
137
|
+
// A path's clip that is not the root is a page to open.
|
|
138
|
+
if (!into && targetValue instanceof Avm1Object && clip !== null) {
|
|
139
|
+
into = clip === rootClip(cx);
|
|
140
|
+
}
|
|
141
|
+
if (into) {
|
|
142
|
+
if (clip !== null) {
|
|
143
|
+
cx.host.loadVariables?.(clip, url, formOf(cx, flags, version));
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else if (loadTarget) {
|
|
149
|
+
if (url === "") {
|
|
150
|
+
if (clip !== null) {
|
|
151
|
+
cx.host.loadMovie?.(clip, "", null);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (clip !== null || level > -1) {
|
|
155
|
+
cx.host.loadMovie?.(clip ?? level, url, formOf(cx, flags, version));
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
else if (level > -1) {
|
|
160
|
+
cx.host.loadMovie?.(clip ?? level, url, null);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
cx.host.navigate?.(url, windowOf(target), formOf(cx, flags, version));
|
|
164
|
+
}
|
|
165
|
+
/** The clip of level `level`, null where there is none yet. */
|
|
166
|
+
function levelClip(cx, level) {
|
|
167
|
+
const object = cx.host.level?.(level);
|
|
168
|
+
return object instanceof Avm1Object ? (cx.host.clipOf?.(object) ?? null) : null;
|
|
169
|
+
}
|
|
170
|
+
function rootClip(cx) {
|
|
171
|
+
const root = cx.host.root?.(cx.base);
|
|
172
|
+
return root instanceof Avm1Object ? (cx.host.clipOf?.(root) ?? null) : null;
|
|
173
|
+
}
|
|
174
|
+
/** The clip a target names: a clip's object itself, none for any other object, else its path from the target. */
|
|
175
|
+
function clipOf(cx, value, version) {
|
|
176
|
+
if (value instanceof Avm1Object) {
|
|
177
|
+
return cx.host.clipOf?.(value) ?? null;
|
|
178
|
+
}
|
|
179
|
+
return pathTarget(cx, targetOrRoot(cx), stringOf(value, version), version);
|
|
180
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// AVM1's values and their conversions, by the version of the SWF whose
|
|
2
|
+
// code converts them, as Ruffle's (https://github.com/ruffle-rs/ruffle)
|
|
3
|
+
// core/src/avm1/value.rs has them (as_bool, coerce_to_f64,
|
|
4
|
+
// coerce_to_string, to_primitive): MIT OR Apache-2.0, Copyright (c)
|
|
5
|
+
// 2018-2022 Ruffle LLC and Ruffle contributors.
|
|
6
|
+
import { NotYet } from "./errors.js";
|
|
7
|
+
import { numberToString, stringToNumber } from "./numbers.js";
|
|
8
|
+
const notYet = (what) => () => {
|
|
9
|
+
throw new NotYet(what);
|
|
10
|
+
};
|
|
11
|
+
export const objects = {
|
|
12
|
+
valueOf: notYet("valueOf of an object"),
|
|
13
|
+
toPrimitive: notYet("an object to a primitive"),
|
|
14
|
+
toString: notYet("toString of an object"),
|
|
15
|
+
typeOf: notYet("typeof of an object"),
|
|
16
|
+
};
|
|
17
|
+
export const isPrimitive = (value) => value === null || (typeof value !== "object" && typeof value !== "function");
|
|
18
|
+
/**
|
|
19
|
+
* A value as a condition: a string by its number up to SWF 6 ("0" and "a"
|
|
20
|
+
* are false), by its length from SWF 7; an object is true.
|
|
21
|
+
*/
|
|
22
|
+
export function toBoolean(value, version) {
|
|
23
|
+
switch (typeof value) {
|
|
24
|
+
case "boolean":
|
|
25
|
+
return value;
|
|
26
|
+
case "number":
|
|
27
|
+
return value !== 0 && !Number.isNaN(value);
|
|
28
|
+
case "string": {
|
|
29
|
+
if (version >= 7) {
|
|
30
|
+
return value.length > 0;
|
|
31
|
+
}
|
|
32
|
+
const n = stringToNumber(value, version);
|
|
33
|
+
return n !== 0 && !Number.isNaN(n);
|
|
34
|
+
}
|
|
35
|
+
case "undefined":
|
|
36
|
+
return false;
|
|
37
|
+
default:
|
|
38
|
+
return value !== null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A primitive as a number: undefined and null are 0 up to SWF 6 and NaN
|
|
43
|
+
* from 7, and an object a `valueOf` left is 0 up to SWF 4 and NaN after.
|
|
44
|
+
*/
|
|
45
|
+
export function primitiveToNumber(value, version) {
|
|
46
|
+
switch (typeof value) {
|
|
47
|
+
case "number":
|
|
48
|
+
return value;
|
|
49
|
+
case "boolean":
|
|
50
|
+
return value ? 1 : 0;
|
|
51
|
+
case "string":
|
|
52
|
+
return stringToNumber(value, version);
|
|
53
|
+
case "undefined":
|
|
54
|
+
return version < 7 ? 0 : Number.NaN;
|
|
55
|
+
default:
|
|
56
|
+
if (value === null) {
|
|
57
|
+
return version < 7 ? 0 : Number.NaN;
|
|
58
|
+
}
|
|
59
|
+
return version < 5 ? 0 : Number.NaN;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** A value as a number, an object by its `valueOf`. */
|
|
63
|
+
export function toNumber(value, version) {
|
|
64
|
+
return isPrimitive(value)
|
|
65
|
+
? primitiveToNumber(value, version)
|
|
66
|
+
: primitiveToNumber(objects.valueOf(value, version), version);
|
|
67
|
+
}
|
|
68
|
+
/** A value as a string: undefined is "" up to SWF 6, and a boolean 1 or 0 up to SWF 4. */
|
|
69
|
+
export function stringOf(value, version) {
|
|
70
|
+
switch (typeof value) {
|
|
71
|
+
case "undefined":
|
|
72
|
+
return version >= 7 ? "undefined" : "";
|
|
73
|
+
case "boolean":
|
|
74
|
+
if (version < 5) {
|
|
75
|
+
return value ? "1" : "0";
|
|
76
|
+
}
|
|
77
|
+
return value ? "true" : "false";
|
|
78
|
+
case "number":
|
|
79
|
+
return numberToString(value);
|
|
80
|
+
case "string":
|
|
81
|
+
return value;
|
|
82
|
+
default:
|
|
83
|
+
return value === null ? "null" : objects.toString(value, version);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** `typeof`, the same in every version. */
|
|
87
|
+
export function typeOf(value) {
|
|
88
|
+
switch (typeof value) {
|
|
89
|
+
case "undefined":
|
|
90
|
+
case "number":
|
|
91
|
+
case "boolean":
|
|
92
|
+
case "string":
|
|
93
|
+
return typeof value;
|
|
94
|
+
default:
|
|
95
|
+
return value === null ? "null" : objects.typeOf(value);
|
|
96
|
+
}
|
|
97
|
+
}
|