@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,529 @@
|
|
|
1
|
+
import { TimedOut } from "./errors.js";
|
|
2
|
+
import { pendingLocal, ScriptFunction } from "./functions.js";
|
|
3
|
+
import { arrayClass } from "./globals/array.js";
|
|
4
|
+
import { broadcasterClass } from "./globals/broadcaster.js";
|
|
5
|
+
import { DateCell, dateClass } from "./globals/date.js";
|
|
6
|
+
import { asnative, globalFunctions } from "./globals/global.js";
|
|
7
|
+
import { mathNative, mathObject } from "./globals/math.js";
|
|
8
|
+
import { booleanClass, numberClass } from "./globals/number.js";
|
|
9
|
+
import { stringClass } from "./globals/string.js";
|
|
10
|
+
import { Timers } from "./globals/timers.js";
|
|
11
|
+
import { Avm1Function, Avm1Object, arraySet, caseSensitive, DONT_DELETE, DONT_ENUM, elementIndex, fold, get, invoke, lengthOf, nameOf, Property, READ_ONLY, set, VERSION_6, } from "./objects.js";
|
|
12
|
+
import { SCOPE_Global, Scope } from "./scope.js";
|
|
13
|
+
import { isPrimitive, objects, stringOf, toNumber } from "./values.js";
|
|
14
|
+
/** The arguments' first, undefined where there is none. */
|
|
15
|
+
const first = (args) => (args.length > 0 ? args[0] : undefined);
|
|
16
|
+
/** A value as ASSetPropFlags takes its bits: an int's low 16, as adl wraps them. */
|
|
17
|
+
const u16 = (value, version) => (toNumber(value, version) | 0) & 0xffff;
|
|
18
|
+
/** Jumps back and calls between two readings of the clock for the script timeout. */
|
|
19
|
+
export const BUDGET = 100_000;
|
|
20
|
+
export class Realm {
|
|
21
|
+
/** `_global`: no prototype, as Flash's has none. */
|
|
22
|
+
global = new Avm1Object();
|
|
23
|
+
objectProto = new Avm1Object();
|
|
24
|
+
functionProto = new Avm1Object();
|
|
25
|
+
Object;
|
|
26
|
+
Function;
|
|
27
|
+
String;
|
|
28
|
+
Number;
|
|
29
|
+
Boolean;
|
|
30
|
+
Array;
|
|
31
|
+
Error;
|
|
32
|
+
AsBroadcaster;
|
|
33
|
+
Date;
|
|
34
|
+
Math;
|
|
35
|
+
/**
|
|
36
|
+
* ASnative's tables: by category, the native at an index, null for none
|
|
37
|
+
* (an index past its natives is undefined's, but Math's, NaN's).
|
|
38
|
+
*/
|
|
39
|
+
natives = new Map();
|
|
40
|
+
/** The bottom of every scope chain. */
|
|
41
|
+
globalScope;
|
|
42
|
+
/** The four registers outside DefineFunction2's own, which every activation shares. */
|
|
43
|
+
registers = [undefined, undefined, undefined, undefined];
|
|
44
|
+
/** By the regions of a block or a unit, the units of its SWF, which V.far runs. */
|
|
45
|
+
units = new WeakMap();
|
|
46
|
+
/** The activation running, null between the player's calls into AVM1 code. */
|
|
47
|
+
current = null;
|
|
48
|
+
/** How many function calls are running, one in another. */
|
|
49
|
+
calls = 0;
|
|
50
|
+
/**
|
|
51
|
+
* How deep function calls may go, the call that reaches it disabling the
|
|
52
|
+
* movie's actions: a SWF's ScriptLimits sets it, adl's is 1000.
|
|
53
|
+
*/
|
|
54
|
+
maxCalls = 1000;
|
|
55
|
+
/**
|
|
56
|
+
* How many clips the player has removed: code whose own clip may be one
|
|
57
|
+
* of them checks it only after a call, where this moved on.
|
|
58
|
+
*/
|
|
59
|
+
removals = 0;
|
|
60
|
+
/** setInterval's and setTimeout's timers, which the player fires by its clock. */
|
|
61
|
+
timers = new Timers();
|
|
62
|
+
/**
|
|
63
|
+
* When the scripts running must have stopped by, on `clock`, the script
|
|
64
|
+
* timeout's ms after the player started them; Infinity while none run.
|
|
65
|
+
*/
|
|
66
|
+
deadline = Number.POSITIVE_INFINITY;
|
|
67
|
+
/** The player's clock, in ms, which the script timeout reads. */
|
|
68
|
+
clock = () => 0;
|
|
69
|
+
/**
|
|
70
|
+
* What code counts down as it jumps back or calls: the clock is read
|
|
71
|
+
* only as it runs out, so a loop pays a decrement for the timeout.
|
|
72
|
+
*/
|
|
73
|
+
budget = BUDGET;
|
|
74
|
+
constructor() {
|
|
75
|
+
// Object's `prototype` is read-only (adl: Extends and a set leave it).
|
|
76
|
+
const object = this.classOf(this.objectProto, (self, args, version) => {
|
|
77
|
+
const v = first(args);
|
|
78
|
+
return v === undefined || v === null ? self : this.box(v, version);
|
|
79
|
+
}, (_, args, version) => {
|
|
80
|
+
const v = first(args);
|
|
81
|
+
return v === undefined || v === null ? new Avm1Object() : this.box(v, version);
|
|
82
|
+
}, READ_ONLY);
|
|
83
|
+
// Function() of nothing gives an object without a prototype, as Ruffle has it.
|
|
84
|
+
const fn = this.classOf(this.functionProto, (self, args) => (args.length > 0 ? args[0] : self), (_, args) => (args.length > 0 ? args[0] : new Avm1Object()));
|
|
85
|
+
this.Object = object;
|
|
86
|
+
this.Function = fn;
|
|
87
|
+
object.define("constructor", fn, DONT_ENUM | DONT_DELETE);
|
|
88
|
+
fn.define("constructor", fn, DONT_ENUM | DONT_DELETE);
|
|
89
|
+
this.functionProto.define("__proto__", this.objectProto, DONT_ENUM | DONT_DELETE);
|
|
90
|
+
this.objectPrototype();
|
|
91
|
+
this.functionPrototype();
|
|
92
|
+
this.String = stringClass(this);
|
|
93
|
+
this.Number = numberClass(this);
|
|
94
|
+
this.Boolean = booleanClass(this);
|
|
95
|
+
this.Array = arrayClass(this);
|
|
96
|
+
this.Error = this.errorClass();
|
|
97
|
+
this.AsBroadcaster = broadcasterClass(this);
|
|
98
|
+
this.Date = dateClass(this);
|
|
99
|
+
this.Math = mathObject(this);
|
|
100
|
+
this.natives.set(200, (i) => mathNative(i));
|
|
101
|
+
// In Flash's order (Ruffle's globals.rs), each DontEnum.
|
|
102
|
+
const g = this.global;
|
|
103
|
+
this.globalScope = new Scope(null, SCOPE_Global, g);
|
|
104
|
+
g.define("ASnative", this.method((_, args, version) => args.length === 2
|
|
105
|
+
? asnative(this, toNumber(args[0], version) >>> 0, toNumber(args[1], version) >>> 0)
|
|
106
|
+
: undefined), DONT_ENUM);
|
|
107
|
+
g.define("Object", object, DONT_ENUM);
|
|
108
|
+
g.define("Function", fn, DONT_ENUM | VERSION_6);
|
|
109
|
+
// Getters, which give undefined to a SWF 4.
|
|
110
|
+
this.getter(g, "NaN", (version) => (version > 4 ? Number.NaN : undefined));
|
|
111
|
+
this.getter(g, "Infinity", (version) => (version > 4 ? Number.POSITIVE_INFINITY : undefined));
|
|
112
|
+
g.define("AsBroadcaster", this.AsBroadcaster.constr, DONT_ENUM);
|
|
113
|
+
g.define("ASSetPropFlags", this.method((_, args, version) => setPropFlags(this, args, version)), DONT_ENUM);
|
|
114
|
+
globalFunctions(this, (name, native) => g.define(name, this.method(native), DONT_ENUM));
|
|
115
|
+
// Flash's own globals leave a variable `o`, set to null.
|
|
116
|
+
g.define("o", null, 0);
|
|
117
|
+
g.define("Number", this.Number.constr, DONT_ENUM);
|
|
118
|
+
g.define("Boolean", this.Boolean.constr, DONT_ENUM);
|
|
119
|
+
g.define("Date", this.Date.constr, DONT_ENUM);
|
|
120
|
+
g.define("String", this.String.constr, DONT_ENUM);
|
|
121
|
+
g.define("Array", this.Array.constr, DONT_ENUM);
|
|
122
|
+
g.define("Math", this.Math, DONT_ENUM);
|
|
123
|
+
g.define("Error", this.Error.constr, DONT_ENUM);
|
|
124
|
+
}
|
|
125
|
+
/** The budget ran out: read the clock, and past the deadline, disable the movie's actions. */
|
|
126
|
+
timeout() {
|
|
127
|
+
this.budget = BUDGET;
|
|
128
|
+
if (this.clock() > this.deadline) {
|
|
129
|
+
throw new TimedOut("a script ran past the script timeout");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** A property of `object` whose value a native getter gives, without a setter. */
|
|
133
|
+
getter(object, name, value) {
|
|
134
|
+
object.add(name, undefined, DONT_ENUM).get = this.method((_, __, version) => value(version));
|
|
135
|
+
}
|
|
136
|
+
/** A native function, a method's: no `prototype`. */
|
|
137
|
+
method(native) {
|
|
138
|
+
return new Avm1Function(this.functionProto, this, native);
|
|
139
|
+
}
|
|
140
|
+
/** A native method that takes `this` unboxed. */
|
|
141
|
+
rawMethod(native) {
|
|
142
|
+
return new Avm1Function(this.functionProto, this, native, null, true);
|
|
143
|
+
}
|
|
144
|
+
/** `value` as an object, as a native's `this`: a primitive boxed by its class on `_global`. */
|
|
145
|
+
box(value, version) {
|
|
146
|
+
if (value instanceof Avm1Object) {
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
const name = boxName(value);
|
|
150
|
+
if (name === null) {
|
|
151
|
+
return new Avm1Object();
|
|
152
|
+
}
|
|
153
|
+
const constr = this.global.own(name, version)?.value;
|
|
154
|
+
const boxed = constr instanceof Avm1Object ? this.construct(constr, [value], version) : undefined;
|
|
155
|
+
return boxed instanceof Avm1Object ? boxed : new Avm1Object();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* `new constr(...args)`: an object whose `__proto__` is the constructor's
|
|
159
|
+
* `prototype`, which knows its constructor, given to the constructor;
|
|
160
|
+
* a native constructor's result is the result. Anything but a function
|
|
161
|
+
* constructs undefined.
|
|
162
|
+
*/
|
|
163
|
+
construct(constr, args, version) {
|
|
164
|
+
if (!(constr instanceof Avm1Function)) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
const prototype = constr.own("prototype", version);
|
|
168
|
+
const self = new Avm1Object(prototype?.value);
|
|
169
|
+
if (version < 7) {
|
|
170
|
+
self.define("constructor", constr, DONT_ENUM);
|
|
171
|
+
}
|
|
172
|
+
self.define("__constructor__", constr, DONT_ENUM);
|
|
173
|
+
if (constr.construct !== null) {
|
|
174
|
+
return constr.construct(self, args, version);
|
|
175
|
+
}
|
|
176
|
+
constr.initialize(self, args, version);
|
|
177
|
+
return self;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* DefineFunction's function of `region`, in the activation `cx` that
|
|
181
|
+
* defines it: its scope, constant pool and clip kept, a new `prototype`
|
|
182
|
+
* whose `constructor` it is.
|
|
183
|
+
*/
|
|
184
|
+
newFunction(cx, region, params, flags, version) {
|
|
185
|
+
const fn = new ScriptFunction(this.functionProto, this, region, cx.code, params, flags, version, cx.scope, cx.pool, cx.base, cx.host.objectOf?.(cx.base) ?? cx.clip, version < 6 ? undefined : cx.self);
|
|
186
|
+
const prototype = new Avm1Object(this.objectProto);
|
|
187
|
+
prototype.define("constructor", fn, DONT_ENUM);
|
|
188
|
+
fn.define("prototype", prototype, DONT_ENUM | DONT_DELETE);
|
|
189
|
+
return fn;
|
|
190
|
+
}
|
|
191
|
+
/** `arguments` or `super` of a function's activation object, as it is first asked for. */
|
|
192
|
+
pendingLocal(cx, o, name, version) {
|
|
193
|
+
return pendingLocal(cx, o, name, version);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* `value[name]` of a primitive, as Flash finds it on the object boxing it,
|
|
197
|
+
* without making one: its own `length`, `__constructor__` and
|
|
198
|
+
* `constructor` up to SWF 6, then its class's prototype, with the
|
|
199
|
+
* primitive as `this`. A class replaced on `_global` boxes it.
|
|
200
|
+
*/
|
|
201
|
+
primitiveMember(value, name, version) {
|
|
202
|
+
const boxName_ = boxName(value);
|
|
203
|
+
if (boxName_ === null) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
const constr = this.global.own(boxName_, version)?.value;
|
|
207
|
+
const builtin = constr === this.String.constr ||
|
|
208
|
+
constr === this.Number.constr ||
|
|
209
|
+
constr === this.Boolean.constr;
|
|
210
|
+
if (!builtin) {
|
|
211
|
+
return get(this.box(value, version), name, version);
|
|
212
|
+
}
|
|
213
|
+
const prototype = constr.own("prototype", version);
|
|
214
|
+
const key = caseSensitive(version) ? name : fold(name);
|
|
215
|
+
switch (key) {
|
|
216
|
+
case "__proto__":
|
|
217
|
+
if (prototype !== undefined) {
|
|
218
|
+
return prototype.value;
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
case "__constructor__":
|
|
222
|
+
return constr;
|
|
223
|
+
case "constructor":
|
|
224
|
+
if (version < 7) {
|
|
225
|
+
return constr;
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
case "length":
|
|
229
|
+
if (typeof value === "string") {
|
|
230
|
+
return value.length;
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
const proto = prototype?.value;
|
|
235
|
+
return proto instanceof Avm1Object ? get(proto, name, version, value) : undefined;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A class with its own prototype object, in Flash's order: `prototype`,
|
|
239
|
+
* `constructor`, `__proto__`; `flags` adds to `prototype`'s attributes.
|
|
240
|
+
*/
|
|
241
|
+
classOf(proto, construct, call, flags = 0) {
|
|
242
|
+
const constr = new Avm1Function(undefined, this, call, construct);
|
|
243
|
+
constr.define("prototype", proto, DONT_ENUM | DONT_DELETE | flags);
|
|
244
|
+
constr.define("constructor", this.Function ?? constr, DONT_ENUM | DONT_DELETE);
|
|
245
|
+
constr.define("__proto__", this.functionProto, DONT_ENUM | DONT_DELETE | VERSION_6);
|
|
246
|
+
proto.define("constructor", constr, DONT_ENUM | DONT_DELETE);
|
|
247
|
+
return constr;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Error, as far as Throw's values need it: a `message` and a `name`,
|
|
251
|
+
* both "Error" on the prototype and listed by for..in, as adl has them,
|
|
252
|
+
* and a `toString` that gives the message. Called as a function it gives
|
|
253
|
+
* undefined. Step 9 completes the classes.
|
|
254
|
+
*/
|
|
255
|
+
errorClass() {
|
|
256
|
+
const proto = new Avm1Object(this.objectProto);
|
|
257
|
+
const constr = this.classOf(proto, (self, args, version) => {
|
|
258
|
+
if (args.length > 0 && args[0] !== undefined) {
|
|
259
|
+
set(self, "message", args[0], version);
|
|
260
|
+
}
|
|
261
|
+
return self;
|
|
262
|
+
}, () => undefined);
|
|
263
|
+
proto.define("message", "Error", 0);
|
|
264
|
+
proto.define("name", "Error", 0);
|
|
265
|
+
proto.define("toString", this.method((self, _, version) => get(self, "message", version)), 0);
|
|
266
|
+
return { constr, proto };
|
|
267
|
+
}
|
|
268
|
+
/** A new array of `elements`, as InitArray makes it. */
|
|
269
|
+
newArray(elements, version) {
|
|
270
|
+
const self = new Avm1Object();
|
|
271
|
+
const constr = this.global.own("Array", version)?.value;
|
|
272
|
+
const prototype = constr instanceof Avm1Object ? constr.own("prototype", version) : undefined;
|
|
273
|
+
if (prototype !== undefined) {
|
|
274
|
+
self.define("__proto__", prototype.value, DONT_ENUM | DONT_DELETE);
|
|
275
|
+
}
|
|
276
|
+
if (constr instanceof Avm1Object) {
|
|
277
|
+
self.define("constructor", constr, DONT_ENUM | DONT_DELETE);
|
|
278
|
+
}
|
|
279
|
+
return this.fillArray(self, elements, version);
|
|
280
|
+
}
|
|
281
|
+
/** `self` made an array of `elements`, then its `length`. */
|
|
282
|
+
fillArray(self, elements, _version) {
|
|
283
|
+
self.array = true;
|
|
284
|
+
if (self.elems === null && !hasIndex(self)) {
|
|
285
|
+
self.elems = [];
|
|
286
|
+
}
|
|
287
|
+
const elems = self.elems;
|
|
288
|
+
if (elems !== null && elems.length === 0) {
|
|
289
|
+
// A new array's elements, straight to their places.
|
|
290
|
+
for (let i = 0; i < elements.length; i++) {
|
|
291
|
+
elems.push(new Property(String(i), elements[i], 0));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
for (let i = 0; i < elements.length; i++) {
|
|
296
|
+
self.define(String(i), elements[i], 0);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
self.define("length", elements.length, DONT_ENUM | DONT_DELETE);
|
|
300
|
+
return self;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* A new object as InitObject makes one: `_global.Object` its
|
|
304
|
+
* `constructor`, which adl has before `__proto__`, its `prototype`.
|
|
305
|
+
*/
|
|
306
|
+
newObject(version) {
|
|
307
|
+
const self = new Avm1Object();
|
|
308
|
+
const constr = this.global.own("Object", version)?.value;
|
|
309
|
+
if (constr instanceof Avm1Object) {
|
|
310
|
+
self.define("constructor", constr, DONT_ENUM | DONT_DELETE);
|
|
311
|
+
const prototype = constr.own("prototype", version);
|
|
312
|
+
if (prototype !== undefined) {
|
|
313
|
+
self.define("__proto__", prototype.value, DONT_ENUM | DONT_DELETE);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return self;
|
|
317
|
+
}
|
|
318
|
+
/** Function.prototype's `call` and `apply`: `this` an object, the global object for none. */
|
|
319
|
+
functionPrototype() {
|
|
320
|
+
const proto = this.functionProto;
|
|
321
|
+
const thisOf = (args, version) => {
|
|
322
|
+
const v = first(args);
|
|
323
|
+
return v === undefined || v === null ? this.global : this.box(v, version);
|
|
324
|
+
};
|
|
325
|
+
proto.define("call", this.method((self, args, version) => invoke(self, thisOf(args, version), args.slice(1), version, 1)), DONT_ENUM | DONT_DELETE);
|
|
326
|
+
proto.define("apply", this.method((self, args, version) => {
|
|
327
|
+
const list = args.length > 1 ? args[1] : undefined;
|
|
328
|
+
const elements = [];
|
|
329
|
+
if (list instanceof Avm1Object) {
|
|
330
|
+
const length = list.array
|
|
331
|
+
? lengthOf(list)
|
|
332
|
+
: toNumber(get(list, "length", version), version);
|
|
333
|
+
// A length far past any list's is cut short, as no SWF gives one.
|
|
334
|
+
const n = Math.min(length | 0, 1 << 20);
|
|
335
|
+
for (let i = 0; i < n; i++) {
|
|
336
|
+
elements.push(get(list, String(i), version));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return invoke(self, thisOf(args, version), elements, version, 1);
|
|
340
|
+
}), DONT_ENUM | DONT_DELETE);
|
|
341
|
+
}
|
|
342
|
+
objectPrototype() {
|
|
343
|
+
const proto = this.objectProto;
|
|
344
|
+
const v6 = DONT_ENUM | DONT_DELETE | VERSION_6;
|
|
345
|
+
// ASnative(101, i): the methods in the order defined, then registerClass (the player's) and Object.
|
|
346
|
+
const table = [];
|
|
347
|
+
const define = (name, flags, native) => {
|
|
348
|
+
if (name !== "toLocaleString") {
|
|
349
|
+
table.push(native);
|
|
350
|
+
}
|
|
351
|
+
proto.define(name, this.method(native), flags);
|
|
352
|
+
};
|
|
353
|
+
this.natives.set(101, (i) => i === 9 ? this.Object.construct : i === 8 ? () => undefined : (table[i] ?? null));
|
|
354
|
+
define("watch", v6, (self, args, version) => {
|
|
355
|
+
if (args.length === 0) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
const name = nameOf(args[0], version);
|
|
359
|
+
const callback = this.box(args.length > 1 ? args[1] : undefined, version);
|
|
360
|
+
if (!(callback instanceof Avm1Function)) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
const data = args.length > 2 ? args[2] : undefined;
|
|
364
|
+
const w = self.watcher(name, version);
|
|
365
|
+
if (w !== undefined) {
|
|
366
|
+
w.callback = callback;
|
|
367
|
+
w.data = data;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
self.watchers ??= [];
|
|
371
|
+
self.watchers.push({ name, callback, data, calls: 0 });
|
|
372
|
+
}
|
|
373
|
+
return true;
|
|
374
|
+
});
|
|
375
|
+
define("unwatch", v6, (self, args, version) => {
|
|
376
|
+
if (args.length === 0 || self.watchers === null) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
const w = self.watcher(nameOf(args[0], version), version);
|
|
380
|
+
if (w === undefined) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
self.watchers.splice(self.watchers.indexOf(w), 1);
|
|
384
|
+
return true;
|
|
385
|
+
});
|
|
386
|
+
define("addProperty", v6, (self, args, version) => {
|
|
387
|
+
if (args.length === 0) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
const name = nameOf(args[0], version);
|
|
391
|
+
const getter = args.length > 1 ? args[1] : undefined;
|
|
392
|
+
const setter = args.length > 2 ? args[2] : undefined;
|
|
393
|
+
// adl takes functions only, and null for no setter.
|
|
394
|
+
if (!(getter instanceof Avm1Function) || name === "") {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
if (!(setter instanceof Avm1Function) && setter !== null) {
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
let p = self.own(name, version);
|
|
401
|
+
if (p === undefined) {
|
|
402
|
+
p = self.add(name, undefined, setter === null ? READ_ONLY : 0);
|
|
403
|
+
}
|
|
404
|
+
p.get = getter;
|
|
405
|
+
p.set = setter;
|
|
406
|
+
// An index's property lengthens an array as its element would (adl).
|
|
407
|
+
if (self.array && p.get !== null && fold(name) !== "length") {
|
|
408
|
+
arraySet(self, name, undefined, version);
|
|
409
|
+
}
|
|
410
|
+
return true;
|
|
411
|
+
});
|
|
412
|
+
define("valueOf", DONT_ENUM | DONT_DELETE, (self) => self);
|
|
413
|
+
define("toString", DONT_ENUM | DONT_DELETE, (self) => self instanceof Avm1Function ? "[type Function]" : "[object Object]");
|
|
414
|
+
// adl's hasOwnProperty does not see a property with ASSetPropFlags' bit 0x100.
|
|
415
|
+
define("hasOwnProperty", v6, (self, args, version) => {
|
|
416
|
+
if (args.length === 0) {
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
const p = self.own(nameOf(args[0], version), version);
|
|
420
|
+
return p !== undefined && (p.flags & 0x100) === 0;
|
|
421
|
+
});
|
|
422
|
+
define("isPrototypeOf", v6, (self, args, version) => {
|
|
423
|
+
if (args.length === 0) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
let p = this.box(args[0], version).protoFor(version);
|
|
427
|
+
for (let depth = 0; p instanceof Avm1Object && depth < 255; depth++) {
|
|
428
|
+
if (p === self) {
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
p = p.protoFor(version);
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
});
|
|
435
|
+
define("isPropertyEnumerable", v6, (self, args, version) => {
|
|
436
|
+
if (args.length === 0) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
const p = self.own(nameOf(args[0], version), version);
|
|
440
|
+
return p !== undefined && (p.flags & DONT_ENUM) === 0;
|
|
441
|
+
});
|
|
442
|
+
define("toLocaleString", DONT_ENUM | DONT_DELETE, (self, _, version) => stringOf(self, version));
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/** The class on `_global` that boxes a primitive, null for undefined and null. */
|
|
446
|
+
function boxName(value) {
|
|
447
|
+
switch (typeof value) {
|
|
448
|
+
case "string":
|
|
449
|
+
return "String";
|
|
450
|
+
case "number":
|
|
451
|
+
return "Number";
|
|
452
|
+
case "boolean":
|
|
453
|
+
return "Boolean";
|
|
454
|
+
default:
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* `ASSetPropFlags(object, names, set, clear)`: the attributes of the named
|
|
460
|
+
* properties, or of all where `names` is null, cleared of `clear`'s bits
|
|
461
|
+
* and given `set`'s. Names are a string, split at commas, or what an array
|
|
462
|
+
* converts to; they are found whatever their case, in every version.
|
|
463
|
+
*/
|
|
464
|
+
function setPropFlags(realm, args, version) {
|
|
465
|
+
if (args.length === 0) {
|
|
466
|
+
return undefined;
|
|
467
|
+
}
|
|
468
|
+
const object = realm.box(args[0], version);
|
|
469
|
+
const set = args.length > 2 ? u16(args[2], version) : 0;
|
|
470
|
+
const clear = args.length > 3 ? u16(args[3], version) : 0;
|
|
471
|
+
const change = (p) => {
|
|
472
|
+
p.flags = (p.flags & ~clear) | set;
|
|
473
|
+
};
|
|
474
|
+
if (args.length < 2) {
|
|
475
|
+
return undefined;
|
|
476
|
+
}
|
|
477
|
+
if (args[1] === null) {
|
|
478
|
+
for (const p of object.ownProperties()) {
|
|
479
|
+
change(p);
|
|
480
|
+
}
|
|
481
|
+
return undefined;
|
|
482
|
+
}
|
|
483
|
+
for (const name of stringOf(args[1], version).split(",")) {
|
|
484
|
+
const p = object.own(name, 6);
|
|
485
|
+
if (p !== undefined) {
|
|
486
|
+
change(p);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* A method's call as a conversion makes it, Flash's "special" calls: no
|
|
493
|
+
* `__resolve` asked, a method that is no function giving undefined.
|
|
494
|
+
*/
|
|
495
|
+
function callMethod(object, name, version) {
|
|
496
|
+
return invoke(get(object, name, version, object, false), object, [], version);
|
|
497
|
+
}
|
|
498
|
+
objects.valueOf = (object, version) => callMethod(object, "valueOf", version);
|
|
499
|
+
objects.toPrimitive = (object, version) => {
|
|
500
|
+
// A Date adds as its string from SWF 6.
|
|
501
|
+
const o = object;
|
|
502
|
+
const value = callMethod(o, version > 5 && o.primitive instanceof DateCell ? "toString" : "valueOf", version);
|
|
503
|
+
return isPrimitive(value) ? value : object;
|
|
504
|
+
};
|
|
505
|
+
objects.toString = (object, version) => {
|
|
506
|
+
const o = object;
|
|
507
|
+
if (typeof o.primitive === "string") {
|
|
508
|
+
return o.primitive;
|
|
509
|
+
}
|
|
510
|
+
// A display object is its path, a clip's wherever its reference reaches now, "" where nothing.
|
|
511
|
+
if (o.display !== null) {
|
|
512
|
+
return o.display.live()?.display?.path() ?? "";
|
|
513
|
+
}
|
|
514
|
+
const value = callMethod(o, "toString", version);
|
|
515
|
+
if (typeof value === "string") {
|
|
516
|
+
return value;
|
|
517
|
+
}
|
|
518
|
+
return o instanceof Avm1Function ? "[type Function]" : "[type Object]";
|
|
519
|
+
};
|
|
520
|
+
objects.typeOf = (object) => object.typeOf();
|
|
521
|
+
/** Whether `o` has a property named as an element. */
|
|
522
|
+
function hasIndex(o) {
|
|
523
|
+
for (const name of o.props.keys()) {
|
|
524
|
+
if (elementIndex(name) >= 0) {
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return false;
|
|
529
|
+
}
|