@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,404 @@
|
|
|
1
|
+
// avmshell's workers, as avmplus' Aggregate and Isolate keep them: each
|
|
2
|
+
// worker's state, parent and shared properties in memory every thread
|
|
3
|
+
// sees, so that a worker's state and what another worker set are seen at
|
|
4
|
+
// once, while the primordial spins in System.sleep. The memory is a
|
|
5
|
+
// SharedArrayBuffer where there is one, as node always has; elsewhere an
|
|
6
|
+
// ArrayBuffer, and there are no other threads to start.
|
|
7
|
+
//
|
|
8
|
+
// The host starts the threads (RuntimeOptions.workers); each runs a
|
|
9
|
+
// runtime made with its worker's ShellWorkerInit, which the runtime finds
|
|
10
|
+
// here by its id.
|
|
11
|
+
import { fromUtf8, utf8 } from "./bytearray.js";
|
|
12
|
+
import { Sync } from "./sync.js";
|
|
13
|
+
/** avmplus' Isolate::State. */
|
|
14
|
+
export const NEW = 1;
|
|
15
|
+
export const CANSTART = 2;
|
|
16
|
+
export const STARTING = 3;
|
|
17
|
+
export const RUNNING = 4;
|
|
18
|
+
export const FINISHING = 5;
|
|
19
|
+
export const TERMINATED = 6;
|
|
20
|
+
export const FAILED = 7;
|
|
21
|
+
export const ABORTED = 8;
|
|
22
|
+
export const EXCEPTION = 9;
|
|
23
|
+
/** Worker.state's names for each, as WorkerObjectBase::get_state reports them. */
|
|
24
|
+
export const STATE_NAMES = [
|
|
25
|
+
"",
|
|
26
|
+
"new",
|
|
27
|
+
"new",
|
|
28
|
+
"new",
|
|
29
|
+
"running",
|
|
30
|
+
"running",
|
|
31
|
+
"terminated",
|
|
32
|
+
"failed",
|
|
33
|
+
"aborted",
|
|
34
|
+
"exception",
|
|
35
|
+
];
|
|
36
|
+
// The control memory's words: the table's lock, the workers made, the
|
|
37
|
+
// table's version and the next item token; then each worker's state and
|
|
38
|
+
// parent, two words a worker.
|
|
39
|
+
const LOCK = 0;
|
|
40
|
+
const COUNT = 1;
|
|
41
|
+
const VERSION = 2;
|
|
42
|
+
const TOKEN = 3;
|
|
43
|
+
const WORKERS = 4;
|
|
44
|
+
const CONTROL_MAX = 16 << 20;
|
|
45
|
+
const TABLE_MAX = 256 << 20;
|
|
46
|
+
/**
|
|
47
|
+
* How a shared property is kept: AMF3, a ByteArray's bytes, a Mutex or a
|
|
48
|
+
* Condition by its address in the sync memory (a byte, 0 for a Mutex, then
|
|
49
|
+
* an int32), a Number's float64, or a shareable ByteArray's memory by its
|
|
50
|
+
* id, as a float64.
|
|
51
|
+
*/
|
|
52
|
+
export const ITEM_AMF = 0;
|
|
53
|
+
export const ITEM_BYTES = 1;
|
|
54
|
+
export const ITEM_SYNC = 2;
|
|
55
|
+
export const ITEM_NUMBER = 3;
|
|
56
|
+
export const ITEM_SHARED = 4;
|
|
57
|
+
/** Growable memory, shared where SharedArrayBuffer is. */
|
|
58
|
+
function growable(length, max) {
|
|
59
|
+
const shared = typeof SharedArrayBuffer === "function";
|
|
60
|
+
const ctor = (shared ? SharedArrayBuffer : ArrayBuffer);
|
|
61
|
+
return new ctor(length, { maxByteLength: max });
|
|
62
|
+
}
|
|
63
|
+
function grow(buffer, length) {
|
|
64
|
+
const b = buffer;
|
|
65
|
+
if (b.byteLength >= length) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (b.grow) {
|
|
69
|
+
b.grow(length);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
b.resize?.(length);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** New memory for the workers of a primordial, itself worker 0, running, whose Mutexes live in `sync`. */
|
|
76
|
+
export function newWorkersMemory(sync) {
|
|
77
|
+
const memory = {
|
|
78
|
+
control: growable((WORKERS + 2) * 4, CONTROL_MAX),
|
|
79
|
+
table: growable(4, TABLE_MAX),
|
|
80
|
+
sync,
|
|
81
|
+
};
|
|
82
|
+
const control = new Int32Array(memory.control);
|
|
83
|
+
control[COUNT] = 1;
|
|
84
|
+
control[WORKERS] = RUNNING;
|
|
85
|
+
control[WORKERS + 1] = -1;
|
|
86
|
+
return memory;
|
|
87
|
+
}
|
|
88
|
+
/** Wait up to `ms` on `word` while it holds `value`, spinning where this thread cannot block. */
|
|
89
|
+
function waitOn(words, index, value, ms) {
|
|
90
|
+
try {
|
|
91
|
+
Atomics.wait(words, index, value, ms);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// An ArrayBuffer's, or a browser's main thread, which cannot block.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Thrown in a worker that was terminated, as avmplus interrupts it: its code stops. */
|
|
98
|
+
export class WorkerTerminated extends Error {
|
|
99
|
+
constructor() {
|
|
100
|
+
super("swf2es: the worker was terminated");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** The workers as one VM sees them, over the memory they share. */
|
|
104
|
+
export class Workers {
|
|
105
|
+
memory;
|
|
106
|
+
self;
|
|
107
|
+
control;
|
|
108
|
+
/** The Mutexes' and Conditions' memory, told which workers have ended. */
|
|
109
|
+
sync;
|
|
110
|
+
/** The table as last read, and its version. */
|
|
111
|
+
entries = new Map();
|
|
112
|
+
version = 0;
|
|
113
|
+
/**
|
|
114
|
+
* This VM's object for each property whose identity it keeps, a
|
|
115
|
+
* ByteArray, by entryKey, with its item's token.
|
|
116
|
+
*/
|
|
117
|
+
objects = new Map();
|
|
118
|
+
constructor(memory,
|
|
119
|
+
/** The worker this VM runs. */
|
|
120
|
+
self) {
|
|
121
|
+
this.memory = memory;
|
|
122
|
+
this.self = self;
|
|
123
|
+
this.control = new Int32Array(memory.control);
|
|
124
|
+
this.sync = new Sync(memory.sync, self);
|
|
125
|
+
}
|
|
126
|
+
/** A worker's state; one past those made has none. */
|
|
127
|
+
state(id) {
|
|
128
|
+
return this.words(id) ? Atomics.load(this.control, WORKERS + 2 * id) : 0;
|
|
129
|
+
}
|
|
130
|
+
parent(id) {
|
|
131
|
+
return this.words(id) ? Atomics.load(this.control, WORKERS + 2 * id + 1) : -1;
|
|
132
|
+
}
|
|
133
|
+
/** Move worker `id` from `from` to `to`; whether it was in `from`. */
|
|
134
|
+
transition(id, from, to) {
|
|
135
|
+
return Atomics.compareExchange(this.control, WORKERS + 2 * id, from, to) === from;
|
|
136
|
+
}
|
|
137
|
+
setState(id, to) {
|
|
138
|
+
Atomics.store(this.control, WORKERS + 2 * id, to);
|
|
139
|
+
}
|
|
140
|
+
/** A new worker of this one's, NEW. */
|
|
141
|
+
create() {
|
|
142
|
+
return this.locked(() => {
|
|
143
|
+
const id = this.control[COUNT];
|
|
144
|
+
// The views track the memory's length as it grows.
|
|
145
|
+
grow(this.memory.control, (WORKERS + 2 * (id + 1)) * 4);
|
|
146
|
+
this.control[WORKERS + 2 * id] = NEW;
|
|
147
|
+
this.control[WORKERS + 2 * id + 1] = this.self;
|
|
148
|
+
this.sync.addThread(id);
|
|
149
|
+
Atomics.store(this.control, COUNT, id + 1);
|
|
150
|
+
return id;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** The workers made so far, by id. */
|
|
154
|
+
count() {
|
|
155
|
+
return Atomics.load(this.control, COUNT);
|
|
156
|
+
}
|
|
157
|
+
get(id, key) {
|
|
158
|
+
if (Atomics.load(this.control, VERSION) !== this.version) {
|
|
159
|
+
this.locked(() => this.read());
|
|
160
|
+
}
|
|
161
|
+
return this.entries.get(entryKey(id, key));
|
|
162
|
+
}
|
|
163
|
+
/** Set worker `id`'s property `key`, or delete it with a null `item`; the item's token. */
|
|
164
|
+
set(id, key, item) {
|
|
165
|
+
return this.locked(() => {
|
|
166
|
+
this.read();
|
|
167
|
+
let token = 0;
|
|
168
|
+
if (item) {
|
|
169
|
+
token = Atomics.add(this.control, TOKEN, 1) + 1;
|
|
170
|
+
const entry = { id, key, kind: item.kind, writer: this.self, token, bytes: item.bytes };
|
|
171
|
+
this.entries.set(entryKey(id, key), entry);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.entries.delete(entryKey(id, key));
|
|
175
|
+
}
|
|
176
|
+
this.write();
|
|
177
|
+
return token;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Terminate worker `id`, started and not yet ended, and the workers it
|
|
182
|
+
* started, theirs and so on, whose threads stop with its own: each
|
|
183
|
+
* `terminated`, its properties let go, as Isolate::releaseActiveResources.
|
|
184
|
+
* The workers terminated, none where `id` was not running. Done holding
|
|
185
|
+
* the lock, so that none of them is in the table then, and none takes
|
|
186
|
+
* the lock again (see locked): its thread may be stopped anywhere once
|
|
187
|
+
* this returns. Their threads may run on until they are stopped, so the
|
|
188
|
+
* sync memory refuses them anything more, and keeps the locks they hold
|
|
189
|
+
* until the caller says their threads have stopped (Sync.end).
|
|
190
|
+
*/
|
|
191
|
+
terminate(id) {
|
|
192
|
+
return this.locked(() => {
|
|
193
|
+
const state = this.state(id);
|
|
194
|
+
if (state <= NEW || state > RUNNING) {
|
|
195
|
+
return new Set();
|
|
196
|
+
}
|
|
197
|
+
const ended = new Set([id]);
|
|
198
|
+
// A worker's number is above its parent's.
|
|
199
|
+
for (let d = id + 1; d < this.count(); d++) {
|
|
200
|
+
const s = this.state(d);
|
|
201
|
+
if (ended.has(this.parent(d)) && s > NEW && s <= RUNNING) {
|
|
202
|
+
ended.add(d);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Their properties first: once a worker holding the lock is
|
|
206
|
+
// terminated, another may take the lock from it (see locked).
|
|
207
|
+
this.drop(ended);
|
|
208
|
+
for (const d of ended) {
|
|
209
|
+
this.setState(d, TERMINATED);
|
|
210
|
+
this.sync.stop(d);
|
|
211
|
+
}
|
|
212
|
+
return ended;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/** This VM's worker has ended, as `to`, its properties let go; unless it was terminated already. */
|
|
216
|
+
end(to) {
|
|
217
|
+
this.locked(() => {
|
|
218
|
+
// Its state last, as in terminate; one that terminated itself is so.
|
|
219
|
+
if (this.state(this.self) === RUNNING) {
|
|
220
|
+
const terminated = this.sync.terminated;
|
|
221
|
+
this.drop(new Set([this.self]));
|
|
222
|
+
this.sync.end(this.self);
|
|
223
|
+
this.setState(this.self, terminated ? TERMINATED : to);
|
|
224
|
+
}
|
|
225
|
+
}, true);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* This VM's worker terminates itself: its code stops, and once it has,
|
|
229
|
+
* it is terminated and what it held let go (endShellWorker).
|
|
230
|
+
*/
|
|
231
|
+
terminateSelf() {
|
|
232
|
+
this.sync.stop(this.self);
|
|
233
|
+
}
|
|
234
|
+
/** Whether this VM's worker was terminated, by another or by itself: its code is to stop. */
|
|
235
|
+
get terminated() {
|
|
236
|
+
return this.self !== 0 && (this.state(this.self) > RUNNING || this.sync.terminated);
|
|
237
|
+
}
|
|
238
|
+
/** Remove the properties of the workers `ids`, holding the lock. */
|
|
239
|
+
drop(ids) {
|
|
240
|
+
this.read();
|
|
241
|
+
let changed = false;
|
|
242
|
+
for (const [k, e] of this.entries) {
|
|
243
|
+
if (ids.has(e.id)) {
|
|
244
|
+
this.entries.delete(k);
|
|
245
|
+
changed = true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (changed) {
|
|
249
|
+
this.write();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
words(id) {
|
|
253
|
+
return id >= 0 && id < Atomics.load(this.control, COUNT);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Run `f` holding the table's lock, whose word holds its holder's id
|
|
257
|
+
* plus one. A worker's thread is stopped only after it was terminated
|
|
258
|
+
* under the lock (terminate), and a terminated worker changes nothing
|
|
259
|
+
* holding it: it throws WorkerTerminated instead. It may still take the
|
|
260
|
+
* lock to find that out, as it can have been waiting for it while it
|
|
261
|
+
* was terminated, and be stopped there; so a lock held by a worker that
|
|
262
|
+
* was terminated is taken from it.
|
|
263
|
+
*/
|
|
264
|
+
locked(f, ending = false) {
|
|
265
|
+
const me = this.self + 1;
|
|
266
|
+
for (;;) {
|
|
267
|
+
const holder = Atomics.compareExchange(this.control, LOCK, 0, me);
|
|
268
|
+
if (holder === 0) {
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
if (holder !== 1 &&
|
|
272
|
+
this.state(holder - 1) > RUNNING &&
|
|
273
|
+
Atomics.compareExchange(this.control, LOCK, holder, me) === holder) {
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
waitOn(this.control, LOCK, holder, 1);
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
if (this.self !== 0 &&
|
|
280
|
+
(this.state(this.self) > RUNNING || (!ending && this.sync.terminated))) {
|
|
281
|
+
throw new WorkerTerminated();
|
|
282
|
+
}
|
|
283
|
+
return f();
|
|
284
|
+
}
|
|
285
|
+
finally {
|
|
286
|
+
Atomics.compareExchange(this.control, LOCK, me, 0);
|
|
287
|
+
Atomics.notify(this.control, LOCK);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/** The table from memory: its length, then each entry. */
|
|
291
|
+
read() {
|
|
292
|
+
this.version = Atomics.load(this.control, VERSION);
|
|
293
|
+
const table = new Uint8Array(this.memory.table);
|
|
294
|
+
const view = new DataView(this.memory.table);
|
|
295
|
+
const end = 4 + view.getUint32(0, true);
|
|
296
|
+
this.entries.clear();
|
|
297
|
+
let at = 4;
|
|
298
|
+
while (at < end) {
|
|
299
|
+
const id = view.getUint32(at, true);
|
|
300
|
+
const keyLength = view.getInt32(at + 4, true);
|
|
301
|
+
at += 8;
|
|
302
|
+
const key = keyLength < 0 ? null : fromUtf8(table.slice(at, at + keyLength));
|
|
303
|
+
at += Math.max(keyLength, 0);
|
|
304
|
+
const kind = table[at];
|
|
305
|
+
const writer = view.getUint32(at + 1, true);
|
|
306
|
+
const token = view.getUint32(at + 5, true);
|
|
307
|
+
const length = view.getUint32(at + 9, true);
|
|
308
|
+
at += 13;
|
|
309
|
+
const bytes = table.slice(at, at + length);
|
|
310
|
+
at += length;
|
|
311
|
+
this.entries.set(entryKey(id, key), { id, key, kind, writer, token, bytes });
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The table into memory, its length first, in one copy: a thread
|
|
316
|
+
* stopped mid-way leaves the old table or the new one.
|
|
317
|
+
*/
|
|
318
|
+
write() {
|
|
319
|
+
const parts = [];
|
|
320
|
+
let length = 0;
|
|
321
|
+
for (const e of this.entries.values()) {
|
|
322
|
+
const key = e.key === null ? null : utf8(e.key);
|
|
323
|
+
const head = new Uint8Array(8);
|
|
324
|
+
const headView = new DataView(head.buffer);
|
|
325
|
+
headView.setUint32(0, e.id, true);
|
|
326
|
+
headView.setInt32(4, key === null ? -1 : key.length, true);
|
|
327
|
+
const item = new Uint8Array(13);
|
|
328
|
+
const itemView = new DataView(item.buffer);
|
|
329
|
+
item[0] = e.kind;
|
|
330
|
+
itemView.setUint32(1, e.writer, true);
|
|
331
|
+
itemView.setUint32(5, e.token, true);
|
|
332
|
+
itemView.setUint32(9, e.bytes.length, true);
|
|
333
|
+
parts.push(head);
|
|
334
|
+
if (key) {
|
|
335
|
+
parts.push(key);
|
|
336
|
+
}
|
|
337
|
+
parts.push(item, e.bytes);
|
|
338
|
+
length += head.length + (key?.length ?? 0) + item.length + e.bytes.length;
|
|
339
|
+
}
|
|
340
|
+
const out = new Uint8Array(4 + length);
|
|
341
|
+
new DataView(out.buffer).setUint32(0, length, true);
|
|
342
|
+
let at = 4;
|
|
343
|
+
for (const p of parts) {
|
|
344
|
+
out.set(p, at);
|
|
345
|
+
at += p.length;
|
|
346
|
+
}
|
|
347
|
+
grow(this.memory.table, out.length);
|
|
348
|
+
new Uint8Array(this.memory.table).set(out);
|
|
349
|
+
this.version = Atomics.add(this.control, VERSION, 1) + 1;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/** A property's key among all the workers'. */
|
|
353
|
+
export const entryKey = (id, key) => `${id}${key === null ? "" : `:${key}`}`;
|
|
354
|
+
/**
|
|
355
|
+
* A background worker's thread has begun, as avmplus' core once set up:
|
|
356
|
+
* whether it is to run, which it is not once terminated.
|
|
357
|
+
*/
|
|
358
|
+
export function startShellWorker(init) {
|
|
359
|
+
return new Workers(init.memory, init.id).transition(init.id, CANSTART, RUNNING);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* A background worker's code has ended, normally or by an exception
|
|
363
|
+
* nothing caught; its properties are let go, as when avmplus deletes its
|
|
364
|
+
* core. One terminated meanwhile stays so.
|
|
365
|
+
*/
|
|
366
|
+
export function endShellWorker(init, exception) {
|
|
367
|
+
try {
|
|
368
|
+
new Workers(init.memory, init.id).end(exception ? EXCEPTION : TERMINATED);
|
|
369
|
+
}
|
|
370
|
+
catch (e) {
|
|
371
|
+
if (!(e instanceof WorkerTerminated)) {
|
|
372
|
+
throw e;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
finally {
|
|
376
|
+
// Its code has ended, and asks nothing more of the sync memory: the
|
|
377
|
+
// locks it held are free to take, a terminated one's too.
|
|
378
|
+
new Sync(init.memory.sync, init.id).end(init.id);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/** Whether a background worker was terminated: its thread's end is then no failure. */
|
|
382
|
+
export function shellWorkerTerminated(init) {
|
|
383
|
+
return new Workers(init.memory, init.id).terminated;
|
|
384
|
+
}
|
|
385
|
+
/** Sleep `ms` milliseconds, as System.sleep: blocking where the thread can, else spinning. */
|
|
386
|
+
export function sleep(ms) {
|
|
387
|
+
if (ms <= 0) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const end = Date.now() + ms;
|
|
391
|
+
if (typeof SharedArrayBuffer === "function") {
|
|
392
|
+
const word = new Int32Array(new SharedArrayBuffer(4));
|
|
393
|
+
try {
|
|
394
|
+
Atomics.wait(word, 0, 0, ms);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
catch {
|
|
398
|
+
// A browser's main thread, which cannot block.
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
while (Date.now() < end) {
|
|
402
|
+
// Spin.
|
|
403
|
+
}
|
|
404
|
+
}
|