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,109 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function verifyMedia({ js, click, change, scrub, pixel, exportProject }) {
|
|
4
|
+
const until = async expression => {
|
|
5
|
+
for (let i = 0; i < 150; i++) {
|
|
6
|
+
if (await js(expression)) return;
|
|
7
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
8
|
+
}
|
|
9
|
+
throw new Error('Timed out: ' + expression);
|
|
10
|
+
};
|
|
11
|
+
const load = async project => {
|
|
12
|
+
await click('#import-project');
|
|
13
|
+
await change('project-io-textarea', JSON.stringify(project));
|
|
14
|
+
await click('#project-io-submit');
|
|
15
|
+
await until("!document.querySelector('#project-io-dialog').open");
|
|
16
|
+
};
|
|
17
|
+
await click('#stop-button');
|
|
18
|
+
await load({ stage: { width: 800, height: 450, frameRate: 24, background: '#000000' },
|
|
19
|
+
scenes: [{ name: 'Local media', durationFrames: 100, elements: [] }] });
|
|
20
|
+
await click('#tab-library');
|
|
21
|
+
await js(`(async () => {
|
|
22
|
+
const canvas = document.createElement('canvas'); canvas.width=80; canvas.height=40;
|
|
23
|
+
const c = canvas.getContext('2d'); c.fillStyle='red'; c.fillRect(0,0,80,40);
|
|
24
|
+
c.fillStyle='blue'; c.fillRect(20,0,40,40);
|
|
25
|
+
const png = await new Promise(done => canvas.toBlob(done, 'image/png'));
|
|
26
|
+
const wav = new ArrayBuffer(44 + 16000), view = new DataView(wav);
|
|
27
|
+
const tag = (pos,s) => [...s].forEach((ch,i) => view.setUint8(pos+i,ch.charCodeAt(0)));
|
|
28
|
+
tag(0,'RIFF'); view.setUint32(4,36+16000,true); tag(8,'WAVE'); tag(12,'fmt ');
|
|
29
|
+
view.setUint32(16,16,true); view.setUint16(20,1,true); view.setUint16(22,1,true);
|
|
30
|
+
view.setUint32(24,8000,true); view.setUint32(28,16000,true); view.setUint16(32,2,true);
|
|
31
|
+
view.setUint16(34,16,true); tag(36,'data'); view.setUint32(40,16000,true);
|
|
32
|
+
for(let i=0;i<8000;i++) view.setInt16(44+2*i,Math.sin(i/10)*1000,true);
|
|
33
|
+
const transfer=new DataTransfer();
|
|
34
|
+
transfer.items.add(new File([png],'blocks.png',{type:'image/png'}));
|
|
35
|
+
transfer.items.add(new File([wav],'tone.wav'));
|
|
36
|
+
const input=document.querySelector('#media-files'); input.files=transfer.files; input.dispatchEvent(new Event('change'));
|
|
37
|
+
})()`);
|
|
38
|
+
await until("document.querySelector('#media-library').options.length === 2 && !document.querySelector('#media-import').disabled");
|
|
39
|
+
await click('#media-place');
|
|
40
|
+
assert.deepEqual(await pixel(365, 223), [255, 0, 0, 255]);
|
|
41
|
+
assert.deepEqual(await pixel(401, 223), [0, 0, 255, 255]);
|
|
42
|
+
await js(`{ const field=document.querySelector('[data-property=height]'); field.value=80; field.dispatchEvent(new Event('change',{bubbles:true})); }`);
|
|
43
|
+
assert.deepEqual(await pixel(406, 195), [0, 0, 0, 255]);
|
|
44
|
+
await change('bitmap-fit', 'cover');
|
|
45
|
+
assert.deepEqual(await pixel(365, 195), [0, 0, 255, 255]);
|
|
46
|
+
await change('bitmap-crop-x', 0);
|
|
47
|
+
assert.deepEqual(await pixel(365, 195), [255, 0, 0, 255], 'The crop can be aligned with the left edge');
|
|
48
|
+
await change('bitmap-fit', 'stretch');
|
|
49
|
+
assert.deepEqual(await pixel(365, 195), [255, 0, 0, 255]);
|
|
50
|
+
await scrub(5);
|
|
51
|
+
const audioId = await js("document.querySelector('#media-library').options[1].value");
|
|
52
|
+
await change('media-library', audioId);
|
|
53
|
+
await click('#media-place');
|
|
54
|
+
assert.equal(await js("document.querySelector('#audio-start').value"), '5');
|
|
55
|
+
await change('audio-end', 64);
|
|
56
|
+
await click('#audio-loop');
|
|
57
|
+
const saved = await exportProject();
|
|
58
|
+
assert.equal(saved.assets.length, 2);
|
|
59
|
+
assert.equal(saved.scenes[0].audioClips[0].loop, true);
|
|
60
|
+
const broken = structuredClone(saved);
|
|
61
|
+
broken.assets.find(asset => asset.kind === 'audio').data = 'data:audio/wav;base64,AQ==';
|
|
62
|
+
await click('#import-project');
|
|
63
|
+
await change('project-io-textarea', JSON.stringify(broken));
|
|
64
|
+
await click('#project-io-submit');
|
|
65
|
+
await until("!document.querySelector('#project-io-error').hidden");
|
|
66
|
+
assert.match(await js("document.querySelector('#project-io-error').textContent"), /decode tone.wav/);
|
|
67
|
+
await click('#project-io-close');
|
|
68
|
+
assert.deepEqual(await exportProject(), saved);
|
|
69
|
+
await load(saved);
|
|
70
|
+
assert.deepEqual(await exportProject(), saved);
|
|
71
|
+
assert.deepEqual(await pixel(365, 195), [255, 0, 0, 255]);
|
|
72
|
+
await click('.audio-span');
|
|
73
|
+
assert.equal(await js("document.querySelector('#timeline-audio').value"), saved.scenes[0].audioClips[0].id);
|
|
74
|
+
await js(`{
|
|
75
|
+
const proto=AudioBufferSourceNode.prototype, start=proto.start, stop=proto.stop;
|
|
76
|
+
window.mediaCalls=[];
|
|
77
|
+
proto.start=function(...args){window.mediaCalls.push(['start',args[1],this.loop,this.buffer.duration]);return start.apply(this,args);};
|
|
78
|
+
proto.stop=function(...args){window.mediaCalls.push(args.length ? ['scheduledStop',args[0]] : ['stop']);return stop.apply(this,args);};
|
|
79
|
+
window.restoreMedia=()=>{proto.start=start;proto.stop=stop;};
|
|
80
|
+
}`);
|
|
81
|
+
try {
|
|
82
|
+
await scrub(17);
|
|
83
|
+
assert.deepEqual(await js('mediaCalls'), [], 'Authoring stays silent');
|
|
84
|
+
await click('#play-button');
|
|
85
|
+
let calls = await js('mediaCalls');
|
|
86
|
+
assert.equal(calls[0][0], 'start');
|
|
87
|
+
assert.ok(Math.abs(calls[0][1] - 0.5) < .001 && Math.abs(calls[0][3] - 1) < .001);
|
|
88
|
+
assert.equal(calls[0][2], true);
|
|
89
|
+
await click('#play-button');
|
|
90
|
+
assert.deepEqual(await js('mediaCalls.at(-1)'), ['stop']);
|
|
91
|
+
await click('#stop-button');
|
|
92
|
+
await scrub(60);
|
|
93
|
+
await click('#play-button');
|
|
94
|
+
calls = await js('mediaCalls');
|
|
95
|
+
const resumed = calls.findLast(call => call[0] === 'start');
|
|
96
|
+
assert.ok(Math.abs(resumed[1] - (55 / 24 % 1)) < .001);
|
|
97
|
+
await until("Number(document.querySelector('#playhead').value) > 64");
|
|
98
|
+
assert.deepEqual(await js('mediaCalls.at(-1)'), ['stop']);
|
|
99
|
+
await click('#stop-button');
|
|
100
|
+
} finally { await js('restoreMedia()'); }
|
|
101
|
+
await click('.audio-span');
|
|
102
|
+
await click('#audio-remove');
|
|
103
|
+
await change('media-library', audioId);
|
|
104
|
+
await click('#media-remove');
|
|
105
|
+
assert.equal((await exportProject()).assets.length, 1);
|
|
106
|
+
await click('#undo');
|
|
107
|
+
await click('#undo');
|
|
108
|
+
assert.deepEqual(await exportProject(), saved);
|
|
109
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function verifyPaintTools({ click, change, drag, js, pixel, exportProject, scrub }) {
|
|
4
|
+
const load = async project => {
|
|
5
|
+
await click('#import-project');
|
|
6
|
+
await change('project-io-textarea', JSON.stringify(project));
|
|
7
|
+
await click('#project-io-submit');
|
|
8
|
+
};
|
|
9
|
+
const tool = async (menu, name) => {
|
|
10
|
+
await click('.' + menu + '-tools summary');
|
|
11
|
+
await click('[data-tool="' + name + '"]');
|
|
12
|
+
};
|
|
13
|
+
const project = { stage: { width: 800, height: 450, frameRate: 24, background: '#ffffff' },
|
|
14
|
+
scenes: [{ name: 'Paint', durationFrames: 4, elements: [] }] };
|
|
15
|
+
await load(project);
|
|
16
|
+
await tool('shape', 'star');
|
|
17
|
+
await drag(110, 60, 220, 160);
|
|
18
|
+
await change('star-points', '8');
|
|
19
|
+
await change('star-radius', '70');
|
|
20
|
+
await tool('shape', 'roundedRectangle');
|
|
21
|
+
await drag(290, 100, 430, 210);
|
|
22
|
+
await change('corner-radius', '30');
|
|
23
|
+
await tool('paint', 'bucket');
|
|
24
|
+
await change('paint-color', '#ee3311', 'input');
|
|
25
|
+
await drag(360, 155);
|
|
26
|
+
assert.deepEqual(await pixel(365, 155), [238, 51, 17, 255]);
|
|
27
|
+
await tool('paint', 'ink');
|
|
28
|
+
await change('paint-color', '#1122cc', 'input');
|
|
29
|
+
await change('paint-size', '12');
|
|
30
|
+
await drag(360, 155);
|
|
31
|
+
await tool('paint', 'eyedropper');
|
|
32
|
+
await drag(360, 155);
|
|
33
|
+
assert.equal(await js("document.querySelector('#paint-color').value"), '#ee3311');
|
|
34
|
+
await drag(165, 110);
|
|
35
|
+
await change('gradient-type', 'linear');
|
|
36
|
+
await tool('paint', 'gradientTransform');
|
|
37
|
+
await drag(165, 110, 190, 120);
|
|
38
|
+
await tool('paint', 'pencil');
|
|
39
|
+
await drag(100, 240, 180, 270);
|
|
40
|
+
await tool('paint', 'brush');
|
|
41
|
+
await drag(100, 310, 220, 310);
|
|
42
|
+
assert.deepEqual(await pixel(148, 310), [238, 51, 17, 255]);
|
|
43
|
+
await scrub(2);
|
|
44
|
+
await tool('paint', 'eraser');
|
|
45
|
+
await drag(148, 290, 148, 330);
|
|
46
|
+
assert.deepEqual(await pixel(148, 310), [255, 255, 255, 255]);
|
|
47
|
+
assert.deepEqual(await pixel(170, 310), [238, 51, 17, 255]);
|
|
48
|
+
await click('#undo');
|
|
49
|
+
assert.deepEqual(await pixel(148, 310), [238, 51, 17, 255]);
|
|
50
|
+
await click('#redo');
|
|
51
|
+
const saved = await exportProject();
|
|
52
|
+
const [star, rectangle, pencil, brush] = saved.scenes[0].elements;
|
|
53
|
+
assert.deepEqual([star.starPoints, star.starRadius], [8, 70]);
|
|
54
|
+
assert.ok(star.gradient.matrix.a > 0);
|
|
55
|
+
assert.deepEqual([rectangle.cornerRadius, rectangle.strokeWidth, rectangle.stroke], [30, 12, '#1122cc']);
|
|
56
|
+
assert.equal(pencil.closed, false);
|
|
57
|
+
assert.equal(brush.closed, true);
|
|
58
|
+
assert.ok(brush.keyframes.find(k => k.frame === 2).erasures.length);
|
|
59
|
+
await load(saved);
|
|
60
|
+
await scrub(1);
|
|
61
|
+
assert.deepEqual(await pixel(148, 310), [238, 51, 17, 255]);
|
|
62
|
+
await scrub(2);
|
|
63
|
+
assert.deepEqual(await pixel(148, 310), [255, 255, 255, 255]);
|
|
64
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
const PNG = 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVR4nGP4z8DwHwyBNIP+fwYGBgBG4AX7NBl3wQAAAABJRU5ErkJggg==';
|
|
5
|
+
|
|
6
|
+
export async function verifyProjects({ call, js, click, change, key, dialogs, game }) {
|
|
7
|
+
const until = async (expression, message = expression, evaluate = js) => {
|
|
8
|
+
for (let i = 0; i < 200; i++) {
|
|
9
|
+
if (await evaluate(expression)) return;
|
|
10
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
11
|
+
}
|
|
12
|
+
assert.fail(`Timed out waiting for ${message}`);
|
|
13
|
+
};
|
|
14
|
+
const api = path => js(`fetch(${JSON.stringify(path)}).then(r => r.json())`);
|
|
15
|
+
const state = () => js(`({
|
|
16
|
+
dirty: document.querySelector('#save-project').dataset.dirty === 'true',
|
|
17
|
+
title: document.title,
|
|
18
|
+
label: document.querySelector('#project-state').textContent,
|
|
19
|
+
})`);
|
|
20
|
+
const reload = async () => {
|
|
21
|
+
const before = await js('performance.timeOrigin');
|
|
22
|
+
await call('Page.reload');
|
|
23
|
+
for (let i = 0; i < 200; i++) {
|
|
24
|
+
if (await js(`performance.timeOrigin !== ${before} && document.readyState === 'complete' && !!document.querySelector('#stage')?.dataset.tool`).catch(() => false)) break;
|
|
25
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
await js(`window.projectWrites = []; window.originalFetch = window.fetch;
|
|
30
|
+
window.fetch = (url, init) => {
|
|
31
|
+
if (init?.body && String(url).startsWith('/api/projects')) {
|
|
32
|
+
projectWrites.push({ method: init.method, url: String(url), encoding: new Headers(init.headers).get('content-encoding') });
|
|
33
|
+
}
|
|
34
|
+
return originalFetch(url, init);
|
|
35
|
+
}`);
|
|
36
|
+
|
|
37
|
+
// Start from a clean example, then save it as a server project.
|
|
38
|
+
await click('#browse-examples');
|
|
39
|
+
await click('[data-example="01-space-mission.json"]');
|
|
40
|
+
await until("document.querySelector('#project-state').textContent === 'Untitled project'");
|
|
41
|
+
assert.equal((await state()).dirty, false);
|
|
42
|
+
await click('#projects-button');
|
|
43
|
+
assert.equal(await js("document.querySelector('#projects-dialog').open"), true);
|
|
44
|
+
await change('project-name', 'Mission Control', 'input');
|
|
45
|
+
await click('#project-save-as');
|
|
46
|
+
await until("!document.querySelector('#projects-dialog').open", 'Save as to finish');
|
|
47
|
+
let current = await state();
|
|
48
|
+
assert.equal(current.dirty, false);
|
|
49
|
+
assert.equal(current.title, 'Mission Control — Swoof Studio');
|
|
50
|
+
assert.equal(current.label, 'Mission Control, saved');
|
|
51
|
+
const list = await api('/api/projects');
|
|
52
|
+
const id = list.projects.find(project => project.name === 'Mission Control').id;
|
|
53
|
+
assert.equal((await api(`/api/projects/${id}`)).revision, 1);
|
|
54
|
+
|
|
55
|
+
// Opening the next project directly from a running scripted Preview must expose its stage.
|
|
56
|
+
const scripted = {
|
|
57
|
+
stage: { width: 200, height: 150, frameRate: 12, background: '#cc3300' },
|
|
58
|
+
scenes: [{ id: 'scene', name: 'Red stage', durationFrames: 1, elements: [],
|
|
59
|
+
events: [{ trigger: 'frameEnter', frame: 1, actions: [{ type: 'script', script: 'stop' }] }] }],
|
|
60
|
+
scripts: [{ id: 'stop', name: 'Stop', language: 'actionscript', swfVersion: 8, code: 'stop();' }],
|
|
61
|
+
};
|
|
62
|
+
const red = await js(`fetch('/api/projects', { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
63
|
+
body: ${JSON.stringify(JSON.stringify({ name: 'Scripted stage', project: scripted }))} }).then(r => r.json())`);
|
|
64
|
+
const open = async projectId => {
|
|
65
|
+
await click('#projects-button');
|
|
66
|
+
await until(`!!document.querySelector('[data-open="${projectId}"]')`);
|
|
67
|
+
await click(`[data-open="${projectId}"]`);
|
|
68
|
+
await until("!document.querySelector('#projects-dialog').open");
|
|
69
|
+
};
|
|
70
|
+
const corner = () => js("Array.from(document.querySelector('#stage').getContext('2d').getImageData(0, 0, 1, 1).data)");
|
|
71
|
+
const missionCorner = await corner();
|
|
72
|
+
await open(red.id);
|
|
73
|
+
assert.deepEqual(await corner(), [204, 51, 0, 255]);
|
|
74
|
+
await click('#preview-button');
|
|
75
|
+
await until("!!globalThis.__swoof?.root", 'the running scripted Preview', game);
|
|
76
|
+
assert.equal(await js("document.querySelector('#swf-player').contentDocument"), null, 'Preview is isolated from the editor');
|
|
77
|
+
await open(id);
|
|
78
|
+
assert.equal(await js("document.querySelector('#swf-player').hidden"), true, 'the previous movie no longer covers the editor');
|
|
79
|
+
assert.deepEqual(await corner(), missionCorner, 'the reopened project appears immediately');
|
|
80
|
+
|
|
81
|
+
// Editing marks the project unsaved; Ctrl/Cmd+S saves only the changed scene.
|
|
82
|
+
await change('scene-name', 'Launch Pad');
|
|
83
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'true'");
|
|
84
|
+
assert.match((await state()).title, /^• Mission Control/);
|
|
85
|
+
await key('s', 'KeyS', 83, 2);
|
|
86
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'false'", 'Ctrl+S to save');
|
|
87
|
+
const saved = await api(`/api/projects/${id}`);
|
|
88
|
+
assert.equal(saved.revision, 2);
|
|
89
|
+
assert.equal(saved.project.scenes[0].name, 'Launch Pad');
|
|
90
|
+
|
|
91
|
+
const writes = await js('window.projectWrites');
|
|
92
|
+
for (const [method, url] of [['POST', '/api/projects'], ['PUT', `/api/projects/${id}`], ['POST', `/api/projects/${id}/journal`]]) {
|
|
93
|
+
assert.ok(writes.some(item => item.url === url && item.method === method && item.encoding === 'gzip'), `${method} ${url} was compressed`);
|
|
94
|
+
}
|
|
95
|
+
await js('window.fetch = window.originalFetch');
|
|
96
|
+
await open(red.id);
|
|
97
|
+
await js('performance.clearResourceTimings()');
|
|
98
|
+
await open(id);
|
|
99
|
+
const transferred = await js(`performance.getEntriesByType('resource')
|
|
100
|
+
.filter(entry => entry.name.includes('/api/projects/${id}/parts/') && entry.transferSize > 0)
|
|
101
|
+
.map(entry => entry.name.split('/').pop())`);
|
|
102
|
+
assert.deepEqual(transferred, [saved.parts.scenes[saved.project.scenes[0].id]], 'only the edited scene crossed the network');
|
|
103
|
+
|
|
104
|
+
// Undoing back to the saved state clears the marker again.
|
|
105
|
+
await change('scene-name', 'Temporary');
|
|
106
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'true'");
|
|
107
|
+
await click('#undo');
|
|
108
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'false'", 'undo to the saved state');
|
|
109
|
+
|
|
110
|
+
// Edits are journaled in the background and recoverable after the page closes.
|
|
111
|
+
await change('scene-name', 'Recovered Pad');
|
|
112
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'true'");
|
|
113
|
+
for (let i = 0; i < 200 && !(await api(`/api/projects/${id}`)).journal.length; i++) {
|
|
114
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
115
|
+
}
|
|
116
|
+
const pending = await api(`/api/projects/${id}`);
|
|
117
|
+
assert.equal(pending.journal.length, 1);
|
|
118
|
+
assert.equal(pending.journal[0].base, 2);
|
|
119
|
+
const before = dialogs.length;
|
|
120
|
+
await reload();
|
|
121
|
+
assert.ok(dialogs.slice(before).some(dialog => dialog.type === 'beforeunload'), 'unload warning for unsaved changes');
|
|
122
|
+
assert.equal((await state()).label, 'Untitled project');
|
|
123
|
+
await click('#projects-button');
|
|
124
|
+
await until(`!!document.querySelector('[data-open="${id}"]')`);
|
|
125
|
+
await click(`[data-open="${id}"]`);
|
|
126
|
+
await until("document.querySelector('#recovery-dialog').open", 'the recovery prompt');
|
|
127
|
+
assert.match(await js("document.querySelector('#recovery-description').textContent"), /1 unsaved change/);
|
|
128
|
+
await click('#recovery-accept');
|
|
129
|
+
await until("document.querySelector('#scene-name').value === 'Recovered Pad'", 'recovered edits');
|
|
130
|
+
current = await state();
|
|
131
|
+
assert.equal(current.dirty, true);
|
|
132
|
+
assert.equal(current.label, 'Mission Control, unsaved changes');
|
|
133
|
+
await key('s', 'KeyS', 83, 4);
|
|
134
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'false'", 'Cmd+S to save');
|
|
135
|
+
assert.equal((await api(`/api/projects/${id}`)).journal.length, 0);
|
|
136
|
+
|
|
137
|
+
// Discarding recovery opens the last saved version.
|
|
138
|
+
await change('scene-name', 'Discard me');
|
|
139
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'true'");
|
|
140
|
+
for (let i = 0; i < 200 && !(await api(`/api/projects/${id}`)).journal.length; i++) {
|
|
141
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
142
|
+
}
|
|
143
|
+
await reload();
|
|
144
|
+
await click('#projects-button');
|
|
145
|
+
await until(`!!document.querySelector('[data-open="${id}"]')`);
|
|
146
|
+
await click(`[data-open="${id}"]`);
|
|
147
|
+
await until("document.querySelector('#recovery-dialog').open");
|
|
148
|
+
await click('#recovery-discard');
|
|
149
|
+
await until("document.querySelector('#scene-name').value === 'Recovered Pad'", 'the saved version');
|
|
150
|
+
assert.equal((await state()).dirty, false);
|
|
151
|
+
assert.equal((await api(`/api/projects/${id}`)).journal.length, 0);
|
|
152
|
+
|
|
153
|
+
// A save from another tab makes this tab's save a conflict instead of an overwrite.
|
|
154
|
+
const other = await api(`/api/projects/${id}`);
|
|
155
|
+
const body = { name: other.name, stage: other.project.stage, assets: [],
|
|
156
|
+
scenes: other.project.scenes.map(scene => ({ id: scene.id, data: { ...scene, name: scene.name + ' (other tab)' } })), symbols: [] };
|
|
157
|
+
assert.equal(await js(`fetch('/api/projects/${id}', { method: 'PUT', headers: { 'Content-Type': 'application/json', 'If-Match': '"${other.revision}"' },
|
|
158
|
+
body: ${JSON.stringify(JSON.stringify(body))} }).then(r => r.status)`), 200);
|
|
159
|
+
await change('scene-name', 'Mine');
|
|
160
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'true'");
|
|
161
|
+
await click('#save-project');
|
|
162
|
+
await until("document.querySelector('#status-message').textContent.includes('saved elsewhere')", 'the conflict message');
|
|
163
|
+
assert.equal((await api(`/api/projects/${id}`)).project.scenes[0].name, 'Recovered Pad (other tab)');
|
|
164
|
+
|
|
165
|
+
// Reopen the other tab's version, then upload media by dropping files on the Library.
|
|
166
|
+
await click('#projects-button');
|
|
167
|
+
await until(`!!document.querySelector('[data-open="${id}"]')`);
|
|
168
|
+
await click(`[data-open="${id}"]`);
|
|
169
|
+
await until("document.querySelector('#scene-name').value === 'Recovered Pad (other tab)'");
|
|
170
|
+
await js("document.querySelector('[role=tab]#tab-library')?.click()");
|
|
171
|
+
await js(`(() => {
|
|
172
|
+
const bytes = Uint8Array.from(atob(${JSON.stringify(PNG)}), c => c.charCodeAt(0));
|
|
173
|
+
window.uploadMeters = [];
|
|
174
|
+
new MutationObserver(records => {
|
|
175
|
+
for (const record of records) for (const row of record.addedNodes) {
|
|
176
|
+
window.uploadMeters.push({ name: row.textContent, meter: row.querySelector('progress') });
|
|
177
|
+
}
|
|
178
|
+
}).observe(document.querySelector('#media-transfers'), { childList: true });
|
|
179
|
+
const transfer = new DataTransfer();
|
|
180
|
+
transfer.items.add(new File([bytes], 'dot.png', { type: 'image/png' }));
|
|
181
|
+
const panel = document.querySelector('#library-panel');
|
|
182
|
+
panel.dispatchEvent(new DragEvent('dragover', { dataTransfer: transfer, bubbles: true, cancelable: true }));
|
|
183
|
+
panel.dispatchEvent(new DragEvent('drop', { dataTransfer: transfer, bubbles: true, cancelable: true }));
|
|
184
|
+
})()`);
|
|
185
|
+
await until("document.querySelector('#media-library').options[0]?.text === 'dot.png'", 'the dropped upload');
|
|
186
|
+
assert.deepEqual(await js("window.uploadMeters.map(({name, meter}) => [name, meter.value, meter.max])"),
|
|
187
|
+
[['dot.png', Buffer.from(PNG, 'base64').length, Buffer.from(PNG, 'base64').length]]);
|
|
188
|
+
assert.equal(await js("document.querySelector('#media-transfers').childElementCount"), 0);
|
|
189
|
+
const assets = (await api(`/api/projects/${id}`)).project.assets;
|
|
190
|
+
assert.equal(assets, undefined, 'uploads are stored but not saved until Save');
|
|
191
|
+
assert.match(await js("document.querySelector('#media-thumbnail').getAttribute('src')"), new RegExp(`^/api/projects/${id}/assets/[0-9a-f]{64}$`));
|
|
192
|
+
await click('#media-place');
|
|
193
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'true'");
|
|
194
|
+
await click('#save-project');
|
|
195
|
+
await until("document.querySelector('#save-project').dataset.dirty === 'false'");
|
|
196
|
+
const stored = (await api(`/api/projects/${id}`)).project;
|
|
197
|
+
assert.equal(stored.assets.length, 1);
|
|
198
|
+
assert.equal(stored.assets[0].type, 'image/png');
|
|
199
|
+
assert.ok(stored.scenes[0].elements.some(element => element.type === 'bitmap' && element.assetId === stored.assets[0].id));
|
|
200
|
+
|
|
201
|
+
// Export embeds server media so the JSON stays portable.
|
|
202
|
+
await click('#export-project');
|
|
203
|
+
await until("document.querySelector('#project-io-textarea').value.length > 0", 'the export to embed media');
|
|
204
|
+
const exported = JSON.parse(await js("document.querySelector('#project-io-textarea').value"));
|
|
205
|
+
await click('#project-io-close');
|
|
206
|
+
assert.equal(exported.assets[0].data, `data:image/png;base64,${PNG}`);
|
|
207
|
+
assert.equal(exported.assets[0].hash, undefined);
|
|
208
|
+
|
|
209
|
+
// Importing that file creates a fresh unsaved project; Save as stores its embedded media.
|
|
210
|
+
await click('#import-project');
|
|
211
|
+
await change('project-io-textarea', JSON.stringify(exported));
|
|
212
|
+
await click('#project-io-submit');
|
|
213
|
+
await until("document.querySelector('#project-state').textContent === 'Untitled project'");
|
|
214
|
+
await click('#projects-button');
|
|
215
|
+
await change('project-name', 'Mission Copy', 'input');
|
|
216
|
+
await click('#project-save-as');
|
|
217
|
+
await until("!document.querySelector('#projects-dialog').open");
|
|
218
|
+
const copy = (await api('/api/projects')).projects.find(project => project.name === 'Mission Copy');
|
|
219
|
+
const copied = await api(`/api/projects/${copy.id}`);
|
|
220
|
+
assert.equal(copied.project.assets[0].hash, stored.assets[0].hash);
|
|
221
|
+
assert.equal(await js("document.querySelector('#media-thumbnail').getAttribute('src') ?? ''").then(src => src.startsWith('data:') || src.startsWith('/api/')), true);
|
|
222
|
+
|
|
223
|
+
// Delete from the Projects dialog.
|
|
224
|
+
await click('#projects-button');
|
|
225
|
+
await until(`!!document.querySelector('[data-remove="${copy.id}"]')`);
|
|
226
|
+
await click(`[data-remove="${copy.id}"]`);
|
|
227
|
+
await until(`!document.querySelector('[data-remove="${copy.id}"]')`);
|
|
228
|
+
assert.equal((await api('/api/projects')).projects.some(project => project.id === copy.id), false);
|
|
229
|
+
const oldCanvas = await js("document.querySelector('#stage').toDataURL()");
|
|
230
|
+
const { root } = await call('DOM.getDocument');
|
|
231
|
+
const { nodeId } = await call('DOM.querySelector', { nodeId: root.nodeId, selector: '#swf-file' });
|
|
232
|
+
await call('DOM.setFileInputFiles', { nodeId, files: [fileURLToPath(new URL('../../demos/neon-grid.swf', import.meta.url))] });
|
|
233
|
+
await until("document.querySelector('#swf-report-dialog').open", 'the SWF conversion report');
|
|
234
|
+
const report = await js("document.querySelector('#swf-report-summary').textContent");
|
|
235
|
+
assert.match(report, /neon-grid\.swf.*Converted.*125 objects/);
|
|
236
|
+
assert.equal((await state()).label, 'neon-grid, saved');
|
|
237
|
+
await js("new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))");
|
|
238
|
+
assert.notEqual(await js("document.querySelector('#stage').toDataURL()"), oldCanvas, 'the new movie draws before Preview');
|
|
239
|
+
await click('#swf-report-close');
|
|
240
|
+
await js("document.querySelector('#swf-report-open').click()");
|
|
241
|
+
assert.equal(await js("document.querySelector('#swf-report-dialog').open"), true);
|
|
242
|
+
assert.equal(await js("document.querySelector('#swf-report-summary').textContent"), report);
|
|
243
|
+
await click('#swf-report-close');
|
|
244
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { compileActionScript } from '../../swf2js/compiler/index.js';
|
|
3
|
+
|
|
4
|
+
// The Actions dialog opens scripts as ActionScript (studiospec/actionscript.md §4).
|
|
5
|
+
export async function verifyScriptEditing({ click, change, js, key, exportProject, game }) {
|
|
6
|
+
const stage = { width: 800, height: 450, frameRate: 24, background: '#000000' };
|
|
7
|
+
const base64 = bytes => Buffer.from(bytes).toString('base64');
|
|
8
|
+
// A value read, then a statement, then the value used: no ActionScript form.
|
|
9
|
+
const push = text => [0x96, text.length + 2, 0, 0, ...Buffer.from(text), 0];
|
|
10
|
+
const opaque = [...push('v'), 0x1c, ...push('v'), ...push('w'), 0x1d, 0x26, 0];
|
|
11
|
+
const scripts = [
|
|
12
|
+
{ id: 'hello', name: 'Hello', language: 'avm1', swfVersion: 8, bytecode: base64(compileActionScript('trace("hi");')) },
|
|
13
|
+
{ id: 'opaque', name: 'Opaque', language: 'avm1', swfVersion: 6, bytecode: base64(opaque), source: '/* translated */' },
|
|
14
|
+
];
|
|
15
|
+
const scene = {
|
|
16
|
+
id: 'main', name: 'Main', durationFrames: 4, elements: [],
|
|
17
|
+
// `hello` also runs on frame 3: an edit on frame 1 must not change frame 3.
|
|
18
|
+
events: [{ trigger: 'frameEnter', frame: 1, actions: [{ type: 'script', script: 'hello' }, { type: 'script', script: 'opaque' }] },
|
|
19
|
+
{ trigger: 'frameEnter', frame: 3, actions: [{ type: 'script', script: 'hello' }] }],
|
|
20
|
+
};
|
|
21
|
+
const until = async (expression, message, evaluate = js) => {
|
|
22
|
+
for (let tries = 0; tries < 100; tries++) {
|
|
23
|
+
if (await evaluate(expression)) return;
|
|
24
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
25
|
+
}
|
|
26
|
+
assert.fail(message);
|
|
27
|
+
};
|
|
28
|
+
const typeCode = code => js(`{ const area = document.querySelector('#script-code');
|
|
29
|
+
area.value = ${JSON.stringify(code)}; area.dispatchEvent(new Event('input')); }`);
|
|
30
|
+
const editButton = index => `#event-actions li:nth-child(${index}) [aria-label^="Edit script"]`;
|
|
31
|
+
|
|
32
|
+
await click('#stop-button');
|
|
33
|
+
await click('#import-project');
|
|
34
|
+
await change('project-io-textarea', JSON.stringify({ stage, scenes: [scene], symbols: [], scripts }));
|
|
35
|
+
await click('#project-io-submit');
|
|
36
|
+
await click('.event-marker[data-frame="1"]');
|
|
37
|
+
assert.equal(await js("document.querySelector('#event-editor').open"), true);
|
|
38
|
+
|
|
39
|
+
// An imported script: decompiled, checked as it is typed, kept as code once changed.
|
|
40
|
+
await click(editButton(1));
|
|
41
|
+
await until("!document.querySelector('#script-code').readOnly", 'the script loads as ActionScript');
|
|
42
|
+
assert.match(await js("document.querySelector('#script-editor h2').textContent"), /used in 2 places/);
|
|
43
|
+
assert.equal(await js("document.querySelector('#script-code').value"), 'trace("hi");\n');
|
|
44
|
+
await until("document.querySelector('#script-check').textContent === 'No errors.'", 'the script is checked');
|
|
45
|
+
await typeCode('trace("bye"');
|
|
46
|
+
await until("document.querySelector('#script-check').textContent.startsWith('Line 1, column 12')", 'errors show their line and column');
|
|
47
|
+
await typeCode('trace("bye");');
|
|
48
|
+
await until("document.querySelector('#script-check').textContent === 'No errors.'", 'fixed code checks clean');
|
|
49
|
+
await click('#script-done');
|
|
50
|
+
assert.match(await js("document.querySelector('#event-actions li').textContent"), /Hello \(edited\)/);
|
|
51
|
+
// Editing the copy again changes it in place.
|
|
52
|
+
await click(editButton(1));
|
|
53
|
+
await until("!document.querySelector('#script-code').readOnly", 'the edited copy reopens');
|
|
54
|
+
assert.equal(await js("document.querySelector('#script-code').value"), 'trace("bye");');
|
|
55
|
+
assert.doesNotMatch(await js("document.querySelector('#script-editor h2').textContent"), /used in/);
|
|
56
|
+
await click('#script-cancel');
|
|
57
|
+
|
|
58
|
+
// Bytecode with no ActionScript form is shown read-only.
|
|
59
|
+
await click(editButton(2));
|
|
60
|
+
await until("document.querySelector('#script-editor-note').textContent.includes(\"can't be shown\")", 'the reason is shown');
|
|
61
|
+
assert.equal(await js("document.querySelector('#script-code').readOnly"), true);
|
|
62
|
+
assert.equal(await js("document.querySelector('#script-code').value"), '/* translated */');
|
|
63
|
+
await click('#script-cancel');
|
|
64
|
+
|
|
65
|
+
await click('#event-save');
|
|
66
|
+
const saved = await exportProject();
|
|
67
|
+
const copy = saved.scripts[2];
|
|
68
|
+
assert.deepEqual(saved.scripts, [...scripts,
|
|
69
|
+
{ id: copy.id, name: 'Hello', language: 'actionscript', swfVersion: 8, code: 'trace("bye");' }]);
|
|
70
|
+
assert.notEqual(copy.id, 'hello');
|
|
71
|
+
assert.deepEqual(saved.scenes[0].events.map(event => event.actions[0].script), [copy.id, 'hello'], 'only frame 1 runs the edit');
|
|
72
|
+
await click('#undo');
|
|
73
|
+
assert.deepEqual((await exportProject()).scripts, scripts, 'Undo restores the imported bytecode');
|
|
74
|
+
|
|
75
|
+
// A new script, in the project's SWF version.
|
|
76
|
+
await click('.event-marker[data-frame="1"]');
|
|
77
|
+
await click('#event-add-script');
|
|
78
|
+
await until("!document.querySelector('#script-code').readOnly", 'a new script opens empty');
|
|
79
|
+
await typeCode('stop();');
|
|
80
|
+
await click('#script-done');
|
|
81
|
+
await click('#event-save');
|
|
82
|
+
const added = await exportProject();
|
|
83
|
+
const created = added.scripts.at(-1);
|
|
84
|
+
assert.deepEqual({ ...created, id: undefined }, { id: undefined, name: 'Main frame 1', language: 'actionscript', swfVersion: 8, code: 'stop();' });
|
|
85
|
+
assert.deepEqual(added.scenes[0].events[0].actions.at(-1), { type: 'script', script: created.id });
|
|
86
|
+
|
|
87
|
+
const scriptsProject = { stage, scripts: [scripts[0]], scenes: [{ id: 'main', durationFrames: 2, elements: [
|
|
88
|
+
{ id: 'art', name: 'starButton', type: 'star', x: 100, y: 100 },
|
|
89
|
+
{ id: 'clip', name: 'clip', type: 'symbol', symbolId: 'panel', x: 300, y: 100,
|
|
90
|
+
scriptEvents: [{ on: ['load'], script: 'hello' }] },
|
|
91
|
+
{ id: 'btn', name: 'button', type: 'symbol', symbolId: 'buttonDef', x: 450, y: 100 },
|
|
92
|
+
] }], symbols: [{ id: 'panel', name: 'Panel', elements: [] }, { id: 'buttonDef', name: 'Button', button: true,
|
|
93
|
+
elements: [{ id: 'skin', type: 'ellipse' }], scriptEvents: [{ on: ['rollOver', 'keyPress'], key: 32, script: 'hello' }] }] };
|
|
94
|
+
await click('#import-project');
|
|
95
|
+
await change('project-io-textarea', JSON.stringify(scriptsProject));
|
|
96
|
+
await click('#project-io-submit');
|
|
97
|
+
const editCode = async code => {
|
|
98
|
+
await until("document.querySelector('#script-editor').open && !document.querySelector('#script-code').readOnly", 'code editor opens');
|
|
99
|
+
await typeCode(code);
|
|
100
|
+
await click('#script-done');
|
|
101
|
+
};
|
|
102
|
+
await click('[data-focus-key="object:art"]');
|
|
103
|
+
await click('#element-is-button');
|
|
104
|
+
await change('button-trigger', 'keyDown');
|
|
105
|
+
await change('button-key', 'A');
|
|
106
|
+
await change('button-action-type', 'script');
|
|
107
|
+
await editCode('_root.artRan = 7;');
|
|
108
|
+
await click('[data-focus-key="object:clip"]');
|
|
109
|
+
await click('#instance-scripts');
|
|
110
|
+
await click('#handler-list button');
|
|
111
|
+
await editCode('_root.clipRan = 1;');
|
|
112
|
+
await click('#handler-save');
|
|
113
|
+
await change('symbol-library', 'panel');
|
|
114
|
+
await click('#symbol-scripts');
|
|
115
|
+
await click('#handler-add-init');
|
|
116
|
+
await editCode('_root.initRan = 2;');
|
|
117
|
+
await click('#handler-save');
|
|
118
|
+
await change('symbol-library', 'buttonDef');
|
|
119
|
+
await click('#symbol-scripts');
|
|
120
|
+
await click('#handler-list button');
|
|
121
|
+
await editCode('_root.buttonRan = 3;');
|
|
122
|
+
await click('#handler-save');
|
|
123
|
+
const scripted = await exportProject();
|
|
124
|
+
assert.deepEqual(scripted.symbols[1].scriptEvents[0].on, ['rollOver', 'keyPress']);
|
|
125
|
+
assert.equal(scripted.symbols[1].scriptEvents[0].key, 32);
|
|
126
|
+
assert.notEqual(scripted.symbols[1].scriptEvents[0].script, scripted.scenes[0].elements[1].scriptEvents[0].script);
|
|
127
|
+
await click('#preview-button');
|
|
128
|
+
await until('globalThis.__swoof?.root?.clipRan === 1', 'edited clip handler runs in Preview', game);
|
|
129
|
+
assert.equal(await game('__swoof.root.initRan'), 2);
|
|
130
|
+
await js("document.querySelector('#swf-player').focus()");
|
|
131
|
+
await key('a', 'KeyA', 65);
|
|
132
|
+
await key(' ', 'Space', 32);
|
|
133
|
+
assert.deepEqual(await game("[__swoof.root.artRan, __swoof.root.buttonRan]"), [7, 3]);
|
|
134
|
+
await click('#stop-button');
|
|
135
|
+
|
|
136
|
+
const faulty = { id: 'fault', name: 'Player controller', language: 'actionscript', swfVersion: 8,
|
|
137
|
+
code: 'trace(hero);\ntrace(' };
|
|
138
|
+
await click('#import-project');
|
|
139
|
+
await change('project-io-textarea', JSON.stringify({ stage, scripts: [faulty], scenes: [{ id: 'main', durationFrames: 2,
|
|
140
|
+
elements: [{ id: 'player', name: 'hero', type: 'rectangle' }],
|
|
141
|
+
events: [{ trigger: 'frameEnter', frame: 1, actions: [{ type: 'script', script: 'fault' }] }] }] }));
|
|
142
|
+
await click('#project-io-submit');
|
|
143
|
+
await click('[data-focus-key="object:player"]');
|
|
144
|
+
await change('element-name', 'runner');
|
|
145
|
+
assert.match(await js("document.querySelector('#status-message').textContent"), /Player controller refers to hero/);
|
|
146
|
+
await click('#undo');
|
|
147
|
+
await click('[data-focus-key="object:player"]');
|
|
148
|
+
await click('#delete-element');
|
|
149
|
+
assert.match(await js("document.querySelector('#status-message').textContent"), /Player controller refers to hero/);
|
|
150
|
+
await click('#preview-button');
|
|
151
|
+
await until("!document.querySelector('#preview-error-script').hidden", 'Preview offers to open the faulty script');
|
|
152
|
+
await click('#preview-error-script');
|
|
153
|
+
assert.equal(await js("document.querySelector('#script-code').selectionStart"), faulty.code.length);
|
|
154
|
+
await click('#script-cancel');
|
|
155
|
+
for (const format of ['swf', 'html']) {
|
|
156
|
+
await click('#export-project');
|
|
157
|
+
await change('export-format', format);
|
|
158
|
+
await click('#export-download');
|
|
159
|
+
await until("!document.querySelector('#export-error-script').hidden", format + ' export locates its compile error');
|
|
160
|
+
await click('#export-error-script');
|
|
161
|
+
assert.equal(await js("document.querySelector('#script-editor h2').textContent"), faulty.name);
|
|
162
|
+
assert.equal(await js("document.querySelector('#script-code').selectionStart"), faulty.code.length);
|
|
163
|
+
if (format === 'swf') await click('#script-cancel');
|
|
164
|
+
}
|
|
165
|
+
const classSource = 'class game.Player { function score() { return 33; } }\nifFrameLoaded(1) _root.result = new game.Player().score();';
|
|
166
|
+
await js(`{ const transfer = new DataTransfer(); transfer.items.add(new File([${JSON.stringify(classSource)}], 'Player.as'));
|
|
167
|
+
const input = document.querySelector('#script-source-file'); input.files = transfer.files; input.dispatchEvent(new Event('change')); }`);
|
|
168
|
+
await until("document.querySelector('#script-check').textContent === 'No errors.'", 'class file checks successfully');
|
|
169
|
+
await click('#script-done');
|
|
170
|
+
await click('#preview-button');
|
|
171
|
+
await until('globalThis.__swoof?.root?.result === 33', 'the class loaded from a file runs in Preview', game);
|
|
172
|
+
await click('#stop-button');
|
|
173
|
+
|
|
174
|
+
// Leave a project without scripts for the tests that follow.
|
|
175
|
+
await click('#import-project');
|
|
176
|
+
await change('project-io-textarea', JSON.stringify({ stage, scenes: [{ id: 'main', name: 'Main', durationFrames: 4, elements: [] }], symbols: [] }));
|
|
177
|
+
await click('#project-io-submit');
|
|
178
|
+
}
|