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,93 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function verifyTriggers({ call, click, change, key, drag, js, exportProject }) {
|
|
4
|
+
const fieldId = 'display';
|
|
5
|
+
const insert = (id, x, trigger, extra = {}) => ({ type: 'rectangle', id, name: id, x, y: 190, width: 65, height: 50,
|
|
6
|
+
buttonAction: { type: 'editInput', target: fieldId, operation: 'insert', value: id, trigger, ...extra } });
|
|
7
|
+
const scene = { elements: [
|
|
8
|
+
{ type: 'text', id: fieldId, inputText: true, text: '', x: 200, y: 65, width: 320, height: 50 },
|
|
9
|
+
insert('A', 50, 'click'), insert('B', 140, 'keyUp', { key: 'Q' }), insert('T', 235, 'touchTap'),
|
|
10
|
+
insert('S', 325, 'swipe', { direction: 'right' }), insert('C', 420, 'click'),
|
|
11
|
+
] };
|
|
12
|
+
await click('#import-project');
|
|
13
|
+
await change('project-io-textarea', JSON.stringify({ stage: { width: 480, height: 320, frameRate: 24 }, scenes: [scene] }));
|
|
14
|
+
await click('#project-io-submit');
|
|
15
|
+
await click('.timeline-lane[data-element-id=A] .timeline-lane-label');
|
|
16
|
+
await change('button-trigger', 'keyDown');
|
|
17
|
+
await change('button-key', 'Q');
|
|
18
|
+
const authored = await exportProject();
|
|
19
|
+
const binding = authored.scenes[0].elements.find(el => el.id === 'A').buttonAction;
|
|
20
|
+
assert.deepEqual(binding, { trigger: 'keyDown', key: 'Q', type: 'editInput', target: fieldId, operation: 'insert', value: 'A' });
|
|
21
|
+
await click('#preview-button');
|
|
22
|
+
const value = () => js("document.querySelector('#preview-surface textarea').value");
|
|
23
|
+
const focus = selector => js(`document.querySelector(${JSON.stringify(selector)}).focus()`);
|
|
24
|
+
const dispatch = type => call('Input.dispatchKeyEvent', { type, key: 'q', code: 'KeyQ', windowsVirtualKeyCode: 81 });
|
|
25
|
+
assert.ok(await js("document.activeElement.id === 'stage'"));
|
|
26
|
+
await key('Tab', 'Tab', 9);
|
|
27
|
+
assert.ok(await js("document.activeElement.matches('#preview-surface textarea')"));
|
|
28
|
+
await key('Tab', 'Tab', 9);
|
|
29
|
+
assert.ok(await js("document.activeElement.matches('[data-preview-button=A]')"));
|
|
30
|
+
await focus('#stage');
|
|
31
|
+
await dispatch('keyDown');
|
|
32
|
+
assert.equal(await value(), '');
|
|
33
|
+
await dispatch('keyUp');
|
|
34
|
+
assert.equal(await value(), 'B', 'Uppermost matching action fires on key release');
|
|
35
|
+
await focus('[data-preview-button=A]');
|
|
36
|
+
await dispatch('keyDown');
|
|
37
|
+
assert.equal(await value(), 'BA', 'Focused instance wins when keys match');
|
|
38
|
+
await dispatch('keyUp');
|
|
39
|
+
await focus('#stage');
|
|
40
|
+
await dispatch('keyDown');
|
|
41
|
+
await focus('#preview-surface textarea');
|
|
42
|
+
await dispatch('keyUp');
|
|
43
|
+
await key('q', 'KeyQ', 81, 0, 'q');
|
|
44
|
+
assert.equal(await value(), 'BAq', 'Typing in a field keeps authored shortcuts out');
|
|
45
|
+
await focus('[data-preview-button=C]');
|
|
46
|
+
await key('Enter', 'Enter', 13, 0, '\r');
|
|
47
|
+
assert.equal(await value(), 'BAqC');
|
|
48
|
+
await drag(235, 190);
|
|
49
|
+
assert.equal(await value(), 'BAqC', 'Touch-only action ignores the mouse');
|
|
50
|
+
|
|
51
|
+
const coords = await js("(() => { const s = document.querySelector('#stage'); return { rect: s.getBoundingClientRect().toJSON(), width: s.width, height: s.height }; })()");
|
|
52
|
+
const touch = (id, x, y = 190) => ({ id, x: coords.rect.left + x * coords.rect.width / coords.width,
|
|
53
|
+
y: coords.rect.top + y * coords.rect.height / coords.height });
|
|
54
|
+
const send = (type, touchPoints) => call('Input.dispatchTouchEvent', { type, touchPoints });
|
|
55
|
+
await send('touchStart', [touch(1, 235)]);
|
|
56
|
+
await send('touchEnd', []);
|
|
57
|
+
assert.equal(await value(), 'BAqCT');
|
|
58
|
+
await send('touchStart', [touch(1, 325)]);
|
|
59
|
+
await send('touchMove', [touch(1, 240)]);
|
|
60
|
+
await send('touchEnd', []);
|
|
61
|
+
assert.equal(await value(), 'BAqCT');
|
|
62
|
+
await send('touchStart', [touch(1, 325)]);
|
|
63
|
+
await send('touchMove', [touch(1, 410)]);
|
|
64
|
+
await send('touchEnd', []);
|
|
65
|
+
assert.equal(await value(), 'BAqCTS');
|
|
66
|
+
await send('touchStart', [touch(1, 235)]);
|
|
67
|
+
await send('touchCancel', []);
|
|
68
|
+
assert.equal(await value(), 'BAqCTS');
|
|
69
|
+
await send('touchStart', [touch(1, 235), touch(2, 420)]);
|
|
70
|
+
await send('touchEnd', []);
|
|
71
|
+
assert.equal((await value()).length, 'BAqCTS'.length + 2);
|
|
72
|
+
assert.equal((await value()).slice(-2).split('').sort().join(''), 'CT');
|
|
73
|
+
await click('#preview-button');
|
|
74
|
+
assert.deepEqual(await exportProject(), authored);
|
|
75
|
+
|
|
76
|
+
// Two instances share a definition and binding, but have independent fields.
|
|
77
|
+
const symbol = { id: 'widget', width: 480, height: 320, elements: [scene.elements[0], {
|
|
78
|
+
...scene.elements[1], buttonAction: { ...binding },
|
|
79
|
+
}] };
|
|
80
|
+
const instance = (id, x) => ({ id, type: 'symbol', symbolId: 'widget', x, y: 160, width: 240, height: 160 });
|
|
81
|
+
await click('#import-project');
|
|
82
|
+
await change('project-io-textarea', JSON.stringify({ stage: authored.stage, symbols: [symbol],
|
|
83
|
+
scenes: [{ elements: [instance('one', 120), instance('two', 360)] }] }));
|
|
84
|
+
await click('#project-io-submit');
|
|
85
|
+
await click('#preview-button');
|
|
86
|
+
await key('q', 'KeyQ', 81);
|
|
87
|
+
const values = () => js("Array.from(document.querySelectorAll('#preview-surface textarea'), el => el.value)");
|
|
88
|
+
assert.deepEqual(await values(), ['', 'A']);
|
|
89
|
+
await focus('[data-preview-button]');
|
|
90
|
+
await key('q', 'KeyQ', 81);
|
|
91
|
+
assert.deepEqual(await values(), ['A', 'A']);
|
|
92
|
+
await click('#preview-button');
|
|
93
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdtemp, readdir, readFile, rm } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
// Video export (studiospec/video-export.md): record from the Export dialog, play the file back in a
|
|
6
|
+
// <video> element and compare it with the stage; check the ending, cancel and the refusal.
|
|
7
|
+
export async function verifyVideoExport({ call, js, click, change, profile }) {
|
|
8
|
+
const folder = await mkdtemp(path.join(profile, 'video-'));
|
|
9
|
+
await call('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: folder });
|
|
10
|
+
// An odd width checks the padding to even sizes.
|
|
11
|
+
const stage = { width: 161, height: 120, background: '#ff0000', frameRate: 10 };
|
|
12
|
+
const box = { id: 'box', name: 'Box', type: 'rectangle', x: 40, y: 60, width: 60, height: 60, fill: '#0000ff', strokeWidth: 0,
|
|
13
|
+
keyframes: [{ frame: 1, x: 40 }, { frame: 6, x: 120 }] };
|
|
14
|
+
const stops = { id: 'main', name: 'Main', durationFrames: 6, elements: [box],
|
|
15
|
+
events: [{ trigger: 'frameEnter', frame: 4, actions: [{ type: 'stop' }] }] };
|
|
16
|
+
async function load(project) {
|
|
17
|
+
await click('#import-project');
|
|
18
|
+
await change('project-io-textarea', JSON.stringify(project));
|
|
19
|
+
await click('#project-io-submit');
|
|
20
|
+
// Projects with media finish importing once their assets are decoded.
|
|
21
|
+
for (let attempt = 0; attempt < 200 && await js("document.querySelector('#project-io-dialog').open"); attempt++) {
|
|
22
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
23
|
+
}
|
|
24
|
+
assert.equal(await js("document.querySelector('#project-io-dialog').open"), false,
|
|
25
|
+
`Imported the video test project: ${await js("document.querySelector('#project-io-error').textContent")}`);
|
|
26
|
+
}
|
|
27
|
+
async function record(format, length = 60, sound = true) {
|
|
28
|
+
await click('#export-project');
|
|
29
|
+
// Choosing a video format probes this browser's encoders and disables formats it cannot write.
|
|
30
|
+
await change('export-format', 'video');
|
|
31
|
+
for (let attempt = 0; attempt < 200 && !await js("document.querySelector('#export-video-field').dataset.ready"); attempt++) {
|
|
32
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
33
|
+
}
|
|
34
|
+
if (await js(`document.querySelector('#export-video-format option[value="${format}"]').disabled`)) {
|
|
35
|
+
await click('#project-io-close');
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
await change('export-video-format', format);
|
|
39
|
+
assert.equal(await js("document.querySelector('#export-video-field').hidden"), false, 'Video formats show video options');
|
|
40
|
+
assert.equal(await js("document.querySelector('#project-io-textarea').hidden"), true, 'Video formats hide the JSON');
|
|
41
|
+
await change('export-video-length', String(length));
|
|
42
|
+
await js(`document.querySelector('#export-video-sound').checked = ${sound}`);
|
|
43
|
+
const soundShown = await js("!document.querySelector('#export-video-sound-field').hidden");
|
|
44
|
+
const animated = ['gif', 'apng', 'webp'].includes(format);
|
|
45
|
+
assert.equal(await js("!document.querySelector('#export-video-silent').hidden"), animated, 'Animated images say they have no sound');
|
|
46
|
+
if (!animated) assert.equal(soundShown, await js("document.querySelector('#export-video-no-sound').hidden"), 'Either the sound choice or the no-sound note');
|
|
47
|
+
else assert.equal(soundShown, false, 'Animated images offer no sound choice');
|
|
48
|
+
await click('#export-download');
|
|
49
|
+
for (let attempt = 0; attempt < 600 && await js("document.querySelector('#export-download').textContent") !== 'Export'; attempt++) {
|
|
50
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
51
|
+
}
|
|
52
|
+
const error = await js("document.querySelector('#project-io-error').hidden ? '' : document.querySelector('#project-io-error').textContent");
|
|
53
|
+
assert.equal(error, '', 'Video export succeeded');
|
|
54
|
+
let file;
|
|
55
|
+
for (let attempt = 0; attempt < 200 && !file; attempt++) {
|
|
56
|
+
file = (await readdir(folder)).find(name => name.endsWith(`.${format === 'apng' ? 'png' : format}`));
|
|
57
|
+
if (!file) await new Promise(resolve => setTimeout(resolve, 30));
|
|
58
|
+
}
|
|
59
|
+
assert.ok(file, `Downloaded the ${format} file`);
|
|
60
|
+
const notice = await js("document.querySelector('#project-io-notice').textContent");
|
|
61
|
+
await click('#project-io-close');
|
|
62
|
+
// Chrome reuses the name for the next download, so each file is removed once read.
|
|
63
|
+
const bytes = await readFile(path.join(folder, file));
|
|
64
|
+
await rm(path.join(folder, file));
|
|
65
|
+
return { bytes, notice, soundShown };
|
|
66
|
+
}
|
|
67
|
+
// Load the file in a <video>, and read a pixel at each time.
|
|
68
|
+
async function inspect(bytes, type, samples) {
|
|
69
|
+
return js(`(async () => {
|
|
70
|
+
const bytes = Uint8Array.from(atob(${JSON.stringify(bytes.toString('base64'))}), c => c.charCodeAt(0));
|
|
71
|
+
const video = document.createElement('video');
|
|
72
|
+
video.muted = true;
|
|
73
|
+
video.src = URL.createObjectURL(new Blob([bytes], { type: '${type}' }));
|
|
74
|
+
await new Promise((resolve, reject) => { video.onloadeddata = resolve; video.onerror = () => reject(new Error('video error ' + video.error?.message)); });
|
|
75
|
+
const canvas = document.createElement('canvas');
|
|
76
|
+
canvas.width = video.videoWidth;
|
|
77
|
+
canvas.height = video.videoHeight;
|
|
78
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
79
|
+
const pixels = [];
|
|
80
|
+
for (const [time, x, y] of ${JSON.stringify(samples)}) {
|
|
81
|
+
video.currentTime = time;
|
|
82
|
+
await new Promise(resolve => video.onseeked = resolve);
|
|
83
|
+
ctx.drawImage(video, 0, 0);
|
|
84
|
+
pixels.push(Array.from(ctx.getImageData(x, y, 1, 1).data.slice(0, 3)));
|
|
85
|
+
}
|
|
86
|
+
// Play briefly so Chrome decodes the audio track, if there is one.
|
|
87
|
+
video.currentTime = 0;
|
|
88
|
+
await new Promise(resolve => video.onseeked = resolve);
|
|
89
|
+
await video.play();
|
|
90
|
+
await new Promise(resolve => setTimeout(resolve, 600));
|
|
91
|
+
video.pause();
|
|
92
|
+
return { width: video.videoWidth, height: video.videoHeight, duration: video.duration, pixels, audioBytes: video.webkitAudioDecodedByteCount };
|
|
93
|
+
})()`);
|
|
94
|
+
}
|
|
95
|
+
const near = (actual, expected, label) => assert.ok(actual.every((value, i) => Math.abs(value - expected[i]) <= 24),
|
|
96
|
+
`${label}: ${actual} is near ${expected}`);
|
|
97
|
+
|
|
98
|
+
await load({ stage, scenes: [stops] });
|
|
99
|
+
const webm = await record('webm');
|
|
100
|
+
assert.equal(webm.soundShown, false, 'A project without sound says so');
|
|
101
|
+
assert.match(webm.notice, /162 × 120, 1\.4 s; it ends where the movie stops/, 'Four frames, then a one-second hold');
|
|
102
|
+
// Frame 1: the box covers x 10–70. Frame 4 (t = 0.3 s) and the hold: x 58–118.
|
|
103
|
+
const played = await inspect(webm.bytes, 'video/webm', [[0.05, 40, 60], [0.05, 100, 60], [0.35, 100, 60], [1.3, 100, 60], [1.3, 161, 60]]);
|
|
104
|
+
assert.equal(played.width, 162);
|
|
105
|
+
assert.equal(played.height, 120);
|
|
106
|
+
assert.ok(Math.abs(played.duration - 1.4) < 0.05, `duration ${played.duration}`);
|
|
107
|
+
near(played.pixels[0], [0, 0, 255], 'box at frame 1');
|
|
108
|
+
near(played.pixels[1], [255, 0, 0], 'background at frame 1');
|
|
109
|
+
near(played.pixels[2], [0, 0, 255], 'box at frame 4');
|
|
110
|
+
near(played.pixels[3], [0, 0, 255], 'held last frame');
|
|
111
|
+
near(played.pixels[4], [255, 0, 0], 'padding column has the background color');
|
|
112
|
+
|
|
113
|
+
const mp4 = await record('mp4');
|
|
114
|
+
if (mp4) {
|
|
115
|
+
assert.equal(mp4.bytes.subarray(4, 8).toString(), 'ftyp');
|
|
116
|
+
assert.equal(mp4.bytes.subarray(mp4.bytes.readUInt32BE(0) + 4, mp4.bytes.readUInt32BE(0) + 8).toString(), 'moov', 'moov precedes mdat');
|
|
117
|
+
const decoded = await inspect(mp4.bytes, 'video/mp4', [[0.35, 100, 60]]);
|
|
118
|
+
assert.ok(Math.abs(decoded.duration - 1.4) < 0.05);
|
|
119
|
+
near(decoded.pixels[0], [0, 0, 255], 'MP4 box at frame 4');
|
|
120
|
+
} else {
|
|
121
|
+
console.log('Skipped MP4 video export: this browser has no H.264 encoder');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Animated images: four distinct frames (the hold only lengthens the last), looping, silent.
|
|
125
|
+
for (const [format, type] of [['gif', 'image/gif'], ['apng', 'image/png'], ['webp', 'image/webp']]) {
|
|
126
|
+
const image = await record(format);
|
|
127
|
+
if (!image) {
|
|
128
|
+
console.log(`Skipped ${format} export: this browser cannot write it`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
assert.match(image.notice, /162 × 120, 1\.4 s; it ends where the movie stops/);
|
|
132
|
+
const decoded = await js(`(async () => {
|
|
133
|
+
const bytes = Uint8Array.from(atob(${JSON.stringify(image.bytes.toString('base64'))}), c => c.charCodeAt(0));
|
|
134
|
+
const decoder = new ImageDecoder({ data: bytes, type: '${type}' });
|
|
135
|
+
await decoder.tracks.ready;
|
|
136
|
+
const track = decoder.tracks.selectedTrack;
|
|
137
|
+
await decoder.completed;
|
|
138
|
+
const canvas = document.createElement('canvas');
|
|
139
|
+
canvas.width = 162; canvas.height = 120;
|
|
140
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
141
|
+
const frames = [];
|
|
142
|
+
let duration = 0;
|
|
143
|
+
for (let i = 0; i < track.frameCount; i++) {
|
|
144
|
+
const { image } = await decoder.decode({ frameIndex: i });
|
|
145
|
+
duration += image.duration ?? 0;
|
|
146
|
+
ctx.drawImage(image, 0, 0);
|
|
147
|
+
image.close();
|
|
148
|
+
frames.push([[40, 60], [100, 60]].map(([x, y]) => Array.from(ctx.getImageData(x, y, 1, 1).data.slice(0, 3))));
|
|
149
|
+
}
|
|
150
|
+
return { count: track.frameCount, animated: track.animated, loops: track.repetitionCount === Infinity, duration: duration / 1e6, frames };
|
|
151
|
+
})()`);
|
|
152
|
+
assert.equal(decoded.animated, true, `${format} is animated`);
|
|
153
|
+
assert.equal(decoded.count, 4, `${format} frames`);
|
|
154
|
+
assert.equal(decoded.loops, true, `${format} loops`);
|
|
155
|
+
assert.ok(Math.abs(decoded.duration - 1.4) < 0.02, `${format} lasts ${decoded.duration} s`);
|
|
156
|
+
near(decoded.frames[0][0], [0, 0, 255], `${format} box at frame 1`);
|
|
157
|
+
near(decoded.frames[0][1], [255, 0, 0], `${format} background at frame 1`);
|
|
158
|
+
near(decoded.frames[3][1], [0, 0, 255], `${format} box at frame 4`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// A looping scene ends where it would repeat; the maximum length cuts a long one.
|
|
162
|
+
await load({ stage, scenes: [{ ...stops, events: [], loop: true }] });
|
|
163
|
+
assert.match((await record('webm')).notice, /0\.6 s; it ends where the movie starts to repeat/);
|
|
164
|
+
await load({ stage, scenes: [{ ...stops, events: [], durationFrames: 600 }] });
|
|
165
|
+
assert.match((await record('webm', 2)).notice, /2\.0 s; it reached the maximum length/);
|
|
166
|
+
|
|
167
|
+
// Cancel stops the recording and downloads nothing.
|
|
168
|
+
await load({ stage: { ...stage, width: 1280, height: 720 }, scenes: [{ ...stops, events: [], durationFrames: 6000 }] });
|
|
169
|
+
await click('#export-project');
|
|
170
|
+
await change('export-format', 'video');
|
|
171
|
+
await change('export-video-format', 'webm');
|
|
172
|
+
await change('export-video-length', '600');
|
|
173
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
174
|
+
const files = new Set(await readdir(folder));
|
|
175
|
+
await click('#export-download');
|
|
176
|
+
await new Promise(resolve => setTimeout(resolve, 400));
|
|
177
|
+
assert.equal(await js("document.querySelector('#export-download').textContent"), 'Cancel');
|
|
178
|
+
await click('#export-download');
|
|
179
|
+
for (let attempt = 0; attempt < 200 && await js("document.querySelector('#export-download').textContent") !== 'Export'; attempt++) {
|
|
180
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
181
|
+
}
|
|
182
|
+
assert.equal(await js("document.querySelector('#project-io-notice').textContent"), 'Video export cancelled');
|
|
183
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
184
|
+
// Earlier checks in the suite may finish downloads into this folder late, so only videos count.
|
|
185
|
+
const added = (await readdir(folder)).filter(name => !files.has(name) && /\.(webm|mp4)$/.test(name));
|
|
186
|
+
assert.deepEqual(added, [], `Cancelled export downloads nothing; found ${added} (before: ${[...files]})`);
|
|
187
|
+
await click('#project-io-close');
|
|
188
|
+
|
|
189
|
+
// Sound and a wipe: a tone plays over scene one, which wipes to an all-green scene two.
|
|
190
|
+
const rate = 8000, count = 2400;
|
|
191
|
+
const wav = Buffer.alloc(44 + count * 2);
|
|
192
|
+
wav.write('RIFF', 0); wav.writeUInt32LE(36 + count * 2, 4); wav.write('WAVEfmt ', 8); wav.writeUInt32LE(16, 16);
|
|
193
|
+
wav.writeUInt16LE(1, 20); wav.writeUInt16LE(1, 22); wav.writeUInt32LE(rate, 24); wav.writeUInt32LE(rate * 2, 28);
|
|
194
|
+
wav.writeUInt16LE(2, 32); wav.writeUInt16LE(16, 34); wav.write('data', 36); wav.writeUInt32LE(count * 2, 40);
|
|
195
|
+
for (let i = 0; i < count; i++) wav.writeInt16LE(Math.round(Math.sin(i * 0.35) * 16000), 44 + i * 2);
|
|
196
|
+
const wipe = { stage, assets: [{ id: 'tone', name: 'tone.wav', kind: 'audio', data: 'data:audio/wav;base64,' + wav.toString('base64') }],
|
|
197
|
+
scenes: [
|
|
198
|
+
{ id: 'one', name: 'One', durationFrames: 3, elements: [{ ...box, keyframes: undefined }], audioClips: [{ id: 'beep', assetId: 'tone', start: 1, end: 3 }],
|
|
199
|
+
events: [{ trigger: 'frameEnter', frame: 3, actions: [{ type: 'gotoScene', target: 'two', play: true }] }] },
|
|
200
|
+
{ id: 'two', name: 'Two', durationFrames: 6, transition: { type: 'wipe', durationFrames: 4, easing: 'linear' },
|
|
201
|
+
elements: [{ ...box, id: 'field', keyframes: undefined, x: 81, y: 60, width: 162, height: 120, fill: '#00ff00' }] },
|
|
202
|
+
] };
|
|
203
|
+
await load(wipe);
|
|
204
|
+
const voiced = await record('webm');
|
|
205
|
+
assert.equal(voiced.soundShown, true, 'A project with sound offers the choice');
|
|
206
|
+
// Two frames of scene one, four wipe frames, six of scene two, then the one-second hold.
|
|
207
|
+
assert.match(voiced.notice, /2\.2 s with sound/);
|
|
208
|
+
assert.ok(voiced.bytes.includes('A_OPUS'), 'WebM has an Opus track');
|
|
209
|
+
const wiped = await inspect(voiced.bytes, 'video/webm', [[0.45, 20, 10], [0.45, 140, 10], [0.65, 140, 10]]);
|
|
210
|
+
assert.ok(wiped.audioBytes > 0, 'Chrome decodes the Opus track');
|
|
211
|
+
near(wiped.pixels[0], [0, 255, 0], 'incoming scene left of the wipe edge');
|
|
212
|
+
near(wiped.pixels[1], [255, 0, 0], 'outgoing scene right of the wipe edge');
|
|
213
|
+
near(wiped.pixels[2], [0, 255, 0], 'incoming scene after the wipe');
|
|
214
|
+
const voicedMp4 = await record('mp4');
|
|
215
|
+
if (voicedMp4) {
|
|
216
|
+
assert.ok(voicedMp4.bytes.includes('soun') && voicedMp4.bytes.includes('edts'), 'MP4 has an audio track with an edit list');
|
|
217
|
+
assert.ok((await inspect(voicedMp4.bytes, 'video/mp4', [])).audioBytes > 0, 'Chrome decodes the MP4 audio track');
|
|
218
|
+
}
|
|
219
|
+
const silent = await record('webm', 60, false);
|
|
220
|
+
assert.doesNotMatch(silent.notice, /with sound/);
|
|
221
|
+
assert.ok(!silent.bytes.includes('A_OPUS'), 'Unchecked sound writes no audio track');
|
|
222
|
+
|
|
223
|
+
// Projects that play on the SWF player are recorded from the Preview movie with a virtual
|
|
224
|
+
// clock: here a script stops the timeline at frame 4, as the stop action did above.
|
|
225
|
+
await load({ stage, scenes: [{ ...stops, events: [{ trigger: 'frameEnter', frame: 4, actions: [{ type: 'script', script: 'halt' }] }] }],
|
|
226
|
+
scripts: [{ id: 'halt', language: 'actionscript', swfVersion: 8, code: 'stop();' }] });
|
|
227
|
+
const scripted = await record('webm');
|
|
228
|
+
assert.match(scripted.notice, /162 × 120, 1\.4 s; it ends where the movie stops/, 'Four frames, then the one-second hold');
|
|
229
|
+
const recorded = await inspect(scripted.bytes, 'video/webm', [[0.05, 40, 60], [0.05, 100, 60], [0.35, 100, 60], [1.3, 100, 60], [1.3, 161, 60]]);
|
|
230
|
+
assert.equal(recorded.width, 162);
|
|
231
|
+
near(recorded.pixels[0], [0, 0, 255], 'recorded box at frame 1');
|
|
232
|
+
near(recorded.pixels[1], [255, 0, 0], 'recorded background at frame 1');
|
|
233
|
+
near(recorded.pixels[2], [0, 0, 255], 'recorded box at frame 4');
|
|
234
|
+
near(recorded.pixels[3], [0, 0, 255], 'recorded hold');
|
|
235
|
+
near(recorded.pixels[4], [255, 0, 0], 'the padding column takes the stage colour');
|
|
236
|
+
assert.equal(await js("document.querySelectorAll('iframe[title=\"Video recording\"]').length"), 0, 'The recording frame is removed');
|
|
237
|
+
const scriptedGif = await record('gif');
|
|
238
|
+
assert.match(scriptedGif.notice, /1\.4 s/);
|
|
239
|
+
await click('#export-project');
|
|
240
|
+
await change('export-format', 'swf');
|
|
241
|
+
assert.equal(await js("document.querySelector('#export-format option[value=swf]').disabled"), false, 'SWF export stays available');
|
|
242
|
+
await click('#project-io-close');
|
|
243
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdir, readdir, readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
// Use hit-tested browser clicks here. Hidden controls in closed docks or
|
|
6
|
+
// controls covered by the stage should fail these checks.
|
|
7
|
+
export async function verifyWorkspace({ call, js, click, change, key, drag, exportProject, profile }) {
|
|
8
|
+
async function pointer(type, point, buttons = 0) {
|
|
9
|
+
await call('Input.dispatchMouseEvent', { type, ...point, button: 'left', buttons, clickCount: 1 });
|
|
10
|
+
}
|
|
11
|
+
async function clickVisible(selector) {
|
|
12
|
+
const point = await js(`(() => {
|
|
13
|
+
const e = document.querySelector(${JSON.stringify(selector)});
|
|
14
|
+
e.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
15
|
+
const r = e.getBoundingClientRect();
|
|
16
|
+
const x = r.x + r.width / 2, y = r.y + r.height / 2;
|
|
17
|
+
return e.contains(document.elementFromPoint(x,y)) && !e.disabled ? {x,y} : null;
|
|
18
|
+
})()`);
|
|
19
|
+
assert.ok(point, 'Reachable control: ' + selector);
|
|
20
|
+
await pointer('mousePressed', point, 1);
|
|
21
|
+
await pointer('mouseReleased', point);
|
|
22
|
+
}
|
|
23
|
+
async function size(width, height) {
|
|
24
|
+
await call('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: false });
|
|
25
|
+
await js('new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))');
|
|
26
|
+
}
|
|
27
|
+
async function bounds(selector) {
|
|
28
|
+
return js(`document.querySelector(${JSON.stringify(selector)}).getBoundingClientRect().toJSON()`);
|
|
29
|
+
}
|
|
30
|
+
const frame = () => js("Number(document.querySelector('#playhead').value)");
|
|
31
|
+
const stageWidth = () => js("document.querySelector('#stage').getBoundingClientRect().width");
|
|
32
|
+
await size(1280, 800);
|
|
33
|
+
await click('#stop-button');
|
|
34
|
+
const testProject = { stage: { width: 800, height: 450, frameRate: 24 }, scenes: [{
|
|
35
|
+
name: 'Workspace check', durationFrames: 120, elements: [
|
|
36
|
+
{ id: 'tiny', type: 'rectangle', x: 210, y: 170, width: 12, height: 12,
|
|
37
|
+
keyframes: [{ frame: 1 }, { frame: 101, x: 610 }] },
|
|
38
|
+
],
|
|
39
|
+
}] };
|
|
40
|
+
await clickVisible('#import-project');
|
|
41
|
+
await change('project-io-textarea', JSON.stringify(testProject));
|
|
42
|
+
await clickVisible('#project-io-submit');
|
|
43
|
+
|
|
44
|
+
const rulerImage = () => js("document.querySelector('#ruler-x').toDataURL()");
|
|
45
|
+
assert.ok((await bounds('#ruler-x')).height >= 15);
|
|
46
|
+
const ungridded = await js("document.querySelector('#stage').toDataURL()");
|
|
47
|
+
await clickVisible('#stage-grid');
|
|
48
|
+
assert.ok(await js("document.querySelector('.stage-mat').classList.contains('show-grid')"));
|
|
49
|
+
assert.equal(await js("document.querySelector('#stage').toDataURL()"), ungridded);
|
|
50
|
+
await clickVisible('#preview-button');
|
|
51
|
+
assert.ok(await js("document.querySelector('#stage-grid').disabled && !document.querySelector('.stage-mat').classList.contains('show-grid')"));
|
|
52
|
+
await key('Escape', 'Escape', 27);
|
|
53
|
+
assert.ok(await js("document.querySelector('.stage-mat').classList.contains('show-grid')"));
|
|
54
|
+
await clickVisible('#stage-grid');
|
|
55
|
+
await clickVisible('.layer-fold');
|
|
56
|
+
assert.ok(await js("document.querySelector('.layer-tracks').hidden"));
|
|
57
|
+
assert.equal(await js("document.querySelectorAll('.layer-overview i').length"), 2);
|
|
58
|
+
await clickVisible('.layer-lock');
|
|
59
|
+
assert.ok(await js("document.querySelector('.layer-tracks').hidden"));
|
|
60
|
+
await clickVisible('.layer-unlock');
|
|
61
|
+
await clickVisible('.layer-fold');
|
|
62
|
+
assert.ok(await js("document.querySelector('.timeline-lane-label').checkVisibility()"));
|
|
63
|
+
const stage = await bounds('#stage'), timeline = await bounds('.timeline-panel');
|
|
64
|
+
assert.ok(stage.width > 650 && stage.bottom < timeline.top && timeline.bottom <= 801);
|
|
65
|
+
await drag(210, 170);
|
|
66
|
+
await drag(210, 170, 225, 180);
|
|
67
|
+
let element = (await exportProject()).scenes[0].elements[0];
|
|
68
|
+
assert.equal(element.keyframes[0].x, 225);
|
|
69
|
+
assert.equal(element.keyframes[0].scaleX, 1);
|
|
70
|
+
await js("document.querySelector('#stage').focus()");
|
|
71
|
+
await key('ArrowRight', 'ArrowRight', 39, 8);
|
|
72
|
+
assert.equal(await js("Number(document.querySelector('[data-property=x]').value)"), 235);
|
|
73
|
+
|
|
74
|
+
const track = await bounds('.timeline-lane-track');
|
|
75
|
+
const onTrack = f => ({ x: track.left + (f - 1) * track.width / 119, y: track.top + track.height / 2 });
|
|
76
|
+
await pointer('mousePressed', onTrack(24), 1);
|
|
77
|
+
await pointer('mouseMoved', onTrack(35), 1);
|
|
78
|
+
await pointer('mouseReleased', onTrack(35));
|
|
79
|
+
assert.equal(await frame(), 35);
|
|
80
|
+
await drag(363, 177);
|
|
81
|
+
assert.equal(await js("document.querySelectorAll('.keyframe-marker').length"), 2);
|
|
82
|
+
await js("document.querySelector('#playhead').focus()");
|
|
83
|
+
await key('F6', 'F6', 117);
|
|
84
|
+
assert.equal(await js("document.querySelectorAll('.keyframe-marker[data-frame=\"35\"]').length"), 1);
|
|
85
|
+
await key('.', 'Period', 190);
|
|
86
|
+
await key('F7', 'F7', 118);
|
|
87
|
+
assert.equal(await js("document.querySelectorAll('.blank-key[data-frame=\"36\"]').length"), 1);
|
|
88
|
+
await key(',', 'Comma', 188);
|
|
89
|
+
assert.equal(await frame(), 35);
|
|
90
|
+
await change('timeline-scale', '16');
|
|
91
|
+
assert.ok(await js("document.querySelector('.timeline-track-wrap').scrollWidth > document.querySelector('.timeline-track-wrap').clientWidth * 1.5"));
|
|
92
|
+
await change('frame-number', 107);
|
|
93
|
+
assert.equal(await frame(), 107);
|
|
94
|
+
assert.ok(await js("document.querySelector('.timeline-track-wrap').scrollLeft > 0"));
|
|
95
|
+
await change('frame-number', '');
|
|
96
|
+
assert.equal(await frame(), 107);
|
|
97
|
+
assert.equal(await js("document.querySelector('#frame-number').value"), '107');
|
|
98
|
+
await change('timeline-scale', 'fit');
|
|
99
|
+
await js("document.querySelector('#stage').focus()");
|
|
100
|
+
await key(' ', 'Space', 32);
|
|
101
|
+
assert.equal(await js("document.querySelector('#preview-button').getAttribute('aria-pressed')"), 'true');
|
|
102
|
+
await key(' ', 'Space', 32);
|
|
103
|
+
const paused = await frame();
|
|
104
|
+
await key('Escape', 'Escape', 27);
|
|
105
|
+
assert.equal(await frame(), paused);
|
|
106
|
+
assert.equal(await js("document.querySelector('#preview-button').getAttribute('aria-pressed')"), 'false');
|
|
107
|
+
|
|
108
|
+
const wheel = async (x, y, deltaY) => {
|
|
109
|
+
await call('Input.dispatchMouseEvent', { type: 'mouseWheel', x, y, deltaX: 0, deltaY });
|
|
110
|
+
await js('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))');
|
|
111
|
+
};
|
|
112
|
+
const fitStage = await bounds('#stage');
|
|
113
|
+
const anchor = { x: Math.round(fitStage.left + fitStage.width * .28), y: Math.round(fitStage.top + fitStage.height * .7) };
|
|
114
|
+
async function checkAnchor(before) {
|
|
115
|
+
const rect = await bounds('#stage');
|
|
116
|
+
const x = (anchor.x - before.left) / before.width;
|
|
117
|
+
const y = (anchor.y - before.top) / before.height;
|
|
118
|
+
assert.ok(Math.abs(rect.left + rect.width * x - anchor.x) < 2, 'Horizontal zoom anchor');
|
|
119
|
+
assert.ok(Math.abs(rect.top + rect.height * y - anchor.y) < 2, 'Vertical zoom anchor');
|
|
120
|
+
return rect.width;
|
|
121
|
+
}
|
|
122
|
+
await wheel(anchor.x, anchor.y, -110);
|
|
123
|
+
assert.ok(await checkAnchor(fitStage) > fitStage.width);
|
|
124
|
+
const wheelIn = await bounds('#stage');
|
|
125
|
+
await wheel(anchor.x, anchor.y, 240);
|
|
126
|
+
assert.ok(await checkAnchor(wheelIn) < fitStage.width);
|
|
127
|
+
const zoomAfterWheel = await js("document.querySelector('#stage-zoom').value");
|
|
128
|
+
assert.ok(Math.abs(Number(zoomAfterWheel) * 800 - await stageWidth()) < 1);
|
|
129
|
+
for (const selector of ['.timeline-heading', '#properties-panel']) {
|
|
130
|
+
const rect = await bounds(selector);
|
|
131
|
+
await wheel(rect.left + 10, rect.top + 10, 120);
|
|
132
|
+
assert.equal(await js("document.querySelector('#stage-zoom').value"), zoomAfterWheel);
|
|
133
|
+
}
|
|
134
|
+
const beforeMax = await bounds('#stage');
|
|
135
|
+
await wheel(anchor.x, anchor.y, -5000);
|
|
136
|
+
assert.ok(Math.abs(await checkAnchor(beforeMax) - 6400) < 1, 'Maximum wheel zoom');
|
|
137
|
+
const beforeMin = await bounds('#stage');
|
|
138
|
+
await wheel(anchor.x, anchor.y, 5000);
|
|
139
|
+
assert.ok(Math.abs(await checkAnchor(beforeMin) - 80) < 1, 'Minimum wheel zoom');
|
|
140
|
+
await change('stage-zoom', 'fit');
|
|
141
|
+
assert.ok(Math.abs(await stageWidth() - fitStage.width) < 1, 'Fit restores the original scale');
|
|
142
|
+
await js('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))');
|
|
143
|
+
const fitRuler = await rulerImage();
|
|
144
|
+
await change('stage-zoom', '2');
|
|
145
|
+
assert.ok(Math.abs(await stageWidth() - 1600) < 2);
|
|
146
|
+
await js('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))');
|
|
147
|
+
assert.notEqual(await rulerImage(), fitRuler);
|
|
148
|
+
const magnified = await rulerImage();
|
|
149
|
+
await js("document.querySelector('.stage-viewport').scrollBy({left:60});");
|
|
150
|
+
await js('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))');
|
|
151
|
+
assert.notEqual(await rulerImage(), magnified);
|
|
152
|
+
await change('stage-zoom', 'fit');
|
|
153
|
+
const before = await bounds('.timeline-panel');
|
|
154
|
+
await js("document.querySelector('#timeline-divider').focus()");
|
|
155
|
+
await key('ArrowUp', 'ArrowUp', 38);
|
|
156
|
+
assert.ok((await bounds('.timeline-panel')).height >= before.height + 15);
|
|
157
|
+
|
|
158
|
+
await clickVisible('#add-layer');
|
|
159
|
+
assert.deepEqual(await js("[...document.querySelectorAll('.layer-entry')].map(row => row.querySelectorAll('.timeline-lane').length)"), [0, 1]);
|
|
160
|
+
assert.equal(await js("document.querySelector('#element-form').hidden"), true);
|
|
161
|
+
await clickVisible('#tab-objects');
|
|
162
|
+
await clickVisible('.element-entry');
|
|
163
|
+
assert.equal(await js("document.querySelector('.layer-entry.is-active .layer-select-btn').textContent"), 'Layer 1');
|
|
164
|
+
await clickVisible('#tab-library');
|
|
165
|
+
assert.equal(await js("document.querySelector('#library-panel').hidden"), false);
|
|
166
|
+
await clickVisible('#tab-properties');
|
|
167
|
+
|
|
168
|
+
await size(390, 844);
|
|
169
|
+
assert.equal((await bounds('#ruler-x')).width, 0);
|
|
170
|
+
assert.ok((await bounds('#stage')).width > 240 && (await bounds('.timeline-panel')).bottom <= 845);
|
|
171
|
+
assert.equal(await js("document.documentElement.scrollWidth <= innerWidth"), true);
|
|
172
|
+
await clickVisible('#toggle-dock');
|
|
173
|
+
await clickVisible('#tab-objects');
|
|
174
|
+
assert.equal(await js("document.querySelector('#objects-panel').hidden"), false);
|
|
175
|
+
await key('Escape', 'Escape', 27);
|
|
176
|
+
assert.equal(await js("document.querySelector('#toggle-dock').getAttribute('aria-expanded')"), 'false');
|
|
177
|
+
await clickVisible('#browse-examples');
|
|
178
|
+
await clickVisible('[data-example="04-kinetic-poster.json"]');
|
|
179
|
+
for (let i = 0; i < 100 && await js("document.querySelector('#project-io-dialog').open"); i++) {
|
|
180
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
181
|
+
}
|
|
182
|
+
assert.equal(await js("document.querySelector('#project-io-dialog').open"), false);
|
|
183
|
+
assert.notEqual(await js("document.querySelector('#stage-scene-name').textContent"), 'Workspace check');
|
|
184
|
+
|
|
185
|
+
const folder = path.join(profile, 'downloads');
|
|
186
|
+
await mkdir(folder);
|
|
187
|
+
await call('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: folder });
|
|
188
|
+
await clickVisible('#export-project');
|
|
189
|
+
await change('export-format', 'json');
|
|
190
|
+
const exported = await js("document.querySelector('#project-io-textarea').value");
|
|
191
|
+
await clickVisible('#export-download');
|
|
192
|
+
const file = path.join(folder, 'swoof-project.json');
|
|
193
|
+
let downloaded;
|
|
194
|
+
for (let attempt = 0; attempt < 100; attempt++) {
|
|
195
|
+
try {
|
|
196
|
+
downloaded = await readFile(file, 'utf8');
|
|
197
|
+
break;
|
|
198
|
+
} catch (error) {
|
|
199
|
+
if (error.code !== 'ENOENT') throw error;
|
|
200
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
assert.equal(downloaded, exported);
|
|
204
|
+
// The same dialog exports the project as a SWF, built on the server.
|
|
205
|
+
await change('export-format', 'swf');
|
|
206
|
+
assert.equal(await js("document.querySelector('#project-io-textarea').hidden"), true, 'SWF export has no JSON text');
|
|
207
|
+
await clickVisible('#export-download');
|
|
208
|
+
let swf;
|
|
209
|
+
for (let attempt = 0; attempt < 200 && !swf; attempt++) {
|
|
210
|
+
const name = (await readdir(folder)).find(entry => entry.endsWith('.swf'));
|
|
211
|
+
if (name) swf = await readFile(path.join(folder, name)).catch(() => null);
|
|
212
|
+
if (!swf?.length) { swf = null; await new Promise(resolve => setTimeout(resolve, 30)); }
|
|
213
|
+
}
|
|
214
|
+
assert.equal(swf.subarray(0, 3).toString(), 'CWS');
|
|
215
|
+
assert.match(await js("document.querySelector('#status-message').textContent"), /Exported .*\.swf \(SWF 8\)/);
|
|
216
|
+
await clickVisible('#project-io-close');
|
|
217
|
+
await clickVisible('#import-project');
|
|
218
|
+
const { root } = await call('DOM.getDocument');
|
|
219
|
+
const { nodeId } = await call('DOM.querySelector', { nodeId: root.nodeId, selector: '#project-file' });
|
|
220
|
+
await call('DOM.setFileInputFiles', { nodeId, files: [file] });
|
|
221
|
+
for (let i = 0; i < 100 && await js("document.querySelector('#project-io-dialog').open"); i++) {
|
|
222
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
223
|
+
}
|
|
224
|
+
assert.equal(await js("document.querySelector('#project-io-dialog').open"), false);
|
|
225
|
+
assert.deepEqual(await exportProject(), JSON.parse(exported));
|
|
226
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { recoverTweens } from './server/tween-recovery.js';
|
|
4
|
+
import { poseAt } from './src/model.js';
|
|
5
|
+
|
|
6
|
+
const base = { type: 'rectangle', x: 0, y: 0, width: 10, height: 10, scaleX: 1, scaleY: 1, rotation: 0, skew: 0, opacity: 1 };
|
|
7
|
+
const holds = values => values.map((x, index) => ({ frame: index + 1, ...base, x, tween: 'hold' }));
|
|
8
|
+
|
|
9
|
+
describe('tween recovery', () => {
|
|
10
|
+
it('merges a per-frame linear motion into one tween', () => {
|
|
11
|
+
const element = { ...base, keyframes: holds([0, 10, 20, 30, 40]) };
|
|
12
|
+
const keys = recoverTweens(element);
|
|
13
|
+
assert.deepEqual(keys.map(key => [key.frame, key.tween]), [[1, 'linear'], [5, 'hold']]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('recognizes eased motion and keeps every frame', () => {
|
|
17
|
+
const values = [0, 1, 2, 3, 4, 5, 6, 7, 8].map(frame => 80 * (1 - (1 - frame / 8) ** 2));
|
|
18
|
+
const element = { ...base, keyframes: holds(values) };
|
|
19
|
+
const keys = recoverTweens(element);
|
|
20
|
+
assert.equal(keys.length, 2);
|
|
21
|
+
assert.equal(keys[0].tween, 'easeOut');
|
|
22
|
+
values.forEach((x, index) => assert.ok(Math.abs(poseAt({ ...element, keyframes: keys }, index + 1).x - x) < 0.05));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('keeps irregular steps and blank keys as holds', () => {
|
|
26
|
+
const element = { ...base, keyframes: [...holds([0, 3, 4, 30]), { frame: 5, ...base, x: 30, tween: 'hold', blank: true }] };
|
|
27
|
+
const keys = recoverTweens(element);
|
|
28
|
+
for (let frame = 1; frame <= 5; frame++) assert.deepEqual(poseAt({ ...element, keyframes: keys }, frame), poseAt(element, frame));
|
|
29
|
+
assert.equal(keys.at(-1).blank, true);
|
|
30
|
+
});
|
|
31
|
+
});
|