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,104 @@
|
|
|
1
|
+
// Records a movie that plays on the swf2js player (studiospec/video-export.md §8.9): the Preview
|
|
2
|
+
// build made with `record: true` runs in an invisible sandboxed frame whose clock only moves
|
|
3
|
+
// when it is asked for the next frame (preview-recorder.js). Frames come back as ImageBitmaps.
|
|
4
|
+
|
|
5
|
+
const EVENT_TAIL_SECONDS = 30;
|
|
6
|
+
|
|
7
|
+
function abortError() {
|
|
8
|
+
return new DOMException('Video export was cancelled', 'AbortError');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Opens the recording frame for `url` (a Preview URL built with `record: true`).
|
|
13
|
+
* Returns `{ width, height, step(), audio(seconds), close() }`.
|
|
14
|
+
*/
|
|
15
|
+
export async function openRecording(url, { fps, width, height, signal }) {
|
|
16
|
+
const frame = document.createElement('iframe');
|
|
17
|
+
frame.title = 'Video recording';
|
|
18
|
+
frame.setAttribute('aria-hidden', 'true');
|
|
19
|
+
frame.tabIndex = -1;
|
|
20
|
+
// In the viewport but invisible, so the browser keeps the frame running at full speed.
|
|
21
|
+
frame.style.cssText = `position:fixed;left:0;top:0;width:${width}px;height:${height}px;border:0;opacity:0;pointer-events:none;z-index:-1`;
|
|
22
|
+
let pending = null;
|
|
23
|
+
const onMessage = event => {
|
|
24
|
+
if (event.source !== frame.contentWindow || !event.data?.swoofRecorder || !pending) return;
|
|
25
|
+
const { resolve, reject } = pending;
|
|
26
|
+
pending = null;
|
|
27
|
+
if (event.data.swoofRecorder === 'error') reject(new Error(`The movie could not be recorded: ${event.data.message}`));
|
|
28
|
+
else resolve(event.data);
|
|
29
|
+
};
|
|
30
|
+
window.addEventListener('message', onMessage);
|
|
31
|
+
const close = () => {
|
|
32
|
+
window.removeEventListener('message', onMessage);
|
|
33
|
+
if (pending) pending.reject(abortError());
|
|
34
|
+
pending = null;
|
|
35
|
+
frame.remove();
|
|
36
|
+
};
|
|
37
|
+
const request = (message, timeout = 60000) => new Promise((resolve, reject) => {
|
|
38
|
+
if (signal?.aborted) return reject(abortError());
|
|
39
|
+
const timer = setTimeout(() => {
|
|
40
|
+
if (pending?.resolve !== done) return;
|
|
41
|
+
pending = null;
|
|
42
|
+
reject(new Error('The movie stopped responding while it was recorded'));
|
|
43
|
+
}, timeout);
|
|
44
|
+
const done = value => { clearTimeout(timer); resolve(value); };
|
|
45
|
+
pending = { resolve: done, reject: error => { clearTimeout(timer); reject(error); } };
|
|
46
|
+
frame.contentWindow.postMessage(message, '*');
|
|
47
|
+
});
|
|
48
|
+
signal?.addEventListener('abort', () => pending?.reject(abortError()), { once: true });
|
|
49
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
50
|
+
frame.src = `${url}${separator}swoofRecord=1`;
|
|
51
|
+
document.body.append(frame);
|
|
52
|
+
try {
|
|
53
|
+
await new Promise((resolve, reject) => {
|
|
54
|
+
frame.addEventListener('load', resolve, { once: true });
|
|
55
|
+
frame.addEventListener('error', () => reject(new Error('The movie could not be loaded for recording')), { once: true });
|
|
56
|
+
});
|
|
57
|
+
const ready = await request({ swoofRecord: 'start', fps }, 120000);
|
|
58
|
+
return {
|
|
59
|
+
width: ready.width, height: ready.height, frameCount: ready.frameCount,
|
|
60
|
+
step: () => request({ swoofRecord: 'step' }),
|
|
61
|
+
audio: seconds => request({ swoofRecord: 'finish', seconds, sound: true }, 300000),
|
|
62
|
+
close,
|
|
63
|
+
};
|
|
64
|
+
} catch (error) {
|
|
65
|
+
close();
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Steps `recording` and passes each frame to `onFrame(bitmap)`, deciding the ending:
|
|
72
|
+
* - stop: the root timeline has stopped, no sound plays and the picture has not changed for
|
|
73
|
+
* `holdFrames` frames (or event sounds ran 30 s past the stop);
|
|
74
|
+
* - repeat: the playing root timeline jumped back (or wrapped) to a frame it showed before, and
|
|
75
|
+
* shows the picture it showed there then, at least a second later (so one- or two-frame
|
|
76
|
+
* script loops do not count); that frame is not recorded;
|
|
77
|
+
* - length: `maxFrames` frames.
|
|
78
|
+
* Returns `{ frames, ending }`.
|
|
79
|
+
*/
|
|
80
|
+
export async function recordFrames(recording, { maxFrames, holdFrames, fps, signal, onFrame }) {
|
|
81
|
+
let frames = 0, still = 0, previous = null, stoppedAt = null, ending = 'length';
|
|
82
|
+
const seen = new Map(); // root frame → { picture, at } when it was first recorded
|
|
83
|
+
while (frames < maxFrames) {
|
|
84
|
+
if (signal?.aborted) throw abortError();
|
|
85
|
+
const { bitmap, state } = await recording.step();
|
|
86
|
+
const before = seen.get(state.frame);
|
|
87
|
+
if (previous?.playing && state.frame < previous.frame && before?.picture === state.picture && frames - before.at >= fps) {
|
|
88
|
+
bitmap.close();
|
|
89
|
+
ending = 'repeat';
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
if (!before) seen.set(state.frame, { picture: state.picture, at: frames });
|
|
93
|
+
await onFrame(bitmap);
|
|
94
|
+
bitmap.close();
|
|
95
|
+
frames++;
|
|
96
|
+
still = previous && state.picture === previous.picture ? still + 1 : 0;
|
|
97
|
+
if (state.playing) stoppedAt = null;
|
|
98
|
+
else stoppedAt ??= frames;
|
|
99
|
+
previous = state;
|
|
100
|
+
if (!state.playing && state.sounds === 0 && still >= holdFrames) { ending = 'stop'; break; }
|
|
101
|
+
if (stoppedAt != null && frames - stoppedAt >= EVENT_TAIL_SECONDS * fps + holdFrames) { ending = 'stop'; break; }
|
|
102
|
+
}
|
|
103
|
+
return { frames, ending };
|
|
104
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { referencesSymbol } from './symbols.js';
|
|
2
|
+
|
|
3
|
+
export function createSymbolLibrary({ create, edit, place, back, scripts }) {
|
|
4
|
+
const list = document.querySelector('#symbol-library');
|
|
5
|
+
const newButton = document.querySelector('#new-symbol');
|
|
6
|
+
const placeButton = document.querySelector('#place-symbol');
|
|
7
|
+
const editButton = document.querySelector('#edit-symbol');
|
|
8
|
+
const backButton = document.querySelector('#leave-symbol');
|
|
9
|
+
const scriptButton = document.querySelector('#symbol-scripts');
|
|
10
|
+
let state;
|
|
11
|
+
newButton.addEventListener('click', create);
|
|
12
|
+
editButton.addEventListener('click', () => edit(list.value));
|
|
13
|
+
scriptButton.addEventListener('click', () => scripts(list.value));
|
|
14
|
+
placeButton.addEventListener('click', () => place(list.value));
|
|
15
|
+
backButton.addEventListener('click', back);
|
|
16
|
+
list.addEventListener('change', updateButtons);
|
|
17
|
+
|
|
18
|
+
function updateButtons() {
|
|
19
|
+
const { definitions, timeline, locked, layerLocked, editing } = state;
|
|
20
|
+
const selected = definitions.get(list.value);
|
|
21
|
+
list.disabled = locked || !definitions.size;
|
|
22
|
+
newButton.disabled = locked;
|
|
23
|
+
editButton.disabled = locked || !selected || selected === timeline;
|
|
24
|
+
scriptButton.disabled = locked || !selected;
|
|
25
|
+
placeButton.disabled = locked || layerLocked || !selected ||
|
|
26
|
+
(editing && referencesSymbol(definitions, selected, timeline.id));
|
|
27
|
+
backButton.hidden = !editing;
|
|
28
|
+
backButton.disabled = locked;
|
|
29
|
+
}
|
|
30
|
+
return function render(symbols, timeline, editing, locked, layerLocked, preferred) {
|
|
31
|
+
const selected = preferred || list.value;
|
|
32
|
+
const definitions = new Map(symbols.map(item => [item.id, item]));
|
|
33
|
+
list.replaceChildren(...symbols.map(item => new Option(item.name, item.id)));
|
|
34
|
+
if (!symbols.length) list.add(new Option('No symbols yet', ''));
|
|
35
|
+
if (definitions.has(selected)) list.value = selected;
|
|
36
|
+
state = { definitions, timeline, locked, layerLocked, editing };
|
|
37
|
+
updateButtons();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { advancePlayhead } from './playback.js';
|
|
2
|
+
|
|
3
|
+
export function advanceSymbol(instance, definition, frame, steps) {
|
|
4
|
+
if (instance.symbolMode === 'single') return frame;
|
|
5
|
+
const startFrame = instance.firstFrame ?? definition.startFrame;
|
|
6
|
+
const loop = instance.symbolMode ? instance.symbolMode === 'loop' : definition.loop;
|
|
7
|
+
return advancePlayhead({ durationFrames: definition.durationFrames, startFrame, loop }, frame, steps).frame;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// The local clock starts on placement and restarts after a blank exposure.
|
|
11
|
+
// Ordinary transform keys keep the same clock.
|
|
12
|
+
export function symbolPlacementFrame(instance, frame) {
|
|
13
|
+
let first = 1;
|
|
14
|
+
let blank = false;
|
|
15
|
+
for (const key of instance.keyframes) {
|
|
16
|
+
if (key.frame > frame) break;
|
|
17
|
+
if (blank && !key.blank) first = key.frame;
|
|
18
|
+
blank = Boolean(key.blank);
|
|
19
|
+
}
|
|
20
|
+
return first;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function symbolFrame(instance, definition, frame, first = symbolPlacementFrame(instance, frame)) {
|
|
24
|
+
const startFrame = instance.firstFrame ?? definition.startFrame;
|
|
25
|
+
return advanceSymbol(instance, definition, startFrame, frame - first);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function referencesSymbol(definitions, definition, targetId, seen = new Set()) {
|
|
29
|
+
if (definition.id === targetId) return true;
|
|
30
|
+
if (seen.has(definition.id)) return false;
|
|
31
|
+
seen.add(definition.id);
|
|
32
|
+
return definition.elements.some(element => {
|
|
33
|
+
if (element.type !== 'symbol') return false;
|
|
34
|
+
const child = definitions.get(element.symbolId);
|
|
35
|
+
return child && referencesSymbol(definitions, child, targetId, seen);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function validateSymbolReferences(project) {
|
|
40
|
+
const definitions = new Map((project.symbols ?? []).map(item => [item.id, item]));
|
|
41
|
+
const checked = new Set();
|
|
42
|
+
const visiting = new Set();
|
|
43
|
+
function visit(timeline) {
|
|
44
|
+
if (checked.has(timeline)) return;
|
|
45
|
+
if (visiting.has(timeline)) throw new Error('A symbol cannot contain itself, including through another symbol');
|
|
46
|
+
visiting.add(timeline);
|
|
47
|
+
for (const item of timeline.elements) {
|
|
48
|
+
if (item.type !== 'symbol') continue;
|
|
49
|
+
const child = definitions.get(item.symbolId);
|
|
50
|
+
if (!child) throw new Error(`Unknown symbol "${item.symbolId}" for ${item.name}`);
|
|
51
|
+
if (item.firstFrame > child.durationFrames) throw new Error(`${item.name} starts beyond the duration of ${child.name}`);
|
|
52
|
+
visit(child);
|
|
53
|
+
}
|
|
54
|
+
visiting.delete(timeline);
|
|
55
|
+
checked.add(timeline);
|
|
56
|
+
}
|
|
57
|
+
for (const timeline of [...definitions.values(), ...project.scenes]) visit(timeline);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function scopedId(scope, id) {
|
|
61
|
+
return scope.length || id.startsWith('[') ? JSON.stringify([...scope, id]) : id;
|
|
62
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Imported HTML fields carry the original markup beside the plain base text.
|
|
2
|
+
// New keyframes can override it by storing their own text or markup.
|
|
3
|
+
export function fieldText(element, pose) {
|
|
4
|
+
return element.field?.html && element.field.htmlText !== undefined && pose.text === element.text
|
|
5
|
+
? element.field.htmlText : pose.text;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function materializeHtmlText(element) {
|
|
9
|
+
const field = element.field;
|
|
10
|
+
if (!field?.html || field.htmlText === undefined) return;
|
|
11
|
+
for (const key of element.keyframes) if (key.text === element.text) key.text = field.htmlText;
|
|
12
|
+
element.text = field.htmlText;
|
|
13
|
+
delete field.htmlText;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function isEditableText(element) {
|
|
17
|
+
return element.type === 'text' && (element.field?.editable ?? !!element.inputText);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Canvas and native text inputs can use the same embedded subset as the published SWF.
|
|
21
|
+
// Remove a project's faces when it closes so another movie can use a different subset
|
|
22
|
+
// with the same Flash family name. HTML face spans use that original family name.
|
|
23
|
+
let activeScripts;
|
|
24
|
+
const faces = new Map();
|
|
25
|
+
export function syncEmbeddedFonts(scripts, repaint) {
|
|
26
|
+
if (scripts === activeScripts || typeof FontFace !== 'function' || !document.fonts) return;
|
|
27
|
+
activeScripts = scripts;
|
|
28
|
+
const next = new Set();
|
|
29
|
+
const loading = [];
|
|
30
|
+
for (const script of scripts ?? []) for (const font of script.fontFaces ?? []) {
|
|
31
|
+
const key = `${script.id}/${font.id}`;
|
|
32
|
+
next.add(key);
|
|
33
|
+
if (faces.get(key)?.data === font.data) continue;
|
|
34
|
+
for (const old of faces.get(key)?.registered ?? []) document.fonts.delete(old);
|
|
35
|
+
const entry = { data: font.data, alias: 'StudioFont' + script.id.replace(/\W/g, '_') + '_' + font.id, registered: [] };
|
|
36
|
+
faces.set(key, entry);
|
|
37
|
+
try {
|
|
38
|
+
const bytes = Uint8Array.from(atob(font.data), c => c.charCodeAt(0));
|
|
39
|
+
for (const family of [entry.alias, font.family]) {
|
|
40
|
+
const face = new FontFace(JSON.stringify(family), bytes, { weight: font.bold ? 'bold' : 'normal', style: font.italic ? 'italic' : 'normal' });
|
|
41
|
+
document.fonts.add(face);
|
|
42
|
+
entry.registered.push(face);
|
|
43
|
+
loading.push(face.load());
|
|
44
|
+
}
|
|
45
|
+
} catch { /* An unsupported font uses the field's fallback family. */ }
|
|
46
|
+
}
|
|
47
|
+
for (const [key, entry] of faces) if (!next.has(key)) {
|
|
48
|
+
for (const face of entry.registered) document.fonts.delete(face);
|
|
49
|
+
faces.delete(key);
|
|
50
|
+
}
|
|
51
|
+
if (loading.length) Promise.allSettled(loading).then(() => { if (activeScripts === scripts) repaint(); });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function editorFieldFont(element, pose) {
|
|
55
|
+
const field = element.field;
|
|
56
|
+
const entry = field?.useOutlines && field.fontFamily === pose.fontFamily && faces.get(`${field.fontLibrary}/${field.fontId}`);
|
|
57
|
+
return entry?.registered?.[0]?.status === 'loaded' ? entry.alias : pose.fontFamily;
|
|
58
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Resolve the workspace palette before the stylesheet paints the first frame.
|
|
2
|
+
(() => {
|
|
3
|
+
const storageKey = 'swoof-studio.theme';
|
|
4
|
+
const system = window.matchMedia('(prefers-color-scheme: dark)');
|
|
5
|
+
const preference = value => value === 'light' || value === 'dark' ? value : 'system';
|
|
6
|
+
let mode = 'system';
|
|
7
|
+
let control;
|
|
8
|
+
try {
|
|
9
|
+
mode = preference(localStorage.getItem(storageKey));
|
|
10
|
+
} catch {
|
|
11
|
+
// The theme can still be changed for this tab when storage is unavailable.
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function apply() {
|
|
15
|
+
const resolved = mode === 'system' ? (system.matches ? 'dark' : 'light') : mode;
|
|
16
|
+
document.documentElement.dataset.theme = resolved;
|
|
17
|
+
if (control) {
|
|
18
|
+
control.value = mode;
|
|
19
|
+
control.title = mode === 'system' ? `Editor theme follows system (${resolved})` : `Editor theme · ${mode}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
apply();
|
|
24
|
+
system.addEventListener('change', apply);
|
|
25
|
+
window.addEventListener('storage', event => {
|
|
26
|
+
if (event.key !== storageKey && event.key !== null) return;
|
|
27
|
+
mode = preference(event.newValue);
|
|
28
|
+
apply();
|
|
29
|
+
});
|
|
30
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
31
|
+
control = document.getElementById('editor-theme');
|
|
32
|
+
apply();
|
|
33
|
+
control.addEventListener('change', () => {
|
|
34
|
+
mode = preference(control.value);
|
|
35
|
+
apply();
|
|
36
|
+
try {
|
|
37
|
+
localStorage.setItem(storageKey, mode);
|
|
38
|
+
} catch {
|
|
39
|
+
// Keep the selected theme in memory for this session.
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
})();
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { maskSources } from './masks.js';
|
|
2
|
+
import { findElementLayer, orderedSceneElements } from './model.js';
|
|
3
|
+
|
|
4
|
+
const LARGE_TIMELINE = 200;
|
|
5
|
+
const OVERVIEW_DIAMONDS = 60;
|
|
6
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
7
|
+
const position = (frame, duration) => 100 * (frame - 1) / Math.max(1, duration - 1);
|
|
8
|
+
|
|
9
|
+
export function createTimeline({ timelineRuler: ruler, timelineLanes: lanes, playhead: slider,
|
|
10
|
+
frameReadout, previousFrame, nextFrame }, { select, seek, editEvent, editClip, clipName, renderLayers }) {
|
|
11
|
+
const panel = ruler.closest('.timeline-panel');
|
|
12
|
+
const scale = panel.querySelector('#timeline-scale');
|
|
13
|
+
const number = panel.querySelector('#frame-number');
|
|
14
|
+
const scrollArea = panel.querySelector('.timeline-track-wrap');
|
|
15
|
+
let duration = 1;
|
|
16
|
+
let locked = false;
|
|
17
|
+
let scrub = null;
|
|
18
|
+
let pendingReveal = 1;
|
|
19
|
+
const playheadMarkers = [ruler, panel.querySelector('.timeline-cursor')].filter(Boolean);
|
|
20
|
+
let revealRequest = 0;
|
|
21
|
+
|
|
22
|
+
function drawRuler() {
|
|
23
|
+
const width = ruler.clientWidth;
|
|
24
|
+
if (!width) return;
|
|
25
|
+
const minimum = (duration - 1) * 32 / width;
|
|
26
|
+
panel.style.setProperty('--frame-step', Math.max(1, Math.ceil((duration - 1) * 4 / width)) * 100 / Math.max(1, duration - 1) + '%');
|
|
27
|
+
const step = [1, 2, 5, 10, 20, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000].find(n => n >= minimum) ?? duration;
|
|
28
|
+
const frames = [1];
|
|
29
|
+
for (let f = step; f < duration; f += step) {
|
|
30
|
+
if (f > 1 && (f - 1) * width / (duration - 1) >= 22) frames.push(f);
|
|
31
|
+
}
|
|
32
|
+
if (duration > 1) {
|
|
33
|
+
if (frames.length > 1 && (duration - frames.at(-1)) * width / (duration - 1) < 24) frames.pop();
|
|
34
|
+
frames.push(duration);
|
|
35
|
+
}
|
|
36
|
+
ruler.replaceChildren(...frames.map(frame => {
|
|
37
|
+
const tick = document.createElement('span');
|
|
38
|
+
tick.textContent = String(frame);
|
|
39
|
+
tick.style.left = position(frame, duration) + '%';
|
|
40
|
+
return tick;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function setScale() {
|
|
44
|
+
// Only the frame area expands. The label column keeps its docked width.
|
|
45
|
+
const labelWidth = ruler.offsetParent ? ruler.offsetLeft : 0;
|
|
46
|
+
const px = Number(scale?.value);
|
|
47
|
+
panel.style.setProperty('--timeline-content-width', px > 0
|
|
48
|
+
? (Math.max(1, duration - 1) * px + labelWidth + 1) + 'px' : '100%');
|
|
49
|
+
drawRuler();
|
|
50
|
+
}
|
|
51
|
+
scale?.addEventListener('change', setScale);
|
|
52
|
+
new ResizeObserver(drawRuler).observe(ruler);
|
|
53
|
+
|
|
54
|
+
function readout(frame) {
|
|
55
|
+
slider.value = String(frame);
|
|
56
|
+
slider.setAttribute('aria-valuetext', `Frame ${frame} of ${duration}`);
|
|
57
|
+
number.value = String(frame);
|
|
58
|
+
number.max = String(duration);
|
|
59
|
+
number.disabled = locked;
|
|
60
|
+
frameReadout.textContent = '/ ' + duration;
|
|
61
|
+
// During playback, keep the playhead in view. Reading scroll geometry right after the style
|
|
62
|
+
// writes above would force a layout every frame, so read it at the start of the next frame.
|
|
63
|
+
if (locked) {
|
|
64
|
+
pendingReveal = frame;
|
|
65
|
+
if (!revealRequest) {
|
|
66
|
+
revealRequest = requestAnimationFrame(() => {
|
|
67
|
+
revealRequest = 0;
|
|
68
|
+
if (locked) revealFrame(pendingReveal);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
previousFrame.disabled = locked || frame <= 1;
|
|
73
|
+
nextFrame.disabled = locked || frame >= duration;
|
|
74
|
+
// Set on the two playhead markers only: a custom property on the panel restyles every lane
|
|
75
|
+
// under it, which is thousands of nodes in a large imported movie.
|
|
76
|
+
const at = position(frame, duration) + '%';
|
|
77
|
+
for (const marker of playheadMarkers) if (marker.style.getPropertyValue('--playhead-position') !== at) marker.style.setProperty('--playhead-position', at);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function revealFrame(frame) {
|
|
81
|
+
if (scrollArea.scrollWidth <= scrollArea.clientWidth) return;
|
|
82
|
+
const positionInView = ruler.clientWidth * position(frame, duration) / 100 - scrollArea.scrollLeft;
|
|
83
|
+
const visible = scrollArea.clientWidth - ruler.offsetLeft;
|
|
84
|
+
if (positionInView < 0 || positionInView > visible - 1) {
|
|
85
|
+
scrollArea.scrollLeft += positionInView - visible / 2;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
number.addEventListener('change', () => {
|
|
89
|
+
const requested = number.valueAsNumber;
|
|
90
|
+
if (Number.isInteger(requested)) {
|
|
91
|
+
seek(Math.max(1, Math.min(duration, requested)));
|
|
92
|
+
revealFrame(Number(slider.value));
|
|
93
|
+
}
|
|
94
|
+
number.value = slider.value;
|
|
95
|
+
});
|
|
96
|
+
number.addEventListener('keydown', event => {
|
|
97
|
+
if (event.key === 'Enter') {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
number.blur();
|
|
100
|
+
slider.focus({ preventScroll:true });
|
|
101
|
+
} else if (event.key === 'Escape') {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
number.value = slider.value;
|
|
104
|
+
slider.focus({ preventScroll:true });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
function atPointer(x) {
|
|
109
|
+
const { left, width } = scrub.bounds;
|
|
110
|
+
return Math.max(1, Math.min(duration, Math.round(1 + (x - left) * (duration - 1) / Math.max(1, width))));
|
|
111
|
+
}
|
|
112
|
+
// Capture on the persistent panel. Selecting a track can redraw its DOM.
|
|
113
|
+
panel.addEventListener('pointerdown', event => {
|
|
114
|
+
if (locked || event.button !== 0 || !event.isPrimary) return;
|
|
115
|
+
const track = event.target.closest('.timeline-lane-track, .layer-overview');
|
|
116
|
+
if (!track && !ruler.contains(event.target)) return;
|
|
117
|
+
const bounds = (track ?? ruler).getBoundingClientRect();
|
|
118
|
+
scrub = { bounds, id: event.pointerId };
|
|
119
|
+
panel.setPointerCapture(event.pointerId);
|
|
120
|
+
const marker = event.target.closest('.keyframe-marker');
|
|
121
|
+
const frame = marker ? Number(marker.dataset.frame) : atPointer(event.clientX);
|
|
122
|
+
const lane = track?.closest('.timeline-lane');
|
|
123
|
+
if (lane) select(lane.dataset.elementId, frame);
|
|
124
|
+
else seek(frame);
|
|
125
|
+
// Keep arrow keys on the accessible range after a pointer scrub.
|
|
126
|
+
slider.focus({ preventScroll: true });
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
});
|
|
129
|
+
panel.addEventListener('pointermove', event => {
|
|
130
|
+
if (event.pointerId === scrub?.id) seek(atPointer(event.clientX));
|
|
131
|
+
});
|
|
132
|
+
panel.addEventListener('lostpointercapture', event => {
|
|
133
|
+
if (event.pointerId === scrub?.id) scrub = null;
|
|
134
|
+
});
|
|
135
|
+
lanes.addEventListener('click', event => {
|
|
136
|
+
if (locked) return;
|
|
137
|
+
const button = event.target.closest('button');
|
|
138
|
+
if (!button?.closest('.timeline-lane')) return;
|
|
139
|
+
if (button.closest('.audio-lane')) {
|
|
140
|
+
seek(Number(button.dataset.frame));
|
|
141
|
+
editClip(button.closest('.audio-lane').dataset.clipId);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (button.closest('.event-lane')) {
|
|
145
|
+
const at = Number(button.dataset.frame ?? slider.value);
|
|
146
|
+
seek(at);
|
|
147
|
+
editEvent(at, button.dataset.trigger);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
select(button.closest('.timeline-lane').dataset.elementId,
|
|
151
|
+
button.dataset.frame ? Number(button.dataset.frame) : undefined);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
function render(scene, selectedIds, frame, inPreview, rebuildLayers = true) {
|
|
155
|
+
duration = scene.durationFrames;
|
|
156
|
+
locked = inPreview;
|
|
157
|
+
slider.disabled = locked;
|
|
158
|
+
slider.max = String(duration);
|
|
159
|
+
const focus = document.activeElement;
|
|
160
|
+
const focusedTrack = focus.closest('.timeline-lane')?.dataset.elementId;
|
|
161
|
+
const focusFrame = focus.dataset.frame;
|
|
162
|
+
if (rebuildLayers) renderLayers();
|
|
163
|
+
const groups = new Map([...lanes.querySelectorAll('.layer-entry')].map(row => {
|
|
164
|
+
const tracks = row.querySelector('.layer-tracks');
|
|
165
|
+
const overview = row.querySelector('.layer-overview');
|
|
166
|
+
tracks.replaceChildren();
|
|
167
|
+
overview.replaceChildren();
|
|
168
|
+
return [row.dataset.id, { tracks, overview, frames: new Set() }];
|
|
169
|
+
}));
|
|
170
|
+
const eventLanes = lanes.querySelector('#event-lanes');
|
|
171
|
+
const audioLanes = lanes.querySelector('#audio-lanes');
|
|
172
|
+
eventLanes.replaceChildren();
|
|
173
|
+
audioLanes.replaceChildren();
|
|
174
|
+
const sources = maskSources(scene);
|
|
175
|
+
// Large imported movies have thousands of lanes; the stylesheet lets the browser skip the
|
|
176
|
+
// ones outside the visible timeline (see .timeline-panel.is-large).
|
|
177
|
+
panel.classList.toggle('is-large', scene.elements.length > LARGE_TIMELINE);
|
|
178
|
+
let restoreFocus;
|
|
179
|
+
for (const element of orderedSceneElements(scene)) {
|
|
180
|
+
const layer = findElementLayer(scene, element);
|
|
181
|
+
const group = groups.get(layer.id);
|
|
182
|
+
// A collapsed layer shows only its summary row: skip building lanes nobody can see.
|
|
183
|
+
if (group.tracks.hidden) {
|
|
184
|
+
for (const key of element.keyframes) group.frames.add(key.frame);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const lane = document.createElement('div');
|
|
188
|
+
lane.className = 'timeline-lane';
|
|
189
|
+
lane.classList.toggle('is-active', selectedIds.includes(element.id));
|
|
190
|
+
lane.classList.toggle('is-hidden-layer', layer?.visible === false);
|
|
191
|
+
lane.dataset.elementId = element.id;
|
|
192
|
+
const label = document.createElement('button');
|
|
193
|
+
label.type = 'button';
|
|
194
|
+
label.className = 'timeline-lane-label';
|
|
195
|
+
label.textContent = sources.has(element.id) ? `${element.name} · Mask` : element.name;
|
|
196
|
+
label.title = layer ? `${label.textContent} · ${layer.name}` : label.textContent;
|
|
197
|
+
if (element.maskId) {
|
|
198
|
+
const source = scene.elements.find(item => item.id === element.maskId);
|
|
199
|
+
label.title += ` · Clipped by ${source.name}`;
|
|
200
|
+
}
|
|
201
|
+
label.setAttribute('aria-pressed', String(selectedIds.includes(element.id)));
|
|
202
|
+
label.disabled = locked;
|
|
203
|
+
if (focusedTrack === element.id && !focusFrame) restoreFocus = label;
|
|
204
|
+
const track = document.createElement('div');
|
|
205
|
+
track.className = 'timeline-lane-track';
|
|
206
|
+
const keys = element.keyframes;
|
|
207
|
+
for (let i = 0; i < keys.length; i++) {
|
|
208
|
+
const key = keys[i], next = keys[i + 1];
|
|
209
|
+
group.frames.add(key.frame);
|
|
210
|
+
if (!key.blank) {
|
|
211
|
+
const band = document.createElement('span');
|
|
212
|
+
band.className = 'exposure-span';
|
|
213
|
+
band.style.left = position(i === 0 ? 1 : key.frame, duration) + '%';
|
|
214
|
+
band.style.right = (next ? 100 - position(next.frame, duration) : 0) + '%';
|
|
215
|
+
track.append(band);
|
|
216
|
+
if (next && !next.blank) {
|
|
217
|
+
const tween = document.createElement('span');
|
|
218
|
+
tween.className = 'tween-span tween-' + key.tween;
|
|
219
|
+
tween.title = `${key.tween} tween, frames ${key.frame}–${next.frame}`;
|
|
220
|
+
tween.style.left = position(key.frame, duration) + '%';
|
|
221
|
+
tween.style.width = (position(next.frame, duration) - position(key.frame, duration)) + '%';
|
|
222
|
+
track.append(tween);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const marker = document.createElement('button');
|
|
226
|
+
marker.type = 'button';
|
|
227
|
+
marker.className = key.blank ? 'keyframe-marker blank-key' : 'keyframe-marker';
|
|
228
|
+
marker.style.left = position(key.frame, duration) + '%';
|
|
229
|
+
marker.dataset.frame = String(key.frame);
|
|
230
|
+
marker.title = `${key.blank ? 'Blank keyframe' : 'Keyframe'} at frame ${key.frame}`;
|
|
231
|
+
marker.setAttribute('aria-label', element.name + ', ' + marker.title);
|
|
232
|
+
marker.disabled = locked;
|
|
233
|
+
if (focusedTrack === element.id && focusFrame === marker.dataset.frame) restoreFocus = marker;
|
|
234
|
+
track.append(marker);
|
|
235
|
+
}
|
|
236
|
+
lane.append(label, track);
|
|
237
|
+
group.tracks.append(lane);
|
|
238
|
+
}
|
|
239
|
+
for (const { overview, frames } of groups.values()) {
|
|
240
|
+
if (frames.size > OVERVIEW_DIAMONDS) {
|
|
241
|
+
// Many keys: one SVG path of ticks instead of an element per frame.
|
|
242
|
+
const svg = document.createElementNS(SVG, 'svg');
|
|
243
|
+
svg.setAttribute('class', 'layer-overview-ticks');
|
|
244
|
+
svg.setAttribute('viewBox', '0 0 100 10');
|
|
245
|
+
svg.setAttribute('preserveAspectRatio', 'none');
|
|
246
|
+
const path = document.createElementNS(SVG, 'path');
|
|
247
|
+
path.setAttribute('d', [...frames].map(frame => `M${position(frame, duration).toFixed(3)} 3V7`).join(''));
|
|
248
|
+
path.setAttribute('vector-effect', 'non-scaling-stroke');
|
|
249
|
+
svg.append(path);
|
|
250
|
+
overview.append(svg);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
for (const frame of frames) {
|
|
254
|
+
const tick = document.createElement('i');
|
|
255
|
+
tick.style.left = position(frame, duration) + '%';
|
|
256
|
+
overview.append(tick);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (scene.events?.some(event => !event.source)) {
|
|
260
|
+
const lane = document.createElement('div');
|
|
261
|
+
lane.className = 'timeline-lane event-lane';
|
|
262
|
+
const label = document.createElement('button');
|
|
263
|
+
label.type = 'button';
|
|
264
|
+
label.className = 'timeline-lane-label';
|
|
265
|
+
const start = scene.events.some(event => event.trigger === 'timelineStart');
|
|
266
|
+
label.textContent = start ? 'Actions · Start' : 'Actions';
|
|
267
|
+
if (start) {
|
|
268
|
+
label.dataset.trigger = 'timelineStart';
|
|
269
|
+
label.title = 'Edit timeline start actions';
|
|
270
|
+
}
|
|
271
|
+
label.disabled = locked;
|
|
272
|
+
const track = document.createElement('div');
|
|
273
|
+
track.className = 'event-track';
|
|
274
|
+
for (const event of scene.events.filter(event => event.trigger === 'frameEnter')) {
|
|
275
|
+
const marker = document.createElement('button');
|
|
276
|
+
marker.type = 'button';
|
|
277
|
+
marker.className = 'event-marker';
|
|
278
|
+
marker.textContent = 'ƒ';
|
|
279
|
+
marker.dataset.frame = event.frame;
|
|
280
|
+
marker.dataset.trigger = event.trigger;
|
|
281
|
+
marker.style.left = position(Number(marker.dataset.frame), duration) + '%';
|
|
282
|
+
marker.title = `Actions on frame ${event.frame}`;
|
|
283
|
+
marker.setAttribute('aria-label', marker.title);
|
|
284
|
+
marker.disabled = locked;
|
|
285
|
+
track.append(marker);
|
|
286
|
+
}
|
|
287
|
+
lane.append(label, track);
|
|
288
|
+
eventLanes.append(lane);
|
|
289
|
+
}
|
|
290
|
+
for (const clip of scene.audioClips ?? []) {
|
|
291
|
+
const lane = document.createElement('div');
|
|
292
|
+
lane.className = 'timeline-lane audio-lane';
|
|
293
|
+
lane.dataset.clipId = clip.id;
|
|
294
|
+
const label = document.createElement('button');
|
|
295
|
+
label.type = 'button';
|
|
296
|
+
label.className = 'timeline-lane-label';
|
|
297
|
+
label.textContent = clipName(clip);
|
|
298
|
+
const track = document.createElement('div');
|
|
299
|
+
track.className = 'audio-track';
|
|
300
|
+
const band = document.createElement('button');
|
|
301
|
+
band.type = 'button';
|
|
302
|
+
band.className = 'audio-span';
|
|
303
|
+
const left = position(clip.start, duration);
|
|
304
|
+
band.style.left = left + '%';
|
|
305
|
+
band.style.right = Math.max(0, 100 - position(clip.end + 1, duration)) + '%';
|
|
306
|
+
for (const button of [label, band]) {
|
|
307
|
+
button.disabled = locked;
|
|
308
|
+
button.dataset.frame = clip.start;
|
|
309
|
+
button.title = `${label.textContent}, frames ${clip.start}–${clip.end}`;
|
|
310
|
+
button.setAttribute('aria-label', button.title);
|
|
311
|
+
}
|
|
312
|
+
track.append(band);
|
|
313
|
+
lane.append(label, track);
|
|
314
|
+
audioLanes.append(lane);
|
|
315
|
+
}
|
|
316
|
+
restoreFocus?.focus({ preventScroll: true });
|
|
317
|
+
setScale();
|
|
318
|
+
readout(frame);
|
|
319
|
+
}
|
|
320
|
+
return { render, readout };
|
|
321
|
+
}
|