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,624 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { decodeSwfAdpcmStream, encodeSound, encodeSoundStream, encodeSpriteSoundStream } from '../emitter/asset-encoder.js';
|
|
3
|
+
import { buildFramesFromTags } from '../transpiler/timeline/display-list.js';
|
|
4
|
+
import { collectActiveSpriteStreams, generateTimelineEngine, resolveStreamAudioTime, timelineHelpersSource } from '../transpiler/timeline/timeline-codegen.js';
|
|
5
|
+
import { decode, decodeTag } from '../decoder/tag-decoder.js';
|
|
6
|
+
import { TAG } from '../decoder/tag-types.js';
|
|
7
|
+
import { parse } from '../parser/swf-parser.js';
|
|
8
|
+
import { SymbolTable } from '../decoder/symbol-table.js';
|
|
9
|
+
import { emit } from '../emitter/bundle-emitter.js';
|
|
10
|
+
import { DiagnosticsCollector } from '../util/diagnostics.js';
|
|
11
|
+
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
import { runInNewContext } from 'node:vm';
|
|
15
|
+
import { AVM1_RUNTIME_STUB, SWFLIB_SOURCE } from '../runtime/index.js';
|
|
16
|
+
|
|
17
|
+
function packBits(fields) {
|
|
18
|
+
const bytes = new Uint8Array(Math.ceil(fields.reduce((sum, field) => sum + field[1], 0) / 8));
|
|
19
|
+
let cursor = 0;
|
|
20
|
+
for (const [value, width] of fields) for (let bit = width - 1; bit >= 0; bit--, cursor++) {
|
|
21
|
+
if ((value >> bit) & 1) bytes[cursor >> 3] |= 1 << (7 - (cursor & 7));
|
|
22
|
+
}
|
|
23
|
+
return bytes;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('nested sprite SoundStream MP3', () => {
|
|
27
|
+
it('decodes advisory playback flags separately from the stream format and signed MP3 latency', () => {
|
|
28
|
+
const mp3 = decodeTag({ code: TAG.SoundStreamHead2, data: Uint8Array.of(0x0f, 0x2a, 0x80, 0x04, 0x60, 0xff) });
|
|
29
|
+
expect(mp3).toMatchObject({ playbackRate: 3, playback16bit: true, playbackStereo: true,
|
|
30
|
+
streamCompression: 2, streamRate: 2, stream16bit: true, streamStereo: false, sampleCount: 1152, latencySeek: -160 });
|
|
31
|
+
const adpcm = decodeTag({ code: TAG.SoundStreamHead, data: Uint8Array.of(0x02, 0x1d, 0x20, 0x00) });
|
|
32
|
+
expect(adpcm).toMatchObject({ playbackRate: 0, streamCompression: 1, streamRate: 3, latencySeek: null });
|
|
33
|
+
expect(encodeSoundStream([adpcm, { type: 'ShowFrame' }])).toBeNull();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('extracts the delayed MP3 stream from the authored Impossible Quiz SWF', async () => {
|
|
37
|
+
const diagnostics = new DiagnosticsCollector();
|
|
38
|
+
const { doc } = await parse(readFileSync('archive/Swf/dagobah_The_Impossible_Quiz.swf'), diagnostics);
|
|
39
|
+
const relevant = new Set([TAG.SoundStreamHead, TAG.SoundStreamHead2, TAG.SoundStreamBlock, TAG.ShowFrame]);
|
|
40
|
+
const stream = encodeSoundStream(doc.tags.filter(tag => relevant.has(tag.code)).map(tag => decodeTag(tag)));
|
|
41
|
+
expect(stream.ext).toBe('mp3');
|
|
42
|
+
expect(stream.data).toHaveLength(34840);
|
|
43
|
+
expect(stream.streamSync).toMatchObject({ codec: 2, sampleRate: 22050, latencySeek: 1633 });
|
|
44
|
+
expect(stream.streamSync.seekMap[0]).toMatchObject({ frame: 11, sampleCount: 2304, seekSamples: 1633, audioSampleStart: 0 });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('keeps stream head and per-frame blocks on decoded sprite frames and encodes their MP3 payloads', () => {
|
|
48
|
+
const head = { type: 'SoundStreamHead', streamCompression: 2, streamRate: 1, latencySeek: 0 };
|
|
49
|
+
const first = decodeTag({ code: 19, data: Uint8Array.of(0x40, 0x02, 0, 0, 0x11, 0x22) });
|
|
50
|
+
const second = decodeTag({ code: 19, data: Uint8Array.of(0x80, 0x04, 0x57, 0x01, 0x33) });
|
|
51
|
+
const frames = buildFramesFromTags([head, first, { type: 'ShowFrame' }, second, { type: 'ShowFrame' }]);
|
|
52
|
+
|
|
53
|
+
expect(frames[0].streamHead.streamCompression).toBe(2);
|
|
54
|
+
expect(frames[0].streamBlocks[0].sampleCount).toBe(576);
|
|
55
|
+
expect(frames[0].streamBlocks[0].seekSamples).toBe(0);
|
|
56
|
+
expect(frames[1].streamBlocks[0].sampleCount).toBe(1152);
|
|
57
|
+
expect(frames[1].streamBlocks[0].seekSamples).toBe(343);
|
|
58
|
+
const encoded = encodeSpriteSoundStream(frames);
|
|
59
|
+
expect(encoded.data).toEqual(Uint8Array.of(0x11, 0x22, 0x33));
|
|
60
|
+
expect(encoded.streamSync).toEqual({
|
|
61
|
+
codec: 2, sampleRate: 11025, latencySeek: 0,
|
|
62
|
+
seekMap: [
|
|
63
|
+
{ frame: 0, sampleCount: 576, seekSamples: 0, audioSampleStart: 0 },
|
|
64
|
+
{ frame: 1, sampleCount: 1152, seekSamples: 343, audioSampleStart: 576 },
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
const rootEncoded = encodeSoundStream([
|
|
68
|
+
head, first, { type: 'ShowFrame' }, second, { type: 'ShowFrame' },
|
|
69
|
+
]);
|
|
70
|
+
expect(rootEncoded.streamSync.seekMap).toEqual(encoded.streamSync.seekMap);
|
|
71
|
+
expect(resolveStreamAudioTime(rootEncoded.streamSync, 1, 12)).toBeCloseTo(919 / 11025, 8);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('finds streams nested in the current frames of displayed sprites', () => {
|
|
75
|
+
const characters = {
|
|
76
|
+
10: { type: 'sprite', hasStream: true, frames: [{ places: [{ depth: 1, characterId: 11 }] }] },
|
|
77
|
+
11: { type: 'sprite', hasStream: true, frames: [{ places: [{ depth: 1, characterId: 12 }] }] },
|
|
78
|
+
12: { type: 'shape', frames: [] },
|
|
79
|
+
20: { type: 'sprite', hasStream: true, frames: [{ places: [] }] },
|
|
80
|
+
};
|
|
81
|
+
const active = collectActiveSpriteStreams(characters, { 1: { characterId: 10 } }, {});
|
|
82
|
+
expect(Object.keys(active).sort()).toEqual(['10', '11']);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('emits nested stream synchronization and strips compressed block data from runtime tables', () => {
|
|
86
|
+
const source = generateTimelineEngine({
|
|
87
|
+
frames: [{ frameIndex: 0, places: [], removes: [], streamBlocks: [{ rawData: [1, 2, 3] }] }],
|
|
88
|
+
characters: { 10: { type: 'sprite', hasStream: true, frames: [{ streamBlocks: [{ rawData: [1, 2, 3] }], places: [] }] } },
|
|
89
|
+
}, { frameRate: 24, frameCount: 1, stageW: 100, stageH: 100 });
|
|
90
|
+
expect(source).toContain('resolveStreamAudioTime(manifest[i].streamSync, frame, FRAME_RATE)');
|
|
91
|
+
expect(source).not.toContain('"rawData":[1,2,3]');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('seeks and pauses repeated nested clips independently and retires removed placements', () => {
|
|
95
|
+
const characters = {
|
|
96
|
+
10: { type: 'sprite', frames: [
|
|
97
|
+
{ places: [{ characterId: 11, depth: 1 }, { characterId: 11, depth: 2 }] },
|
|
98
|
+
{ removes: [1] },
|
|
99
|
+
{ places: [{ characterId: 11, depth: 1 }] },
|
|
100
|
+
] },
|
|
101
|
+
11: { type: 'sprite', hasStream: true, frames: Array.from({ length: 8 }, () => ({})) },
|
|
102
|
+
};
|
|
103
|
+
const engine = generateTimelineEngine({
|
|
104
|
+
frames: [{ places: [{ characterId: 10, depth: 1 }] }],
|
|
105
|
+
characters,
|
|
106
|
+
}, { embedded: true, frameRate: 25, frameCount: 1 });
|
|
107
|
+
const helpers = new Function(`return ${timelineHelpersSource()};`)();
|
|
108
|
+
const media = [];
|
|
109
|
+
class FakeAudio {
|
|
110
|
+
currentTime = 0;
|
|
111
|
+
paused = true;
|
|
112
|
+
constructor() { media.push(this); }
|
|
113
|
+
cloneNode() { return new FakeAudio(); }
|
|
114
|
+
play() { this.paused = false; return Promise.resolve(); }
|
|
115
|
+
pause() { this.paused = true; }
|
|
116
|
+
}
|
|
117
|
+
const source = new FakeAudio();
|
|
118
|
+
const manifest = [{ id: -1000011, streamSync: {
|
|
119
|
+
sampleRate: 1000, seekMap: [
|
|
120
|
+
{ frame: 0, audioSampleStart: 0 },
|
|
121
|
+
{ frame: 3, audioSampleStart: 100 },
|
|
122
|
+
{ frame: 7, audioSampleStart: 400 },
|
|
123
|
+
],
|
|
124
|
+
} }];
|
|
125
|
+
const { timeline, displayList } = new Function('loaded', 'ASSETS', 'sharedTimelineHelpers', `
|
|
126
|
+
var FRAME_RATE = 25;
|
|
127
|
+
${engine}
|
|
128
|
+
return { timeline, displayList };
|
|
129
|
+
`)({ '-1000011': source }, manifest, helpers);
|
|
130
|
+
const first = { frame: 3, playing: true };
|
|
131
|
+
const second = { frame: 7, playing: true };
|
|
132
|
+
const owner = displayList[1]._clip = {
|
|
133
|
+
_swoofTimelinePlayhead: { frame: 0, playing: true },
|
|
134
|
+
_swoofSpriteChildren: {
|
|
135
|
+
'10:1': { _swoofTimelinePlayhead: first },
|
|
136
|
+
'10:2': { _swoofTimelinePlayhead: second },
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
timeline.setStreamPlaybackSuspended(true);
|
|
141
|
+
expect(media).toHaveLength(1);
|
|
142
|
+
expect(source.paused).toBe(true);
|
|
143
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
144
|
+
expect(media).toHaveLength(2);
|
|
145
|
+
expect(media.map(audio => [audio.currentTime, audio.paused])).toEqual([[0.1, false], [0.4, false]]);
|
|
146
|
+
|
|
147
|
+
first.playing = false;
|
|
148
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
149
|
+
expect(media.map(audio => audio.paused)).toEqual([true, false]);
|
|
150
|
+
first.playing = true;
|
|
151
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
152
|
+
expect(source.paused).toBe(false);
|
|
153
|
+
first.frame = 0; // A discontinuous seek should override clock-drift tolerance.
|
|
154
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
155
|
+
expect(source.currentTime).toBe(0);
|
|
156
|
+
|
|
157
|
+
timeline.setStreamPlaybackSuspended(true);
|
|
158
|
+
expect(media.map(audio => audio.paused)).toEqual([true, true]);
|
|
159
|
+
second.frame = 3;
|
|
160
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
161
|
+
expect(media.map(audio => [audio.currentTime, audio.paused])).toEqual([[0, false], [0.1, false]]);
|
|
162
|
+
|
|
163
|
+
owner._swoofTimelinePlayhead.frame = 1;
|
|
164
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
165
|
+
expect(media.map(audio => audio.paused)).toEqual([true, false]);
|
|
166
|
+
owner._swoofTimelinePlayhead.frame = 2;
|
|
167
|
+
first.frame = 7;
|
|
168
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
169
|
+
expect(media).toHaveLength(2);
|
|
170
|
+
expect(media.map(audio => [audio.currentTime, audio.paused])).toEqual([[0.4, false], [0.1, false]]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('seeks to the MP3 sample offsets specified by SWF seek samples and initial latency', () => {
|
|
174
|
+
const sync = {
|
|
175
|
+
sampleRate: 11025, latencySeek: 940,
|
|
176
|
+
seekMap: [
|
|
177
|
+
{ frame: 0, sampleCount: 1728, seekSamples: 940, audioSampleStart: 0 },
|
|
178
|
+
{ frame: 1, sampleCount: 576, seekSamples: 131, audioSampleStart: 1728 },
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
expect(resolveStreamAudioTime(sync, 0, 12)).toBeCloseTo(940 / 11025, 8);
|
|
182
|
+
expect(resolveStreamAudioTime(sync, 1, 12)).toBeCloseTo((1728 + 940 + 131) / 11025, 8);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('leaves the media paused before a delayed first packet and counts latency once when playback begins', () => {
|
|
186
|
+
const head = decodeTag({ code: TAG.SoundStreamHead2, data: Uint8Array.of(0x2e, 0x2a, 0x80, 0x04, 0x61, 0x06) });
|
|
187
|
+
const show = { type: 'ShowFrame' };
|
|
188
|
+
const block = (bytes) => ({ type: 'SoundStreamBlock', rawData: Uint8Array.from(bytes) });
|
|
189
|
+
const stream = encodeSoundStream([
|
|
190
|
+
head, block([0, 0, 0, 0]), show, show, block([0x00, 0x09, 0x61, 0x06, 0xff]),
|
|
191
|
+
show, block([0x80, 0x04, 0x1f, 0x03, 0xff]), show,
|
|
192
|
+
]);
|
|
193
|
+
expect(stream.streamSync.seekMap.map(record => record.frame)).toEqual([2, 3]);
|
|
194
|
+
const helpers = new Function('return ' + timelineHelpersSource())();
|
|
195
|
+
const engine = generateTimelineEngine({ frames: [{}, {}, {}, {}], characters: {} }, { embedded: true, frameRate: 30 });
|
|
196
|
+
let playCalls = 0;
|
|
197
|
+
const audio = {
|
|
198
|
+
paused: true, currentTime: 0, duration: 0.15,
|
|
199
|
+
play() { this.paused = false; playCalls++; },
|
|
200
|
+
pause() { this.paused = true; },
|
|
201
|
+
};
|
|
202
|
+
const manifest = [{ id: -1, streamSync: stream.streamSync }];
|
|
203
|
+
const timeline = new Function('loaded', 'ASSETS', 'sharedTimelineHelpers', 'FRAME_RATE', 'requestAnimationFrame', 'ctx',
|
|
204
|
+
engine + '\nreturn timeline;')({ '-1': audio }, manifest, helpers, 30, () => 1, null);
|
|
205
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
206
|
+
timeline.gotoAndPlay(2);
|
|
207
|
+
expect(playCalls).toBe(0);
|
|
208
|
+
timeline.gotoAndPlay(3);
|
|
209
|
+
expect(playCalls).toBe(1);
|
|
210
|
+
expect(audio.currentTime).toBeCloseTo(1633 / 22050);
|
|
211
|
+
expect(resolveStreamAudioTime(stream.streamSync, 3, 30)).toBeCloseTo((2304 + 1633 + 799) / 22050);
|
|
212
|
+
timeline.gotoAndPlay(4);
|
|
213
|
+
expect(audio.paused).toBe(true);
|
|
214
|
+
expect(playCalls).toBe(1);
|
|
215
|
+
timeline.gotoAndPlay(1);
|
|
216
|
+
expect(audio.paused).toBe(true);
|
|
217
|
+
timeline.gotoAndPlay(3);
|
|
218
|
+
expect(playCalls).toBe(2);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('applies master volume and pauses root and nested streams until their playheads move', () => {
|
|
222
|
+
const runtime = runInNewContext(SWFLIB_SOURCE + '\n__swoof_swflib;', {});
|
|
223
|
+
const helpers = new Function('return ' + timelineHelpersSource())();
|
|
224
|
+
const engine = generateTimelineEngine({ frames: [{ places: [{ characterId: 1, depth: 1 }] }, {}],
|
|
225
|
+
characters: { 1: { type: 'sprite', hasStream: true, frames: [{}, {}] } },
|
|
226
|
+
}, { embedded: true, frameRate: 20 });
|
|
227
|
+
const makeAudio = () => ({ paused: true, currentTime: 0, play() { this.paused = false; }, pause() { this.paused = true; } });
|
|
228
|
+
const root = makeAudio(), child = makeAudio();
|
|
229
|
+
const movie = new Function('loaded', 'sharedTimelineHelpers', '__swoof_swflib', 'FRAME_RATE',
|
|
230
|
+
engine + '\nreturn { timeline, displayList };')({ '-1': root, '-1000001': child }, helpers, runtime, 20);
|
|
231
|
+
const head = { frame: 0, playing: true };
|
|
232
|
+
movie.displayList[1]._clip = { _swoofTimelinePlayhead: head };
|
|
233
|
+
const { SoundMixer, SoundTransform } = runtime.packages.media;
|
|
234
|
+
SoundMixer.soundTransform = new SoundTransform(0.25);
|
|
235
|
+
movie.timeline.setStreamPlaybackSuspended(false);
|
|
236
|
+
expect([root.paused, child.paused]).toEqual([false, false]);
|
|
237
|
+
expect([root.volume, child.volume]).toEqual([0.25, 0.25]);
|
|
238
|
+
SoundMixer.soundTransform = new SoundTransform(0.5);
|
|
239
|
+
expect([root.volume, child.volume]).toEqual([0.5, 0.5]);
|
|
240
|
+
SoundMixer.stopAll();
|
|
241
|
+
expect([root.paused, child.paused]).toEqual([true, true]);
|
|
242
|
+
expect(movie.timeline.playing).toBe(true);
|
|
243
|
+
movie.timeline.setStreamPlaybackSuspended(false);
|
|
244
|
+
expect([root.paused, child.paused]).toEqual([true, true]);
|
|
245
|
+
movie.timeline.frame = head.frame = 1;
|
|
246
|
+
movie.timeline.setStreamPlaybackSuspended(false);
|
|
247
|
+
expect([root.paused, child.paused]).toEqual([false, false]);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('emits nested stream seek metadata with its audio asset', () => {
|
|
251
|
+
const output = mkdtempSync(join(tmpdir(), 'swoof-stream-meta-'));
|
|
252
|
+
try {
|
|
253
|
+
const symbolTable = new SymbolTable();
|
|
254
|
+
symbolTable.set(10, {
|
|
255
|
+
type: 'Sprite', characterId: 10, frameCount: 1,
|
|
256
|
+
tags: [
|
|
257
|
+
{ code: 18, data: Uint8Array.of(0x0e, 0x2a, 0x80, 0x04, 0, 0) },
|
|
258
|
+
{ code: 19, data: Uint8Array.of(0x80, 0x04, 0x57, 0x01, 0xff, 0xfb, 0x90, 0x64) },
|
|
259
|
+
{ code: 1, data: new Uint8Array(0) },
|
|
260
|
+
],
|
|
261
|
+
});
|
|
262
|
+
const diagnostics = new DiagnosticsCollector();
|
|
263
|
+
const result = emit({
|
|
264
|
+
header: { version: 10, frameSize: { xMin: 0, xMax: 2000, yMin: 0, yMax: 1000 }, frameRate: 12, frameCount: 1 },
|
|
265
|
+
tags: [{ type: 'ShowFrame' }], symbolTable,
|
|
266
|
+
actionScript: { needsSwflib: false, fullJs: '', avm1Scripts: [], avm2Blocks: [] },
|
|
267
|
+
}, 'nested-stream.swf', output, diagnostics);
|
|
268
|
+
const bundle = readFileSync(result.jsPath, 'utf8');
|
|
269
|
+
expect(bundle).toContain('"spriteStream": 10');
|
|
270
|
+
expect(bundle).toContain('"latencySeek": 0');
|
|
271
|
+
expect(bundle).toContain('"seekSamples": 343');
|
|
272
|
+
expect(bundle).toContain('"sampleRate": 22050');
|
|
273
|
+
expect(readFileSync(join(result.bundleDir, 'assets/sound_stream_sprite_10.mp3'))).toEqual(Buffer.from([0xff, 0xfb, 0x90, 0x64]));
|
|
274
|
+
} finally {
|
|
275
|
+
rmSync(output, { recursive: true, force: true });
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('wraps uncompressed little-endian 16-bit stream samples in a playable WAV', () => {
|
|
280
|
+
const head = { type: 'SoundStreamHead', streamCompression: 3, streamRate: 1, stream16bit: true, streamStereo: false };
|
|
281
|
+
const encoded = encodeSoundStream([
|
|
282
|
+
head,
|
|
283
|
+
{ type: 'SoundStreamBlock', rawData: Uint8Array.of(0x34, 0x12, 0xfe, 0xff) },
|
|
284
|
+
{ type: 'ShowFrame' },
|
|
285
|
+
]);
|
|
286
|
+
expect(encoded.mimeType).toBe('audio/wav');
|
|
287
|
+
expect(encoded.ext).toBe('wav');
|
|
288
|
+
expect([...encoded.data.slice(0, 4)]).toEqual([0x52, 0x49, 0x46, 0x46]);
|
|
289
|
+
expect([...encoded.data.slice(44)]).toEqual([0x34, 0x12, 0xfe, 0xff]);
|
|
290
|
+
expect(encoded.streamSync).toEqual({ codec: 3, sampleRate: 11025, latencySeek: 0,
|
|
291
|
+
seekMap: [{ frame: 0, sampleCount: 2, seekSamples: 0, audioSampleStart: 0 }] });
|
|
292
|
+
|
|
293
|
+
const nativeEndian = encodeSoundStream([
|
|
294
|
+
{ type: 'SoundStreamHead', streamCompression: 0, streamRate: 0, stream16bit: true, streamStereo: false },
|
|
295
|
+
{ type: 'SoundStreamBlock', rawData: Uint8Array.of(0x12, 0x34) },
|
|
296
|
+
]);
|
|
297
|
+
expect([...nativeEndian.data.slice(44)]).toEqual([0x34, 0x12]);
|
|
298
|
+
expect(new DataView(nativeEndian.data.buffer).getUint32(24, true)).toBe(5512);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('decodes SWF ADPCM mono and interleaved stereo blocks to signed PCM', () => {
|
|
302
|
+
const mono = Uint8Array.of(0x00, 0x00, 0x00, 0x1b); // 2-bit, initial 0/index 0, codes 0,1,2,3
|
|
303
|
+
const decodedMono = decodeSwfAdpcmStream(mono, false);
|
|
304
|
+
const monoView = new DataView(decodedMono.pcm.buffer);
|
|
305
|
+
expect(decodedMono.sampleCount).toBe(5);
|
|
306
|
+
expect(Array.from({ length: 5 }, (_, i) => monoView.getInt16(i * 2, true))).toEqual([0, 3, 13, 9, -3]);
|
|
307
|
+
|
|
308
|
+
// header, initial L=100/index0, R=-100/index0, then L0,R1,L2,R3
|
|
309
|
+
const stereo = packBits([[0, 2], [100, 16], [0, 6], [0xff9c, 16], [0, 6], [0, 2], [1, 2], [2, 2], [3, 2]]);
|
|
310
|
+
const decodedStereo = decodeSwfAdpcmStream(stereo, true);
|
|
311
|
+
const stereoView = new DataView(decodedStereo.pcm.buffer);
|
|
312
|
+
expect(decodedStereo.sampleCount).toBe(3);
|
|
313
|
+
expect(Array.from({ length: 6 }, (_, i) => stereoView.getInt16(i * 2, true))).toEqual([100, -100, 103, -90, 100, -103]);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('emits decoded ADPCM stream blocks as WAV while retaining sample-clock metadata', () => {
|
|
317
|
+
const encoded = encodeSoundStream([
|
|
318
|
+
{ type: 'SoundStreamHead', streamCompression: 1, streamRate: 0, stream16bit: true, streamStereo: false, sampleCount: 5 },
|
|
319
|
+
{ type: 'SoundStreamBlock', rawData: Uint8Array.of(0x00, 0x00, 0x00, 0x1b) },
|
|
320
|
+
{ type: 'ShowFrame' },
|
|
321
|
+
]);
|
|
322
|
+
expect(encoded.mimeType).toBe('audio/wav');
|
|
323
|
+
expect(encoded.data.length).toBe(54);
|
|
324
|
+
expect(encoded.streamSync.seekMap[0].sampleCount).toBe(5);
|
|
325
|
+
expect(encoded.streamSync.sampleRate).toBe(5512);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('emits nested ADPCM stream data as a WAV asset', () => {
|
|
329
|
+
const output = mkdtempSync(join(tmpdir(), 'swoof-adpcm-stream-'));
|
|
330
|
+
try {
|
|
331
|
+
const symbolTable = new SymbolTable();
|
|
332
|
+
symbolTable.set(4, {
|
|
333
|
+
type: 'Sprite', characterId: 4, frameCount: 1,
|
|
334
|
+
tags: [
|
|
335
|
+
{ code: 18, data: Uint8Array.of(0x0e, 0x16, 5, 0) },
|
|
336
|
+
{ code: 19, data: Uint8Array.of(0, 0, 0, 0x1b) },
|
|
337
|
+
{ code: 1, data: new Uint8Array(0) },
|
|
338
|
+
],
|
|
339
|
+
});
|
|
340
|
+
const result = emit({
|
|
341
|
+
header: { version: 10, frameSize: { xMin: 0, xMax: 2000, yMin: 0, yMax: 1000 }, frameRate: 24, frameCount: 1 },
|
|
342
|
+
tags: [{ type: 'ShowFrame' }], symbolTable,
|
|
343
|
+
actionScript: { needsSwflib: false, fullJs: '', avm1Scripts: [], avm2Blocks: [] },
|
|
344
|
+
}, 'adpcm-stream.swf', output, new DiagnosticsCollector());
|
|
345
|
+
const audio = readFileSync(join(result.bundleDir, 'assets/sound_stream_sprite_4.wav'));
|
|
346
|
+
expect(audio.subarray(0, 4).toString()).toBe('RIFF');
|
|
347
|
+
const bundle = readFileSync(result.jsPath, 'utf8');
|
|
348
|
+
expect(bundle).toContain('"spriteStream": 4');
|
|
349
|
+
expect(bundle).toContain('"codec": 1');
|
|
350
|
+
expect(bundle).toContain('"sampleCount": 5');
|
|
351
|
+
} finally {
|
|
352
|
+
rmSync(output, { recursive: true, force: true });
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
describe('DefineSound event PCM and ADPCM assets', () => {
|
|
359
|
+
function decodeSound(flags, sampleCount, data) {
|
|
360
|
+
const header = [
|
|
361
|
+
7, 0, flags, sampleCount & 255, (sampleCount >>> 8) & 255,
|
|
362
|
+
(sampleCount >>> 16) & 255, sampleCount >>> 24,
|
|
363
|
+
];
|
|
364
|
+
return decodeTag({ code: 14, data: Uint8Array.from([...header, ...data]) });
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
it('starts the next mono packet with its predictor and trims padding to the declared frame count', () => {
|
|
368
|
+
const adpcm = packBits([
|
|
369
|
+
[0, 2], [0, 16], [0, 6], ...Array(4095).fill([0, 2]),
|
|
370
|
+
[-1000, 16], [0, 6], [1, 2],
|
|
371
|
+
]);
|
|
372
|
+
const stream = decodeSwfAdpcmStream(adpcm);
|
|
373
|
+
expect(stream.sampleCount).toBe(4099); // without an exact count, padding has one full code
|
|
374
|
+
const sound = decodeSound(0x14, 4098, adpcm); // ADPCM, 11025 Hz, mono
|
|
375
|
+
const encoded = encodeSound(sound);
|
|
376
|
+
expect(encoded).toMatchObject({ ext: 'wav', mimeType: 'audio/wav' });
|
|
377
|
+
const wav = new DataView(encoded.data.buffer);
|
|
378
|
+
expect(wav.getUint16(22, true)).toBe(1);
|
|
379
|
+
expect(wav.getUint16(34, true)).toBe(16);
|
|
380
|
+
expect(wav.getUint32(24, true)).toBe(11025);
|
|
381
|
+
expect(wav.getUint32(40, true)).toBe(4098 * 2);
|
|
382
|
+
expect(wav.getInt16(44 + 4095 * 2, true)).toBe(12285);
|
|
383
|
+
expect(wav.getInt16(44 + 4096 * 2, true)).toBe(-1000);
|
|
384
|
+
expect(wav.getInt16(44 + 4097 * 2, true)).toBe(-990);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('resets both stereo predictors at the second packet without reading a new code size', () => {
|
|
388
|
+
const adpcm = packBits([
|
|
389
|
+
[1, 2], [100, 16], [0, 6], [-100, 16], [0, 6], ...Array(8190).fill([0, 3]),
|
|
390
|
+
[1200, 16], [0, 6], [-1200, 16], [0, 6], [7, 3], [3, 3],
|
|
391
|
+
]);
|
|
392
|
+
const sound = decodeSound(0x1d, 4098, adpcm); // ADPCM, 44100 Hz, stereo
|
|
393
|
+
const { data } = encodeSound(sound);
|
|
394
|
+
const wav = new DataView(data.buffer);
|
|
395
|
+
const readStereoFrame = i => [wav.getInt16(44 + i * 4, true), wav.getInt16(46 + i * 4, true)];
|
|
396
|
+
expect(wav.getUint16(22, true)).toBe(2);
|
|
397
|
+
expect(wav.getUint32(40, true)).toBe(4098 * 4);
|
|
398
|
+
expect(readStereoFrame(0)).toEqual([100, -100]);
|
|
399
|
+
expect(readStereoFrame(4096)).toEqual([1200, -1200]);
|
|
400
|
+
expect(readStereoFrame(4097)).toEqual([1189, -1189]);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('preserves codec 3 little-endian stereo samples and trims surplus frames', () => {
|
|
404
|
+
const pcm = Uint8Array.of(0x34, 0x12, 0xfe, 0xff, 0x11, 0x22, 0x33, 0x44);
|
|
405
|
+
const sound = decodeSound(0x3b, 1, pcm); // 22050 Hz, stereo, 16-bit
|
|
406
|
+
const encoded = encodeSound(sound);
|
|
407
|
+
expect(encoded).toMatchObject({ ext: 'wav', mimeType: 'audio/wav' });
|
|
408
|
+
const wav = new DataView(encoded.data.buffer);
|
|
409
|
+
expect(wav.getUint16(22, true)).toBe(2);
|
|
410
|
+
expect(wav.getUint32(24, true)).toBe(22050);
|
|
411
|
+
expect(wav.getUint32(40, true)).toBe(4);
|
|
412
|
+
expect(encoded.data.subarray(44)).toEqual(pcm.subarray(0, 4));
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it('pads odd-sized PCM RIFF chunks without counting the pad as an audio sample', () => {
|
|
416
|
+
const { data } = encodeSound(decodeSound(0x30, 3, Uint8Array.of(0, 128, 255)));
|
|
417
|
+
const wav = new DataView(data.buffer);
|
|
418
|
+
expect(wav.getUint16(34, true)).toBe(8);
|
|
419
|
+
expect(wav.getUint32(40, true)).toBe(3);
|
|
420
|
+
expect(wav.getUint32(4, true)).toBe(data.length - 8);
|
|
421
|
+
expect(data.subarray(44)).toEqual(Uint8Array.of(0, 128, 255, 0));
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it('realigns the stream after explicit short seeks and backward sparse sample discontinuities', () => {
|
|
426
|
+
const show = { type: 'ShowFrame' };
|
|
427
|
+
const pcmBlock = { type: 'SoundStreamBlock', rawData: new Uint8Array(220) };
|
|
428
|
+
const stream = encodeSoundStream([
|
|
429
|
+
{ type: 'SoundStreamHead', streamCompression: 3, streamRate: 1, stream16bit: true },
|
|
430
|
+
pcmBlock, show, show, pcmBlock, show, show,
|
|
431
|
+
]);
|
|
432
|
+
expect(stream.streamSync.seekMap.map(block => [block.frame, block.audioSampleStart])).toEqual([[0, 0], [2, 110]]);
|
|
433
|
+
const helpers = new Function('return ' + timelineHelpersSource())();
|
|
434
|
+
const engine = generateTimelineEngine({ frames: [{}, {}, {}, {}], characters: {} }, { embedded: true, frameRate: 20 });
|
|
435
|
+
const audio = { paused: true, currentTime: 0, duration: 1,
|
|
436
|
+
play() { this.paused = false; }, pause() { this.paused = true; },
|
|
437
|
+
};
|
|
438
|
+
const timeline = new Function('loaded', 'ASSETS', 'sharedTimelineHelpers', 'FRAME_RATE', 'requestAnimationFrame', 'ctx',
|
|
439
|
+
engine + '\nreturn timeline;')({ '-1': audio }, [{ id: -1, streamSync: stream.streamSync }], helpers, 20, () => 1, null);
|
|
440
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
441
|
+
timeline.gotoAndPlay(2);
|
|
442
|
+
expect(audio.currentTime).toBeCloseTo(551 / 11025);
|
|
443
|
+
audio.currentTime = 0.08;
|
|
444
|
+
timeline.gotoAndPlay(2);
|
|
445
|
+
expect(audio.currentTime).toBeCloseTo(551 / 11025);
|
|
446
|
+
timeline.tick();
|
|
447
|
+
expect(audio.currentTime).toBeCloseTo(110 / 11025);
|
|
448
|
+
audio.currentTime = 0.04;
|
|
449
|
+
timeline.tick();
|
|
450
|
+
expect(audio.currentTime).toBe(0.04); // consecutive playback still tolerates small drift
|
|
451
|
+
timeline.tick();
|
|
452
|
+
expect(audio.currentTime).toBe(0); // loop back to the first mapped sample
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it.each([false, true])('preserves same-frame stream tag order in binary SWFs (nested %s)', async nested => {
|
|
456
|
+
const output = mkdtempSync(join(tmpdir(), 'swoof-segmented-stream-'));
|
|
457
|
+
function rawTag(code, data = Buffer.alloc(0)) {
|
|
458
|
+
const long = data.length >= 63;
|
|
459
|
+
const header = Buffer.alloc(long ? 6 : 2);
|
|
460
|
+
header.writeUInt16LE((code << 6) | (long ? 63 : data.length));
|
|
461
|
+
if (long) header.writeUInt32LE(data.length, 2);
|
|
462
|
+
return Buffer.concat([header, data]);
|
|
463
|
+
}
|
|
464
|
+
function head(rate) {
|
|
465
|
+
return rawTag(TAG.SoundStreamHead2, Buffer.from([0x0e, 0x32 | rate << 2, 0, 0]));
|
|
466
|
+
}
|
|
467
|
+
const show = rawTag(TAG.ShowFrame);
|
|
468
|
+
const firstBlock = rawTag(TAG.SoundStreamBlock, Buffer.alloc(220));
|
|
469
|
+
const secondBlock = rawTag(TAG.SoundStreamBlock, Buffer.alloc(440));
|
|
470
|
+
const audioTags = Buffer.concat([
|
|
471
|
+
head(1), firstBlock, show, firstBlock, head(3), head(2), show, show, secondBlock, show, secondBlock, show,
|
|
472
|
+
]);
|
|
473
|
+
const bytes = Buffer.concat([
|
|
474
|
+
Buffer.from([70, 87, 83, 10, 0, 0, 0, 0, 8, 0, 0, 20, nested ? 1 : 5, 0]),
|
|
475
|
+
nested ? rawTag(TAG.DefineSprite, Buffer.concat([Buffer.from([10, 0, 5, 0]), audioTags, rawTag(TAG.End)])) : audioTags,
|
|
476
|
+
...(nested ? [show] : []), rawTag(TAG.End),
|
|
477
|
+
]);
|
|
478
|
+
bytes.writeUInt32LE(bytes.length, 4);
|
|
479
|
+
try {
|
|
480
|
+
const diagnostics = new DiagnosticsCollector();
|
|
481
|
+
const { doc } = await parse(bytes, diagnostics);
|
|
482
|
+
const { tags, symbolTable } = decode(doc, diagnostics);
|
|
483
|
+
const bundle = emit({ header: doc.header, tags, symbolTable, actionScript: { fullJs: '' } },
|
|
484
|
+
'segmented.swf', output, diagnostics);
|
|
485
|
+
expect(diagnostics.errors()).toEqual([]);
|
|
486
|
+
const prefix = nested ? 'sound_stream_sprite_10' : 'sound_stream';
|
|
487
|
+
const first = readFileSync(join(bundle.bundleDir, `assets/${prefix}.wav`));
|
|
488
|
+
const second = readFileSync(join(bundle.bundleDir, `assets/${prefix}_2.wav`));
|
|
489
|
+
expect(first.readUInt32LE(24)).toBe(11025);
|
|
490
|
+
expect(first.readUInt32LE(40)).toBe(440);
|
|
491
|
+
expect(second.readUInt32LE(24)).toBe(22050);
|
|
492
|
+
expect(second.readUInt32LE(40)).toBe(880);
|
|
493
|
+
if (nested) {
|
|
494
|
+
const generated = readFileSync(bundle.jsPath, 'utf8');
|
|
495
|
+
expect(generated).toContain('"streamEnd": 2');
|
|
496
|
+
expect(generated).toContain('"streamStart": 2');
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const media = [], transitions = [];
|
|
500
|
+
class Audio {
|
|
501
|
+
currentTime = 0;
|
|
502
|
+
paused = true;
|
|
503
|
+
duration = 1;
|
|
504
|
+
constructor() { media.push(this); }
|
|
505
|
+
addEventListener() {}
|
|
506
|
+
play() { transitions.push(['play', this.src]); this.paused = false; }
|
|
507
|
+
pause() { transitions.push(['pause', this.src]); this.paused = true; }
|
|
508
|
+
}
|
|
509
|
+
const context = {
|
|
510
|
+
Audio, setTimeout, clearTimeout, requestAnimationFrame: () => 1, addEventListener() {},
|
|
511
|
+
document: { readyState: 'complete', getElementById: () => null },
|
|
512
|
+
};
|
|
513
|
+
context.window = context;
|
|
514
|
+
runInNewContext(readFileSync(bundle.swflibPath, 'utf8'), context);
|
|
515
|
+
runInNewContext(readFileSync(bundle.jsPath, 'utf8'), context);
|
|
516
|
+
await new Promise(setImmediate);
|
|
517
|
+
const timeline = context.__swoof.timeline;
|
|
518
|
+
expect(media.map(audio => audio.paused)).toEqual([false, true]);
|
|
519
|
+
timeline.gotoAndPlay(2);
|
|
520
|
+
expect(media[0].currentTime).toBeCloseTo(110 / 11025);
|
|
521
|
+
timeline.tick();
|
|
522
|
+
expect(media.map(audio => audio.paused)).toEqual([true, true]); // new header, no block yet
|
|
523
|
+
timeline.tick();
|
|
524
|
+
expect(media.map(audio => audio.paused)).toEqual([true, false]);
|
|
525
|
+
expect(media[1].currentTime).toBe(0);
|
|
526
|
+
timeline.gotoAndPlay(5);
|
|
527
|
+
expect(media[1].currentTime).toBeCloseTo(220 / 22050);
|
|
528
|
+
timeline.tick();
|
|
529
|
+
expect(media.map(audio => audio.paused)).toEqual([false, true]);
|
|
530
|
+
expect(media[0].currentTime).toBe(0);
|
|
531
|
+
expect(transitions.map(([action]) => action)).toEqual(['play', 'pause', 'play', 'pause', 'play']);
|
|
532
|
+
} finally {
|
|
533
|
+
rmSync(output, { recursive: true, force: true });
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
it('does not treat an empty MP3 block as a fresh anchor when seeking', () => {
|
|
538
|
+
const show = { type: 'ShowFrame' };
|
|
539
|
+
const block = (...bytes) => ({ type: 'SoundStreamBlock', rawData: Uint8Array.of(...bytes) });
|
|
540
|
+
const stream = encodeSoundStream([
|
|
541
|
+
{ type: 'SoundStreamHead', streamCompression: 2, streamRate: 1, latencySeek: 100 },
|
|
542
|
+
block(0, 0, 0, 0), show,
|
|
543
|
+
block(64, 2, 100, 0, 0xff), show,
|
|
544
|
+
block(0, 0, 0, 0), show,
|
|
545
|
+
block(64, 2, 159, 0, 0xfe), show,
|
|
546
|
+
]);
|
|
547
|
+
expect(stream.data).toEqual(Uint8Array.of(0xff, 0xfe));
|
|
548
|
+
expect(stream.streamSync.seekMap.map(anchor => [anchor.frame, anchor.audioSampleStart])).toEqual([[1, 0], [3, 576]]);
|
|
549
|
+
const helpers = new Function('return ' + timelineHelpersSource())();
|
|
550
|
+
const engine = generateTimelineEngine({ frames: [{}, {}, {}, {}], characters: {} }, { embedded: true, frameRate: 30 });
|
|
551
|
+
const audio = {
|
|
552
|
+
paused: true, currentTime: 0, duration: 1,
|
|
553
|
+
play() { this.paused = false; }, pause() { this.paused = true; },
|
|
554
|
+
};
|
|
555
|
+
const timeline = new Function('loaded', 'ASSETS', 'sharedTimelineHelpers', 'FRAME_RATE', 'requestAnimationFrame', 'ctx',
|
|
556
|
+
engine + '\nreturn timeline;')({ '-1': audio }, [{ id: -1, streamSync: stream.streamSync }], helpers, 30, () => 1, null);
|
|
557
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
558
|
+
expect(audio.paused).toBe(true);
|
|
559
|
+
timeline.gotoAndPlay(3);
|
|
560
|
+
expect(audio.paused).toBe(false);
|
|
561
|
+
expect(audio.currentTime).toBeCloseTo(468 / 11025);
|
|
562
|
+
timeline.gotoAndPlay(4);
|
|
563
|
+
expect(audio.currentTime).toBeCloseTo(835 / 11025);
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
it('seeks named AVM1 sprite streams independently on adjacent and same-frame goto', () => {
|
|
567
|
+
const show = { type: 'ShowFrame' };
|
|
568
|
+
const pcm = { type: 'SoundStreamBlock', rawData: new Uint8Array(220) };
|
|
569
|
+
const stream = encodeSoundStream([
|
|
570
|
+
{ type: 'SoundStreamHead', streamCompression: 3, streamRate: 1, stream16bit: true },
|
|
571
|
+
pcm, show, pcm, show, pcm, show,
|
|
572
|
+
]);
|
|
573
|
+
const engine = generateTimelineEngine({
|
|
574
|
+
frames: [{ places: [{ characterId: 12, depth: 1, name: 'left' }, { characterId: 12, depth: 2, name: 'right' }] }],
|
|
575
|
+
characters: { 12: { type: 'sprite', hasStream: true, frames: [{}, {}, {}] } },
|
|
576
|
+
}, { embedded: true, frameRate: 30, frameCount: 1 });
|
|
577
|
+
const media = [];
|
|
578
|
+
class Audio {
|
|
579
|
+
paused = true;
|
|
580
|
+
currentTime = 0;
|
|
581
|
+
duration = 1;
|
|
582
|
+
constructor() { media.push(this); }
|
|
583
|
+
cloneNode() { return new Audio(); }
|
|
584
|
+
play() { this.paused = false; }
|
|
585
|
+
pause() { this.paused = true; }
|
|
586
|
+
}
|
|
587
|
+
const context = {
|
|
588
|
+
loaded: { '-1000012': new Audio() }, ASSETS: [{ id: -1000012, streamSync: stream.streamSync }],
|
|
589
|
+
FRAME_RATE: 30, requestAnimationFrame: () => 1, ctx: null,
|
|
590
|
+
};
|
|
591
|
+
context.window = context;
|
|
592
|
+
const { root, timeline } = runInNewContext(`
|
|
593
|
+
${SWFLIB_SOURCE}
|
|
594
|
+
${AVM1_RUNTIME_STUB}
|
|
595
|
+
var sharedTimelineHelpers = ${timelineHelpersSource()};
|
|
596
|
+
${engine}
|
|
597
|
+
window.__swoof = { root, timeline };
|
|
598
|
+
timeline.enter();
|
|
599
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
600
|
+
({ root, timeline });
|
|
601
|
+
`, context);
|
|
602
|
+
expect(root.left).not.toBe(root.right);
|
|
603
|
+
expect(media).toHaveLength(2);
|
|
604
|
+
expect(media.map(audio => audio.paused)).toEqual([false, false]);
|
|
605
|
+
media[0].currentTime = 0.03;
|
|
606
|
+
media[1].currentTime = 0.04;
|
|
607
|
+
root.left.gotoAndPlay(2);
|
|
608
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
609
|
+
expect(media[0].currentTime).toBeCloseTo(110 / 11025);
|
|
610
|
+
expect(media[1].currentTime).toBe(0.04);
|
|
611
|
+
media[0].currentTime = 0.05;
|
|
612
|
+
root.left.gotoAndPlay(2);
|
|
613
|
+
root.right.stop();
|
|
614
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
615
|
+
expect(media[0].currentTime).toBeCloseTo(110 / 11025);
|
|
616
|
+
expect(media.map(audio => audio.paused)).toEqual([false, true]);
|
|
617
|
+
root.right.gotoAndStop(3);
|
|
618
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
619
|
+
expect(media[1].paused).toBe(true);
|
|
620
|
+
root.right.play();
|
|
621
|
+
timeline.setStreamPlaybackSuspended(false);
|
|
622
|
+
expect(media[1].currentTime).toBeCloseTo(220 / 11025);
|
|
623
|
+
expect(media.map(audio => audio.paused)).toEqual([false, false]);
|
|
624
|
+
});
|