@swf2es/cli 0.0.0-stage → 0.1.1
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 +202 -0
- package/LICENSE.third-party +389 -0
- package/README.md +32 -2
- package/dist/aot.d.ts +98 -0
- package/dist/aot.d.ts.map +1 -0
- package/dist/aot.js +145 -0
- package/dist/aot.js.map +1 -0
- package/dist/args.d.ts +31 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +37 -0
- package/dist/args.js.map +1 -0
- package/dist/commands/compile.d.ts +3 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +233 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/help.d.ts +6 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +52 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +122 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/files.d.ts +10 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +35 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +45 -0
- package/dist/main.js.map +1 -0
- package/dist/output.d.ts +7 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +20 -0
- package/dist/output.js.map +1 -0
- package/dist/shell-memories.d.ts +2 -0
- package/dist/shell-memories.d.ts.map +1 -0
- package/dist/shell-memories.js +32 -0
- package/dist/shell-memories.js.map +1 -0
- package/dist/shell-thread.d.ts +2 -0
- package/dist/shell-thread.d.ts.map +1 -0
- package/dist/shell-thread.js +49 -0
- package/dist/shell-thread.js.map +1 -0
- package/dist/shell-toplevel-library.d.ts +2 -0
- package/dist/shell-toplevel-library.d.ts.map +1 -0
- package/dist/shell-toplevel-library.js +22 -0
- package/dist/shell-toplevel-library.js.map +1 -0
- package/dist/shell.d.ts +62 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +135 -0
- package/dist/shell.js.map +1 -0
- package/dist/threads.d.ts +85 -0
- package/dist/threads.d.ts.map +1 -0
- package/dist/threads.js +145 -0
- package/dist/threads.js.map +1 -0
- package/package.json +46 -3
- package/src/aot.ts +239 -0
- package/src/args.ts +53 -0
- package/src/commands/compile.ts +286 -0
- package/src/commands/help.ts +60 -0
- package/src/commands/run.ts +131 -0
- package/src/files.ts +38 -0
- package/src/index.ts +25 -0
- package/src/main.ts +51 -0
- package/src/output.ts +23 -0
- package/src/shell-memories.ts +35 -0
- package/src/shell-thread.ts +54 -0
- package/src/shell-toplevel-library.ts +28 -0
- package/src/shell.ts +211 -0
- package/src/threads.ts +223 -0
package/dist/aot.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { AIR_API_VERSION, API_VERSION, type Codegen } from "@swf2es/codegen";
|
|
2
|
+
import { type ActionList } from "@swf2es/format";
|
|
3
|
+
export { AIR_API_VERSION, API_VERSION };
|
|
4
|
+
export interface AbcInput {
|
|
5
|
+
/** DoABC2's name, "" for a DoABC or a bare ABC. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** DoABC2's lazy flag: its scripts run on first use, not when it loads. */
|
|
8
|
+
lazy: boolean;
|
|
9
|
+
abc: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
export interface Input {
|
|
12
|
+
kind: "swf" | "abc";
|
|
13
|
+
/** The SWF's version, 0 for a bare ABC. */
|
|
14
|
+
version: number;
|
|
15
|
+
abcs: AbcInput[];
|
|
16
|
+
/** An AVM1 SWF's action blocks; null for an AS3 SWF or an ABC. */
|
|
17
|
+
avm1: Avm1Input | null;
|
|
18
|
+
}
|
|
19
|
+
export interface Avm1Input {
|
|
20
|
+
/** The SWF's decompressed bytes, which the blocks' ranges are of. */
|
|
21
|
+
bytes: Uint8Array;
|
|
22
|
+
actions: ActionList;
|
|
23
|
+
}
|
|
24
|
+
/** An AVM1 SWF's module. */
|
|
25
|
+
export interface ActionsModule {
|
|
26
|
+
/** The ES module's source. */
|
|
27
|
+
module: string;
|
|
28
|
+
/** SHA-256 of the SWF's decompressed bytes, as the key names it. */
|
|
29
|
+
hash: string;
|
|
30
|
+
/**
|
|
31
|
+
* The SHA-256 of its key, codegen's actionsKey, as the player's module
|
|
32
|
+
* cache is to look it up; null for a compiler without an identity.
|
|
33
|
+
*/
|
|
34
|
+
key: string | null;
|
|
35
|
+
/** How many blocks it has an entry for. */
|
|
36
|
+
blocks: number;
|
|
37
|
+
}
|
|
38
|
+
export interface Module {
|
|
39
|
+
name: string;
|
|
40
|
+
/** SHA-256 of the ABC, as the player and the cache key name it. */
|
|
41
|
+
hash: string;
|
|
42
|
+
lazy: boolean;
|
|
43
|
+
/** The ES module's source. */
|
|
44
|
+
module: string;
|
|
45
|
+
/**
|
|
46
|
+
* What compiling it fixed in the compiler's domain, which the player
|
|
47
|
+
* replays in its place (Codegen.compileModuleLogged); null where it
|
|
48
|
+
* cannot be.
|
|
49
|
+
*/
|
|
50
|
+
log: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The SHA-256 of its key, as the player's module cache looks it up when
|
|
53
|
+
* it loads the SWF as its main movie (codegen's moduleKey); null for a
|
|
54
|
+
* compiler without an identity, or a module without a log.
|
|
55
|
+
*/
|
|
56
|
+
key: string | null;
|
|
57
|
+
}
|
|
58
|
+
/** Input the command cannot compile, with why. */
|
|
59
|
+
export declare class InputError extends Error {
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The ABCs of a SWF, in tag order as the player links them, or a bare ABC
|
|
63
|
+
* as one; for an AVM1 SWF its action blocks instead, as the player runs
|
|
64
|
+
* its code as AVM1 and never compiles its DoABCs.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readInput(bytes: Uint8Array): Input;
|
|
67
|
+
export declare function sha256(bytes: Uint8Array): string;
|
|
68
|
+
export declare class RejectedError extends Error {
|
|
69
|
+
readonly what: string;
|
|
70
|
+
readonly verifyError: number;
|
|
71
|
+
/** A library's, not the input's. */
|
|
72
|
+
readonly library: boolean;
|
|
73
|
+
constructor(what: string, verifyError: number,
|
|
74
|
+
/** A library's, not the input's. */
|
|
75
|
+
library: boolean);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The libraries' modules, those asked for by `keepLibraries`, and the
|
|
79
|
+
* ABCs' modules, in order, compiled at `apiVersion`: Flash Player's, or
|
|
80
|
+
* AIR_API_VERSION for a host that plays them as AIR does (the player's
|
|
81
|
+
* `air`), whose keys are its alone. The libraries compile whether kept or
|
|
82
|
+
* not: the player compiles each, and what a compile resolves of an ABC is
|
|
83
|
+
* what later ABCs compile against.
|
|
84
|
+
*/
|
|
85
|
+
export declare function compileAhead(codegen: Codegen, libraries: {
|
|
86
|
+
name: string;
|
|
87
|
+
abc: Uint8Array;
|
|
88
|
+
}[], abcs: AbcInput[], keepLibraries?: boolean, apiVersion?: number): {
|
|
89
|
+
libraries: Module[];
|
|
90
|
+
libraryInputs: {
|
|
91
|
+
name: string;
|
|
92
|
+
abc: Uint8Array;
|
|
93
|
+
}[];
|
|
94
|
+
abcs: Module[];
|
|
95
|
+
};
|
|
96
|
+
/** An AVM1 SWF's action blocks' module, as the player is to compile it, and its key. */
|
|
97
|
+
export declare function compileActionsAhead(codegen: Codegen, input: Avm1Input): ActionsModule;
|
|
98
|
+
//# sourceMappingURL=aot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aot.d.ts","sourceRoot":"","sources":["../src/aot.ts"],"names":[],"mappings":"AASA,OAAO,EACL,eAAe,EACf,WAAW,EAEX,KAAK,OAAO,EAIb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,UAAU,EAAgD,MAAM,gBAAgB,CAAC;AAG/F,OAAO,EAAE,eAAe,EAAE,WA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,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM;IAC5B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO;IAJ3B,YACW,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM;IAC5B,oCAAoC;IAC3B,OAAO,EAAE,OAAO,EAG1B;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,UAAU,CAAA;CAAE,EAAE,EAC9C,IAAI,EAAE,QAAQ,EAAE,EAChB,aAAa,UAAQ,EACrB,UAAU,SAAc,GACvB;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,UAAU,CAAA;KAAE,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CA0D7F;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,aAAa,CAOrF"}
|
package/dist/aot.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Ahead-of-time compilation: a SWF's ABCs compiled as the player compiles
|
|
2
|
+
// them for a SWF it loads as its main movie, so that each module is byte
|
|
3
|
+
// for byte what the browser would compile (the JIT/AOT invariant in
|
|
4
|
+
// docs/architecture/overview.md). The steps are Code's in packages/player, in the
|
|
5
|
+
// same order: the libraries added to the root domain, each compiled as it
|
|
6
|
+
// is added, then the SWF's DoABCs all added to a child of the root before
|
|
7
|
+
// any of them compiles. An AVM1 SWF's action blocks compile to one module
|
|
8
|
+
// of their own (compileActionsAhead), which needs no library.
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { AIR_API_VERSION, API_VERSION, actionsKey, libraryLog, moduleKey, } from "@swf2es/codegen";
|
|
11
|
+
import { isAs3, readActions, readDoAbc, readSwf, tags } from "@swf2es/format";
|
|
12
|
+
import { avm2 } from "@swf2es/runtime";
|
|
13
|
+
export { AIR_API_VERSION, API_VERSION };
|
|
14
|
+
const SIGNATURES = new Set(["FWS", "CWS", "ZWS"]);
|
|
15
|
+
/** Input the command cannot compile, with why. */
|
|
16
|
+
export class InputError extends Error {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The ABCs of a SWF, in tag order as the player links them, or a bare ABC
|
|
20
|
+
* as one; for an AVM1 SWF its action blocks instead, as the player runs
|
|
21
|
+
* its code as AVM1 and never compiles its DoABCs.
|
|
22
|
+
*/
|
|
23
|
+
export function readInput(bytes) {
|
|
24
|
+
const signature = String.fromCharCode(...bytes.subarray(0, 3));
|
|
25
|
+
if (!SIGNATURES.has(signature)) {
|
|
26
|
+
// ABC headers name a minor and major version: 46 for Flash, 47 for AIR float.
|
|
27
|
+
if (bytes.length < 4 || (bytes[2] !== 46 && bytes[2] !== 47) || bytes[3] !== 0) {
|
|
28
|
+
throw new InputError("neither a SWF nor an ABC");
|
|
29
|
+
}
|
|
30
|
+
return { kind: "abc", version: 0, abcs: [{ name: "", lazy: false, abc: bytes }], avm1: null };
|
|
31
|
+
}
|
|
32
|
+
let swf;
|
|
33
|
+
try {
|
|
34
|
+
swf = readSwf(bytes);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
throw new InputError(`a truncated or corrupt SWF (${e.message})`);
|
|
38
|
+
}
|
|
39
|
+
const version = swf.header.version;
|
|
40
|
+
if (!isAs3(swf)) {
|
|
41
|
+
return {
|
|
42
|
+
kind: "swf",
|
|
43
|
+
version,
|
|
44
|
+
abcs: [],
|
|
45
|
+
avm1: { bytes: swf.bytes, actions: readActions(swf) },
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// A DoABC cut short would reach codegen as a malformed ABC and read as
|
|
49
|
+
// the code's error; a SWF cut elsewhere the player plays, as far as it goes.
|
|
50
|
+
const last = swf.tags.at(-1);
|
|
51
|
+
if (swf.truncated && (last?.code === tags.DoABC || last?.code === tags.DoABC2)) {
|
|
52
|
+
throw new InputError("a truncated SWF: the file ends inside a DoABC tag");
|
|
53
|
+
}
|
|
54
|
+
const abcs = [];
|
|
55
|
+
for (const t of swf.tags) {
|
|
56
|
+
if (t.code === tags.DoABC || t.code === tags.DoABC2) {
|
|
57
|
+
abcs.push(readDoAbc(swf.bytes, t));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { kind: "swf", version, abcs, avm1: null };
|
|
61
|
+
}
|
|
62
|
+
export function sha256(bytes) {
|
|
63
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
64
|
+
}
|
|
65
|
+
export class RejectedError extends Error {
|
|
66
|
+
what;
|
|
67
|
+
verifyError;
|
|
68
|
+
library;
|
|
69
|
+
constructor(what, verifyError,
|
|
70
|
+
/** A library's, not the input's. */
|
|
71
|
+
library) {
|
|
72
|
+
super(`${what} was rejected: VerifyError #${verifyError}`);
|
|
73
|
+
this.what = what;
|
|
74
|
+
this.verifyError = verifyError;
|
|
75
|
+
this.library = library;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The libraries' modules, those asked for by `keepLibraries`, and the
|
|
80
|
+
* ABCs' modules, in order, compiled at `apiVersion`: Flash Player's, or
|
|
81
|
+
* AIR_API_VERSION for a host that plays them as AIR does (the player's
|
|
82
|
+
* `air`), whose keys are its alone. The libraries compile whether kept or
|
|
83
|
+
* not: the player compiles each, and what a compile resolves of an ABC is
|
|
84
|
+
* what later ABCs compile against.
|
|
85
|
+
*/
|
|
86
|
+
export function compileAhead(codegen, libraries, abcs, keepLibraries = false, apiVersion = API_VERSION) {
|
|
87
|
+
codegen.reset(apiVersion);
|
|
88
|
+
if (abcs.some(({ abc }) => {
|
|
89
|
+
const version = codegen.abcVersion(abc);
|
|
90
|
+
return version?.major === 47 && version.minor >= 16;
|
|
91
|
+
}) &&
|
|
92
|
+
!avm2.hasFloatLibrary(libraries.map((lib) => lib.abc))) {
|
|
93
|
+
libraries = [...libraries, { name: "float", abc: avm2.floatLibrary }];
|
|
94
|
+
}
|
|
95
|
+
const hashes = [];
|
|
96
|
+
const builtins = [];
|
|
97
|
+
const add = (what, abc, builtin, domain) => {
|
|
98
|
+
const error = codegen.add(abc, builtin, domain);
|
|
99
|
+
if (error) {
|
|
100
|
+
throw new RejectedError(what, error, builtin);
|
|
101
|
+
}
|
|
102
|
+
hashes.push(sha256(abc));
|
|
103
|
+
builtins.push(builtin);
|
|
104
|
+
return hashes.length - 1;
|
|
105
|
+
};
|
|
106
|
+
// Keyed before it compiles, as the player keys it before it asks its cache.
|
|
107
|
+
const compile = (index, libraryDigest) => {
|
|
108
|
+
const keyText = codegen.identity === null
|
|
109
|
+
? null
|
|
110
|
+
: moduleKey(codegen, index, { hashes, builtins }, libraryDigest);
|
|
111
|
+
const { module, log } = codegen.compileModuleLogged(hashes, index);
|
|
112
|
+
const key = keyText === null || log === null ? null : sha256Text(keyText);
|
|
113
|
+
return { hash: hashes[index], module, log, key };
|
|
114
|
+
};
|
|
115
|
+
const libraryModules = [];
|
|
116
|
+
for (const { name, abc } of libraries) {
|
|
117
|
+
const index = add(`library ${name}`, abc, true, 0);
|
|
118
|
+
const compiled = compile(index, null);
|
|
119
|
+
if (keepLibraries) {
|
|
120
|
+
libraryModules.push({ name, lazy: false, ...compiled });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// The main movie's application domain, a child of the root's, as the player's mainDomain.
|
|
124
|
+
const domain = codegen.childDomain(0);
|
|
125
|
+
const indices = abcs.map(({ name, abc }, i) => add(`ABC ${i}${name ? ` (${name})` : ""}`, abc, false, domain));
|
|
126
|
+
// The libraries' part of the log, by its digest, as the player's keys name it once a SWF is added.
|
|
127
|
+
const count = libraries.length;
|
|
128
|
+
const digest = indices.length > 0
|
|
129
|
+
? { count, digest: sha256Text(libraryLog(codegen, indices[0], count)) }
|
|
130
|
+
: null;
|
|
131
|
+
const modules = abcs.map(({ name, lazy }, i) => ({ name, lazy, ...compile(indices[i], digest) }));
|
|
132
|
+
return { libraries: libraryModules, libraryInputs: libraries, abcs: modules };
|
|
133
|
+
}
|
|
134
|
+
/** An AVM1 SWF's action blocks' module, as the player is to compile it, and its key. */
|
|
135
|
+
export function compileActionsAhead(codegen, input) {
|
|
136
|
+
const { bytes, actions } = input;
|
|
137
|
+
const hash = sha256(bytes);
|
|
138
|
+
const key = codegen.identity === null ? null : sha256Text(actionsKey(codegen, hash, actions.version));
|
|
139
|
+
const module = codegen.compileActionsModule(bytes, actions);
|
|
140
|
+
return { module, hash, key, blocks: actions.blocks.length };
|
|
141
|
+
}
|
|
142
|
+
function sha256Text(text) {
|
|
143
|
+
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=aot.js.map
|
package/dist/aot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aot.js","sourceRoot":"","sources":["../src/aot.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,oEAAoE;AACpE,kFAAkF;AAClF,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,8DAA8D;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EACf,WAAW,EACX,UAAU,EAGV,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAmB,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC;AA6DxC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,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C,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;AAC9D,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface Command {
|
|
2
|
+
name: string;
|
|
3
|
+
/** One line for the list of commands. */
|
|
4
|
+
summary: string;
|
|
5
|
+
usage: string;
|
|
6
|
+
main(argv: string[]): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** The options every command takes, which parseArgs' options spread. */
|
|
9
|
+
export declare const COMMON_OPTIONS: {
|
|
10
|
+
readonly help: {
|
|
11
|
+
readonly type: "boolean";
|
|
12
|
+
readonly short: "h";
|
|
13
|
+
};
|
|
14
|
+
readonly version: {
|
|
15
|
+
readonly type: "boolean";
|
|
16
|
+
readonly short: "v";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare const COMMON_USAGE = " -h, --help show this\n -v, --version print the compiler's version";
|
|
20
|
+
export declare function printVersion(): void;
|
|
21
|
+
/**
|
|
22
|
+
* `command`'s arguments as `parse` reads them, a mistake in them a usage
|
|
23
|
+
* error; null once -h or -v has been answered, and the command is done.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parse<T extends {
|
|
26
|
+
values: {
|
|
27
|
+
help?: boolean;
|
|
28
|
+
version?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}>(command: Command, read: () => T): T | null;
|
|
31
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED,wEAAwE;AACxE,eAAO,MAAM,cAAc;aACzB,IAAI;iBAAI,IAAI,EAAE,SAAS;iBAAE,KAAK,EAAE,GAAG;;aACnC,OAAO;iBAAI,IAAI,EAAE,SAAS;iBAAE,KAAK,EAAE,GAAG;;CAC9B,CAAC;AAEX,eAAO,MAAM,YAAY,0FAC2B,CAAC;AAErD,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,EAC/E,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,CAAC,GACZ,CAAC,GAAG,IAAI,CAmBV"}
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// What every command shares of its command line: the options all take,
|
|
2
|
+
// and a mistake in it reported as a usage error.
|
|
3
|
+
import { COMPILER_VERSION } from "@swf2es/codegen";
|
|
4
|
+
import { usageError } from "./output.js";
|
|
5
|
+
/** The options every command takes, which parseArgs' options spread. */
|
|
6
|
+
export const COMMON_OPTIONS = {
|
|
7
|
+
help: { type: "boolean", short: "h" },
|
|
8
|
+
version: { type: "boolean", short: "v" },
|
|
9
|
+
};
|
|
10
|
+
export const COMMON_USAGE = ` -h, --help show this
|
|
11
|
+
-v, --version print the compiler's version`;
|
|
12
|
+
export function printVersion() {
|
|
13
|
+
console.log(`swf2es ${COMPILER_VERSION}`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `command`'s arguments as `parse` reads them, a mistake in them a usage
|
|
17
|
+
* error; null once -h or -v has been answered, and the command is done.
|
|
18
|
+
*/
|
|
19
|
+
export function parse(command, read) {
|
|
20
|
+
let parsed;
|
|
21
|
+
try {
|
|
22
|
+
parsed = read();
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
usageError(e.message, command.name);
|
|
26
|
+
}
|
|
27
|
+
if (parsed.values.help) {
|
|
28
|
+
console.log(command.usage);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (parsed.values.version) {
|
|
32
|
+
printVersion();
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return parsed;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,iDAAiD;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAUzC,wEAAwE;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE;IACrC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE;CAChC,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG;oDACwB,CAAC;AAErD,MAAM,UAAU,YAAY;IAC1B,OAAO,CAAC,GAAG,CAAC,UAAU,gBAAgB,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CACnB,OAAgB,EAChB,IAAa;IAEb,IAAI,MAAS,CAAC;IACd,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,UAAU,CAAE,CAAW,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1B,YAAY,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAgC,KAAK,OAAO,EAAS,MAAM,YAAY,CAAC;AAwF/E,eAAO,MAAM,OAAO,EAAE,OA6HrB,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// swf2es compile: a SWF's or an ABC's modules, ahead of time, as the player
|
|
2
|
+
// compiles them for its main movie, with a manifest; an AVM1 SWF's one
|
|
3
|
+
// module of its action blocks.
|
|
4
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { basename, extname, join } from "node:path";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
import { COMPILER_VERSION, createCodegen } from "@swf2es/codegen";
|
|
8
|
+
import { airLibrary, builtinLibrary, playerglobalLibrary } from "@swf2es/player/libraries";
|
|
9
|
+
import { AIR_API_VERSION, API_VERSION, compileActionsAhead, compileAhead, InputError, RejectedError, readInput, sha256, } from "../aot.js";
|
|
10
|
+
import { COMMON_OPTIONS, COMMON_USAGE, parse } from "../args.js";
|
|
11
|
+
import { codegenModule, read, readLibraries, writing } from "../files.js";
|
|
12
|
+
import { fail, usageError } from "../output.js";
|
|
13
|
+
const USAGE = `usage: swf2es compile <file.swf|file.abc> [options]
|
|
14
|
+
swf2es <file.swf|file.abc> [options]
|
|
15
|
+
|
|
16
|
+
Compiles the ABCs of a SWF (its DoABC and DoABC2 tags, in order), or a bare
|
|
17
|
+
ABC, to ES modules as the player compiles them for a SWF it loads as its
|
|
18
|
+
main movie, byte for byte. Writes a .js file per ABC, a .log file of what
|
|
19
|
+
its compile fixed, which the player replays in its place, and a
|
|
20
|
+
manifest.json naming them, their ABCs' hashes, the keys the player's
|
|
21
|
+
module cache looks them up by, and the compiler. An AVM1 SWF (one whose
|
|
22
|
+
FileAttributes has no ActionScript 3 flag) compiles to one module of its
|
|
23
|
+
action blocks, avm1.js, which takes no library.
|
|
24
|
+
|
|
25
|
+
options:
|
|
26
|
+
-o, --out <dir> where to write (default: <file name>.swf2es)
|
|
27
|
+
--lib <file.abc> a library the code links against, loaded into the
|
|
28
|
+
root domain in the order given; repeat for each.
|
|
29
|
+
Default: what the player loads, which swf2es ships:
|
|
30
|
+
avmplus' builtin.abc and the player's playerglobal,
|
|
31
|
+
and with --air AIR's library after them
|
|
32
|
+
--emit-libraries write the libraries' modules too
|
|
33
|
+
--air compile for a player that plays the SWF as AIR does
|
|
34
|
+
(its \`air\` option), AIR's API defined; a player
|
|
35
|
+
in the other mode looks none of the modules up.
|
|
36
|
+
Refused for an AVM1 SWF, which has no API versions
|
|
37
|
+
-q, --quiet print nothing but errors
|
|
38
|
+
${COMMON_USAGE}
|
|
39
|
+
|
|
40
|
+
exit status: 0 on success, 2 for a mistake in the command line, 1 for
|
|
41
|
+
anything else (an unreadable or rejected input or library, or an output
|
|
42
|
+
that cannot be written)`;
|
|
43
|
+
const OPTIONS = {
|
|
44
|
+
out: { type: "string", short: "o" },
|
|
45
|
+
lib: { type: "string", multiple: true },
|
|
46
|
+
"emit-libraries": { type: "boolean" },
|
|
47
|
+
air: { type: "boolean" },
|
|
48
|
+
quiet: { type: "boolean", short: "q" },
|
|
49
|
+
...COMMON_OPTIONS,
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* manifest.json's format: 2 added each module's log, key and lengths, and
|
|
53
|
+
* named the compiler by its stamped identity rather than its file's hash.
|
|
54
|
+
* An AVM1 SWF's `avm1` entry, which a reader of the ABCs' entries need not
|
|
55
|
+
* know, came later without a new version.
|
|
56
|
+
*/
|
|
57
|
+
const MANIFEST_VERSION = 2;
|
|
58
|
+
/** What a previous run wrote to `out`, as its manifest names it, so that no stale module stays beside a new manifest. */
|
|
59
|
+
async function removeModules(out) {
|
|
60
|
+
let old;
|
|
61
|
+
try {
|
|
62
|
+
old = JSON.parse(await readFile(join(out, "manifest.json"), "utf8"));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const entries = [old?.libraries, old?.abcs, [old?.avm1]].flatMap((list) => Array.isArray(list) ? list : []);
|
|
68
|
+
// Only names this command writes: a manifest edited by hand names nothing else to delete.
|
|
69
|
+
for (const entry of entries) {
|
|
70
|
+
const name = entry?.module;
|
|
71
|
+
if (typeof name === "string" && /^((abc|lib)-\d+|avm1)\.js$/.test(name)) {
|
|
72
|
+
for (const file of [name, name.replace(/\.js$/, ".log")]) {
|
|
73
|
+
await writing(join(out, file), () => rm(join(out, file), { force: true }));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The libraries the player loads, as @swf2es/web gives them, AIR's after
|
|
80
|
+
* the rest for an AIR player; the manifest's names tell swf2es's
|
|
81
|
+
* playerglobal from Flash Player's.
|
|
82
|
+
*/
|
|
83
|
+
function playerLibraries(air = false) {
|
|
84
|
+
const libraries = [
|
|
85
|
+
{ name: "builtin", abc: builtinLibrary },
|
|
86
|
+
{ name: "playerglobal-swf2es", abc: playerglobalLibrary },
|
|
87
|
+
];
|
|
88
|
+
return air ? [...libraries, { name: "air", abc: airLibrary }] : libraries;
|
|
89
|
+
}
|
|
90
|
+
export const compile = {
|
|
91
|
+
name: "compile",
|
|
92
|
+
summary: "compile a SWF's or an ABC's modules ahead of time, with a manifest",
|
|
93
|
+
usage: USAGE,
|
|
94
|
+
async main(argv) {
|
|
95
|
+
const parsed = parse(compile, () => parseArgs({ args: argv, allowPositionals: true, options: OPTIONS }));
|
|
96
|
+
if (!parsed) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const { values, positionals } = parsed;
|
|
100
|
+
if (positionals.length !== 1) {
|
|
101
|
+
usageError(`expected one input file, got ${positionals.length}`, "compile");
|
|
102
|
+
}
|
|
103
|
+
const file = positionals[0];
|
|
104
|
+
const bytes = await read(file, "input");
|
|
105
|
+
let input;
|
|
106
|
+
try {
|
|
107
|
+
input = readInput(bytes);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
fail(e instanceof InputError ? `${file}: ${e.message}` : String(e.stack ?? e));
|
|
111
|
+
}
|
|
112
|
+
const out = values.out ?? `${basename(file, extname(file))}.swf2es`;
|
|
113
|
+
if (input.avm1) {
|
|
114
|
+
// AVM1 has no API versions: its module is the same for every player.
|
|
115
|
+
if (values.air) {
|
|
116
|
+
usageError(`${file} is an AVM1 SWF, which --air does not apply to`, "compile");
|
|
117
|
+
}
|
|
118
|
+
await compileAvm1(file, bytes, input.avm1, out, values.quiet ?? false);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const libs = values.lib ? await readLibraries(values.lib) : playerLibraries(values.air);
|
|
122
|
+
if (input.abcs.length === 0) {
|
|
123
|
+
fail(`${file}: no DoABC or DoABC2 tag, so no ActionScript 3 to compile`);
|
|
124
|
+
}
|
|
125
|
+
const codegen = await createCodegen(await codegenModule());
|
|
126
|
+
const started = performance.now();
|
|
127
|
+
let compiled;
|
|
128
|
+
try {
|
|
129
|
+
compiled = compileAhead(codegen, libs, input.abcs, values["emit-libraries"], values.air ? AIR_API_VERSION : API_VERSION);
|
|
130
|
+
}
|
|
131
|
+
catch (e) {
|
|
132
|
+
if (!(e instanceof RejectedError)) {
|
|
133
|
+
fail(String(e.stack ?? e));
|
|
134
|
+
}
|
|
135
|
+
fail(e.library ? e.message : `${file}: ${e.message}`);
|
|
136
|
+
}
|
|
137
|
+
const ms = performance.now() - started;
|
|
138
|
+
await writing(out, () => mkdir(out, { recursive: true }));
|
|
139
|
+
await removeModules(out);
|
|
140
|
+
let size = 0;
|
|
141
|
+
const write = async (file, text) => {
|
|
142
|
+
await writing(join(out, file), () => writeFile(join(out, file), text));
|
|
143
|
+
size += Buffer.byteLength(text);
|
|
144
|
+
return file;
|
|
145
|
+
};
|
|
146
|
+
// A module, its log beside it, and what a host's precompiled module cache
|
|
147
|
+
// looks it up by and checks it with: the key and the two's lengths.
|
|
148
|
+
const entry = async (name, m) => {
|
|
149
|
+
const module = await write(`${name}.js`, m.module);
|
|
150
|
+
if (m.log === null || m.key === null) {
|
|
151
|
+
return { module };
|
|
152
|
+
}
|
|
153
|
+
const log = await write(`${name}.log`, m.log);
|
|
154
|
+
return { module, log, key: m.key, lengths: [m.module.length, m.log.length] };
|
|
155
|
+
};
|
|
156
|
+
// The compiler is named by the identity stamped into its binary, which
|
|
157
|
+
// the keys name too, so that a host can tell what another build wrote;
|
|
158
|
+
// an ABC by its hash, as its module names it, with the ABCs it was
|
|
159
|
+
// linked against.
|
|
160
|
+
const manifest = {
|
|
161
|
+
manifestVersion: MANIFEST_VERSION,
|
|
162
|
+
compiler: { name: "swf2es", version: COMPILER_VERSION, identity: codegen.identity },
|
|
163
|
+
// The version the modules were compiled at, which their keys name too.
|
|
164
|
+
apiVersion: codegen.apiVersion,
|
|
165
|
+
input: {
|
|
166
|
+
file: basename(file),
|
|
167
|
+
kind: input.kind,
|
|
168
|
+
version: input.version,
|
|
169
|
+
sha256: sha256(bytes),
|
|
170
|
+
},
|
|
171
|
+
libraries: await Promise.all(compiled.libraryInputs.map(async ({ name, abc }, i) => {
|
|
172
|
+
const m = compiled.libraries[i];
|
|
173
|
+
const lib = { name, sha256: sha256(abc) };
|
|
174
|
+
return m ? { ...lib, ...(await entry(`lib-${i}`, m)) } : lib;
|
|
175
|
+
})),
|
|
176
|
+
abcs: await Promise.all(compiled.abcs.map(async (m, i) => ({
|
|
177
|
+
name: m.name,
|
|
178
|
+
sha256: m.hash,
|
|
179
|
+
lazy: m.lazy,
|
|
180
|
+
...(await entry(`abc-${i}`, m)),
|
|
181
|
+
}))),
|
|
182
|
+
};
|
|
183
|
+
const manifestPath = join(out, "manifest.json");
|
|
184
|
+
await writing(manifestPath, () => writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`));
|
|
185
|
+
if (!values.quiet) {
|
|
186
|
+
const count = compiled.abcs.length + compiled.libraries.length;
|
|
187
|
+
console.log(`${file}: ${count} module${count === 1 ? "" : "s"}, ${size} bytes, ` +
|
|
188
|
+
`compiled in ${Math.round(ms)} ms, in ${out}`);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* An AVM1 SWF's module, avm1.js, and its manifest: the module's key, as
|
|
194
|
+
* the player's module cache is to look it up, the SHA-256 of the SWF's
|
|
195
|
+
* decompressed bytes it names, its length and how many blocks it has.
|
|
196
|
+
*/
|
|
197
|
+
async function compileAvm1(file, bytes, avm1, out, quiet) {
|
|
198
|
+
const codegen = await createCodegen(await codegenModule());
|
|
199
|
+
const started = performance.now();
|
|
200
|
+
const compiled = compileActionsAhead(codegen, avm1);
|
|
201
|
+
const ms = performance.now() - started;
|
|
202
|
+
await writing(out, () => mkdir(out, { recursive: true }));
|
|
203
|
+
await removeModules(out);
|
|
204
|
+
const module = "avm1.js";
|
|
205
|
+
await writing(join(out, module), () => writeFile(join(out, module), compiled.module));
|
|
206
|
+
const manifest = {
|
|
207
|
+
manifestVersion: MANIFEST_VERSION,
|
|
208
|
+
compiler: { name: "swf2es", version: COMPILER_VERSION, identity: codegen.identity },
|
|
209
|
+
apiVersion: API_VERSION,
|
|
210
|
+
input: {
|
|
211
|
+
file: basename(file),
|
|
212
|
+
kind: "swf",
|
|
213
|
+
version: avm1.actions.version,
|
|
214
|
+
sha256: sha256(bytes),
|
|
215
|
+
},
|
|
216
|
+
libraries: [],
|
|
217
|
+
abcs: [],
|
|
218
|
+
avm1: {
|
|
219
|
+
module,
|
|
220
|
+
sha256: compiled.hash,
|
|
221
|
+
blocks: compiled.blocks,
|
|
222
|
+
...(compiled.key === null ? {} : { key: compiled.key, length: compiled.module.length }),
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
const manifestPath = join(out, "manifest.json");
|
|
226
|
+
await writing(manifestPath, () => writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`));
|
|
227
|
+
if (!quiet) {
|
|
228
|
+
const size = Buffer.byteLength(compiled.module);
|
|
229
|
+
const blocks = `${compiled.blocks} AVM1 block${compiled.blocks === 1 ? "" : "s"}`;
|
|
230
|
+
console.log(`${file}: ${blocks}, 1 module, ${size} bytes, compiled in ${Math.round(ms)} ms, in ${out}`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,uEAAuE;AACvE,+BAA+B;AAC/B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EACL,eAAe,EACf,WAAW,EAEX,mBAAmB,EACnB,YAAY,EACZ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AC,CAAC,CAAC,GAAG,EAAE,CAAC;QAClF,OAAO,CAAC,GAAG,CACT,GAAG,IAAI,KAAK,MAAM,eAAe,IAAI,uBAAuB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,GAAG,EAAE,CAC3F,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Command } from "../args.js";
|
|
2
|
+
export declare const help: Command;
|
|
3
|
+
export declare const commands: Map<string, Command>;
|
|
4
|
+
/** The command's own usage: its commands, and the bare form compile keeps. */
|
|
5
|
+
export declare function usage(): string;
|
|
6
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,OAAO,EAAS,MAAM,YAAY,CAAC;AAK/E,eAAO,MAAM,IAAI,EAAE,OAkClB,CAAC;AAEF,eAAO,MAAM,QAAQ,sBAAyE,CAAC;AAE/F,8EAA8E;AAC9E,wBAAgB,KAAK,IAAI,MAAM,CAa9B"}
|