@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,11 @@
|
|
|
1
|
+
import { DxtEncoder } from "../../native/render/index.js";
|
|
2
|
+
let encoder = null;
|
|
3
|
+
/** The realm's native encoder, made only when a compressed texture takes pixels. */
|
|
4
|
+
export function encodeDxt(rgba, dxt5, width, height) {
|
|
5
|
+
encoder ??= new DxtEncoder();
|
|
6
|
+
return encoder.encode(rgba, dxt5, width, height);
|
|
7
|
+
}
|
|
8
|
+
/** The last player's textures went with it; their encoder's memory can go too. */
|
|
9
|
+
export function releaseDxtEncoder() {
|
|
10
|
+
encoder?.release();
|
|
11
|
+
}
|
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
// BitmapData.applyFilter and generateFilterRect, on the CPU, as adl
|
|
2
|
+
// computes them (docs/architecture/compositing.md, "Filters"): the source filtered, past
|
|
3
|
+
// the source rect too, and the filter's rect written whole into the
|
|
4
|
+
// destination; a blur's runs truncated to 8 bits each, a glow's alpha from
|
|
5
|
+
// the blur so truncated times strength, a bevel's from the difference of two
|
|
6
|
+
// reads of it, a colour matrix of straight colour, rounded, a convolution of
|
|
7
|
+
// straight colour, truncated; the blurs, glows, shadows, bevels and
|
|
8
|
+
// convolutions by the render module.
|
|
9
|
+
import { ramp } from "../display/gradients.js";
|
|
10
|
+
import { EDGE_LIMIT, NAN_EDGE, over, premultiply, unmultiply, } from "./bitmap.js";
|
|
11
|
+
import { bitmapKernel } from "./kernel.js";
|
|
12
|
+
/** The filters with a glow, a shadow or a bevel, which an opaque destination refuses. */
|
|
13
|
+
export const GLOWS = new Set([
|
|
14
|
+
"glow",
|
|
15
|
+
"dropShadow",
|
|
16
|
+
"bevel",
|
|
17
|
+
"gradientGlow",
|
|
18
|
+
"gradientBevel",
|
|
19
|
+
]);
|
|
20
|
+
/** The filters this filters: the others' rects and pixels are still to come. */
|
|
21
|
+
export const filtersDrawn = new Set([
|
|
22
|
+
"blur",
|
|
23
|
+
"glow",
|
|
24
|
+
"dropShadow",
|
|
25
|
+
"colorMatrix",
|
|
26
|
+
"convolution",
|
|
27
|
+
"bevel",
|
|
28
|
+
"gradientGlow",
|
|
29
|
+
"gradientBevel",
|
|
30
|
+
"displacementMap",
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* How far adl's rect for a blur of `quality` passes reaches, a blur below
|
|
34
|
+
* 1 counting as 1: the passes' spread, which grows slower than their
|
|
35
|
+
* number, as a float, times the blur; for a blur that rounded up from a
|
|
36
|
+
* quarter, for the others half to even from a half, as x87 rounds.
|
|
37
|
+
*/
|
|
38
|
+
const PASS_SPREADS = [
|
|
39
|
+
1.0, 2.1, 2.7, 3.1, 3.5, 3.8, 4.0, 4.2, 4.4, 4.6, 5.0, 6.0, 6.0, 7.0, 7.0,
|
|
40
|
+
].map((spread) => Math.fround(spread) / 2);
|
|
41
|
+
function spreadOf(blur, quality, kind) {
|
|
42
|
+
if (quality < 1) {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
const x = Math.max(blur || 0, 1) * PASS_SPREADS[Math.min(quality, 15) - 1];
|
|
46
|
+
if (kind === "blur") {
|
|
47
|
+
return Math.floor(x + 0.75);
|
|
48
|
+
}
|
|
49
|
+
const v = x + 0.5;
|
|
50
|
+
const whole = Math.floor(v);
|
|
51
|
+
return v - whole === 0.5 ? whole + (whole % 2) : Math.round(v);
|
|
52
|
+
}
|
|
53
|
+
/** How far a filter's rect reaches past what it filters, each way, before any offset: [x, y], whole pixels. */
|
|
54
|
+
function reach(f) {
|
|
55
|
+
if (f.kind === "convolution") {
|
|
56
|
+
return [f.matrixX >> 1, f.matrixY >> 1];
|
|
57
|
+
}
|
|
58
|
+
if (f.kind === "colorMatrix") {
|
|
59
|
+
return [0, 0];
|
|
60
|
+
}
|
|
61
|
+
// A displacement map's reach, by its scale, as adl reckons it: a quarter of it, whole; none with no map.
|
|
62
|
+
if (f.kind === "displacementMap") {
|
|
63
|
+
return f.mapBitmap
|
|
64
|
+
? [Math.floor(Math.abs(f.scaleX) / 4) || 0, Math.floor(Math.abs(f.scaleY) / 4) || 0]
|
|
65
|
+
: [0, 0];
|
|
66
|
+
}
|
|
67
|
+
return [spreadOf(f.blurX, f.quality, f.kind), spreadOf(f.blurY, f.quality, f.kind)];
|
|
68
|
+
}
|
|
69
|
+
/** Where adl's offsets in 256ths run out: the most a part of one reaches, as -2^23 - 256. */
|
|
70
|
+
const FAR = -(2 ** 23 + 256);
|
|
71
|
+
/**
|
|
72
|
+
* How far off adl's angle is, in radians: its offset has a part across the
|
|
73
|
+
* angle of 6.79e-9 of the distance, back, even on the axes, so 4e9 at 0°
|
|
74
|
+
* reaches 30 up past a reach of 2 and 27 right at 90°, and 1e11 679 both
|
|
75
|
+
* ways (fitted from 5e5 to 1e11 at the four axes, either sign).
|
|
76
|
+
*/
|
|
77
|
+
const SKEW = -6.79e-9;
|
|
78
|
+
/**
|
|
79
|
+
* A shadow's or a bevel's offset, down: [x, y], unrounded. adl keeps each
|
|
80
|
+
* part in 256ths in an int, so one of 2^23 - 1 or more wraps round and one
|
|
81
|
+
* below FAR stops there, both at FAR (generateFilterRect's -8388866 past
|
|
82
|
+
* a reach of 2), as Infinity does; its angle is off by SKEW, which this
|
|
83
|
+
* takes where it comes to a 512th, from a distance of some 288,000, and
|
|
84
|
+
* leaves out nearer, where it would only move a sample between pixels by
|
|
85
|
+
* a hair. A distance of NaN is FAR both ways for an outer shadow or
|
|
86
|
+
* gradient glow, none for the rest; an angle of NaN or Infinity is 0 (an
|
|
87
|
+
* outer shadow refuses either NaN: filterRefusal).
|
|
88
|
+
*/
|
|
89
|
+
function shadowOffset(f) {
|
|
90
|
+
const d = f.distance;
|
|
91
|
+
if (Number.isNaN(d)) {
|
|
92
|
+
return (f.kind === "dropShadow" || f.kind === "gradientGlow") && !isInner(f)
|
|
93
|
+
? [FAR, FAR]
|
|
94
|
+
: [0, 0];
|
|
95
|
+
}
|
|
96
|
+
const skew = Math.abs(d * SKEW) >= 1 / 512 ? SKEW : 0;
|
|
97
|
+
const radians = ((f.angle || 0) * Math.PI) / 180 + skew;
|
|
98
|
+
// A part a whisker off whole is whole, as adl's 256ths have it: 3 at
|
|
99
|
+
// 180° is -3 across and 0 down, not 3.7e-16, which would read between rows.
|
|
100
|
+
const part = (v) => {
|
|
101
|
+
const whole = Math.round(v);
|
|
102
|
+
return !(v < 2 ** 23 - 1 && v >= FAR) ? FAR : Math.abs(v - whole) < 1e-9 ? whole : v;
|
|
103
|
+
};
|
|
104
|
+
return [part(d * Math.cos(radians)), part(d * Math.sin(radians))];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A shadow's or a bevel's offset in whole pixels, down: [x, y]. adl has it
|
|
108
|
+
* in 256ths, to the nearest, so the cosine of 90° is 0, not just under it,
|
|
109
|
+
* and 6 × sin 30° is 3, not just under.
|
|
110
|
+
*/
|
|
111
|
+
function offsetOf(f) {
|
|
112
|
+
const whole = (v) => Math.floor(Math.round(v * 256) / 256);
|
|
113
|
+
const [ox, oy] = shadowOffset(f);
|
|
114
|
+
return [whole(ox), whole(oy)];
|
|
115
|
+
}
|
|
116
|
+
/** Whether `f` is drawn within what it filters: an inner glow, shadow, bevel or gradient one. */
|
|
117
|
+
export function isInner(f) {
|
|
118
|
+
return f.kind === "glow" || f.kind === "dropShadow" ? f.inner : f.type === "inner";
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The rect a filter makes of `rect`, as generateFilterRect gives it: grown
|
|
122
|
+
* by its reach; a shadow's, inner too, by its offset where it moves and
|
|
123
|
+
* less it on the other side, never inward; a bevel's by the offset's size
|
|
124
|
+
* both ways.
|
|
125
|
+
*/
|
|
126
|
+
export function filterRect(rect, f) {
|
|
127
|
+
const [rx, ry] = reach(f);
|
|
128
|
+
let [left, right, top, bottom] = [rx, rx, ry, ry];
|
|
129
|
+
if (f.kind === "dropShadow" || f.kind === "gradientGlow") {
|
|
130
|
+
const [ox, oy] = offsetOf(f);
|
|
131
|
+
left = Math.max(0, rx - ox);
|
|
132
|
+
right = Math.max(0, rx + ox);
|
|
133
|
+
top = Math.max(0, ry - oy);
|
|
134
|
+
bottom = Math.max(0, ry + oy);
|
|
135
|
+
}
|
|
136
|
+
else if (f.kind === "bevel" || f.kind === "gradientBevel") {
|
|
137
|
+
const [ox, oy] = offsetOf(f);
|
|
138
|
+
left = right = rx + Math.abs(ox);
|
|
139
|
+
top = bottom = ry + Math.abs(oy);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
x: rect.x - left,
|
|
143
|
+
y: rect.y - top,
|
|
144
|
+
width: rect.width + left + right,
|
|
145
|
+
height: rect.height + top + bottom,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* generateFilterRect's rect of `given` on a bitmap of `width` by `height`:
|
|
150
|
+
* the rect within the bitmap first, an edge of it a rect of no width, and
|
|
151
|
+
* grown by the filter; one apart from it Flash makes 2^27 - 1 on each side,
|
|
152
|
+
* of no size, grown as any other but an inner filter's, which stays where
|
|
153
|
+
* it is. A displacement map's result is within the bitmap too, and an
|
|
154
|
+
* inner filter's, which draws within what it filters.
|
|
155
|
+
*/
|
|
156
|
+
export function generatedRect(width, height, given, f) {
|
|
157
|
+
const x0 = Math.max(0, given.x);
|
|
158
|
+
const y0 = Math.max(0, given.y);
|
|
159
|
+
const x1 = Math.min(width, given.x + given.width);
|
|
160
|
+
const y1 = Math.min(height, given.y + given.height);
|
|
161
|
+
if (x1 < x0 || y1 < y0) {
|
|
162
|
+
const apart = { x: 0x7ffffff, y: 0x7ffffff, width: 0, height: 0 };
|
|
163
|
+
return isInner(f) ? apart : filterRect(apart, f);
|
|
164
|
+
}
|
|
165
|
+
const r = filterRect({ x: x0, y: y0, width: x1 - x0, height: y1 - y0 }, f);
|
|
166
|
+
if (f.kind !== "displacementMap" && !isInner(f)) {
|
|
167
|
+
return r;
|
|
168
|
+
}
|
|
169
|
+
const rx0 = Math.max(0, r.x);
|
|
170
|
+
const ry0 = Math.max(0, r.y);
|
|
171
|
+
const rx1 = Math.min(width, r.x + r.width);
|
|
172
|
+
const ry1 = Math.min(height, r.y + r.height);
|
|
173
|
+
return rx1 > rx0 && ry1 > ry0
|
|
174
|
+
? { x: rx0, y: ry0, width: rx1 - rx0, height: ry1 - ry0 }
|
|
175
|
+
: { x: 0, y: 0, width: 0, height: 0 };
|
|
176
|
+
}
|
|
177
|
+
/** The filters adl refuses a rect for whose left or top edge lies as far as an edge can. */
|
|
178
|
+
const EDGED = new Set(["bevel", "gradientBevel", "gradientGlow", "displacementMap"]);
|
|
179
|
+
/** The filters whose buffers adl sizes by the rect they write, and refuses past its reach. */
|
|
180
|
+
const SIZED = new Set(["colorMatrix", "convolution", "blur", "glow", "dropShadow"]);
|
|
181
|
+
/**
|
|
182
|
+
* The error adl refuses applyFilter's `rect` (bitmap.ts pixelRect) for `f`
|
|
183
|
+
* with, as it does where it cannot make the filter's buffers: 2015
|
|
184
|
+
* (ArgumentError), 2077 (IllegalOperationError), or 0 for none. Probed
|
|
185
|
+
* under adl: an x or y of NaN, 2015, for every filter but a colour matrix
|
|
186
|
+
* and a drop shadow cast some distance; a left or top edge clamped to the
|
|
187
|
+
* farthest, as -Infinity is (-2^29 passes), 2015 for the bevels, a
|
|
188
|
+
* gradient glow and a displacement map; and for the filters sized by what
|
|
189
|
+
* they write, 2015 for a filter rect a side of which passes 2^31 / 20
|
|
190
|
+
* pixels (106e6 passes, 108e6 is refused) or of more than 2^29 pixels, a
|
|
191
|
+
* width or height of NaN or Infinity among them, the sizes in int
|
|
192
|
+
* arithmetic as the edges' difference wraps; an outer shadow's grown by
|
|
193
|
+
* its offset (1e5 at 45° is refused), an inner one's not. By its offset
|
|
194
|
+
* alone, as what the rect holds of the source grows by it: a gradient
|
|
195
|
+
* glow outer or full past 2^29 pixels, 2015, and a bevel past a side of
|
|
196
|
+
* 2^31 / 20 or 2^29 pixels, 2077, but outer or full 2015, and 2077 past
|
|
197
|
+
* 2^31 / 10 pixels already; and an outer shadow or gradient glow of
|
|
198
|
+
* a distance or angle of NaN (or Infinity, which the angle keeps as NaN),
|
|
199
|
+
* 2015. A blur or glow some way short of those is refused with 2077,
|
|
200
|
+
* which this leaves.
|
|
201
|
+
*/
|
|
202
|
+
export function filterRefusal(rect, f, source) {
|
|
203
|
+
if (rect.x === NAN_EDGE || rect.y === NAN_EDGE) {
|
|
204
|
+
return f.kind !== "colorMatrix" && !(f.kind === "dropShadow" && f.distance) ? 2015 : 0;
|
|
205
|
+
}
|
|
206
|
+
if (EDGED.has(f.kind) && (rect.x <= 1 - EDGE_LIMIT || rect.y <= 1 - EDGE_LIMIT)) {
|
|
207
|
+
return 2015;
|
|
208
|
+
}
|
|
209
|
+
const outerShadow = (f.kind === "dropShadow" || f.kind === "gradientGlow") && !isInner(f);
|
|
210
|
+
if (outerShadow && (Number.isNaN(f.distance) || Number.isNaN(f.angle))) {
|
|
211
|
+
return 2015;
|
|
212
|
+
}
|
|
213
|
+
const side = 2 ** 31 / 20;
|
|
214
|
+
const held = intersect(rect, source);
|
|
215
|
+
if (held && (f.kind === "gradientGlow" || f.kind === "bevel" || f.kind === "gradientBevel")) {
|
|
216
|
+
const out = filterRect(held, f);
|
|
217
|
+
const pixels = out.width * out.height;
|
|
218
|
+
if (f.kind === "gradientGlow") {
|
|
219
|
+
return !isInner(f) && pixels > 2 ** 29 ? 2015 : 0;
|
|
220
|
+
}
|
|
221
|
+
const past = out.width > side || out.height > side || pixels > 2 ** 29;
|
|
222
|
+
// A bevel outer or full is refused sooner, with 2077 (16777740 by 14, not by
|
|
223
|
+
// 12), and past the rest with 2015.
|
|
224
|
+
if (!isInner(f)) {
|
|
225
|
+
return past ? 2015 : pixels > 2 ** 31 / 10 ? 2077 : 0;
|
|
226
|
+
}
|
|
227
|
+
return past ? 2077 : 0;
|
|
228
|
+
}
|
|
229
|
+
if (!SIZED.has(f.kind)) {
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
232
|
+
const sized = isInner(f) ? { ...f, distance: 0 } : f;
|
|
233
|
+
const out = filterRect({ ...rect, width: rect.width | 0, height: rect.height | 0 }, sized);
|
|
234
|
+
const w = Math.abs(out.width);
|
|
235
|
+
const h = Math.abs(out.height);
|
|
236
|
+
return w > side || h > side || w * h > 2 ** 29 ? 2015 : 0;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* `f` with what a filter from a SWF's tags may hold past the ranges the
|
|
240
|
+
* player's filter objects keep (passes to 31, blurs signed 16.16, strength
|
|
241
|
+
* signed 8.8, copied as they are: filterOfSwf) brought within them, as the
|
|
242
|
+
* render module's kernels take them: a blur under 0 none and past 255 255,
|
|
243
|
+
* NaN kept; quality to 15; a strength under 0 none.
|
|
244
|
+
*/
|
|
245
|
+
function kept(f) {
|
|
246
|
+
const blur = (v) => (v < 0 ? 0 : v > 255 ? 255 : v);
|
|
247
|
+
return {
|
|
248
|
+
...f,
|
|
249
|
+
blurX: blur(f.blurX),
|
|
250
|
+
blurY: blur(f.blurY),
|
|
251
|
+
quality: Math.max(0, Math.min(15, Math.trunc(f.quality) || 0)),
|
|
252
|
+
strength: Math.max(0, Math.min(255, f.strength || 0)),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Filter `rect` of `source` into `dest` at (dx, dy), as applyFilter does:
|
|
257
|
+
* the filter's rect, moved there and clipped, written whole. True where the
|
|
258
|
+
* filter is one this draws; the others leave `dest` as it was.
|
|
259
|
+
*/
|
|
260
|
+
export function applyFilter(dest, source, rect, dx, dy, given, map = null) {
|
|
261
|
+
if (!filtersDrawn.has(given.kind)) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const f = given.kind === "blur" || GLOWS.has(given.kind) ? kept(given) : given;
|
|
265
|
+
const out = filterRect(rect, f);
|
|
266
|
+
// What the destination shows of the filter's rect, in the filter's
|
|
267
|
+
// coordinates, and the work: that and as far round it as the filter
|
|
268
|
+
// reaches into it, so that a rect far past the destination costs nothing.
|
|
269
|
+
let mx = dx - rect.x;
|
|
270
|
+
let my = dy - rect.y;
|
|
271
|
+
// A displacement map writes the rect alone: what adl writes past it is a quirk of its own.
|
|
272
|
+
let written = f.kind === "displacementMap" ? rect : out;
|
|
273
|
+
if (isInner(f)) {
|
|
274
|
+
// adl writes an inner filter's rect as generateFilterRect gives it, within the bitmap, and
|
|
275
|
+
// moves it by that rect's corner from the source rect's a second time (apply-filter-inner).
|
|
276
|
+
const bitmap = { x: 0, y: 0, width: source.width, height: source.height };
|
|
277
|
+
const held = intersect(rect, bitmap);
|
|
278
|
+
const grown = held && intersect(filterRect(held, f), bitmap);
|
|
279
|
+
if (!grown) {
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
mx += grown.x - rect.x;
|
|
283
|
+
my += grown.y - rect.y;
|
|
284
|
+
written = grown;
|
|
285
|
+
}
|
|
286
|
+
const shown = intersect(written, { x: -mx, y: -my, width: dest.width, height: dest.height });
|
|
287
|
+
if (!shown) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
if (f.kind === "displacementMap") {
|
|
291
|
+
write(dest, displace(source, rect, shown, f, map), shown, shown, mx, my);
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
if (f.kind === "convolution" && (f.matrixX === 0 || f.matrixY === 0)) {
|
|
295
|
+
copyEmpty(dest, source, rect, out, shown, mx, my);
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
if (f.kind === "convolution") {
|
|
299
|
+
const pixels = convolve(source, shown, f, dest.transparent);
|
|
300
|
+
if (pixels) {
|
|
301
|
+
write(dest, pixels, shown, shown, mx, my);
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
if (f.kind === "colorMatrix") {
|
|
306
|
+
colorMatrix(dest, source, rect, dx, dy, f.matrix);
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
if (f.kind === "blur") {
|
|
310
|
+
// What is shown, blurred as far round it as the blur reaches into it, which may be past the
|
|
311
|
+
// rect, whose edge cuts what is written alone.
|
|
312
|
+
const pixels = bitmapKernel()?.blur(source, shown, f.blurX, f.blurY, f.quality);
|
|
313
|
+
if (pixels) {
|
|
314
|
+
write(dest, pixels, shown, shown, mx, my);
|
|
315
|
+
}
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
// The source's pixels where they are shown, and its alpha blurred and read
|
|
319
|
+
// from the offset, each over what is shown alone: however far the offset
|
|
320
|
+
// reaches, the work is the destination's size.
|
|
321
|
+
const [ox, oy] = f.kind === "glow" ? [0, 0] : shadowOffset(f);
|
|
322
|
+
// An outer shadow cast as far as an offset goes adl writes empty, the
|
|
323
|
+
// source's own pixels too.
|
|
324
|
+
const outer = (f.kind === "dropShadow" || f.kind === "gradientGlow") && !isInner(f);
|
|
325
|
+
if (outer && (ox === FAR || oy === FAR)) {
|
|
326
|
+
write(dest, new Uint32Array(shown.width * shown.height), shown, shown, mx, my);
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
const glowing = f.kind === "glow" || f.kind === "dropShadow";
|
|
330
|
+
const bevelled = f.kind === "bevel" || f.kind === "gradientBevel";
|
|
331
|
+
const pixels = bitmapKernel()?.layer(source, shown, {
|
|
332
|
+
kind: f.kind,
|
|
333
|
+
inner: glowing && f.inner,
|
|
334
|
+
knockout: f.knockout,
|
|
335
|
+
hideObject: f.kind === "dropShadow" && f.hideObject,
|
|
336
|
+
type: f.type,
|
|
337
|
+
// An inner glow blurs what the source leaves.
|
|
338
|
+
invert: glowing && f.inner,
|
|
339
|
+
quality: f.quality,
|
|
340
|
+
blurX: f.blurX,
|
|
341
|
+
blurY: f.blurY,
|
|
342
|
+
strength: f.strength,
|
|
343
|
+
// What the kind does not have, 0, as the kernel takes only values the player's filters hold.
|
|
344
|
+
alpha: glowing ? f.alpha : 0,
|
|
345
|
+
highlightAlpha: f.kind === "bevel" ? f.highlightAlpha : 0,
|
|
346
|
+
shadowAlpha: f.kind === "bevel" ? f.shadowAlpha : 0,
|
|
347
|
+
color: glowing ? f.color : 0,
|
|
348
|
+
highlightColor: f.kind === "bevel" ? f.highlightColor : 0,
|
|
349
|
+
shadowColor: f.kind === "bevel" ? f.shadowColor : 0,
|
|
350
|
+
table: f.kind === "gradientGlow" || f.kind === "gradientBevel" ? gradientTable(f) : null,
|
|
351
|
+
},
|
|
352
|
+
// Read on and back for a bevel, from the offset back for the rest.
|
|
353
|
+
bevelled
|
|
354
|
+
? [
|
|
355
|
+
[ox, oy],
|
|
356
|
+
[-ox, -oy],
|
|
357
|
+
]
|
|
358
|
+
: [[-ox, -oy]]);
|
|
359
|
+
if (pixels) {
|
|
360
|
+
write(dest, pixels, shown, shown, mx, my);
|
|
361
|
+
}
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
function intersect(p, q) {
|
|
365
|
+
const x0 = Math.max(p.x, q.x);
|
|
366
|
+
const y0 = Math.max(p.y, q.y);
|
|
367
|
+
const x1 = Math.min(p.x + p.width, q.x + q.width);
|
|
368
|
+
const y1 = Math.min(p.y + p.height, q.y + q.height);
|
|
369
|
+
return x1 > x0 && y1 > y0 ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : null;
|
|
370
|
+
}
|
|
371
|
+
/** The bounds of the pixels of `rect` of the source that are not transparent: null for none. */
|
|
372
|
+
function contentOf(source, rect) {
|
|
373
|
+
const area = intersect(rect, { x: 0, y: 0, width: source.width, height: source.height });
|
|
374
|
+
if (!area) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
const pixels = source.pixels;
|
|
378
|
+
let x0 = Number.POSITIVE_INFINITY;
|
|
379
|
+
let y0 = Number.POSITIVE_INFINITY;
|
|
380
|
+
let x1 = -1;
|
|
381
|
+
let y1 = -1;
|
|
382
|
+
for (let y = area.y; y < area.y + area.height; y++) {
|
|
383
|
+
for (let x = area.x; x < area.x + area.width; x++) {
|
|
384
|
+
if (pixels[y * source.width + x] >>> 24) {
|
|
385
|
+
x0 = Math.min(x0, x);
|
|
386
|
+
y0 = Math.min(y0, y);
|
|
387
|
+
x1 = Math.max(x1, x);
|
|
388
|
+
y1 = Math.max(y1, y);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return x1 < 0 ? null : { x: x0, y: y0, width: x1 - x0 + 1, height: y1 - y0 + 1 };
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* A colour matrix of each pixel's straight colour, rounded, into `dest`.
|
|
396
|
+
* adl maps the pixels about what the source has, its bounds and one more
|
|
397
|
+
* each way, one by one, their colour premultiplied by the new alpha and
|
|
398
|
+
* truncated; the rest of the rect it fills with the map of a transparent
|
|
399
|
+
* pixel, written as the store premultiplies it. Of the rect, only what
|
|
400
|
+
* lies within the source is written, the point moved with the clip, as a
|
|
401
|
+
* copy's is.
|
|
402
|
+
*/
|
|
403
|
+
function colorMatrix(dest, source, rect, dx, dy, m) {
|
|
404
|
+
const area = intersect(rect, { x: 0, y: 0, width: source.width, height: source.height });
|
|
405
|
+
const mx = dx - rect.x;
|
|
406
|
+
const my = dy - rect.y;
|
|
407
|
+
const shown = area && intersect(area, { x: -mx, y: -my, width: dest.width, height: dest.height });
|
|
408
|
+
if (!shown) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
// The map of a transparent pixel, each channel clamped and rounded.
|
|
412
|
+
const [er, eg, eb, ea] = [0, 1, 2, 3].map((row) => {
|
|
413
|
+
const v = m[row * 5] * 0 +
|
|
414
|
+
m[row * 5 + 1] * 0 +
|
|
415
|
+
m[row * 5 + 2] * 0 +
|
|
416
|
+
m[row * 5 + 3] * 0 +
|
|
417
|
+
m[row * 5 + 4];
|
|
418
|
+
return Math.max(0, Math.min(255, Math.round(Number.isNaN(v) ? 0 : v)));
|
|
419
|
+
});
|
|
420
|
+
const empty = dest.premultiplied(((ea << 24) | (er << 16) | (eg << 8) | eb) >>> 0);
|
|
421
|
+
// What the source has, and one more each way.
|
|
422
|
+
const content = contentOf(source, area);
|
|
423
|
+
const near = content && {
|
|
424
|
+
x: content.x - 1,
|
|
425
|
+
y: content.y - 1,
|
|
426
|
+
width: content.width + 2,
|
|
427
|
+
height: content.height + 2,
|
|
428
|
+
};
|
|
429
|
+
// Rows down, each in fours from its start, a four read whole before it is
|
|
430
|
+
// written, the rest one by one: in place, a move right repeats what the
|
|
431
|
+
// fours before wrote, as 480 rows under adl show (pixels.zig).
|
|
432
|
+
const into = dest.pixels;
|
|
433
|
+
bitmapKernel()?.copy(into, dest.width, source.pixels, source.width, { x: shown.x + mx, y: shown.y + my, width: shown.width, height: shown.height }, shown.x, shown.y, dest.transparent, { op: "matrix", matrix: m, near, empty });
|
|
434
|
+
dest.changed();
|
|
435
|
+
}
|
|
436
|
+
/** The channel of an unmultiplied pixel a displacement reads: red 1, green 2, blue 4, alpha 8; any other none, 128. */
|
|
437
|
+
function channelOf(pixel, component) {
|
|
438
|
+
switch (component) {
|
|
439
|
+
case 1:
|
|
440
|
+
return (pixel >>> 16) & 0xff;
|
|
441
|
+
case 2:
|
|
442
|
+
return (pixel >>> 8) & 0xff;
|
|
443
|
+
case 4:
|
|
444
|
+
return pixel & 0xff;
|
|
445
|
+
case 8:
|
|
446
|
+
return pixel >>> 24;
|
|
447
|
+
default:
|
|
448
|
+
return 128;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* A displacement map over `area` of the source: each pixel takes the
|
|
453
|
+
* source's at itself moved by the map's channels there, (c − 128) × scale
|
|
454
|
+
* / 256, between pixels linearly with weights in 256ths; past the source
|
|
455
|
+
* rect as the mode says: wrapped, clamped, the pixel's own (ignore) or the
|
|
456
|
+
* filter's colour. Where the map is not, it keeps its own.
|
|
457
|
+
*/
|
|
458
|
+
function displace(source, rect, area, f, map) {
|
|
459
|
+
const pixels = source.pixels;
|
|
460
|
+
const sw = source.width;
|
|
461
|
+
const own = (x, y) => x >= 0 && y >= 0 && x < sw && y < source.height ? pixels[y * sw + x] : 0;
|
|
462
|
+
const a = Math.floor(f.alpha * 255);
|
|
463
|
+
const colour = premultiply(((a << 24) | (f.color & 0xffffff)) >>> 0);
|
|
464
|
+
const result = new Uint32Array(area.width * area.height);
|
|
465
|
+
for (let y = 0; y < area.height; y++) {
|
|
466
|
+
const sy = area.y + y;
|
|
467
|
+
for (let x = 0; x < area.width; x++) {
|
|
468
|
+
const sx = area.x + x;
|
|
469
|
+
const mx = sx - rect.x - f.mapPoint[0];
|
|
470
|
+
const my = sy - rect.y - f.mapPoint[1];
|
|
471
|
+
if (!map || mx < 0 || my < 0 || mx >= map.width || my >= map.height) {
|
|
472
|
+
result[y * area.width + x] = own(sx, sy);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
const m = unmultiply(map.pixels[my * map.width + mx]);
|
|
476
|
+
// Where to read, in 256ths, the offset truncated toward 0 as adl's fixed point has it.
|
|
477
|
+
const px = sx * 256 + Math.trunc((channelOf(m, f.componentX) - 128) * f.scaleX);
|
|
478
|
+
const py = sy * 256 + Math.trunc((channelOf(m, f.componentY) - 128) * f.scaleY);
|
|
479
|
+
let x0 = px >> 8;
|
|
480
|
+
let y0 = py >> 8;
|
|
481
|
+
const fx = px & 255;
|
|
482
|
+
const fy = py & 255;
|
|
483
|
+
const left = rect.x;
|
|
484
|
+
const top = rect.y;
|
|
485
|
+
const right = rect.x + rect.width - 1;
|
|
486
|
+
const bottom = rect.y + rect.height - 1;
|
|
487
|
+
// Ignoring, a place past the rect takes the pixel's own, its fraction kept.
|
|
488
|
+
if (f.mode === "ignore") {
|
|
489
|
+
x0 = x0 < left || x0 > right ? sx : x0;
|
|
490
|
+
y0 = y0 < top || y0 > bottom ? sy : y0;
|
|
491
|
+
}
|
|
492
|
+
const at = (cx, cy) => {
|
|
493
|
+
let ix = cx - rect.x;
|
|
494
|
+
let iy = cy - rect.y;
|
|
495
|
+
if (ix >= 0 && iy >= 0 && ix < rect.width && iy < rect.height) {
|
|
496
|
+
return own(cx, cy);
|
|
497
|
+
}
|
|
498
|
+
if (f.mode === "wrap") {
|
|
499
|
+
ix = ((ix % rect.width) + rect.width) % rect.width;
|
|
500
|
+
iy = ((iy % rect.height) + rect.height) % rect.height;
|
|
501
|
+
}
|
|
502
|
+
else if (f.mode === "color") {
|
|
503
|
+
return colour;
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
ix = Math.max(0, Math.min(rect.width - 1, ix));
|
|
507
|
+
iy = Math.max(0, Math.min(rect.height - 1, iy));
|
|
508
|
+
}
|
|
509
|
+
return own(rect.x + ix, rect.y + iy);
|
|
510
|
+
};
|
|
511
|
+
// The corners' weights in 256ths, each truncated, as adl's fixed point has them.
|
|
512
|
+
const w00 = ((256 - fx) * (256 - fy)) >> 8;
|
|
513
|
+
const w10 = (fx * (256 - fy)) >> 8;
|
|
514
|
+
const w01 = ((256 - fx) * fy) >> 8;
|
|
515
|
+
const w11 = (fx * fy) >> 8;
|
|
516
|
+
const c00 = at(x0, y0);
|
|
517
|
+
const c10 = at(x0 + 1, y0);
|
|
518
|
+
const c01 = at(x0, y0 + 1);
|
|
519
|
+
const c11 = at(x0 + 1, y0 + 1);
|
|
520
|
+
let out = 0;
|
|
521
|
+
for (const shift of [24, 16, 8, 0]) {
|
|
522
|
+
const v = ((c00 >>> shift) & 0xff) * w00 +
|
|
523
|
+
((c10 >>> shift) & 0xff) * w10 +
|
|
524
|
+
((c01 >>> shift) & 0xff) * w01 +
|
|
525
|
+
((c11 >>> shift) & 0xff) * w11;
|
|
526
|
+
out |= (v >> 8) << shift;
|
|
527
|
+
}
|
|
528
|
+
result[y * area.width + x] = out >>> 0;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return result;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* What adl makes of a convolution with no taps: a copy, of as much of the
|
|
535
|
+
* source as the filter's rect is big (the other size of the matrix still
|
|
536
|
+
* grows it) from the source rect's corner, to that rect's corner; over
|
|
537
|
+
* what an opaque destination has, into a transparent one as it is; what
|
|
538
|
+
* lies past the source left as it was, and in place the source as it was
|
|
539
|
+
* before. `shown` is what the destination shows of `out`, and (mx, my)
|
|
540
|
+
* moves both there.
|
|
541
|
+
*/
|
|
542
|
+
function copyEmpty(dest, source, rect, out, shown, mx, my) {
|
|
543
|
+
const target = dest.pixels;
|
|
544
|
+
const pixels = source === dest ? source.pixels.slice() : source.pixels;
|
|
545
|
+
for (let y = shown.y; y < shown.y + shown.height; y++) {
|
|
546
|
+
const sy = rect.y + y - out.y;
|
|
547
|
+
if (sy < 0 || sy >= source.height) {
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
for (let x = shown.x; x < shown.x + shown.width; x++) {
|
|
551
|
+
const sx = rect.x + x - out.x;
|
|
552
|
+
if (sx >= 0 && sx < source.width) {
|
|
553
|
+
const p = pixels[sy * source.width + sx];
|
|
554
|
+
const at = (y + my) * dest.width + x + mx;
|
|
555
|
+
target[at] = dest.transparent ? p : over(p, target[at]);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
dest.changed();
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* A convolution over `area` of the source, as adl computes it, by the
|
|
563
|
+
* render module (convolve.zig): each tap reads the source's straight
|
|
564
|
+
* colour, past the rect too, and past the bitmap the nearest edge's or the
|
|
565
|
+
* filter's colour; the sum divided (0 counting as 1), the bias added,
|
|
566
|
+
* clamped and truncated, the alpha the source's where the filter keeps it;
|
|
567
|
+
* the colour premultiplied by that alpha, or kept straight for an opaque
|
|
568
|
+
* destination. Null where the kernel could not, as out of memory, or the
|
|
569
|
+
* realm has none.
|
|
570
|
+
*/
|
|
571
|
+
function convolve(source, area, f, transparent) {
|
|
572
|
+
return bitmapKernel()?.convolve(source, area, f, transparent) ?? null;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* The reciprocal adl divides a 3 × 3 kernel by in fixed point, where it
|
|
576
|
+
* takes that way, which it does inside the bitmap for whole weights whose
|
|
577
|
+
* positive and negative sums each stay within 127 and a divisor from 1.1,
|
|
578
|
+
* or past 2.0001 with a negative weight: 65536 / divisor, truncated, plus
|
|
579
|
+
* one, wrapped to a short. That way also reads the centre for the last tap.
|
|
580
|
+
* Null where it takes the other.
|
|
581
|
+
*/
|
|
582
|
+
export function integerKernel(matrix, divisor) {
|
|
583
|
+
if (matrix.length !== 9 || !matrix.every(Number.isInteger)) {
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
const positive = matrix.reduce((s, m) => s + Math.max(0, m), 0);
|
|
587
|
+
const negative = matrix.reduce((s, m) => s + Math.min(0, m), 0);
|
|
588
|
+
const enough = negative < 0 ? divisor > Math.fround(2.0001) : divisor >= Math.fround(1.1);
|
|
589
|
+
if (positive > 127 || negative < -127 || !enough) {
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
return ((Math.floor(65536 / divisor) + 1) << 16) >> 16;
|
|
593
|
+
}
|
|
594
|
+
/** A gradient filter's 256 colours, premultiplied, from its stops, as a gradient fill's ramp; with none, none. */
|
|
595
|
+
export function gradientTable(f) {
|
|
596
|
+
if (f.colors.length === 0) {
|
|
597
|
+
return new Uint32Array(256);
|
|
598
|
+
}
|
|
599
|
+
const stops = f.colors.map((c, k) => ({
|
|
600
|
+
ratio: f.ratios[k],
|
|
601
|
+
color: ((Math.round((f.alphas[k] ?? 1) * 255) << 24) | (c & 0xffffff)) >>> 0,
|
|
602
|
+
}));
|
|
603
|
+
return ramp(stops, false);
|
|
604
|
+
}
|
|
605
|
+
/** `part` of `pixels`, which cover `rect`, into `dest`, moved by (mx, my), clipped; an opaque store keeps its alpha. */
|
|
606
|
+
function write(dest, pixels, rect, part, mx, my) {
|
|
607
|
+
const target = dest.pixels;
|
|
608
|
+
const to = intersect({ x: part.x + mx, y: part.y + my, width: part.width, height: part.height }, { x: 0, y: 0, width: dest.width, height: dest.height });
|
|
609
|
+
if (to) {
|
|
610
|
+
const opaque = dest.transparent ? 0 : 0xff000000;
|
|
611
|
+
for (let ty = to.y; ty < to.y + to.height; ty++) {
|
|
612
|
+
let i = (ty - my - rect.y) * rect.width + to.x - mx - rect.x;
|
|
613
|
+
let t = ty * dest.width + to.x;
|
|
614
|
+
for (let n = 0; n < to.width; n++) {
|
|
615
|
+
target[t++] = (pixels[i++] | opaque) >>> 0;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
dest.changed();
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* A distance as far as a display object's filter pads: NaN none; Infinity,
|
|
623
|
+
* or the -8388866 generateFilterRect makes of NaN, as far as a GPU's
|
|
624
|
+
* texture could be, which the renderer cuts to what it can draw
|
|
625
|
+
* (paddingCap).
|
|
626
|
+
*/
|
|
627
|
+
export function paddedDistance(distance) {
|
|
628
|
+
return Number.isNaN(distance) ? 0 : Math.max(-(2 ** 24), Math.min(2 ** 24, distance));
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* How far a gradient filter's rect grows past a display object in stage
|
|
632
|
+
* pixels, as applyFilter's does: left, top, right, bottom.
|
|
633
|
+
*/
|
|
634
|
+
export function filterGrowth(f) {
|
|
635
|
+
const rect = filterRect({ x: 0, y: 0, width: 1, height: 1 }, { ...f, distance: paddedDistance(f.distance) });
|
|
636
|
+
return [-rect.x, -rect.y, rect.x + rect.width - 1, rect.y + rect.height - 1];
|
|
637
|
+
}
|
|
638
|
+
/** A displacement's channel (1 red, 2 green, 4 blue, 8 alpha) as weights of the four; none, all 0. */
|
|
639
|
+
export function channelWeights(channel) {
|
|
640
|
+
return [
|
|
641
|
+
channel === 1 ? 1 : 0,
|
|
642
|
+
channel === 2 ? 1 : 0,
|
|
643
|
+
channel === 4 ? 1 : 0,
|
|
644
|
+
channel === 8 ? 1 : 0,
|
|
645
|
+
];
|
|
646
|
+
}
|
|
647
|
+
/** How far a displacement in colour mode fills round the object, as adl draws it: half its scale. */
|
|
648
|
+
export function displacementGrowth(f) {
|
|
649
|
+
return f.mode === "color"
|
|
650
|
+
? [Math.floor(Math.abs(f.scaleX) / 2) || 0, Math.floor(Math.abs(f.scaleY) / 2) || 0]
|
|
651
|
+
: [0, 0];
|
|
652
|
+
}
|
|
653
|
+
/** A displacement's colour mode's alpha, in whole 255ths down, as adl takes it. */
|
|
654
|
+
export function displacementAlpha(f) {
|
|
655
|
+
return Math.floor(f.alpha * 255) / 255;
|
|
656
|
+
}
|