@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,635 @@
|
|
|
1
|
+
// flash.filters' AS2 classes, as Ruffle's (https://github.com/ruffle-rs/ruffle)
|
|
2
|
+
// core/src/avm1/globals/bitmap_filter.rs, blur_filter.rs, glow_filter.rs,
|
|
3
|
+
// drop_shadow_filter.rs, bevel_filter.rs, gradient_filter.rs,
|
|
4
|
+
// color_matrix_filter.rs, convolution_filter.rs and
|
|
5
|
+
// displacement_map_filter.rs have them: MIT OR Apache-2.0, Copyright (c)
|
|
6
|
+
// 2018-2022 Ruffle LLC and Ruffle contributors. Each object holds the
|
|
7
|
+
// record a display object's filters keep (display/filters.ts), its values
|
|
8
|
+
// as Flash keeps them: an alpha in a byte, a strength in 256ths, a matrix
|
|
9
|
+
// in floats, a gradient in sixteen slots whose alphas and ratios outlast a
|
|
10
|
+
// shorter list. Its properties are getters and setters on the prototype,
|
|
11
|
+
// listed, from SWF 8; read of anything else they are undefined.
|
|
12
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
13
|
+
import { TRANSFORM } from "../../display/display.js";
|
|
14
|
+
import { copyFilter, filterDefaults } from "../../display/filters.js";
|
|
15
|
+
import { makeGeom } from "./geom.js";
|
|
16
|
+
const MAX_COLORS = 16;
|
|
17
|
+
/**
|
|
18
|
+
* A list's length is read up to this, as Function.apply's is: Flash keeps a
|
|
19
|
+
* kernel of 100,000 elements and walks a filters list as long (adl), but a
|
|
20
|
+
* script's length of 2^31 - 1 would hang the page or run it out of memory.
|
|
21
|
+
*/
|
|
22
|
+
const MAX_LIST = 1 << 20;
|
|
23
|
+
/** The angle a new shadow, bevel or gradient filter has: 0.785398163 radians, nearly 45°. */
|
|
24
|
+
const ANGLE = 0.785398163 * (180 / Math.PI);
|
|
25
|
+
const states = new WeakMap();
|
|
26
|
+
/** The class names by kind, as `flash.filters` has them. */
|
|
27
|
+
const NAMES = {
|
|
28
|
+
blur: "BlurFilter",
|
|
29
|
+
glow: "GlowFilter",
|
|
30
|
+
dropShadow: "DropShadowFilter",
|
|
31
|
+
bevel: "BevelFilter",
|
|
32
|
+
gradientGlow: "GradientGlowFilter",
|
|
33
|
+
gradientBevel: "GradientBevelFilter",
|
|
34
|
+
colorMatrix: "ColorMatrixFilter",
|
|
35
|
+
convolution: "ConvolutionFilter",
|
|
36
|
+
displacementMap: "DisplacementMapFilter",
|
|
37
|
+
};
|
|
38
|
+
/** A double as a byte as Rust casts it: truncated, saturating, NaN 0. */
|
|
39
|
+
const byte = (x) => (Number.isNaN(x) ? 0 : Math.max(0, Math.min(255, Math.trunc(x))));
|
|
40
|
+
/** A double as a u16 as Rust casts it. */
|
|
41
|
+
const u16 = (x) => (Number.isNaN(x) ? 0 : Math.max(0, Math.min(65535, Math.trunc(x))));
|
|
42
|
+
/** A double as an i32 as Rust casts it: saturating, NaN 0. */
|
|
43
|
+
const i32 = (x) => Number.isNaN(x) ? 0 : Math.max(-0x80000000, Math.min(0x7fffffff, Math.trunc(x)));
|
|
44
|
+
const clamp = (x, lo, hi) => (x < lo ? lo : x > hi ? hi : x);
|
|
45
|
+
/** A clamp that takes NaN to its low end. */
|
|
46
|
+
const clampNaN = (x, lo, hi) => (Number.isNaN(x) ? lo : clamp(x, lo, hi));
|
|
47
|
+
function newState(kind) {
|
|
48
|
+
const f = filterDefaults(kind);
|
|
49
|
+
if ("angle" in f) {
|
|
50
|
+
f.angle = ANGLE;
|
|
51
|
+
}
|
|
52
|
+
const gradient = kind === "gradientGlow" || kind === "gradientBevel";
|
|
53
|
+
return {
|
|
54
|
+
f,
|
|
55
|
+
slots: gradient
|
|
56
|
+
? {
|
|
57
|
+
count: 0,
|
|
58
|
+
colors: new Array(MAX_COLORS).fill(0),
|
|
59
|
+
alphas: new Array(MAX_COLORS).fill(0),
|
|
60
|
+
ratios: new Array(MAX_COLORS).fill(0),
|
|
61
|
+
}
|
|
62
|
+
: null,
|
|
63
|
+
map: null,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** A filter object's record, or null for anything else: what a display object or applyFilter takes. */
|
|
67
|
+
export function filterRecordOf(o) {
|
|
68
|
+
const state = o instanceof avm1.Avm1Object ? states.get(o) : undefined;
|
|
69
|
+
if (state === undefined) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
// NaN and all, as AS3's records may hold them: the renderer and applyFilter take them so.
|
|
73
|
+
const f = copyFilter(state.f);
|
|
74
|
+
const slots = state.slots;
|
|
75
|
+
if (slots) {
|
|
76
|
+
f.colors = slots.colors.slice(0, slots.count);
|
|
77
|
+
f.alphas = slots.alphas.slice(0, slots.count).map((a) => a / 255);
|
|
78
|
+
f.ratios = slots.ratios.slice(0, slots.count);
|
|
79
|
+
}
|
|
80
|
+
if (f.kind === "convolution") {
|
|
81
|
+
const n = f.matrixX * f.matrixY;
|
|
82
|
+
f.matrix = Array.from({ length: n }, (_, i) => f.matrix[i] ?? 0);
|
|
83
|
+
}
|
|
84
|
+
if (f.kind === "displacementMap") {
|
|
85
|
+
f.mapBitmap = state.map && !state.map.disposed ? { $store: state.map } : null;
|
|
86
|
+
}
|
|
87
|
+
return f;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A display object's `filters` set from a list: the records of its filter
|
|
91
|
+
* objects up to its length, in order, anything else left out, so an object
|
|
92
|
+
* without a length sets none (adl).
|
|
93
|
+
*/
|
|
94
|
+
function filtersOf(value, version) {
|
|
95
|
+
const out = [];
|
|
96
|
+
const length = value instanceof avm1.Avm1Object ? lengthOf(value, version) : 0;
|
|
97
|
+
for (let i = 0; i < length; i++) {
|
|
98
|
+
const f = filterRecordOf(element(value, i, version));
|
|
99
|
+
if (f !== null) {
|
|
100
|
+
out.push(f);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
/** An object's `length` as Flash reads it for a list: a string's its length, 0 for no int. */
|
|
106
|
+
function lengthOf(value, version) {
|
|
107
|
+
if (typeof value === "string") {
|
|
108
|
+
return Math.min(value.length, MAX_LIST);
|
|
109
|
+
}
|
|
110
|
+
if (!(value instanceof avm1.Avm1Object)) {
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
const n = avm1.toNumber(avm1.get(value, "length", version), version) | 0;
|
|
114
|
+
return n < 0 ? 0 : Math.min(n, MAX_LIST);
|
|
115
|
+
}
|
|
116
|
+
function element(value, i, version) {
|
|
117
|
+
return value instanceof avm1.Avm1Object ? avm1.get(value, String(i), version) : undefined;
|
|
118
|
+
}
|
|
119
|
+
const num = (v, version) => avm1.toNumber(v, version);
|
|
120
|
+
function plain(name, convert) {
|
|
121
|
+
return {
|
|
122
|
+
name,
|
|
123
|
+
get: (s) => s.f[name],
|
|
124
|
+
set: (s, v, version) => {
|
|
125
|
+
s.f[name] = convert(v, version);
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const distance = plain("distance", num);
|
|
130
|
+
const angle = {
|
|
131
|
+
name: "angle",
|
|
132
|
+
get: (s) => s.f.angle,
|
|
133
|
+
set: (s, v, version) => {
|
|
134
|
+
s.f.angle = (num(v, version) % 360) * (Math.PI / 180) * (180 / Math.PI);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
const quality = plain("quality", (v, version) => clamp(num(v, version) | 0, 0, 15));
|
|
138
|
+
const strength = plain("strength", (v, version) => Math.min(u16(num(v, version) * 256), 0xff00) / 256);
|
|
139
|
+
const flag = (name) => plain(name, (v, version) => avm1.toBoolean(v, version));
|
|
140
|
+
const blur = (name, nanToZero = false) => plain(name, (v, version) => nanToZero ? clampNaN(num(v, version), 0, 255) : clamp(num(v, version), 0, 255));
|
|
141
|
+
const rgb = (name) => plain(name, (v, version) => (num(v, version) >>> 0) & 0xffffff);
|
|
142
|
+
/** An alpha kept in a byte; `unit` clamps it to 0 to 1 first, NaN 0. */
|
|
143
|
+
const alpha = (name, unit = false) => plain(name, (v, version) => {
|
|
144
|
+
const a = num(v, version);
|
|
145
|
+
return byte((unit ? clampNaN(a, 0, 1) : a) * 255) / 255;
|
|
146
|
+
});
|
|
147
|
+
/** A bevel's type: inner, outer, or anything else full. */
|
|
148
|
+
const type = plain("type", (v, version) => {
|
|
149
|
+
const t = avm1.stringOf(v, version);
|
|
150
|
+
return t === "inner" || t === "outer" ? t : "full";
|
|
151
|
+
});
|
|
152
|
+
/** A gradient's lists: colors set the count, ratios may lower it, alphas never change it. */
|
|
153
|
+
const colors = {
|
|
154
|
+
name: "colors",
|
|
155
|
+
get: (s, version, make) => s.slots && make.list(s.slots.colors.slice(0, s.slots.count), version),
|
|
156
|
+
set: (s, v, version) => {
|
|
157
|
+
const slots = s.slots;
|
|
158
|
+
if (!slots) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
slots.count = Math.min(lengthOf(v, version), MAX_COLORS);
|
|
162
|
+
for (let i = 0; i < slots.count; i++) {
|
|
163
|
+
slots.colors[i] = (num(element(v, i, version), version) | 0) & 0xffffff;
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
const alphas = {
|
|
168
|
+
name: "alphas",
|
|
169
|
+
get: (s, version, make) => s.slots &&
|
|
170
|
+
make.list(s.slots.alphas.slice(0, s.slots.count).map((a) => a / 255), version),
|
|
171
|
+
set: (s, v, version) => {
|
|
172
|
+
const slots = s.slots;
|
|
173
|
+
if (!slots || !(v instanceof avm1.Avm1Object)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const length = lengthOf(v, version);
|
|
177
|
+
for (let i = 0; i < slots.count; i++) {
|
|
178
|
+
const a = i < length ? num(element(v, i, version), version) : Number.NaN;
|
|
179
|
+
slots.alphas[i] = Number.isFinite(a) ? byte(255 * a + 0.5) : 255;
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
const ratios = {
|
|
184
|
+
name: "ratios",
|
|
185
|
+
get: (s, version, make) => s.slots && make.list(s.slots.ratios.slice(0, s.slots.count), version),
|
|
186
|
+
set: (s, v, version) => {
|
|
187
|
+
const slots = s.slots;
|
|
188
|
+
if (!slots || !(v instanceof avm1.Avm1Object)) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
slots.count = Math.min(lengthOf(v, version), slots.count);
|
|
192
|
+
for (let i = 0; i < slots.count; i++) {
|
|
193
|
+
slots.ratios[i] = clamp(num(element(v, i, version), version) | 0, 0, 255);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
/** A convolution's kernel grown, never shrunk, to its size. */
|
|
198
|
+
function fitKernel(f) {
|
|
199
|
+
const n = f.matrixX * f.matrixY;
|
|
200
|
+
while (f.matrix.length < n) {
|
|
201
|
+
f.matrix.push(0);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const matrixSide = (name) => ({
|
|
205
|
+
name,
|
|
206
|
+
get: (s) => s.f[name],
|
|
207
|
+
set: (s, v, version) => {
|
|
208
|
+
s.f[name] = clamp(num(v, version) | 0, 0, 15);
|
|
209
|
+
fitKernel(s.f);
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
const kernel = {
|
|
213
|
+
name: "matrix",
|
|
214
|
+
get: (s, version, make) => make.list(s.f.matrix, version),
|
|
215
|
+
set: (s, v, version) => {
|
|
216
|
+
const length = lengthOf(v, version);
|
|
217
|
+
const matrix = [];
|
|
218
|
+
for (let i = 0; i < length; i++) {
|
|
219
|
+
matrix.push(Math.fround(num(element(v, i, version), version)));
|
|
220
|
+
}
|
|
221
|
+
s.f.matrix = matrix;
|
|
222
|
+
fitKernel(s.f);
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
const float = (name) => plain(name, (v, version) => Math.fround(num(v, version)));
|
|
226
|
+
/** A colour matrix's twenty floats: an object's elements, NaN past them; anything else all NaN. */
|
|
227
|
+
const colorMatrix = {
|
|
228
|
+
name: "matrix",
|
|
229
|
+
get: (s, version, make) => make.list(s.f.matrix, version),
|
|
230
|
+
set: (s, v, version) => {
|
|
231
|
+
if (v === undefined || v === null) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const matrix = new Array(20).fill(Number.NaN);
|
|
235
|
+
if (v instanceof avm1.Avm1Object) {
|
|
236
|
+
for (let i = 0; i < 20; i++) {
|
|
237
|
+
if (i < lengthOf(v, version)) {
|
|
238
|
+
matrix[i] = Math.fround(num(element(v, i, version), version));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
s.f.matrix = matrix;
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
const mapBitmap = {
|
|
246
|
+
name: "mapBitmap",
|
|
247
|
+
get: (s, _, make) => (s.map ? make.bitmap(s.map) : undefined),
|
|
248
|
+
set: (s, v, _, make) => {
|
|
249
|
+
const store = make.store(v);
|
|
250
|
+
if (store !== null) {
|
|
251
|
+
s.map = store;
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* The map's point, own x and y converted both before either error is
|
|
257
|
+
* thrown, x's first; a point with only one of them, or no object, is (0, 0);
|
|
258
|
+
* one that fails to convert is int's least.
|
|
259
|
+
*/
|
|
260
|
+
const mapPoint = {
|
|
261
|
+
name: "mapPoint",
|
|
262
|
+
get: (s, version, make) => make.point(s.f.mapPoint[0], s.f.mapPoint[1], version),
|
|
263
|
+
set: (s, v, version) => {
|
|
264
|
+
if (!(v instanceof avm1.Avm1Object)) {
|
|
265
|
+
s.f.mapPoint = [0, 0];
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const convert = (name) => {
|
|
269
|
+
const p = v.own(name, version);
|
|
270
|
+
if (p === undefined) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
return { n: i32(num(p.value, version)), error: null };
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
return { n: -0x80000000, error };
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const x = convert("x");
|
|
281
|
+
const y = convert("y");
|
|
282
|
+
s.f.mapPoint = x && y ? [x.n, y.n] : [0, 0];
|
|
283
|
+
if (x?.error) {
|
|
284
|
+
throw x.error;
|
|
285
|
+
}
|
|
286
|
+
if (y?.error) {
|
|
287
|
+
throw y.error;
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
const component = (name) => plain(name, (v, version) => num(v, version) | 0);
|
|
292
|
+
const scale = (name) => plain(name, (v, version) => Math.fround(clampNaN(num(v, version), -65535, 65535)));
|
|
293
|
+
const mode = plain("mode", (v, version) => {
|
|
294
|
+
const m = avm1.stringOf(v, version);
|
|
295
|
+
return m === "clamp" || m === "ignore" || m === "color" ? m : "wrap";
|
|
296
|
+
});
|
|
297
|
+
/** Each class's properties in Flash's order, and its constructor's arguments in theirs. */
|
|
298
|
+
const CLASSES = (() => {
|
|
299
|
+
const [blurX, blurY] = [blur("blurX"), blur("blurY")];
|
|
300
|
+
const [color, a] = [rgb("color"), alpha("alpha")];
|
|
301
|
+
const [inner, knockout] = [flag("inner"), flag("knockout")];
|
|
302
|
+
const highlightColor = rgb("highlightColor");
|
|
303
|
+
const highlightAlpha = alpha("highlightAlpha");
|
|
304
|
+
const shadowColor = rgb("shadowColor");
|
|
305
|
+
const shadowAlpha = alpha("shadowAlpha");
|
|
306
|
+
const [gBlurX, gBlurY] = [blur("blurX", true), blur("blurY", true)];
|
|
307
|
+
const gradient = {
|
|
308
|
+
props: [
|
|
309
|
+
distance,
|
|
310
|
+
angle,
|
|
311
|
+
colors,
|
|
312
|
+
alphas,
|
|
313
|
+
ratios,
|
|
314
|
+
gBlurX,
|
|
315
|
+
gBlurY,
|
|
316
|
+
quality,
|
|
317
|
+
strength,
|
|
318
|
+
knockout,
|
|
319
|
+
type,
|
|
320
|
+
],
|
|
321
|
+
args: [
|
|
322
|
+
distance,
|
|
323
|
+
angle,
|
|
324
|
+
colors,
|
|
325
|
+
alphas,
|
|
326
|
+
ratios,
|
|
327
|
+
gBlurX,
|
|
328
|
+
gBlurY,
|
|
329
|
+
strength,
|
|
330
|
+
quality,
|
|
331
|
+
type,
|
|
332
|
+
knockout,
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
const [divisor, bias] = [float("divisor"), float("bias")];
|
|
336
|
+
const unitAlpha = alpha("alpha", true);
|
|
337
|
+
return {
|
|
338
|
+
blur: { props: [blurX, blurY, quality], args: [blurX, blurY, quality] },
|
|
339
|
+
glow: {
|
|
340
|
+
props: [color, a, quality, inner, knockout, blurX, blurY, strength],
|
|
341
|
+
args: [color, a, blurX, blurY, strength, quality, inner, knockout],
|
|
342
|
+
},
|
|
343
|
+
dropShadow: {
|
|
344
|
+
props: [
|
|
345
|
+
distance,
|
|
346
|
+
angle,
|
|
347
|
+
color,
|
|
348
|
+
a,
|
|
349
|
+
quality,
|
|
350
|
+
inner,
|
|
351
|
+
knockout,
|
|
352
|
+
blurX,
|
|
353
|
+
blurY,
|
|
354
|
+
strength,
|
|
355
|
+
flag("hideObject"),
|
|
356
|
+
],
|
|
357
|
+
args: [
|
|
358
|
+
distance,
|
|
359
|
+
angle,
|
|
360
|
+
color,
|
|
361
|
+
a,
|
|
362
|
+
blurX,
|
|
363
|
+
blurY,
|
|
364
|
+
strength,
|
|
365
|
+
quality,
|
|
366
|
+
inner,
|
|
367
|
+
knockout,
|
|
368
|
+
flag("hideObject"),
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
bevel: {
|
|
372
|
+
props: [
|
|
373
|
+
distance,
|
|
374
|
+
angle,
|
|
375
|
+
highlightColor,
|
|
376
|
+
highlightAlpha,
|
|
377
|
+
shadowColor,
|
|
378
|
+
shadowAlpha,
|
|
379
|
+
quality,
|
|
380
|
+
strength,
|
|
381
|
+
knockout,
|
|
382
|
+
blurX,
|
|
383
|
+
blurY,
|
|
384
|
+
type,
|
|
385
|
+
],
|
|
386
|
+
args: [
|
|
387
|
+
distance,
|
|
388
|
+
angle,
|
|
389
|
+
highlightColor,
|
|
390
|
+
highlightAlpha,
|
|
391
|
+
shadowColor,
|
|
392
|
+
shadowAlpha,
|
|
393
|
+
blurX,
|
|
394
|
+
blurY,
|
|
395
|
+
strength,
|
|
396
|
+
quality,
|
|
397
|
+
type,
|
|
398
|
+
knockout,
|
|
399
|
+
],
|
|
400
|
+
},
|
|
401
|
+
gradientGlow: gradient,
|
|
402
|
+
gradientBevel: gradient,
|
|
403
|
+
colorMatrix: { props: [colorMatrix], args: [colorMatrix] },
|
|
404
|
+
convolution: {
|
|
405
|
+
props: [
|
|
406
|
+
matrixSide("matrixX"),
|
|
407
|
+
matrixSide("matrixY"),
|
|
408
|
+
kernel,
|
|
409
|
+
divisor,
|
|
410
|
+
bias,
|
|
411
|
+
flag("preserveAlpha"),
|
|
412
|
+
flag("clamp"),
|
|
413
|
+
rgb("color"),
|
|
414
|
+
unitAlpha,
|
|
415
|
+
],
|
|
416
|
+
// Its divisor and colour are the constructor's own (see below).
|
|
417
|
+
args: [matrixSide("matrixX"), matrixSide("matrixY"), kernel],
|
|
418
|
+
},
|
|
419
|
+
displacementMap: {
|
|
420
|
+
props: [
|
|
421
|
+
mapBitmap,
|
|
422
|
+
mapPoint,
|
|
423
|
+
component("componentX"),
|
|
424
|
+
component("componentY"),
|
|
425
|
+
scale("scaleX"),
|
|
426
|
+
scale("scaleY"),
|
|
427
|
+
mode,
|
|
428
|
+
rgb("color"),
|
|
429
|
+
unitAlpha,
|
|
430
|
+
],
|
|
431
|
+
args: [
|
|
432
|
+
mapBitmap,
|
|
433
|
+
mapPoint,
|
|
434
|
+
component("componentX"),
|
|
435
|
+
component("componentY"),
|
|
436
|
+
scale("scaleX"),
|
|
437
|
+
scale("scaleY"),
|
|
438
|
+
mode,
|
|
439
|
+
rgb("color"),
|
|
440
|
+
unitAlpha,
|
|
441
|
+
],
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
})();
|
|
445
|
+
/**
|
|
446
|
+
* A convolution's constructor past its kernel: a divisor not given is the
|
|
447
|
+
* kernel's sum where any argument is; a colour given makes its alpha 1,
|
|
448
|
+
* the documentation aside (Ruffle).
|
|
449
|
+
*/
|
|
450
|
+
function constructConvolution(s, args, version) {
|
|
451
|
+
const f = s.f;
|
|
452
|
+
if (args.length > 3) {
|
|
453
|
+
f.divisor = Math.fround(num(args[3], version));
|
|
454
|
+
}
|
|
455
|
+
else if (args.length > 0) {
|
|
456
|
+
f.divisor = Math.fround(f.matrix.reduce((sum, x) => Math.fround(sum + x), 0));
|
|
457
|
+
}
|
|
458
|
+
if (args.length > 4) {
|
|
459
|
+
f.bias = Math.fround(num(args[4], version));
|
|
460
|
+
}
|
|
461
|
+
if (args.length > 5) {
|
|
462
|
+
f.preserveAlpha = avm1.toBoolean(args[5], version);
|
|
463
|
+
}
|
|
464
|
+
if (args.length > 6) {
|
|
465
|
+
f.clamp = avm1.toBoolean(args[6], version);
|
|
466
|
+
}
|
|
467
|
+
if (args.length > 7) {
|
|
468
|
+
f.color = (num(args[7], version) >>> 0) & 0xffffff;
|
|
469
|
+
f.alpha = 1;
|
|
470
|
+
}
|
|
471
|
+
if (args.length > 8) {
|
|
472
|
+
f.alpha = byte(clampNaN(num(args[8], version), 0, 1) * 255) / 255;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
/** `flash.filters`, its classes on `filters`; what reads a display object's filters back. */
|
|
476
|
+
export function filtersPackage(host, filters) {
|
|
477
|
+
const realm = host.realm;
|
|
478
|
+
const make = {
|
|
479
|
+
list: (values, version) => realm.newArray([...values], version),
|
|
480
|
+
bitmap: (store) => host.bitmapObject(store),
|
|
481
|
+
point: (x, y, version) => makeGeom(realm, "Point", [x, y], version),
|
|
482
|
+
store: (value) => host.storeOf(value),
|
|
483
|
+
};
|
|
484
|
+
/** A native function as a class's constructor, `prototype` and `constructor` its own. */
|
|
485
|
+
const classOf = (proto, construct) => {
|
|
486
|
+
const constr = new avm1.Avm1Function(undefined, realm, () => undefined, construct);
|
|
487
|
+
constr.define("prototype", proto, avm1.DONT_ENUM | avm1.DONT_DELETE);
|
|
488
|
+
constr.define("constructor", realm.Function, avm1.DONT_ENUM | avm1.DONT_DELETE);
|
|
489
|
+
constr.define("__proto__", realm.functionProto, avm1.DONT_ENUM | avm1.DONT_DELETE | avm1.VERSION_6);
|
|
490
|
+
return constr;
|
|
491
|
+
};
|
|
492
|
+
// BitmapFilter: no state of its own, a clone that copies a filter's.
|
|
493
|
+
const base = new avm1.Avm1Object(realm.objectProto);
|
|
494
|
+
const baseClass = classOf(base, (self) => self);
|
|
495
|
+
base.define("constructor", baseClass, avm1.DONT_ENUM | avm1.DONT_DELETE);
|
|
496
|
+
base.define("clone", realm.method((self) => {
|
|
497
|
+
const state = states.get(self);
|
|
498
|
+
if (state === undefined) {
|
|
499
|
+
return undefined;
|
|
500
|
+
}
|
|
501
|
+
const copy = new avm1.Avm1Object(self.proto);
|
|
502
|
+
states.set(copy, cloneState(state));
|
|
503
|
+
return copy;
|
|
504
|
+
}), 0);
|
|
505
|
+
filters.define("BitmapFilter", baseClass, 0);
|
|
506
|
+
const protos = new Map();
|
|
507
|
+
// Defined in Flash's order, for..in lists them the other way round.
|
|
508
|
+
const order = [
|
|
509
|
+
"dropShadow",
|
|
510
|
+
"blur",
|
|
511
|
+
"glow",
|
|
512
|
+
"bevel",
|
|
513
|
+
"gradientGlow",
|
|
514
|
+
"gradientBevel",
|
|
515
|
+
"convolution",
|
|
516
|
+
"colorMatrix",
|
|
517
|
+
"displacementMap",
|
|
518
|
+
];
|
|
519
|
+
for (const kind of order) {
|
|
520
|
+
const { props, args } = CLASSES[kind];
|
|
521
|
+
// As a class that extends BitmapFilter: its __constructor__, no constructor.
|
|
522
|
+
const proto = new avm1.Avm1Object(base);
|
|
523
|
+
proto.define("__constructor__", baseClass, avm1.DONT_ENUM);
|
|
524
|
+
const constr = classOf(proto, (self, given, version) => {
|
|
525
|
+
const state = newState(kind);
|
|
526
|
+
for (let i = 0; i < args.length && i < given.length; i++) {
|
|
527
|
+
args[i].set(state, given[i], version, make);
|
|
528
|
+
}
|
|
529
|
+
if (kind === "convolution") {
|
|
530
|
+
constructConvolution(state, given, version);
|
|
531
|
+
}
|
|
532
|
+
states.set(self, state);
|
|
533
|
+
return self;
|
|
534
|
+
});
|
|
535
|
+
for (const prop of props) {
|
|
536
|
+
const p = proto.add(prop.name, undefined, avm1.VERSION_8);
|
|
537
|
+
p.get = realm.method((self, _, version) => {
|
|
538
|
+
const state = states.get(self);
|
|
539
|
+
return state === undefined ? undefined : prop.get(state, version, make);
|
|
540
|
+
});
|
|
541
|
+
p.set = realm.method((self, values, version) => {
|
|
542
|
+
const state = states.get(self);
|
|
543
|
+
if (state !== undefined) {
|
|
544
|
+
prop.set(state, values[0], version, make);
|
|
545
|
+
}
|
|
546
|
+
return undefined;
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
protos.set(kind, proto);
|
|
550
|
+
filters.define(NAMES[kind], constr, 0);
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
objectOf(f) {
|
|
554
|
+
const o = new avm1.Avm1Object(protos.get(f.kind));
|
|
555
|
+
states.set(o, stateOf(f));
|
|
556
|
+
return o;
|
|
557
|
+
},
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
/** A state of a display object's record, as its `filters` reads it. */
|
|
561
|
+
function stateOf(record) {
|
|
562
|
+
const f = copyFilter(record);
|
|
563
|
+
const state = { f, slots: null, map: null };
|
|
564
|
+
if (f.kind === "gradientGlow" || f.kind === "gradientBevel") {
|
|
565
|
+
const count = Math.min(f.colors.length, MAX_COLORS);
|
|
566
|
+
const fill = (values) => [
|
|
567
|
+
...values.slice(0, count),
|
|
568
|
+
...new Array(MAX_COLORS - count).fill(0),
|
|
569
|
+
];
|
|
570
|
+
state.slots = {
|
|
571
|
+
count,
|
|
572
|
+
colors: fill(f.colors),
|
|
573
|
+
alphas: fill(f.alphas.map((a) => Math.round(a * 255))),
|
|
574
|
+
ratios: fill(f.ratios),
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (f.kind === "displacementMap") {
|
|
578
|
+
state.map = f.mapBitmap?.$store ?? null;
|
|
579
|
+
f.mapSnapshot = undefined;
|
|
580
|
+
}
|
|
581
|
+
return state;
|
|
582
|
+
}
|
|
583
|
+
function cloneState(s) {
|
|
584
|
+
const slots = s.slots;
|
|
585
|
+
return {
|
|
586
|
+
f: copyFilter(s.f),
|
|
587
|
+
slots: slots
|
|
588
|
+
? {
|
|
589
|
+
count: slots.count,
|
|
590
|
+
colors: [...slots.colors],
|
|
591
|
+
alphas: [...slots.alphas],
|
|
592
|
+
ratios: [...slots.ratios],
|
|
593
|
+
}
|
|
594
|
+
: null,
|
|
595
|
+
map: s.map,
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* A display object's `filters` on its class's prototype, of `flags`: a new
|
|
600
|
+
* array of new filter objects each read; a list's filter objects set them.
|
|
601
|
+
*/
|
|
602
|
+
export function filtersProperty(realm, proto, flags, targetOf, faces) {
|
|
603
|
+
const p = proto.add("filters", undefined, flags);
|
|
604
|
+
p.get = realm.method((self, _, version) => {
|
|
605
|
+
const d = targetOf(self);
|
|
606
|
+
const made = faces();
|
|
607
|
+
return d === null || made === null
|
|
608
|
+
? undefined
|
|
609
|
+
: realm.newArray(d.filters.map((f) => made.objectOf(f)), version);
|
|
610
|
+
});
|
|
611
|
+
p.set = realm.method((self, args, version) => {
|
|
612
|
+
const d = targetOf(self);
|
|
613
|
+
if (d !== null) {
|
|
614
|
+
setDisplayFilters(d, args[0], version);
|
|
615
|
+
}
|
|
616
|
+
return undefined;
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* A display object's `filters` set: the records of the filter objects in
|
|
621
|
+
* the array, anything else left out; a displacement map's pixels taken as
|
|
622
|
+
* they are now, as AS3's are.
|
|
623
|
+
*/
|
|
624
|
+
function setDisplayFilters(d, value, version) {
|
|
625
|
+
const list = filtersOf(value, version);
|
|
626
|
+
for (const f of list) {
|
|
627
|
+
const store = f.mapBitmap?.$store;
|
|
628
|
+
if (f.kind === "displacementMap" && store) {
|
|
629
|
+
f.mapSnapshot = { $store: store.clone() };
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
d.touch();
|
|
633
|
+
d.filters = list;
|
|
634
|
+
d.invalidate(TRANSFORM);
|
|
635
|
+
}
|