@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,250 @@
|
|
|
1
|
+
// air.net.WebSocket, AIR 51's client, over the host's WebSocket (hosts.ts).
|
|
2
|
+
// What it throws and dispatches is what adl does (docs/architecture/services.md);
|
|
3
|
+
// where a browser cannot do as AIR does, the nearest it can.
|
|
4
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
5
|
+
import { dispatchEvent } from "../../../scripting/events.js";
|
|
6
|
+
const TEXT = 1;
|
|
7
|
+
const BINARY = 2;
|
|
8
|
+
const CLOSE = 8;
|
|
9
|
+
/** The close codes a browser lets a page send. */
|
|
10
|
+
const sendable = (code) => code === 1000 || (code >= 3000 && code <= 4999);
|
|
11
|
+
export function webSocketNatives(s) {
|
|
12
|
+
const natives = {};
|
|
13
|
+
const connections = new WeakMap();
|
|
14
|
+
const connection = (o) => {
|
|
15
|
+
let c = connections.get(o);
|
|
16
|
+
if (!c) {
|
|
17
|
+
c = {
|
|
18
|
+
state: "new",
|
|
19
|
+
url: "",
|
|
20
|
+
transport: null,
|
|
21
|
+
protocol: null,
|
|
22
|
+
closeReason: -1,
|
|
23
|
+
closedHere: false,
|
|
24
|
+
};
|
|
25
|
+
connections.set(o, c);
|
|
26
|
+
}
|
|
27
|
+
return c;
|
|
28
|
+
};
|
|
29
|
+
const byteArray = () => s.rt.classNamed("flash.utils::ByteArray");
|
|
30
|
+
const invalid = () => {
|
|
31
|
+
throw s.rt.error("flash.errors::IOError", 2002);
|
|
32
|
+
};
|
|
33
|
+
const errorEvent = (o, cls, type, id, text) => {
|
|
34
|
+
const event = s.rt.construct(s.rt.classNamed(cls), type, false, false, text, id);
|
|
35
|
+
dispatchEvent(s, o, event);
|
|
36
|
+
};
|
|
37
|
+
// As adl words it: a connection that failed gives its host, a handshake its URL.
|
|
38
|
+
const ioError = (o, where) => errorEvent(o, "flash.events::IOErrorEvent", "ioError", 2031, `Error #2031: Socket Error.${where && ` URL: ${where}`}`);
|
|
39
|
+
const hostOf = (url) => {
|
|
40
|
+
try {
|
|
41
|
+
return new URL(url).hostname;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/** End a connection before its handshake is done, as AIR does when a frame goes out first. */
|
|
48
|
+
const interrupt = (o, c) => {
|
|
49
|
+
c.transport?.close();
|
|
50
|
+
c.transport = null;
|
|
51
|
+
c.state = "closed";
|
|
52
|
+
s.loads.deferHostEvent(() => {
|
|
53
|
+
ioError(o, c.url);
|
|
54
|
+
dispatchEvent(s, o, s.event("close"));
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const send = (c, opcode, bytes) => {
|
|
58
|
+
const transport = c.transport;
|
|
59
|
+
if (!transport) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// AIR writes the opcode's low four bits, whatever they are.
|
|
63
|
+
switch (opcode & 0x0f) {
|
|
64
|
+
case TEXT:
|
|
65
|
+
// A leading BOM is the SWF's bytes, as AIR sends them, not a mark to drop.
|
|
66
|
+
transport.send(new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes));
|
|
67
|
+
break;
|
|
68
|
+
case BINARY:
|
|
69
|
+
transport.send(bytes);
|
|
70
|
+
break;
|
|
71
|
+
case CLOSE: {
|
|
72
|
+
// A close frame of the SWF's own: adl sends its code alone, and then
|
|
73
|
+
// dispatches the close, as for the server's.
|
|
74
|
+
const code = bytes.length >= 2 ? (bytes[0] << 8) | bytes[1] : 0;
|
|
75
|
+
c.state = "closing";
|
|
76
|
+
transport.close(sendable(code) ? code : undefined);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
default:
|
|
80
|
+
// Pings, pongs and reserved opcodes, which AIR sends as they are and a
|
|
81
|
+
// browser cannot: the browser answers the server's pings itself, and
|
|
82
|
+
// AIR dispatches nothing for a pong or for a reserved frame echoed.
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
class WebSocketNatives {
|
|
87
|
+
"air.net:WebSocket::internalConnect"(url, protocols) {
|
|
88
|
+
if (url === null || url === undefined) {
|
|
89
|
+
throw s.rt.error("TypeError", 2007, "url");
|
|
90
|
+
}
|
|
91
|
+
const c = connection(this);
|
|
92
|
+
if (c.state !== "new") {
|
|
93
|
+
throw s.rt.error("flash.errors::IllegalOperationError", 2082);
|
|
94
|
+
}
|
|
95
|
+
const text = s.rt.toString(url);
|
|
96
|
+
if (!/^wss?:\/\//.test(text)) {
|
|
97
|
+
throw s.rt.error("ArgumentError", 2147, text);
|
|
98
|
+
}
|
|
99
|
+
c.state = "connecting";
|
|
100
|
+
c.url = text;
|
|
101
|
+
// AIR offers the vector's protocols, null ones left out, not `protocol`.
|
|
102
|
+
const offered = protocols === null || protocols === undefined
|
|
103
|
+
? []
|
|
104
|
+
: protocols.$a
|
|
105
|
+
.filter((p) => p !== null && p !== undefined)
|
|
106
|
+
.map((p) => s.rt.toString(p));
|
|
107
|
+
const fail = () => {
|
|
108
|
+
if (c.state !== "connecting") {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
c.transport = null;
|
|
112
|
+
c.state = "failed";
|
|
113
|
+
ioError(this, hostOf(text));
|
|
114
|
+
};
|
|
115
|
+
const host = s.webSocket;
|
|
116
|
+
if (!host) {
|
|
117
|
+
s.loads.deferHostEvent(fail);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
// AIR sends a URL's fragment in its request line; a browser refuses one.
|
|
122
|
+
c.transport = host.connect(text.replace(/#.*$/s, ""), offered, {
|
|
123
|
+
open: (protocol) => s.loads.deferHostEvent(() => {
|
|
124
|
+
if (c.state !== "connecting") {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
c.state = "open";
|
|
128
|
+
if (protocol !== "") {
|
|
129
|
+
c.protocol = protocol;
|
|
130
|
+
}
|
|
131
|
+
dispatchEvent(s, this, s.event("connect"));
|
|
132
|
+
}),
|
|
133
|
+
message: (data) => s.loads.deferHostEvent(() => {
|
|
134
|
+
if (c.state !== "open" && c.state !== "closing") {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const array = s.rt.construct(byteArray());
|
|
138
|
+
const bytes = avm2.bytesOf(s.rt, array);
|
|
139
|
+
bytes.write(typeof data === "string" ? new TextEncoder().encode(data) : data.slice());
|
|
140
|
+
bytes.position = 0;
|
|
141
|
+
const format = typeof data === "string" ? TEXT : BINARY;
|
|
142
|
+
const cls = s.rt.classNamed("flash.events::WebSocketEvent");
|
|
143
|
+
dispatchEvent(s, this, s.rt.construct(cls, "websocketData", format, array));
|
|
144
|
+
}),
|
|
145
|
+
close: (code) => s.loads.deferHostEvent(() => {
|
|
146
|
+
if (c.state === "connecting") {
|
|
147
|
+
fail();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (c.state !== "open" && c.state !== "closing") {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
c.state = "closed";
|
|
154
|
+
c.transport = null;
|
|
155
|
+
// A close without a frame, or a frame without a code, leaves AIR's -1.
|
|
156
|
+
if (code !== 1005 && code !== 1006) {
|
|
157
|
+
c.closeReason = code;
|
|
158
|
+
}
|
|
159
|
+
if (!c.closedHere) {
|
|
160
|
+
dispatchEvent(s, this, s.event("close"));
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
error: () => s.loads.deferHostEvent(fail),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
if (e?.name === "SecurityError") {
|
|
168
|
+
c.state = "failed";
|
|
169
|
+
s.loads.deferHostEvent(() => errorEvent(this, "flash.events::SecurityErrorEvent", "securityError", 2048, `Error #2048: Security sandbox violation: ${s.url} cannot load data from ${text}.`));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
s.loads.deferHostEvent(fail);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
sendMessage(opcode, data) {
|
|
177
|
+
let bytes;
|
|
178
|
+
if (typeof data === "string") {
|
|
179
|
+
bytes = new TextEncoder().encode(data);
|
|
180
|
+
}
|
|
181
|
+
else if (data !== null && data !== undefined && s.rt.isInstance(data, byteArray())) {
|
|
182
|
+
const b = avm2.bytesOf(s.rt, data);
|
|
183
|
+
bytes = b.buffer.slice(0, b.length);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
throw s.rt.error("ArgumentError", 1508, "data");
|
|
187
|
+
}
|
|
188
|
+
const c = connection(this);
|
|
189
|
+
switch (c.state) {
|
|
190
|
+
case "open":
|
|
191
|
+
send(c, s.rt.toUint(opcode), bytes);
|
|
192
|
+
break;
|
|
193
|
+
case "connecting":
|
|
194
|
+
interrupt(this, c);
|
|
195
|
+
break;
|
|
196
|
+
case "new":
|
|
197
|
+
case "closed":
|
|
198
|
+
// Before connect, adl crashes; this is what it throws once closed.
|
|
199
|
+
invalid();
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
"air.net:WebSocket::internalClose"(reasonCode) {
|
|
206
|
+
const c = connection(this);
|
|
207
|
+
switch (c.state) {
|
|
208
|
+
case "open": {
|
|
209
|
+
// AIR sends any code, cut to 16 bits; a browser sends only these.
|
|
210
|
+
const code = s.rt.toUint(reasonCode) & 0xffff;
|
|
211
|
+
c.state = "closing";
|
|
212
|
+
c.closedHere = true;
|
|
213
|
+
c.transport?.close(sendable(code) ? code : undefined);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
case "connecting":
|
|
217
|
+
interrupt(this, c);
|
|
218
|
+
break;
|
|
219
|
+
case "new":
|
|
220
|
+
case "closed":
|
|
221
|
+
invalid();
|
|
222
|
+
break;
|
|
223
|
+
default:
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
get protocol() {
|
|
228
|
+
return connection(this).protocol;
|
|
229
|
+
}
|
|
230
|
+
set protocol(value) {
|
|
231
|
+
const c = connection(this);
|
|
232
|
+
if (c.state === "open" || c.state === "closing" || c.state === "closed") {
|
|
233
|
+
throw s.rt.error("ArgumentError", 2014);
|
|
234
|
+
}
|
|
235
|
+
c.protocol = value === null || value === undefined ? null : s.rt.toString(value);
|
|
236
|
+
}
|
|
237
|
+
get closeReason() {
|
|
238
|
+
return connection(this).closeReason;
|
|
239
|
+
}
|
|
240
|
+
startServer(socket) {
|
|
241
|
+
if (socket === null || socket === undefined) {
|
|
242
|
+
throw s.rt.error("TypeError", 2007, "socket");
|
|
243
|
+
}
|
|
244
|
+
// What AIR throws for a method its profile lacks (Updater.update in adl).
|
|
245
|
+
throw s.rt.construct(s.rt.classNamed("flash.errors::IllegalOperationError"), "This method is not supported in this profile.");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
avm2.registerNativeClass(natives, "air.net::WebSocket", WebSocketNatives);
|
|
249
|
+
return natives;
|
|
250
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// AIR's air.net.WebSocket and flash.events.WebSocketEvent, declared for
|
|
2
|
+
// the player: the ABC compiled from their .as files under as3/air.
|
|
3
|
+
// Generated by tests/player/air-library.ts; not to be edited.
|
|
4
|
+
/**
|
|
5
|
+
* An ABC to load after builtin and playerglobal (Scripting.loadLibraries),
|
|
6
|
+
* for SWFs that use AIR 51's WebSocket client.
|
|
7
|
+
*/
|
|
8
|
+
export const airLibrary = Uint8Array.from(atob("EAAuAAcBAggJCugHAAA5BERBVEEABlN0cmluZw13ZWJzb2NrZXREYXRhB19mb3JtYXQbZmxhc2guZXZlbnRzOldlYlNvY2tldEV2ZW50BHVpbnQFX2RhdGEJQnl0ZUFycmF5C2ZsYXNoLnV0aWxzBmZvcm1hdARkYXRhCnN0cmluZ0RhdGEOV2ViU29ja2V0RXZlbnQMZmxhc2guZXZlbnRzBUV2ZW50B2ZtdFRFWFQJZm10QklOQVJZCGZtdENMT1NFB2ZtdFBJTkcHZm10UE9ORwdjb25uZWN0D2ludGVybmFsQ29ubmVjdBFhaXIubmV0OldlYlNvY2tldAtzZW5kTWVzc2FnZQVjbG9zZQ1pbnRlcm5hbENsb3NlCHByb3RvY29sC2Nsb3NlUmVhc29uC3N0YXJ0U2VydmVyCVdlYlNvY2tldAdhaXIubmV0D0V2ZW50RGlzcGF0Y2hlcghwb3NpdGlvbgZsZW5ndGgMcmVhZFVURkJ5dGVzBHR5cGUGVmVjdG9yC19fQVMzX18udmVjBHZvaWQDdXJsCXByb3RvY29scwpyZWFzb25Db2RlBk9iamVjdAZvcGNvZGUFdmFsdWUDaW50BlNvY2tldAlmbGFzaC5uZXQGc29ja2V0A+6KlA5mbGFzaC51dGlsc+6KlA9mbGFzaC5ldmVudHPuipQKYWlyLm5ldO6KlA5fX0FTM19fLnZlY+6KlAxmbGFzaC5uZXTuipQJFjMFBhY0FjUFGBY2FjcWOAAkBwEBBwEDBwIFBwEHBwIIBwMJBwELBwEMBwENBwQOBwQQBwERBwESBwETBwEUBwEVBwEWBwUXBwEZBwEaBwUbBwEcBwEdBwEeBwYfBwQhBwEiBwEjBwEkHR8BAgcHJgcBKAcBLAcBLwcIMBEAAAAAAAQLAAAGDAAAAg0AAwACBAYOgCULDAAAAAACIAIeFogBDAwpKgIgAh4XoCkqAiAEABmgLQwBIAQaiAEGAysBIAQboCsAAhwgASACHKAuACIdIAEgIx6gMgAAHwAAAAAAAAIKCwEABAUDAAAEAAUAAAYABwIAAQgCAAIJAgADGRoBAA8JEQEABhIBAAcTAQAIFAEACRUBAAoWAgALFgMADBcCAA0YAQAOBQEBBgACBAEQBQwGAAQBAw0GAAQCAw4GAAQDAw8GAAQEAxAGAAQFAwEAAgoEAAAZBAABCgEBAQABBdAwYANIAAACAgEAAQvQMGAFJABhG2AFSAAAAwIBAAEe0DBgAyQBq5YSAgAAIEhgBSQAYRtgBWAFZhxGHQFIAAAEBAQAARXQMNDRJydJA9JeAythA9NeBSthBUcAAAUAAQAAAUcAAAYDAwABCtAwXRLR0k8SAkcAAAkCAgABCdAwXRXRTxUBRwAADwEBAAEG0DDQSQBHAAAQAAEAAAFHAAAAAwEAAyHQMGUAYCEwYAsqMFgAHR1oCmUAYCEwYBoqMFgBHR1oGUcAAA=="), (c) => c.charCodeAt(0));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// flash.accessibility.Accessibility: this player has no platform accessibility bridge.
|
|
2
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
3
|
+
export function accessibilityNatives(s) {
|
|
4
|
+
const natives = {};
|
|
5
|
+
class AccessibilityNatives {
|
|
6
|
+
static get active() {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
static sendEvent(source, _childId, _eventType, _nonHtml) {
|
|
10
|
+
if (source === null || source === undefined) {
|
|
11
|
+
throw s.rt.error("TypeError", 2007, "source");
|
|
12
|
+
}
|
|
13
|
+
// No platform accessibility bridge receives events.
|
|
14
|
+
}
|
|
15
|
+
static updateProperties() {
|
|
16
|
+
// No platform accessibility bridge holds properties.
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
avm2.registerNativeClass(natives, "flash.accessibility::Accessibility", AccessibilityNatives);
|
|
20
|
+
return natives;
|
|
21
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// flash.crypto contains one function: cryptographically strong bytes from
|
|
2
|
+
// the host, with Flash's bounded length and a fresh ByteArray at position 0.
|
|
3
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
4
|
+
export function cryptoNatives() {
|
|
5
|
+
return {
|
|
6
|
+
"flash.crypto::generateRandomBytes": (rt) => (count) => {
|
|
7
|
+
const length = rt.toUint(count);
|
|
8
|
+
if (length === 0) {
|
|
9
|
+
// AIR returns null here, though the API reference gives 1 as the minimum.
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (length > 1024) {
|
|
13
|
+
throw rt.error("Error", 2004);
|
|
14
|
+
}
|
|
15
|
+
const crypto = globalThis.crypto;
|
|
16
|
+
if (!crypto?.getRandomValues) {
|
|
17
|
+
throw rt.error("Error", 0);
|
|
18
|
+
}
|
|
19
|
+
const array = rt.construct(rt.classNamed("flash.utils::ByteArray"));
|
|
20
|
+
const bytes = avm2.bytesOf(rt, array);
|
|
21
|
+
bytes.setLength(length);
|
|
22
|
+
try {
|
|
23
|
+
// A new ByteArray, never shared.
|
|
24
|
+
crypto.getRandomValues(bytes.buffer.subarray(0, length));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
throw rt.error("Error", 0);
|
|
28
|
+
}
|
|
29
|
+
return array;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// flash.data.EncryptedLocalStore over the host's EncryptedStoreHost
|
|
2
|
+
// (hosts.ts), as adl (AIR 51.3) has it: an item is the whole of a
|
|
3
|
+
// ByteArray, whatever its position, which stays as it was; getItem gives
|
|
4
|
+
// a new ByteArray of it at position 0, and null for a name of none or of
|
|
5
|
+
// empty bytes. A null name or data is ArgumentError 2007, an empty name
|
|
6
|
+
// 2085. stronglyBound, which ties an item to the application's signature,
|
|
7
|
+
// is taken and changes nothing: there is no signature to tie it to.
|
|
8
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
9
|
+
export function encryptedLocalStoreNatives(s) {
|
|
10
|
+
const natives = {};
|
|
11
|
+
const store = () => s.encryptedStore;
|
|
12
|
+
/** An item's name; ArgumentError for none, or for "". */
|
|
13
|
+
const nameOf = (name) => {
|
|
14
|
+
if (name === null || name === undefined) {
|
|
15
|
+
throw s.rt.error("ArgumentError", 2007, "name");
|
|
16
|
+
}
|
|
17
|
+
const named = s.rt.toString(name);
|
|
18
|
+
if (named === "") {
|
|
19
|
+
throw s.rt.error("ArgumentError", 2085, "name");
|
|
20
|
+
}
|
|
21
|
+
return named;
|
|
22
|
+
};
|
|
23
|
+
class EncryptedLocalStoreNatives {
|
|
24
|
+
static get isSupported() {
|
|
25
|
+
return store() !== null;
|
|
26
|
+
}
|
|
27
|
+
static setItem(name, data, _stronglyBound = false) {
|
|
28
|
+
const named = nameOf(name);
|
|
29
|
+
if (data === null || data === undefined) {
|
|
30
|
+
throw s.rt.error("ArgumentError", 2007, "data");
|
|
31
|
+
}
|
|
32
|
+
const bytes = avm2.bytesOf(s.rt, data);
|
|
33
|
+
const copy = bytes.buffer.slice(0, bytes.length);
|
|
34
|
+
if (copy.length === 0) {
|
|
35
|
+
store()?.removeItem(named);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
store()?.setItem(named, copy);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
static getItem(name) {
|
|
42
|
+
const bytes = store()?.getItem(nameOf(name));
|
|
43
|
+
if (!bytes || bytes.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const out = s.rt.construct(s.rt.classNamed("flash.utils::ByteArray"));
|
|
47
|
+
const into = avm2.bytesOf(s.rt, out);
|
|
48
|
+
into.write(bytes);
|
|
49
|
+
into.position = 0;
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
static removeItem(name) {
|
|
53
|
+
store()?.removeItem(nameOf(name));
|
|
54
|
+
}
|
|
55
|
+
static reset() {
|
|
56
|
+
store()?.reset();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
avm2.registerNativeClass(natives, "flash.data::EncryptedLocalStore", EncryptedLocalStoreNatives);
|
|
60
|
+
return natives;
|
|
61
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// flash.desktop.Clipboard as Flash Player has it: one Clipboard, the
|
|
2
|
+
// system's, generalClipboard, over the player's (scripting/clipboard.ts).
|
|
3
|
+
// playerglobal's AS3 maps formats to these natives and checks access with
|
|
4
|
+
// canReadContents and canWriteContents: a script reads only in a paste,
|
|
5
|
+
// writes only in a user's event. Flash Player carries text, HTML, rich
|
|
6
|
+
// text, a script's own formats as references and serialized objects; a
|
|
7
|
+
// URL is kept as AIR keeps it, but bitmaps and files are AIR's alone.
|
|
8
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
9
|
+
import { HTML, TEXT } from "../../../scripting/clipboard.js";
|
|
10
|
+
const RTF = "air:rtf";
|
|
11
|
+
const URL_FORMAT = "air:url";
|
|
12
|
+
const REFERENCE = "air:reference:";
|
|
13
|
+
const SERIALIZATION = "air:serialization:";
|
|
14
|
+
/** Whether `format` is one of Flash's own, which keeps its name, rather than a script's. */
|
|
15
|
+
const system = (format) => format.startsWith("air:") || format.startsWith("flash:");
|
|
16
|
+
export function clipboardNatives(s) {
|
|
17
|
+
const natives = {};
|
|
18
|
+
const clipboard = () => s.clipboard;
|
|
19
|
+
const str = (v) => s.rt.toString(v);
|
|
20
|
+
/** clear and clearData check their own access, as no AS3 does it for them. */
|
|
21
|
+
const writing = () => {
|
|
22
|
+
if (!clipboard().writable) {
|
|
23
|
+
throw s.rt.error("SecurityError", 2191);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** A stored ByteArray from its start, as each read deserializes it anew. */
|
|
27
|
+
const rewound = (v) => {
|
|
28
|
+
if (v) {
|
|
29
|
+
avm2.bytesOf(s.rt, v).position = 0;
|
|
30
|
+
}
|
|
31
|
+
return v ?? null;
|
|
32
|
+
};
|
|
33
|
+
class ClipboardNatives {
|
|
34
|
+
static get generalClipboard() {
|
|
35
|
+
return general(s);
|
|
36
|
+
}
|
|
37
|
+
/** Its formats, a script's own by the names it gave them. */
|
|
38
|
+
get formats() {
|
|
39
|
+
const names = clipboard().formats.map((f) => f.startsWith(REFERENCE)
|
|
40
|
+
? f.slice(REFERENCE.length)
|
|
41
|
+
: f.startsWith(SERIALIZATION)
|
|
42
|
+
? f.slice(SERIALIZATION.length)
|
|
43
|
+
: f);
|
|
44
|
+
return s.rt.array([...new Set(names)]);
|
|
45
|
+
}
|
|
46
|
+
clear() {
|
|
47
|
+
writing();
|
|
48
|
+
clipboard().clear();
|
|
49
|
+
}
|
|
50
|
+
clearData(format) {
|
|
51
|
+
writing();
|
|
52
|
+
const name = str(format);
|
|
53
|
+
if (system(name)) {
|
|
54
|
+
clipboard().delete(name);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
clipboard().delete(REFERENCE + name);
|
|
58
|
+
clipboard().delete(SERIALIZATION + name);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// A dead clipboard is AIR's, one let go of after a drag.
|
|
62
|
+
get "flash.desktop:Clipboard::alive"() {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
get "flash.desktop:Clipboard::canReadContents"() {
|
|
66
|
+
return clipboard().readable;
|
|
67
|
+
}
|
|
68
|
+
get "flash.desktop:Clipboard::canWriteContents"() {
|
|
69
|
+
return clipboard().writable;
|
|
70
|
+
}
|
|
71
|
+
"flash.desktop:Clipboard::nativeSetHandler"(format, handler) {
|
|
72
|
+
clipboard().setHandler(str(format), () => {
|
|
73
|
+
s.rt.call(handler, null);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
"flash.desktop:Clipboard::setHandlerStoringData"(storing) {
|
|
77
|
+
clipboard().storing = !!storing;
|
|
78
|
+
}
|
|
79
|
+
"flash.desktop:Clipboard::getObjectReference"(format) {
|
|
80
|
+
return clipboard().get(str(format));
|
|
81
|
+
}
|
|
82
|
+
"flash.desktop:Clipboard::putObjectReference"(format, value) {
|
|
83
|
+
clipboard().set(str(format), value);
|
|
84
|
+
}
|
|
85
|
+
"flash.desktop:Clipboard::getString"() {
|
|
86
|
+
return clipboard().get(TEXT) ?? null;
|
|
87
|
+
}
|
|
88
|
+
"flash.desktop:Clipboard::putString"(text) {
|
|
89
|
+
clipboard().set(TEXT, str(text));
|
|
90
|
+
}
|
|
91
|
+
"flash.desktop:Clipboard::getHTML"() {
|
|
92
|
+
return clipboard().get(HTML) ?? null;
|
|
93
|
+
}
|
|
94
|
+
"flash.desktop:Clipboard::putHTML"(html) {
|
|
95
|
+
clipboard().set(HTML, str(html));
|
|
96
|
+
}
|
|
97
|
+
"flash.desktop:Clipboard::getRTF"() {
|
|
98
|
+
return rewound(clipboard().get(RTF));
|
|
99
|
+
}
|
|
100
|
+
"flash.desktop:Clipboard::putRTF"(bytes) {
|
|
101
|
+
clipboard().set(RTF, bytes);
|
|
102
|
+
}
|
|
103
|
+
"flash.desktop:Clipboard::getByteArray"(format) {
|
|
104
|
+
return rewound(clipboard().get(str(format)));
|
|
105
|
+
}
|
|
106
|
+
"flash.desktop:Clipboard::putByteArray"(format, bytes) {
|
|
107
|
+
clipboard().set(str(format), bytes);
|
|
108
|
+
}
|
|
109
|
+
get "flash.desktop:Clipboard::swfVersion"() {
|
|
110
|
+
return s.rt.swfVersion;
|
|
111
|
+
}
|
|
112
|
+
get supportsFilePromise() {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
"flash.desktop:Clipboard::getURL"() {
|
|
116
|
+
return clipboard().get(URL_FORMAT) ?? null;
|
|
117
|
+
}
|
|
118
|
+
"flash.desktop:Clipboard::putURL"(url) {
|
|
119
|
+
clipboard().set(URL_FORMAT, str(url));
|
|
120
|
+
}
|
|
121
|
+
// Bitmaps and files go only through AIR's clipboard.
|
|
122
|
+
"flash.desktop:Clipboard::getBitmapData"() {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
"flash.desktop:Clipboard::putBitmapData"() { }
|
|
126
|
+
"flash.desktop:Clipboard::getFileList"() {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
"flash.desktop:Clipboard::nativePutFileList"() { }
|
|
130
|
+
"flash.desktop:Clipboard::nativeGetFilePromiseList"() {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
"flash.desktop:Clipboard::nativePutFilePromiseList"() { }
|
|
134
|
+
}
|
|
135
|
+
avm2.registerNativeClass(natives, "flash.desktop::Clipboard", ClipboardNatives);
|
|
136
|
+
return natives;
|
|
137
|
+
}
|
|
138
|
+
/** Each player's generalClipboard, made on first use. */
|
|
139
|
+
const generals = new WeakMap();
|
|
140
|
+
/** Whether the player is making its generalClipboard, the one Clipboard `new` may make. */
|
|
141
|
+
let making = false;
|
|
142
|
+
function general(s) {
|
|
143
|
+
let o = generals.get(s);
|
|
144
|
+
if (!o) {
|
|
145
|
+
making = true;
|
|
146
|
+
try {
|
|
147
|
+
o = s.rt.constructClass(s.rt.classNamed("flash.desktop::Clipboard"), []);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
making = false;
|
|
151
|
+
}
|
|
152
|
+
generals.set(s, o);
|
|
153
|
+
}
|
|
154
|
+
return o;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* `new Clipboard()` is AIR's: Flash Player has the system's alone, and
|
|
158
|
+
* refuses another with IllegalOperationError #2178.
|
|
159
|
+
*/
|
|
160
|
+
export function clipboardHooks() {
|
|
161
|
+
return {
|
|
162
|
+
"flash.desktop::Clipboard": {
|
|
163
|
+
construct(rt, cls, args) {
|
|
164
|
+
if (!making) {
|
|
165
|
+
throw rt.error("flash.errors::IllegalOperationError", 2178);
|
|
166
|
+
}
|
|
167
|
+
const o = cls.$it.instance();
|
|
168
|
+
cls.$it.proto.$init.apply(o, args);
|
|
169
|
+
return o;
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|