@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,801 @@
|
|
|
1
|
+
// AMF3, as avmplus' AvmPlusObjectOutput and AvmPlusObjectInput write and
|
|
2
|
+
// read it for ByteArray's writeObject and readObject: the markers, 29-bit
|
|
3
|
+
// references, and the string, object and traits tables, fresh for each
|
|
4
|
+
// call. A number is an integer if it is one of avmplus' int atoms: whole,
|
|
5
|
+
// not -0, and within 29 bits (avmshell is a 32-bit build). Doubles and
|
|
6
|
+
// Vector elements are big-endian whatever the ByteArray's byte order: avmplus
|
|
7
|
+
// writes AMF through a wrapper of its own.
|
|
8
|
+
// Dates too, as a reference or their time, Dictionaries, by name or object
|
|
9
|
+
// key, XML, as a reference or its toXMLString, and an IExternalizable by
|
|
10
|
+
// its writeExternal and readExternal.
|
|
11
|
+
//
|
|
12
|
+
// Translated from avmplus' core/AvmSerializer.cpp, this file is subject to
|
|
13
|
+
// the Mozilla Public License, v. 2.0: http://mozilla.org/MPL/2.0/.
|
|
14
|
+
import { FloatValue } from "./float.js";
|
|
15
|
+
import { NS_PackageInternal, NS_Public, namespace, publicQname, qname } from "./names.js";
|
|
16
|
+
import { bytesOf, fromUtf8, utf8 } from "./natives/bytearray.js";
|
|
17
|
+
import { xmlToXMLString } from "./natives/xml/strings.js";
|
|
18
|
+
const kUndefined = 0;
|
|
19
|
+
const kNull = 1;
|
|
20
|
+
const kFalse = 2;
|
|
21
|
+
const kTrue = 3;
|
|
22
|
+
const kInteger = 4;
|
|
23
|
+
const kDouble = 5;
|
|
24
|
+
const kString = 6;
|
|
25
|
+
const kXmlDocument = 7;
|
|
26
|
+
const kDate = 8;
|
|
27
|
+
const kArray = 9;
|
|
28
|
+
const kObject = 10;
|
|
29
|
+
const kXml = 11;
|
|
30
|
+
const kByteArray = 12;
|
|
31
|
+
const kVectorInt = 13;
|
|
32
|
+
const kVectorUint = 14;
|
|
33
|
+
const kVectorDouble = 15;
|
|
34
|
+
const kVectorObject = 16;
|
|
35
|
+
const kDictionary = 17;
|
|
36
|
+
const kFloat = 21;
|
|
37
|
+
const kVectorFloat = 18;
|
|
38
|
+
const VECTOR_KINDS = {
|
|
39
|
+
"__AS3__.vec::Vector$int": kVectorInt,
|
|
40
|
+
"__AS3__.vec::Vector$uint": kVectorUint,
|
|
41
|
+
"__AS3__.vec::Vector$double": kVectorDouble,
|
|
42
|
+
};
|
|
43
|
+
// IExternalizable's traits, by runtime: each writeObject describes its
|
|
44
|
+
// classes afresh, and looking the interface up by name each time cost AMF3
|
|
45
|
+
// a tenth of its time. Whether a class implements it is asked each time,
|
|
46
|
+
// as an interface it names may link only later.
|
|
47
|
+
const externalizableTraits = new WeakMap();
|
|
48
|
+
function isExternalizable(rt, traits) {
|
|
49
|
+
let iface = externalizableTraits.get(rt);
|
|
50
|
+
if (iface === undefined) {
|
|
51
|
+
iface = rt.classNamed("flash.utils::IExternalizable").$it;
|
|
52
|
+
externalizableTraits.set(rt, iface);
|
|
53
|
+
}
|
|
54
|
+
return traits.isSubtypeOf(iface);
|
|
55
|
+
}
|
|
56
|
+
/** One of flash.utils' internal ObjectOutput or ObjectInput, over `stream`. */
|
|
57
|
+
function externalStream(rt, name, stream) {
|
|
58
|
+
const cls = rt.resolveName(qname(namespace(NS_PackageInternal, "flash.utils"), name));
|
|
59
|
+
const o = rt.constructClass(cls, []);
|
|
60
|
+
o.$amf = stream;
|
|
61
|
+
return o;
|
|
62
|
+
}
|
|
63
|
+
/** The traits a class's instances have, and their superclasses', for tests of what a value is. */
|
|
64
|
+
function isA(traits, name) {
|
|
65
|
+
for (let t = traits; t; t = t.base) {
|
|
66
|
+
if (t.name === name) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/** The kind of Vector a value is, or 0. */
|
|
73
|
+
function vectorKind(traits) {
|
|
74
|
+
if (traits.cls?.$param === "float") {
|
|
75
|
+
return kVectorFloat;
|
|
76
|
+
}
|
|
77
|
+
for (let t = traits; t; t = t.base) {
|
|
78
|
+
const kind = VECTOR_KINDS[t.name];
|
|
79
|
+
if (kind) {
|
|
80
|
+
return kind;
|
|
81
|
+
}
|
|
82
|
+
if (t.name === "__AS3__.vec::Vector$object") {
|
|
83
|
+
return kVectorObject;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* As ClassInfo's constructor for output: the public variables (not
|
|
90
|
+
* constants) and the public accessors with both a getter and a setter, of
|
|
91
|
+
* the traits and then their bases', but [Transient] ones.
|
|
92
|
+
*/
|
|
93
|
+
function classInfoOf(rt, traits) {
|
|
94
|
+
// An IExternalizable writes itself, and is read back as its alias's class.
|
|
95
|
+
if (isExternalizable(rt, traits)) {
|
|
96
|
+
const name = rt.aliasOf(traits);
|
|
97
|
+
if (name === "") {
|
|
98
|
+
throw rt.error("ArgumentError", 2004);
|
|
99
|
+
}
|
|
100
|
+
return { name, sealed: [], dynamic: traits.dynamic, externalizable: true };
|
|
101
|
+
}
|
|
102
|
+
const sealed = [];
|
|
103
|
+
for (let t = traits; t; t = t.base) {
|
|
104
|
+
for (const [name, list] of t.bindings) {
|
|
105
|
+
for (const b of list) {
|
|
106
|
+
const kind = b.value & 7;
|
|
107
|
+
const isPublic = b.ns.kind === NS_Public && b.ns.uri === "" && b.version <= rt.apiVersion;
|
|
108
|
+
if (isPublic && (kind === 2 || kind === 7) && !traits.isTransient(b.value)) {
|
|
109
|
+
sealed.push(name);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { name: rt.aliasOf(traits), sealed, dynamic: traits.dynamic, externalizable: false };
|
|
115
|
+
}
|
|
116
|
+
/** An AMF3 writer over a ByteArray, for one writeObject. */
|
|
117
|
+
export class Writer {
|
|
118
|
+
rt;
|
|
119
|
+
out;
|
|
120
|
+
strings = new Map();
|
|
121
|
+
objects = new Map();
|
|
122
|
+
traits = new Map();
|
|
123
|
+
littleEndian = false;
|
|
124
|
+
objectEncoding = 3;
|
|
125
|
+
constructor(rt, out) {
|
|
126
|
+
this.rt = rt;
|
|
127
|
+
this.out = out;
|
|
128
|
+
}
|
|
129
|
+
get bytes() {
|
|
130
|
+
return this.out;
|
|
131
|
+
}
|
|
132
|
+
u8(v) {
|
|
133
|
+
const at = this.out.shortWrite(1);
|
|
134
|
+
this.out.buffer[at] = v;
|
|
135
|
+
}
|
|
136
|
+
/** As WriteUint29: 1 to 4 bytes; 2^29 and above a RangeError. */
|
|
137
|
+
uint29(ref) {
|
|
138
|
+
if (ref < 0x80) {
|
|
139
|
+
this.u8(ref);
|
|
140
|
+
}
|
|
141
|
+
else if (ref < 0x4000) {
|
|
142
|
+
this.u8(((ref >> 7) & 0x7f) | 0x80);
|
|
143
|
+
this.u8(ref & 0x7f);
|
|
144
|
+
}
|
|
145
|
+
else if (ref < 0x200000) {
|
|
146
|
+
this.u8(((ref >> 14) & 0x7f) | 0x80);
|
|
147
|
+
this.u8(((ref >> 7) & 0x7f) | 0x80);
|
|
148
|
+
this.u8(ref & 0x7f);
|
|
149
|
+
}
|
|
150
|
+
else if (ref < 0x40000000) {
|
|
151
|
+
this.u8(((ref >> 22) & 0x7f) | 0x80);
|
|
152
|
+
this.u8(((ref >> 15) & 0x7f) | 0x80);
|
|
153
|
+
this.u8(((ref >> 8) & 0x7f) | 0x80);
|
|
154
|
+
this.u8(ref & 0xff);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
throw this.rt.error("RangeError", 2006);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
double(v) {
|
|
161
|
+
const at = this.out.shortWrite(8);
|
|
162
|
+
this.out.view.setFloat64(at, v, false);
|
|
163
|
+
}
|
|
164
|
+
/** As WriteString: the empty string as 1, else a reference to it or its UTF-8. */
|
|
165
|
+
string(s) {
|
|
166
|
+
if (s.length === 0) {
|
|
167
|
+
this.uint29(1);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const ref = this.strings.get(s);
|
|
171
|
+
if (ref !== undefined) {
|
|
172
|
+
this.uint29(ref << 1);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.strings.set(s, this.strings.size);
|
|
176
|
+
const bytes = utf8(s);
|
|
177
|
+
this.uint29((bytes.length << 1) | 1);
|
|
178
|
+
this.out.write(bytes);
|
|
179
|
+
}
|
|
180
|
+
/** A reference to an object already written, or false, adding it to the table. */
|
|
181
|
+
reference(o) {
|
|
182
|
+
const ref = this.objects.get(o);
|
|
183
|
+
if (ref !== undefined) {
|
|
184
|
+
this.uint29(ref << 1);
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
this.objects.set(o, this.objects.size);
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
/** As WriteAtom. */
|
|
191
|
+
value(v) {
|
|
192
|
+
const rt = this.rt;
|
|
193
|
+
if (v instanceof FloatValue) {
|
|
194
|
+
this.u8(kFloat);
|
|
195
|
+
const at = this.out.shortWrite(4);
|
|
196
|
+
this.out.view.setFloat32(at, v.value);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
switch (typeof v) {
|
|
200
|
+
case "undefined":
|
|
201
|
+
this.u8(kUndefined);
|
|
202
|
+
return;
|
|
203
|
+
case "boolean":
|
|
204
|
+
this.u8(v ? kTrue : kFalse);
|
|
205
|
+
return;
|
|
206
|
+
case "number":
|
|
207
|
+
if (Number.isInteger(v) && !Object.is(v, -0) && v >= -0x10000000 && v < 0x10000000) {
|
|
208
|
+
this.u8(kInteger);
|
|
209
|
+
this.uint29(v & 0x1fffffff);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this.u8(kDouble);
|
|
213
|
+
this.double(v);
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
case "string":
|
|
217
|
+
this.u8(kString);
|
|
218
|
+
this.string(v);
|
|
219
|
+
return;
|
|
220
|
+
default:
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
if (v === null) {
|
|
224
|
+
this.u8(kNull);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// Functions are not serialized.
|
|
228
|
+
if (v.$f) {
|
|
229
|
+
this.u8(kUndefined);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const traits = rt.traitsOf(v);
|
|
233
|
+
if (isA(traits, "Date")) {
|
|
234
|
+
// As WriteDate: in the objects' table; new, an odd reference, 1, then its time.
|
|
235
|
+
this.u8(kDate);
|
|
236
|
+
if (!this.reference(v)) {
|
|
237
|
+
this.uint29(1);
|
|
238
|
+
this.double(v.$time ?? Number.NaN);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else if (isA(traits, "Array")) {
|
|
242
|
+
this.u8(kArray);
|
|
243
|
+
this.array(v);
|
|
244
|
+
}
|
|
245
|
+
else if (isA(traits, "flash.utils::ByteArray")) {
|
|
246
|
+
this.u8(kByteArray);
|
|
247
|
+
if (!this.reference(v)) {
|
|
248
|
+
const b = bytesOf(rt, v);
|
|
249
|
+
this.uint29((b.length << 1) | 1);
|
|
250
|
+
this.out.write(b.buffer.slice(0, b.length));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (vectorKind(traits)) {
|
|
254
|
+
this.vector(v, vectorKind(traits));
|
|
255
|
+
}
|
|
256
|
+
else if (isA(traits, "flash.utils::Dictionary")) {
|
|
257
|
+
this.dictionary(v);
|
|
258
|
+
}
|
|
259
|
+
else if (isA(traits, "XML")) {
|
|
260
|
+
// As WriteXML: toXMLString, as toString leaves out a simple element's tags.
|
|
261
|
+
this.u8(kXml);
|
|
262
|
+
if (!this.reference(v)) {
|
|
263
|
+
const bytes = utf8(xmlToXMLString(rt, v.$node));
|
|
264
|
+
this.uint29((bytes.length << 1) | 1);
|
|
265
|
+
this.out.write(bytes);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
this.u8(kObject);
|
|
270
|
+
this.object(v, traits);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* As WriteDictionary: a reference, or how many entries, whether its keys
|
|
275
|
+
* are weak, then each key and value. A name is a string, as avmplus writes
|
|
276
|
+
* the integer names its table holds, and an object key the object.
|
|
277
|
+
*/
|
|
278
|
+
dictionary(d) {
|
|
279
|
+
this.u8(kDictionary);
|
|
280
|
+
if (this.reference(d)) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const rt = this.rt;
|
|
284
|
+
const names = rt.enumerableNames(d);
|
|
285
|
+
const keys = d.$keys ? [...d.$keys] : [];
|
|
286
|
+
this.uint29(((names.length + keys.length) << 1) | 1);
|
|
287
|
+
this.u8(d.$weakKeys ? 1 : 0);
|
|
288
|
+
for (const name of names) {
|
|
289
|
+
this.value(name);
|
|
290
|
+
this.value(rt.getProperty(d, publicQname(name, rt.userVersions)));
|
|
291
|
+
}
|
|
292
|
+
for (const [key, value] of keys) {
|
|
293
|
+
this.value(key);
|
|
294
|
+
this.value(value);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/** As WriteArray: the dense part up to the first hole or function, then the rest by name. */
|
|
298
|
+
array(a) {
|
|
299
|
+
if (this.reference(a)) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const rt = this.rt;
|
|
303
|
+
const elements = a.$a;
|
|
304
|
+
let dense = elements.length;
|
|
305
|
+
for (let i = 0; i < elements.length; i++) {
|
|
306
|
+
if (!(i in elements)) {
|
|
307
|
+
dense = i;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
for (let i = 0; i < dense; i++) {
|
|
312
|
+
if (elements[i]?.$f) {
|
|
313
|
+
dense = i;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
this.uint29((dense << 1) | 1);
|
|
318
|
+
for (const name of rt.enumerableNames(a)) {
|
|
319
|
+
const index = Number(name);
|
|
320
|
+
if (Number.isInteger(index) && index >= 0 && index < dense && String(index) === name) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const value = rt.getProperty(a, publicQname(name, rt.userVersions));
|
|
324
|
+
if (value?.$f) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
this.string(name);
|
|
328
|
+
this.value(value);
|
|
329
|
+
}
|
|
330
|
+
this.string("");
|
|
331
|
+
for (let i = 0; i < dense; i++) {
|
|
332
|
+
this.value(elements[i]);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/** As WriteTypedVector. */
|
|
336
|
+
vector(v, kind) {
|
|
337
|
+
this.u8(kind);
|
|
338
|
+
if (this.reference(v)) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const elements = v.$a;
|
|
342
|
+
this.uint29((elements.length << 1) | 1);
|
|
343
|
+
this.u8(v.$fixed ? 1 : 0);
|
|
344
|
+
// A numeric Vector's elements in bytes reserved at once, which may move
|
|
345
|
+
// the buffer: its view is read after.
|
|
346
|
+
if (kind === kVectorFloat) {
|
|
347
|
+
const at = this.out.shortWrite(elements.length * 4);
|
|
348
|
+
const view = this.out.view;
|
|
349
|
+
for (let i = 0; i < elements.length; i++) {
|
|
350
|
+
view.setFloat32(at + i * 4, v.$a.data[i]);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else if (kind === kVectorDouble) {
|
|
354
|
+
const at = this.out.shortWrite(elements.length * 8);
|
|
355
|
+
const view = this.out.view;
|
|
356
|
+
for (let i = 0; i < elements.length; i++) {
|
|
357
|
+
view.setFloat64(at + i * 8, elements[i], false);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
else if (kind === kVectorInt || kind === kVectorUint) {
|
|
361
|
+
const at = this.out.shortWrite(elements.length * 4);
|
|
362
|
+
const view = this.out.view;
|
|
363
|
+
for (let i = 0; i < elements.length; i++) {
|
|
364
|
+
view.setUint32(at + i * 4, elements[i] >>> 0);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
const param = v.$traits.cls.$param;
|
|
369
|
+
this.string(param ? this.rt.aliasOf(this.rt.classOf(param).$it) : "*");
|
|
370
|
+
for (const e of elements) {
|
|
371
|
+
this.value(e);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/** As WriteScriptObject: its class, by reference or described, then its sealed and dynamic properties. */
|
|
376
|
+
object(o, traits) {
|
|
377
|
+
if (this.reference(o)) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
let known = this.traits.get(traits);
|
|
381
|
+
if (known) {
|
|
382
|
+
this.uint29((known[0] << 2) | 1);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
const info = classInfoOf(this.rt, traits);
|
|
386
|
+
known = [this.traits.size, info];
|
|
387
|
+
this.traits.set(traits, known);
|
|
388
|
+
const flags = (info.externalizable ? 4 : 0) | (info.dynamic ? 8 : 0);
|
|
389
|
+
this.uint29(3 | flags | (info.sealed.length << 4));
|
|
390
|
+
this.string(info.name);
|
|
391
|
+
for (const name of info.sealed) {
|
|
392
|
+
this.string(name);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const info = known[1];
|
|
396
|
+
if (info.externalizable) {
|
|
397
|
+
const write = this.rt.getProperty(o, publicQname("writeExternal", this.rt.userVersions));
|
|
398
|
+
if (write?.$f) {
|
|
399
|
+
this.rt.callValue(write, o, [externalStream(this.rt, "ObjectOutput", this)], null);
|
|
400
|
+
}
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
for (const name of info.sealed) {
|
|
404
|
+
this.value(this.rt.getProperty(o, publicQname(name, this.rt.userVersions)));
|
|
405
|
+
}
|
|
406
|
+
if (info.dynamic) {
|
|
407
|
+
const writer = this.rt.dynamicPropertyWriter;
|
|
408
|
+
if (writer) {
|
|
409
|
+
this.dynamicProperties(writer, o);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
for (const name of this.rt.enumerableNames(o)) {
|
|
413
|
+
const value = this.rt.getProperty(o, publicQname(name, this.rt.userVersions));
|
|
414
|
+
if (value?.$f || name.length === 0) {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
this.string(name);
|
|
418
|
+
this.value(value);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
this.string("");
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* As ObjectEncoding.dynamicPropertyWriter has it: its
|
|
426
|
+
* writeDynamicProperties called with the object and a
|
|
427
|
+
* DynamicPropertyOutput that writes here, if it is an object.
|
|
428
|
+
*/
|
|
429
|
+
dynamicProperties(writer, o) {
|
|
430
|
+
const rt = this.rt;
|
|
431
|
+
const f = rt.getProperty(writer, publicQname("writeDynamicProperties", rt.userVersions));
|
|
432
|
+
if (f === null || typeof f !== "object") {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const cls = rt.resolveName(qname(namespace(NS_PackageInternal, "flash.net"), "DynamicPropertyOutput"));
|
|
436
|
+
const output = rt.constructClass(cls, []);
|
|
437
|
+
output.$amf = this;
|
|
438
|
+
rt.callValue(f, writer, [o, output], null);
|
|
439
|
+
}
|
|
440
|
+
/** As WriteDynamicProperty: a name and its value, whatever they are. */
|
|
441
|
+
dynamicProperty(name, value) {
|
|
442
|
+
this.string(name);
|
|
443
|
+
this.value(value);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/** An AMF3 reader over a ByteArray, for one readObject. */
|
|
447
|
+
export class Reader {
|
|
448
|
+
rt;
|
|
449
|
+
input;
|
|
450
|
+
strings = [];
|
|
451
|
+
objects = [];
|
|
452
|
+
classes = [];
|
|
453
|
+
littleEndian = false;
|
|
454
|
+
objectEncoding = 3;
|
|
455
|
+
constructor(rt, input) {
|
|
456
|
+
this.rt = rt;
|
|
457
|
+
this.input = input;
|
|
458
|
+
}
|
|
459
|
+
get bytes() {
|
|
460
|
+
return this.input;
|
|
461
|
+
}
|
|
462
|
+
u8() {
|
|
463
|
+
const at = this.input.shortRead(1);
|
|
464
|
+
return this.input.buffer[at];
|
|
465
|
+
}
|
|
466
|
+
/** As ReadUint29. */
|
|
467
|
+
uint29() {
|
|
468
|
+
let byte = this.u8();
|
|
469
|
+
if (byte < 128) {
|
|
470
|
+
return byte;
|
|
471
|
+
}
|
|
472
|
+
let ref = (byte & 0x7f) << 7;
|
|
473
|
+
byte = this.u8();
|
|
474
|
+
if (byte < 128) {
|
|
475
|
+
return ref | byte;
|
|
476
|
+
}
|
|
477
|
+
ref = (ref | (byte & 0x7f)) << 7;
|
|
478
|
+
byte = this.u8();
|
|
479
|
+
if (byte < 128) {
|
|
480
|
+
return ref | byte;
|
|
481
|
+
}
|
|
482
|
+
ref = (ref | (byte & 0x7f)) << 8;
|
|
483
|
+
return (ref | this.u8()) >>> 0;
|
|
484
|
+
}
|
|
485
|
+
double() {
|
|
486
|
+
const at = this.input.shortRead(8);
|
|
487
|
+
return this.input.view.getFloat64(at);
|
|
488
|
+
}
|
|
489
|
+
u32() {
|
|
490
|
+
const at = this.input.shortRead(4);
|
|
491
|
+
return this.input.view.getUint32(at);
|
|
492
|
+
}
|
|
493
|
+
find(list, i) {
|
|
494
|
+
if (i >= list.length) {
|
|
495
|
+
throw this.rt.error("RangeError", 2006);
|
|
496
|
+
}
|
|
497
|
+
return list[i];
|
|
498
|
+
}
|
|
499
|
+
/** As ReadString. */
|
|
500
|
+
string() {
|
|
501
|
+
const ref = this.uint29();
|
|
502
|
+
if ((ref & 1) === 0) {
|
|
503
|
+
return this.find(this.strings, ref >>> 1);
|
|
504
|
+
}
|
|
505
|
+
const length = ref >>> 1;
|
|
506
|
+
if (length === 0) {
|
|
507
|
+
return "";
|
|
508
|
+
}
|
|
509
|
+
// A short ASCII string straight from the input, a character at a time;
|
|
510
|
+
// any other through fromUtf8.
|
|
511
|
+
const input = this.input;
|
|
512
|
+
const at = input.position;
|
|
513
|
+
if (length < 16 && input.available >= length) {
|
|
514
|
+
const b = input.buffer;
|
|
515
|
+
let ascii = "";
|
|
516
|
+
let k = 0;
|
|
517
|
+
for (; k < length && b[at + k] < 0x80; k++) {
|
|
518
|
+
ascii += String.fromCharCode(b[at + k]);
|
|
519
|
+
}
|
|
520
|
+
if (k === length) {
|
|
521
|
+
input.position = (at + length) >>> 0;
|
|
522
|
+
this.strings.push(ascii);
|
|
523
|
+
return ascii;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const s = fromUtf8(input.readView(length));
|
|
527
|
+
this.strings.push(s);
|
|
528
|
+
return s;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* As ObjectInput::SetObjectProperty: a property that cannot be set, as on
|
|
532
|
+
* a sealed class, is skipped, the error written to the console.
|
|
533
|
+
*/
|
|
534
|
+
set(o, name, value) {
|
|
535
|
+
try {
|
|
536
|
+
this.rt.setProperty(o, publicQname(name, this.rt.userVersions), value);
|
|
537
|
+
}
|
|
538
|
+
catch (e) {
|
|
539
|
+
if (e instanceof Error) {
|
|
540
|
+
throw e;
|
|
541
|
+
}
|
|
542
|
+
this.rt.print(this.rt.toString(e));
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
/** As ReadAtom. */
|
|
546
|
+
/** As ReadDictionary: a reference, or its entries, each key a string or an object; anything else is 2004. */
|
|
547
|
+
dictionary() {
|
|
548
|
+
const rt = this.rt;
|
|
549
|
+
const ref = this.uint29();
|
|
550
|
+
if ((ref & 1) === 0) {
|
|
551
|
+
return this.find(this.objects, ref >>> 1);
|
|
552
|
+
}
|
|
553
|
+
const length = ref >>> 1;
|
|
554
|
+
const weakKeys = this.u8() !== 0;
|
|
555
|
+
const d = rt.constructClass(rt.dictionaryClass(), [weakKeys]);
|
|
556
|
+
this.objects.push(d);
|
|
557
|
+
for (let i = 0; i < length; i++) {
|
|
558
|
+
const key = this.value();
|
|
559
|
+
const value = this.value();
|
|
560
|
+
if (typeof key === "string") {
|
|
561
|
+
rt.setProperty(d, publicQname(key, rt.userVersions), value);
|
|
562
|
+
}
|
|
563
|
+
else if (typeof key === "object" && key !== null) {
|
|
564
|
+
d.$keys.set(key, value);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
throw rt.error("ArgumentError", 2004);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return d;
|
|
571
|
+
}
|
|
572
|
+
value() {
|
|
573
|
+
const rt = this.rt;
|
|
574
|
+
const type = this.u8();
|
|
575
|
+
switch (type) {
|
|
576
|
+
case kUndefined:
|
|
577
|
+
return undefined;
|
|
578
|
+
case kNull:
|
|
579
|
+
return null;
|
|
580
|
+
case kFalse:
|
|
581
|
+
return false;
|
|
582
|
+
case kTrue:
|
|
583
|
+
return true;
|
|
584
|
+
case kInteger:
|
|
585
|
+
return (this.uint29() << 3) >> 3;
|
|
586
|
+
case kFloat: {
|
|
587
|
+
const at = this.input.shortRead(4);
|
|
588
|
+
return rt.float(this.input.view.getFloat32(at));
|
|
589
|
+
}
|
|
590
|
+
case kDouble:
|
|
591
|
+
return this.double();
|
|
592
|
+
case kString:
|
|
593
|
+
return this.string();
|
|
594
|
+
case kDictionary:
|
|
595
|
+
return this.dictionary();
|
|
596
|
+
case kDate: {
|
|
597
|
+
// As ReadDate: a reference, or a new Date of the time that follows.
|
|
598
|
+
const ref = this.uint29();
|
|
599
|
+
if ((ref & 1) === 0) {
|
|
600
|
+
return this.find(this.objects, ref >>> 1);
|
|
601
|
+
}
|
|
602
|
+
const date = rt.constructClass(rt.builtinClass("Date"), []);
|
|
603
|
+
date.$time = this.double();
|
|
604
|
+
this.objects.push(date);
|
|
605
|
+
return date;
|
|
606
|
+
}
|
|
607
|
+
case kArray:
|
|
608
|
+
return this.array();
|
|
609
|
+
case kObject:
|
|
610
|
+
return this.object();
|
|
611
|
+
case kByteArray: {
|
|
612
|
+
const ref = this.uint29();
|
|
613
|
+
if ((ref & 1) === 0) {
|
|
614
|
+
return this.find(this.objects, ref >>> 1);
|
|
615
|
+
}
|
|
616
|
+
const o = rt.constructClass(rt.byteArrayClass(), []);
|
|
617
|
+
this.objects.push(o);
|
|
618
|
+
const length = ref >>> 1;
|
|
619
|
+
const b = bytesOf(rt, o);
|
|
620
|
+
b.setLength(length);
|
|
621
|
+
b.buffer.set(this.input.readView(length));
|
|
622
|
+
return o;
|
|
623
|
+
}
|
|
624
|
+
case kVectorInt:
|
|
625
|
+
case kVectorUint:
|
|
626
|
+
case kVectorDouble:
|
|
627
|
+
case kVectorObject:
|
|
628
|
+
case kVectorFloat:
|
|
629
|
+
return this.vector(type);
|
|
630
|
+
case kXmlDocument:
|
|
631
|
+
case kXml: {
|
|
632
|
+
// As ReadXML: an XMLDocument's too is read as XML, made from its text.
|
|
633
|
+
const ref = this.uint29();
|
|
634
|
+
if ((ref & 1) === 0) {
|
|
635
|
+
return this.find(this.objects, ref >>> 1);
|
|
636
|
+
}
|
|
637
|
+
const text = fromUtf8(this.input.readView(ref >>> 1));
|
|
638
|
+
const xml = rt.constructClass(rt.builtinClass("XML"), [text]);
|
|
639
|
+
this.objects.push(xml);
|
|
640
|
+
return xml;
|
|
641
|
+
}
|
|
642
|
+
default:
|
|
643
|
+
throw rt.error("RangeError", 2006);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
/** As ReadArray: the named part first, then the dense one. */
|
|
647
|
+
array() {
|
|
648
|
+
const rt = this.rt;
|
|
649
|
+
const ref = this.uint29();
|
|
650
|
+
if ((ref & 1) === 0) {
|
|
651
|
+
return this.find(this.objects, ref >>> 1);
|
|
652
|
+
}
|
|
653
|
+
const length = ref >>> 1;
|
|
654
|
+
const a = rt.array(new Array(length));
|
|
655
|
+
this.objects.push(a);
|
|
656
|
+
for (;;) {
|
|
657
|
+
const name = this.string();
|
|
658
|
+
if (name.length === 0) {
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
this.set(a, name, this.value());
|
|
662
|
+
}
|
|
663
|
+
for (let i = 0; i < length; i++) {
|
|
664
|
+
a.$a[i] = this.value();
|
|
665
|
+
}
|
|
666
|
+
return a;
|
|
667
|
+
}
|
|
668
|
+
/** As ReadTypedVector. */
|
|
669
|
+
vector(type) {
|
|
670
|
+
const rt = this.rt;
|
|
671
|
+
const ref = this.uint29();
|
|
672
|
+
if ((ref & 1) === 0) {
|
|
673
|
+
return this.find(this.objects, ref >>> 1);
|
|
674
|
+
}
|
|
675
|
+
const length = ref >>> 1;
|
|
676
|
+
const fixed = this.u8() !== 0;
|
|
677
|
+
let cls;
|
|
678
|
+
if (type === kVectorObject) {
|
|
679
|
+
const name = this.string();
|
|
680
|
+
// As getClassClosureFromAlias: a class with no alias, as String, reads as Object.
|
|
681
|
+
const param = name === "*" ? null : rt.classByAlias(name, true);
|
|
682
|
+
cls = rt.vectorClass(param);
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
cls = rt.vectorClass(rt.builtinClass(type === kVectorInt
|
|
686
|
+
? "int"
|
|
687
|
+
: type === kVectorUint
|
|
688
|
+
? "uint"
|
|
689
|
+
: type === kVectorFloat
|
|
690
|
+
? "float"
|
|
691
|
+
: "Number"));
|
|
692
|
+
}
|
|
693
|
+
const v = rt.constructClass(cls, [length]);
|
|
694
|
+
this.objects.push(v);
|
|
695
|
+
// A numeric Vector's elements, when all are there, at once: into its
|
|
696
|
+
// storage, each as its type reads it. Else each on its own, to fail
|
|
697
|
+
// where avmplus does; an empty one reads none, even at the end, where
|
|
698
|
+
// shortRead would fail even for no bytes.
|
|
699
|
+
const size = type === kVectorDouble ? 8 : 4;
|
|
700
|
+
if (type !== kVectorObject && length > 0 && this.input.available >= length * size) {
|
|
701
|
+
const at = this.input.shortRead(length * size);
|
|
702
|
+
const view = this.input.view;
|
|
703
|
+
const elements = v.$a;
|
|
704
|
+
for (let i = 0; i < length; i++) {
|
|
705
|
+
if (type === kVectorFloat) {
|
|
706
|
+
v.$a.data[i] = view.getFloat32(at + i * 4);
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
elements[i] =
|
|
710
|
+
type === kVectorDouble
|
|
711
|
+
? view.getFloat64(at + i * 8)
|
|
712
|
+
: type === kVectorInt
|
|
713
|
+
? view.getInt32(at + i * 4)
|
|
714
|
+
: view.getUint32(at + i * 4);
|
|
715
|
+
}
|
|
716
|
+
v.$fixed = fixed;
|
|
717
|
+
return v;
|
|
718
|
+
}
|
|
719
|
+
// Each element through the Vector's own setter, which converts it to
|
|
720
|
+
// its type, as setProperty would reach it for an index.
|
|
721
|
+
const setIndex = v.$traits.setIndex;
|
|
722
|
+
for (let i = 0; i < length; i++) {
|
|
723
|
+
const value = type === kVectorDouble
|
|
724
|
+
? this.double()
|
|
725
|
+
: type === kVectorFloat
|
|
726
|
+
? rt.float(this.input.view.getFloat32(this.input.shortRead(4)))
|
|
727
|
+
: type === kVectorObject
|
|
728
|
+
? this.value()
|
|
729
|
+
: this.u32();
|
|
730
|
+
setIndex(v, i, value, rt);
|
|
731
|
+
}
|
|
732
|
+
v.$fixed = fixed;
|
|
733
|
+
return v;
|
|
734
|
+
}
|
|
735
|
+
/** As ReadScriptObject: its class, by reference or described, an instance of it, then its properties. */
|
|
736
|
+
object() {
|
|
737
|
+
const rt = this.rt;
|
|
738
|
+
const ref = this.uint29();
|
|
739
|
+
if ((ref & 1) === 0) {
|
|
740
|
+
return this.find(this.objects, ref >>> 1);
|
|
741
|
+
}
|
|
742
|
+
let entry;
|
|
743
|
+
if ((ref & 3) === 1) {
|
|
744
|
+
entry = this.find(this.classes, ref >>> 2);
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
const externalizable = (ref & 4) !== 0;
|
|
748
|
+
const dynamic = (ref & 8) !== 0;
|
|
749
|
+
const count = ref >>> 4;
|
|
750
|
+
const name = this.string();
|
|
751
|
+
const sealed = [];
|
|
752
|
+
for (let i = 0; i < count; i++) {
|
|
753
|
+
sealed.push(this.string());
|
|
754
|
+
}
|
|
755
|
+
// An unknown alias reads as an Object, which cannot read itself.
|
|
756
|
+
const cls = rt.classByAlias(name, true);
|
|
757
|
+
if (externalizable && !isExternalizable(rt, cls.$it)) {
|
|
758
|
+
throw rt.error("ArgumentError", 2173, name);
|
|
759
|
+
}
|
|
760
|
+
entry = [{ name, sealed, dynamic, externalizable }, cls];
|
|
761
|
+
this.classes.push(entry);
|
|
762
|
+
}
|
|
763
|
+
const [info, cls] = entry;
|
|
764
|
+
const o = rt.constructClass(cls, []);
|
|
765
|
+
this.objects.push(o);
|
|
766
|
+
if (info.externalizable) {
|
|
767
|
+
const read = rt.getProperty(o, publicQname("readExternal", rt.userVersions));
|
|
768
|
+
if (read?.$f) {
|
|
769
|
+
rt.callValue(read, o, [externalStream(rt, "ObjectInput", this)], null);
|
|
770
|
+
}
|
|
771
|
+
return o;
|
|
772
|
+
}
|
|
773
|
+
for (const name of info.sealed) {
|
|
774
|
+
this.set(o, name, this.value());
|
|
775
|
+
}
|
|
776
|
+
if (info.dynamic) {
|
|
777
|
+
for (;;) {
|
|
778
|
+
const name = this.string();
|
|
779
|
+
if (name.length === 0) {
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
this.set(o, name, this.value());
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return o;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
/** As Toplevel::writeObject: AMF3 only, as avmshell has no AMF0. */
|
|
789
|
+
export function writeObject(rt, b, v) {
|
|
790
|
+
if (b.objectEncoding < 3) {
|
|
791
|
+
throw rt.error("ArgumentError", 1508, "objectEncoding");
|
|
792
|
+
}
|
|
793
|
+
new Writer(rt, b).value(v);
|
|
794
|
+
}
|
|
795
|
+
/** As Toplevel::readObject. */
|
|
796
|
+
export function readObject(rt, b) {
|
|
797
|
+
if (b.objectEncoding < 3) {
|
|
798
|
+
throw rt.error("ArgumentError", 1508, "objectEncoding");
|
|
799
|
+
}
|
|
800
|
+
return new Reader(rt, b).value();
|
|
801
|
+
}
|