@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,222 @@
|
|
|
1
|
+
// A SWF's AVM1 action blocks, listed from its tags: DoAction, DoInitAction,
|
|
2
|
+
// a PlaceObject 2 to 4's clip actions and a button's actions, as Ruffle's
|
|
3
|
+
// (https://github.com/ruffle-rs/ruffle) swf/src/read.rs reads them
|
|
4
|
+
// (read_clip_actions, read_clip_event_flags, read_define_button_1 and 2,
|
|
5
|
+
// read_button_action) and its swf/src/types.rs numbers their flags: MIT OR
|
|
6
|
+
// Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors.
|
|
7
|
+
// Where they differ on clip actions, what adl does decides (clipActions, the
|
|
8
|
+
// list's `corrupt`). A malformed button action ends the button's list and
|
|
9
|
+
// keeps those before it: adl defines the button, and its actions cannot run
|
|
10
|
+
// there without a pointer to check them.
|
|
11
|
+
import { buttonActionsOffset } from "./button.js";
|
|
12
|
+
import { clipActionsOffset, readSprite } from "./display.js";
|
|
13
|
+
import { SwfReader } from "./swf.js";
|
|
14
|
+
import { DefineButton, DefineButton2, DefineSprite, DoAction, DoInitAction, PlaceObject2, PlaceObject3, PlaceObject4, ShowFrame, } from "./tags.js";
|
|
15
|
+
/** A clip action's events, CLIPEVENTFLAGS' bits; SWF 5 has only the low 16. */
|
|
16
|
+
export const ClipEvent = {
|
|
17
|
+
load: 1 << 0,
|
|
18
|
+
enterFrame: 1 << 1,
|
|
19
|
+
unload: 1 << 2,
|
|
20
|
+
mouseMove: 1 << 3,
|
|
21
|
+
mouseDown: 1 << 4,
|
|
22
|
+
mouseUp: 1 << 5,
|
|
23
|
+
keyDown: 1 << 6,
|
|
24
|
+
keyUp: 1 << 7,
|
|
25
|
+
data: 1 << 8,
|
|
26
|
+
initialize: 1 << 9,
|
|
27
|
+
press: 1 << 10,
|
|
28
|
+
release: 1 << 11,
|
|
29
|
+
releaseOutside: 1 << 12,
|
|
30
|
+
rollOver: 1 << 13,
|
|
31
|
+
rollOut: 1 << 14,
|
|
32
|
+
dragOver: 1 << 15,
|
|
33
|
+
dragOut: 1 << 16,
|
|
34
|
+
keyPress: 1 << 17,
|
|
35
|
+
construct: 1 << 18,
|
|
36
|
+
};
|
|
37
|
+
/** The bits Flash knows; it skips a record with none of them, and only flags of 0 end the list. */
|
|
38
|
+
const CLIP_EVENTS = 0x7ffff;
|
|
39
|
+
/** A button's state transitions, BUTTONCONDACTION's low 9 bits; its key code is above them. */
|
|
40
|
+
export const ButtonCondition = {
|
|
41
|
+
idleToOverUp: 1 << 0,
|
|
42
|
+
overUpToIdle: 1 << 1,
|
|
43
|
+
overUpToOverDown: 1 << 2,
|
|
44
|
+
overDownToOverUp: 1 << 3,
|
|
45
|
+
overDownToOutDown: 1 << 4,
|
|
46
|
+
outDownToOverDown: 1 << 5,
|
|
47
|
+
outDownToIdle: 1 << 6,
|
|
48
|
+
idleToOverDown: 1 << 7,
|
|
49
|
+
overDownToIdle: 1 << 8,
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A SWF's action blocks, a pure function of its bytes. A block may be empty.
|
|
53
|
+
* They are listed in an ActionScript 3 SWF too, where Flash runs none.
|
|
54
|
+
*/
|
|
55
|
+
export function readActions(swf) {
|
|
56
|
+
const list = {
|
|
57
|
+
version: swf.header.version,
|
|
58
|
+
blocks: [],
|
|
59
|
+
byTag: new Map(),
|
|
60
|
+
corrupt: [],
|
|
61
|
+
corruptEvents: new Map(),
|
|
62
|
+
};
|
|
63
|
+
walk(swf.bytes, swf.tags, null, list);
|
|
64
|
+
return list;
|
|
65
|
+
}
|
|
66
|
+
function walk(bytes, tags, timeline, list) {
|
|
67
|
+
let frame = 0;
|
|
68
|
+
for (const tag of tags) {
|
|
69
|
+
const end = tag.offset + tag.length;
|
|
70
|
+
switch (tag.code) {
|
|
71
|
+
case ShowFrame:
|
|
72
|
+
frame++;
|
|
73
|
+
break;
|
|
74
|
+
case DoAction:
|
|
75
|
+
add(list, tag, { type: "frame", timeline, frame }, tag.offset, end);
|
|
76
|
+
break;
|
|
77
|
+
case DoInitAction:
|
|
78
|
+
// A tag too short for its sprite id is no block, as Ruffle fails to read it.
|
|
79
|
+
if (tag.length >= 2) {
|
|
80
|
+
const sprite = bytes[tag.offset] | (bytes[tag.offset + 1] << 8);
|
|
81
|
+
add(list, tag, { type: "init", sprite, timeline, frame }, tag.offset + 2, end);
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case PlaceObject2:
|
|
85
|
+
case PlaceObject3:
|
|
86
|
+
case PlaceObject4: {
|
|
87
|
+
const { depth, offset } = clipActionsOffset(bytes, tag);
|
|
88
|
+
if (offset >= 0) {
|
|
89
|
+
clipActions(bytes, tag, offset, list, timeline, frame, depth);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case DefineButton:
|
|
94
|
+
case DefineButton2:
|
|
95
|
+
buttonActions(bytes, tag, list);
|
|
96
|
+
break;
|
|
97
|
+
case DefineSprite: {
|
|
98
|
+
const sprite = readSprite(bytes, tag);
|
|
99
|
+
walk(bytes, sprite.tags, sprite.id, list);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function add(list, tag, owner, offset, end) {
|
|
106
|
+
const index = list.blocks.length;
|
|
107
|
+
list.blocks.push({ index, owner, tag: tag.offset, offset, length: end - offset });
|
|
108
|
+
const indices = list.byTag.get(tag.offset);
|
|
109
|
+
if (indices) {
|
|
110
|
+
indices.push(index);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
list.byTag.set(tag.offset, [index]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function corrupt(list, tag, events) {
|
|
117
|
+
list.corrupt.push(tag.offset);
|
|
118
|
+
list.corruptEvents.set(tag.offset, events);
|
|
119
|
+
}
|
|
120
|
+
/** CLIPACTIONS: a reserved u16, the events Flash dispatches, then records to one of no events. */
|
|
121
|
+
function clipActions(bytes, tag, start, list, timeline, frame, depth) {
|
|
122
|
+
const end = tag.offset + tag.length;
|
|
123
|
+
const r = new SwfReader(bytes, start, end);
|
|
124
|
+
const wide = list.version >= 6;
|
|
125
|
+
const flagSize = wide ? 4 : 2;
|
|
126
|
+
r.u16();
|
|
127
|
+
// Flags cut short end the list whatever their bytes, in adl as in Ruffle (its #2899).
|
|
128
|
+
const flags = () => {
|
|
129
|
+
if (r.pos + flagSize > end) {
|
|
130
|
+
r.pos = end;
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
return wide ? r.u32() : r.u16();
|
|
134
|
+
};
|
|
135
|
+
// Flash runs a record only for the events this field also has.
|
|
136
|
+
const all = flags() & CLIP_EVENTS;
|
|
137
|
+
const records = [];
|
|
138
|
+
for (;;) {
|
|
139
|
+
const raw = flags();
|
|
140
|
+
if (raw === 0) {
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
// A record cut short stops the whole SWF in Flash, before any of the place's records runs.
|
|
144
|
+
if (r.pos + 4 > end) {
|
|
145
|
+
corrupt(list, tag, all);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const events = raw & all;
|
|
149
|
+
const length = r.u32();
|
|
150
|
+
let start = r.pos;
|
|
151
|
+
let key = 0;
|
|
152
|
+
// keyPress's key code is the first byte of the record's length. Flash
|
|
153
|
+
// reads it even of a length of 0, as the next record's first byte, and
|
|
154
|
+
// goes on from there: that record keeps its key and has no actions.
|
|
155
|
+
if (raw & ClipEvent.keyPress) {
|
|
156
|
+
if (r.pos >= end) {
|
|
157
|
+
corrupt(list, tag, all);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
key = bytes[r.pos];
|
|
161
|
+
start += Math.min(length, 1);
|
|
162
|
+
}
|
|
163
|
+
if (length > end - r.pos) {
|
|
164
|
+
corrupt(list, tag, all);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (events !== 0) {
|
|
168
|
+
const owner = { type: "clip", timeline, frame, depth, events, key };
|
|
169
|
+
records.push({ owner, start, end: r.pos + length });
|
|
170
|
+
}
|
|
171
|
+
r.pos += length;
|
|
172
|
+
}
|
|
173
|
+
for (const record of records) {
|
|
174
|
+
add(list, tag, record.owner, record.start, record.end);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* DefineButton's actions run to the tag's end. DefineButton2's, after its
|
|
179
|
+
* records when its action offset is not 0, are BUTTONCONDACTIONs: a size,
|
|
180
|
+
* 0 for the last, which runs to the end, then the conditions and key.
|
|
181
|
+
*/
|
|
182
|
+
function buttonActions(bytes, tag, list) {
|
|
183
|
+
const { id, offset } = buttonActionsOffset(bytes, tag);
|
|
184
|
+
const end = tag.offset + tag.length;
|
|
185
|
+
if (offset < 0) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (tag.code === DefineButton) {
|
|
189
|
+
const owner = {
|
|
190
|
+
type: "button",
|
|
191
|
+
button: id,
|
|
192
|
+
conditions: ButtonCondition.overDownToOverUp,
|
|
193
|
+
key: 0,
|
|
194
|
+
};
|
|
195
|
+
add(list, tag, owner, offset, end);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const r = new SwfReader(bytes, offset, end);
|
|
199
|
+
for (;;) {
|
|
200
|
+
if (r.pos + 4 > end) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const size = r.u16();
|
|
204
|
+
const conditions = r.u16();
|
|
205
|
+
// Sizes 1 to 3 are shorter than the record's own head: Ruffle's error, so the end here.
|
|
206
|
+
if ((size !== 0 && size < 4) || size - 4 > end - r.pos) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const blockEnd = size === 0 ? end : r.pos + size - 4;
|
|
210
|
+
const owner = {
|
|
211
|
+
type: "button",
|
|
212
|
+
button: id,
|
|
213
|
+
conditions: conditions & 0x1ff,
|
|
214
|
+
key: conditions >> 9,
|
|
215
|
+
};
|
|
216
|
+
add(list, tag, owner, r.pos, blockEnd);
|
|
217
|
+
if (size === 0) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
r.pos = blockEnd;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// An AIR application's descriptor (`<name>-app.xml`), as adl reads what it
|
|
2
|
+
// needs of one to run it: the application's id, and its first window's
|
|
3
|
+
// content SWF, title and size. Elements are found by name, whatever
|
|
4
|
+
// namespace the descriptor's AIR version gives them; what is not there is
|
|
5
|
+
// left to its default. A desktop app reads it from disk, a page from an
|
|
6
|
+
// AIR package (`.air`) or the files of one.
|
|
7
|
+
/** The text of the first `<name>` element in `xml`, entities decoded; null for none. */
|
|
8
|
+
function element(xml, name) {
|
|
9
|
+
const m = new RegExp(`<(?:[\\w.-]+:)?${name}(?:\\s[^>]*)?>([\\s\\S]*?)</(?:[\\w.-]+:)?${name}\\s*>`).exec(xml);
|
|
10
|
+
return m ? decode(m[1].trim()) : null;
|
|
11
|
+
}
|
|
12
|
+
/** XML's five entities and its character references, and a CDATA section's text. */
|
|
13
|
+
function decode(text) {
|
|
14
|
+
const cdata = /^<!\[CDATA\[([\s\S]*)\]\]>$/.exec(text);
|
|
15
|
+
if (cdata) {
|
|
16
|
+
return cdata[1];
|
|
17
|
+
}
|
|
18
|
+
return text.replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot|apos);/gi, (_, e) => {
|
|
19
|
+
switch (e.toLowerCase()) {
|
|
20
|
+
case "amp":
|
|
21
|
+
return "&";
|
|
22
|
+
case "lt":
|
|
23
|
+
return "<";
|
|
24
|
+
case "gt":
|
|
25
|
+
return ">";
|
|
26
|
+
case "quot":
|
|
27
|
+
return '"';
|
|
28
|
+
case "apos":
|
|
29
|
+
return "'";
|
|
30
|
+
default:
|
|
31
|
+
return String.fromCodePoint(e[1].toLowerCase() === "x" ? Number.parseInt(e.slice(2), 16) : Number(e.slice(1)));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** A whole number of pixels, or null for none or nonsense. */
|
|
36
|
+
function size(text) {
|
|
37
|
+
const n = text === null ? Number.NaN : Number(text);
|
|
38
|
+
return Number.isInteger(n) && n > 0 ? n : null;
|
|
39
|
+
}
|
|
40
|
+
/** What `xml`, a descriptor, says; an Error naming what it lacks that adl requires. */
|
|
41
|
+
export function readAirDescriptor(xml) {
|
|
42
|
+
if (!/<(?:[\w.-]+:)?application[\s>]/.test(xml)) {
|
|
43
|
+
throw new Error("not an AIR application descriptor: no <application>");
|
|
44
|
+
}
|
|
45
|
+
// The comments out first, which may hold an element of each name.
|
|
46
|
+
const text = xml.replace(/<!--[\s\S]*?-->/g, "");
|
|
47
|
+
const id = element(text, "id");
|
|
48
|
+
const window = element(text, "initialWindow");
|
|
49
|
+
const content = window === null ? null : element(window, "content");
|
|
50
|
+
if (!id) {
|
|
51
|
+
throw new Error("the descriptor names no <id>");
|
|
52
|
+
}
|
|
53
|
+
if (!content) {
|
|
54
|
+
throw new Error("the descriptor's <initialWindow> names no <content>");
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
content: content.replaceAll("\\", "/"),
|
|
59
|
+
title: window === null ? null : element(window, "title"),
|
|
60
|
+
width: window === null ? null : size(element(window, "width")),
|
|
61
|
+
height: window === null ? null : size(element(window, "height")),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The API versions of avmplus' core/api-versions.h that hosts run ABCs at,
|
|
2
|
+
// in one place for the compiler and the runtime, which must agree: a
|
|
3
|
+
// version names a series of names, Flash Player's or AIR's, which
|
|
4
|
+
// alternate, and what code of that version sees in it.
|
|
5
|
+
/** Flash Player's latest, SWF_31: what a browser's SWFs, and avmshell's by default, run at. */
|
|
6
|
+
export const API_VERSION = 50;
|
|
7
|
+
/** AIR's latest, AIR_20_0: what an AIR host's SWFs run at. */
|
|
8
|
+
export const AIR_API_VERSION = 51;
|
|
9
|
+
/** VM_INTERNAL, which no ABC runs at: the first version past both series. */
|
|
10
|
+
const API_INTERNAL = 52;
|
|
11
|
+
/**
|
|
12
|
+
* `version` if ABCs can run at it, a version of either series, as
|
|
13
|
+
* avmshell's -api names them (1, AIR_1_0, up to AIR_API_VERSION); else a
|
|
14
|
+
* RangeError, so that the compiler, which keeps a byte, and the runtime
|
|
15
|
+
* never take two different versions for one.
|
|
16
|
+
*/
|
|
17
|
+
export function checkApiVersion(version) {
|
|
18
|
+
if (!Number.isInteger(version) || version < 1 || version >= API_INTERNAL) {
|
|
19
|
+
throw new RangeError(`swf2es: no ABC runs at API version ${version}`);
|
|
20
|
+
}
|
|
21
|
+
return version;
|
|
22
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// The SWF's bitmap tags. The lossless formats are read here to pixels; the
|
|
2
|
+
// JPEG tags hold an image (a JPEG, PNG or GIF) for the player to decode,
|
|
3
|
+
// with what Flash does to its bytes first already done.
|
|
4
|
+
import { zlibUncompress } from "./compression.js";
|
|
5
|
+
import { DefineBits, DefineBitsJPEG2, DefineBitsJPEG3, DefineBitsJPEG4, DefineBitsLossless, DefineBitsLossless2, } from "./tags.js";
|
|
6
|
+
/** Whether a tag defines a bitmap. */
|
|
7
|
+
export function isBitmapTag(code) {
|
|
8
|
+
return (code === DefineBits ||
|
|
9
|
+
code === DefineBitsJPEG2 ||
|
|
10
|
+
code === DefineBitsJPEG3 ||
|
|
11
|
+
code === DefineBitsJPEG4 ||
|
|
12
|
+
code === DefineBitsLossless ||
|
|
13
|
+
code === DefineBitsLossless2);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A bitmap tag's character. `tables` is the JPEGTables tag's data that
|
|
17
|
+
* DefineBits needs, null if there was none.
|
|
18
|
+
*/
|
|
19
|
+
export function readBitmap(bytes, tag, tables) {
|
|
20
|
+
const body = bytes.subarray(tag.offset, tag.offset + tag.length);
|
|
21
|
+
const id = body.length >= 2 ? body[0] | (body[1] << 8) : 0;
|
|
22
|
+
// Flash refuses a bitmap tag written with the short header, whatever it holds.
|
|
23
|
+
if (!tag.long || body.length < 2) {
|
|
24
|
+
return { id, type: "invalid" };
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
switch (tag.code) {
|
|
28
|
+
case DefineBitsLossless:
|
|
29
|
+
case DefineBitsLossless2:
|
|
30
|
+
return lossless(id, body, tag.code === DefineBitsLossless2);
|
|
31
|
+
case DefineBits:
|
|
32
|
+
return tables ? image(id, concat(tables, body.subarray(2)), null, false) : invalid(id);
|
|
33
|
+
case DefineBitsJPEG2:
|
|
34
|
+
return image(id, body.subarray(2), null, false);
|
|
35
|
+
default: {
|
|
36
|
+
const size = u32(body, 2);
|
|
37
|
+
const start = tag.code === DefineBitsJPEG4 ? 8 : 6;
|
|
38
|
+
if (start + size > body.length) {
|
|
39
|
+
return invalid(id);
|
|
40
|
+
}
|
|
41
|
+
const alpha = zlibUncompress(body.subarray(start + size));
|
|
42
|
+
return image(id, body.subarray(start, start + size), alpha, tag.code === DefineBitsJPEG4);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Corrupt zlib data.
|
|
48
|
+
return invalid(id);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function invalid(id) {
|
|
52
|
+
return { id, type: "invalid" };
|
|
53
|
+
}
|
|
54
|
+
function u16(b, at) {
|
|
55
|
+
return b[at] | (b[at + 1] << 8);
|
|
56
|
+
}
|
|
57
|
+
function u32(b, at) {
|
|
58
|
+
return (b[at] | (b[at + 1] << 8) | (b[at + 2] << 16) | (b[at + 3] << 24)) >>> 0;
|
|
59
|
+
}
|
|
60
|
+
function concat(a, b) {
|
|
61
|
+
const out = new Uint8Array(a.length + b.length);
|
|
62
|
+
out.set(a);
|
|
63
|
+
out.set(b, a.length);
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
function image(id, data, alpha, jpeg4) {
|
|
67
|
+
if (data[0] === 0x89 && data[1] === 0x50 && data[2] === 0x4e && data[3] === 0x47) {
|
|
68
|
+
// A PNG or GIF keeps its own alpha; the tag's is ignored.
|
|
69
|
+
return { id, type: "image", format: "png", data, alpha: null, opaque: false };
|
|
70
|
+
}
|
|
71
|
+
if (data[0] === 0x47 && data[1] === 0x49 && data[2] === 0x46 && data[3] === 0x38) {
|
|
72
|
+
return { id, type: "image", format: "gif", data, alpha: null, opaque: false };
|
|
73
|
+
}
|
|
74
|
+
const jpeg = cleanJpeg(data);
|
|
75
|
+
if (!jpeg) {
|
|
76
|
+
return invalid(id);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
id,
|
|
80
|
+
type: "image",
|
|
81
|
+
format: "jpeg",
|
|
82
|
+
data: jpeg,
|
|
83
|
+
alpha: jpeg4 ? null : alpha,
|
|
84
|
+
opaque: jpeg4,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A JPEG as a decoder takes it: one SOI, then its segments, with the EOI
|
|
89
|
+
* and SOI between tables and image that SWFs carry dropped. Old tools
|
|
90
|
+
* wrote a stray FF D9 FF D8 at the start, and DefineBits' tables come as
|
|
91
|
+
* a JPEG of their own; Flash reads both. Null if it is not a JPEG.
|
|
92
|
+
*/
|
|
93
|
+
function cleanJpeg(data) {
|
|
94
|
+
const out = [Uint8Array.of(0xff, 0xd8)];
|
|
95
|
+
let at = 0;
|
|
96
|
+
while (at + 1 < data.length) {
|
|
97
|
+
if (data[at] !== 0xff) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const marker = data[at + 1];
|
|
101
|
+
if (marker === 0xd8 || marker === 0xd9) {
|
|
102
|
+
at += 2;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (marker === 0xff) {
|
|
106
|
+
// Fill bytes before a marker.
|
|
107
|
+
at++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (marker === 0xda) {
|
|
111
|
+
// The scan, and everything after it, as it is.
|
|
112
|
+
out.push(data.subarray(at));
|
|
113
|
+
return concatAll(out);
|
|
114
|
+
}
|
|
115
|
+
if (at + 3 >= data.length) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const end = at + 2 + ((data[at + 2] << 8) | data[at + 3]);
|
|
119
|
+
out.push(data.subarray(at, end));
|
|
120
|
+
at = end;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
function concatAll(parts) {
|
|
125
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
126
|
+
let at = 0;
|
|
127
|
+
for (const p of parts) {
|
|
128
|
+
out.set(p, at);
|
|
129
|
+
at += p.length;
|
|
130
|
+
}
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
/** DefineBitsLossless and 2: a palette, 15-bit or 32-bit pixels, zlib'd. */
|
|
134
|
+
function lossless(id, body, alpha) {
|
|
135
|
+
if (body.length < 7) {
|
|
136
|
+
return invalid(id);
|
|
137
|
+
}
|
|
138
|
+
const format = body[2];
|
|
139
|
+
const width = u16(body, 3);
|
|
140
|
+
const height = u16(body, 5);
|
|
141
|
+
if (width === 0 || height === 0 || (format !== 3 && format !== 4 && format !== 5)) {
|
|
142
|
+
return invalid(id);
|
|
143
|
+
}
|
|
144
|
+
const colors = format === 3 ? body[7] + 1 : 0;
|
|
145
|
+
const data = zlibUncompress(body.subarray(format === 3 ? 8 : 7));
|
|
146
|
+
const pixels = new Uint32Array(width * height);
|
|
147
|
+
if (format === 3) {
|
|
148
|
+
const entry = alpha ? 4 : 3;
|
|
149
|
+
const palette = new Uint32Array(256);
|
|
150
|
+
for (let i = 0; i < colors; i++) {
|
|
151
|
+
const p = i * entry;
|
|
152
|
+
// Lossless2's palette is premultiplied ARGB, as its pixels are.
|
|
153
|
+
palette[i] = alpha
|
|
154
|
+
? ((data[p + 3] << 24) | (data[p] << 16) | (data[p + 1] << 8) | data[p + 2]) >>> 0
|
|
155
|
+
: (0xff000000 | (data[p] << 16) | (data[p + 1] << 8) | data[p + 2]) >>> 0;
|
|
156
|
+
}
|
|
157
|
+
const stride = (width + 3) & ~3;
|
|
158
|
+
const start = colors * entry;
|
|
159
|
+
if (start + stride * (height - 1) + width > data.length) {
|
|
160
|
+
return invalid(id);
|
|
161
|
+
}
|
|
162
|
+
for (let y = 0; y < height; y++) {
|
|
163
|
+
for (let x = 0; x < width; x++) {
|
|
164
|
+
pixels[y * width + x] = palette[data[start + y * stride + x]];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else if (format === 4) {
|
|
169
|
+
// 15-bit RGB, rows padded to 4 bytes; a channel v is v * 8 + 7, 0 kept at 0.
|
|
170
|
+
const stride = (width * 2 + 3) & ~3;
|
|
171
|
+
if (stride * (height - 1) + width * 2 > data.length) {
|
|
172
|
+
return invalid(id);
|
|
173
|
+
}
|
|
174
|
+
const widen = (v) => (v === 0 ? 0 : v * 8 + 7);
|
|
175
|
+
for (let y = 0; y < height; y++) {
|
|
176
|
+
for (let x = 0; x < width; x++) {
|
|
177
|
+
const p = y * stride + x * 2;
|
|
178
|
+
const v = (data[p] << 8) | data[p + 1];
|
|
179
|
+
pixels[y * width + x] =
|
|
180
|
+
(0xff000000 |
|
|
181
|
+
(widen((v >> 10) & 31) << 16) |
|
|
182
|
+
(widen((v >> 5) & 31) << 8) |
|
|
183
|
+
widen(v & 31)) >>>
|
|
184
|
+
0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
if (width * height * 4 > data.length) {
|
|
190
|
+
return invalid(id);
|
|
191
|
+
}
|
|
192
|
+
for (let i = 0; i < width * height; i++) {
|
|
193
|
+
const p = i * 4;
|
|
194
|
+
const rgb = (data[p + 1] << 16) | (data[p + 2] << 8) | data[p + 3];
|
|
195
|
+
pixels[i] = alpha ? ((data[p] << 24) | rgb) >>> 0 : (0xff000000 | rgb) >>> 0;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return { id, type: "pixels", width, height, transparent: alpha, pixels };
|
|
199
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readFilterBytes } from "./display.js";
|
|
2
|
+
import { readColorTransform, readMatrix } from "./shape.js";
|
|
3
|
+
import { SwfReader } from "./swf.js";
|
|
4
|
+
import { DefineButton2 } from "./tags.js";
|
|
5
|
+
/** A button's state, as BUTTONRECORD's flags have them. */
|
|
6
|
+
export const BUTTON_UP = 0x01;
|
|
7
|
+
export const BUTTON_OVER = 0x02;
|
|
8
|
+
export const BUTTON_DOWN = 0x04;
|
|
9
|
+
export const BUTTON_HIT_TEST = 0x08;
|
|
10
|
+
/** A DefineButton or DefineButton2; given the SWF's action list, with the indices of its actions. */
|
|
11
|
+
export function readButton(bytes, tag, actions) {
|
|
12
|
+
const { button } = parseButton(bytes, tag);
|
|
13
|
+
button.actions = actions?.byTag.get(tag.offset) ?? null;
|
|
14
|
+
return button;
|
|
15
|
+
}
|
|
16
|
+
/** A button's id, and where its actions start: -1 for a DefineButton2 whose action offset is 0. */
|
|
17
|
+
export function buttonActionsOffset(bytes, tag) {
|
|
18
|
+
const { button, actions } = parseButton(bytes, tag);
|
|
19
|
+
return { id: button.id, offset: actions };
|
|
20
|
+
}
|
|
21
|
+
function parseButton(bytes, tag) {
|
|
22
|
+
const r = new SwfReader(bytes, tag.offset, tag.offset + tag.length);
|
|
23
|
+
const two = tag.code === DefineButton2;
|
|
24
|
+
const button = { id: r.u16(), records: [], trackAsMenu: false, actions: null };
|
|
25
|
+
// Only whether it is 0 counts: the actions start after the records' end, as Ruffle reads them.
|
|
26
|
+
let hasActions = true;
|
|
27
|
+
if (two) {
|
|
28
|
+
button.trackAsMenu = (r.u8() & 0x01) !== 0;
|
|
29
|
+
hasActions = r.u16() !== 0;
|
|
30
|
+
}
|
|
31
|
+
// The records end at a flags byte of 0.
|
|
32
|
+
while (r.pos < r.end && !r.overrun) {
|
|
33
|
+
const flags = r.u8();
|
|
34
|
+
if (flags === 0) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
const record = {
|
|
38
|
+
states: flags & 0x0f,
|
|
39
|
+
character: r.u16(),
|
|
40
|
+
depth: r.u16(),
|
|
41
|
+
matrix: readMatrix(r),
|
|
42
|
+
colorTransform: null,
|
|
43
|
+
filters: null,
|
|
44
|
+
blendMode: null,
|
|
45
|
+
};
|
|
46
|
+
if (two) {
|
|
47
|
+
record.colorTransform = readColorTransform(r, true);
|
|
48
|
+
if (flags & 0x10) {
|
|
49
|
+
record.filters = readFilterBytes(r);
|
|
50
|
+
}
|
|
51
|
+
if (flags & 0x20) {
|
|
52
|
+
record.blendMode = r.u8();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!r.overrun) {
|
|
56
|
+
button.records.push(record);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { button, actions: hasActions ? Math.min(r.pos, r.end) : -1 };
|
|
60
|
+
}
|