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,55 @@
|
|
|
1
|
+
// SWF file framing: tag records and the file header. Compression is injected (`deflate`
|
|
2
|
+
// returning zlib data) so this module has no Node dependencies.
|
|
3
|
+
import { BitWriter } from './bit-writer.js';
|
|
4
|
+
import { TAG } from '../decoder/tag-types.js';
|
|
5
|
+
|
|
6
|
+
// Bitmap tags are always written with the long header, as Flash's own output does; some
|
|
7
|
+
// players read their size from it.
|
|
8
|
+
const LONG_FORM = new Set([TAG.DefineBits, TAG.DefineBitsJPEG2, TAG.DefineBitsJPEG3, TAG.DefineBitsLossless, TAG.DefineBitsLossless2]);
|
|
9
|
+
|
|
10
|
+
/** One tag record: header (short or long form) and body. */
|
|
11
|
+
export function encodeTag(code, body = new Uint8Array(0)) {
|
|
12
|
+
const long = body.length >= 63 || LONG_FORM.has(code);
|
|
13
|
+
const out = new Uint8Array((long ? 6 : 2) + body.length);
|
|
14
|
+
const header = (code << 6) | (long ? 63 : body.length);
|
|
15
|
+
out[0] = header & 0xff;
|
|
16
|
+
out[1] = header >> 8;
|
|
17
|
+
if (long) {
|
|
18
|
+
out[2] = body.length & 0xff;
|
|
19
|
+
out[3] = (body.length >> 8) & 0xff;
|
|
20
|
+
out[4] = (body.length >> 16) & 0xff;
|
|
21
|
+
out[5] = (body.length >>> 24) & 0xff;
|
|
22
|
+
}
|
|
23
|
+
out.set(body, long ? 6 : 2);
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function concatBytes(parts) {
|
|
28
|
+
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
29
|
+
const out = new Uint8Array(total);
|
|
30
|
+
let offset = 0;
|
|
31
|
+
for (const part of parts) {
|
|
32
|
+
out.set(part, offset);
|
|
33
|
+
offset += part.length;
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Write a SWF file. `frameSize` is a RECT in twips; `tags` are encoded tag records (an End tag
|
|
40
|
+
* is added). With `deflate`, the file is compressed (CWS).
|
|
41
|
+
*/
|
|
42
|
+
export function writeSwf({ version, frameSize, frameRate, frameCount, tags, deflate = null }) {
|
|
43
|
+
const head = new BitWriter();
|
|
44
|
+
head.writeRect(frameSize);
|
|
45
|
+
head.writeUI16(Math.round(frameRate * 256));
|
|
46
|
+
head.writeUI16(frameCount);
|
|
47
|
+
const body = concatBytes([head.toBytes(), ...tags, encodeTag(TAG.End)]);
|
|
48
|
+
const fileLength = 8 + body.length;
|
|
49
|
+
const payload = deflate ? deflate(body) : body;
|
|
50
|
+
const out = new Uint8Array(8 + payload.length);
|
|
51
|
+
out.set([deflate ? 0x43 : 0x46, 0x57, 0x53, version], 0);
|
|
52
|
+
out.set([fileLength & 0xff, (fileLength >> 8) & 0xff, (fileLength >> 16) & 0xff, (fileLength >>> 24) & 0xff], 4);
|
|
53
|
+
out.set(payload, 8);
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* The browser file has no import statements.
|
|
4
4
|
*/
|
|
5
5
|
import esbuild from 'esbuild';
|
|
6
|
-
import { dirname } from 'path';
|
|
6
|
+
import { dirname, join } from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// The runtime modules live in swooflib/ at the repository root, shared with Studio.
|
|
10
|
+
const dir = join(dirname(fileURLToPath(import.meta.url)), '../../swooflib');
|
|
10
11
|
|
|
11
12
|
export const SWFLIB_ENTRY = 'builtins.js';
|
|
12
13
|
|
|
@@ -23,7 +24,7 @@ export function assembleSwflibSource() {
|
|
|
23
24
|
banner: {
|
|
24
25
|
js: `/**
|
|
25
26
|
* swoof swflib — shared SWF player.
|
|
26
|
-
* Built from the ES modules in
|
|
27
|
+
* Built from the ES modules in swooflib/.
|
|
27
28
|
* Loaded before bundle.js:
|
|
28
29
|
* <script src="swoof.js"></script>
|
|
29
30
|
* <script src="bundle.js"></script>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createXMLNodeClass } from '../../swooflib/xml-node.js';
|
|
2
|
+
import { avm1KeyPressCode, buttonRecordsFor as getButtonRecords, compareDisplayDepthPaths, drawPathBounds, findTimelineLabel, frameHasLabel, hasAvm1ButtonHandlers, morphBoundsFor, morphDrawsFor as getMorphDraws, pixelHintPath, pointInStrokePlan as mapStrokePoint, pointOnStroke as strokeContainsPoint, prepareStrokeOutput as planStrokeOutput, transformFillToOutputPixels, transformPathToOutputPixels } from '../transpiler/timeline/timeline-codegen.js';
|
|
2
3
|
|
|
3
4
|
// Keep these local names stable when the hit-test functions are emitted as source.
|
|
5
|
+
const buttonRecordsFor = getButtonRecords;
|
|
4
6
|
const pointOnStroke = strokeContainsPoint;
|
|
5
7
|
const pointInStrokePlan = mapStrokePoint;
|
|
6
8
|
const prepareStrokeOutput = planStrokeOutput;
|
|
@@ -658,6 +660,16 @@ Avm1MovieClip.prototype.hitTest = function (a, b, c) {
|
|
|
658
660
|
return _hitTestImpl(this, a, b, c);
|
|
659
661
|
};
|
|
660
662
|
Avm1MovieClip.prototype.getBounds = _mcGetBounds;
|
|
663
|
+
// Built-in clip members are not listed by for…in in Flash, which lists child clips and script
|
|
664
|
+
// variables only (Pacman hides its ghosts with \`for (g in Ghost) Ghost[g]._visible = false\`).
|
|
665
|
+
// The names are kept on the prototype (\`_swoofNativeKeys\`) when the first clip is made, once the
|
|
666
|
+
// prototype is complete, so for…in can read them from the clip whichever runtime copy enumerates it.
|
|
667
|
+
function _avm1RecordNativeClipKeys(raw) {
|
|
668
|
+
if (Object.prototype.hasOwnProperty.call(Avm1MovieClip.prototype, '_swoofNativeKeys')) return;
|
|
669
|
+
var keys = new Set(Object.getOwnPropertyNames(raw).concat(Object.getOwnPropertyNames(Avm1MovieClip.prototype)));
|
|
670
|
+
for (var key in Avm1MovieClip.prototype) keys.add(key);
|
|
671
|
+
Object.defineProperty(Avm1MovieClip.prototype, '_swoofNativeKeys', { value: keys });
|
|
672
|
+
}
|
|
661
673
|
|
|
662
674
|
var _linkageByName = Object.create(null); // symbolName → constructor or characterId
|
|
663
675
|
var _linkageById = Object.create(null); // characterId → constructor
|
|
@@ -1030,6 +1042,26 @@ if (typeof STAGE_WIDTH === 'number' && typeof STAGE_HEIGHT === 'number') {
|
|
|
1030
1042
|
}
|
|
1031
1043
|
}
|
|
1032
1044
|
}
|
|
1045
|
+
var Avm1XMLNode = (${createXMLNodeClass.toString()})();
|
|
1046
|
+
function avm1TextFieldClass(builtins) {
|
|
1047
|
+
if (!builtins?.TextField || !builtins.StyleSheet) return builtins?.TextField;
|
|
1048
|
+
function LegacyTextField(...args) { return Reflect.construct(builtins.TextField, args); }
|
|
1049
|
+
LegacyTextField.prototype = builtins.TextField.prototype;
|
|
1050
|
+
Object.setPrototypeOf(LegacyTextField, builtins.TextField);
|
|
1051
|
+
LegacyTextField.StyleSheet = class extends builtins.StyleSheet {
|
|
1052
|
+
getStyleNames() { return this.styleNames; }
|
|
1053
|
+
parseCSS(source) { return this._parseCSSRules(source); }
|
|
1054
|
+
load(url) {
|
|
1055
|
+
if (url == null || String(url) === '') return false;
|
|
1056
|
+
return requestAvm1Xml(this, _avm1URLRequest(String(url), 0));
|
|
1057
|
+
}
|
|
1058
|
+
onData(source) {
|
|
1059
|
+
this.loaded = source !== undefined && this.parseCSS(source);
|
|
1060
|
+
this.onLoad?.(this.loaded);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
return LegacyTextField;
|
|
1064
|
+
}
|
|
1033
1065
|
function avm1MoviePackages() {
|
|
1034
1066
|
var library = avm1FlashPackages && typeof avm1FlashPackages === 'object' ? avm1FlashPackages : null;
|
|
1035
1067
|
var swoof = library ? Object.create(library) : {};
|
|
@@ -1060,7 +1092,7 @@ var globals = {
|
|
|
1060
1092
|
Color: Color,
|
|
1061
1093
|
ColorTransform: typeof ColorTransform !== 'undefined' ? ColorTransform : undefined,
|
|
1062
1094
|
MovieClip: Avm1MovieClip,
|
|
1063
|
-
TextField: typeof __swoof_swflib !== 'undefined' ? __swoof_swflib.builtins
|
|
1095
|
+
TextField: typeof __swoof_swflib !== 'undefined' ? avm1TextFieldClass(__swoof_swflib.builtins) : undefined,
|
|
1064
1096
|
MovieClipLoader: MovieClipLoader,
|
|
1065
1097
|
XML: Avm1XML,
|
|
1066
1098
|
XMLNode: Avm1XMLNode,
|
|
@@ -1378,10 +1410,17 @@ function _avm1Enumerate(object, stack) {
|
|
|
1378
1410
|
stack.push(null);
|
|
1379
1411
|
var clip = _avm1MovieClips.has(object);
|
|
1380
1412
|
var drawingSize = _avm1HasDrawingSize(_avm1ClipRaw.get(object));
|
|
1413
|
+
var raw = clip ? _avm1ClipRaw.get(object) : null;
|
|
1414
|
+
var natives = clip ? object._swoofNativeKeys : null;
|
|
1381
1415
|
for (var key in (object || {})) {
|
|
1382
1416
|
if (clip && key === 'x' && !(_avm1ScriptX in object)) continue;
|
|
1383
1417
|
if (clip && key === 'y' && !(_avm1ScriptY in object)) continue;
|
|
1384
1418
|
if (drawingSize && (key === 'width' || key === 'height') && !(_avm1DisplayMemberSlot(key) in object)) continue;
|
|
1419
|
+
if (clip && key !== 'x' && key !== 'y' && !(drawingSize && (key === 'width' || key === 'height'))) {
|
|
1420
|
+
if (key.startsWith('_swoof')) continue;
|
|
1421
|
+
if (key === 'name') { if (raw && avm1NameMember in raw) stack.push(key); continue; }
|
|
1422
|
+
if (natives && natives.has(key)) continue;
|
|
1423
|
+
}
|
|
1385
1424
|
stack.push(key);
|
|
1386
1425
|
}
|
|
1387
1426
|
return stack;
|
|
@@ -1487,7 +1526,18 @@ function _avm1URLRequest(url, method, entries) {
|
|
|
1487
1526
|
return { url: url, method: 'GET', body: null };
|
|
1488
1527
|
}
|
|
1489
1528
|
|
|
1529
|
+
var _avm1RequestPolicy = typeof __swoof_swflib !== 'undefined' && __swoof_swflib.allowMovieRequest;
|
|
1530
|
+
function _avm1AllowsRequest(url, kind) {
|
|
1531
|
+
return !_avm1RequestPolicy || _avm1RequestPolicy(url, kind);
|
|
1532
|
+
}
|
|
1490
1533
|
function _avm1Fetch(request, signal, onStatus) {
|
|
1534
|
+
if (!_avm1AllowsRequest(request.url, 'data request')) {
|
|
1535
|
+
return Promise.resolve().then(function () {
|
|
1536
|
+
signal?.throwIfAborted?.();
|
|
1537
|
+
onStatus?.(200);
|
|
1538
|
+
return { ok: true, status: 200, text: async () => '', arrayBuffer: async () => new ArrayBuffer(0) };
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1491
1541
|
var options = { method: request.method };
|
|
1492
1542
|
if (signal) options.signal = signal;
|
|
1493
1543
|
if (request.body != null) {
|
|
@@ -1507,54 +1557,6 @@ function _avm1Fetch(request, signal, onStatus) {
|
|
|
1507
1557
|
});
|
|
1508
1558
|
}
|
|
1509
1559
|
|
|
1510
|
-
function Avm1XMLNode(type, value) {
|
|
1511
|
-
this.nodeType = type | 0;
|
|
1512
|
-
this.nodeName = this.nodeType === 1 && value != null ? String(value) : null;
|
|
1513
|
-
this.nodeValue = this.nodeType === 3 && value != null ? String(value) : null;
|
|
1514
|
-
this.childNodes = [];
|
|
1515
|
-
this.attributes = Object.create(null);
|
|
1516
|
-
this.parentNode = null;
|
|
1517
|
-
}
|
|
1518
|
-
function avm1XmlSibling(node, delta) {
|
|
1519
|
-
var siblings = node.parentNode?.childNodes;
|
|
1520
|
-
return siblings?.[siblings.indexOf(node) + delta] || null;
|
|
1521
|
-
}
|
|
1522
|
-
Object.defineProperties(Avm1XMLNode.prototype, {
|
|
1523
|
-
firstChild: { get: function () { return this.childNodes[0] || null; } },
|
|
1524
|
-
lastChild: { get: function () { return this.childNodes[this.childNodes.length - 1] || null; } },
|
|
1525
|
-
previousSibling: { get: function () { return avm1XmlSibling(this, -1); } },
|
|
1526
|
-
nextSibling: { get: function () { return avm1XmlSibling(this, 1); } },
|
|
1527
|
-
});
|
|
1528
|
-
Avm1XMLNode.prototype.appendChild = function (child) {
|
|
1529
|
-
if (!(child instanceof Avm1XMLNode) || this.nodeType !== 1) return;
|
|
1530
|
-
for (var ancestor = this; ancestor; ancestor = ancestor.parentNode) {
|
|
1531
|
-
if (ancestor === child) return;
|
|
1532
|
-
}
|
|
1533
|
-
child.removeNode();
|
|
1534
|
-
child.parentNode = this;
|
|
1535
|
-
this.childNodes.push(child);
|
|
1536
|
-
};
|
|
1537
|
-
Avm1XMLNode.prototype.removeNode = function () {
|
|
1538
|
-
var siblings = this.parentNode?.childNodes;
|
|
1539
|
-
var index = siblings ? siblings.indexOf(this) : -1;
|
|
1540
|
-
if (index >= 0) siblings.splice(index, 1);
|
|
1541
|
-
this.parentNode = null;
|
|
1542
|
-
};
|
|
1543
|
-
Avm1XMLNode.prototype.hasChildNodes = function () { return !!this.childNodes.length; };
|
|
1544
|
-
function avm1XmlEscape(value) {
|
|
1545
|
-
return String(value ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
1546
|
-
}
|
|
1547
|
-
Avm1XMLNode.prototype.toString = function () {
|
|
1548
|
-
if (this.nodeType === 3) return avm1XmlEscape(this.nodeValue);
|
|
1549
|
-
var content = this.childNodes.join('');
|
|
1550
|
-
if (!this.nodeName) return content;
|
|
1551
|
-
var start = '<' + this.nodeName;
|
|
1552
|
-
for (var name of Object.keys(this.attributes)) {
|
|
1553
|
-
start += ' ' + name + '="' + avm1XmlEscape(this.attributes[name]).replace(/"/g, '"') + '"';
|
|
1554
|
-
}
|
|
1555
|
-
return content ? start + '>' + content + '</' + this.nodeName + '>' : start + ' />';
|
|
1556
|
-
};
|
|
1557
|
-
|
|
1558
1560
|
function Avm1XML(source) {
|
|
1559
1561
|
Avm1XMLNode.call(this, 1, null);
|
|
1560
1562
|
this.loaded = undefined;
|
|
@@ -1764,12 +1766,18 @@ function _avm1Navigate(request, target, entries) {
|
|
|
1764
1766
|
if (request.method !== 'POST') {
|
|
1765
1767
|
var navigate = typeof __swoof_swflib !== 'undefined' && __swoof_swflib?.builtins?.navigateToURL;
|
|
1766
1768
|
if (typeof navigate === 'function') navigate(request, target);
|
|
1767
|
-
else if (typeof window.open === 'function') window.open(request.url, target);
|
|
1769
|
+
else if (typeof window.open === 'function' && _avm1AllowsRequest(request.url, 'navigation')) window.open(request.url, target);
|
|
1768
1770
|
return;
|
|
1769
1771
|
}
|
|
1770
|
-
if (typeof document === 'undefined' || !document?.body) return;
|
|
1772
|
+
if (typeof document === 'undefined' || !document?.body || !_avm1AllowsRequest(request.url, 'form submission')) return;
|
|
1773
|
+
if (typeof __swoof_swflib !== 'undefined' && __swoof_swflib.requestMovieNavigation) {
|
|
1774
|
+
__swoof_swflib.requestMovieNavigation(request.url, function (href) { _avm1SubmitForm(href, '_blank', entries); });
|
|
1775
|
+
} else _avm1SubmitForm(request.url, target, entries);
|
|
1776
|
+
}
|
|
1777
|
+
function _avm1SubmitForm(url, target, entries) {
|
|
1771
1778
|
var form = document.createElement('form');
|
|
1772
|
-
form.
|
|
1779
|
+
form.rel = 'noopener noreferrer';
|
|
1780
|
+
form.method = 'post'; form.action = url; form.target = target; form.hidden = true;
|
|
1773
1781
|
for (var [name, value] of entries) {
|
|
1774
1782
|
var input = document.createElement('input');
|
|
1775
1783
|
input.type = 'hidden'; input.name = name; input.value = value;
|
|
@@ -1966,6 +1974,7 @@ function _avm1LoadMovie(clip, request, notify) {
|
|
|
1966
1974
|
function load(src) {
|
|
1967
1975
|
if (!current()) return;
|
|
1968
1976
|
var image = active.image = new globalThis.Image();
|
|
1977
|
+
if (typeof __swoof_swflib !== 'undefined' && __swoof_swflib.needsMovieAssetCors?.(src)) image.crossOrigin = 'anonymous';
|
|
1969
1978
|
image.onload = function () {
|
|
1970
1979
|
if (!current()) return;
|
|
1971
1980
|
start();
|
|
@@ -2015,7 +2024,24 @@ function _avm1LoadMovie(clip, request, notify) {
|
|
|
2015
2024
|
var http = /^(?:https?:)?\\/\\//i.test(request.url) ||
|
|
2016
2025
|
!/^[a-z][a-z\\d+.-]*:/i.test(request.url) && /^https?:$/.test(globalThis.location?.protocol);
|
|
2017
2026
|
var fetchBytes = request.method !== 'GET' || notify && http;
|
|
2018
|
-
if (
|
|
2027
|
+
if (!_avm1AllowsRequest(request.url, 'image')) {
|
|
2028
|
+
Promise.resolve().then(function () {
|
|
2029
|
+
if (!current()) return;
|
|
2030
|
+
start();
|
|
2031
|
+
if (!current()) return;
|
|
2032
|
+
active.status = 200;
|
|
2033
|
+
notify?.('onLoadProgress', [0, 0]);
|
|
2034
|
+
if (!current()) return;
|
|
2035
|
+
var canvas = globalThis.document.createElement('canvas');
|
|
2036
|
+
canvas.width = canvas.height = 1;
|
|
2037
|
+
notify?.('onLoadComplete', statusArgs());
|
|
2038
|
+
if (!current()) return;
|
|
2039
|
+
_avm1CancelMovieLoad(clip);
|
|
2040
|
+
_avm1ReplaceMovie(clip, canvas, request.url);
|
|
2041
|
+
if (typeof clip.onData === 'function') runClipScript(clip, clip.onData);
|
|
2042
|
+
if (avm1MovieProgress.get(clip) === progress) notify?.('onLoadInit', []);
|
|
2043
|
+
});
|
|
2044
|
+
} else if (fetchBytes && typeof globalThis.fetch === 'function' && globalThis.URL?.createObjectURL) {
|
|
2019
2045
|
if (typeof globalThis.AbortController === 'function') active.controller = new globalThis.AbortController();
|
|
2020
2046
|
_avm1Fetch(request, active.controller?.signal, function (status) { active.status = status; })
|
|
2021
2047
|
.then(readImage).catch(fail);
|
|
@@ -2694,7 +2720,7 @@ function _avm1HasDrawingSize(clip) {
|
|
|
2694
2720
|
!clip._swoofLoadedImage && !clip._swoofMovieUnloaded && !clip._swoofAttachedBitmap;
|
|
2695
2721
|
}
|
|
2696
2722
|
|
|
2697
|
-
function _clipBounds(mc, includeBitmapChildren = true) {
|
|
2723
|
+
function _clipBounds(mc, includeBitmapChildren = true, mode = 'shape') {
|
|
2698
2724
|
if (!mc) return { x: 0, y: 0, w: 0, h: 0 };
|
|
2699
2725
|
var w = +_clipStoredDimension(mc, 'width') || 0;
|
|
2700
2726
|
var h = +_clipStoredDimension(mc, 'height') || 0;
|
|
@@ -2702,8 +2728,8 @@ function _clipBounds(mc, includeBitmapChildren = true) {
|
|
|
2702
2728
|
if ((!w || !h) && mc._swoofCharacterId != null && typeof CHARACTERS !== 'undefined') {
|
|
2703
2729
|
var id = mc._swoofCharacterId;
|
|
2704
2730
|
var info = CHARACTERS[String(id)];
|
|
2705
|
-
var bounds = info?.morph ? morphBoundsFor(info, mc._swoofMaskRatio) :
|
|
2706
|
-
info?.bounds || (typeof authoredSpriteBounds === 'function' && authoredSpriteBounds(id, mc));
|
|
2731
|
+
var bounds = info?.morph && mode === 'live' ? morphBoundsFor(info, mc._swoofMaskRatio) :
|
|
2732
|
+
info?.bounds || (typeof authoredSpriteBounds === 'function' && authoredSpriteBounds(id, mc, 0, undefined, undefined, mode));
|
|
2707
2733
|
if (bounds) {
|
|
2708
2734
|
if (!w) w = bounds.w;
|
|
2709
2735
|
if (!h) h = bounds.h;
|
|
@@ -2737,7 +2763,7 @@ function _mcGetBounds(coordinateSpace) {
|
|
|
2737
2763
|
return _avm1GeometryBounds(this, matrix) || { xMin: 0, yMin: 0, xMax: 0, yMax: 0 };
|
|
2738
2764
|
}
|
|
2739
2765
|
|
|
2740
|
-
function _avm1GeometryBounds(clip, matrix) {
|
|
2766
|
+
function _avm1GeometryBounds(clip, matrix, mode = 'shape') {
|
|
2741
2767
|
var xMin = Infinity, yMin = Infinity, xMax = -Infinity, yMax = -Infinity;
|
|
2742
2768
|
function include(bounds, transform) {
|
|
2743
2769
|
if (!bounds || !(bounds.w || bounds.h)) return;
|
|
@@ -2747,7 +2773,7 @@ function _avm1GeometryBounds(clip, matrix) {
|
|
|
2747
2773
|
}
|
|
2748
2774
|
function visit(clip, transform, includeSymbol, depth) {
|
|
2749
2775
|
if (depth > 24) return;
|
|
2750
|
-
if (includeSymbol) include(_clipBounds(clip, false), transform);
|
|
2776
|
+
if (includeSymbol) include(_clipBounds(clip, false, mode), transform);
|
|
2751
2777
|
for (var draw of clip._swoofDraws || []) include(drawPathBounds(draw), transform);
|
|
2752
2778
|
for (var child of Object.values(clip._swoofChildren || {})) {
|
|
2753
2779
|
if (child?.parent === clip && !child._swoofDetached) visit(child, composeAvm1HitMatrix(transform, _clipMatrix(child)), true, depth + 1);
|
|
@@ -2839,16 +2865,16 @@ function _hitTestImpl(mc, a, b, c, visibleOnly, pointIsStage) {
|
|
|
2839
2865
|
);
|
|
2840
2866
|
if (shapeHit != null) return shapeHit;
|
|
2841
2867
|
}
|
|
2842
|
-
var bounds = _clipHitBounds(mc);
|
|
2868
|
+
var bounds = _clipHitBounds(mc, 'live');
|
|
2843
2869
|
return bounds.right > bounds.left && bounds.bottom > bounds.top &&
|
|
2844
2870
|
x >= bounds.left && x <= bounds.right && y >= bounds.top && y <= bounds.bottom;
|
|
2845
2871
|
}
|
|
2846
2872
|
|
|
2847
|
-
function _clipHitBounds(clip) {
|
|
2873
|
+
function _clipHitBounds(clip, mode = 'shape') {
|
|
2848
2874
|
var matrix = _clipWorldMatrix(clip);
|
|
2849
|
-
var bounds = _avm1GeometryBounds(clip, matrix);
|
|
2875
|
+
var bounds = _avm1GeometryBounds(clip, matrix, mode);
|
|
2850
2876
|
return bounds ? { left: bounds.xMin, top: bounds.yMin, right: bounds.xMax, bottom: bounds.yMax } :
|
|
2851
|
-
_avm1TransformBounds(_clipBounds(clip), matrix);
|
|
2877
|
+
_avm1TransformBounds(_clipBounds(clip, true, mode), matrix);
|
|
2852
2878
|
}
|
|
2853
2879
|
|
|
2854
2880
|
function _clipWorldBounds(mc) {
|
|
@@ -3928,6 +3954,7 @@ function createMovieClip(name) {
|
|
|
3928
3954
|
Object.defineProperties(raw, avm1MouseProperties);
|
|
3929
3955
|
Object.defineProperty(raw, 'useHandCursor', avm1HandCursorProperty);
|
|
3930
3956
|
Object.defineProperty(raw, '_target', avm1TargetProperty);
|
|
3957
|
+
_avm1RecordNativeClipKeys(raw);
|
|
3931
3958
|
var knownNames = _legacyAvm1Names && new Map(Object.getOwnPropertyNames(raw).map(function (key) {
|
|
3932
3959
|
return [key.toLowerCase(), key];
|
|
3933
3960
|
}));
|
|
@@ -5058,6 +5085,18 @@ export const AVM1_RUNTIME_FACTORY_SOURCE = `function createAvm1Runtime(_avm1Host
|
|
|
5058
5085
|
} : undefined;
|
|
5059
5086
|
if (Sound) {
|
|
5060
5087
|
Sound.prototype = Object.create(HostSound.prototype, { constructor: { value: Sound } });
|
|
5088
|
+
var avm1UrlSounds = new WeakSet();
|
|
5089
|
+
Sound.prototype.loadSound = function (url, streaming) {
|
|
5090
|
+
if (url == null || this._avm1SoundInvalidTarget || this._avm1SoundTarget?._swoofDetached) return;
|
|
5091
|
+
var sound = this;
|
|
5092
|
+
if (!avm1UrlSounds.has(sound)) {
|
|
5093
|
+
avm1UrlSounds.add(sound);
|
|
5094
|
+
sound.addEventListener('complete', function () { sound.onLoad?.(true); });
|
|
5095
|
+
sound.addEventListener('ioError', function () { sound.onLoad?.(false); });
|
|
5096
|
+
}
|
|
5097
|
+
sound.load({ url: String(url) });
|
|
5098
|
+
if (streaming) sound.start();
|
|
5099
|
+
};
|
|
5061
5100
|
Sound.prototype.play = function () {
|
|
5062
5101
|
if (this._avm1SoundInvalidTarget || this._avm1SoundTarget?._swoofDetached) return;
|
|
5063
5102
|
var target = this._avm1SoundTarget, id = this._audio ? null : this._id;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { createAvm2Runtime } from './avm2-runtime.js';
|
|
6
|
-
import { assembleSwflibSource } from './
|
|
6
|
+
import { assembleSwflibSource } from './assemble-swooflib.js';
|
|
7
7
|
|
|
8
8
|
/** Shared SWF player API shim (geom, display, events, media, ui). */
|
|
9
9
|
export const SWFLIB_BASE_SOURCE = assembleSwflibSource().trim();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Serialized into swflib.js. Movie-specific lexical bindings are supplied by
|
|
2
2
|
// the generated script installer, while playback runs in this shared runtime.
|
|
3
3
|
export function installMovieRuntime(runtime, global) {
|
|
4
|
+
runtime.installMovieNetwork();
|
|
4
5
|
const document = global.document;
|
|
5
6
|
const window = global.window || global;
|
|
6
7
|
const fontLoads = new Map();
|
|
@@ -59,12 +60,14 @@ export function installMovieRuntime(runtime, global) {
|
|
|
59
60
|
resolve();
|
|
60
61
|
}
|
|
61
62
|
const image = new global.Image();
|
|
63
|
+
if (runtime.needsMovieAssetCors(asset.path)) image.crossOrigin = 'anonymous';
|
|
62
64
|
image.onload = () => {
|
|
63
65
|
if (!asset.alphaPath) {
|
|
64
66
|
finish(image, true);
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
69
|
const alpha = new global.Image();
|
|
70
|
+
if (image.crossOrigin) alpha.crossOrigin = image.crossOrigin;
|
|
68
71
|
alpha.onload = () => {
|
|
69
72
|
const canvas = document.createElement('canvas');
|
|
70
73
|
canvas.width = image.naturalWidth || image.width;
|
|
@@ -84,10 +87,24 @@ export function installMovieRuntime(runtime, global) {
|
|
|
84
87
|
image.onerror = () => finish(null, false);
|
|
85
88
|
image.src = asset.path;
|
|
86
89
|
}));
|
|
90
|
+
} else if (asset.type === 'audio' && asset.encoding === 'adpcm') {
|
|
91
|
+
// ADPCM stays compressed on disk. Decode it to WAV before the first frame so every
|
|
92
|
+
// audio element and clone sees a playable source.
|
|
93
|
+
const audio = new global.Audio();
|
|
94
|
+
audio.preload = 'auto';
|
|
95
|
+
loaded[asset.id] = audio;
|
|
96
|
+
visualPromises.push(readClassicAsset(asset.path, '_swoofAudio', 'audio').then(data => {
|
|
97
|
+
const wav = runtime.decodeAdpcmAudio(data);
|
|
98
|
+
const url = global.URL.createObjectURL(new global.Blob([wav], { type: 'audio/wav' }));
|
|
99
|
+
asset.path = url;
|
|
100
|
+
audio.addEventListener('error', () => { loaded[asset.id] = null; });
|
|
101
|
+
audio.src = url;
|
|
102
|
+
}).catch(() => { loaded[asset.id] = null; }));
|
|
87
103
|
} else if (asset.type === 'audio') {
|
|
88
104
|
try {
|
|
89
105
|
const audio = new global.Audio();
|
|
90
106
|
audio.preload = 'auto';
|
|
107
|
+
if (runtime.needsMovieAssetCors(asset.path)) audio.crossOrigin = 'anonymous';
|
|
91
108
|
loaded[asset.id] = audio;
|
|
92
109
|
audio.addEventListener('error', () => { loaded[asset.id] = null; });
|
|
93
110
|
audio.src = asset.path;
|
|
@@ -131,10 +148,19 @@ export function installMovieRuntime(runtime, global) {
|
|
|
131
148
|
}
|
|
132
149
|
|
|
133
150
|
function mountMovie(movie, installScripts) {
|
|
151
|
+
// Bundles with a movie-data.js pass null and the data arrives through the global.
|
|
152
|
+
if (!movie) {
|
|
153
|
+
movie = global.__swoofMovieData;
|
|
154
|
+
if (!movie) throw new Error('Missing movie data (movie-data.js)');
|
|
155
|
+
delete global.__swoofMovieData;
|
|
156
|
+
}
|
|
157
|
+
if (movie.player && runtime.playerId && movie.player !== runtime.playerId) {
|
|
158
|
+
global.console?.warn?.('swoof: this movie was converted by a different swf2js build than the player (swoof.js) it loaded. '
|
|
159
|
+
+ 'Reconvert it, or convert it with --standalone to keep its own player.');
|
|
160
|
+
}
|
|
134
161
|
const { stageWidth, stageHeight, frameRate, background, assets, symbolClasses, exportAssets } = movie;
|
|
135
|
-
const data = movie.timelineData
|
|
162
|
+
const data = movie.timelineData;
|
|
136
163
|
if (!data) throw new Error('Missing SWF timeline data');
|
|
137
|
-
if (!movie.timelineData) delete global.__swoofTimelineData;
|
|
138
164
|
const { frameCount, scenes } = data;
|
|
139
165
|
const anchorFrames = new Map();
|
|
140
166
|
for (const [frameIndex, frame] of data.frames.entries()) {
|