@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,520 @@
|
|
|
1
|
+
import { hitsGlyph } from "../text/static.js";
|
|
2
|
+
import { BitmapObject, Clips, Container, ShapeObject, StaticTextObject, TextObject, VideoObject, } from "./display.js";
|
|
3
|
+
import { apply, behindEye, boxThrough, concat, contains, invert, isProjective, overlaps, transformRect, union, } from "./geometry.js";
|
|
4
|
+
import { sliceFor, sliceLayers, withinMask } from "./scale9.js";
|
|
5
|
+
import { facing, flatten, inside, orientation, pointsOf, } from "./shapes.js";
|
|
6
|
+
const TWIPS = 20;
|
|
7
|
+
const IDENTITY = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
|
|
8
|
+
/** The matrix from `d`'s space to the stage's (`stage` itself excluded), through every parent, scroll shifts and all. */
|
|
9
|
+
export function toStage(d, stage) {
|
|
10
|
+
let m = d.placed;
|
|
11
|
+
for (let p = d.parent; p && p !== stage; p = p.parent) {
|
|
12
|
+
m = concat(m, p.placed);
|
|
13
|
+
}
|
|
14
|
+
return m;
|
|
15
|
+
}
|
|
16
|
+
/** What `d` itself draws, in its own space: null for nothing. `lines` counts the lines' widths. */
|
|
17
|
+
export function ownBounds(d, lines) {
|
|
18
|
+
if (d.drawing) {
|
|
19
|
+
return d.drawing.bounds(lines);
|
|
20
|
+
}
|
|
21
|
+
if (d instanceof BitmapObject) {
|
|
22
|
+
const store = d.store;
|
|
23
|
+
return store && !store.disposed
|
|
24
|
+
? { xMin: 0, yMin: 0, xMax: store.width, yMax: store.height }
|
|
25
|
+
: null;
|
|
26
|
+
}
|
|
27
|
+
if (d instanceof TextObject) {
|
|
28
|
+
return { xMin: d.left, yMin: d.top, xMax: d.left + d.width, yMax: d.top + d.height };
|
|
29
|
+
}
|
|
30
|
+
if (d instanceof VideoObject) {
|
|
31
|
+
return { xMin: 0, yMin: 0, xMax: d.boxWidth, yMax: d.boxHeight };
|
|
32
|
+
}
|
|
33
|
+
if (d instanceof StaticTextObject) {
|
|
34
|
+
const r = d.definition.definition.bounds;
|
|
35
|
+
return {
|
|
36
|
+
xMin: r.xMin / TWIPS,
|
|
37
|
+
yMin: r.yMin / TWIPS,
|
|
38
|
+
xMax: r.xMax / TWIPS,
|
|
39
|
+
yMax: r.yMax / TWIPS,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (d instanceof ShapeObject && d.shape) {
|
|
43
|
+
const r = (lines ? null : d.shape.shape.edgeBounds) ?? d.shape.shape.bounds;
|
|
44
|
+
return {
|
|
45
|
+
xMin: r.xMin / TWIPS,
|
|
46
|
+
yMin: r.yMin / TWIPS,
|
|
47
|
+
xMax: r.xMax / TWIPS,
|
|
48
|
+
yMax: r.yMax / TWIPS,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `d`'s bounds in its own space, its children's included: null for an
|
|
55
|
+
* object with nothing in it. A scrolled object's are its scroll's size at
|
|
56
|
+
* (0, 0), whatever it draws, as Flash reports them; masks clip none.
|
|
57
|
+
* `drawn` takes a 3D object in another as drawn, not as reported
|
|
58
|
+
* (placedRect), for the bitmap the other is drawn into.
|
|
59
|
+
*/
|
|
60
|
+
export function bounds(d, lines, drawn = false) {
|
|
61
|
+
const scroll = d.scroll;
|
|
62
|
+
if (scroll) {
|
|
63
|
+
return { xMin: 0, yMin: 0, xMax: scroll.xMax - scroll.xMin, yMax: scroll.yMax - scroll.yMin };
|
|
64
|
+
}
|
|
65
|
+
let r = ownBounds(d, lines);
|
|
66
|
+
if (d instanceof Container) {
|
|
67
|
+
for (const child of d.children) {
|
|
68
|
+
const b = bounds(child, lines, drawn);
|
|
69
|
+
// A 3D child with a corner behind the eye is not drawn, and counts for nothing.
|
|
70
|
+
if (b && !(child.space && behindEye(b, child.placed))) {
|
|
71
|
+
r = union(r, placedRect(child, b, drawn));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return r;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* `r`, in the space of `d`, through `d`'s matrix into its parent's space.
|
|
79
|
+
* A 3D object's is the box around what its plane draws in its projector's
|
|
80
|
+
* space, out to whole pixels, taken back to its parent's as a box, as Flash
|
|
81
|
+
* measures it: so under a rotated 2D parent its box there is the box of a
|
|
82
|
+
* box, larger than what is drawn (the `three-d-bounds` case). In a 3D
|
|
83
|
+
* parent, it is its box through its matrix3D's x and y rows, without
|
|
84
|
+
* perspective, as its width is in adl; or, `drawn`, its plane's there,
|
|
85
|
+
* which the parent's bitmap must hold.
|
|
86
|
+
*/
|
|
87
|
+
export function placedRect(d, r, drawn = false) {
|
|
88
|
+
if (!d.space) {
|
|
89
|
+
return transformRect(r, d.placed);
|
|
90
|
+
}
|
|
91
|
+
if (d.parent?.space) {
|
|
92
|
+
return transformRect(r, drawn ? d.placed : d.flatPlaced);
|
|
93
|
+
}
|
|
94
|
+
const { own, back } = d.planes();
|
|
95
|
+
const box = transformRect(r, own);
|
|
96
|
+
return back ? boxThrough(box, back) : box;
|
|
97
|
+
}
|
|
98
|
+
/** `d`'s bounds in `target`'s space (its own for null), through the stage. */
|
|
99
|
+
export function boundsIn(d, target, stage, lines) {
|
|
100
|
+
const own = bounds(d, lines) ?? { xMin: 0, yMin: 0, xMax: 0, yMax: 0 };
|
|
101
|
+
if (!target || target === d) {
|
|
102
|
+
return own;
|
|
103
|
+
}
|
|
104
|
+
const up = toStage(d, stage);
|
|
105
|
+
const down = target === stage ? IDENTITY : (invert(toStage(target, stage)) ?? IDENTITY);
|
|
106
|
+
if (!isProjective(up)) {
|
|
107
|
+
return transformRect(own, concat(up, down));
|
|
108
|
+
}
|
|
109
|
+
// Through a plane: a 2D object's only up to where it and the target meet, so that a plane and
|
|
110
|
+
// its inverse do not both go into it, out to whole pixels where they cancel.
|
|
111
|
+
if (!d.space) {
|
|
112
|
+
let common = target;
|
|
113
|
+
while (common && !common.encloses(d)) {
|
|
114
|
+
common = common.parent;
|
|
115
|
+
}
|
|
116
|
+
if (!common || common === stage) {
|
|
117
|
+
return transformRect(own, concat(up, down));
|
|
118
|
+
}
|
|
119
|
+
const toTarget = target === common ? IDENTITY : invert(toStage(target, common));
|
|
120
|
+
return toTarget
|
|
121
|
+
? transformRect(own, concat(toStage(d, common), toTarget))
|
|
122
|
+
: transformRect(own, concat(up, down));
|
|
123
|
+
}
|
|
124
|
+
// A 3D object's, as Flash measures it: the box on the stage, out to whole pixels, then that
|
|
125
|
+
// box taken into the target's space, a box of a box (the `three-d-bounds` case).
|
|
126
|
+
const box = transformRect(own, up);
|
|
127
|
+
return target === stage ? box : boxThrough(box, down);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether the point (x, y) is within `d`'s bounds, or, for `shape`, on what
|
|
131
|
+
* it or its children draw. The point is in the main root's space, as Flash
|
|
132
|
+
* has it (the corpus's `displayobject_hittestpoint_root`): moving the root
|
|
133
|
+
* moves nothing under the point, moving a loaded SWF's root does. The
|
|
134
|
+
* shape test asks for a root above `d`, the bounds test does not.
|
|
135
|
+
*/
|
|
136
|
+
export function hitsPoint(d, x, y, shape, root) {
|
|
137
|
+
const up = toStage(d, root);
|
|
138
|
+
if (isProjective(up) && inHidden3D(d)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
// In 3D, the bounds are the box around what is drawn on the stage, as Flash tests them.
|
|
142
|
+
if (!shape && isProjective(up)) {
|
|
143
|
+
const r = bounds(d, true);
|
|
144
|
+
return r !== null && !behindEye(r, up) && contains(transformRect(r, up), x, y);
|
|
145
|
+
}
|
|
146
|
+
const toLocal = invert(up);
|
|
147
|
+
if (!toLocal) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (!shape) {
|
|
151
|
+
const [lx, ly] = apply(toLocal, x, y);
|
|
152
|
+
const r = bounds(d, true);
|
|
153
|
+
return r !== null && contains(r, lx, ly);
|
|
154
|
+
}
|
|
155
|
+
// A mask is not drawn, and adl hits nothing of it, a script's or a timeline's, nor of what
|
|
156
|
+
// is in it. Nor the stage's shape test, though the stage is a root for what a script puts
|
|
157
|
+
// on it: the one root with no parent.
|
|
158
|
+
if (!underRoot(d) || withinMask(d) || (d.parent === null && d.loaderInfo !== null)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
// Flash samples half a pixel to the left of the point and on its row: a
|
|
162
|
+
// point on a shape's right edge hits, one on its left, top or bottom edge
|
|
163
|
+
// does not (the corpus's displayobject_hittestpoint_boundary).
|
|
164
|
+
const [lx, ly] = apply(toLocal, x - 0.5, y);
|
|
165
|
+
const probe = { x: x - 0.5, y, root };
|
|
166
|
+
return drawnAt(d, lx, ly, probe, false) && !clippedAbove(d, probe);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* What this object itself draws under a pointer, without asking its
|
|
170
|
+
* children. For the pointer's own pick (`clips`), the timeline's masks
|
|
171
|
+
* above it clip it too, as Flash picks (the corpus's `mouse_pick_masking`):
|
|
172
|
+
* a list scrolled under a mask layer takes no click where it is hidden.
|
|
173
|
+
*/
|
|
174
|
+
export function hitsOwnPoint(d, x, y, root, clips = false) {
|
|
175
|
+
if (!underRoot(d) || d.maskOf) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
const toLocal = invert(toStage(d, root));
|
|
179
|
+
if (!toLocal) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const probe = { x: x - 0.5, y, root };
|
|
183
|
+
const [lx, ly] = apply(toLocal, probe.x, probe.y);
|
|
184
|
+
return hitsOwnLocal(d, lx, ly, probe, clips);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* hitsOwnPoint with the probe already in `d`'s own space, at (`lx`, `ly`):
|
|
188
|
+
* the pointer's pick carries it down the list, making no matrix per object.
|
|
189
|
+
*/
|
|
190
|
+
export function hitsOwnLocal(d, lx, ly, probe, clips = false) {
|
|
191
|
+
if (!underRoot(d) || d.maskOf) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
let hit;
|
|
195
|
+
if (d instanceof TextObject) {
|
|
196
|
+
const r = ownBounds(d, true);
|
|
197
|
+
const scroll = d.scroll;
|
|
198
|
+
hit =
|
|
199
|
+
!!r &&
|
|
200
|
+
contains(r, lx, ly) &&
|
|
201
|
+
(!scroll || contains(scroll, lx, ly)) &&
|
|
202
|
+
(!d.mask || inMask(d.mask, probe));
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
hit = drawnAt(d, lx, ly, probe, false, false);
|
|
206
|
+
}
|
|
207
|
+
// What clips it is asked only of a hit: a pick tests every object under its
|
|
208
|
+
// containers, and finding the mask layers over one walks its siblings.
|
|
209
|
+
return hit && !clippedAbove(d, probe) && !(clips && clippedByLayers(d, probe));
|
|
210
|
+
}
|
|
211
|
+
/** Whether a mask or a scroll above `d` leaves the probe out. */
|
|
212
|
+
function clippedAbove(d, probe) {
|
|
213
|
+
for (let p = d.parent; p; p = p.parent) {
|
|
214
|
+
if (p.mask && !p.maskOf && !p.mask.encloses(p) && !inMask(p.mask, probe)) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
const scroll = p.scroll;
|
|
218
|
+
const toLocal = scroll && invert(toStage(p, probe.root));
|
|
219
|
+
if (scroll && toLocal) {
|
|
220
|
+
const [x, y] = apply(toLocal, probe.x, probe.y);
|
|
221
|
+
if (!(x >= scroll.xMin && x < scroll.xMax && y >= scroll.yMin && y < scroll.yMax)) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
/** Whether any of the first `n` clip layers open leaves the probe out. */
|
|
229
|
+
function outsideLayers(clips, n, probe) {
|
|
230
|
+
for (let i = 0; i < n; i++) {
|
|
231
|
+
if (!inMask(clips.masks[i], probe)) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
/** Whether a timeline's mask over `d` or over a container above it leaves the probe out. */
|
|
238
|
+
function clippedByLayers(d, probe) {
|
|
239
|
+
for (let o = d; o.parent; o = o.parent) {
|
|
240
|
+
const clips = new Clips();
|
|
241
|
+
for (const child of o.parent.children) {
|
|
242
|
+
const n = clips.enter(child);
|
|
243
|
+
if (child !== o) {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (outsideLayers(clips, n, probe)) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
/** Whether the probe is on `mask`'s fills, where it is: its lines clip nothing; a 3D mask's, all of it. */
|
|
255
|
+
function inMask(mask, probe) {
|
|
256
|
+
// A 3D mask clips nothing, as Flash draws it.
|
|
257
|
+
if (mask.space) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
const toLocal = invert(toStage(mask, probe.root));
|
|
261
|
+
if (!toLocal) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const [x, y] = apply(toLocal, probe.x, probe.y);
|
|
265
|
+
return drawnAt(mask, x, y, probe, true);
|
|
266
|
+
}
|
|
267
|
+
/** Whether a SWF's root, the main one's or a loaded one's, is `d` or above it. */
|
|
268
|
+
function underRoot(d) {
|
|
269
|
+
for (let o = d; o; o = o.parent) {
|
|
270
|
+
if (o.loaderInfo || o.avm1Root) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Whether (x, y), in `d`'s space, is on a fill or a line of `d` or of a
|
|
278
|
+
* child, within the scroll and the masks that clip it. As a mask (`mask`)
|
|
279
|
+
* its lines count for nothing and its own mask is not asked, so that two
|
|
280
|
+
* masks of each other end.
|
|
281
|
+
*/
|
|
282
|
+
function drawnAt(d, x, y, probe, mask, children = true) {
|
|
283
|
+
const scroll = d.scroll;
|
|
284
|
+
if (scroll && !(x >= scroll.xMin && x < scroll.xMax && y >= scroll.yMin && y < scroll.yMax)) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if (!mask && d.mask && !d.maskOf && !d.mask.encloses(d) && !inMask(d.mask, probe)) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
// A Bitmap is hit, and masks, over its whole rectangle, transparent pixels and all.
|
|
291
|
+
if (d instanceof BitmapObject) {
|
|
292
|
+
const store = d.store;
|
|
293
|
+
return !!store && !store.disposed && x >= 0 && x < store.width && y >= 0 && y < store.height;
|
|
294
|
+
}
|
|
295
|
+
if (d instanceof StaticTextObject) {
|
|
296
|
+
return hitsGlyph(d.definition, d.glyphs.glyphs, x, y, mask);
|
|
297
|
+
}
|
|
298
|
+
const drawing = d.drawing;
|
|
299
|
+
let layers = drawing
|
|
300
|
+
? facing(drawing.layers, drawing.culled && turnedOver(d), drawing.version)
|
|
301
|
+
: d instanceof ShapeObject
|
|
302
|
+
? (d.shape?.layers ?? [])
|
|
303
|
+
: [];
|
|
304
|
+
// A 9-slice is hit where it is drawn, its layers as the renderer moves them, and only within
|
|
305
|
+
// its own bounds as drawn unsliced: adl misses an owner's fill that a wider child stretched
|
|
306
|
+
// past them. A mask is not sliced.
|
|
307
|
+
const own = layers.length > 0 && !mask && (d.scale9Grid || d.parent?.scale9Grid) ? sliceFor(d) : null;
|
|
308
|
+
if (own) {
|
|
309
|
+
const r = ownBounds(d, true);
|
|
310
|
+
layers =
|
|
311
|
+
r && contains(r, x, y) ? sliceLayers(layers, own.slice, own.m, d.drawing?.version) : [];
|
|
312
|
+
}
|
|
313
|
+
for (const layer of layers) {
|
|
314
|
+
for (const { contours, winding } of layer.fills) {
|
|
315
|
+
// Inside by the fill's rule: an odd number of its contours around the
|
|
316
|
+
// point for even-odd, a non-zero sum of their orientations for non-zero.
|
|
317
|
+
let crossings = 0;
|
|
318
|
+
let sum = 0;
|
|
319
|
+
for (const contour of contours) {
|
|
320
|
+
const box = boxOf(contour);
|
|
321
|
+
if (!near(box, x, y, 0)) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
const flat = flatOf(contour, box);
|
|
325
|
+
if (inside(flat.points, x, y)) {
|
|
326
|
+
crossings++;
|
|
327
|
+
sum += flat.orientation;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (winding === "nonZero" ? sum !== 0 : crossings % 2) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (layer.meshes?.some((mesh) => inMesh(mesh.positions, x, y))) {
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
if (mask) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
for (const { line, paths } of layer.strokes) {
|
|
341
|
+
const half = Math.max(line.width / TWIPS, 1) / 2;
|
|
342
|
+
for (const path of paths) {
|
|
343
|
+
const box = boxOf(path);
|
|
344
|
+
if (near(box, x, y, half) && nearPolyline(flatOf(path, box).points, x, y, half)) {
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (children && d instanceof Container) {
|
|
351
|
+
// Masks are not drawn; a timeline's clip no hit test, as Flash's do not. What a clip
|
|
352
|
+
// layer clips is hit only where the layer covers the probe: a clip that plays its mask
|
|
353
|
+
// to an empty frame hides a part from a shape test too (adl, avm1-hit-test-under-mask).
|
|
354
|
+
let clips = null;
|
|
355
|
+
for (const child of d.children) {
|
|
356
|
+
if (child.clipDepth > 0) {
|
|
357
|
+
clips ??= new Clips();
|
|
358
|
+
}
|
|
359
|
+
const n = clips ? clips.enter(child) : 0;
|
|
360
|
+
if (child.clipDepth !== 0 || child.maskOf !== null) {
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
const toChild = invert(child.placed);
|
|
364
|
+
if (toChild &&
|
|
365
|
+
!(child.space && hidden3D(child)) &&
|
|
366
|
+
!(clips && !mask && outsideLayers(clips, n, probe)) &&
|
|
367
|
+
drawnAt(child, ...apply(toChild, x, y), probe, mask)) {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Whether `d` is turned over on the stage, which decides the triangles a
|
|
376
|
+
* culled drawTriangles keeps there: as the renderer draws it, within a 3D
|
|
377
|
+
* object's own space.
|
|
378
|
+
*/
|
|
379
|
+
function turnedOver(d) {
|
|
380
|
+
let turned = false;
|
|
381
|
+
for (let o = d; o && !o.space; o = o.parent) {
|
|
382
|
+
const m = o.matrix;
|
|
383
|
+
if (m.a * m.d - m.b * m.c < 0) {
|
|
384
|
+
turned = !turned;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return turned;
|
|
388
|
+
}
|
|
389
|
+
/** Whether (x, y) is in any of the triangles, three points of `positions` each. */
|
|
390
|
+
function inMesh(positions, x, y) {
|
|
391
|
+
const triangle = [0, 0, 0, 0, 0, 0];
|
|
392
|
+
for (let i = 0; i < positions.length; i += 6) {
|
|
393
|
+
for (let k = 0; k < 6; k++) {
|
|
394
|
+
triangle[k] = positions[i + k];
|
|
395
|
+
}
|
|
396
|
+
if (inside(triangle, x, y)) {
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
/** Whether `d` or a 3D object above it has a corner behind the eye, so that none of `d` is drawn. */
|
|
403
|
+
function inHidden3D(d) {
|
|
404
|
+
for (let p = d; p; p = p.parent) {
|
|
405
|
+
if (p.space && hidden3D(p)) {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
/** Whether a 3D object has a corner behind the eye, which Flash draws none of, and hits none of. */
|
|
412
|
+
export function hidden3D(d) {
|
|
413
|
+
const r = bounds(d, true);
|
|
414
|
+
return r !== null && behindEye(r, d.placed);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* The boxes of paths not flattened: their points' and control points',
|
|
418
|
+
* which hold their curves, made with nothing flattened. A drawing redrawn on
|
|
419
|
+
* every frame has new paths each time, most of them far from the pointer,
|
|
420
|
+
* which were flattened for their box alone.
|
|
421
|
+
*/
|
|
422
|
+
const hulls = new WeakMap();
|
|
423
|
+
/** The path's box: its flattening's where that was made, else its points' and control points'. */
|
|
424
|
+
function boxOf(path) {
|
|
425
|
+
const flat = flats.get(path);
|
|
426
|
+
if (flat && flat.length === path.length) {
|
|
427
|
+
return flat;
|
|
428
|
+
}
|
|
429
|
+
const kept = hulls.get(path);
|
|
430
|
+
if (kept && kept.length === path.length) {
|
|
431
|
+
return kept;
|
|
432
|
+
}
|
|
433
|
+
let xMin = Infinity;
|
|
434
|
+
let yMin = Infinity;
|
|
435
|
+
let xMax = -Infinity;
|
|
436
|
+
let yMax = -Infinity;
|
|
437
|
+
for (let i = 0; i < path.length;) {
|
|
438
|
+
const end = i + 1 + pointsOf(path[i]) * 2;
|
|
439
|
+
for (let k = i + 1; k < end; k += 2) {
|
|
440
|
+
xMin = Math.min(xMin, path[k]);
|
|
441
|
+
xMax = Math.max(xMax, path[k]);
|
|
442
|
+
yMin = Math.min(yMin, path[k + 1]);
|
|
443
|
+
yMax = Math.max(yMax, path[k + 1]);
|
|
444
|
+
}
|
|
445
|
+
i = end;
|
|
446
|
+
}
|
|
447
|
+
const box = { length: path.length, xMin, yMin, xMax, yMax };
|
|
448
|
+
hulls.set(path, box);
|
|
449
|
+
return box;
|
|
450
|
+
}
|
|
451
|
+
/** The path flattened: `box` itself where boxOf gave its flattening. */
|
|
452
|
+
function flatOf(path, box) {
|
|
453
|
+
return "points" in box ? box : flattened(path);
|
|
454
|
+
}
|
|
455
|
+
/** Whether (x, y) is within `half` of the box, as it must be to be in or on its path. */
|
|
456
|
+
function near(box, x, y, half) {
|
|
457
|
+
// Negated, so a box made NaN by a drawing's NaN point rules nothing out:
|
|
458
|
+
// the full test then skips only the NaN edges, as it did.
|
|
459
|
+
return !(x < box.xMin - half ||
|
|
460
|
+
x > box.xMax + half ||
|
|
461
|
+
y < box.yMin - half ||
|
|
462
|
+
y > box.yMax + half);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Paths flattened once, not on every hit test: the pointer asks on every
|
|
466
|
+
* move, of every shape under the point's ancestors, and a curve's chords
|
|
467
|
+
* cost more than a box test that rules most of them out.
|
|
468
|
+
*/
|
|
469
|
+
const flats = new WeakMap();
|
|
470
|
+
function flattened(path) {
|
|
471
|
+
const cached = flats.get(path);
|
|
472
|
+
if (cached && cached.length === path.length) {
|
|
473
|
+
return cached;
|
|
474
|
+
}
|
|
475
|
+
const points = flatten(path);
|
|
476
|
+
let [xMin, yMin, xMax, yMax] = [Infinity, Infinity, -Infinity, -Infinity];
|
|
477
|
+
for (let i = 0; i < points.length; i += 2) {
|
|
478
|
+
xMin = Math.min(xMin, points[i]);
|
|
479
|
+
xMax = Math.max(xMax, points[i]);
|
|
480
|
+
yMin = Math.min(yMin, points[i + 1]);
|
|
481
|
+
yMax = Math.max(yMax, points[i + 1]);
|
|
482
|
+
}
|
|
483
|
+
const flat = {
|
|
484
|
+
length: path.length,
|
|
485
|
+
points,
|
|
486
|
+
orientation: orientation(points),
|
|
487
|
+
xMin,
|
|
488
|
+
yMin,
|
|
489
|
+
xMax,
|
|
490
|
+
yMax,
|
|
491
|
+
};
|
|
492
|
+
flats.set(path, flat);
|
|
493
|
+
return flat;
|
|
494
|
+
}
|
|
495
|
+
/** Whether (px, py) is within `half` of any segment of the open polyline. */
|
|
496
|
+
function nearPolyline(points, px, py, half) {
|
|
497
|
+
for (let i = 2; i < points.length; i += 2) {
|
|
498
|
+
const ax = points[i - 2];
|
|
499
|
+
const ay = points[i - 1];
|
|
500
|
+
const bx = points[i];
|
|
501
|
+
const by = points[i + 1];
|
|
502
|
+
const dx = bx - ax;
|
|
503
|
+
const dy = by - ay;
|
|
504
|
+
const length2 = dx * dx + dy * dy;
|
|
505
|
+
const t = length2 === 0 ? 0 : Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / length2));
|
|
506
|
+
if (Math.hypot(px - (ax + t * dx), py - (ay + t * dy)) <= half) {
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
/** Whether the two objects' bounds in the stage's space overlap. */
|
|
513
|
+
export function hitsObject(a, b, stage) {
|
|
514
|
+
const ra = bounds(a, true);
|
|
515
|
+
const rb = bounds(b, true);
|
|
516
|
+
if (!ra || !rb) {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
return overlaps(transformRect(ra, toStage(a, stage)), transformRect(rb, toStage(b, stage)));
|
|
520
|
+
}
|