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,138 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function verifyAccessibility({ call, js, key, click, change, scrub, exportProject }) {
|
|
4
|
+
const focus = selector => js(`document.querySelector(${JSON.stringify(selector)}).focus()`);
|
|
5
|
+
const focused = selector => js(`document.activeElement.matches(${JSON.stringify(selector)})`);
|
|
6
|
+
const tab = () => key('Tab', 'Tab', 9);
|
|
7
|
+
const enter = () => key('Enter', 'Enter', 13, 0, '\r');
|
|
8
|
+
const escape = () => key('Escape', 'Escape', 27);
|
|
9
|
+
const tree = async () => (await call('Accessibility.getFullAXTree')).nodes.filter(node => !node.ignored);
|
|
10
|
+
const property = (node, name) => node.properties?.find(prop => prop.name === name)?.value.value;
|
|
11
|
+
async function checkNames() {
|
|
12
|
+
const roles = new Set(['button', 'tab', 'textbox', 'spinbutton', 'slider', 'combobox', 'checkbox',
|
|
13
|
+
'DisclosureTriangle', 'ColorWell', 'dialog', 'toolbar', 'separator']);
|
|
14
|
+
const unnamed = (await tree()).filter(node => roles.has(node.role.value) && !node.name?.value?.trim());
|
|
15
|
+
const details = [];
|
|
16
|
+
for (const node of unnamed) {
|
|
17
|
+
const { node: dom } = await call('DOM.describeNode', { backendNodeId: node.backendDOMNodeId });
|
|
18
|
+
details.push([node.role.value, dom.nodeName, dom.attributes]);
|
|
19
|
+
}
|
|
20
|
+
assert.deepEqual(details, [], 'Exposed editor controls need accessible names');
|
|
21
|
+
}
|
|
22
|
+
async function size(width, height) {
|
|
23
|
+
await call('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: false });
|
|
24
|
+
await js('new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))');
|
|
25
|
+
}
|
|
26
|
+
await size(1280, 800);
|
|
27
|
+
await call('Accessibility.enable');
|
|
28
|
+
await click('#import-project');
|
|
29
|
+
await change('project-io-textarea', JSON.stringify({ stage: { width: 800, height: 450, frameRate: 24 },
|
|
30
|
+
scenes: [{ id: 'scene', elements: [{ id: 'box', type: 'rectangle', x: 90 }] }] }));
|
|
31
|
+
await click('#project-io-submit');
|
|
32
|
+
await focus('#preview-button');
|
|
33
|
+
await tab();
|
|
34
|
+
assert.ok(await focused('.toolbar [tabindex="0"]'));
|
|
35
|
+
await key('Home', 'Home', 36);
|
|
36
|
+
assert.ok(await focused('[data-tool=select]'));
|
|
37
|
+
await key('ArrowDown', 'ArrowDown', 40);
|
|
38
|
+
assert.ok(await focused('[data-tool=scale]'));
|
|
39
|
+
await enter();
|
|
40
|
+
assert.equal(await js("document.querySelector('#stage').dataset.tool"), 'scale');
|
|
41
|
+
await key('End', 'End', 35);
|
|
42
|
+
await enter();
|
|
43
|
+
await tab();
|
|
44
|
+
assert.ok(await focused('.shape-tools [data-tool=rectangle]'));
|
|
45
|
+
await enter();
|
|
46
|
+
assert.ok(await focused('.shape-tools summary'));
|
|
47
|
+
assert.equal(await js("document.querySelector('.shape-tools').open"), false);
|
|
48
|
+
assert.equal(await js("document.querySelector('#stage').dataset.tool"), 'rectangle');
|
|
49
|
+
await tab();
|
|
50
|
+
assert.ok(await focused('#scene-switcher summary'));
|
|
51
|
+
await enter();
|
|
52
|
+
await focus('.scene-entry');
|
|
53
|
+
await enter();
|
|
54
|
+
assert.ok(await focused('#scene-switcher summary'));
|
|
55
|
+
|
|
56
|
+
await focus('#stage');
|
|
57
|
+
for (const [letter, tool] of Object.entries({ s: 'scale', r: 'rotate', m: 'rectangle', o: 'ellipse',
|
|
58
|
+
g: 'polygon', l: 'line', p: 'pen', t: 'text', v: 'select' })) {
|
|
59
|
+
const upper = letter.toUpperCase();
|
|
60
|
+
await key(letter, 'Key' + upper, upper.charCodeAt(0));
|
|
61
|
+
assert.equal(await js("document.querySelector('#stage').dataset.tool"), tool);
|
|
62
|
+
assert.equal(await js(`document.querySelector('[aria-keyshortcuts="${upper}"]').getAttribute('aria-pressed')`), 'true');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await focus('.layer-select-btn');
|
|
66
|
+
await key('F2', 'F2', 113);
|
|
67
|
+
assert.ok(await focused('.layer-rename-input'));
|
|
68
|
+
await key('p', 'KeyP', 80, 0, 'p');
|
|
69
|
+
assert.equal(await js("document.querySelector('#stage').dataset.tool"), 'select');
|
|
70
|
+
await enter();
|
|
71
|
+
assert.ok(await focused('.layer-select-btn'));
|
|
72
|
+
assert.equal(await js('document.activeElement.textContent'), 'p');
|
|
73
|
+
await focus('.layer-lock');
|
|
74
|
+
await enter();
|
|
75
|
+
assert.ok(await focused('.layer-unlock'));
|
|
76
|
+
await enter();
|
|
77
|
+
|
|
78
|
+
await click('#tab-objects');
|
|
79
|
+
await focus('.element-entry');
|
|
80
|
+
await enter();
|
|
81
|
+
assert.ok(await focused('.element-entry[aria-pressed=true]'));
|
|
82
|
+
await click('#tab-properties');
|
|
83
|
+
await checkNames();
|
|
84
|
+
await scrub(5);
|
|
85
|
+
const original = await exportProject();
|
|
86
|
+
await js("const x = document.querySelector('[data-property=x]'); x.focus(); x.value = ''; x.dispatchEvent(new Event('change', { bubbles: true }));");
|
|
87
|
+
assert.equal(await js("document.querySelector('[data-property=x]').valueAsNumber"), 90);
|
|
88
|
+
const alert = (await tree()).find(node => node.role.value === 'alert' && property(node, 'live') === 'assertive');
|
|
89
|
+
assert.ok(alert);
|
|
90
|
+
const nodes = await tree();
|
|
91
|
+
assert.ok(nodes.some(node => node.parentId === alert.nodeId && /finite number/.test(node.name?.value)));
|
|
92
|
+
assert.deepEqual(await exportProject(), original);
|
|
93
|
+
await focus('#stage');
|
|
94
|
+
await key('o', 'KeyO', 79);
|
|
95
|
+
const announced = await tree();
|
|
96
|
+
const status = announced.find(node => node.role.value === 'status' && property(node, 'live') === 'polite' &&
|
|
97
|
+
announced.some(child => child.parentId === node.nodeId && child.name?.value.includes('ellipse')));
|
|
98
|
+
assert.ok(status);
|
|
99
|
+
await focus('#frame-edit');
|
|
100
|
+
await change('frame-edit', 'events');
|
|
101
|
+
await focus('#event-add');
|
|
102
|
+
await enter();
|
|
103
|
+
assert.ok(await focused('#event-actions select'));
|
|
104
|
+
await checkNames();
|
|
105
|
+
await focus('#event-actions button[aria-label="Remove action"]');
|
|
106
|
+
await enter();
|
|
107
|
+
assert.ok(await focused('#event-add'));
|
|
108
|
+
await escape();
|
|
109
|
+
assert.ok(await focused('#frame-edit'));
|
|
110
|
+
await click('#preview-button');
|
|
111
|
+
await focus('#tab-properties');
|
|
112
|
+
await escape();
|
|
113
|
+
assert.equal(await js("document.querySelector('#preview-button').getAttribute('aria-pressed')"), 'false');
|
|
114
|
+
|
|
115
|
+
for (const [width, height] of [[320, 568], [640, 360]]) {
|
|
116
|
+
await size(width, height);
|
|
117
|
+
assert.ok(await js('document.documentElement.scrollWidth <= innerWidth && document.documentElement.scrollHeight <= innerHeight'));
|
|
118
|
+
await focus('#toggle-dock');
|
|
119
|
+
await enter();
|
|
120
|
+
assert.ok(await focused('[role=tab][aria-selected=true]'));
|
|
121
|
+
await key('End', 'End', 35);
|
|
122
|
+
assert.ok(await focused('#tab-library'));
|
|
123
|
+
await checkNames();
|
|
124
|
+
await tab();
|
|
125
|
+
assert.ok(await focused('#library-panel *'));
|
|
126
|
+
assert.ok(await js('(() => { const r = document.activeElement.getBoundingClientRect(); return r.bottom > 0 && r.top < innerHeight && r.right > 0 && r.left < innerWidth; })()'));
|
|
127
|
+
await escape();
|
|
128
|
+
assert.ok(await focused('#toggle-dock'));
|
|
129
|
+
await focus('#import-project');
|
|
130
|
+
await enter();
|
|
131
|
+
await checkNames();
|
|
132
|
+
await tab();
|
|
133
|
+
assert.ok(await focused('#project-io-dialog *'));
|
|
134
|
+
await escape();
|
|
135
|
+
assert.ok(await focused('#import-project'));
|
|
136
|
+
}
|
|
137
|
+
await size(1280, 800);
|
|
138
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function verifyAppearance({ click, change, js, scrub, pixel, drag, exportProject }) {
|
|
4
|
+
async function load(project) {
|
|
5
|
+
await click('#import-project');
|
|
6
|
+
await change('project-io-textarea', JSON.stringify(project));
|
|
7
|
+
await click('#project-io-submit');
|
|
8
|
+
}
|
|
9
|
+
const field = id => js(`document.getElementById(${JSON.stringify(id)}).value`);
|
|
10
|
+
const art = { type: 'rectangle', x: 250, y: 180, width: 80, height: 40, scaleX: 1.5,
|
|
11
|
+
rotation: 90, fill: '#ff0000', strokeWidth: 0, buttonAction: { type: 'gotoFrame', target: 7 },
|
|
12
|
+
keyframes: [{ frame: 1 }, { frame: 7 }] };
|
|
13
|
+
await click('#stop-button');
|
|
14
|
+
const ink = await js(`(() => {
|
|
15
|
+
const canvas = document.createElement('canvas');
|
|
16
|
+
canvas.width = canvas.height = 1;
|
|
17
|
+
const ctx = canvas.getContext('2d');
|
|
18
|
+
ctx.fillStyle = '#12ab34';
|
|
19
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
20
|
+
return canvas.toDataURL();
|
|
21
|
+
})()`);
|
|
22
|
+
await load({ stage: { width: 800, height: 450, frameRate: 24, background: '#000000' },
|
|
23
|
+
assets: [{ id: 'ink', kind: 'image', name: 'Ink', data: ink }],
|
|
24
|
+
scenes: [{ name: 'Bitmap line', elements: [{ type: 'path', x: 250, y: 180, width: 100, height: 1,
|
|
25
|
+
points: [{ x: -50, y: 0 }, { x: 50, y: 0 }], strokeWidth: 320.05,
|
|
26
|
+
bitmapStroke: { assetId: 'ink', matrix: { a: 1, d: 1, b: 0, c: 0, tx: 0, ty: 0 }, repeat: true, smoothed: false } }] }] });
|
|
27
|
+
for (let i = 0; i < 100 && await field('scene-name') !== 'Bitmap line'; i++) {
|
|
28
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
29
|
+
}
|
|
30
|
+
assert.deepEqual(await pixel(250, 325), [18, 171, 52, 255], 'The canvas paints the full imported bitmap line width');
|
|
31
|
+
assert.deepEqual(await pixel(250, 345), [0, 0, 0, 255]);
|
|
32
|
+
await load({ stage: { width: 800, height: 450, frameRate: 24, background: '#000000' },
|
|
33
|
+
scenes: [{ elements: [{ type: 'line', x: 250, y: 180, width: 100, height: 20, stroke: '#ff0000', strokeWidth: 12 }] }] });
|
|
34
|
+
await click('.timeline-lane-label');
|
|
35
|
+
await change('stroke-gradient-type', 'linear');
|
|
36
|
+
await change('strokeGradient-endColor', '#0000ff');
|
|
37
|
+
const leftStroke = await pixel(210, 182), rightStroke = await pixel(290, 182);
|
|
38
|
+
assert.ok(leftStroke[0] > 200 && rightStroke[2] > 200, 'Stroke gradient changes color across its path');
|
|
39
|
+
assert.equal((await exportProject()).scenes[0].elements[0].strokeGradient.endColor, '#0000ff');
|
|
40
|
+
await load({ stage: { width: 800, height: 450, frameRate: 24, background: '#000000' },
|
|
41
|
+
scenes: [{ durationFrames: 7, elements: [art] }] });
|
|
42
|
+
await click('.timeline-lane-label');
|
|
43
|
+
await change('gradient-type', 'linear');
|
|
44
|
+
await change('gradient-endColor', '#0000ff');
|
|
45
|
+
const start = await pixel(254, 126), end = await pixel(254, 234);
|
|
46
|
+
assert.ok(start[0] > 225 && start[2] < 30 && end[2] > 225 && end[0] < 30,
|
|
47
|
+
'Gradient follows the scaled and rotated long axis: ' + JSON.stringify({ start, end }));
|
|
48
|
+
await change('gradient-type', 'radial');
|
|
49
|
+
assert.equal(await field('gradient-endColor'), '#0000ff');
|
|
50
|
+
const center = await pixel(251, 181), edge = await pixel(267, 180);
|
|
51
|
+
assert.ok(center[0] > 220 && edge[2] > 205, 'Elliptical radial fill: ' + JSON.stringify({ center, edge }));
|
|
52
|
+
await change('gradient-focus', 0.5);
|
|
53
|
+
assert.ok((await pixel(250, 210))[0] > 230, 'Focal point follows the object rotation');
|
|
54
|
+
await change('effect-type', 'blur');
|
|
55
|
+
await change('effect-blurX', 20);
|
|
56
|
+
await change('effect-blurY', 20);
|
|
57
|
+
await click('#preview-button');
|
|
58
|
+
const blurred = await pixel(273, 180);
|
|
59
|
+
assert.ok(blurred[2] > 5, 'Blur paints beyond the transformed bounds: ' + blurred);
|
|
60
|
+
assert.equal(await js("document.querySelector('#effect-blurX').disabled"), true);
|
|
61
|
+
await click('#preview-button');
|
|
62
|
+
await change('effect-type', 'glow');
|
|
63
|
+
await change('effect-color', '#00ff00');
|
|
64
|
+
await click('#preview-button');
|
|
65
|
+
assert.ok((await pixel(273, 180))[1] > 5, 'Glow extends beyond transformed artwork');
|
|
66
|
+
await click('#preview-button');
|
|
67
|
+
await change('effect-type', 'shadow');
|
|
68
|
+
await change('effect-distance', 30);
|
|
69
|
+
await change('effect-angle', 0);
|
|
70
|
+
await change('effect-blurX', 0);
|
|
71
|
+
await change('effect-blurY', 0);
|
|
72
|
+
await change('effect-alpha', 2);
|
|
73
|
+
assert.equal(await field('effect-alpha'), '1', 'Invalid opacity restores the evaluated value');
|
|
74
|
+
await click('#preview-button');
|
|
75
|
+
assert.deepEqual(await pixel(282, 180), [0, 255, 0, 255]);
|
|
76
|
+
assert.deepEqual(await pixel(303, 180), [0, 0, 0, 255]);
|
|
77
|
+
await drag(282, 180);
|
|
78
|
+
assert.equal(await field('playhead'), '1', 'A painted shadow is outside the button hit area');
|
|
79
|
+
await drag(250, 180);
|
|
80
|
+
assert.equal(await field('playhead'), '7', 'The transformed artwork activates the button');
|
|
81
|
+
await click('#preview-button');
|
|
82
|
+
assert.equal(await field('effect-type'), '', 'The pre-existing plain key retains its style');
|
|
83
|
+
assert.equal(await field('gradient-type'), '');
|
|
84
|
+
await change('gradient-type', 'radial');
|
|
85
|
+
await change('gradient-focus', -0.5);
|
|
86
|
+
await scrub(4);
|
|
87
|
+
assert.equal(await field('gradient-focus'), '0', 'Scrubbing shows the tweened parameter');
|
|
88
|
+
await change('gradient-focus', 0.25);
|
|
89
|
+
assert.equal((await exportProject()).scenes[0].elements[0].keyframes.find(k => k.frame === 4).gradient.focus, 0.25);
|
|
90
|
+
await scrub(1);
|
|
91
|
+
await click('.timeline-lane-label');
|
|
92
|
+
await change('effect-type', '');
|
|
93
|
+
await click('#undo');
|
|
94
|
+
assert.equal(await field('effect-type'), 'shadow');
|
|
95
|
+
await click('#redo');
|
|
96
|
+
assert.equal(await field('effect-type'), '');
|
|
97
|
+
await click('#undo');
|
|
98
|
+
const saved = await exportProject();
|
|
99
|
+
await load(saved);
|
|
100
|
+
assert.deepEqual(await exportProject(), saved);
|
|
101
|
+
await click('#preview-button');
|
|
102
|
+
assert.deepEqual(await pixel(282, 180), [0, 255, 0, 255], 'Reopened projects render the same effect');
|
|
103
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { controlDefinitions, CONTROL_KINDS } from '../../swooflib/control-definitions.js';
|
|
3
|
+
|
|
4
|
+
export async function verifyControls({ click, change, key, drag, js, exportProject }) {
|
|
5
|
+
const load = async project => {
|
|
6
|
+
await click('#import-project');
|
|
7
|
+
await change('project-io-textarea', JSON.stringify(project));
|
|
8
|
+
await click('#project-io-submit');
|
|
9
|
+
assert.equal(await js("document.querySelector('#project-io-dialog').open"), false);
|
|
10
|
+
};
|
|
11
|
+
await load({ stage: { width: 800, height: 450, background: '#ffffff', frameRate: 12 },
|
|
12
|
+
scenes: [{ id: 'controls', name: 'Controls', durationFrames: 12, elements: [] }] });
|
|
13
|
+
assert.deepEqual(await js("[...document.querySelectorAll('.control-tools [data-tool]')].map(el => el.dataset.tool)"), CONTROL_KINDS);
|
|
14
|
+
// Use every toolbar tool. The same placement also tests DOM stacking in Preview.
|
|
15
|
+
for (const kind of CONTROL_KINDS.filter(kind => kind !== 'CheckBox').concat('CheckBox')) {
|
|
16
|
+
if (kind === 'CheckBox') {
|
|
17
|
+
await js("document.querySelector('.control-tools summary').focus()");
|
|
18
|
+
await key('Enter', 'Enter', 13, 0, '\r');
|
|
19
|
+
await key('Tab', 'Tab', 9);
|
|
20
|
+
await key('Tab', 'Tab', 9);
|
|
21
|
+
assert.equal(await js('document.activeElement.dataset.tool'), 'CheckBox');
|
|
22
|
+
await key('Enter', 'Enter', 13, 0, '\r');
|
|
23
|
+
} else {
|
|
24
|
+
await click('.control-tools summary');
|
|
25
|
+
assert.equal(await js("document.querySelector('.control-tools').open"), true);
|
|
26
|
+
await click(`[data-tool="${kind}"]`);
|
|
27
|
+
}
|
|
28
|
+
if (kind === 'Slider') await drag(150, 120, 410, 158);
|
|
29
|
+
else await drag(180, 200);
|
|
30
|
+
assert.equal(await js("document.querySelector('#element-type').textContent"), controlDefinitions[kind].label);
|
|
31
|
+
}
|
|
32
|
+
const label = '[data-parameter="label"]';
|
|
33
|
+
await js(`{const field = document.querySelector('${label}'); field.value = 'Sound effects'; field.dispatchEvent(new Event('change', { bubbles: true }));}`);
|
|
34
|
+
await change('control-variable', 'soundEnabled');
|
|
35
|
+
await click('#control-actions'); await click('#event-add');
|
|
36
|
+
await js(`{const type = document.querySelector('#event-actions select'); type.value = 'gotoFrame'; type.dispatchEvent(new Event('change'));
|
|
37
|
+
const frame = document.querySelector('#event-actions input'); frame.value = '7'; frame.dispatchEvent(new Event('input'));}`);
|
|
38
|
+
await click('#event-save');
|
|
39
|
+
const project = await exportProject(), scene = project.scenes[0];
|
|
40
|
+
assert.equal(scene.elements.length, CONTROL_KINDS.length);
|
|
41
|
+
const checkbox = scene.elements.find(item => item.control === 'CheckBox');
|
|
42
|
+
assert.equal(checkbox.parameters.label, 'Sound effects');
|
|
43
|
+
assert.equal(checkbox.variable, 'soundEnabled');
|
|
44
|
+
assert.equal(checkbox.width, controlDefinitions.CheckBox.width);
|
|
45
|
+
assert.ok(Math.abs(scene.elements.find(item => item.control === 'Slider').width - 260) < 0.1);
|
|
46
|
+
assert.deepEqual(scene.events, [{ source: checkbox.id, trigger: 'click', actions: [{ type: 'gotoFrame', target: 7 }] }]);
|
|
47
|
+
await load(project);
|
|
48
|
+
assert.deepEqual(await exportProject(), project);
|
|
49
|
+
await click('#preview-button');
|
|
50
|
+
const surface = '#preview-surface', check = surface + ' input[type="checkbox"]';
|
|
51
|
+
assert.equal(await js(`document.querySelectorAll('${surface} [data-control]').length`), CONTROL_KINDS.length);
|
|
52
|
+
assert.equal(await js(`document.querySelector('${check}').getAttribute('aria-label')`), 'Sound effects');
|
|
53
|
+
await js(`document.querySelector('${check}').focus()`);
|
|
54
|
+
await key(' ', 'Space', 32, 0, ' ');
|
|
55
|
+
assert.equal(await js("document.querySelector('#playhead').value"), '7');
|
|
56
|
+
assert.equal(await js(`document.querySelector('${check}').checked`), true);
|
|
57
|
+
assert.equal(await js(`document.activeElement === document.querySelector('${check}')`), true);
|
|
58
|
+
await click('#stop-button');
|
|
59
|
+
assert.deepEqual(await exportProject(), project);
|
|
60
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function verifyFrameEvents({ click, change, js, scrub, pixel, exportProject }) {
|
|
4
|
+
const stage = { width: 800, height: 450, frameRate: 24, background: '#000000' };
|
|
5
|
+
const box = { id: 'box', name: 'Box', type: 'rectangle', x: 200, y: 200, width: 60, height: 60, fill: '#ff0000', strokeWidth: 0 };
|
|
6
|
+
const scene = { id: 'intro', name: 'Intro', durationFrames: 12, elements: [box] };
|
|
7
|
+
const enter = (frame, ...actions) => ({ trigger: 'frameEnter', frame, actions });
|
|
8
|
+
const red = [255, 0, 0, 255], black = [0, 0, 0, 255];
|
|
9
|
+
const frame = () => js("Number(document.querySelector('#playhead').value)");
|
|
10
|
+
const paused = () => js("document.querySelector('#play-button').textContent === 'Play'");
|
|
11
|
+
async function load(scenes, symbols = []) {
|
|
12
|
+
await click('#stop-button');
|
|
13
|
+
await click('#import-project');
|
|
14
|
+
await change('project-io-textarea', JSON.stringify({ stage, scenes, symbols }));
|
|
15
|
+
await click('#project-io-submit');
|
|
16
|
+
assert.equal(await js("document.querySelector('#project-io-dialog').open"), false);
|
|
17
|
+
}
|
|
18
|
+
const action = (idx, type) => js(`{ const node = document.querySelectorAll('#event-actions li')[${idx}].querySelector('select');
|
|
19
|
+
node.value = ${JSON.stringify(type)}; node.dispatchEvent(new Event('change')); }`);
|
|
20
|
+
await load([scene]);
|
|
21
|
+
await click('.timeline-lane[data-element-id=box] .timeline-lane-label');
|
|
22
|
+
await scrub(3);
|
|
23
|
+
await change('frame-edit', 'events');
|
|
24
|
+
await click('#event-add');
|
|
25
|
+
await action(0, 'gotoFrame');
|
|
26
|
+
await js("{const n = document.querySelector('#event-actions input'); n.value=42; n.dispatchEvent(new Event('input'));}");
|
|
27
|
+
await click('#event-save');
|
|
28
|
+
assert.match(await js("document.querySelector('#event-editor [role=alert]').textContent"), /between 1 and 12/);
|
|
29
|
+
await action(0, 'hide');
|
|
30
|
+
await click('#event-add');
|
|
31
|
+
await change('event-trigger', 'timelineStart');
|
|
32
|
+
await click('#event-add');
|
|
33
|
+
await action(0, 'play');
|
|
34
|
+
await click('#event-save');
|
|
35
|
+
const authored = await exportProject();
|
|
36
|
+
await click('#delete-element');
|
|
37
|
+
const deleted = await exportProject();
|
|
38
|
+
assert.deepEqual(deleted.scenes[0].events[1].actions, [{ type: 'stop' }]);
|
|
39
|
+
await click('#undo');
|
|
40
|
+
assert.deepEqual(await exportProject(), authored);
|
|
41
|
+
assert.deepEqual(authored.scenes[0].events, [{ trigger: 'timelineStart', actions: [{ type: 'play' }] },
|
|
42
|
+
enter(3, { type: 'hide', target: 'box' }, { type: 'stop' })]);
|
|
43
|
+
await click('#undo');
|
|
44
|
+
assert.equal(await js("document.querySelectorAll('.event-marker').length"), 0);
|
|
45
|
+
await click('#redo');
|
|
46
|
+
await click('.event-marker[data-frame="3"]');
|
|
47
|
+
assert.equal(await js("document.querySelector('#event-editor').open"), true);
|
|
48
|
+
await click('#event-actions li:last-child [aria-label="Move action up"]');
|
|
49
|
+
assert.equal(await js("document.querySelector('#event-actions select').value"), 'stop');
|
|
50
|
+
await click('#event-actions [aria-label="Remove action"]');
|
|
51
|
+
await click('#event-cancel');
|
|
52
|
+
assert.deepEqual(await exportProject(), authored, 'Cancel discards reordering and removals');
|
|
53
|
+
await scrub(1);
|
|
54
|
+
await scrub(3);
|
|
55
|
+
assert.deepEqual(await pixel(), red, 'Scrubbing across an action never executes it');
|
|
56
|
+
|
|
57
|
+
// Advance animation callbacks deterministically, including a five-frame catch-up tick.
|
|
58
|
+
await js(`{ const request = window.requestAnimationFrame, cancel = window.cancelAnimationFrame;
|
|
59
|
+
const pending = new Map(); let seq = 0, now = 0;
|
|
60
|
+
window.requestAnimationFrame = cb => { pending.set(++seq, cb); return seq; };
|
|
61
|
+
window.cancelAnimationFrame = id => pending.delete(id);
|
|
62
|
+
window.advanceStudio = ms => { now += ms; const callbacks = [...pending.values()]; pending.clear(); for (const cb of callbacks) cb(now); };
|
|
63
|
+
window.restoreStudioTime = () => { window.requestAnimationFrame = request; window.cancelAnimationFrame = cancel; }; }`);
|
|
64
|
+
try {
|
|
65
|
+
await click('#preview-button');
|
|
66
|
+
assert.equal(await paused(), false);
|
|
67
|
+
await js('advanceStudio(0); advanceStudio(220)');
|
|
68
|
+
assert.equal(await frame(), 3, 'Catch-up runs the intermediate stop');
|
|
69
|
+
assert.equal(await paused(), true);
|
|
70
|
+
assert.deepEqual(await pixel(), black);
|
|
71
|
+
await click('#play-button');
|
|
72
|
+
await js('advanceStudio(0); advanceStudio(44)');
|
|
73
|
+
assert.equal(await frame(), 4, 'Resuming a stopped frame does not run its actions again');
|
|
74
|
+
await click('#stop-button');
|
|
75
|
+
assert.deepEqual(await pixel(), red);
|
|
76
|
+
assert.deepEqual(await exportProject(), authored);
|
|
77
|
+
|
|
78
|
+
await load([{ ...scene, durationFrames: 2, loop: true,
|
|
79
|
+
events: [enter(1, { type: 'toggleVisibility', target: 'box' })] }]);
|
|
80
|
+
await click('#play-button');
|
|
81
|
+
assert.deepEqual(await pixel(), black);
|
|
82
|
+
await js('advanceStudio(0); advanceStudio(85)');
|
|
83
|
+
assert.equal(await frame(), 1);
|
|
84
|
+
assert.deepEqual(await pixel(), red, 'The loop re-enters frame 1');
|
|
85
|
+
|
|
86
|
+
await load([{ ...scene, events: [enter(1, { type: 'gotoScene', target: 'end', play: true })] },
|
|
87
|
+
{ id: 'end', name: 'End', durationFrames: 8, elements: [], events: [
|
|
88
|
+
enter(2, { type: 'gotoFrame', target: 6 }), enter(6, { type: 'stop' })] }]);
|
|
89
|
+
await click('.timeline-lane[data-element-id=box] .timeline-lane-label');
|
|
90
|
+
await click('#preview-button');
|
|
91
|
+
await js('advanceStudio(0); advanceStudio(90)');
|
|
92
|
+
assert.equal(await js("document.querySelector('#stage-scene-name').textContent"), 'End');
|
|
93
|
+
assert.equal(await frame(), 6);
|
|
94
|
+
assert.equal(await paused(), true);
|
|
95
|
+
await click('#preview-button');
|
|
96
|
+
assert.equal(await js("document.querySelector('#stage-scene-name').textContent"), 'Intro');
|
|
97
|
+
assert.equal(await js("document.querySelector('.timeline-lane[data-element-id=box] button').getAttribute('aria-pressed')"), 'true');
|
|
98
|
+
|
|
99
|
+
const symbol = { id: 'widget', name: 'Widget', width: 200, height: 120, durationFrames: 5,
|
|
100
|
+
elements: [{ ...box, x: 100, y: 60 }], events: [enter(2, { type: 'hide', target: 'box' }, { type: 'stop' })] };
|
|
101
|
+
const placed = { type: 'symbol', symbolId: 'widget', width: 200, height: 120, y: 200 };
|
|
102
|
+
await load([{ ...scene, elements: [{ ...placed, x: 200 }, { ...placed, x: 500, symbolMode: 'single' }] }], [symbol]);
|
|
103
|
+
await click('#play-button');
|
|
104
|
+
await js('advanceStudio(0); advanceStudio(135)');
|
|
105
|
+
assert.equal(await frame(), 4);
|
|
106
|
+
assert.deepEqual(await pixel(200, 200), black);
|
|
107
|
+
assert.deepEqual(await pixel(500, 200), red, 'Instance events only affect their own objects');
|
|
108
|
+
|
|
109
|
+
await load([{ ...scene, events: [enter(1, { type: 'gotoFrame', target: 2 }), enter(2, { type: 'gotoFrame', target: 1 })] }]);
|
|
110
|
+
await click('#preview-button');
|
|
111
|
+
assert.equal(await paused(), true);
|
|
112
|
+
assert.match(await js("document.querySelector('#status-message').textContent"), /circular frame actions/);
|
|
113
|
+
await click('#stop-button');
|
|
114
|
+
} finally {
|
|
115
|
+
await js('restoreStudioTime()');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { once } from 'node:events';
|
|
3
|
+
import { createServer } from 'node:http';
|
|
4
|
+
import { writeFile } from 'node:fs/promises';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { pathToFileURL } from 'node:url';
|
|
7
|
+
|
|
8
|
+
export async function verifyExternalResources({ call, js, studio, profile }) {
|
|
9
|
+
const seen = [];
|
|
10
|
+
let hostedExport;
|
|
11
|
+
const remote = createServer((req, res) => {
|
|
12
|
+
if (req.url === '/game.html') {
|
|
13
|
+
res.writeHead(200, { 'Content-Type': 'text/html', 'Cache-Control': 'no-store' });
|
|
14
|
+
res.end(hostedExport);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (req.url === '/favicon.ico') { res.writeHead(204); res.end(); return; }
|
|
18
|
+
seen.push([req.method, req.url]);
|
|
19
|
+
res.writeHead(200, { 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'no-store' });
|
|
20
|
+
res.end('answer=yes');
|
|
21
|
+
});
|
|
22
|
+
remote.listen(0, '127.0.0.1');
|
|
23
|
+
await once(remote, 'listening');
|
|
24
|
+
const origin = 'http://127.0.0.1:' + remote.address().port;
|
|
25
|
+
const project = {
|
|
26
|
+
stage: { width: 320, height: 240, frameRate: 12, background: '#ffffff' },
|
|
27
|
+
scenes: [{ id: 'main', durationFrames: 1, elements: [], events: [
|
|
28
|
+
{ trigger: 'frameEnter', frame: 1, actions: [{ type: 'script', script: 'boot' }] },
|
|
29
|
+
] }],
|
|
30
|
+
scripts: [{ id: 'boot', language: 'actionscript', swfVersion: 8,
|
|
31
|
+
code: 'stop(); var vars = new LoadVars(); vars.onData = function(body) { _root.reply = body; }; vars.load("' + origin + '/boot");' }],
|
|
32
|
+
};
|
|
33
|
+
async function until(expression) {
|
|
34
|
+
for (let i = 0; i < 150; i++) {
|
|
35
|
+
if (await js(expression).catch(() => false)) return;
|
|
36
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
37
|
+
}
|
|
38
|
+
assert.fail('Timed out waiting for ' + expression);
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
await call('Network.emulateNetworkConditions', { offline: false, latency: 0, downloadThroughput: -1, uploadThroughput: -1 });
|
|
42
|
+
for (const [mode, choice] of [[undefined], ['allow'], ['prompt', 'disallow'], ['prompt', 'allow']]) {
|
|
43
|
+
seen.length = 0;
|
|
44
|
+
const standalone = mode === 'prompt';
|
|
45
|
+
const allowed = (choice ?? mode) === 'allow';
|
|
46
|
+
const movie = structuredClone(project);
|
|
47
|
+
movie.scripts[0].code += ' getURL("' + origin + '/first-link", "_blank");';
|
|
48
|
+
if (!allowed) movie.scripts[0].code += ' var sound = new Sound(); sound.onLoad = function(ok) { _root.audioReady = ok; }; sound.onSoundComplete = function() { _root.audioDone = true; }; sound.loadSound("' + origin + '/stream.mp3", true);';
|
|
49
|
+
const response = await fetch(studio + (standalone ? '/api/export/html' : '/api/preview'), {
|
|
50
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
51
|
+
body: JSON.stringify({ project: movie, externalResources: mode }),
|
|
52
|
+
});
|
|
53
|
+
assert.ok(response.ok);
|
|
54
|
+
let url;
|
|
55
|
+
if (standalone) {
|
|
56
|
+
const file = path.join(profile, 'prompt-' + choice + '.html');
|
|
57
|
+
await writeFile(file, new Uint8Array(await response.arrayBuffer()));
|
|
58
|
+
url = pathToFileURL(file).href;
|
|
59
|
+
} else url = studio + (await response.json()).url;
|
|
60
|
+
await call('Page.navigate', { url });
|
|
61
|
+
if (choice) {
|
|
62
|
+
await until("document.querySelector('#external-prompt')?.open");
|
|
63
|
+
assert.equal(await js("typeof globalThis.__swoof"), 'undefined');
|
|
64
|
+
assert.deepEqual(seen, []);
|
|
65
|
+
await js('document.querySelector("#external-prompt [value=' + choice + ']").click()');
|
|
66
|
+
}
|
|
67
|
+
await until("typeof globalThis.__swoof?.root.reply === 'string'");
|
|
68
|
+
assert.equal(await js('__swoof.root.reply'), allowed ? 'answer=yes' : '');
|
|
69
|
+
const data = await js(`(async () => {
|
|
70
|
+
const req = new URLRequest(${JSON.stringify(origin + '/post')});
|
|
71
|
+
req.method = 'POST';
|
|
72
|
+
req.data = 'probe=1';
|
|
73
|
+
const data = new URLLoader();
|
|
74
|
+
const done = new Promise((resolve, reject) => {
|
|
75
|
+
data.addEventListener('complete', () => resolve([data.status, data.data]));
|
|
76
|
+
data.addEventListener('ioError', e => reject(new Error(e.text)));
|
|
77
|
+
});
|
|
78
|
+
data.load(req);
|
|
79
|
+
return done;
|
|
80
|
+
})()`);
|
|
81
|
+
assert.deepEqual(data, [200, allowed ? 'answer=yes' : '']);
|
|
82
|
+
if (!allowed) {
|
|
83
|
+
await until('__swoof.root.audioReady && __swoof.root.audioDone');
|
|
84
|
+
const placeholders = await js(`(async () => {
|
|
85
|
+
const base = ${JSON.stringify(origin)};
|
|
86
|
+
async function load(path) {
|
|
87
|
+
const loader = new Loader();
|
|
88
|
+
const done = new Promise(resolve => loader.contentLoaderInfo.addEventListener('complete', resolve));
|
|
89
|
+
loader.load(new URLRequest(base + path));
|
|
90
|
+
await done;
|
|
91
|
+
return loader.content;
|
|
92
|
+
}
|
|
93
|
+
const picture = await load('/pixel.png');
|
|
94
|
+
const movie = await load('/ad.swf');
|
|
95
|
+
const sound = new Sound();
|
|
96
|
+
const ready = new Promise(resolve => sound.addEventListener('complete', resolve));
|
|
97
|
+
sound.load(new URLRequest(base + '/music.mp3'));
|
|
98
|
+
await ready;
|
|
99
|
+
const channel = sound.play();
|
|
100
|
+
await new Promise(resolve => channel.addEventListener('soundComplete', resolve));
|
|
101
|
+
return [picture.width, picture.height, picture.bitmapData.getPixel32(0, 0), movie.totalFrames];
|
|
102
|
+
})()`);
|
|
103
|
+
assert.deepEqual(placeholders, [1, 1, 0, 2]);
|
|
104
|
+
assert.deepEqual(seen, []);
|
|
105
|
+
} else assert.deepEqual(seen, [['GET', '/boot'], ['POST', '/post']]);
|
|
106
|
+
const dialog = "document.querySelector('#movie-link-prompt')";
|
|
107
|
+
const navigate = pathname => '__swoof_swflib.builtins.navigateToURL(new URLRequest(' + JSON.stringify(origin + pathname) + '))';
|
|
108
|
+
await until(dialog + '?.open');
|
|
109
|
+
await js(navigate('/while-pending'));
|
|
110
|
+
assert.equal(await js(dialog + ".querySelector('bdi').textContent"), origin + '/first-link');
|
|
111
|
+
await js(dialog + ".querySelector('[value=allow]').click()"); // Scripted clicks cannot grant permission.
|
|
112
|
+
assert.equal(await js(dialog + '.open'), true);
|
|
113
|
+
const approveLinks = mode === undefined || choice === 'allow';
|
|
114
|
+
const point = await js(`(() => { const box = ${dialog}.querySelector('[value=${approveLinks ? 'allow' : 'block'}]').getBoundingClientRect();
|
|
115
|
+
return {x:box.x + box.width/2, y:box.y + box.height/2}; })()`);
|
|
116
|
+
if (mode === 'allow') {
|
|
117
|
+
await call('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });
|
|
118
|
+
await call('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });
|
|
119
|
+
} else {
|
|
120
|
+
for (const type of ['mousePressed', 'mouseReleased']) await call('Input.dispatchMouseEvent', {
|
|
121
|
+
type, ...point, button: 'left', clickCount: 1,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
await until('!' + dialog);
|
|
125
|
+
await call('Runtime.evaluate', { expression: navigate('/next-link'), userGesture: true });
|
|
126
|
+
if (approveLinks) {
|
|
127
|
+
for (let i = 0; i < 100 && !seen.some(([, url]) => url === '/next-link'); i++) {
|
|
128
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
assert.deepEqual(seen.filter(([, url]) => url.includes('link') || url === '/while-pending')
|
|
132
|
+
.map(([, url]) => url).sort(), approveLinks ? ['/first-link', '/next-link'] : []);
|
|
133
|
+
assert.equal(await js(dialog + '?.open === true'), false);
|
|
134
|
+
if (!standalone) {
|
|
135
|
+
assert.equal(await js("['camera','microphone','geolocation','display-capture','clipboard-read','payment','usb'].every(feature => !document.featurePolicy.allowsFeature(feature))"), true);
|
|
136
|
+
const local = await js(`(async () => {
|
|
137
|
+
const loader = new URLLoader();
|
|
138
|
+
const complete = new Promise(resolve => loader.addEventListener('complete', () => resolve(loader.data.length)));
|
|
139
|
+
loader.load(new URLRequest('./movie-data.js'));
|
|
140
|
+
return complete;
|
|
141
|
+
})()`);
|
|
142
|
+
assert.ok(local > 0, 'packaged movie data remains accessible');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function openGame(projectId) {
|
|
146
|
+
const response = await fetch(studio + '/api/export/html', {
|
|
147
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
148
|
+
body: JSON.stringify({ project, projectId }),
|
|
149
|
+
});
|
|
150
|
+
assert.ok(response.ok);
|
|
151
|
+
hostedExport = await response.text();
|
|
152
|
+
await call('Page.navigate', { url: origin + '/game.html' });
|
|
153
|
+
await until('!!globalThis.__swoof?.root');
|
|
154
|
+
}
|
|
155
|
+
await openGame('save-test-one');
|
|
156
|
+
await js("localStorage.setItem('swoof.so.slot', JSON.stringify({score:99}));");
|
|
157
|
+
const save = "SharedObject.getLocal('slot')";
|
|
158
|
+
assert.equal(await js(save + '.data.score'), undefined);
|
|
159
|
+
await js("let slot = " + save + "; slot.data.score = 7; slot.flush()");
|
|
160
|
+
await openGame('save-test-two');
|
|
161
|
+
assert.equal(await js(save + '.data.score'), undefined);
|
|
162
|
+
assert.equal(await js('SharedObject.getDiskUsage()'), 0);
|
|
163
|
+
await js("let slot = " + save + "; slot.data.score = 2; slot.flush()");
|
|
164
|
+
assert.equal(await js('SharedObject.deleteAll()'), 1);
|
|
165
|
+
assert.equal(await js("JSON.parse(localStorage.getItem('swoof.so.slot')).score"), 99);
|
|
166
|
+
await openGame('save-test-one');
|
|
167
|
+
assert.equal(await js(save + '.data.score'), 7);
|
|
168
|
+
await js("window.testCopies = []; Object.defineProperty(navigator, 'clipboard', { value: {writeText: async value => testCopies.push(value)} });");
|
|
169
|
+
await js("System.setClipboard('background')");
|
|
170
|
+
assert.deepEqual(await js('testCopies'), []);
|
|
171
|
+
await call('Runtime.evaluate', { expression: "System.setClipboard('clicked')", userGesture: true });
|
|
172
|
+
assert.deepEqual(await js('testCopies'), ['clicked']);
|
|
173
|
+
} finally { remote.close(); }
|
|
174
|
+
}
|