@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,64 @@
|
|
|
1
|
+
// The builtins' native methods, in TypeScript, bound by the names the
|
|
2
|
+
// compiler gives them: "Class.name" for a static method, "Class#name" for an
|
|
3
|
+
// instance method, the name alone for a script's function, with "get:" and
|
|
4
|
+
// "set:" for accessors and "uri::name" outside the public namespace. And how
|
|
5
|
+
// the builtin classes differ from others: how their instances hold native
|
|
6
|
+
// state, and what calling or constructing them does.
|
|
7
|
+
import { aliasesNatives } from "./aliases.js";
|
|
8
|
+
import { arrayHooks, arrayNatives } from "./array.js";
|
|
9
|
+
import { byteArrayHook, byteArrayNatives } from "./bytearray.js";
|
|
10
|
+
import { concurrentNatives } from "./concurrent.js";
|
|
11
|
+
import { dateHook, dateNatives } from "./date.js";
|
|
12
|
+
import { describeNatives } from "./describe.js";
|
|
13
|
+
import { dictionaryNatives } from "./dictionary.js";
|
|
14
|
+
import { floatHooks, floatNatives } from "./float.js";
|
|
15
|
+
import { jsonNatives } from "./json.js";
|
|
16
|
+
import { numberHooks, numberNatives } from "./number.js";
|
|
17
|
+
import { objectHooks, objectNatives } from "./object.js";
|
|
18
|
+
import { proxyHooks, proxyNatives } from "./proxy.js";
|
|
19
|
+
import { regexpHooks, regexpNatives } from "./regexp.js";
|
|
20
|
+
import { shellHooks, shellNatives } from "./shell.js";
|
|
21
|
+
import { stringHooks, stringNatives } from "./string.js";
|
|
22
|
+
import { errorHooks, toplevelNatives } from "./toplevel.js";
|
|
23
|
+
import { vectorHooks, vectorNatives } from "./vector.js";
|
|
24
|
+
import { xmlHooks, xmlNatives } from "./xml/xml.js";
|
|
25
|
+
/** The builtins' natives for `rt`: most are the same for every runtime; a class of natives closes over it. */
|
|
26
|
+
export function builtinNatives(rt) {
|
|
27
|
+
return {
|
|
28
|
+
...objectNatives,
|
|
29
|
+
...arrayNatives,
|
|
30
|
+
...stringNatives,
|
|
31
|
+
...regexpNatives(rt),
|
|
32
|
+
...numberNatives,
|
|
33
|
+
...floatNatives,
|
|
34
|
+
...toplevelNatives,
|
|
35
|
+
...describeNatives,
|
|
36
|
+
...proxyNatives,
|
|
37
|
+
...aliasesNatives,
|
|
38
|
+
...shellNatives(rt),
|
|
39
|
+
...dictionaryNatives,
|
|
40
|
+
...vectorNatives,
|
|
41
|
+
...byteArrayNatives(rt),
|
|
42
|
+
...concurrentNatives(rt),
|
|
43
|
+
...dateNatives(),
|
|
44
|
+
...jsonNatives(),
|
|
45
|
+
...xmlNatives,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function builtinHooks() {
|
|
49
|
+
return {
|
|
50
|
+
...objectHooks,
|
|
51
|
+
...numberHooks,
|
|
52
|
+
...floatHooks,
|
|
53
|
+
...stringHooks,
|
|
54
|
+
...arrayHooks,
|
|
55
|
+
...regexpHooks,
|
|
56
|
+
"flash.utils::ByteArray": byteArrayHook,
|
|
57
|
+
Date: dateHook,
|
|
58
|
+
...vectorHooks,
|
|
59
|
+
...xmlHooks,
|
|
60
|
+
...proxyHooks,
|
|
61
|
+
...errorHooks,
|
|
62
|
+
...shellHooks,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
import { FloatValue } from "../float.js";
|
|
2
|
+
import { FloatVector } from "./float-vector.js";
|
|
3
|
+
import { NS_Public, publicQname } from "../names.js";
|
|
4
|
+
/** Whether each traits binds a public toJSON, found once. */
|
|
5
|
+
const boundToJSON = new WeakMap();
|
|
6
|
+
/**
|
|
7
|
+
* As JSONParser, through the host's JSON.parse, then its values made AS3's
|
|
8
|
+
* in place. The text the host rejects goes to parse(): avmplus reads some
|
|
9
|
+
* of it (numbers with leading zeros, as 01), and fails the rest as
|
|
10
|
+
* SyntaxError 1132.
|
|
11
|
+
*/
|
|
12
|
+
function parseText(rt, text) {
|
|
13
|
+
let tree;
|
|
14
|
+
try {
|
|
15
|
+
tree = JSON.parse(text);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return parse(rt, text);
|
|
19
|
+
}
|
|
20
|
+
return fromHost(rt, tree);
|
|
21
|
+
}
|
|
22
|
+
/** How deep fromHost recurses before it continues with a stack of its own. */
|
|
23
|
+
const RECURSION_DEPTH = 500;
|
|
24
|
+
const LITERALS = ["null", "true", "false"];
|
|
25
|
+
/**
|
|
26
|
+
* A value of the host's JSON.parse as AS3's: an array as an Array holding
|
|
27
|
+
* it, its elements made AS3's in place, and an object as an Object with its
|
|
28
|
+
* keys, each where a public name of a plain Object is set (JSON's
|
|
29
|
+
* `__proto__` is a key of the object's own). Deeper than RECURSION_DEPTH,
|
|
30
|
+
* as deepFromHost does, as avmplus reads any depth.
|
|
31
|
+
*/
|
|
32
|
+
function fromHost(rt, v, depth = 0) {
|
|
33
|
+
if (typeof v !== "object" || v === null) {
|
|
34
|
+
return v;
|
|
35
|
+
}
|
|
36
|
+
if (depth > RECURSION_DEPTH) {
|
|
37
|
+
return deepFromHost(rt, v);
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(v)) {
|
|
40
|
+
for (let i = 0; i < v.length; i++) {
|
|
41
|
+
v[i] = fromHost(rt, v[i], depth + 1);
|
|
42
|
+
}
|
|
43
|
+
return rt.array(v);
|
|
44
|
+
}
|
|
45
|
+
const o = rt.newObject([]);
|
|
46
|
+
const d = o.$d;
|
|
47
|
+
const from = v;
|
|
48
|
+
for (const key in from) {
|
|
49
|
+
d.set(key, fromHost(rt, from[key], depth + 1));
|
|
50
|
+
}
|
|
51
|
+
return o;
|
|
52
|
+
}
|
|
53
|
+
/** As fromHost, with a stack of its own, not the host's: slower, and at any depth. */
|
|
54
|
+
function deepFromHost(rt, root) {
|
|
55
|
+
const pending = [];
|
|
56
|
+
const wrap = (v) => {
|
|
57
|
+
if (typeof v !== "object" || v === null) {
|
|
58
|
+
return v;
|
|
59
|
+
}
|
|
60
|
+
const o = Array.isArray(v) ? rt.array(v) : rt.newObject([]);
|
|
61
|
+
pending.push([v, o]);
|
|
62
|
+
return o;
|
|
63
|
+
};
|
|
64
|
+
const result = wrap(root);
|
|
65
|
+
for (let next = pending.pop(); next; next = pending.pop()) {
|
|
66
|
+
const [host, o] = next;
|
|
67
|
+
if (Array.isArray(host)) {
|
|
68
|
+
for (let i = 0; i < host.length; i++) {
|
|
69
|
+
host[i] = wrap(host[i]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const d = o.$d;
|
|
74
|
+
const from = host;
|
|
75
|
+
for (const key in from) {
|
|
76
|
+
d.set(key, wrap(from[key]));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
/** As JSONParser: the JSON text to a value, or SyntaxError 1132. */
|
|
83
|
+
function parse(rt, text) {
|
|
84
|
+
let i = 0;
|
|
85
|
+
let token = "";
|
|
86
|
+
// The current token, read through a function: advance() changes it.
|
|
87
|
+
const current = () => token;
|
|
88
|
+
let value;
|
|
89
|
+
const fail = () => {
|
|
90
|
+
throw rt.error("SyntaxError", 1132);
|
|
91
|
+
};
|
|
92
|
+
const digits = () => {
|
|
93
|
+
const start = i;
|
|
94
|
+
while (i < text.length && text.charCodeAt(i) >= 48 && text.charCodeAt(i) <= 57) {
|
|
95
|
+
i++;
|
|
96
|
+
}
|
|
97
|
+
if (i <= start) {
|
|
98
|
+
fail();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const advance = () => {
|
|
102
|
+
token = "";
|
|
103
|
+
while (i < text.length) {
|
|
104
|
+
const c = text[i];
|
|
105
|
+
switch (c) {
|
|
106
|
+
case "\t":
|
|
107
|
+
case "\n":
|
|
108
|
+
case "\r":
|
|
109
|
+
case " ":
|
|
110
|
+
i++;
|
|
111
|
+
continue;
|
|
112
|
+
case ",":
|
|
113
|
+
case ":":
|
|
114
|
+
case "{":
|
|
115
|
+
case "}":
|
|
116
|
+
case "[":
|
|
117
|
+
case "]":
|
|
118
|
+
i++;
|
|
119
|
+
token = c;
|
|
120
|
+
return;
|
|
121
|
+
case '"': {
|
|
122
|
+
i++;
|
|
123
|
+
let s = "";
|
|
124
|
+
let start = i;
|
|
125
|
+
while (i < text.length) {
|
|
126
|
+
const code = text.charCodeAt(i);
|
|
127
|
+
if (code < 32) {
|
|
128
|
+
fail();
|
|
129
|
+
}
|
|
130
|
+
if (code === 34) {
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
if (code === 92) {
|
|
134
|
+
s += text.slice(start, i);
|
|
135
|
+
i++;
|
|
136
|
+
if (i === text.length) {
|
|
137
|
+
fail();
|
|
138
|
+
}
|
|
139
|
+
const e = text[i];
|
|
140
|
+
const simple = {
|
|
141
|
+
'"': '"',
|
|
142
|
+
"/": "/",
|
|
143
|
+
"\\": "\\",
|
|
144
|
+
b: "\b",
|
|
145
|
+
f: "\f",
|
|
146
|
+
n: "\n",
|
|
147
|
+
r: "\r",
|
|
148
|
+
t: "\t",
|
|
149
|
+
};
|
|
150
|
+
if (e in simple) {
|
|
151
|
+
s += simple[e];
|
|
152
|
+
}
|
|
153
|
+
else if (e === "u") {
|
|
154
|
+
const hex = text.slice(i + 1, i + 5);
|
|
155
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
|
|
156
|
+
fail();
|
|
157
|
+
}
|
|
158
|
+
s += String.fromCharCode(Number.parseInt(hex, 16));
|
|
159
|
+
i += 4;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
fail();
|
|
163
|
+
}
|
|
164
|
+
i++;
|
|
165
|
+
start = i;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
i++;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (i === text.length) {
|
|
172
|
+
fail();
|
|
173
|
+
}
|
|
174
|
+
value = s + text.slice(start, i);
|
|
175
|
+
i++;
|
|
176
|
+
token = '"';
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
case "-":
|
|
180
|
+
case ".":
|
|
181
|
+
case "0":
|
|
182
|
+
case "1":
|
|
183
|
+
case "2":
|
|
184
|
+
case "3":
|
|
185
|
+
case "4":
|
|
186
|
+
case "5":
|
|
187
|
+
case "6":
|
|
188
|
+
case "7":
|
|
189
|
+
case "8":
|
|
190
|
+
case "9": {
|
|
191
|
+
const start = i;
|
|
192
|
+
if (text[i] === "-") {
|
|
193
|
+
i++;
|
|
194
|
+
}
|
|
195
|
+
digits();
|
|
196
|
+
if (text[i] === ".") {
|
|
197
|
+
i++;
|
|
198
|
+
digits();
|
|
199
|
+
}
|
|
200
|
+
if (text[i] === "e" || text[i] === "E") {
|
|
201
|
+
i++;
|
|
202
|
+
if (text[i] === "-" || text[i] === "+") {
|
|
203
|
+
i++;
|
|
204
|
+
}
|
|
205
|
+
digits();
|
|
206
|
+
}
|
|
207
|
+
value = text.slice(start, i);
|
|
208
|
+
token = "0";
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
default:
|
|
212
|
+
for (const word of LITERALS) {
|
|
213
|
+
if (text.startsWith(word, i)) {
|
|
214
|
+
i += word.length;
|
|
215
|
+
token = word[0];
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
fail();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const parseValue = () => {
|
|
224
|
+
switch (current()) {
|
|
225
|
+
case "n":
|
|
226
|
+
advance();
|
|
227
|
+
return null;
|
|
228
|
+
case "t":
|
|
229
|
+
advance();
|
|
230
|
+
return true;
|
|
231
|
+
case "f":
|
|
232
|
+
advance();
|
|
233
|
+
return false;
|
|
234
|
+
case '"': {
|
|
235
|
+
const s = value;
|
|
236
|
+
advance();
|
|
237
|
+
return s;
|
|
238
|
+
}
|
|
239
|
+
case "0": {
|
|
240
|
+
const n = Number(value);
|
|
241
|
+
advance();
|
|
242
|
+
return n;
|
|
243
|
+
}
|
|
244
|
+
case "[": {
|
|
245
|
+
advance();
|
|
246
|
+
const a = [];
|
|
247
|
+
if (current() !== "]") {
|
|
248
|
+
for (;;) {
|
|
249
|
+
a.push(parseValue());
|
|
250
|
+
if (current() !== ",") {
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
advance();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (current() !== "]") {
|
|
257
|
+
fail();
|
|
258
|
+
}
|
|
259
|
+
advance();
|
|
260
|
+
return rt.array(a);
|
|
261
|
+
}
|
|
262
|
+
case "{": {
|
|
263
|
+
advance();
|
|
264
|
+
const o = rt.newObject([]);
|
|
265
|
+
if (current() !== "}") {
|
|
266
|
+
for (;;) {
|
|
267
|
+
if (current() !== '"') {
|
|
268
|
+
fail();
|
|
269
|
+
}
|
|
270
|
+
const name = parseValue();
|
|
271
|
+
if (current() !== ":") {
|
|
272
|
+
fail();
|
|
273
|
+
}
|
|
274
|
+
advance();
|
|
275
|
+
rt.setProperty(o, publicQname(name, rt.userVersions), parseValue());
|
|
276
|
+
if (current() !== ",") {
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
advance();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (current() !== "}") {
|
|
283
|
+
fail();
|
|
284
|
+
}
|
|
285
|
+
advance();
|
|
286
|
+
return o;
|
|
287
|
+
}
|
|
288
|
+
default:
|
|
289
|
+
return fail();
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
advance();
|
|
293
|
+
const result = parseValue();
|
|
294
|
+
if (current() !== "") {
|
|
295
|
+
fail();
|
|
296
|
+
}
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
/** A class instance's public variables and readable accessors but [Transient] ones, the class's own first, as TypeDescriber lists them. */
|
|
300
|
+
function describedNames(traits, apiVersion) {
|
|
301
|
+
const variables = [];
|
|
302
|
+
const accessors = [];
|
|
303
|
+
for (let t = traits; t && t.name !== "Object"; t = t.base) {
|
|
304
|
+
for (const [name, list] of t.bindings) {
|
|
305
|
+
for (const b of list) {
|
|
306
|
+
// A member of a later version, AIR-only or VM-internal, is not the code's to see.
|
|
307
|
+
if (b.ns.kind !== NS_Public ||
|
|
308
|
+
b.ns.uri !== "" ||
|
|
309
|
+
b.version > apiVersion ||
|
|
310
|
+
traits.isTransient(b.value)) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
const kind = b.value & 7;
|
|
314
|
+
if (kind === 2 || kind === 3) {
|
|
315
|
+
variables.push(name);
|
|
316
|
+
}
|
|
317
|
+
else if (kind === 5 || kind === 7) {
|
|
318
|
+
accessors.push(name);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return [variables, accessors];
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* As JSONSerializer, in two steps, as Ruffle's does: the walk over the AS3
|
|
327
|
+
* values, calling toJSON and the replacer in avmplus' order and failing a
|
|
328
|
+
* cycle as it does, builds a tree of the host's values, which the host's
|
|
329
|
+
* JSON.stringify writes, gap and all. The text need not be avmplus' own:
|
|
330
|
+
* key order, escapes and numbers' digits differ, and it reads back as the
|
|
331
|
+
* same keys and values.
|
|
332
|
+
*/
|
|
333
|
+
class Serializer {
|
|
334
|
+
rt;
|
|
335
|
+
propertyList;
|
|
336
|
+
replacer;
|
|
337
|
+
gap;
|
|
338
|
+
active = new Set();
|
|
339
|
+
constructor(rt, propertyList, replacer, gap) {
|
|
340
|
+
this.rt = rt;
|
|
341
|
+
this.propertyList = propertyList;
|
|
342
|
+
this.replacer = replacer;
|
|
343
|
+
this.gap = gap;
|
|
344
|
+
}
|
|
345
|
+
stringify(v) {
|
|
346
|
+
const wrapper = this.rt.newObject([]);
|
|
347
|
+
wrapper.$d.set("", v);
|
|
348
|
+
const tree = this.str("", v, wrapper);
|
|
349
|
+
return tree === undefined ? undefined : JSON.stringify(tree, null, this.gap);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* As StrFoundValue: the value to write for `valueIn`, the host's, or
|
|
353
|
+
* undefined for none. A number the host writes as null if it is not
|
|
354
|
+
* finite, as avmplus does.
|
|
355
|
+
*/
|
|
356
|
+
str(key, valueIn, holder) {
|
|
357
|
+
const rt = this.rt;
|
|
358
|
+
let value = valueIn;
|
|
359
|
+
if (value !== null && value !== undefined) {
|
|
360
|
+
const probe = this.toJSONOf(value);
|
|
361
|
+
if (probe?.$f) {
|
|
362
|
+
value = rt.callValue(probe, value, [key], null);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (this.replacer) {
|
|
366
|
+
value = rt.callValue(this.replacer, holder, [key, value], null);
|
|
367
|
+
}
|
|
368
|
+
if (value instanceof FloatValue) {
|
|
369
|
+
return value.value;
|
|
370
|
+
}
|
|
371
|
+
switch (typeof value) {
|
|
372
|
+
case "boolean":
|
|
373
|
+
case "string":
|
|
374
|
+
case "number":
|
|
375
|
+
return value;
|
|
376
|
+
case "object":
|
|
377
|
+
break;
|
|
378
|
+
default:
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
if (value === null) {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
if (value.$f) {
|
|
385
|
+
return undefined;
|
|
386
|
+
}
|
|
387
|
+
const traits = rt.traitsOf(value);
|
|
388
|
+
if (isA(traits, "Array") || isVector(traits)) {
|
|
389
|
+
return this.array(value);
|
|
390
|
+
}
|
|
391
|
+
return this.object(value, traits);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* As the probe of StrFoundValue: `value`'s toJSON, or null. A public
|
|
395
|
+
* binding first; else, as hasProperty finds a public name that is not an
|
|
396
|
+
* index, the object's own dynamic one and then its prototype chain's.
|
|
397
|
+
*
|
|
398
|
+
* avmplus probes the AS3 namespace before the public one, with the
|
|
399
|
+
* builtin's own AS3 namespace, which sees AS3 bindings only at the
|
|
400
|
+
* builtin's API version: no class of avmshell's binds an AS3 toJSON
|
|
401
|
+
* (theirs are its prototypes'), and a script's AS3 toJSON is never
|
|
402
|
+
* found, even when it has no public one. So only the public one is.
|
|
403
|
+
*/
|
|
404
|
+
toJSONOf(value) {
|
|
405
|
+
const rt = this.rt;
|
|
406
|
+
const traits = rt.traitsOf(value);
|
|
407
|
+
let bound = boundToJSON.get(traits);
|
|
408
|
+
if (bound === undefined) {
|
|
409
|
+
bound = traits.find(rt.toJSONName) !== 0;
|
|
410
|
+
boundToJSON.set(traits, bound);
|
|
411
|
+
}
|
|
412
|
+
if (bound) {
|
|
413
|
+
return rt.getProperty(value, rt.toJSONName);
|
|
414
|
+
}
|
|
415
|
+
const own = typeof value === "object" ? value.$d : undefined;
|
|
416
|
+
if (own?.has("toJSON")) {
|
|
417
|
+
return own.get("toJSON");
|
|
418
|
+
}
|
|
419
|
+
for (let p = rt.protoOf(value); p; p = p.$p) {
|
|
420
|
+
if (p.$d?.has("toJSON")) {
|
|
421
|
+
return p.$d.get("toJSON");
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
enter(value) {
|
|
427
|
+
if (this.active.has(value)) {
|
|
428
|
+
throw this.rt.error("TypeError", 1129);
|
|
429
|
+
}
|
|
430
|
+
this.active.add(value);
|
|
431
|
+
}
|
|
432
|
+
/** As JO: the property list, or the described properties and then the dynamic ones. */
|
|
433
|
+
object(value, traits) {
|
|
434
|
+
const rt = this.rt;
|
|
435
|
+
this.enter(value);
|
|
436
|
+
const out = {};
|
|
437
|
+
const own = value.$d;
|
|
438
|
+
const prop = (name) => {
|
|
439
|
+
// A dynamic property of its own is where getProperty would find it.
|
|
440
|
+
const v = own?.has(name)
|
|
441
|
+
? own.get(name)
|
|
442
|
+
: rt.getProperty(value, publicQname(name, rt.userVersions));
|
|
443
|
+
const written = this.str(name, v, value);
|
|
444
|
+
if (written === undefined) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (name === "__proto__") {
|
|
448
|
+
// Assigned, it would set the prototype, not the key.
|
|
449
|
+
Object.defineProperty(out, name, { value: written, enumerable: true, writable: true });
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
out[name] = written;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
if (this.propertyList) {
|
|
456
|
+
for (const name of this.propertyList) {
|
|
457
|
+
prop(name);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
const [variables, accessors] = describedNames(traits, rt.apiVersion);
|
|
462
|
+
for (const name of [...variables, ...accessors]) {
|
|
463
|
+
prop(name);
|
|
464
|
+
}
|
|
465
|
+
for (const name of rt.enumerableNames(value)) {
|
|
466
|
+
prop(name);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
this.active.delete(value);
|
|
470
|
+
return out;
|
|
471
|
+
}
|
|
472
|
+
/** As JAfinish: each element, null for one that writes nothing. */
|
|
473
|
+
array(value) {
|
|
474
|
+
this.enter(value);
|
|
475
|
+
const length = value.$a.length;
|
|
476
|
+
const out = new Array(length);
|
|
477
|
+
for (let i = 0; i < length; i++) {
|
|
478
|
+
// The elements as they are now: toJSON or the replacer may have
|
|
479
|
+
// changed them, or the Vector its storage. A hole, or an element
|
|
480
|
+
// since removed, is got as getUintProperty gets it: from the
|
|
481
|
+
// prototype chain, or a Vector's RangeError.
|
|
482
|
+
const elements = value.$a;
|
|
483
|
+
const element = !(elements instanceof FloatVector) && i in elements
|
|
484
|
+
? elements[i]
|
|
485
|
+
: this.rt.getProperty(value, this.rt.publicName(i));
|
|
486
|
+
const written = this.str(String(i), element, value);
|
|
487
|
+
out[i] = written === undefined ? null : written;
|
|
488
|
+
}
|
|
489
|
+
this.active.delete(value);
|
|
490
|
+
return out;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function isVector(traits) {
|
|
494
|
+
for (let t = traits; t; t = t.base) {
|
|
495
|
+
if (t.name.startsWith("__AS3__.vec::Vector$")) {
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
function isA(traits, name) {
|
|
502
|
+
for (let t = traits; t; t = t.base) {
|
|
503
|
+
if (t.name === name) {
|
|
504
|
+
return true;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
export function jsonNatives() {
|
|
510
|
+
return {
|
|
511
|
+
"JSON.JSON::parseCore": (rt) => (text) => parseText(rt, rt.toString(text)),
|
|
512
|
+
"JSON.JSON::stringifySpecializedToString": (rt) => (value, propertyList, replacer, gap) => new Serializer(rt, propertyList?.$a ? propertyList.$a.map((n) => rt.toString(n)) : null, replacer?.$f ? replacer : null, gap === null || gap === undefined ? "" : rt.toString(gap)).stringify(value),
|
|
513
|
+
};
|
|
514
|
+
}
|