@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,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the browser's file picker greys out every file of a type it does not know when an
|
|
3
|
+
* input names any, as iOS's and iPadOS's do (an iPad asks as a Mac with touch; so does a Mac
|
|
4
|
+
* emulating touch in its developer tools): there an input takes no filter, and every file can
|
|
5
|
+
* be picked.
|
|
6
|
+
*/
|
|
7
|
+
export function filtersGreyOutFiles(navigator) {
|
|
8
|
+
if (!navigator) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return (/\b(iPhone|iPad|iPod)\b/.test(navigator.userAgent) ||
|
|
12
|
+
(navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1));
|
|
13
|
+
}
|
|
14
|
+
/** The extensions FileReference's filters name, ".xml" for "*.xml"; none for a filter of any file. */
|
|
15
|
+
function extensionsOf(filters) {
|
|
16
|
+
return filters
|
|
17
|
+
.flatMap((filter) => filter.extension.split(";"))
|
|
18
|
+
.map((ext) => ext.trim().replace(/^\*\./, "."))
|
|
19
|
+
.filter((ext) => /^\.[\w-]+$/.test(ext));
|
|
20
|
+
}
|
|
21
|
+
/** A file input's `accept` for FileReference's filters, none where the picker would grey files out. */
|
|
22
|
+
export function acceptOf(filters, navigator) {
|
|
23
|
+
return filtersGreyOutFiles(navigator) ? "" : extensionsOf(filters).join(",");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Whether a file picked with no filter is one the filters take: where the picker could not
|
|
27
|
+
* filter, the files it gives are held to them here, as Flash's dialog never offers others.
|
|
28
|
+
*/
|
|
29
|
+
export function filtersTake(filters, name) {
|
|
30
|
+
const extensions = extensionsOf(filters);
|
|
31
|
+
const lower = name.toLowerCase();
|
|
32
|
+
return extensions.length === 0 || extensions.some((ext) => lower.endsWith(ext.toLowerCase()));
|
|
33
|
+
}
|
|
34
|
+
/** Browser dialogs are asked synchronously, while transient user activation is still present. */
|
|
35
|
+
export function browserFileHost() {
|
|
36
|
+
if (typeof document === "undefined") {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const active = () => globalThis.navigator?.userActivation?.isActive === true;
|
|
40
|
+
return {
|
|
41
|
+
browse(filters, multiple, signal) {
|
|
42
|
+
if (!active() || signal.aborted) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const input = document.createElement("input");
|
|
47
|
+
input.type = "file";
|
|
48
|
+
input.multiple = multiple;
|
|
49
|
+
input.accept = acceptOf(filters, globalThis.navigator);
|
|
50
|
+
const unfiltered = input.accept === "";
|
|
51
|
+
input.hidden = true;
|
|
52
|
+
const finish = (files) => {
|
|
53
|
+
signal.removeEventListener("abort", abort);
|
|
54
|
+
input.remove();
|
|
55
|
+
resolve(files);
|
|
56
|
+
};
|
|
57
|
+
const abort = () => finish([]);
|
|
58
|
+
input.addEventListener("cancel", () => finish([]), { once: true });
|
|
59
|
+
input.addEventListener("change", () => finish(
|
|
60
|
+
// None that the filters take is a cancel, as a dialog closed with none chosen.
|
|
61
|
+
Array.from(input.files ?? [])
|
|
62
|
+
.filter((file) => !unfiltered || filtersTake(filters, file.name))
|
|
63
|
+
.map((file) => ({
|
|
64
|
+
name: file.name,
|
|
65
|
+
size: file.size,
|
|
66
|
+
modificationDate: file.lastModified,
|
|
67
|
+
read: async () => new Uint8Array(await file.arrayBuffer()),
|
|
68
|
+
}))), { once: true });
|
|
69
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
70
|
+
document.body.append(input);
|
|
71
|
+
try {
|
|
72
|
+
if (typeof input.showPicker === "function") {
|
|
73
|
+
input.showPicker();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
input.click();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
signal.removeEventListener("abort", abort);
|
|
81
|
+
input.remove();
|
|
82
|
+
reject(error);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
save(name, signal) {
|
|
87
|
+
if (!active() || signal.aborted) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return pickSaveFile(name);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Where `save` writes: a file the user picks, or a download where the browser has no picker. */
|
|
95
|
+
async function pickSaveFile(name) {
|
|
96
|
+
const picker = globalThis.showSaveFilePicker;
|
|
97
|
+
if (picker) {
|
|
98
|
+
try {
|
|
99
|
+
const handle = await picker.call(globalThis, { suggestedName: name });
|
|
100
|
+
return {
|
|
101
|
+
name: handle.name,
|
|
102
|
+
async write(bytes, signal) {
|
|
103
|
+
signal.throwIfAborted();
|
|
104
|
+
const stream = await handle.createWritable();
|
|
105
|
+
try {
|
|
106
|
+
await stream.write(bytes);
|
|
107
|
+
signal.throwIfAborted();
|
|
108
|
+
await stream.close();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
await stream.abort();
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error.name === "AbortError") {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
name,
|
|
126
|
+
async write(bytes, signal) {
|
|
127
|
+
signal.throwIfAborted();
|
|
128
|
+
const url = URL.createObjectURL(new Blob([bytes.slice().buffer]));
|
|
129
|
+
const link = document.createElement("a");
|
|
130
|
+
link.href = url;
|
|
131
|
+
link.download = name;
|
|
132
|
+
link.hidden = true;
|
|
133
|
+
document.body.append(link);
|
|
134
|
+
link.click();
|
|
135
|
+
link.remove();
|
|
136
|
+
// The browser may consume the URL after click returns.
|
|
137
|
+
setTimeout(() => URL.revokeObjectURL(url), 60_000);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** One reference's operation, with stale host callbacks suppressed after cancel or destruction. */
|
|
142
|
+
export class FileReference {
|
|
143
|
+
services;
|
|
144
|
+
event;
|
|
145
|
+
file = null;
|
|
146
|
+
data = null;
|
|
147
|
+
operation = null;
|
|
148
|
+
generation = 0;
|
|
149
|
+
constructor(services, event) {
|
|
150
|
+
this.services = services;
|
|
151
|
+
this.event = event;
|
|
152
|
+
}
|
|
153
|
+
cancel() {
|
|
154
|
+
this.generation++;
|
|
155
|
+
this.operation?.abort();
|
|
156
|
+
this.operation = null;
|
|
157
|
+
}
|
|
158
|
+
begin() {
|
|
159
|
+
if (this.operation) {
|
|
160
|
+
this.services.error(2174);
|
|
161
|
+
}
|
|
162
|
+
const abort = new AbortController();
|
|
163
|
+
const operation = {
|
|
164
|
+
generation: ++this.generation,
|
|
165
|
+
signal: AbortSignal.any([abort.signal, this.services.signal]),
|
|
166
|
+
abort: () => abort.abort(),
|
|
167
|
+
};
|
|
168
|
+
this.operation = operation;
|
|
169
|
+
return operation;
|
|
170
|
+
}
|
|
171
|
+
emit(operation, type, loaded = 0, total = 0, text = "") {
|
|
172
|
+
if (operation.signal.aborted || operation.generation !== this.generation) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
this.event(type, loaded, total, text);
|
|
176
|
+
return !operation.signal.aborted && operation.generation === this.generation;
|
|
177
|
+
}
|
|
178
|
+
fail(operation) {
|
|
179
|
+
this.operation = null;
|
|
180
|
+
try {
|
|
181
|
+
this.emit(operation, "ioError", 0, 0, "Error #2038: File I/O Error.");
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
// Hosts may hold a save destination even when the transfer never reached write().
|
|
185
|
+
operation.abort();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Deliver what `task` gives in the next frame; a value already known goes without a promise's
|
|
190
|
+
* delay. Any thenable is a promise here: a host built in another window has that realm's.
|
|
191
|
+
*/
|
|
192
|
+
after(operation, task, deliver) {
|
|
193
|
+
if (typeof task?.then !== "function") {
|
|
194
|
+
this.services.defer(() => {
|
|
195
|
+
if (!operation.signal.aborted && operation.generation === this.generation) {
|
|
196
|
+
deliver(task);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.services.track(Promise.resolve(task).then((value) => this.services.defer(() => {
|
|
202
|
+
if (!operation.signal.aborted && operation.generation === this.generation) {
|
|
203
|
+
deliver(value);
|
|
204
|
+
}
|
|
205
|
+
}), () => this.services.defer(() => {
|
|
206
|
+
if (!operation.signal.aborted && operation.generation === this.generation) {
|
|
207
|
+
this.fail(operation);
|
|
208
|
+
}
|
|
209
|
+
})));
|
|
210
|
+
}
|
|
211
|
+
browse(filters, multiple = false, selected) {
|
|
212
|
+
const operation = this.begin();
|
|
213
|
+
const task = this.services.host?.browse(filters, multiple, operation.signal) ?? [];
|
|
214
|
+
this.after(operation, task, (files) => {
|
|
215
|
+
this.operation = null;
|
|
216
|
+
if (files.length) {
|
|
217
|
+
this.file = files[0];
|
|
218
|
+
this.data = null;
|
|
219
|
+
selected?.(files);
|
|
220
|
+
}
|
|
221
|
+
this.emit(operation, files.length ? "select" : "cancel");
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
load() {
|
|
225
|
+
const file = this.file ?? this.services.error(2037);
|
|
226
|
+
const operation = this.begin();
|
|
227
|
+
this.after(operation, file.read(operation.signal), (bytes) => {
|
|
228
|
+
this.data = bytes;
|
|
229
|
+
if (this.emit(operation, "open") &&
|
|
230
|
+
this.emit(operation, "progress", bytes.length, bytes.length)) {
|
|
231
|
+
this.operation = null;
|
|
232
|
+
this.emit(operation, "complete");
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
save(name, bytes) {
|
|
237
|
+
const operation = this.begin();
|
|
238
|
+
const task = this.services.host?.save(name, operation.signal) ?? null;
|
|
239
|
+
this.after(operation, task, (destination) => {
|
|
240
|
+
if (!destination) {
|
|
241
|
+
this.operation = null;
|
|
242
|
+
this.emit(operation, "cancel");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.file = {
|
|
246
|
+
name: destination.name,
|
|
247
|
+
size: 0,
|
|
248
|
+
modificationDate: 0,
|
|
249
|
+
read: async () => this.services.error(2037),
|
|
250
|
+
};
|
|
251
|
+
this.data = null;
|
|
252
|
+
if (!this.emit(operation, "select") || !this.emit(operation, "open")) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const transfer = async () => {
|
|
256
|
+
const result = bytes instanceof Uint8Array
|
|
257
|
+
? bytes
|
|
258
|
+
: (await this.services.fetch(bytes, operation.signal)).bytes;
|
|
259
|
+
if (result === null) {
|
|
260
|
+
throw new Error("download failed");
|
|
261
|
+
}
|
|
262
|
+
operation.signal.throwIfAborted();
|
|
263
|
+
await destination.write(result, operation.signal);
|
|
264
|
+
return result;
|
|
265
|
+
};
|
|
266
|
+
this.after(operation, transfer(), (bytes) => {
|
|
267
|
+
if (this.file) {
|
|
268
|
+
this.file.size = bytes.length;
|
|
269
|
+
this.file.modificationDate = Date.now();
|
|
270
|
+
this.file.read = async () => bytes.slice();
|
|
271
|
+
}
|
|
272
|
+
if (this.emit(operation, "progress", bytes.length, bytes.length)) {
|
|
273
|
+
this.operation = null;
|
|
274
|
+
this.emit(operation, "complete");
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
upload(request, field, test = false) {
|
|
280
|
+
const file = this.file ?? this.services.error(2037);
|
|
281
|
+
const operation = this.begin();
|
|
282
|
+
const transfer = async () => {
|
|
283
|
+
const bytes = await file.read(operation.signal);
|
|
284
|
+
operation.signal.throwIfAborted();
|
|
285
|
+
const outgoing = field === null
|
|
286
|
+
? { ...request, body: bytes }
|
|
287
|
+
: await multipart(request, file.name, field, bytes);
|
|
288
|
+
if (test && bytes.length > 10 * 1024) {
|
|
289
|
+
const probe = await this.services.fetch({ ...outgoing, body: new Uint8Array() }, operation.signal);
|
|
290
|
+
if (probe.bytes === null) {
|
|
291
|
+
throw new Error("test upload failed");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const result = await this.services.fetch(outgoing, operation.signal);
|
|
295
|
+
return { result, size: bytes.length };
|
|
296
|
+
};
|
|
297
|
+
this.services.defer(() => this.emit(operation, "open"));
|
|
298
|
+
this.after(operation, transfer(), ({ result, size }) => {
|
|
299
|
+
if (!this.emit(operation, "progress", size, size)) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (result.bytes === null || result.status >= 400) {
|
|
303
|
+
if (result.status && !this.emit(operation, "httpStatus", result.status)) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
this.fail(operation);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
this.operation = null;
|
|
310
|
+
if (this.emit(operation, "complete")) {
|
|
311
|
+
this.emit(operation, "uploadCompleteData", 0, 0, new TextDecoder().decode(result.bytes));
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/** Let the platform encode multipart quoting and the boundary, then send through the host's fetch. */
|
|
317
|
+
async function multipart(request, name, field, bytes) {
|
|
318
|
+
const form = new FormData();
|
|
319
|
+
if (request.body) {
|
|
320
|
+
for (const [key, value] of new URLSearchParams(new TextDecoder().decode(request.body))) {
|
|
321
|
+
form.append(key, value);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
form.append("Filename", name);
|
|
325
|
+
form.append(field, new Blob([bytes.slice().buffer], { type: "application/octet-stream" }), name);
|
|
326
|
+
form.append("Upload", "Submit Query");
|
|
327
|
+
const encoded = new Response(form);
|
|
328
|
+
return {
|
|
329
|
+
...request,
|
|
330
|
+
method: "POST",
|
|
331
|
+
headers: [["Content-Type", encoded.headers.get("content-type")]],
|
|
332
|
+
body: new Uint8Array(await encoded.arrayBuffer()),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/** Targets that would replace the player's own page or a frame around it. */
|
|
2
|
+
const IN_PLACE = new Set(["_self", "_parent", "_top", ""]);
|
|
3
|
+
/**
|
|
4
|
+
* The browser's navigation, deliberately conservative, as a SWF is not to
|
|
5
|
+
* be trusted by the page that embeds it: only an http: or https: URL opens,
|
|
6
|
+
* so a javascript: one cannot run in the embedding page; a target that
|
|
7
|
+
* would replace the page or a frame around it is refused, as Ruffle's web
|
|
8
|
+
* navigator refuses it without script access; and every other target opens
|
|
9
|
+
* a new window, since a name reaches the window or frame of that name,
|
|
10
|
+
* noopener or not, so a SWF cannot reuse a window it named. A GET opens in
|
|
11
|
+
* window.open without an opener; a POST is a form submitted to a new
|
|
12
|
+
* window, the only way a browser posts into one, its body read as form
|
|
13
|
+
* data. A host that trusts its SWFs further gives a navigate of its own.
|
|
14
|
+
* Null where there is no window to open, as in node.
|
|
15
|
+
*/
|
|
16
|
+
export function browserNavigate() {
|
|
17
|
+
if (typeof globalThis.open !== "function" || typeof document === "undefined") {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return (request, window) => {
|
|
21
|
+
if (window !== null && IN_PLACE.has(window.toLowerCase())) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let url;
|
|
25
|
+
try {
|
|
26
|
+
url = new URL(request.url, globalThis.location?.href);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (request.method.toUpperCase() !== "POST" || !request.body) {
|
|
35
|
+
globalThis.open(url.href, "_blank", "noopener");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!document.body) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const form = document.createElement("form");
|
|
42
|
+
form.method = "POST";
|
|
43
|
+
form.action = url.href;
|
|
44
|
+
form.target = "_blank";
|
|
45
|
+
form.rel = "noopener";
|
|
46
|
+
form.style.display = "none";
|
|
47
|
+
for (const [name, value] of new URLSearchParams(new TextDecoder().decode(request.body))) {
|
|
48
|
+
const input = document.createElement("input");
|
|
49
|
+
input.type = "hidden";
|
|
50
|
+
input.name = name;
|
|
51
|
+
input.value = value;
|
|
52
|
+
form.append(input);
|
|
53
|
+
}
|
|
54
|
+
document.body.append(form);
|
|
55
|
+
form.submit();
|
|
56
|
+
form.remove();
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The default storage: localStorage, base64 under a prefix, where the host
|
|
61
|
+
* has it and lets it be read; memory otherwise. localStorage is first reached
|
|
62
|
+
* when a SWF first uses a shared object, since merely reading it can throw
|
|
63
|
+
* (a SecurityError where site data is blocked). A write it refuses, a full
|
|
64
|
+
* quota say, throws, which flush reports as Error #2130.
|
|
65
|
+
*/
|
|
66
|
+
export function defaultStorage() {
|
|
67
|
+
const memory = new Map();
|
|
68
|
+
const inMemory = {
|
|
69
|
+
get: (key) => memory.get(key) ?? null,
|
|
70
|
+
set: (key, bytes) => {
|
|
71
|
+
memory.set(key, bytes.slice());
|
|
72
|
+
},
|
|
73
|
+
remove: (key) => {
|
|
74
|
+
memory.delete(key);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
let chosen;
|
|
78
|
+
const storage = () => {
|
|
79
|
+
if (!chosen) {
|
|
80
|
+
let local;
|
|
81
|
+
try {
|
|
82
|
+
local = globalThis.localStorage;
|
|
83
|
+
local?.getItem(PREFIX);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
local = undefined;
|
|
87
|
+
}
|
|
88
|
+
chosen = local ? localStorageOf(local) : inMemory;
|
|
89
|
+
}
|
|
90
|
+
return chosen;
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
get: (key) => storage().get(key),
|
|
94
|
+
set: (key, bytes) => storage().set(key, bytes),
|
|
95
|
+
remove: (key) => storage().remove(key),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const PREFIX = "swf2es:so:";
|
|
99
|
+
function localStorageOf(local) {
|
|
100
|
+
return {
|
|
101
|
+
get: (key) => {
|
|
102
|
+
const text = local.getItem(PREFIX + key);
|
|
103
|
+
return text === null ? null : Uint8Array.from(atob(text), (c) => c.charCodeAt(0));
|
|
104
|
+
},
|
|
105
|
+
set: (key, bytes) => {
|
|
106
|
+
// In chunks: one String.fromCharCode of every byte overflows the stack.
|
|
107
|
+
const parts = [];
|
|
108
|
+
for (let i = 0; i < bytes.length; i += 0x2000) {
|
|
109
|
+
parts.push(String.fromCharCode(...bytes.subarray(i, i + 0x2000)));
|
|
110
|
+
}
|
|
111
|
+
local.setItem(PREFIX + key, btoa(parts.join("")));
|
|
112
|
+
},
|
|
113
|
+
remove: (key) => local.removeItem(PREFIX + key),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** The platform as the host's browser reports it, a Linux plugin's where it has none. */
|
|
117
|
+
export function platformCapabilities() {
|
|
118
|
+
const navigator = globalThis
|
|
119
|
+
.navigator;
|
|
120
|
+
const agent = navigator?.userAgent ?? "";
|
|
121
|
+
const mac = /Mac OS X (\d+)[._](\d+)(?:[._](\d+))?/.exec(agent);
|
|
122
|
+
const [os, manufacturer, platform] = /Windows/.test(agent)
|
|
123
|
+
? ["Windows 10", "Adobe Windows", "WIN"]
|
|
124
|
+
: mac
|
|
125
|
+
? [`Mac OS ${mac[1]}.${mac[2]}${mac[3] ? `.${mac[3]}` : ""}`, "Adobe Macintosh", "MAC"]
|
|
126
|
+
: ["Linux", "Adobe Linux", "LNX"];
|
|
127
|
+
// Flash gives the country only where the language needs it.
|
|
128
|
+
const tag = navigator?.language ?? new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
129
|
+
const [lang, country] = tag.split("-");
|
|
130
|
+
const language = (lang === "zh" || lang === "pt") && country ? `${lang}-${country}` : lang;
|
|
131
|
+
return {
|
|
132
|
+
os,
|
|
133
|
+
manufacturer,
|
|
134
|
+
version: `${platform} 32,0,0,465`,
|
|
135
|
+
language,
|
|
136
|
+
locale: tag,
|
|
137
|
+
playerType: "PlugIn",
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** How many touches the browser's screen takes at once, as Multitouch.maxTouchPoints reports; 0 without a browser. */
|
|
141
|
+
export function hostTouchPoints() {
|
|
142
|
+
const navigator = globalThis.navigator;
|
|
143
|
+
return navigator?.maxTouchPoints ?? 0;
|
|
144
|
+
}
|
|
145
|
+
/** An EncryptedLocalStore of an application's items held in memory, for as long as it plays. */
|
|
146
|
+
export function memoryStore() {
|
|
147
|
+
const items = new Map();
|
|
148
|
+
return {
|
|
149
|
+
getItem: (name) => items.get(name) ?? null,
|
|
150
|
+
setItem: (name, bytes) => {
|
|
151
|
+
items.set(name, bytes);
|
|
152
|
+
},
|
|
153
|
+
removeItem: (name) => {
|
|
154
|
+
items.delete(name);
|
|
155
|
+
},
|
|
156
|
+
reset: () => items.clear(),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/** The global WebSocket's client, a browser's or node's; null where there is none. */
|
|
160
|
+
export function globalWebSocketHost() {
|
|
161
|
+
const Client = globalThis.WebSocket;
|
|
162
|
+
if (typeof Client !== "function") {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
connect(url, protocols, events) {
|
|
167
|
+
const socket = new Client(url, protocols);
|
|
168
|
+
socket.binaryType = "arraybuffer";
|
|
169
|
+
socket.addEventListener("open", () => events.open(socket.protocol));
|
|
170
|
+
socket.addEventListener("message", ({ data }) => {
|
|
171
|
+
events.message(typeof data === "string" ? data : new Uint8Array(data));
|
|
172
|
+
});
|
|
173
|
+
socket.addEventListener("close", ({ code }) => events.close(code));
|
|
174
|
+
socket.addEventListener("error", () => events.error());
|
|
175
|
+
return {
|
|
176
|
+
// The natives send bytes of their own, never a view of a shared buffer.
|
|
177
|
+
send: (data) => socket.send(data),
|
|
178
|
+
close: (code) => socket.close(code),
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The browser's async Clipboard API, which writes during a user's gesture
|
|
185
|
+
* without asking; HTML only where ClipboardItem takes it, else the text
|
|
186
|
+
* alone. Null where there is none, as in node.
|
|
187
|
+
*/
|
|
188
|
+
export function browserClipboard() {
|
|
189
|
+
const clipboard = globalThis.navigator?.clipboard;
|
|
190
|
+
if (!clipboard || typeof clipboard.writeText !== "function") {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
const Item = globalThis.ClipboardItem;
|
|
194
|
+
return {
|
|
195
|
+
write: ({ text, html }) => {
|
|
196
|
+
const written = html !== undefined && Item && typeof clipboard.write === "function"
|
|
197
|
+
? clipboard.write([
|
|
198
|
+
new Item({
|
|
199
|
+
"text/plain": new Blob([text], { type: "text/plain" }),
|
|
200
|
+
"text/html": new Blob([html], { type: "text/html" }),
|
|
201
|
+
}),
|
|
202
|
+
])
|
|
203
|
+
: clipboard.writeText(text);
|
|
204
|
+
written.catch(() => { });
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Avm1Pointer } from "../avm1/pointer.js";
|
|
2
|
+
export class LoadedAvm1Input {
|
|
3
|
+
s;
|
|
4
|
+
movies = new Map();
|
|
5
|
+
over = null;
|
|
6
|
+
constructor(s) {
|
|
7
|
+
this.s = s;
|
|
8
|
+
}
|
|
9
|
+
add(root, vm) {
|
|
10
|
+
const stage = this.s.stage;
|
|
11
|
+
if (!stage) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const pointer = new Avm1Pointer(stage, vm, root);
|
|
15
|
+
pointer.onCursor = () => this.s.pointer?.updateCursor();
|
|
16
|
+
this.movies.set(root, pointer);
|
|
17
|
+
}
|
|
18
|
+
remove(root) {
|
|
19
|
+
const pointer = this.movies.get(root);
|
|
20
|
+
if (this.over === pointer) {
|
|
21
|
+
this.over = null;
|
|
22
|
+
}
|
|
23
|
+
this.movies.delete(root);
|
|
24
|
+
return this.movies.size === 0;
|
|
25
|
+
}
|
|
26
|
+
/** A stable callback for the AS3 pick: the AVM1Movie stands in for its interactive children. */
|
|
27
|
+
hit = (root, x, y) => this.movies.get(root)?.hit(x, y) ?? false;
|
|
28
|
+
broadcast(type, p) {
|
|
29
|
+
for (const pointer of this.movies.values()) {
|
|
30
|
+
pointer.broadcast(type, p);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Global listeners ran already; only the winning movie gets button picks. */
|
|
34
|
+
prepare(type, p, target) {
|
|
35
|
+
this.over = this.movies.get(target) ?? null;
|
|
36
|
+
let redraws = 0;
|
|
37
|
+
for (const pointer of this.movies.values()) {
|
|
38
|
+
const before = pointer.redraws;
|
|
39
|
+
pointer.pickable = pointer === this.over;
|
|
40
|
+
if (type === "move") {
|
|
41
|
+
pointer.handle(type, p, false);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
pointer.sync(p, pointer.pickable);
|
|
45
|
+
}
|
|
46
|
+
redraws += pointer.redraws - before;
|
|
47
|
+
}
|
|
48
|
+
return redraws;
|
|
49
|
+
}
|
|
50
|
+
finish(type, p) {
|
|
51
|
+
let redraws = 0;
|
|
52
|
+
for (const pointer of this.movies.values()) {
|
|
53
|
+
const before = pointer.redraws;
|
|
54
|
+
pointer.handle(type, p, false);
|
|
55
|
+
redraws += pointer.redraws - before;
|
|
56
|
+
}
|
|
57
|
+
return redraws;
|
|
58
|
+
}
|
|
59
|
+
sync(p, target) {
|
|
60
|
+
this.over = this.movies.get(target) ?? null;
|
|
61
|
+
let redraws = 0;
|
|
62
|
+
for (const pointer of this.movies.values()) {
|
|
63
|
+
const before = pointer.redraws;
|
|
64
|
+
pointer.sync(p, pointer === this.over);
|
|
65
|
+
redraws += pointer.redraws - before;
|
|
66
|
+
}
|
|
67
|
+
return redraws;
|
|
68
|
+
}
|
|
69
|
+
leave(p) {
|
|
70
|
+
let redraws = 0;
|
|
71
|
+
this.over = null;
|
|
72
|
+
for (const pointer of this.movies.values()) {
|
|
73
|
+
const before = pointer.redraws;
|
|
74
|
+
pointer.handle("leave", p, false);
|
|
75
|
+
redraws += pointer.redraws - before;
|
|
76
|
+
}
|
|
77
|
+
return redraws;
|
|
78
|
+
}
|
|
79
|
+
cursor() {
|
|
80
|
+
return this.over?.cursor() ?? null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { dispatchTo } from "../scripting/events.js";
|
|
2
|
+
import { pointerTarget } from "./pointer.js";
|
|
3
|
+
export function customContextMenu(s, stage, p) {
|
|
4
|
+
const result = { items: [], quality: s.showDefaultContextMenu };
|
|
5
|
+
s.mouseStageX = p.x;
|
|
6
|
+
s.mouseStageY = p.y;
|
|
7
|
+
const rt = s.rt;
|
|
8
|
+
const get = (o, name) => rt.getProperty(o, rt.publicName(name));
|
|
9
|
+
const picked = pointerTarget(stage, p.x, p.y, s.stageViewportWidth || s.stageWidth, s.stageViewportHeight || s.stageHeight, undefined, s.stageViewportX, s.stageViewportY);
|
|
10
|
+
const target = picked === stage ? s.root : picked;
|
|
11
|
+
let owner = target;
|
|
12
|
+
let menu = null;
|
|
13
|
+
for (; owner; owner = owner.parent) {
|
|
14
|
+
const value = owner.object?.$contextMenu;
|
|
15
|
+
if (value && rt.isInstance(value, rt.classNamed("flash.ui::ContextMenu"))) {
|
|
16
|
+
menu = value;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (!menu) {
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
const mouse = target?.object ?? null;
|
|
24
|
+
const contextOwner = owner?.object ?? null;
|
|
25
|
+
const event = (type) => rt.construct(rt.classNamed("flash.events::ContextMenuEvent"), type, false, false, mouse, contextOwner);
|
|
26
|
+
dispatchTo(s, menu, event("menuSelect"));
|
|
27
|
+
const builtIn = get(menu, "builtInItems");
|
|
28
|
+
result.quality &&= !!builtIn && rt.toBoolean(get(builtIn, "quality"));
|
|
29
|
+
const custom = get(menu, "customItems");
|
|
30
|
+
if (!custom) {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
const length = rt.toUint(get(custom, "length"));
|
|
34
|
+
const cls = rt.classNamed("flash.ui::ContextMenuItem");
|
|
35
|
+
const captions = new Set();
|
|
36
|
+
let selected = false;
|
|
37
|
+
for (let i = 0; i < length && result.items.length < 15; i++) {
|
|
38
|
+
const item = get(custom, String(i));
|
|
39
|
+
if (!rt.isInstance(item, cls) || !rt.toBoolean(get(item, "visible"))) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const caption = rt.toString(get(item, "caption"));
|
|
43
|
+
if (!caption || captions.has(caption)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
captions.add(caption);
|
|
47
|
+
const enabled = rt.toBoolean(get(item, "enabled"));
|
|
48
|
+
result.items.push({
|
|
49
|
+
caption,
|
|
50
|
+
enabled,
|
|
51
|
+
separatorBefore: rt.toBoolean(get(item, "separatorBefore")),
|
|
52
|
+
select: () => {
|
|
53
|
+
if (!enabled || selected || s.destroyed) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
selected = true;
|
|
57
|
+
s.clipboard.gesture(() => dispatchTo(s, item, event("menuItemSelect")));
|
|
58
|
+
s.updates++;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|