@swf2es/player-hosts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// String, as Ruffle's (https://github.com/ruffle-rs/ruffle)
|
|
2
|
+
// core/src/avm1/globals/string.rs has it: MIT OR Apache-2.0, Copyright (c)
|
|
3
|
+
// 2018-2022 Ruffle LLC and Ruffle contributors. Where adl parts from
|
|
4
|
+
// Ruffle, adl decides (docs/avm1.md, "Array and String").
|
|
5
|
+
//
|
|
6
|
+
// The methods take `this` unboxed: a string's method call makes no String
|
|
7
|
+
// object. Up to SWF 5 a string is its bytes, each a code unit here, which
|
|
8
|
+
// the methods count and cut as they are. From SWF 6 they cut UTF-16 code
|
|
9
|
+
// units, and keep half a surrogate pair as it is, which joins its other
|
|
10
|
+
// half again (adl), unlike StringExtract's (operators.ts).
|
|
11
|
+
import { lowerCase, upperCase } from "../case.js";
|
|
12
|
+
import { Avm1Object, DONT_DELETE, DONT_ENUM, } from "../objects.js";
|
|
13
|
+
import { stringOf, toNumber } from "../values.js";
|
|
14
|
+
const toInt = (value, version) => toNumber(value, version) | 0;
|
|
15
|
+
/** An index as slice and substr take one: from the end where negative, within 0 and `length`. */
|
|
16
|
+
function wrapping(i, length) {
|
|
17
|
+
return i < 0 ? Math.max(length + i, 0) : Math.min(i, length);
|
|
18
|
+
}
|
|
19
|
+
/** An index as substring takes one: within 0 and `length`. */
|
|
20
|
+
const clamped = (i, length) => (i < 0 ? 0 : Math.min(i, length));
|
|
21
|
+
/** Each code unit of `s` mapped by `map`; up to SWF 5, a byte's mapping only to a byte. */
|
|
22
|
+
function mapped(s, map, bytes) {
|
|
23
|
+
let out = "";
|
|
24
|
+
let changed = false;
|
|
25
|
+
for (let i = 0; i < s.length; i++) {
|
|
26
|
+
const c = s.charCodeAt(i);
|
|
27
|
+
let m = map(c);
|
|
28
|
+
if (bytes && m > 0xff) {
|
|
29
|
+
m = c;
|
|
30
|
+
}
|
|
31
|
+
changed ||= m !== c;
|
|
32
|
+
out += String.fromCharCode(m);
|
|
33
|
+
}
|
|
34
|
+
return changed ? out : s;
|
|
35
|
+
}
|
|
36
|
+
/** The class: its constructor, prototype and methods. */
|
|
37
|
+
export function stringClass(realm) {
|
|
38
|
+
const proto = new Avm1Object();
|
|
39
|
+
const constr = realm.classOf(proto, (self, args, version) => {
|
|
40
|
+
const s = args.length > 0 ? stringOf(args[0], version) : "";
|
|
41
|
+
self.primitive = s;
|
|
42
|
+
self.define("length", s.length, DONT_ENUM | DONT_DELETE);
|
|
43
|
+
return self;
|
|
44
|
+
}, (_, args, version) => (args.length > 0 ? stringOf(args[0], version) : ""));
|
|
45
|
+
proto.define("__proto__", realm.objectProto, DONT_ENUM | DONT_DELETE);
|
|
46
|
+
/** `this` as the string the methods work on: a String's own, else what it converts to. */
|
|
47
|
+
const text = (self, version) => {
|
|
48
|
+
if (typeof self === "string") {
|
|
49
|
+
return self;
|
|
50
|
+
}
|
|
51
|
+
const o = realm.box(self, version);
|
|
52
|
+
return typeof o.primitive === "string" ? o.primitive : stringOf(o, version);
|
|
53
|
+
};
|
|
54
|
+
const define = (name, native) => proto.define(name, realm.rawMethod(native), DONT_ENUM | DONT_DELETE);
|
|
55
|
+
// A String's own string, but undefined for anything else; valueOf gives
|
|
56
|
+
// anything else as a string, by its toString (adl; Ruffle gives undefined).
|
|
57
|
+
const own = (self) => {
|
|
58
|
+
if (typeof self === "string") {
|
|
59
|
+
return self;
|
|
60
|
+
}
|
|
61
|
+
return self instanceof Avm1Object && typeof self.primitive === "string"
|
|
62
|
+
? self.primitive
|
|
63
|
+
: undefined;
|
|
64
|
+
};
|
|
65
|
+
define("valueOf", (self, _, version) => own(self) ?? text(self, version));
|
|
66
|
+
define("toString", (self) => own(self));
|
|
67
|
+
define("toUpperCase", (self, _, version) => mapped(text(self, version), upperCase, version < 6));
|
|
68
|
+
define("toLowerCase", (self, _, version) => mapped(text(self, version), lowerCase, version < 6));
|
|
69
|
+
define("charAt", (self, args, version) => {
|
|
70
|
+
const s = text(self, version);
|
|
71
|
+
const i = toInt(args.length > 0 ? args[0] : undefined, version);
|
|
72
|
+
if (i < 0 || i >= s.length) {
|
|
73
|
+
return "";
|
|
74
|
+
}
|
|
75
|
+
return s[i];
|
|
76
|
+
});
|
|
77
|
+
define("charCodeAt", (self, args, version) => {
|
|
78
|
+
const s = text(self, version);
|
|
79
|
+
const i = toInt(args.length > 0 ? args[0] : undefined, version);
|
|
80
|
+
if (i >= 0 && i < s.length) {
|
|
81
|
+
return s.charCodeAt(i);
|
|
82
|
+
}
|
|
83
|
+
// A SWF 5 has 0 past the end.
|
|
84
|
+
return i >= 0 && version === 5 ? 0 : Number.NaN;
|
|
85
|
+
});
|
|
86
|
+
define("concat", (self, args, version) => {
|
|
87
|
+
let s = text(self, version);
|
|
88
|
+
for (const arg of args) {
|
|
89
|
+
s += stringOf(arg, version);
|
|
90
|
+
}
|
|
91
|
+
return s;
|
|
92
|
+
});
|
|
93
|
+
define("indexOf", (self, args, version) => {
|
|
94
|
+
const s = text(self, version);
|
|
95
|
+
if (args.length === 0) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
const pattern = stringOf(args[0], version);
|
|
99
|
+
const start = args.length > 1 && args[1] !== undefined ? Math.max(toInt(args[1], version), 0) : 0;
|
|
100
|
+
return start > s.length ? -1 : s.indexOf(pattern, start);
|
|
101
|
+
});
|
|
102
|
+
define("lastIndexOf", (self, args, version) => {
|
|
103
|
+
const s = text(self, version);
|
|
104
|
+
if (args.length === 0) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
const pattern = stringOf(args[0], version);
|
|
108
|
+
let end = s.length;
|
|
109
|
+
if (args.length > 1 && args[1] !== undefined) {
|
|
110
|
+
const i = toInt(args[1], version);
|
|
111
|
+
if (i < 0) {
|
|
112
|
+
return -1;
|
|
113
|
+
}
|
|
114
|
+
end = Math.min(i + pattern.length, s.length);
|
|
115
|
+
}
|
|
116
|
+
const found = s.lastIndexOf(pattern, end - pattern.length);
|
|
117
|
+
return found >= 0 && found + pattern.length <= end ? found : -1;
|
|
118
|
+
});
|
|
119
|
+
define("slice", (self, args, version) => {
|
|
120
|
+
if (args.length === 0) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
const s = text(self, version);
|
|
124
|
+
const start = wrapping(toInt(args[0], version), s.length);
|
|
125
|
+
const end = args.length > 1 && args[1] !== undefined
|
|
126
|
+
? wrapping(toInt(args[1], version), s.length)
|
|
127
|
+
: s.length;
|
|
128
|
+
return start < end ? s.slice(start, end) : "";
|
|
129
|
+
});
|
|
130
|
+
define("substring", (self, args, version) => {
|
|
131
|
+
if (args.length === 0) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
const s = text(self, version);
|
|
135
|
+
let start = clamped(toInt(args[0], version), s.length);
|
|
136
|
+
// adl: nothing from the end on, whatever the end (Ruffle swaps first).
|
|
137
|
+
if (start >= s.length) {
|
|
138
|
+
return "";
|
|
139
|
+
}
|
|
140
|
+
let end = args.length > 1 && args[1] !== undefined
|
|
141
|
+
? clamped(toInt(args[1], version), s.length)
|
|
142
|
+
: s.length;
|
|
143
|
+
if (end < start) {
|
|
144
|
+
[start, end] = [end, start];
|
|
145
|
+
}
|
|
146
|
+
return s.slice(start, end);
|
|
147
|
+
});
|
|
148
|
+
define("split", (self, args, version) => {
|
|
149
|
+
const s = text(self, version);
|
|
150
|
+
const limitArg = args.length > 1 ? args[1] : undefined;
|
|
151
|
+
const limit = limitArg === undefined ? Number.POSITIVE_INFINITY : Math.max(toInt(limitArg, version), 0);
|
|
152
|
+
const d = args.length > 0 ? args[0] : undefined;
|
|
153
|
+
const take = (parts) => realm.newArray(limit < parts.length ? parts.slice(0, limit) : parts, version);
|
|
154
|
+
// A SWF 5 splits at commas by default, and only at one character: an
|
|
155
|
+
// empty delimiter leaves the string whole whatever the limit, a longer
|
|
156
|
+
// one within it (adl).
|
|
157
|
+
if (version < 6) {
|
|
158
|
+
const delimiter = d === undefined ? "," : stringOf(d, version);
|
|
159
|
+
if (delimiter === "") {
|
|
160
|
+
return realm.newArray([s], version);
|
|
161
|
+
}
|
|
162
|
+
return take(delimiter.length === 1 ? s.split(delimiter) : [s]);
|
|
163
|
+
}
|
|
164
|
+
// Without a delimiter, the string whole whatever the limit; an empty
|
|
165
|
+
// string so too, but split by "" (adl).
|
|
166
|
+
if (d === undefined) {
|
|
167
|
+
return realm.newArray([s], version);
|
|
168
|
+
}
|
|
169
|
+
const delimiter = stringOf(d, version);
|
|
170
|
+
if (s === "" && delimiter !== "") {
|
|
171
|
+
return realm.newArray([s], version);
|
|
172
|
+
}
|
|
173
|
+
return take(delimiter === "" ? s.split("") : s.split(delimiter));
|
|
174
|
+
});
|
|
175
|
+
define("substr", (self, args, version) => {
|
|
176
|
+
if (args.length === 0) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
const s = text(self, version);
|
|
180
|
+
const start = wrapping(toInt(args[0], version), s.length);
|
|
181
|
+
const count = args.length > 1 && args[1] !== undefined ? toInt(args[1], version) : s.length;
|
|
182
|
+
const end = wrapping(start + count, s.length);
|
|
183
|
+
return start < end ? s.slice(start, end) : "";
|
|
184
|
+
});
|
|
185
|
+
constr.define("fromCharCode", realm.method((_, args, version) => {
|
|
186
|
+
let s = "";
|
|
187
|
+
for (const arg of args) {
|
|
188
|
+
const code = toNumber(arg, version) & 0xffff;
|
|
189
|
+
if (code === 0) {
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
// A SWF 5's string is bytes: a code past 0xFF is two, the high one first.
|
|
193
|
+
s +=
|
|
194
|
+
version < 6 && code > 0xff
|
|
195
|
+
? String.fromCharCode(code >> 8, code & 0xff)
|
|
196
|
+
: String.fromCharCode(code);
|
|
197
|
+
}
|
|
198
|
+
return s;
|
|
199
|
+
}), DONT_ENUM | DONT_DELETE);
|
|
200
|
+
return { constr, proto };
|
|
201
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// setInterval, setTimeout, clearInterval and clearTimeout (docs/avm1.md,
|
|
2
|
+
// "Time"), as Ruffle's (https://github.com/ruffle-rs/ruffle)
|
|
3
|
+
// core/src/timer.rs and avm1/globals.rs (create_timer) have them: MIT OR
|
|
4
|
+
// Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors.
|
|
5
|
+
// The timers are the runtime's, the clock the player's: it tells the
|
|
6
|
+
// runtime the time and asks it to fire what is due between frames.
|
|
7
|
+
import { Avm1Function, Avm1Object } from "../objects.js";
|
|
8
|
+
import { toInt32 } from "../operators.js";
|
|
9
|
+
import { stringOf } from "../values.js";
|
|
10
|
+
/** The shortest interval a timer has, in ms, as Ruffle has it: Flash fires none much faster. */
|
|
11
|
+
const MIN_INTERVAL = 10;
|
|
12
|
+
/** A timer: a function to call, or an object and the name of its method, every `interval` ms. */
|
|
13
|
+
export class Timer {
|
|
14
|
+
id;
|
|
15
|
+
callback;
|
|
16
|
+
method;
|
|
17
|
+
args;
|
|
18
|
+
interval;
|
|
19
|
+
due;
|
|
20
|
+
once;
|
|
21
|
+
seq;
|
|
22
|
+
constructor(id, callback,
|
|
23
|
+
/** The method's name, null where `callback` is the function. */
|
|
24
|
+
method, args, interval,
|
|
25
|
+
/** When it falls due next, in the clock's ms. */
|
|
26
|
+
due,
|
|
27
|
+
/** setTimeout's: it fires once. */
|
|
28
|
+
once,
|
|
29
|
+
/** Its place among those due at once: the one set first fires first. */
|
|
30
|
+
seq) {
|
|
31
|
+
this.id = id;
|
|
32
|
+
this.callback = callback;
|
|
33
|
+
this.method = method;
|
|
34
|
+
this.args = args;
|
|
35
|
+
this.interval = interval;
|
|
36
|
+
this.due = due;
|
|
37
|
+
this.once = once;
|
|
38
|
+
this.seq = seq;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** A runtime's timers, by when they fall due. */
|
|
42
|
+
export class Timers {
|
|
43
|
+
/** The time now on the player's clock, in ms: a timer set now counts from it. */
|
|
44
|
+
now = 0;
|
|
45
|
+
counter = 0;
|
|
46
|
+
seq = 0;
|
|
47
|
+
list = [];
|
|
48
|
+
get size() {
|
|
49
|
+
return this.list.length;
|
|
50
|
+
}
|
|
51
|
+
/** A new timer, its id: from 1, as Flash never gives 0. */
|
|
52
|
+
add(callback, method, args, interval, once) {
|
|
53
|
+
this.counter = (this.counter + 1) | 0;
|
|
54
|
+
const ms = Math.max(interval, MIN_INTERVAL);
|
|
55
|
+
this.list.push(new Timer(this.counter, callback, method, args, ms, this.now + ms, once, this.seq++));
|
|
56
|
+
return this.counter;
|
|
57
|
+
}
|
|
58
|
+
/** Clear timer `id`: whether there was one. */
|
|
59
|
+
remove(id) {
|
|
60
|
+
const i = this.list.findIndex((t) => t.id === id);
|
|
61
|
+
if (i < 0) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
this.list.splice(i, 1);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
has(timer) {
|
|
68
|
+
return this.list.includes(timer);
|
|
69
|
+
}
|
|
70
|
+
/** The timer due first by `time`, of two due at once the one set first; null for none. */
|
|
71
|
+
due(time) {
|
|
72
|
+
let first = null;
|
|
73
|
+
for (const t of this.list) {
|
|
74
|
+
if (t.due <= time &&
|
|
75
|
+
(first === null || t.due < first.due || (t.due === first.due && t.seq < first.seq))) {
|
|
76
|
+
first = t;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return first;
|
|
80
|
+
}
|
|
81
|
+
/** `timer` fired: due again an interval on, or gone for a timeout. */
|
|
82
|
+
fired(timer) {
|
|
83
|
+
if (timer.once) {
|
|
84
|
+
this.remove(timer.id);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
timer.due += timer.interval;
|
|
88
|
+
timer.seq = this.seq++;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
clear() {
|
|
92
|
+
this.list.length = 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* setInterval's and setTimeout's native: `(function, interval, ...args)`
|
|
97
|
+
* or `(object, name, interval, ...args)`; undefined where there is no
|
|
98
|
+
* callback or no interval.
|
|
99
|
+
*/
|
|
100
|
+
function create(realm, args, version, once) {
|
|
101
|
+
const first = args.length > 0 ? args[0] : undefined;
|
|
102
|
+
if (!(first instanceof Avm1Object)) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const isFunction = first instanceof Avm1Function;
|
|
106
|
+
const interval = isFunction ? args[1] : args[2];
|
|
107
|
+
if (interval === undefined) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const method = isFunction ? null : stringOf(args.length > 1 ? args[1] : undefined, version);
|
|
111
|
+
const rest = args.slice(isFunction ? 2 : 3);
|
|
112
|
+
return realm.timers.add(first, method, rest, toInt32(interval, version), once);
|
|
113
|
+
}
|
|
114
|
+
/** The timer natives, in Flash's order on `_global`, and ASnative(250, i): setInterval, clearInterval, setTimeout. */
|
|
115
|
+
export function timerFunctions(realm) {
|
|
116
|
+
const setInterval = (_, args, version) => create(realm, args, version, false);
|
|
117
|
+
const setTimeout = (_, args, version) => create(realm, args, version, true);
|
|
118
|
+
const clear = (_, args, version) => {
|
|
119
|
+
realm.timers.remove(toInt32(args.length > 0 ? args[0] : undefined, version));
|
|
120
|
+
return undefined;
|
|
121
|
+
};
|
|
122
|
+
realm.natives.set(250, (i) => [setInterval, clear, setTimeout][i] ?? null);
|
|
123
|
+
return [
|
|
124
|
+
["setInterval", setInterval],
|
|
125
|
+
["clearTimeout", clear],
|
|
126
|
+
["clearInterval", clear],
|
|
127
|
+
["setTimeout", setTimeout],
|
|
128
|
+
];
|
|
129
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// What AVM1 code asks of the player, which has the display list the
|
|
2
|
+
// runtime does not (docs/avm1.md, "Where each piece lives"). A clip is the
|
|
3
|
+
// player's, opaque here.
|
|
4
|
+
/** What a display object's AVM1 object found for a name that is none of its own properties: nothing. */
|
|
5
|
+
export const ABSENT = Symbol("absent");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The AVM1 (AS1 and AS2) runtime: values, their conversions by version, and what modules call. */
|
|
2
|
+
export { goto } from "./clips.js";
|
|
3
|
+
export { Avm1Super, ScriptFunction } from "./functions.js";
|
|
4
|
+
export { broadcastMessage, initializeBroadcaster } from "./globals/broadcaster.js";
|
|
5
|
+
export { DateCell } from "./globals/date.js";
|
|
6
|
+
export { escapeAvm1, parseIntAvm1, unescapeAvm1 } from "./globals/global.js";
|
|
7
|
+
export { ABSENT, } from "./host.js";
|
|
8
|
+
export { numberToString, parseFloatAvm1, stringToNumber } from "./numbers.js";
|
|
9
|
+
export { Avm1Function, Avm1Object, allowed, caseSensitive, DONT_DELETE, DONT_ENUM, find, fold, get, has, invoke, keys, markNames, Property, READ_ONLY, removeOwn, set, VERSION_6, VERSION_7, VERSION_8, } from "./objects.js";
|
|
10
|
+
export { Realm } from "./realm.js";
|
|
11
|
+
export { Activation, Avm1Throw, Disabled, Halt, NotYet, OwnUnits, Runtime, TimedOut, } from "./runtime.js";
|
|
12
|
+
export { Scope, targetPath } from "./scope.js";
|
|
13
|
+
export { getUrlMethod } from "./urls.js";
|
|
14
|
+
export { isPrimitive, objects, stringOf, toBoolean, toNumber, typeOf, } from "./values.js";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// AS2's classes as the compiler writes them: Extends, InstanceOf, CastOp
|
|
2
|
+
// and ImplementsOp, as Ruffle's (https://github.com/ruffle-rs/ruffle)
|
|
3
|
+
// core/src/avm1/activation.rs and object.rs (is_instance_of) have them:
|
|
4
|
+
// MIT OR Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle
|
|
5
|
+
// contributors. Where adl parts from Ruffle, adl decides (docs/avm1.md,
|
|
6
|
+
// "Classes").
|
|
7
|
+
import { Avm1Object, DONT_ENUM, get, set, VERSION_6 } from "./objects.js";
|
|
8
|
+
import { isPrimitive, toNumber } from "./values.js";
|
|
9
|
+
/** What Flash's log says of a primitive where an action takes an object. */
|
|
10
|
+
export const PRIMITIVE = "Parameters of primitive types are no longer coerced into the required type - Object.";
|
|
11
|
+
/** And of an object where it takes a number. */
|
|
12
|
+
const OBJECT = "Parameters of type Object are no longer coerced into the required primitive type - number.";
|
|
13
|
+
/** A primitive where an object is taken: undefined and null say nothing, any other writes to the log. */
|
|
14
|
+
function refuse(cx, value) {
|
|
15
|
+
if (value !== undefined && value !== null) {
|
|
16
|
+
cx.host.trace(PRIMITIVE);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** The deepest a prototype chain is walked, as objects.ts walks one. */
|
|
20
|
+
const DEPTH = 255;
|
|
21
|
+
/**
|
|
22
|
+
* A class's or an interface's `prototype` as InstanceOf and ImplementsOp
|
|
23
|
+
* read it: its own stored value, no getter called, nothing inherited.
|
|
24
|
+
*/
|
|
25
|
+
function prototypeOf(o, version) {
|
|
26
|
+
return o.own("prototype", version)?.value;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether `value` is an instance of `constr`: its `prototype` on the
|
|
30
|
+
* object's chain, or among the interfaces of one there, and theirs. A
|
|
31
|
+
* primitive class, or prototype, is boxed, by `_global`'s class.
|
|
32
|
+
*/
|
|
33
|
+
export function instanceOf(realm, value, constr, version) {
|
|
34
|
+
if (!(value instanceof Avm1Object) || constr === undefined || constr === null) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
let prototype = prototypeOf(realm.box(constr, version), version);
|
|
38
|
+
if (isPrimitive(prototype) && prototype !== undefined && prototype !== null) {
|
|
39
|
+
prototype = realm.box(prototype, version);
|
|
40
|
+
}
|
|
41
|
+
if (!(prototype instanceof Avm1Object)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
let p = value.protoFor(version);
|
|
45
|
+
for (let depth = 0; p instanceof Avm1Object && depth < DEPTH; depth++) {
|
|
46
|
+
if (p === prototype) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (p.interfaces !== null && implementsOf(p.interfaces, prototype, 0)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
p = p.protoFor(version);
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
/** Whether `prototype` is among `interfaces`, or theirs. */
|
|
57
|
+
function implementsOf(interfaces, prototype, depth) {
|
|
58
|
+
for (const i of interfaces) {
|
|
59
|
+
if (i === prototype) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (i.interfaces !== null &&
|
|
63
|
+
depth < DEPTH &&
|
|
64
|
+
implementsOf(i.interfaces, prototype, depth + 1)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extends: the subclass's `prototype` a new object whose prototype is the
|
|
72
|
+
* superclass's, which knows its `__constructor__` but has no `constructor`
|
|
73
|
+
* of its own (adl; Ruffle gives it one). A primitive on either side
|
|
74
|
+
* changes nothing (adl).
|
|
75
|
+
*/
|
|
76
|
+
export function extend(cx, superclass, subclass, version) {
|
|
77
|
+
if (!(superclass instanceof Avm1Object)) {
|
|
78
|
+
refuse(cx, superclass);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!(subclass instanceof Avm1Object)) {
|
|
82
|
+
refuse(cx, subclass);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// `__constructor__` is hidden from a SWF 5 (adl).
|
|
86
|
+
const prototype = new Avm1Object(get(superclass, "prototype", version));
|
|
87
|
+
prototype.define("__constructor__", superclass, DONT_ENUM | VERSION_6);
|
|
88
|
+
set(subclass, "prototype", prototype, version);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* ImplementsOp: the constructor, the interfaces' count and the interfaces
|
|
92
|
+
* popped, the interfaces' prototypes given to the constructor's: only the
|
|
93
|
+
* first time, as adl has it (Ruffle replaces them), and from SWF 6 too.
|
|
94
|
+
*/
|
|
95
|
+
export function implementsOp(cx, version) {
|
|
96
|
+
const st = cx.st;
|
|
97
|
+
const constr = st.pop();
|
|
98
|
+
if (!(constr instanceof Avm1Object)) {
|
|
99
|
+
refuse(cx, constr);
|
|
100
|
+
}
|
|
101
|
+
const countValue = st.pop();
|
|
102
|
+
let count = 0;
|
|
103
|
+
if (isPrimitive(countValue)) {
|
|
104
|
+
count = toNumber(countValue, version) | 0;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
cx.host.trace(OBJECT);
|
|
108
|
+
}
|
|
109
|
+
count = Math.min(count, st.length);
|
|
110
|
+
if (count <= 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const interfaces = [];
|
|
114
|
+
for (let k = 0; k < count; k++) {
|
|
115
|
+
const i = st.pop();
|
|
116
|
+
if (i instanceof Avm1Object) {
|
|
117
|
+
const p = prototypeOf(i, version);
|
|
118
|
+
if (p instanceof Avm1Object) {
|
|
119
|
+
interfaces.push(p);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
refuse(cx, i);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (constr instanceof Avm1Object) {
|
|
127
|
+
const prototype = prototypeOf(constr, version);
|
|
128
|
+
if (prototype instanceof Avm1Object && prototype.interfaces === null) {
|
|
129
|
+
prototype.interfaces = interfaces;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|