@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,509 @@
|
|
|
1
|
+
// The layout model: an object's traits, its bindings and slots as the
|
|
2
|
+
// module's descriptor gives them, and the references by which a module
|
|
3
|
+
// names a class or a Vector type before it exists.
|
|
4
|
+
import { DynamicProperties } from "./dynamic-properties.js";
|
|
5
|
+
import { invalidate } from "./property-cache.js";
|
|
6
|
+
// Binding kinds, as the compiler encodes them: kind | id << 3.
|
|
7
|
+
export const BIND_Method = 1;
|
|
8
|
+
export const BIND_Var = 2;
|
|
9
|
+
export const BIND_Const = 3;
|
|
10
|
+
export const BIND_Get = 5;
|
|
11
|
+
export const BIND_Set = 6;
|
|
12
|
+
export const BIND_GetSet = 7;
|
|
13
|
+
/**
|
|
14
|
+
* Set class `cls`'s own static variable `name`, in whatever namespace, to
|
|
15
|
+
* `value`: for a class hook setting what the VM keeps there, as a private
|
|
16
|
+
* static the class reads.
|
|
17
|
+
*/
|
|
18
|
+
export function setStaticVar(cls, name, value) {
|
|
19
|
+
for (const [, , n, b] of cls.$desc.static.bindings) {
|
|
20
|
+
if (n === name && (b & 7) === BIND_Var) {
|
|
21
|
+
cls[`$${b >> 3}`] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The field that holds class `cls`'s own instance variable `name`, in
|
|
27
|
+
* whatever namespace, or null if it declares none: for a player that reads
|
|
28
|
+
* or writes a private field its playerglobal's AS3 keeps.
|
|
29
|
+
*/
|
|
30
|
+
export function instanceVarField(cls, name) {
|
|
31
|
+
// A class no module describes, as a host's stand-in, declares none.
|
|
32
|
+
const desc = cls?.$desc;
|
|
33
|
+
for (const [, , n, b] of desc?.instance.bindings ?? []) {
|
|
34
|
+
if (n === name && (b & 7) === BIND_Var) {
|
|
35
|
+
return `$${b >> 3}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/** The builtins besides Object whose type tests isInstanceOf answers from the value, not its traits. */
|
|
41
|
+
export const VALUE_TESTS = new Set(["float", "Number", "int", "uint", "String", "Boolean"]);
|
|
42
|
+
/** Trait kinds as the ABC has them, which the descriptors' metadata is keyed by. */
|
|
43
|
+
const TRAIT_Slot = 0;
|
|
44
|
+
const TRAIT_Getter = 2;
|
|
45
|
+
const TRAIT_Setter = 3;
|
|
46
|
+
const TRAIT_Class = 4;
|
|
47
|
+
const TRAIT_Const = 6;
|
|
48
|
+
/**
|
|
49
|
+
* The traits of an object: its own bindings by local name, and its own
|
|
50
|
+
* slots' types and initial values; lookups continue in the base's, as
|
|
51
|
+
* avmplus' do, so a base described after its subclass was made (Object,
|
|
52
|
+
* Class and Function, during the bootstrap) is still seen.
|
|
53
|
+
*/
|
|
54
|
+
export class Traits {
|
|
55
|
+
name;
|
|
56
|
+
base;
|
|
57
|
+
bindings = new Map();
|
|
58
|
+
slotTypes = [];
|
|
59
|
+
own = [];
|
|
60
|
+
/** Every slot field and its initial value, the base's first, once an instance is made. */
|
|
61
|
+
allDefaults = null;
|
|
62
|
+
/** What the module compiled to set the slots by name, if it did (TraitsDesc.fill). */
|
|
63
|
+
fill = null;
|
|
64
|
+
/** Once an instance is made: the fill these traits' objects use, if any, and its values by slot. */
|
|
65
|
+
filler = null;
|
|
66
|
+
slotValues = [];
|
|
67
|
+
/** The JavaScript prototype of objects with these traits. */
|
|
68
|
+
proto;
|
|
69
|
+
/** The object its methods go into now (methodHome): its prototype, or one chained below it. */
|
|
70
|
+
home = null;
|
|
71
|
+
/** How many properties `home` has taken, a few counted in advance for the prototype's own. */
|
|
72
|
+
homeSize = HOME_SLACK;
|
|
73
|
+
/** Whether it declares a slot its objects keep in their array `$S` (SPILL_SLOTS). */
|
|
74
|
+
spills = false;
|
|
75
|
+
/** The class whose instances these are the traits of, once it exists. */
|
|
76
|
+
cls = null;
|
|
77
|
+
interfaces = new Set();
|
|
78
|
+
dynamic = false;
|
|
79
|
+
/** Whether it is a script's global object's, as System.isGlobal asks. */
|
|
80
|
+
isGlobal = false;
|
|
81
|
+
/**
|
|
82
|
+
* Whether a dynamic class's instances refuse any name but their own and
|
|
83
|
+
* an index, getting it or setting it, as a Vector's do: they delete one,
|
|
84
|
+
* or have one in, as any dynamic object, which it never has.
|
|
85
|
+
*/
|
|
86
|
+
refusesNames = false;
|
|
87
|
+
/** How to allocate an instance, for classes whose instances hold native state. */
|
|
88
|
+
create;
|
|
89
|
+
/** The class's own hook, a builtin's or a player's; not inherited, but a specialized Vector has its base's. */
|
|
90
|
+
hooks = null;
|
|
91
|
+
/** How its instances resolve the names it does not bind, if not as dynamic properties. */
|
|
92
|
+
properties = null;
|
|
93
|
+
/** Its own slots with [Transient] metadata, if any. */
|
|
94
|
+
transientSlots = null;
|
|
95
|
+
/** Its own accessors with metadata, if any, by dispatch id: whether any of it is [Transient]. */
|
|
96
|
+
accessorMetadata = null;
|
|
97
|
+
/** Its own methods' signatures, by dispatch id, for describeType. */
|
|
98
|
+
signatures = new Map();
|
|
99
|
+
/** Its own slots' and methods' metadata, by slot id and by dispatch id, for describeType. */
|
|
100
|
+
slotMetadata = null;
|
|
101
|
+
methodMetadata = null;
|
|
102
|
+
/** The class's: whether it is final or an interface, its constructor's parameters, its own metadata. */
|
|
103
|
+
final = false;
|
|
104
|
+
isInterface = false;
|
|
105
|
+
/** The ABC that defines the class, whether it is restricted, and whether that makes it one nothing constructs. */
|
|
106
|
+
abc = null;
|
|
107
|
+
restricted = false;
|
|
108
|
+
uninstantiable = false;
|
|
109
|
+
ctor = null;
|
|
110
|
+
metadata = null;
|
|
111
|
+
getIndex;
|
|
112
|
+
setIndex;
|
|
113
|
+
hasIndex;
|
|
114
|
+
index;
|
|
115
|
+
/**
|
|
116
|
+
* Whether a type test against these traits looks at more than an object's
|
|
117
|
+
* traits, as one against Object, a number type, String or Boolean does,
|
|
118
|
+
* which takes primitives: those builtins' own, not a class named as one.
|
|
119
|
+
*/
|
|
120
|
+
testsValues = false;
|
|
121
|
+
/**
|
|
122
|
+
* Object.prototype.toString's "[object Name]" for its instances, once
|
|
123
|
+
* made: the same string each time, whose hash V8 keeps, so that looking
|
|
124
|
+
* it up, as `in` a Dictionary does for each object key it misses, does
|
|
125
|
+
* not hash it anew.
|
|
126
|
+
*/
|
|
127
|
+
objectString = null;
|
|
128
|
+
/**
|
|
129
|
+
* The keys of the methods its instances are called by through each
|
|
130
|
+
* interface, as Runtime.interfaceKey finds them: by the interface's
|
|
131
|
+
* traits, an array by the interface's dispatch ids. The last interface
|
|
132
|
+
* looked up, and its keys, are kept apart, as most receivers are called
|
|
133
|
+
* through one.
|
|
134
|
+
*/
|
|
135
|
+
interfaceKeys = null;
|
|
136
|
+
lastInterface = null;
|
|
137
|
+
lastInterfaceKeys = [];
|
|
138
|
+
constructor(name, base, proto) {
|
|
139
|
+
this.name = name;
|
|
140
|
+
this.base = base;
|
|
141
|
+
this.proto = proto ?? Object.create(base ? base.proto : null);
|
|
142
|
+
this.proto.$traits = this;
|
|
143
|
+
this.create = base ? base.create : null;
|
|
144
|
+
this.properties = base ? base.properties : null;
|
|
145
|
+
this.getIndex = base?.getIndex;
|
|
146
|
+
this.setIndex = base?.setIndex;
|
|
147
|
+
this.hasIndex = base?.hasIndex;
|
|
148
|
+
this.index = base?.index;
|
|
149
|
+
if (base) {
|
|
150
|
+
for (const i of base.interfaces) {
|
|
151
|
+
this.interfaces.add(i);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The object a method and its entries, `count` properties, go into:
|
|
157
|
+
* the prototype, till it holds HOME_PROPERTIES, then an object chained
|
|
158
|
+
* below it, above the base's, and so on. V8 keeps an object of more
|
|
159
|
+
* than 1020 properties as a dictionary, which hashes every name looked
|
|
160
|
+
* up in it: a script of thousands of functions, as Crossbridge compiles
|
|
161
|
+
* C, called each through such a prototype ran five times as slow as
|
|
162
|
+
* through one that is not. A prototype chain of objects V8 keeps fast
|
|
163
|
+
* looks a name up as fast as one object.
|
|
164
|
+
*/
|
|
165
|
+
methodHome(count) {
|
|
166
|
+
let home = this.home ?? this.proto;
|
|
167
|
+
if (this.homeSize + count > HOME_PROPERTIES) {
|
|
168
|
+
// Chained before it takes its methods: V8 keeps an object fast that is a prototype first.
|
|
169
|
+
const below = Object.create(Object.getPrototypeOf(home));
|
|
170
|
+
Object.setPrototypeOf(home, below);
|
|
171
|
+
home = below;
|
|
172
|
+
this.homeSize = 0;
|
|
173
|
+
}
|
|
174
|
+
this.home = home;
|
|
175
|
+
this.homeSize += count;
|
|
176
|
+
return home;
|
|
177
|
+
}
|
|
178
|
+
/** Add a traits' own bindings and slots from its descriptor. */
|
|
179
|
+
describe(desc) {
|
|
180
|
+
invalidate();
|
|
181
|
+
for (const [ns, version, name, value] of desc.bindings) {
|
|
182
|
+
let list = this.bindings.get(name);
|
|
183
|
+
if (!list) {
|
|
184
|
+
list = [];
|
|
185
|
+
this.bindings.set(name, list);
|
|
186
|
+
}
|
|
187
|
+
list.push({ ns, version, value });
|
|
188
|
+
}
|
|
189
|
+
for (const [slot, value, type] of desc.defaults) {
|
|
190
|
+
this.slotTypes[slot] = type;
|
|
191
|
+
this.own.push([slotKey(slot), value]);
|
|
192
|
+
if (slot >= SPILL_SLOTS) {
|
|
193
|
+
this.spills = true;
|
|
194
|
+
spilledSlot(this.methodHome(1), slot);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
for (const [d, , , returnType, params, required] of desc.methods) {
|
|
198
|
+
this.signatures.set(d, [returnType, params, required]);
|
|
199
|
+
}
|
|
200
|
+
if (desc.meta) {
|
|
201
|
+
this.annotate(desc.meta);
|
|
202
|
+
}
|
|
203
|
+
this.fill = desc.fill ?? null;
|
|
204
|
+
this.allDefaults = null;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Keep the traits' metadata, and what AMF and JSON ask of it: the slots
|
|
208
|
+
* with [Transient], and for each accessor with metadata whether any of
|
|
209
|
+
* it is [Transient], since an accessor's metadata hides its base's, as
|
|
210
|
+
* avmplus' getMethodMetadataPos finds it.
|
|
211
|
+
*/
|
|
212
|
+
annotate(meta) {
|
|
213
|
+
const transient = (entries) => entries.some(([name]) => name === "Transient");
|
|
214
|
+
for (const [kind, id, entries] of meta) {
|
|
215
|
+
if (kind === TRAIT_Slot || kind === TRAIT_Const || kind === TRAIT_Class) {
|
|
216
|
+
this.slotMetadata ??= new Map();
|
|
217
|
+
this.slotMetadata.set(id, entries);
|
|
218
|
+
if (transient(entries)) {
|
|
219
|
+
this.transientSlots ??= new Set();
|
|
220
|
+
this.transientSlots.add(id);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
this.methodMetadata ??= new Map();
|
|
225
|
+
this.methodMetadata.set(id, entries);
|
|
226
|
+
if (kind === TRAIT_Getter || kind === TRAIT_Setter) {
|
|
227
|
+
this.accessorMetadata ??= new Map();
|
|
228
|
+
this.accessorMetadata.set(id, transient(entries));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Whether the member binding `b` names is [Transient], which AMF and
|
|
235
|
+
* JSON leave out: a slot, or either accessor of a pair, whose metadata,
|
|
236
|
+
* found as avmplus' TraitsMetadata finds it, has it.
|
|
237
|
+
*/
|
|
238
|
+
isTransient(b) {
|
|
239
|
+
const kind = b & 7;
|
|
240
|
+
const id = b >> 3;
|
|
241
|
+
if (kind === BIND_Var || kind === BIND_Const) {
|
|
242
|
+
for (let t = this; t; t = t.base) {
|
|
243
|
+
if (t.transientSlots?.has(id)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
return (((kind === BIND_Get || kind === BIND_GetSet) && this.transientAccessor(id)) ||
|
|
250
|
+
((kind === BIND_Set || kind === BIND_GetSet) && this.transientAccessor(id + 1)));
|
|
251
|
+
}
|
|
252
|
+
/** Whether accessor `id`'s metadata, the nearest traits' that has any, is [Transient]. */
|
|
253
|
+
transientAccessor(id) {
|
|
254
|
+
for (let t = this; t; t = t.base) {
|
|
255
|
+
const transient = t.accessorMetadata?.get(id);
|
|
256
|
+
if (transient !== undefined) {
|
|
257
|
+
return transient;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
/** Whether it or a base declares a slot kept in the array `$S`. */
|
|
263
|
+
spillsAny() {
|
|
264
|
+
for (let t = this; t; t = t.base) {
|
|
265
|
+
if (t.spills) {
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
/** The type of slot `id`, declared here or by a base. */
|
|
272
|
+
slotType(id) {
|
|
273
|
+
for (let t = this; t; t = t.base) {
|
|
274
|
+
if (id in t.slotTypes) {
|
|
275
|
+
return t.slotTypes[id];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
/** The binding `mn` names, or 0: the first of its namespaces that binds it at its version. */
|
|
281
|
+
find(mn) {
|
|
282
|
+
const name = mn.name;
|
|
283
|
+
if (name === null) {
|
|
284
|
+
return 0;
|
|
285
|
+
}
|
|
286
|
+
const namespaces = mn.namespaces;
|
|
287
|
+
for (let t = this; t; t = t.base) {
|
|
288
|
+
const list = t.bindings.get(name);
|
|
289
|
+
if (!list) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
// Indexes, not for-of: compiled code looks its names up here.
|
|
293
|
+
for (let i = 0; i < namespaces.length; i++) {
|
|
294
|
+
const ns = namespaces[i];
|
|
295
|
+
for (let k = 0; k < list.length; k++) {
|
|
296
|
+
const b = list[k];
|
|
297
|
+
if (b.ns === ns && b.version <= mn.versions[i]) {
|
|
298
|
+
return b.value;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
/** A new object with these traits, its slots at their initial values. */
|
|
306
|
+
instance() {
|
|
307
|
+
const o = this.create ? this.create(this) : Object.create(this.proto);
|
|
308
|
+
o.$d = this.dynamic ? new DynamicProperties() : null;
|
|
309
|
+
if (!this.allDefaults) {
|
|
310
|
+
this.allDefaults = this.base ? [...this.base.defaultsOf(), ...this.own] : this.own.slice();
|
|
311
|
+
this.filler = this.fillOf();
|
|
312
|
+
this.slotValues = this.filler ? valuesBySlot(this.allDefaults) : [];
|
|
313
|
+
}
|
|
314
|
+
if (this.filler) {
|
|
315
|
+
this.filler(o, this.slotValues);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
// Those past SPILL_SLOTS through their accessors, into the array.
|
|
319
|
+
if (this.spillsAny()) {
|
|
320
|
+
o.$S = [];
|
|
321
|
+
}
|
|
322
|
+
// Traits no module compiled a fill for: a catch scope's, or past
|
|
323
|
+
// FILL_SLOTS, where V8 keeps no object fast anyway.
|
|
324
|
+
const defaults = this.allDefaults;
|
|
325
|
+
for (let i = 0; i < defaults.length; i++) {
|
|
326
|
+
o[defaults[i][0]] = defaults[i][1];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return o;
|
|
330
|
+
}
|
|
331
|
+
/** The fill for these traits' objects: their module's, or a base's that has all their slots, as a Vector.<T>'s. */
|
|
332
|
+
fillOf() {
|
|
333
|
+
if (this.fill || this.own.length) {
|
|
334
|
+
return this.fill;
|
|
335
|
+
}
|
|
336
|
+
return this.base ? this.base.fillOf() : null;
|
|
337
|
+
}
|
|
338
|
+
defaultsOf() {
|
|
339
|
+
return this.allDefaults ?? (this.base ? [...this.base.defaultsOf(), ...this.own] : this.own);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Interfaces named by a class made before them, as a script may define a
|
|
343
|
+
* class before an interface it implements: each gives the interface's
|
|
344
|
+
* traits once its class exists, or null before. avmplus takes interfaces
|
|
345
|
+
* from traits, which exist from loading; these are settled when a type
|
|
346
|
+
* test first needs them.
|
|
347
|
+
*/
|
|
348
|
+
pendingInterfaces = null;
|
|
349
|
+
/** Add the interfaces now made that were pending, here and in the bases. */
|
|
350
|
+
settleInterfaces() {
|
|
351
|
+
for (let c = this; c; c = c.base) {
|
|
352
|
+
const pending = c.pendingInterfaces;
|
|
353
|
+
if (!pending) {
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
c.pendingInterfaces = pending.filter((get) => {
|
|
357
|
+
const iface = get();
|
|
358
|
+
if (!iface) {
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
iface.settleInterfaces();
|
|
362
|
+
c.interfaces.add(iface);
|
|
363
|
+
for (const i of iface.interfaces) {
|
|
364
|
+
c.interfaces.add(i);
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
});
|
|
368
|
+
if (!c.pendingInterfaces.length) {
|
|
369
|
+
c.pendingInterfaces = null;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* The interfaces of this class and its bases, once none of them has one
|
|
375
|
+
* pending: from then on what isSubtypeOf answers no more changes, and
|
|
376
|
+
* a class that is not t answers by this alone, as `is` on a 3D
|
|
377
|
+
* engine's scene nodes asks every frame.
|
|
378
|
+
*/
|
|
379
|
+
allInterfaces = null;
|
|
380
|
+
isSubtypeOf(t) {
|
|
381
|
+
for (let c = this; c; c = c.base) {
|
|
382
|
+
if (c === t) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// A class is a supertype only as a base; only interfaces are in the sets below.
|
|
387
|
+
if (!t.isInterface) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
if (this.allInterfaces !== null) {
|
|
391
|
+
return this.allInterfaces.has(t);
|
|
392
|
+
}
|
|
393
|
+
if (this.interfaces.has(t)) {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
// An interface a base settled after this class copied its interfaces.
|
|
397
|
+
this.settleInterfaces();
|
|
398
|
+
let settled = true;
|
|
399
|
+
const all = new Set();
|
|
400
|
+
for (let c = this; c; c = c.base) {
|
|
401
|
+
if (c.pendingInterfaces) {
|
|
402
|
+
settled = false;
|
|
403
|
+
}
|
|
404
|
+
for (const i of c.interfaces) {
|
|
405
|
+
all.add(i);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (settled) {
|
|
409
|
+
this.allInterfaces = all;
|
|
410
|
+
}
|
|
411
|
+
return all.has(t);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/** A class named in a module, resolved the first time it is needed. */
|
|
415
|
+
export class ClassRef {
|
|
416
|
+
ns;
|
|
417
|
+
name;
|
|
418
|
+
domain;
|
|
419
|
+
cls = null;
|
|
420
|
+
/**
|
|
421
|
+
* Its instances' traits, once coerceTo has found them; a compiled
|
|
422
|
+
* method's parameter of the type reads them by name on entry.
|
|
423
|
+
*/
|
|
424
|
+
traits = null;
|
|
425
|
+
constructor(ns, name,
|
|
426
|
+
/** The domain its module was loaded into, which it is resolved in. */
|
|
427
|
+
domain) {
|
|
428
|
+
this.ns = ns;
|
|
429
|
+
this.name = name;
|
|
430
|
+
this.domain = domain;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/** Vector.<T>, resolved the first time it is needed. */
|
|
434
|
+
export class VectorRef {
|
|
435
|
+
param;
|
|
436
|
+
cls = null;
|
|
437
|
+
/**
|
|
438
|
+
* Its instances' traits, once coerceTo has found them; a compiled
|
|
439
|
+
* method's parameter of the type reads them by name on entry.
|
|
440
|
+
*/
|
|
441
|
+
traits = null;
|
|
442
|
+
constructor(param) {
|
|
443
|
+
this.param = param;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/** The initial values of `defaults` by slot id, the last of a slot listed twice, as they are set. */
|
|
447
|
+
function valuesBySlot(defaults) {
|
|
448
|
+
let count = 0;
|
|
449
|
+
for (const [key] of defaults) {
|
|
450
|
+
count = Math.max(count, Number(key.slice(1)) + 1);
|
|
451
|
+
}
|
|
452
|
+
const values = new Array(count).fill(undefined);
|
|
453
|
+
for (const [key, value] of defaults) {
|
|
454
|
+
values[Number(key.slice(1))] = value;
|
|
455
|
+
}
|
|
456
|
+
return values;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* The properties a prototype object takes before its traits' methods go
|
|
460
|
+
* on in another below it (Traits.methodHome), well short of V8's 1020; a
|
|
461
|
+
* few counted in advance for the prototype's own ($traits, $p, $init).
|
|
462
|
+
*/
|
|
463
|
+
const HOME_PROPERTIES = 768;
|
|
464
|
+
const HOME_SLACK = 16;
|
|
465
|
+
/**
|
|
466
|
+
* The first slot an object keeps in its array `$S` rather than in a
|
|
467
|
+
* property of its own, as the codegen's SPILL_SLOTS (emit/refs.ts), which
|
|
468
|
+
* compiled code reads and writes there (`o.$S[n - SPILL_SLOTS]`): V8
|
|
469
|
+
* keeps an object of more than 1020 properties as a dictionary, which
|
|
470
|
+
* hashes every name looked up in it. A Crossbridge program's global, of
|
|
471
|
+
* thousands of slots, its stack pointer and registers among the first,
|
|
472
|
+
* ran five times as slow as one that is not. The slot's name reaches the
|
|
473
|
+
* array through an accessor on the prototype (spilledSlot), so that what
|
|
474
|
+
* looks slots up by name finds them as any other.
|
|
475
|
+
*/
|
|
476
|
+
export const SPILL_SLOTS = 900;
|
|
477
|
+
/** Slot `slot`'s accessor in `home`, a prototype of its objects: the object's `$S` at its place. */
|
|
478
|
+
function spilledSlot(home, slot) {
|
|
479
|
+
const at = slot - SPILL_SLOTS;
|
|
480
|
+
Object.defineProperty(home, slotKey(slot), {
|
|
481
|
+
get() {
|
|
482
|
+
return this.$S[at];
|
|
483
|
+
},
|
|
484
|
+
set(v) {
|
|
485
|
+
this.$S[at] = v;
|
|
486
|
+
},
|
|
487
|
+
configurable: true,
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
// The names of slot and method properties by id, made once each, for the
|
|
491
|
+
// runtime's dynamic paths; generated code names them itself.
|
|
492
|
+
const slotKeys = [];
|
|
493
|
+
const methodKeys = [];
|
|
494
|
+
export const slotKey = (id) => (slotKeys[id] ??= `$${id}`);
|
|
495
|
+
export const methodKey = (id) => (methodKeys[id] ??= `$m${id}`);
|
|
496
|
+
const untypedSetKeys = [];
|
|
497
|
+
/**
|
|
498
|
+
* Where a native's setter, dispatch id `id`, is kept as an untyped set
|
|
499
|
+
* calls it, its value coerced (installMethod); a setter with none is
|
|
500
|
+
* called as it is.
|
|
501
|
+
*/
|
|
502
|
+
export const untypedSetKey = (id) => (untypedSetKeys[id] ??= `$u${id}`);
|
|
503
|
+
const boundKeys = [];
|
|
504
|
+
/**
|
|
505
|
+
* Where a method, dispatch id `id`, is kept as calls the compiler bound
|
|
506
|
+
* call it, their arguments coerced and counted already: its entry for
|
|
507
|
+
* them if it has one (a compiled method's `$bound`), else itself.
|
|
508
|
+
*/
|
|
509
|
+
export const boundKey = (id) => (boundKeys[id] ??= `$b${id}`);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language runtime that generated code calls into. Only AS2/AS3 semantics
|
|
3
|
+
* live here; playerglobal belongs to @swf2es/player, so this package runs in
|
|
4
|
+
* node next to avmshell for conformance tests.
|
|
5
|
+
*/
|
|
6
|
+
export * as avm1 from "./avm1/index.js";
|
|
7
|
+
export * as avm2 from "./avm2/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-worker.d.ts","sourceRoot":"","sources":["../src/web-worker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// A Web Worker running one background flash.system.Worker (workers.ts).
|
|
2
|
+
import { runWorkerThread } from "@swf2es/player/worker";
|
|
3
|
+
// The DOM's types, not a worker's, are this package's: its global scope as a worker sees it.
|
|
4
|
+
const scope = globalThis;
|
|
5
|
+
runWorkerThread({
|
|
6
|
+
post: (message) => scope.postMessage(message),
|
|
7
|
+
listen: (receive) => {
|
|
8
|
+
scope.onmessage = (event) => {
|
|
9
|
+
// The host's first message: answered, it tells the host that what it
|
|
10
|
+
// posts reaches this worker, which it then counts on while the page's
|
|
11
|
+
// thread is blocked (workers.ts).
|
|
12
|
+
if (event.data?.type === "ping") {
|
|
13
|
+
scope.postMessage({ type: "ready" });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
receive(event.data);
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=web-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-worker.js","sourceRoot":"","sources":["../src/web-worker.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,6FAA6F;AAC7F,MAAM,KAAK,GAAG,UAGb,CAAC;AACF,eAAe,CAAC;IACd,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC;IAC7C,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,KAAK,CAAC,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE;YAC1B,qEAAqE;YACrE,sEAAsE;YACtE,kCAAkC;YAClC,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;gBAChC,KAAK,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;gBACrC,OAAO;YACT,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SocketHost } from "@swf2es/player";
|
|
2
|
+
/** Map the AS3 host and port to a WebSocket endpoint that relays a byte stream. */
|
|
3
|
+
export declare function webSocketSocketHost(urlFor: (host: string, port: number) => string, open?: (url: string) => WebSocket): SocketHost;
|
|
4
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../src/websocket.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,mFAAmF;AACnF,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,EAC9C,IAAI,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAuC,GAC7D,UAAU,CAwBZ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Map the AS3 host and port to a WebSocket endpoint that relays a byte stream. */
|
|
2
|
+
export function webSocketSocketHost(urlFor, open = (url) => new WebSocket(url)) {
|
|
3
|
+
return {
|
|
4
|
+
connect(host, port, events) {
|
|
5
|
+
const socket = open(urlFor(host, port));
|
|
6
|
+
socket.binaryType = "arraybuffer";
|
|
7
|
+
socket.addEventListener("open", () => events.open());
|
|
8
|
+
socket.addEventListener("message", ({ data }) => {
|
|
9
|
+
if (data instanceof ArrayBuffer) {
|
|
10
|
+
events.data(new Uint8Array(data));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
events.error("Socket bridge sent a non-binary WebSocket message.");
|
|
14
|
+
socket.close();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
socket.addEventListener("close", () => events.close());
|
|
18
|
+
socket.addEventListener("error", () => events.error("Error #2031: Socket Error."));
|
|
19
|
+
return {
|
|
20
|
+
// Browser WebSocket accepts typed arrays; the Socket native supplies ArrayBuffer-backed bytes.
|
|
21
|
+
send: (bytes) => socket.send(bytes),
|
|
22
|
+
close: () => socket.close(),
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=websocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../src/websocket.ts"],"names":[],"mappings":"AAGA,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CACjC,MAA8C,EAC9C,IAAI,GAA+B,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC;IAE9D,OAAO;QACL,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM;YACxB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YACxC,MAAM,CAAC,UAAU,GAAG,aAAa,CAAC;YAClC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC9C,IAAI,IAAI,YAAY,WAAW,EAAE,CAAC;oBAChC,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;gBACpC,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;oBACnE,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,CAAC;YACH,CAAC,CAAC,CAAC;YACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACvD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;YAEnF,OAAO;gBACL,+FAA+F;gBAC/F,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC;gBAC9D,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;aAC5B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WorkerHost } from "@swf2es/player";
|
|
2
|
+
export interface WebWorkerHostOptions {
|
|
3
|
+
/** codegen.wasm compiled, as the player's own codegen was made from. */
|
|
4
|
+
codegen: WebAssembly.Module;
|
|
5
|
+
/**
|
|
6
|
+
* The worker script: by default this package's dist/thread/, which
|
|
7
|
+
* holds web-worker.js and the modules it imports with their bare
|
|
8
|
+
* specifiers made relative (build-thread.ts), so that it loads wherever
|
|
9
|
+
* the package is served, as a worker sees no import map. One from
|
|
10
|
+
* another origin, as a CDN's, starts through a module of the page's own
|
|
11
|
+
* that imports it, which a Content-Security-Policy must allow as a
|
|
12
|
+
* worker's `blob:` source.
|
|
13
|
+
*/
|
|
14
|
+
url?: string | URL;
|
|
15
|
+
/**
|
|
16
|
+
* How many Web Workers to keep started ahead, for workers a script starts
|
|
17
|
+
* and then waits for without returning to the event loop: by default as
|
|
18
|
+
* many as the machine has cores, from 2 up to 4. The page's hosts for one
|
|
19
|
+
* script URL share them, and they are let go a while after the last
|
|
20
|
+
* player that used them is.
|
|
21
|
+
*/
|
|
22
|
+
spares?: number;
|
|
23
|
+
}
|
|
24
|
+
/** A host of Web Workers, and when the workers it started ahead have loaded. */
|
|
25
|
+
export interface WebWorkerHost extends WorkerHost {
|
|
26
|
+
/**
|
|
27
|
+
* Resolves once the workers started ahead have loaded, or failed to:
|
|
28
|
+
* a page that awaits it before it plays a SWF has them for a script
|
|
29
|
+
* that blocks at once.
|
|
30
|
+
*/
|
|
31
|
+
readonly ready: Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/** Background workers on module Web Workers. */
|
|
34
|
+
export declare function webWorkerHost(options: WebWorkerHostOptions): WebWorkerHost;
|
|
35
|
+
//# sourceMappingURL=workers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../src/workers.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC;IAC5B;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,gFAAgF;AAChF,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAuJD,gDAAgD;AAChD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAiD1E"}
|