@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,377 @@
|
|
|
1
|
+
// Array's and Vector's sort and sortOn, as avmplus' ArraySort does them:
|
|
2
|
+
// its own quicksort, not stable, so that elements that compare equal end
|
|
3
|
+
// up in the order avmplus leaves them; undefined elements after the
|
|
4
|
+
// others, and missing ones last; and its options and comparisons, with the
|
|
5
|
+
// bug compatibility of the latest SWF version (bugzillas 524122, 532454).
|
|
6
|
+
//
|
|
7
|
+
// Translated from avmplus' core/ArrayClass.cpp, this file is subject to the
|
|
8
|
+
// Mozilla Public License, v. 2.0: http://mozilla.org/MPL/2.0/.
|
|
9
|
+
import { FloatValue } from "../float.js";
|
|
10
|
+
import { publicQname } from "../names.js";
|
|
11
|
+
import { SEALED_ELEMENTS } from "../runtime.js";
|
|
12
|
+
import { lowerCase } from "./case.js";
|
|
13
|
+
import { getElement, isObject, lengthOf } from "./define.js";
|
|
14
|
+
import { FloatVector } from "./float-vector.js";
|
|
15
|
+
const kCaseInsensitive = 1;
|
|
16
|
+
const kDescending = 2;
|
|
17
|
+
const kUniqueSort = 4;
|
|
18
|
+
const kReturnIndexedArray = 8;
|
|
19
|
+
const kNumeric = 16;
|
|
20
|
+
function stringCompare(rt, lower) {
|
|
21
|
+
return (x, y) => {
|
|
22
|
+
let a = rt.toString(x);
|
|
23
|
+
let b = rt.toString(y);
|
|
24
|
+
if (lower) {
|
|
25
|
+
a = lowerCase(a);
|
|
26
|
+
b = lowerCase(b);
|
|
27
|
+
}
|
|
28
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function numericCompare(rt) {
|
|
32
|
+
return (x, y) => {
|
|
33
|
+
const a = rt.toNumber(x);
|
|
34
|
+
const b = rt.toNumber(y);
|
|
35
|
+
const diff = a - b;
|
|
36
|
+
if (!Number.isNaN(diff)) {
|
|
37
|
+
return diff < 0 ? -1 : diff > 0 ? 1 : 0;
|
|
38
|
+
}
|
|
39
|
+
return !Number.isNaN(b) ? 1 : !Number.isNaN(a) ? -1 : 0;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** The comparison options name, without a compare function. */
|
|
43
|
+
function compareOf(rt, options) {
|
|
44
|
+
const compare = options & kNumeric ? numericCompare(rt) : stringCompare(rt, (options & kCaseInsensitive) !== 0);
|
|
45
|
+
return options & kDescending ? (x, y) => compare(y, x) : compare;
|
|
46
|
+
}
|
|
47
|
+
/** As ArrayClass::generic_sort: sort(), sort(compare), sort(options) or sort(compare, options). */
|
|
48
|
+
export function sort(rt, d, args) {
|
|
49
|
+
if (!isObject(d)) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
let compare = null;
|
|
53
|
+
let options = 0;
|
|
54
|
+
let numeric = false;
|
|
55
|
+
if (args.length >= 1) {
|
|
56
|
+
const arg0 = args[0];
|
|
57
|
+
if (isObject(arg0)) {
|
|
58
|
+
if (!arg0.$f) {
|
|
59
|
+
throw rt.error("TypeError", 1034, rt.describe(arg0), "Function");
|
|
60
|
+
}
|
|
61
|
+
// The comparator's result counts by its sign, as a Number. Its arguments go in one pair for
|
|
62
|
+
// the sort, not one a comparison: the comparator has $f, which callValue calls with apply,
|
|
63
|
+
// and apply copies the pair into the call's own parameters, rest or arguments, a native's
|
|
64
|
+
// as an AS3 method's, keeping no reference to it. A comparator that sorts inside itself has
|
|
65
|
+
// its own sort's pair.
|
|
66
|
+
const pair = [undefined, undefined];
|
|
67
|
+
compare = (x, y) => {
|
|
68
|
+
pair[0] = x;
|
|
69
|
+
pair[1] = y;
|
|
70
|
+
const result = rt.toNumber(rt.callValue(arg0, d, pair, null));
|
|
71
|
+
return result > 0 ? 1 : result < 0 ? -1 : 0;
|
|
72
|
+
};
|
|
73
|
+
if (args.length >= 2) {
|
|
74
|
+
if (typeof args[1] !== "number" && !(args[1] instanceof FloatValue)) {
|
|
75
|
+
throw rt.error("TypeError", 1034, rt.describe(args[1]), "Number");
|
|
76
|
+
}
|
|
77
|
+
options = rt.toInt(args[1]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (typeof arg0 === "number" || arg0 instanceof FloatValue) {
|
|
81
|
+
options = rt.toInt(arg0);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw rt.error("TypeError", 1034, rt.describe(arg0), "Function");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (compare === null) {
|
|
88
|
+
numeric = (options & kNumeric) !== 0;
|
|
89
|
+
compare = compareOf(rt, options);
|
|
90
|
+
}
|
|
91
|
+
else if (options & kDescending) {
|
|
92
|
+
const ascending = compare;
|
|
93
|
+
compare = (x, y) => ascending(y, x);
|
|
94
|
+
}
|
|
95
|
+
return sortWith(rt, d, options, compare, numeric, null);
|
|
96
|
+
}
|
|
97
|
+
/** As ArrayClass::generic_sortOn: by one field or several, each with its options. */
|
|
98
|
+
export function sortOn(rt, d, names, optionsIn) {
|
|
99
|
+
if (!isObject(d)) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const fields = [];
|
|
103
|
+
let options = 0;
|
|
104
|
+
if (typeof names === "string") {
|
|
105
|
+
options = rt.toInt(optionsIn);
|
|
106
|
+
fields.push({ name: names, options });
|
|
107
|
+
}
|
|
108
|
+
else if (names?.$a && names.$traits.name === "Array") {
|
|
109
|
+
for (const n of names.$a) {
|
|
110
|
+
fields.push({ name: rt.toString(n), options: 0 });
|
|
111
|
+
}
|
|
112
|
+
if (optionsIn?.$a && optionsIn.$traits.name === "Array") {
|
|
113
|
+
const list = optionsIn.$a;
|
|
114
|
+
if (list.length === fields.length) {
|
|
115
|
+
options = rt.toInt(list[0]);
|
|
116
|
+
fields.forEach((f, i) => {
|
|
117
|
+
f.options = rt.toInt(list[i]);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
options = rt.toInt(optionsIn);
|
|
123
|
+
for (const f of fields) {
|
|
124
|
+
f.options = options;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// One field sorts by its values (sortWith), which needs no comparison of the elements.
|
|
129
|
+
const compare = fields.length === 1 ? unused : fieldCompare(rt, fields, options);
|
|
130
|
+
return sortWith(rt, d, options, compare, false, fields);
|
|
131
|
+
}
|
|
132
|
+
/** No comparison: sortWith makes its own where it is given this. */
|
|
133
|
+
const unused = () => 0;
|
|
134
|
+
/** As ArraySort::FieldCompare: by each field in turn, until one differs. */
|
|
135
|
+
function fieldCompare(rt, fields, options) {
|
|
136
|
+
// Each field's name and comparison made once for the sort, not for each comparison.
|
|
137
|
+
const names = fields.map((field) => publicQname(field.name, rt.userVersions));
|
|
138
|
+
const compares = fields.map((field) => field.options & kNumeric
|
|
139
|
+
? numericCompare(rt)
|
|
140
|
+
: stringCompare(rt, (field.options & kCaseInsensitive) !== 0));
|
|
141
|
+
return (j, k) => {
|
|
142
|
+
let opt = options;
|
|
143
|
+
let result = 0;
|
|
144
|
+
const objJ = isObject(j) ? j : null;
|
|
145
|
+
const objK = isObject(k) ? k : null;
|
|
146
|
+
if (!(objJ && objK)) {
|
|
147
|
+
result = objK ? 1 : objJ ? -1 : 0;
|
|
148
|
+
return opt & kDescending ? -result : result;
|
|
149
|
+
}
|
|
150
|
+
for (let f = 0; f < fields.length; f++) {
|
|
151
|
+
const name = names[f];
|
|
152
|
+
opt = fields[f].options;
|
|
153
|
+
const x = rt.getProperty(objJ, name);
|
|
154
|
+
const y = rt.getProperty(objK, name);
|
|
155
|
+
const defX = x !== undefined;
|
|
156
|
+
const defY = y !== undefined;
|
|
157
|
+
if (!(defX && defY)) {
|
|
158
|
+
if (defY) {
|
|
159
|
+
result = 1;
|
|
160
|
+
}
|
|
161
|
+
else if (defX) {
|
|
162
|
+
result = -1;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const hasX = rt.hasProperty(objJ, name);
|
|
166
|
+
const hasY = rt.hasProperty(objK, name);
|
|
167
|
+
result = !hasX && hasY ? 1 : hasX && !hasY ? -1 : 0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
result = compares[f](x, y);
|
|
172
|
+
}
|
|
173
|
+
if (result !== 0) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return opt & kDescending ? -result : result;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* As ArraySort's constructor: split the elements into defined, undefined
|
|
182
|
+
* and missing ones, quicksort the defined, then write them back, or
|
|
183
|
+
* return their order.
|
|
184
|
+
*/
|
|
185
|
+
function sortWith(rt, d, options, compareIn, numeric, fields) {
|
|
186
|
+
// The length as getLengthProperty reads it: an Array subclass may
|
|
187
|
+
// override its getter. An Array's or a Vector's elements are in their
|
|
188
|
+
// storage; anything else's are its properties.
|
|
189
|
+
const len = lengthOf(rt, d);
|
|
190
|
+
const storage = d.$a;
|
|
191
|
+
const a = storage !== undefined && storage !== SEALED_ELEMENTS ? storage : null;
|
|
192
|
+
// As ArraySort, which leaves what it cannot index unsorted.
|
|
193
|
+
if (len === 0 || len >= 0x10000000) {
|
|
194
|
+
return d;
|
|
195
|
+
}
|
|
196
|
+
const index = new Array(len);
|
|
197
|
+
const atoms = new Array(len);
|
|
198
|
+
let fieldAtoms = null;
|
|
199
|
+
let compare = compareIn;
|
|
200
|
+
let j = len;
|
|
201
|
+
let newlen = len;
|
|
202
|
+
// An element that sorts after the others: undefined ones next, then missing ones.
|
|
203
|
+
const partition = (i) => {
|
|
204
|
+
j--;
|
|
205
|
+
const temp = index[i];
|
|
206
|
+
index[i] = index[j];
|
|
207
|
+
// As hasUintProperty: a Proxy is asked through its hasProperty.
|
|
208
|
+
if (!(a !== null ? i in a : rt.in(i, d))) {
|
|
209
|
+
newlen--;
|
|
210
|
+
index[j] = index[newlen];
|
|
211
|
+
index[newlen] = temp;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
index[j] = temp;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
if (fields && fields.length === 1) {
|
|
218
|
+
// One field: sort by its values, then write back the elements.
|
|
219
|
+
fieldAtoms = new Array(len);
|
|
220
|
+
const name = publicQname(fields[0].name, rt.userVersions);
|
|
221
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
222
|
+
index[i] = i;
|
|
223
|
+
const v = getElement(rt, d, i);
|
|
224
|
+
fieldAtoms[i] = v;
|
|
225
|
+
if (isObject(v)) {
|
|
226
|
+
atoms[i] = rt.getProperty(v, name);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
partition(i);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
compare = compareOf(rt, fields[0].options);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
236
|
+
index[i] = i;
|
|
237
|
+
// As getUintProperty: a hole finds the prototype's element.
|
|
238
|
+
atoms[i] = getElement(rt, d, i);
|
|
239
|
+
if (numeric &&
|
|
240
|
+
typeof atoms[i] !== "number" &&
|
|
241
|
+
!(atoms[i] instanceof FloatValue) &&
|
|
242
|
+
Number.isNaN(rt.toNumber(atoms[i]))) {
|
|
243
|
+
throw rt.error("TypeError", 1034, rt.describe(atoms[i]), "Number");
|
|
244
|
+
}
|
|
245
|
+
if (atoms[i] === undefined) {
|
|
246
|
+
partition(i);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const cmp = (l, r) => compare(atoms[index[l]], atoms[index[r]]);
|
|
251
|
+
const swap = (l, r) => {
|
|
252
|
+
const t = index[l];
|
|
253
|
+
index[l] = index[r];
|
|
254
|
+
index[r] = t;
|
|
255
|
+
};
|
|
256
|
+
if (j > 1) {
|
|
257
|
+
qsort(0, j - 1, cmp, swap);
|
|
258
|
+
}
|
|
259
|
+
if (options & kUniqueSort) {
|
|
260
|
+
for (let i = 0; i < len - 1; i++) {
|
|
261
|
+
if (cmp(i, i + 1) === 0) {
|
|
262
|
+
return 0;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (options & kReturnIndexedArray) {
|
|
267
|
+
return rt.array(index.slice());
|
|
268
|
+
}
|
|
269
|
+
// Into the elements as they are now: a comparison may have set a
|
|
270
|
+
// Vector's length, which gives it a new array. Read through the order from
|
|
271
|
+
// the sort's own copy of them.
|
|
272
|
+
const source = fieldAtoms ?? atoms;
|
|
273
|
+
const target = d.$a;
|
|
274
|
+
if (target === undefined || target === SEALED_ELEMENTS) {
|
|
275
|
+
// As setUintProperty and delUintProperty: the length is left as it is.
|
|
276
|
+
for (let i = 0; i < newlen; i++) {
|
|
277
|
+
rt.setProperty(d, rt.publicName(i), source[index[i]]);
|
|
278
|
+
}
|
|
279
|
+
for (let i = newlen; i < len; i++) {
|
|
280
|
+
rt.deleteProperty(d, rt.publicName(i));
|
|
281
|
+
}
|
|
282
|
+
return d;
|
|
283
|
+
}
|
|
284
|
+
if (target instanceof FloatVector) {
|
|
285
|
+
if (target.length < newlen) {
|
|
286
|
+
target.length = newlen;
|
|
287
|
+
}
|
|
288
|
+
for (let i = 0; i < newlen; i++) {
|
|
289
|
+
target.data[i] = rt.toNumber(source[index[i]]);
|
|
290
|
+
}
|
|
291
|
+
return d;
|
|
292
|
+
}
|
|
293
|
+
for (let i = 0; i < newlen; i++) {
|
|
294
|
+
target[i] = source[index[i]];
|
|
295
|
+
}
|
|
296
|
+
for (let i = newlen; i < len; i++) {
|
|
297
|
+
delete target[i];
|
|
298
|
+
}
|
|
299
|
+
return d;
|
|
300
|
+
}
|
|
301
|
+
/** As ArraySort::qsort: iterative, the middle element as pivot, the smaller partition first. */
|
|
302
|
+
function qsort(loIn, hiIn, compare, swap) {
|
|
303
|
+
let lo = loIn;
|
|
304
|
+
let hi = hiIn;
|
|
305
|
+
// Each frame's lo and hi, flat: a pair for each was garbage of the sort.
|
|
306
|
+
const stack = [];
|
|
307
|
+
if (lo >= hi) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
for (;;) {
|
|
311
|
+
const size = hi - lo + 1;
|
|
312
|
+
if (size < 4) {
|
|
313
|
+
if (size === 3) {
|
|
314
|
+
if (compare(lo, lo + 1) > 0) {
|
|
315
|
+
swap(lo, lo + 1);
|
|
316
|
+
if (compare(lo + 1, lo + 2) > 0) {
|
|
317
|
+
swap(lo + 1, lo + 2);
|
|
318
|
+
if (compare(lo, lo + 1) > 0) {
|
|
319
|
+
swap(lo, lo + 1);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else if (compare(lo + 1, lo + 2) > 0) {
|
|
324
|
+
swap(lo + 1, lo + 2);
|
|
325
|
+
if (compare(lo, lo + 1) > 0) {
|
|
326
|
+
swap(lo, lo + 1);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else if (size === 2 && compare(lo, lo + 1) > 0) {
|
|
331
|
+
swap(lo, lo + 1);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
swap(lo + Math.floor(size / 2), lo);
|
|
336
|
+
let left = lo;
|
|
337
|
+
let right = hi + 1;
|
|
338
|
+
for (;;) {
|
|
339
|
+
do {
|
|
340
|
+
left++;
|
|
341
|
+
} while (left <= hi && compare(left, lo) <= 0);
|
|
342
|
+
do {
|
|
343
|
+
right--;
|
|
344
|
+
} while (right > lo && compare(right, lo) >= 0);
|
|
345
|
+
if (right < left) {
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
swap(left, right);
|
|
349
|
+
}
|
|
350
|
+
swap(lo, right);
|
|
351
|
+
// Unsigned in avmplus: right - 1 - lo wraps when right is lo.
|
|
352
|
+
if ((right - 1 - lo) >>> 0 >= (hi - left) >>> 0) {
|
|
353
|
+
if (lo + 1 < right) {
|
|
354
|
+
stack.push(lo, right - 1);
|
|
355
|
+
}
|
|
356
|
+
if (left < hi) {
|
|
357
|
+
lo = left;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
if (left < hi) {
|
|
363
|
+
stack.push(left, hi);
|
|
364
|
+
}
|
|
365
|
+
if (lo + 1 < right) {
|
|
366
|
+
hi = right - 1;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (stack.length === 0) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
hi = stack.pop();
|
|
375
|
+
lo = stack.pop();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// String: `this` is the string.
|
|
2
|
+
import { lowerCase, upperCase } from "./case.js";
|
|
3
|
+
import { AS3, conversion, plain } from "./define.js";
|
|
4
|
+
import { compile, matchArray, replacement as replacementOf } from "./regexp.js";
|
|
5
|
+
/** Flash resolves a negative end (start + length) from the string's end. */
|
|
6
|
+
function substr(s, start, length) {
|
|
7
|
+
if (!(length < 0)) {
|
|
8
|
+
return s.substr(start, length);
|
|
9
|
+
}
|
|
10
|
+
const offset = Math.trunc(start) || 0;
|
|
11
|
+
const at = offset < 0 ? Math.max(0, s.length + offset) : Math.min(offset, s.length);
|
|
12
|
+
const end = at + Math.trunc(length);
|
|
13
|
+
return end < 0 ? s.slice(at, end) : "";
|
|
14
|
+
}
|
|
15
|
+
export const stringNatives = {
|
|
16
|
+
"String#get:length": plain(function () {
|
|
17
|
+
return this.length;
|
|
18
|
+
}),
|
|
19
|
+
[`String.${AS3}::fromCharCode`]: (rt) => (...codes) => {
|
|
20
|
+
return String.fromCharCode(...codes.map((c) => rt.toUint(c) & 0xffff));
|
|
21
|
+
},
|
|
22
|
+
[`String#${AS3}::charAt`]: (rt) => function (i = 0) {
|
|
23
|
+
return this.charAt(rt.toNumber(i));
|
|
24
|
+
},
|
|
25
|
+
[`String#${AS3}::charCodeAt`]: (rt) => function (i = 0) {
|
|
26
|
+
return this.charCodeAt(rt.toNumber(i));
|
|
27
|
+
},
|
|
28
|
+
[`String#${AS3}::indexOf`]: (rt) => function (s = "undefined", i = 0) {
|
|
29
|
+
return this.indexOf(rt.toString(s), rt.toNumber(i));
|
|
30
|
+
},
|
|
31
|
+
[`String#${AS3}::lastIndexOf`]: (rt) => function (s = "undefined", i = 0x7fffffff) {
|
|
32
|
+
// As String::lastIndexOf, from INTCLAMP: from before the start nothing matches.
|
|
33
|
+
const at = rt.toNumber(i);
|
|
34
|
+
return at <= -1 ? -1 : this.lastIndexOf(rt.toString(s), at);
|
|
35
|
+
},
|
|
36
|
+
[`String#${AS3}::localeCompare`]: (rt) => function (other) {
|
|
37
|
+
// As String::Compare: the first difference of their character codes,
|
|
38
|
+
// else which is longer.
|
|
39
|
+
const o = rt.toString(other);
|
|
40
|
+
const n = Math.min(this.length, o.length);
|
|
41
|
+
for (let i = 0; i < n; i++) {
|
|
42
|
+
const d = this.charCodeAt(i) - o.charCodeAt(i);
|
|
43
|
+
if (d) {
|
|
44
|
+
return d;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return Math.sign(this.length - o.length);
|
|
48
|
+
},
|
|
49
|
+
[`String#${AS3}::slice`]: (rt) => function (start = 0, end = 0x7fffffff) {
|
|
50
|
+
return this.slice(rt.toNumber(start), rt.toNumber(end));
|
|
51
|
+
},
|
|
52
|
+
[`String#${AS3}::substring`]: (rt) => function (start = 0, end = 0x7fffffff) {
|
|
53
|
+
return this.substring(rt.toNumber(start), rt.toNumber(end));
|
|
54
|
+
},
|
|
55
|
+
[`String#${AS3}::substr`]: (rt) => function (start = 0, length = 0x7fffffff) {
|
|
56
|
+
return substr(this, rt.toNumber(start), rt.toNumber(length));
|
|
57
|
+
},
|
|
58
|
+
[`String#${AS3}::toLowerCase`]: plain(function () {
|
|
59
|
+
return lowerCase(this);
|
|
60
|
+
}),
|
|
61
|
+
[`String#${AS3}::toUpperCase`]: plain(function () {
|
|
62
|
+
return upperCase(this);
|
|
63
|
+
}),
|
|
64
|
+
"String#String::_indexOf": plain(function (s, i = 0) {
|
|
65
|
+
return this.indexOf(s, i);
|
|
66
|
+
}),
|
|
67
|
+
"String#String::_lastIndexOf": plain(function (s, i = 0x7fffffff) {
|
|
68
|
+
return i < 0 ? -1 : this.lastIndexOf(s, i);
|
|
69
|
+
}),
|
|
70
|
+
"String#String::_slice": plain(function (start = 0, end = 0x7fffffff) {
|
|
71
|
+
return this.slice(start, end);
|
|
72
|
+
}),
|
|
73
|
+
"String#String::_substring": plain(function (start = 0, end = 0x7fffffff) {
|
|
74
|
+
return this.substring(start, end);
|
|
75
|
+
}),
|
|
76
|
+
"String#String::_substr": plain(function (start = 0, length = 0x7fffffff) {
|
|
77
|
+
return substr(this, start, length);
|
|
78
|
+
}),
|
|
79
|
+
"String.String::_replace": (rt) => (s, pattern, replacement) => {
|
|
80
|
+
const p = pattern?.$re instanceof RegExp ? pattern.$re : rt.toString(pattern);
|
|
81
|
+
if (replacement !== null && typeof replacement === "object" && replacement.$f) {
|
|
82
|
+
// The function gets the match, its groups, its position and the string.
|
|
83
|
+
return s.replace(p, (...a) => {
|
|
84
|
+
const args = typeof a[a.length - 1] === "object" ? a.slice(0, -1) : a;
|
|
85
|
+
return rt.toString(rt.callValue(replacement, null, args, null));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const text = rt.toString(replacement);
|
|
89
|
+
return s.replace(p, p instanceof RegExp ? replacementOf(p, text) : text);
|
|
90
|
+
},
|
|
91
|
+
// A string pattern is a RegExp's, as avmplus makes one of it.
|
|
92
|
+
"String.String::_search": (rt) => (s, pattern) => s.search(pattern?.$re instanceof RegExp ? pattern.$re : compile(rt.toString(pattern), "")),
|
|
93
|
+
"String.String::_match": (rt) => (s, pattern) => {
|
|
94
|
+
const re = pattern?.$re instanceof RegExp ? pattern.$re : compile(rt.toString(pattern), "");
|
|
95
|
+
if (!re.global) {
|
|
96
|
+
const m = s.match(re);
|
|
97
|
+
return m ? matchArray(rt, m) : null;
|
|
98
|
+
}
|
|
99
|
+
// As RegExpObject::match: each match from where the last ended, until
|
|
100
|
+
// one fails or is empty, so none is an empty Array; lastIndex is then
|
|
101
|
+
// where the last try ended, 0 for a failed one, one on if it was there.
|
|
102
|
+
const old = re.lastIndex;
|
|
103
|
+
const found = [];
|
|
104
|
+
let at = 0;
|
|
105
|
+
for (;;) {
|
|
106
|
+
re.lastIndex = at;
|
|
107
|
+
const m = re.exec(s);
|
|
108
|
+
const last = at;
|
|
109
|
+
at = m ? m.index + m[0].length : 0;
|
|
110
|
+
if (!m || at === last) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
found.push(m[0]);
|
|
114
|
+
}
|
|
115
|
+
re.lastIndex = at === old ? at + 1 : at;
|
|
116
|
+
return rt.array(found);
|
|
117
|
+
},
|
|
118
|
+
"String.String::_split": (rt) => (s, delimiter, limit) => {
|
|
119
|
+
// The empty string splits to itself, whatever the delimiter, as avmplus has it.
|
|
120
|
+
if (s === "") {
|
|
121
|
+
return rt.array(limit === 0 ? [] : [""]);
|
|
122
|
+
}
|
|
123
|
+
if (delimiter?.$re instanceof RegExp) {
|
|
124
|
+
return rt.array(s.split(delimiter.$re, limit >= 0 ? limit : undefined));
|
|
125
|
+
}
|
|
126
|
+
const parts = s.split(rt.toString(delimiter));
|
|
127
|
+
return rt.array(limit >= 0 && limit < parts.length ? parts.slice(0, limit) : parts);
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
export const stringHooks = {
|
|
131
|
+
String: conversion((rt, args) => (args.length ? rt.toString(args[0]) : "")),
|
|
132
|
+
};
|