@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,162 @@
|
|
|
1
|
+
// Number, int, uint and Boolean, and Math, whose functions Number has
|
|
2
|
+
// copies of.
|
|
3
|
+
import { numberToString } from "../number-strings.js";
|
|
4
|
+
import { convertDoubleToString, convertDoubleToStringRadix, DTOSTR_EXPONENTIAL, DTOSTR_FIXED, DTOSTR_PRECISION, } from "../numbers.js";
|
|
5
|
+
import { conversion, plain } from "./define.js";
|
|
6
|
+
export const numberNatives = {
|
|
7
|
+
// As NumberClass::_numberToString: another radix writes the integer part only.
|
|
8
|
+
"Number.Number::_numberToString": (rt) => (n, radix) => {
|
|
9
|
+
if (radix === 10 || !Number.isFinite(n)) {
|
|
10
|
+
return numberToString(n);
|
|
11
|
+
}
|
|
12
|
+
if (radix < 2 || radix > 36) {
|
|
13
|
+
throw rt.error("RangeError", 1003, radix);
|
|
14
|
+
}
|
|
15
|
+
return convertDoubleToStringRadix(n, radix);
|
|
16
|
+
},
|
|
17
|
+
// As NumberClass::_convert: toFixed, toPrecision and toExponential.
|
|
18
|
+
"Number.Number::_convert": (rt) => (n, precision, mode) => {
|
|
19
|
+
const [min, max] = mode === DTOSTR_PRECISION ? [1, 21] : [0, 20];
|
|
20
|
+
if (precision < min || precision > max) {
|
|
21
|
+
throw rt.error("RangeError", 1002, precision, min, max);
|
|
22
|
+
}
|
|
23
|
+
switch (mode) {
|
|
24
|
+
case DTOSTR_FIXED:
|
|
25
|
+
return numberToFixed(n, precision);
|
|
26
|
+
case DTOSTR_PRECISION:
|
|
27
|
+
return numberToPrecision(n, precision);
|
|
28
|
+
default:
|
|
29
|
+
return numberToExponential(n, precision);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"Number.Number::_minValue": plain(() => Number.MIN_VALUE),
|
|
33
|
+
};
|
|
34
|
+
// toFixed, toPrecision and toExponential write avmplus' text, which is not
|
|
35
|
+
// JavaScript's, though JavaScript's methods give it for most numbers at a
|
|
36
|
+
// fraction of the cost. avmplus takes the digits D of a number x from its
|
|
37
|
+
// D2A, the shortest within half an ulp of x narrowed by 10^precision, in
|
|
38
|
+
// exact arithmetic. Scaled so that the last place written is 1, x is some y
|
|
39
|
+
// and D is within y * 2^-53 of it. toFixed and toPrecision then round D
|
|
40
|
+
// half up there, as JavaScript rounds x itself; toExponential truncates D,
|
|
41
|
+
// since avmplus rounds only on D2A's fast path, which no 53-bit mantissa
|
|
42
|
+
// takes. So where y is clear of the point where the rounding (or the
|
|
43
|
+
// truncation) changes, both write the same digits. The guards scale x by
|
|
44
|
+
// a power of ten up to 1e22, which doubles hold exactly, so f is within
|
|
45
|
+
// y * 2^-53 of y, and take JavaScript's text only where f is more than
|
|
46
|
+
// f * 2^-50 from those points. Elsewhere avmplus goes its own way: toFixed
|
|
47
|
+
// writes zeros, unrounded, for a number below its last place (0.006 to
|
|
48
|
+
// "0.00"); toPrecision never writes an exponent below 1, and keeps the
|
|
49
|
+
// exponent it had before rounding carried ("10.0" for 9.99 to 2 digits,
|
|
50
|
+
// "0.e+5" for 99999.9); toExponential leaves out "e+0", and writes 0 as
|
|
51
|
+
// "0.00e-16". tests/unit/runtime/numbers.test.ts checks every precision.
|
|
52
|
+
const powersOfTen = Array.from({ length: 23 }, (_, i) => Number(`1e${i}`));
|
|
53
|
+
/** x * 10^k, rounded once, for k from -22 to 22. */
|
|
54
|
+
function scaled(x, k) {
|
|
55
|
+
return k >= 0 ? x * powersOfTen[k] : x / powersOfTen[-k];
|
|
56
|
+
}
|
|
57
|
+
/** As Number.toFixed. */
|
|
58
|
+
export function numberToFixed(n, digits) {
|
|
59
|
+
// NaN, infinities and f past 2^49, where the tolerance reaches 0.5, fail every test.
|
|
60
|
+
const f = (n < 0 ? -n : n) * powersOfTen[digits];
|
|
61
|
+
const tolerance = f / 2 ** 50;
|
|
62
|
+
const half = f - Math.floor(f) - 0.5;
|
|
63
|
+
if ((half > tolerance || half < -tolerance) && (f < 0.5 || f > 1 + tolerance)) {
|
|
64
|
+
return n.toFixed(digits);
|
|
65
|
+
}
|
|
66
|
+
return convertDoubleToString(n, DTOSTR_FIXED, digits);
|
|
67
|
+
}
|
|
68
|
+
/** As Number.toPrecision. */
|
|
69
|
+
export function numberToPrecision(n, digits) {
|
|
70
|
+
// log10 may be one off next to a power of ten: the bounds on f catch that.
|
|
71
|
+
const x = n < 0 ? -n : n;
|
|
72
|
+
const exponent = Math.floor(Math.log10(x));
|
|
73
|
+
const k = digits - 1 - exponent;
|
|
74
|
+
if (exponent >= -6 && k >= -22 && k <= 22) {
|
|
75
|
+
const f = scaled(x, k);
|
|
76
|
+
const tolerance = f / 2 ** 50;
|
|
77
|
+
const half = f - Math.floor(f) - 0.5;
|
|
78
|
+
const clear = half > tolerance || half < -tolerance;
|
|
79
|
+
if (clear && f >= powersOfTen[digits - 1] + tolerance && f < powersOfTen[digits] - 0.5) {
|
|
80
|
+
return n.toPrecision(digits);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return convertDoubleToString(n, DTOSTR_PRECISION, digits);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* As Number.toExponential: JavaScript's digits to one place more, the last
|
|
87
|
+
* dropped, which truncates as avmplus does where rounding that place does
|
|
88
|
+
* not carry.
|
|
89
|
+
*/
|
|
90
|
+
export function numberToExponential(n, digits) {
|
|
91
|
+
const x = n < 0 ? -n : n;
|
|
92
|
+
const exponent = Math.floor(Math.log10(x));
|
|
93
|
+
const k = digits - exponent;
|
|
94
|
+
if (k >= -22 && k <= 22) {
|
|
95
|
+
const f = scaled(x, k);
|
|
96
|
+
const fraction = f - Math.floor(f);
|
|
97
|
+
const inRange = f >= powersOfTen[digits] && f < powersOfTen[digits + 1];
|
|
98
|
+
if (fraction > f / 2 ** 50 && fraction < 0.9 && inRange) {
|
|
99
|
+
const text = x.toExponential(digits + 1);
|
|
100
|
+
const e = text.indexOf("e");
|
|
101
|
+
const mantissa = text.slice(0, digits === 0 ? 1 : e - 1);
|
|
102
|
+
const written = exponent === 0 ? mantissa : mantissa + text.slice(e);
|
|
103
|
+
return n < 0 ? `-${written}` : written;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return convertDoubleToString(n, DTOSTR_EXPONENTIAL, digits);
|
|
107
|
+
}
|
|
108
|
+
// Math, and Number's copies of it.
|
|
109
|
+
for (const name of [
|
|
110
|
+
"abs",
|
|
111
|
+
"acos",
|
|
112
|
+
"asin",
|
|
113
|
+
"atan",
|
|
114
|
+
"ceil",
|
|
115
|
+
"cos",
|
|
116
|
+
"exp",
|
|
117
|
+
"floor",
|
|
118
|
+
"log",
|
|
119
|
+
"sin",
|
|
120
|
+
"sqrt",
|
|
121
|
+
"tan",
|
|
122
|
+
]) {
|
|
123
|
+
const f = Math[name];
|
|
124
|
+
const native = (rt) => (x) => f(rt.toNumber(x));
|
|
125
|
+
numberNatives[`Math.${name}`] = native;
|
|
126
|
+
numberNatives[`Number.${name}`] = native;
|
|
127
|
+
}
|
|
128
|
+
for (const prefix of ["Math", "Number"]) {
|
|
129
|
+
// As MathUtils::round, floor(x + 0.5): never -0, as JavaScript's is for -0.5 to -0.
|
|
130
|
+
numberNatives[`${prefix}.round`] = (rt) => (x) => {
|
|
131
|
+
const r = Math.round(rt.toNumber(x));
|
|
132
|
+
return r === 0 ? 0 : r;
|
|
133
|
+
};
|
|
134
|
+
numberNatives[`${prefix}.atan2`] = (rt) => (y, x) => Math.atan2(rt.toNumber(y), rt.toNumber(x));
|
|
135
|
+
numberNatives[`${prefix}.pow`] = (rt) => (x, y) => rt.toNumber(x) ** rt.toNumber(y);
|
|
136
|
+
numberNatives[`${prefix}.random`] = plain(() => Math.random());
|
|
137
|
+
// Of two declared parameters, and any more, so that their length is 2.
|
|
138
|
+
numberNatives[`${prefix}.max`] = (rt) => function (x, y) {
|
|
139
|
+
// biome-ignore lint/complexity/noArguments: all of them, however many
|
|
140
|
+
const args = arguments;
|
|
141
|
+
if (args.length === 2) {
|
|
142
|
+
return Math.max(rt.toNumber(x), rt.toNumber(y));
|
|
143
|
+
}
|
|
144
|
+
return Math.max(...Array.from(args, (a) => rt.toNumber(a)));
|
|
145
|
+
};
|
|
146
|
+
numberNatives[`${prefix}.min`] = (rt) => function (x, y) {
|
|
147
|
+
// biome-ignore lint/complexity/noArguments: all of them, however many
|
|
148
|
+
const args = arguments;
|
|
149
|
+
if (args.length === 2) {
|
|
150
|
+
return Math.min(rt.toNumber(x), rt.toNumber(y));
|
|
151
|
+
}
|
|
152
|
+
return Math.min(...Array.from(args, (a) => rt.toNumber(a)));
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
numberNatives["Math.Math::_max"] = plain((x, y) => Math.max(x, y));
|
|
156
|
+
numberNatives["Math.Math::_min"] = plain((x, y) => Math.min(x, y));
|
|
157
|
+
export const numberHooks = {
|
|
158
|
+
int: conversion((rt, args) => (args.length ? rt.toInt(args[0]) : 0)),
|
|
159
|
+
uint: conversion((rt, args) => (args.length ? rt.toUint(args[0]) : 0)),
|
|
160
|
+
Number: conversion((rt, args) => (args.length ? rt.toNumber(args[0]) : 0)),
|
|
161
|
+
Boolean: conversion((rt, args) => rt.toBoolean(args[0])),
|
|
162
|
+
};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// Object, Class, Function, Namespace and QName: their natives, and what
|
|
2
|
+
// calling or constructing Object, Namespace, QName or Function does.
|
|
3
|
+
import { formatClassName, Namespace, prefixOf, publicQname } from "../names.js";
|
|
4
|
+
import { NOT_FOUND } from "../runtime.js";
|
|
5
|
+
import { AS3, elements, plain } from "./define.js";
|
|
6
|
+
import { constructNamespace, newNamespace } from "./xml/names.js";
|
|
7
|
+
export const objectNatives = {
|
|
8
|
+
// Object
|
|
9
|
+
"Object.Object::_hasOwnProperty": (rt) => (o, v) => {
|
|
10
|
+
const name = rt.toString(v);
|
|
11
|
+
const traits = rt.traitsOf(o);
|
|
12
|
+
if (traits.find(publicQname(name, rt.userVersions)) !== 0) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
// An index of a class with its own elements, a Vector's: in range or not, no RangeError.
|
|
16
|
+
if (traits.hasIndex && /^(?:0|[1-9]\d*)$/.test(name) && Number(name) < 0xffffffff) {
|
|
17
|
+
return traits.hasIndex(o, Number(name));
|
|
18
|
+
}
|
|
19
|
+
return rt.getOwn(o, name) !== NOT_FOUND;
|
|
20
|
+
},
|
|
21
|
+
"Object.Object::_propertyIsEnumerable": (rt) => (o, v) => {
|
|
22
|
+
const name = rt.toString(v);
|
|
23
|
+
// E4X 13.2.5: a Namespace's prefix and uri are enumerable.
|
|
24
|
+
if (o instanceof Namespace) {
|
|
25
|
+
return name === "uri" || name === "prefix";
|
|
26
|
+
}
|
|
27
|
+
// A Vector's elements are not enumerable to it, in or out of range, as avmplus has it.
|
|
28
|
+
if (o?.$traits?.refusesNames) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return rt.getOwn(o, name) !== NOT_FOUND && !o.$dontEnum?.has(name);
|
|
32
|
+
},
|
|
33
|
+
"Object.Object::_setPropertyIsEnumerable": (rt) => (o, v, enumerable) => {
|
|
34
|
+
if (typeof o !== "object" || o === null) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const name = rt.toString(v);
|
|
38
|
+
if (enumerable) {
|
|
39
|
+
o.$dontEnum?.delete(name);
|
|
40
|
+
if (o.$d) {
|
|
41
|
+
// A name shown: the for-ins that found them all hidden look again.
|
|
42
|
+
o.$d.allHidden = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
o.$dontEnum ??= new Set();
|
|
47
|
+
o.$dontEnum.add(name);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
// A primitive's prototype chain is its class's, as toPrototype gives it.
|
|
51
|
+
"Object.Object::_isPrototypeOf": (rt) => (o, v) => {
|
|
52
|
+
if (v === null || v === undefined) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
for (let p = rt.protoOf(v); p; p = p.$p) {
|
|
56
|
+
if (p === o) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
},
|
|
62
|
+
"Object.Object::_toString": (rt) => (o) => {
|
|
63
|
+
if (o !== null && typeof o === "object" && o.$it) {
|
|
64
|
+
return `[class ${shortName(o.$it.name)}]`;
|
|
65
|
+
}
|
|
66
|
+
// As FunctionObject::implToString: its method's id.
|
|
67
|
+
if (o !== null && typeof o === "object" && o.$f) {
|
|
68
|
+
return `[object Function-${o.$id}]`;
|
|
69
|
+
}
|
|
70
|
+
const traits = rt.traitsOf(o);
|
|
71
|
+
traits.objectString ??= `[object ${shortName(traits.name)}]`;
|
|
72
|
+
return traits.objectString;
|
|
73
|
+
},
|
|
74
|
+
// Class and Function
|
|
75
|
+
"Class#get:prototype": plain(function () {
|
|
76
|
+
return this.$prototype;
|
|
77
|
+
}),
|
|
78
|
+
"Function#get:prototype": (rt) => function () {
|
|
79
|
+
return rt.functionPrototype(this);
|
|
80
|
+
},
|
|
81
|
+
// As FunctionObject's setter: null and undefined clear it, a primitive is refused.
|
|
82
|
+
"Function#set:prototype": (rt) => function (p) {
|
|
83
|
+
if (p === null || p === undefined) {
|
|
84
|
+
this.$prototype = undefined;
|
|
85
|
+
this.$noPrototype = true;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (typeof p !== "object" && typeof p !== "function") {
|
|
89
|
+
throw rt.error("TypeError", 1049);
|
|
90
|
+
}
|
|
91
|
+
this.$prototype = p;
|
|
92
|
+
this.$noPrototype = false;
|
|
93
|
+
},
|
|
94
|
+
"Function#get:length": plain(function () {
|
|
95
|
+
return this.$length ?? this.$f.length;
|
|
96
|
+
}),
|
|
97
|
+
[`Function#${AS3}::call`]: (rt) => function (receiver, ...args) {
|
|
98
|
+
// Not a tail call, as the runtime's calls are not (see Runtime.getProperty).
|
|
99
|
+
// biome-ignore lint/style/useConst: a const is folded into a tail call (see Runtime.getProperty)
|
|
100
|
+
let r;
|
|
101
|
+
r = rt.callValue(this, receiver, args, null);
|
|
102
|
+
return r;
|
|
103
|
+
},
|
|
104
|
+
[`Function#${AS3}::apply`]: (rt) => function (receiver, args) {
|
|
105
|
+
// Its arguments an Array, or none, as FunctionObject::AS3_apply has them.
|
|
106
|
+
if (args !== null && args !== undefined && args.$a === undefined) {
|
|
107
|
+
throw rt.error("TypeError", 1116);
|
|
108
|
+
}
|
|
109
|
+
// biome-ignore lint/style/useConst: a const is folded into a tail call (see Runtime.getProperty)
|
|
110
|
+
let r;
|
|
111
|
+
r = rt.callValue(this, receiver, elements(args).slice(), null);
|
|
112
|
+
return r;
|
|
113
|
+
},
|
|
114
|
+
// Namespace and QName: a QName holds its namespace, null for any, and its
|
|
115
|
+
// local name, null for any.
|
|
116
|
+
"Namespace#get:uri": plain(function () {
|
|
117
|
+
return this.uri ?? "";
|
|
118
|
+
}),
|
|
119
|
+
"QName#get:localName": plain(function () {
|
|
120
|
+
return this.$local ?? "*";
|
|
121
|
+
}),
|
|
122
|
+
"QName#get:uri": plain(function () {
|
|
123
|
+
return this.$ns ? this.$ns.uri : null;
|
|
124
|
+
}),
|
|
125
|
+
"Namespace#get:prefix": plain(function () {
|
|
126
|
+
return prefixOf(this);
|
|
127
|
+
}),
|
|
128
|
+
};
|
|
129
|
+
/** As QNameClass::construct: QName(name) or QName(namespace, name). */
|
|
130
|
+
function newQName(rt, cls, args) {
|
|
131
|
+
if (args.length === 1 && args[0]?.$local !== undefined) {
|
|
132
|
+
return args[0];
|
|
133
|
+
}
|
|
134
|
+
const name = args.length >= 2 ? args[1] : args[0];
|
|
135
|
+
const o = cls.$it.instance();
|
|
136
|
+
// With no namespace, a name is in the default XML namespace.
|
|
137
|
+
let ns = rt.defaultXmlNamespace.interned;
|
|
138
|
+
if (args.length >= 2 && args[0] !== undefined) {
|
|
139
|
+
ns =
|
|
140
|
+
args[0] === null
|
|
141
|
+
? null
|
|
142
|
+
: args[0] instanceof Namespace
|
|
143
|
+
? args[0].interned
|
|
144
|
+
: newNamespace(rt, args[0]);
|
|
145
|
+
}
|
|
146
|
+
else if (name?.$local !== undefined) {
|
|
147
|
+
ns = name.$ns;
|
|
148
|
+
}
|
|
149
|
+
const local = name === undefined ? "" : name?.$local !== undefined ? name.$local : rt.toString(name);
|
|
150
|
+
// With no namespace given, the any name is in any namespace too.
|
|
151
|
+
if (local === "*" && (args.length < 2 || args[0] === undefined)) {
|
|
152
|
+
ns = null;
|
|
153
|
+
}
|
|
154
|
+
o.$ns = ns;
|
|
155
|
+
o.$local = local === "*" ? null : local;
|
|
156
|
+
o.$attr = false;
|
|
157
|
+
return o;
|
|
158
|
+
}
|
|
159
|
+
/** A class's name without its package, as its toString has it: a Vector's parameter keeps its own, "Vector.<pkg::T>". */
|
|
160
|
+
function shortName(qualified) {
|
|
161
|
+
const name = formatClassName(qualified);
|
|
162
|
+
const i = name.indexOf("::");
|
|
163
|
+
return i < 0 ? name : name.slice(i + 2);
|
|
164
|
+
}
|
|
165
|
+
export function qualifiedClassName(rt, v) {
|
|
166
|
+
switch (typeof v) {
|
|
167
|
+
// As TypeDescriber::chooseTraits: an int is one that fits avmplus' 29-bit int atom.
|
|
168
|
+
case "number":
|
|
169
|
+
return (v | 0) === v && v >= -(1 << 28) && v < 1 << 28 ? "int" : "Number";
|
|
170
|
+
case "string":
|
|
171
|
+
return "String";
|
|
172
|
+
case "boolean":
|
|
173
|
+
return "Boolean";
|
|
174
|
+
case "undefined":
|
|
175
|
+
return "void";
|
|
176
|
+
default:
|
|
177
|
+
if (v === null) {
|
|
178
|
+
return "null";
|
|
179
|
+
}
|
|
180
|
+
return formatClassName(v.$it ? v.$it.name : rt.traitsOf(v).name);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function emptyFunction(rt, args) {
|
|
184
|
+
if (args.length) {
|
|
185
|
+
throw rt.error("EvalError", 1066);
|
|
186
|
+
}
|
|
187
|
+
return rt.newFunctionObject(() => undefined, null);
|
|
188
|
+
}
|
|
189
|
+
/** A class of static natives only, which cannot be instantiated: construct="none" in its declaration. */
|
|
190
|
+
const notInstantiated = (name) => ({
|
|
191
|
+
construct: (rt) => {
|
|
192
|
+
throw rt.error("ArgumentError", 2012, name);
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
export const objectHooks = {
|
|
196
|
+
JSON: notInstantiated("JSON"),
|
|
197
|
+
"flash.net::ObjectEncoding": notInstantiated("ObjectEncoding"),
|
|
198
|
+
"avmplus::System": notInstantiated("System"),
|
|
199
|
+
"avmplus::File": notInstantiated("File"),
|
|
200
|
+
// Math is neither a function nor a constructor.
|
|
201
|
+
Math: {
|
|
202
|
+
call: (rt) => {
|
|
203
|
+
throw rt.error("TypeError", 1075);
|
|
204
|
+
},
|
|
205
|
+
construct: (rt) => {
|
|
206
|
+
throw rt.error("TypeError", 1076);
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
Object: {
|
|
210
|
+
call: (rt, _cls, args) => args[0] === null || args[0] === undefined ? rt.newObject([]) : args[0],
|
|
211
|
+
construct: (rt, _cls, args) => args[0] === null || args[0] === undefined ? rt.newObject([]) : args[0],
|
|
212
|
+
},
|
|
213
|
+
// As ClassClass::construct: Class itself makes no classes.
|
|
214
|
+
Class: {
|
|
215
|
+
construct: (rt) => {
|
|
216
|
+
throw rt.error("TypeError", 1115, "Class");
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
// As NamespaceClass: Namespace(),Namespace(uri) or Namespace(prefix, uri).
|
|
220
|
+
Namespace: {
|
|
221
|
+
construct: (rt, _cls, args) => constructNamespace(rt, args),
|
|
222
|
+
call: (rt, _cls, args) => args.length === 1 && args[0] instanceof Namespace ? args[0] : constructNamespace(rt, args),
|
|
223
|
+
},
|
|
224
|
+
// As QNameClass::construct.
|
|
225
|
+
QName: {
|
|
226
|
+
construct: newQName,
|
|
227
|
+
call: newQName,
|
|
228
|
+
},
|
|
229
|
+
// Function() and new Function(): an empty function; with a body, which
|
|
230
|
+
// would be compiled at run time, EvalError 1066, as FunctionClass has it.
|
|
231
|
+
Function: {
|
|
232
|
+
construct: (rt, _cls, args) => emptyFunction(rt, args),
|
|
233
|
+
call: (rt, _cls, args) => emptyFunction(rt, args),
|
|
234
|
+
// Function.prototype is a function, that does nothing.
|
|
235
|
+
prototype: (rt) => rt.newFunctionObject(() => undefined, null),
|
|
236
|
+
},
|
|
237
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// flash.utils.Proxy: an instance's names its traits do not bind go to its
|
|
2
|
+
// flash_proxy methods, as avmplus' ProxyObject (core/ProxyGlue.cpp) sends
|
|
3
|
+
// them: a name the code wrote, a multiname, as a QName object; a name made
|
|
4
|
+
// at run time, as proxy[name], as the value it was, a string or a QName.
|
|
5
|
+
// callProperty gets the QName and the arguments; for-in asks
|
|
6
|
+
// nextNameIndex, nextName and nextValue.
|
|
7
|
+
import { NS_Public, namespace, publicNs, publicQname, qname } from "../names.js";
|
|
8
|
+
const FLASH_PROXY = namespace(NS_Public, "http://www.adobe.com/2006/actionscript/flash/proxy");
|
|
9
|
+
/**
|
|
10
|
+
* The name a flash_proxy method gets for `mn`: a QName that was the name
|
|
11
|
+
* stays one, an index comes as its string, as avmplus' getUintProperty
|
|
12
|
+
* interns it, and any other name as a QName in its namespace.
|
|
13
|
+
*/
|
|
14
|
+
function nameFor(rt, mn) {
|
|
15
|
+
if (mn.key !== undefined && mn.key?.$local !== undefined) {
|
|
16
|
+
return mn.key;
|
|
17
|
+
}
|
|
18
|
+
const name = mn.name;
|
|
19
|
+
if (name !== null && !mn.attribute && isIndex(name)) {
|
|
20
|
+
return name;
|
|
21
|
+
}
|
|
22
|
+
// A QName keeps the whole multiname in avmplus; of a set of several it
|
|
23
|
+
// reports the empty URI, and still names all of them as a lookup's name.
|
|
24
|
+
const ns = mn.namespaces.length > 1 ? publicNs : mn.namespaces.length ? mn.namespaces[0] : null;
|
|
25
|
+
const q = rt.builtinClass("QName").$it.instance();
|
|
26
|
+
q.$ns = ns;
|
|
27
|
+
q.$local = name;
|
|
28
|
+
q.$attr = mn.attribute;
|
|
29
|
+
if (mn.namespaces.length > 1) {
|
|
30
|
+
q.$mn = mn;
|
|
31
|
+
}
|
|
32
|
+
return q;
|
|
33
|
+
}
|
|
34
|
+
function isIndex(name) {
|
|
35
|
+
return /^(?:0|[1-9]\d*)$/.test(name) && Number(name) < 0xffffffff;
|
|
36
|
+
}
|
|
37
|
+
function call(rt, o, method, ...args) {
|
|
38
|
+
// Not a tail call, as the runtime's calls are not (see Runtime.getProperty).
|
|
39
|
+
// biome-ignore lint/style/useConst: a const is folded into a tail call (see Runtime.getProperty)
|
|
40
|
+
let r;
|
|
41
|
+
r = rt.callProperty(o, qname(FLASH_PROXY, method), ...args);
|
|
42
|
+
return r;
|
|
43
|
+
}
|
|
44
|
+
const proxyHook = {
|
|
45
|
+
// A method the traits bind is the method, as for any object; only unbound names reach the proxy.
|
|
46
|
+
hidesMethods: false,
|
|
47
|
+
get: (rt, o, mn) => call(rt, o, "getProperty", nameFor(rt, mn)),
|
|
48
|
+
set: (rt, o, mn, v) => {
|
|
49
|
+
call(rt, o, "setProperty", nameFor(rt, mn), v);
|
|
50
|
+
},
|
|
51
|
+
// The flash_proxy methods declare Boolean results, coerced on their way out.
|
|
52
|
+
delete: (rt, o, mn) => call(rt, o, "deleteProperty", nameFor(rt, mn)) === true,
|
|
53
|
+
// `in` asks with the name's string, as hasAtomProperty gets it.
|
|
54
|
+
has: (rt, o, mn) => call(rt, o, "hasProperty", mn.key !== undefined ? mn.key : mn.name) === true,
|
|
55
|
+
callee: (rt, o, mn) => {
|
|
56
|
+
const name = nameFor(rt, mn);
|
|
57
|
+
return rt.newFunctionObject((...args) => call(rt, o, "callProperty", name, ...args), null);
|
|
58
|
+
},
|
|
59
|
+
descendants: (rt, o, mn) => call(rt, o, "getDescendants", nameFor(rt, mn)),
|
|
60
|
+
nextIndex: (rt, o, index) => rt.toInt(call(rt, o, "nextNameIndex", index)),
|
|
61
|
+
nextName: (rt, o, index) => call(rt, o, "nextName", index),
|
|
62
|
+
nextValue: (rt, o, index) => call(rt, o, "nextValue", index),
|
|
63
|
+
equals: () => undefined,
|
|
64
|
+
add: () => undefined,
|
|
65
|
+
// toString is a call like any other the traits do not bind: callProperty answers it.
|
|
66
|
+
toString: (rt, o) => rt.toString(call(rt, o, "callProperty", nameFor(rt, publicQname("toString", rt.userVersions)))),
|
|
67
|
+
toXMLString: (rt, o) => rt.toString(call(rt, o, "callProperty", nameFor(rt, publicQname("toString", rt.userVersions)))),
|
|
68
|
+
};
|
|
69
|
+
export const proxyHooks = {
|
|
70
|
+
"flash.utils::Proxy": { properties: proxyHook },
|
|
71
|
+
};
|
|
72
|
+
export const proxyNatives = {
|
|
73
|
+
// As ProxyObject::flash_proxy_isAttribute: whether the name is a QName of an attribute.
|
|
74
|
+
"flash.utils::Proxy#http://www.adobe.com/2006/actionscript/flash/proxy::isAttribute": () => (name) => name !== null && typeof name === "object" && name.$local !== undefined && name.$attr === true,
|
|
75
|
+
};
|