@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,393 @@
|
|
|
1
|
+
// What a for-in goes through, as avmplus' nextNameIndex: an Array's or a
|
|
2
|
+
// Vector's elements by index up to their length at each step, then the
|
|
3
|
+
// object's other names, each kept in a slot for as long as it is there, as
|
|
4
|
+
// in avmplus' hashtable, so that names come and go during a for-in without
|
|
5
|
+
// moving the others.
|
|
6
|
+
import { DictionaryKeys } from "./dictionary-keys.js";
|
|
7
|
+
import { GONE } from "./dynamic-properties.js";
|
|
8
|
+
import { Namespace } from "./names.js";
|
|
9
|
+
import { FloatVector } from "./natives/float-vector.js";
|
|
10
|
+
/**
|
|
11
|
+
* How many Arrays keep sparse indices, across runtimes, so that a for-in
|
|
12
|
+
* over a dense one, as nearly all are, never looks for them. One collected
|
|
13
|
+
* while it keeps them, its for-in left off, is never taken off: then they
|
|
14
|
+
* are looked for, as before.
|
|
15
|
+
*/
|
|
16
|
+
let sparseKept = 0;
|
|
17
|
+
/**
|
|
18
|
+
* The Array whose sparse indices a for-in last took or went on by, and
|
|
19
|
+
* those, so that each of its steps past a gap finds them without a lookup
|
|
20
|
+
* in the WeakMap. Let go when they are dropped; until then held, as
|
|
21
|
+
* lastStep holds its object.
|
|
22
|
+
*/
|
|
23
|
+
let sparseOwner = null;
|
|
24
|
+
let ownerSparse = null;
|
|
25
|
+
/** Drop the sparse indices `o` keeps, if any: its for-in is over, or another starts. */
|
|
26
|
+
function dropSparse(enumerating, o) {
|
|
27
|
+
if (sparseKept === 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const e = enumerating.get(o);
|
|
31
|
+
if (e?.sparse !== undefined) {
|
|
32
|
+
e.sparse = undefined;
|
|
33
|
+
sparseKept--;
|
|
34
|
+
}
|
|
35
|
+
if (o === sparseOwner) {
|
|
36
|
+
sparseOwner = null;
|
|
37
|
+
ownerSparse = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** The names below this come back from a for-in as numbers: avmplus' int atoms, of 29 bits. */
|
|
41
|
+
export const INT_ATOM_LIMIT = 0x10000000;
|
|
42
|
+
/** An object's own names, its elements' included, then its dynamic properties' and a Dictionary's keys. */
|
|
43
|
+
export function ownNames(o) {
|
|
44
|
+
const names = [];
|
|
45
|
+
if (o.$a instanceof FloatVector) {
|
|
46
|
+
for (let i = 0; i < o.$a.length; i++) {
|
|
47
|
+
names.push(String(i));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (o.$a !== undefined) {
|
|
51
|
+
for (const i of Object.keys(o.$a)) {
|
|
52
|
+
names.push(i);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (o.$d) {
|
|
56
|
+
names.push(...o.$d.keys());
|
|
57
|
+
}
|
|
58
|
+
if (o.$keys !== undefined) {
|
|
59
|
+
for (const k of o.$keys.keys()) {
|
|
60
|
+
names.push(k);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return names;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The name of `o`, not a Dictionary, at a for-in's index among the names
|
|
67
|
+
* past its elements, the index less their length.
|
|
68
|
+
*/
|
|
69
|
+
export function enumerated(o, at, index) {
|
|
70
|
+
// The slots the step itself went through, without looking them up again.
|
|
71
|
+
const walk = o === lastStep.o && index === lastStep.index && lastStep.walk !== null
|
|
72
|
+
? lastStep.walk
|
|
73
|
+
: walkOf(o);
|
|
74
|
+
return walk?.slots[at - 1] ?? "";
|
|
75
|
+
}
|
|
76
|
+
function walkOf(o) {
|
|
77
|
+
const d = o.$d;
|
|
78
|
+
return d ? d.walk : null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The index after `index` of an enumerable name of `o`, or 0. As avmplus'
|
|
82
|
+
* ArrayObject and TypedVectorObject, the elements come first, by their
|
|
83
|
+
* length at each step, not when the for-in started, so it goes on through
|
|
84
|
+
* those pushed or filled in during it; then the other names, whose indices
|
|
85
|
+
* come after the elements' length, which moves them if it changes then.
|
|
86
|
+
*/
|
|
87
|
+
export function nextIndex(enumerating, o, index) {
|
|
88
|
+
// An object without elements never gains them: past its first step, no need to look again.
|
|
89
|
+
const known = o === lastStep.o && index === lastStep.index;
|
|
90
|
+
const a = known && lastStep.none ? undefined : o.$a;
|
|
91
|
+
if (!known) {
|
|
92
|
+
lastStep.walk = null;
|
|
93
|
+
if (a !== undefined) {
|
|
94
|
+
// Not the keys of a Dictionary whose for-in was left off.
|
|
95
|
+
lastStep.keys = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const next = a === undefined
|
|
99
|
+
? nextOfNames(o, index, known)
|
|
100
|
+
: nextOfElements(enumerating, o, a, index, known);
|
|
101
|
+
if (next === 0) {
|
|
102
|
+
lastStep.o = null;
|
|
103
|
+
lastStep.keys = null;
|
|
104
|
+
lastStep.walk = null;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
lastStep.o = o;
|
|
108
|
+
lastStep.index = next;
|
|
109
|
+
lastStep.none = a === undefined;
|
|
110
|
+
}
|
|
111
|
+
return next;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* As nextIndex, over an object without elements: a Dictionary by its keys,
|
|
115
|
+
* any other by the names of its dynamic properties.
|
|
116
|
+
*/
|
|
117
|
+
function nextOfNames(o, index, known) {
|
|
118
|
+
// One is a Dictionary or not for good: past its first step, no need to look again.
|
|
119
|
+
const keys = known ? lastStep.keys : dictionaryKeys(o);
|
|
120
|
+
lastStep.keys = keys;
|
|
121
|
+
return keys !== null ? keys.next(o, index) : nextNameIndex(o, index, index === 0, known);
|
|
122
|
+
}
|
|
123
|
+
function dictionaryKeys(o) {
|
|
124
|
+
const keys = o?.$keys;
|
|
125
|
+
return keys instanceof DictionaryKeys ? keys : null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The keys of Dictionary `o` at a for-in's index, which hold its names and
|
|
129
|
+
* values there; null for any other object.
|
|
130
|
+
*/
|
|
131
|
+
export function dictionaryAt(o, index) {
|
|
132
|
+
return o === lastStep.o && index === lastStep.index ? lastStep.keys : dictionaryKeys(o);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The step a for-in last took: the object, the index it gave, whether the
|
|
136
|
+
* object has no elements and its keys if a Dictionary, so that the next
|
|
137
|
+
* step and the nextName and nextValue right after it need not look for
|
|
138
|
+
* them again, which misses, at a cost, on the many objects that have
|
|
139
|
+
* neither, and never gain any. Let go when a for-in ends.
|
|
140
|
+
*/
|
|
141
|
+
const lastStep = {
|
|
142
|
+
o: null,
|
|
143
|
+
index: 0,
|
|
144
|
+
none: false,
|
|
145
|
+
keys: null,
|
|
146
|
+
walk: null,
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Whether a for-in's step over `o` at `index` goes on from the last one
|
|
150
|
+
* nextIndex gave, so that `o` is an ordinary object: no hook, no QName.
|
|
151
|
+
*/
|
|
152
|
+
export function continues(o, index) {
|
|
153
|
+
return o === lastStep.o && index === lastStep.index;
|
|
154
|
+
}
|
|
155
|
+
/** The length of the elements of `o` at a for-in's index: where those end and its other names start. */
|
|
156
|
+
export function elementsAt(o, index) {
|
|
157
|
+
if (o === lastStep.o && index === lastStep.index && lastStep.none) {
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
return o?.$a?.length ?? 0;
|
|
161
|
+
}
|
|
162
|
+
/** As nextIndex, over an object with elements. */
|
|
163
|
+
function nextOfElements(enumerating, o, a, index, known) {
|
|
164
|
+
if (index === 0) {
|
|
165
|
+
dropSparse(enumerating, o);
|
|
166
|
+
walkOf(o)?.freeDeleted();
|
|
167
|
+
}
|
|
168
|
+
const length = a.length;
|
|
169
|
+
if (index < length) {
|
|
170
|
+
const i = nextElement(enumerating, o, a, index);
|
|
171
|
+
if (i >= 0) {
|
|
172
|
+
return i + 1;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const at = Math.max(index - length, 0);
|
|
176
|
+
// An Array that has never had other names needs no list of them.
|
|
177
|
+
const next = at === 0 && !o.$d?.size ? 0 : nextNameIndex(o, at, false, known);
|
|
178
|
+
if (next === 0) {
|
|
179
|
+
// The for-in is over: its indices go with it.
|
|
180
|
+
dropSparse(enumerating, o);
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
return length + next;
|
|
184
|
+
}
|
|
185
|
+
/** After this many holes in a row, the next element is found by an Array's indices, so that a sparse one stays cheap. */
|
|
186
|
+
const HOLE_SCAN_LIMIT = 16;
|
|
187
|
+
/** The first element of `o` at or after `from`, or -1. */
|
|
188
|
+
function nextElement(enumerating, o, a, from) {
|
|
189
|
+
const length = a.length;
|
|
190
|
+
if (a instanceof FloatVector) {
|
|
191
|
+
return from < length ? from : -1;
|
|
192
|
+
}
|
|
193
|
+
if (enumerable(o, a, from)) {
|
|
194
|
+
return from;
|
|
195
|
+
}
|
|
196
|
+
let e;
|
|
197
|
+
if (sparseKept !== 0) {
|
|
198
|
+
if (o === sparseOwner) {
|
|
199
|
+
return nextSparse(o, a, ownerSparse, from);
|
|
200
|
+
}
|
|
201
|
+
e = enumerating.get(o);
|
|
202
|
+
if (e?.sparse !== undefined) {
|
|
203
|
+
sparseOwner = o;
|
|
204
|
+
ownerSparse = e.sparse;
|
|
205
|
+
return nextSparse(o, a, e.sparse, from);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// From the hole at `from`, up to HOLE_SCAN_LIMIT of them one by one.
|
|
209
|
+
const scanned = Math.min(length, from + HOLE_SCAN_LIMIT);
|
|
210
|
+
for (let i = from + 1; i < scanned; i++) {
|
|
211
|
+
if (enumerable(o, a, i)) {
|
|
212
|
+
return i;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (scanned === length) {
|
|
216
|
+
return -1;
|
|
217
|
+
}
|
|
218
|
+
const keeper = e ?? enumerating.get(o) ?? {};
|
|
219
|
+
enumerating.set(o, keeper);
|
|
220
|
+
sparseKept++;
|
|
221
|
+
keeper.sparse = {
|
|
222
|
+
indices: indicesOf(a, 0),
|
|
223
|
+
length,
|
|
224
|
+
at: -1,
|
|
225
|
+
given: -1,
|
|
226
|
+
sinceTaken: 0,
|
|
227
|
+
retaken: false,
|
|
228
|
+
};
|
|
229
|
+
sparseOwner = o;
|
|
230
|
+
ownerSparse = keeper.sparse;
|
|
231
|
+
return nextSparse(o, a, keeper.sparse, scanned);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The first element of `o` at or after `from` by its indices, brought up to
|
|
235
|
+
* a length grown or shrunk since. One of them gone was deleted, or moved by
|
|
236
|
+
* a reorder such as reverse: the first time, and then once as many have
|
|
237
|
+
* been given since as a sixteenth of them, they are taken again, so that
|
|
238
|
+
* one moved is found; between, those gone are passed over, so that a for-in
|
|
239
|
+
* deleting ahead of itself stays linear. As in avmplus' hashtable, which a
|
|
240
|
+
* sparse Array keeps its elements in, one moved may then be missed.
|
|
241
|
+
*/
|
|
242
|
+
function nextSparse(o, a, sparse, from) {
|
|
243
|
+
const length = a.length;
|
|
244
|
+
if (length > sparse.length) {
|
|
245
|
+
if (length - sparse.length <= HOLE_SCAN_LIMIT * HOLE_SCAN_LIMIT) {
|
|
246
|
+
for (let i = sparse.length; i < length; i++) {
|
|
247
|
+
if (i in a) {
|
|
248
|
+
sparse.indices.push(i);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// Appended one by one: spread as arguments, many would overflow the stack.
|
|
254
|
+
indicesOf(a, sparse.length, sparse.indices);
|
|
255
|
+
}
|
|
256
|
+
sparse.length = length;
|
|
257
|
+
}
|
|
258
|
+
else if (length < sparse.length) {
|
|
259
|
+
retake(a, sparse);
|
|
260
|
+
}
|
|
261
|
+
let j = sparse.given === from - 1 ? sparse.at + 1 : firstAtOrAfter(sparse.indices, from);
|
|
262
|
+
while (j < sparse.indices.length) {
|
|
263
|
+
const i = sparse.indices[j];
|
|
264
|
+
if (enumerable(o, a, i)) {
|
|
265
|
+
sparse.at = j;
|
|
266
|
+
sparse.given = i;
|
|
267
|
+
sparse.sinceTaken++;
|
|
268
|
+
return i;
|
|
269
|
+
}
|
|
270
|
+
if (!sparse.retaken || sparse.sinceTaken * 16 >= sparse.indices.length) {
|
|
271
|
+
retake(a, sparse);
|
|
272
|
+
sparse.retaken = true;
|
|
273
|
+
j = firstAtOrAfter(sparse.indices, from);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
j++;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return -1;
|
|
280
|
+
}
|
|
281
|
+
/** Take a sparse Array's indices again. */
|
|
282
|
+
function retake(a, sparse) {
|
|
283
|
+
sparse.indices = indicesOf(a, 0);
|
|
284
|
+
sparse.length = a.length;
|
|
285
|
+
sparse.at = -1;
|
|
286
|
+
sparse.given = -1;
|
|
287
|
+
sparse.sinceTaken = 0;
|
|
288
|
+
}
|
|
289
|
+
/** An Array's indices from `from` on, in order, as Object.keys gives them, appended to `indices`. */
|
|
290
|
+
function indicesOf(a, from, indices = []) {
|
|
291
|
+
for (const k of Object.keys(a)) {
|
|
292
|
+
const i = Number(k);
|
|
293
|
+
if (i >= from) {
|
|
294
|
+
indices.push(i);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return indices;
|
|
298
|
+
}
|
|
299
|
+
/** Where in `indices`, in order, the first at or after `from` is. */
|
|
300
|
+
function firstAtOrAfter(indices, from) {
|
|
301
|
+
let low = 0;
|
|
302
|
+
let high = indices.length;
|
|
303
|
+
while (low < high) {
|
|
304
|
+
const mid = (low + high) >>> 1;
|
|
305
|
+
if (indices[mid] < from) {
|
|
306
|
+
low = mid + 1;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
high = mid;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return low;
|
|
313
|
+
}
|
|
314
|
+
function enumerable(o, a, i) {
|
|
315
|
+
return i in a && !o.$dontEnum?.has(String(i));
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* The index after `index` among the names of `o` but its elements, or 0,
|
|
319
|
+
* `starting` a for-in over it.
|
|
320
|
+
*/
|
|
321
|
+
function nextNameIndex(o, index, starting, known) {
|
|
322
|
+
// As the prototypes a for-in goes on to, whose methods are all hidden:
|
|
323
|
+
// nothing to go through, and no slots to keep for it.
|
|
324
|
+
if (index === 0 && !anyEnumerable(o)) {
|
|
325
|
+
return 0;
|
|
326
|
+
}
|
|
327
|
+
const walk = index === 0
|
|
328
|
+
? o.$d.startWalk(starting)
|
|
329
|
+
: known && lastStep.walk !== null
|
|
330
|
+
? lastStep.walk
|
|
331
|
+
: walkOf(o);
|
|
332
|
+
lastStep.walk = walk;
|
|
333
|
+
if (walk === null) {
|
|
334
|
+
return 0;
|
|
335
|
+
}
|
|
336
|
+
// A name deleted since the for-in started is passed over.
|
|
337
|
+
const slots = walk.slots;
|
|
338
|
+
const live = walk.live;
|
|
339
|
+
for (let i = index; i < slots.length; i++) {
|
|
340
|
+
if (live[i] !== GONE && !o.$dontEnum?.has(slots[i])) {
|
|
341
|
+
return i + 1;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return 0;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Whether prototype `p` has nothing a for-in goes through, as most have:
|
|
348
|
+
* no names but hidden methods, no elements, keys or hook. Then a for-in
|
|
349
|
+
* passes over it with nothing to set up, as one starting over it does
|
|
350
|
+
* nothing, but for an Array's, whose start frees its deleted names'
|
|
351
|
+
* slots: one that has kept slots is left to that.
|
|
352
|
+
*/
|
|
353
|
+
export function walkless(p) {
|
|
354
|
+
const d = p.$d;
|
|
355
|
+
if (d === null || d === undefined || (d.size !== 0 && !d.allHidden)) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
const a = p.$a;
|
|
359
|
+
return ((a === undefined || (a.length === 0 && d.walk === null)) &&
|
|
360
|
+
p.$keys === undefined &&
|
|
361
|
+
p.$local === undefined &&
|
|
362
|
+
!p.$traits?.properties);
|
|
363
|
+
}
|
|
364
|
+
/** Whether any dynamic property of `o` is not hidden. */
|
|
365
|
+
function anyEnumerable(o) {
|
|
366
|
+
const d = o.$d;
|
|
367
|
+
if (!d?.size || d.allHidden) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
// Fewer hidden than there are names leaves one shown, whatever else is hidden.
|
|
371
|
+
const hidden = o.$dontEnum;
|
|
372
|
+
if (hidden === undefined || hidden.size < d.size) {
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
for (const name of d.keys()) {
|
|
376
|
+
if (!hidden.has(name)) {
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
d.allHidden = true;
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* A Namespace or QName, which enumerate "uri" and the name this gives
|
|
385
|
+
* ("prefix" or "localName"), as avmplus' nextName does; else null.
|
|
386
|
+
*/
|
|
387
|
+
export function pairOf(o) {
|
|
388
|
+
if (o instanceof Namespace) {
|
|
389
|
+
return "prefix";
|
|
390
|
+
}
|
|
391
|
+
return typeof o === "object" && o !== null && o.$local !== undefined ? "localName" : null;
|
|
392
|
+
}
|
|
393
|
+
export const pairIndex = (index) => (index < 2 ? index + 1 : 0);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// What the runtime's errors say: their messages, the number alone or, in
|
|
2
|
+
// debugger mode, its text, as avmplus words them; how a value is named in
|
|
3
|
+
// one; and where an AS3 error was made, for a host to show.
|
|
4
|
+
import { FloatValue } from "./float.js";
|
|
5
|
+
import { Namespace } from "./names.js";
|
|
6
|
+
import { errorMessages } from "./player-messages.js";
|
|
7
|
+
/** Thrown for an AS3 exception that is an Error the runtime made, before its class existed. */
|
|
8
|
+
export class AsError extends Error {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where an AS3 error was made, as JavaScript stack lines from the first
|
|
12
|
+
* compiled method's (their names begin with `$`), the runtime's and the
|
|
13
|
+
* player's frames before it left out, those between kept; every line if
|
|
14
|
+
* no compiled method made it, and null for anything but an AS3 error.
|
|
15
|
+
*/
|
|
16
|
+
export function stackOf(error) {
|
|
17
|
+
const made = error?.$jsError;
|
|
18
|
+
if (!(made instanceof Error) || !made.stack) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// V8 heads its stack with the error's own line; other engines give frames alone, `name@url`.
|
|
22
|
+
const frames = made.stack.split("\n").filter((line) => !/^Error\b/.test(line));
|
|
23
|
+
const first = frames.findIndex((line) => /^(?:\s*at (?:[\w$]+\.)?)?\$[\w$]/.test(line));
|
|
24
|
+
return frames.slice(Math.max(0, first)).join("\n");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error `id`'s message as AS3 sees it: its number, as the release player
|
|
28
|
+
* and avmshell give it, or with its text and arguments in debugger mode.
|
|
29
|
+
*/
|
|
30
|
+
export function errorMessage(debuggerMode, id, args) {
|
|
31
|
+
if (!debuggerMode) {
|
|
32
|
+
return `Error #${id}`;
|
|
33
|
+
}
|
|
34
|
+
const template = errorMessages[id] ?? "";
|
|
35
|
+
const text = template.replace(/%(\d)/g, (_, n) => String(args[Number(n) - 1] ?? ""));
|
|
36
|
+
return `Error #${id}: ${text}`;
|
|
37
|
+
}
|
|
38
|
+
/** A value as avmplus names it in an error message. */
|
|
39
|
+
export function describe(rt, v) {
|
|
40
|
+
if (v === null || typeof v !== "object" || v instanceof FloatValue || v instanceof Namespace) {
|
|
41
|
+
return rt.toString(v);
|
|
42
|
+
}
|
|
43
|
+
const name = v.$traits.name;
|
|
44
|
+
return `${name.slice(name.lastIndexOf("::") + (name.includes("::") ? 2 : 0))}@0`;
|
|
45
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Generated from as3/builtin/src/float.as by tests/libraries/float.ts.
|
|
2
|
+
// Load after builtin.abc, as a builtin, to expose AIR's scalar float type.
|
|
3
|
+
// biome-ignore format: preserve the generated byte table.
|
|
4
|
+
export const floatLibrary = new Uint8Array([
|
|
5
|
+
16, 0, 46, 0, 4, 1, 10, 0, 0, 0, 65, 6, 108, 101, 110, 103, 116, 104, 0, 3, 105, 110, 116, 9,
|
|
6
|
+
77, 65, 88, 95, 86, 65, 76, 85, 69, 5, 102, 108, 111, 97, 116, 9, 77, 73, 78, 95, 86, 65, 76, 85,
|
|
7
|
+
69, 3, 78, 97, 78, 17, 80, 79, 83, 73, 84, 73, 86, 69, 95, 73, 78, 70, 73, 78, 73, 84, 89, 17,
|
|
8
|
+
78, 69, 71, 65, 84, 73, 86, 69, 95, 73, 78, 70, 73, 78, 73, 84, 89, 1, 69, 4, 76, 78, 49, 48,
|
|
9
|
+
3, 76, 78, 50, 5, 76, 79, 71, 50, 69, 2, 80, 73, 7, 83, 81, 82, 84, 49, 95, 50, 5, 83, 81,
|
|
10
|
+
82, 84, 50, 3, 97, 98, 115, 4, 97, 99, 111, 115, 4, 97, 115, 105, 110, 4, 97, 116, 97, 110, 4, 99,
|
|
11
|
+
101, 105, 108, 3, 99, 111, 115, 3, 101, 120, 112, 5, 102, 108, 111, 111, 114, 3, 108, 111, 103, 5, 114, 111,
|
|
12
|
+
117, 110, 100, 3, 115, 105, 110, 4, 115, 113, 114, 116, 3, 116, 97, 110, 5, 97, 116, 97, 110, 50, 3, 112,
|
|
13
|
+
111, 119, 3, 109, 97, 120, 3, 109, 105, 110, 6, 114, 97, 110, 100, 111, 109, 10, 114, 101, 99, 105, 112, 114,
|
|
14
|
+
111, 99, 97, 108, 5, 114, 115, 113, 114, 116, 9, 95, 116, 111, 83, 116, 114, 105, 110, 103, 8, 95, 116, 111,
|
|
15
|
+
70, 105, 120, 101, 100, 14, 95, 116, 111, 69, 120, 112, 111, 110, 101, 110, 116, 105, 97, 108, 12, 95, 116, 111,
|
|
16
|
+
80, 114, 101, 99, 105, 115, 105, 111, 110, 7, 118, 97, 108, 117, 101, 79, 102, 33, 104, 116, 116, 112, 58, 47,
|
|
17
|
+
47, 97, 100, 111, 98, 101, 46, 99, 111, 109, 47, 65, 83, 51, 47, 50, 48, 48, 54, 47, 98, 117, 105, 108,
|
|
18
|
+
116, 105, 110, 8, 116, 111, 83, 116, 114, 105, 110, 103, 7, 116, 111, 70, 105, 120, 101, 100, 13, 116, 111, 69,
|
|
19
|
+
120, 112, 111, 110, 101, 110, 116, 105, 97, 108, 11, 116, 111, 80, 114, 101, 99, 105, 115, 105, 111, 110, 6, 79,
|
|
20
|
+
98, 106, 101, 99, 116, 6, 83, 116, 114, 105, 110, 103, 5, 114, 97, 100, 105, 120, 14, 102, 114, 97, 99, 116,
|
|
21
|
+
105, 111, 110, 68, 105, 103, 105, 116, 115, 9, 112, 114, 101, 99, 105, 115, 105, 111, 110, 20, 102, 108, 111, 97,
|
|
22
|
+
116, 46, 97, 115, 36, 48, 58, 97, 110, 111, 110, 121, 109, 111, 117, 115, 20, 102, 108, 111, 97, 116, 46, 97,
|
|
23
|
+
115, 36, 49, 58, 97, 110, 111, 110, 121, 109, 111, 117, 115, 20, 102, 108, 111, 97, 116, 46, 97, 115, 36, 50,
|
|
24
|
+
58, 97, 110, 111, 110, 121, 109, 111, 117, 115, 20, 102, 108, 111, 97, 116, 46, 97, 115, 36, 51, 58, 97, 110,
|
|
25
|
+
111, 110, 121, 109, 111, 117, 115, 20, 102, 108, 111, 97, 116, 46, 97, 115, 36, 52, 58, 97, 110, 111, 110, 121,
|
|
26
|
+
109, 111, 117, 115, 5, 118, 97, 108, 117, 101, 9, 112, 114, 111, 116, 111, 116, 121, 112, 101, 19, 70, 105, 108,
|
|
27
|
+
101, 80, 114, 105, 118, 97, 116, 101, 78, 83, 58, 102, 108, 111, 97, 116, 14, 116, 111, 76, 111, 99, 97, 108,
|
|
28
|
+
101, 83, 116, 114, 105, 110, 103, 1, 120, 1, 121, 6, 100, 105, 103, 105, 116, 115, 3, 238, 138, 148, 8, 22,
|
|
29
|
+
64, 5, 5, 8, 42, 26, 5, 26, 47, 23, 2, 5, 59, 2, 6, 2, 4, 5, 1, 6, 7, 54, 7, 1,
|
|
30
|
+
1, 7, 1, 3, 7, 1, 4, 7, 1, 5, 7, 1, 6, 7, 1, 7, 7, 1, 8, 7, 1, 9, 7, 1,
|
|
31
|
+
10, 7, 1, 11, 7, 1, 12, 7, 1, 13, 7, 1, 14, 7, 1, 15, 7, 1, 16, 7, 1, 17, 7, 1,
|
|
32
|
+
18, 7, 1, 19, 7, 1, 20, 7, 1, 21, 7, 1, 22, 7, 1, 23, 7, 1, 24, 7, 1, 25, 7, 1,
|
|
33
|
+
26, 7, 1, 27, 7, 1, 28, 7, 1, 29, 7, 1, 30, 7, 1, 31, 7, 1, 32, 7, 1, 33, 7, 1,
|
|
34
|
+
34, 7, 1, 35, 7, 1, 36, 7, 2, 37, 7, 2, 38, 7, 2, 39, 7, 2, 40, 7, 3, 41, 7, 3,
|
|
35
|
+
43, 7, 3, 44, 7, 3, 45, 7, 3, 46, 7, 1, 47, 7, 1, 48, 9, 58, 1, 9, 41, 1, 9, 43,
|
|
36
|
+
1, 9, 60, 1, 9, 44, 1, 9, 45, 1, 9, 46, 1, 37, 0, 0, 0, 0, 1, 4, 4, 17, 160, 61,
|
|
37
|
+
1, 4, 4, 18, 160, 61, 1, 4, 4, 19, 160, 61, 1, 4, 4, 20, 160, 61, 1, 4, 4, 21, 160, 61,
|
|
38
|
+
1, 4, 4, 22, 160, 61, 1, 4, 4, 23, 160, 61, 1, 4, 4, 24, 160, 61, 1, 4, 4, 25, 160, 61,
|
|
39
|
+
1, 4, 4, 26, 160, 61, 1, 4, 4, 27, 160, 61, 1, 4, 4, 28, 160, 61, 1, 4, 4, 29, 160, 61,
|
|
40
|
+
2, 4, 4, 4, 30, 160, 62, 61, 2, 4, 4, 4, 31, 160, 61, 62, 0, 4, 32, 164, 0, 4, 33, 164,
|
|
41
|
+
0, 4, 34, 32, 1, 4, 4, 35, 160, 61, 1, 4, 4, 36, 160, 61, 0, 0, 0, 0, 0, 4, 52, 0,
|
|
42
|
+
1, 46, 0, 53, 8, 1, 2, 3, 1, 46, 0, 54, 8, 1, 3, 3, 1, 46, 0, 55, 8, 1, 3, 3,
|
|
43
|
+
1, 46, 0, 56, 8, 1, 3, 3, 0, 4, 41, 0, 1, 46, 0, 43, 136, 1, 2, 3, 49, 1, 46, 0,
|
|
44
|
+
44, 136, 1, 3, 3, 50, 1, 46, 0, 45, 136, 1, 3, 3, 50, 1, 46, 0, 46, 136, 1, 3, 3, 51,
|
|
45
|
+
2, 46, 4, 0, 37, 160, 57, 49, 2, 46, 4, 0, 38, 160, 57, 63, 2, 46, 4, 0, 39, 160, 57, 63,
|
|
46
|
+
2, 46, 4, 0, 40, 160, 57, 63, 1, 0, 0, 5, 136, 1, 3, 3, 57, 0, 1, 4, 45, 3, 0, 36,
|
|
47
|
+
5, 40, 1, 0, 27, 41, 1, 0, 28, 42, 1, 0, 29, 43, 1, 0, 30, 44, 1, 0, 31, 21, 37, 1,
|
|
48
|
+
6, 0, 2, 1, 3, 3, 6, 0, 4, 0, 5, 6, 0, 4, 0, 6, 6, 0, 4, 0, 7, 6, 0, 4,
|
|
49
|
+
0, 8, 6, 0, 4, 0, 9, 6, 0, 4, 0, 10, 6, 0, 4, 0, 11, 6, 0, 4, 0, 12, 6, 0,
|
|
50
|
+
4, 0, 13, 6, 0, 4, 0, 14, 6, 0, 4, 0, 15, 6, 0, 4, 0, 16, 1, 0, 1, 17, 1, 0,
|
|
51
|
+
2, 18, 1, 0, 3, 19, 1, 0, 4, 20, 1, 0, 5, 21, 1, 0, 6, 22, 1, 0, 7, 23, 1, 0,
|
|
52
|
+
8, 24, 1, 0, 9, 25, 1, 0, 10, 26, 1, 0, 11, 27, 1, 0, 12, 28, 1, 0, 13, 29, 1, 0,
|
|
53
|
+
14, 30, 1, 0, 15, 31, 1, 0, 16, 32, 1, 0, 17, 33, 1, 0, 18, 34, 1, 0, 19, 35, 1, 0,
|
|
54
|
+
20, 36, 1, 0, 32, 37, 1, 0, 33, 38, 1, 0, 34, 39, 1, 0, 35, 1, 0, 1, 4, 4, 0, 0,
|
|
55
|
+
13, 27, 1, 1, 0, 1, 4, 208, 48, 208, 72, 0, 0, 28, 3, 2, 0, 1, 10, 208, 48, 93, 36, 208,
|
|
56
|
+
209, 70, 36, 2, 72, 0, 0, 29, 3, 2, 0, 1, 10, 208, 48, 93, 37, 208, 209, 70, 37, 2, 72, 0,
|
|
57
|
+
0, 30, 3, 2, 0, 1, 10, 208, 48, 93, 38, 208, 209, 70, 38, 2, 72, 0, 0, 31, 3, 2, 0, 1,
|
|
58
|
+
10, 208, 48, 93, 39, 208, 209, 70, 39, 2, 72, 0, 0, 22, 3, 1, 0, 0, 6, 208, 208, 208, 65, 1,
|
|
59
|
+
72, 0, 0, 23, 4, 2, 0, 0, 12, 93, 36, 208, 208, 208, 65, 1, 209, 70, 36, 2, 72, 0, 0, 24,
|
|
60
|
+
4, 2, 0, 0, 12, 93, 37, 208, 208, 208, 65, 1, 209, 70, 37, 2, 72, 0, 0, 25, 4, 2, 0, 0,
|
|
61
|
+
12, 93, 38, 208, 208, 208, 65, 1, 209, 70, 38, 2, 72, 0, 0, 26, 4, 2, 0, 0, 12, 93, 39, 208,
|
|
62
|
+
208, 208, 65, 1, 209, 70, 39, 2, 72, 0, 0, 36, 1, 2, 0, 1, 6, 208, 48, 208, 73, 0, 71, 0,
|
|
63
|
+
0, 21, 2, 1, 0, 1, 41, 208, 48, 96, 47, 64, 22, 97, 48, 96, 47, 64, 23, 97, 49, 96, 47, 96,
|
|
64
|
+
47, 102, 49, 97, 50, 96, 47, 64, 24, 97, 51, 96, 47, 64, 25, 97, 52, 96, 47, 64, 26, 97, 53, 71,
|
|
65
|
+
0, 0, 0, 3, 1, 0, 2, 14, 208, 48, 101, 0, 96, 45, 42, 48, 88, 0, 29, 104, 4, 71, 0, 0,
|
|
66
|
+
]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { floatLibrary } from "./float-library.js";
|
|
2
|
+
// A scalar float keeps its identity when it escapes into a dynamic value.
|
|
3
|
+
// Its numeric payload is rounded only when a float is produced.
|
|
4
|
+
export class FloatValue {
|
|
5
|
+
value;
|
|
6
|
+
constructor(value) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
}
|
|
9
|
+
valueOf() {
|
|
10
|
+
return this.value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const ZERO = new FloatValue(0);
|
|
14
|
+
const NEGATIVE_ZERO = new FloatValue(-0);
|
|
15
|
+
const NAN = new FloatValue(NaN);
|
|
16
|
+
export function floatValue(value) {
|
|
17
|
+
const rounded = Math.fround(value);
|
|
18
|
+
if (rounded === 0) {
|
|
19
|
+
return Object.is(rounded, -0) ? NEGATIVE_ZERO : ZERO;
|
|
20
|
+
}
|
|
21
|
+
return Number.isNaN(rounded) ? NAN : new FloatValue(rounded);
|
|
22
|
+
}
|
|
23
|
+
/** Whether a caller already supplied the scalar float builtin. */
|
|
24
|
+
export function hasFloatLibrary(abcs) {
|
|
25
|
+
return abcs.some((abc) => abc.length === floatLibrary.length && abc.every((byte, i) => byte === floatLibrary[i]));
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// What the natives and a player plug into the runtime for the builtin
|
|
2
|
+
// classes that differ from others: how they allocate, index, resolve
|
|
3
|
+
// names, and are called and constructed.
|
|
4
|
+
import { NS_Public } from "./names.js";
|
|
5
|
+
import { BIND_Method } from "./traits.js";
|
|
6
|
+
/**
|
|
7
|
+
* Whether a hooked class's hook resolves `mn`, bound to `b`: a name its
|
|
8
|
+
* traits do not bind, an attribute's, or a public name of a method, as a
|
|
9
|
+
* child or attribute of XML hides the methods of its names (as avmplus'
|
|
10
|
+
* getproperty does for XML and XMLList).
|
|
11
|
+
*/
|
|
12
|
+
export function hookedBinding(b, mn, hook) {
|
|
13
|
+
if (b === 0 || mn.attribute) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return (hook.hidesMethods &&
|
|
17
|
+
(b & 7) === BIND_Method &&
|
|
18
|
+
mn.namespaces.some((ns) => ns?.kind === NS_Public && ns.uri === ""));
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The AVM2 runtime: what generated modules call as `rt`.
|
|
2
|
+
import { builtinHooks, builtinNatives } from "./natives/index.js";
|
|
3
|
+
import { Runtime } from "./runtime.js";
|
|
4
|
+
export { Reader as Amf3Reader, Writer as Amf3Writer } from "./amf.js";
|
|
5
|
+
/** avmplus' builtin.abc (MPL-2.0), which every runtime loads first. */
|
|
6
|
+
export { builtinLibrary } from "./builtin-library.js";
|
|
7
|
+
export { frameScripts, frameSites, siteScript, stackFrames } from "./domain.js";
|
|
8
|
+
export { FloatValue, hasFloatLibrary } from "./float.js";
|
|
9
|
+
export { floatLibrary } from "./float-library.js";
|
|
10
|
+
export { messages } from "./messages.js";
|
|
11
|
+
export { publicNs, qname } from "./names.js";
|
|
12
|
+
export { Bytes, byteArrayHook, bytesOf, canShareMemory, GLOBAL_MEMORY_MIN_SIZE, notIsolated, setDomainMemory, shareBytes, sharedByteArray, } from "./natives/bytearray.js";
|
|
13
|
+
export { syncError, syncObject, syncOf, syncRef, } from "./natives/concurrent.js";
|
|
14
|
+
export { plain, registerNativeClass } from "./natives/define.js";
|
|
15
|
+
// The builtins' natives and hooks, for a player that adds playerglobal's to them.
|
|
16
|
+
export { builtinHooks, builtinNatives } from "./natives/index.js";
|
|
17
|
+
export { endShellWorker, shellWorkerTerminated, startShellWorker, } from "./natives/shell-workers.js";
|
|
18
|
+
export { newSyncMemory, SCRIPT_TIMEOUT, Sync, SyncFull, SyncTerminated, SyncTimeout, } from "./natives/sync.js";
|
|
19
|
+
// avmplus' XML tokenizer, which playerglobal's flash.xml.XMLDocument parses with too.
|
|
20
|
+
export { XMLParser, XMLTag } from "./natives/xml/parser.js";
|
|
21
|
+
export { errorMessages } from "./player-messages.js";
|
|
22
|
+
// A destroyed host must not remain reachable through shared inline-cache entries.
|
|
23
|
+
export { invalidate as clearPropertyCaches } from "./property-cache.js";
|
|
24
|
+
export { Runtime } from "./runtime.js";
|
|
25
|
+
// methodKey: where a method sits on its traits, for a player that makes a closure of its own.
|
|
26
|
+
export { instanceVarField, methodKey, setStaticVar } from "./traits.js";
|
|
27
|
+
/** A runtime with the builtins' natives, for modules compiled from builtin.abc and after. */
|
|
28
|
+
export function createRuntime(options = {}) {
|
|
29
|
+
return new Runtime(builtinNatives, builtinHooks(), options);
|
|
30
|
+
}
|
|
31
|
+
/** AS3 `int(value)`: ToInt32(ToNumber(value)). */
|
|
32
|
+
export function toInt(value) {
|
|
33
|
+
return Number(value) | 0;
|
|
34
|
+
}
|
|
35
|
+
/** AS3 `uint(value)`: ToUint32(ToNumber(value)). */
|
|
36
|
+
export function toUint(value) {
|
|
37
|
+
return Number(value) >>> 0;
|
|
38
|
+
}
|