@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,214 @@
|
|
|
1
|
+
// Text fields bound to AVM1 variables, as Ruffle's (https://github.com/
|
|
2
|
+
// ruffle-rs/ruffle) core/src/display_object/edit_text.rs
|
|
3
|
+
// (try_bind_text_field_variable, propagate_text_binding, set_variable) and
|
|
4
|
+
// display_object.rs (Avm1TextFieldBinding) have them: MIT OR Apache-2.0,
|
|
5
|
+
// Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors. A field's
|
|
6
|
+
// variable is a name, or a path and a name, from the clip the field is in.
|
|
7
|
+
// Where it names a display object's property, the field is bound: a set of
|
|
8
|
+
// the property shows in the field. A field's text set by a script sets the
|
|
9
|
+
// variable, wherever its path leads then. A field whose variable has no
|
|
10
|
+
// object yet waits, and is tried again as a display object is made whose
|
|
11
|
+
// name is a step of its path, the only kind that can give it one.
|
|
12
|
+
import { avm1 } from "../../runtime/index.js";
|
|
13
|
+
import { ButtonObject, CONTENT, MovieClip, TextObject, } from "../display/display.js";
|
|
14
|
+
import { htmlTextOf, setHtmlText, stateOf } from "./globals/TextField.js";
|
|
15
|
+
export class VariableBindings {
|
|
16
|
+
host;
|
|
17
|
+
/** The fields bound to each display object's properties, by the property's name. */
|
|
18
|
+
bound = new WeakMap();
|
|
19
|
+
/** What each bound field is bound to. */
|
|
20
|
+
boundTo = new WeakMap();
|
|
21
|
+
/** How many fields are bound, which a property set looks for none while there are none. */
|
|
22
|
+
count = 0;
|
|
23
|
+
/** The fields whose variable's object is not there yet, each with its path's steps in lower case. */
|
|
24
|
+
waiting = [];
|
|
25
|
+
/** The fields whose text their variable is taking. */
|
|
26
|
+
propagating = new Set();
|
|
27
|
+
constructor(host) {
|
|
28
|
+
this.host = host;
|
|
29
|
+
}
|
|
30
|
+
/** A field made: bound, taking its variable's value, or waiting. */
|
|
31
|
+
made(field) {
|
|
32
|
+
if (!this.bind(field, true)) {
|
|
33
|
+
this.wait(field);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** `d` made: the fields waiting with its name a step of their path tried again. */
|
|
37
|
+
retry(d) {
|
|
38
|
+
if (this.waiting.length === 0 || d.name === "") {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const name = d.name.toLowerCase();
|
|
42
|
+
this.waiting = this.waiting.filter((waiting) => !waiting.steps.has(name) || !this.bind(waiting.field, false));
|
|
43
|
+
}
|
|
44
|
+
/** `field` waiting for its variable's object; not one without a path, whose object is its parent. */
|
|
45
|
+
wait(field) {
|
|
46
|
+
const variable = stateOf(field).variable;
|
|
47
|
+
const separator = variable === null ? -1 : lastSeparator(variable);
|
|
48
|
+
if (variable === null || separator < 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const steps = variable.slice(0, separator).toLowerCase().split(/[.:/]/);
|
|
52
|
+
this.waiting.push({ field, steps: new Set(steps) });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A field's text changed by a script: the variable takes it, as HTML,
|
|
56
|
+
* its path resolved again; not again while it is taking it.
|
|
57
|
+
*/
|
|
58
|
+
textChanged(field) {
|
|
59
|
+
const variable = stateOf(field).variable;
|
|
60
|
+
const parent = parentOf(field);
|
|
61
|
+
if (variable === null || parent === null || this.propagating.has(field)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.propagating.add(field);
|
|
65
|
+
try {
|
|
66
|
+
this.host.inActivation(parent, (cx) => {
|
|
67
|
+
const found = variablePath(cx, parent, variable, this.host.version);
|
|
68
|
+
if (found !== null) {
|
|
69
|
+
avm1.set(found[0], found[1], htmlTextOf(field), this.host.version);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
this.propagating.delete(field);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A field's variable set: its binding cleared, its text its tag's again,
|
|
79
|
+
* and bound where it can be now. One that cannot does not wait, as in
|
|
80
|
+
* Ruffle's set_variable, which leaves it off the unbound list.
|
|
81
|
+
*/
|
|
82
|
+
variableChanged(field) {
|
|
83
|
+
this.unbindField(field);
|
|
84
|
+
field.model.setText(field.definition?.definition?.text ?? "");
|
|
85
|
+
field.invalidate(CONTENT);
|
|
86
|
+
field.fit();
|
|
87
|
+
this.bind(field, true);
|
|
88
|
+
}
|
|
89
|
+
/** A property of `d`'s AVM1 object set: the fields bound to it by the name show the value. */
|
|
90
|
+
propertyChanged(d, name, value, version) {
|
|
91
|
+
const list = this.count === 0 ? undefined : this.bound.get(d);
|
|
92
|
+
if (list === undefined) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const key = version > 6 ? name : avm1.fold(name);
|
|
96
|
+
for (const { field, name: bound } of [...list]) {
|
|
97
|
+
if ((version > 6 ? bound : avm1.fold(bound)) === key) {
|
|
98
|
+
setHtmlText(field, avm1.stringOf(value, version));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* `d` unloaded: a field no longer bound nor waiting, and the fields bound
|
|
104
|
+
* to `d`'s properties waiting again, for an object at its path.
|
|
105
|
+
*/
|
|
106
|
+
unloaded(d) {
|
|
107
|
+
if (d instanceof TextObject) {
|
|
108
|
+
this.unbindField(d);
|
|
109
|
+
}
|
|
110
|
+
const list = this.bound.get(d);
|
|
111
|
+
if (list !== undefined) {
|
|
112
|
+
this.bound.delete(d);
|
|
113
|
+
this.count -= list.length;
|
|
114
|
+
for (const { field } of list) {
|
|
115
|
+
this.boundTo.delete(field);
|
|
116
|
+
this.wait(field);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Bind a field to its variable: where `initial`, the field takes the
|
|
122
|
+
* variable's value, or, where it has none, a field with text gives it
|
|
123
|
+
* its text. Whether it is bound, which it is only to a display object's
|
|
124
|
+
* property; a field without a variable is as good as bound.
|
|
125
|
+
*/
|
|
126
|
+
bind(field, initial) {
|
|
127
|
+
const variable = stateOf(field).variable;
|
|
128
|
+
if (variable === null) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
const parent = parentOf(field);
|
|
132
|
+
if (parent === null) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
let bound = false;
|
|
136
|
+
const version = this.host.version;
|
|
137
|
+
this.host.inActivation(parent, (cx) => {
|
|
138
|
+
const found = variablePath(cx, parent, variable, version);
|
|
139
|
+
if (found === null) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const [object, name] = found;
|
|
143
|
+
if (initial) {
|
|
144
|
+
if (avm1.has(object, name, version)) {
|
|
145
|
+
setHtmlText(field, avm1.stringOf(avm1.get(object, name, version), version));
|
|
146
|
+
}
|
|
147
|
+
else if (field.model.text !== "") {
|
|
148
|
+
avm1.set(object, name, field.model.text, version);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const target = object.display?.target;
|
|
152
|
+
if (target !== undefined) {
|
|
153
|
+
let list = this.bound.get(target);
|
|
154
|
+
if (list === undefined) {
|
|
155
|
+
list = [];
|
|
156
|
+
this.bound.set(target, list);
|
|
157
|
+
}
|
|
158
|
+
list.push({ field, name });
|
|
159
|
+
this.count++;
|
|
160
|
+
this.boundTo.set(field, target);
|
|
161
|
+
bound = true;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return bound;
|
|
165
|
+
}
|
|
166
|
+
/** A field's binding cleared, and the field no longer waiting for one. */
|
|
167
|
+
unbindField(field) {
|
|
168
|
+
const target = this.boundTo.get(field);
|
|
169
|
+
if (target !== undefined) {
|
|
170
|
+
this.boundTo.delete(field);
|
|
171
|
+
const list = this.bound.get(target);
|
|
172
|
+
if (list !== undefined) {
|
|
173
|
+
const rest = list.filter((b) => b.field !== field);
|
|
174
|
+
this.count -= list.length - rest.length;
|
|
175
|
+
this.bound.set(target, rest);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const at = this.waiting.findIndex((waiting) => waiting.field === field);
|
|
179
|
+
if (at >= 0) {
|
|
180
|
+
this.waiting.splice(at, 1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** The clip a field's variable is resolved from: its parent, past any button. */
|
|
185
|
+
function parentOf(field) {
|
|
186
|
+
let parent = field.parent;
|
|
187
|
+
while (parent instanceof ButtonObject) {
|
|
188
|
+
parent = parent.parent;
|
|
189
|
+
}
|
|
190
|
+
return parent instanceof MovieClip && parent.avm1 !== null ? parent : null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* A variable's object and name: a path's object, up to its last `.` or
|
|
194
|
+
* `:`, resolved along the scope chain, and the name after it; a name
|
|
195
|
+
* alone is `parent`'s (Ruffle's resolve_variable_path).
|
|
196
|
+
*/
|
|
197
|
+
function variablePath(cx, parent, path, version) {
|
|
198
|
+
const separator = lastSeparator(path);
|
|
199
|
+
if (separator < 0) {
|
|
200
|
+
return parent.avm1 === null ? null : [parent.avm1, path];
|
|
201
|
+
}
|
|
202
|
+
const name = path.slice(separator + 1);
|
|
203
|
+
for (let s = cx.scope; s !== null; s = s.parent) {
|
|
204
|
+
const object = avm1.targetPath(cx, s.object, path.slice(0, separator), true, true, version);
|
|
205
|
+
if (object !== null) {
|
|
206
|
+
return [object, name];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
/** Where a variable's last `.` or `:` is, which ends its path; -1 for a name alone. */
|
|
212
|
+
function lastSeparator(variable) {
|
|
213
|
+
return Math.max(variable.lastIndexOf(":"), variable.lastIndexOf("."));
|
|
214
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Object.registerClass's classes: the constructor a symbol's clips are
|
|
2
|
+
// constructed as, bound by the symbol's export name for every SWF, and
|
|
3
|
+
// the name each was registered by, which SharedObject types objects by.
|
|
4
|
+
import { avm1 } from "../../runtime/index.js";
|
|
5
|
+
import { MovieClip } from "../display/display.js";
|
|
6
|
+
/** A symbol name as registerClass keys it, by a SWF of `version`: in its case from SWF 7. */
|
|
7
|
+
function classKey(name, version) {
|
|
8
|
+
return version > 6 ? name : avm1.fold(name);
|
|
9
|
+
}
|
|
10
|
+
/** The classes Object.registerClass bound, by symbol name. */
|
|
11
|
+
export class RegisteredClasses {
|
|
12
|
+
movie;
|
|
13
|
+
/**
|
|
14
|
+
* Object.registerClass's classes, by symbol name, one for every SWF:
|
|
15
|
+
* named in its case from SWF 7, folded up to SWF 6, by the code that
|
|
16
|
+
* registers and by the SWF of the clip it is looked up for (the
|
|
17
|
+
* corpus's register_class).
|
|
18
|
+
*/
|
|
19
|
+
registered = new Map();
|
|
20
|
+
/**
|
|
21
|
+
* The name each key was last registered by, in the case it was given,
|
|
22
|
+
* which AMF0 writes, and when: a constructor of two names is the later's.
|
|
23
|
+
*/
|
|
24
|
+
spelled = new Map();
|
|
25
|
+
registrations = 0;
|
|
26
|
+
constructor(movie) {
|
|
27
|
+
this.movie = movie;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The class Object.registerClass bound to `d`'s character's export name
|
|
31
|
+
* in its SWF, null for none.
|
|
32
|
+
*/
|
|
33
|
+
classOf(d) {
|
|
34
|
+
// A sprite's only: a button's symbol stays a Button (the corpus's register_class).
|
|
35
|
+
const id = d instanceof MovieClip ? d.character?.id : undefined;
|
|
36
|
+
const swf = this.movie.swfOf(d);
|
|
37
|
+
const name = id === undefined ? undefined : swf.exportNames.get(id);
|
|
38
|
+
return name === undefined ? null : (this.registered.get(classKey(name, swf.version)) ?? null);
|
|
39
|
+
}
|
|
40
|
+
/** The name Object.registerClass gave `constr`, as SharedObject's AMF0 types an object; null for none. */
|
|
41
|
+
registeredName(constr) {
|
|
42
|
+
if (!(constr instanceof avm1.Avm1Function)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
let found = null;
|
|
46
|
+
for (const [key, registered] of this.registered) {
|
|
47
|
+
const spelled = this.spelled.get(key) ?? { name: key, at: -1 };
|
|
48
|
+
if (registered === constr && (found === null || spelled.at > found.at)) {
|
|
49
|
+
found = spelled;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return found?.name ?? null;
|
|
53
|
+
}
|
|
54
|
+
/** Object.registerClass(name, constructor): true where it binds or unbinds (null) the name. */
|
|
55
|
+
registerClass(args, version) {
|
|
56
|
+
if (args.length < 2) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const constr = args[1];
|
|
60
|
+
if (constr !== undefined && constr !== null && !(constr instanceof avm1.Avm1Function)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const name = avm1.stringOf(args[0], version);
|
|
64
|
+
const key = classKey(name, version);
|
|
65
|
+
if (constr instanceof avm1.Avm1Function) {
|
|
66
|
+
this.registered.set(key, constr);
|
|
67
|
+
this.spelled.set(key, { name, at: this.registrations++ });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.registered.delete(key);
|
|
71
|
+
this.spelled.delete(key);
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// The display objects an AVM1 movie's scripts make and take away:
|
|
2
|
+
// attachMovie's, createEmptyMovieClip's, createTextField's and
|
|
3
|
+
// duplicateMovieClip's, each placed and made at once, constructed as its
|
|
4
|
+
// registered class with its init object's properties, and removeMovieClip's
|
|
5
|
+
// removal of what is at a depth scripts place at.
|
|
6
|
+
// The depths and the order of construction follow Ruffle's
|
|
7
|
+
// (https://github.com/ruffle-rs/ruffle) construct_as_avm1_object: MIT OR
|
|
8
|
+
// Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors.
|
|
9
|
+
import { ClipEvent } from "../../format/index.js";
|
|
10
|
+
import { avm1 } from "../../runtime/index.js";
|
|
11
|
+
import { Container, construct, displayFor, EMPTY_TIMELINE, MovieClip, TextObject, } from "../display/display.js";
|
|
12
|
+
import { ClipNative, DEPTH_BIAS, nativeOf } from "./globals/MovieClip.js";
|
|
13
|
+
import { asciiLower } from "./paths.js";
|
|
14
|
+
import { BLOCK, CONSTRUCT, NO_ARGS, Queued } from "./queue.js";
|
|
15
|
+
import { NO_HANDLERS } from "./swf.js";
|
|
16
|
+
/** The highest timeline depth scripts place at, 2^31 - 16777220, as Ruffle has it. */
|
|
17
|
+
const MAX_DEPTH = 2130706428;
|
|
18
|
+
/** The depth from which removeMovieClip removes nothing. */
|
|
19
|
+
const MAX_REMOVE_DEPTH = 2130706416;
|
|
20
|
+
/** The blocks of a clip's construct events. */
|
|
21
|
+
export function constructBlocks(native) {
|
|
22
|
+
const blocks = [];
|
|
23
|
+
for (const h of native.handlers ?? NO_HANDLERS) {
|
|
24
|
+
if (h.events & ClipEvent.construct) {
|
|
25
|
+
blocks.push(h.block);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return blocks;
|
|
29
|
+
}
|
|
30
|
+
/** Whether a character is one a timeline places. */
|
|
31
|
+
function isDisplayCharacter(c) {
|
|
32
|
+
const type = c?.type;
|
|
33
|
+
return (type === "sprite" ||
|
|
34
|
+
type === "shape" ||
|
|
35
|
+
type === "morph" ||
|
|
36
|
+
type === "button" ||
|
|
37
|
+
type === "text" ||
|
|
38
|
+
type === "static" ||
|
|
39
|
+
type === "bitmap");
|
|
40
|
+
}
|
|
41
|
+
/** What the movie's scripts place on and take off the display list. */
|
|
42
|
+
export class ScriptClips {
|
|
43
|
+
movie;
|
|
44
|
+
/** The display object a script is making, which it constructs itself; its children are the timeline's. */
|
|
45
|
+
scripted = null;
|
|
46
|
+
constructor(movie) {
|
|
47
|
+
this.movie = movie;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* attachMovie: the character exported as `name` placed in `parent` at
|
|
51
|
+
* AVM1 depth `depth` as `instance`, made as a script makes one; null
|
|
52
|
+
* where there is no such character or the depth is out of range.
|
|
53
|
+
*/
|
|
54
|
+
attachMovie(parent, name, instance, depth, init) {
|
|
55
|
+
const timelineDepth = (depth + DEPTH_BIAS) | 0;
|
|
56
|
+
if (timelineDepth < 0 || timelineDepth > MAX_DEPTH) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const swf = this.movie.swfOf(parent);
|
|
60
|
+
const id = swf.exports.get(asciiLower(name));
|
|
61
|
+
const character = id === undefined ? undefined : swf.library?.characters.get(id);
|
|
62
|
+
if (!isDisplayCharacter(character)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const child = displayFor(character, parent.library);
|
|
66
|
+
return this.scriptPlace(parent, child, character, instance, timelineDepth, init);
|
|
67
|
+
}
|
|
68
|
+
/** createEmptyMovieClip: an empty clip in `parent` at AVM1 depth `depth` as `instance`. */
|
|
69
|
+
createEmptyMovieClip(parent, instance, depth) {
|
|
70
|
+
const child = new MovieClip(EMPTY_TIMELINE, parent.library);
|
|
71
|
+
return this.scriptPlace(parent, child, null, instance, (depth + DEPTH_BIAS) | 0, null);
|
|
72
|
+
}
|
|
73
|
+
/** createTextField: an empty field in `parent` at AVM1 depth `depth` as `instance`. */
|
|
74
|
+
createTextField(parent, instance, depth, [x, y, width, height]) {
|
|
75
|
+
const field = new TextObject(null);
|
|
76
|
+
field.fonts = parent.library.fonts;
|
|
77
|
+
field.width = width;
|
|
78
|
+
field.height = height;
|
|
79
|
+
field.matrix = { ...field.matrix, tx: x, ty: y };
|
|
80
|
+
return this.scriptPlace(parent, field, null, instance, (depth + DEPTH_BIAS) | 0, null);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* duplicateMovieClip and CloneSprite: a new one of `d`'s character, or an
|
|
84
|
+
* empty clip for a script's, beside it at timeline depth `depth` as
|
|
85
|
+
* `name`, with its matrix, colour and clip actions; null where `d` has
|
|
86
|
+
* no clip for a parent or the depth is out of range.
|
|
87
|
+
*/
|
|
88
|
+
duplicate(d, name, depth, init) {
|
|
89
|
+
const parent = this.movie.levelOf(d) !== null ? null : d.parent;
|
|
90
|
+
if (!(parent instanceof MovieClip) || this.movie.removed(d) || depth < 0 || depth > MAX_DEPTH) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const character = d.character;
|
|
94
|
+
let child;
|
|
95
|
+
if (isDisplayCharacter(character)) {
|
|
96
|
+
child = displayFor(character, parent.library);
|
|
97
|
+
}
|
|
98
|
+
else if (d instanceof MovieClip) {
|
|
99
|
+
child = new MovieClip(EMPTY_TIMELINE, parent.library);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
child.matrix = { ...d.matrix };
|
|
105
|
+
child.colorTransform = d.colorTransform === null ? null : { ...d.colorTransform };
|
|
106
|
+
const native = nativeOf(d);
|
|
107
|
+
if (native !== null && native.handlers !== null) {
|
|
108
|
+
this.handed.set(child, native);
|
|
109
|
+
}
|
|
110
|
+
return this.scriptPlace(parent, child, isDisplayCharacter(character) ? character : null, name, depth, init);
|
|
111
|
+
}
|
|
112
|
+
/** The clips a duplicate takes the clip actions of, until it is made. */
|
|
113
|
+
handed = new WeakMap();
|
|
114
|
+
/**
|
|
115
|
+
* removeMovieClip and RemoveSprite: `d` removed, where it is at a depth
|
|
116
|
+
* scripts place at (a timeline's clip swapped there too), as Flash
|
|
117
|
+
* removes only those.
|
|
118
|
+
*/
|
|
119
|
+
remove(d) {
|
|
120
|
+
const parent = this.movie.levelOf(d) !== null ? null : d.parent;
|
|
121
|
+
const depth = d.depth;
|
|
122
|
+
if (!(parent instanceof Container) ||
|
|
123
|
+
depth === null ||
|
|
124
|
+
depth < DEPTH_BIAS ||
|
|
125
|
+
depth >= MAX_REMOVE_DEPTH ||
|
|
126
|
+
this.movie.removed(d)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
parent.removeAtDepth(depth);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A display object a script made, put in `parent` at timeline depth
|
|
133
|
+
* `depth` as `name` and made: its first frame entered, its children
|
|
134
|
+
* placed, its load queued; then its construct events, its init
|
|
135
|
+
* object's properties, before them up to SWF 6, its class's constructor
|
|
136
|
+
* and its onConstruct at once, its initialize events queued as it was
|
|
137
|
+
* made (adl:
|
|
138
|
+
* Ruffle runs neither event, and onConstruct only for
|
|
139
|
+
* createEmptyMovieClip's).
|
|
140
|
+
*/
|
|
141
|
+
scriptPlace(parent, child, character, name, depth, init) {
|
|
142
|
+
child.name = name;
|
|
143
|
+
parent.placeAtDepth(child, depth);
|
|
144
|
+
const outer = this.scripted;
|
|
145
|
+
this.scripted = child;
|
|
146
|
+
try {
|
|
147
|
+
if (character !== null) {
|
|
148
|
+
construct(child, character, parent.library);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.movie.made(child);
|
|
152
|
+
if (child instanceof MovieClip) {
|
|
153
|
+
child.enterFirstFrame();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
this.scripted = outer;
|
|
159
|
+
}
|
|
160
|
+
const face = child.avm1;
|
|
161
|
+
const native = face?.display;
|
|
162
|
+
if (face === null || !(native instanceof ClipNative)) {
|
|
163
|
+
return child;
|
|
164
|
+
}
|
|
165
|
+
const version = this.movie.swfOf(child).version;
|
|
166
|
+
const constr = this.movie.classes.classOf(child);
|
|
167
|
+
if (constr !== null) {
|
|
168
|
+
face.define("__proto__", avm1.get(constr, "prototype", version), avm1.DONT_ENUM | avm1.DONT_DELETE);
|
|
169
|
+
}
|
|
170
|
+
// It is constructed as the queue's constructions are: a function returning in it
|
|
171
|
+
// runs only initializations queued (the corpus's register_and_init_order).
|
|
172
|
+
const pass = this.movie.queue.priority;
|
|
173
|
+
this.movie.queue.priority = CONSTRUCT;
|
|
174
|
+
try {
|
|
175
|
+
// A SWF 6 sets the init object's properties before the construct events, a later one
|
|
176
|
+
// after (adl).
|
|
177
|
+
if (version <= 6) {
|
|
178
|
+
this.initProperties(face, init, version);
|
|
179
|
+
}
|
|
180
|
+
for (const block of constructBlocks(native)) {
|
|
181
|
+
this.movie.queue.runOne(new Queued(BLOCK, child, native.swf, block), []);
|
|
182
|
+
}
|
|
183
|
+
if (version > 6) {
|
|
184
|
+
this.initProperties(face, init, version);
|
|
185
|
+
}
|
|
186
|
+
if (constr !== null) {
|
|
187
|
+
this.construct(child, face, constr);
|
|
188
|
+
}
|
|
189
|
+
// Then its onConstruct, from MovieClip's prototype or its class's, what it
|
|
190
|
+
// throws caught there (adl, and the corpus's movieclip_onconstruct).
|
|
191
|
+
const cx = this.movie.activationOf(child);
|
|
192
|
+
if (cx !== null) {
|
|
193
|
+
this.movie.rt.callMethod(cx, face, "onConstruct", NO_ARGS, version);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
this.movie.queue.priority = pass;
|
|
198
|
+
}
|
|
199
|
+
return child;
|
|
200
|
+
}
|
|
201
|
+
/** An init object's properties set on `face`, in the reverse of for..in's order, as Flash sets them. */
|
|
202
|
+
initProperties(face, init, version) {
|
|
203
|
+
const cx = init === null ? null : this.movie.activationOf(this.movie.root);
|
|
204
|
+
if (init === null || cx === null) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this.movie.rt.call(cx, () => {
|
|
208
|
+
const names = avm1.keys(init, version);
|
|
209
|
+
for (let i = names.length - 1; i >= 0; i--) {
|
|
210
|
+
avm1.set(face, names[i], avm1.get(init, names[i], version), version);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/** `constr` run on the clip's object as its constructor, as `new` runs one. */
|
|
215
|
+
construct(clip, face, constr) {
|
|
216
|
+
const cx = this.movie.activationOf(clip);
|
|
217
|
+
if (cx === null) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const version = this.movie.swfOf(clip).version;
|
|
221
|
+
face.define("__constructor__", constr, avm1.DONT_ENUM);
|
|
222
|
+
if (version < 7) {
|
|
223
|
+
face.define("constructor", constr, avm1.DONT_ENUM);
|
|
224
|
+
}
|
|
225
|
+
this.movie.rt.call(cx, () => {
|
|
226
|
+
constr.callConstructor(face, NO_ARGS, version, 1);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { avm1 } from "../../runtime/index.js";
|
|
2
|
+
import { evaluateFunction } from "../scripting/evaluate.js";
|
|
3
|
+
let scripts = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Stable region arrays let the runtime and ExternalInterface identify a
|
|
6
|
+
* block before it is compiled; its functions keep that same array after.
|
|
7
|
+
*/
|
|
8
|
+
export function lazyBlocks(codegen, bytes, actions, rt) {
|
|
9
|
+
const script = ++scripts;
|
|
10
|
+
const version = actions.version;
|
|
11
|
+
const evaluate = (entry, name) => {
|
|
12
|
+
// AVM1 identifies its callers by region arrays, including on engines
|
|
13
|
+
// whose Function stack frames do not name their sourceURL.
|
|
14
|
+
const source = `export default function (rt) {\nconst V = rt.version(${version});\n${version < 5 ? "const V5 = rt.version(5);\n" : ""}return [\n${entry}\n];\n}\n`;
|
|
15
|
+
const factory = evaluateFunction(source, `swf2es-avm1-${script}-${name}.js`);
|
|
16
|
+
return factory(rt)[0];
|
|
17
|
+
};
|
|
18
|
+
const blocks = actions.blocks.map((_, index) => {
|
|
19
|
+
const regions = [];
|
|
20
|
+
regions.push((cx) => {
|
|
21
|
+
const entry = codegen.compileActionBlocks(bytes, actions, [index]).get(index);
|
|
22
|
+
if (entry === undefined) {
|
|
23
|
+
throw new Error(`swf2es: no compiled AVM1 block ${index}`);
|
|
24
|
+
}
|
|
25
|
+
const compiled = evaluate(entry, `${index}`);
|
|
26
|
+
regions.length = 0;
|
|
27
|
+
for (const region of compiled) {
|
|
28
|
+
regions.push(region);
|
|
29
|
+
}
|
|
30
|
+
return regions[0](cx);
|
|
31
|
+
});
|
|
32
|
+
return regions;
|
|
33
|
+
});
|
|
34
|
+
const units = unitsOf(codegen, bytes, actions, blocks, rt.realm.units, evaluate);
|
|
35
|
+
for (const regions of blocks) {
|
|
36
|
+
rt.realm.units.set(regions, units);
|
|
37
|
+
}
|
|
38
|
+
return blocks;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A SWF's units, each compiled as control first goes on in it: first the
|
|
42
|
+
* one of a region and bytes that end at the next bound of a block, which
|
|
43
|
+
* most regions can run, else the region's own (codegen's module.ts).
|
|
44
|
+
*/
|
|
45
|
+
function unitsOf(codegen, bytes, actions, blocks, known, evaluate) {
|
|
46
|
+
const bounds = blockBounds(bytes.length, actions);
|
|
47
|
+
// By offset, twice and once more for SWF 5's functions; by key, those of a region alone.
|
|
48
|
+
const first = new Map();
|
|
49
|
+
const own = new avm1.OwnUnits();
|
|
50
|
+
// Units of the same code are one, as the module writes them once: by
|
|
51
|
+
// the code's hash and length, the code itself not kept.
|
|
52
|
+
const byCode = new Map();
|
|
53
|
+
const units = {
|
|
54
|
+
blocks,
|
|
55
|
+
unit(at, end, bound, five) {
|
|
56
|
+
const index = at * 2 + (five ? 1 : 0);
|
|
57
|
+
let unit = first.get(index);
|
|
58
|
+
if (unit === undefined) {
|
|
59
|
+
const segment = segmentEnd(bounds, bytes.length, at);
|
|
60
|
+
const compiled = codegen.compileActionUnit(bytes, actions, {
|
|
61
|
+
at,
|
|
62
|
+
end: segment,
|
|
63
|
+
bound: segment,
|
|
64
|
+
five,
|
|
65
|
+
});
|
|
66
|
+
// One that only its own region runs never runs as a first choice.
|
|
67
|
+
unit = { ...compiled, code: compiled.high >= 0 ? compiled.code : null, regions: null };
|
|
68
|
+
first.set(index, unit);
|
|
69
|
+
}
|
|
70
|
+
if (unit.high >= 0 && unit.high <= end && unit.reach <= bound) {
|
|
71
|
+
if (unit.regions === null) {
|
|
72
|
+
unit.regions = regionsOf(unit.code ?? "", at);
|
|
73
|
+
unit.code = null;
|
|
74
|
+
}
|
|
75
|
+
return unit.regions;
|
|
76
|
+
}
|
|
77
|
+
let regions = own.get(at, end, bound, five);
|
|
78
|
+
if (regions === undefined) {
|
|
79
|
+
const { code } = codegen.compileActionUnit(bytes, actions, { at, end, bound, five });
|
|
80
|
+
regions = regionsOf(code, at);
|
|
81
|
+
own.set(at, end, bound, five, regions);
|
|
82
|
+
}
|
|
83
|
+
return regions;
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
const regionsOf = (code, at) => {
|
|
87
|
+
const hash = hashOf(code);
|
|
88
|
+
const same = byCode.get(hash);
|
|
89
|
+
for (const regions of same ?? []) {
|
|
90
|
+
// The regions' source is the code they were made of.
|
|
91
|
+
if (`[${regions.join(", ")}]` === code) {
|
|
92
|
+
return regions;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const regions = evaluate(code, `at-${at}`);
|
|
96
|
+
known.set(regions, units);
|
|
97
|
+
if (same === undefined) {
|
|
98
|
+
byCode.set(hash, [regions]);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
same.push(regions);
|
|
102
|
+
}
|
|
103
|
+
return regions;
|
|
104
|
+
};
|
|
105
|
+
return units;
|
|
106
|
+
}
|
|
107
|
+
/** FNV-1a of `text`'s code units, and its length. */
|
|
108
|
+
function hashOf(text) {
|
|
109
|
+
let hash = 0x811c9dc5;
|
|
110
|
+
for (let i = 0; i < text.length; i++) {
|
|
111
|
+
hash = Math.imul(hash ^ text.charCodeAt(i), 0x01000193);
|
|
112
|
+
}
|
|
113
|
+
return (hash >>> 0) * 0x100000 + (text.length & 0xfffff);
|
|
114
|
+
}
|
|
115
|
+
/** The starts and ends of the SWF's blocks within its bytes, ascending, once each. */
|
|
116
|
+
function blockBounds(size, actions) {
|
|
117
|
+
const bounds = new Set();
|
|
118
|
+
for (const { offset, length } of actions.blocks) {
|
|
119
|
+
if (offset >= 0 && length >= 0 && offset + length <= size) {
|
|
120
|
+
bounds.add(offset);
|
|
121
|
+
bounds.add(offset + length);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return [...bounds].sort((a, b) => a - b);
|
|
125
|
+
}
|
|
126
|
+
/** The first of `bounds` past `at`, else the SWF's end, as codegen's units.ts finds it. */
|
|
127
|
+
function segmentEnd(bounds, size, at) {
|
|
128
|
+
let low = 0;
|
|
129
|
+
let high = bounds.length;
|
|
130
|
+
while (low < high) {
|
|
131
|
+
const mid = (low + high) >>> 1;
|
|
132
|
+
if (bounds[mid] <= at) {
|
|
133
|
+
low = mid + 1;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
high = mid;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return low < bounds.length ? bounds[low] : size;
|
|
140
|
+
}
|