@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,245 @@
|
|
|
1
|
+
// SharedObject, AS1 and AS2's local kind, as Ruffle's (https://github.com/
|
|
2
|
+
// ruffle-rs/ruffle) core/src/avm1/globals/shared_object.rs and
|
|
3
|
+
// core/src/avm1/amf.rs have it: MIT OR Apache-2.0, Copyright (c) 2018-2022
|
|
4
|
+
// Ruffle LLC and Ruffle contributors. Its data is kept in the host's
|
|
5
|
+
// storage as the .sol file Flash writes for AVM1, AMF0, under the key AS3's
|
|
6
|
+
// SharedObject uses (playerglobal/flash/net/SharedObject.ts), so that
|
|
7
|
+
// one SWF's saves are found whichever AVM reads them.
|
|
8
|
+
//
|
|
9
|
+
// A .sol file: 0x00BF, the length of what follows, "TCSO", 00 04 00 00 00
|
|
10
|
+
// 00, the name (u16 length, UTF-8), the AMF version as a u32 (0 here), then
|
|
11
|
+
// each of the data's properties: its name (u16 length), its AMF0 value, a 0.
|
|
12
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
13
|
+
import { put, Reader, Writer } from "../amf.js";
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
/** What a name may not hold, white space included: getLocal then gives null (adl; Ruffle's INVALID_CHARS). */
|
|
16
|
+
const BAD_NAME = /[~%&\\;:"',<>?#\s]/;
|
|
17
|
+
/** The .sol file of `data` under `name`: empty for no properties, as Flash writes none. */
|
|
18
|
+
function serialize(host, name, data, version) {
|
|
19
|
+
if (!(data instanceof avm1.Avm1Object)) {
|
|
20
|
+
return new Uint8Array(0);
|
|
21
|
+
}
|
|
22
|
+
const body = new Writer((c) => host.registeredName(c), version, data);
|
|
23
|
+
// Each property a name, a value and a 0, the object's own references shared across them.
|
|
24
|
+
const entry = new Writer((c) => host.registeredName(c), version, data);
|
|
25
|
+
for (const key of avm1.keys(data, version).reverse()) {
|
|
26
|
+
const v = avm1.find(data, key, version)?.get ? undefined : avm1.get(data, key, version);
|
|
27
|
+
if (v instanceof avm1.Avm1Function) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
entry.name(key);
|
|
31
|
+
entry.value(v);
|
|
32
|
+
entry.bytes(0);
|
|
33
|
+
}
|
|
34
|
+
if (entry.size === 0) {
|
|
35
|
+
return new Uint8Array(0);
|
|
36
|
+
}
|
|
37
|
+
const title = encoder.encode(name).subarray(0, 0xffff);
|
|
38
|
+
body.bytes(0x00, 0xbf);
|
|
39
|
+
body.u32(0);
|
|
40
|
+
body.bytes(0x54, 0x43, 0x53, 0x4f, 0, 4, 0, 0, 0, 0);
|
|
41
|
+
body.u16(title.length);
|
|
42
|
+
body.push(title);
|
|
43
|
+
body.u32(0);
|
|
44
|
+
body.push(entry.finish());
|
|
45
|
+
const file = body.finish();
|
|
46
|
+
new DataView(file.buffer).setUint32(2, file.length - 6);
|
|
47
|
+
return file;
|
|
48
|
+
}
|
|
49
|
+
/** The data a .sol file holds, or null for one that is not AMF0's or cannot be read. */
|
|
50
|
+
function deserialize(bytes, realm, version) {
|
|
51
|
+
if (bytes.length < 18 || bytes[0] !== 0x00 || bytes[1] !== 0xbf) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const reader = new Reader(bytes, realm, version, true, Infinity);
|
|
55
|
+
const data = realm.newObject(version);
|
|
56
|
+
try {
|
|
57
|
+
reader.at = 16;
|
|
58
|
+
reader.name();
|
|
59
|
+
// An AMF3 file, AS3's, is not AS2's to read.
|
|
60
|
+
if (reader.u32() !== 0) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
while (reader.at < bytes.length) {
|
|
64
|
+
const key = reader.name();
|
|
65
|
+
put(data, key, reader.value(), version);
|
|
66
|
+
// The 0 after each value.
|
|
67
|
+
reader.at++;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return data;
|
|
74
|
+
}
|
|
75
|
+
const FIXED = avm1.DONT_ENUM | avm1.DONT_DELETE;
|
|
76
|
+
/** `_global.SharedObject`, and what writes its objects changed since read or written, as a player goes. */
|
|
77
|
+
export function sharedObjectClass(host) {
|
|
78
|
+
const realm = host.realm;
|
|
79
|
+
const proto = new avm1.Avm1Object(realm.objectProto);
|
|
80
|
+
const constr = realm.classOf(proto, (self) => self, () => undefined);
|
|
81
|
+
/** The objects getLocal made, by key, and what each was last read or written as. */
|
|
82
|
+
const open = new Map();
|
|
83
|
+
const entryOf = (self) => {
|
|
84
|
+
for (const entry of open.values()) {
|
|
85
|
+
if (entry.o === self) {
|
|
86
|
+
return entry;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
};
|
|
91
|
+
const method = (name, f) => proto.define(name, realm.method(f), FIXED);
|
|
92
|
+
const stub = () => undefined;
|
|
93
|
+
constr.define("getLocal", realm.method((_, args, v) => {
|
|
94
|
+
const name = avm1.stringOf(args[0], v);
|
|
95
|
+
if (name === "" || BAD_NAME.test(name)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
let url;
|
|
99
|
+
try {
|
|
100
|
+
url = new URL(host.url, "file:///");
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const secure = args.length > 2 && avm1.toBoolean(args[2], v);
|
|
106
|
+
if (secure && url.protocol !== "https:") {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
// The SWF's own path by default; a path it names must lead to the SWF, as AS3's.
|
|
110
|
+
const own = url.pathname.endsWith("/") ? `${url.pathname}[swf]` : url.pathname;
|
|
111
|
+
let path = own;
|
|
112
|
+
if (args.length > 1 && typeof args[1] === "string") {
|
|
113
|
+
path = args[1];
|
|
114
|
+
if (path === "") {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const directory = path.endsWith("/") ? path : `${path}/`;
|
|
118
|
+
if (path !== own && !own.startsWith(directory)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const key = `${url.host}${path.startsWith("/") ? "" : "/"}${path}/${name}${secure ? "#secure" : ""}`;
|
|
123
|
+
if (key.split("/").some((part) => part.startsWith("."))) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const known = open.get(key);
|
|
127
|
+
if (known) {
|
|
128
|
+
return known.o;
|
|
129
|
+
}
|
|
130
|
+
const o = new avm1.Avm1Object(avm1.get(constr, "prototype", v));
|
|
131
|
+
let stored = null;
|
|
132
|
+
try {
|
|
133
|
+
stored = host.storage.get(key);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
stored = null;
|
|
137
|
+
}
|
|
138
|
+
const data = (stored && deserialize(stored, realm, v)) ?? realm.newObject(v);
|
|
139
|
+
o.define("data", data, avm1.DONT_DELETE);
|
|
140
|
+
open.set(key, { o, name, saved: serialize(host, name, data, v) });
|
|
141
|
+
return o;
|
|
142
|
+
}), 0);
|
|
143
|
+
constr.define("getRemote", realm.method(stub), 0);
|
|
144
|
+
constr.define("deleteAll", realm.method(stub), avm1.DONT_ENUM);
|
|
145
|
+
constr.define("getDiskUsage", realm.method(stub), avm1.DONT_ENUM);
|
|
146
|
+
// Written now: true, or false where storage refuses it, a full quota say. Flash writes no
|
|
147
|
+
// empty one, and says it did.
|
|
148
|
+
method("flush", (self, _, v) => {
|
|
149
|
+
const entry = entryOf(self);
|
|
150
|
+
if (!entry) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
// Data nested too deep to write fails as a refused write does.
|
|
154
|
+
let file;
|
|
155
|
+
try {
|
|
156
|
+
file = serialize(host, entry.name, avm1.get(self, "data", v), v);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
if (file.length === 0) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
for (const [key, e] of open) {
|
|
165
|
+
if (e === entry) {
|
|
166
|
+
try {
|
|
167
|
+
host.storage.set(key, file);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
entry.saved = file;
|
|
175
|
+
return true;
|
|
176
|
+
});
|
|
177
|
+
// The file's size, header and all; 0 for none.
|
|
178
|
+
method("getSize", (self, _, v) => {
|
|
179
|
+
const entry = entryOf(self);
|
|
180
|
+
if (!entry) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
return serialize(host, entry.name, avm1.get(self, "data", v), v).length;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return 0;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
// Every property of the data deleted, and the file with them.
|
|
191
|
+
method("clear", (self, _, v) => {
|
|
192
|
+
const entry = entryOf(self);
|
|
193
|
+
const data = avm1.get(self, "data", v);
|
|
194
|
+
if (data instanceof avm1.Avm1Object) {
|
|
195
|
+
for (const key of avm1.keys(data, v)) {
|
|
196
|
+
avm1.removeOwn(data, key, v);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const [key, e] of open) {
|
|
200
|
+
if (e === entry) {
|
|
201
|
+
try {
|
|
202
|
+
host.storage.remove(key);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// Storage the host refuses keeps nothing to remove.
|
|
206
|
+
}
|
|
207
|
+
e.saved = new Uint8Array(0);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return undefined;
|
|
211
|
+
});
|
|
212
|
+
for (const name of ["connect", "send", "close", "setFps", "onStatus", "onSync"]) {
|
|
213
|
+
method(name, stub);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
constr,
|
|
217
|
+
// Flash wrote each open object as its SWF went: what a script changed since it was read or
|
|
218
|
+
// written. Never a removal: an object whose stored file could not be read starts empty.
|
|
219
|
+
flush(version) {
|
|
220
|
+
for (const [key, entry] of open) {
|
|
221
|
+
try {
|
|
222
|
+
const file = serialize(host, entry.name, avm1.get(entry.o, "data", version), version);
|
|
223
|
+
if (file.length && !sameBytes(file, entry.saved)) {
|
|
224
|
+
host.storage.set(key, file);
|
|
225
|
+
entry.saved = file;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// One that cannot be written keeps the others from nothing.
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function sameBytes(a, b) {
|
|
236
|
+
if (a.length !== b.length) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
for (let i = 0; i < a.length; i++) {
|
|
240
|
+
if (a[i] !== b[i]) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// Sound, AS1 and AS2's, as Ruffle's (https://github.com/ruffle-rs/ruffle)
|
|
2
|
+
// core/src/avm1/globals/sound.rs has it: MIT OR Apache-2.0, Copyright (c)
|
|
3
|
+
// 2018-2022 Ruffle LLC and Ruffle contributors. A Sound keeps its target
|
|
4
|
+
// as given and finds the clip again each time it is used: its transform is
|
|
5
|
+
// the clip's, which every sound under the clip plays by; with no target it
|
|
6
|
+
// is the global one, over every sound. The sounds it starts are the
|
|
7
|
+
// timeline's kind, held to the same 32 and stopped with them.
|
|
8
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
9
|
+
import { soundsOf, startScriptSound, stopSoundsOf, stopTimelineSound, stopTimelineSounds, } from "../../media/sounds.js";
|
|
10
|
+
export const FULL = {
|
|
11
|
+
volume: 100,
|
|
12
|
+
leftToLeft: 100,
|
|
13
|
+
leftToRight: 0,
|
|
14
|
+
rightToLeft: 0,
|
|
15
|
+
rightToRight: 100,
|
|
16
|
+
};
|
|
17
|
+
const FIXED = avm1.DONT_ENUM | avm1.DONT_DELETE | avm1.READ_ONLY;
|
|
18
|
+
/**
|
|
19
|
+
* A volume or pan as Windows' Flash Player 32 and AIR take it: a 32-bit
|
|
20
|
+
* integer, wrapped, NaN 0. Ruffle's corpus (`sound`) expects another
|
|
21
|
+
* player's, which saturates, NaN to -2^31: a game that sets its sounds'
|
|
22
|
+
* volume from a setting not yet loaded, undefined, gets 0 from Flash.
|
|
23
|
+
*/
|
|
24
|
+
function int32(n) {
|
|
25
|
+
return n | 0;
|
|
26
|
+
}
|
|
27
|
+
/** loops as Rust's `as u16` casts it, at least 1. */
|
|
28
|
+
function loopsOf(n) {
|
|
29
|
+
return Math.max(1, Number.isNaN(n) ? 0 : Math.trunc(Math.max(0, Math.min(0xffff, n))));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The pan as Flash gives it back from the left and right volumes (Ruffle's
|
|
33
|
+
* `sound` test): it is neither's plain difference.
|
|
34
|
+
*/
|
|
35
|
+
function panOf(t) {
|
|
36
|
+
return t.leftToLeft !== 100 ? 100 - Math.abs(t.leftToLeft) : Math.abs(t.rightToRight) - 100;
|
|
37
|
+
}
|
|
38
|
+
/** `_global.Sound`. */
|
|
39
|
+
export function soundClass(host) {
|
|
40
|
+
const realm = host.realm;
|
|
41
|
+
const h = host.sounds;
|
|
42
|
+
const states = new WeakMap();
|
|
43
|
+
const proto = new avm1.Avm1Object(realm.objectProto);
|
|
44
|
+
const constr = realm.classOf(proto, (self, args, v) => {
|
|
45
|
+
// The target is made a path now, a clip's too, its toString called once (the corpus's
|
|
46
|
+
// sound_owner_reference): a clip renamed is found by its path, as a variable or a child.
|
|
47
|
+
const given = args.length > 0 ? args[0] : undefined;
|
|
48
|
+
const target = given === undefined || given === null ? given : avm1.stringOf(given, v);
|
|
49
|
+
states.set(self, {
|
|
50
|
+
target,
|
|
51
|
+
character: null,
|
|
52
|
+
duration: undefined,
|
|
53
|
+
playing: null,
|
|
54
|
+
offset: 0,
|
|
55
|
+
position: 0,
|
|
56
|
+
});
|
|
57
|
+
return self;
|
|
58
|
+
}, () => undefined);
|
|
59
|
+
const global = (state) => state.target === undefined || state.target === null;
|
|
60
|
+
// The clip a targeted Sound works on, null where the target names none.
|
|
61
|
+
const owner = (state, v) => (global(state) ? null : host.resolve(state.target, v));
|
|
62
|
+
const valid = (state, v) => global(state) || owner(state, v) !== null;
|
|
63
|
+
// The transform it reads and sets: its clip's, or the global one; undefined for no clip.
|
|
64
|
+
const transformOf = (state, v) => {
|
|
65
|
+
if (global(state)) {
|
|
66
|
+
return host.soundTransform(null);
|
|
67
|
+
}
|
|
68
|
+
const d = owner(state, v);
|
|
69
|
+
return d === null ? undefined : host.soundTransform(d);
|
|
70
|
+
};
|
|
71
|
+
const setTransform = (state, v, f) => {
|
|
72
|
+
const g = global(state);
|
|
73
|
+
const d = g ? null : owner(state, v);
|
|
74
|
+
if (g || d !== null) {
|
|
75
|
+
const t = { ...host.soundTransform(d) };
|
|
76
|
+
f(t);
|
|
77
|
+
host.setSoundTransform(d, t);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
// Where it plays: from its offset, each loop after the first from the offset again, as the
|
|
81
|
+
// device loops it; where it was stopped, by whatever stopped it; the end once it ended.
|
|
82
|
+
const positionOf = (state) => {
|
|
83
|
+
const playing = state.playing;
|
|
84
|
+
if (playing === null || playing.endedAt !== null) {
|
|
85
|
+
return state.position;
|
|
86
|
+
}
|
|
87
|
+
const length = state.duration ?? 0;
|
|
88
|
+
const elapsed = Math.max(0, (playing.stoppedAt ?? h.now) - playing.started);
|
|
89
|
+
const loop = length - state.offset;
|
|
90
|
+
return Math.round(state.offset + (loop > 0 && elapsed >= loop ? elapsed % loop : elapsed));
|
|
91
|
+
};
|
|
92
|
+
const method = (name, f, flags = 0) => proto.define(name, realm.method((self, args, v) => {
|
|
93
|
+
const state = states.get(self);
|
|
94
|
+
return state === undefined ? undefined : f(state, args, v, self);
|
|
95
|
+
}), FIXED | flags);
|
|
96
|
+
const duration = (state, _, v) => valid(state, v) ? state.duration : undefined;
|
|
97
|
+
const position = (state, _, v) => state.character !== null && valid(state, v) ? positionOf(state) : undefined;
|
|
98
|
+
method("getPan", (state, _, v) => {
|
|
99
|
+
const t = transformOf(state, v);
|
|
100
|
+
return t === undefined ? undefined : panOf(t);
|
|
101
|
+
});
|
|
102
|
+
// Surprisingly, lr is right to left and rl left to right (Ruffle).
|
|
103
|
+
method("getTransform", (state, _, v) => {
|
|
104
|
+
const t = transformOf(state, v);
|
|
105
|
+
if (t === undefined) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
const o = realm.newObject(v);
|
|
109
|
+
avm1.set(o, "ll", t.leftToLeft, v);
|
|
110
|
+
avm1.set(o, "lr", t.rightToLeft, v);
|
|
111
|
+
avm1.set(o, "rr", t.rightToRight, v);
|
|
112
|
+
avm1.set(o, "rl", t.leftToRight, v);
|
|
113
|
+
return o;
|
|
114
|
+
});
|
|
115
|
+
method("getVolume", (state, _, v) => transformOf(state, v)?.volume);
|
|
116
|
+
method("setPan", (state, args, v) => {
|
|
117
|
+
const pan = int32(avm1.toNumber(args.length > 0 ? args[0] : 0, v));
|
|
118
|
+
setTransform(state, v, (t) => {
|
|
119
|
+
t.leftToLeft = pan >= 0 ? 100 - pan : 100;
|
|
120
|
+
t.rightToRight = pan >= 0 ? 100 : 100 + pan;
|
|
121
|
+
t.leftToRight = 0;
|
|
122
|
+
t.rightToLeft = 0;
|
|
123
|
+
});
|
|
124
|
+
return undefined;
|
|
125
|
+
});
|
|
126
|
+
// Only the keys the object has of its own change, each wrapped to 32 bits.
|
|
127
|
+
method("setTransform", (state, args, v) => {
|
|
128
|
+
const o = args[0];
|
|
129
|
+
setTransform(state, v, (t) => {
|
|
130
|
+
if (!(o instanceof avm1.Avm1Object)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const own = (key) => o.own(key, v) ? avm1.toNumber(avm1.get(o, key, v), v) | 0 : undefined;
|
|
134
|
+
t.leftToLeft = own("ll") ?? t.leftToLeft;
|
|
135
|
+
t.leftToRight = own("rl") ?? t.leftToRight;
|
|
136
|
+
t.rightToLeft = own("lr") ?? t.rightToLeft;
|
|
137
|
+
t.rightToRight = own("rr") ?? t.rightToRight;
|
|
138
|
+
});
|
|
139
|
+
return undefined;
|
|
140
|
+
});
|
|
141
|
+
method("setVolume", (state, args, v) => {
|
|
142
|
+
const volume = int32(avm1.toNumber(args.length > 0 ? args[0] : 0, v));
|
|
143
|
+
setTransform(state, v, (t) => {
|
|
144
|
+
t.volume = volume;
|
|
145
|
+
});
|
|
146
|
+
return undefined;
|
|
147
|
+
});
|
|
148
|
+
// A name stops every sound of that export, whoever started it; none, the
|
|
149
|
+
// sounds under its clip, or, for the global Sound, all of them.
|
|
150
|
+
method("stop", (state, args, v) => {
|
|
151
|
+
if (args.length > 0) {
|
|
152
|
+
const name = avm1.stringOf(args[0], v);
|
|
153
|
+
const character = valid(state, v) ? host.exportedSound(name) : null;
|
|
154
|
+
if (character !== null) {
|
|
155
|
+
stopSoundsOf(h, character);
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
if (global(state)) {
|
|
160
|
+
stopTimelineSounds(h);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const d = owner(state, v);
|
|
164
|
+
if (d !== null) {
|
|
165
|
+
for (const sound of soundsOf(h, d)) {
|
|
166
|
+
stopTimelineSound(h, sound);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
});
|
|
172
|
+
method("attachSound", (state, args, v, self) => {
|
|
173
|
+
if (!valid(state, v)) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
const character = host.exportedSound(avm1.stringOf(args[0], v));
|
|
177
|
+
if (character === null) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
const definition = character.definition;
|
|
181
|
+
state.character = character;
|
|
182
|
+
state.duration = Math.round((definition.sampleCount * 1000) / definition.sampleRate);
|
|
183
|
+
state.position = 0;
|
|
184
|
+
// position and duration are the object's own from its first sound, as getters.
|
|
185
|
+
for (const [name, get] of [
|
|
186
|
+
["position", position],
|
|
187
|
+
["duration", duration],
|
|
188
|
+
]) {
|
|
189
|
+
if (!avm1.has(self, name, v)) {
|
|
190
|
+
const p = self.add(name, undefined, avm1.DONT_ENUM | avm1.DONT_DELETE);
|
|
191
|
+
p.get = realm.method((o, a, version) => {
|
|
192
|
+
const s = states.get(o);
|
|
193
|
+
return s === undefined ? undefined : get(s, a, version);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
});
|
|
199
|
+
// From `offset` seconds in, `loops` times.
|
|
200
|
+
method("start", (state, args, v, self) => {
|
|
201
|
+
if (!valid(state, v) || state.character === null) {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
const offset = avm1.toNumber(args.length > 0 ? args[0] : 0, v) * 1000;
|
|
205
|
+
const loops = loopsOf(avm1.toNumber(args.length > 1 ? args[1] : 1, v));
|
|
206
|
+
const start = Number.isNaN(offset) ? 0 : Math.max(0, offset);
|
|
207
|
+
const sound = startScriptSound(h, owner(state, v), state.character, start, loops, () => {
|
|
208
|
+
if (state.playing === sound) {
|
|
209
|
+
state.position = state.duration ?? 0;
|
|
210
|
+
}
|
|
211
|
+
host.complete(self);
|
|
212
|
+
});
|
|
213
|
+
if (sound !== null) {
|
|
214
|
+
state.playing = sound;
|
|
215
|
+
state.offset = start;
|
|
216
|
+
}
|
|
217
|
+
return undefined;
|
|
218
|
+
});
|
|
219
|
+
method("getDuration", duration, avm1.VERSION_6);
|
|
220
|
+
method("setDuration", () => undefined, avm1.VERSION_6);
|
|
221
|
+
method("getPosition", position, avm1.VERSION_6);
|
|
222
|
+
method("setPosition", () => undefined, avm1.VERSION_6);
|
|
223
|
+
// Loading a sound by URL is not here yet: nothing starts, and onLoad never comes.
|
|
224
|
+
method("loadSound", () => undefined, avm1.VERSION_6);
|
|
225
|
+
method("getBytesLoaded", () => 1, avm1.VERSION_6);
|
|
226
|
+
method("getBytesTotal", () => 1, avm1.VERSION_6);
|
|
227
|
+
return constr;
|
|
228
|
+
}
|
|
229
|
+
/** An AVM1 transform as the device mixes it, from percentages to fractions. */
|
|
230
|
+
export function mixOfTransform(t) {
|
|
231
|
+
return {
|
|
232
|
+
volume: t.volume / 100,
|
|
233
|
+
leftToLeft: t.leftToLeft / 100,
|
|
234
|
+
leftToRight: t.leftToRight / 100,
|
|
235
|
+
rightToLeft: t.rightToLeft / 100,
|
|
236
|
+
rightToRight: t.rightToRight / 100,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// AVM1's Stage singleton: its dimensions belong to the outer player,
|
|
2
|
+
// including for a SWF loaded inside AS3. Flash exposes them as enumerable,
|
|
3
|
+
// deletable getters, so assigning to them never changes the stage's size.
|
|
4
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
5
|
+
export function stageObject(realm, size) {
|
|
6
|
+
const stage = new avm1.Avm1Object(realm.objectProto);
|
|
7
|
+
// Older SWFs can reveal these functions by clearing their version flags.
|
|
8
|
+
avm1.initializeBroadcaster(stage, realm, 6);
|
|
9
|
+
stage.add("width", undefined, 0).get = realm.method(() => size.stageWidth);
|
|
10
|
+
stage.add("height", undefined, 0).get = realm.method(() => size.stageHeight);
|
|
11
|
+
return stage;
|
|
12
|
+
}
|