@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,34 @@
|
|
|
1
|
+
// flash.events.GestureEvent's natives, its subclasses' included: the
|
|
2
|
+
// stage point, and the local point Flash Player's playerglobal keeps in
|
|
3
|
+
// natives, which ours keeps in AS3 with the rest. Scripts make and dispatch gesture
|
|
4
|
+
// events of their own: the player recognizes no gestures yet.
|
|
5
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
6
|
+
import { stagePoint } from "./MouseEvent.js";
|
|
7
|
+
export function gestureEventNatives(s) {
|
|
8
|
+
const natives = {};
|
|
9
|
+
class GestureEventNatives {
|
|
10
|
+
updateAfterEvent() {
|
|
11
|
+
s.updates++;
|
|
12
|
+
}
|
|
13
|
+
get localX() {
|
|
14
|
+
return this.$gestureX ?? Number.NaN;
|
|
15
|
+
}
|
|
16
|
+
set localX(value) {
|
|
17
|
+
this.$gestureX = s.rt.toNumber(value);
|
|
18
|
+
}
|
|
19
|
+
get localY() {
|
|
20
|
+
return this.$gestureY ?? Number.NaN;
|
|
21
|
+
}
|
|
22
|
+
set localY(value) {
|
|
23
|
+
this.$gestureY = s.rt.toNumber(value);
|
|
24
|
+
}
|
|
25
|
+
"flash.events:GestureEvent::getStageX"(x, y) {
|
|
26
|
+
return stagePoint(s, this, x ?? this.$gestureX, y ?? this.$gestureY)[0];
|
|
27
|
+
}
|
|
28
|
+
"flash.events:GestureEvent::getStageY"(x, y) {
|
|
29
|
+
return stagePoint(s, this, x ?? this.$gestureX, y ?? this.$gestureY)[1];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
avm2.registerNativeClass(natives, "flash.events::GestureEvent", GestureEventNatives);
|
|
33
|
+
return natives;
|
|
34
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// flash.events.KeyboardEvent's natives: a redraw, and the character and
|
|
2
|
+
// modifier keys Flash Player's playerglobal keeps in natives, which ours
|
|
3
|
+
// keeps in AS3; and TextEvent's one native, which a clone copies IME data
|
|
4
|
+
// through.
|
|
5
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
6
|
+
export function keyboardEventNatives(s) {
|
|
7
|
+
const natives = {};
|
|
8
|
+
class KeyboardEventNatives {
|
|
9
|
+
get charCode() {
|
|
10
|
+
return this.$charCode ?? 0;
|
|
11
|
+
}
|
|
12
|
+
set charCode(value) {
|
|
13
|
+
this.$charCode = s.rt.toUint(value);
|
|
14
|
+
}
|
|
15
|
+
get ctrlKey() {
|
|
16
|
+
return this.$ctrlKey ?? false;
|
|
17
|
+
}
|
|
18
|
+
set ctrlKey(value) {
|
|
19
|
+
this.$ctrlKey = !!value;
|
|
20
|
+
}
|
|
21
|
+
get altKey() {
|
|
22
|
+
return this.$altKey ?? false;
|
|
23
|
+
}
|
|
24
|
+
set altKey(value) {
|
|
25
|
+
this.$altKey = !!value;
|
|
26
|
+
}
|
|
27
|
+
get shiftKey() {
|
|
28
|
+
return this.$shiftKey ?? false;
|
|
29
|
+
}
|
|
30
|
+
set shiftKey(value) {
|
|
31
|
+
this.$shiftKey = !!value;
|
|
32
|
+
}
|
|
33
|
+
get commandKey() {
|
|
34
|
+
return this.$commandKey ?? false;
|
|
35
|
+
}
|
|
36
|
+
set commandKey(value) {
|
|
37
|
+
this.$commandKey = !!value;
|
|
38
|
+
}
|
|
39
|
+
updateAfterEvent() {
|
|
40
|
+
s.updates++;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
avm2.registerNativeClass(natives, "flash.events::KeyboardEvent", KeyboardEventNatives);
|
|
44
|
+
class TextEventNatives {
|
|
45
|
+
"flash.events:TextEvent::copyNativeData"(_from) {
|
|
46
|
+
// A text input's IME data, which the player has none of.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
avm2.registerNativeClass(natives, "flash.events::TextEvent", TextEventNatives);
|
|
50
|
+
return natives;
|
|
51
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// flash.events.MouseEvent's natives. Playerglobal keeps its fields in AS3;
|
|
2
|
+
// its stage point follows its target. The local point's accessors are
|
|
3
|
+
// Flash Player's playerglobal's natives, kept for it.
|
|
4
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
5
|
+
import { toStage } from "../../../display/bounds.js";
|
|
6
|
+
import { apply } from "../../../display/geometry.js";
|
|
7
|
+
import { eventFields } from "../../../scripting/events.js";
|
|
8
|
+
/**
|
|
9
|
+
* The stage point of an event's local point, (x, y) on its target where
|
|
10
|
+
* that is on the display list; TouchEvent and GestureEvent read theirs so.
|
|
11
|
+
*/
|
|
12
|
+
export function stagePoint(s, event, x = Number.NaN, y = Number.NaN) {
|
|
13
|
+
const target = event[eventFields(s).target]?.$display;
|
|
14
|
+
if (target) {
|
|
15
|
+
return apply(toStage(target, s.stage), x, y);
|
|
16
|
+
}
|
|
17
|
+
return [Number.isNaN(x) ? Number.NaN : 0, Number.isNaN(y) ? Number.NaN : 0];
|
|
18
|
+
}
|
|
19
|
+
export function mouseEventNatives(s) {
|
|
20
|
+
const natives = {};
|
|
21
|
+
class MouseEventNatives {
|
|
22
|
+
updateAfterEvent() {
|
|
23
|
+
s.updates++;
|
|
24
|
+
}
|
|
25
|
+
get localX() {
|
|
26
|
+
return this.$mouseX ?? Number.NaN;
|
|
27
|
+
}
|
|
28
|
+
set localX(value) {
|
|
29
|
+
this.$mouseX = s.rt.toNumber(value);
|
|
30
|
+
}
|
|
31
|
+
get localY() {
|
|
32
|
+
return this.$mouseY ?? Number.NaN;
|
|
33
|
+
}
|
|
34
|
+
set localY(value) {
|
|
35
|
+
this.$mouseY = s.rt.toNumber(value);
|
|
36
|
+
}
|
|
37
|
+
// Ours passes its local point; Flash Player's keeps it in the natives above.
|
|
38
|
+
"flash.events:MouseEvent::getStageX"(x, y) {
|
|
39
|
+
return stagePoint(s, this, x ?? this.$mouseX, y ?? this.$mouseY)[0];
|
|
40
|
+
}
|
|
41
|
+
"flash.events:MouseEvent::getStageY"(x, y) {
|
|
42
|
+
return stagePoint(s, this, x ?? this.$mouseX, y ?? this.$mouseY)[1];
|
|
43
|
+
}
|
|
44
|
+
get movementX() {
|
|
45
|
+
return this.$movementX ?? 0;
|
|
46
|
+
}
|
|
47
|
+
set movementX(value) {
|
|
48
|
+
this.$movementX = s.rt.toNumber(value);
|
|
49
|
+
}
|
|
50
|
+
get movementY() {
|
|
51
|
+
return this.$movementY ?? 0;
|
|
52
|
+
}
|
|
53
|
+
set movementY(value) {
|
|
54
|
+
this.$movementY = s.rt.toNumber(value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
avm2.registerNativeClass(natives, "flash.events::MouseEvent", MouseEventNatives);
|
|
58
|
+
return natives;
|
|
59
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// flash.events.PressAndTapGestureEvent's natives: the tap's stage point,
|
|
2
|
+
// on the target as GestureEvent's own point is, and its local point, which
|
|
3
|
+
// Flash Player's playerglobal keeps in natives and ours in AS3.
|
|
4
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
5
|
+
import { stagePoint } from "./MouseEvent.js";
|
|
6
|
+
export function pressAndTapGestureEventNatives(s) {
|
|
7
|
+
const natives = {};
|
|
8
|
+
class PressAndTapGestureEventNatives {
|
|
9
|
+
get tapLocalX() {
|
|
10
|
+
return this.$tapX ?? Number.NaN;
|
|
11
|
+
}
|
|
12
|
+
set tapLocalX(value) {
|
|
13
|
+
this.$tapX = s.rt.toNumber(value);
|
|
14
|
+
}
|
|
15
|
+
get tapLocalY() {
|
|
16
|
+
return this.$tapY ?? Number.NaN;
|
|
17
|
+
}
|
|
18
|
+
set tapLocalY(value) {
|
|
19
|
+
this.$tapY = s.rt.toNumber(value);
|
|
20
|
+
}
|
|
21
|
+
"flash.events:PressAndTapGestureEvent::getTapStageX"(x, y) {
|
|
22
|
+
return stagePoint(s, this, x ?? this.$tapX, y ?? this.$tapY)[0];
|
|
23
|
+
}
|
|
24
|
+
"flash.events:PressAndTapGestureEvent::getTapStageY"(x, y) {
|
|
25
|
+
return stagePoint(s, this, x ?? this.$tapX, y ?? this.$tapY)[1];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
avm2.registerNativeClass(natives, "flash.events::PressAndTapGestureEvent", PressAndTapGestureEventNatives);
|
|
29
|
+
return natives;
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// flash.events.TimerEvent's one native: updateAfterEvent, which asks for a
|
|
2
|
+
// redraw, as MouseEvent's and KeyboardEvent's do. A timer that fires
|
|
3
|
+
// between frames has the stage render after its listeners, RENDER and all,
|
|
4
|
+
// as Flash does; in a frame, the frame's own drawing answers it.
|
|
5
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
6
|
+
export function timerEventNatives(s) {
|
|
7
|
+
const natives = {};
|
|
8
|
+
class TimerEventNatives {
|
|
9
|
+
updateAfterEvent() {
|
|
10
|
+
s.updates++;
|
|
11
|
+
s.timers.renderAsked = true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
avm2.registerNativeClass(natives, "flash.events::TimerEvent", TimerEventNatives);
|
|
15
|
+
return natives;
|
|
16
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// flash.events.TouchEvent's natives: the stage point, which follows the
|
|
2
|
+
// target as MouseEvent's does, and the local point Flash Player's
|
|
3
|
+
// playerglobal keeps in natives, which ours keeps in AS3 with the rest.
|
|
4
|
+
// No device the player knows records a stylus's samples, so there are none
|
|
5
|
+
// to get, and no tool button is down.
|
|
6
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
7
|
+
import { stagePoint } from "./MouseEvent.js";
|
|
8
|
+
export function touchEventNatives(s) {
|
|
9
|
+
const natives = {};
|
|
10
|
+
class TouchEventNatives {
|
|
11
|
+
updateAfterEvent() {
|
|
12
|
+
s.updates++;
|
|
13
|
+
}
|
|
14
|
+
get localX() {
|
|
15
|
+
return this.$touchX ?? Number.NaN;
|
|
16
|
+
}
|
|
17
|
+
set localX(value) {
|
|
18
|
+
this.$touchX = s.rt.toNumber(value);
|
|
19
|
+
}
|
|
20
|
+
get localY() {
|
|
21
|
+
return this.$touchY ?? Number.NaN;
|
|
22
|
+
}
|
|
23
|
+
set localY(value) {
|
|
24
|
+
this.$touchY = s.rt.toNumber(value);
|
|
25
|
+
}
|
|
26
|
+
"flash.events:TouchEvent::getStageX"(x, y) {
|
|
27
|
+
return stagePoint(s, this, x ?? this.$touchX, y ?? this.$touchY)[0];
|
|
28
|
+
}
|
|
29
|
+
"flash.events:TouchEvent::getStageY"(x, y) {
|
|
30
|
+
return stagePoint(s, this, x ?? this.$touchX, y ?? this.$touchY)[1];
|
|
31
|
+
}
|
|
32
|
+
isToolButtonDown() {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
getSamples() {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
"flash.events:TouchEvent::privateGetSamples"() {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
"flash.events:TouchEvent::setSamples"() { }
|
|
42
|
+
}
|
|
43
|
+
avm2.registerNativeClass(natives, "flash.events::TouchEvent", TouchEventNatives);
|
|
44
|
+
return natives;
|
|
45
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// playerglobal's private ExternalInterface natives use the optional host
|
|
2
|
+
// given to Scripting. Without one, available is false and calls throw #2067.
|
|
3
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
4
|
+
export function externalInterfaceNatives(s) {
|
|
5
|
+
const natives = {};
|
|
6
|
+
// The host, if it lets the calling SWF use it; if the caller cannot be
|
|
7
|
+
// told, only if it lets every SWF ever loaded (Code.securityUrls). Called
|
|
8
|
+
// straight from the natives: 2 counts this and the native as the player's.
|
|
9
|
+
const bridge = () => {
|
|
10
|
+
const host = s.externalInterface;
|
|
11
|
+
const allows = host?.allows;
|
|
12
|
+
return host && (!allows || s.code.securityUrls(2).every((url) => allows.call(host, url)))
|
|
13
|
+
? host
|
|
14
|
+
: null;
|
|
15
|
+
};
|
|
16
|
+
class ExternalInterfaceNatives {
|
|
17
|
+
static get available() {
|
|
18
|
+
return bridge() !== null;
|
|
19
|
+
}
|
|
20
|
+
static get objectID() {
|
|
21
|
+
return bridge()?.objectID ?? null;
|
|
22
|
+
}
|
|
23
|
+
static "flash.external:ExternalInterface::_initJS"() {
|
|
24
|
+
// The host supplies the bridge; playerglobal's JavaScript shim needs no installation.
|
|
25
|
+
}
|
|
26
|
+
static "flash.external:ExternalInterface::_getPropNames"(object) {
|
|
27
|
+
const names = [];
|
|
28
|
+
let index = s.rt.hasNext(object, 0);
|
|
29
|
+
while (index !== 0) {
|
|
30
|
+
names.push(s.rt.nextName(object, index));
|
|
31
|
+
index = s.rt.hasNext(object, index);
|
|
32
|
+
}
|
|
33
|
+
return s.rt.array(names);
|
|
34
|
+
}
|
|
35
|
+
static get "flash.external:ExternalInterface::activeX"() {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
static "flash.external:ExternalInterface::_addCallback"(name, closure, remove) {
|
|
39
|
+
const host = bridge();
|
|
40
|
+
if (!host) {
|
|
41
|
+
throw s.rt.error("Error", 2067);
|
|
42
|
+
}
|
|
43
|
+
host.addCallback(s.rt.toString(name), remove || closure === null || closure === undefined
|
|
44
|
+
? null
|
|
45
|
+
: (request, args) => {
|
|
46
|
+
s.hostCalls++;
|
|
47
|
+
return s.rt.callValue(closure, null, [request, args === null ? null : s.rt.array(args)], null);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
static "flash.external:ExternalInterface::_evalJS"(source) {
|
|
51
|
+
const host = bridge();
|
|
52
|
+
if (!host) {
|
|
53
|
+
throw s.rt.error("Error", 2067);
|
|
54
|
+
}
|
|
55
|
+
return host.evalJS?.(s.rt.toString(source)) ?? null;
|
|
56
|
+
}
|
|
57
|
+
static "flash.external:ExternalInterface::_callOut"(request) {
|
|
58
|
+
const host = bridge();
|
|
59
|
+
if (!host) {
|
|
60
|
+
throw s.rt.error("Error", 2067);
|
|
61
|
+
}
|
|
62
|
+
return host.callOut(s.rt.toString(request));
|
|
63
|
+
}
|
|
64
|
+
static "flash.external:ExternalInterface::_quotedStringFromString"(value) {
|
|
65
|
+
return JSON.stringify(s.rt.toString(value));
|
|
66
|
+
}
|
|
67
|
+
static "flash.external:ExternalInterface::_quotedStringFromError"(error) {
|
|
68
|
+
return JSON.stringify(s.rt.toString(error));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
avm2.registerNativeClass(natives, "flash.external::ExternalInterface", ExternalInterfaceNatives);
|
|
72
|
+
return natives;
|
|
73
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
// flash.filesystem.File over the host's FileSystemHost (hosts.ts), as adl
|
|
2
|
+
// (AIR 51.3) has it: a native path and the URL that names it, under the
|
|
3
|
+
// file system's root, the application's directory (app:/) or its storage's
|
|
4
|
+
// (app-storage:/), which a File keeps as it resolves paths and goes up,
|
|
5
|
+
// never climbing out of app:/. Relative paths are refused (ArgumentError
|
|
6
|
+
// 2004), a File of no path is unusable (Error 2037), and what reads a file
|
|
7
|
+
// that is not there fails (Error 3003). Reading what is there is
|
|
8
|
+
// synchronous, as File's properties are; FileStream reads a file's bytes
|
|
9
|
+
// (FileStream.ts). It makes and deletes directories and deletes, copies
|
|
10
|
+
// and moves files and directories (writes.ts), at once or on the next
|
|
11
|
+
// frame with an event, as the asynchronous methods do; dialogs are not
|
|
12
|
+
// supported yet. Without a host, nothing is there.
|
|
13
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
14
|
+
import { dispatchEvent } from "../../../scripting/events.js";
|
|
15
|
+
import { NativePaths } from "./paths.js";
|
|
16
|
+
import { copyOrMove, createDirectory, deleteDirectory, deleteFile, ioErrorEvent, refuseApp, } from "./writes.js";
|
|
17
|
+
/** The location of `o`, a File given a path; null for one of none, or a FileReference. */
|
|
18
|
+
export function fileLocation(o) {
|
|
19
|
+
return o.$fileLocation ?? null;
|
|
20
|
+
}
|
|
21
|
+
/** What `name`, `size` and the dates of a File read: its name and what is there, null where nothing is. */
|
|
22
|
+
export function fileEntry(s, o) {
|
|
23
|
+
const at = fileLocation(o);
|
|
24
|
+
if (!at) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const paths = new NativePaths(s.fileSystem?.separator ?? "/");
|
|
28
|
+
return { name: paths.name(at.path), stat: s.fileSystem?.stat(at.path) ?? null };
|
|
29
|
+
}
|
|
30
|
+
/** A new File at the native path `path`, under the file system's root. */
|
|
31
|
+
export function fileAt(s, path) {
|
|
32
|
+
const file = s.rt.construct(s.rt.classNamed("flash.filesystem::File"));
|
|
33
|
+
file.$fileLocation = { root: "file", path };
|
|
34
|
+
return file;
|
|
35
|
+
}
|
|
36
|
+
export function fileNatives(s) {
|
|
37
|
+
const natives = {};
|
|
38
|
+
const host = s.fileSystem;
|
|
39
|
+
const paths = new NativePaths(host?.separator ?? "/");
|
|
40
|
+
const fileClass = () => s.rt.classNamed("flash.filesystem::File");
|
|
41
|
+
/** The directory a root's URLs start from; null for the file system's. */
|
|
42
|
+
const floor = (root) => {
|
|
43
|
+
switch (root) {
|
|
44
|
+
case "app":
|
|
45
|
+
return host?.directories.application ?? null;
|
|
46
|
+
case "app-storage":
|
|
47
|
+
return host?.directories.applicationStorage ?? null;
|
|
48
|
+
default:
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/** A new File at `at`. */
|
|
53
|
+
const make = (at) => {
|
|
54
|
+
const file = s.rt.construct(fileClass());
|
|
55
|
+
file.$fileLocation = at;
|
|
56
|
+
return file;
|
|
57
|
+
};
|
|
58
|
+
/** A directory AIR names, as a File; one the host does not have is refused. */
|
|
59
|
+
const named = (root, path) => {
|
|
60
|
+
if (!path) {
|
|
61
|
+
throw s.rt.error("Error", 2014);
|
|
62
|
+
}
|
|
63
|
+
return make({ root, path: paths.normalize(path) ?? path });
|
|
64
|
+
};
|
|
65
|
+
/** Where `o` is; Error 2037 for a File of no path. */
|
|
66
|
+
const locationOf = (o) => {
|
|
67
|
+
const at = fileLocation(o);
|
|
68
|
+
if (!at) {
|
|
69
|
+
throw s.rt.error("Error", 2037);
|
|
70
|
+
}
|
|
71
|
+
return at;
|
|
72
|
+
};
|
|
73
|
+
const refuse = () => {
|
|
74
|
+
throw s.rt.error("ArgumentError", 2004);
|
|
75
|
+
};
|
|
76
|
+
/** The location a native path or a file:, app: or app-storage: URL names; null for neither. */
|
|
77
|
+
const parse = (given) => {
|
|
78
|
+
const app = /^(app|app-storage):(.*)$/i.exec(given);
|
|
79
|
+
if (app) {
|
|
80
|
+
const root = app[1].toLowerCase();
|
|
81
|
+
const base = floor(root);
|
|
82
|
+
const segments = paths.urlSegments(app[2]);
|
|
83
|
+
if (!base || !segments) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return { root, path: paths.resolve(base, segments.join(paths.separator), base) };
|
|
87
|
+
}
|
|
88
|
+
if (/^file:/i.test(given)) {
|
|
89
|
+
const path = paths.fromFileUrl(given);
|
|
90
|
+
return path ? { root: "file", path } : null;
|
|
91
|
+
}
|
|
92
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(given)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const path = paths.normalize(given);
|
|
96
|
+
return path ? { root: "file", path } : null;
|
|
97
|
+
};
|
|
98
|
+
/** Throws the IOError `id`, unless it is 0. */
|
|
99
|
+
const check = (id) => {
|
|
100
|
+
if (id) {
|
|
101
|
+
throw s.rt.error("flash.errors::IOError", id);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/** `file`'s location, to be written: a SecurityError for one of the app: URL. */
|
|
105
|
+
const writable = (file) => {
|
|
106
|
+
if (file === null || file === undefined) {
|
|
107
|
+
throw s.rt.error("TypeError", 2007, "newLocation");
|
|
108
|
+
}
|
|
109
|
+
const at = locationOf(file);
|
|
110
|
+
refuseApp(s, at);
|
|
111
|
+
return at;
|
|
112
|
+
};
|
|
113
|
+
/** Runs `change` on the next frame, then tells `file` complete, or ioError for the IOError it gives. */
|
|
114
|
+
const later = (file, change) => {
|
|
115
|
+
s.loads.deferHostEvent(() => {
|
|
116
|
+
const id = change();
|
|
117
|
+
dispatchEvent(s, file, id ? ioErrorEvent(s, id) : s.event("complete"));
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
/** What is at `at`; Error 3003 where nothing is. */
|
|
121
|
+
const there = (at) => {
|
|
122
|
+
const stat = host?.stat(at.path);
|
|
123
|
+
if (!stat) {
|
|
124
|
+
throw s.rt.error("Error", 3003);
|
|
125
|
+
}
|
|
126
|
+
return stat;
|
|
127
|
+
};
|
|
128
|
+
class FileNatives {
|
|
129
|
+
static get systemCharset() {
|
|
130
|
+
return "utf-8";
|
|
131
|
+
}
|
|
132
|
+
static get separator() {
|
|
133
|
+
return paths.separator;
|
|
134
|
+
}
|
|
135
|
+
static get lineEnding() {
|
|
136
|
+
return paths.separator === "\\" ? "\r\n" : "\n";
|
|
137
|
+
}
|
|
138
|
+
static get applicationDirectory() {
|
|
139
|
+
return named("app", host?.directories.application);
|
|
140
|
+
}
|
|
141
|
+
static get applicationStorageDirectory() {
|
|
142
|
+
return named("app-storage", host?.directories.applicationStorage);
|
|
143
|
+
}
|
|
144
|
+
static get userDirectory() {
|
|
145
|
+
return named("file", host?.directories.user);
|
|
146
|
+
}
|
|
147
|
+
static get documentsDirectory() {
|
|
148
|
+
return named("file", host?.directories.documents);
|
|
149
|
+
}
|
|
150
|
+
static get desktopDirectory() {
|
|
151
|
+
return named("file", host?.directories.desktop);
|
|
152
|
+
}
|
|
153
|
+
static get cacheDirectory() {
|
|
154
|
+
return named("file", host?.directories.cache);
|
|
155
|
+
}
|
|
156
|
+
static getRootDirectories() {
|
|
157
|
+
const roots = new Set();
|
|
158
|
+
for (const dir of Object.values(host?.directories ?? {})) {
|
|
159
|
+
let at = dir ? paths.normalize(dir) : null;
|
|
160
|
+
while (at && paths.parent(at) !== null) {
|
|
161
|
+
at = paths.parent(at);
|
|
162
|
+
}
|
|
163
|
+
if (at) {
|
|
164
|
+
roots.add(at);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return s.rt.array([...roots].map((path) => make({ root: "file", path })));
|
|
168
|
+
}
|
|
169
|
+
static createTempFile() {
|
|
170
|
+
throw s.rt.unsupported("File.createTempFile");
|
|
171
|
+
}
|
|
172
|
+
static createTempDirectory() {
|
|
173
|
+
throw s.rt.unsupported("File.createTempDirectory");
|
|
174
|
+
}
|
|
175
|
+
"flash.filesystem:File::_init"(given) {
|
|
176
|
+
this.$fileLocation = parse(String(given)) ?? refuse();
|
|
177
|
+
}
|
|
178
|
+
toString() {
|
|
179
|
+
return "[object File]";
|
|
180
|
+
}
|
|
181
|
+
get exists() {
|
|
182
|
+
return !!host?.stat(locationOf(this).path);
|
|
183
|
+
}
|
|
184
|
+
get isDirectory() {
|
|
185
|
+
return host?.stat(locationOf(this).path)?.directory ?? false;
|
|
186
|
+
}
|
|
187
|
+
get isHidden() {
|
|
188
|
+
return host?.stat(locationOf(this).path)?.hidden ?? false;
|
|
189
|
+
}
|
|
190
|
+
get isSymbolicLink() {
|
|
191
|
+
return host?.stat(locationOf(this).path)?.symbolicLink ?? false;
|
|
192
|
+
}
|
|
193
|
+
get isPackage() {
|
|
194
|
+
locationOf(this);
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
resolvePath(given) {
|
|
198
|
+
const at = locationOf(this);
|
|
199
|
+
const text = String(given ?? "");
|
|
200
|
+
// A File's URL or an absolute path names its own place, whatever this File's is; "a:b" is
|
|
201
|
+
// a name, as on a system that allows a colon in one.
|
|
202
|
+
if (/^(file|app|app-storage):/i.test(text) && !paths.isAbsolute(text)) {
|
|
203
|
+
return make(parse(text) ?? refuse());
|
|
204
|
+
}
|
|
205
|
+
if (paths.isAbsolute(text)) {
|
|
206
|
+
return make({ root: "file", path: paths.normalize(text) });
|
|
207
|
+
}
|
|
208
|
+
return make({ root: at.root, path: paths.resolve(at.path, text, floor(at.root)) });
|
|
209
|
+
}
|
|
210
|
+
getRelativePath(ref, useDotDot) {
|
|
211
|
+
const from = locationOf(this).path;
|
|
212
|
+
const to = locationOf(ref).path;
|
|
213
|
+
const below = paths.under(to, from);
|
|
214
|
+
if (below) {
|
|
215
|
+
return below.join("/");
|
|
216
|
+
}
|
|
217
|
+
if (!useDotDot) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
// Up to the nearest directory both are in, then down.
|
|
221
|
+
let common = from;
|
|
222
|
+
let ups = 0;
|
|
223
|
+
while (common !== null && !paths.under(to, common)) {
|
|
224
|
+
common = paths.parent(common);
|
|
225
|
+
ups++;
|
|
226
|
+
}
|
|
227
|
+
if (common === null) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return [...Array(ups).fill(".."), ...paths.under(to, common)].join("/");
|
|
231
|
+
}
|
|
232
|
+
get parent() {
|
|
233
|
+
const at = locationOf(this);
|
|
234
|
+
const base = floor(at.root);
|
|
235
|
+
// The application's directory and its storage's have none, as adl's.
|
|
236
|
+
if (base !== null && paths.under(base, at.path)) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
const up = paths.parent(at.path);
|
|
240
|
+
return up === null ? null : make({ root: at.root, path: up });
|
|
241
|
+
}
|
|
242
|
+
get nativePath() {
|
|
243
|
+
return locationOf(this).path;
|
|
244
|
+
}
|
|
245
|
+
set nativePath(v) {
|
|
246
|
+
const path = paths.normalize(String(v ?? ""));
|
|
247
|
+
this.$fileLocation = path ? { root: "file", path } : refuse();
|
|
248
|
+
}
|
|
249
|
+
canonicalize() {
|
|
250
|
+
locationOf(this);
|
|
251
|
+
}
|
|
252
|
+
get url() {
|
|
253
|
+
const at = locationOf(this);
|
|
254
|
+
const base = floor(at.root);
|
|
255
|
+
if (base !== null) {
|
|
256
|
+
const below = paths.under(at.path, base) ?? [];
|
|
257
|
+
return `${at.root}:/${below.map(encodeURIComponent).join("/")}`;
|
|
258
|
+
}
|
|
259
|
+
return paths.fileUrl(at.path);
|
|
260
|
+
}
|
|
261
|
+
set url(v) {
|
|
262
|
+
const text = String(v ?? "");
|
|
263
|
+
const at = /^(file|app|app-storage):/i.test(text) ? parse(text) : null;
|
|
264
|
+
this.$fileLocation = at ?? refuse();
|
|
265
|
+
}
|
|
266
|
+
getDirectoryListing() {
|
|
267
|
+
const at = locationOf(this);
|
|
268
|
+
const stat = there(at);
|
|
269
|
+
if (!stat.directory) {
|
|
270
|
+
throw s.rt.error("Error", 3007);
|
|
271
|
+
}
|
|
272
|
+
const names = host?.list(at.path) ?? [];
|
|
273
|
+
return s.rt.array(names.map((name) => make({ root: at.root, path: paths.resolve(at.path, name, null) })));
|
|
274
|
+
}
|
|
275
|
+
getDirectoryListingAsync() {
|
|
276
|
+
const at = locationOf(this);
|
|
277
|
+
s.loads.deferHostEvent(() => {
|
|
278
|
+
const stat = host?.stat(at.path);
|
|
279
|
+
if (!stat?.directory) {
|
|
280
|
+
dispatchEvent(s, this, ioErrorEvent(s, stat ? 3007 : 3003));
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const files = (host?.list(at.path) ?? []).map((name) => make({ root: at.root, path: paths.resolve(at.path, name, null) }));
|
|
284
|
+
dispatchEvent(s, this, s.rt.construct(s.rt.classNamed("flash.events::FileListEvent"), "directoryListing", false, false, s.rt.array(files)));
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
createDirectory() {
|
|
288
|
+
check(createDirectory(s, writable(this).path));
|
|
289
|
+
}
|
|
290
|
+
deleteFile() {
|
|
291
|
+
check(deleteFile(s, writable(this).path));
|
|
292
|
+
}
|
|
293
|
+
deleteFileAsync() {
|
|
294
|
+
const at = writable(this);
|
|
295
|
+
later(this, () => deleteFile(s, at.path));
|
|
296
|
+
}
|
|
297
|
+
deleteDirectory(contents = false) {
|
|
298
|
+
check(deleteDirectory(s, writable(this).path, !!contents));
|
|
299
|
+
}
|
|
300
|
+
deleteDirectoryAsync(contents = false) {
|
|
301
|
+
const at = writable(this);
|
|
302
|
+
later(this, () => deleteDirectory(s, at.path, !!contents));
|
|
303
|
+
}
|
|
304
|
+
copyTo(to, overwrite = false) {
|
|
305
|
+
const from = locationOf(this);
|
|
306
|
+
check(copyOrMove(s, from.path, writable(to).path, !!overwrite, false));
|
|
307
|
+
}
|
|
308
|
+
copyToAsync(to, overwrite = false) {
|
|
309
|
+
const from = locationOf(this);
|
|
310
|
+
const into = writable(to);
|
|
311
|
+
later(this, () => copyOrMove(s, from.path, into.path, !!overwrite, false));
|
|
312
|
+
}
|
|
313
|
+
moveTo(to, overwrite = false) {
|
|
314
|
+
const from = writable(this);
|
|
315
|
+
check(copyOrMove(s, from.path, writable(to).path, !!overwrite, true));
|
|
316
|
+
}
|
|
317
|
+
moveToAsync(to, overwrite = false) {
|
|
318
|
+
const from = writable(this);
|
|
319
|
+
const into = writable(to);
|
|
320
|
+
later(this, () => copyOrMove(s, from.path, into.path, !!overwrite, true));
|
|
321
|
+
}
|
|
322
|
+
clone() {
|
|
323
|
+
return make({ ...locationOf(this) });
|
|
324
|
+
}
|
|
325
|
+
cancel() { }
|
|
326
|
+
get icon() {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
get downloaded() {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
set downloaded(_v) { }
|
|
333
|
+
get preventBackup() {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
set preventBackup(_v) { }
|
|
337
|
+
}
|
|
338
|
+
avm2.registerNativeClass(natives, "flash.filesystem::File", FileNatives);
|
|
339
|
+
return natives;
|
|
340
|
+
}
|