@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,471 @@
|
|
|
1
|
+
// A SWF's characters, and its timelines as frames of display commands:
|
|
2
|
+
// what the root and each sprite place, move and remove on each frame, and
|
|
3
|
+
// the frames' labels. Definitions are read once, at load, as the whole
|
|
4
|
+
// file is there.
|
|
5
|
+
import { isAs3, isBitmapTag, readActions, readBinaryData, readBitmap, readButton, readButtonSound, readCsmTextSettings, readEditText, readFont, readFont4, readFontAlignZones, readFontInfo, readFrameLabel, readMorphShape, readPlace, readRemove, readScalingGrid, readSceneData, readShape, readSound, readSoundStreamBlock, readSoundStreamHead, readSprite, readStartSound, readStaticText, tags, } from "../../format/index.js";
|
|
6
|
+
import { FontSet } from "../text/fonts.js";
|
|
7
|
+
import { boundsOf, shapeLayers } from "./shapes.js";
|
|
8
|
+
/** What Flash makes of a bitmap it cannot read. */
|
|
9
|
+
export const INVALID_PIXELS = {
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0,
|
|
12
|
+
transparent: false,
|
|
13
|
+
pixels: new Uint32Array(0),
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Shapes by their tag's bytes, shared by every SWF that defines one alike:
|
|
17
|
+
* a SWF loaded again, as each of a crowd of one creature may be, draws
|
|
18
|
+
* with the first's fills and lines, which the renderer keeps by shape,
|
|
19
|
+
* rather than building and holding its own. A shape filled with a bitmap
|
|
20
|
+
* keeps to its SWF, whose bitmap it is. Held weakly: one no library holds
|
|
21
|
+
* goes, and its entry after it.
|
|
22
|
+
*/
|
|
23
|
+
const sharedShapes = new Map();
|
|
24
|
+
const sharedGone = new FinalizationRegistry(({ hash, tag }) => {
|
|
25
|
+
const list = sharedShapes.get(hash)?.filter((entry) => entry.tag !== tag) ?? [];
|
|
26
|
+
if (list.length > 0) {
|
|
27
|
+
sharedShapes.set(hash, list);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
sharedShapes.delete(hash);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Bitmaps by their tag's bytes, as shapes are: a SWF loaded again reads
|
|
35
|
+
* the first's pixels rather than inflating its own and keeping them, its
|
|
36
|
+
* images decode once (images.ts), and its fills draw from one store and
|
|
37
|
+
* one texture of them (characterStore), as an animation a crowd of loads
|
|
38
|
+
* plays holds a copy of each frame's bitmap, not one a load. DefineBits
|
|
39
|
+
* keeps to its SWF, as it is read with that SWF's JPEGTables.
|
|
40
|
+
*/
|
|
41
|
+
const sharedBitmaps = new Map();
|
|
42
|
+
const bitmapsGone = new FinalizationRegistry(({ hash, tag }) => {
|
|
43
|
+
const list = sharedBitmaps.get(hash)?.filter((entry) => entry.tag !== tag) ?? [];
|
|
44
|
+
if (list.length > 0) {
|
|
45
|
+
sharedBitmaps.set(hash, list);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
sharedBitmaps.delete(hash);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* The largest bitmap tag shared, in bytes: each entry keeps a copy of its
|
|
53
|
+
* tag to tell it from another of the same hash, and hashes it at each read,
|
|
54
|
+
* which pays for a crowd of small ones, not for one large atlas.
|
|
55
|
+
*/
|
|
56
|
+
const SHARED_BITMAP_MOST = 1 << 20;
|
|
57
|
+
/** The bitmap tag `t` defines, the one a SWF read before defined alike where there is one. */
|
|
58
|
+
function sharedBitmap(bytes, t, tables) {
|
|
59
|
+
// A short header is a bitmap Flash refuses: read as invalid, never shared with a long one.
|
|
60
|
+
if (t.code === tags.DefineBits || !t.long || t.length > SHARED_BITMAP_MOST) {
|
|
61
|
+
return readBitmap(bytes, t, tables);
|
|
62
|
+
}
|
|
63
|
+
const tag = bytes.subarray(t.offset, t.offset + t.length);
|
|
64
|
+
const hash = sampledHash(t.code, tag);
|
|
65
|
+
for (const entry of sharedBitmaps.get(hash) ?? []) {
|
|
66
|
+
const definition = entry.definition.deref();
|
|
67
|
+
if (definition && sameBytes(entry.tag, tag)) {
|
|
68
|
+
return definition;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const definition = readBitmap(bytes, t, tables);
|
|
72
|
+
// An image's definition holds its bytes in the SWF's already; a lossless one only its pixels.
|
|
73
|
+
const own = definition.type === "image" ? tag : tag.slice();
|
|
74
|
+
const list = sharedBitmaps.get(hash) ?? [];
|
|
75
|
+
list.push({ tag: own, definition: new WeakRef(definition) });
|
|
76
|
+
sharedBitmaps.set(hash, list);
|
|
77
|
+
bitmapsGone.register(definition, { hash, tag: own });
|
|
78
|
+
return definition;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* FNV-1a over the tag's code, its length and up to 256 of its bytes, evenly
|
|
82
|
+
* apart: a match is told by comparing the bytes, so the hash need only
|
|
83
|
+
* spread the tags, and a large one costs no pass of its own.
|
|
84
|
+
*/
|
|
85
|
+
function sampledHash(code, tag) {
|
|
86
|
+
let hash = Math.imul(0x811c9dc5 ^ code, 0x01000193);
|
|
87
|
+
hash = Math.imul(hash ^ tag.length, 0x01000193);
|
|
88
|
+
const step = Math.max(1, Math.floor(tag.length / 256));
|
|
89
|
+
for (let i = 0; i < tag.length; i += step) {
|
|
90
|
+
hash = Math.imul(hash ^ tag[i], 0x01000193);
|
|
91
|
+
}
|
|
92
|
+
return hash >>> 0;
|
|
93
|
+
}
|
|
94
|
+
/** FNV-1a over the tag's code and bytes. */
|
|
95
|
+
function tagHash(code, tag) {
|
|
96
|
+
let hash = Math.imul(0x811c9dc5 ^ code, 0x01000193);
|
|
97
|
+
for (let i = 0; i < tag.length; i++) {
|
|
98
|
+
hash = Math.imul(hash ^ tag[i], 0x01000193);
|
|
99
|
+
}
|
|
100
|
+
return hash >>> 0;
|
|
101
|
+
}
|
|
102
|
+
function sameBytes(a, b) {
|
|
103
|
+
if (a.length !== b.length) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
for (let i = 0; i < a.length; i++) {
|
|
107
|
+
if (a[i] !== b[i]) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
/** The shape a DefineShape tag defines, as another SWF defined it alike if one did. */
|
|
114
|
+
function shapeOf(bytes, t, bitmap, version) {
|
|
115
|
+
const tag = bytes.subarray(t.offset, t.offset + t.length);
|
|
116
|
+
const hash = tagHash(t.code, tag);
|
|
117
|
+
for (const entry of sharedShapes.get(hash) ?? []) {
|
|
118
|
+
const shared = entry.shape.deref();
|
|
119
|
+
if (shared && sameBytes(entry.tag, tag)) {
|
|
120
|
+
return shared;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const shape = readShape(bytes, t.code, t.offset, t.length, version);
|
|
124
|
+
// Its bitmap fills' bitmaps as the SWF has them now, which defines them before the shapes that
|
|
125
|
+
// use them; a shape with any is the SWF's own, not shared.
|
|
126
|
+
// The parse is not kept: no function made here refers to it, so its records go.
|
|
127
|
+
const bitmaps = new Map();
|
|
128
|
+
const styles = [shape.fills];
|
|
129
|
+
for (const r of shape.records) {
|
|
130
|
+
if (r.type === "style" && r.styles) {
|
|
131
|
+
styles.push(r.styles.fills);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const fills of styles) {
|
|
135
|
+
for (const fill of fills) {
|
|
136
|
+
if (fill.type === "bitmap" && !bitmaps.has(fill.bitmap)) {
|
|
137
|
+
bitmaps.set(fill.bitmap, bitmap(fill.bitmap));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
let layers = null;
|
|
142
|
+
const character = {
|
|
143
|
+
type: "shape",
|
|
144
|
+
id: shape.id,
|
|
145
|
+
shape: boundsOf(shape),
|
|
146
|
+
// Drawn into layers when first asked for, from the tag: most of the shapes a large
|
|
147
|
+
// application's SWFs define are never shown, and their layers were most of its memory.
|
|
148
|
+
get layers() {
|
|
149
|
+
layers ??= shapeLayers(readShape(bytes, t.code, t.offset, t.length, version), (id) => bitmaps.get(id) ?? null);
|
|
150
|
+
return layers;
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
if (bitmaps.size === 0) {
|
|
154
|
+
const own = tag.slice();
|
|
155
|
+
const list = sharedShapes.get(hash) ?? [];
|
|
156
|
+
list.push({ tag: own, shape: new WeakRef(character) });
|
|
157
|
+
sharedShapes.set(hash, list);
|
|
158
|
+
sharedGone.register(character, { hash, tag: own });
|
|
159
|
+
}
|
|
160
|
+
return character;
|
|
161
|
+
}
|
|
162
|
+
function timelineOf(bytes, list, frameCount, library, jpeg, actions,
|
|
163
|
+
// The SWF's version, which its shapes' bitmap fills are read by.
|
|
164
|
+
version) {
|
|
165
|
+
const avm1 = actions !== null;
|
|
166
|
+
const frames = [[]];
|
|
167
|
+
const tagged = [];
|
|
168
|
+
const frameLabels = new Map();
|
|
169
|
+
const sounds = new Map();
|
|
170
|
+
let head = null;
|
|
171
|
+
const blocks = [];
|
|
172
|
+
const byFrame = new Map();
|
|
173
|
+
let scenes = null;
|
|
174
|
+
for (const t of list) {
|
|
175
|
+
const frame = frames[frames.length - 1];
|
|
176
|
+
switch (t.code) {
|
|
177
|
+
case tags.ShowFrame:
|
|
178
|
+
frames.push([]);
|
|
179
|
+
break;
|
|
180
|
+
case tags.PlaceObject:
|
|
181
|
+
case tags.PlaceObject2:
|
|
182
|
+
case tags.PlaceObject3:
|
|
183
|
+
case tags.PlaceObject4:
|
|
184
|
+
frame.push({ type: "place", place: readPlace(bytes, t, actions ?? undefined) });
|
|
185
|
+
break;
|
|
186
|
+
case tags.RemoveObject:
|
|
187
|
+
case tags.RemoveObject2:
|
|
188
|
+
frame.push({ type: "remove", depth: readRemove(bytes, t) });
|
|
189
|
+
break;
|
|
190
|
+
case tags.DoAction:
|
|
191
|
+
if (avm1 && t.length > 0) {
|
|
192
|
+
frame.push({ type: "actions", tag: t.offset });
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case tags.FrameLabel: {
|
|
196
|
+
const name = readFrameLabel(bytes, t);
|
|
197
|
+
tagged.push({ name, frame: frames.length });
|
|
198
|
+
// A frame may have aliases: gotos find every name, currentFrameLabel the first.
|
|
199
|
+
if (!frameLabels.has(frames.length)) {
|
|
200
|
+
frameLabels.set(frames.length, name);
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
case tags.StartSound:
|
|
205
|
+
case tags.StartSound2: {
|
|
206
|
+
const list = sounds.get(frames.length) ?? [];
|
|
207
|
+
list.push(readStartSound(bytes, t));
|
|
208
|
+
sounds.set(frames.length, list);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case tags.SoundStreamHead:
|
|
212
|
+
case tags.SoundStreamHead2:
|
|
213
|
+
head ??= readSoundStreamHead(bytes, t);
|
|
214
|
+
break;
|
|
215
|
+
case tags.SoundStreamBlock:
|
|
216
|
+
// A block before the head, or a second on a frame, has no place in the stream.
|
|
217
|
+
if (head && !byFrame.has(frames.length)) {
|
|
218
|
+
byFrame.set(frames.length, blocks.length);
|
|
219
|
+
blocks.push(readSoundStreamBlock(bytes, t, head.format));
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
case tags.DefineSceneAndFrameLabelData:
|
|
223
|
+
scenes = readSceneData(bytes, t);
|
|
224
|
+
break;
|
|
225
|
+
case tags.DefineShape:
|
|
226
|
+
case tags.DefineShape2:
|
|
227
|
+
case tags.DefineShape3:
|
|
228
|
+
case tags.DefineShape4: {
|
|
229
|
+
// Its bitmap fills' bitmaps, which a SWF defines before the shapes that use them.
|
|
230
|
+
const bitmap = (id) => {
|
|
231
|
+
const c = library.get(id);
|
|
232
|
+
return c?.type === "bitmap" ? c : null;
|
|
233
|
+
};
|
|
234
|
+
const shape = shapeOf(bytes, t, bitmap, version);
|
|
235
|
+
library.set(shape.id, shape);
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case tags.DefineMorphShape:
|
|
239
|
+
case tags.DefineMorphShape2: {
|
|
240
|
+
const morph = readMorphShape(bytes, t.code, t.offset, t.length, version);
|
|
241
|
+
library.set(morph.id, {
|
|
242
|
+
type: "morph",
|
|
243
|
+
id: morph.id,
|
|
244
|
+
morph,
|
|
245
|
+
blends: new Map(),
|
|
246
|
+
bitmap: (id) => {
|
|
247
|
+
const c = library.get(id);
|
|
248
|
+
return c?.type === "bitmap" ? c : null;
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case tags.DefineSprite: {
|
|
254
|
+
const sprite = readSprite(bytes, t);
|
|
255
|
+
library.set(sprite.id, {
|
|
256
|
+
type: "sprite",
|
|
257
|
+
id: sprite.id,
|
|
258
|
+
timeline: {
|
|
259
|
+
...timelineOf(bytes, sprite.tags, sprite.frameCount, library, jpeg, actions, version),
|
|
260
|
+
length: t.length - 4,
|
|
261
|
+
},
|
|
262
|
+
grid: null,
|
|
263
|
+
});
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
case tags.DefineButton:
|
|
267
|
+
case tags.DefineButton2: {
|
|
268
|
+
const button = readButton(bytes, t);
|
|
269
|
+
library.set(button.id, {
|
|
270
|
+
type: "button",
|
|
271
|
+
id: button.id,
|
|
272
|
+
records: button.records,
|
|
273
|
+
trackAsMenu: button.trackAsMenu,
|
|
274
|
+
sounds: null,
|
|
275
|
+
grid: null,
|
|
276
|
+
});
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
case tags.DefineButtonSound: {
|
|
280
|
+
const given = readButtonSound(bytes, t);
|
|
281
|
+
const button = library.get(given.id);
|
|
282
|
+
if (button?.type === "button") {
|
|
283
|
+
button.sounds = given.sounds;
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
case tags.DefineScalingGrid: {
|
|
288
|
+
const { id, grid } = readScalingGrid(bytes, t);
|
|
289
|
+
const symbol = library.get(id);
|
|
290
|
+
if (symbol?.type === "sprite" || symbol?.type === "button") {
|
|
291
|
+
symbol.grid = {
|
|
292
|
+
xMin: grid.xMin / 20,
|
|
293
|
+
yMin: grid.yMin / 20,
|
|
294
|
+
xMax: grid.xMax / 20,
|
|
295
|
+
yMax: grid.yMax / 20,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case tags.DefineFont:
|
|
301
|
+
case tags.DefineFont2:
|
|
302
|
+
case tags.DefineFont3: {
|
|
303
|
+
const font = readFont(bytes, t);
|
|
304
|
+
library.set(font.id, {
|
|
305
|
+
type: "font",
|
|
306
|
+
id: font.id,
|
|
307
|
+
name: font.name,
|
|
308
|
+
bold: font.bold,
|
|
309
|
+
italic: font.italic,
|
|
310
|
+
font,
|
|
311
|
+
});
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case tags.DefineFontInfo:
|
|
315
|
+
case tags.DefineFontInfo2: {
|
|
316
|
+
const info = readFontInfo(bytes, t);
|
|
317
|
+
const font = library.get(info.id);
|
|
318
|
+
if (font?.type === "font") {
|
|
319
|
+
font.name = font.font.name = info.name;
|
|
320
|
+
font.bold = font.font.bold = info.bold;
|
|
321
|
+
font.italic = font.font.italic = info.italic;
|
|
322
|
+
for (let i = 0; i < Math.min(info.codes.length, font.font.glyphs.length); i++) {
|
|
323
|
+
font.font.glyphs[i].code = info.codes[i];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case tags.DefineFontAlignZones: {
|
|
329
|
+
const { id, csmHint } = readFontAlignZones(bytes, t);
|
|
330
|
+
const font = library.get(id);
|
|
331
|
+
if (font?.type === "font") {
|
|
332
|
+
font.font.csmHint = csmHint;
|
|
333
|
+
}
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
case tags.CSMTextSettings: {
|
|
337
|
+
const csm = readCsmTextSettings(bytes, t);
|
|
338
|
+
const text = library.get(csm.id);
|
|
339
|
+
if (text?.type === "static" || text?.type === "text") {
|
|
340
|
+
text.csm = csm;
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case tags.DefineFont4: {
|
|
345
|
+
const font = readFont4(bytes, t);
|
|
346
|
+
library.set(font.id, {
|
|
347
|
+
type: "fontCff",
|
|
348
|
+
id: font.id,
|
|
349
|
+
name: font.name,
|
|
350
|
+
bold: font.bold,
|
|
351
|
+
italic: font.italic,
|
|
352
|
+
font,
|
|
353
|
+
});
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
case tags.DefineText:
|
|
357
|
+
case tags.DefineText2: {
|
|
358
|
+
const definition = readStaticText(bytes, t);
|
|
359
|
+
library.set(definition.id, { type: "static", id: definition.id, definition });
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
case tags.DefineEditText: {
|
|
363
|
+
const definition = readEditText(bytes, t);
|
|
364
|
+
const font = definition.fontId === null ? null : library.get(definition.fontId);
|
|
365
|
+
library.set(definition.id, {
|
|
366
|
+
type: "text",
|
|
367
|
+
id: definition.id,
|
|
368
|
+
definition,
|
|
369
|
+
font: font?.type === "font" ? font : null,
|
|
370
|
+
});
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
case tags.DefineBinaryData: {
|
|
374
|
+
const { id, data } = readBinaryData(bytes, t);
|
|
375
|
+
library.set(id, { type: "binary", id, data });
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
case tags.DefineSound: {
|
|
379
|
+
const definition = readSound(bytes, t);
|
|
380
|
+
library.set(definition.id, { type: "sound", id: definition.id, definition });
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
case tags.JPEGTables:
|
|
384
|
+
jpeg.tables = bytes.slice(t.offset, t.offset + t.length);
|
|
385
|
+
break;
|
|
386
|
+
default:
|
|
387
|
+
if (isBitmapTag(t.code)) {
|
|
388
|
+
const definition = sharedBitmap(bytes, t, jpeg.tables);
|
|
389
|
+
library.set(definition.id, {
|
|
390
|
+
type: "bitmap",
|
|
391
|
+
id: definition.id,
|
|
392
|
+
definition,
|
|
393
|
+
pixels: definition.type === "pixels"
|
|
394
|
+
? definition
|
|
395
|
+
: definition.type === "invalid"
|
|
396
|
+
? INVALID_PIXELS
|
|
397
|
+
: null,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// An AVM1 timeline has as many frames as its ShowFrame tags end, whatever
|
|
403
|
+
// its header says, as Flash plays and loops one (the corpus's
|
|
404
|
+
// looping_real_*): what follows the last places nothing, and its actions
|
|
405
|
+
// run with the last frame where the timeline loops, and once after it, as
|
|
406
|
+
// the clip stops there, where it does not (`tail`): a timeline of one
|
|
407
|
+
// frame, or without an End tag (adl, and the corpus's `looping_child_*`).
|
|
408
|
+
// An AS3 one has as many as its header says.
|
|
409
|
+
const loops = !avm1 || list.at(-1)?.code === tags.End;
|
|
410
|
+
let tail = [];
|
|
411
|
+
if (avm1) {
|
|
412
|
+
tail = frames.length > 1 ? frames[frames.length - 1].filter((c) => c.type === "actions") : [];
|
|
413
|
+
frames.length = Math.max(1, frames.length - 1);
|
|
414
|
+
if (loops && frames.length > 1) {
|
|
415
|
+
frames[frames.length - 1].push(...tail);
|
|
416
|
+
tail = [];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
frames.length = Math.max(1, Math.min(frames.length, frameCount || 1));
|
|
421
|
+
while (frames.length < (frameCount || 1)) {
|
|
422
|
+
frames.push([]);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
// Scene data counts frames from 0; a frame name from 1, as scripts do.
|
|
426
|
+
const named = (list) => list.map(({ frame, name }) => ({ name, frame: frame + 1 }));
|
|
427
|
+
// Scene data that names no scene is none, as Flash reads it; its first
|
|
428
|
+
// scene starts the timeline whatever frame it gives.
|
|
429
|
+
const data = scenes?.scenes.length ? scenes : null;
|
|
430
|
+
const labels = data ? named(data.labels).sort((a, b) => a.frame - b.frame) : tagged;
|
|
431
|
+
const sceneList = data ? named(data.scenes) : [{ name: "", frame: 1 }];
|
|
432
|
+
sceneList[0].frame = 1;
|
|
433
|
+
return {
|
|
434
|
+
frames,
|
|
435
|
+
labels,
|
|
436
|
+
gotoLabels: labels.length > 0 ? labels : tagged,
|
|
437
|
+
frameLabels,
|
|
438
|
+
scenes: sceneList,
|
|
439
|
+
sounds,
|
|
440
|
+
stream: head && blocks.length > 0 ? { head, blocks, byFrame } : null,
|
|
441
|
+
loops,
|
|
442
|
+
tail,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
/** The characters a SWF defines, and its root timeline. */
|
|
446
|
+
export function readLibrary(swf) {
|
|
447
|
+
const characters = new Map();
|
|
448
|
+
// An AVM1 SWF's action blocks, which its places' clip actions are among.
|
|
449
|
+
const actions = isAs3(swf) ? null : readActions(swf);
|
|
450
|
+
const root = timelineOf(swf.bytes, swf.tags, swf.frameCount, characters, { tables: null }, actions, swf.header.version);
|
|
451
|
+
const fonts = new FontSet();
|
|
452
|
+
for (const c of characters.values()) {
|
|
453
|
+
if (c.type === "font") {
|
|
454
|
+
fonts.add(c.font);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
characters,
|
|
459
|
+
root,
|
|
460
|
+
classes: new Map(),
|
|
461
|
+
construct: null,
|
|
462
|
+
constructLater: null,
|
|
463
|
+
constructPlaced: null,
|
|
464
|
+
uncaught: null,
|
|
465
|
+
removing: null,
|
|
466
|
+
fonts,
|
|
467
|
+
version: swf.header.version,
|
|
468
|
+
sounds: null,
|
|
469
|
+
actions,
|
|
470
|
+
};
|
|
471
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Caches kept as short lists of entries found by their values, the latest
|
|
2
|
+
// used last, rather than in maps by keys formatted from those values on
|
|
3
|
+
// every frame: the renderer's lines, gradients and device runs, and the
|
|
4
|
+
// slices of a set of layers. Each finds its entry in a loop of its own,
|
|
5
|
+
// comparing its fields with `same`, and keeps its list with these.
|
|
6
|
+
/** Whether two numbers are the same as a cache's key: NaN the same as NaN, as "NaN" was. */
|
|
7
|
+
export function same(x, y) {
|
|
8
|
+
return x === y || (Number.isNaN(x) && Number.isNaN(y));
|
|
9
|
+
}
|
|
10
|
+
/** Entry `i` of `list` moved to its end, as the latest used: the entry. */
|
|
11
|
+
export function moveLast(list, i) {
|
|
12
|
+
const entry = list[i];
|
|
13
|
+
for (let k = i; k < list.length - 1; k++) {
|
|
14
|
+
list[k] = list[k + 1];
|
|
15
|
+
}
|
|
16
|
+
list[list.length - 1] = entry;
|
|
17
|
+
return entry;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Room made in `list` for one more, where it holds `most` already: those
|
|
21
|
+
* `gone` dropped in place, then the least lately used, each `let go`.
|
|
22
|
+
*/
|
|
23
|
+
export function makeRoom(list, most, gone, letGo) {
|
|
24
|
+
if (list.length < most) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let kept = 0;
|
|
28
|
+
for (const entry of list) {
|
|
29
|
+
if (gone(entry)) {
|
|
30
|
+
letGo(entry);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
list[kept++] = entry;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
list.length = kept;
|
|
37
|
+
while (list.length >= most) {
|
|
38
|
+
letGo(list.shift());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { BUTTON, CLIP, OTHER } from "./displayobject.js";
|
|
2
|
+
/** The shortest list a container keeps for itself; a shorter one its parent's making walks again. */
|
|
3
|
+
const KEPT_WALK = 32;
|
|
4
|
+
/**
|
|
5
|
+
* Those the frame's walks visit at and under `root`, as WalkList lays them
|
|
6
|
+
* out: kept on each container till a clip or a container comes or goes
|
|
7
|
+
* under it (Container.relist), so that a frame visits the clips alone,
|
|
8
|
+
* where its walks visited every object with children, twice or more.
|
|
9
|
+
* Made again in the arrays it had, as a busy movie's are made again every
|
|
10
|
+
* frame, some ten thousand objects long.
|
|
11
|
+
*/
|
|
12
|
+
export function walkList(root) {
|
|
13
|
+
let list = root.walk;
|
|
14
|
+
if (list?.current) {
|
|
15
|
+
return list;
|
|
16
|
+
}
|
|
17
|
+
list ??= { items: [], ends: [], current: false };
|
|
18
|
+
const length = listInto(root, list, 0, false);
|
|
19
|
+
// Cut to length, which keeps the arrays' room unless far shorter: a length of 0 would not.
|
|
20
|
+
list.items.length = length;
|
|
21
|
+
list.ends.length = length;
|
|
22
|
+
list.current = true;
|
|
23
|
+
root.walk = list;
|
|
24
|
+
return list;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `c` and those under it written to `list` from index `at`, each
|
|
28
|
+
* container's kept list copied where it has one; `c`'s own kept too where
|
|
29
|
+
* `keep`, and long enough. Returns the index after the last written.
|
|
30
|
+
*/
|
|
31
|
+
function listInto(c, list, at, keep = true) {
|
|
32
|
+
// AS3 sees a loaded AVM1 movie as one opaque object; its VM owns the frame walk.
|
|
33
|
+
if (c.avm1Root) {
|
|
34
|
+
return at;
|
|
35
|
+
}
|
|
36
|
+
const { items, ends } = list;
|
|
37
|
+
const start = at;
|
|
38
|
+
let n = at;
|
|
39
|
+
if (c.kind === CLIP) {
|
|
40
|
+
items[n] = c;
|
|
41
|
+
ends[n++] = 0;
|
|
42
|
+
}
|
|
43
|
+
const children = c.children;
|
|
44
|
+
for (let i = 0; i < children.length; i++) {
|
|
45
|
+
const child = children[i];
|
|
46
|
+
if (child.kind === BUTTON) {
|
|
47
|
+
items[n] = child;
|
|
48
|
+
ends[n] = n + 1;
|
|
49
|
+
n++;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (child.kind === OTHER && child.frameChildren.length === 0) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const kept = child.walk;
|
|
56
|
+
if (!kept?.current) {
|
|
57
|
+
n = listInto(child, list, n);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const base = n;
|
|
61
|
+
const keptItems = kept.items;
|
|
62
|
+
const keptEnds = kept.ends;
|
|
63
|
+
for (let k = 0; k < keptItems.length; k++) {
|
|
64
|
+
items[n] = keptItems[k];
|
|
65
|
+
ends[n++] = keptEnds[k] + base;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (c.kind === CLIP) {
|
|
69
|
+
ends[start] = n;
|
|
70
|
+
}
|
|
71
|
+
// Long enough, kept for the next list made above it, which then copies it.
|
|
72
|
+
const length = n - start;
|
|
73
|
+
if (keep && length >= KEPT_WALK) {
|
|
74
|
+
let own = c.walk;
|
|
75
|
+
if (!own) {
|
|
76
|
+
own = { items: [], ends: [], current: false };
|
|
77
|
+
c.walk = own;
|
|
78
|
+
}
|
|
79
|
+
const ownItems = own.items;
|
|
80
|
+
const ownEnds = own.ends;
|
|
81
|
+
for (let k = 0; k < length; k++) {
|
|
82
|
+
ownItems[k] = items[start + k];
|
|
83
|
+
ownEnds[k] = ends[start + k] - start;
|
|
84
|
+
}
|
|
85
|
+
ownItems.length = length;
|
|
86
|
+
ownEnds.length = length;
|
|
87
|
+
own.current = true;
|
|
88
|
+
}
|
|
89
|
+
return n;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The display objects whose frame scripts a display object's run: those
|
|
93
|
+
* whose frames its frames run, but a button's first, in a SWF after 9, up,
|
|
94
|
+
* over, down, then hit test, as Flash runs them while the button is made.
|
|
95
|
+
*/
|
|
96
|
+
export function scriptChildren(d) {
|
|
97
|
+
if (d.kind === BUTTON && d.firstScripts) {
|
|
98
|
+
const b = d;
|
|
99
|
+
b.firstScripts = false;
|
|
100
|
+
return [b.upState, b.overState, b.downState, b.hitTestState].filter((o, i, all) => o !== null && all.indexOf(o) === i && !o.encloses(b));
|
|
101
|
+
}
|
|
102
|
+
return d.kind === BUTTON ? d.playingStates() : d.frameChildren;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A walk of a container's children in render order, for the timeline
|
|
106
|
+
* masks that clip each: a mask clips the children after it until one
|
|
107
|
+
* placed deeper than its clip depth; one a script put among them has no
|
|
108
|
+
* depth and ends nothing. A class, not a generator: the renderer walks
|
|
109
|
+
* every child each time a container's children change.
|
|
110
|
+
*/
|
|
111
|
+
export class Clips {
|
|
112
|
+
/** The masks open, outermost first. */
|
|
113
|
+
masks = [];
|
|
114
|
+
/** The next child: how many of `masks`, from the first, clip it; it clips those after it, if a mask. */
|
|
115
|
+
enter(child) {
|
|
116
|
+
const depth = child.depth;
|
|
117
|
+
const masks = this.masks;
|
|
118
|
+
while (depth !== null && masks.length > 0 && masks[masks.length - 1].clipDepth < depth) {
|
|
119
|
+
masks.pop();
|
|
120
|
+
}
|
|
121
|
+
const n = masks.length;
|
|
122
|
+
if (child.clipDepth > 0) {
|
|
123
|
+
masks.push(child);
|
|
124
|
+
}
|
|
125
|
+
return n;
|
|
126
|
+
}
|
|
127
|
+
}
|