swf2js 0.1.2 → 0.4.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/README.md +81 -14
- package/package.json +11 -7
- package/studio/actionscript-roundtrip.test.js +54 -0
- package/studio/actionscript-scripts.test.js +169 -0
- package/studio/animated-image.test.js +137 -0
- package/studio/arithmetic.test.js +16 -0
- package/studio/as3-import.test.js +110 -0
- package/studio/audio-info.test.js +44 -0
- package/studio/components.test.js +152 -0
- package/studio/document-editing.test.js +92 -0
- package/studio/examples/01-space-mission.json +1628 -0
- package/studio/examples/02-clockwork-vault.json +1079 -0
- package/studio/examples/03-neon-synth.json +1364 -0
- package/studio/examples/04-kinetic-poster.json +923 -0
- package/studio/examples/05-signal-relay.json +1131 -0
- package/studio/examples/06-calculator.json +564 -0
- package/studio/frame-editing.test.js +129 -0
- package/studio/frame-events.test.js +117 -0
- package/studio/groups.test.js +88 -0
- package/studio/index.html +962 -0
- package/studio/interaction-triggers.test.js +37 -0
- package/studio/linked-actions.test.js +48 -0
- package/studio/lottie.test.js +208 -0
- package/studio/masks.test.js +43 -0
- package/studio/media-assets.test.js +62 -0
- package/studio/paint-tools.test.js +60 -0
- package/studio/playback.test.js +17 -0
- package/studio/project-io.test.js +405 -0
- package/studio/project-preview.test.js +475 -0
- package/studio/scene-transition.test.js +32 -0
- package/studio/server/archive-companions.js +27 -0
- package/studio/server/as3-library.js +91 -0
- package/studio/server/assets.js +162 -0
- package/studio/server/audio-info.js +82 -0
- package/studio/server/font-files.js +332 -0
- package/studio/server/http.js +135 -0
- package/studio/server/linked-actions.js +93 -0
- package/studio/server/png-decode.js +1 -0
- package/studio/server/project-movie.js +1164 -0
- package/studio/server/project-preview.js +152 -0
- package/studio/server/projects.js +370 -0
- package/studio/server/report.js +29 -0
- package/studio/server/routes.js +93 -0
- package/studio/server/swf-authoring.js +90 -0
- package/studio/server/swf-control-runtime.as +513 -0
- package/studio/server/swf-controls.js +119 -0
- package/studio/server/swf-export.js +293 -0
- package/studio/server/swf-import.js +1675 -0
- package/studio/server/swf-morphs.js +64 -0
- package/studio/server/swf-routes.js +42 -0
- package/studio/server/swf-streams.js +80 -0
- package/studio/server/swf-transition-runtime.as +52 -0
- package/studio/server/tween-recovery.js +106 -0
- package/studio/server-api.test.js +283 -0
- package/studio/server.js +320 -0
- package/studio/src/animated-image.js +423 -0
- package/studio/src/appearance-inspector.js +63 -0
- package/studio/src/arithmetic.js +50 -0
- package/studio/src/authored-controls.js +42 -0
- package/studio/src/busy.js +41 -0
- package/studio/src/canvas.js +430 -0
- package/studio/src/clipper-browser.js +2 -0
- package/studio/src/color-transform.js +38 -0
- package/studio/src/component-inspector.js +126 -0
- package/studio/src/components.js +268 -0
- package/studio/src/display-frame.js +262 -0
- package/studio/src/document-editing.js +69 -0
- package/studio/src/event-editor.js +150 -0
- package/studio/src/frame-editing.js +150 -0
- package/studio/src/frame-events.js +128 -0
- package/studio/src/frame-image.js +28 -0
- package/studio/src/groups.js +125 -0
- package/studio/src/handler-editor.js +122 -0
- package/studio/src/history.js +83 -0
- package/studio/src/imported-paths.js +99 -0
- package/studio/src/index.js +3582 -0
- package/studio/src/interaction-triggers.js +42 -0
- package/studio/src/json-patch.js +77 -0
- package/studio/src/layer-icons.js +25 -0
- package/studio/src/lottie-export.js +948 -0
- package/studio/src/lottie-import.js +1138 -0
- package/studio/src/masks.js +69 -0
- package/studio/src/media-assets.js +188 -0
- package/studio/src/media-library.js +193 -0
- package/studio/src/model.js +431 -0
- package/studio/src/numeric-fields.js +46 -0
- package/studio/src/object-list.js +57 -0
- package/studio/src/paint-tools.js +76 -0
- package/studio/src/placement-effects.js +74 -0
- package/studio/src/playback.js +10 -0
- package/studio/src/preview-audio.js +64 -0
- package/studio/src/preview-interactions.js +106 -0
- package/studio/src/preview-recorder.js +335 -0
- package/studio/src/preview-surface.js +338 -0
- package/studio/src/project-io.js +905 -0
- package/studio/src/project-session.js +375 -0
- package/studio/src/projects-dialog.js +319 -0
- package/studio/src/scene-transition.js +129 -0
- package/studio/src/script-editor.js +175 -0
- package/studio/src/script-references.js +74 -0
- package/studio/src/scripted-controls.js +146 -0
- package/studio/src/scripts.js +185 -0
- package/studio/src/stage-guides.js +101 -0
- package/studio/src/svg-animation.js +416 -0
- package/studio/src/svg-context.js +522 -0
- package/studio/src/svg-frame.js +413 -0
- package/studio/src/svg-import.js +1208 -0
- package/studio/src/swf-recording.js +104 -0
- package/studio/src/symbol-library.js +39 -0
- package/studio/src/symbols.js +62 -0
- package/studio/src/text-fields.js +58 -0
- package/studio/src/theme.js +43 -0
- package/studio/src/timeline.js +321 -0
- package/studio/src/vector-cut.js +103 -0
- package/studio/src/vector-geometry.js +254 -0
- package/studio/src/vector-style.js +146 -0
- package/studio/src/video-encode.js +84 -0
- package/studio/src/video-export.js +331 -0
- package/studio/src/video-mux.js +339 -0
- package/studio/src/video-playback.js +281 -0
- package/studio/src/workspace.js +344 -0
- package/studio/stroke-style.test.js +119 -0
- package/studio/styles.css +1547 -0
- package/studio/svg-export.test.js +162 -0
- package/studio/svg-import.test.js +318 -0
- package/studio/swf-authoring.test.js +140 -0
- package/studio/swf-export.test.js +324 -0
- package/studio/swf-import.test.js +489 -0
- package/studio/symbols.test.js +68 -0
- package/studio/tests/accessibility-interactions.mjs +138 -0
- package/studio/tests/appearance-interactions.mjs +103 -0
- package/studio/tests/control-interactions.mjs +60 -0
- package/studio/tests/event-interactions.mjs +117 -0
- package/studio/tests/external-resources.mjs +174 -0
- package/studio/tests/frame-image.mjs +71 -0
- package/studio/tests/html-export.mjs +68 -0
- package/studio/tests/import-files.mjs +131 -0
- package/studio/tests/lottie.mjs +125 -0
- package/studio/tests/mask-interactions.mjs +148 -0
- package/studio/tests/media-interactions.mjs +109 -0
- package/studio/tests/paint-interactions.mjs +64 -0
- package/studio/tests/project-interactions.mjs +244 -0
- package/studio/tests/script-interactions.mjs +178 -0
- package/studio/tests/scripted-control-interactions.mjs +107 -0
- package/studio/tests/svg-export.mjs +149 -0
- package/studio/tests/text-field-interactions.mjs +64 -0
- package/studio/tests/theme-interactions.mjs +53 -0
- package/studio/tests/timeline-browser.mjs +507 -0
- package/studio/tests/transition-interactions.mjs +94 -0
- package/studio/tests/trigger-interactions.mjs +93 -0
- package/studio/tests/video-export.mjs +243 -0
- package/studio/tests/workspace-interactions.mjs +226 -0
- package/studio/tween-recovery.test.js +31 -0
- package/studio/vector-style.test.js +56 -0
- package/studio/video-export.test.js +326 -0
- package/studiospec/actionscript.md +88 -0
- package/studiospec/architecture.md +378 -0
- package/studiospec/controls.md +100 -0
- package/studiospec/file-support.md +268 -0
- package/studiospec/lottie.md +69 -0
- package/studiospec/requirements.md +135 -0
- package/studiospec/stroke-style.md +95 -0
- package/studiospec/svg-export.md +83 -0
- package/studiospec/svg-import.md +139 -0
- package/studiospec/swooflib-integration.md +115 -0
- package/studiospec/tasks.md +573 -0
- package/studiospec/video-export.md +127 -0
- package/swf2js/__tests__/actionscript.test.js +1609 -0
- package/swf2js/__tests__/adpcm-audio.test.js +43 -0
- package/swf2js/__tests__/as2-compiler.test.js +153 -0
- package/swf2js/__tests__/as3-mixed-depth.test.js +498 -0
- package/swf2js/__tests__/authored-sprite-hit.test.js +118 -0
- package/swf2js/__tests__/authored-sprite-sizing.test.js +164 -0
- package/swf2js/__tests__/avm1-action-prefix.test.js +134 -0
- package/swf2js/__tests__/avm1-attach-movie.test.js +1151 -0
- package/swf2js/__tests__/avm1-boxhead-budget.test.js +73 -0
- package/swf2js/__tests__/avm1-cfg-bubble-tanks.test.js +101 -0
- package/swf2js/__tests__/avm1-cfg-mario-kart.test.js +184 -0
- package/swf2js/__tests__/avm1-cfg-mario.test.js +31 -0
- package/swf2js/__tests__/avm1-cfg-pacman.test.js +49 -0
- package/swf2js/__tests__/avm1-checkers-gameplay.test.js +122 -0
- package/swf2js/__tests__/avm1-clip-actions.test.js +2002 -0
- package/swf2js/__tests__/avm1-clone-drag.test.js +626 -0
- package/swf2js/__tests__/avm1-decompiler.test.js +102 -0
- package/swf2js/__tests__/avm1-dynamic-locals.test.js +159 -0
- package/swf2js/__tests__/avm1-formal-parameters.test.js +71 -0
- package/swf2js/__tests__/avm1-key-events.test.js +52 -0
- package/swf2js/__tests__/avm1-load-bitmap.test.js +75 -0
- package/swf2js/__tests__/avm1-loading-host-actions.test.js +764 -0
- package/swf2js/__tests__/avm1-multibyte-strings.test.js +63 -0
- package/swf2js/__tests__/avm1-pacman-gameplay.test.js +115 -0
- package/swf2js/__tests__/avm1-shape-hittest.test.js +311 -0
- package/swf2js/__tests__/avm1-shared-bodies.test.js +57 -0
- package/swf2js/__tests__/avm1-shared-runtime.test.js +1364 -0
- package/swf2js/__tests__/avm1-snake-gameplay.test.js +139 -0
- package/swf2js/__tests__/avm1-super.test.js +70 -0
- package/swf2js/__tests__/avm1-target-path.test.js +325 -0
- package/swf2js/__tests__/avm1-try.test.js +229 -0
- package/swf2js/__tests__/avm2-activation-closures.test.js +65 -0
- package/swf2js/__tests__/avm2-applytype.test.js +180 -0
- package/swf2js/__tests__/avm2-call-ops.test.js +232 -0
- package/swf2js/__tests__/avm2-callsuperid.test.js +231 -0
- package/swf2js/__tests__/avm2-class-initializer.test.js +219 -0
- package/swf2js/__tests__/avm2-custom-namespace.test.js +139 -0
- package/swf2js/__tests__/avm2-describe-type.test.js +96 -0
- package/swf2js/__tests__/avm2-dictionary.test.js +96 -0
- package/swf2js/__tests__/avm2-domain-memory.test.js +332 -0
- package/swf2js/__tests__/avm2-e4x.test.js +326 -0
- package/swf2js/__tests__/avm2-exceptions.test.js +81 -0
- package/swf2js/__tests__/avm2-findprop.test.js +110 -0
- package/swf2js/__tests__/avm2-getlex.test.js +166 -0
- package/swf2js/__tests__/avm2-global-slot.test.js +106 -0
- package/swf2js/__tests__/avm2-interface.test.js +95 -0
- package/swf2js/__tests__/avm2-multiname-precedence.test.js +148 -0
- package/swf2js/__tests__/avm2-named-namespace-types.test.js +106 -0
- package/swf2js/__tests__/avm2-optional-args.test.js +100 -0
- package/swf2js/__tests__/avm2-outer-scopes.test.js +101 -0
- package/swf2js/__tests__/avm2-package-internal-class.test.js +106 -0
- package/swf2js/__tests__/avm2-protected-namespace.test.js +105 -0
- package/swf2js/__tests__/avm2-protected.test.js +214 -0
- package/swf2js/__tests__/avm2-qwop-gameplay.test.js +116 -0
- package/swf2js/__tests__/avm2-runtime-namespaces.test.js +159 -0
- package/swf2js/__tests__/avm2-script-traits.test.js +89 -0
- package/swf2js/__tests__/avm2-shared-runtime.test.js +52 -0
- package/swf2js/__tests__/avm2-slot-ops.test.js +117 -0
- package/swf2js/__tests__/avm2-type-ops.test.js +224 -0
- package/swf2js/__tests__/bevel-filter.test.js +116 -0
- package/swf2js/__tests__/bitmap-button-mask.test.js +106 -0
- package/swf2js/__tests__/bitmap-data-draw.test.js +388 -0
- package/swf2js/__tests__/bitmap-decoder.test.js +108 -0
- package/swf2js/__tests__/bitmapdata-color-bounds.test.js +70 -0
- package/swf2js/__tests__/bitmapdata-copy-channel.test.js +91 -0
- package/swf2js/__tests__/bitmapdata-copy-pixels.test.js +136 -0
- package/swf2js/__tests__/bitmapdata-fill-compare.test.js +241 -0
- package/swf2js/__tests__/bitmapdata-filter.test.js +232 -0
- package/swf2js/__tests__/bitmapdata-hit-test.test.js +71 -0
- package/swf2js/__tests__/bitmapdata-merge.test.js +84 -0
- package/swf2js/__tests__/bitmapdata-palette-map.test.js +92 -0
- package/swf2js/__tests__/bitmapdata-pixels-io.test.js +198 -0
- package/swf2js/__tests__/bitmapdata-threshold.test.js +97 -0
- package/swf2js/__tests__/bitmapdata-vector.test.js +82 -0
- package/swf2js/__tests__/blur-filter.test.js +48 -0
- package/swf2js/__tests__/bundle-emitter.test.js +394 -0
- package/swf2js/__tests__/button-actions.test.js +370 -0
- package/swf2js/__tests__/button-color-transform.test.js +48 -0
- package/swf2js/__tests__/button-decoder.test.js +106 -0
- package/swf2js/__tests__/button-hit-test.test.js +825 -0
- package/swf2js/__tests__/button-scaling-grid.test.js +124 -0
- package/swf2js/__tests__/button-sound.test.js +105 -0
- package/swf2js/__tests__/bytearray-coercion.test.js +23 -0
- package/swf2js/__tests__/bytearray-object-serialization.test.js +380 -0
- package/swf2js/__tests__/cfg-switch-loop.test.js +103 -0
- package/swf2js/__tests__/clip-depth-mask.test.js +119 -0
- package/swf2js/__tests__/clipped-bitmap-fill.test.js +118 -0
- package/swf2js/__tests__/companion-swf.test.js +638 -0
- package/swf2js/__tests__/context-menu.test.js +149 -0
- package/swf2js/__tests__/convolution-filter.test.js +74 -0
- package/swf2js/__tests__/definefont4.test.js +280 -0
- package/swf2js/__tests__/display-displacement.test.js +161 -0
- package/swf2js/__tests__/display-list.test.js +80 -0
- package/swf2js/__tests__/display-mask-render.test.js +656 -0
- package/swf2js/__tests__/displayobject-stage.test.js +320 -0
- package/swf2js/__tests__/embedded-script-audio.test.js +131 -0
- package/swf2js/__tests__/embedded-swf.test.js +202 -0
- package/swf2js/__tests__/embedded-textfield.test.js +107 -0
- package/swf2js/__tests__/embedded-timeline-audio.test.js +182 -0
- package/swf2js/__tests__/embedded-timeline-input.test.js +420 -0
- package/swf2js/__tests__/embedded-timer-lifecycle.test.js +145 -0
- package/swf2js/__tests__/event-priority-order.test.js +125 -0
- package/swf2js/__tests__/event-weak-listeners.test.js +53 -0
- package/swf2js/__tests__/event-will-trigger.test.js +43 -0
- package/swf2js/__tests__/flash-text-engine-content.test.js +115 -0
- package/swf2js/__tests__/flash-text-engine-format.test.js +95 -0
- package/swf2js/__tests__/flash-text-engine-line.test.js +314 -0
- package/swf2js/__tests__/font-encoder.test.js +95 -0
- package/swf2js/__tests__/font-outline-text.test.js +659 -0
- package/swf2js/__tests__/glow-shadow-filter.test.js +68 -0
- package/swf2js/__tests__/graphics-bitmap-smoothing.test.js +32 -0
- package/swf2js/__tests__/graphics-fill-lifetime.test.js +36 -0
- package/swf2js/__tests__/graphics-gradient-matrix.test.js +53 -0
- package/swf2js/__tests__/graphics-stroke-hit-test.test.js +457 -0
- package/swf2js/__tests__/hit-test-primitives.test.js +414 -0
- package/swf2js/__tests__/input-events.test.js +714 -0
- package/swf2js/__tests__/integration/corpus.test.js +41 -0
- package/swf2js/__tests__/loader-embedded-swf.test.js +210 -0
- package/swf2js/__tests__/loader-info.test.js +81 -0
- package/swf2js/__tests__/local-connection.test.js +122 -0
- package/swf2js/__tests__/morph-focal-gradient.test.js +51 -0
- package/swf2js/__tests__/morph-topology.test.js +267 -0
- package/swf2js/__tests__/movie-data-codec.test.js +128 -0
- package/swf2js/__tests__/nellymoser-audio.test.js +84 -0
- package/swf2js/__tests__/opaque-background-cache.test.js +352 -0
- package/swf2js/__tests__/path-stream.test.js +81 -0
- package/swf2js/__tests__/place-object-filters.test.js +88 -0
- package/swf2js/__tests__/place-object3-decoder.test.js +116 -0
- package/swf2js/__tests__/place-object3-image.test.js +85 -0
- package/swf2js/__tests__/player-version.test.js +46 -0
- package/swf2js/__tests__/root-textfield.test.js +287 -0
- package/swf2js/__tests__/scaling-grid.test.js +183 -0
- package/swf2js/__tests__/shape-decoder.test.js +361 -0
- package/swf2js/__tests__/shape-line-style2.test.js +138 -0
- package/swf2js/__tests__/shape-nonscaling-stroke.test.js +131 -0
- package/swf2js/__tests__/shape-pixel-hint.test.js +101 -0
- package/swf2js/__tests__/simplebutton-pointer.test.js +1477 -0
- package/swf2js/__tests__/socket-offline.test.js +67 -0
- package/swf2js/__tests__/sound-avm1-stop.test.js +99 -0
- package/swf2js/__tests__/sound-envelope.test.js +110 -0
- package/swf2js/__tests__/sound-extract.test.js +168 -0
- package/swf2js/__tests__/sound-id3.test.js +283 -0
- package/swf2js/__tests__/sound-load.test.js +259 -0
- package/swf2js/__tests__/sound-mixer-spectrum.test.js +261 -0
- package/swf2js/__tests__/sound-stream-sprite.test.js +624 -0
- package/swf2js/__tests__/sound-transform.test.js +104 -0
- package/swf2js/__tests__/speex-audio.test.js +77 -0
- package/swf2js/__tests__/stage-noscale.test.js +45 -0
- package/swf2js/__tests__/swf-encoder.test.js +134 -0
- package/swf2js/__tests__/swflib-assemble.test.js +20 -0
- package/swf2js/__tests__/textfield-html-text.test.js +368 -0
- package/swf2js/__tests__/textfield-line-layout.test.js +339 -0
- package/swf2js/__tests__/textfield-programmatic-overlay.test.js +2506 -0
- package/swf2js/__tests__/textfield-scroll.test.js +79 -0
- package/swf2js/__tests__/textfield-selection.test.js +383 -0
- package/swf2js/__tests__/timeline-effect-surfaces.test.js +295 -0
- package/swf2js/__tests__/timeline-named-anchor.test.js +139 -0
- package/swf2js/__tests__/timeline-scenes.test.js +1723 -0
- package/swf2js/__tests__/urlloader-http-status.test.js +236 -0
- package/{src → swf2js}/cli.js +43 -11
- package/swf2js/compiler/as2-classes.js +156 -0
- package/swf2js/compiler/as2-parser.js +598 -0
- package/swf2js/compiler/avm1-codegen.js +897 -0
- package/swf2js/compiler/index.js +28 -0
- package/{src → swf2js}/decoder/button-decoder.js +3 -1
- package/swf2js/decoder/png.js +114 -0
- package/{src → swf2js}/decoder/shape-decoder.js +20 -10
- package/{src → swf2js}/decoder/tag-decoder.js +5 -3
- package/{src → swf2js}/decoder/tag-types.js +4 -0
- package/swf2js/decompiler/avm1-decompiler.js +1138 -0
- package/{src → swf2js}/emitter/asset-encoder.js +66 -113
- package/{src → swf2js}/emitter/bundle-emitter.js +209 -78
- package/swf2js/emitter/external-resources.js +39 -0
- package/swf2js/emitter/movie-data-codec.js +91 -0
- package/swf2js/encoder/bit-writer.js +182 -0
- package/swf2js/encoder/shape-encoder.js +310 -0
- package/swf2js/encoder/swf-builder.js +639 -0
- package/swf2js/encoder/swf-writer.js +55 -0
- package/{src/runtime/swflib/assemble.js → swf2js/runtime/assemble-swooflib.js} +4 -3
- package/{src → swf2js}/runtime/avm1-runtime.js +102 -63
- package/{src → swf2js}/runtime/index.js +1 -1
- package/{src → swf2js}/runtime/movie-runtime.js +28 -2
- package/{src → swf2js}/transpiler/actionscript.js +82 -19
- package/{src → swf2js}/transpiler/avm1/avm1-opcodes.js +5 -3
- package/{src → swf2js}/transpiler/avm1/avm1-transpiler.js +69 -6
- package/{src → swf2js}/transpiler/avm2/avm2-transpiler.js +1 -1
- package/{src → swf2js}/transpiler/timeline/display-list.js +41 -22
- package/{src → swf2js}/transpiler/timeline/timeline-codegen.js +97 -36
- package/swooflib/README.md +569 -0
- package/swooflib/adpcm.js +147 -0
- package/{src/runtime/swflib → swooflib}/builtins.js +6 -0
- package/{src/runtime/swflib → swooflib}/context-menu.js +7 -1
- package/swooflib/control-definitions.js +42 -0
- package/swooflib/control-widget.js +763 -0
- package/swooflib/controls.js +300 -0
- package/{src/runtime/swflib → swooflib}/display.js +16 -10
- package/{src/runtime/swflib → swooflib}/events.js +11 -0
- package/{src/runtime/swflib → swooflib}/flash.js +6 -5
- package/{src/runtime/swflib → swooflib}/graphics.js +81 -19
- package/{src/runtime/swflib → swooflib}/input.js +12 -14
- package/{src/runtime/swflib → swooflib}/loader.js +52 -22
- package/swooflib/movie-network.js +86 -0
- package/swooflib/path-stream.js +169 -0
- package/{src/runtime/swflib → swooflib}/render.js +3 -13
- package/{src/runtime/swflib → swooflib}/sound.js +25 -2
- package/{src/runtime/swflib → swooflib}/stage.js +3 -3
- package/swooflib/stream-time.js +21 -0
- package/{src/runtime/swflib → swooflib}/system.js +88 -37
- package/{src/runtime/swflib → swooflib}/text-paint.js +14 -3
- package/{src/runtime/swflib → swooflib}/text.js +8 -0
- package/swooflib/xml-node.js +53 -0
- package/src/emitter/timeline-data-codec.js +0 -58
- /package/{src → swf2js}/decoder/symbol-table.js +0 -0
- /package/{src → swf2js}/emitter/embedded-swf.js +0 -0
- /package/{src → swf2js}/emitter/font-encoder.js +0 -0
- /package/{src → swf2js}/model/swf-document.js +0 -0
- /package/{src → swf2js}/model/transpile-result.js +0 -0
- /package/{src → swf2js}/parser/bit-reader.js +0 -0
- /package/{src → swf2js}/parser/decompressor.js +0 -0
- /package/{src → swf2js}/parser/swf-parser.js +0 -0
- /package/{src → swf2js}/pretty-printer/pretty-printer.js +0 -0
- /package/{src → swf2js}/runtime/avm2-runtime.js +0 -0
- /package/{src → swf2js}/runtime/embedded-movie-runtime.js +0 -0
- /package/{src → swf2js}/transpiler/avm1/avm1-ir.js +0 -0
- /package/{src → swf2js}/transpiler/avm1/avm1-rewrite.js +0 -0
- /package/{src → swf2js}/transpiler/avm2/abc-reader.js +0 -0
- /package/{src → swf2js}/transpiler/cfg-structurer.js +0 -0
- /package/{src → swf2js}/util/diagnostics.js +0 -0
- /package/{src → swf2js}/util/logger.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bitmap-image.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bitmap.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bytearray.js +0 -0
- /package/{src/runtime/swflib → swooflib}/compiled-swf.js +0 -0
- /package/{src/runtime/swflib → swooflib}/cursor-flag.js +0 -0
- /package/{src/runtime/swflib → swooflib}/dictionary.js +0 -0
- /package/{src/runtime/swflib → swooflib}/filters.js +0 -0
- /package/{src/runtime/swflib → swooflib}/geom.js +0 -0
- /package/{src/runtime/swflib → swooflib}/glyph-metrics.js +0 -0
- /package/{src/runtime/swflib → swooflib}/host.js +0 -0
- /package/{src/runtime/swflib → swooflib}/inherit.js +0 -0
- /package/{src/runtime/swflib → swooflib}/marks.js +0 -0
- /package/{src/runtime/swflib → swooflib}/matrix3d.js +0 -0
- /package/{src/runtime/swflib → swooflib}/pointer-bridge.js +0 -0
- /package/{src/runtime/swflib → swooflib}/projection.js +0 -0
- /package/{src/runtime/swflib → swooflib}/sprite-drag.js +0 -0
- /package/{src/runtime/swflib → swooflib}/stage-ref.js +0 -0
- /package/{src/runtime/swflib → swooflib}/text-field.js +0 -0
- /package/{src/runtime/swflib → swooflib}/transform.js +0 -0
- /package/{src/runtime/swflib → swooflib}/xml.js +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// Flash UI components (studiospec/controls.md). A component is a library symbol plus ActionScript
|
|
2
|
+
// classes compiled into the SWF; each placed instance carries its parameters in a clip handler that
|
|
3
|
+
// Flash generated from the Component Inspector: `onClipEvent (initialize)` for Flash MX components,
|
|
4
|
+
// `onClipEvent (construct)` for version 2. That handler is only constant assignments, so Studio keeps
|
|
5
|
+
// it as data (`element.component`) and regenerates the bytecode for Preview.
|
|
6
|
+
|
|
7
|
+
import { CONTROL_KINDS } from '../../swooflib/control-definitions.js';
|
|
8
|
+
export { CONTROL_KINDS };
|
|
9
|
+
const KIND_SET = new Set(CONTROL_KINDS);
|
|
10
|
+
// Linkage spellings that differ from the kind.
|
|
11
|
+
const ALIASES = {
|
|
12
|
+
PushButton: 'Button', ListBox: 'List', UIScrollBar: 'ScrollBar', HScrollBar: 'ScrollBar', VScrollBar: 'ScrollBar',
|
|
13
|
+
SimpleButton: 'Button', UILoader: 'Loader',
|
|
14
|
+
};
|
|
15
|
+
export const COMPONENT_EVENTS = ['initialize', 'construct'];
|
|
16
|
+
const MAX_PARAMETERS = 200;
|
|
17
|
+
const MAX_ARRAY = 10000;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The component a linkage name stands for: `FRadioButtonSymbol` (Flash MX) or `CheckBox` (version
|
|
21
|
+
* 2). Returns null for other symbols, including the `__Packages.mx.controls.*` holders, which only
|
|
22
|
+
* carry class code and are never placed.
|
|
23
|
+
*/
|
|
24
|
+
export function componentKind(linkage) {
|
|
25
|
+
if (typeof linkage !== 'string') return null;
|
|
26
|
+
let match = /^F([A-Za-z]+)Symbol$/.exec(linkage);
|
|
27
|
+
if (match) {
|
|
28
|
+
const kind = ALIASES[match[1]] ?? match[1];
|
|
29
|
+
return KIND_SET.has(kind) ? { kind, generation: 'mx' } : null;
|
|
30
|
+
}
|
|
31
|
+
match = /^(?:mx\.(?:controls|containers)\.)?([A-Za-z]+)$/.exec(linkage);
|
|
32
|
+
if (!match) return null;
|
|
33
|
+
const kind = ALIASES[match[1]] ?? match[1];
|
|
34
|
+
// SimpleButton is v2's internal button base; it is a component only through its subclasses.
|
|
35
|
+
if (match[1] === 'SimpleButton') return null;
|
|
36
|
+
return KIND_SET.has(kind) ? { kind, generation: 'v2' } : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ---- Bytecode ↔ parameters ----
|
|
40
|
+
|
|
41
|
+
const OP = { End: 0x00, SetVariable: 0x1d, GetVariable: 0x1c, SetMember: 0x4f, InitArray: 0x42, InitObject: 0x43, ConstantPool: 0x88, Push: 0x96 };
|
|
42
|
+
|
|
43
|
+
function readString(bytes, at) {
|
|
44
|
+
let end = at;
|
|
45
|
+
while (end < bytes.length && bytes[end] !== 0) end++;
|
|
46
|
+
if (end >= bytes.length) return null;
|
|
47
|
+
return { value: new TextDecoder().decode(bytes.subarray(at, end)), next: end + 1 };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Values one Push action places on the stack, or null for kinds parameters never use. */
|
|
51
|
+
const pushWidths = { 1: 4, 2: 0, 3: 0, 5: 1, 6: 8, 7: 4, 8: 1, 9: 2 };
|
|
52
|
+
function pushValues(bytes, start, end, pool, view) {
|
|
53
|
+
const values = [];
|
|
54
|
+
let at = start;
|
|
55
|
+
while (at < end) {
|
|
56
|
+
const type = bytes[at++];
|
|
57
|
+
if (at + (pushWidths[type] ?? 0) > end) return null;
|
|
58
|
+
if (type === 0) {
|
|
59
|
+
const text = readString(bytes, at);
|
|
60
|
+
if (!text || text.next > end) return null;
|
|
61
|
+
values.push(text.value); at = text.next;
|
|
62
|
+
} else if (type === 1) { values.push(view.getFloat32(at, true)); at += 4; }
|
|
63
|
+
else if (type === 2) values.push(null);
|
|
64
|
+
else if (type === 3) values.push(undefined);
|
|
65
|
+
else if (type === 5) values.push(bytes[at++] !== 0);
|
|
66
|
+
else if (type === 6) {
|
|
67
|
+
// SWF doubles store their two 32-bit halves high word first.
|
|
68
|
+
const swapped = new DataView(new ArrayBuffer(8));
|
|
69
|
+
swapped.setUint32(0, view.getUint32(at + 4, true), true);
|
|
70
|
+
swapped.setUint32(4, view.getUint32(at, true), true);
|
|
71
|
+
values.push(swapped.getFloat64(0, true)); at += 8;
|
|
72
|
+
} else if (type === 7) { values.push(view.getInt32(at, true)); at += 4; }
|
|
73
|
+
else if (type === 8) { if (bytes[at] >= pool.length) return null; values.push(pool[bytes[at++]]); }
|
|
74
|
+
else if (type === 9) { const index = view.getUint16(at, true); if (index >= pool.length) return null; values.push(pool[index]); at += 2; }
|
|
75
|
+
else return null; // registers (4) belong to code, not parameters
|
|
76
|
+
}
|
|
77
|
+
return at === end ? values : null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const isPrimitive = value => value === null || typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value));
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Decode constant assignments, including nested list and object literals and assignments to array indices.
|
|
84
|
+
* Returns the parameters in assignment order, or null when the handler does anything else.
|
|
85
|
+
*/
|
|
86
|
+
export function decodeComponentParameters(bytecode) {
|
|
87
|
+
const bytes = bytecode instanceof Uint8Array ? bytecode : new Uint8Array(bytecode);
|
|
88
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
89
|
+
const parameters = {};
|
|
90
|
+
let pool = [];
|
|
91
|
+
const stack = [];
|
|
92
|
+
const isLiteral = item => item && !item.name && (item.composite || isPrimitive(item.value));
|
|
93
|
+
let at = 0;
|
|
94
|
+
let count = 0;
|
|
95
|
+
while (at < bytes.length) {
|
|
96
|
+
const code = bytes[at++];
|
|
97
|
+
if (code === OP.End) break;
|
|
98
|
+
let length = 0;
|
|
99
|
+
if (code >= 0x80) {
|
|
100
|
+
if (at + 2 > bytes.length) return null;
|
|
101
|
+
length = view.getUint16(at, true); at += 2;
|
|
102
|
+
}
|
|
103
|
+
const end = at + length;
|
|
104
|
+
if (end > bytes.length) return null;
|
|
105
|
+
if (code === OP.ConstantPool) {
|
|
106
|
+
if (length < 2) return null;
|
|
107
|
+
const size = view.getUint16(at, true);
|
|
108
|
+
let cursor = at + 2;
|
|
109
|
+
pool = [];
|
|
110
|
+
for (let i = 0; i < size; i++) {
|
|
111
|
+
const text = readString(bytes, cursor);
|
|
112
|
+
if (!text || text.next > end) return null;
|
|
113
|
+
pool.push(text.value); cursor = text.next;
|
|
114
|
+
}
|
|
115
|
+
} else if (code === OP.Push) {
|
|
116
|
+
const values = pushValues(bytes, at, end, pool, view);
|
|
117
|
+
if (!values) return null;
|
|
118
|
+
stack.push(...values.map(value => ({ value })));
|
|
119
|
+
} else if (code === OP.InitArray || code === OP.InitObject) {
|
|
120
|
+
const size = stack.pop()?.value;
|
|
121
|
+
const required = code === OP.InitArray ? size : 2 * size;
|
|
122
|
+
if (!Number.isInteger(size) || size < 0 || size > MAX_ARRAY || required > stack.length) return null;
|
|
123
|
+
let depth = 1;
|
|
124
|
+
const items = [];
|
|
125
|
+
for (let i = 0; i < size; i++) {
|
|
126
|
+
const item = stack.pop();
|
|
127
|
+
if (!isLiteral(item)) return null;
|
|
128
|
+
depth = Math.max(depth, (item.depth ?? 0) + 1);
|
|
129
|
+
if (depth > 16) return null;
|
|
130
|
+
if (code === OP.InitObject) {
|
|
131
|
+
const key = stack.pop()?.value;
|
|
132
|
+
if (typeof key !== 'string') return null;
|
|
133
|
+
items.push([key, item.value]);
|
|
134
|
+
} else items.push(item.value);
|
|
135
|
+
}
|
|
136
|
+
stack.push({ value: code === OP.InitArray ? items : Object.fromEntries(items), composite: true, depth });
|
|
137
|
+
} else if (code === OP.GetVariable) {
|
|
138
|
+
const name = stack.pop()?.value;
|
|
139
|
+
if (typeof name !== 'string' || !Object.hasOwn(parameters, name) || !Array.isArray(parameters[name])) return null;
|
|
140
|
+
stack.push({ value: parameters[name], name });
|
|
141
|
+
} else if (code === OP.SetVariable) {
|
|
142
|
+
const item = stack.pop();
|
|
143
|
+
const name = stack.pop()?.value;
|
|
144
|
+
if (typeof name !== 'string' || !/^[A-Za-z_$][\w$]{0,127}$/.test(name) || !isLiteral(item)) return null;
|
|
145
|
+
// A second assignment can trigger a component setter twice, which a parameter map cannot represent.
|
|
146
|
+
if (Object.hasOwn(parameters, name) || ++count > MAX_PARAMETERS) return null;
|
|
147
|
+
Object.defineProperty(parameters, name, { value: item.value, writable: true, enumerable: true, configurable: true });
|
|
148
|
+
} else if (code === OP.SetMember) {
|
|
149
|
+
const item = stack.pop();
|
|
150
|
+
const index = stack.pop()?.value;
|
|
151
|
+
const target = stack.pop();
|
|
152
|
+
if (!target?.name || !Number.isInteger(index) || index < 0 || index >= MAX_ARRAY || !isLiteral(item)) return null;
|
|
153
|
+
const array = parameters[target.name];
|
|
154
|
+
while (array.length < index) array.push(null);
|
|
155
|
+
array[index] = item.value;
|
|
156
|
+
} else {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
at = end;
|
|
160
|
+
}
|
|
161
|
+
return stack.length === 0 ? parameters : null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function encodeString(text) {
|
|
165
|
+
return [...new TextEncoder().encode(text), 0];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function pushAction(values) {
|
|
169
|
+
const body = [];
|
|
170
|
+
for (const value of values) {
|
|
171
|
+
if (typeof value === 'string') body.push(0, ...encodeString(value));
|
|
172
|
+
else if (value === null) body.push(2);
|
|
173
|
+
else if (typeof value === 'boolean') body.push(5, value ? 1 : 0);
|
|
174
|
+
else if (Number.isInteger(value) && value >= -0x80000000 && value <= 0x7fffffff) {
|
|
175
|
+
const bytes = new Uint8Array(4);
|
|
176
|
+
new DataView(bytes.buffer).setInt32(0, value, true);
|
|
177
|
+
body.push(7, ...bytes);
|
|
178
|
+
} else {
|
|
179
|
+
const raw = new DataView(new ArrayBuffer(8));
|
|
180
|
+
raw.setFloat64(0, value, true);
|
|
181
|
+
const bytes = new Uint8Array(raw.buffer);
|
|
182
|
+
body.push(6, ...bytes.subarray(4, 8), ...bytes.subarray(0, 4));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (body.length > 0xffff) throw new Error('A component parameter is too long');
|
|
186
|
+
return [OP.Push, body.length & 0xff, body.length >> 8, ...body];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function writeLiteral(out, value) {
|
|
190
|
+
if (isPrimitive(value)) {
|
|
191
|
+
out.push(...pushAction([value]));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (Array.isArray(value)) {
|
|
195
|
+
for (let i = value.length - 1; i >= 0; i--) writeLiteral(out, value[i]);
|
|
196
|
+
out.push(...pushAction([value.length]), OP.InitArray);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const entries = Object.entries(value);
|
|
200
|
+
for (const [key, item] of entries.reverse()) {
|
|
201
|
+
out.push(...pushAction([key]));
|
|
202
|
+
writeLiteral(out, item);
|
|
203
|
+
}
|
|
204
|
+
out.push(...pushAction([entries.length]), OP.InitObject);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Bytecode that assigns `parameters` in order, as Flash's Component Inspector writes it. */
|
|
208
|
+
export function encodeComponentParameters(parameters) {
|
|
209
|
+
const out = [];
|
|
210
|
+
for (const [name, value] of Object.entries(parameters)) {
|
|
211
|
+
if (Array.isArray(value)) {
|
|
212
|
+
out.push(...pushAction([name, 0]), OP.InitArray, OP.SetVariable);
|
|
213
|
+
value.forEach((item, index) => {
|
|
214
|
+
out.push(...pushAction([name]), OP.GetVariable, ...pushAction([index]));
|
|
215
|
+
writeLiteral(out, item);
|
|
216
|
+
out.push(OP.SetMember);
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
out.push(...pushAction([name]));
|
|
220
|
+
writeLiteral(out, value);
|
|
221
|
+
out.push(OP.SetVariable);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
out.push(OP.End);
|
|
225
|
+
return new Uint8Array(out);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ---- Project format ----
|
|
229
|
+
|
|
230
|
+
function readLiteral(value, at, depth = 0) {
|
|
231
|
+
if (typeof value === 'string' && (value.includes('\0') || new TextEncoder().encode(value).length > 65533)) throw new Error(`${at} is too long or contains a null character`);
|
|
232
|
+
if (isPrimitive(value)) return value;
|
|
233
|
+
if (!value || typeof value !== 'object' || depth >= 16) throw new Error(`${at} must contain only constant parameter data`);
|
|
234
|
+
if (Array.isArray(value)) {
|
|
235
|
+
if (value.length > MAX_ARRAY) throw new Error(`${at} has too many values`);
|
|
236
|
+
return value.map(item => readLiteral(item, at, depth + 1));
|
|
237
|
+
}
|
|
238
|
+
const entries = Object.entries(value);
|
|
239
|
+
if (entries.length > MAX_ARRAY) throw new Error(`${at} has too many fields`);
|
|
240
|
+
return Object.fromEntries(entries.map(([key, item]) => [readLiteral(key, at), readLiteral(item, at, depth + 1)]));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Validate `element.component`. */
|
|
244
|
+
export function readComponent(raw, label) {
|
|
245
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw new Error(`${label}.component must be an object`);
|
|
246
|
+
if (!KIND_SET.has(raw.kind)) throw new Error(`${label}.component.kind is not a supported control`);
|
|
247
|
+
if (!COMPONENT_EVENTS.includes(raw.event)) throw new Error(`${label}.component.event must be initialize or construct`);
|
|
248
|
+
const parameters = raw.parameters ?? {};
|
|
249
|
+
if (typeof parameters !== 'object' || Array.isArray(parameters)) throw new Error(`${label}.component.parameters must be an object`);
|
|
250
|
+
const names = Object.keys(parameters);
|
|
251
|
+
if (names.length > MAX_PARAMETERS) throw new Error(`${label}.component has too many parameters`);
|
|
252
|
+
const result = {};
|
|
253
|
+
for (const name of names) {
|
|
254
|
+
const value = parameters[name];
|
|
255
|
+
const at = `${label}.component.parameters.${name}`;
|
|
256
|
+
if (!/^[A-Za-z_$][\w$]{0,127}$/.test(name)) throw new Error(`${at} is not a valid parameter name`);
|
|
257
|
+
const literal = readLiteral(value, at);
|
|
258
|
+
Object.defineProperty(result, name, { value: literal, writable: true, enumerable: true, configurable: true });
|
|
259
|
+
}
|
|
260
|
+
return { kind: raw.kind, event: raw.event, parameters: result };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** Validate `symbol.component`. */
|
|
264
|
+
export function readComponentSymbol(raw, label) {
|
|
265
|
+
if (!raw || typeof raw !== 'object' || !KIND_SET.has(raw.kind)) throw new Error(`${label}.component.kind is not a supported control`);
|
|
266
|
+
if (!['mx', 'v2'].includes(raw.generation)) throw new Error(`${label}.component.generation must be mx or v2`);
|
|
267
|
+
return { kind: raw.kind, generation: raw.generation };
|
|
268
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// Construct one frame of the authored display tree. Canvas strips on either
|
|
2
|
+
// side of native inputs recreate only the active chain of Sprite containers.
|
|
3
|
+
import { isEditableText } from './text-fields.js';
|
|
4
|
+
import { blendModes } from './placement-effects.js';
|
|
5
|
+
import { maskSlots, maskSources } from './masks.js';
|
|
6
|
+
import { orientedVectorPathData, vectorMaskPath } from './vector-geometry.js';
|
|
7
|
+
import { hasVectorFill } from './vector-style.js';
|
|
8
|
+
import { Sprite } from '../swooflib/graphics.js';
|
|
9
|
+
import { ColorTransform, Matrix } from '../swooflib/geom.js';
|
|
10
|
+
import { renderDisplayTree } from '../swooflib/render.js';
|
|
11
|
+
import { matrixComponents, orderedSceneElements, pointToLocal, poseAt } from './model.js';
|
|
12
|
+
import { advanceSymbol, scopedId, symbolFrame, symbolPlacementFrame } from './symbols.js';
|
|
13
|
+
|
|
14
|
+
function displayMatrix(pose) {
|
|
15
|
+
const { a, b, c, d } = matrixComponents(pose);
|
|
16
|
+
return new Matrix(a, b, c, d, pose.x, pose.y);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function insideBounds(pose, point) {
|
|
20
|
+
const local = pointToLocal(point, pose);
|
|
21
|
+
return Math.abs(local.x) <= pose.width / 2 && Math.abs(local.y) <= pose.height / 2;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// `capture` evaluates the frame as Preview does (hidden objects, symbol clocks, active timelines)
|
|
25
|
+
// but draws inputs and controls as artwork on the one canvas, for video export.
|
|
26
|
+
export function buildDisplayFrame({ scene, symbols, playhead, ctx, preview, makeArtwork, makeButton,
|
|
27
|
+
inPreview, capture = false, previewHiddenIds, clocks, editingTextElementId, pressedButtonId, hoveredButtonId, selectedId, onFlush = null }) {
|
|
28
|
+
const definitions = new Map(symbols.map(item => [item.id, item]));
|
|
29
|
+
const entries = new Map();
|
|
30
|
+
const controls = [];
|
|
31
|
+
const timelines = [];
|
|
32
|
+
let root = new Sprite();
|
|
33
|
+
let paint = ctx;
|
|
34
|
+
let lastInput = null;
|
|
35
|
+
let paintClips = [];
|
|
36
|
+
|
|
37
|
+
// Keep adjacent display objects in one Swoof tree until their clipping region
|
|
38
|
+
// changes or a native input splits the canvas. Paths are in stage coordinates.
|
|
39
|
+
// `onFlush(root, clips)` receives each strip instead of it being painted (SVG export).
|
|
40
|
+
function flush() {
|
|
41
|
+
if (root.numChildren && onFlush) onFlush(root, paintClips);
|
|
42
|
+
else if (root.numChildren) {
|
|
43
|
+
paint.save();
|
|
44
|
+
for (const clip of paintClips) paint.clip(clip.stagePath, clip.rule ?? 'nonzero');
|
|
45
|
+
renderDisplayTree(paint, root, 0);
|
|
46
|
+
paint.restore();
|
|
47
|
+
}
|
|
48
|
+
root = new Sprite();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Tints and brightness (pose.colorTransform); `alpha` stays the pose's opacity.
|
|
52
|
+
function applyColor(display, colorTransform, alpha) {
|
|
53
|
+
if (colorTransform) {
|
|
54
|
+
const c = colorTransform;
|
|
55
|
+
display.transform.colorTransform = new ColorTransform(c.redMultiplier, c.greenMultiplier, c.blueMultiplier, 1,
|
|
56
|
+
c.redOffset, c.greenOffset, c.blueOffset, 0);
|
|
57
|
+
}
|
|
58
|
+
display.alpha = alpha;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function container(parent, name, matrix, opacity = 1, colorTransform = null, pose = {}, key = name) {
|
|
62
|
+
let strip, sprite;
|
|
63
|
+
return () => {
|
|
64
|
+
if (strip !== root) {
|
|
65
|
+
strip = root;
|
|
66
|
+
sprite = new Sprite();
|
|
67
|
+
sprite.name = name;
|
|
68
|
+
sprite._svgKey = key;
|
|
69
|
+
if (matrix) sprite.transform.matrix = matrix;
|
|
70
|
+
applyColor(sprite, colorTransform, opacity);
|
|
71
|
+
if (pose.filters) sprite.filters = pose.filters;
|
|
72
|
+
if (pose.blendMode) sprite.blendMode = blendModes[pose.blendMode];
|
|
73
|
+
parent().addChild(sprite);
|
|
74
|
+
}
|
|
75
|
+
return sprite;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// A symbol used as a mask clips by the filled shapes of its current frame; lines do not count,
|
|
80
|
+
// as in Flash. The clip path is in the definition's space, mapped to the stage by `matrix`.
|
|
81
|
+
function symbolMaskPath(element, frame, pose, world) {
|
|
82
|
+
const definition = definitions.get(element.symbolId);
|
|
83
|
+
if (!definition) return null;
|
|
84
|
+
const parts = [];
|
|
85
|
+
const collect = (timeline, childFrame, toSpace, nesting) => {
|
|
86
|
+
for (const child of orderedSceneElements(timeline, { includeHidden: false, frame: childFrame })) {
|
|
87
|
+
const childPose = poseAt(child, childFrame, child.keyframes);
|
|
88
|
+
const childMatrix = displayMatrix(childPose).concat(toSpace);
|
|
89
|
+
if (child.type === 'symbol') {
|
|
90
|
+
const inner = definitions.get(child.symbolId);
|
|
91
|
+
if (!inner || nesting > 16) continue;
|
|
92
|
+
const local = new Matrix(childPose.width / inner.width, 0, 0, childPose.height / inner.height,
|
|
93
|
+
-childPose.width / 2, -childPose.height / 2).concat(childMatrix);
|
|
94
|
+
collect(inner, symbolFrame(child, inner, childFrame), local, nesting + 1);
|
|
95
|
+
} else if (hasVectorFill(child)) {
|
|
96
|
+
parts.push(orientedVectorPathData(child, childPose, childMatrix));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
collect(definition, symbolFrame(element, definition, frame), new Matrix(), 0);
|
|
101
|
+
const data = parts.join(' ');
|
|
102
|
+
const matrix = new Matrix(pose.width / definition.width, 0, 0, pose.height / definition.height, -pose.width / 2, -pose.height / 2)
|
|
103
|
+
.concat(displayMatrix(pose)).concat(world);
|
|
104
|
+
const stagePath = new Path2D();
|
|
105
|
+
stagePath.addPath(new Path2D(data), { a: matrix.a, b: matrix.b, c: matrix.c, d: matrix.d, e: matrix.tx, f: matrix.ty });
|
|
106
|
+
return { data, matrix, stagePath };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function drawTimeline(timeline, frame, scope, parent, world, opacity, parentFrame, inheritedClips, exposure = '', repeatOnTick = false, audioActive = true) {
|
|
110
|
+
if (inPreview) timelines.push({ timeline, frame, scope, parentFrame, exposure, repeatOnTick, audioActive });
|
|
111
|
+
const childrenInTimeline = [];
|
|
112
|
+
let groupId, mount = parent;
|
|
113
|
+
const visible = orderedSceneElements(timeline, { includeHidden: false, frame })
|
|
114
|
+
.filter(item => !inPreview || !previewHiddenIds.has(scopedId(scope, item.id)));
|
|
115
|
+
const sources = maskSources(timeline);
|
|
116
|
+
// Imported masks swapped at their depth (mask slots) clip the targets of the first one.
|
|
117
|
+
const slots = maskSlots(timeline);
|
|
118
|
+
for (const members of slots.values()) {
|
|
119
|
+
for (const member of members) if (hasVectorFill(member) || member.type === 'symbol') sources.add(member.id);
|
|
120
|
+
}
|
|
121
|
+
const stencils = new Map();
|
|
122
|
+
for (const element of visible) {
|
|
123
|
+
if (!sources.has(element.id)) continue;
|
|
124
|
+
const pose = poseAt(element, frame, element.keyframes);
|
|
125
|
+
const path = element.type === 'symbol'
|
|
126
|
+
? symbolMaskPath(element, frame, pose, world)
|
|
127
|
+
: vectorMaskPath(element, pose, displayMatrix(pose).concat(world));
|
|
128
|
+
if (path) {
|
|
129
|
+
path.key = scopedId(scope, element.id);
|
|
130
|
+
stencils.set(element.id, { element, path });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const stencilFor = id => stencils.get(id) ?? slots.get(id)?.map(member => stencils.get(member.id)).find(Boolean);
|
|
134
|
+
const sourceHidden = id => {
|
|
135
|
+
const source = timeline.elements.find(element => element.id === id);
|
|
136
|
+
return timeline.layers?.find(layer => layer.id === source?.layerId)?.visible === false
|
|
137
|
+
|| (inPreview && previewHiddenIds.has(scopedId(scope, id)));
|
|
138
|
+
};
|
|
139
|
+
const chains = new Map();
|
|
140
|
+
function clipsFor(maskId) {
|
|
141
|
+
if (!maskId) return inheritedClips;
|
|
142
|
+
if (chains.has(maskId)) return chains.get(maskId);
|
|
143
|
+
const clips = [...inheritedClips];
|
|
144
|
+
let id = maskId;
|
|
145
|
+
let stencil;
|
|
146
|
+
while (id && (stencil = stencilFor(id))) {
|
|
147
|
+
clips.push(stencil.path);
|
|
148
|
+
id = stencil.element.maskId;
|
|
149
|
+
}
|
|
150
|
+
// A hidden or blank source anywhere in the chain hides the entire target. An imported mask
|
|
151
|
+
// slot with nothing on stage leaves it unmasked, as in Flash, unless its layer is hidden.
|
|
152
|
+
const result = id && (!slots.has(id) || sourceHidden(id)) ? null : clips;
|
|
153
|
+
chains.set(maskId, result);
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
for (const element of visible) {
|
|
157
|
+
const id = scopedId(scope, element.id);
|
|
158
|
+
if (inPreview && element.type === 'control' && element.parameters?.visible === false) continue;
|
|
159
|
+
const stencil = stencils.get(element.id);
|
|
160
|
+
if (stencil) {
|
|
161
|
+
if (!inPreview && !scope.length && selectedId === element.id) {
|
|
162
|
+
const path = stencil.path.stagePath;
|
|
163
|
+
entries.set(id, { pose: poseAt(element, frame, element.keyframes), maskPath: path,
|
|
164
|
+
hit: point => ctx.isPointInPath(path, point.x, point.y) });
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const clips = clipsFor(element.maskId);
|
|
169
|
+
if (!clips) continue;
|
|
170
|
+
if (element.groupId !== groupId) {
|
|
171
|
+
groupId = element.groupId;
|
|
172
|
+
mount = groupId ? container(parent, groupId, null, 1, null, {}, `group:${scopedId(scope, groupId)}`) : parent;
|
|
173
|
+
}
|
|
174
|
+
const pose = poseAt(element, frame, element.keyframes);
|
|
175
|
+
const matrix = displayMatrix(pose);
|
|
176
|
+
const global = matrix.clone().concat(world);
|
|
177
|
+
const globalPose = { ...pose, matrix: global, x: global.tx, y: global.ty, opacity: opacity * pose.opacity };
|
|
178
|
+
const entry = { id, element, timeline, frame, parentFrame, scope, pose: globalPose, clips };
|
|
179
|
+
if (inPreview && (element.field?.variable || element.variable)) {
|
|
180
|
+
entry.scopeNames = scope.map((part, i) => entries.get(scopedId(scope.slice(0, i), part))?.element.name ?? part);
|
|
181
|
+
}
|
|
182
|
+
entries.set(id, entry);
|
|
183
|
+
if (element.type === 'symbol') {
|
|
184
|
+
const definition = definitions.get(element.symbolId);
|
|
185
|
+
const childScope = [...scope, element.id];
|
|
186
|
+
let clock = inPreview && clocks.get(id);
|
|
187
|
+
if (clock && (frame < clock.lastFrame ||
|
|
188
|
+
element.keyframes.some(key => key.blank && key.frame > clock.lastFrame && key.frame <= frame))) {
|
|
189
|
+
clocks.delete(id);
|
|
190
|
+
clock = null;
|
|
191
|
+
}
|
|
192
|
+
if (clock) clock.lastFrame = frame;
|
|
193
|
+
const placement = symbolPlacementFrame(element, frame);
|
|
194
|
+
const childFrame = clock
|
|
195
|
+
? advanceSymbol(element, definition, clock.frame, clock.play ? frame - clock.anchor : 0)
|
|
196
|
+
: symbolFrame(element, definition, frame, placement);
|
|
197
|
+
// Map the definition artboard onto the instance's authored rectangle.
|
|
198
|
+
const local = new Matrix(pose.width / definition.width, 0, 0, pose.height / definition.height,
|
|
199
|
+
-pose.width / 2, -pose.height / 2).concat(matrix);
|
|
200
|
+
const childMount = container(mount, element.name, local, pose.opacity, pose.colorTransform, pose, id);
|
|
201
|
+
const loops = element.symbolMode ? element.symbolMode === 'loop' : definition.loop;
|
|
202
|
+
const first = element.firstFrame ?? definition.startFrame;
|
|
203
|
+
const running = element.symbolMode !== 'single' && clock?.play !== false;
|
|
204
|
+
const elapsedFrame = clock ? clock.frame + frame - clock.anchor : first + frame - placement;
|
|
205
|
+
const children = drawTimeline(definition, childFrame, childScope, childMount,
|
|
206
|
+
local.clone().concat(world), globalPose.opacity, frame, clips, `${exposure}/${placement}`,
|
|
207
|
+
running && loops && first === definition.durationFrames,
|
|
208
|
+
audioActive && running && (loops || elapsedFrame <= definition.durationFrames));
|
|
209
|
+
entry.hit = children.length
|
|
210
|
+
? point => children.some(child => child.hit(point))
|
|
211
|
+
: point => !inPreview && insideBounds(globalPose, point);
|
|
212
|
+
} else if (inPreview && !capture && element.type === 'control') {
|
|
213
|
+
flush();
|
|
214
|
+
preview.control(entry, exposure + '/' + symbolPlacementFrame(element, frame));
|
|
215
|
+
lastInput = id;
|
|
216
|
+
entry.hit = point => insideBounds(globalPose, point);
|
|
217
|
+
} else if (inPreview && !capture && element.type === 'text' && !element.buttonAction &&
|
|
218
|
+
(isEditableText(element) || element.field?.selectable || element.field?.variable)) {
|
|
219
|
+
flush();
|
|
220
|
+
preview.input(entry);
|
|
221
|
+
lastInput = id;
|
|
222
|
+
entry.hit = point => insideBounds(globalPose, point);
|
|
223
|
+
} else {
|
|
224
|
+
if (lastInput !== null) {
|
|
225
|
+
paint = preview.canvasAbove(lastInput);
|
|
226
|
+
lastInput = null;
|
|
227
|
+
}
|
|
228
|
+
if (paintClips !== clips) {
|
|
229
|
+
flush();
|
|
230
|
+
paintClips = clips;
|
|
231
|
+
}
|
|
232
|
+
const art = makeArtwork(element, pose);
|
|
233
|
+
const display = element.buttonAction
|
|
234
|
+
? makeButton(art, element, pose, inPreview && pressedButtonId === id, inPreview && hoveredButtonId === id)
|
|
235
|
+
: art;
|
|
236
|
+
if (pose.filters) display.filters = [...pose.filters, ...(display.filters ?? [])];
|
|
237
|
+
if (pose.blendMode) display.blendMode = blendModes[pose.blendMode];
|
|
238
|
+
display.name = element.name;
|
|
239
|
+
display._svgKey = id;
|
|
240
|
+
display.transform.matrix = matrix;
|
|
241
|
+
applyColor(display, pose.colorTransform, !scope.length && editingTextElementId === element.id ? 0 : pose.opacity);
|
|
242
|
+
mount().addChild(display);
|
|
243
|
+
entry.hit = point => display.hitTestPoint(point.x, point.y, true);
|
|
244
|
+
}
|
|
245
|
+
if (clips.length) {
|
|
246
|
+
const hit = entry.hit;
|
|
247
|
+
entry.hit = point => clips.every(clip => ctx.isPointInPath(clip.stagePath, point.x, point.y, clip.rule ?? 'nonzero')) && hit(point);
|
|
248
|
+
}
|
|
249
|
+
if (inPreview && !capture && element.buttonAction) preview.button(entry);
|
|
250
|
+
if (element.buttonAction || isEditableText(element) || element.field?.selectable || element.type === 'control') controls.push(entry);
|
|
251
|
+
childrenInTimeline.push(entry);
|
|
252
|
+
}
|
|
253
|
+
return childrenInTimeline;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
drawTimeline(scene, playhead, [], () => root, new Matrix(), 1, playhead, []);
|
|
257
|
+
for (const id of clocks.keys()) {
|
|
258
|
+
if (!entries.has(id)) clocks.delete(id);
|
|
259
|
+
}
|
|
260
|
+
flush();
|
|
261
|
+
return { entries, controls, paint, timelines };
|
|
262
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ensureKeyframe, isElementLocked } from './model.js';
|
|
2
|
+
import { appearanceKinds, shapePropertyValue } from './vector-style.js';
|
|
3
|
+
import { numericPoseRange, readInteger, readNumber, stageRanges } from './numeric-fields.js';
|
|
4
|
+
import { objectAction, removeEventTargets } from './frame-events.js';
|
|
5
|
+
import { pruneGroups } from './groups.js';
|
|
6
|
+
import { removeMissingMasks } from './masks.js';
|
|
7
|
+
|
|
8
|
+
export function setPoseAtFrame(element, frame, property, value) {
|
|
9
|
+
for (const existing of element.keyframes) {
|
|
10
|
+
if (existing[property] === undefined) {
|
|
11
|
+
if (property === 'erasures') existing.erasures = element.erasures ?? [];
|
|
12
|
+
else if (['starPoints', 'starRadius', 'cornerRadius'].includes(property)) {
|
|
13
|
+
existing[property] = element[property] ?? shapePropertyValue(property, { ...element, ...existing });
|
|
14
|
+
} else existing[property] = Object.hasOwn(appearanceKinds, property) ? element[property] ?? null : element[property];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const keyframe = ensureKeyframe(element, frame);
|
|
18
|
+
keyframe[property] = value;
|
|
19
|
+
if (frame === 1 || element.keyframes.length <= 1) {
|
|
20
|
+
element[property] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function setNumericPoseAtFrame(element, frame, property, value, stage) {
|
|
25
|
+
readNumber(value, property, ...numericPoseRange(property, stage));
|
|
26
|
+
setPoseAtFrame(element, frame, property, value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function setStageNumber(project, timeline, property, value) {
|
|
30
|
+
const read = property === 'frameRate' ? readNumber : readInteger;
|
|
31
|
+
read(value, property, ...stageRanges[property]);
|
|
32
|
+
const symbol = project.symbols?.includes(timeline);
|
|
33
|
+
const target = symbol && property !== 'frameRate' ? timeline : project.stage;
|
|
34
|
+
target[property] = value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function setStartFrame(scene, value) {
|
|
38
|
+
scene.startFrame = readInteger(value, 'Start frame', 1, scene.durationFrames);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function removeObjects(scene, ids) {
|
|
42
|
+
const removed = new Set(ids);
|
|
43
|
+
if (scene.elements.some(el => removed.has(el.id) && isElementLocked(scene, el))) {
|
|
44
|
+
throw new Error('Unlock the layer before deleting these objects');
|
|
45
|
+
}
|
|
46
|
+
removeEventTargets(scene, removed, objectAction, true);
|
|
47
|
+
scene.elements = scene.elements.filter(el => !removed.has(el.id));
|
|
48
|
+
pruneGroups(scene);
|
|
49
|
+
removeMissingMasks(scene);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function removeProjectScene(project, id) {
|
|
53
|
+
if (project.scenes.length <= 1) throw new Error('A movie must keep at least one scene');
|
|
54
|
+
const index = project.scenes.findIndex(scene => scene.id === id);
|
|
55
|
+
if (index < 0) throw new Error('Choose an existing scene');
|
|
56
|
+
const removedIds = new Set([id]);
|
|
57
|
+
for (const owner of [...project.scenes, ...(project.symbols ?? [])]) {
|
|
58
|
+
removeEventTargets(owner, removedIds, type => type === 'gotoScene');
|
|
59
|
+
}
|
|
60
|
+
for (const symbol of project.symbols ?? []) {
|
|
61
|
+
if (symbol.initAt?.scene === id) delete symbol.initAt;
|
|
62
|
+
}
|
|
63
|
+
const [removed] = project.scenes.splice(index, 1);
|
|
64
|
+
// The original class dictionary belongs to the entire movie, including later scenes.
|
|
65
|
+
for (const record of removed.avm2 ?? []) {
|
|
66
|
+
if (record.library) (project.scenes[0].avm2 ??= []).unshift({ ...record, frame: 1 });
|
|
67
|
+
}
|
|
68
|
+
return { removed, next: project.scenes[Math.max(0, index - 1)] };
|
|
69
|
+
}
|