@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,542 @@
|
|
|
1
|
+
// flash.display.BitmapData's AS2 face, as Ruffle's (https://github.com/
|
|
2
|
+
// ruffle-rs/ruffle) core/src/avm1/globals/bitmap_data.rs has it: MIT OR
|
|
3
|
+
// Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors.
|
|
4
|
+
// Each object holds a BitmapStore, the player's bitmap, whose operations
|
|
5
|
+
// AS3's BitmapData shares (bitmap/bitmap.ts, bitmap/ops.ts); a display
|
|
6
|
+
// object is drawn into one by the host's renderer, as AS3's draw is. What
|
|
7
|
+
// AS3 throws, AS2 answers with a number: -1 for too few arguments or a
|
|
8
|
+
// disposed bitmap, -2 for a source that is none, -3 for a disposed one,
|
|
9
|
+
// -4 for a rectangle that is none.
|
|
10
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
11
|
+
import { BitmapStore, pixelRect, spanRect } from "../../bitmap/bitmap.js";
|
|
12
|
+
import { drawDisplayObject } from "../../bitmap/draw.js";
|
|
13
|
+
import { applyFilter, filterRefusal, GLOWS, generatedRect } from "../../bitmap/filters.js";
|
|
14
|
+
import { alphaAt, colorBounds, colorTransform, comparePixels, copyChannel, drawBitmap, floodFill, isThresholdOperation, merge, noise, paletteMap, perlinNoise, pixelDissolve, scroll, threshold, } from "../../bitmap/ops.js";
|
|
15
|
+
import { BLEND_MODES } from "../../display/displayobject.js";
|
|
16
|
+
import { filterRecordOf } from "./filters.js";
|
|
17
|
+
import { colorValues, makeGeom } from "./geom.js";
|
|
18
|
+
/** Each BitmapData's store, by its AVM1 object. */
|
|
19
|
+
const stores = new WeakMap();
|
|
20
|
+
/** A new BitmapData object of `proto` showing `store`, as a displacement map's `mapBitmap` reads it. */
|
|
21
|
+
export function bitmapObject(proto, store) {
|
|
22
|
+
const o = new avm1.Avm1Object(proto);
|
|
23
|
+
stores.set(o, store);
|
|
24
|
+
return o;
|
|
25
|
+
}
|
|
26
|
+
/** `o`'s store where it is a BitmapData, disposed or not; null for anything else. */
|
|
27
|
+
export function storeOf(o) {
|
|
28
|
+
return o instanceof avm1.Avm1Object ? (stores.get(o) ?? null) : null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether a bitmap of `w` by `h` may be made in SWF `version`: up to SWF 9
|
|
32
|
+
* 2880 a side; to 12 under 8192 a side and 2^24 pixels; from 13 up to
|
|
33
|
+
* 0x6666666 a side and under 2^29 pixels (Ruffle's is_size_valid).
|
|
34
|
+
*/
|
|
35
|
+
function sizeValid(w, h, version) {
|
|
36
|
+
if (w === 0 || h === 0) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (version <= 9) {
|
|
40
|
+
return w <= 2880 && h <= 2880;
|
|
41
|
+
}
|
|
42
|
+
if (version <= 12) {
|
|
43
|
+
return w < 8192 && h < 8192 && w * h < 0x1000000;
|
|
44
|
+
}
|
|
45
|
+
return w <= 0x6666666 && h <= 0x6666666 && w * h < 0x20000000;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A rectangle's own or inherited x, y, width and height as ints, clipped
|
|
49
|
+
* as Flash clips, a negative size spanning back with `span`; null if one
|
|
50
|
+
* is missing.
|
|
51
|
+
*/
|
|
52
|
+
function rectOf(o, v, span = false, ints = true) {
|
|
53
|
+
if (!(o instanceof avm1.Avm1Object)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const names = ["x", "y", "width", "height"];
|
|
57
|
+
if (names.some((n) => !avm1.has(o, n, v))) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const [x, y, w, h] = names.map((n) => {
|
|
61
|
+
const d = avm1.toNumber(avm1.get(o, n, v), v);
|
|
62
|
+
return ints ? d | 0 : d;
|
|
63
|
+
});
|
|
64
|
+
return (span ? spanRect : pixelRect)(x, y, w, h);
|
|
65
|
+
}
|
|
66
|
+
/** A point's own x and y as ints, as hitTest takes them; null if either is not its own. */
|
|
67
|
+
function ownPoint(o, v) {
|
|
68
|
+
if (!(o instanceof avm1.Avm1Object) ||
|
|
69
|
+
o.own("x", v) === undefined ||
|
|
70
|
+
o.own("y", v) === undefined) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return [avm1.toNumber(avm1.get(o, "x", v), v) | 0, avm1.toNumber(avm1.get(o, "y", v), v) | 0];
|
|
74
|
+
}
|
|
75
|
+
/** An alpha threshold: an int clamped to a byte. */
|
|
76
|
+
function threshold8(x, v) {
|
|
77
|
+
return Math.max(0, Math.min(255, avm1.toNumber(x, v) | 0));
|
|
78
|
+
}
|
|
79
|
+
/** A point's x and y, truncated to ints. */
|
|
80
|
+
function pointOf(o, v) {
|
|
81
|
+
const coord = (n) => Math.trunc(avm1.toNumber(o instanceof avm1.Avm1Object ? avm1.get(o, n, v) : undefined, v)) | 0;
|
|
82
|
+
return [coord("x"), coord("y")];
|
|
83
|
+
}
|
|
84
|
+
/** A matrix's six fields as numbers, the identity's where it is none. */
|
|
85
|
+
function matrixOf(o, v) {
|
|
86
|
+
if (!(o instanceof avm1.Avm1Object)) {
|
|
87
|
+
return { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
|
|
88
|
+
}
|
|
89
|
+
const n = (name) => avm1.toNumber(avm1.get(o, name, v), v);
|
|
90
|
+
return { a: n("a"), b: n("b"), c: n("c"), d: n("d"), tx: n("tx"), ty: n("ty") };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A blend mode as AVM1 takes one: a name as BlendMode has it, or
|
|
94
|
+
* PlaceObject3's number of one, a byte, undefined and null normal; null for
|
|
95
|
+
* anything else, a name in another case or a number in a string included
|
|
96
|
+
* (adl, the corpus's movieclip_blend_mode_property).
|
|
97
|
+
*/
|
|
98
|
+
export function blendModeOf(value) {
|
|
99
|
+
if (value === undefined || value === null) {
|
|
100
|
+
return "normal";
|
|
101
|
+
}
|
|
102
|
+
if (typeof value === "number") {
|
|
103
|
+
return BLEND_MODES[(Number.isFinite(value) ? Math.trunc(value) : 0) & 0xff] ?? null;
|
|
104
|
+
}
|
|
105
|
+
return typeof value === "string" && BLEND_MODES.includes(value) ? value : null;
|
|
106
|
+
}
|
|
107
|
+
/** A native ColorTransform's values as a colour transform; null for anything else. */
|
|
108
|
+
function colorOf(o) {
|
|
109
|
+
const c = colorValues(o);
|
|
110
|
+
return c
|
|
111
|
+
? {
|
|
112
|
+
rMul: c[0],
|
|
113
|
+
gMul: c[1],
|
|
114
|
+
bMul: c[2],
|
|
115
|
+
aMul: c[3],
|
|
116
|
+
rAdd: c[4],
|
|
117
|
+
gAdd: c[5],
|
|
118
|
+
bAdd: c[6],
|
|
119
|
+
aAdd: c[7],
|
|
120
|
+
}
|
|
121
|
+
: null;
|
|
122
|
+
}
|
|
123
|
+
/** Samples a side a display object is drawn at, by the stage's quality: Flash's 1, 2 and 4. */
|
|
124
|
+
function samplesOf(quality) {
|
|
125
|
+
switch (quality) {
|
|
126
|
+
case "LOW":
|
|
127
|
+
return 1;
|
|
128
|
+
case "MEDIUM":
|
|
129
|
+
return 2;
|
|
130
|
+
default:
|
|
131
|
+
return 4;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const FIXED = avm1.DONT_ENUM | avm1.DONT_DELETE;
|
|
135
|
+
/** `flash.display.BitmapData`. */
|
|
136
|
+
export function bitmapDataClass(host) {
|
|
137
|
+
const realm = host.realm;
|
|
138
|
+
const proto = new avm1.Avm1Object(realm.objectProto);
|
|
139
|
+
const constr = realm.classOf(proto, (self, args, v) => {
|
|
140
|
+
// Fewer than two arguments, or a size Flash does not make, and `new` gives undefined.
|
|
141
|
+
if (args.length < 2) {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
const w = avm1.toNumber(args[0], v) >>> 0;
|
|
145
|
+
const h = avm1.toNumber(args[1], v) >>> 0;
|
|
146
|
+
if (!sizeValid(w, h, host.version)) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
// An explicit undefined or null is false, and a fill of 0.
|
|
150
|
+
const transparent = args.length < 3 || avm1.toBoolean(args[2], v);
|
|
151
|
+
const fill = args.length < 4 ? 0xffffffff : avm1.toNumber(args[3], v) >>> 0;
|
|
152
|
+
stores.set(self, new BitmapStore(w, h, transparent, Number.isNaN(fill) ? 0 : fill));
|
|
153
|
+
return self;
|
|
154
|
+
}, () => undefined);
|
|
155
|
+
/** A method of a live bitmap: -1 for a disposed one, or one with fewer than `least` arguments. */
|
|
156
|
+
const method = (name, least, f) => {
|
|
157
|
+
proto.define(name, realm.method((self, args, v) => {
|
|
158
|
+
const store = stores.get(self);
|
|
159
|
+
return store === undefined || store.disposed || args.length < least
|
|
160
|
+
? -1
|
|
161
|
+
: f(store, args, v, self);
|
|
162
|
+
}), 0);
|
|
163
|
+
};
|
|
164
|
+
const getter = (name, f) => {
|
|
165
|
+
const p = proto.add(name, undefined, 0);
|
|
166
|
+
p.get = realm.method((self, _, v) => {
|
|
167
|
+
const store = stores.get(self);
|
|
168
|
+
return store === undefined || store.disposed ? -1 : f(store, v);
|
|
169
|
+
});
|
|
170
|
+
// Assigning to it does nothing.
|
|
171
|
+
p.set = realm.method(() => undefined);
|
|
172
|
+
};
|
|
173
|
+
getter("width", (store) => store.width);
|
|
174
|
+
getter("height", (store) => store.height);
|
|
175
|
+
getter("transparent", (store) => store.transparent);
|
|
176
|
+
getter("rectangle", (store, v) => makeGeom(realm, "Rectangle", [0, 0, store.width, store.height], v));
|
|
177
|
+
method("getPixel", 2, (store, args, v) => store.getPixel(avm1.toNumber(args[0], v) | 0, avm1.toNumber(args[1], v) | 0) | 0);
|
|
178
|
+
method("getPixel32", 2, (store, args, v) => store.getPixel32(avm1.toNumber(args[0], v) | 0, avm1.toNumber(args[1], v) | 0) | 0);
|
|
179
|
+
method("setPixel", 3, (store, args, v) => {
|
|
180
|
+
store.setPixel(avm1.toNumber(args[0], v) | 0, avm1.toNumber(args[1], v) | 0, avm1.toNumber(args[2], v) >>> 0);
|
|
181
|
+
return 0;
|
|
182
|
+
});
|
|
183
|
+
method("setPixel32", 3, (store, args, v) => {
|
|
184
|
+
store.setPixel32(avm1.toNumber(args[0], v) | 0, avm1.toNumber(args[1], v) | 0, avm1.toNumber(args[2], v) >>> 0);
|
|
185
|
+
return 0;
|
|
186
|
+
});
|
|
187
|
+
method("fillRect", 2, (store, args, v) => {
|
|
188
|
+
const r = rectOf(args[0], v);
|
|
189
|
+
if (r === null) {
|
|
190
|
+
return -1;
|
|
191
|
+
}
|
|
192
|
+
store.fillRect(r, avm1.toNumber(args[1], v) >>> 0);
|
|
193
|
+
return 0;
|
|
194
|
+
});
|
|
195
|
+
method("copyPixels", 3, (store, args, v) => {
|
|
196
|
+
const source = storeOf(args[0]);
|
|
197
|
+
if (source === null) {
|
|
198
|
+
return -2;
|
|
199
|
+
}
|
|
200
|
+
if (source.disposed) {
|
|
201
|
+
return -3;
|
|
202
|
+
}
|
|
203
|
+
const r = rectOf(args[1], v);
|
|
204
|
+
if (r === null) {
|
|
205
|
+
return -4;
|
|
206
|
+
}
|
|
207
|
+
const [dx, dy] = pointOf(args[2], v);
|
|
208
|
+
// An alpha bitmap counts only with its point given, and mergeAlpha is
|
|
209
|
+
// false unless given, whatever the documentation says (the corpus's
|
|
210
|
+
// bitmap_data_thorough).
|
|
211
|
+
const alpha = args.length >= 5 ? storeOf(args[3]) : null;
|
|
212
|
+
const merge = args.length >= 6 && avm1.toBoolean(args[5], v);
|
|
213
|
+
if (alpha !== null && !alpha.disposed) {
|
|
214
|
+
const [ax, ay] = pointOf(args[4], v);
|
|
215
|
+
store.copyPixels(source, r, dx, dy, merge, alpha, ax, ay);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
store.copyPixels(source, r, dx, dy, merge);
|
|
219
|
+
}
|
|
220
|
+
return 0;
|
|
221
|
+
});
|
|
222
|
+
method("draw", 0, (store, args, v) => {
|
|
223
|
+
// A matrix given as null or undefined draws nothing, -4, before the source is looked at;
|
|
224
|
+
// a draw returns 0, no source -2, a disposed one -3 (adl).
|
|
225
|
+
if (args.length > 1 && (args[1] === null || args[1] === undefined)) {
|
|
226
|
+
return -4;
|
|
227
|
+
}
|
|
228
|
+
const m = matrixOf(args[1], v);
|
|
229
|
+
const c = colorOf(args[2]);
|
|
230
|
+
// draw takes anything that is no blend mode as normal (adl).
|
|
231
|
+
const blend = blendModeOf(args[3]) ?? "normal";
|
|
232
|
+
const clip = args.length > 4 ? rectOf(args[4], v) : null;
|
|
233
|
+
const smooth = args.length > 5 && avm1.toBoolean(args[5], v);
|
|
234
|
+
const source = storeOf(args[0]);
|
|
235
|
+
if (source !== null) {
|
|
236
|
+
if (source.disposed) {
|
|
237
|
+
return -3;
|
|
238
|
+
}
|
|
239
|
+
// Into itself a row at a time, as AS3's BitmapData draws (adl, avm1-draw-self).
|
|
240
|
+
drawBitmap(store, source, m, c, blend, clip, smooth, true);
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
const d = displayOf(args[0]);
|
|
244
|
+
if (d === null) {
|
|
245
|
+
return -2;
|
|
246
|
+
}
|
|
247
|
+
// Without a renderer nothing is drawn: there is no other way to draw a display object.
|
|
248
|
+
if (host.drawer !== null) {
|
|
249
|
+
drawDisplayObject(host.drawer, store, d, m, c, blend, clip, samplesOf(host.quality));
|
|
250
|
+
}
|
|
251
|
+
return 0;
|
|
252
|
+
});
|
|
253
|
+
method("clone", 0, (store, _, v, self) => {
|
|
254
|
+
// A bare object of this one's prototype, a subclass's too (Ruffle).
|
|
255
|
+
const copy = new avm1.Avm1Object(avm1.get(self, "__proto__", v));
|
|
256
|
+
stores.set(copy, store.clone());
|
|
257
|
+
return copy;
|
|
258
|
+
});
|
|
259
|
+
method("dispose", 0, (store) => {
|
|
260
|
+
store.dispose();
|
|
261
|
+
return undefined;
|
|
262
|
+
});
|
|
263
|
+
// 1 where it filled, 0 for a point off the bitmap or a fill of the colour already there.
|
|
264
|
+
method("floodFill", 3, (store, args, v) => {
|
|
265
|
+
const x = avm1.toNumber(args[0], v) >>> 0;
|
|
266
|
+
const y = avm1.toNumber(args[1], v) >>> 0;
|
|
267
|
+
const color = avm1.toNumber(args[2], v) >>> 0;
|
|
268
|
+
if (x >= store.width ||
|
|
269
|
+
y >= store.height ||
|
|
270
|
+
store.pixels[y * store.width + x] === store.premultiplied(color)) {
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
floodFill(store, x, y, color);
|
|
274
|
+
return 1;
|
|
275
|
+
});
|
|
276
|
+
method("scroll", 2, (store, args, v) => {
|
|
277
|
+
scroll(store, avm1.toNumber(args[0], v) | 0, avm1.toNumber(args[1], v) | 0);
|
|
278
|
+
return 0;
|
|
279
|
+
});
|
|
280
|
+
// A filter's rect is not worked out yet (Ruffle's neither).
|
|
281
|
+
// -1 for no rect, -2 for no filter object (adl).
|
|
282
|
+
method("generateFilterRect", 2, (store, args, v) => {
|
|
283
|
+
const r = rectOf(args[0], v);
|
|
284
|
+
if (r === null) {
|
|
285
|
+
return -1;
|
|
286
|
+
}
|
|
287
|
+
const f = filterRecordOf(args[1]);
|
|
288
|
+
if (f === null) {
|
|
289
|
+
return -2;
|
|
290
|
+
}
|
|
291
|
+
const g = generatedRect(store.width, store.height, r, f);
|
|
292
|
+
return makeGeom(realm, "Rectangle", [g.x, g.y, g.width, g.height], v);
|
|
293
|
+
});
|
|
294
|
+
// AS3's operation, its errors numbers (adl): -4 for no rect, -5 for no filter object, -6 for a
|
|
295
|
+
// glow, shadow or bevel into an opaque bitmap; a point that is none is (0, 0).
|
|
296
|
+
method("applyFilter", 4, (store, args, v) => {
|
|
297
|
+
const source = storeOf(args[0]);
|
|
298
|
+
if (source === null) {
|
|
299
|
+
return -2;
|
|
300
|
+
}
|
|
301
|
+
if (source.disposed) {
|
|
302
|
+
return -3;
|
|
303
|
+
}
|
|
304
|
+
// Its rect's numbers as AS3's are, not as ints: an edge of NaN or of
|
|
305
|
+
// Infinity is refused as AS3 refuses it (adl).
|
|
306
|
+
const r = rectOf(args[1], v, false, false);
|
|
307
|
+
if (r === null) {
|
|
308
|
+
return -4;
|
|
309
|
+
}
|
|
310
|
+
const f = filterRecordOf(args[3]);
|
|
311
|
+
if (f === null) {
|
|
312
|
+
return -5;
|
|
313
|
+
}
|
|
314
|
+
// What AS3 refuses with an error, an edge or a size past what Flash makes its buffers for,
|
|
315
|
+
// AVM1 answers -6 for too (adl).
|
|
316
|
+
const refused = filterRefusal(r, f, { x: 0, y: 0, width: source.width, height: source.height }) !== 0;
|
|
317
|
+
if (refused || (!store.transparent && GLOWS.has(f.kind))) {
|
|
318
|
+
return -6;
|
|
319
|
+
}
|
|
320
|
+
const [dx, dy] = pointOf(args[2], v);
|
|
321
|
+
const map = f.mapBitmap?.$store ?? null;
|
|
322
|
+
applyFilter(store, source, r, dx, dy, f, map);
|
|
323
|
+
return 0;
|
|
324
|
+
});
|
|
325
|
+
method("colorTransform", 2, (store, args, v) => {
|
|
326
|
+
const r = rectOf(args[0], v);
|
|
327
|
+
if (r === null) {
|
|
328
|
+
return -2;
|
|
329
|
+
}
|
|
330
|
+
const c = colorOf(args[1]);
|
|
331
|
+
if (c === null) {
|
|
332
|
+
return -3;
|
|
333
|
+
}
|
|
334
|
+
colorTransform(store, r, c);
|
|
335
|
+
return -1;
|
|
336
|
+
});
|
|
337
|
+
/**
|
|
338
|
+
* The source, rect and destination point the copying methods take: -2
|
|
339
|
+
* for a source that is no BitmapData, -3 for a disposed one, -4 for a
|
|
340
|
+
* rect that is none. Their rect spans back from a negative size, as AS3's
|
|
341
|
+
* does.
|
|
342
|
+
*/
|
|
343
|
+
const copyArgs = (args, v) => {
|
|
344
|
+
const source = storeOf(args[0]);
|
|
345
|
+
if (source === null) {
|
|
346
|
+
return -2;
|
|
347
|
+
}
|
|
348
|
+
if (source.disposed) {
|
|
349
|
+
return -3;
|
|
350
|
+
}
|
|
351
|
+
const r = rectOf(args[1], v, true);
|
|
352
|
+
if (r === null) {
|
|
353
|
+
return -4;
|
|
354
|
+
}
|
|
355
|
+
const [dx, dy] = pointOf(args[2], v);
|
|
356
|
+
return { source, r, dx, dy };
|
|
357
|
+
};
|
|
358
|
+
// An argument left out takes its default; one given as undefined is converted, as Flash does.
|
|
359
|
+
const given = (args, i) => args.length > i;
|
|
360
|
+
method("copyChannel", 5, (store, args, v) => {
|
|
361
|
+
const a = copyArgs(args, v);
|
|
362
|
+
if (typeof a === "number") {
|
|
363
|
+
return a;
|
|
364
|
+
}
|
|
365
|
+
const from = avm1.toNumber(args[3], v) | 0;
|
|
366
|
+
const to = avm1.toNumber(args[4], v) | 0;
|
|
367
|
+
copyChannel(store, a.source, a.r, a.dx, a.dy, from >>> 0, to >>> 0);
|
|
368
|
+
return -1;
|
|
369
|
+
});
|
|
370
|
+
method("merge", 6, (store, args, v) => {
|
|
371
|
+
const a = copyArgs(args, v);
|
|
372
|
+
if (typeof a === "number") {
|
|
373
|
+
return a;
|
|
374
|
+
}
|
|
375
|
+
// The alpha multiplier may be left out, whatever the documentation says; each is an int
|
|
376
|
+
// clamped to 0 to 256, where AS3's is a uint taken as it is (Ruffle).
|
|
377
|
+
const muls = [3, 4, 5, 6].map((i) => i === 6 && !given(args, i) ? 0xff : Math.max(0, Math.min(256, avm1.toNumber(args[i], v) | 0)));
|
|
378
|
+
merge(store, a.source, a.r, a.dx, a.dy, muls);
|
|
379
|
+
return -1;
|
|
380
|
+
});
|
|
381
|
+
// Three arguments are enough by the documentation, but without the red table it does nothing.
|
|
382
|
+
method("paletteMap", 4, (store, args, v) => {
|
|
383
|
+
const a = copyArgs(args, v);
|
|
384
|
+
if (typeof a === "number") {
|
|
385
|
+
return a;
|
|
386
|
+
}
|
|
387
|
+
// A channel without a table, an object, maps to itself.
|
|
388
|
+
const table = (t, shift) => Uint32Array.from({ length: 256 }, (_, i) => t instanceof avm1.Avm1Object
|
|
389
|
+
? avm1.toNumber(avm1.get(t, String(i), v), v) >>> 0
|
|
390
|
+
: (i << shift) >>> 0);
|
|
391
|
+
paletteMap(store, a.source, a.r, a.dx, a.dy, [
|
|
392
|
+
table(args[3], 16),
|
|
393
|
+
table(args[4], 8),
|
|
394
|
+
table(args[5], 0),
|
|
395
|
+
table(args[6], 24),
|
|
396
|
+
]);
|
|
397
|
+
return -1;
|
|
398
|
+
});
|
|
399
|
+
method("threshold", 5, (store, args, v) => {
|
|
400
|
+
const a = copyArgs(args, v);
|
|
401
|
+
if (typeof a === "number") {
|
|
402
|
+
return a;
|
|
403
|
+
}
|
|
404
|
+
// An operation threshold does not know is "<".
|
|
405
|
+
const op = avm1.stringOf(args[3], v);
|
|
406
|
+
return threshold(store, a.source, a.r, a.dx, a.dy, isThresholdOperation(op) ? op : "<", avm1.toNumber(args[4], v) >>> 0, avm1.toNumber(args[5], v) >>> 0, given(args, 6) ? avm1.toNumber(args[6], v) >>> 0 : 0xffffffff, avm1.toBoolean(args[7], v), true);
|
|
407
|
+
});
|
|
408
|
+
// Four arguments are enough by the documentation, but without numPixels it does nothing.
|
|
409
|
+
method("pixelDissolve", 5, (store, args, v) => {
|
|
410
|
+
const a = copyArgs(args, v);
|
|
411
|
+
if (typeof a === "number") {
|
|
412
|
+
return a;
|
|
413
|
+
}
|
|
414
|
+
return pixelDissolve(store, a.source, a.r, a.dx, a.dy, avm1.toNumber(args[3], v) | 0,
|
|
415
|
+
// A negative count is a uint's, which comes round the rect as any other.
|
|
416
|
+
avm1.toNumber(args[4], v) >>> 0, given(args, 5) ? avm1.toNumber(args[5], v) >>> 0 : 0);
|
|
417
|
+
});
|
|
418
|
+
method("noise", 1, (store, args, v) => {
|
|
419
|
+
// The bounds are ints clamped to a byte, not bytes, so a negative low is 0.
|
|
420
|
+
const byte = (x) => Math.max(0, Math.min(255, avm1.toNumber(x, v) | 0));
|
|
421
|
+
noise(store, avm1.toNumber(args[0], v) | 0, byte(args[1]), given(args, 2) ? byte(args[2]) : 255, given(args, 3) ? (avm1.toNumber(args[3], v) | 0) & 0xf : 7, avm1.toBoolean(args[4], v));
|
|
422
|
+
return 0;
|
|
423
|
+
});
|
|
424
|
+
method("perlinNoise", 6, (store, args, v) => {
|
|
425
|
+
// Past 1024 octaves the sum no longer changes (the AS3 face's perlinNoise).
|
|
426
|
+
const count = Math.min(Math.max(0, avm1.toNumber(args[2], v) | 0), 1024);
|
|
427
|
+
const offsets = args[8];
|
|
428
|
+
const shifts = Array.from({ length: count }, (_, i) => {
|
|
429
|
+
const p = offsets instanceof avm1.Avm1Object ? avm1.get(offsets, String(i), v) : undefined;
|
|
430
|
+
return p instanceof avm1.Avm1Object
|
|
431
|
+
? [avm1.toNumber(avm1.get(p, "x", v), v), avm1.toNumber(avm1.get(p, "y", v), v)]
|
|
432
|
+
: [0, 0];
|
|
433
|
+
});
|
|
434
|
+
perlinNoise(store, [avm1.toNumber(args[0], v), avm1.toNumber(args[1], v)], shifts, avm1.toNumber(args[3], v) | 0, avm1.toBoolean(args[4], v), avm1.toBoolean(args[5], v), given(args, 6) ? (avm1.toNumber(args[6], v) | 0) & 0xf : 7, avm1.toBoolean(args[7], v));
|
|
435
|
+
return 0;
|
|
436
|
+
});
|
|
437
|
+
method("getColorBoundsRect", 2, (store, args, v) => {
|
|
438
|
+
const r = colorBounds(store, avm1.toNumber(args[0], v) >>> 0, avm1.toNumber(args[1], v) >>> 0, !given(args, 2) || avm1.toBoolean(args[2], v), true);
|
|
439
|
+
return makeGeom(realm, "Rectangle", [r.x, r.y, r.width, r.height], v);
|
|
440
|
+
});
|
|
441
|
+
// compare's answers are its own: -1 for no argument, -2 for one that is no live BitmapData,
|
|
442
|
+
// -3 and -4 for another width and height, 0 for the same pixels.
|
|
443
|
+
method("compare", 1, (store, args, v, self) => {
|
|
444
|
+
const other = storeOf(args[0]);
|
|
445
|
+
if (other === null || other.disposed) {
|
|
446
|
+
return -2;
|
|
447
|
+
}
|
|
448
|
+
if (other.width !== store.width) {
|
|
449
|
+
return -3;
|
|
450
|
+
}
|
|
451
|
+
if (other.height !== store.height) {
|
|
452
|
+
return -4;
|
|
453
|
+
}
|
|
454
|
+
const pixels = comparePixels(store, other);
|
|
455
|
+
if (pixels === null) {
|
|
456
|
+
return 0;
|
|
457
|
+
}
|
|
458
|
+
const diff = new BitmapStore(store.width, store.height, true, 0);
|
|
459
|
+
diff.pixels.set(pixels);
|
|
460
|
+
diff.changed();
|
|
461
|
+
const o = new avm1.Avm1Object(avm1.get(self, "__proto__", v));
|
|
462
|
+
stores.set(o, diff);
|
|
463
|
+
return o;
|
|
464
|
+
});
|
|
465
|
+
method("hitTest", 3, (store, args, v) => {
|
|
466
|
+
// Despite the documentation's Boolean, the errors are negative numbers.
|
|
467
|
+
const first = ownPoint(args[0], v);
|
|
468
|
+
if (first === null) {
|
|
469
|
+
return -2;
|
|
470
|
+
}
|
|
471
|
+
const [fx, fy] = first;
|
|
472
|
+
const a1 = threshold8(args[1], v);
|
|
473
|
+
const second = args[2];
|
|
474
|
+
const other = storeOf(second);
|
|
475
|
+
if (other !== null) {
|
|
476
|
+
if (other.disposed) {
|
|
477
|
+
return -3;
|
|
478
|
+
}
|
|
479
|
+
// The second point may be left out, but not be given as something else.
|
|
480
|
+
const at = ownPoint(args[3], v);
|
|
481
|
+
if (at === null && given(args, 3)) {
|
|
482
|
+
return -4;
|
|
483
|
+
}
|
|
484
|
+
const [sx, sy] = at ?? [0, 0];
|
|
485
|
+
const a2 = threshold8(args[4], v);
|
|
486
|
+
const ox = sx - fx;
|
|
487
|
+
const oy = sy - fy;
|
|
488
|
+
for (let y = Math.max(0, oy); y < Math.min(store.height, oy + other.height); y++) {
|
|
489
|
+
for (let x = Math.max(0, ox); x < Math.min(store.width, ox + other.width); x++) {
|
|
490
|
+
if (alphaAt(store, x, y) >= a1 && alphaAt(other, x - ox, y - oy) >= a2) {
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
// A point or a rectangle, duck-typed by its own fields.
|
|
498
|
+
if (!(second instanceof avm1.Avm1Object)) {
|
|
499
|
+
return -3;
|
|
500
|
+
}
|
|
501
|
+
const field = (n) => second.own(n, v) === undefined ? null : avm1.toNumber(avm1.get(second, n, v), v) | 0;
|
|
502
|
+
const [x, y, w, h] = ["x", "y", "width", "height"].map(field);
|
|
503
|
+
if (x === null || y === null || (w === null) !== (h === null)) {
|
|
504
|
+
return -3;
|
|
505
|
+
}
|
|
506
|
+
const x0 = x - fx;
|
|
507
|
+
const y0 = y - fy;
|
|
508
|
+
// A point hits no pixel of alpha 0, at threshold 0 too; a rect does (Ruffle).
|
|
509
|
+
const least = w === null ? Math.max(1, a1) : a1;
|
|
510
|
+
const x1 = x0 + (w ?? 1);
|
|
511
|
+
const y1 = y0 + (h ?? 1);
|
|
512
|
+
for (let py = Math.max(0, y0); py < Math.min(store.height, y1); py++) {
|
|
513
|
+
for (let px = Math.max(0, x0); px < Math.min(store.width, x1); px++) {
|
|
514
|
+
if (alphaAt(store, px, py) >= least) {
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
});
|
|
521
|
+
// Plain properties, enumerable and writable, as Flash has them (the corpus's bitmapdata_channels).
|
|
522
|
+
constr.define("RED_CHANNEL", 1, 0);
|
|
523
|
+
constr.define("GREEN_CHANNEL", 2, 0);
|
|
524
|
+
constr.define("BLUE_CHANNEL", 4, 0);
|
|
525
|
+
constr.define("ALPHA_CHANNEL", 8, 0);
|
|
526
|
+
// The library's bitmap exported as the name, transparent; undefined where there is none.
|
|
527
|
+
constr.define("loadBitmap", realm.method((_, args, v) => {
|
|
528
|
+
const store = args.length > 0 ? host.libraryBitmap(avm1.stringOf(args[0], v)) : null;
|
|
529
|
+
if (store === null) {
|
|
530
|
+
return undefined;
|
|
531
|
+
}
|
|
532
|
+
const o = new avm1.Avm1Object(avm1.get(constr, "prototype", v));
|
|
533
|
+
stores.set(o, store);
|
|
534
|
+
return o;
|
|
535
|
+
}), FIXED);
|
|
536
|
+
return constr;
|
|
537
|
+
}
|
|
538
|
+
/** What a clip's or button's AVM1 object is the face of; null for anything else. */
|
|
539
|
+
function displayOf(o) {
|
|
540
|
+
const target = o instanceof avm1.Avm1Object ? o.display?.target : undefined;
|
|
541
|
+
return target === undefined ? null : target;
|
|
542
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Button's AS2 face as far as the frame needs it, a button's prototype, as
|
|
2
|
+
// Ruffle's (https://github.com/ruffle-rs/ruffle) core/src/avm1/globals/
|
|
3
|
+
// button.rs has it: MIT OR Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC
|
|
4
|
+
// and Ruffle contributors. Its events and the rest of its properties come
|
|
5
|
+
// with the pointer (docs/avm1.md, step 12).
|
|
6
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
7
|
+
import { ButtonObject } from "../../display/display.js";
|
|
8
|
+
import { filtersProperty } from "./filters.js";
|
|
9
|
+
import { blendModeProperty, cacheAsBitmapProperty, DEPTH_BIAS } from "./MovieClip.js";
|
|
10
|
+
/** Button: its constructor and its prototype, as `_global.Button`. */
|
|
11
|
+
export function buttonClass(movie) {
|
|
12
|
+
const realm = movie.realm;
|
|
13
|
+
const proto = new avm1.Avm1Object(realm.objectProto);
|
|
14
|
+
const constr = realm.classOf(proto, (self) => self, () => undefined);
|
|
15
|
+
proto.define("useHandCursor", true, 0);
|
|
16
|
+
proto.define("enabled", true, 0);
|
|
17
|
+
proto.define("getDepth", realm.method((self) => {
|
|
18
|
+
const d = self instanceof avm1.Avm1Object ? self.display?.target : undefined;
|
|
19
|
+
const depth = d?.depth;
|
|
20
|
+
return depth === undefined || depth === null ? undefined : depth - DEPTH_BIAS;
|
|
21
|
+
}), avm1.VERSION_6);
|
|
22
|
+
const buttonOf = (self) => {
|
|
23
|
+
const d = self.display?.live()?.display?.target;
|
|
24
|
+
return d instanceof ButtonObject ? d : null;
|
|
25
|
+
};
|
|
26
|
+
// Read-only as Ruffle declares them, which their setters still take; listed (adl).
|
|
27
|
+
filtersProperty(realm, proto, avm1.READ_ONLY | avm1.VERSION_8, buttonOf, () => movie.filterFaces);
|
|
28
|
+
blendModeProperty(realm, proto, avm1.READ_ONLY | avm1.VERSION_8, buttonOf);
|
|
29
|
+
cacheAsBitmapProperty(realm, proto, avm1.READ_ONLY | avm1.VERSION_8, buttonOf);
|
|
30
|
+
return { constr, proto };
|
|
31
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Color, AS1's colour transform of a clip, as Ruffle's (https://github.com/
|
|
2
|
+
// ruffle-rs/ruffle) core/src/avm1/globals/color.rs has it: MIT OR
|
|
3
|
+
// Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors.
|
|
4
|
+
// A Color keeps its target as given, a clip or a path, and finds it again
|
|
5
|
+
// each time it is used; the clip's colour transform is kept as a clip keeps
|
|
6
|
+
// one, the multipliers in 8.8 fixed point and the offsets whole, 16 bits
|
|
7
|
+
// each, wrapped.
|
|
8
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
9
|
+
import { TRANSFORM } from "../../display/display.js";
|
|
10
|
+
import { int16 } from "./geom.js";
|
|
11
|
+
import { IDENTITY_COLOR as IDENTITY } from "./MovieClip.js";
|
|
12
|
+
const FIXED = avm1.DONT_ENUM | avm1.DONT_DELETE | avm1.READ_ONLY;
|
|
13
|
+
/** `_global.Color`. */
|
|
14
|
+
export function colorClass(host) {
|
|
15
|
+
const realm = host.realm;
|
|
16
|
+
const proto = new avm1.Avm1Object(realm.objectProto);
|
|
17
|
+
const constr = realm.classOf(proto, (self, args) => {
|
|
18
|
+
self.define("target", args.length > 0 ? args[0] : undefined, FIXED);
|
|
19
|
+
return self;
|
|
20
|
+
}, () => undefined);
|
|
21
|
+
const target = (self, v) => {
|
|
22
|
+
const value = avm1.get(self, "target", v);
|
|
23
|
+
return value === undefined ? null : host.resolve(value, v);
|
|
24
|
+
};
|
|
25
|
+
const changed = (d) => {
|
|
26
|
+
d.touch();
|
|
27
|
+
d.invalidate(TRANSFORM);
|
|
28
|
+
};
|
|
29
|
+
const method = (name, f) => proto.define(name, realm.method(f), FIXED);
|
|
30
|
+
// The offsets as one colour, 0xRRGGBB, signed.
|
|
31
|
+
method("getRGB", (self, _, v) => {
|
|
32
|
+
const d = target(self, v);
|
|
33
|
+
if (d === null) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const c = d.colorTransform ?? IDENTITY;
|
|
37
|
+
return (c.rAdd << 16) | (c.gAdd << 8) | c.bAdd;
|
|
38
|
+
});
|
|
39
|
+
method("setRGB", (self, args, v) => {
|
|
40
|
+
const d = target(self, v);
|
|
41
|
+
if (d !== null) {
|
|
42
|
+
const rgb = avm1.toNumber(args[0], v) | 0;
|
|
43
|
+
const c = d.colorTransform ?? IDENTITY;
|
|
44
|
+
d.colorTransform = {
|
|
45
|
+
...c,
|
|
46
|
+
rMul: 0,
|
|
47
|
+
gMul: 0,
|
|
48
|
+
bMul: 0,
|
|
49
|
+
rAdd: (rgb >> 16) & 0xff,
|
|
50
|
+
gAdd: (rgb >> 8) & 0xff,
|
|
51
|
+
bAdd: rgb & 0xff,
|
|
52
|
+
};
|
|
53
|
+
changed(d);
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
});
|
|
57
|
+
// The multipliers as percentages, ra to aa, then the offsets, rb to ab.
|
|
58
|
+
method("getTransform", (self, _, v) => {
|
|
59
|
+
const d = target(self, v);
|
|
60
|
+
if (d === null) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const c = d.colorTransform ?? IDENTITY;
|
|
64
|
+
const out = new avm1.Avm1Object(realm.objectProto);
|
|
65
|
+
const values = [
|
|
66
|
+
["ra", c.rMul * 100],
|
|
67
|
+
["ga", c.gMul * 100],
|
|
68
|
+
["ba", c.bMul * 100],
|
|
69
|
+
["aa", c.aMul * 100],
|
|
70
|
+
["rb", c.rAdd],
|
|
71
|
+
["gb", c.gAdd],
|
|
72
|
+
["bb", c.bAdd],
|
|
73
|
+
["ab", c.aAdd],
|
|
74
|
+
];
|
|
75
|
+
for (const [name, value] of values) {
|
|
76
|
+
avm1.set(out, name, value, v);
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
});
|
|
80
|
+
// Only the fields the object has of its own; each wrapped to 16 bits, as Flash keeps them.
|
|
81
|
+
// Without an object, none: the clip is still the script's, the timeline's transforms no longer its.
|
|
82
|
+
method("setTransform", (self, args, v) => {
|
|
83
|
+
const d = target(self, v);
|
|
84
|
+
if (d === null) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
const t = realm.box(args[0], v);
|
|
88
|
+
const c = { ...(d.colorTransform ?? IDENTITY) };
|
|
89
|
+
const field = (name) => {
|
|
90
|
+
const p = t.own(name, v);
|
|
91
|
+
return p === undefined ? null : avm1.toNumber(avm1.get(t, name, v), v);
|
|
92
|
+
};
|
|
93
|
+
const mul = (name, old) => {
|
|
94
|
+
const n = field(name);
|
|
95
|
+
return n === null ? old : int16(n * 2.56) / 256;
|
|
96
|
+
};
|
|
97
|
+
const add = (name, old) => {
|
|
98
|
+
const n = field(name);
|
|
99
|
+
return n === null ? old : int16(n);
|
|
100
|
+
};
|
|
101
|
+
d.colorTransform = {
|
|
102
|
+
rMul: mul("ra", c.rMul),
|
|
103
|
+
gMul: mul("ga", c.gMul),
|
|
104
|
+
bMul: mul("ba", c.bMul),
|
|
105
|
+
aMul: mul("aa", c.aMul),
|
|
106
|
+
rAdd: add("rb", c.rAdd),
|
|
107
|
+
gAdd: add("gb", c.gAdd),
|
|
108
|
+
bAdd: add("bb", c.bAdd),
|
|
109
|
+
aAdd: add("ab", c.aAdd),
|
|
110
|
+
};
|
|
111
|
+
changed(d);
|
|
112
|
+
return undefined;
|
|
113
|
+
});
|
|
114
|
+
return constr;
|
|
115
|
+
}
|