@swf2es/player-hosts 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
// AMF0 of AVM1's values, as Ruffle's (https://github.com/ruffle-rs/ruffle)
|
|
2
|
+
// core/src/avm1/amf.rs has it: MIT OR Apache-2.0, Copyright (c) 2018-2022
|
|
3
|
+
// Ruffle LLC and Ruffle contributors. SharedObject's .sol files
|
|
4
|
+
// (globals/SharedObject.ts) and NetConnection's remoting packets
|
|
5
|
+
// (globals/NetConnection.ts) write and read their values with it.
|
|
6
|
+
import { avm1 } from "../../runtime/index.js";
|
|
7
|
+
// AMF0's markers.
|
|
8
|
+
export const NUMBER = 0x00;
|
|
9
|
+
export const BOOLEAN = 0x01;
|
|
10
|
+
export const STRING = 0x02;
|
|
11
|
+
export const OBJECT = 0x03;
|
|
12
|
+
export const NULL = 0x05;
|
|
13
|
+
export const UNDEFINED = 0x06;
|
|
14
|
+
export const REFERENCE = 0x07;
|
|
15
|
+
export const ECMA_ARRAY = 0x08;
|
|
16
|
+
export const OBJECT_END = 0x09;
|
|
17
|
+
export const UNSUPPORTED = 0x0d;
|
|
18
|
+
export const STRICT_ARRAY = 0x0a;
|
|
19
|
+
export const DATE = 0x0b;
|
|
20
|
+
export const LONG_STRING = 0x0c;
|
|
21
|
+
export const XML = 0x0f;
|
|
22
|
+
export const TYPED_OBJECT = 0x10;
|
|
23
|
+
const encoder = new TextEncoder();
|
|
24
|
+
const decoder = new TextDecoder();
|
|
25
|
+
/**
|
|
26
|
+
* The most values a remoting value writes: a length a script sets, or an
|
|
27
|
+
* object shared down a tree of them (a = [b, b], b = [c, c]...) met each
|
|
28
|
+
* time, would otherwise hang the page or run it out of memory. Arrays
|
|
29
|
+
* and properties stop when it is spent; the reader refuses more values.
|
|
30
|
+
*/
|
|
31
|
+
export const MAX_VALUES = 1 << 20;
|
|
32
|
+
/** How deep values nest as they are written or read; past it, undefined, or a read fails. */
|
|
33
|
+
export const MAX_DEPTH = 1024;
|
|
34
|
+
/** AMF0 written into one growing buffer, so primitive values allocate no chunks. */
|
|
35
|
+
export class Writer {
|
|
36
|
+
typedName;
|
|
37
|
+
version;
|
|
38
|
+
data;
|
|
39
|
+
remoting;
|
|
40
|
+
maxBytes;
|
|
41
|
+
buffer = new Uint8Array(64);
|
|
42
|
+
view = new DataView(this.buffer.buffer);
|
|
43
|
+
length = 0;
|
|
44
|
+
/**
|
|
45
|
+
* The objects and arrays written, by their place: a second sight of one
|
|
46
|
+
* is a reference. Flash counts the data object as the first (adl).
|
|
47
|
+
*/
|
|
48
|
+
references = new Map();
|
|
49
|
+
nextReference;
|
|
50
|
+
/** The values a remoting value may still write (MAX_VALUES). */
|
|
51
|
+
left = MAX_VALUES;
|
|
52
|
+
depth = 0;
|
|
53
|
+
constructor(
|
|
54
|
+
/** The name Object.registerClass gave a constructor, which an object of is written typed. */
|
|
55
|
+
typedName, version,
|
|
56
|
+
/**
|
|
57
|
+
* A .sol file's data object, which Flash writes as unsupported wherever
|
|
58
|
+
* it is inside itself (adl), and counts as the first reference; null
|
|
59
|
+
* for none, the references counted from 1 still.
|
|
60
|
+
*/
|
|
61
|
+
data,
|
|
62
|
+
/**
|
|
63
|
+
* A remoting packet's ways, where they part from a .sol file's: an XML
|
|
64
|
+
* node as its text, a date's zone as 0, an array of indices alone as a
|
|
65
|
+
* strict array (the corpus's netconnection_serialize_arrays), a getter
|
|
66
|
+
* or an element that throws undefined, its values bounded.
|
|
67
|
+
*/
|
|
68
|
+
remoting = null, maxBytes = Infinity) {
|
|
69
|
+
this.typedName = typedName;
|
|
70
|
+
this.version = version;
|
|
71
|
+
this.data = data;
|
|
72
|
+
this.remoting = remoting;
|
|
73
|
+
this.maxBytes = maxBytes;
|
|
74
|
+
this.nextReference = remoting?.first ?? 1;
|
|
75
|
+
}
|
|
76
|
+
get size() {
|
|
77
|
+
return this.length;
|
|
78
|
+
}
|
|
79
|
+
/** An owned snapshot: queued messages must not retain spare buffer capacity. */
|
|
80
|
+
finish() {
|
|
81
|
+
return this.buffer.slice(0, this.length);
|
|
82
|
+
}
|
|
83
|
+
reserve(size) {
|
|
84
|
+
if (size > this.maxBytes - this.length) {
|
|
85
|
+
throw new RangeError("AMF0 message too large");
|
|
86
|
+
}
|
|
87
|
+
const at = this.length;
|
|
88
|
+
const end = at + size;
|
|
89
|
+
if (end > this.buffer.length) {
|
|
90
|
+
const buffer = new Uint8Array(Math.min(this.maxBytes, Math.max(end, this.buffer.length * 2)));
|
|
91
|
+
buffer.set(this.buffer.subarray(0, at));
|
|
92
|
+
this.buffer = buffer;
|
|
93
|
+
this.view = new DataView(buffer.buffer);
|
|
94
|
+
}
|
|
95
|
+
this.length = end;
|
|
96
|
+
return at;
|
|
97
|
+
}
|
|
98
|
+
byte(n) {
|
|
99
|
+
const at = this.reserve(1);
|
|
100
|
+
this.buffer[at] = n;
|
|
101
|
+
}
|
|
102
|
+
bytes(...b) {
|
|
103
|
+
const at = this.reserve(b.length);
|
|
104
|
+
this.buffer.set(b, at);
|
|
105
|
+
}
|
|
106
|
+
push(chunk) {
|
|
107
|
+
const at = this.reserve(chunk.length);
|
|
108
|
+
this.buffer.set(chunk, at);
|
|
109
|
+
}
|
|
110
|
+
u16(n) {
|
|
111
|
+
const at = this.reserve(2);
|
|
112
|
+
this.view.setUint16(at, n);
|
|
113
|
+
}
|
|
114
|
+
u32(n) {
|
|
115
|
+
const at = this.reserve(4);
|
|
116
|
+
this.view.setUint32(at, n);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A number as Flash writes it (adl's .sol): NaN as 7FFF FFFF FFFF FFFF,
|
|
120
|
+
* and -0 as 0, as its AVM1 keeps a whole number as an integer.
|
|
121
|
+
*/
|
|
122
|
+
double(n) {
|
|
123
|
+
const at = this.reserve(8);
|
|
124
|
+
if (Number.isNaN(n)) {
|
|
125
|
+
this.view.setUint32(at, 0x7fffffff);
|
|
126
|
+
this.view.setUint32(at + 4, 0xffffffff);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.view.setFloat64(at, n === 0 ? 0 : n);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** A name, a u16-long UTF-8 string without a marker, cut to fit one. */
|
|
133
|
+
name(text) {
|
|
134
|
+
if (Math.min(text.length, 0xffff) > this.maxBytes - this.length) {
|
|
135
|
+
throw new RangeError("AMF0 message too large");
|
|
136
|
+
}
|
|
137
|
+
const b = encoder.encode(text).subarray(0, 0xffff);
|
|
138
|
+
this.u16(b.length);
|
|
139
|
+
this.push(b);
|
|
140
|
+
}
|
|
141
|
+
string(text) {
|
|
142
|
+
if (text.length > this.maxBytes - this.length) {
|
|
143
|
+
throw new RangeError("AMF0 message too large");
|
|
144
|
+
}
|
|
145
|
+
const b = encoder.encode(text);
|
|
146
|
+
if (b.length > 0xffff) {
|
|
147
|
+
this.byte(LONG_STRING);
|
|
148
|
+
this.u32(b.length);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.byte(STRING);
|
|
152
|
+
this.u16(b.length);
|
|
153
|
+
}
|
|
154
|
+
this.push(b);
|
|
155
|
+
}
|
|
156
|
+
value(v) {
|
|
157
|
+
if (this.remoting !== null && this.left-- <= 0) {
|
|
158
|
+
this.left = 0;
|
|
159
|
+
this.byte(UNDEFINED);
|
|
160
|
+
}
|
|
161
|
+
else if (v === undefined) {
|
|
162
|
+
this.byte(UNDEFINED);
|
|
163
|
+
}
|
|
164
|
+
else if (v === null) {
|
|
165
|
+
this.byte(NULL);
|
|
166
|
+
}
|
|
167
|
+
else if (typeof v === "boolean") {
|
|
168
|
+
this.bytes(BOOLEAN, v ? 1 : 0);
|
|
169
|
+
}
|
|
170
|
+
else if (typeof v === "number") {
|
|
171
|
+
this.byte(NUMBER);
|
|
172
|
+
this.double(v);
|
|
173
|
+
}
|
|
174
|
+
else if (typeof v === "string") {
|
|
175
|
+
this.string(v);
|
|
176
|
+
}
|
|
177
|
+
else if (v instanceof avm1.Avm1Object) {
|
|
178
|
+
this.object(v);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.byte(UNDEFINED);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** A call's implicit argument array, already reserved as reference 0 by the caller. */
|
|
185
|
+
arguments(values) {
|
|
186
|
+
this.left--;
|
|
187
|
+
this.depth++;
|
|
188
|
+
try {
|
|
189
|
+
this.array(values.length, (i) => values[i]);
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
this.depth--;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/** A property of `o` as remoting reads it: undefined where its getter throws (Ruffle). */
|
|
196
|
+
read(o, key) {
|
|
197
|
+
if (this.remoting === null) {
|
|
198
|
+
return avm1.get(o, key, this.version);
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
return avm1.get(o, key, this.version);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (error instanceof avm1.Avm1Throw) {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
object(o) {
|
|
211
|
+
// Leave room for the undefined leaf in the reader's depth budget.
|
|
212
|
+
if (this.depth >= MAX_DEPTH - 1) {
|
|
213
|
+
this.byte(UNDEFINED);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.depth++;
|
|
217
|
+
try {
|
|
218
|
+
this.contents(o);
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
this.depth--;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
contents(o) {
|
|
225
|
+
// A clip is no data: Flash writes undefined for it.
|
|
226
|
+
if (o.display !== null) {
|
|
227
|
+
this.byte(UNDEFINED);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
// A date's time and its zone's offset as getTimezoneOffset gives it, minutes behind UTC, as
|
|
231
|
+
// Flash writes it (adl: -120 at UTC+2), which reading ignores.
|
|
232
|
+
if (o.primitive instanceof avm1.DateCell) {
|
|
233
|
+
const time = o.primitive.time;
|
|
234
|
+
this.byte(DATE);
|
|
235
|
+
this.double(time);
|
|
236
|
+
const offset = this.remoting === null && Number.isFinite(time) ? new Date(time).getTimezoneOffset() : 0;
|
|
237
|
+
this.u16(offset & 0xffff);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const xml = this.remoting?.xmlText(o) ?? null;
|
|
241
|
+
if (xml !== null) {
|
|
242
|
+
if (xml.length > this.maxBytes - this.length) {
|
|
243
|
+
throw new RangeError("AMF0 message too large");
|
|
244
|
+
}
|
|
245
|
+
const b = encoder.encode(xml);
|
|
246
|
+
this.byte(XML);
|
|
247
|
+
this.u32(b.length);
|
|
248
|
+
this.push(b);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (o === this.data) {
|
|
252
|
+
this.byte(UNSUPPORTED);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const seen = this.references.get(o);
|
|
256
|
+
if (seen !== undefined) {
|
|
257
|
+
this.byte(REFERENCE);
|
|
258
|
+
this.u16(seen);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
this.references.set(o, this.nextReference++);
|
|
262
|
+
if (o.array && this.remoting !== null && this.dense(o)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (o.array) {
|
|
266
|
+
// Its length, as the int it is kept as.
|
|
267
|
+
this.byte(ECMA_ARRAY);
|
|
268
|
+
this.u32(avm1.toNumber(this.read(o, "length"), this.version) >>> 0);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
const typed = this.typedName(constructorOf(o, this.version));
|
|
272
|
+
if (typed !== null) {
|
|
273
|
+
this.byte(TYPED_OBJECT);
|
|
274
|
+
this.name(typed);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.byte(OBJECT);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
this.properties(o);
|
|
281
|
+
this.bytes(0, 0, OBJECT_END);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* An array of indices alone written as a strict array, its length grown
|
|
285
|
+
* past the last index, the holes undefined; false, nothing written, for
|
|
286
|
+
* one with a key that is no index.
|
|
287
|
+
*/
|
|
288
|
+
dense(o) {
|
|
289
|
+
const keys = avm1.keys(o, this.version);
|
|
290
|
+
if (keys.some((key) => !/^\d+$/.test(key))) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
let length = Math.max(0, avm1.toNumber(this.read(o, "length"), this.version) | 0);
|
|
294
|
+
for (const key of keys) {
|
|
295
|
+
length = Math.max(length, Number(key) + 1);
|
|
296
|
+
}
|
|
297
|
+
this.array(length, (i) => this.read(o, String(i)));
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
/** An array's elements, shortened where nested values spend the remaining budget. */
|
|
301
|
+
array(length, read) {
|
|
302
|
+
// No more than the values left to write, which also keeps it a u32.
|
|
303
|
+
length = Math.min(length, this.left);
|
|
304
|
+
this.byte(STRICT_ARRAY);
|
|
305
|
+
// Nested values spend this budget too, so the final count is only known after writing them.
|
|
306
|
+
const count = this.reserve(4);
|
|
307
|
+
let written = 0;
|
|
308
|
+
for (let i = 0; i < length && this.left > 0; i++) {
|
|
309
|
+
this.value(read(i));
|
|
310
|
+
written++;
|
|
311
|
+
}
|
|
312
|
+
this.view.setUint32(count, written);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* `o`'s properties as for..in lists them, reversed, as Flash writes them:
|
|
316
|
+
* a function left out, a getter, own or inherited, never called but
|
|
317
|
+
* written undefined (adl).
|
|
318
|
+
*/
|
|
319
|
+
properties(o) {
|
|
320
|
+
for (const key of avm1.keys(o, this.version).reverse()) {
|
|
321
|
+
if (this.remoting !== null && this.left === 0) {
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
if (avm1.find(o, key, this.version)?.get) {
|
|
325
|
+
this.name(key);
|
|
326
|
+
this.value(undefined);
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
const v = this.read(o, key);
|
|
330
|
+
if (v instanceof avm1.Avm1Function) {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
this.name(key);
|
|
334
|
+
this.value(v);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/** The constructor AMF0 types an object by: an own `constructor`, else `__constructor__`. */
|
|
339
|
+
function constructorOf(o, version) {
|
|
340
|
+
const own = o.own("constructor", version);
|
|
341
|
+
if (own) {
|
|
342
|
+
return own.get ? undefined : own.value;
|
|
343
|
+
}
|
|
344
|
+
// Its stored value: a getter is not called (Ruffle's get_stored_property).
|
|
345
|
+
const found = avm1.find(o, "__constructor__", version);
|
|
346
|
+
return found === undefined || found.get ? undefined : found.value;
|
|
347
|
+
}
|
|
348
|
+
/** AMF0 read back into AVM1 values; a marker it does not know ends the file there. */
|
|
349
|
+
export class Reader {
|
|
350
|
+
bytes;
|
|
351
|
+
realm;
|
|
352
|
+
version;
|
|
353
|
+
left;
|
|
354
|
+
xml;
|
|
355
|
+
at = 0;
|
|
356
|
+
view;
|
|
357
|
+
references;
|
|
358
|
+
depth = 0;
|
|
359
|
+
constructor(bytes, realm, version,
|
|
360
|
+
/** As a .sol file's writer counts its data object first, which Flash never refers to. */
|
|
361
|
+
data = false,
|
|
362
|
+
/** Remoting's value limit; .sol reads use Infinity to match their uncapped writer. */
|
|
363
|
+
left = MAX_VALUES, xml = null) {
|
|
364
|
+
this.bytes = bytes;
|
|
365
|
+
this.realm = realm;
|
|
366
|
+
this.version = version;
|
|
367
|
+
this.left = left;
|
|
368
|
+
this.xml = xml;
|
|
369
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
370
|
+
this.references = data ? [undefined] : [];
|
|
371
|
+
}
|
|
372
|
+
u16() {
|
|
373
|
+
const n = this.view.getUint16(this.at);
|
|
374
|
+
this.at += 2;
|
|
375
|
+
return n;
|
|
376
|
+
}
|
|
377
|
+
u32() {
|
|
378
|
+
const n = this.view.getUint32(this.at);
|
|
379
|
+
this.at += 4;
|
|
380
|
+
return n;
|
|
381
|
+
}
|
|
382
|
+
utf8(length) {
|
|
383
|
+
if (this.at + length > this.bytes.length) {
|
|
384
|
+
throw new RangeError("past the end");
|
|
385
|
+
}
|
|
386
|
+
const text = decoder.decode(this.bytes.subarray(this.at, this.at + length));
|
|
387
|
+
this.at += length;
|
|
388
|
+
return text;
|
|
389
|
+
}
|
|
390
|
+
name() {
|
|
391
|
+
return this.utf8(this.u16());
|
|
392
|
+
}
|
|
393
|
+
/** A value; past the count or depth budget, a RangeError, as for bytes past the end. */
|
|
394
|
+
value() {
|
|
395
|
+
if (this.left-- <= 0) {
|
|
396
|
+
throw new RangeError("AMF0 too many values");
|
|
397
|
+
}
|
|
398
|
+
if (this.depth >= MAX_DEPTH) {
|
|
399
|
+
throw new RangeError("AMF0 nested too deep");
|
|
400
|
+
}
|
|
401
|
+
this.depth++;
|
|
402
|
+
try {
|
|
403
|
+
return this.marked();
|
|
404
|
+
}
|
|
405
|
+
finally {
|
|
406
|
+
this.depth--;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
marked() {
|
|
410
|
+
const marker = this.bytes[this.at++];
|
|
411
|
+
switch (marker) {
|
|
412
|
+
case NUMBER: {
|
|
413
|
+
const n = this.view.getFloat64(this.at);
|
|
414
|
+
this.at += 8;
|
|
415
|
+
return n;
|
|
416
|
+
}
|
|
417
|
+
case BOOLEAN:
|
|
418
|
+
if (this.at >= this.bytes.length) {
|
|
419
|
+
throw new RangeError("past the end");
|
|
420
|
+
}
|
|
421
|
+
return this.bytes[this.at++] !== 0;
|
|
422
|
+
case STRING:
|
|
423
|
+
return this.name();
|
|
424
|
+
case LONG_STRING:
|
|
425
|
+
return this.utf8(this.u32());
|
|
426
|
+
case NULL:
|
|
427
|
+
return null;
|
|
428
|
+
case UNDEFINED:
|
|
429
|
+
case UNSUPPORTED:
|
|
430
|
+
return undefined;
|
|
431
|
+
case REFERENCE:
|
|
432
|
+
return this.references[this.u16()];
|
|
433
|
+
case OBJECT:
|
|
434
|
+
case TYPED_OBJECT: {
|
|
435
|
+
if (marker === TYPED_OBJECT) {
|
|
436
|
+
this.name();
|
|
437
|
+
}
|
|
438
|
+
const o = this.realm.newObject(this.version);
|
|
439
|
+
this.references.push(o);
|
|
440
|
+
this.entries(o);
|
|
441
|
+
return o;
|
|
442
|
+
}
|
|
443
|
+
case ECMA_ARRAY: {
|
|
444
|
+
// Its length, which holes at its end leave longer than its entries (adl: new Array(5)).
|
|
445
|
+
const length = this.u32();
|
|
446
|
+
const a = this.realm.newArray([], this.version);
|
|
447
|
+
this.references.push(a);
|
|
448
|
+
this.entries(a);
|
|
449
|
+
if (length > avm1.toNumber(avm1.get(a, "length", this.version), this.version)) {
|
|
450
|
+
avm1.set(a, "length", length, this.version);
|
|
451
|
+
}
|
|
452
|
+
return a;
|
|
453
|
+
}
|
|
454
|
+
case STRICT_ARRAY: {
|
|
455
|
+
const a = this.realm.newArray([], this.version);
|
|
456
|
+
this.references.push(a);
|
|
457
|
+
const count = this.u32();
|
|
458
|
+
if (count > this.left) {
|
|
459
|
+
throw new RangeError("AMF0 too many values");
|
|
460
|
+
}
|
|
461
|
+
for (let i = 0; i < count; i++) {
|
|
462
|
+
put(a, String(i), this.value(), this.version);
|
|
463
|
+
}
|
|
464
|
+
const length = a.own("length", this.version);
|
|
465
|
+
if (length) {
|
|
466
|
+
length.value = count;
|
|
467
|
+
}
|
|
468
|
+
return a;
|
|
469
|
+
}
|
|
470
|
+
case DATE: {
|
|
471
|
+
const time = this.view.getFloat64(this.at);
|
|
472
|
+
this.at += 8;
|
|
473
|
+
this.u16();
|
|
474
|
+
// Flash's own Date, whatever a script set _global.Date to.
|
|
475
|
+
return this.realm.construct(this.realm.Date.constr, [time], this.version);
|
|
476
|
+
}
|
|
477
|
+
case XML: {
|
|
478
|
+
const text = this.utf8(this.u32());
|
|
479
|
+
return this.xml?.(text);
|
|
480
|
+
}
|
|
481
|
+
default:
|
|
482
|
+
throw new RangeError(`AMF0 marker ${marker}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/** Name and value pairs up to an empty name and the end marker, set on `o`. */
|
|
486
|
+
entries(o) {
|
|
487
|
+
for (;;) {
|
|
488
|
+
const key = this.name();
|
|
489
|
+
if (key === "" && this.bytes[this.at] === OBJECT_END) {
|
|
490
|
+
this.at++;
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
put(o, key, this.value(), this.version);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* A property read back, defined as it is rather than set: no setter or
|
|
499
|
+
* watcher a script added to a prototype runs, and no key makes itself the
|
|
500
|
+
* object's prototype.
|
|
501
|
+
*/
|
|
502
|
+
export function put(o, key, value, version) {
|
|
503
|
+
if (key.toLowerCase() === "__proto__" && (version <= 6 || key === "__proto__")) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
o.define(key, value, 0);
|
|
507
|
+
}
|