@swf2es/player-hosts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
// XMLNode, AS1 and AS2's, and the tree XML documents are made of, as
|
|
2
|
+
// Ruffle's (https://github.com/ruffle-rs/ruffle) core/src/avm1/xml/tree.rs
|
|
3
|
+
// and core/src/avm1/globals/xml_node.rs have them: MIT OR Apache-2.0,
|
|
4
|
+
// Copyright (c) 2018-2022 Ruffle LLC and Ruffle contributors. A node is
|
|
5
|
+
// native, and its AVM1 object made as a script first reaches it, of
|
|
6
|
+
// XMLNode's prototype at that time; its attributes are a plain object
|
|
7
|
+
// without a prototype, listed by for..in in the order they were written.
|
|
8
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
9
|
+
export const ELEMENT_NODE = 1;
|
|
10
|
+
export const TEXT_NODE = 3;
|
|
11
|
+
export class XmlNode {
|
|
12
|
+
type;
|
|
13
|
+
value;
|
|
14
|
+
/** Its AVM1 object, once a script has reached it. */
|
|
15
|
+
object = null;
|
|
16
|
+
parent = null;
|
|
17
|
+
prev = null;
|
|
18
|
+
next = null;
|
|
19
|
+
children = [];
|
|
20
|
+
attributes = new avm1.Avm1Object();
|
|
21
|
+
/**
|
|
22
|
+
* The `childNodes` array once asked for, kept in step with `children`,
|
|
23
|
+
* and what makes a child's object for it.
|
|
24
|
+
*/
|
|
25
|
+
childNodes = null;
|
|
26
|
+
/** A document's root's XML declaration and DOCTYPE, which its toString writes first. */
|
|
27
|
+
xmlDecl = null;
|
|
28
|
+
docTypeDecl = null;
|
|
29
|
+
constructor(
|
|
30
|
+
/** 1 for an element, 3 for text; any other number is kept, as text. */
|
|
31
|
+
type,
|
|
32
|
+
/** An element's name or a text's value; null for a document's root. */
|
|
33
|
+
value) {
|
|
34
|
+
this.type = type;
|
|
35
|
+
this.value = value;
|
|
36
|
+
}
|
|
37
|
+
/** Itself and its ancestors, nearest first. */
|
|
38
|
+
*ancestors() {
|
|
39
|
+
for (let n = this; n !== null; n = n.parent) {
|
|
40
|
+
yield n;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Whether `node` is this node or one of its ancestors. */
|
|
44
|
+
within(node) {
|
|
45
|
+
for (let n = this; n !== null; n = n.parent) {
|
|
46
|
+
if (n === node) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
/** `child` put at `position` among the children, out of any other parent; nothing where it is an ancestor. */
|
|
53
|
+
insert(position, child, version) {
|
|
54
|
+
// Only a node with children can be an ancestor but this one.
|
|
55
|
+
if (child === this || (child.children.length > 0 && this.within(child))) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const old = child.parent;
|
|
59
|
+
if (old !== null) {
|
|
60
|
+
old.orphan(child, version);
|
|
61
|
+
}
|
|
62
|
+
if (position >= this.children.length) {
|
|
63
|
+
this.adopt(child, version);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
child.parent = this;
|
|
67
|
+
this.children.splice(position, 0, child);
|
|
68
|
+
child.prev = this.children[position - 1] ?? null;
|
|
69
|
+
child.next = this.children[position + 1] ?? null;
|
|
70
|
+
if (child.prev !== null) {
|
|
71
|
+
child.prev.next = child;
|
|
72
|
+
}
|
|
73
|
+
if (child.next !== null) {
|
|
74
|
+
child.next.prev = child;
|
|
75
|
+
}
|
|
76
|
+
this.refresh(version);
|
|
77
|
+
}
|
|
78
|
+
append(child, version) {
|
|
79
|
+
this.insert(this.children.length, child, version);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* `child`, which has no parent, made the last child: no ancestor to
|
|
83
|
+
* check, and `childNodes`, where a script has it, takes it in place.
|
|
84
|
+
*/
|
|
85
|
+
adopt(child, version) {
|
|
86
|
+
const last = this.children.length > 0 ? this.children[this.children.length - 1] : null;
|
|
87
|
+
child.parent = this;
|
|
88
|
+
child.prev = last;
|
|
89
|
+
child.next = null;
|
|
90
|
+
if (last !== null) {
|
|
91
|
+
last.next = child;
|
|
92
|
+
}
|
|
93
|
+
this.children.push(child);
|
|
94
|
+
const cached = this.childNodes;
|
|
95
|
+
if (cached !== null) {
|
|
96
|
+
const i = this.children.length - 1;
|
|
97
|
+
avm1.set(cached.array, String(i), cached.objectOf(child, version), version);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Out of its parent's children. */
|
|
101
|
+
remove(version) {
|
|
102
|
+
this.parent?.orphan(this, version);
|
|
103
|
+
}
|
|
104
|
+
/** Every child out, at once. */
|
|
105
|
+
clear(version) {
|
|
106
|
+
for (const child of this.children) {
|
|
107
|
+
child.parent = null;
|
|
108
|
+
child.prev = null;
|
|
109
|
+
child.next = null;
|
|
110
|
+
}
|
|
111
|
+
this.children.length = 0;
|
|
112
|
+
this.refresh(version);
|
|
113
|
+
}
|
|
114
|
+
orphan(child, version) {
|
|
115
|
+
const i = this.children.indexOf(child);
|
|
116
|
+
if (i >= 0) {
|
|
117
|
+
this.children.splice(i, 1);
|
|
118
|
+
}
|
|
119
|
+
child.unlink();
|
|
120
|
+
child.parent = null;
|
|
121
|
+
this.refresh(version);
|
|
122
|
+
}
|
|
123
|
+
/** Out of its siblings' list, which closes over the gap. */
|
|
124
|
+
unlink() {
|
|
125
|
+
if (this.prev !== null) {
|
|
126
|
+
this.prev.next = this.next;
|
|
127
|
+
}
|
|
128
|
+
if (this.next !== null) {
|
|
129
|
+
this.next.prev = this.prev;
|
|
130
|
+
}
|
|
131
|
+
this.prev = null;
|
|
132
|
+
this.next = null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* `childNodes`, where a script has it, made the children's objects again,
|
|
136
|
+
* in place, so that an array a script holds follows, as Flash's does.
|
|
137
|
+
*/
|
|
138
|
+
refresh(version) {
|
|
139
|
+
const cached = this.childNodes;
|
|
140
|
+
if (cached === null) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
avm1.set(cached.array, "length", 0, version);
|
|
144
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
145
|
+
avm1.set(cached.array, String(i), cached.objectOf(this.children[i], version), version);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/** The attributes' names, in the order for..in lists them, which is the order they were written. */
|
|
149
|
+
attributeNames(version) {
|
|
150
|
+
return avm1.keys(this.attributes, version);
|
|
151
|
+
}
|
|
152
|
+
/** A copy, without a parent or an object, of its children too where `deep`; a loop, however deep. */
|
|
153
|
+
duplicate(version, deep) {
|
|
154
|
+
const copy = (node) => {
|
|
155
|
+
const clone = new XmlNode(node.type, node.value);
|
|
156
|
+
copyAttributes(node.attributes, clone.attributes, version);
|
|
157
|
+
return clone;
|
|
158
|
+
};
|
|
159
|
+
const root = copy(this);
|
|
160
|
+
if (!deep) {
|
|
161
|
+
return root;
|
|
162
|
+
}
|
|
163
|
+
const stack = [[this, root]];
|
|
164
|
+
for (let pair = stack.pop(); pair !== undefined; pair = stack.pop()) {
|
|
165
|
+
const [from, to] = pair;
|
|
166
|
+
for (const child of from.children) {
|
|
167
|
+
const clone = copy(child);
|
|
168
|
+
to.adopt(clone, version);
|
|
169
|
+
stack.push([child, clone]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return root;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The URI an `xmlns` attribute of it or an ancestor gives `prefix`, the
|
|
176
|
+
* nearest first; the empty prefix takes any `xmlns` attribute.
|
|
177
|
+
*/
|
|
178
|
+
namespaceOf(prefix, version) {
|
|
179
|
+
for (const node of this.ancestors()) {
|
|
180
|
+
for (const key of node.attributeNames(version)) {
|
|
181
|
+
if (!key.startsWith("xmlns")) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const rest = key.slice(5);
|
|
185
|
+
if (prefix === "" || (rest.startsWith(":") && rest.slice(1) === prefix)) {
|
|
186
|
+
return avm1.get(node.attributes, key, version);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** `from`'s attributes on `to`, in the same for..in order. */
|
|
194
|
+
function copyAttributes(from, to, version) {
|
|
195
|
+
const names = avm1.keys(from, version);
|
|
196
|
+
for (let i = names.length - 1; i >= 0; i--) {
|
|
197
|
+
to.define(names[i], avm1.get(from, names[i], version), 0);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const ESCAPES = {
|
|
201
|
+
"&": "&",
|
|
202
|
+
"<": "<",
|
|
203
|
+
">": ">",
|
|
204
|
+
'"': """,
|
|
205
|
+
"'": "'",
|
|
206
|
+
};
|
|
207
|
+
/** `text` with XML's five characters escaped. */
|
|
208
|
+
export function escapeXml(text) {
|
|
209
|
+
return text.replace(/[&<>"']/g, (c) => ESCAPES[c]);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The node as XML text: an element with no children as `<a />`, a
|
|
213
|
+
* document's root as its declarations and its children (adl).
|
|
214
|
+
*/
|
|
215
|
+
export function serialize(node, version) {
|
|
216
|
+
const out = [];
|
|
217
|
+
if (node.xmlDecl !== null) {
|
|
218
|
+
out.push(node.xmlDecl);
|
|
219
|
+
}
|
|
220
|
+
if (node.docTypeDecl !== null) {
|
|
221
|
+
out.push(node.docTypeDecl);
|
|
222
|
+
}
|
|
223
|
+
// A loop over a stack of what is left to write, however deep the tree:
|
|
224
|
+
// a node to open, or the end tag of an element whose children are written.
|
|
225
|
+
const stack = [node];
|
|
226
|
+
for (let item = stack.pop(); item !== undefined; item = stack.pop()) {
|
|
227
|
+
if (typeof item === "string") {
|
|
228
|
+
out.push(item);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (item.type !== ELEMENT_NODE) {
|
|
232
|
+
out.push(escapeXml(item.value ?? ""));
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const name = item.value;
|
|
236
|
+
if (name !== null) {
|
|
237
|
+
out.push("<", name);
|
|
238
|
+
for (const key of item.attributeNames(version)) {
|
|
239
|
+
const value = avm1.stringOf(avm1.get(item.attributes, key, version), version);
|
|
240
|
+
out.push(" ", key, '="', escapeXml(value), '"');
|
|
241
|
+
}
|
|
242
|
+
if (item.children.length === 0) {
|
|
243
|
+
out.push(" />");
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
out.push(">");
|
|
247
|
+
stack.push(`</${name}>`);
|
|
248
|
+
}
|
|
249
|
+
for (let i = item.children.length - 1; i >= 0; i--) {
|
|
250
|
+
stack.push(item.children[i]);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return out.join("");
|
|
254
|
+
}
|
|
255
|
+
/** `_global.XMLNode`. */
|
|
256
|
+
export function xmlNodeClass(host) {
|
|
257
|
+
const realm = host.realm;
|
|
258
|
+
const nodes = new WeakMap();
|
|
259
|
+
const nodeOf = (value) => value instanceof avm1.Avm1Object ? (nodes.get(value) ?? null) : null;
|
|
260
|
+
const bind = (object, node) => {
|
|
261
|
+
node.object = object;
|
|
262
|
+
nodes.set(object, node);
|
|
263
|
+
};
|
|
264
|
+
const proto = new avm1.Avm1Object(realm.objectProto);
|
|
265
|
+
const constr = realm.classOf(proto,
|
|
266
|
+
// Without a type and a value it is no node: its properties are undefined (adl).
|
|
267
|
+
(self, args, v) => {
|
|
268
|
+
if (args.length >= 2) {
|
|
269
|
+
bind(self, new XmlNode(avm1.toNumber(args[0], v) & 0xff, avm1.stringOf(args[1], v)));
|
|
270
|
+
}
|
|
271
|
+
return self;
|
|
272
|
+
}, () => undefined);
|
|
273
|
+
// A node's object is of the prototype the class has when a script first reaches it.
|
|
274
|
+
const objectOf = (node, version) => {
|
|
275
|
+
if (node.object === null) {
|
|
276
|
+
const prototype = avm1.get(constr, "prototype", version);
|
|
277
|
+
bind(new avm1.Avm1Object(prototype instanceof avm1.Avm1Object ? prototype : undefined), node);
|
|
278
|
+
}
|
|
279
|
+
return node.object;
|
|
280
|
+
};
|
|
281
|
+
const objectOrNull = (node, version) => node === null ? null : objectOf(node, version);
|
|
282
|
+
const method = (name, fn) => proto.define(name, realm.method(fn), 0);
|
|
283
|
+
/** A getter, and a setter where given, of a node, undefined for any other object. */
|
|
284
|
+
const property = (name, get, set) => {
|
|
285
|
+
const p = proto.add(name, undefined, 0);
|
|
286
|
+
p.get = realm.method((self, _, v) => {
|
|
287
|
+
const node = nodes.get(self);
|
|
288
|
+
return node === undefined ? undefined : get(node, v);
|
|
289
|
+
});
|
|
290
|
+
if (set !== undefined) {
|
|
291
|
+
p.set = realm.method((self, args, v) => {
|
|
292
|
+
const node = nodes.get(self);
|
|
293
|
+
if (node !== undefined) {
|
|
294
|
+
set(node, args[0], v);
|
|
295
|
+
}
|
|
296
|
+
return undefined;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
method("cloneNode", (self, args, v) => {
|
|
301
|
+
const node = nodes.get(self);
|
|
302
|
+
if (node === undefined) {
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
305
|
+
const deep = args.length > 0 && avm1.toBoolean(args[0], v);
|
|
306
|
+
return objectOf(node.duplicate(v, deep), v);
|
|
307
|
+
});
|
|
308
|
+
method("removeNode", (self, _, v) => {
|
|
309
|
+
nodes.get(self)?.remove(v);
|
|
310
|
+
return undefined;
|
|
311
|
+
});
|
|
312
|
+
method("insertBefore", (self, args, v) => {
|
|
313
|
+
const node = nodes.get(self);
|
|
314
|
+
const child = nodeOf(args[0]);
|
|
315
|
+
const before = nodeOf(args[1]);
|
|
316
|
+
if (node === undefined || child === null || before === null || child.parent === node) {
|
|
317
|
+
return undefined;
|
|
318
|
+
}
|
|
319
|
+
const position = node.children.indexOf(before);
|
|
320
|
+
if (position >= 0) {
|
|
321
|
+
node.insert(position, child, v);
|
|
322
|
+
}
|
|
323
|
+
return undefined;
|
|
324
|
+
});
|
|
325
|
+
method("appendChild", (self, args, v) => {
|
|
326
|
+
const node = nodes.get(self);
|
|
327
|
+
const child = nodeOf(args[0]);
|
|
328
|
+
if (node !== undefined && child !== null && child.parent !== node) {
|
|
329
|
+
node.append(child, v);
|
|
330
|
+
}
|
|
331
|
+
return undefined;
|
|
332
|
+
});
|
|
333
|
+
method("hasChildNodes", (self) => {
|
|
334
|
+
const node = nodes.get(self);
|
|
335
|
+
return node === undefined ? undefined : node.children.length > 0;
|
|
336
|
+
});
|
|
337
|
+
method("toString", (self, _, v) => {
|
|
338
|
+
const node = nodes.get(self);
|
|
339
|
+
return node === undefined ? "" : serialize(node, v);
|
|
340
|
+
});
|
|
341
|
+
method("getNamespaceForPrefix", (self, args, v) => {
|
|
342
|
+
const node = nodes.get(self);
|
|
343
|
+
if (node === undefined || args.length === 0) {
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
return node.namespaceOf(avm1.stringOf(args[0], v), v);
|
|
347
|
+
});
|
|
348
|
+
method("getPrefixForNamespace", (self, args, v) => {
|
|
349
|
+
const node = nodes.get(self);
|
|
350
|
+
if (node === undefined || args.length === 0) {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
const uri = avm1.stringOf(args[0], v);
|
|
354
|
+
for (const ancestor of node.ancestors()) {
|
|
355
|
+
for (const key of ancestor.attributeNames(v)) {
|
|
356
|
+
const value = avm1.stringOf(avm1.get(ancestor.attributes, key, v), v);
|
|
357
|
+
if (value === uri && key.startsWith("xmlns")) {
|
|
358
|
+
const rest = key.slice(5);
|
|
359
|
+
return rest.startsWith(":") ? rest.slice(1) : "";
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return null;
|
|
364
|
+
});
|
|
365
|
+
property("attributes", (node) => node.attributes);
|
|
366
|
+
property("childNodes", (node, v) => {
|
|
367
|
+
if (node.childNodes === null) {
|
|
368
|
+
node.childNodes = { array: realm.newArray([], v), objectOf };
|
|
369
|
+
node.refresh(v);
|
|
370
|
+
}
|
|
371
|
+
return node.childNodes.array;
|
|
372
|
+
});
|
|
373
|
+
property("firstChild", (node, v) => objectOrNull(node.children[0] ?? null, v));
|
|
374
|
+
property("lastChild", (node, v) => objectOrNull(node.children.at(-1) ?? null, v));
|
|
375
|
+
property("nextSibling", (node, v) => objectOrNull(node.next, v));
|
|
376
|
+
// nodeName and nodeValue set the same: an element's name or a text's value.
|
|
377
|
+
const setValue = (node, value, v) => {
|
|
378
|
+
if (value !== undefined) {
|
|
379
|
+
node.value = avm1.stringOf(value, v);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
property("nodeName", (node) => (node.type === ELEMENT_NODE ? node.value : null), setValue);
|
|
383
|
+
property("nodeType", (node) => node.type);
|
|
384
|
+
property("nodeValue", (node) => (node.type === ELEMENT_NODE ? null : node.value), setValue);
|
|
385
|
+
property("parentNode", (node, v) => objectOrNull(node.parent, v));
|
|
386
|
+
property("previousSibling", (node, v) => objectOrNull(node.prev, v));
|
|
387
|
+
property("prefix", (node) => {
|
|
388
|
+
const name = node.type === ELEMENT_NODE ? node.value : null;
|
|
389
|
+
if (name === null) {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
const colon = name.indexOf(":");
|
|
393
|
+
return colon >= 0 && colon + 1 < name.length ? name.slice(0, colon) : "";
|
|
394
|
+
});
|
|
395
|
+
property("localName", (node) => {
|
|
396
|
+
const name = node.type === ELEMENT_NODE ? node.value : null;
|
|
397
|
+
if (name === null) {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
const colon = name.indexOf(":");
|
|
401
|
+
return colon >= 0 && colon + 1 < name.length ? name.slice(colon + 1) : name;
|
|
402
|
+
});
|
|
403
|
+
property("namespaceURI", (node, v) => {
|
|
404
|
+
const name = node.type === ELEMENT_NODE ? node.value : null;
|
|
405
|
+
if (name === null) {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
const colon = name.indexOf(":");
|
|
409
|
+
const prefix = colon >= 0 && colon + 1 < name.length ? name.slice(0, colon) : "";
|
|
410
|
+
return node.namespaceOf(prefix, v) ?? "";
|
|
411
|
+
});
|
|
412
|
+
return { constr, proto, nodeOf, objectOf, bind };
|
|
413
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// XMLSocket, AS1 and AS2's, as Ruffle's (https://github.com/ruffle-rs/
|
|
2
|
+
// ruffle) core/src/avm1/globals/xml_socket.rs and core/src/socket.rs have
|
|
3
|
+
// it: MIT OR Apache-2.0, Copyright (c) 2018-2022 Ruffle LLC and Ruffle
|
|
4
|
+
// contributors. It connects through the host's sockets, as AS3's Socket
|
|
5
|
+
// and XMLSocket do, so the same hosts serve both: the browser's refusal or
|
|
6
|
+
// relay, the desktop app's TCP. Each message either way is a string ended
|
|
7
|
+
// by a zero byte; each that comes is given to onData, whose default makes
|
|
8
|
+
// an XML of it for onXML. Without a host, or refused, the connection fails
|
|
9
|
+
// as Flash's does, with onConnect(false), never an error.
|
|
10
|
+
import { avm1 } from "../../../runtime/index.js";
|
|
11
|
+
import { bytesFor, textFor } from "../net.js";
|
|
12
|
+
/** The SWF's domain, which a connect without a host goes to: localhost for a file's. */
|
|
13
|
+
function swfDomain(url) {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = new URL(url);
|
|
16
|
+
return parsed.protocol === "file:" || !parsed.hostname ? "localhost" : parsed.hostname;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return "localhost";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The most a message may hold before its zero byte: a server that never
|
|
24
|
+
* ends one has its connection closed, rather than the player's memory fill.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_MESSAGE = 16 * 1024 * 1024;
|
|
27
|
+
const decoder = new TextDecoder();
|
|
28
|
+
/** `_global.XMLSocket`, given `_global.XML`'s constructor, which the default onData makes its XML with. */
|
|
29
|
+
export function xmlSocketClass(host, xml) {
|
|
30
|
+
const realm = host.realm;
|
|
31
|
+
const connections = new WeakMap();
|
|
32
|
+
const proto = new avm1.Avm1Object(realm.objectProto);
|
|
33
|
+
const constr = realm.classOf(proto, (self) => {
|
|
34
|
+
connections.set(self, {
|
|
35
|
+
transport: null,
|
|
36
|
+
generation: 0,
|
|
37
|
+
open: false,
|
|
38
|
+
queued: [],
|
|
39
|
+
partial: [],
|
|
40
|
+
partialLength: 0,
|
|
41
|
+
// Flash's default, 20 seconds.
|
|
42
|
+
timeout: 20000,
|
|
43
|
+
});
|
|
44
|
+
return self;
|
|
45
|
+
}, () => undefined);
|
|
46
|
+
// Each of them hidden from for..in (adl).
|
|
47
|
+
const HIDDEN = avm1.DONT_ENUM | avm1.DONT_DELETE;
|
|
48
|
+
const method = (name, fn) => proto.define(name, realm.method(fn), HIDDEN);
|
|
49
|
+
/** The connection dropped, from the script's side or either end's: no event of it comes after. */
|
|
50
|
+
const drop = (c) => {
|
|
51
|
+
c.generation++;
|
|
52
|
+
if (c.transport !== null) {
|
|
53
|
+
host.net.closed(c.transport);
|
|
54
|
+
}
|
|
55
|
+
c.transport = null;
|
|
56
|
+
c.open = false;
|
|
57
|
+
c.queued = [];
|
|
58
|
+
c.partial = [];
|
|
59
|
+
c.partialLength = 0;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* `bytes` come: each message they end to onData, while the connection is
|
|
63
|
+
* the one they came on. Only the new bytes are searched for a zero byte;
|
|
64
|
+
* what comes before one waits, up to MAX_MESSAGE.
|
|
65
|
+
*/
|
|
66
|
+
const received = (self, c, generation, bytes) => {
|
|
67
|
+
let start = 0;
|
|
68
|
+
for (let end = bytes.indexOf(0); end >= 0; end = bytes.indexOf(0, start)) {
|
|
69
|
+
let message = bytes.subarray(start, end);
|
|
70
|
+
if (c.partialLength > 0) {
|
|
71
|
+
c.partial.push(message);
|
|
72
|
+
message = new Uint8Array(c.partialLength + message.length);
|
|
73
|
+
let at = 0;
|
|
74
|
+
for (const part of c.partial) {
|
|
75
|
+
message.set(part, at);
|
|
76
|
+
at += part.length;
|
|
77
|
+
}
|
|
78
|
+
c.partial = [];
|
|
79
|
+
c.partialLength = 0;
|
|
80
|
+
}
|
|
81
|
+
start = end + 1;
|
|
82
|
+
host.callback(self, "onData", [textFor(decoder.decode(message), host.version)]);
|
|
83
|
+
if (c.generation !== generation) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (start < bytes.length) {
|
|
88
|
+
c.partial.push(bytes.slice(start));
|
|
89
|
+
c.partialLength += bytes.length - start;
|
|
90
|
+
if (c.partialLength > MAX_MESSAGE) {
|
|
91
|
+
drop(c);
|
|
92
|
+
host.callback(self, "onClose", []);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const timeout = proto.add("timeout", undefined, HIDDEN);
|
|
97
|
+
timeout.get = realm.method((self) => connections.get(self)?.timeout);
|
|
98
|
+
timeout.set = realm.method((self, args, v) => {
|
|
99
|
+
const c = connections.get(self);
|
|
100
|
+
if (c !== undefined) {
|
|
101
|
+
c.timeout = avm1.toNumber(args[0], v) >>> 0;
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
});
|
|
105
|
+
method("close", (self) => {
|
|
106
|
+
const c = connections.get(self);
|
|
107
|
+
if (c !== undefined && c.transport !== null) {
|
|
108
|
+
drop(c);
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
});
|
|
112
|
+
method("connect", (self, args, v) => {
|
|
113
|
+
const c = connections.get(self);
|
|
114
|
+
if (c === undefined) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const given = args[0];
|
|
118
|
+
const name = given === undefined || given === null ? swfDomain(host.url) : avm1.stringOf(given, v);
|
|
119
|
+
// A port out of range is refused, as AS3's Socket refuses it, and nothing connects.
|
|
120
|
+
const port = avm1.toNumber(args[1], v) | 0;
|
|
121
|
+
if (port < 0 || port > 0xffff) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
drop(c);
|
|
125
|
+
const generation = c.generation;
|
|
126
|
+
const current = () => c.generation === generation;
|
|
127
|
+
const failed = () => {
|
|
128
|
+
if (current()) {
|
|
129
|
+
drop(c);
|
|
130
|
+
host.callback(self, "onConnect", [false]);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
c.transport = host.net.connect(name, port, {
|
|
134
|
+
open: () => {
|
|
135
|
+
if (!current()) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
c.open = true;
|
|
139
|
+
for (const bytes of c.queued) {
|
|
140
|
+
c.transport?.send(bytes);
|
|
141
|
+
}
|
|
142
|
+
c.queued = [];
|
|
143
|
+
host.callback(self, "onConnect", [true]);
|
|
144
|
+
},
|
|
145
|
+
data: (bytes) => {
|
|
146
|
+
if (current() && c.open) {
|
|
147
|
+
received(self, c, generation, bytes);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
close: () => {
|
|
151
|
+
if (!current()) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (!c.open) {
|
|
155
|
+
failed();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
c.generation++;
|
|
159
|
+
c.transport = null;
|
|
160
|
+
c.open = false;
|
|
161
|
+
c.partial = [];
|
|
162
|
+
c.partialLength = 0;
|
|
163
|
+
host.callback(self, "onClose", []);
|
|
164
|
+
},
|
|
165
|
+
error: () => {
|
|
166
|
+
if (!current()) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (!c.open) {
|
|
170
|
+
failed();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
drop(c);
|
|
174
|
+
host.callback(self, "onClose", []);
|
|
175
|
+
},
|
|
176
|
+
}, failed, c.timeout);
|
|
177
|
+
// Whether it connects is known only later: true says it was asked.
|
|
178
|
+
return true;
|
|
179
|
+
});
|
|
180
|
+
method("send", (self, args, v) => {
|
|
181
|
+
const c = connections.get(self);
|
|
182
|
+
if (c === undefined || c.transport === null) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
const text = bytesFor(avm1.stringOf(args[0], v), v);
|
|
186
|
+
const bytes = new Uint8Array(text.length + 1);
|
|
187
|
+
bytes.set(text);
|
|
188
|
+
if (c.open) {
|
|
189
|
+
c.transport.send(bytes);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
c.queued.push(bytes);
|
|
193
|
+
}
|
|
194
|
+
return undefined;
|
|
195
|
+
});
|
|
196
|
+
method("onConnect", () => undefined);
|
|
197
|
+
method("onClose", () => undefined);
|
|
198
|
+
method("onData", (self, args, v) => {
|
|
199
|
+
const document = realm.construct(xml, args, v);
|
|
200
|
+
avm1.invoke(avm1.get(self, "onXML", v), self, [document], v);
|
|
201
|
+
return undefined;
|
|
202
|
+
});
|
|
203
|
+
method("onXML", () => undefined);
|
|
204
|
+
return constr;
|
|
205
|
+
}
|