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,107 @@
|
|
|
1
|
+
// Controls are MovieClip instances in scripted Preview. Exercise both ActionScript-facing
|
|
2
|
+
// properties/listeners and the native widget, including the first frame before it is painted.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { convertSwf } from '../server/swf-import.js';
|
|
5
|
+
import { exportProjectSwf } from '../server/swf-export.js';
|
|
6
|
+
import { CONTROL_KINDS, controlDefinitions } from '../../swooflib/control-definitions.js';
|
|
7
|
+
|
|
8
|
+
export async function verifyScriptedControls({ js, click, change, key, game }) {
|
|
9
|
+
const stage = { width: 800, height: 600, frameRate: 12, background: '#ffffff' };
|
|
10
|
+
const elements = CONTROL_KINDS.map((control, index) => {
|
|
11
|
+
const { width, height } = controlDefinitions[control];
|
|
12
|
+
const name = control[0].toLowerCase() + control.slice(1);
|
|
13
|
+
return { type: 'control', control, id: name, name, width, height, x: 80 + index % 5 * 160, y: 50 + Math.floor(index / 5) * 110,
|
|
14
|
+
...(control === 'CheckBox' && { variable: 'checked' }),
|
|
15
|
+
...(control === 'RadioButton' && { parameters: { data: 'first', selected: true } }) };
|
|
16
|
+
});
|
|
17
|
+
elements.push({ ...elements.find(element => element.control === 'RadioButton'), id: 'second', name: 'second',
|
|
18
|
+
x: 140, y: 540, parameters: { data: 'second' } });
|
|
19
|
+
const instance = { id: 'nested', name: 'nested', type: 'symbol', symbolId: 'radioPanel', x: 340, y: 540, width: 140, height: 26 };
|
|
20
|
+
const project = {
|
|
21
|
+
stage,
|
|
22
|
+
symbols: [{ id: 'radioPanel', width: 160, height: 120, elements: [
|
|
23
|
+
{ ...elements.find(element => element.control === 'RadioButton'), id: 'nestedRadio', x: 80, y: 60, parameters: { data: 'nested', selected: true } },
|
|
24
|
+
] }],
|
|
25
|
+
scenes: [{ id: 'scene', name: 'Controls', durationFrames: 2, elements: [...elements, instance],
|
|
26
|
+
events: [{ trigger: 'frameEnter', frame: 1, actions: [{ type: 'script', script: 'setup' }] },
|
|
27
|
+
{ trigger: 'click', source: 'checkBox', actions: [{ type: 'script', script: 'changed' }] }] }],
|
|
28
|
+
scripts: [{ id: 'setup', name: 'Set up controls', language: 'actionscript', swfVersion: 8,
|
|
29
|
+
code: 'stop(); checkBox.selected = true; checkBox.label = "Sound"; checkBox.addEventListener("click", function(e) { _root.heard = e.target.getValue(); });' },
|
|
30
|
+
{ id: 'changed', name: 'Checkbox clicked', language: 'actionscript', swfVersion: 8,
|
|
31
|
+
code: 'textInput.text = "Clicked";' }],
|
|
32
|
+
};
|
|
33
|
+
async function load(project) {
|
|
34
|
+
await click('#import-project');
|
|
35
|
+
await change('project-io-textarea', JSON.stringify(project));
|
|
36
|
+
await click('#project-io-submit');
|
|
37
|
+
assert.ok(await js('document.querySelector("#project-io-error").hidden'), await js('document.querySelector("#project-io-error").textContent'));
|
|
38
|
+
}
|
|
39
|
+
await load(project);
|
|
40
|
+
assert.equal(await js("document.querySelector('#preview-network').value"), 'disallow');
|
|
41
|
+
await change('preview-network', 'prompt');
|
|
42
|
+
await click('#preview-button');
|
|
43
|
+
let prompted = false;
|
|
44
|
+
for (let i = 0; i < 200 && !prompted; i++) {
|
|
45
|
+
prompted = await game("document.querySelector('#external-prompt')?.open").catch(() => false);
|
|
46
|
+
if (!prompted) await new Promise(resolve => setTimeout(resolve, 35));
|
|
47
|
+
}
|
|
48
|
+
assert.ok(prompted, 'Preview asks before starting the movie');
|
|
49
|
+
assert.equal(await game('typeof globalThis.__swoof'), 'undefined');
|
|
50
|
+
await game("document.querySelector('#external-prompt [value=disallow]').click()");
|
|
51
|
+
await change('preview-network', 'disallow');
|
|
52
|
+
let ready;
|
|
53
|
+
for (let i = 0; i < 200; i++) {
|
|
54
|
+
ready = await game('document.querySelectorAll("[data-control]").length').catch(() => 0);
|
|
55
|
+
if (ready === elements.length + 1) break;
|
|
56
|
+
await new Promise(resolve => setTimeout(resolve, 35));
|
|
57
|
+
}
|
|
58
|
+
assert.equal(ready, elements.length + 1, 'each authored control mounts inside the scripted movie');
|
|
59
|
+
const checkbox = 'document.querySelector(\'[data-control="CheckBox"] input\')';
|
|
60
|
+
assert.deepEqual(await game(`[${checkbox}.checked, ${checkbox}.getAttribute("aria-label"), __swoof.root.checked]`), [true, 'Sound', true]);
|
|
61
|
+
await game(`${checkbox}.click()`);
|
|
62
|
+
assert.deepEqual(await game('[__swoof.root.checked, __swoof.root.heard, document.querySelector(\'[data-control="TextInput"] input\').value]'), [false, false, 'Clicked']);
|
|
63
|
+
await game('__swoof.root.checked = true');
|
|
64
|
+
assert.equal(await game('__swoof.root.checkBox.getValue()'), true, 'script variable writes update the control');
|
|
65
|
+
await game(`${checkbox}.focus()`);
|
|
66
|
+
await key(' ', 'Space', 32, 0, ' ');
|
|
67
|
+
assert.equal(await game('__swoof.root.checked'), false, 'Space toggles the focused checkbox');
|
|
68
|
+
await game("document.querySelector('[data-control=RadioButton] input').focus()");
|
|
69
|
+
await key('ArrowRight', 'ArrowRight', 39);
|
|
70
|
+
assert.deepEqual(await game('[__swoof.root.radioButton.selected, __swoof.root.second.selected, __swoof.root.radioGroup.selectedData]'),
|
|
71
|
+
[false, true, 'second'], 'arrow keys select within the timeline radio group');
|
|
72
|
+
assert.equal(await game('__swoof.root.nested.radioGroup.selectedData'), 'nested', 'a nested radio group keeps its own selection');
|
|
73
|
+
await game('__swoof.root.radioGroup.selectedData = "first"');
|
|
74
|
+
assert.deepEqual(await game('[__swoof.root.radioButton.selected, __swoof.root.second.selected, __swoof.root.second.selectedData]'), [true, false, 'first']);
|
|
75
|
+
await game(`__swoof.root.comboBox.rowCount = 2;
|
|
76
|
+
document.querySelector('[data-control="ComboBox"] [role="combobox"]').click();`);
|
|
77
|
+
assert.deepEqual(await game(`(() => { const list = document.querySelector('[data-control="ComboBox"] select');
|
|
78
|
+
return [list.matches(':popover-open'), list.size, list.options.length]; })()`), [true, 2, 3]);
|
|
79
|
+
await game(`document.querySelector('[data-control="ComboBox"] select').hidePopover();
|
|
80
|
+
__swoof.root.dateField.dayNames = ['Su','Mo','Tu','We','Th','Fr','Sa'];
|
|
81
|
+
__swoof.root.dateField.firstDayOfWeek = 1;
|
|
82
|
+
document.querySelector('[data-control="DateField"] [aria-haspopup="dialog"]').click();`);
|
|
83
|
+
assert.deepEqual(await game(`[...document.querySelector('[data-control="DateField"] [role="dialog"]').querySelectorAll('span')]
|
|
84
|
+
.filter(span => span.style.gridRow === '2').map(span => span.textContent)`), ['Mo','Tu','We','Th','Fr','Sa','Su']);
|
|
85
|
+
await game(`document.querySelector('[data-control="DateField"] [role="dialog"] [aria-pressed]').click();`);
|
|
86
|
+
assert.match(await game('__swoof.root.dateField.selectedDate'), /^\d{4}-\d{2}-01$/);
|
|
87
|
+
await game('__swoof.root.comboBox.selectedIndex = 2');
|
|
88
|
+
assert.equal(await game('__swoof.root.comboBox.getValue()'), 'Item 3');
|
|
89
|
+
await game('window.firstControl = __swoof.root.comboBox; __swoof.root.gotoAndStop(2)');
|
|
90
|
+
assert.deepEqual(await game('[__swoof.root._currentframe, firstControl === __swoof.root.comboBox, __swoof.root.comboBox.selectedIndex]'),
|
|
91
|
+
[2, true, 2], 'exposed controls keep their state across frames');
|
|
92
|
+
await click('#stop-button');
|
|
93
|
+
const { bytes } = await exportProjectSwf(project);
|
|
94
|
+
const { project: reopened } = await convertSwf(bytes, { name: 'Published controls', idPrefix: 'roundtrip' });
|
|
95
|
+
await load(reopened);
|
|
96
|
+
await click('#preview-button');
|
|
97
|
+
for (let i = 0; i < 200; ++i) {
|
|
98
|
+
if (await game('typeof globalThis.__swoof?.root?.checkBox?.getValue === "function"').catch(() => false)) break;
|
|
99
|
+
await new Promise(resolve => setTimeout(resolve, 35));
|
|
100
|
+
}
|
|
101
|
+
assert.deepEqual(await game('[__swoof.root.checkBox.selected, __swoof.root.comboBox.getValue()]'), [true, 'Item 1']);
|
|
102
|
+
await game('__swoof.root.checkBox.__surface.part2.onRelease()');
|
|
103
|
+
assert.deepEqual(await game('[__swoof.root.checkBox.selected, __swoof.root.heard, __swoof.root.checked, __swoof.root.textInput.text]'),
|
|
104
|
+
[false, false, false, 'Clicked'], 'published SWF dispatches an authored control event on its owning timeline');
|
|
105
|
+
await click('#stop-button');
|
|
106
|
+
await load({ stage, scenes: [{ id: 'scene', name: 'Scene', durationFrames: 4, elements: [] }] });
|
|
107
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdtemp, readdir, readFile, rm } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
// SVG export (studiospec/svg-export.md): a frame and an animation from the Export dialog, compared
|
|
6
|
+
// with Studio's own capture of the same frames.
|
|
7
|
+
export async function verifySvgExport({ call, js, click, change, profile }) {
|
|
8
|
+
const folder = await mkdtemp(path.join(profile, 'svg-'));
|
|
9
|
+
await call('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: folder });
|
|
10
|
+
const stage = { width: 200, height: 120, background: '#ffffff', frameRate: 10 };
|
|
11
|
+
const rect = (id, x, y, width, height, extra = {}) => ({ id, name: id, type: 'rectangle', x, y, width, height, fill: '#3366cc', strokeWidth: 0, ...extra });
|
|
12
|
+
const scene = { id: 'look', name: 'Look', durationFrames: 10, loop: true, elements: [
|
|
13
|
+
rect('sky', 100, 60, 200, 120, { gradient: { type: 'linear', angle: 90, stops: [{ ratio: 0, color: '#203060', alpha: 1 }, { ratio: 1, color: '#c0a0f0', alpha: 1 }] } }),
|
|
14
|
+
{ id: 'hole', name: 'hole', type: 'ellipse', x: 40, y: 40, width: 50, height: 50, fill: '#000000', strokeWidth: 0 },
|
|
15
|
+
rect('masked', 40, 40, 70, 70, { fill: '#ffcc00', maskId: 'hole' }),
|
|
16
|
+
{ id: 'glow', name: 'glow', type: 'ellipse', x: 110, y: 35, width: 30, height: 30, fill: '#ffffff', strokeWidth: 0,
|
|
17
|
+
effect: { type: 'glow', color: '#ff3300', alpha: 1, blurX: 12, blurY: 12 } },
|
|
18
|
+
rect('shadow', 160, 35, 30, 30, { fill: '#33cc66', effect: { type: 'shadow', distance: 6, angle: 45, color: '#000000', alpha: 0.8, blurX: 6, blurY: 6 } }),
|
|
19
|
+
rect('tinted', 40, 95, 40, 30, { fill: '#808080', colorTransform: { redMultiplier: 1, greenMultiplier: 0.2, blueMultiplier: 0.2, redOffset: 60, greenOffset: 0, blueOffset: 0 } }),
|
|
20
|
+
rect('multiply', 100, 95, 60, 30, { fill: '#ff8800', keyframes: [{ frame: 1, blendMode: 3 }] }),
|
|
21
|
+
{ id: 'label', name: 'label', type: 'text', x: 160, y: 95, width: 70, height: 24, text: 'Boo', fontSize: 16, textColor: '#ffffff', strokeWidth: 0 },
|
|
22
|
+
rect('mover', 20, 70, 16, 16, { fill: '#ff0066', keyframes: [{ frame: 1, x: 20 }, { frame: 6, x: 180, tween: 'hold' }, { frame: 10, x: 180 }] }),
|
|
23
|
+
] };
|
|
24
|
+
await click('#import-project');
|
|
25
|
+
await change('project-io-textarea', JSON.stringify({ stage, scenes: [scene] }));
|
|
26
|
+
await click('#project-io-submit');
|
|
27
|
+
for (let attempt = 0; attempt < 200 && await js("document.querySelector('#project-io-dialog').open"); attempt++) {
|
|
28
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
29
|
+
}
|
|
30
|
+
assert.equal(await js("document.querySelector('#project-io-dialog').open"), false,
|
|
31
|
+
`Imported the SVG test project: ${await js("document.querySelector('#project-io-error').textContent")}`);
|
|
32
|
+
await change('playhead', 3, 'input');
|
|
33
|
+
|
|
34
|
+
async function download(extension) {
|
|
35
|
+
let file;
|
|
36
|
+
for (let attempt = 0; attempt < 400 && !file; attempt++) {
|
|
37
|
+
file = (await readdir(folder)).find(name => name.endsWith(extension));
|
|
38
|
+
if (!file) await new Promise(resolve => setTimeout(resolve, 25));
|
|
39
|
+
}
|
|
40
|
+
assert.ok(file, `Downloaded the ${extension} file`);
|
|
41
|
+
const error = await js("document.querySelector('#project-io-error').hidden ? '' : document.querySelector('#project-io-error').textContent");
|
|
42
|
+
assert.equal(error, '');
|
|
43
|
+
const notice = await js("document.querySelector('#project-io-notice').textContent");
|
|
44
|
+
await click('#project-io-close');
|
|
45
|
+
const text = await readFile(path.join(folder, file), 'utf8');
|
|
46
|
+
await rm(path.join(folder, file));
|
|
47
|
+
return { file, text, notice };
|
|
48
|
+
}
|
|
49
|
+
// Studio's capture of a playback frame (index counted as video frames), and its mean difference
|
|
50
|
+
// from `pixels` (RGBA of the stage at 1×).
|
|
51
|
+
const compare = (index, pixels) => js(`(async () => {
|
|
52
|
+
const { parseProjectJson } = await import('/src/project-io.js');
|
|
53
|
+
const { playHeadless } = await import('/src/video-playback.js');
|
|
54
|
+
const { renderCaptureFrame } = await import('/src/canvas.js');
|
|
55
|
+
const project = parseProjectJson(${JSON.stringify(JSON.stringify({ stage, scenes: [scene] }))});
|
|
56
|
+
const canvas = document.createElement('canvas');
|
|
57
|
+
canvas.width = ${stage.width}; canvas.height = ${stage.height};
|
|
58
|
+
let index = 0, reference;
|
|
59
|
+
await playHeadless({ project, maxFrames: ${index + 1}, holdFrames: 10,
|
|
60
|
+
render: ({ scene, playhead, hiddenIds, clocks }) => renderCaptureFrame(canvas, { stage: project.stage, scene, symbols: [], assets: [], clocks, playhead, hiddenIds }),
|
|
61
|
+
snapshot: () => {}, emit: async () => { if (index++ === ${index}) reference = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height).data; } });
|
|
62
|
+
const pixels = ${JSON.stringify(pixels)};
|
|
63
|
+
let sum = 0;
|
|
64
|
+
for (let i = 0; i < reference.length; i += 4) for (let c = 0; c < 3; c++) sum += Math.abs(reference[i + c] - pixels[i + c]);
|
|
65
|
+
return sum / (reference.length / 4 * 3);
|
|
66
|
+
})()`);
|
|
67
|
+
const rasterize = text => js(`(async () => {
|
|
68
|
+
const image = new Image();
|
|
69
|
+
image.src = URL.createObjectURL(new Blob([${JSON.stringify(text)}], { type: 'image/svg+xml' }));
|
|
70
|
+
await image.decode();
|
|
71
|
+
const canvas = document.createElement('canvas');
|
|
72
|
+
canvas.width = ${stage.width}; canvas.height = ${stage.height};
|
|
73
|
+
canvas.getContext('2d').drawImage(image, 0, 0, ${stage.width}, ${stage.height});
|
|
74
|
+
return Array.from(canvas.getContext('2d').getImageData(0, 0, ${stage.width}, ${stage.height}).data);
|
|
75
|
+
})()`);
|
|
76
|
+
|
|
77
|
+
// A frame: every feature of the fixture drawn as Studio draws it.
|
|
78
|
+
await click('#export-project');
|
|
79
|
+
await change('export-format', 'image');
|
|
80
|
+
await change('export-image-format', 'svg');
|
|
81
|
+
await change('export-image-scale', '2');
|
|
82
|
+
await click('#export-download');
|
|
83
|
+
const frame = await download('.svg');
|
|
84
|
+
assert.match(frame.file, /-Look-frame-3\.svg$/);
|
|
85
|
+
assert.match(frame.text, /^<\?xml[^>]*>\s*<svg [^>]*width="400" height="240" viewBox="0 0 200 120"/);
|
|
86
|
+
assert.match(frame.text, /<linearGradient /);
|
|
87
|
+
assert.match(frame.text, /<clipPath /);
|
|
88
|
+
assert.match(frame.text, /<feGaussianBlur /);
|
|
89
|
+
assert.match(frame.text, /<feOffset /);
|
|
90
|
+
assert.match(frame.text, /mix-blend-mode:multiply/);
|
|
91
|
+
assert.match(frame.text, />Boo<\/text>/);
|
|
92
|
+
assert.match(frame.notice, /KB/);
|
|
93
|
+
// The playhead shows frame 3, which is the third video frame (index 2).
|
|
94
|
+
const frameDifference = await compare(2, await rasterize(frame.text));
|
|
95
|
+
assert.ok(frameDifference < 2, `The SVG frame matches the stage (mean difference ${frameDifference.toFixed(2)})`);
|
|
96
|
+
|
|
97
|
+
// An animation: it plays, holds and loops as the movie does.
|
|
98
|
+
await click('#export-project');
|
|
99
|
+
await change('export-format', 'video');
|
|
100
|
+
for (let attempt = 0; attempt < 200 && !await js("document.querySelector('#export-video-field').dataset.ready"); attempt++) {
|
|
101
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
102
|
+
}
|
|
103
|
+
await change('export-video-format', 'svg');
|
|
104
|
+
assert.equal(await js("!document.querySelector('#export-video-silent').hidden"), true, 'Animated SVG says it has no sound');
|
|
105
|
+
assert.equal(await js("document.querySelector('#export-video-sound-field').hidden"), true);
|
|
106
|
+
await click('#export-download');
|
|
107
|
+
const movie = await download('.svg');
|
|
108
|
+
assert.match(movie.notice, /1\.0 s; it then loops from where the movie repeats/);
|
|
109
|
+
assert.match(movie.text, /<animateTransform attributeName="transform" type="translate" additive="replace" begin="0s" dur="1s" repeatCount="indefinite"/);
|
|
110
|
+
for (const [time, index] of [[0, 0], [0.3, 3], [0.7, 7], [1.3, 3], [2.7, 7]]) {
|
|
111
|
+
const pixels = await js(`(async () => {
|
|
112
|
+
const host = document.createElement('div');
|
|
113
|
+
host.style.cssText = 'position:fixed;left:0;top:0;z-index:2147483647;background:#fff';
|
|
114
|
+
host.innerHTML = ${JSON.stringify(movie.text.replace(/^<\?xml[^>]*>\s*/, ''))};
|
|
115
|
+
document.body.append(host);
|
|
116
|
+
const svg = host.querySelector('svg');
|
|
117
|
+
svg.setAttribute('width', '${stage.width}'); svg.setAttribute('height', '${stage.height}');
|
|
118
|
+
svg.pauseAnimations();
|
|
119
|
+
svg.setCurrentTime(${time} + 0.0001);
|
|
120
|
+
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
121
|
+
window.__svgHost = host;
|
|
122
|
+
return 1;
|
|
123
|
+
})()`);
|
|
124
|
+
assert.equal(pixels, 1);
|
|
125
|
+
const { data } = await call('Page.captureScreenshot', { format: 'png', clip: { x: 0, y: 0, width: stage.width, height: stage.height, scale: 1 } });
|
|
126
|
+
const shot = await js(`(async () => {
|
|
127
|
+
window.__svgHost.remove();
|
|
128
|
+
const image = new Image();
|
|
129
|
+
image.src = 'data:image/png;base64,${data}';
|
|
130
|
+
await image.decode();
|
|
131
|
+
const canvas = document.createElement('canvas');
|
|
132
|
+
canvas.width = ${stage.width}; canvas.height = ${stage.height};
|
|
133
|
+
canvas.getContext('2d').drawImage(image, 0, 0, ${stage.width}, ${stage.height});
|
|
134
|
+
return Array.from(canvas.getContext('2d').getImageData(0, 0, ${stage.width}, ${stage.height}).data);
|
|
135
|
+
})()`);
|
|
136
|
+
const difference = await compare(index, shot);
|
|
137
|
+
assert.ok(difference < 2.5, `The animated SVG at ${time} s shows frame ${index + 1} (mean difference ${difference.toFixed(2)})`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Scripted movies play on the swf2js player, which gives pixels: animated SVG names the reason.
|
|
141
|
+
const refusal = await js(`(async () => {
|
|
142
|
+
const { parseProjectJson } = await import('/src/project-io.js');
|
|
143
|
+
const { exportAnimatedSvg } = await import('/src/svg-animation.js');
|
|
144
|
+
const project = parseProjectJson(${JSON.stringify(JSON.stringify({ stage, scenes: [{ ...scene, events: [{ trigger: 'frameEnter', frame: 1, actions: [{ type: 'script', script: 'halt' }] }] }],
|
|
145
|
+
scripts: [{ id: 'halt', language: 'actionscript', swfVersion: 8, code: 'stop();' }] }))});
|
|
146
|
+
return exportAnimatedSvg(project).then(() => '', error => error.message);
|
|
147
|
+
})()`);
|
|
148
|
+
assert.match(refusal, /^Animated SVG does not support movies that play on the SWF player yet\. This project uses ActionScript\. Export a frame as SVG/);
|
|
149
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { parse } from '../../swf2js/parser/swf-parser.js';
|
|
5
|
+
import { TAG } from '../../swf2js/decoder/tag-types.js';
|
|
6
|
+
import { writeSwf, encodeTag } from '../../swf2js/encoder/swf-writer.js';
|
|
7
|
+
import { convertSwf } from '../server/swf-import.js';
|
|
8
|
+
|
|
9
|
+
export async function verifyTextFields({ click, change, js, key, exportProject }) {
|
|
10
|
+
const stage = { width: 800, height: 450, frameRate: 12 };
|
|
11
|
+
const project = { stage, scenes: [{ id: 'one', durationFrames: 1, elements: [
|
|
12
|
+
{ id: 'entry', name: 'entry', type: 'text', x: 160, y: 60, text: 'Name',
|
|
13
|
+
field: { html: true, htmlText: '<b>Name</b>', editable: true, selectable: true, wordWrap: true, multiline: true } },
|
|
14
|
+
{ id: 'echo', name: 'echo', type: 'text', x: 160, y: 130, text: '', field: { variable: 'user', selectable: true } },
|
|
15
|
+
{ id: 'rich', name: 'rich', type: 'text', x: 160, y: 185, text: 'Flash', field: { html: true, htmlText: '<i>Flash</i>', selectable: true } },
|
|
16
|
+
] }] };
|
|
17
|
+
const load = async doc => {
|
|
18
|
+
await click('#import-project');
|
|
19
|
+
await change('project-io-textarea', JSON.stringify(doc));
|
|
20
|
+
await click('#project-io-submit');
|
|
21
|
+
};
|
|
22
|
+
const field = name => '[data-text-field="' + name + '"]';
|
|
23
|
+
const set = (selector, value, type = 'change') => js(`{const el = document.querySelector(${JSON.stringify(selector)});
|
|
24
|
+
el.value = ${JSON.stringify(value)}; el.dispatchEvent(new Event(${JSON.stringify(type)}, {bubbles:true}));}`);
|
|
25
|
+
const raze = new URL('../../archive/Swf/raze-2.swf', import.meta.url);
|
|
26
|
+
if (existsSync(raze)) {
|
|
27
|
+
const { doc } = await parse(await readFile(raze));
|
|
28
|
+
const tags = doc.tags.filter(tag => [TAG.DefineFont3, TAG.DefineEditText].includes(tag.code) && [442, 443].includes(tag.data[0] | tag.data[1] << 8))
|
|
29
|
+
.map(tag => encodeTag(tag.code, tag.data));
|
|
30
|
+
tags.push(encodeTag(TAG.PlaceObject2, Uint8Array.of(2, 1, 0, 443 & 255, 443 >> 8)), encodeTag(TAG.ShowFrame));
|
|
31
|
+
const movie = await convertSwf(writeSwf({ ...doc.header, frameCount: 1, tags }), { name: 'Embedded field' });
|
|
32
|
+
await load(movie.project);
|
|
33
|
+
assert.equal(await js("document.fonts.ready.then(() => [...document.fonts].filter(face => face.status === 'loaded' && face.family.includes('QTypeSquare-Book_12pt_st')).length)"), 1);
|
|
34
|
+
}
|
|
35
|
+
await load(project);
|
|
36
|
+
assert.equal(await js("[...document.fonts].filter(face => face.family.includes('QTypeSquare-Book_12pt_st')).length"), 0, 'replacing a project releases its embedded faces');
|
|
37
|
+
await click('[data-focus-key="object:entry"]');
|
|
38
|
+
assert.equal(await js("document.querySelector('#input-text').checked"), true);
|
|
39
|
+
const text = '[data-property="text"]';
|
|
40
|
+
assert.equal(await js(`document.querySelector('${text}').value`), '<b>Name</b>');
|
|
41
|
+
await set(text, '<b>PIN</b>', 'input');
|
|
42
|
+
await set(field('variable'), 'user');
|
|
43
|
+
await set(field('maxLength'), 3);
|
|
44
|
+
for (const flag of ['password', 'multiline', 'wordWrap', 'border']) await click(field(flag));
|
|
45
|
+
const saved = await exportProject();
|
|
46
|
+
await load(saved);
|
|
47
|
+
await click('#preview-button');
|
|
48
|
+
const node = "document.querySelector('#preview-surface [data-element-id=entry]')";
|
|
49
|
+
const echo = "document.querySelector('#preview-surface [data-element-id=echo]')";
|
|
50
|
+
assert.deepEqual(await js(`[${node}.type, ${node}.value, ${node}.maxLength, ${node}.style.borderWidth, ${echo}.textContent]`),
|
|
51
|
+
['password', 'PIN', 3, '1px', 'PIN']);
|
|
52
|
+
assert.equal(await js("document.querySelector('#preview-surface [data-element-id=rich] i').textContent"), 'Flash');
|
|
53
|
+
await js(`${node}.focus(); ${node}.select()`);
|
|
54
|
+
for (const n of ['1','2','3','4']) await key(n, 'Digit' + n, n.charCodeAt(0), 0, n);
|
|
55
|
+
assert.deepEqual(await js(`[${node}.value, ${echo}.textContent]`), ['123', '123']);
|
|
56
|
+
await click('#stop-button');
|
|
57
|
+
assert.deepEqual(await exportProject(), saved);
|
|
58
|
+
await click('[data-focus-key="object:entry"]');
|
|
59
|
+
await click('#input-text');
|
|
60
|
+
await click(field('password'));
|
|
61
|
+
await click('#preview-button');
|
|
62
|
+
assert.equal(await js(node + ".querySelector('b').textContent"), 'PIN', 'an edited HTML field displays its markup');
|
|
63
|
+
await click('#stop-button');
|
|
64
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function verifyTheme({ call, js, change, exportProject }) {
|
|
4
|
+
const paint = () => js('new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))');
|
|
5
|
+
const background = selector => js(`getComputedStyle(document.querySelector(${JSON.stringify(selector)})).backgroundColor`);
|
|
6
|
+
const scheme = () => js('getComputedStyle(document.documentElement).colorScheme');
|
|
7
|
+
const system = async value => {
|
|
8
|
+
await call('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value }] });
|
|
9
|
+
await paint();
|
|
10
|
+
};
|
|
11
|
+
await system('dark');
|
|
12
|
+
assert.equal(await js("document.querySelector('#editor-theme').value"), 'system');
|
|
13
|
+
assert.equal(await scheme(), 'dark');
|
|
14
|
+
const project = await exportProject();
|
|
15
|
+
await js("window.stageBeforeTheme = document.querySelector('#stage').toDataURL()");
|
|
16
|
+
const surfaces = ['.topbar', '.tool-rail', '.stage-viewport', '.side-dock', '.timeline-panel',
|
|
17
|
+
'#stage-width', '#project-io-dialog', '#event-editor'];
|
|
18
|
+
const colors = await Promise.all(surfaces.map(background));
|
|
19
|
+
await system('light');
|
|
20
|
+
assert.equal(await scheme(), 'light');
|
|
21
|
+
for (const [index, selector] of surfaces.entries()) {
|
|
22
|
+
assert.notEqual(await background(selector), colors[index], selector + ' follows the active theme');
|
|
23
|
+
}
|
|
24
|
+
await change('editor-theme', 'dark');
|
|
25
|
+
await system('dark');
|
|
26
|
+
await system('light');
|
|
27
|
+
assert.equal(await scheme(), 'dark', 'An explicit theme takes priority over the system');
|
|
28
|
+
assert.deepEqual(await exportProject(), project);
|
|
29
|
+
assert.equal(await js("document.querySelector('#stage').toDataURL() === window.stageBeforeTheme"), true);
|
|
30
|
+
await change('editor-theme', 'light');
|
|
31
|
+
await system('dark');
|
|
32
|
+
const before = await js('performance.timeOrigin');
|
|
33
|
+
await call('Page.reload');
|
|
34
|
+
for (let i = 0; i < 100; i++) {
|
|
35
|
+
if (await js(`performance.timeOrigin !== ${before} && document.readyState === 'complete'`)) break;
|
|
36
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
37
|
+
}
|
|
38
|
+
assert.notEqual(await js('performance.timeOrigin'), before);
|
|
39
|
+
assert.equal(await scheme(), 'light');
|
|
40
|
+
assert.equal(await js("document.querySelector('#editor-theme').value"), 'light');
|
|
41
|
+
await change('editor-theme', 'system');
|
|
42
|
+
assert.equal(await scheme(), 'dark');
|
|
43
|
+
for (const width of [320, 390, 600, 1280]) {
|
|
44
|
+
await call('Emulation.setDeviceMetricsOverride', { width, height: 844, deviceScaleFactor: 1, mobile: false });
|
|
45
|
+
await paint();
|
|
46
|
+
assert.equal(await js(`(() => {
|
|
47
|
+
const control = document.querySelector('#editor-theme'), r = control.getBoundingClientRect();
|
|
48
|
+
return document.documentElement.scrollWidth <= innerWidth && r.width >= 24 &&
|
|
49
|
+
document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2) === control &&
|
|
50
|
+
document.querySelector('#preview-button').getBoundingClientRect().right <= innerWidth;
|
|
51
|
+
})()`), true, 'Theme and preview controls fit at ' + width + 'px');
|
|
52
|
+
}
|
|
53
|
+
}
|