@swf2es/player-hosts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/LICENSE.third-party +759 -0
- package/README.md +43 -2
- package/dist/indexeddb.d.ts +27 -0
- package/dist/indexeddb.d.ts.map +1 -0
- package/dist/indexeddb.js +170 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +12 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +43 -0
- package/dist/node.js.map +1 -0
- package/dist/precompiled.d.ts +31 -0
- package/dist/precompiled.d.ts.map +1 -0
- package/dist/precompiled.js +125 -0
- package/dist/precompiled.js.map +1 -0
- package/dist/stage3d.d.ts +13 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +61 -0
- package/dist/stage3d.js.map +1 -0
- package/dist/thread/codegen/codegen.js +308 -0
- package/dist/thread/codegen/index.js +405 -0
- package/dist/thread/format/abc-names.js +126 -0
- package/dist/thread/format/actions.js +222 -0
- package/dist/thread/format/air-descriptor.js +63 -0
- package/dist/thread/format/api-versions.js +22 -0
- package/dist/thread/format/bitmap.js +199 -0
- package/dist/thread/format/button.js +60 -0
- package/dist/thread/format/compression.js +200 -0
- package/dist/thread/format/display.js +305 -0
- package/dist/thread/format/filters.js +136 -0
- package/dist/thread/format/font.js +168 -0
- package/dist/thread/format/index.js +26 -0
- package/dist/thread/format/pbj.js +484 -0
- package/dist/thread/format/shape.js +411 -0
- package/dist/thread/format/sound.js +91 -0
- package/dist/thread/format/swf.js +163 -0
- package/dist/thread/format/tags.js +58 -0
- package/dist/thread/format/text.js +135 -0
- package/dist/thread/format/zip.js +91 -0
- package/dist/thread/native/audio/binary.js +3 -0
- package/dist/thread/native/audio/index.js +72 -0
- package/dist/thread/native/base64.js +9 -0
- package/dist/thread/native/compress/binary.js +3 -0
- package/dist/thread/native/compress/index.js +145 -0
- package/dist/thread/native/instance.js +49 -0
- package/dist/thread/native/mp3/binary.js +3 -0
- package/dist/thread/native/mp3/index.js +48 -0
- package/dist/thread/native/render/binary.js +3 -0
- package/dist/thread/native/render/bitmap-kernel.js +591 -0
- package/dist/thread/native/render/draw-kernel.js +204 -0
- package/dist/thread/native/render/dxt-encoder.js +94 -0
- package/dist/thread/native/render/index.js +10 -0
- package/dist/thread/native/render/lines.js +122 -0
- package/dist/thread/native/render/module.js +26 -0
- package/dist/thread/native/render/pixel-ops.js +235 -0
- package/dist/thread/native/render/tessellator.js +250 -0
- package/dist/thread/player/avm1/amf.js +507 -0
- package/dist/thread/player/avm1/avm1.js +1304 -0
- package/dist/thread/player/avm1/bindings.js +214 -0
- package/dist/thread/player/avm1/classes.js +75 -0
- package/dist/thread/player/avm1/clips.js +229 -0
- package/dist/thread/player/avm1/compile.js +140 -0
- package/dist/thread/player/avm1/external.js +79 -0
- package/dist/thread/player/avm1/focus.js +278 -0
- package/dist/thread/player/avm1/globals/BitmapData.js +542 -0
- package/dist/thread/player/avm1/globals/Button.js +31 -0
- package/dist/thread/player/avm1/globals/Color.js +115 -0
- package/dist/thread/player/avm1/globals/ExternalInterface.js +310 -0
- package/dist/thread/player/avm1/globals/FileReference.js +217 -0
- package/dist/thread/player/avm1/globals/Key.js +60 -0
- package/dist/thread/player/avm1/globals/LoadVars.js +208 -0
- package/dist/thread/player/avm1/globals/LocalConnection.js +92 -0
- package/dist/thread/player/avm1/globals/MovieClip.js +1070 -0
- package/dist/thread/player/avm1/globals/MovieClipLoader.js +90 -0
- package/dist/thread/player/avm1/globals/NetConnection.js +261 -0
- package/dist/thread/player/avm1/globals/PrintJob.js +37 -0
- package/dist/thread/player/avm1/globals/Selection.js +62 -0
- package/dist/thread/player/avm1/globals/SharedObject.js +245 -0
- package/dist/thread/player/avm1/globals/Sound.js +238 -0
- package/dist/thread/player/avm1/globals/Stage.js +12 -0
- package/dist/thread/player/avm1/globals/StyleSheet.js +205 -0
- package/dist/thread/player/avm1/globals/TextField.js +396 -0
- package/dist/thread/player/avm1/globals/TextFormat.js +194 -0
- package/dist/thread/player/avm1/globals/TextSnapshot.js +88 -0
- package/dist/thread/player/avm1/globals/XML.js +396 -0
- package/dist/thread/player/avm1/globals/XMLNode.js +413 -0
- package/dist/thread/player/avm1/globals/XMLSocket.js +205 -0
- package/dist/thread/player/avm1/globals/drawing.js +202 -0
- package/dist/thread/player/avm1/globals/filters.js +635 -0
- package/dist/thread/player/avm1/globals/geom.js +600 -0
- package/dist/thread/player/avm1/input.js +483 -0
- package/dist/thread/player/avm1/keyboard.js +113 -0
- package/dist/thread/player/avm1/loads.js +352 -0
- package/dist/thread/player/avm1/net.js +219 -0
- package/dist/thread/player/avm1/paths.js +104 -0
- package/dist/thread/player/avm1/pointer.js +512 -0
- package/dist/thread/player/avm1/queue.js +303 -0
- package/dist/thread/player/avm1/sound.js +106 -0
- package/dist/thread/player/avm1/swf.js +141 -0
- package/dist/thread/player/avm1/timers.js +113 -0
- package/dist/thread/player/bitmap/bitmap.js +627 -0
- package/dist/thread/player/bitmap/draw.js +68 -0
- package/dist/thread/player/bitmap/dxt.js +11 -0
- package/dist/thread/player/bitmap/filters.js +656 -0
- package/dist/thread/player/bitmap/images.js +240 -0
- package/dist/thread/player/bitmap/kernel.js +65 -0
- package/dist/thread/player/bitmap/ops.js +1239 -0
- package/dist/thread/player/bitmap/pixel-bender.js +911 -0
- package/dist/thread/player/bitmap/png.js +139 -0
- package/dist/thread/player/bitmap/turbulence.js +89 -0
- package/dist/thread/player/clock.js +182 -0
- package/dist/thread/player/display/bitmapobject.js +25 -0
- package/dist/thread/player/display/bounds.js +520 -0
- package/dist/thread/player/display/buttonobject.js +305 -0
- package/dist/thread/player/display/color.js +40 -0
- package/dist/thread/player/display/container.js +150 -0
- package/dist/thread/player/display/display.js +14 -0
- package/dist/thread/player/display/displayobject.js +664 -0
- package/dist/thread/player/display/drawing.js +613 -0
- package/dist/thread/player/display/filters.js +285 -0
- package/dist/thread/player/display/geometry.js +189 -0
- package/dist/thread/player/display/gradients.js +117 -0
- package/dist/thread/player/display/graphicsdata.js +592 -0
- package/dist/thread/player/display/instantiate.js +71 -0
- package/dist/thread/player/display/matrix3d.js +373 -0
- package/dist/thread/player/display/morph.js +226 -0
- package/dist/thread/player/display/movieclip.js +680 -0
- package/dist/thread/player/display/perspective.js +193 -0
- package/dist/thread/player/display/scale9.js +236 -0
- package/dist/thread/player/display/shapeobject.js +131 -0
- package/dist/thread/player/display/shapes.js +407 -0
- package/dist/thread/player/display/textobjects.js +222 -0
- package/dist/thread/player/display/timeline.js +471 -0
- package/dist/thread/player/display/value-lists.js +40 -0
- package/dist/thread/player/display/videoobject.js +6 -0
- package/dist/thread/player/display/walk.js +127 -0
- package/dist/thread/player/files.js +334 -0
- package/dist/thread/player/hosts.js +207 -0
- package/dist/thread/player/input/avm1.js +82 -0
- package/dist/thread/player/input/context-menu.js +63 -0
- package/dist/thread/player/input/keyboard.js +458 -0
- package/dist/thread/player/input/pointer.js +863 -0
- package/dist/thread/player/input/text-editor.js +319 -0
- package/dist/thread/player/input/touch.js +209 -0
- package/dist/thread/player/localconnection.js +90 -0
- package/dist/thread/player/media/audio.js +376 -0
- package/dist/thread/player/media/dynamic-sound.js +90 -0
- package/dist/thread/player/media/extract.js +135 -0
- package/dist/thread/player/media/mp3.js +152 -0
- package/dist/thread/player/media/sounds.js +507 -0
- package/dist/thread/player/media/streaming-audio.js +133 -0
- package/dist/thread/player/player.js +616 -0
- package/dist/thread/player/playerglobal/air/net/WebSocket.js +250 -0
- package/dist/thread/player/playerglobal/air-library.js +8 -0
- package/dist/thread/player/playerglobal/flash/accessibility/Accessibility.js +21 -0
- package/dist/thread/player/playerglobal/flash/crypto/generateRandomBytes.js +32 -0
- package/dist/thread/player/playerglobal/flash/data/EncryptedLocalStore.js +61 -0
- package/dist/thread/player/playerglobal/flash/desktop/Clipboard.js +173 -0
- package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +179 -0
- package/dist/thread/player/playerglobal/flash/display/AVM1Movie.js +19 -0
- package/dist/thread/player/playerglobal/flash/display/Bitmap.js +58 -0
- package/dist/thread/player/playerglobal/flash/display/BitmapData.js +633 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +614 -0
- package/dist/thread/player/playerglobal/flash/display/DisplayObjectContainer.js +224 -0
- package/dist/thread/player/playerglobal/flash/display/Graphics.js +345 -0
- package/dist/thread/player/playerglobal/flash/display/InteractiveObject.js +87 -0
- package/dist/thread/player/playerglobal/flash/display/Loader.js +79 -0
- package/dist/thread/player/playerglobal/flash/display/LoaderInfo.js +128 -0
- package/dist/thread/player/playerglobal/flash/display/MovieClip.js +194 -0
- package/dist/thread/player/playerglobal/flash/display/NativeWindow.js +245 -0
- package/dist/thread/player/playerglobal/flash/display/Shader.js +26 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderData.js +85 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderInput.js +64 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderJob.js +181 -0
- package/dist/thread/player/playerglobal/flash/display/ShaderParameter.js +23 -0
- package/dist/thread/player/playerglobal/flash/display/Shape.js +13 -0
- package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +103 -0
- package/dist/thread/player/playerglobal/flash/display/Sprite.js +84 -0
- package/dist/thread/player/playerglobal/flash/display/Stage.js +231 -0
- package/dist/thread/player/playerglobal/flash/display/Stage3D.js +54 -0
- package/dist/thread/player/playerglobal/flash/display/shaders.js +228 -0
- package/dist/thread/player/playerglobal/flash/events/Event.js +58 -0
- package/dist/thread/player/playerglobal/flash/events/EventDispatcher.js +103 -0
- package/dist/thread/player/playerglobal/flash/events/GestureEvent.js +34 -0
- package/dist/thread/player/playerglobal/flash/events/HTTPStatusEvent.js +8 -0
- package/dist/thread/player/playerglobal/flash/events/KeyboardEvent.js +51 -0
- package/dist/thread/player/playerglobal/flash/events/MouseEvent.js +59 -0
- package/dist/thread/player/playerglobal/flash/events/PressAndTapGestureEvent.js +30 -0
- package/dist/thread/player/playerglobal/flash/events/TimerEvent.js +16 -0
- package/dist/thread/player/playerglobal/flash/events/TouchEvent.js +45 -0
- package/dist/thread/player/playerglobal/flash/external/ExternalInterface.js +73 -0
- package/dist/thread/player/playerglobal/flash/filesystem/File.js +340 -0
- package/dist/thread/player/playerglobal/flash/filesystem/FileStream.js +453 -0
- package/dist/thread/player/playerglobal/flash/filesystem/paths.js +156 -0
- package/dist/thread/player/playerglobal/flash/filesystem/writes.js +143 -0
- package/dist/thread/player/playerglobal/flash/filters/BevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/BitmapFilter.js +205 -0
- package/dist/thread/player/playerglobal/flash/filters/BlurFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ColorMatrixFilter.js +11 -0
- package/dist/thread/player/playerglobal/flash/filters/ConvolutionFilter.js +26 -0
- package/dist/thread/player/playerglobal/flash/filters/DisplacementMapFilter.js +51 -0
- package/dist/thread/player/playerglobal/flash/filters/DropShadowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientBevelFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/GradientGlowFilter.js +4 -0
- package/dist/thread/player/playerglobal/flash/filters/ShaderFilter.js +53 -0
- package/dist/thread/player/playerglobal/flash/geom/Matrix3D.js +361 -0
- package/dist/thread/player/playerglobal/flash/geom/PerspectiveProjection.js +122 -0
- package/dist/thread/player/playerglobal/flash/geom/Transform.js +245 -0
- package/dist/thread/player/playerglobal/flash/geom/Utils3D.js +85 -0
- package/dist/thread/player/playerglobal/flash/globalization/Collator.js +149 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyFormatter.js +272 -0
- package/dist/thread/player/playerglobal/flash/globalization/CurrencyParseResult.js +21 -0
- package/dist/thread/player/playerglobal/flash/globalization/DateTimeFormatter.js +463 -0
- package/dist/thread/player/playerglobal/flash/globalization/LocaleID.js +144 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberFormatter.js +444 -0
- package/dist/thread/player/playerglobal/flash/globalization/NumberParseResult.js +22 -0
- package/dist/thread/player/playerglobal/flash/globalization/StringTools.js +59 -0
- package/dist/thread/player/playerglobal/flash/globalization/locale.js +190 -0
- package/dist/thread/player/playerglobal/flash/media/Camera.js +89 -0
- package/dist/thread/player/playerglobal/flash/media/Microphone.js +126 -0
- package/dist/thread/player/playerglobal/flash/media/Sound.js +543 -0
- package/dist/thread/player/playerglobal/flash/media/SoundMixer.js +74 -0
- package/dist/thread/player/playerglobal/flash/media/SoundTransform.js +40 -0
- package/dist/thread/player/playerglobal/flash/media/Video.js +43 -0
- package/dist/thread/player/playerglobal/flash/net/FileFilter.js +27 -0
- package/dist/thread/player/playerglobal/flash/net/FileReference.js +197 -0
- package/dist/thread/player/playerglobal/flash/net/LocalConnection.js +167 -0
- package/dist/thread/player/playerglobal/flash/net/NetConnection.js +155 -0
- package/dist/thread/player/playerglobal/flash/net/SharedObject.js +299 -0
- package/dist/thread/player/playerglobal/flash/net/Socket.js +282 -0
- package/dist/thread/player/playerglobal/flash/net/URLRequest.js +93 -0
- package/dist/thread/player/playerglobal/flash/net/URLStream.js +146 -0
- package/dist/thread/player/playerglobal/flash/net/XMLSocket.js +14 -0
- package/dist/thread/player/playerglobal/flash/net/local-modern.js +142 -0
- package/dist/thread/player/playerglobal/flash/net/local-values.js +217 -0
- package/dist/thread/player/playerglobal/flash/net/navigateToURL.js +29 -0
- package/dist/thread/player/playerglobal/flash/profiler/Telemetry.js +25 -0
- package/dist/thread/player/playerglobal/flash/sensors/Accelerometer.js +12 -0
- package/dist/thread/player/playerglobal/flash/system/ApplicationDomain.js +69 -0
- package/dist/thread/player/playerglobal/flash/system/Capabilities.js +163 -0
- package/dist/thread/player/playerglobal/flash/system/FSCommandHost.js +17 -0
- package/dist/thread/player/playerglobal/flash/system/Security.js +46 -0
- package/dist/thread/player/playerglobal/flash/system/SecurityDomain.js +21 -0
- package/dist/thread/player/playerglobal/flash/system/System.js +73 -0
- package/dist/thread/player/playerglobal/flash/system/Worker.js +112 -0
- package/dist/thread/player/playerglobal/flash/text/Font.js +95 -0
- package/dist/thread/player/playerglobal/flash/text/StaticText.js +16 -0
- package/dist/thread/player/playerglobal/flash/text/StyleSheet.js +65 -0
- package/dist/thread/player/playerglobal/flash/text/TextField.js +707 -0
- package/dist/thread/player/playerglobal/flash/text/TextRenderer.js +77 -0
- package/dist/thread/player/playerglobal/flash/text/engine/FontDescription.js +141 -0
- package/dist/thread/player/playerglobal/flash/text/engine/TabStop.js +46 -0
- package/dist/thread/player/playerglobal/flash/trace/Trace.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/ContextMenu.js +17 -0
- package/dist/thread/player/playerglobal/flash/ui/GameInput.js +19 -0
- package/dist/thread/player/playerglobal/flash/ui/Keyboard.js +27 -0
- package/dist/thread/player/playerglobal/flash/ui/Mouse.js +127 -0
- package/dist/thread/player/playerglobal/flash/ui/Multitouch.js +46 -0
- package/dist/thread/player/playerglobal/flash/utils/ByteArray.js +155 -0
- package/dist/thread/player/playerglobal/flash/utils/Timer.js +25 -0
- package/dist/thread/player/playerglobal/flash/xml/XMLDocument.js +74 -0
- package/dist/thread/player/playerglobal/index.js +224 -0
- package/dist/thread/player/playerglobal/libraries.js +10 -0
- package/dist/thread/player/playerglobal/playerglobal-library.js +22 -0
- package/dist/thread/player/playerglobal/toplevel.js +122 -0
- package/dist/thread/player/scripting/clipboard.js +146 -0
- package/dist/thread/player/scripting/code.js +900 -0
- package/dist/thread/player/scripting/evaluate.js +144 -0
- package/dist/thread/player/scripting/events.js +172 -0
- package/dist/thread/player/scripting/handover.js +182 -0
- package/dist/thread/player/scripting/lazy.js +38 -0
- package/dist/thread/player/scripting/lifecycle.js +272 -0
- package/dist/thread/player/scripting/loads.js +860 -0
- package/dist/thread/player/scripting/sha256.js +95 -0
- package/dist/thread/player/scripting/symbols.js +348 -0
- package/dist/thread/player/scripting/timers.js +434 -0
- package/dist/thread/player/scripting/workers.js +923 -0
- package/dist/thread/player/scripting.js +1018 -0
- package/dist/thread/player/stage.js +4 -0
- package/dist/thread/player/text/csm.js +113 -0
- package/dist/thread/player/text/css.js +167 -0
- package/dist/thread/player/text/fonts.js +97 -0
- package/dist/thread/player/text/layout.js +393 -0
- package/dist/thread/player/text/static.js +109 -0
- package/dist/thread/player/text/text.js +431 -0
- package/dist/thread/player/workers/thread.js +159 -0
- package/dist/thread/player/workers/wire.js +198 -0
- package/dist/thread/player-hosts/web-worker.js +19 -0
- package/dist/thread/runtime/avm1/activation.js +89 -0
- package/dist/thread/runtime/avm1/case.js +249 -0
- package/dist/thread/runtime/avm1/clips.js +334 -0
- package/dist/thread/runtime/avm1/control.js +280 -0
- package/dist/thread/runtime/avm1/errors.js +50 -0
- package/dist/thread/runtime/avm1/functions.js +249 -0
- package/dist/thread/runtime/avm1/globals/array.js +549 -0
- package/dist/thread/runtime/avm1/globals/broadcaster.js +131 -0
- package/dist/thread/runtime/avm1/globals/date.js +436 -0
- package/dist/thread/runtime/avm1/globals/global.js +344 -0
- package/dist/thread/runtime/avm1/globals/math.js +139 -0
- package/dist/thread/runtime/avm1/globals/number.js +93 -0
- package/dist/thread/runtime/avm1/globals/string.js +201 -0
- package/dist/thread/runtime/avm1/globals/timers.js +129 -0
- package/dist/thread/runtime/avm1/host.js +5 -0
- package/dist/thread/runtime/avm1/index.js +14 -0
- package/dist/thread/runtime/avm1/inheritance.js +132 -0
- package/dist/thread/runtime/avm1/numbers.js +298 -0
- package/dist/thread/runtime/avm1/objects.js +896 -0
- package/dist/thread/runtime/avm1/operators.js +170 -0
- package/dist/thread/runtime/avm1/realm.js +529 -0
- package/dist/thread/runtime/avm1/runtime.js +882 -0
- package/dist/thread/runtime/avm1/scope.js +385 -0
- package/dist/thread/runtime/avm1/urls.js +180 -0
- package/dist/thread/runtime/avm1/values.js +97 -0
- package/dist/thread/runtime/avm2/amf-classes.js +66 -0
- package/dist/thread/runtime/avm2/amf.js +801 -0
- package/dist/thread/runtime/avm2/array-conversion.js +100 -0
- package/dist/thread/runtime/avm2/builtin-library.js +21 -0
- package/dist/thread/runtime/avm2/cache-fill.js +86 -0
- package/dist/thread/runtime/avm2/classes.js +211 -0
- package/dist/thread/runtime/avm2/definitions.js +69 -0
- package/dist/thread/runtime/avm2/descriptors.js +5 -0
- package/dist/thread/runtime/avm2/dictionary-keys.js +295 -0
- package/dist/thread/runtime/avm2/domain-memory.js +75 -0
- package/dist/thread/runtime/avm2/domain.js +280 -0
- package/dist/thread/runtime/avm2/dynamic-properties.js +182 -0
- package/dist/thread/runtime/avm2/enumeration.js +393 -0
- package/dist/thread/runtime/avm2/errors.js +45 -0
- package/dist/thread/runtime/avm2/float-library.js +66 -0
- package/dist/thread/runtime/avm2/float.js +26 -0
- package/dist/thread/runtime/avm2/hooks.js +19 -0
- package/dist/thread/runtime/avm2/index.js +38 -0
- package/dist/thread/runtime/avm2/messages.js +177 -0
- package/dist/thread/runtime/avm2/method-factories.js +95 -0
- package/dist/thread/runtime/avm2/modules.js +105 -0
- package/dist/thread/runtime/avm2/names.js +248 -0
- package/dist/thread/runtime/avm2/natives/aliases.js +47 -0
- package/dist/thread/runtime/avm2/natives/array.js +390 -0
- package/dist/thread/runtime/avm2/natives/bytearray.js +1227 -0
- package/dist/thread/runtime/avm2/natives/case.js +88 -0
- package/dist/thread/runtime/avm2/natives/concurrent.js +199 -0
- package/dist/thread/runtime/avm2/natives/date.js +581 -0
- package/dist/thread/runtime/avm2/natives/define.js +130 -0
- package/dist/thread/runtime/avm2/natives/describe.js +351 -0
- package/dist/thread/runtime/avm2/natives/dictionary.js +12 -0
- package/dist/thread/runtime/avm2/natives/float-vector.js +81 -0
- package/dist/thread/runtime/avm2/natives/float.js +96 -0
- package/dist/thread/runtime/avm2/natives/index.js +64 -0
- package/dist/thread/runtime/avm2/natives/json.js +514 -0
- package/dist/thread/runtime/avm2/natives/number.js +162 -0
- package/dist/thread/runtime/avm2/natives/object.js +237 -0
- package/dist/thread/runtime/avm2/natives/proxy.js +75 -0
- package/dist/thread/runtime/avm2/natives/regexp.js +485 -0
- package/dist/thread/runtime/avm2/natives/shell-workers.js +404 -0
- package/dist/thread/runtime/avm2/natives/shell.js +557 -0
- package/dist/thread/runtime/avm2/natives/sort.js +377 -0
- package/dist/thread/runtime/avm2/natives/string.js +132 -0
- package/dist/thread/runtime/avm2/natives/sync.js +821 -0
- package/dist/thread/runtime/avm2/natives/toplevel.js +139 -0
- package/dist/thread/runtime/avm2/natives/vector-elements.js +46 -0
- package/dist/thread/runtime/avm2/natives/vector.js +406 -0
- package/dist/thread/runtime/avm2/natives/xml/access.js +633 -0
- package/dist/thread/runtime/avm2/natives/xml/build.js +291 -0
- package/dist/thread/runtime/avm2/natives/xml/chars.js +112 -0
- package/dist/thread/runtime/avm2/natives/xml/escape.js +38 -0
- package/dist/thread/runtime/avm2/natives/xml/names.js +204 -0
- package/dist/thread/runtime/avm2/natives/xml/node.js +272 -0
- package/dist/thread/runtime/avm2/natives/xml/operators.js +69 -0
- package/dist/thread/runtime/avm2/natives/xml/parser.js +356 -0
- package/dist/thread/runtime/avm2/natives/xml/strings.js +191 -0
- package/dist/thread/runtime/avm2/natives/xml/values.js +122 -0
- package/dist/thread/runtime/avm2/natives/xml/xml.js +645 -0
- package/dist/thread/runtime/avm2/number-strings.js +110 -0
- package/dist/thread/runtime/avm2/numbers.js +558 -0
- package/dist/thread/runtime/avm2/options.js +16 -0
- package/dist/thread/runtime/avm2/player-messages.js +550 -0
- package/dist/thread/runtime/avm2/property-cache.js +135 -0
- package/dist/thread/runtime/avm2/runtime.js +2644 -0
- package/dist/thread/runtime/avm2/traits.js +509 -0
- package/dist/thread/runtime/index.js +7 -0
- package/dist/web-worker.d.ts +2 -0
- package/dist/web-worker.d.ts.map +1 -0
- package/dist/web-worker.js +20 -0
- package/dist/web-worker.js.map +1 -0
- package/dist/websocket.d.ts +4 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +27 -0
- package/dist/websocket.js.map +1 -0
- package/dist/workers.d.ts +35 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +171 -0
- package/dist/workers.js.map +1 -0
- package/package.json +62 -3
- package/src/indexeddb.ts +227 -0
- package/src/node-worker.ts +13 -0
- package/src/node.ts +49 -0
- package/src/precompiled.ts +166 -0
- package/src/stage3d.ts +76 -0
- package/src/web-worker.ts +24 -0
- package/src/websocket.ts +32 -0
- package/src/workers.ts +255 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
// flash.filesystem.FileStream over the host's FileSystemHost (hosts.ts),
|
|
2
|
+
// as adl (AIR 51.3, Windows) has it. A stream holds its file's bytes in a
|
|
3
|
+
// ByteArray, whose DataInput and DataOutput it reads and writes with, as
|
|
4
|
+
// URLStream's does. READ reads the file; WRITE empties it or makes it;
|
|
5
|
+
// APPEND writes only at its end, whose position cannot be set; UPDATE
|
|
6
|
+
// reads and writes it, from its start. WRITE and APPEND read nothing, nor
|
|
7
|
+
// tell bytesAvailable (IOError 2029, as a stream not open, and READ's
|
|
8
|
+
// writes and truncate). The modes that write make the file, and the
|
|
9
|
+
// directories it is in. What is written reaches the file as adl's does,
|
|
10
|
+
// at the end of the frame and at close, and a write to a file of the
|
|
11
|
+
// app: URL is a SecurityError. open does all this at once and throws its
|
|
12
|
+
// errors; openAsync does it on the next frame and reports them as an
|
|
13
|
+
// ioError event, then hands a file being read over a 40960-byte chunk a
|
|
14
|
+
// frame, each with a progress event, and complete (READ and UPDATE), and
|
|
15
|
+
// tells what it wrote with outputProgress, as adl's do. A missing file is
|
|
16
|
+
// IOError 3003 to read, a directory 3006, and a directory a file in the
|
|
17
|
+
// way 3003 to write. Windows' AIR also refuses to open a file another
|
|
18
|
+
// stream has open to write (IOError 3013), which macOS' does not; nor
|
|
19
|
+
// does this.
|
|
20
|
+
import { avm2 } from "../../../../runtime/index.js";
|
|
21
|
+
import { dispatchEvent } from "../../../scripting/events.js";
|
|
22
|
+
import { fileLocation } from "./File.js";
|
|
23
|
+
import { ioErrorEvent, openRefusal, refuseApp, writeFile } from "./writes.js";
|
|
24
|
+
/** How much of an asynchronously opened file a frame hands over, as adl's reads do. */
|
|
25
|
+
const CHUNK = 40960;
|
|
26
|
+
const MODES = ["read", "write", "append", "update"];
|
|
27
|
+
const EMPTY = new Uint8Array(0);
|
|
28
|
+
export function fileStreamNatives(s) {
|
|
29
|
+
const natives = {};
|
|
30
|
+
const host = s.fileSystem;
|
|
31
|
+
const notOpen = () => {
|
|
32
|
+
throw s.rt.error("flash.errors::IOError", 2029);
|
|
33
|
+
};
|
|
34
|
+
/** The open stream's buffer; IOError 2029 for one not open. */
|
|
35
|
+
const opened = (stream) => stream.$buffer ?? notOpen();
|
|
36
|
+
/** The buffer of a stream that reads; IOError 2029 for one not open or in WRITE or APPEND mode. */
|
|
37
|
+
const reading = (stream) => {
|
|
38
|
+
const buffer = opened(stream);
|
|
39
|
+
return stream.$mode === "write" || stream.$mode === "append" ? notOpen() : buffer;
|
|
40
|
+
};
|
|
41
|
+
/** The buffer of a stream that writes; IOError 2029 for one not open or in READ mode. */
|
|
42
|
+
const writing = (stream) => {
|
|
43
|
+
const buffer = opened(stream);
|
|
44
|
+
return stream.$mode === "read" ? notOpen() : buffer;
|
|
45
|
+
};
|
|
46
|
+
const read = (stream, method, ...args) => s.rt.callProperty(reading(stream), s.rt.publicName(method), ...args);
|
|
47
|
+
const write = (stream, method, ...args) => {
|
|
48
|
+
const bytes = avm2.bytesOf(s.rt, writing(stream));
|
|
49
|
+
// A write past the end leaves zeros before it, which the file, made as long, has too.
|
|
50
|
+
const from = bytes.position;
|
|
51
|
+
s.rt.callProperty(stream.$buffer, s.rt.publicName(method), ...args);
|
|
52
|
+
stream.$written = (stream.$written ?? 0) + (bytes.position - from);
|
|
53
|
+
changed(stream, from, bytes.position);
|
|
54
|
+
};
|
|
55
|
+
const event = (stream, e) => dispatchEvent(s, stream, e);
|
|
56
|
+
const outputProgress = (stream) => event(stream, s.rt.construct(s.rt.classNamed("flash.events::OutputProgressEvent"), "outputProgress", false, false, 0, stream.$written ?? 0));
|
|
57
|
+
/** Marks `from` to `to` of `stream`'s bytes, and its length, for the file, at the end of the frame. */
|
|
58
|
+
const changed = (stream, from, to) => {
|
|
59
|
+
stream.$from = Math.min(stream.$from ?? from, from);
|
|
60
|
+
stream.$to = Math.max(stream.$to ?? to, to);
|
|
61
|
+
if (stream.$flushing) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
stream.$flushing = true;
|
|
65
|
+
const generation = stream.$generation;
|
|
66
|
+
s.loads.deferHostEvent(() => {
|
|
67
|
+
// An open since has its own.
|
|
68
|
+
if (stream.$generation !== generation) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
stream.$flushing = false;
|
|
72
|
+
if (flush(stream) && stream.$async) {
|
|
73
|
+
outputProgress(stream);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
/** What `stream` changed, given to its file: whether there was any. */
|
|
78
|
+
const flush = (stream) => {
|
|
79
|
+
if (stream.$from === undefined || !stream.$buffer || !stream.$made) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const bytes = avm2.bytesOf(s.rt, stream.$buffer);
|
|
83
|
+
const from = Math.min(stream.$from, bytes.length);
|
|
84
|
+
const to = Math.max(from, Math.min(stream.$to ?? from, bytes.length));
|
|
85
|
+
stream.$from = undefined;
|
|
86
|
+
stream.$to = undefined;
|
|
87
|
+
writeFile(s, stream.$path, bytes.buffer.subarray(from, to), from, bytes.length);
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The native path of `file` and its mode, or why it cannot be opened in
|
|
92
|
+
* it: what open and openAsync throw at once (no File, no path, no such
|
|
93
|
+
* mode, a mode that writes a file of the app: URL).
|
|
94
|
+
*/
|
|
95
|
+
const target = (file, mode) => {
|
|
96
|
+
if (file === null || file === undefined) {
|
|
97
|
+
throw s.rt.error("TypeError", 2007, "file");
|
|
98
|
+
}
|
|
99
|
+
const at = fileLocation(file);
|
|
100
|
+
if (!at) {
|
|
101
|
+
throw s.rt.error("flash.errors::IllegalOperationError", 2037);
|
|
102
|
+
}
|
|
103
|
+
const named = s.rt.toString(mode);
|
|
104
|
+
if (!MODES.includes(named)) {
|
|
105
|
+
throw s.rt.error("ArgumentError", 2004);
|
|
106
|
+
}
|
|
107
|
+
if (named !== "read") {
|
|
108
|
+
refuseApp(s, at);
|
|
109
|
+
}
|
|
110
|
+
return { path: at.path, mode: named };
|
|
111
|
+
};
|
|
112
|
+
/** What a READ finds at `path`: 3003 for nothing there, 3006 for a directory, or the bytes. */
|
|
113
|
+
const contents = (path) => {
|
|
114
|
+
const stat = host?.stat(path);
|
|
115
|
+
if (!stat) {
|
|
116
|
+
return 3003;
|
|
117
|
+
}
|
|
118
|
+
if (stat.directory) {
|
|
119
|
+
return 3006;
|
|
120
|
+
}
|
|
121
|
+
return host?.read?.(path) ?? 3003;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Makes the file at `path` for `mode`, which writes: emptied for WRITE,
|
|
125
|
+
* as it was for the others, there now. The IOError why it cannot be, or
|
|
126
|
+
* what it held before.
|
|
127
|
+
*/
|
|
128
|
+
const make = (path, mode) => {
|
|
129
|
+
const refusal = openRefusal(s, path);
|
|
130
|
+
if (refusal) {
|
|
131
|
+
return refusal;
|
|
132
|
+
}
|
|
133
|
+
// A file there that cannot be read is not emptied by a mode that keeps it.
|
|
134
|
+
const there = !!host?.stat(path);
|
|
135
|
+
const before = mode === "write" || !there ? EMPTY : host?.read?.(path);
|
|
136
|
+
if (!before) {
|
|
137
|
+
return 3001;
|
|
138
|
+
}
|
|
139
|
+
return writeFile(s, path, EMPTY, before.length, before.length) ? before : 3001;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* A new buffer for `stream`, empty, with its endian and object encoding,
|
|
143
|
+
* open on `path` in `mode`, in place of any open one, which has given its
|
|
144
|
+
* file what it wrote.
|
|
145
|
+
*/
|
|
146
|
+
const reopen = (stream, async, path, mode) => {
|
|
147
|
+
flush(stream);
|
|
148
|
+
stream.$generation = (stream.$generation ?? 0) + 1;
|
|
149
|
+
const buffer = s.rt.construct(s.rt.classNamed("flash.utils::ByteArray"));
|
|
150
|
+
s.rt.setProperty(buffer, s.rt.publicName("endian"), stream.$endian ?? "bigEndian");
|
|
151
|
+
s.rt.setProperty(buffer, s.rt.publicName("objectEncoding"), stream.$objectEncoding ?? 3);
|
|
152
|
+
stream.$buffer = buffer;
|
|
153
|
+
stream.$async = async;
|
|
154
|
+
stream.$path = path;
|
|
155
|
+
stream.$mode = mode;
|
|
156
|
+
stream.$made = !async;
|
|
157
|
+
stream.$from = undefined;
|
|
158
|
+
stream.$to = undefined;
|
|
159
|
+
stream.$flushing = false;
|
|
160
|
+
stream.$written = 0;
|
|
161
|
+
return buffer;
|
|
162
|
+
};
|
|
163
|
+
/** Closes `stream`, what it wrote given to its file, and stops what its open had yet to do. */
|
|
164
|
+
const shut = (stream) => {
|
|
165
|
+
const wrote = flush(stream);
|
|
166
|
+
stream.$buffer = null;
|
|
167
|
+
stream.$generation = (stream.$generation ?? 0) + 1;
|
|
168
|
+
return wrote;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Puts `bytes`, the file's from `at`, in the buffer of `stream`, its
|
|
172
|
+
* position kept: but where the stream wrote before the file was read in,
|
|
173
|
+
* what it wrote stands.
|
|
174
|
+
*/
|
|
175
|
+
const merge = (stream, bytes, at) => {
|
|
176
|
+
const into = avm2.bytesOf(s.rt, stream.$buffer);
|
|
177
|
+
const position = into.position;
|
|
178
|
+
const from = Math.max(at, stream.$from ?? Number.POSITIVE_INFINITY);
|
|
179
|
+
const to = Math.min(at + bytes.length, stream.$to ?? 0, into.length);
|
|
180
|
+
const written = from < to ? into.buffer.slice(from, to) : null;
|
|
181
|
+
into.position = at;
|
|
182
|
+
into.write(bytes);
|
|
183
|
+
if (written) {
|
|
184
|
+
into.position = from;
|
|
185
|
+
into.write(written);
|
|
186
|
+
}
|
|
187
|
+
into.position = position;
|
|
188
|
+
};
|
|
189
|
+
/** Puts `bytes` in the buffer of `stream`, its position at their start, or for APPEND their end. */
|
|
190
|
+
const fill = (stream, bytes) => {
|
|
191
|
+
const into = avm2.bytesOf(s.rt, stream.$buffer);
|
|
192
|
+
into.write(bytes);
|
|
193
|
+
into.position = stream.$mode === "append" ? into.length : 0;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Hands `bytes` to `stream` a chunk a frame, each in its place with a
|
|
197
|
+
* progress event, then complete, while the open of `generation` lasts;
|
|
198
|
+
* `done` before complete.
|
|
199
|
+
*/
|
|
200
|
+
const deliver = (stream, bytes, generation, done) => {
|
|
201
|
+
const current = () => stream.$generation === generation;
|
|
202
|
+
let loaded = 0;
|
|
203
|
+
const next = () => {
|
|
204
|
+
if (!current()) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const end = Math.min(loaded + CHUNK, bytes.length);
|
|
208
|
+
merge(stream, bytes.subarray(loaded, end), loaded);
|
|
209
|
+
loaded = end;
|
|
210
|
+
event(stream, s.rt.construct(s.rt.classNamed("flash.events::ProgressEvent"), "progress", false, false, loaded, bytes.length));
|
|
211
|
+
if (!current()) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (loaded < bytes.length) {
|
|
215
|
+
s.loads.deferHostEvent(next);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
done();
|
|
219
|
+
event(stream, s.event("complete"));
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
s.loads.deferHostEvent(next);
|
|
223
|
+
};
|
|
224
|
+
class FileStreamNatives {
|
|
225
|
+
open(file, mode) {
|
|
226
|
+
const at = target(file, mode);
|
|
227
|
+
const bytes = at.mode === "read" ? contents(at.path) : make(at.path, at.mode);
|
|
228
|
+
if (typeof bytes === "number") {
|
|
229
|
+
shut(this);
|
|
230
|
+
throw s.rt.error("flash.errors::IOError", bytes);
|
|
231
|
+
}
|
|
232
|
+
reopen(this, false, at.path, at.mode);
|
|
233
|
+
fill(this, bytes);
|
|
234
|
+
}
|
|
235
|
+
openAsync(file, mode) {
|
|
236
|
+
const at = target(file, mode);
|
|
237
|
+
reopen(this, true, at.path, at.mode);
|
|
238
|
+
const generation = this.$generation;
|
|
239
|
+
const failed = (id) => {
|
|
240
|
+
shut(this);
|
|
241
|
+
event(this, ioErrorEvent(s, id, ` file: ${at.path}`));
|
|
242
|
+
};
|
|
243
|
+
if (at.mode === "read") {
|
|
244
|
+
const bytes = contents(at.path);
|
|
245
|
+
s.loads.deferHostEvent(() => {
|
|
246
|
+
if (this.$generation !== generation) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (typeof bytes === "number") {
|
|
250
|
+
failed(bytes);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
deliver(this, bytes, generation, () => { });
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
// APPEND's position is the file's end at once; WRITE's and APPEND's bytes are not read.
|
|
259
|
+
if (at.mode === "append") {
|
|
260
|
+
fill(this, host?.read?.(at.path) ?? EMPTY);
|
|
261
|
+
}
|
|
262
|
+
s.loads.deferHostEvent(() => {
|
|
263
|
+
if (this.$generation !== generation) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const made = make(at.path, at.mode);
|
|
267
|
+
if (typeof made === "number") {
|
|
268
|
+
failed(made);
|
|
269
|
+
}
|
|
270
|
+
else if (at.mode === "update") {
|
|
271
|
+
deliver(this, made, generation, () => {
|
|
272
|
+
this.$made = true;
|
|
273
|
+
if (flush(this)) {
|
|
274
|
+
outputProgress(this);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
this.$made = true;
|
|
280
|
+
if (flush(this)) {
|
|
281
|
+
outputProgress(this);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
close() {
|
|
287
|
+
if (!this.$buffer) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
// A file an asynchronous open had yet to make, or to read in, is made
|
|
291
|
+
// now to take what was written, around what it held.
|
|
292
|
+
if (!this.$made && this.$mode !== "read") {
|
|
293
|
+
const before = make(this.$path, this.$mode);
|
|
294
|
+
if (typeof before !== "number") {
|
|
295
|
+
if (this.$mode === "update") {
|
|
296
|
+
merge(this, before, 0);
|
|
297
|
+
}
|
|
298
|
+
this.$made = true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const wrote = shut(this);
|
|
302
|
+
// An asynchronous stream says so on a later frame; a synchronous one says nothing.
|
|
303
|
+
if (this.$async) {
|
|
304
|
+
const generation = this.$generation;
|
|
305
|
+
s.loads.deferHostEvent(() => {
|
|
306
|
+
if (this.$generation === generation) {
|
|
307
|
+
if (wrote) {
|
|
308
|
+
outputProgress(this);
|
|
309
|
+
}
|
|
310
|
+
event(this, s.event("close"));
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
truncate() {
|
|
316
|
+
const buffer = writing(this);
|
|
317
|
+
const bytes = avm2.bytesOf(s.rt, buffer);
|
|
318
|
+
const at = bytes.position;
|
|
319
|
+
s.rt.setProperty(buffer, s.rt.publicName("length"), at);
|
|
320
|
+
changed(this, at, at);
|
|
321
|
+
// The file is cut at once, as adl's is, with what was written before.
|
|
322
|
+
flush(this);
|
|
323
|
+
}
|
|
324
|
+
get position() {
|
|
325
|
+
return avm2.bytesOf(s.rt, opened(this)).position;
|
|
326
|
+
}
|
|
327
|
+
set position(value) {
|
|
328
|
+
const bytes = avm2.bytesOf(s.rt, opened(this));
|
|
329
|
+
// APPEND writes at the end alone.
|
|
330
|
+
if (this.$mode === "append") {
|
|
331
|
+
throw s.rt.error("flash.errors::IllegalOperationError", 2037);
|
|
332
|
+
}
|
|
333
|
+
// As ByteArray's setter: a uint32 of its own, not toUint's (see Bytes).
|
|
334
|
+
bytes.position = s.rt.toUint(value) >>> 0;
|
|
335
|
+
}
|
|
336
|
+
get bytesAvailable() {
|
|
337
|
+
return avm2.bytesOf(s.rt, reading(this)).available;
|
|
338
|
+
}
|
|
339
|
+
get readAhead() {
|
|
340
|
+
return this.$readAhead ?? Number.POSITIVE_INFINITY;
|
|
341
|
+
}
|
|
342
|
+
set readAhead(value) {
|
|
343
|
+
this.$readAhead = s.rt.toNumber(value);
|
|
344
|
+
}
|
|
345
|
+
get endian() {
|
|
346
|
+
return this.$buffer
|
|
347
|
+
? s.rt.getProperty(this.$buffer, s.rt.publicName("endian"))
|
|
348
|
+
: (this.$endian ?? "bigEndian");
|
|
349
|
+
}
|
|
350
|
+
set endian(value) {
|
|
351
|
+
// The buffer's setter checks it; the stream keeps it for the files it opens next.
|
|
352
|
+
if (this.$buffer) {
|
|
353
|
+
s.rt.setProperty(this.$buffer, s.rt.publicName("endian"), value);
|
|
354
|
+
}
|
|
355
|
+
this.$endian = this.$buffer
|
|
356
|
+
? s.rt.getProperty(this.$buffer, s.rt.publicName("endian"))
|
|
357
|
+
: value;
|
|
358
|
+
}
|
|
359
|
+
get objectEncoding() {
|
|
360
|
+
return this.$buffer
|
|
361
|
+
? s.rt.getProperty(this.$buffer, s.rt.publicName("objectEncoding"))
|
|
362
|
+
: (this.$objectEncoding ?? 3);
|
|
363
|
+
}
|
|
364
|
+
set objectEncoding(value) {
|
|
365
|
+
if (this.$buffer) {
|
|
366
|
+
s.rt.setProperty(this.$buffer, s.rt.publicName("objectEncoding"), value);
|
|
367
|
+
}
|
|
368
|
+
this.$objectEncoding = this.$buffer
|
|
369
|
+
? s.rt.getProperty(this.$buffer, s.rt.publicName("objectEncoding"))
|
|
370
|
+
: value;
|
|
371
|
+
}
|
|
372
|
+
readBytes(bytes, offset = 0, length = 0) {
|
|
373
|
+
read(this, "readBytes", bytes, offset, length);
|
|
374
|
+
}
|
|
375
|
+
readBoolean() {
|
|
376
|
+
return read(this, "readBoolean");
|
|
377
|
+
}
|
|
378
|
+
readByte() {
|
|
379
|
+
return read(this, "readByte");
|
|
380
|
+
}
|
|
381
|
+
readUnsignedByte() {
|
|
382
|
+
return read(this, "readUnsignedByte");
|
|
383
|
+
}
|
|
384
|
+
readShort() {
|
|
385
|
+
return read(this, "readShort");
|
|
386
|
+
}
|
|
387
|
+
readUnsignedShort() {
|
|
388
|
+
return read(this, "readUnsignedShort");
|
|
389
|
+
}
|
|
390
|
+
readInt() {
|
|
391
|
+
return read(this, "readInt");
|
|
392
|
+
}
|
|
393
|
+
readUnsignedInt() {
|
|
394
|
+
return read(this, "readUnsignedInt");
|
|
395
|
+
}
|
|
396
|
+
readFloat() {
|
|
397
|
+
return read(this, "readFloat");
|
|
398
|
+
}
|
|
399
|
+
readDouble() {
|
|
400
|
+
return read(this, "readDouble");
|
|
401
|
+
}
|
|
402
|
+
readUTF() {
|
|
403
|
+
return read(this, "readUTF");
|
|
404
|
+
}
|
|
405
|
+
readUTFBytes(length) {
|
|
406
|
+
return read(this, "readUTFBytes", length);
|
|
407
|
+
}
|
|
408
|
+
readMultiByte(length, charset) {
|
|
409
|
+
return read(this, "readMultiByte", length, charset);
|
|
410
|
+
}
|
|
411
|
+
readObject() {
|
|
412
|
+
return read(this, "readObject");
|
|
413
|
+
}
|
|
414
|
+
writeBoolean(...args) {
|
|
415
|
+
write(this, "writeBoolean", ...args);
|
|
416
|
+
}
|
|
417
|
+
writeByte(...args) {
|
|
418
|
+
write(this, "writeByte", ...args);
|
|
419
|
+
}
|
|
420
|
+
writeBytes(...args) {
|
|
421
|
+
write(this, "writeBytes", ...args);
|
|
422
|
+
}
|
|
423
|
+
writeDouble(...args) {
|
|
424
|
+
write(this, "writeDouble", ...args);
|
|
425
|
+
}
|
|
426
|
+
writeFloat(...args) {
|
|
427
|
+
write(this, "writeFloat", ...args);
|
|
428
|
+
}
|
|
429
|
+
writeInt(...args) {
|
|
430
|
+
write(this, "writeInt", ...args);
|
|
431
|
+
}
|
|
432
|
+
writeMultiByte(...args) {
|
|
433
|
+
write(this, "writeMultiByte", ...args);
|
|
434
|
+
}
|
|
435
|
+
writeObject(...args) {
|
|
436
|
+
write(this, "writeObject", ...args);
|
|
437
|
+
}
|
|
438
|
+
writeShort(...args) {
|
|
439
|
+
write(this, "writeShort", ...args);
|
|
440
|
+
}
|
|
441
|
+
writeUnsignedInt(...args) {
|
|
442
|
+
write(this, "writeUnsignedInt", ...args);
|
|
443
|
+
}
|
|
444
|
+
writeUTF(...args) {
|
|
445
|
+
write(this, "writeUTF", ...args);
|
|
446
|
+
}
|
|
447
|
+
writeUTFBytes(...args) {
|
|
448
|
+
write(this, "writeUTFBytes", ...args);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
avm2.registerNativeClass(natives, "flash.filesystem::FileStream", FileStreamNatives);
|
|
452
|
+
return natives;
|
|
453
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// flash.filesystem.File's paths as AIR has them: native paths of the
|
|
2
|
+
// host's system, POSIX or Windows by its separator, absolute alone, and
|
|
3
|
+
// the URLs that name them: file: for any, app: and app-storage: for those
|
|
4
|
+
// under the application's directory and its storage. A URL encodes each
|
|
5
|
+
// segment of the path as UTF-8, as adl does (a space as %20, "#" as %23).
|
|
6
|
+
export class NativePaths {
|
|
7
|
+
separator;
|
|
8
|
+
constructor(
|
|
9
|
+
/** The host's separator: "/", or "\\" on Windows. */
|
|
10
|
+
separator) {
|
|
11
|
+
this.separator = separator;
|
|
12
|
+
}
|
|
13
|
+
get windows() {
|
|
14
|
+
return this.separator === "\\";
|
|
15
|
+
}
|
|
16
|
+
/** A path's root and the segments under it; null where it is not absolute. */
|
|
17
|
+
split(path) {
|
|
18
|
+
if (this.windows) {
|
|
19
|
+
const drive = /^([A-Za-z]:)[\\/]?/.exec(path);
|
|
20
|
+
if (drive) {
|
|
21
|
+
return {
|
|
22
|
+
root: `${drive[1].toUpperCase()}\\`,
|
|
23
|
+
segments: this.segments(path.slice(drive[0].length)),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const unc = /^[\\/]{2}([^\\/]+)[\\/]+([^\\/]+)[\\/]?/.exec(path);
|
|
27
|
+
return unc
|
|
28
|
+
? { root: `\\\\${unc[1]}\\${unc[2]}\\`, segments: this.segments(path.slice(unc[0].length)) }
|
|
29
|
+
: null;
|
|
30
|
+
}
|
|
31
|
+
return path.startsWith("/") ? { root: "/", segments: this.segments(path.slice(1)) } : null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `rest`'s segments after `under`'s, its "." left out and each ".."
|
|
35
|
+
* taking the one before, but none of the first `floor`.
|
|
36
|
+
*/
|
|
37
|
+
segments(rest, under = [], floor = 0) {
|
|
38
|
+
const out = [...under];
|
|
39
|
+
for (const segment of rest.split(this.windows ? /[\\/]/ : "/")) {
|
|
40
|
+
if (segment === "" || segment === ".") {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (segment === "..") {
|
|
44
|
+
if (out.length > floor) {
|
|
45
|
+
out.pop();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
out.push(segment);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
isAbsolute(path) {
|
|
55
|
+
return this.split(path) !== null;
|
|
56
|
+
}
|
|
57
|
+
/** An absolute path in its plain form: one separator between segments, no "." or "..". */
|
|
58
|
+
normalize(path) {
|
|
59
|
+
const parts = this.split(path);
|
|
60
|
+
return parts ? parts.root + parts.segments.join(this.separator) : null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `relative` resolved against `base`, an absolute path: an absolute
|
|
64
|
+
* `relative` stands alone; a relative one never goes above `floor`,
|
|
65
|
+
* where the File's URL starts, as adl keeps app:/'s ".." at app:/.
|
|
66
|
+
*/
|
|
67
|
+
resolve(base, relative, floor) {
|
|
68
|
+
if (this.isAbsolute(relative)) {
|
|
69
|
+
return this.normalize(relative);
|
|
70
|
+
}
|
|
71
|
+
const parts = this.split(base);
|
|
72
|
+
// A path never climbs out of app:/ or app-storage:/.
|
|
73
|
+
const depth = floor ? (this.split(floor)?.segments.length ?? 0) : 0;
|
|
74
|
+
return parts.root + this.segments(relative, parts.segments, depth).join(this.separator);
|
|
75
|
+
}
|
|
76
|
+
/** The directory `path` is in; null for a root. */
|
|
77
|
+
parent(path) {
|
|
78
|
+
const parts = this.split(path);
|
|
79
|
+
if (!parts || parts.segments.length === 0) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return parts.root + parts.segments.slice(0, -1).join(this.separator);
|
|
83
|
+
}
|
|
84
|
+
/** Its last segment, or for a root the root. */
|
|
85
|
+
name(path) {
|
|
86
|
+
const parts = this.split(path);
|
|
87
|
+
return parts && parts.segments.length > 0 ? parts.segments.at(-1) : path;
|
|
88
|
+
}
|
|
89
|
+
/** `path`'s segments under `under`, an ancestor or itself; null where it is not under it. */
|
|
90
|
+
under(path, under) {
|
|
91
|
+
const a = this.split(path);
|
|
92
|
+
const b = this.split(under);
|
|
93
|
+
if (!a || !b || !this.same(a.root, b.root) || a.segments.length < b.segments.length) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
for (let i = 0; i < b.segments.length; i++) {
|
|
97
|
+
if (!this.same(a.segments[i], b.segments[i])) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return a.segments.slice(b.segments.length);
|
|
102
|
+
}
|
|
103
|
+
/** Whether two names are one, as Windows' file system takes letters' case as one. */
|
|
104
|
+
same(a, b) {
|
|
105
|
+
return this.windows ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
106
|
+
}
|
|
107
|
+
/** `path`'s file: URL, its segments encoded. */
|
|
108
|
+
fileUrl(path) {
|
|
109
|
+
const parts = this.split(path);
|
|
110
|
+
const encoded = parts.segments.map(encodeSegment).join("/");
|
|
111
|
+
if (this.windows) {
|
|
112
|
+
// file:///Z:/... for a drive, file://server/share/... for a share.
|
|
113
|
+
const unc = /^\\\\([^\\]+)\\([^\\]+)\\$/.exec(parts.root);
|
|
114
|
+
const head = unc
|
|
115
|
+
? `file://${unc[1]}/${encodeSegment(unc[2])}/`
|
|
116
|
+
: `file:///${parts.root.slice(0, 2)}/`;
|
|
117
|
+
return head + encoded;
|
|
118
|
+
}
|
|
119
|
+
return `file:///${encoded}`;
|
|
120
|
+
}
|
|
121
|
+
/** The native path of a file: URL; null where it names none. */
|
|
122
|
+
fromFileUrl(url) {
|
|
123
|
+
const m = /^file:\/\/([^/]*)(\/.*)?$/i.exec(url);
|
|
124
|
+
if (!m) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
let decoded;
|
|
128
|
+
try {
|
|
129
|
+
decoded = decodeURIComponent(m[2] ?? "/");
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (this.windows) {
|
|
135
|
+
const path = m[1] ? `\\\\${m[1]}${decoded}` : decoded.replace(/^\/([A-Za-z]:)/, "$1");
|
|
136
|
+
return this.normalize(path.replaceAll("/", "\\"));
|
|
137
|
+
}
|
|
138
|
+
return m[1] ? null : this.normalize(decoded);
|
|
139
|
+
}
|
|
140
|
+
/** The segments of a URL's path under its root, decoded; null where one does not decode. */
|
|
141
|
+
urlSegments(rest) {
|
|
142
|
+
try {
|
|
143
|
+
return rest
|
|
144
|
+
.split("/")
|
|
145
|
+
.filter((s) => s !== "" && s !== ".")
|
|
146
|
+
.map(decodeURIComponent);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** A path segment in a URL: UTF-8, percent-encoded as adl writes them ("#?%" and spaces among them). */
|
|
154
|
+
export function encodeSegment(segment) {
|
|
155
|
+
return encodeURIComponent(segment);
|
|
156
|
+
}
|