@swf2es/player-hosts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
// A MovieClip: a container its timeline's frames place, move and remove
|
|
2
|
+
// children in as its playhead plays or jumps.
|
|
3
|
+
import { IDENTITY } from "../../format/index.js";
|
|
4
|
+
import { BitmapObject } from "./bitmapobject.js";
|
|
5
|
+
import { ButtonObject } from "./buttonobject.js";
|
|
6
|
+
import { IDENTITY_COLOR } from "./color.js";
|
|
7
|
+
import { Container } from "./container.js";
|
|
8
|
+
import { CLIP, CONTENT, scriptWork } from "./displayobject.js";
|
|
9
|
+
import { construct, displayFor } from "./instantiate.js";
|
|
10
|
+
import { cached, ShapeObject, StaleCache } from "./shapeobject.js";
|
|
11
|
+
import { StaticTextObject, TextObject } from "./textobjects.js";
|
|
12
|
+
const NO_FILTER_BYTES = new Uint8Array([0]);
|
|
13
|
+
/**
|
|
14
|
+
* Whether `display` is the kind of object `character` makes, so that a
|
|
15
|
+
* rewind's place may keep it in that place's stead: a shape for a shape or
|
|
16
|
+
* a morph, a clip for a clip, and so on. Not for a character that makes
|
|
17
|
+
* none (data, a font, a sound), which the place leaves as it is.
|
|
18
|
+
*/
|
|
19
|
+
function madeAs(display, character) {
|
|
20
|
+
switch (character?.type) {
|
|
21
|
+
case "shape":
|
|
22
|
+
case "morph":
|
|
23
|
+
return display instanceof ShapeObject;
|
|
24
|
+
case "sprite":
|
|
25
|
+
return display instanceof MovieClip;
|
|
26
|
+
case "button":
|
|
27
|
+
return display instanceof ButtonObject;
|
|
28
|
+
case "bitmap":
|
|
29
|
+
return display instanceof BitmapObject;
|
|
30
|
+
case "text":
|
|
31
|
+
return display instanceof TextObject;
|
|
32
|
+
case "static":
|
|
33
|
+
return display instanceof StaticTextObject;
|
|
34
|
+
default:
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Another character placed in a child's stead, with the move flag or where
|
|
40
|
+
* a rewind keeps the child: Flash makes no new object, and only a Shape,
|
|
41
|
+
* MorphShape or StaticText no script has touched takes the new shape's,
|
|
42
|
+
* morph's or text's graphic; a clip, a Shape a script set a property of,
|
|
43
|
+
* and a Shape a sprite is placed over all stay as they are (`replaces`,
|
|
44
|
+
* `static-text-replace`). Flash also gives a Shape a text's glyphs and a
|
|
45
|
+
* StaticText a shape's fills, which the player does not: they stay as
|
|
46
|
+
* they are.
|
|
47
|
+
*/
|
|
48
|
+
function swap(existing, character) {
|
|
49
|
+
if (existing.scripted || existing.character === character) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (existing instanceof StaticTextObject) {
|
|
53
|
+
if (character.type === "static") {
|
|
54
|
+
existing.show(character);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!(existing instanceof ShapeObject)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Cached as a bitmap, a Shape takes the new shape but Flash goes on
|
|
62
|
+
// showing the bitmap it drew of the old while their bounds are the same
|
|
63
|
+
// (`replaces`, `cache-replace`); other bounds draw it again
|
|
64
|
+
// (`scripted-touch`). A text draws its new glyphs whatever its bounds.
|
|
65
|
+
const old = existing.drawn();
|
|
66
|
+
if (cached(existing) && character.type === "shape" && old && sameBounds(old, character)) {
|
|
67
|
+
existing.stale ??= new StaleCache(old, existing);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
existing.stale = null;
|
|
71
|
+
}
|
|
72
|
+
// A morph is blended when it is next drawn, at the ratio the place gives.
|
|
73
|
+
if (character.type === "morph") {
|
|
74
|
+
existing.morph = character;
|
|
75
|
+
}
|
|
76
|
+
else if (character.type === "shape") {
|
|
77
|
+
existing.morph = null;
|
|
78
|
+
existing.shape = character;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
existing.character = character;
|
|
84
|
+
existing.invalidate(CONTENT);
|
|
85
|
+
}
|
|
86
|
+
function sameBounds(a, b) {
|
|
87
|
+
const x = a.shape.bounds;
|
|
88
|
+
const y = b.shape.bounds;
|
|
89
|
+
return x.xMin === y.xMin && x.xMax === y.xMax && x.yMin === y.yMin && x.yMax === y.yMax;
|
|
90
|
+
}
|
|
91
|
+
export class MovieClip extends Container {
|
|
92
|
+
frame = 0;
|
|
93
|
+
scripts = new Map();
|
|
94
|
+
making = false;
|
|
95
|
+
placedByTimeline = false;
|
|
96
|
+
running = true;
|
|
97
|
+
/** Its timeline's stream as it plays, for what plays it (TimelineSounds); null while none does. */
|
|
98
|
+
stream = null;
|
|
99
|
+
/**
|
|
100
|
+
* Made by a script with `new`, or placed on the first frame of one that
|
|
101
|
+
* was as it was made: Flash has such a clip sit out the next frame's
|
|
102
|
+
* advance, wherever it is by then (`fresh-clips`).
|
|
103
|
+
*/
|
|
104
|
+
fresh = false;
|
|
105
|
+
/**
|
|
106
|
+
* The frame whose script last ran, so that entering a frame runs its
|
|
107
|
+
* script once: set to currentFrame alone, as a round's skipping
|
|
108
|
+
* (scriptWork) has it.
|
|
109
|
+
*/
|
|
110
|
+
scriptedFrame = 0;
|
|
111
|
+
/** A goto a frame script asked for, taken when the script returns, as Flash defers it; null for none. */
|
|
112
|
+
queuedGoto = null;
|
|
113
|
+
/** Whether that goto plays or stops the clip, as it happens, not as it is asked for. */
|
|
114
|
+
queuedPlay = false;
|
|
115
|
+
/**
|
|
116
|
+
* The frame count (Scripting.frames) at a script's goto in a SWF of
|
|
117
|
+
* version 9 or earlier, a goto to the frame it is on among them: the next
|
|
118
|
+
* frame it sits out, with all in it, as Flash has such a clip
|
|
119
|
+
* (`goto-children`). A stamp, not a flag: one a skipped parent took along,
|
|
120
|
+
* or a clip no frame reached, is past by the frame after and never skips.
|
|
121
|
+
* From version 10 a goto leaves its frames as they were.
|
|
122
|
+
*/
|
|
123
|
+
skipsAfter = -1;
|
|
124
|
+
/** Whether an AVM1 clip ran the actions after its last ShowFrame, which it does once. */
|
|
125
|
+
tailed = false;
|
|
126
|
+
/** Its frames: its character's, or, once an AVM1 load has filled it, the SWF's root's. */
|
|
127
|
+
timeline;
|
|
128
|
+
constructor(timeline, library) {
|
|
129
|
+
super();
|
|
130
|
+
this.kind = CLIP;
|
|
131
|
+
this.timeline = timeline;
|
|
132
|
+
this.library = library;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* What an AVM1 load puts in it, as Flash keeps the clip and replaces
|
|
136
|
+
* what it shows: `timeline` of `library` in place of its own, its
|
|
137
|
+
* children gone, before its first frame and playing. Telling of what it
|
|
138
|
+
* showed going, its unload, is the caller's.
|
|
139
|
+
*/
|
|
140
|
+
replaceTimeline(timeline, library) {
|
|
141
|
+
this.library.sounds?.stopStream(this);
|
|
142
|
+
for (const child of [...this.children]) {
|
|
143
|
+
this.removeChild(child);
|
|
144
|
+
}
|
|
145
|
+
this.depths.clear();
|
|
146
|
+
this.held = [];
|
|
147
|
+
this.timeline = timeline;
|
|
148
|
+
this.library = library;
|
|
149
|
+
this.drawing = null;
|
|
150
|
+
this.currentFrame = 0;
|
|
151
|
+
this.running = true;
|
|
152
|
+
this.tailed = false;
|
|
153
|
+
this.queuedGoto = null;
|
|
154
|
+
this.invalidate(CONTENT);
|
|
155
|
+
}
|
|
156
|
+
/** The frame it shows, 1 the first; 0 before its first frame is entered. */
|
|
157
|
+
get currentFrame() {
|
|
158
|
+
return this.frame;
|
|
159
|
+
}
|
|
160
|
+
set currentFrame(frame) {
|
|
161
|
+
if (frame !== this.frame) {
|
|
162
|
+
this.frame = frame;
|
|
163
|
+
scriptWork.changes++;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** The scripts addFrameScript registered, by frame, 1 the first. */
|
|
167
|
+
get frameScripts() {
|
|
168
|
+
return this.scripts;
|
|
169
|
+
}
|
|
170
|
+
/** Register `script` for frame `frame`, or, null, take the frame's away. */
|
|
171
|
+
setFrameScript(frame, script) {
|
|
172
|
+
if (script === null || script === undefined) {
|
|
173
|
+
this.scripts.delete(frame);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.scripts.set(frame, script);
|
|
177
|
+
}
|
|
178
|
+
scriptWork.changes++;
|
|
179
|
+
}
|
|
180
|
+
/** Whether its constructor's super() is making its first frame's children. */
|
|
181
|
+
get makingChildren() {
|
|
182
|
+
return this.making;
|
|
183
|
+
}
|
|
184
|
+
set makingChildren(making) {
|
|
185
|
+
if (making !== this.making) {
|
|
186
|
+
this.making = making;
|
|
187
|
+
scriptWork.changes++;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Placed by a timeline, not made by a script with `new`. */
|
|
191
|
+
get timelineChild() {
|
|
192
|
+
return this.placedByTimeline;
|
|
193
|
+
}
|
|
194
|
+
set timelineChild(placed) {
|
|
195
|
+
if (placed !== this.placedByTimeline) {
|
|
196
|
+
this.placedByTimeline = placed;
|
|
197
|
+
scriptWork.changes++;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Whether its playhead moves on; stopped, its stream stops, as in Flash and Ruffle. */
|
|
201
|
+
get playing() {
|
|
202
|
+
return this.running;
|
|
203
|
+
}
|
|
204
|
+
set playing(play) {
|
|
205
|
+
this.running = play;
|
|
206
|
+
if (!play && this.stream) {
|
|
207
|
+
this.library.sounds?.stopStream(this);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
get totalFrames() {
|
|
211
|
+
return this.timeline.frames.length;
|
|
212
|
+
}
|
|
213
|
+
/** The frame's sounds, where it has any and something plays them. */
|
|
214
|
+
frameSounds(frame) {
|
|
215
|
+
const timeline = this.timeline;
|
|
216
|
+
if ((timeline.stream || timeline.sounds.size > 0) && this.library.sounds) {
|
|
217
|
+
this.library.sounds.frame(this, frame);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* First-frame children placed but not yet made alive: placed before the
|
|
222
|
+
* clip's class constructor runs, made by Sprite's constructChildren in its
|
|
223
|
+
* super(), as Flash has a constructor find them (`instantiation_on_enter_frame`).
|
|
224
|
+
*/
|
|
225
|
+
held = [];
|
|
226
|
+
/**
|
|
227
|
+
* Run frame `frame`'s commands as the playhead reaches it: place, move and
|
|
228
|
+
* remove the timeline's children. A place without the move flag at a depth
|
|
229
|
+
* already taken is let be, as Flash lets it (`same-depth`).
|
|
230
|
+
* A new child is made alive at once, or `later`: by the frame's construct
|
|
231
|
+
* phase, after ENTER_FRAME, for a frame played on; by constructChildren,
|
|
232
|
+
* held, for a clip's first frame.
|
|
233
|
+
*/
|
|
234
|
+
runFrame(frame, later = null) {
|
|
235
|
+
this.library.avm1?.entered(this, frame);
|
|
236
|
+
for (const command of this.timeline.frames[frame - 1] ?? []) {
|
|
237
|
+
if (command.type === "remove") {
|
|
238
|
+
this.removeAtDepth(command.depth);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (command.type === "actions") {
|
|
242
|
+
this.library.avm1?.actions(this, command.tag);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
const place = command.place;
|
|
246
|
+
const existing = this.depths.get(place.depth);
|
|
247
|
+
if (!place.move && existing) {
|
|
248
|
+
this.library.avm1?.occupied(place.depth);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (place.move && existing && place.character === null) {
|
|
252
|
+
existing.applyPlace(place);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
// A new character, or one that replaces what is at the depth.
|
|
256
|
+
// Data is no display object: Flash places nothing for it.
|
|
257
|
+
const character = place.character === null ? null : this.library.characters.get(place.character);
|
|
258
|
+
if (!character ||
|
|
259
|
+
character.type === "binary" ||
|
|
260
|
+
character.type === "font" ||
|
|
261
|
+
character.type === "fontCff" ||
|
|
262
|
+
character.type === "sound") {
|
|
263
|
+
existing?.applyPlace(place);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// With the move flag the child stays, another character or not; and
|
|
267
|
+
// where there is none, the move places nothing (`rewind-first`).
|
|
268
|
+
if (place.move) {
|
|
269
|
+
if (existing) {
|
|
270
|
+
swap(existing, character);
|
|
271
|
+
existing.applyPlace(place);
|
|
272
|
+
}
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const child = displayFor(character, this.library, place.hasImage);
|
|
276
|
+
child.applyPlace(place);
|
|
277
|
+
child.metaData = place.metaData;
|
|
278
|
+
child.placeFrame = frame;
|
|
279
|
+
this.library.avm1?.placing(child, place);
|
|
280
|
+
this.placeAtDepth(child, place.depth);
|
|
281
|
+
if (later === "held" && this.library.construct) {
|
|
282
|
+
this.held.push({ display: child, character });
|
|
283
|
+
}
|
|
284
|
+
else if (later === "frame" && this.library.constructLater) {
|
|
285
|
+
this.library.constructLater(child, character);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
construct(child, character, this.library);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
this.frameSounds(frame);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Jump to frame `frame`, as Flash does rather than by running the frames
|
|
295
|
+
* between: the frames up to it (from the first, for a rewind) are
|
|
296
|
+
* replayed into one jump per depth. On a rewind the children the timeline
|
|
297
|
+
* placed after it go, but one at a depth the frames up to it end on a
|
|
298
|
+
* place without the move flag at, which stays and takes the place; and
|
|
299
|
+
* any child whose ratio is not the one the replayed frames give goes,
|
|
300
|
+
* whenever it was placed. Each jump then changes the child still at its
|
|
301
|
+
* depth, or makes one where the frames placed one anew, or where a
|
|
302
|
+
* rewind ends on another character or ratio. The result is what playing
|
|
303
|
+
* the frames would leave, except that a child placed before the frame and
|
|
304
|
+
* untouched since keeps playing, and its identity; on a rewind a place
|
|
305
|
+
* puts back what it leaves unsaid too, so it looks as it did when first
|
|
306
|
+
* placed. A clip's own loop (`looping`) makes the children it places
|
|
307
|
+
* alive in the frame's construct phase, as playing on does (`loop-ratio`);
|
|
308
|
+
* a script's goto, at once.
|
|
309
|
+
*/
|
|
310
|
+
gotoFrame(frame, looping = false) {
|
|
311
|
+
const target = Math.max(1, Math.min(frame, this.totalFrames));
|
|
312
|
+
const from = this.currentFrame;
|
|
313
|
+
const rewind = target < from;
|
|
314
|
+
// A goto past the last frame reads its definitions without queueing its frame actions (adl).
|
|
315
|
+
if (target !== from) {
|
|
316
|
+
this.library.avm1?.skipped(this, rewind ? 1 : from + 1, target - (target === frame ? 1 : 0));
|
|
317
|
+
}
|
|
318
|
+
// A goto stops the stream, and the frame it lands on starts it again
|
|
319
|
+
// if the clip plays, as Ruffle's run_goto has it; one to the frame it is
|
|
320
|
+
// on is nothing to it, as Ruffle's goto_frame_now has it.
|
|
321
|
+
if (this.stream && target !== from) {
|
|
322
|
+
this.library.sounds?.stopStream(this);
|
|
323
|
+
}
|
|
324
|
+
const jumps = new Map();
|
|
325
|
+
for (let f = (rewind ? 0 : this.currentFrame) + 1; f <= target; f++) {
|
|
326
|
+
for (const command of this.timeline.frames[f - 1] ?? []) {
|
|
327
|
+
if (command.type === "actions") {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (command.type === "remove") {
|
|
331
|
+
jumps.delete(command.depth);
|
|
332
|
+
// Going forward, a removal between the frames takes effect.
|
|
333
|
+
if (!rewind) {
|
|
334
|
+
this.removeAtDepth(command.depth);
|
|
335
|
+
}
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const place = command.place;
|
|
339
|
+
const jump = jumps.get(place.depth) ?? {
|
|
340
|
+
before: null,
|
|
341
|
+
place: null,
|
|
342
|
+
frame: f,
|
|
343
|
+
placed: false,
|
|
344
|
+
};
|
|
345
|
+
// A rewind replays from an empty display list, so what the frames do
|
|
346
|
+
// at a depth nothing has placed yet is known: a change does nothing,
|
|
347
|
+
// and a place in a child's stead places anew.
|
|
348
|
+
if (place.character === null) {
|
|
349
|
+
if (jump.place) {
|
|
350
|
+
jump.place = mergePlace(jump.place, place);
|
|
351
|
+
}
|
|
352
|
+
else if (!rewind) {
|
|
353
|
+
jump.before = jump.before ? mergePlace(jump.before, place) : place;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else if (!place.move && (jump.place || (!rewind && this.depths.has(place.depth)))) {
|
|
357
|
+
// At a depth taken by then, as frame by frame: let be.
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
else if (!place.move) {
|
|
361
|
+
// Anew: the child starts from nothing, and from here.
|
|
362
|
+
jump.before = null;
|
|
363
|
+
jump.place = rewind ? asFirstPlaced(place) : place;
|
|
364
|
+
jump.frame = f;
|
|
365
|
+
jump.placed = true;
|
|
366
|
+
}
|
|
367
|
+
else if (jump.place) {
|
|
368
|
+
jump.place = mergePlace(jump.place, place);
|
|
369
|
+
}
|
|
370
|
+
else if (!rewind && this.depths.has(place.depth)) {
|
|
371
|
+
jump.place = place;
|
|
372
|
+
jump.frame = f;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
// Another character with the move flag where nothing is: as frame
|
|
376
|
+
// by frame, nothing is placed (`rewind-first`).
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
jumps.set(place.depth, jump);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// On a rewind, what the timeline placed after the target goes, but where
|
|
383
|
+
// the frames replayed end on a place without the move flag: that child
|
|
384
|
+
// stays and takes the place, as Flash keeps it (`same-depth` at the
|
|
385
|
+
// loop, `rewind-first`), a clip its character and a shape the place's
|
|
386
|
+
// (swap, `morph-shapes`), if it is the kind of object the place makes:
|
|
387
|
+
// a shape where the place makes a clip, or a clip where it makes a
|
|
388
|
+
// shape, goes, and the place makes it anew (`rewind-shape-clip`).
|
|
389
|
+
// Replayed from the first frame, a depth the
|
|
390
|
+
// frames left empty is empty. Whenever it was placed, a child whose
|
|
391
|
+
// ratio is not the one the frames replayed give goes too, to be made
|
|
392
|
+
// anew: authoring tools give each placement a ratio of its own, and
|
|
393
|
+
// Flash takes another ratio for another object, of every kind
|
|
394
|
+
// (`rewind-ratio`, `rewind-kinds`), where Ruffle compares it only for
|
|
395
|
+
// children placed after the target, and for morphs. In render order, as
|
|
396
|
+
// Ruffle removes.
|
|
397
|
+
const kept = new Set();
|
|
398
|
+
if (rewind) {
|
|
399
|
+
const avm1 = this.library.avm1;
|
|
400
|
+
for (const child of [...this.children]) {
|
|
401
|
+
const depth = child.depth;
|
|
402
|
+
if (depth === null) {
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
// In AVM1, what is at a script's depths stays, a timeline's clip swapped there
|
|
406
|
+
// too, and a script's clip at the timeline's goes (Ruffle's survives_rewind).
|
|
407
|
+
if (avm1) {
|
|
408
|
+
if (depth < 0 || depth >= AVM1_DEPTH_BIAS) {
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (child.placeFrame <= 0) {
|
|
412
|
+
this.removeAtDepth(depth);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else if (child.placeFrame <= 0) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
const jump = jumps.get(depth);
|
|
420
|
+
const id = jump?.place?.character ?? null;
|
|
421
|
+
if (!jump || (jump.place && jump.place.ratio !== child.ratio)) {
|
|
422
|
+
this.removeAtDepth(depth);
|
|
423
|
+
}
|
|
424
|
+
else if (child.placeFrame > target &&
|
|
425
|
+
jump.placed &&
|
|
426
|
+
madeAs(child, id === null ? undefined : this.library.characters.get(id)) &&
|
|
427
|
+
// An AVM1 clip of another character goes, to be made anew (Ruffle's survives_rewind).
|
|
428
|
+
!(this.library.avm1 && child instanceof MovieClip && child.character?.id !== id)) {
|
|
429
|
+
kept.add(depth);
|
|
430
|
+
}
|
|
431
|
+
else if (child.placeFrame > target) {
|
|
432
|
+
this.removeAtDepth(depth);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// On the frame before its children are made: one constructed now sees it there, as in Flash.
|
|
437
|
+
this.currentFrame = target;
|
|
438
|
+
// Every child the jump places is placed before any is made alive, as
|
|
439
|
+
// Flash places a goto's: a constructor finds the others placed, and a
|
|
440
|
+
// button's early frame makes those after it alive before its
|
|
441
|
+
// FRAME_CONSTRUCTED, which a parent's listener reads them in
|
|
442
|
+
// (`goto-place-first`).
|
|
443
|
+
const placed = [];
|
|
444
|
+
for (const [depth, jump] of jumps) {
|
|
445
|
+
const existing = this.depths.get(depth);
|
|
446
|
+
if (existing && kept.has(depth) && jump.place) {
|
|
447
|
+
const id = jump.place.character;
|
|
448
|
+
const character = id === null ? undefined : this.library.characters.get(id);
|
|
449
|
+
if (character) {
|
|
450
|
+
swap(existing, character);
|
|
451
|
+
}
|
|
452
|
+
existing.applyPlace(jump.place);
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (existing && jump.before) {
|
|
456
|
+
existing.applyPlace(jump.before);
|
|
457
|
+
}
|
|
458
|
+
if (!jump.place) {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
const character = jump.place.character === null ? null : this.library.characters.get(jump.place.character);
|
|
462
|
+
if (!character ||
|
|
463
|
+
character.type === "binary" ||
|
|
464
|
+
character.type === "font" ||
|
|
465
|
+
character.type === "fontCff" ||
|
|
466
|
+
character.type === "sound") {
|
|
467
|
+
existing?.applyPlace(jump.place);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
// Forward, the child stays for a place with the move flag, whatever
|
|
471
|
+
// character it names, as frame by frame; on a rewind it stays only
|
|
472
|
+
// for its own character, and another, however the frames between went,
|
|
473
|
+
// makes a new child (`place_object_replace_2`, and AVM1's
|
|
474
|
+
// `goto_rewind_movieclip_replace`). But an AVM1 clip a script took
|
|
475
|
+
// over, as swapDepths does both clips it moves, stays whatever its
|
|
476
|
+
// character, under its own name and where the script left it
|
|
477
|
+
// (`avm1-rewind-swapped`). Placed anew it is a new child.
|
|
478
|
+
if (rewind &&
|
|
479
|
+
existing instanceof MovieClip &&
|
|
480
|
+
this.library.avm1 &&
|
|
481
|
+
existing.transformed &&
|
|
482
|
+
existing.character !== character) {
|
|
483
|
+
existing.applyPlace({ ...jump.place, name: null });
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
const same = existing?.character === character;
|
|
487
|
+
if (existing && (rewind ? same : jump.place.move)) {
|
|
488
|
+
swap(existing, character);
|
|
489
|
+
existing.applyPlace(jump.place);
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
const child = displayFor(character, this.library, jump.place.hasImage);
|
|
493
|
+
child.applyPlace(jump.place);
|
|
494
|
+
child.metaData = jump.place.metaData;
|
|
495
|
+
child.placeFrame = jump.frame;
|
|
496
|
+
this.library.avm1?.placing(child, jump.place);
|
|
497
|
+
this.placeAtDepth(child, depth);
|
|
498
|
+
if (looping && this.library.constructLater) {
|
|
499
|
+
this.library.constructLater(child, character);
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
placed.push({ display: child, character });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (this.library.constructPlaced) {
|
|
506
|
+
this.library.constructPlaced(placed);
|
|
507
|
+
}
|
|
508
|
+
else if (this.library.avm1 && target !== from) {
|
|
509
|
+
// As playing would order them: the children placed before the frame
|
|
510
|
+
// run their first frames, then the frame's places and actions in tag
|
|
511
|
+
// order, a place's child its first frame, the actions queued (adl); a
|
|
512
|
+
// frame past the last queues none (Ruffle's run_goto).
|
|
513
|
+
const avm1 = this.library.avm1;
|
|
514
|
+
const made = new Set();
|
|
515
|
+
const make = (display, character) => {
|
|
516
|
+
made.add(display);
|
|
517
|
+
construct(display, character, this.library);
|
|
518
|
+
};
|
|
519
|
+
for (const { display, character } of placed) {
|
|
520
|
+
if (display.placeFrame < target) {
|
|
521
|
+
make(display, character);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (target === frame) {
|
|
525
|
+
avm1.entered(this, target);
|
|
526
|
+
for (const command of this.timeline.frames[target - 1] ?? []) {
|
|
527
|
+
if (command.type === "actions") {
|
|
528
|
+
avm1.actions(this, command.tag);
|
|
529
|
+
}
|
|
530
|
+
else if (command.type === "place") {
|
|
531
|
+
const child = this.depths.get(command.place.depth);
|
|
532
|
+
const at = placed.find((p) => p.display === child);
|
|
533
|
+
if (at && !made.has(at.display)) {
|
|
534
|
+
make(at.display, at.character);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
for (const { display, character } of placed) {
|
|
540
|
+
if (!made.has(display)) {
|
|
541
|
+
make(display, character);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
for (const { display, character } of placed) {
|
|
547
|
+
construct(display, character, this.library);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
// The frame it lands on plays its sounds, unless it is the one it was on.
|
|
551
|
+
if (target !== from) {
|
|
552
|
+
this.frameSounds(target);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
/** The first frame, as a clip runs it when it is made, its children placed and made alive; once. */
|
|
556
|
+
enterFirstFrame() {
|
|
557
|
+
this.placeFirstFrame();
|
|
558
|
+
// One at a time: a constructor that throws stops here, as its error stops the frame.
|
|
559
|
+
const outer = this.makingChildren;
|
|
560
|
+
this.makingChildren = true;
|
|
561
|
+
try {
|
|
562
|
+
for (let next = this.held.shift(); next; next = this.held.shift()) {
|
|
563
|
+
if (!next.display.object && next.display.parent === this) {
|
|
564
|
+
construct(next.display, next.character, this.library);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
finally {
|
|
569
|
+
this.makingChildren = outer;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
/** The first frame's children placed, to be made alive by enterFirstFrame; once. */
|
|
573
|
+
placeFirstFrame() {
|
|
574
|
+
if (this.currentFrame !== 0) {
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
this.currentFrame = 1;
|
|
578
|
+
this.runFrame(1, "held");
|
|
579
|
+
// What a goto places later, or a script adds, plays on at once: only these sit out with it.
|
|
580
|
+
if (this.fresh) {
|
|
581
|
+
for (const { display } of this.held) {
|
|
582
|
+
if (display instanceof MovieClip) {
|
|
583
|
+
display.fresh = true;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* On to the next frame, if it plays and has one. From the last frame it
|
|
590
|
+
* loops to the first as a goto, so what the first frame placed stays.
|
|
591
|
+
*/
|
|
592
|
+
advance() {
|
|
593
|
+
if (this.fresh) {
|
|
594
|
+
this.fresh = false;
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
// An AVM1 clip on its last frame that does not loop, one of a single
|
|
598
|
+
// frame or without an End tag, stops there, and the DoAction tags
|
|
599
|
+
// after its last ShowFrame run, once (Ruffle's determine_next_frame).
|
|
600
|
+
const avm1 = this.library.avm1;
|
|
601
|
+
if (avm1 &&
|
|
602
|
+
this.playing &&
|
|
603
|
+
this.currentFrame >= this.totalFrames &&
|
|
604
|
+
!(this.timeline.loops && this.totalFrames > 1)) {
|
|
605
|
+
this.playing = false;
|
|
606
|
+
for (const command of this.tailed ? [] : (this.timeline.tail ?? [])) {
|
|
607
|
+
if (command.type === "actions") {
|
|
608
|
+
avm1.actions(this, command.tag);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
this.tailed = true;
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
if (!this.playing || this.totalFrames <= 1) {
|
|
615
|
+
// A clip of one frame plays its stream for that frame only, as Ruffle stops it.
|
|
616
|
+
if (this.stream) {
|
|
617
|
+
this.library.sounds?.stopStream(this);
|
|
618
|
+
}
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (this.currentFrame >= this.totalFrames) {
|
|
622
|
+
if (this.timeline.loops) {
|
|
623
|
+
this.gotoFrame(1, true);
|
|
624
|
+
}
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
this.currentFrame++;
|
|
628
|
+
this.runFrame(this.currentFrame, "frame");
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* A rewind's place with what it leaves unsaid said: the transform, colour,
|
|
633
|
+
* ratio and the rest as a character first placed has them, as Ruffle's
|
|
634
|
+
* goto fills them in. The name and visibility are not among them: they
|
|
635
|
+
* stay as they were.
|
|
636
|
+
*/
|
|
637
|
+
function asFirstPlaced(place) {
|
|
638
|
+
return {
|
|
639
|
+
...place,
|
|
640
|
+
matrix: place.matrix ?? IDENTITY,
|
|
641
|
+
colorTransform: place.colorTransform ?? IDENTITY_COLOR,
|
|
642
|
+
ratio: place.ratio ?? 0,
|
|
643
|
+
blendMode: place.blendMode ?? 0,
|
|
644
|
+
// An empty FILTERLIST: a rewind clears what the frames after set.
|
|
645
|
+
filters: place.filters ?? NO_FILTER_BYTES,
|
|
646
|
+
cacheAsBitmap: place.cacheAsBitmap ?? false,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
/** `next` over `previous`: what the later place sets, and the rest as it was. */
|
|
650
|
+
function mergePlace(previous, next) {
|
|
651
|
+
return {
|
|
652
|
+
...previous,
|
|
653
|
+
character: next.character ?? previous.character,
|
|
654
|
+
matrix: next.matrix ?? previous.matrix,
|
|
655
|
+
colorTransform: next.colorTransform ?? previous.colorTransform,
|
|
656
|
+
ratio: next.ratio ?? previous.ratio,
|
|
657
|
+
name: next.name ?? previous.name,
|
|
658
|
+
clipDepth: next.clipDepth ?? previous.clipDepth,
|
|
659
|
+
className: next.className ?? previous.className,
|
|
660
|
+
blendMode: next.blendMode ?? previous.blendMode,
|
|
661
|
+
cacheAsBitmap: next.cacheAsBitmap ?? previous.cacheAsBitmap,
|
|
662
|
+
visible: next.visible ?? previous.visible,
|
|
663
|
+
opaqueBackground: next.opaqueBackground ?? previous.opaqueBackground,
|
|
664
|
+
filters: next.filters ?? previous.filters,
|
|
665
|
+
actions: next.actions ?? previous.actions,
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
/** The timeline depth AVM1's depths count from: a script's depths are from it, the timeline's below it. */
|
|
669
|
+
const AVM1_DEPTH_BIAS = 16384;
|
|
670
|
+
/** A timeline of one empty frame: a clip a script makes. */
|
|
671
|
+
export const EMPTY_TIMELINE = {
|
|
672
|
+
frames: [[]],
|
|
673
|
+
labels: [],
|
|
674
|
+
gotoLabels: [],
|
|
675
|
+
frameLabels: new Map(),
|
|
676
|
+
scenes: [{ name: "", frame: 1 }],
|
|
677
|
+
sounds: new Map(),
|
|
678
|
+
stream: null,
|
|
679
|
+
loops: true,
|
|
680
|
+
};
|