@swf2es/player-hosts 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
// flash.display.BitmapData: a pixel store (bitmap/bitmap.ts) behind the AS3
|
|
2
|
+
// object, as $store; the natives read and write it. Flash's limits and its
|
|
3
|
+
// ArgumentError 2015 for a size it refuses and for a store disposed.
|
|
4
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
5
|
+
import { BitmapStore, pixelRect, spanRect } from "../../../bitmap/bitmap.js";
|
|
6
|
+
import { drawDisplayObject } from "../../../bitmap/draw.js";
|
|
7
|
+
import { applyFilter, filterRefusal, filtersDrawn, GLOWS, generatedRect, } from "../../../bitmap/filters.js";
|
|
8
|
+
import { alphaAt, colorBounds, colorTransform, comparePixels, copyChannel, drawBitmap, floodFill, histogram, isThresholdOperation, merge, noise, paletteMap, perlinNoise, pixelDissolve, scroll, threshold, } from "../../../bitmap/ops.js";
|
|
9
|
+
import { shaderFilter } from "../../../bitmap/pixel-bender.js";
|
|
10
|
+
import { encodePng } from "../../../bitmap/png.js";
|
|
11
|
+
import { INVALID_PIXELS } from "../../../display/timeline.js";
|
|
12
|
+
import { filterKindOf, recordOf } from "../filters/BitmapFilter.js";
|
|
13
|
+
import { colorOf } from "../geom/Transform.js";
|
|
14
|
+
import { programOf } from "./ShaderData.js";
|
|
15
|
+
import { kernelOfShader, READ, shaderUse } from "./shaders.js";
|
|
16
|
+
/** The longest side adl makes a BitmapData of: 2^31 / 20, whole. */
|
|
17
|
+
const MAX_SIDE = 107374182;
|
|
18
|
+
/** The most pixels adl makes a BitmapData of, whatever its shape: 2146500576 bytes. */
|
|
19
|
+
const MAX_PIXELS = 536625144;
|
|
20
|
+
/** The store of a BitmapData object, or ArgumentError 2015 where it was disposed or never made. */
|
|
21
|
+
export function storeOf(s, o) {
|
|
22
|
+
const store = sizeOf(s, o);
|
|
23
|
+
// A bitmap of 0 by 0 is one Flash could not read from the SWF: it has a size and nothing else.
|
|
24
|
+
if (store.width === 0) {
|
|
25
|
+
throw s.rt.error("ArgumentError", 2015);
|
|
26
|
+
}
|
|
27
|
+
return store;
|
|
28
|
+
}
|
|
29
|
+
/** The store for reading its size: one Flash could not read has it, a disposed one not. */
|
|
30
|
+
function sizeOf(s, o) {
|
|
31
|
+
const store = o.$store;
|
|
32
|
+
if (!store || store.disposed) {
|
|
33
|
+
throw s.rt.error("ArgumentError", 2015);
|
|
34
|
+
}
|
|
35
|
+
return store;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A flash.geom.Rectangle as pixels (bitmap.ts pixelRect), NaN and Infinity
|
|
39
|
+
* as adl takes them; with `span`, a negative size spanning back, as merge,
|
|
40
|
+
* copyChannel, paletteMap, threshold and pixelDissolve take it (spanRect).
|
|
41
|
+
* TypeError 2007 for null.
|
|
42
|
+
*/
|
|
43
|
+
function rectOf(s, v, span = false) {
|
|
44
|
+
if (v === null || v === undefined) {
|
|
45
|
+
throw s.rt.error("TypeError", 2007, "rect");
|
|
46
|
+
}
|
|
47
|
+
const r = v;
|
|
48
|
+
const read = (k) => s.rt.toNumber(s.rt.getProperty(r, s.rt.publicName(k)));
|
|
49
|
+
return (span ? spanRect : pixelRect)(read("x"), read("y"), read("width"), read("height"));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A flash.geom.Point's values as pixels, truncated toward 0 as Flash's
|
|
53
|
+
* destination, alpha and hit-test points are, unlike a rect's rounded
|
|
54
|
+
* edges; NaN, and anything past int's range, int's least, which lies off
|
|
55
|
+
* every bitmap, as adl takes them; TypeError 2007 for null.
|
|
56
|
+
*/
|
|
57
|
+
function pointOf(s, v, name) {
|
|
58
|
+
if (v === null || v === undefined) {
|
|
59
|
+
throw s.rt.error("TypeError", 2007, name);
|
|
60
|
+
}
|
|
61
|
+
const p = v;
|
|
62
|
+
const read = (k) => {
|
|
63
|
+
const t = Math.trunc(s.rt.toNumber(s.rt.getProperty(p, s.rt.publicName(k))));
|
|
64
|
+
return t >= -0x80000000 && t <= 0x7fffffff ? t + 0 : -0x80000000;
|
|
65
|
+
};
|
|
66
|
+
return [read("x"), read("y")];
|
|
67
|
+
}
|
|
68
|
+
/** A source BitmapData's store; TypeError 2007 for null. */
|
|
69
|
+
function sourceOf(s, v) {
|
|
70
|
+
if (v === null || v === undefined) {
|
|
71
|
+
throw s.rt.error("TypeError", 2007, "sourceBitmapData");
|
|
72
|
+
}
|
|
73
|
+
return storeOf(s, v);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* draw: a BitmapData, or a Bitmap as its data, its own transform ignored,
|
|
77
|
+
* composited on the CPU (bitmap/ops.ts drawBitmap); any other display
|
|
78
|
+
* object rendered by the Scripting's drawer at `samples` a side, over its
|
|
79
|
+
* own bounds alone, then composited the same way. A null source is
|
|
80
|
+
* ArgumentError 2005, as Flash words it.
|
|
81
|
+
*/
|
|
82
|
+
function drawInto(s, store, source, matrix, ct, mode, clip, smoothing, samples = 4) {
|
|
83
|
+
if (source === null || source === undefined) {
|
|
84
|
+
throw s.rt.error("ArgumentError", 2005, 0);
|
|
85
|
+
}
|
|
86
|
+
const o = source;
|
|
87
|
+
const data = o.$store !== undefined ? o : o.$display?.store !== undefined ? (o.$bitmapData ?? null) : null;
|
|
88
|
+
if (data === null && o.$display === undefined) {
|
|
89
|
+
throw s.rt.error("ArgumentError", 2005, 0);
|
|
90
|
+
}
|
|
91
|
+
const m = matrix === null || matrix === undefined
|
|
92
|
+
? { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }
|
|
93
|
+
: matrixOf(s, matrix);
|
|
94
|
+
const c = ct === null || ct === undefined ? null : colorOf(s, ct);
|
|
95
|
+
const blend = mode === null || mode === undefined ? "normal" : s.rt.toString(mode);
|
|
96
|
+
const r = clip === null || clip === undefined ? null : rectOf(s, clip);
|
|
97
|
+
if (data === null) {
|
|
98
|
+
// Any other display object, through the renderer, then composited as a bitmap is.
|
|
99
|
+
if (!s.drawer) {
|
|
100
|
+
throw s.rt.unsupported("BitmapData#draw of a display object without a renderer");
|
|
101
|
+
}
|
|
102
|
+
drawDisplayObject(s.drawer, store, o.$display, m, c, blend, r, samples);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (data.$bitmapData === null && data.$store === undefined) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// A BitmapData drawn into itself goes a row at a time; through a Bitmap, in scan order. A
|
|
109
|
+
// Bitmap is a display object, whose erase and alpha blends a BitmapData's are not.
|
|
110
|
+
const bitmap = o.$store === undefined;
|
|
111
|
+
drawBitmap(store, storeOf(s, data), m, c, blend, r, !!smoothing, !bitmap, bitmap ? "bitmap" : null);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A flash.geom.Matrix's six values, its translation as draw takes it under
|
|
115
|
+
* adl, in twips in an int: NaN is int's least, and so is anything past
|
|
116
|
+
* the int's range, Infinity too, which a matrix that only moves draws at
|
|
117
|
+
* 0 (and any other off every bitmap); and a move within 2^30 twips of
|
|
118
|
+
* the range's ends wraps round to near 0, 107374180 drawing at -2.4.
|
|
119
|
+
*/
|
|
120
|
+
function matrixOf(s, o) {
|
|
121
|
+
const read = (k) => s.rt.toNumber(s.rt.getProperty(o, s.rt.publicName(k)));
|
|
122
|
+
const m = {
|
|
123
|
+
a: read("a"),
|
|
124
|
+
b: read("b"),
|
|
125
|
+
c: read("c"),
|
|
126
|
+
d: read("d"),
|
|
127
|
+
tx: read("tx"),
|
|
128
|
+
ty: read("ty"),
|
|
129
|
+
};
|
|
130
|
+
const moves = m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1;
|
|
131
|
+
const twips = (t) => {
|
|
132
|
+
const v = t * 20;
|
|
133
|
+
if (Number.isNaN(v) || (moves && Math.abs(v) >= 2 ** 31)) {
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
return moves && Math.abs(v) >= 2 ** 30 ? (v - Math.sign(v) * 2 ** 31) / 20 : t;
|
|
137
|
+
};
|
|
138
|
+
m.tx = twips(m.tx);
|
|
139
|
+
m.ty = twips(m.ty);
|
|
140
|
+
return m;
|
|
141
|
+
}
|
|
142
|
+
/** Samples a side of each pixel a display object is rendered at, by drawWithQuality's quality: Flash's 1, 2 and 4. */
|
|
143
|
+
function samplesOf(s, quality) {
|
|
144
|
+
if (quality === null || quality === undefined) {
|
|
145
|
+
return 4;
|
|
146
|
+
}
|
|
147
|
+
switch (s.rt.toString(quality).toLowerCase()) {
|
|
148
|
+
case "low":
|
|
149
|
+
return 1;
|
|
150
|
+
case "medium":
|
|
151
|
+
return 2;
|
|
152
|
+
default:
|
|
153
|
+
return 4;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export function bitmapDataNatives(s) {
|
|
157
|
+
const natives = {};
|
|
158
|
+
/** A filter object's record; TypeError 2007 for null, as for anything that is no filter. */
|
|
159
|
+
const filterOf = (v) => {
|
|
160
|
+
const kind = v && typeof v === "object" ? filterKindOf(s.rt, v) : null;
|
|
161
|
+
if (!kind) {
|
|
162
|
+
throw s.rt.error("TypeError", 2007, "filter");
|
|
163
|
+
}
|
|
164
|
+
return recordOf(v, kind);
|
|
165
|
+
};
|
|
166
|
+
class BitmapDataNatives {
|
|
167
|
+
"flash.display:BitmapData::ctor"(width, height, transparent, fill) {
|
|
168
|
+
// A class SymbolClass binds to a bitmap has its pixels, whatever size it asks for.
|
|
169
|
+
const symbol = this.$symbol;
|
|
170
|
+
if (symbol) {
|
|
171
|
+
this.$store = BitmapStore.of(symbol.pixels ?? INVALID_PIXELS);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
// A side under 1 is refused, and as adl refuses them, a side past 2^31 / 20
|
|
175
|
+
// (107374183 by 1) and more than MAX_PIXELS (32753 by 16384, 65514 by 8191).
|
|
176
|
+
const w = s.rt.toInt(width);
|
|
177
|
+
const h = s.rt.toInt(height);
|
|
178
|
+
if (w < 1 || h < 1 || w > MAX_SIDE || h > MAX_SIDE || w * h > MAX_PIXELS) {
|
|
179
|
+
throw s.rt.error("ArgumentError", 2015);
|
|
180
|
+
}
|
|
181
|
+
// One the browser cannot allocate is refused, as adl refuses what its memory
|
|
182
|
+
// cannot hold, rather than ending the player with a RangeError.
|
|
183
|
+
try {
|
|
184
|
+
this.$store = new BitmapStore(w, h, transparent === undefined ? true : !!transparent, s.rt.toUint(fill === undefined ? 0xffffffff : fill));
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
if (e instanceof RangeError) {
|
|
188
|
+
throw s.rt.error("ArgumentError", 2015);
|
|
189
|
+
}
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Disposed, every read throws, the size included, as Flash has it.
|
|
194
|
+
get width() {
|
|
195
|
+
return sizeOf(s, this).width;
|
|
196
|
+
}
|
|
197
|
+
get height() {
|
|
198
|
+
return sizeOf(s, this).height;
|
|
199
|
+
}
|
|
200
|
+
get transparent() {
|
|
201
|
+
return sizeOf(s, this).transparent;
|
|
202
|
+
}
|
|
203
|
+
get rect() {
|
|
204
|
+
const store = sizeOf(s, this);
|
|
205
|
+
return s.rt.construct(s.rt.classNamed("flash.geom::Rectangle"), 0, 0, store.width, store.height);
|
|
206
|
+
}
|
|
207
|
+
getPixel(x, y) {
|
|
208
|
+
return storeOf(s, this).getPixel(s.rt.toInt(x), s.rt.toInt(y));
|
|
209
|
+
}
|
|
210
|
+
getPixel32(x, y) {
|
|
211
|
+
return storeOf(s, this).getPixel32(s.rt.toInt(x), s.rt.toInt(y));
|
|
212
|
+
}
|
|
213
|
+
setPixel(x, y, color) {
|
|
214
|
+
storeOf(s, this).setPixel(s.rt.toInt(x), s.rt.toInt(y), s.rt.toUint(color));
|
|
215
|
+
}
|
|
216
|
+
setPixel32(x, y, color) {
|
|
217
|
+
storeOf(s, this).setPixel32(s.rt.toInt(x), s.rt.toInt(y), s.rt.toUint(color));
|
|
218
|
+
}
|
|
219
|
+
fillRect(rect, color) {
|
|
220
|
+
const store = storeOf(s, this);
|
|
221
|
+
store.fillRect(rectOf(s, rect), s.rt.toUint(color));
|
|
222
|
+
}
|
|
223
|
+
clone() {
|
|
224
|
+
const store = storeOf(s, this);
|
|
225
|
+
const o = s.rt.construct(s.rt.classNamed("flash.display::BitmapData"), store.width, store.height, store.transparent, 0);
|
|
226
|
+
o.$store = store.clone();
|
|
227
|
+
return o;
|
|
228
|
+
}
|
|
229
|
+
dispose() {
|
|
230
|
+
const store = this.$store;
|
|
231
|
+
if (store && !store.disposed) {
|
|
232
|
+
store.dispose();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
copyPixels(source, rect, dest, alphaBitmap, alphaPoint, mergeAlpha) {
|
|
236
|
+
const store = storeOf(s, this);
|
|
237
|
+
if (source === null || source === undefined) {
|
|
238
|
+
throw s.rt.error("TypeError", 2007, "sourceBitmapData");
|
|
239
|
+
}
|
|
240
|
+
const from = storeOf(s, source);
|
|
241
|
+
const r = rectOf(s, rect);
|
|
242
|
+
const [dx, dy] = pointOf(s, dest, "destPoint");
|
|
243
|
+
const alpha = alphaBitmap === null || alphaBitmap === undefined
|
|
244
|
+
? null
|
|
245
|
+
: storeOf(s, alphaBitmap);
|
|
246
|
+
const [ax, ay] = alphaPoint === null || alphaPoint === undefined
|
|
247
|
+
? [0, 0]
|
|
248
|
+
: pointOf(s, alphaPoint, "alphaPoint");
|
|
249
|
+
store.copyPixels(from, r, dx, dy, !!mergeAlpha, alpha, ax, ay);
|
|
250
|
+
}
|
|
251
|
+
/** `sourceRect` of the source filtered into this at `destPoint`, its filter's rect written whole (bitmap/filters.ts). */
|
|
252
|
+
applyFilter(source, sourceRect, destPoint, filter) {
|
|
253
|
+
const store = storeOf(s, this);
|
|
254
|
+
const from = sourceOf(s, source);
|
|
255
|
+
const r = rectOf(s, sourceRect);
|
|
256
|
+
const [dx, dy] = pointOf(s, destPoint, "destPoint");
|
|
257
|
+
const f = filterOf(filter);
|
|
258
|
+
if (f.kind === "shader") {
|
|
259
|
+
if (!kernelOfShader(f.shader)) {
|
|
260
|
+
throw s.rt.error("ArgumentError", 2171);
|
|
261
|
+
}
|
|
262
|
+
// Its inputs read as they are, as a job reads them: run now, not drawn later.
|
|
263
|
+
const use = shaderUse(s, f.shader, 1, READ);
|
|
264
|
+
shaderFilter(store, from, r, dx, dy, f.extensions, use, programOf(use.kernel));
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
// adl draws none of the filters with a glow into an opaque destination.
|
|
268
|
+
if (!store.transparent && GLOWS.has(f.kind)) {
|
|
269
|
+
throw s.rt.error("flash.errors::IllegalOperationError", 2077);
|
|
270
|
+
}
|
|
271
|
+
switch (filterRefusal(r, f, { x: 0, y: 0, width: from.width, height: from.height })) {
|
|
272
|
+
case 2015:
|
|
273
|
+
throw s.rt.error("ArgumentError", 2015);
|
|
274
|
+
case 2077:
|
|
275
|
+
throw s.rt.error("flash.errors::IllegalOperationError", 2077);
|
|
276
|
+
}
|
|
277
|
+
// A displacement map's map as it is now, not as it was when set.
|
|
278
|
+
const map = f.kind === "displacementMap" && f.mapBitmap ? storeOf(s, f.mapBitmap) : null;
|
|
279
|
+
if (!applyFilter(store, from, r, dx, dy, f, map)) {
|
|
280
|
+
throw s.rt.unsupported(`BitmapData.applyFilter with a ${f.kind} filter`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
generateFilterRect(sourceRect, filter) {
|
|
284
|
+
const store = storeOf(s, this);
|
|
285
|
+
const f = filterOf(filter);
|
|
286
|
+
if (f.kind === "shader") {
|
|
287
|
+
// This bitmap's rect grown by the extensions, whatever the rect given, as adl gives it.
|
|
288
|
+
rectOf(s, sourceRect);
|
|
289
|
+
const [left, top, right, bottom] = f.extensions;
|
|
290
|
+
return s.rt.construct(s.rt.classNamed("flash.geom::Rectangle"), -left, -top, store.width + left + right, store.height + top + bottom);
|
|
291
|
+
}
|
|
292
|
+
if (!filtersDrawn.has(f.kind)) {
|
|
293
|
+
throw s.rt.unsupported(`BitmapData.generateFilterRect with a ${f.kind} filter`);
|
|
294
|
+
}
|
|
295
|
+
const r = generatedRect(store.width, store.height, rectOf(s, sourceRect), f);
|
|
296
|
+
return s.rt.construct(s.rt.classNamed("flash.geom::Rectangle"), r.x, r.y, r.width, r.height);
|
|
297
|
+
}
|
|
298
|
+
getPixels(rect) {
|
|
299
|
+
const store = storeOf(s, this);
|
|
300
|
+
const o = s.rt.construct(s.rt.classNamed("flash.utils::ByteArray"));
|
|
301
|
+
o.$bytes.write(store.argbBytes(rectOf(s, rect)));
|
|
302
|
+
return o;
|
|
303
|
+
}
|
|
304
|
+
copyPixelsToByteArray(rect, target) {
|
|
305
|
+
const store = storeOf(s, this);
|
|
306
|
+
if (target === null || target === undefined) {
|
|
307
|
+
throw s.rt.error("TypeError", 2007, "data");
|
|
308
|
+
}
|
|
309
|
+
const bytes = target.$bytes;
|
|
310
|
+
bytes.write(store.argbBytes(rectOf(s, rect), bytes.littleEndian));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The rect as an image file, written into `byteArray` from its position
|
|
314
|
+
* or into a new one, which is returned: PNG; JPEG and JPEG XR, which
|
|
315
|
+
* Flash also writes, are not supported yet.
|
|
316
|
+
*/
|
|
317
|
+
encode(rect, compressor, byteArray) {
|
|
318
|
+
const store = storeOf(s, this);
|
|
319
|
+
if (rect === null || rect === undefined) {
|
|
320
|
+
throw s.rt.error("TypeError", 2007, "rectangle");
|
|
321
|
+
}
|
|
322
|
+
if (compressor === null || compressor === undefined) {
|
|
323
|
+
throw s.rt.error("TypeError", 2007, "compressor");
|
|
324
|
+
}
|
|
325
|
+
const options = compressor;
|
|
326
|
+
const is = (name) => s.rt.isInstance(options, s.rt.classNamed(name));
|
|
327
|
+
if (!is("flash.display::PNGEncoderOptions")) {
|
|
328
|
+
if (is("flash.display::JPEGEncoderOptions") || is("flash.display::JPEGXREncoderOptions")) {
|
|
329
|
+
throw s.rt.unsupported("BitmapData#encode as JPEG");
|
|
330
|
+
}
|
|
331
|
+
throw s.rt.error("ArgumentError", 2004);
|
|
332
|
+
}
|
|
333
|
+
const area = store.clip(rectOf(s, rect));
|
|
334
|
+
if (!area) {
|
|
335
|
+
throw s.rt.error("ArgumentError", 2006);
|
|
336
|
+
}
|
|
337
|
+
const fast = !!s.rt.getProperty(options, s.rt.publicName("fastCompression"));
|
|
338
|
+
const out = byteArray === null || byteArray === undefined
|
|
339
|
+
? s.rt.construct(s.rt.classNamed("flash.utils::ByteArray"))
|
|
340
|
+
: byteArray;
|
|
341
|
+
out.$bytes.write(encodePng(store, area, fast));
|
|
342
|
+
return out;
|
|
343
|
+
}
|
|
344
|
+
setPixels(rect, input) {
|
|
345
|
+
const store = storeOf(s, this);
|
|
346
|
+
// The parameters checked in order: the rect's null before the input's.
|
|
347
|
+
const r = rectOf(s, rect);
|
|
348
|
+
if (input === null || input === undefined) {
|
|
349
|
+
throw s.rt.error("TypeError", 2007, "inputByteArray");
|
|
350
|
+
}
|
|
351
|
+
const c = store.clip(r);
|
|
352
|
+
if (!c) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
// A pixel at a time, as Flash reads them: those read before the end are set, then EOFError 2030.
|
|
356
|
+
const bytes = input.$bytes;
|
|
357
|
+
const values = [];
|
|
358
|
+
try {
|
|
359
|
+
for (let i = 0; i < c.width * c.height; i++) {
|
|
360
|
+
bytes.checkEOF(4);
|
|
361
|
+
values.push(bytes.view.getUint32(bytes.position, bytes.littleEndian));
|
|
362
|
+
bytes.position = (bytes.position + 4) >>> 0;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
finally {
|
|
366
|
+
store.setVector(c, values);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
getVector(rect) {
|
|
370
|
+
const store = storeOf(s, this);
|
|
371
|
+
const cls = s.rt.resolve(s.rt.vector("uint"));
|
|
372
|
+
const o = cls.$it.instance();
|
|
373
|
+
o.$a = store.getVector(rectOf(s, rect));
|
|
374
|
+
return o;
|
|
375
|
+
}
|
|
376
|
+
setVector(rect, input) {
|
|
377
|
+
const store = storeOf(s, this);
|
|
378
|
+
const r = rectOf(s, rect);
|
|
379
|
+
if (input === null || input === undefined) {
|
|
380
|
+
throw s.rt.error("TypeError", 2007, "imputVector");
|
|
381
|
+
}
|
|
382
|
+
const c = store.clip(r);
|
|
383
|
+
if (!c) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const values = input.$a;
|
|
387
|
+
if (values.length < c.width * c.height) {
|
|
388
|
+
throw s.rt.error("RangeError", 2006);
|
|
389
|
+
}
|
|
390
|
+
store.setVector(c, values);
|
|
391
|
+
}
|
|
392
|
+
noise(seed, low, high, channels, gray) {
|
|
393
|
+
noise(storeOf(s, this), s.rt.toInt(seed), low === undefined ? 0 : s.rt.toUint(low), high === undefined ? 255 : s.rt.toUint(high), channels === undefined ? 7 : s.rt.toUint(channels), !!gray);
|
|
394
|
+
}
|
|
395
|
+
copyChannel(source, rect, dest, from, to) {
|
|
396
|
+
const store = storeOf(s, this);
|
|
397
|
+
const src = sourceOf(s, source);
|
|
398
|
+
const r = rectOf(s, rect, true);
|
|
399
|
+
const [dx, dy] = pointOf(s, dest, "destPoint");
|
|
400
|
+
copyChannel(store, src, r, dx, dy, s.rt.toUint(from), s.rt.toUint(to));
|
|
401
|
+
}
|
|
402
|
+
/** Offsets past those given, or not Points, are (0, 0). */
|
|
403
|
+
perlinNoise(baseX, baseY, octaves, seed, stitch, fractal, channels = 7, gray = false, offsets = null) {
|
|
404
|
+
const store = storeOf(s, this);
|
|
405
|
+
const given = offsets?.$a;
|
|
406
|
+
const point = s.rt.classNamed("flash.geom::Point");
|
|
407
|
+
const read = (p, k) => s.rt.toNumber(s.rt.getProperty(p, s.rt.publicName(k)));
|
|
408
|
+
// Past 1024 octaves the doubles' ratio would be infinite, where Flash's sum stays as it was from
|
|
409
|
+
// some 40 on, for any count up to 2^32 - 1, a negative one too (the `perlin-noise` case).
|
|
410
|
+
const count = Math.min(s.rt.toUint(octaves), 1024);
|
|
411
|
+
const shifts = Array.from({ length: count }, (_, i) => {
|
|
412
|
+
const p = given?.[i];
|
|
413
|
+
return p && s.rt.isInstanceOf(p, point.$it)
|
|
414
|
+
? [read(p, "x"), read(p, "y")]
|
|
415
|
+
: [0, 0];
|
|
416
|
+
});
|
|
417
|
+
perlinNoise(store, [s.rt.toNumber(baseX), s.rt.toNumber(baseY)], shifts, s.rt.toInt(seed), !!stitch, !!fractal, s.rt.toUint(channels), !!gray);
|
|
418
|
+
}
|
|
419
|
+
paletteMap(source, rect, dest, red = null, green = null, blue = null, alpha = null) {
|
|
420
|
+
const store = storeOf(s, this);
|
|
421
|
+
const src = sourceOf(s, source);
|
|
422
|
+
if (rect === null || rect === undefined) {
|
|
423
|
+
throw s.rt.error("TypeError", 2007, "sourceRect");
|
|
424
|
+
}
|
|
425
|
+
const r = rectOf(s, rect, true);
|
|
426
|
+
const [dx, dy] = pointOf(s, dest, "destPoint");
|
|
427
|
+
// A channel's table, or itself where none is given.
|
|
428
|
+
const table = (v, shift) => Uint32Array.from({ length: 256 }, (_, i) => v === null || v === undefined
|
|
429
|
+
? i << shift
|
|
430
|
+
: s.rt.toUint(s.rt.getProperty(v, s.rt.publicName(i))));
|
|
431
|
+
paletteMap(store, src, r, dx, dy, [
|
|
432
|
+
table(red, 16),
|
|
433
|
+
table(green, 8),
|
|
434
|
+
table(blue, 0),
|
|
435
|
+
table(alpha, 24),
|
|
436
|
+
]);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* 0 for the same pixels, a BitmapData of their differences, or -3 and
|
|
440
|
+
* -4 for another width and height, as Flash's; -1 for this one disposed.
|
|
441
|
+
*/
|
|
442
|
+
compare(other) {
|
|
443
|
+
if (other === null || other === undefined) {
|
|
444
|
+
throw s.rt.error("TypeError", 2007, "otherBitmapData");
|
|
445
|
+
}
|
|
446
|
+
const own = this.$store;
|
|
447
|
+
if (!own || own.disposed) {
|
|
448
|
+
return -1;
|
|
449
|
+
}
|
|
450
|
+
const theirs = storeOf(s, other);
|
|
451
|
+
if (theirs.width !== own.width) {
|
|
452
|
+
return -3;
|
|
453
|
+
}
|
|
454
|
+
if (theirs.height !== own.height) {
|
|
455
|
+
return -4;
|
|
456
|
+
}
|
|
457
|
+
const pixels = comparePixels(own, theirs);
|
|
458
|
+
if (!pixels) {
|
|
459
|
+
return 0;
|
|
460
|
+
}
|
|
461
|
+
const o = s.rt.construct(s.rt.classNamed("flash.display::BitmapData"), own.width, own.height, true, 0);
|
|
462
|
+
o.$store.pixels.set(pixels);
|
|
463
|
+
o.$store.changed();
|
|
464
|
+
return o;
|
|
465
|
+
}
|
|
466
|
+
colorTransform(rect, ct) {
|
|
467
|
+
const store = storeOf(s, this);
|
|
468
|
+
const r = rectOf(s, rect);
|
|
469
|
+
if (ct === null || ct === undefined) {
|
|
470
|
+
throw s.rt.error("TypeError", 2007, "colorTransform");
|
|
471
|
+
}
|
|
472
|
+
// A foot of NaN, int's least, less a top past 0 wraps round in int
|
|
473
|
+
// arithmetic to a height reaching the bitmap's foot, as adl has it; a
|
|
474
|
+
// width of NaN covers nothing.
|
|
475
|
+
r.height |= 0;
|
|
476
|
+
colorTransform(store, r, colorOf(s, ct));
|
|
477
|
+
}
|
|
478
|
+
merge(source, rect, dest, rMul, gMul, bMul, aMul) {
|
|
479
|
+
const store = storeOf(s, this);
|
|
480
|
+
const src = sourceOf(s, source);
|
|
481
|
+
const r = rectOf(s, rect, true);
|
|
482
|
+
const [dx, dy] = pointOf(s, dest, "destPoint");
|
|
483
|
+
merge(store, src, r, dx, dy, [rMul, gMul, bMul, aMul].map((m) => s.rt.toUint(m)));
|
|
484
|
+
}
|
|
485
|
+
scroll(x, y) {
|
|
486
|
+
scroll(storeOf(s, this), s.rt.toInt(x), s.rt.toInt(y));
|
|
487
|
+
}
|
|
488
|
+
threshold(source, rect, dest, op, value, color, mask, copySource) {
|
|
489
|
+
const store = storeOf(s, this);
|
|
490
|
+
const src = sourceOf(s, source);
|
|
491
|
+
const r = rectOf(s, rect, true);
|
|
492
|
+
const [dx, dy] = pointOf(s, dest, "destPoint");
|
|
493
|
+
// A String parameter: undefined is null, refused with 2007 before the value is looked at.
|
|
494
|
+
if (op === null || op === undefined) {
|
|
495
|
+
throw s.rt.error("TypeError", 2007, "operation");
|
|
496
|
+
}
|
|
497
|
+
const operation = s.rt.toString(op);
|
|
498
|
+
if (!isThresholdOperation(operation)) {
|
|
499
|
+
throw s.rt.error("ArgumentError", 2005, 3);
|
|
500
|
+
}
|
|
501
|
+
return threshold(store, src, r, dx, dy, operation, s.rt.toUint(value), s.rt.toUint(color), mask === undefined ? 0xffffffff : s.rt.toUint(mask), !!copySource);
|
|
502
|
+
}
|
|
503
|
+
getColorBoundsRect(mask, color, find) {
|
|
504
|
+
const r = colorBounds(storeOf(s, this), s.rt.toUint(mask), s.rt.toUint(color), find === undefined ? true : !!find);
|
|
505
|
+
return s.rt.construct(s.rt.classNamed("flash.geom::Rectangle"), r.x, r.y, r.width, r.height);
|
|
506
|
+
}
|
|
507
|
+
floodFill(x, y, color) {
|
|
508
|
+
floodFill(storeOf(s, this), s.rt.toInt(x), s.rt.toInt(y), s.rt.toUint(color));
|
|
509
|
+
}
|
|
510
|
+
histogram(rect) {
|
|
511
|
+
const store = storeOf(s, this);
|
|
512
|
+
const counts = histogram(store, rect === null || rect === undefined
|
|
513
|
+
? { x: 0, y: 0, width: store.width, height: store.height }
|
|
514
|
+
: rectOf(s, rect));
|
|
515
|
+
const inner = s.rt.resolve(s.rt.vector("Number"));
|
|
516
|
+
const outer = s.rt.applyType(s.rt.classNamed("__AS3__.vec::Vector"), [inner]);
|
|
517
|
+
const o = outer.$it.instance();
|
|
518
|
+
o.$a = counts.map((c) => {
|
|
519
|
+
const v = inner.$it.instance();
|
|
520
|
+
v.$a = c;
|
|
521
|
+
return v;
|
|
522
|
+
});
|
|
523
|
+
return o;
|
|
524
|
+
}
|
|
525
|
+
hitTest(firstPoint, firstAlpha, second, secondPoint, secondAlpha) {
|
|
526
|
+
const store = storeOf(s, this);
|
|
527
|
+
const [fx, fy] = pointOf(s, firstPoint, "firstPoint");
|
|
528
|
+
// adl refuses a point the bitmap, put there, would reach past int's range from.
|
|
529
|
+
if (fx + store.width > 0x7fffffff || fy + store.height > 0x7fffffff) {
|
|
530
|
+
throw s.rt.error("ArgumentError", 1508, "firstPoint");
|
|
531
|
+
}
|
|
532
|
+
const a1 = s.rt.toUint(firstAlpha);
|
|
533
|
+
const other = second;
|
|
534
|
+
if (other === null || other === undefined) {
|
|
535
|
+
throw s.rt.error("ArgumentError", 2005, 2);
|
|
536
|
+
}
|
|
537
|
+
const name = s.rt.traitsOf(other).name;
|
|
538
|
+
// A Bitmap tests as its BitmapData.
|
|
539
|
+
const data = other.$store !== undefined
|
|
540
|
+
? other
|
|
541
|
+
: other.$display?.store !== undefined
|
|
542
|
+
? (other.$bitmapData ?? null)
|
|
543
|
+
: null;
|
|
544
|
+
const isPoint = name === "flash.geom::Point";
|
|
545
|
+
const isRect = name === "flash.geom::Rectangle";
|
|
546
|
+
if (isPoint || isRect) {
|
|
547
|
+
// A point truncated, a rect's edges rounded, as everywhere else.
|
|
548
|
+
const area = isRect ? rectOf(s, other) : null;
|
|
549
|
+
const [px, py] = isPoint ? pointOf(s, other, "secondObject") : [0, 0];
|
|
550
|
+
const x0 = (area ? area.x : px) - fx;
|
|
551
|
+
const y0 = (area ? area.y : py) - fy;
|
|
552
|
+
const w = area ? area.width : 1;
|
|
553
|
+
const h = area ? area.height : 1;
|
|
554
|
+
for (let y = Math.max(0, y0); y < Math.min(store.height, y0 + h); y++) {
|
|
555
|
+
for (let x = Math.max(0, x0); x < Math.min(store.width, x0 + w); x++) {
|
|
556
|
+
// A point or rect hits no pixel of alpha 0, at threshold 0 too (bitmapdata_hittest_threshold).
|
|
557
|
+
const a = alphaAt(store, x, y);
|
|
558
|
+
if (a > 0 && a >= a1) {
|
|
559
|
+
return true;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
if (data) {
|
|
566
|
+
const second = storeOf(s, data);
|
|
567
|
+
// Against a bitmap, its point is required.
|
|
568
|
+
const [sx, sy] = pointOf(s, secondPoint, "secondBitmapDataPoint");
|
|
569
|
+
if (sx + second.width > 0x7fffffff || sy + second.height > 0x7fffffff) {
|
|
570
|
+
throw s.rt.error("ArgumentError", 1508, "secondBitmapDataPoint");
|
|
571
|
+
}
|
|
572
|
+
const a2 = secondAlpha === undefined ? 1 : s.rt.toUint(secondAlpha);
|
|
573
|
+
const ox = sx - fx;
|
|
574
|
+
const oy = sy - fy;
|
|
575
|
+
for (let y = Math.max(0, oy); y < Math.min(store.height, oy + second.height); y++) {
|
|
576
|
+
for (let x = Math.max(0, ox); x < Math.min(store.width, ox + second.width); x++) {
|
|
577
|
+
if (alphaAt(store, x, y) >= a1 && alphaAt(second, x - ox, y - oy) >= a2) {
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
throw s.rt.error("ArgumentError", 2005, 2);
|
|
585
|
+
}
|
|
586
|
+
pixelDissolve(source, rect, dest, seed, count, fill) {
|
|
587
|
+
const store = storeOf(s, this);
|
|
588
|
+
// Anything but a BitmapData is refused as null, as Flash words it.
|
|
589
|
+
if (source === null || source === undefined || source.$store === undefined) {
|
|
590
|
+
throw s.rt.error("TypeError", 2007, "sourceBitmapData");
|
|
591
|
+
}
|
|
592
|
+
const src = storeOf(s, source);
|
|
593
|
+
if (rect === null || rect === undefined) {
|
|
594
|
+
throw s.rt.error("TypeError", 2007, "sourceRect");
|
|
595
|
+
}
|
|
596
|
+
const r = rectOf(s, rect, true);
|
|
597
|
+
const [dx, dy] = pointOf(s, dest, "destPoint");
|
|
598
|
+
const n = count === undefined ? 0 : s.rt.toInt(count);
|
|
599
|
+
if (n < 0) {
|
|
600
|
+
throw s.rt.error("RangeError", 2027, "numPixels", n);
|
|
601
|
+
}
|
|
602
|
+
return pixelDissolve(store, src, r, dx, dy,
|
|
603
|
+
// An int, as declared: NaN is 0, where it would never reach a state.
|
|
604
|
+
seed === undefined ? 0 : s.rt.toInt(seed), n, fill === undefined ? 0 : s.rt.toUint(fill));
|
|
605
|
+
}
|
|
606
|
+
draw(source, matrix, ct, mode, clip, smoothing) {
|
|
607
|
+
drawInto(s, storeOf(s, this), source, matrix, ct, mode, clip, smoothing);
|
|
608
|
+
}
|
|
609
|
+
drawWithQuality(source, matrix, ct, mode, clip, smoothing, quality) {
|
|
610
|
+
drawInto(s, storeOf(s, this), source, matrix, ct, mode, clip, smoothing, samplesOf(s, quality));
|
|
611
|
+
}
|
|
612
|
+
lock() {
|
|
613
|
+
storeOf(s, this);
|
|
614
|
+
}
|
|
615
|
+
unlock() {
|
|
616
|
+
storeOf(s, this);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
avm2.registerNativeClass(natives, "flash.display::BitmapData", BitmapDataNatives);
|
|
620
|
+
return natives;
|
|
621
|
+
}
|
|
622
|
+
export function bitmapDataHooks(s) {
|
|
623
|
+
return {
|
|
624
|
+
"flash.display::BitmapData": {
|
|
625
|
+
create: (traits) => {
|
|
626
|
+
const o = Object.create(traits.proto);
|
|
627
|
+
o.$store = null;
|
|
628
|
+
o.$symbol = s.symbols.bitmapSymbol(traits);
|
|
629
|
+
return o;
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
};
|
|
633
|
+
}
|