@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,393 @@
|
|
|
1
|
+
// A field's text laid out as Flash lays it out (docs/architecture/text.md,
|
|
2
|
+
// "Text"): lines, and each character's place on them, in twips, which the
|
|
3
|
+
// metrics, the line and character queries, autoSize and the renderer all
|
|
4
|
+
// read. adl sets the rules, with fonts of rectangles from the tests' SWF
|
|
5
|
+
// writer.
|
|
6
|
+
import { glyphOf } from "../../format/index.js";
|
|
7
|
+
import { deviceMetrics } from "./fonts.js";
|
|
8
|
+
const TWIPS = 20;
|
|
9
|
+
/** The gutter: 2 pixels between the field's edge and its text, each side. */
|
|
10
|
+
export const GUTTER = 2 * TWIPS;
|
|
11
|
+
const BULLET = 36 * TWIPS;
|
|
12
|
+
/** Font units, or pixels for `em` 1, to twips at `size`, truncated as Flash does. */
|
|
13
|
+
function twips(units, size, em) {
|
|
14
|
+
return Math.trunc((units * size * TWIPS) / em);
|
|
15
|
+
}
|
|
16
|
+
/** A whole-pixel size, as a TextFormat keeps it; 0 for none. */
|
|
17
|
+
function sizeOf(format) {
|
|
18
|
+
return Math.max(0, format.size);
|
|
19
|
+
}
|
|
20
|
+
/** The line height a format asks, with no character: its font's ascent and descent. */
|
|
21
|
+
function heightOf(field, format) {
|
|
22
|
+
const size = sizeOf(format);
|
|
23
|
+
if (field.embedFonts) {
|
|
24
|
+
const font = field.fonts?.find(format.font, format.bold, format.italic) ?? null;
|
|
25
|
+
return font?.layout
|
|
26
|
+
? { ascent: twips(font.ascent, size, font.em), descent: twips(font.descent, size, font.em) }
|
|
27
|
+
: { ascent: 0, descent: 0 };
|
|
28
|
+
}
|
|
29
|
+
const m = deviceMetrics(format.font, size, format.bold, format.italic);
|
|
30
|
+
return { ascent: twips(m.ascent, size, size), descent: twips(m.descent, size, size) };
|
|
31
|
+
}
|
|
32
|
+
function measure(field, code, format, previous) {
|
|
33
|
+
const size = sizeOf(format);
|
|
34
|
+
// A TextFormat keeps a spacing of NaN or Infinity as given; laid out, it is none.
|
|
35
|
+
const spacing = Math.trunc(format.letterSpacing * TWIPS) || 0;
|
|
36
|
+
if (field.embedFonts) {
|
|
37
|
+
const font = field.fonts?.find(format.font, format.bold, format.italic) ?? null;
|
|
38
|
+
if (!font?.layout) {
|
|
39
|
+
return {
|
|
40
|
+
font,
|
|
41
|
+
glyph: null,
|
|
42
|
+
advance: 0,
|
|
43
|
+
pen: 0,
|
|
44
|
+
run: false,
|
|
45
|
+
kern: 0,
|
|
46
|
+
ascent: 0,
|
|
47
|
+
descent: 0,
|
|
48
|
+
shown: false,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const ascent = twips(font.ascent, size, font.em);
|
|
52
|
+
const descent = twips(font.descent, size, font.em);
|
|
53
|
+
const glyph = glyphOf(font, code);
|
|
54
|
+
if (!glyph) {
|
|
55
|
+
return {
|
|
56
|
+
font,
|
|
57
|
+
glyph: null,
|
|
58
|
+
advance: 0,
|
|
59
|
+
pen: 0,
|
|
60
|
+
run: false,
|
|
61
|
+
kern: 0,
|
|
62
|
+
ascent,
|
|
63
|
+
descent,
|
|
64
|
+
shown: false,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// A pair's kerning shortens the second character, as adl has it where
|
|
68
|
+
// the pair ends the text. Before another character, adl's boundaries
|
|
69
|
+
// give it to the first instead in normal text, and in advanced text
|
|
70
|
+
// only some of the time: the player keeps to the rule at the end.
|
|
71
|
+
const pair = format.kerning && previous >= 0 ? font.kerning.get((previous << 16) | code) : 0;
|
|
72
|
+
const kern = pair ? twips(pair, size, font.em) : 0;
|
|
73
|
+
// Kerned, the advance and the pair's adjustment are summed in the font's
|
|
74
|
+
// units and truncated once: 230 − 77 units at 11 pixels is 32 twips, not 49 − 16.
|
|
75
|
+
const advance = twips(glyph.advance + (pair || 0), size, font.em) + spacing;
|
|
76
|
+
// Advanced text keeps its pen in fractions of a twip, and only where a
|
|
77
|
+
// character lands is truncated, as adl lays it out: 230 units of a
|
|
78
|
+
// 1024 em at 10 pixels move it 44.92 twips, and eight of them land at
|
|
79
|
+
// 0, 44, 89, 134 and on to 359, not at multiples of 44. Fitting to the
|
|
80
|
+
// pixel grid ("pixel") moves advances only by the font's alignment
|
|
81
|
+
// zones, which the player does not read yet: it is laid out as "none".
|
|
82
|
+
const pen = field.antiAliasType === "advanced"
|
|
83
|
+
? ((glyph.advance + (pair || 0)) * size * TWIPS) / font.em + spacing
|
|
84
|
+
: advance;
|
|
85
|
+
return { font, glyph, advance, pen, run: false, kern, ascent, descent, shown: true };
|
|
86
|
+
}
|
|
87
|
+
const m = deviceMetrics(format.font, size, format.bold, format.italic);
|
|
88
|
+
const advance = twips(m.advance(String.fromCharCode(code)), size, size) + spacing;
|
|
89
|
+
return {
|
|
90
|
+
font: null,
|
|
91
|
+
glyph: null,
|
|
92
|
+
advance,
|
|
93
|
+
pen: advance,
|
|
94
|
+
run: false,
|
|
95
|
+
kern: 0,
|
|
96
|
+
ascent: twips(m.ascent, size, size),
|
|
97
|
+
descent: twips(m.descent, size, size),
|
|
98
|
+
shown: true,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The field's text in lines: broken at each newline, and with word wrap
|
|
103
|
+
* before a word that does not fit without its trailing spaces (one that
|
|
104
|
+
* ends at the room's edge fits), or between the characters of a
|
|
105
|
+
* word longer than the line.
|
|
106
|
+
*/
|
|
107
|
+
export function layoutText(field) {
|
|
108
|
+
const { text, formats } = field;
|
|
109
|
+
const lines = [];
|
|
110
|
+
let y = GUTTER;
|
|
111
|
+
let start = 0;
|
|
112
|
+
do {
|
|
113
|
+
let end = text.indexOf("\r", start);
|
|
114
|
+
const newline = end >= 0;
|
|
115
|
+
end = newline ? end : text.length;
|
|
116
|
+
const format = formats[start] ?? field.defaultFormat;
|
|
117
|
+
const measures = [];
|
|
118
|
+
for (let i = start; i < end; i++) {
|
|
119
|
+
const glyphs = measures[i - start - 1];
|
|
120
|
+
const previous = i > start && glyphs?.shown ? text.charCodeAt(i - 1) : -1;
|
|
121
|
+
const m = measure(field, text.charCodeAt(i), formats[i], previous);
|
|
122
|
+
m.run = i > start && newRun(formats[i - 1], formats[i]);
|
|
123
|
+
measures.push(m);
|
|
124
|
+
}
|
|
125
|
+
// The paragraph's lines: [from, to) of its characters each.
|
|
126
|
+
// A bullet's paragraph is set in 36 pixels, as adl sets it.
|
|
127
|
+
const bullet = format.bullet ? BULLET : 0;
|
|
128
|
+
const room = Math.trunc(field.width * TWIPS) -
|
|
129
|
+
2 * GUTTER -
|
|
130
|
+
bullet -
|
|
131
|
+
Math.trunc((format.leftMargin + format.rightMargin + format.blockIndent) * TWIPS);
|
|
132
|
+
// A negative indent, a hanging one, moves the first line left, as far
|
|
133
|
+
// as the gutter, and gives it no more room, as adl lays it out.
|
|
134
|
+
const indent = Math.trunc(format.indent * TWIPS);
|
|
135
|
+
const firstRoom = room - Math.max(0, indent);
|
|
136
|
+
const margin = Math.trunc((format.leftMargin + format.blockIndent) * TWIPS);
|
|
137
|
+
const breaks = [];
|
|
138
|
+
let from = 0;
|
|
139
|
+
while (from < measures.length || breaks.length === 0) {
|
|
140
|
+
let to = measures.length;
|
|
141
|
+
if (field.wordWrap) {
|
|
142
|
+
to = wrap(text, start, measures, from, breaks.length === 0 ? firstRoom : room);
|
|
143
|
+
}
|
|
144
|
+
breaks.push([from, to]);
|
|
145
|
+
from = to;
|
|
146
|
+
if (from >= measures.length) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
for (const [k, [a, b]] of breaks.entries()) {
|
|
151
|
+
const chars = [];
|
|
152
|
+
let x = 0;
|
|
153
|
+
let pen = 0;
|
|
154
|
+
let ascent = 0;
|
|
155
|
+
let descent = 0;
|
|
156
|
+
for (let i = a; i < b; i++) {
|
|
157
|
+
const m = measures[i];
|
|
158
|
+
// A run of another size starts where the last one's text landed, as
|
|
159
|
+
// adl lays advanced text out: 10, 13 and 17 pixels in one line.
|
|
160
|
+
const at = m.run ? x : pen;
|
|
161
|
+
pen = at + m.pen;
|
|
162
|
+
// A pen a negative spacing took left of 0 lands at 0, not -0.
|
|
163
|
+
const next = Math.trunc(pen) || 0;
|
|
164
|
+
chars.push({
|
|
165
|
+
index: start + i,
|
|
166
|
+
x,
|
|
167
|
+
at,
|
|
168
|
+
advance: next - x,
|
|
169
|
+
kern: m.kern,
|
|
170
|
+
font: m.font,
|
|
171
|
+
glyph: m.glyph,
|
|
172
|
+
shown: m.shown,
|
|
173
|
+
format: formats[start + i],
|
|
174
|
+
});
|
|
175
|
+
x = next;
|
|
176
|
+
ascent = Math.max(ascent, m.ascent);
|
|
177
|
+
descent = Math.max(descent, m.descent);
|
|
178
|
+
}
|
|
179
|
+
if (a === b) {
|
|
180
|
+
({ ascent, descent } = heightOf(field, formats[start + a] ?? format));
|
|
181
|
+
}
|
|
182
|
+
const last = k === breaks.length - 1;
|
|
183
|
+
const lineEnd = last && newline ? end + 1 : start + b;
|
|
184
|
+
if (last && newline) {
|
|
185
|
+
chars.push({
|
|
186
|
+
index: end,
|
|
187
|
+
x,
|
|
188
|
+
at: x,
|
|
189
|
+
advance: 0,
|
|
190
|
+
kern: 0,
|
|
191
|
+
font: null,
|
|
192
|
+
glyph: null,
|
|
193
|
+
shown: false,
|
|
194
|
+
format: formats[end],
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const left = GUTTER + bullet + (k === 0 ? Math.max(0, margin + indent) : margin);
|
|
198
|
+
const lineRoom = k === 0 ? firstRoom : room;
|
|
199
|
+
const space = lineRoom - x;
|
|
200
|
+
// Justified, a wrapped line but the paragraph's last has its inner
|
|
201
|
+
// spaces share the room left, its trailing spaces out.
|
|
202
|
+
if (format.align === "justify" && !last) {
|
|
203
|
+
x = justify(text, chars, lineRoom);
|
|
204
|
+
}
|
|
205
|
+
// Centred in the room left; right-aligned, one twip further left, as adl places it.
|
|
206
|
+
const align = format.align === "center"
|
|
207
|
+
? Math.trunc(space / 2)
|
|
208
|
+
: format.align === "right"
|
|
209
|
+
? space - 1
|
|
210
|
+
: 0;
|
|
211
|
+
const lineX = left + Math.max(0, align);
|
|
212
|
+
for (const c of chars) {
|
|
213
|
+
c.x += lineX;
|
|
214
|
+
c.at += lineX;
|
|
215
|
+
}
|
|
216
|
+
const leading = Math.trunc(format.leading * TWIPS);
|
|
217
|
+
lines.push({
|
|
218
|
+
start: start + a,
|
|
219
|
+
end: lineEnd,
|
|
220
|
+
x: lineX,
|
|
221
|
+
y,
|
|
222
|
+
width: x,
|
|
223
|
+
ascent,
|
|
224
|
+
descent,
|
|
225
|
+
leading,
|
|
226
|
+
chars,
|
|
227
|
+
});
|
|
228
|
+
y += ascent + descent + leading;
|
|
229
|
+
}
|
|
230
|
+
start = end + 1;
|
|
231
|
+
if (!newline) {
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
// A newline at the end leaves an empty line after it.
|
|
235
|
+
if (start === text.length) {
|
|
236
|
+
const f = formats[end] ?? field.defaultFormat;
|
|
237
|
+
const { ascent, descent } = heightOf(field, f);
|
|
238
|
+
lines.push({
|
|
239
|
+
start,
|
|
240
|
+
end: start,
|
|
241
|
+
x: GUTTER +
|
|
242
|
+
Math.max(0, Math.trunc((f.leftMargin + f.blockIndent) * TWIPS) + Math.trunc(f.indent * TWIPS)),
|
|
243
|
+
y,
|
|
244
|
+
width: 0,
|
|
245
|
+
ascent,
|
|
246
|
+
descent,
|
|
247
|
+
leading: Math.trunc(f.leading * TWIPS),
|
|
248
|
+
chars: [],
|
|
249
|
+
});
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
} while (start <= text.length);
|
|
253
|
+
return { lines, width: textWidth(lines), height: textHeight(text, lines, field.input) };
|
|
254
|
+
}
|
|
255
|
+
/** A justified line's characters placed: its inner spaces widened alike to fill `room`; its width. */
|
|
256
|
+
function justify(text, chars, room) {
|
|
257
|
+
let end = chars.length;
|
|
258
|
+
while (end > 0 && text[chars[end - 1].index] === " ") {
|
|
259
|
+
end--;
|
|
260
|
+
}
|
|
261
|
+
let width = 0;
|
|
262
|
+
let spaces = 0;
|
|
263
|
+
for (let i = 0; i < end; i++) {
|
|
264
|
+
width += chars[i].advance;
|
|
265
|
+
if (text[chars[i].index] === " ") {
|
|
266
|
+
spaces++;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (spaces > 0 && room > width) {
|
|
270
|
+
const extra = Math.trunc((room - width) / spaces);
|
|
271
|
+
for (let i = 0; i < end; i++) {
|
|
272
|
+
if (text[chars[i].index] === " ") {
|
|
273
|
+
chars[i].advance += extra;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
let x = 0;
|
|
278
|
+
for (const c of chars) {
|
|
279
|
+
c.x = x;
|
|
280
|
+
c.at = x;
|
|
281
|
+
x += c.advance;
|
|
282
|
+
}
|
|
283
|
+
return x;
|
|
284
|
+
}
|
|
285
|
+
/** The end, exclusive, of a wrapped line from `from` with `room` twips. */
|
|
286
|
+
function wrap(text, start, measures, from, room) {
|
|
287
|
+
let width = 0;
|
|
288
|
+
let i = from;
|
|
289
|
+
while (i < measures.length) {
|
|
290
|
+
// The next word, measured only until it runs past the room: a word
|
|
291
|
+
// longer than many lines is not measured again for each of them.
|
|
292
|
+
let wordEnd = i;
|
|
293
|
+
let wordWidth = width;
|
|
294
|
+
while (wordEnd < measures.length && text[start + wordEnd] !== " ") {
|
|
295
|
+
const m = measures[wordEnd];
|
|
296
|
+
wordWidth = (m.run ? Math.trunc(wordWidth) : wordWidth) + m.pen;
|
|
297
|
+
if (Math.trunc(wordWidth) > room) {
|
|
298
|
+
// On a line of its own, it breaks before the character that runs past, one at least.
|
|
299
|
+
return i > from ? i : Math.max(wordEnd, from + 1);
|
|
300
|
+
}
|
|
301
|
+
wordEnd++;
|
|
302
|
+
}
|
|
303
|
+
width = wordWidth;
|
|
304
|
+
i = wordEnd;
|
|
305
|
+
while (i < measures.length && text[start + i] === " ") {
|
|
306
|
+
const m = measures[i];
|
|
307
|
+
width = (m.run ? Math.trunc(width) : width) + m.pen;
|
|
308
|
+
i++;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return measures.length;
|
|
312
|
+
}
|
|
313
|
+
/** Whether `b` lays out in another run from `a`: another font, size, style or spacing. */
|
|
314
|
+
function newRun(a, b) {
|
|
315
|
+
return (a !== b &&
|
|
316
|
+
(a.font !== b.font ||
|
|
317
|
+
a.size !== b.size ||
|
|
318
|
+
a.bold !== b.bold ||
|
|
319
|
+
a.italic !== b.italic ||
|
|
320
|
+
a.letterSpacing !== b.letterSpacing));
|
|
321
|
+
}
|
|
322
|
+
function textWidth(lines) {
|
|
323
|
+
let width = 0;
|
|
324
|
+
for (const line of lines) {
|
|
325
|
+
width = Math.max(width, line.width);
|
|
326
|
+
}
|
|
327
|
+
return width;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The lines' heights, leading and all, but for the last one's leading
|
|
331
|
+
* where there are two lines or more, as adl counts them; an empty field
|
|
332
|
+
* counts nothing, and the empty line a final newline leaves counts only
|
|
333
|
+
* in an input field, where the caret can stand on it.
|
|
334
|
+
*/
|
|
335
|
+
function textHeight(text, lines, input) {
|
|
336
|
+
if (text.length === 0) {
|
|
337
|
+
return 0;
|
|
338
|
+
}
|
|
339
|
+
const counted = text.endsWith("\r") && !input ? lines.slice(0, -1) : lines;
|
|
340
|
+
let height = 0;
|
|
341
|
+
for (const line of counted) {
|
|
342
|
+
height += line.ascent + line.descent + line.leading;
|
|
343
|
+
}
|
|
344
|
+
return counted.length > 1 ? height - counted[counted.length - 1].leading : height;
|
|
345
|
+
}
|
|
346
|
+
/** The line a character is on: the last one starting at or before it. */
|
|
347
|
+
export function lineOf(layout, index) {
|
|
348
|
+
let lo = 0;
|
|
349
|
+
let hi = layout.lines.length - 1;
|
|
350
|
+
while (lo < hi) {
|
|
351
|
+
const mid = (lo + hi + 1) >> 1;
|
|
352
|
+
if (layout.lines[mid].start <= index) {
|
|
353
|
+
lo = mid;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
hi = mid - 1;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return lo;
|
|
360
|
+
}
|
|
361
|
+
/** The lines of a field's layout that fit its height from line `first`: one at least. */
|
|
362
|
+
export function shownLines(field, first) {
|
|
363
|
+
const lines = field.layout.lines;
|
|
364
|
+
const room = field.height * TWIPS - 2 * GUTTER;
|
|
365
|
+
let n = 0;
|
|
366
|
+
let used = 0;
|
|
367
|
+
for (let i = first; i < lines.length; i++) {
|
|
368
|
+
used += lines[i].ascent + lines[i].descent;
|
|
369
|
+
if (n > 0 && used > room) {
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
used += lines[i].leading;
|
|
373
|
+
n++;
|
|
374
|
+
}
|
|
375
|
+
return Math.max(1, n);
|
|
376
|
+
}
|
|
377
|
+
/** The last first line a scroll can show: the lines after it fit the field's height. */
|
|
378
|
+
export function maxScrollV(field) {
|
|
379
|
+
const lines = field.layout.lines;
|
|
380
|
+
const room = field.height * TWIPS - 2 * GUTTER;
|
|
381
|
+
let used = 0;
|
|
382
|
+
let first = lines.length;
|
|
383
|
+
while (first > 0) {
|
|
384
|
+
const line = lines[first - 1];
|
|
385
|
+
const next = used + line.ascent + line.descent + (first < lines.length ? line.leading : 0);
|
|
386
|
+
if (next > room && first < lines.length) {
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
used = next;
|
|
390
|
+
first--;
|
|
391
|
+
}
|
|
392
|
+
return Math.max(1, first + 1);
|
|
393
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { flatten, inside, shapeLayers } from "../display/shapes.js";
|
|
2
|
+
/**
|
|
3
|
+
* The text's glyphs as placed, each record keeping what the one before set,
|
|
4
|
+
* transparent and at the origin until one sets it, as adl draws a text that
|
|
5
|
+
* sets no colour as nothing. A glyph of a font the SWF lacks, of none, or
|
|
6
|
+
* past its font's glyphs, is not drawn and does not move the pen. `text` is
|
|
7
|
+
* the glyphs' characters, a line feed before a record's first where its
|
|
8
|
+
* line is not the last glyph's, as adl reads it; null where a glyph has no
|
|
9
|
+
* font or character mapping, or there are none. (adl reads a glyph past
|
|
10
|
+
* its font as some other character; the player reads the text as null.)
|
|
11
|
+
*/
|
|
12
|
+
export function placeGlyphs(character, characters) {
|
|
13
|
+
const glyphs = [];
|
|
14
|
+
const chars = [];
|
|
15
|
+
let unknown = false;
|
|
16
|
+
let font = null;
|
|
17
|
+
let color = 0;
|
|
18
|
+
let height = 0;
|
|
19
|
+
let x = 0;
|
|
20
|
+
let y = 0;
|
|
21
|
+
let lineY = null;
|
|
22
|
+
for (const record of character.definition.records) {
|
|
23
|
+
if (record.font !== null) {
|
|
24
|
+
const c = characters.get(record.font);
|
|
25
|
+
font = c?.type === "font" ? c.font : null;
|
|
26
|
+
height = record.height ?? height;
|
|
27
|
+
}
|
|
28
|
+
color = record.color ?? color;
|
|
29
|
+
x = record.x ?? x;
|
|
30
|
+
y = record.y ?? y;
|
|
31
|
+
for (const { index, advance } of record.glyphs) {
|
|
32
|
+
const glyph = font?.glyphs[index];
|
|
33
|
+
if (!font || !glyph) {
|
|
34
|
+
unknown = true;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (lineY !== null && lineY !== y) {
|
|
38
|
+
chars.push("\n");
|
|
39
|
+
}
|
|
40
|
+
lineY = y;
|
|
41
|
+
glyphs.push({ font, glyph, x, y, height, color });
|
|
42
|
+
if (glyph.code < 0) {
|
|
43
|
+
unknown = true;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
chars.push(String.fromCharCode(glyph.code));
|
|
47
|
+
}
|
|
48
|
+
x += advance;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const text = unknown || glyphs.length === 0 ? null : chars.join("");
|
|
52
|
+
return { glyphs, text };
|
|
53
|
+
}
|
|
54
|
+
/** A glyph's outline as contours, in the font's units over 20, as shapeLayers reads twips; cached. */
|
|
55
|
+
const outlines = new WeakMap();
|
|
56
|
+
function outlineOf(glyph) {
|
|
57
|
+
let contours = outlines.get(glyph);
|
|
58
|
+
if (!contours) {
|
|
59
|
+
const shape = {
|
|
60
|
+
id: 0,
|
|
61
|
+
bounds: { xMin: 0, xMax: 0, yMin: 0, yMax: 0 },
|
|
62
|
+
edgeBounds: null,
|
|
63
|
+
fills: [{ type: "solid", color: 0xffffffff }],
|
|
64
|
+
lines: [],
|
|
65
|
+
records: glyph.records,
|
|
66
|
+
truncated: false,
|
|
67
|
+
};
|
|
68
|
+
contours = shapeLayers(shape).flatMap((layer) => layer.fills.flatMap((f) => f.contours));
|
|
69
|
+
outlines.set(glyph, contours);
|
|
70
|
+
}
|
|
71
|
+
return contours;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Whether the point (x, y), in the text's own pixels, is on one of its
|
|
75
|
+
* glyphs: Flash hits static text by its glyphs' outlines, not its bounds,
|
|
76
|
+
* and a glyph it draws transparent not at all, but as a mask, which clips
|
|
77
|
+
* by its fills whatever their colour.
|
|
78
|
+
*/
|
|
79
|
+
export function hitsGlyph(character, glyphs, x, y, mask = false) {
|
|
80
|
+
const m = character.definition.matrix;
|
|
81
|
+
const det = m.a * m.d - m.b * m.c;
|
|
82
|
+
if (det === 0) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
// Into the text's space, in twips, through the inverse of its matrix.
|
|
86
|
+
const px = x * 20 - m.tx;
|
|
87
|
+
const py = y * 20 - m.ty;
|
|
88
|
+
const tx = (m.d * px - m.c * py) / det;
|
|
89
|
+
const ty = (m.a * py - m.b * px) / det;
|
|
90
|
+
for (const g of glyphs) {
|
|
91
|
+
if ((!mask && g.color >>> 24 === 0) || g.height === 0) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// Into the glyph's outline: the font's units, over 20.
|
|
95
|
+
const scale = g.height / g.font.em;
|
|
96
|
+
const gx = (tx - g.x) / scale / 20;
|
|
97
|
+
const gy = (ty - g.y) / scale / 20;
|
|
98
|
+
let crossings = 0;
|
|
99
|
+
for (const contour of outlineOf(g.glyph)) {
|
|
100
|
+
if (inside(flatten(contour), gx, gy)) {
|
|
101
|
+
crossings++;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (crossings % 2) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|