@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,434 @@
|
|
|
1
|
+
import { SpinClock } from "../clock.js";
|
|
2
|
+
export class Timers {
|
|
3
|
+
s;
|
|
4
|
+
/**
|
|
5
|
+
* The frame clock, in ms since the start, moved by the frame step alone;
|
|
6
|
+
* Timer fires by it without a real clock, and sounds go by it with one.
|
|
7
|
+
*/
|
|
8
|
+
clock = 0;
|
|
9
|
+
/**
|
|
10
|
+
* By the frame clock, the time getTimer tells and a timer started now
|
|
11
|
+
* counts from (sounds go by it with either clock): the clock,
|
|
12
|
+
* except while a timer's closure runs, when it is the time the timer fell
|
|
13
|
+
* due, as Flash fires timers between frames at their own times, so that
|
|
14
|
+
* one timer set from another keeps the first's pace, not the frame's.
|
|
15
|
+
*/
|
|
16
|
+
now = 0;
|
|
17
|
+
realTime;
|
|
18
|
+
/** The timers started, by their Timer objects, and a heap of them by when they fall due. */
|
|
19
|
+
running = new Map();
|
|
20
|
+
timers = new TimerHeap();
|
|
21
|
+
/** Timers started so far: a pass of the real clock fires those due in start order. */
|
|
22
|
+
starts = 0;
|
|
23
|
+
/** Set by updateAfterEvent: a timer fired between frames has the stage render after it. */
|
|
24
|
+
renderAsked = false;
|
|
25
|
+
/**
|
|
26
|
+
* The timers' time with a real clock: the host's, the sum of what it
|
|
27
|
+
* passed to advance() since the first call, which started it at the
|
|
28
|
+
* real clock's; NaN until then. Frames lie on an exact grid by it, where
|
|
29
|
+
* the real clock read as each runs wobbles with the host's latency, and
|
|
30
|
+
* a timer as long as a frame would miss frames by a fraction of a ms.
|
|
31
|
+
*/
|
|
32
|
+
host = Number.NaN;
|
|
33
|
+
/** elapsed() when `host` last moved, to tell the time between calls. */
|
|
34
|
+
hostReal = 0;
|
|
35
|
+
/**
|
|
36
|
+
* The time of the frame or the between-frames pass that runs, which a
|
|
37
|
+
* timer started in it counts from; NaN outside. A frame's is the call's
|
|
38
|
+
* time, less the frame interval for each frame the call plays after it.
|
|
39
|
+
*/
|
|
40
|
+
at = Number.NaN;
|
|
41
|
+
/**
|
|
42
|
+
* The running frame's time on the frame grid: the time it fell due,
|
|
43
|
+
* which the timers as long as a frame or longer go by, so that one of
|
|
44
|
+
* the frame's length fires every frame however the host's calls fall
|
|
45
|
+
* (a 25 fps SWF's frames are 33 and 50 ms apart at 60 Hz). Those shorter
|
|
46
|
+
* go by `at`, so as not to wait for a between-frames check's time plus
|
|
47
|
+
* their delay while the frame runs late.
|
|
48
|
+
*/
|
|
49
|
+
grid = Number.NaN;
|
|
50
|
+
/**
|
|
51
|
+
* While a frame waits for a load from bytes, the host's time of the
|
|
52
|
+
* frame's slot: no timer due after it fires until release(); Infinity
|
|
53
|
+
* otherwise (Player.advance).
|
|
54
|
+
*/
|
|
55
|
+
cap = Number.POSITIVE_INFINITY;
|
|
56
|
+
/** The last pass's time: none goes back before it. */
|
|
57
|
+
lastPass = Number.NEGATIVE_INFINITY;
|
|
58
|
+
/** The real clock's last finite reading, and the sum of its forward steps since the start. */
|
|
59
|
+
lastRaw = Number.NaN;
|
|
60
|
+
sum = 0;
|
|
61
|
+
/** getTimer on the real clock, skipping a spin on it (clock.ts). */
|
|
62
|
+
spin;
|
|
63
|
+
constructor(s, options) {
|
|
64
|
+
this.s = s;
|
|
65
|
+
this.realTime = options.realTime === undefined ? defaultClock() : options.realTime;
|
|
66
|
+
this.spin = new SpinClock(() => this.elapsed());
|
|
67
|
+
// getTimer's zero: when the player is made, as Flash's is when it starts.
|
|
68
|
+
if (this.realTime) {
|
|
69
|
+
this.elapsed();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* What getTimer tells: whole milliseconds since the start, by the real
|
|
74
|
+
* clock, truncated as Flash's are, or by the frame clock's now, rounded
|
|
75
|
+
* as it always has been, so that the traces recorded by it stay.
|
|
76
|
+
*/
|
|
77
|
+
timer() {
|
|
78
|
+
if (!this.realTime) {
|
|
79
|
+
return Math.round(this.now);
|
|
80
|
+
}
|
|
81
|
+
return Math.floor(this.spin.read());
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* How far getTimer and the timers run ahead of the real clock, in ms,
|
|
85
|
+
* since a spin had the clock skip to the time it waited for: the frames
|
|
86
|
+
* wait for the real clock (Player.advance). Ends the pass that ran.
|
|
87
|
+
*/
|
|
88
|
+
ahead() {
|
|
89
|
+
return this.realTime ? this.spin.ahead() : 0;
|
|
90
|
+
}
|
|
91
|
+
/** What the clock tells beyond the real clock at `real`: the timers' time keeps to getTimer's. */
|
|
92
|
+
lead(real) {
|
|
93
|
+
return this.spin.lead(real);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Milliseconds since the start by the real clock, unrounded: the sum of
|
|
97
|
+
* its forward steps, so that a reading that is not finite is skipped and
|
|
98
|
+
* one that jumps back neither goes back nor stops the time after it.
|
|
99
|
+
*/
|
|
100
|
+
elapsed() {
|
|
101
|
+
const raw = this.realTime();
|
|
102
|
+
if (Number.isFinite(raw)) {
|
|
103
|
+
if (raw > this.lastRaw) {
|
|
104
|
+
this.sum += raw - this.lastRaw;
|
|
105
|
+
}
|
|
106
|
+
this.lastRaw = raw;
|
|
107
|
+
}
|
|
108
|
+
return this.sum;
|
|
109
|
+
}
|
|
110
|
+
/** The timers' time now with a real clock: the host's, run on by the real clock since. */
|
|
111
|
+
current() {
|
|
112
|
+
const real = this.elapsed();
|
|
113
|
+
const time = Number.isNaN(this.host) ? real : this.host + (real - this.hostReal);
|
|
114
|
+
return time + this.lead(real);
|
|
115
|
+
}
|
|
116
|
+
/** advance() was called with `passed` ms: the host's time moves on. */
|
|
117
|
+
hostPassed(passed) {
|
|
118
|
+
if (!this.realTime) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const real = this.elapsed();
|
|
122
|
+
this.host = Number.isNaN(this.host) ? real : this.host + passed;
|
|
123
|
+
this.hostReal = real;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The next frame of the call runs `slot` ms of frames before its last,
|
|
127
|
+
* and fell due on the grid `rest` ms before that; both NaN once the
|
|
128
|
+
* call's frames are over.
|
|
129
|
+
*/
|
|
130
|
+
frameAt(slot, rest) {
|
|
131
|
+
const off = Number.isNaN(slot) || Number.isNaN(this.host);
|
|
132
|
+
const lead = off ? 0 : this.lead(this.elapsed());
|
|
133
|
+
this.at = off ? Number.NaN : this.host - slot + lead;
|
|
134
|
+
this.grid = off ? Number.NaN : this.host - slot - rest + lead;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A frame waits for a load from bytes `ms` before its slot, from the
|
|
138
|
+
* host's time now: timers due after the slot wait for release(), then
|
|
139
|
+
* fire once each, the ticks they lost dropped. Already waiting, nothing.
|
|
140
|
+
*/
|
|
141
|
+
holdAfter(ms) {
|
|
142
|
+
if (this.realTime && this.cap === Number.POSITIVE_INFINITY && !Number.isNaN(this.host)) {
|
|
143
|
+
this.cap = this.host + this.lead(this.elapsed()) + ms;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** The frame that waited has played: the timers fire as they fall due again. */
|
|
147
|
+
release() {
|
|
148
|
+
this.cap = Number.POSITIVE_INFINITY;
|
|
149
|
+
}
|
|
150
|
+
/** A frame begins: the frame clock moves on by `ms`; its timers fire after ENTER_FRAME. */
|
|
151
|
+
beginFrame(ms) {
|
|
152
|
+
if (this.realTime) {
|
|
153
|
+
this.spin.settle();
|
|
154
|
+
}
|
|
155
|
+
this.clock += ms;
|
|
156
|
+
this.now = this.clock;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* By the frame clock, the timers that fall due by the frame's time, each
|
|
160
|
+
* firing the earliest due, so that two timers interleave as their times
|
|
161
|
+
* do and one started from another with time to spare fires in the same
|
|
162
|
+
* pass.
|
|
163
|
+
*/
|
|
164
|
+
fireByClock() {
|
|
165
|
+
try {
|
|
166
|
+
for (;;) {
|
|
167
|
+
const next = this.timers.pop(this.clock);
|
|
168
|
+
if (!next) {
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
this.now = next.due;
|
|
172
|
+
next.due += next.delay;
|
|
173
|
+
try {
|
|
174
|
+
this.s.rt.call(next.closure, next.object);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
// Reported, and the timers after it and the frame still run.
|
|
178
|
+
this.s.reportUncaught(error);
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
// Pushed back whatever the call did, unless it stopped the timer or
|
|
182
|
+
// started it anew: one whose closure throws still has its next time.
|
|
183
|
+
if (!next.stopped) {
|
|
184
|
+
this.timers.push(next);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
this.now = this.clock;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The frame's timers, after ENTER_FRAME and before the frame's
|
|
195
|
+
* construction, as Flash fires them: by the real clock every timer due
|
|
196
|
+
* fires once; by the frame clock every due time in the frame fires.
|
|
197
|
+
*/
|
|
198
|
+
frameTimers() {
|
|
199
|
+
if (this.realTime) {
|
|
200
|
+
// A frame run by tick() alone, not advance(), goes by the time now.
|
|
201
|
+
const now = Number.isNaN(this.at) ? this.current() : this.at;
|
|
202
|
+
const grid = Number.isNaN(this.grid) ? now : this.grid;
|
|
203
|
+
this.fireDue(now, grid, 1000 / this.s.frameRate, false);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this.fireByClock();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* A check between frames by the real clock: the timers due whose delay
|
|
211
|
+
* is shorter than the frame fire once each. Flash fires those between
|
|
212
|
+
* frames at their times and holds a longer one for the next frame, a
|
|
213
|
+
* 45 ms timer at 24 fps firing every other frame though the player
|
|
214
|
+
* checks between (measured in adl, docs/architecture/input.md).
|
|
215
|
+
*/
|
|
216
|
+
betweenFrames(frameMs) {
|
|
217
|
+
if (!this.realTime) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.spin.settle();
|
|
221
|
+
const real = this.elapsed();
|
|
222
|
+
this.at = (Number.isNaN(this.host) ? real : this.host) + this.lead(real);
|
|
223
|
+
try {
|
|
224
|
+
this.fireDue(this.at, Number.NaN, frameMs, true);
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
this.at = Number.NaN;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* A pass: each timer due fires once, in the order the timers were
|
|
232
|
+
* started, and next falls due its delay after the frame's time on the
|
|
233
|
+
* grid, or after `time` between frames (`frameGrid` NaN), so the ticks a long
|
|
234
|
+
* frame or a stall lost are dropped, not caught up with, as in Flash.
|
|
235
|
+
* Those shorter than `frameMs` are due by `time`; the others by `frameGrid`,
|
|
236
|
+
* and wait for a frame.
|
|
237
|
+
*/
|
|
238
|
+
fireDue(time, frameGrid, frameMs, between) {
|
|
239
|
+
// While a frame waits for a load, none due after its slot.
|
|
240
|
+
const now = Math.max(Math.min(time, this.cap), this.lastPass);
|
|
241
|
+
const grid = Math.min(frameGrid, this.cap);
|
|
242
|
+
this.lastPass = now;
|
|
243
|
+
const due = [];
|
|
244
|
+
const held = [];
|
|
245
|
+
for (;;) {
|
|
246
|
+
// The grid's time is never after the call's. Sums of a host's
|
|
247
|
+
// intervals land a hair off the grid: due then is due.
|
|
248
|
+
const next = this.timers.pop(now + GRID_SLACK);
|
|
249
|
+
if (!next) {
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
// A short timer is due by the call's time, so as not to wait for a
|
|
253
|
+
// between-frames check's time plus its delay while the frame runs
|
|
254
|
+
// late; a longer one by the grid's. Either next falls due from the
|
|
255
|
+
// grid's, which frames keep to, as Flash's keep to its own.
|
|
256
|
+
// Between frames, a short one also waits its whole delay since it
|
|
257
|
+
// last fired, as Flash's do: due from the grid, it is a little early.
|
|
258
|
+
const short = next.delay < frameMs;
|
|
259
|
+
const ready = !between || next.fired + next.delay <= now + GRID_SLACK;
|
|
260
|
+
if (ready && next.due <= (short ? now : grid) + GRID_SLACK) {
|
|
261
|
+
next.due = Number.isNaN(grid) ? now : grid;
|
|
262
|
+
next.fired = now;
|
|
263
|
+
due.push(next);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
held.push(next);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
for (const record of held) {
|
|
270
|
+
this.timers.push(record);
|
|
271
|
+
}
|
|
272
|
+
if (!due.length) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
due.sort((a, b) => a.order - b.order);
|
|
276
|
+
try {
|
|
277
|
+
for (const record of due) {
|
|
278
|
+
// Stopped by a closure before it in the pass; one started anew has a record of its own.
|
|
279
|
+
if (record.stopped) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
// `due` holds the time it fired by, set above.
|
|
283
|
+
record.due += record.delay;
|
|
284
|
+
this.renderAsked = false;
|
|
285
|
+
try {
|
|
286
|
+
this.s.rt.call(record.closure, record.object);
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
this.s.reportUncaught(error);
|
|
290
|
+
}
|
|
291
|
+
finally {
|
|
292
|
+
if (!record.stopped) {
|
|
293
|
+
this.timers.push(record);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// updateAfterEvent between frames: the stage renders now, RENDER and all, as in Flash.
|
|
297
|
+
if (between && this.renderAsked) {
|
|
298
|
+
this.s.render();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
this.renderAsked = false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/** Timer._start: `closure` is called every `delay` ms from now, until stopped; a timer running already is started anew. */
|
|
307
|
+
startTimer(object, delay, closure) {
|
|
308
|
+
this.stopTimer(object);
|
|
309
|
+
// Whole milliseconds, as Flash's: Timer(1000 / 24) is 41 ms, shorter than the frame.
|
|
310
|
+
const ms = Math.max(Math.trunc(delay) || 0, 1);
|
|
311
|
+
// In a frame, one as long as a frame counts from the frame's time on
|
|
312
|
+
// the grid, which it fires by; others from the frame's or the pass's.
|
|
313
|
+
let from = this.now;
|
|
314
|
+
if (this.realTime) {
|
|
315
|
+
const long = ms >= 1000 / this.s.frameRate && !Number.isNaN(this.grid);
|
|
316
|
+
from = long ? this.grid : Number.isNaN(this.at) ? this.current() : this.at;
|
|
317
|
+
}
|
|
318
|
+
const record = {
|
|
319
|
+
object,
|
|
320
|
+
delay: ms,
|
|
321
|
+
closure,
|
|
322
|
+
due: from + ms,
|
|
323
|
+
fired: Number.NEGATIVE_INFINITY,
|
|
324
|
+
seq: 0,
|
|
325
|
+
order: this.starts++,
|
|
326
|
+
stopped: false,
|
|
327
|
+
};
|
|
328
|
+
this.running.set(object, record);
|
|
329
|
+
this.timers.push(record);
|
|
330
|
+
}
|
|
331
|
+
stopTimer(object) {
|
|
332
|
+
const record = this.running.get(object);
|
|
333
|
+
if (record) {
|
|
334
|
+
record.stopped = true;
|
|
335
|
+
this.running.delete(object);
|
|
336
|
+
this.timers.stopped();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
timerRunning(object) {
|
|
340
|
+
return this.running.has(object);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/** How far past a pass's time a timer still counts as due, in ms: far below a whole one. */
|
|
344
|
+
const GRID_SLACK = 1e-6;
|
|
345
|
+
/** The real clock where the host has one, browsers and node alike; else none, and the frame clock. */
|
|
346
|
+
function defaultClock() {
|
|
347
|
+
return typeof performance !== "undefined" ? () => performance.now() : null;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The started timers by due time, a binary min-heap as asyncio keeps its
|
|
351
|
+
* scheduled callbacks: the next due is found and rescheduled in O(log n)
|
|
352
|
+
* where a scan of all timers is O(n) per firing, which at a thousand
|
|
353
|
+
* timers is the difference between 0.3 and 2.5 ms a frame. A stopped
|
|
354
|
+
* timer stays until it surfaces, and the heap is rebuilt without the
|
|
355
|
+
* stopped when they are more than half of it.
|
|
356
|
+
*/
|
|
357
|
+
class TimerHeap {
|
|
358
|
+
heap = [];
|
|
359
|
+
seq = 0;
|
|
360
|
+
stoppedCount = 0;
|
|
361
|
+
push(record) {
|
|
362
|
+
record.seq = this.seq++;
|
|
363
|
+
this.insert(record);
|
|
364
|
+
}
|
|
365
|
+
/** `record` in its place by due time and the sequence it has. */
|
|
366
|
+
insert(record) {
|
|
367
|
+
const h = this.heap;
|
|
368
|
+
h.push(record);
|
|
369
|
+
let i = h.length - 1;
|
|
370
|
+
while (i > 0) {
|
|
371
|
+
const parent = (i - 1) >> 1;
|
|
372
|
+
if (!before(h[i], h[parent])) {
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
[h[i], h[parent]] = [h[parent], h[i]];
|
|
376
|
+
i = parent;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/** The earliest due timer at or before `clock`, taken out; stopped ones in the way are dropped. */
|
|
380
|
+
pop(clock) {
|
|
381
|
+
for (;;) {
|
|
382
|
+
const top = this.heap[0];
|
|
383
|
+
if (!top || top.due > clock) {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
this.remove();
|
|
387
|
+
if (top.stopped) {
|
|
388
|
+
this.stoppedCount--;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
return top;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
stopped() {
|
|
395
|
+
this.stoppedCount++;
|
|
396
|
+
if (this.stoppedCount > this.heap.length / 2) {
|
|
397
|
+
// Rebuilt with each record's own sequence: the order of two due at once must not change.
|
|
398
|
+
const live = this.heap.filter((r) => !r.stopped);
|
|
399
|
+
this.heap = [];
|
|
400
|
+
this.stoppedCount = 0;
|
|
401
|
+
for (const record of live) {
|
|
402
|
+
this.insert(record);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
remove() {
|
|
407
|
+
const h = this.heap;
|
|
408
|
+
const last = h.pop();
|
|
409
|
+
if (!h.length) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
h[0] = last;
|
|
413
|
+
let i = 0;
|
|
414
|
+
for (;;) {
|
|
415
|
+
const left = 2 * i + 1;
|
|
416
|
+
const right = left + 1;
|
|
417
|
+
let least = i;
|
|
418
|
+
if (left < h.length && before(h[left], h[least])) {
|
|
419
|
+
least = left;
|
|
420
|
+
}
|
|
421
|
+
if (right < h.length && before(h[right], h[least])) {
|
|
422
|
+
least = right;
|
|
423
|
+
}
|
|
424
|
+
if (least === i) {
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
[h[i], h[least]] = [h[least], h[i]];
|
|
428
|
+
i = least;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function before(a, b) {
|
|
433
|
+
return a.due < b.due || (a.due === b.due && a.seq < b.seq);
|
|
434
|
+
}
|