@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,592 @@
|
|
|
1
|
+
import { apply, concat } from "./geometry.js";
|
|
2
|
+
import { CUBIC, CURVE, LINE, } from "./shapes.js";
|
|
3
|
+
const TWIPS = 20;
|
|
4
|
+
const IDENTITY_MATRIX = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
|
|
5
|
+
/** The matrix adl reads back for a gradient begun with none: a 200-pixel square about the origin. */
|
|
6
|
+
const DEFAULT_GRADIENT = {
|
|
7
|
+
a: 100 / 819.2,
|
|
8
|
+
b: 0,
|
|
9
|
+
c: 0,
|
|
10
|
+
d: 100 / 819.2,
|
|
11
|
+
tx: 0,
|
|
12
|
+
ty: 0,
|
|
13
|
+
};
|
|
14
|
+
/** What a cubic may stray from the quadratics that stand for it, in twips, before it is split again. */
|
|
15
|
+
const CUBIC_TOLERANCE = 50;
|
|
16
|
+
/** A 0xAARRGGBB colour back from Flash's premultiplied store: the alpha a byte, each channel through it and back. */
|
|
17
|
+
export function storedColor(argb) {
|
|
18
|
+
const a = argb >>> 24;
|
|
19
|
+
if (a === 0) {
|
|
20
|
+
return { color: 0, alpha: 0 };
|
|
21
|
+
}
|
|
22
|
+
// Fitted to all 256 levels of a channel at nine alphas in adl.
|
|
23
|
+
const back = Math.floor(65280 / a);
|
|
24
|
+
let color = 0;
|
|
25
|
+
for (const shift of [16, 8, 0]) {
|
|
26
|
+
const premultiplied = (((argb >>> shift) & 0xff) * (a + 1)) >> 8;
|
|
27
|
+
color |= Math.min(255, (premultiplied * back + 127) >> 8) << shift;
|
|
28
|
+
}
|
|
29
|
+
return { color, alpha: a / 255 };
|
|
30
|
+
}
|
|
31
|
+
function datumOf(paint, m, defaults) {
|
|
32
|
+
switch (paint.type) {
|
|
33
|
+
case "solid":
|
|
34
|
+
return { type: "solid", ...storedColor(paint.color) };
|
|
35
|
+
case "gradient": {
|
|
36
|
+
const g = concat(defaults.has(paint) ? DEFAULT_GRADIENT : paint.matrix, m);
|
|
37
|
+
// The linear part in single floats and the offset in whole pixels, toward zero.
|
|
38
|
+
return {
|
|
39
|
+
type: "gradient",
|
|
40
|
+
radial: paint.radial,
|
|
41
|
+
colors: paint.stops.map((s) => s.color >>> 0),
|
|
42
|
+
alphas: paint.stops.map((s) => (s.color >>> 24) / 255),
|
|
43
|
+
ratios: paint.stops.map((s) => s.ratio),
|
|
44
|
+
matrix: {
|
|
45
|
+
a: Math.fround(g.a),
|
|
46
|
+
b: Math.fround(g.b),
|
|
47
|
+
c: Math.fround(g.c),
|
|
48
|
+
d: Math.fround(g.d),
|
|
49
|
+
tx: Math.trunc(g.tx),
|
|
50
|
+
ty: Math.trunc(g.ty),
|
|
51
|
+
},
|
|
52
|
+
spread: paint.spread === 1 ? "reflect" : paint.spread === 2 ? "repeat" : "pad",
|
|
53
|
+
linearRgb: paint.linearRgb,
|
|
54
|
+
focal: paint.radial ? Math.round(Math.max(-1, Math.min(1, paint.focal)) * 255) / 255 : 0,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case "image": {
|
|
58
|
+
// A bitmap's matrix comes back 4095/4096 of itself, its offset in whole pixels.
|
|
59
|
+
const b = concat(paint.matrix, m);
|
|
60
|
+
const k = 4095 / 4096;
|
|
61
|
+
return {
|
|
62
|
+
type: "bitmap",
|
|
63
|
+
image: paint.image,
|
|
64
|
+
matrix: {
|
|
65
|
+
a: Math.fround(b.a * k),
|
|
66
|
+
b: Math.fround(b.b * k),
|
|
67
|
+
c: Math.fround(b.c * k),
|
|
68
|
+
d: Math.fround(b.d * k),
|
|
69
|
+
tx: Math.round(b.tx * k),
|
|
70
|
+
ty: Math.round(b.ty * k),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
default:
|
|
75
|
+
return { type: "bitmap", image: null, matrix: IDENTITY_MATRIX };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** A path as Flash writes it out, in twips: a move to where the pen is goes, and a curve along its chord is a line. */
|
|
79
|
+
class Writer {
|
|
80
|
+
commands = [];
|
|
81
|
+
data = [];
|
|
82
|
+
x = Number.NaN;
|
|
83
|
+
y = Number.NaN;
|
|
84
|
+
move(x, y) {
|
|
85
|
+
if (x !== this.x || y !== this.y) {
|
|
86
|
+
this.commands.push(1);
|
|
87
|
+
this.to(x, y);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
line(x, y) {
|
|
91
|
+
this.commands.push(2);
|
|
92
|
+
this.to(x, y);
|
|
93
|
+
}
|
|
94
|
+
curve(cx, cy, x, y) {
|
|
95
|
+
if (Math.abs(2 * cx - this.x - x) <= 1 && Math.abs(2 * cy - this.y - y) <= 1) {
|
|
96
|
+
this.line(x, y);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.commands.push(3);
|
|
100
|
+
this.data.push(cx / TWIPS, cy / TWIPS);
|
|
101
|
+
this.to(x, y);
|
|
102
|
+
}
|
|
103
|
+
to(x, y) {
|
|
104
|
+
this.data.push(x / TWIPS, y / TWIPS);
|
|
105
|
+
this.x = x;
|
|
106
|
+
this.y = y;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A cubic as Flash keeps it: split in halves until a quadratic for each
|
|
111
|
+
* part strays under the tolerance, the error going down eightfold with
|
|
112
|
+
* each halving, and each part the quadratic of its cubic's middle.
|
|
113
|
+
*/
|
|
114
|
+
function cubicSegments(out, p0, c1, c2, p3) {
|
|
115
|
+
const ex = p3[0] - 3 * c2[0] + 3 * c1[0] - p0[0];
|
|
116
|
+
const ey = p3[1] - 3 * c2[1] + 3 * c1[1] - p0[1];
|
|
117
|
+
const error = Math.hypot(ex, ey);
|
|
118
|
+
let n = 1;
|
|
119
|
+
while (error / n ** 3 > CUBIC_TOLERANCE && n < 1024) {
|
|
120
|
+
n *= 2;
|
|
121
|
+
}
|
|
122
|
+
const at = (t, k) => {
|
|
123
|
+
const u = 1 - t;
|
|
124
|
+
return u * u * u * p0[k] + 3 * u * u * t * c1[k] + 3 * u * t * t * c2[k] + t * t * t * p3[k];
|
|
125
|
+
};
|
|
126
|
+
const slope = (t, k) => {
|
|
127
|
+
const u = 1 - t;
|
|
128
|
+
return 3 * (u * u * (c1[k] - p0[k]) + 2 * u * t * (c2[k] - c1[k]) + t * t * (p3[k] - c2[k]));
|
|
129
|
+
};
|
|
130
|
+
let x = Math.round(p0[0]);
|
|
131
|
+
let y = Math.round(p0[1]);
|
|
132
|
+
for (let i = 0; i < n; i++) {
|
|
133
|
+
const t0 = i / n;
|
|
134
|
+
const t1 = (i + 1) / n;
|
|
135
|
+
const third = 1 / (3 * n);
|
|
136
|
+
const control = [0, 1].map((k) => {
|
|
137
|
+
const a = at(t0, k);
|
|
138
|
+
const d = at(t1, k);
|
|
139
|
+
return (3 * (a + slope(t0, k) * third + d - slope(t1, k) * third) - (a + d)) / 4;
|
|
140
|
+
});
|
|
141
|
+
const x1 = Math.round(at(t1, 0));
|
|
142
|
+
const y1 = Math.round(at(t1, 1));
|
|
143
|
+
out.push({
|
|
144
|
+
x0: x,
|
|
145
|
+
y0: y,
|
|
146
|
+
curve: true,
|
|
147
|
+
cx: Math.round(control[0]),
|
|
148
|
+
cy: Math.round(control[1]),
|
|
149
|
+
x1,
|
|
150
|
+
y1,
|
|
151
|
+
});
|
|
152
|
+
x = x1;
|
|
153
|
+
y = y1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** A path's segments through `m`, in whole twips. */
|
|
157
|
+
function segmentsOf(path, m) {
|
|
158
|
+
const out = [];
|
|
159
|
+
const point = (i) => {
|
|
160
|
+
const [x, y] = apply(m, path[i], path[i + 1]);
|
|
161
|
+
return [x * TWIPS, y * TWIPS];
|
|
162
|
+
};
|
|
163
|
+
let [x, y] = point(1);
|
|
164
|
+
for (let i = 3; i < path.length;) {
|
|
165
|
+
const command = path[i];
|
|
166
|
+
if (command === LINE) {
|
|
167
|
+
const [x1, y1] = point(i + 1);
|
|
168
|
+
out.push({ x0: Math.round(x), y0: Math.round(y), curve: false, cx: 0, cy: 0, x1, y1 });
|
|
169
|
+
[x, y] = [x1, y1];
|
|
170
|
+
i += 3;
|
|
171
|
+
}
|
|
172
|
+
else if (command === CURVE) {
|
|
173
|
+
const [cx, cy] = point(i + 1);
|
|
174
|
+
const [x1, y1] = point(i + 3);
|
|
175
|
+
out.push({ x0: Math.round(x), y0: Math.round(y), curve: true, cx, cy, x1, y1 });
|
|
176
|
+
[x, y] = [x1, y1];
|
|
177
|
+
i += 5;
|
|
178
|
+
}
|
|
179
|
+
else if (command === CUBIC) {
|
|
180
|
+
const p3 = point(i + 5);
|
|
181
|
+
cubicSegments(out, [x, y], point(i + 1), point(i + 3), p3);
|
|
182
|
+
[x, y] = p3;
|
|
183
|
+
i += 7;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const s of out) {
|
|
190
|
+
s.cx = Math.round(s.cx);
|
|
191
|
+
s.cy = Math.round(s.cy);
|
|
192
|
+
s.x1 = Math.round(s.x1);
|
|
193
|
+
s.y1 = Math.round(s.y1);
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
function writeSegment(w, s) {
|
|
198
|
+
if (s.curve) {
|
|
199
|
+
w.curve(s.cx, s.cy, s.x1, s.y1);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
w.line(s.x1, s.y1);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A fill's contours in the order Flash links its edges back up: one that
|
|
207
|
+
* starts where the last ended follows it, before the rest in their order.
|
|
208
|
+
*/
|
|
209
|
+
function writeContours(w, contours, m) {
|
|
210
|
+
const left = contours.map((c) => segmentsOf(c, m)).filter((c) => c.length);
|
|
211
|
+
while (left.length) {
|
|
212
|
+
let next = left.findIndex((c) => c[0].x0 === w.x && c[0].y0 === w.y);
|
|
213
|
+
if (next < 0) {
|
|
214
|
+
next = 0;
|
|
215
|
+
}
|
|
216
|
+
writeContour(w, left.splice(next, 1)[0]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* A fill's contour, as Flash keeps it: one left open along a line, which
|
|
221
|
+
* encloses nothing, is dropped; one left open otherwise is closed with a
|
|
222
|
+
* line.
|
|
223
|
+
*/
|
|
224
|
+
function writeContour(w, segments) {
|
|
225
|
+
const first = segments[0];
|
|
226
|
+
const last = segments[segments.length - 1];
|
|
227
|
+
const closed = last.x1 === first.x0 && last.y1 === first.y0;
|
|
228
|
+
if (!closed && !bent(segments)) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
w.move(first.x0, first.y0);
|
|
232
|
+
for (const s of segments) {
|
|
233
|
+
writeSegment(w, s);
|
|
234
|
+
}
|
|
235
|
+
if (!closed) {
|
|
236
|
+
w.line(first.x0, first.y0);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/** Whether a contour's points, control points too, leave the line through its first two. */
|
|
240
|
+
function bent(segments) {
|
|
241
|
+
const x0 = segments[0].x0;
|
|
242
|
+
const y0 = segments[0].y0;
|
|
243
|
+
let dx = 0;
|
|
244
|
+
let dy = 0;
|
|
245
|
+
for (const s of segments) {
|
|
246
|
+
for (const [x, y] of s.curve
|
|
247
|
+
? [
|
|
248
|
+
[s.cx, s.cy],
|
|
249
|
+
[s.x1, s.y1],
|
|
250
|
+
]
|
|
251
|
+
: [[s.x1, s.y1]]) {
|
|
252
|
+
if (!dx && !dy) {
|
|
253
|
+
[dx, dy] = [x - x0, y - y0];
|
|
254
|
+
}
|
|
255
|
+
else if (dx * (y - y0) !== dy * (x - x0)) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Lines thinner than a pixel and a half are a whole pixel or a hairline:
|
|
264
|
+
* adl strokes every line at its width rounded to a whole pixel, half to
|
|
265
|
+
* even, and a line that scales neither way a fifth as wide.
|
|
266
|
+
*/
|
|
267
|
+
function halfWidth(line) {
|
|
268
|
+
const pixels = line.width / TWIPS;
|
|
269
|
+
let whole = Math.round(pixels);
|
|
270
|
+
if (Math.abs(pixels % 1) === 0.5 && whole % 2) {
|
|
271
|
+
whole--;
|
|
272
|
+
}
|
|
273
|
+
return line.noHScale && line.noVScale ? whole * 2 : whole * 10;
|
|
274
|
+
}
|
|
275
|
+
const unit = (x, y) => {
|
|
276
|
+
const l = Math.hypot(x, y);
|
|
277
|
+
return l ? [x / l, y / l] : [0, 0];
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* The outline of a line's path, as Flash builds it to fill: from the end
|
|
281
|
+
* of the first segment's +n side back along it, around the start cap, out
|
|
282
|
+
* along every -n side to the end cap, and back along the +n sides; a path
|
|
283
|
+
* that ends where it starts is two contours instead, its +n sides and its
|
|
284
|
+
* -n sides, joined all around. Joins are drawn on the outer side of a
|
|
285
|
+
* turn, the inner side going straight across; round ones, and round caps,
|
|
286
|
+
* are arcs of at most 45° a quadratic, whose on-curve points lie halfway
|
|
287
|
+
* between their control points in whole twips.
|
|
288
|
+
*/
|
|
289
|
+
function writeStroke(w, segments, line) {
|
|
290
|
+
const h = halfWidth(line);
|
|
291
|
+
const hairline = h === 0;
|
|
292
|
+
const parts = [];
|
|
293
|
+
for (const s of segments) {
|
|
294
|
+
if (s.x0 === s.x1 && s.y0 === s.y1 && (!s.curve || (s.cx === s.x0 && s.cy === s.y0))) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const t0 = s.curve && (s.cx !== s.x0 || s.cy !== s.y0)
|
|
298
|
+
? unit(s.cx - s.x0, s.cy - s.y0)
|
|
299
|
+
: unit(s.x1 - s.x0, s.y1 - s.y0);
|
|
300
|
+
const t1 = s.curve && (s.cx !== s.x1 || s.cy !== s.y1)
|
|
301
|
+
? unit(s.x1 - s.cx, s.y1 - s.cy)
|
|
302
|
+
: unit(s.x1 - s.x0, s.y1 - s.y0);
|
|
303
|
+
parts.push({
|
|
304
|
+
segment: s,
|
|
305
|
+
t0,
|
|
306
|
+
t1,
|
|
307
|
+
plus: offset(s, t0, t1, h, 1, hairline),
|
|
308
|
+
minus: offset(s, t0, t1, h, -1, hairline),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (!parts.length) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const first = parts[0];
|
|
315
|
+
const last = parts[parts.length - 1];
|
|
316
|
+
const closed = parts.length > 1 &&
|
|
317
|
+
last.segment.x1 === first.segment.x0 &&
|
|
318
|
+
last.segment.y1 === first.segment.y0;
|
|
319
|
+
const cap = hairline ? 1 : line.startCap;
|
|
320
|
+
const join = hairline ? 1 : line.join;
|
|
321
|
+
const limit = Math.max(1, line.miterLimit);
|
|
322
|
+
// The inner side's joins that go nowhere, which Flash leaves to the end as contours of their own.
|
|
323
|
+
const stray = [];
|
|
324
|
+
const joinTo = (a, b, side, forward) => {
|
|
325
|
+
const s = a.segment;
|
|
326
|
+
const cross = a.t1[0] * b.t0[1] - a.t1[1] * b.t0[0];
|
|
327
|
+
const from = forward ? (side > 0 ? a.plus : a.minus) : side > 0 ? b.plus : b.minus;
|
|
328
|
+
const to = forward ? (side > 0 ? b.plus : b.minus) : side > 0 ? a.plus : a.minus;
|
|
329
|
+
const [fx, fy] = forward ? [from.x1, from.y1] : [from.x0, from.y0];
|
|
330
|
+
const [tx, ty] = forward ? [to.x0, to.y0] : [to.x1, to.y1];
|
|
331
|
+
const outer = (cross >= 0 ? 1 : -1) === side;
|
|
332
|
+
if (!outer || join === 1) {
|
|
333
|
+
if (!outer && tx === fx && ty === fy) {
|
|
334
|
+
stray.push([tx, ty]);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
w.line(tx, ty);
|
|
338
|
+
}
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
// The turn, from a's normal on this side to b's.
|
|
342
|
+
const na = [a.t1[1] * side, -a.t1[0] * side];
|
|
343
|
+
const nb = [b.t0[1] * side, -b.t0[0] * side];
|
|
344
|
+
const turn = Math.atan2(na[0] * nb[1] - na[1] * nb[0], na[0] * nb[0] + na[1] * nb[1]);
|
|
345
|
+
if (join === 0) {
|
|
346
|
+
arc(w, s.x1, s.y1, h, forward ? turn : -turn, tx, ty);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const points = miter(s.x1, s.y1, h, a, b, na, nb, Math.abs(turn), limit);
|
|
350
|
+
for (const [x, y] of forward ? points : points.reverse()) {
|
|
351
|
+
w.line(x, y);
|
|
352
|
+
}
|
|
353
|
+
w.line(tx, ty);
|
|
354
|
+
};
|
|
355
|
+
const capAt = (part, start) => {
|
|
356
|
+
const s = part.segment;
|
|
357
|
+
const [x, y] = start ? [s.x0, s.y0] : [s.x1, s.y1];
|
|
358
|
+
const t = start ? part.t0 : part.t1;
|
|
359
|
+
const from = start ? part.plus : part.minus;
|
|
360
|
+
const to = start ? part.minus : part.plus;
|
|
361
|
+
const [fx, fy] = start ? [from.x0, from.y0] : [from.x1, from.y1];
|
|
362
|
+
const [tx, ty] = start ? [to.x0, to.y0] : [to.x1, to.y1];
|
|
363
|
+
if (cap === 0) {
|
|
364
|
+
arc(w, x, y, h, -Math.PI, tx, ty);
|
|
365
|
+
}
|
|
366
|
+
else if (cap === 2) {
|
|
367
|
+
// The rounded sides moved on by the rounded half width.
|
|
368
|
+
const sign = start ? -1 : 1;
|
|
369
|
+
const dx = Math.round(t[0] * h) * sign;
|
|
370
|
+
const dy = Math.round(t[1] * h) * sign;
|
|
371
|
+
w.line(fx + dx, fy + dy);
|
|
372
|
+
w.line(tx + dx, ty + dy);
|
|
373
|
+
w.line(tx, ty);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
w.line(tx, ty);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
const back = (side) => {
|
|
380
|
+
if (side.curve) {
|
|
381
|
+
w.curve(side.cx, side.cy, side.x0, side.y0);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
w.line(side.x0, side.y0);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
const on = (side) => {
|
|
388
|
+
if (side.curve) {
|
|
389
|
+
w.curve(side.cx, side.cy, side.x1, side.y1);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
w.line(side.x1, side.y1);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
w.move(first.plus.x1, first.plus.y1);
|
|
396
|
+
back(first.plus);
|
|
397
|
+
if (closed) {
|
|
398
|
+
joinTo(last, first, 1, false);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
capAt(first, true);
|
|
402
|
+
for (let i = 0; i < parts.length; i++) {
|
|
403
|
+
on(parts[i].minus);
|
|
404
|
+
if (i + 1 < parts.length) {
|
|
405
|
+
joinTo(parts[i], parts[i + 1], -1, true);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
capAt(last, false);
|
|
409
|
+
}
|
|
410
|
+
for (let i = parts.length - 1; i > 0; i--) {
|
|
411
|
+
back(parts[i].plus);
|
|
412
|
+
joinTo(parts[i - 1], parts[i], 1, false);
|
|
413
|
+
}
|
|
414
|
+
if (closed) {
|
|
415
|
+
w.move(first.minus.x0, first.minus.y0);
|
|
416
|
+
for (let i = 0; i < parts.length; i++) {
|
|
417
|
+
on(parts[i].minus);
|
|
418
|
+
joinTo(parts[i], parts[(i + 1) % parts.length], -1, true);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
for (const [x, y] of stray) {
|
|
422
|
+
w.move(x, y);
|
|
423
|
+
w.line(x, y);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* A segment's side `sign` (+1 for +n), `h` twips out: its ends moved
|
|
428
|
+
* along their normals rounded to whole twips, a curve's control point
|
|
429
|
+
* where the moved tangents meet. A hairline's sides are the segment and
|
|
430
|
+
* the segment a twip across its run, right or down.
|
|
431
|
+
*/
|
|
432
|
+
function offset(s, t0, t1, h, sign, hairline) {
|
|
433
|
+
if (hairline) {
|
|
434
|
+
const [ox, oy] = Math.abs(s.x1 - s.x0) >= Math.abs(s.y1 - s.y0) ? [0, 1] : [1, 0];
|
|
435
|
+
const normal = ox * t0[1] - oy * t0[0];
|
|
436
|
+
const k = normal * sign > 0 ? 1 : 0;
|
|
437
|
+
return {
|
|
438
|
+
x0: s.x0 + ox * k,
|
|
439
|
+
y0: s.y0 + oy * k,
|
|
440
|
+
curve: s.curve,
|
|
441
|
+
cx: s.cx + ox * k,
|
|
442
|
+
cy: s.cy + oy * k,
|
|
443
|
+
x1: s.x1 + ox * k,
|
|
444
|
+
y1: s.y1 + oy * k,
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
const n0x = Math.round(t0[1] * h) * sign;
|
|
448
|
+
const n0y = Math.round(-t0[0] * h) * sign;
|
|
449
|
+
const n1x = Math.round(t1[1] * h) * sign;
|
|
450
|
+
const n1y = Math.round(-t1[0] * h) * sign;
|
|
451
|
+
const side = {
|
|
452
|
+
x0: s.x0 + n0x,
|
|
453
|
+
y0: s.y0 + n0y,
|
|
454
|
+
curve: s.curve,
|
|
455
|
+
cx: 0,
|
|
456
|
+
cy: 0,
|
|
457
|
+
x1: s.x1 + n1x,
|
|
458
|
+
y1: s.y1 + n1y,
|
|
459
|
+
};
|
|
460
|
+
if (s.curve) {
|
|
461
|
+
const cross = t0[0] * t1[1] - t0[1] * t1[0];
|
|
462
|
+
if (Math.abs(cross) < 1e-9) {
|
|
463
|
+
side.cx = s.cx + n0x;
|
|
464
|
+
side.cy = s.cy + n0y;
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
const u = ((side.x1 - side.x0) * t1[1] - (side.y1 - side.y0) * t1[0]) / cross;
|
|
468
|
+
side.cx = Math.round(side.x0 + t0[0] * u);
|
|
469
|
+
side.cy = Math.round(side.y0 + t0[1] * u);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return side;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* An arc about (`x`, `y`) of radius `r` from the pen, turning `sweep`, to
|
|
476
|
+
* the end (`ex`, `ey`), in quadratics of at most 45° each: control points
|
|
477
|
+
* where the tangents meet, rounded, and the on-curve points between them
|
|
478
|
+
* halfway, in whole twips down. The arc starts toward the pen as rounded,
|
|
479
|
+
* which comes nearer adl's than the exact angle does, but adl's control
|
|
480
|
+
* points still differ from these by a twip at some angles.
|
|
481
|
+
*/
|
|
482
|
+
function arc(w, x, y, r, sweep, ex, ey) {
|
|
483
|
+
const angle = Math.atan2(w.y - y, w.x - x);
|
|
484
|
+
const pieces = Math.ceil(Math.abs(sweep) / (Math.PI / 4) - 1e-9);
|
|
485
|
+
if (pieces === 0) {
|
|
486
|
+
w.line(ex, ey);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const step = sweep / pieces;
|
|
490
|
+
const reach = r / Math.cos(step / 2);
|
|
491
|
+
const controls = [];
|
|
492
|
+
for (let i = 0; i < pieces; i++) {
|
|
493
|
+
const a = angle + step * (i + 0.5);
|
|
494
|
+
controls.push([Math.round(x + reach * Math.cos(a)), Math.round(y + reach * Math.sin(a))]);
|
|
495
|
+
}
|
|
496
|
+
for (let i = 0; i < pieces; i++) {
|
|
497
|
+
const [cx, cy] = controls[i];
|
|
498
|
+
const next = controls[i + 1];
|
|
499
|
+
if (next) {
|
|
500
|
+
w.curve(cx, cy, Math.floor((cx + next[0]) / 2), Math.floor((cy + next[1]) / 2));
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
w.curve(cx, cy, ex, ey);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* The points a miter join goes through between its sides: its tip, or
|
|
509
|
+
* where the limit, `limit` half widths out along the bisector, cuts it.
|
|
510
|
+
*/
|
|
511
|
+
function miter(x, y, h, a, b, na, nb, turn, limit) {
|
|
512
|
+
let [bx, by] = unit(na[0] + nb[0], na[1] + nb[1]);
|
|
513
|
+
if (!bx && !by) {
|
|
514
|
+
[bx, by] = unit(a.t1[0] - b.t0[0], a.t1[1] - b.t0[1]);
|
|
515
|
+
}
|
|
516
|
+
const ratio = 1 / Math.cos(turn / 2);
|
|
517
|
+
if (ratio <= limit) {
|
|
518
|
+
return [[Math.round(x + bx * h * ratio), Math.round(y + by * h * ratio)]];
|
|
519
|
+
}
|
|
520
|
+
const reach = limit * h;
|
|
521
|
+
const cut = (px, py, dx, dy) => {
|
|
522
|
+
const along = dx * bx + dy * by;
|
|
523
|
+
const t = along ? (reach - (px * bx + py * by)) / along : 0;
|
|
524
|
+
return [Math.round(x + px + dx * t), Math.round(y + py + dy * t)];
|
|
525
|
+
};
|
|
526
|
+
return [
|
|
527
|
+
cut(na[0] * h, na[1] * h, a.t1[0], a.t1[1]),
|
|
528
|
+
cut(nb[0] * h, nb[1] * h, -b.t0[0], -b.t0[1]),
|
|
529
|
+
];
|
|
530
|
+
}
|
|
531
|
+
/** A stroke's path `at` and the lines closing fills that go on from its end. */
|
|
532
|
+
function strokeSegments(path, closes, at, m) {
|
|
533
|
+
const segments = segmentsOf(path, m);
|
|
534
|
+
for (const close of closes) {
|
|
535
|
+
if (close.at !== at) {
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
const end = segments.length
|
|
539
|
+
? [segments[segments.length - 1].x1, segments[segments.length - 1].y1]
|
|
540
|
+
: (() => {
|
|
541
|
+
const [x, y] = apply(m, path[1], path[2]);
|
|
542
|
+
return [Math.round(x * TWIPS), Math.round(y * TWIPS)];
|
|
543
|
+
})();
|
|
544
|
+
const [x, y] = apply(m, close.x, close.y);
|
|
545
|
+
segments.push({
|
|
546
|
+
x0: end[0],
|
|
547
|
+
y0: end[1],
|
|
548
|
+
curve: false,
|
|
549
|
+
cx: 0,
|
|
550
|
+
cy: 0,
|
|
551
|
+
x1: Math.round(x * TWIPS),
|
|
552
|
+
y1: Math.round(y * TWIPS),
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return segments;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* The layers' data, as seen through `m`, onto `out`. `defaults` holds the
|
|
559
|
+
* gradients beginGradientFill was given no matrix for.
|
|
560
|
+
*/
|
|
561
|
+
export function graphicsData(layers, m, defaults, out) {
|
|
562
|
+
for (const layer of layers) {
|
|
563
|
+
for (const fill of layer.fills) {
|
|
564
|
+
const w = new Writer();
|
|
565
|
+
writeContours(w, fill.contours, m);
|
|
566
|
+
if (w.commands.length) {
|
|
567
|
+
out.push(datumOf(fill.fill, m, defaults));
|
|
568
|
+
out.push({ type: "path", winding: fill.winding, commands: w.commands, data: w.data });
|
|
569
|
+
out.push({ type: "end" });
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
// A drawTriangles' textured triangles are left out, as adl leaves them, and their lines are
|
|
573
|
+
// one path.
|
|
574
|
+
for (const stroke of layer.strokes) {
|
|
575
|
+
let w = new Writer();
|
|
576
|
+
for (const [i, path] of stroke.paths.entries()) {
|
|
577
|
+
writeStroke(w, strokeSegments(path, stroke.closes ?? [], i, m), stroke.line);
|
|
578
|
+
if (!stroke.triangles || i === stroke.paths.length - 1) {
|
|
579
|
+
writeLine(out, w, stroke.line);
|
|
580
|
+
w = new Writer();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
function writeLine(out, w, line) {
|
|
587
|
+
if (w.commands.length) {
|
|
588
|
+
out.push({ type: "solid", ...storedColor(line.color) });
|
|
589
|
+
out.push({ type: "path", winding: "nonZero", commands: w.commands, data: w.data });
|
|
590
|
+
out.push({ type: "end" });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// What a character makes: the display object a timeline places for it,
|
|
2
|
+
// and its bringing to life once placed.
|
|
3
|
+
import { BitmapStore } from "../bitmap/bitmap.js";
|
|
4
|
+
import { BitmapObject } from "./bitmapobject.js";
|
|
5
|
+
import { ButtonObject, buttonStates } from "./buttonobject.js";
|
|
6
|
+
import { MovieClip } from "./movieclip.js";
|
|
7
|
+
import { ShapeObject } from "./shapeobject.js";
|
|
8
|
+
import { StaticTextObject, TextObject } from "./textobjects.js";
|
|
9
|
+
import { INVALID_PIXELS } from "./timeline.js";
|
|
10
|
+
/** A display object for a character, before its first frame: a shape, or a clip. */
|
|
11
|
+
/** `hasImage` is PlaceObject3's flag where a timeline places it, which a bitmap's construction reads. */
|
|
12
|
+
export function displayFor(character, library, hasImage = false) {
|
|
13
|
+
if (character.type === "shape") {
|
|
14
|
+
return new ShapeObject(character);
|
|
15
|
+
}
|
|
16
|
+
if (character.type === "morph") {
|
|
17
|
+
return ShapeObject.ofMorph(character);
|
|
18
|
+
}
|
|
19
|
+
if (character.type === "bitmap") {
|
|
20
|
+
// With scripts, its Bitmap's constructor gives it its data; without, a copy of the pixels.
|
|
21
|
+
const bitmap = new BitmapObject(library.construct ? null : BitmapStore.of(character.pixels ?? INVALID_PIXELS));
|
|
22
|
+
bitmap.character = character;
|
|
23
|
+
bitmap.hasImage = hasImage;
|
|
24
|
+
return bitmap;
|
|
25
|
+
}
|
|
26
|
+
if (character.type === "static") {
|
|
27
|
+
return new StaticTextObject(character, library.characters);
|
|
28
|
+
}
|
|
29
|
+
if (character.type === "text") {
|
|
30
|
+
const text = new TextObject(character);
|
|
31
|
+
text.fonts = library.fonts;
|
|
32
|
+
return text;
|
|
33
|
+
}
|
|
34
|
+
// Its states are made where it is constructed (Scripting.construct).
|
|
35
|
+
if (character.type === "button") {
|
|
36
|
+
const button = new ButtonObject();
|
|
37
|
+
button.character = character;
|
|
38
|
+
button.library = library;
|
|
39
|
+
button.trackAsMenu = character.trackAsMenu;
|
|
40
|
+
button.scale9Grid = character.grid;
|
|
41
|
+
return button;
|
|
42
|
+
}
|
|
43
|
+
const clip = new MovieClip(character.timeline, library);
|
|
44
|
+
clip.character = character;
|
|
45
|
+
clip.scale9Grid = character.grid;
|
|
46
|
+
return clip;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Bring a display object the timeline placed to life: its AS3 object
|
|
50
|
+
* constructed where the SWF has scripts, which enters a clip's first frame
|
|
51
|
+
* and names it on its parent, else a clip's first frame entered. After the
|
|
52
|
+
* placement, as Flash has it, so that the parent and the name are there.
|
|
53
|
+
*/
|
|
54
|
+
export function construct(display, character, library) {
|
|
55
|
+
library.avm1?.made(display);
|
|
56
|
+
if (library.construct) {
|
|
57
|
+
library.construct(display, character);
|
|
58
|
+
}
|
|
59
|
+
else if (display instanceof MovieClip) {
|
|
60
|
+
display.enterFirstFrame();
|
|
61
|
+
}
|
|
62
|
+
else if (display instanceof ButtonObject && character.type === "button") {
|
|
63
|
+
buttonStates(display, character, library, (d, c) => construct(d, c, library), () => { });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** A display object for a character as the timeline would place it, alive, but in no container. */
|
|
67
|
+
export function instantiate(character, library) {
|
|
68
|
+
const display = displayFor(character, library);
|
|
69
|
+
construct(display, character, library);
|
|
70
|
+
return display;
|
|
71
|
+
}
|