swf2js 0.0.0-stage → 0.1.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/LICENSE-GPL +680 -0
- package/README.md +208 -2
- package/package.json +24 -4
- package/src/cli.js +272 -0
- package/src/decoder/button-decoder.js +136 -0
- package/src/decoder/shape-decoder.js +786 -0
- package/src/decoder/symbol-table.js +36 -0
- package/src/decoder/tag-decoder.js +1190 -0
- package/src/decoder/tag-types.js +258 -0
- package/src/emitter/asset-encoder.js +708 -0
- package/src/emitter/bundle-emitter.js +596 -0
- package/src/emitter/embedded-swf.js +246 -0
- package/src/emitter/font-encoder.js +365 -0
- package/src/emitter/timeline-data-codec.js +58 -0
- package/src/model/swf-document.js +59 -0
- package/src/model/transpile-result.js +32 -0
- package/src/parser/bit-reader.js +237 -0
- package/src/parser/decompressor.js +91 -0
- package/src/parser/swf-parser.js +164 -0
- package/src/pretty-printer/pretty-printer.js +137 -0
- package/src/runtime/avm1-runtime.js +4907 -0
- package/src/runtime/avm2-runtime.js +1591 -0
- package/src/runtime/embedded-movie-runtime.js +208 -0
- package/src/runtime/index.js +17 -0
- package/src/runtime/movie-runtime.js +306 -0
- package/src/runtime/swflib.js +14050 -0
- package/src/transpiler/actionscript.js +390 -0
- package/src/transpiler/avm1/avm1-ir.js +205 -0
- package/src/transpiler/avm1/avm1-opcodes.js +149 -0
- package/src/transpiler/avm1/avm1-rewrite.js +291 -0
- package/src/transpiler/avm1/avm1-transpiler.js +2082 -0
- package/src/transpiler/avm2/abc-reader.js +416 -0
- package/src/transpiler/avm2/avm2-transpiler.js +2560 -0
- package/src/transpiler/cfg-structurer.js +876 -0
- package/src/transpiler/timeline/display-list.js +643 -0
- package/src/transpiler/timeline/timeline-codegen.js +6354 -0
- package/src/util/diagnostics.js +50 -0
- package/src/util/logger.js +40 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Diagnostic collection — warnings and errors accumulate here throughout the pipeline.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** @import { Diagnostic } from '../model/transpile-result.js' */
|
|
6
|
+
|
|
7
|
+
export class DiagnosticsCollector {
|
|
8
|
+
constructor() {
|
|
9
|
+
/** @type {Diagnostic[]} */
|
|
10
|
+
this._items = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} message
|
|
15
|
+
* @param {"parse"|"decode"|"transpile"|"emit"} stage
|
|
16
|
+
* @param {Record<string, unknown>} [context]
|
|
17
|
+
*/
|
|
18
|
+
warn(message, stage, context) {
|
|
19
|
+
this._items.push({ level: 'warning', stage, message, context });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} message
|
|
24
|
+
* @param {"parse"|"decode"|"transpile"|"emit"} stage
|
|
25
|
+
* @param {Record<string, unknown>} [context]
|
|
26
|
+
*/
|
|
27
|
+
error(message, stage, context) {
|
|
28
|
+
this._items.push({ level: 'error', stage, message, context });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @returns {Diagnostic[]} */
|
|
32
|
+
all() {
|
|
33
|
+
return this._items.slice();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** @returns {boolean} */
|
|
37
|
+
hasErrors() {
|
|
38
|
+
return this._items.some(d => d.level === 'error');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** @returns {Diagnostic[]} */
|
|
42
|
+
errors() {
|
|
43
|
+
return this._items.filter(d => d.level === 'error');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @returns {Diagnostic[]} */
|
|
47
|
+
warnings() {
|
|
48
|
+
return this._items.filter(d => d.level === 'warning');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Logger — wraps process.stdout/stderr, respects --verbose and --warn-unknown flags.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export class Logger {
|
|
6
|
+
/**
|
|
7
|
+
* @param {{ verbose?: boolean, warnUnknown?: boolean }} opts
|
|
8
|
+
*/
|
|
9
|
+
constructor(opts = {}) {
|
|
10
|
+
this.verbose = opts.verbose ?? false;
|
|
11
|
+
this.warnUnknown = opts.warnUnknown ?? false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** @param {string} msg */
|
|
15
|
+
info(msg) {
|
|
16
|
+
process.stdout.write(msg + '\n');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Prints when --warn-unknown or --verbose is active.
|
|
21
|
+
* @param {string} msg
|
|
22
|
+
*/
|
|
23
|
+
warn(msg) {
|
|
24
|
+
if (this.warnUnknown || this.verbose) {
|
|
25
|
+
process.stderr.write('[warn] ' + msg + '\n');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Always prints to stderr regardless of flags. @param {string} msg */
|
|
30
|
+
error(msg) {
|
|
31
|
+
process.stderr.write('[error] ' + msg + '\n');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Only prints when --verbose is active. @param {string} msg */
|
|
35
|
+
verboseLog(msg) {
|
|
36
|
+
if (this.verbose) {
|
|
37
|
+
process.stdout.write('[verbose] ' + msg + '\n');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|