@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,896 @@
|
|
|
1
|
+
// AVM1's objects and their properties, as Ruffle's
|
|
2
|
+
// (https://github.com/ruffle-rs/ruffle) core/src/avm1/property.rs,
|
|
3
|
+
// property_map.rs, object.rs and object/script_object.rs have them: MIT OR
|
|
4
|
+
// Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors.
|
|
5
|
+
// Where adl parts from Ruffle, adl decides (docs/avm1.md, "Objects").
|
|
6
|
+
//
|
|
7
|
+
// An object keeps its properties in a Map by their exact names, in the
|
|
8
|
+
// order they were added, which is Flash's order of enumeration reversed.
|
|
9
|
+
// A SWF up to 6 finds names whatever their case: it asks the exact name
|
|
10
|
+
// first, as code mostly spells a name one way, then the name folded to
|
|
11
|
+
// lower case, and else an index of the names folding changes, which an
|
|
12
|
+
// object builds the first time such a lookup misses and keeps from then
|
|
13
|
+
// on: none while all its names are lower case. A SWF from 7 never needs it.
|
|
14
|
+
// `__proto__` is a property like any other, which the object also keeps
|
|
15
|
+
// at hand for the walks up its prototypes.
|
|
16
|
+
//
|
|
17
|
+
// An array keeps its elements apart, by index in a JavaScript array, while
|
|
18
|
+
// they are 0 to n - 1 each there, as arrays mostly are: a read or write of
|
|
19
|
+
// an element by its number, and Array's methods, then need no Map and no
|
|
20
|
+
// name. A hole, an element deleted from the middle or set past the end,
|
|
21
|
+
// moves them all into the Map. Each property has its sequence number, the
|
|
22
|
+
// order of its adding, which for..in lists in, elements among the rest.
|
|
23
|
+
import { lowerCase } from "./case.js";
|
|
24
|
+
import { Avm1Throw } from "./errors.js";
|
|
25
|
+
import { ABSENT } from "./host.js";
|
|
26
|
+
import { stringOf, toNumber } from "./values.js";
|
|
27
|
+
/** Not listed by for..in. */
|
|
28
|
+
export const DONT_ENUM = 1;
|
|
29
|
+
/** Not removed by delete. */
|
|
30
|
+
export const DONT_DELETE = 2;
|
|
31
|
+
/** Not changed by a set. */
|
|
32
|
+
export const READ_ONLY = 4;
|
|
33
|
+
/** The bits from 0x8 up, which hide a property from SWFs before a version (ASSetPropFlags). */
|
|
34
|
+
export const VERSION_BITS = 0xfff8;
|
|
35
|
+
export const VERSION_6 = 0x80;
|
|
36
|
+
// 0x400 alone hides a property from SWF 5 and 6, and leaves it to hasOwnProperty,
|
|
37
|
+
// which 0x100 would hide it from (adl, the corpus's global_proto_decls).
|
|
38
|
+
export const VERSION_7 = 0x400;
|
|
39
|
+
export const VERSION_8 = 0x1000;
|
|
40
|
+
export const VERSION_9 = 0x2000;
|
|
41
|
+
export const VERSION_10 = 0x4000;
|
|
42
|
+
/** By version, the bits that hide a property from it (Ruffle's VERSION_MASKS); none from 10. */
|
|
43
|
+
const HIDING = [0x7ff8, 0x7ff8, 0x7ff8, 0x7ff8, 0x7ff8, 0x7480, 0x7500, 0x7000, 0x6000, 0x4000];
|
|
44
|
+
/** Whether a property of `flags` is there for a SWF of `version`. */
|
|
45
|
+
export const allowed = (flags, version) => version >= 10 || (flags & HIDING[version < 0 ? 0 : version]) === 0;
|
|
46
|
+
/** Whether a SWF of `version` finds names in their case: from 7. */
|
|
47
|
+
export const caseSensitive = (version) => version > 6;
|
|
48
|
+
/** The code units folding may change. */
|
|
49
|
+
const FOLDED = /[A-Z\u0080-\uffff]/g;
|
|
50
|
+
/** Names folded by Flash's lower case, once each, as the same names come back. */
|
|
51
|
+
const foldCache = new Map();
|
|
52
|
+
/**
|
|
53
|
+
* A name as a SWF up to 6 compares it: each code unit folded to Flash's
|
|
54
|
+
* lower case (`case.ts`), which is not JavaScript's: `ΑΣ` and `ασ`
|
|
55
|
+
* are one name, `İ` and `i` too, `ẞ` and `ß` are not.
|
|
56
|
+
*/
|
|
57
|
+
export function fold(name) {
|
|
58
|
+
let i = 0;
|
|
59
|
+
for (; i < name.length; i++) {
|
|
60
|
+
const c = name.charCodeAt(i);
|
|
61
|
+
if ((c >= 0x41 && c <= 0x5a) || c >= 0x80) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (i === name.length) {
|
|
66
|
+
return name;
|
|
67
|
+
}
|
|
68
|
+
let folded = foldCache.get(name);
|
|
69
|
+
if (folded === undefined) {
|
|
70
|
+
folded = name.replace(FOLDED, (c) => String.fromCharCode(lowerCase(c.charCodeAt(0))));
|
|
71
|
+
if (foldCache.size >= 4096) {
|
|
72
|
+
foldCache.clear();
|
|
73
|
+
}
|
|
74
|
+
foldCache.set(name, folded);
|
|
75
|
+
}
|
|
76
|
+
return folded;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether any object has had a property named `__resolve`: until one has,
|
|
80
|
+
* a name the chain lacks is undefined without a second walk for one.
|
|
81
|
+
*/
|
|
82
|
+
let resolvers = false;
|
|
83
|
+
/** The sequence number the next property added takes. */
|
|
84
|
+
let added = 0;
|
|
85
|
+
/**
|
|
86
|
+
* Names, folded, whose adding marks an object (Avm1Object.marked), as a
|
|
87
|
+
* host asks (markNames), and their first characters in either case, which
|
|
88
|
+
* most names added fail before they are folded.
|
|
89
|
+
*/
|
|
90
|
+
const markedNames = new Set();
|
|
91
|
+
const markedFirsts = new Set();
|
|
92
|
+
/**
|
|
93
|
+
* Mark from now on each object a property named `names` is added to, in
|
|
94
|
+
* any case: so that a host that asks every object of a chain for those
|
|
95
|
+
* names, as the pointer asks each clip for onPress and the rest, passes
|
|
96
|
+
* by those never given one.
|
|
97
|
+
*/
|
|
98
|
+
export function markNames(names) {
|
|
99
|
+
for (const name of names) {
|
|
100
|
+
const first = name.charCodeAt(0);
|
|
101
|
+
// Folding a first character outside ASCII can make one of another, which this would not see.
|
|
102
|
+
if (!(first < 0x80)) {
|
|
103
|
+
throw new Error(`markNames: ${name} does not begin in ASCII`);
|
|
104
|
+
}
|
|
105
|
+
markedNames.add(fold(name));
|
|
106
|
+
markedFirsts.add(fold(name[0]).charCodeAt(0));
|
|
107
|
+
markedFirsts.add(name[0].toUpperCase().charCodeAt(0));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** A property: a value, or a getter and maybe a setter (addProperty), and its attributes. */
|
|
111
|
+
export class Property {
|
|
112
|
+
name;
|
|
113
|
+
value;
|
|
114
|
+
flags;
|
|
115
|
+
get = null;
|
|
116
|
+
set = null;
|
|
117
|
+
/** How many calls of its getter, setter or watcher are running, for the recursion limit. */
|
|
118
|
+
calls = 0;
|
|
119
|
+
/** When it was added: for..in lists an object's properties in this order, reversed. */
|
|
120
|
+
seq = added++;
|
|
121
|
+
constructor(
|
|
122
|
+
/** As it was first set, which for..in lists. */
|
|
123
|
+
name, value, flags) {
|
|
124
|
+
this.name = name;
|
|
125
|
+
this.value = value;
|
|
126
|
+
this.flags = flags;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* How many calls of a property's getter, setter or watcher may run at once,
|
|
131
|
+
* one inside another, for a SWF of `version`: past that the getter gives
|
|
132
|
+
* the stored value and the setter and watcher are skipped. A SWF up to 6
|
|
133
|
+
* runs none inside another (adl, the corpus's `*_recursion_swf6`).
|
|
134
|
+
*/
|
|
135
|
+
const propertyCalls = (version) => (version > 6 ? 65 : 1);
|
|
136
|
+
/**
|
|
137
|
+
* `name` as an index of an array's elements: digits with no leading zero
|
|
138
|
+
* (`0` itself, `12`, not `012` nor `1.0`), -1 for any other name.
|
|
139
|
+
*/
|
|
140
|
+
export function elementIndex(name) {
|
|
141
|
+
const n = name.length;
|
|
142
|
+
if (n === 0 || n > 10) {
|
|
143
|
+
return -1;
|
|
144
|
+
}
|
|
145
|
+
let index = name.charCodeAt(0) - 0x30;
|
|
146
|
+
if (index < 0 || index > 9 || (index === 0 && n > 1)) {
|
|
147
|
+
return -1;
|
|
148
|
+
}
|
|
149
|
+
for (let i = 1; i < n; i++) {
|
|
150
|
+
const d = name.charCodeAt(i) - 0x30;
|
|
151
|
+
if (d < 0 || d > 9) {
|
|
152
|
+
return -1;
|
|
153
|
+
}
|
|
154
|
+
index = index * 10 + d;
|
|
155
|
+
}
|
|
156
|
+
return index;
|
|
157
|
+
}
|
|
158
|
+
const bySeq = (a, b) => a.seq - b.seq;
|
|
159
|
+
/** The index of an object none of whose names folding changes, shared. */
|
|
160
|
+
const UNCHANGED = new Map();
|
|
161
|
+
export class Avm1Object {
|
|
162
|
+
/**
|
|
163
|
+
* What node's inspector shows: an object reaches the whole realm, so a
|
|
164
|
+
* failed assertion that printed it in full ran a test to tens of gigabytes.
|
|
165
|
+
*/
|
|
166
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
167
|
+
return `Avm1Object(${this.props.size} properties)`;
|
|
168
|
+
}
|
|
169
|
+
/** By exact name, in the order they were added. */
|
|
170
|
+
props = new Map();
|
|
171
|
+
/**
|
|
172
|
+
* By folded name, the first added of each name folding changes, once a
|
|
173
|
+
* SWF up to 6 needs it; UNCHANGED while there is none.
|
|
174
|
+
*/
|
|
175
|
+
folded = null;
|
|
176
|
+
/** The property named `__proto__`, if any. */
|
|
177
|
+
protoProp = null;
|
|
178
|
+
/** By the name each watches, as set. */
|
|
179
|
+
watchers = null;
|
|
180
|
+
/** Whether it is an array, whose `length` follows its elements: what Array's constructor makes. */
|
|
181
|
+
array = false;
|
|
182
|
+
/**
|
|
183
|
+
* An array's elements by index while each of 0 to n - 1 is there, none
|
|
184
|
+
* of them in `props`; null once one is missing, and for any other object.
|
|
185
|
+
*/
|
|
186
|
+
elems = null;
|
|
187
|
+
/**
|
|
188
|
+
* The primitive a String, Number or Boolean object boxes, a Date's
|
|
189
|
+
* DateCell, undefined for any other.
|
|
190
|
+
*/
|
|
191
|
+
primitive = undefined;
|
|
192
|
+
/** A function's activation object's `arguments` and `super`, until it has made them. */
|
|
193
|
+
lazy = null;
|
|
194
|
+
/** A prototype's interfaces' prototypes, which ImplementsOp gives it, for InstanceOf. */
|
|
195
|
+
interfaces = null;
|
|
196
|
+
/** A display object's side, where it is a clip's, a button's or a text field's AVM1 object (host.ts). */
|
|
197
|
+
display = null;
|
|
198
|
+
/** Whether it has ever had a property named as markNames asks, in any case: it may have one still. */
|
|
199
|
+
marked = false;
|
|
200
|
+
/** An object whose `__proto__` is `proto`, or without one. */
|
|
201
|
+
constructor(proto) {
|
|
202
|
+
if (proto !== undefined) {
|
|
203
|
+
this.define("__proto__", proto, DONT_ENUM | DONT_DELETE);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** The prototype, `__proto__`'s value. */
|
|
207
|
+
get proto() {
|
|
208
|
+
return this.protoProp === null ? undefined : this.protoProp.value;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The prototype a SWF of `version` walks to: none where `__proto__` is
|
|
212
|
+
* hidden from it, as a function's is from SWF 5.
|
|
213
|
+
*/
|
|
214
|
+
protoFor(version) {
|
|
215
|
+
const p = this.protoProp;
|
|
216
|
+
return p === null || !allowed(p.flags, version) ? undefined : p.value;
|
|
217
|
+
}
|
|
218
|
+
/** The own property of exactly `name`, an element or in `props`. */
|
|
219
|
+
exact(name) {
|
|
220
|
+
const elems = this.elems;
|
|
221
|
+
if (elems !== null) {
|
|
222
|
+
const i = elementIndex(name);
|
|
223
|
+
if (i >= 0) {
|
|
224
|
+
return i < elems.length ? elems[i] : undefined;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return this.props.get(name);
|
|
228
|
+
}
|
|
229
|
+
/** The own property `name` names for a SWF of `version`, whatever its attributes. */
|
|
230
|
+
own(name, version) {
|
|
231
|
+
const p = this.exact(name);
|
|
232
|
+
if (p !== undefined) {
|
|
233
|
+
return p;
|
|
234
|
+
}
|
|
235
|
+
if (this.lazy !== null) {
|
|
236
|
+
const made = this.lazy.local(this, name, version);
|
|
237
|
+
if (made !== undefined) {
|
|
238
|
+
return made;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return version > 6 ? undefined : this.ownFolded(name, fold(name));
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The own property a SWF up to 6 finds for `name`, folded `key`, once
|
|
245
|
+
* the exact name missed: the one spelt `key`, else the first added
|
|
246
|
+
* whose name folds to it.
|
|
247
|
+
*/
|
|
248
|
+
ownFolded(name, key) {
|
|
249
|
+
if (key !== name) {
|
|
250
|
+
const p = this.props.get(key);
|
|
251
|
+
if (p !== undefined) {
|
|
252
|
+
return p;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const folded = this.folded ?? this.index();
|
|
256
|
+
return folded === UNCHANGED ? undefined : folded.get(key);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Set `name` to a value with `flags`, as a builtin is defined: in its
|
|
260
|
+
* case, replacing what it had, a getter included, where it was.
|
|
261
|
+
*/
|
|
262
|
+
define(name, value, flags) {
|
|
263
|
+
const p = this.exact(name);
|
|
264
|
+
if (p !== undefined) {
|
|
265
|
+
p.value = value;
|
|
266
|
+
p.flags = flags;
|
|
267
|
+
p.get = null;
|
|
268
|
+
p.set = null;
|
|
269
|
+
return p;
|
|
270
|
+
}
|
|
271
|
+
return this.add(name, value, flags);
|
|
272
|
+
}
|
|
273
|
+
/** A new property, last in the order: the prototype where `proto`. */
|
|
274
|
+
add(name, value, flags, proto = name === "__proto__") {
|
|
275
|
+
const p = new Property(name, value, flags);
|
|
276
|
+
const elems = this.elems;
|
|
277
|
+
if (elems !== null) {
|
|
278
|
+
const i = elementIndex(name);
|
|
279
|
+
if (i === elems.length) {
|
|
280
|
+
elems.push(p);
|
|
281
|
+
return p;
|
|
282
|
+
}
|
|
283
|
+
if (i >= 0) {
|
|
284
|
+
this.sparse();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
this.props.set(name, p);
|
|
288
|
+
if (proto) {
|
|
289
|
+
this.protoProp = p;
|
|
290
|
+
}
|
|
291
|
+
else if (name.length === 9 && !resolvers && fold(name) === "__resolve") {
|
|
292
|
+
resolvers = true;
|
|
293
|
+
}
|
|
294
|
+
if (!this.marked && markedFirsts.has(name.charCodeAt(0)) && markedNames.has(fold(name))) {
|
|
295
|
+
this.marked = true;
|
|
296
|
+
}
|
|
297
|
+
const folded = this.folded;
|
|
298
|
+
if (folded !== null) {
|
|
299
|
+
const key = fold(name);
|
|
300
|
+
if (key === name) {
|
|
301
|
+
return p;
|
|
302
|
+
}
|
|
303
|
+
if (folded === UNCHANGED) {
|
|
304
|
+
this.folded = new Map([[key, p]]);
|
|
305
|
+
}
|
|
306
|
+
else if (!folded.has(key)) {
|
|
307
|
+
folded.set(key, p);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return p;
|
|
311
|
+
}
|
|
312
|
+
remove(p) {
|
|
313
|
+
const elems = this.elems;
|
|
314
|
+
if (elems !== null) {
|
|
315
|
+
const i = elementIndex(p.name);
|
|
316
|
+
if (i >= 0 && i < elems.length && elems[i] === p) {
|
|
317
|
+
if (i === elems.length - 1) {
|
|
318
|
+
elems.pop();
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
this.sparse();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
this.props.delete(p.name);
|
|
325
|
+
if (p === this.protoProp) {
|
|
326
|
+
this.protoProp = null;
|
|
327
|
+
}
|
|
328
|
+
const folded = this.folded;
|
|
329
|
+
if (folded === null || folded === UNCHANGED) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const key = fold(p.name);
|
|
333
|
+
if (folded.get(key) === p) {
|
|
334
|
+
folded.delete(key);
|
|
335
|
+
for (const other of this.props.values()) {
|
|
336
|
+
if (other.name !== key && fold(other.name) === key) {
|
|
337
|
+
folded.set(key, other);
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/** Its own properties in the order they were added: its elements among the rest. */
|
|
344
|
+
ownProperties() {
|
|
345
|
+
const own = [...this.props.values()];
|
|
346
|
+
const elems = this.elems;
|
|
347
|
+
if (elems === null || elems.length === 0) {
|
|
348
|
+
return own;
|
|
349
|
+
}
|
|
350
|
+
for (const p of elems) {
|
|
351
|
+
own.push(p);
|
|
352
|
+
}
|
|
353
|
+
return own.sort(bySeq);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* An own property set as Array's methods set an element they delete
|
|
357
|
+
* first: its value, no attributes, last in the order.
|
|
358
|
+
*/
|
|
359
|
+
renew(p, value) {
|
|
360
|
+
p.value = value;
|
|
361
|
+
p.flags = 0;
|
|
362
|
+
p.get = null;
|
|
363
|
+
p.set = null;
|
|
364
|
+
p.seq = added++;
|
|
365
|
+
}
|
|
366
|
+
/** Its elements moved into `props`, as a hole needs: in the order they were added. */
|
|
367
|
+
sparse() {
|
|
368
|
+
const elems = this.elems;
|
|
369
|
+
if (elems === null) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
this.elems = null;
|
|
373
|
+
if (elems.length === 0) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const all = [...this.props.values(), ...elems].sort(bySeq);
|
|
377
|
+
this.props.clear();
|
|
378
|
+
for (const p of all) {
|
|
379
|
+
this.props.set(p.name, p);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
/** The watcher of `name` for a SWF of `version`. */
|
|
383
|
+
watcher(name, version) {
|
|
384
|
+
const watchers = this.watchers;
|
|
385
|
+
if (watchers === null) {
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
388
|
+
for (const w of watchers) {
|
|
389
|
+
if (w.name === name) {
|
|
390
|
+
return w;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (version > 6) {
|
|
394
|
+
return undefined;
|
|
395
|
+
}
|
|
396
|
+
const key = fold(name);
|
|
397
|
+
return watchers.find((w) => fold(w.name) === key);
|
|
398
|
+
}
|
|
399
|
+
/** What `typeof` says of it. */
|
|
400
|
+
typeOf() {
|
|
401
|
+
return this.display === null ? "object" : this.display.type;
|
|
402
|
+
}
|
|
403
|
+
index() {
|
|
404
|
+
let folded = UNCHANGED;
|
|
405
|
+
for (const p of this.props.values()) {
|
|
406
|
+
const key = fold(p.name);
|
|
407
|
+
if (key === p.name) {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
if (folded === UNCHANGED) {
|
|
411
|
+
folded = new Map();
|
|
412
|
+
}
|
|
413
|
+
if (!folded.has(key)) {
|
|
414
|
+
folded.set(key, p);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
this.folded = folded;
|
|
418
|
+
return folded;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* A function. Natives are TypeScript; one called with `new` runs
|
|
423
|
+
* `construct` where it has one, as Flash's native constructors (Object,
|
|
424
|
+
* Array...) do otherwise than when called. Those DefineFunction makes are
|
|
425
|
+
* functions.ts's ScriptFunction.
|
|
426
|
+
*/
|
|
427
|
+
export class Avm1Function extends Avm1Object {
|
|
428
|
+
realm;
|
|
429
|
+
native;
|
|
430
|
+
construct;
|
|
431
|
+
raw;
|
|
432
|
+
constructor(proto, realm, native, construct = null,
|
|
433
|
+
/** Whether `native` takes `this` unboxed, a RawNative. */
|
|
434
|
+
raw = false) {
|
|
435
|
+
super();
|
|
436
|
+
this.realm = realm;
|
|
437
|
+
this.native = native;
|
|
438
|
+
this.construct = construct;
|
|
439
|
+
this.raw = raw;
|
|
440
|
+
// A SWF 5 sees no prototype of a function, as adl has it.
|
|
441
|
+
if (proto !== undefined) {
|
|
442
|
+
this.define("__proto__", proto, DONT_ENUM | DONT_DELETE | VERSION_6);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
typeOf() {
|
|
446
|
+
return "function";
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Call it with `self` as `this`; `depth`, how far up `this`'s prototypes
|
|
450
|
+
* it was found, is what `super` starts from in a ScriptFunction.
|
|
451
|
+
*/
|
|
452
|
+
call(self, args, version, _depth = 0) {
|
|
453
|
+
return this.raw
|
|
454
|
+
? this.native(self, args, version)
|
|
455
|
+
: this.native(this.realm.box(self, version), args, version);
|
|
456
|
+
}
|
|
457
|
+
/** Run it on `self`, the object `new` made, where it has no `construct`. */
|
|
458
|
+
initialize(self, args, version) {
|
|
459
|
+
this.native(self, args, version);
|
|
460
|
+
}
|
|
461
|
+
/** Run it as a constructor of `self`, made already, as `super()` runs its class's. */
|
|
462
|
+
callConstructor(self, args, version, _depth) {
|
|
463
|
+
return (this.construct ?? this.native)(self, args, version);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/** Call `fn` if it is a function; anything else gives undefined, as Flash does. */
|
|
467
|
+
export function invoke(fn, self, args, version, depth = 0) {
|
|
468
|
+
return fn instanceof Avm1Function ? fn.call(self, args, version, depth) : undefined;
|
|
469
|
+
}
|
|
470
|
+
/** How far up its object's prototypes `get` found what it gave last, a getter's value too: 0 its own. */
|
|
471
|
+
export let foundDepth = 0;
|
|
472
|
+
/** The deepest a prototype chain is walked, as Ruffle stops: no further. */
|
|
473
|
+
const DEPTH = 255;
|
|
474
|
+
/**
|
|
475
|
+
* What `find` gives for a display object's child or property, one object
|
|
476
|
+
* reused, as each name a script resolves on a clip comes through it: its
|
|
477
|
+
* callers read it at once, keep none and let go of its value
|
|
478
|
+
* (`foundValue`, `has`).
|
|
479
|
+
*/
|
|
480
|
+
const displayFound = new Property("", undefined, DONT_ENUM);
|
|
481
|
+
/**
|
|
482
|
+
* The first own property `name` names on `o` or its prototypes, whatever
|
|
483
|
+
* its attributes: whether the name is there, as the scope chain asks.
|
|
484
|
+
*/
|
|
485
|
+
export function find(o, name, version) {
|
|
486
|
+
let key = null;
|
|
487
|
+
let p = o;
|
|
488
|
+
for (let depth = 0; p instanceof Avm1Object && depth < DEPTH; depth++) {
|
|
489
|
+
let own = p.exact(name);
|
|
490
|
+
if (own === undefined && p.lazy !== null) {
|
|
491
|
+
own = p.lazy.local(p, name, version);
|
|
492
|
+
}
|
|
493
|
+
if (own === undefined && version <= 6) {
|
|
494
|
+
key ??= fold(name);
|
|
495
|
+
own = p.ownFolded(name, key);
|
|
496
|
+
}
|
|
497
|
+
if (own !== undefined) {
|
|
498
|
+
return own;
|
|
499
|
+
}
|
|
500
|
+
// A display object's children and properties, after its own (Ruffle's has_property).
|
|
501
|
+
if (p.display !== null) {
|
|
502
|
+
const value = p.display.get(name, version);
|
|
503
|
+
if (value !== ABSENT) {
|
|
504
|
+
displayFound.value = value;
|
|
505
|
+
return displayFound;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
p = p.protoFor(version);
|
|
509
|
+
}
|
|
510
|
+
return undefined;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* `o[name]`: the first property its version sees on `o` or its
|
|
514
|
+
* prototypes, its getter called with `self` as `this`, or what a
|
|
515
|
+
* `__resolve` on the chain gives for the name.
|
|
516
|
+
*/
|
|
517
|
+
export function get(o, name, version, self = o, resolving = true) {
|
|
518
|
+
let key = null;
|
|
519
|
+
let p = o;
|
|
520
|
+
for (let depth = 0; p instanceof Avm1Object && depth < DEPTH; depth++) {
|
|
521
|
+
let own = p.exact(name);
|
|
522
|
+
if (own === undefined && p.lazy !== null) {
|
|
523
|
+
own = p.lazy.local(p, name, version);
|
|
524
|
+
}
|
|
525
|
+
if (own === undefined && version <= 6) {
|
|
526
|
+
key ??= fold(name);
|
|
527
|
+
own = p.ownFolded(name, key);
|
|
528
|
+
}
|
|
529
|
+
if (own !== undefined && allowed(own.flags, version)) {
|
|
530
|
+
if (own.get === null || own.calls >= propertyCalls(version)) {
|
|
531
|
+
foundDepth = depth;
|
|
532
|
+
return own.value;
|
|
533
|
+
}
|
|
534
|
+
// Where the getter was found, not where its own lookups were.
|
|
535
|
+
const value = callGetter(own, self, version);
|
|
536
|
+
foundDepth = depth;
|
|
537
|
+
return value;
|
|
538
|
+
}
|
|
539
|
+
if (own === undefined && p.display !== null) {
|
|
540
|
+
const value = p.display.get(name, version);
|
|
541
|
+
if (value !== ABSENT) {
|
|
542
|
+
foundDepth = depth;
|
|
543
|
+
return value;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
p = p.protoFor(version);
|
|
547
|
+
}
|
|
548
|
+
foundDepth = 0;
|
|
549
|
+
return resolving && resolvers ? resolve(o, name, version, self) : undefined;
|
|
550
|
+
}
|
|
551
|
+
function callGetter(p, self, version) {
|
|
552
|
+
p.calls++;
|
|
553
|
+
try {
|
|
554
|
+
return invoke(p.get, self, [], version, 1);
|
|
555
|
+
}
|
|
556
|
+
finally {
|
|
557
|
+
p.calls--;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
/** A setter's call, unless as many of the property's calls are running as may (propertyCalls). */
|
|
561
|
+
function callSetter(p, setter, self, value, version) {
|
|
562
|
+
if (p.calls >= propertyCalls(version)) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
p.calls++;
|
|
566
|
+
try {
|
|
567
|
+
invoke(setter, self, [value], version, 1);
|
|
568
|
+
}
|
|
569
|
+
finally {
|
|
570
|
+
p.calls--;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* A missing name's value: the first `__resolve` on the chain that holds an
|
|
575
|
+
* object, called with the name; a primitive one is skipped, and an object
|
|
576
|
+
* that is no function gives undefined.
|
|
577
|
+
*/
|
|
578
|
+
function resolve(o, name, version, self) {
|
|
579
|
+
let p = o;
|
|
580
|
+
for (let depth = 0; p instanceof Avm1Object && depth < DEPTH; depth++) {
|
|
581
|
+
// adl calls a `__resolve` its version bits hide.
|
|
582
|
+
// A clip is skipped as a primitive is (the corpus's `object_resolve`).
|
|
583
|
+
const own = p.own("__resolve", version);
|
|
584
|
+
if (own !== undefined &&
|
|
585
|
+
own.value instanceof Avm1Object &&
|
|
586
|
+
own.value.typeOf() !== "movieclip") {
|
|
587
|
+
return invoke(own.value, self, [name], version);
|
|
588
|
+
}
|
|
589
|
+
p = p.protoFor(version);
|
|
590
|
+
}
|
|
591
|
+
return undefined;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* What the watcher of `name` on `o` gives for a set of `value` over `old`,
|
|
595
|
+
* `value` where it has none, or where as many of its calls run as may.
|
|
596
|
+
*/
|
|
597
|
+
export function watched(o, name, old, value, version) {
|
|
598
|
+
const w = o.watcher(name, version);
|
|
599
|
+
if (w === undefined) {
|
|
600
|
+
return value;
|
|
601
|
+
}
|
|
602
|
+
// The calls count on the property, the getter's and setter's with them, else on the watcher.
|
|
603
|
+
const own = o.own(name, version);
|
|
604
|
+
const count = own ?? w;
|
|
605
|
+
if (count.calls >= propertyCalls(version)) {
|
|
606
|
+
return value;
|
|
607
|
+
}
|
|
608
|
+
count.calls++;
|
|
609
|
+
try {
|
|
610
|
+
// adl names the property as it was first set, where there is one (`FOO` sets `foo`).
|
|
611
|
+
return invoke(w.callback, o, [own?.name ?? name, old, value, w.data], version);
|
|
612
|
+
}
|
|
613
|
+
finally {
|
|
614
|
+
count.calls--;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
/** `name`'s stored value on `o` or its prototypes, no getter called: what a watcher is told was there. */
|
|
618
|
+
function stored(o, name, version) {
|
|
619
|
+
let p = o;
|
|
620
|
+
for (let depth = 0; p instanceof Avm1Object && depth < DEPTH; depth++) {
|
|
621
|
+
const own = p.own(name, version);
|
|
622
|
+
if (own !== undefined && allowed(own.flags, version)) {
|
|
623
|
+
return own.value;
|
|
624
|
+
}
|
|
625
|
+
p = p.protoFor(version);
|
|
626
|
+
}
|
|
627
|
+
return undefined;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* `o[name] = value`: the watcher of the name on `o` first, which gives the
|
|
631
|
+
* value set; then an own property's setter, or the first getter's setter
|
|
632
|
+
* on the prototypes, or the value stored on `o`, unless read-only.
|
|
633
|
+
*/
|
|
634
|
+
export function set(o, name, value, version) {
|
|
635
|
+
if (name === "") {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
// adl changes an array's `length`, telling its watcher, before the set's own watcher is told.
|
|
639
|
+
const early = o.array && o.watchers !== null;
|
|
640
|
+
if (early && virtual(o, name, version) === undefined) {
|
|
641
|
+
arraySet(o, name, value, version);
|
|
642
|
+
}
|
|
643
|
+
if (o.watchers !== null) {
|
|
644
|
+
try {
|
|
645
|
+
value = watched(o, name, stored(o, name, version), value, version);
|
|
646
|
+
}
|
|
647
|
+
catch (error) {
|
|
648
|
+
if (!(error instanceof Avm1Throw)) {
|
|
649
|
+
throw error;
|
|
650
|
+
}
|
|
651
|
+
// A watcher that throws sets undefined, then the value is thrown (adl).
|
|
652
|
+
store(o, name, undefined, version, early);
|
|
653
|
+
throw error;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
store(o, name, value, version, early);
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* A set past the watcher: the setter, or the value stored; an array's
|
|
660
|
+
* `length` changed with it unless `early`, before the watcher, did.
|
|
661
|
+
*/
|
|
662
|
+
function store(o, name, value, version, early) {
|
|
663
|
+
o.display?.changed?.(name, value, version);
|
|
664
|
+
const own = o.own(name, version);
|
|
665
|
+
// A display property takes the value where the object has no property of the name (Ruffle's set_local).
|
|
666
|
+
if (own === undefined && o.display !== null && o.display.set(name, value, version)) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (own === undefined) {
|
|
670
|
+
const v = virtual(o, name, version);
|
|
671
|
+
if (v !== undefined) {
|
|
672
|
+
if (v.set !== null) {
|
|
673
|
+
callSetter(v, v.set, o, value, version);
|
|
674
|
+
}
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (o.array && !early) {
|
|
679
|
+
arraySet(o, name, value, version);
|
|
680
|
+
}
|
|
681
|
+
if (own === undefined) {
|
|
682
|
+
// Up to SWF 6, `__PROTO__` is the prototype too, where there is no `__proto__`.
|
|
683
|
+
o.add(name, value, 0, version > 6 ? name === "__proto__" : fold(name) === "__proto__");
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (own.set !== null) {
|
|
687
|
+
callSetter(own, own.set, o, value, version);
|
|
688
|
+
}
|
|
689
|
+
// A value set over a builtin's shows it to every version; but adl's SWF 6 keeps bit 0x400.
|
|
690
|
+
if ((own.flags & READ_ONLY) === 0) {
|
|
691
|
+
own.value = value;
|
|
692
|
+
own.flags &= version === 6 ? ~VERSION_BITS | 0x400 : ~VERSION_BITS;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
/** The first getter on the prototypes of `o` that a set of `name` goes to, where `o` has no `name`. */
|
|
696
|
+
function virtual(o, name, version) {
|
|
697
|
+
if (o.own(name, version) !== undefined) {
|
|
698
|
+
return undefined;
|
|
699
|
+
}
|
|
700
|
+
let p = o.protoFor(version);
|
|
701
|
+
for (let depth = 0; p instanceof Avm1Object && depth < DEPTH; depth++) {
|
|
702
|
+
const v = p.own(name, version);
|
|
703
|
+
if (v !== undefined && v.get !== null && allowed(v.flags, version)) {
|
|
704
|
+
return v;
|
|
705
|
+
}
|
|
706
|
+
p = p.protoFor(version);
|
|
707
|
+
}
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* An array's `length` as a set changes it: elements past a shorter one go,
|
|
712
|
+
* an index past it grows it. Under a watcher, adl sets `length` twice, as
|
|
713
|
+
* the array and then as the set: the watcher is told of both, the first
|
|
714
|
+
* one's value is the length cut to and kept, the second's what is stored.
|
|
715
|
+
*/
|
|
716
|
+
export function arraySet(a, name, value, version) {
|
|
717
|
+
if ((caseSensitive(version) ? name : fold(name)) === "length") {
|
|
718
|
+
const p = a.props.get("length");
|
|
719
|
+
const old = p?.value;
|
|
720
|
+
if (a.watchers !== null) {
|
|
721
|
+
watched(a, "length", old, value, version);
|
|
722
|
+
}
|
|
723
|
+
if (typeof old === "number") {
|
|
724
|
+
truncate(a, toNumber(value, version) | 0, old | 0);
|
|
725
|
+
}
|
|
726
|
+
if (a.watchers !== null && p !== undefined && (p.flags & READ_ONLY) === 0) {
|
|
727
|
+
p.value = value;
|
|
728
|
+
}
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
const index = arrayIndex(name, version);
|
|
732
|
+
if (index !== null && index >= lengthOf(a)) {
|
|
733
|
+
growTo(a, (index + 1) | 0, version);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* An array's `length` grown to `length` by an element set past it, its
|
|
738
|
+
* watcher told, though what it gives is not kept (adl); past 2^31 - 1 the
|
|
739
|
+
* int wraps, shorter, and deletes.
|
|
740
|
+
*/
|
|
741
|
+
export function growTo(a, length, version) {
|
|
742
|
+
const p = a.props.get("length");
|
|
743
|
+
if (a.watchers !== null) {
|
|
744
|
+
watched(a, "length", p === undefined ? undefined : p.value, length, version);
|
|
745
|
+
}
|
|
746
|
+
if (length < 0 && p !== undefined && typeof p.value === "number") {
|
|
747
|
+
truncate(a, length, p.value | 0);
|
|
748
|
+
}
|
|
749
|
+
if (p === undefined) {
|
|
750
|
+
a.add("length", length, 0);
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
p.value = length;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* The elements of `a` from `length` to `old` deleted, as a shorter
|
|
758
|
+
* `length` deletes them; those that cannot be deleted stay.
|
|
759
|
+
*/
|
|
760
|
+
export function truncate(a, length, old) {
|
|
761
|
+
const from = Math.max(length, 0);
|
|
762
|
+
if (old <= from) {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
let i = old - 1;
|
|
766
|
+
const elems = a.elems;
|
|
767
|
+
if (elems !== null) {
|
|
768
|
+
// No index past a dense array's elements is there.
|
|
769
|
+
i = Math.min(i, elems.length - 1);
|
|
770
|
+
while (i >= from && a.elems !== null) {
|
|
771
|
+
const p = a.elems[i];
|
|
772
|
+
if ((p.flags & DONT_DELETE) === 0) {
|
|
773
|
+
a.remove(p);
|
|
774
|
+
}
|
|
775
|
+
i--;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
if (i < from) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
// Past what the object holds, its names are fewer than the indices.
|
|
782
|
+
if (i - from > a.props.size) {
|
|
783
|
+
for (const p of [...a.props.values()]) {
|
|
784
|
+
const index = elementIndex(p.name);
|
|
785
|
+
if (index >= from && index <= i && (p.flags & DONT_DELETE) === 0) {
|
|
786
|
+
a.remove(p);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
for (; i >= from; i--) {
|
|
792
|
+
const p = a.props.get(String(i));
|
|
793
|
+
if (p !== undefined && (p.flags & DONT_DELETE) === 0) {
|
|
794
|
+
a.remove(p);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
/** An array's own `length`, as an int, converted as a SWF of `version` converts it. */
|
|
799
|
+
export function lengthOf(o, version = 7) {
|
|
800
|
+
const length = o.props.get("length")?.value;
|
|
801
|
+
return typeof length === "number" ? length | 0 : toNumber(length, version) | 0;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* A name as an array index, as adl reads one: spaces, a sign and digits,
|
|
805
|
+
* wrapped to 32 bits; a SWF up to 6 takes them before anything else
|
|
806
|
+
* (`3abc` and `1.9` are 3 and 1), a later one only alone. Null for none.
|
|
807
|
+
*/
|
|
808
|
+
function arrayIndex(name, version) {
|
|
809
|
+
const n = name.length;
|
|
810
|
+
let i = 0;
|
|
811
|
+
for (; i < n; i++) {
|
|
812
|
+
const c = name.charCodeAt(i);
|
|
813
|
+
if (c !== 0x20 && (c < 0x09 || c > 0x0d)) {
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
const negative = name.charCodeAt(i) === 0x2d;
|
|
818
|
+
if (negative || name.charCodeAt(i) === 0x2b) {
|
|
819
|
+
i++;
|
|
820
|
+
}
|
|
821
|
+
const start = i;
|
|
822
|
+
let index = 0;
|
|
823
|
+
for (; i < n; i++) {
|
|
824
|
+
const d = name.charCodeAt(i) - 0x30;
|
|
825
|
+
if (d < 0 || d > 9) {
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
828
|
+
index = (Math.imul(index, 10) + d) | 0;
|
|
829
|
+
}
|
|
830
|
+
if (i === start || (i < n && version > 6)) {
|
|
831
|
+
return null;
|
|
832
|
+
}
|
|
833
|
+
return negative ? -index | 0 : index;
|
|
834
|
+
}
|
|
835
|
+
/** `delete o[name]`: whether an own property went, which DontDelete keeps. */
|
|
836
|
+
export function removeOwn(o, name, version) {
|
|
837
|
+
const own = o.own(name, version);
|
|
838
|
+
if (own === undefined || own.flags & DONT_DELETE) {
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
o.remove(own);
|
|
842
|
+
return true;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* The names for..in visits on `o`, in Flash's order: its prototypes' first,
|
|
846
|
+
* the deepest's first, but those `o` lists itself, then its own, the last
|
|
847
|
+
* added first; DontEnum ones left out. An own DontEnum property does not
|
|
848
|
+
* hide a prototype's of the same name (adl).
|
|
849
|
+
*/
|
|
850
|
+
export function keys(o, version, out = [], depth = 0) {
|
|
851
|
+
const proto = o.protoFor(version);
|
|
852
|
+
if (proto instanceof Avm1Object && depth < DEPTH) {
|
|
853
|
+
const start = out.length;
|
|
854
|
+
keys(proto, version, out, depth + 1);
|
|
855
|
+
let n = start;
|
|
856
|
+
for (let i = start; i < out.length; i++) {
|
|
857
|
+
const own = o.own(out[i], version);
|
|
858
|
+
if (own === undefined || own.flags & DONT_ENUM) {
|
|
859
|
+
out[n++] = out[i];
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
out.length = n;
|
|
863
|
+
}
|
|
864
|
+
const own = o.ownProperties();
|
|
865
|
+
for (let i = own.length - 1; i >= 0; i--) {
|
|
866
|
+
if ((own[i].flags & DONT_ENUM) === 0) {
|
|
867
|
+
out.push(own[i].name);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
// A clip's children last, by depth, the highest first.
|
|
871
|
+
if (o.display !== null) {
|
|
872
|
+
o.display.keys(out);
|
|
873
|
+
}
|
|
874
|
+
return out;
|
|
875
|
+
}
|
|
876
|
+
/** Whether `name` is on `o` or its prototypes, whatever its attributes. */
|
|
877
|
+
export function has(o, name, version) {
|
|
878
|
+
const found = find(o, name, version) !== undefined;
|
|
879
|
+
displayFound.value = undefined;
|
|
880
|
+
return found;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* The value of `p`, which `find` found for `name` on `o`, as the scope
|
|
884
|
+
* chain reads it: a plain one's own, else as `get` gives it. The reused
|
|
885
|
+
* display property lets go of its value, a clip's AVM1 object perhaps.
|
|
886
|
+
*/
|
|
887
|
+
export function foundValue(p, o, name, version) {
|
|
888
|
+
if (p === displayFound) {
|
|
889
|
+
const value = p.value;
|
|
890
|
+
p.value = undefined;
|
|
891
|
+
return value;
|
|
892
|
+
}
|
|
893
|
+
return p.get === null && allowed(p.flags, version) ? p.value : get(o, name, version);
|
|
894
|
+
}
|
|
895
|
+
/** `name` as a property's name: the string a value converts to. */
|
|
896
|
+
export const nameOf = (value, version) => typeof value === "string" ? value : stringOf(value, version);
|