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,378 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
This document describes how Swoof is put together: the swf2js transpiler, the swooflib runtime, and Swoof Studio, including the planned file support. Requirements live in [requirements.md](./requirements.md), [file-support.md](./file-support.md), [actionscript.md](./actionscript.md), [video-export.md](./video-export.md), [svg-export.md](./svg-export.md) [lottie.md](./lottie.md), [svg-import.md](./svg-import.md) and [stroke-style.md](./stroke-style.md). Progress lives in [tasks.md](./tasks.md). Integration rules for the runtime live in [swooflib-integration.md](./swooflib-integration.md).
|
|
4
|
+
|
|
5
|
+
Sections marked **Planned** describe designs from the spec that are not yet implemented.
|
|
6
|
+
|
|
7
|
+
## 1. System overview
|
|
8
|
+
|
|
9
|
+
Swoof has three parts that share one SWF vocabulary:
|
|
10
|
+
|
|
11
|
+
- **swf2js** (`swf2js/`) reads SWF files and transpiles them into standalone HTML/JS bundles. It runs in Node.
|
|
12
|
+
- **swooflib** (`swooflib/`, at the repository root) is the Flash-compatible browser runtime. It contains display objects, vector graphics, text, input, sound, and the Canvas renderer. Generated bundles ship it, and Studio uses it to render.
|
|
13
|
+
- **Swoof Studio** (`studio/`) is a browser animation editor served by a small Node server. It owns an editable document model and renders it through swooflib.
|
|
14
|
+
|
|
15
|
+
```mermaid
|
|
16
|
+
flowchart LR
|
|
17
|
+
subgraph Node
|
|
18
|
+
CLI[swf2js CLI<br/>swf2js/cli.js]
|
|
19
|
+
READ[SWF reader<br/>swf2js/parser + swf2js/decoder]
|
|
20
|
+
TRANS[Transpiler<br/>swf2js/transpiler]
|
|
21
|
+
EMIT[Bundle emitter<br/>swf2js/emitter]
|
|
22
|
+
ENC[SWF encoder<br/>swf2js/encoder · planned]
|
|
23
|
+
SRV[Studio server<br/>studio/server.js]
|
|
24
|
+
IMP[SWF import<br/>studio/server · planned]
|
|
25
|
+
EXP[SWF export<br/>studio/server · planned]
|
|
26
|
+
end
|
|
27
|
+
subgraph Browser
|
|
28
|
+
BUNDLE[Generated bundle<br/>index.html + bundle.js + swoof.js]
|
|
29
|
+
STUDIO[Studio editor<br/>studio/src]
|
|
30
|
+
LIB[swooflib<br/>display · render · input]
|
|
31
|
+
end
|
|
32
|
+
SWF[(.swf)] --> CLI --> READ --> TRANS --> EMIT --> BUNDLE
|
|
33
|
+
BUNDLE --> LIB
|
|
34
|
+
STUDIO --> LIB
|
|
35
|
+
STUDIO <-->|HTTP /api| SRV
|
|
36
|
+
SRV --> IMP --> READ
|
|
37
|
+
SRV --> EXP --> ENC --> SWF2[(.swf)]
|
|
38
|
+
SWF2 -. publish .-> CLI
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The SWF reader and the planned encoder are the shared core. swf2js uses the reader for transpiling, and Studio uses it on the server for SWF import. Studio's SWF export uses the encoder. The resulting SWF can be passed back to swf2js to publish an HTML bundle.
|
|
42
|
+
|
|
43
|
+
## 2. Repository layout
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
swf2js/ swf2js (npm package "swf2js", bin swf2js)
|
|
47
|
+
cli.js Command line: parse → decode → transpile → emit
|
|
48
|
+
parser/ Bytes → SwfDocument (header, decompression, raw tags)
|
|
49
|
+
decoder/ Raw tags → typed tag structures and the symbol table
|
|
50
|
+
encoder/ Planned: typed tag structures → bytes
|
|
51
|
+
model/ Shared typedefs (SwfDocument, TranspileResult)
|
|
52
|
+
transpiler/ AVM1/AVM2 bytecode → JS; timeline and display-list codegen
|
|
53
|
+
emitter/ Bundle files, assets, fonts, timeline data
|
|
54
|
+
runtime/ Runtime sources serialized into bundles; assemble-swooflib.js builds swoof.js
|
|
55
|
+
pretty-printer/ --inspect output
|
|
56
|
+
__tests__/ vitest suites
|
|
57
|
+
studio/ Swoof Studio (bin studio)
|
|
58
|
+
server.js node:http server: static files and /api routes
|
|
59
|
+
server/ Planned: storage, uploads, journal, SWF import/export
|
|
60
|
+
index.html, styles.css Editor shell
|
|
61
|
+
src/ Editor modules (browser ES modules, no build step)
|
|
62
|
+
examples/ Six editable example projects (JSON)
|
|
63
|
+
*.test.js Model tests (node --test)
|
|
64
|
+
tests/ Chromium regression suite (CDP over a pipe)
|
|
65
|
+
studiospec/ Studio requirements, design, and tasks
|
|
66
|
+
demos/ Generated demo bundles and their SWFs
|
|
67
|
+
source/ One-time scripts that produced the demo SWFs
|
|
68
|
+
swooflib/ Player ES modules, shared by swf2js output (swoof.js) and Studio (/swooflib/)
|
|
69
|
+
doc/ SWF file format specification (v19)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 3. swf2js
|
|
73
|
+
|
|
74
|
+
### Read pipeline
|
|
75
|
+
|
|
76
|
+
```mermaid
|
|
77
|
+
flowchart LR
|
|
78
|
+
B[bytes] --> P[swf-parser<br/>header · FWS/CWS/ZWS · raw tags]
|
|
79
|
+
P --> D[tag-decoder<br/>typed tags · SymbolTable]
|
|
80
|
+
D --> T[actionscript.js<br/>AVM1 / AVM2 → JS]
|
|
81
|
+
D --> DL[display-list.js<br/>frames · characters]
|
|
82
|
+
T --> CG[timeline-codegen.js]
|
|
83
|
+
DL --> CG
|
|
84
|
+
CG --> E[bundle-emitter<br/>index.html · bundle.js · swoof.js · assets]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
| Stage | Modules | Output |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| Parse | `parser/bit-reader.js`, `decompressor.js`, `swf-parser.js` | `SwfDocument`: version, frame size and rate, raw tags (`code`, `offset`, `data`) |
|
|
90
|
+
| Decode | `decoder/tag-decoder.js`, `shape-decoder.js`, `button-decoder.js`, `symbol-table.js`, `tag-types.js` | Typed tag objects (`type: 'Shape'`, `'PlaceObject2'`, …) and a `SymbolTable` keyed by character ID |
|
|
91
|
+
| Transpile | `transpiler/actionscript.js`, `avm1/`, `avm2/`, `cfg-structurer.js` | JavaScript for DoAction, DoInitAction, button actions, and ABC classes |
|
|
92
|
+
| Timeline | `transpiler/timeline/display-list.js`, `timeline-codegen.js` | Per-frame display-list operations and the timeline engine source |
|
|
93
|
+
| Emit | `emitter/bundle-emitter.js`, `asset-encoder.js`, `font-encoder.js`, `movie-data-codec.js`, `embedded-swf.js` | A movie folder with HTML, `movie-data.js`, `bundle.js`, and assets, and `swoof.js` (shared in the output folder for batch runs) |
|
|
94
|
+
|
|
95
|
+
Every stage reports through `util/diagnostics.js`, so malformed input produces diagnostics instead of exceptions where possible.
|
|
96
|
+
|
|
97
|
+
### Bundle size (planned)
|
|
98
|
+
|
|
99
|
+
The current bundle expands shapes into JSON path arrays and emits clip-event handlers once per placement. On the 57-movie archive corpus, 264 MB of SWF becomes 351 MB of `bundle.js` plus 403 MB of `timeline-data.js`, and the largest movies no longer load. The fix follows the library-once rule of Flash's XFL format and of Studio's project folder: store each definition once, and refer to it by ID everywhere else. See [.kiro/specs/compact-bundle-format](../.kiro/specs/compact-bundle-format/design.md) for the manifest, content-addressed chunks, path-stream geometry, and on-demand loading.
|
|
100
|
+
|
|
101
|
+
### Runtime
|
|
102
|
+
|
|
103
|
+
`swooflib/` holds the player ES modules. `swf2js/runtime/assemble-swooflib.js` bundles them with esbuild into the classic script `swoof.js`. The other files in `swf2js/runtime/` hold the AVM1 and AVM2 runtimes, the movie runtime, and the embedded-movie runtime. The emitter serializes these into bundles as source text.
|
|
104
|
+
|
|
105
|
+
## 4. Swoof Studio
|
|
106
|
+
|
|
107
|
+
### Process model
|
|
108
|
+
|
|
109
|
+
```mermaid
|
|
110
|
+
flowchart LR
|
|
111
|
+
subgraph Browser tab
|
|
112
|
+
UI[index.html + styles.css]
|
|
113
|
+
C[index.js<br/>controller and state]
|
|
114
|
+
M[Model modules<br/>pure functions]
|
|
115
|
+
R[Rendering adapter<br/>canvas.js · display-frame.js]
|
|
116
|
+
P[Preview runtime]
|
|
117
|
+
L[swooflib]
|
|
118
|
+
end
|
|
119
|
+
subgraph "Node · studio/server.js"
|
|
120
|
+
S[Static files]
|
|
121
|
+
A[/api routes · planned/]
|
|
122
|
+
FS[(projects directory)]
|
|
123
|
+
end
|
|
124
|
+
UI --> C --> M
|
|
125
|
+
C --> R --> L
|
|
126
|
+
C --> P --> R
|
|
127
|
+
C <-->|fetch| A --> FS
|
|
128
|
+
UI -.GET.-> S
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The editor is plain ES modules with no build step. The server serves `studio/` and hides tests and server source. Server routes run before static files. All application state lives in the browser tab until the file-support work adds server storage.
|
|
132
|
+
|
|
133
|
+
### Module map
|
|
134
|
+
|
|
135
|
+
| Layer | Modules | Responsibility |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| Controller | `index.js` | Owns `project`, selection, playhead, tool, and preview state. Wires DOM events to model operations, records history, and requests renders |
|
|
138
|
+
| Document model | `model.js`, `document-editing.js`, `frame-editing.js`, `groups.js`, `masks.js`, `symbols.js`, `frame-events.js`, `vector-style.js`, `media-assets.js`, `scene-transition.js`, `interaction-triggers.js`, `numeric-fields.js` | Pure functions over the project: pose and style evaluation, easing, keyframe and frame-span edits, layers, groups, masks, symbol clocks, typed events, validation |
|
|
139
|
+
| Persistence | `project-io.js`, `history.js` | JSON serialization and validation (`serializeProject`, `parseProjectJson`), ID sequences, and undo/redo snapshots |
|
|
140
|
+
| Playback | `playback.js`, `symbols.js` (`advanceSymbol`), `frame-events.js` (`createEventDispatcher`) | Advancing the playhead, nested symbol clocks, and frame-entry dispatch |
|
|
141
|
+
| Rendering adapter | `canvas.js`, `display-frame.js`, `vector-geometry.js` | Builds a swooflib display tree for the evaluated frame, renders it, and hit-tests editor objects and handles |
|
|
142
|
+
| Preview runtime | `preview-surface.js`, `preview-interactions.js`, `preview-audio.js`, `scene-transition.js`, `arithmetic.js` | Native input fields, pointer, touch, and key bindings, Web Audio voices, scene transitions, and calculator evaluation |
|
|
143
|
+
| Panels | `timeline.js`, `object-list.js`, `symbol-library.js`, `media-library.js`, `appearance-inspector.js`, `event-editor.js`, `layer-icons.js` | DOM views that render from state and call back into the controller |
|
|
144
|
+
| Workspace | `workspace.js`, `stage-guides.js`, `theme.js` | Zoom, pan, rulers, grid, panel docking, compact drawer, theme |
|
|
145
|
+
| Video and image export | `video-playback.js`, `video-export.js`, `video-encode.js`, `video-mux.js`, `animated-image.js`, `frame-image.js`, `swf-recording.js`, `preview-recorder.js` | Headless playback with Preview's rules, recording of scripted movies from the swf2js player on a virtual clock, offline rendering and audio mix, WebCodecs encoding, MP4 and WebM writing, GIF/APNG/WebP animations, still frames as images. See [video-export.md](./video-export.md) |
|
|
146
|
+
| SVG export | `svg-context.js`, `svg-frame.js`, `svg-animation.js` | Frames as SVG from the display tree through a recording 2D context; animated SVG (SMIL) from per-frame trees merged by Studio id. See [svg-export.md](./svg-export.md) |
|
|
147
|
+
| SVG import | `svg-import.js` | SVG read with Studio's own XML reader into a one-frame project: primitives or baked paths, gradients, line style and dashes, text (on paths too), images, clip paths as masks, filters as effects; patterns as bitmap fills, soft masks and other filters as pictures drawn by the browser (`rasterizeInBrowser`). The Import picker tells SWF, Lottie, SVG and project files apart by content. See [svg-import.md](./svg-import.md) |
|
|
148
|
+
| Stroke and fill style | `project-io.js`, `vector-geometry.js`, `server/project-movie.js`, `swf2js/encoder/shape-encoder.js` | Line ends, corners, miter limit, dashes, fill rule, italic and inner effects on objects: drawn through swooflib line styles and `lineDashStyle`, written to SWF (DefineShape4 caps, joins, winding flag; dashes cut into pieces), SVG and Lottie. Masks clip with their fill rule; symbol masks use oriented contours. See [stroke-style.md](./stroke-style.md) |
|
|
149
|
+
| Lottie | `lottie-export.js`, `lottie-import.js` | Export: headless playback written as Lottie layers, keyframes, precomps and scene markers, with Studio's project embedded for exact roundtrips. Import: Lottie evaluated per frame and reduced to Studio keyframes, symbols, masks and scene events. See [lottie.md](./lottie.md) |
|
|
150
|
+
|
|
151
|
+
Dependencies point downward. Panels and the adapter depend on the model, the controller depends on everything, and model modules depend only on other model modules. The adapter is the only code that imports swooflib.
|
|
152
|
+
|
|
153
|
+
### Edit cycle
|
|
154
|
+
|
|
155
|
+
```mermaid
|
|
156
|
+
sequenceDiagram
|
|
157
|
+
participant U as User
|
|
158
|
+
participant C as index.js
|
|
159
|
+
participant M as Model modules
|
|
160
|
+
participant H as history.js
|
|
161
|
+
participant R as canvas.js
|
|
162
|
+
U->>C: Gesture or inspector change
|
|
163
|
+
C->>M: Pure edit (e.g. setPoseAtFrame)
|
|
164
|
+
M-->>C: Updated project or validation error
|
|
165
|
+
alt valid
|
|
166
|
+
C->>H: record(project, view)
|
|
167
|
+
C->>R: render(scene, playhead, selection)
|
|
168
|
+
C->>C: Refresh timeline, objects, inspectors
|
|
169
|
+
else invalid
|
|
170
|
+
C->>U: Inline error. The project is unchanged
|
|
171
|
+
end
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
History stores one JSON snapshot per committed edit, up to 64 entries, together with the view (scene, layer, selection, playhead). Media assets are shared by reference and never serialized into history. A stage drag or an inline text session coalesces into one entry.
|
|
175
|
+
|
|
176
|
+
### Frame evaluation and rendering
|
|
177
|
+
|
|
178
|
+
1. `model.js` evaluates each element at the playhead. `poseAt` interpolates transform keys with the track easing, and `visibleAt` applies blank keys.
|
|
179
|
+
2. `symbols.js` computes each instance's local frame from its placement, its playback mode, and the parent playhead.
|
|
180
|
+
3. `display-frame.js` builds a swooflib display tree. It creates `Shape` for vectors and bitmaps, `Sprite` for groups and symbol instances, and `TextField`/`SimpleButton` for text and buttons. It applies gradients, filters, and mask clips.
|
|
181
|
+
4. `render.js` (swooflib) paints the tree to the stage canvas. Hit testing uses the same tree, so selection and preview hits match what is drawn.
|
|
182
|
+
|
|
183
|
+
Scrubbing and paused redraws run only the evaluation and rendering steps. Playback adds frame-event dispatch, symbol clocks, and audio. The renderer never changes the document.
|
|
184
|
+
|
|
185
|
+
### Preview
|
|
186
|
+
|
|
187
|
+
Preview mode switches pointer routing from editing gestures to authored interactions. `preview-interactions.js` resolves click, tap, swipe, and key triggers to typed actions. `frame-events.js` runs frame and timeline-start actions. Both run against a preview session that holds visibility and playback overrides, field values, and transition state. Exiting preview discards the session and restores the authoring view.
|
|
188
|
+
|
|
189
|
+
## 5. Document model
|
|
190
|
+
|
|
191
|
+
The editor works on one JSON-compatible object:
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
project
|
|
195
|
+
├─ stage { width, height, background, frameRate }
|
|
196
|
+
├─ assets[] image/audio entries (embedded data URL; planned: server src + hash)
|
|
197
|
+
├─ symbols[] shared timelines: layers, elements, events, audioClips
|
|
198
|
+
└─ scenes[] timelines with transition, startFrame, loop
|
|
199
|
+
├─ layers[] order, visible, locked
|
|
200
|
+
├─ elements[] type, layerId, groupId?, maskId?, symbolId?, buttonAction?
|
|
201
|
+
│ └─ keyframes[] frame, pose, style overrides, path points, blank
|
|
202
|
+
├─ events[] timelineStart / frameEnter → ordered typed actions
|
|
203
|
+
└─ audioClips[] assetId, start, end, loop
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`project-io.js` is the schema authority. `parseProjectJson` validates every reference (layers, symbols with cycle detection, masks, groups, assets, button and event targets) and normalizes older documents. Anything that produces a project, including JSON import, examples, server load, journal replay, and SWF import, must go through it.
|
|
207
|
+
|
|
208
|
+
## 6. Studio server
|
|
209
|
+
|
|
210
|
+
### Current
|
|
211
|
+
|
|
212
|
+
`studio/server.js` exports `createStudioServer({ root, routes })`. It is also the `studio` bin and `npm run studio` entry point.
|
|
213
|
+
|
|
214
|
+
- Listens on 127.0.0.1:4810 by default. `--port`, `--host`, `PORT`, and `HOST` change the address.
|
|
215
|
+
- `routes` maps `"METHOD /path"` to async handlers that run before static files. Unknown `/api/` paths return 404.
|
|
216
|
+
- Static serving resolves paths inside the Studio directory only and refuses traversal. It hides `tests/`, `*.test.js`, and the server source, and sends `nosniff` and `no-cache` headers.
|
|
217
|
+
- The Chromium suite creates the same server in process.
|
|
218
|
+
|
|
219
|
+
### Planned structure
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
studio/server.js CLI entry and createStudioServer
|
|
223
|
+
studio/server/
|
|
224
|
+
http.js Body reading with limits, JSON responses, error mapping
|
|
225
|
+
projects.js Project folders, parts, revisions, atomic commit
|
|
226
|
+
journal.js Append, validate base/seq, replay, truncate
|
|
227
|
+
assets.js Upload streaming, sha256, magic-byte detection, SVG sanitizing
|
|
228
|
+
routes.js /api route table built from the modules above
|
|
229
|
+
swf-import.js Decoded SWF → Studio project + report
|
|
230
|
+
swf-export.js Studio project → SWF tags via swf2js/encoder + report
|
|
231
|
+
font-files.js Installed TrueType fonts → glyph outlines for DefineFont3 (SWF export)
|
|
232
|
+
swf-transition-runtime.as AVM1 helper compiled into exported SWFs: scene transitions as fading snapshots
|
|
233
|
+
report.js Shared approximated/dropped report builder
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Each module is a set of functions over a projects-directory handle, so it can be tested without HTTP. `routes.js` adapts them to `createStudioServer({ routes })`.
|
|
237
|
+
|
|
238
|
+
## 7. File support (planned)
|
|
239
|
+
|
|
240
|
+
[file-support.md](./file-support.md) defines the behavior. This section covers the components and their interactions.
|
|
241
|
+
|
|
242
|
+
### Project storage
|
|
243
|
+
|
|
244
|
+
A project is a folder. `project.json` is the commit point and lists each scene and symbol part with its content hash. Parts are immutable files named `<id>.<hash>.json`, and media files are named `<sha256>.<ext>`.
|
|
245
|
+
|
|
246
|
+
```mermaid
|
|
247
|
+
sequenceDiagram
|
|
248
|
+
participant E as Editor
|
|
249
|
+
participant S as projects.js
|
|
250
|
+
participant F as Filesystem
|
|
251
|
+
E->>S: PUT project (If-Match rev 14, changed parts only)
|
|
252
|
+
S->>S: Check revision; verify unchanged part hashes
|
|
253
|
+
S->>F: Write changed parts (temp + rename, new hashed names)
|
|
254
|
+
S->>F: Write project.json rev 15 (temp + rename) ← commit
|
|
255
|
+
S->>F: Truncate journal; delete unreferenced parts and assets
|
|
256
|
+
S-->>E: { revision: 15 }
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
The editor knows which parts changed by comparing each scene and symbol's serialized hash with the hashes returned by the last load or save. A crash before the commit leaves revision 14 intact. A crash after it leaves only garbage files, which the next save removes.
|
|
260
|
+
|
|
261
|
+
### Journal
|
|
262
|
+
|
|
263
|
+
```mermaid
|
|
264
|
+
sequenceDiagram
|
|
265
|
+
participant H as history.js
|
|
266
|
+
participant E as Editor (journal client)
|
|
267
|
+
participant J as journal.js
|
|
268
|
+
H-->>E: New snapshot committed
|
|
269
|
+
E->>E: JSON Patch(last journaled doc, snapshot), throttled to 2 s
|
|
270
|
+
E->>J: POST entry { base: 14, seq: n, ops }
|
|
271
|
+
J->>J: Reject unless base == revision and seq == last + 1
|
|
272
|
+
J->>J: Append one NDJSON line
|
|
273
|
+
Note over E,J: On open: GET returns entries for the current revision → Recover replays them and validates with parseProjectJson
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The journal makes autosave cheap without rewriting parts on every edit. Patches address the whole-document form from `serializeProject`, so the server stores and replays them without understanding the model.
|
|
277
|
+
|
|
278
|
+
### Asset uploads
|
|
279
|
+
|
|
280
|
+
The editor sends one raw-body `POST` per file, up to four at a time. `assets.js` streams the body to a temporary file while hashing it and enforcing the size limit. It then checks magic bytes, sanitizes SVG, and renames the file into `assets/<sha256>.<ext>`. Identical bytes resolve to the existing file. The response is the asset entry that the editor adds to `project.assets` as an ordinary history-recorded edit.
|
|
281
|
+
|
|
282
|
+
### SWF import
|
|
283
|
+
|
|
284
|
+
```mermaid
|
|
285
|
+
flowchart LR
|
|
286
|
+
U[Upload .swf] --> L[Size and decompression limits]
|
|
287
|
+
L --> P[swf2js/parser]
|
|
288
|
+
P --> D[swf2js/decoder]
|
|
289
|
+
D --> I[swf-import.js<br/>timelines · shapes · bitmaps · sounds · text · actions]
|
|
290
|
+
I --> A[assets.js<br/>store extracted media]
|
|
291
|
+
I --> V[parseProjectJson]
|
|
292
|
+
V --> R[project + report]
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
`swf-import.js` reads only decoded tag structures and the symbol table. It never uses transpiler output. Media extraction reuses `emitter/asset-encoder.js` helpers for JPEG cleanup, PNG creation from RGBA, and sound dumps. Every approximation goes into the report.
|
|
296
|
+
|
|
297
|
+
### SWF export and publishing
|
|
298
|
+
|
|
299
|
+
```mermaid
|
|
300
|
+
flowchart LR
|
|
301
|
+
P[Saved project] --> X[swf-export.js<br/>depths · sampled tweens · symbols · actions]
|
|
302
|
+
X --> B[swf2js/encoder SwfBuilder]
|
|
303
|
+
B --> W[swf-writer]
|
|
304
|
+
W --> F[(.swf)]
|
|
305
|
+
F -->|?bundle=1| T[swf2js transpile + emit]
|
|
306
|
+
T --> Z[(HTML bundle .zip)]
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
`swf-export.js` turns Studio concepts into the builder's vocabulary: characters, depths, placements, frames, labels, and actions. It never writes bytes directly.
|
|
310
|
+
|
|
311
|
+
## 8. SWF encoder in swf2js (planned)
|
|
312
|
+
|
|
313
|
+
The encoder is the write-side mirror of the reader, with the same layering:
|
|
314
|
+
|
|
315
|
+
| Read side | Write side | Role |
|
|
316
|
+
|---|---|---|
|
|
317
|
+
| `parser/bit-reader.js` | `encoder/bit-writer.js` | Bit and byte primitives: UB/SB/FB, UI8–UI32, SI16, FIXED, FIXED8, EncodedU32, strings, RECT, MATRIX, CXFORM, CXFORMWITHALPHA, RGB, RGBA |
|
|
318
|
+
| `parser/swf-parser.js` | `encoder/swf-writer.js` | Header, FWS/CWS framing, tag headers, frame count, file length |
|
|
319
|
+
| `decoder/tag-decoder.js` | `encoder/tag-encoder.js` | Typed tag structure → tag body, dispatched by `type` |
|
|
320
|
+
| `decoder/shape-decoder.js` | `encoder/shape-encoder.js` | SHAPEWITHSTYLE from a path model with fill and line styles |
|
|
321
|
+
| `decoder/button-decoder.js` | `encoder/button-encoder.js` | Button records, conditions, and action blocks |
|
|
322
|
+
| `transpiler/avm1/avm1-opcodes.js` | `encoder/avm1-assembler.js` | Action records from an instruction list, with labels resolved to branch offsets |
|
|
323
|
+
| — | `encoder/swf-builder.js` | Character ID allocation, depth bookkeeping, per-frame display-list diffing, sprites, labels, scenes |
|
|
324
|
+
|
|
325
|
+
### Design rules
|
|
326
|
+
|
|
327
|
+
- **One vocabulary.** `tag-encoder` accepts the same typed structures documented in `decoder/tag-types.js`, and uses the same `TAG` codes. When the decoder output is lossy for a tag (shapes decode into draw lists), `tag-types.js` documents an explicit encoder input type and the encoder accepts that.
|
|
328
|
+
- **Portable core.** Encoders use `Uint8Array` and `DataView` only. `swf-writer` takes the deflate function as an argument, using `zlib.deflateSync` in Node and `CompressionStream` in a browser.
|
|
329
|
+
- **Correct by construction.** Field widths are computed from values. Tags that the format requires in long form (`DefineBits*`, `DefineBitsLossless*`, `SoundStreamBlock`) always use long headers. The builder rejects out-of-range values, unknown goto labels, and duplicate labels with clear errors.
|
|
330
|
+
- **No authoring concepts.** `swf2js/encoder` knows SWF only. Polygons, rounded rectangles, tweens, and Studio element types belong in `studio/server/swf-export.js`.
|
|
331
|
+
- **The reader is the test oracle.** Every encoder has round-trip tests through the parser and decoder. Bit-level primitives also have fast-check property tests.
|
|
332
|
+
|
|
333
|
+
### Relationship to `demos/source`
|
|
334
|
+
|
|
335
|
+
`demos/source/swf-writer.mjs` and `compile-avm1.mjs` were one-time scripts that produced the demo SWFs. They are reference material, not a starting point. They confirm working field layouts for PlaceObject2 move semantics, clipped bitmap fills, JPEG3 alpha, uncompressed PCM DefineSound, and DefineButton2 key conditions. The demo SWFs they produced become decode fixtures. The encoder's acceptance tests rebuild equivalent movies with `SwfBuilder` and compare the decoded tag lists (semantic equivalence, not byte identity).
|
|
336
|
+
|
|
337
|
+
A JavaScript-subset compiler to AVM1, like `compile-avm1.mjs`, is out of scope. If frame scripts are added later, a compiler would sit on top of `avm1-assembler.js`.
|
|
338
|
+
|
|
339
|
+
## 9. Dependency rules
|
|
340
|
+
|
|
341
|
+
| From | May import | Must not import |
|
|
342
|
+
|---|---|---|
|
|
343
|
+
| `studio/src` (browser) | Other `studio/src` modules; swooflib through the rendering adapter only | `swf2js/` (Node-only, and not served); server modules |
|
|
344
|
+
| `studio/server` | `swf2js/parser`, `swf2js/decoder`, `swf2js/encoder`, `swf2js/emitter/asset-encoder.js`; `studio/src` model modules that are pure (`project-io.js` and its dependencies) | DOM code, swooflib |
|
|
345
|
+
| `swf2js/encoder` | `swf2js/decoder/tag-types.js`, `swf2js/transpiler/avm1/avm1-opcodes.js` | Node built-ins, Studio |
|
|
346
|
+
| `swf2js/` (rest) | Its own modules | Studio |
|
|
347
|
+
|
|
348
|
+
The server shares `project-io.js` with the editor so validation runs in one place. That module and everything it imports must stay free of DOM access.
|
|
349
|
+
|
|
350
|
+
### Known structural debt
|
|
351
|
+
|
|
352
|
+
- ~~**Copied runtime.**~~ Resolved: the player modules live once in `swooflib/`. Studio's server maps `/swooflib/` to it, and swf2js assembles `swoof.js` from it. Studio's null-safety fixes were merged first.
|
|
353
|
+
- **Large controller.** `index.js` is about 2,600 lines and holds state, DOM wiring, and gesture handling. File support adds a project session (load, save, journal, dirty state). That session should go in its own module rather than grow `index.js`.
|
|
354
|
+
- **Cyclic imports in swooflib.** Studio imports `flash.js` first so the cycles initialize in a supported order. A narrow facade module would make this explicit.
|
|
355
|
+
|
|
356
|
+
## 10. Testing
|
|
357
|
+
|
|
358
|
+
| Layer | Runner | Scope |
|
|
359
|
+
|---|---|---|
|
|
360
|
+
| swf2js | `npm test` (vitest), `npm run test:integration` | Parser, decoder, transpilers, runtime, emitter; planned encoder round trips and property tests |
|
|
361
|
+
| Studio model | `node --test studio/*.test.js` | Pure model, project IO, and examples. Planned: server modules against temporary directories |
|
|
362
|
+
| Studio browser | `node studio/tests/timeline-browser.mjs` | Chromium via the DevTools protocol against `createStudioServer`. Covers authoring, preview, media, accessibility, and themes |
|
|
363
|
+
| Cross-system (planned) | Server tests | SWF import of the `demos/` SWFs; export → decode → re-import of the examples; publishing an exported SWF through swf2js and booting it in Chromium |
|
|
364
|
+
|
|
365
|
+
## 11. Key decisions
|
|
366
|
+
|
|
367
|
+
| Decision | Reason |
|
|
368
|
+
|---|---|
|
|
369
|
+
| Studio keeps its own document model instead of editing SWF timelines | Editing needs stable object identity, tweens, and typed actions. Compiled timelines are output-oriented |
|
|
370
|
+
| swooflib is reached only through the rendering adapter | Keeps runtime internals replaceable and avoids depending on transpiler data formats |
|
|
371
|
+
| Plain ES modules, no build step for Studio | Fast iteration, and the server can serve the source directly |
|
|
372
|
+
| `node:http` with no framework | Small surface area. Routes are a plain table, so they are easy to test in process |
|
|
373
|
+
| Project folders with hashed parts and an NDJSON journal | Saves write only what changed, commits are atomic, files stay diffable, and autosave is cheap |
|
|
374
|
+
| Raw-body uploads, one file per request | No multipart parser. Streaming, hashing, and limits stay simple |
|
|
375
|
+
| SWF writing lives in swf2js, not swooflib | It mirrors the existing reader and is tested by it. swooflib ships in every bundle and stays runtime-only |
|
|
376
|
+
| SWF export writes AVM1, at the scripts' own SWF version | Scripts keep their meaning: SWF 6 bytecode is case-insensitive, SWF 7 and later is not, so the version is never changed under them. Projects without scripts export as SWF 8 |
|
|
377
|
+
| Library-once storage everywhere | Like XFL's `LIBRARY/` and `bin/`: definitions, scripts, and media are stored once and referenced by ID. Studio projects already do this; swf2js bundles adopt it in compact-bundle-format |
|
|
378
|
+
| Compress on the wire, keep JSON for documents | The project JSON compresses 15–20× (Castle Hero: 57.7 MB → 2.9 MB with brotli), stays diffable, and works with the JSON Patch journal. Binary formats are used where data is numeric and never edited by hand (bundle geometry) |
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Input controls
|
|
2
|
+
|
|
3
|
+
Related: [actionscript.md](./actionscript.md) (scripts and scripted Preview), [file-support.md](./file-support.md) (SWF import), [tasks.md §13](./tasks.md).
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Flash movies take input through more than buttons and text fields. Authors dragged check boxes, radio buttons, combo boxes, lists, steppers and scroll bars from the Components panel, set their parameters in the Component Inspector, and read them from ActionScript. Studio should do the same: keep those controls when it imports a SWF, let the author see and change their parameters, and offer the same controls for new projects.
|
|
8
|
+
|
|
9
|
+
### Using controls in Studio
|
|
10
|
+
|
|
11
|
+
Open **Inputs** on the stage toolbar and choose a control. Click the stage to place it at its default size, or drag to set its bounds. The Component Inspector exposes parameters, a variable binding and the events available under **Control actions**. Choice lists support one label per line. Data-grid rows and other structured data use JSON.
|
|
12
|
+
|
|
13
|
+
All 25 kinds listed below are available in the editor. Ordinary Preview uses native browser inputs. Scripted Preview exposes an authored control by its instance name to AVM1. Imported Flash MX and v2 components keep the artwork and ActionScript from the source SWF. Native SWF publishing uses Flash MovieClips with AVM1 constructors, device text fields and the drawing API. Custom collection layouts and the RGB color editor appear in the export report. An AS3 movie reports authored AVM1 controls as dropped.
|
|
14
|
+
|
|
15
|
+
### What a SWF contains
|
|
16
|
+
|
|
17
|
+
Flash Player has only two built-in input objects: buttons (`DefineButton`, `DefineButton2`) and editable text fields (`DefineEditText` without `readOnly`). Mouse and keyboard events (`onClipEvent`, `Key`, `Mouse`) complete the picture. Studio already converts all three.
|
|
18
|
+
|
|
19
|
+
Every other control is a **component**: library symbols (skins, states, hit areas) plus ActionScript classes, compiled into the SWF. Three generations exist:
|
|
20
|
+
|
|
21
|
+
| Generation | Player | Symbols and classes | Parameters on each instance |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| Flash MX UI components | 6 | `FPushButtonSymbol`, `FCheckBoxSymbol`, `FRadioButtonSymbol`, `FComboBoxSymbol`, `FListBoxSymbol`, `FScrollBarSymbol`, `FScrollPaneSymbol`; classes in `#initclip` | `onClipEvent(initialize)` |
|
|
24
|
+
| Version 2 components (AS2) | 7–8 | `mx.controls.*` and `mx.containers.*`, linked by name; classes in `__Packages.*` init code | `onClipEvent(construct)` |
|
|
25
|
+
| ActionScript 3 components | 9+ | `fl.controls.*` in `DoABC` | `[Inspectable]` metadata and component-shim data |
|
|
26
|
+
|
|
27
|
+
The parameter handlers are plain assignments. Interactive Buddy's combo box:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
onClipEvent (construct) { editable = false; labels = []; labels[0] = "Minimum"; labels[1] = "Half"; labels[2] = "Full"; rowCount = 5; enabled = true; visible = true; minHeight = 0; minWidth = 0; }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The archive uses these components: Interactive Buddy (Button, CheckBox, ComboBox, List, NumericStepper, TextInput, TextArea, Label, Window, scroll bars), Motherload (Button, CheckBox, `FScrollBar`), Minesweeper (`FRadioButton`), Super Smash Flash (`UIScrollBar`, Button). Strike Force Heroes 3 also uses AS3 components, including fl.controls.CheckBox, RadioButton and Slider.
|
|
34
|
+
|
|
35
|
+
## Control kinds
|
|
36
|
+
|
|
37
|
+
Tier 1 is what forms and game menus use. Tier 2 is the rest of the Flash component sets.
|
|
38
|
+
|
|
39
|
+
| Kind | Tier | Parameters (Studio names follow the v2 names) | Value | Change event |
|
|
40
|
+
|---|---|---|---|---|
|
|
41
|
+
| Button | 1 | `label`, `icon`, `labelPlacement`, `toggle`, `selected` | `selected` (toggle) | `click` |
|
|
42
|
+
| CheckBox | 1 | `label`, `labelPlacement`, `selected` | `selected` | `click` |
|
|
43
|
+
| RadioButton | 1 | `label`, `labelPlacement`, `groupName`, `data`, `selected` | group's `selectedData` | `click` |
|
|
44
|
+
| ComboBox | 1 | `labels`, `data`, `editable`, `rowCount` | `selectedIndex`, `value` | `change` |
|
|
45
|
+
| List | 1 | `labels`, `data`, `multipleSelection`, `rowHeight` | `selectedIndex`, `selectedIndices` | `change` |
|
|
46
|
+
| TextInput | 1 | `text`, `editable`, `password`, `maxChars`, `restrict` | `text` | `change`, `enter` |
|
|
47
|
+
| TextArea | 1 | `text`, `editable`, `html`, `wordWrap` | `text` | `change` |
|
|
48
|
+
| NumericStepper | 1 | `minimum`, `maximum`, `stepSize`, `value` | `value` | `change` |
|
|
49
|
+
| Slider | 1 | `minimum`, `maximum`, `snapInterval`, `value`, `direction` | `value` | `change` |
|
|
50
|
+
| ScrollBar (`UIScrollBar`) | 1 | `scrollTargetName`, `horizontal` | `scrollPosition` | `scroll` |
|
|
51
|
+
| ScrollPane | 1 | `contentPath`, `hScrollPolicy`, `vScrollPolicy` | scroll position | `scroll` |
|
|
52
|
+
| ProgressBar | 1 | `mode`, `source`, `direction`, `label` | `percentComplete` | `progress`, `complete` |
|
|
53
|
+
| Label | 1 | `text`, `html`, `autoSize` | none | none |
|
|
54
|
+
| DataGrid, TileList | 2 | `dataProvider`, columns | `selectedIndex` | `change` |
|
|
55
|
+
| ColorPicker | 2 | `selectedColor` | `selectedColor` | `change` |
|
|
56
|
+
| Window, Alert | 2 | `title`, `closeButton`, `contentPath` | none | `click`, `close` |
|
|
57
|
+
| Menu, MenuBar, Tree, Accordion | 2 | `labels` or XML data | selected item | `change` |
|
|
58
|
+
| DateChooser, DateField | 2 | `selectedDate`, `dayNames`, `firstDayOfWeek` | `selectedDate` | `change` |
|
|
59
|
+
| Loader (`UILoader`) | 2 | `contentPath`, `autoLoad`, `scaleContent` | `percentLoaded` | `complete` |
|
|
60
|
+
|
|
61
|
+
Every control has `enabled` and `visible`. A control's value may be bound to a variable (`variable`), as a text field's `field.variable` is: the variable holds the value, and setting the variable updates the control.
|
|
62
|
+
|
|
63
|
+
## Requirements
|
|
64
|
+
|
|
65
|
+
### 1. Imported components (path A)
|
|
66
|
+
|
|
67
|
+
An imported component keeps running the SWF's own component code in Preview. Studio does not replace it with its own control, because game scripts call the component's own API (`qualCombo.selectedIndex`, `cb.addEventListener("click", …)`) and its skins are part of the movie's look.
|
|
68
|
+
|
|
69
|
+
1. THE import SHALL keep component symbols, their linkage names, and their initialization code, and Preview SHALL run initialization code in the SWF's definition order (base classes first). Done: Minesweeper's radio buttons and Interactive Buddy's menu bar now appear in Preview.
|
|
70
|
+
2. THE import SHALL recognize a component symbol from its linkage name (`F<Kind>Symbol` for Flash MX, `<Kind>` for v2; the `__Packages.mx.controls.*` symbols only hold class code and are not components) and mark it `symbol.component = { kind, generation: 'mx' | 'v2' }`.
|
|
71
|
+
3. THE import SHALL decode a component instance's parameter handler when it consists only of constant assignments (strings, numbers, booleans, `null`, arrays and objects of those) into `element.component = { kind, event: 'initialize' | 'construct', parameters }`, and SHALL NOT also keep it as a script. A handler with any other code SHALL stay a script, and the inspector SHALL show its parameters read-only.
|
|
72
|
+
4. Preview SHALL regenerate the parameter handler from `element.component.parameters`. For an unedited instance, the generated bytecode SHALL produce the same assignments, in the same order, as the original.
|
|
73
|
+
5. THE inspector SHALL show a component instance's kind and parameters, typed by value (text, number, check box, list of values), and edits SHALL be undoable and saved.
|
|
74
|
+
6. Component code defined after frame 1 (v2 movies often define classes in frame 2, after a preloader) SHALL run when its frame is reached, not at load. Studio preserves the initializer's scene and frame. Motherload registers different scrollbar classes on frames 1 and 3.
|
|
75
|
+
|
|
76
|
+
### 2. Studio controls (path B)
|
|
77
|
+
|
|
78
|
+
1. THE editor SHALL offer each tier 1 kind as a new object type, `{ type: 'control', control: <kind>, parameters, variable? }`, with a default size and parameters, drawn by swooflib in the editor and in Preview.
|
|
79
|
+
2. swooflib SHALL provide the controls as display objects in `swooflib/controls.js`, with a v2-style API: the parameters as properties, `getValue`/`setValue` where v2 has them, and `addEventListener(event, listener)` for the change events above. Radio buttons with the same `groupName` in one timeline form a group.
|
|
80
|
+
3. Studio's own preview SHALL handle pointer and keyboard input on controls (focus, Tab order, arrow keys, Space and Enter) and SHALL keep each control's value across frames while it stays on the stage.
|
|
81
|
+
4. Timeline events SHALL accept the control's change event as a trigger on that control (`{ trigger: 'change', … }`), with the existing typed actions.
|
|
82
|
+
5. In scripted Preview, a control SHALL be reachable by its instance name from AVM1 scripts, with the same properties, methods and events, so a script written for a v2 component works on a Studio control.
|
|
83
|
+
6. AVM1 SWF export SHALL publish each authored control as a linked MovieClip with its parameters, methods, bindings and event handlers. Imported v2 components retain the original symbols and classes.
|
|
84
|
+
|
|
85
|
+
### 3. Coverage and limits
|
|
86
|
+
|
|
87
|
+
1. Kinds the archive contains (Button, CheckBox, RadioButton, ComboBox, List, NumericStepper, TextInput, TextArea, Label, ScrollBar, Window) SHALL be tested against those SWFs. The other kinds SHALL be tested against fixtures.
|
|
88
|
+
2. Imported ActionScript 3 components (`fl.controls`) run the movie’s compiled class code and skins in the swf2js player. Their AS3 source and class parameters have no authoring inspector.
|
|
89
|
+
|
|
90
|
+
## Design notes
|
|
91
|
+
|
|
92
|
+
- **Parameters as data, code as code.** The parameter handler is the one script Flash generated rather than the author wrote, so Studio decodes it into data the inspector can edit, and regenerates it. Everything else stays bytecode.
|
|
93
|
+
- **One set of names.** Studio controls use the v2 parameter and event names, so imported and authored controls read the same in the inspector, and export can target v2 components.
|
|
94
|
+
- **Generation matters for the event only.** Flash MX components read their parameters in `initialize`, v2 components in `construct`; `element.component.event` keeps which one to regenerate.
|
|
95
|
+
|
|
96
|
+
## Acceptance
|
|
97
|
+
|
|
98
|
+
- Minesweeper: the three difficulty radio buttons show, clicking one moves the selection, and the inspector shows each one's `label`, `groupName`, `data` and `selected`. Changing a label is reflected in Preview.
|
|
99
|
+
- Interactive Buddy: the File menu opens, the combo box shows Minimum, Half and Full, and the stepper's range is 1–40.
|
|
100
|
+
- A new project with one of each tier 1 control works in Studio's preview and in scripted Preview, and a change event runs its actions.
|