@swf2es/cli 0.1.16 → 0.1.18

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.
@@ -0,0 +1,27 @@
1
+ import type { AbcSurface } from "@swf2es/format";
2
+ /** A library the ABCs link against, whose declarations are written elsewhere. */
3
+ export interface DeclaredLibrary {
4
+ abcs: AbcSurface[];
5
+ /** The type its instance interfaces are keyed in by qualified name, as the output spells it. */
6
+ classes: string;
7
+ }
8
+ export interface DeclarationsOptions {
9
+ /** The ABCs whose classes are declared, in the order they load: the first definition of a name wins. */
10
+ abcs: AbcSurface[];
11
+ /** The maps' names: `${name}Classes` and `${name}Statics`. */
12
+ name: string;
13
+ /** What the ABCs link against, in the order they load, before the ABCs. */
14
+ libraries: DeclaredLibrary[];
15
+ /** The comment the output starts with, without its `// ` prefixes. */
16
+ header: string[];
17
+ /** The import declarations the output needs for `ref`, `value` and the libraries' maps. */
18
+ imports: string[];
19
+ /** How the output spells @swf2es/runtime's avm2 Ref and Value types. */
20
+ ref: string;
21
+ value: string;
22
+ /** Parameter names for a method whose ABC has none, by its class's qualified name and its own. */
23
+ paramNames?: (qualified: string, method: string) => string[] | undefined;
24
+ }
25
+ /** The declarations of the classes `options.abcs` define, as a TypeScript module. */
26
+ export declare function as3Declarations(options: DeclarationsOptions): string;
27
+ //# sourceMappingURL=as3-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"as3-types.d.ts","sourceRoot":"","sources":["../src/as3-types.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAuB,UAAU,EAAY,MAAM,gBAAgB,CAAC;AAEhF,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,gGAAgG;IAChG,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,wGAAwG;IACxG,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,sEAAsE;IACtE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,2FAA2F;IAC3F,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,wEAAwE;IACxE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,kGAAkG;IAClG,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,EAAE,GAAG,SAAS,CAAC;CAC1E;AAwHD,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAsPpE"}
@@ -0,0 +1,299 @@
1
+ // TypeScript declarations of the classes ABCs define: for each class, an
2
+ // interface of its instances' public members and one of its class
3
+ // object's, as natives and hosts reach them through Runtime.prop, setProp
4
+ // and callProp (docs/architecture/runtime.md, "AS3 classes in
5
+ // TypeScript"). The libraries the ABCs link against name the classes they
6
+ // extend and the types they use; what none defines is `Value`.
7
+ //
8
+ // Only type imports, so that node runs this file as it is
9
+ // (tools/as3-types.ts); the command reads the ABCs (commands/types.ts).
10
+ /** A name as the surface spells it ("Array", "flash.geom::Point", "{package:@v0}::uint"), taken apart. */
11
+ function parseName(raw) {
12
+ if (raw.startsWith("{")) {
13
+ const end = raw.lastIndexOf("}::");
14
+ // One namespace, or the same one in several API versions: the first's kind and URI.
15
+ const ns = raw.slice(1, end).split(",")[0];
16
+ const colon = ns.indexOf(":");
17
+ const kind = colon < 0 ? ns : ns.slice(0, colon);
18
+ return {
19
+ kind: kind.replace(/#\d+$/, ""),
20
+ uri: (colon < 0 ? "" : ns.slice(colon + 1)).replace(/@v\d+$/, ""),
21
+ local: raw.slice(end + 3),
22
+ };
23
+ }
24
+ const at = raw.lastIndexOf("::");
25
+ return {
26
+ kind: "package",
27
+ uri: at < 0 ? "" : raw.slice(0, at),
28
+ local: at < 0 ? raw : raw.slice(at + 2),
29
+ };
30
+ }
31
+ /**
32
+ * A class's qualified name, "flash.geom::Rectangle" or a top-level
33
+ * "Array", or null for one no other ABC can name; the builtin's Vector
34
+ * classes, internal to __AS3__.vec, as the types of Vectors.
35
+ */
36
+ function classKey(raw) {
37
+ const n = parseName(raw);
38
+ if (n.kind === "package" || (n.kind === "internal" && n.uri === "__AS3__.vec")) {
39
+ return n.uri ? `${n.uri}::${n.local}` : n.local;
40
+ }
41
+ return null;
42
+ }
43
+ const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
44
+ /** Words a parameter may not be named. */
45
+ const RESERVED = new Set(("break case catch class const continue debugger default delete do else enum export " +
46
+ "extends false finally for function if implements import in instanceof interface let " +
47
+ "new null package private protected public return static super switch this throw true " +
48
+ "try typeof var void while with yield await arguments eval").split(" "));
49
+ function memberName(local) {
50
+ return IDENTIFIER.test(local) && local !== "constructor" ? local : JSON.stringify(local);
51
+ }
52
+ /** The public members of `traits`, a getter and a setter of one name as one property. */
53
+ function membersOf(traits, isInterface) {
54
+ const out = new Map();
55
+ for (const t of traits) {
56
+ const n = parseName(t.name);
57
+ // An interface's methods are in its own namespace, and public in each class that implements it.
58
+ if (n.kind !== "package" && !(isInterface && n.kind === "namespace")) {
59
+ continue;
60
+ }
61
+ switch (t.kind) {
62
+ case "slot":
63
+ case "const":
64
+ out.set(n.local, {
65
+ kind: "property",
66
+ type: t.type,
67
+ readable: true,
68
+ writable: t.kind === "slot",
69
+ constant: t.kind === "const",
70
+ });
71
+ break;
72
+ case "getter":
73
+ case "setter": {
74
+ const had = out.get(n.local);
75
+ const type = t.kind === "getter" ? t.method.returns : (t.method.params[0]?.type ?? "*");
76
+ const was = had?.kind === "property" ? had : null;
77
+ out.set(n.local, {
78
+ kind: "property",
79
+ type: t.kind === "getter" || !was ? type : was.type,
80
+ readable: t.kind === "getter" || (was?.readable ?? false),
81
+ writable: t.kind === "setter" || (was?.writable ?? false),
82
+ constant: false,
83
+ });
84
+ break;
85
+ }
86
+ case "method":
87
+ out.set(n.local, { kind: "method", method: t.method });
88
+ break;
89
+ }
90
+ }
91
+ return out;
92
+ }
93
+ /** The declarations of the classes `options.abcs` define, as a TypeScript module. */
94
+ export function as3Declarations(options) {
95
+ const { ref, value } = options;
96
+ const definitions = new Map();
97
+ const define = (abcs, own, library) => {
98
+ for (const abc of abcs) {
99
+ for (const script of abc.scripts) {
100
+ for (const t of script.traits) {
101
+ const key = t.kind === "class" ? classKey(t.name) : null;
102
+ if (t.kind === "class" && key !== null && !definitions.has(key)) {
103
+ definitions.set(key, { key, cls: t.class, own, library });
104
+ }
105
+ }
106
+ }
107
+ }
108
+ };
109
+ for (const library of options.libraries) {
110
+ define(library.abcs, false, library);
111
+ }
112
+ define(options.abcs, true);
113
+ // Each class's interface's name: its qualified name as an identifier,
114
+ // "As3_flash_geom_Rectangle", and its class object's with a $ after it,
115
+ // told apart by a number where two would meet.
116
+ const keys = [...definitions.keys()].sort();
117
+ const identifiers = new Map();
118
+ const taken = new Set();
119
+ for (const key of keys) {
120
+ const base = `As3_${key.replace(/::|\./g, "_").replace(/[^\w$]/g, "_")}`;
121
+ let id = base;
122
+ for (let i = 2; taken.has(id) || taken.has(`${id}$`); i++) {
123
+ id = `${base}_${i}`;
124
+ }
125
+ taken.add(id);
126
+ taken.add(`${id}$`);
127
+ identifiers.set(key, id);
128
+ }
129
+ // The libraries' classes the output names, each by an alias of its map's entry.
130
+ const used = new Set();
131
+ const named = (key) => {
132
+ const d = definitions.get(key);
133
+ if (!d.own) {
134
+ used.add(key);
135
+ }
136
+ return identifiers.get(key);
137
+ };
138
+ const tsType = (raw) => {
139
+ if (raw === "*") {
140
+ return value;
141
+ }
142
+ if (raw === "void") {
143
+ return "void";
144
+ }
145
+ const vector = raw.match(/^(.*?)\.<(.*)>$/);
146
+ if (vector) {
147
+ const element = classKey(vector[2]);
148
+ const store = element === "int" || element === "uint"
149
+ ? element
150
+ : element === "Number"
151
+ ? "double"
152
+ : "object";
153
+ const key = `__AS3__.vec::Vector$${store}`;
154
+ return definitions.has(key) ? `${ref}<${named(key)}> | null` : value;
155
+ }
156
+ const key = classKey(raw);
157
+ switch (key) {
158
+ case "int":
159
+ case "uint":
160
+ case "Number":
161
+ case "float":
162
+ return "number";
163
+ case "void":
164
+ return "void";
165
+ case "Boolean":
166
+ return "boolean";
167
+ case "String":
168
+ return "string | null";
169
+ case "Object":
170
+ case null:
171
+ return value;
172
+ }
173
+ return definitions.has(key) ? `${ref}<${named(key)}> | null` : value;
174
+ };
175
+ // What each class declares, its bases' included, for telling an override from a new member.
176
+ const declared = new Map();
177
+ const allMembers = (key, seen = new Set()) => {
178
+ const known = declared.get(key);
179
+ if (known) {
180
+ return known;
181
+ }
182
+ const all = new Map();
183
+ const d = definitions.get(key);
184
+ if (d && !seen.has(key)) {
185
+ seen.add(key);
186
+ const isInterface = d.cls.flags.includes("interface");
187
+ const bases = isInterface ? d.cls.interfaces : d.cls.super ? [d.cls.super] : [];
188
+ for (const base of bases) {
189
+ const b = classKey(base);
190
+ if (b !== null) {
191
+ for (const [name, m] of allMembers(b, seen)) {
192
+ all.set(name, m);
193
+ }
194
+ }
195
+ }
196
+ for (const [name, m] of membersOf(d.cls.instance, isInterface)) {
197
+ const had = all.get(name);
198
+ // An accessor's override may declare one half alone: the other is still the base's.
199
+ if (m.kind === "property" && had?.kind === "property" && !m.constant) {
200
+ all.set(name, {
201
+ ...had,
202
+ readable: m.readable || had.readable,
203
+ writable: m.writable || had.writable,
204
+ });
205
+ }
206
+ else {
207
+ all.set(name, m);
208
+ }
209
+ }
210
+ }
211
+ declared.set(key, all);
212
+ return all;
213
+ };
214
+ const params = (key, member, m) => {
215
+ const names = options.paramNames?.(key, member);
216
+ const seen = new Set();
217
+ const name = (i, given) => {
218
+ const n = given ?? names?.[i];
219
+ const ok = n !== undefined && IDENTIFIER.test(n) && !RESERVED.has(n) && !seen.has(n);
220
+ const out = ok ? n : `arg${i}`;
221
+ seen.add(out);
222
+ return out;
223
+ };
224
+ const list = m.params.map((p, i) => `${name(i, p.name)}${p.default ? "?" : ""}: ${tsType(p.type)}`);
225
+ if (m.flags.includes("rest")) {
226
+ const rest = names?.[m.params.length];
227
+ const n = rest && IDENTIFIER.test(rest) && !RESERVED.has(rest) ? rest : "rest";
228
+ list.push(`...${seen.has(n) ? "rest" : n}: ${value}[]`);
229
+ }
230
+ return list.join(", ");
231
+ };
232
+ const memberLines = (key, members) => {
233
+ const lines = [];
234
+ for (const name of [...members.keys()].sort()) {
235
+ const m = members.get(name);
236
+ if (m.kind === "method") {
237
+ lines.push(` ${memberName(name)}(${params(key, name, m.method)}): ${tsType(m.method.returns)};`);
238
+ continue;
239
+ }
240
+ if (!m.readable) {
241
+ lines.push(" /** Write-only: reading it throws, as in AS3. */");
242
+ }
243
+ lines.push(` ${m.writable ? "" : "readonly "}${memberName(name)}: ${tsType(m.type)};`);
244
+ }
245
+ return lines;
246
+ };
247
+ const block = (head, lines) => lines.length ? [`${head} {`, ...lines, "}"] : [`${head} {}`];
248
+ const body = [];
249
+ const own = keys.filter((k) => definitions.get(k).own);
250
+ for (const key of own) {
251
+ const d = definitions.get(key);
252
+ const id = identifiers.get(key);
253
+ const isInterface = d.cls.flags.includes("interface");
254
+ const bases = (isInterface ? d.cls.interfaces : d.cls.super ? [d.cls.super] : [])
255
+ .map(classKey)
256
+ .filter((b) => b !== null && definitions.has(b));
257
+ const inherited = new Map();
258
+ for (const b of bases) {
259
+ for (const [name, m] of allMembers(b)) {
260
+ inherited.set(name, m);
261
+ }
262
+ }
263
+ // A member a base declares stays the base's, but for an accessor this class makes writable.
264
+ const mine = new Map();
265
+ for (const [name, m] of allMembers(key)) {
266
+ const had = inherited.get(name);
267
+ if (had === undefined ||
268
+ (had.kind === "property" && m.kind === "property" && m.writable && !had.writable)) {
269
+ mine.set(name, m);
270
+ }
271
+ }
272
+ body.push("", ...block(`export interface ${id}${bases.length ? ` extends ${bases.map(named).join(", ")}` : ""}`, memberLines(key, mine)), "", ...block(`export interface ${id}$`, memberLines(key, membersOf(d.cls.static, false))));
273
+ }
274
+ const aliases = [];
275
+ for (const key of [...used].sort()) {
276
+ const library = definitions.get(key).library;
277
+ aliases.push(`type ${identifiers.get(key)} = ${library.classes}[${JSON.stringify(key)}];`);
278
+ }
279
+ const map = (suffix) => own.map((k) => ` ${JSON.stringify(k)}: ${identifiers.get(k)}${suffix};`);
280
+ return [
281
+ ...options.header.map((line) => (line ? `// ${line}` : "//")),
282
+ "",
283
+ ...options.imports,
284
+ ...(aliases.length ? ["", ...aliases] : []),
285
+ "",
286
+ "/** Each class's instances' public members, by the class's qualified name. */",
287
+ `export interface ${options.name}Classes {`,
288
+ ...map(""),
289
+ "}",
290
+ "",
291
+ "/** Each class object's public members, its static ones, by the class's qualified name. */",
292
+ `export interface ${options.name}Statics {`,
293
+ ...map("$"),
294
+ "}",
295
+ ...body,
296
+ "",
297
+ ].join("\n");
298
+ }
299
+ //# sourceMappingURL=as3-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"as3-types.js","sourceRoot":"","sources":["../src/as3-types.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,kEAAkE;AAClE,0EAA0E;AAC1E,8DAA8D;AAC9D,0EAA0E;AAC1E,+DAA+D;AAC/D,EAAE;AACF,0DAA0D;AAC1D,wEAAwE;AAoCxE,0GAA0G;AAC1G,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACnC,oFAAoF;QACpF,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,IAAI,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C,CAAC,CAAC,EAAE,CAAC;QAC3C,EAAE;QACF,+EAA+E;QAC/E,oBAAoB,OAAO,CAAC,IAAI,WAAW;QAC3C,GAAG,GAAG,CAAC,EAAE,CAAC;QACV,GAAG;QACH,EAAE;QACF,4FAA4F;QAC5F,oBAAoB,OAAO,CAAC,IAAI,WAAW;QAC3C,GAAG,GAAG,CAAC,GAAG,CAAC;QACX,GAAG;QACH,GAAG,IAAI;QACP,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -1 +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;AAyC/E,eAAO,MAAM,QAAQ,sBAAyE,CAAC;AAE/F,8EAA8E;AAC9E,wBAAgB,KAAK,IAAI,MAAM,CAa9B"}
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,OAAO,EAAS,MAAM,YAAY,CAAC;AA0C/E,eAAO,MAAM,QAAQ,sBAEpB,CAAC;AAEF,8EAA8E;AAC9E,wBAAgB,KAAK,IAAI,MAAM,CAa9B"}
@@ -4,6 +4,7 @@ import { COMMON_OPTIONS, COMMON_USAGE, parse } from "../args.js";
4
4
  import { usageError } from "../output.js";
5
5
  import { compile } from "./compile.js";
6
6
  import { run } from "./run.js";
7
+ import { types } from "./types.js";
7
8
  const help = {
8
9
  name: "help",
9
10
  summary: "show the commands, or a command's usage",
@@ -33,7 +34,7 @@ ${COMMON_USAGE}`,
33
34
  console.log(command.usage);
34
35
  },
35
36
  };
36
- export const commands = new Map([compile, run, help].map((c) => [c.name, c]));
37
+ export const commands = new Map([compile, run, types, help].map((c) => [c.name, c]));
37
38
  /** The command's own usage: its commands, and the bare form compile keeps. */
38
39
  export function usage() {
39
40
  const width = Math.max(...[...commands.keys()].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AEF,8EAA8E;AAC9E,MAAM,UAAU,KAAK;IACnB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1F,OAAO;;;;EAIP,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGf,YAAY;;mDAEqC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Command } from "../args.js";
2
+ export declare const types: Command;
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AASA,OAAO,EAAgC,KAAK,OAAO,EAAS,MAAM,YAAY,CAAC;AA2C/E,eAAO,MAAM,KAAK,EAAE,OA6DnB,CAAC"}
@@ -0,0 +1,104 @@
1
+ // swf2es types: TypeScript declarations of the classes a SWF's or an ABC's
2
+ // code defines (as3-types.ts), extending those of the libraries the player
3
+ // links it against, for a host or a native to reach its objects by.
4
+ import { writeFile } from "node:fs/promises";
5
+ import { basename } from "node:path";
6
+ import { parseArgs } from "node:util";
7
+ import { readAbcSurface } from "@swf2es/format";
8
+ import { airLibrary, builtinLibrary, playerglobalLibrary } from "@swf2es/player/libraries";
9
+ import { InputError, readInput } from "../aot.js";
10
+ import { COMMON_OPTIONS, COMMON_USAGE, parse } from "../args.js";
11
+ import { as3Declarations } from "../as3-types.js";
12
+ import { read, writing } from "../files.js";
13
+ import { fail, usageError } from "../output.js";
14
+ const USAGE = `usage: swf2es types <file.swf|file.abc> [options]
15
+
16
+ Writes TypeScript declarations of the classes a SWF's ABCs (its DoABC and
17
+ DoABC2 tags) or a bare ABC define: for each class, an interface of its
18
+ instances' public members and one of its class object's (statics), keyed
19
+ by qualified name in Classes and Statics, for @swf2es/runtime's
20
+ Runtime.prop, setProp and callProp. A class extends the declarations of
21
+ the one it extends in the libraries the player loads, builtin.abc and
22
+ the player's playerglobal (@swf2es/player/as3-types); a type that none
23
+ defines is avm2.Value.
24
+
25
+ options:
26
+ -o, --out <file> where to write (default: standard output)
27
+ --name <prefix> the maps' names' prefix: <prefix>Classes and
28
+ <prefix>Statics (default: none)
29
+ --air resolve types against AIR's library too, as the
30
+ player links an AIR application's SWF
31
+ ${COMMON_USAGE}
32
+
33
+ exit status: 0 on success, 2 for a mistake in the command line, 1 for
34
+ anything else (an unreadable, malformed or AVM1 input, or an output that
35
+ cannot be written)`;
36
+ const OPTIONS = {
37
+ out: { type: "string", short: "o" },
38
+ name: { type: "string" },
39
+ air: { type: "boolean" },
40
+ ...COMMON_OPTIONS,
41
+ };
42
+ function surfaceOf(abc, what) {
43
+ try {
44
+ return readAbcSurface(abc);
45
+ }
46
+ catch (e) {
47
+ fail(`${what}: a malformed ABC (${e.message})`);
48
+ }
49
+ }
50
+ export const types = {
51
+ name: "types",
52
+ summary: "write TypeScript declarations of a SWF's or an ABC's classes",
53
+ usage: USAGE,
54
+ async main(argv) {
55
+ const parsed = parse(types, () => parseArgs({ args: argv, allowPositionals: true, options: OPTIONS }));
56
+ if (!parsed) {
57
+ return;
58
+ }
59
+ const { values, positionals } = parsed;
60
+ if (positionals.length !== 1) {
61
+ usageError(`expected one input file, got ${positionals.length}`, "types");
62
+ }
63
+ const name = values.name ?? "";
64
+ if (name && !/^[A-Za-z_$][\w$]*$/.test(name)) {
65
+ usageError(`--name ${name} is not an identifier`, "types");
66
+ }
67
+ const file = positionals[0];
68
+ let input;
69
+ try {
70
+ input = readInput(await read(file, "input"));
71
+ }
72
+ catch (e) {
73
+ fail(e instanceof InputError ? `${file}: ${e.message}` : String(e.stack ?? e));
74
+ }
75
+ if (input.avm1) {
76
+ fail(`${file} is an AVM1 SWF, which defines no classes`);
77
+ }
78
+ const abcs = input.abcs.map((a, i) => surfaceOf(a.abc, `${file}, ABC ${i}`));
79
+ const libraries = [builtinLibrary, playerglobalLibrary, ...(values.air ? [airLibrary] : [])];
80
+ const text = as3Declarations({
81
+ abcs,
82
+ name,
83
+ libraries: [{ abcs: libraries.map((l) => surfaceOf(l, "a library")), classes: "As3Classes" }],
84
+ header: [
85
+ `TypeScript declarations of ${basename(file)}'s classes: each one's public`,
86
+ "members, for @swf2es/runtime's Runtime.prop, setProp and callProp.",
87
+ `Generated by swf2es types${values.air ? " --air" : ""}.`,
88
+ ],
89
+ imports: [
90
+ 'import type { As3Classes } from "@swf2es/player/as3-types";',
91
+ 'import type { avm2 } from "@swf2es/runtime";',
92
+ ],
93
+ ref: "avm2.Ref",
94
+ value: "avm2.Value",
95
+ });
96
+ const out = values.out;
97
+ if (out === undefined) {
98
+ process.stdout.write(text);
99
+ return;
100
+ }
101
+ await writing(out, () => writeFile(out, text));
102
+ },
103
+ };
104
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,oEAAoE;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAmB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WA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QAC7F,MAAM,IAAI,GAAG,eAAe,CAAC;YAC3B,IAAI;YACJ,IAAI;YACJ,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;YAC7F,MAAM,EAAE;gBACN,8BAA8B,QAAQ,CAAC,IAAI,CAAC,+BAA+B;gBAC3E,oEAAoE;gBACpE,4BAA4B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG;aAC1D;YACD,OAAO,EAAE;gBACP,6DAA6D;gBAC7D,8CAA8C;aAC/C;YACD,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,YAAY;SACpB,CAAC,CAAC;QAEH,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACvB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,OAAO;QACT,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;CACF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
- /** The ahead-of-time compiler and avmshell's way of running ABCs as a library, for a host that does without the command. */
1
+ /**
2
+ * The ahead-of-time compiler, avmshell's way of running ABCs and the
3
+ * declarations of ABCs' classes as a library, for a host that does without
4
+ * the command.
5
+ */
2
6
  export { type AbcInput, type ActionsModule, AIR_API_VERSION, API_VERSION, type Avm1Input, compileActionsAhead, compileAhead, type Input, type Module, RejectedError, readInput, sha256, } from "./aot.js";
7
+ export { as3Declarations, type DeclarationsOptions, type DeclaredLibrary } from "./as3-types.js";
3
8
  export { evaluateModule, runShell, type ShellCompiler, type ShellLibrary, type ShellModule, type ShellOptions, shellDomain, } from "./shell.js";
4
9
  export { nodeShellThreads, type ShellThreads, type ShellThreadsOptions } from "./threads.js";
5
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4HAA4H;AAC5H,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,eAAe,EACf,WAAW,EACX,KAAK,SAAS,EACd,mBAAmB,EACnB,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,aAAa,EACb,SAAS,EACT,MAAM,GACP,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,cAAc,EACd,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,eAAe,EACf,WAAW,EACX,KAAK,SAAS,EACd,mBAAmB,EACnB,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,aAAa,EACb,SAAS,EACT,MAAM,GACP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,EACL,cAAc,EACd,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,10 @@
1
- /** The ahead-of-time compiler and avmshell's way of running ABCs as a library, for a host that does without the command. */
1
+ /**
2
+ * The ahead-of-time compiler, avmshell's way of running ABCs and the
3
+ * declarations of ABCs' classes as a library, for a host that does without
4
+ * the command.
5
+ */
2
6
  export { AIR_API_VERSION, API_VERSION, compileActionsAhead, compileAhead, RejectedError, readInput, sha256, } from "./aot.js";
7
+ export { as3Declarations } from "./as3-types.js";
3
8
  export { evaluateModule, runShell, shellDomain, } from "./shell.js";
4
9
  export { nodeShellThreads } from "./threads.js";
5
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4HAA4H;AAC5H,OAAO,EAGL,eAAe,EACf,WAAW,EAEX,mBAAmB,EACnB,YAAY,EAGZ,aAAa,EACb,SAAS,EACT,MAAM,GACP,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,cAAc,EACd,QAAQ,EAKR,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAA+C,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAGL,eAAe,EACf,WAAW,EAEX,mBAAmB,EACnB,YAAY,EAGZ,aAAa,EACb,SAAS,EACT,MAAM,GACP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAkD,MAAM,gBAAgB,CAAC;AACjG,OAAO,EACL,cAAc,EACd,QAAQ,EAKR,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAA+C,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swf2es/cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "swf2es command line: ahead-of-time compile SWF and ABC files, and run ABCs as avmshell does",
5
5
  "keywords": [
6
6
  "swf",
@@ -41,9 +41,9 @@
41
41
  "LICENSE.third-party"
42
42
  ],
43
43
  "dependencies": {
44
- "@swf2es/format": "0.1.16",
45
- "@swf2es/codegen": "0.1.16",
46
- "@swf2es/runtime": "0.1.16",
47
- "@swf2es/player": "0.1.16"
44
+ "@swf2es/format": "0.1.18",
45
+ "@swf2es/player": "0.1.18",
46
+ "@swf2es/codegen": "0.1.18",
47
+ "@swf2es/runtime": "0.1.18"
48
48
  }
49
49
  }
@@ -0,0 +1,403 @@
1
+ // TypeScript declarations of the classes ABCs define: for each class, an
2
+ // interface of its instances' public members and one of its class
3
+ // object's, as natives and hosts reach them through Runtime.prop, setProp
4
+ // and callProp (docs/architecture/runtime.md, "AS3 classes in
5
+ // TypeScript"). The libraries the ABCs link against name the classes they
6
+ // extend and the types they use; what none defines is `Value`.
7
+ //
8
+ // Only type imports, so that node runs this file as it is
9
+ // (tools/as3-types.ts); the command reads the ABCs (commands/types.ts).
10
+
11
+ import type { AbcClass, AbcMethod, AbcSurface, AbcTrait } from "@swf2es/format";
12
+
13
+ /** A library the ABCs link against, whose declarations are written elsewhere. */
14
+ export interface DeclaredLibrary {
15
+ abcs: AbcSurface[];
16
+ /** The type its instance interfaces are keyed in by qualified name, as the output spells it. */
17
+ classes: string;
18
+ }
19
+
20
+ export interface DeclarationsOptions {
21
+ /** The ABCs whose classes are declared, in the order they load: the first definition of a name wins. */
22
+ abcs: AbcSurface[];
23
+ /** The maps' names: `${name}Classes` and `${name}Statics`. */
24
+ name: string;
25
+ /** What the ABCs link against, in the order they load, before the ABCs. */
26
+ libraries: DeclaredLibrary[];
27
+ /** The comment the output starts with, without its `// ` prefixes. */
28
+ header: string[];
29
+ /** The import declarations the output needs for `ref`, `value` and the libraries' maps. */
30
+ imports: string[];
31
+ /** How the output spells @swf2es/runtime's avm2 Ref and Value types. */
32
+ ref: string;
33
+ value: string;
34
+ /** Parameter names for a method whose ABC has none, by its class's qualified name and its own. */
35
+ paramNames?: (qualified: string, method: string) => string[] | undefined;
36
+ }
37
+
38
+ /** A name's namespace kind and URI, and its local name. */
39
+ interface Name {
40
+ kind: string;
41
+ uri: string;
42
+ local: string;
43
+ }
44
+
45
+ /** A name as the surface spells it ("Array", "flash.geom::Point", "{package:@v0}::uint"), taken apart. */
46
+ function parseName(raw: string): Name {
47
+ if (raw.startsWith("{")) {
48
+ const end = raw.lastIndexOf("}::");
49
+ // One namespace, or the same one in several API versions: the first's kind and URI.
50
+ const ns = raw.slice(1, end).split(",")[0];
51
+ const colon = ns.indexOf(":");
52
+ const kind = colon < 0 ? ns : ns.slice(0, colon);
53
+ return {
54
+ kind: kind.replace(/#\d+$/, ""),
55
+ uri: (colon < 0 ? "" : ns.slice(colon + 1)).replace(/@v\d+$/, ""),
56
+ local: raw.slice(end + 3),
57
+ };
58
+ }
59
+
60
+ const at = raw.lastIndexOf("::");
61
+ return {
62
+ kind: "package",
63
+ uri: at < 0 ? "" : raw.slice(0, at),
64
+ local: at < 0 ? raw : raw.slice(at + 2),
65
+ };
66
+ }
67
+
68
+ /**
69
+ * A class's qualified name, "flash.geom::Rectangle" or a top-level
70
+ * "Array", or null for one no other ABC can name; the builtin's Vector
71
+ * classes, internal to __AS3__.vec, as the types of Vectors.
72
+ */
73
+ function classKey(raw: string): string | null {
74
+ const n = parseName(raw);
75
+ if (n.kind === "package" || (n.kind === "internal" && n.uri === "__AS3__.vec")) {
76
+ return n.uri ? `${n.uri}::${n.local}` : n.local;
77
+ }
78
+
79
+ return null;
80
+ }
81
+
82
+ const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
83
+
84
+ /** Words a parameter may not be named. */
85
+ const RESERVED = new Set(
86
+ (
87
+ "break case catch class const continue debugger default delete do else enum export " +
88
+ "extends false finally for function if implements import in instanceof interface let " +
89
+ "new null package private protected public return static super switch this throw true " +
90
+ "try typeof var void while with yield await arguments eval"
91
+ ).split(" "),
92
+ );
93
+
94
+ function memberName(local: string): string {
95
+ return IDENTIFIER.test(local) && local !== "constructor" ? local : JSON.stringify(local);
96
+ }
97
+
98
+ /** A class's public members, by local name: what a property or a method declares. */
99
+ type Member =
100
+ | { kind: "property"; type: string; readable: boolean; writable: boolean; constant: boolean }
101
+ | { kind: "method"; method: AbcMethod };
102
+
103
+ interface Definition {
104
+ key: string;
105
+ cls: AbcClass;
106
+ /** Whether the output declares it, rather than a library's. */
107
+ own: boolean;
108
+ /** The library whose map declares it, if not own. */
109
+ library?: DeclaredLibrary;
110
+ }
111
+
112
+ /** The public members of `traits`, a getter and a setter of one name as one property. */
113
+ function membersOf(traits: AbcTrait[], isInterface: boolean): Map<string, Member> {
114
+ const out = new Map<string, Member>();
115
+ for (const t of traits) {
116
+ const n = parseName(t.name);
117
+ // An interface's methods are in its own namespace, and public in each class that implements it.
118
+ if (n.kind !== "package" && !(isInterface && n.kind === "namespace")) {
119
+ continue;
120
+ }
121
+
122
+ switch (t.kind) {
123
+ case "slot":
124
+ case "const":
125
+ out.set(n.local, {
126
+ kind: "property",
127
+ type: t.type,
128
+ readable: true,
129
+ writable: t.kind === "slot",
130
+ constant: t.kind === "const",
131
+ });
132
+ break;
133
+ case "getter":
134
+ case "setter": {
135
+ const had = out.get(n.local);
136
+ const type = t.kind === "getter" ? t.method.returns : (t.method.params[0]?.type ?? "*");
137
+ const was = had?.kind === "property" ? had : null;
138
+ out.set(n.local, {
139
+ kind: "property",
140
+ type: t.kind === "getter" || !was ? type : was.type,
141
+ readable: t.kind === "getter" || (was?.readable ?? false),
142
+ writable: t.kind === "setter" || (was?.writable ?? false),
143
+ constant: false,
144
+ });
145
+ break;
146
+ }
147
+ case "method":
148
+ out.set(n.local, { kind: "method", method: t.method });
149
+ break;
150
+ }
151
+ }
152
+
153
+ return out;
154
+ }
155
+
156
+ /** The declarations of the classes `options.abcs` define, as a TypeScript module. */
157
+ export function as3Declarations(options: DeclarationsOptions): string {
158
+ const { ref, value } = options;
159
+ const definitions = new Map<string, Definition>();
160
+ const define = (abcs: AbcSurface[], own: boolean, library?: DeclaredLibrary) => {
161
+ for (const abc of abcs) {
162
+ for (const script of abc.scripts) {
163
+ for (const t of script.traits) {
164
+ const key = t.kind === "class" ? classKey(t.name) : null;
165
+ if (t.kind === "class" && key !== null && !definitions.has(key)) {
166
+ definitions.set(key, { key, cls: t.class, own, library });
167
+ }
168
+ }
169
+ }
170
+ }
171
+ };
172
+ for (const library of options.libraries) {
173
+ define(library.abcs, false, library);
174
+ }
175
+
176
+ define(options.abcs, true);
177
+
178
+ // Each class's interface's name: its qualified name as an identifier,
179
+ // "As3_flash_geom_Rectangle", and its class object's with a $ after it,
180
+ // told apart by a number where two would meet.
181
+ const keys = [...definitions.keys()].sort();
182
+ const identifiers = new Map<string, string>();
183
+ const taken = new Set<string>();
184
+ for (const key of keys) {
185
+ const base = `As3_${key.replace(/::|\./g, "_").replace(/[^\w$]/g, "_")}`;
186
+ let id = base;
187
+ for (let i = 2; taken.has(id) || taken.has(`${id}$`); i++) {
188
+ id = `${base}_${i}`;
189
+ }
190
+
191
+ taken.add(id);
192
+ taken.add(`${id}$`);
193
+ identifiers.set(key, id);
194
+ }
195
+
196
+ // The libraries' classes the output names, each by an alias of its map's entry.
197
+ const used = new Set<string>();
198
+ const named = (key: string): string => {
199
+ const d = definitions.get(key) as Definition;
200
+ if (!d.own) {
201
+ used.add(key);
202
+ }
203
+
204
+ return identifiers.get(key) as string;
205
+ };
206
+
207
+ const tsType = (raw: string): string => {
208
+ if (raw === "*") {
209
+ return value;
210
+ }
211
+
212
+ if (raw === "void") {
213
+ return "void";
214
+ }
215
+
216
+ const vector = raw.match(/^(.*?)\.<(.*)>$/);
217
+ if (vector) {
218
+ const element = classKey(vector[2]);
219
+ const store =
220
+ element === "int" || element === "uint"
221
+ ? element
222
+ : element === "Number"
223
+ ? "double"
224
+ : "object";
225
+ const key = `__AS3__.vec::Vector$${store}`;
226
+ return definitions.has(key) ? `${ref}<${named(key)}> | null` : value;
227
+ }
228
+
229
+ const key = classKey(raw);
230
+ switch (key) {
231
+ case "int":
232
+ case "uint":
233
+ case "Number":
234
+ case "float":
235
+ return "number";
236
+ case "void":
237
+ return "void";
238
+ case "Boolean":
239
+ return "boolean";
240
+ case "String":
241
+ return "string | null";
242
+ case "Object":
243
+ case null:
244
+ return value;
245
+ }
246
+
247
+ return definitions.has(key) ? `${ref}<${named(key)}> | null` : value;
248
+ };
249
+
250
+ // What each class declares, its bases' included, for telling an override from a new member.
251
+ const declared = new Map<string, Map<string, Member>>();
252
+ const allMembers = (key: string, seen: Set<string> = new Set()): Map<string, Member> => {
253
+ const known = declared.get(key);
254
+ if (known) {
255
+ return known;
256
+ }
257
+
258
+ const all = new Map<string, Member>();
259
+ const d = definitions.get(key);
260
+ if (d && !seen.has(key)) {
261
+ seen.add(key);
262
+ const isInterface = d.cls.flags.includes("interface");
263
+ const bases = isInterface ? d.cls.interfaces : d.cls.super ? [d.cls.super] : [];
264
+ for (const base of bases) {
265
+ const b = classKey(base);
266
+ if (b !== null) {
267
+ for (const [name, m] of allMembers(b, seen)) {
268
+ all.set(name, m);
269
+ }
270
+ }
271
+ }
272
+
273
+ for (const [name, m] of membersOf(d.cls.instance, isInterface)) {
274
+ const had = all.get(name);
275
+ // An accessor's override may declare one half alone: the other is still the base's.
276
+ if (m.kind === "property" && had?.kind === "property" && !m.constant) {
277
+ all.set(name, {
278
+ ...had,
279
+ readable: m.readable || had.readable,
280
+ writable: m.writable || had.writable,
281
+ });
282
+ } else {
283
+ all.set(name, m);
284
+ }
285
+ }
286
+ }
287
+
288
+ declared.set(key, all);
289
+ return all;
290
+ };
291
+
292
+ const params = (key: string, member: string, m: AbcMethod): string => {
293
+ const names = options.paramNames?.(key, member);
294
+ const seen = new Set<string>();
295
+ const name = (i: number, given: string | undefined) => {
296
+ const n = given ?? names?.[i];
297
+ const ok = n !== undefined && IDENTIFIER.test(n) && !RESERVED.has(n) && !seen.has(n);
298
+ const out = ok ? n : `arg${i}`;
299
+ seen.add(out);
300
+ return out;
301
+ };
302
+ const list = m.params.map(
303
+ (p, i) => `${name(i, p.name)}${p.default ? "?" : ""}: ${tsType(p.type)}`,
304
+ );
305
+ if (m.flags.includes("rest")) {
306
+ const rest = names?.[m.params.length];
307
+ const n = rest && IDENTIFIER.test(rest) && !RESERVED.has(rest) ? rest : "rest";
308
+ list.push(`...${seen.has(n) ? "rest" : n}: ${value}[]`);
309
+ }
310
+
311
+ return list.join(", ");
312
+ };
313
+
314
+ const memberLines = (key: string, members: Map<string, Member>): string[] => {
315
+ const lines: string[] = [];
316
+ for (const name of [...members.keys()].sort()) {
317
+ const m = members.get(name) as Member;
318
+ if (m.kind === "method") {
319
+ lines.push(
320
+ ` ${memberName(name)}(${params(key, name, m.method)}): ${tsType(m.method.returns)};`,
321
+ );
322
+ continue;
323
+ }
324
+
325
+ if (!m.readable) {
326
+ lines.push(" /** Write-only: reading it throws, as in AS3. */");
327
+ }
328
+
329
+ lines.push(` ${m.writable ? "" : "readonly "}${memberName(name)}: ${tsType(m.type)};`);
330
+ }
331
+
332
+ return lines;
333
+ };
334
+
335
+ const block = (head: string, lines: string[]) =>
336
+ lines.length ? [`${head} {`, ...lines, "}"] : [`${head} {}`];
337
+
338
+ const body: string[] = [];
339
+ const own = keys.filter((k) => (definitions.get(k) as Definition).own);
340
+ for (const key of own) {
341
+ const d = definitions.get(key) as Definition;
342
+ const id = identifiers.get(key) as string;
343
+ const isInterface = d.cls.flags.includes("interface");
344
+ const bases = (isInterface ? d.cls.interfaces : d.cls.super ? [d.cls.super] : [])
345
+ .map(classKey)
346
+ .filter((b): b is string => b !== null && definitions.has(b));
347
+ const inherited = new Map<string, Member>();
348
+ for (const b of bases) {
349
+ for (const [name, m] of allMembers(b)) {
350
+ inherited.set(name, m);
351
+ }
352
+ }
353
+
354
+ // A member a base declares stays the base's, but for an accessor this class makes writable.
355
+ const mine = new Map<string, Member>();
356
+ for (const [name, m] of allMembers(key)) {
357
+ const had = inherited.get(name);
358
+ if (
359
+ had === undefined ||
360
+ (had.kind === "property" && m.kind === "property" && m.writable && !had.writable)
361
+ ) {
362
+ mine.set(name, m);
363
+ }
364
+ }
365
+
366
+ body.push(
367
+ "",
368
+ ...block(
369
+ `export interface ${id}${bases.length ? ` extends ${bases.map(named).join(", ")}` : ""}`,
370
+ memberLines(key, mine),
371
+ ),
372
+ "",
373
+ ...block(`export interface ${id}$`, memberLines(key, membersOf(d.cls.static, false))),
374
+ );
375
+ }
376
+
377
+ const aliases: string[] = [];
378
+ for (const key of [...used].sort()) {
379
+ const library = (definitions.get(key) as Definition).library as DeclaredLibrary;
380
+ aliases.push(`type ${identifiers.get(key)} = ${library.classes}[${JSON.stringify(key)}];`);
381
+ }
382
+
383
+ const map = (suffix: string) =>
384
+ own.map((k) => ` ${JSON.stringify(k)}: ${identifiers.get(k)}${suffix};`);
385
+ return [
386
+ ...options.header.map((line) => (line ? `// ${line}` : "//")),
387
+ "",
388
+ ...options.imports,
389
+ ...(aliases.length ? ["", ...aliases] : []),
390
+ "",
391
+ "/** Each class's instances' public members, by the class's qualified name. */",
392
+ `export interface ${options.name}Classes {`,
393
+ ...map(""),
394
+ "}",
395
+ "",
396
+ "/** Each class object's public members, its static ones, by the class's qualified name. */",
397
+ `export interface ${options.name}Statics {`,
398
+ ...map("$"),
399
+ "}",
400
+ ...body,
401
+ "",
402
+ ].join("\n");
403
+ }
@@ -4,6 +4,7 @@ import { COMMON_OPTIONS, COMMON_USAGE, type Command, parse } from "../args.js";
4
4
  import { usageError } from "../output.js";
5
5
  import { compile } from "./compile.js";
6
6
  import { run } from "./run.js";
7
+ import { types } from "./types.js";
7
8
 
8
9
  const help: Command = {
9
10
  name: "help",
@@ -41,7 +42,9 @@ ${COMMON_USAGE}`,
41
42
  },
42
43
  };
43
44
 
44
- export const commands = new Map<string, Command>([compile, run, help].map((c) => [c.name, c]));
45
+ export const commands = new Map<string, Command>(
46
+ [compile, run, types, help].map((c) => [c.name, c]),
47
+ );
45
48
 
46
49
  /** The command's own usage: its commands, and the bare form compile keeps. */
47
50
  export function usage(): string {
@@ -0,0 +1,114 @@
1
+ // swf2es types: TypeScript declarations of the classes a SWF's or an ABC's
2
+ // code defines (as3-types.ts), extending those of the libraries the player
3
+ // links it against, for a host or a native to reach its objects by.
4
+ import { writeFile } from "node:fs/promises";
5
+ import { basename } from "node:path";
6
+ import { parseArgs } from "node:util";
7
+ import { type AbcSurface, readAbcSurface } from "@swf2es/format";
8
+ import { airLibrary, builtinLibrary, playerglobalLibrary } from "@swf2es/player/libraries";
9
+ import { InputError, readInput } from "../aot.js";
10
+ import { COMMON_OPTIONS, COMMON_USAGE, type Command, parse } from "../args.js";
11
+ import { as3Declarations } from "../as3-types.js";
12
+ import { read, writing } from "../files.js";
13
+ import { fail, usageError } from "../output.js";
14
+
15
+ const USAGE = `usage: swf2es types <file.swf|file.abc> [options]
16
+
17
+ Writes TypeScript declarations of the classes a SWF's ABCs (its DoABC and
18
+ DoABC2 tags) or a bare ABC define: for each class, an interface of its
19
+ instances' public members and one of its class object's (statics), keyed
20
+ by qualified name in Classes and Statics, for @swf2es/runtime's
21
+ Runtime.prop, setProp and callProp. A class extends the declarations of
22
+ the one it extends in the libraries the player loads, builtin.abc and
23
+ the player's playerglobal (@swf2es/player/as3-types); a type that none
24
+ defines is avm2.Value.
25
+
26
+ options:
27
+ -o, --out <file> where to write (default: standard output)
28
+ --name <prefix> the maps' names' prefix: <prefix>Classes and
29
+ <prefix>Statics (default: none)
30
+ --air resolve types against AIR's library too, as the
31
+ player links an AIR application's SWF
32
+ ${COMMON_USAGE}
33
+
34
+ exit status: 0 on success, 2 for a mistake in the command line, 1 for
35
+ anything else (an unreadable, malformed or AVM1 input, or an output that
36
+ cannot be written)`;
37
+
38
+ const OPTIONS = {
39
+ out: { type: "string", short: "o" },
40
+ name: { type: "string" },
41
+ air: { type: "boolean" },
42
+ ...COMMON_OPTIONS,
43
+ } as const;
44
+
45
+ function surfaceOf(abc: Uint8Array, what: string): AbcSurface {
46
+ try {
47
+ return readAbcSurface(abc);
48
+ } catch (e) {
49
+ fail(`${what}: a malformed ABC (${(e as Error).message})`);
50
+ }
51
+ }
52
+
53
+ export const types: Command = {
54
+ name: "types",
55
+ summary: "write TypeScript declarations of a SWF's or an ABC's classes",
56
+ usage: USAGE,
57
+ async main(argv) {
58
+ const parsed = parse(types, () =>
59
+ parseArgs({ args: argv, allowPositionals: true, options: OPTIONS }),
60
+ );
61
+ if (!parsed) {
62
+ return;
63
+ }
64
+
65
+ const { values, positionals } = parsed;
66
+ if (positionals.length !== 1) {
67
+ usageError(`expected one input file, got ${positionals.length}`, "types");
68
+ }
69
+
70
+ const name = values.name ?? "";
71
+ if (name && !/^[A-Za-z_$][\w$]*$/.test(name)) {
72
+ usageError(`--name ${name} is not an identifier`, "types");
73
+ }
74
+
75
+ const file = positionals[0];
76
+ let input: ReturnType<typeof readInput>;
77
+ try {
78
+ input = readInput(await read(file, "input"));
79
+ } catch (e) {
80
+ fail(e instanceof InputError ? `${file}: ${e.message}` : String((e as Error).stack ?? e));
81
+ }
82
+
83
+ if (input.avm1) {
84
+ fail(`${file} is an AVM1 SWF, which defines no classes`);
85
+ }
86
+
87
+ const abcs = input.abcs.map((a, i) => surfaceOf(a.abc, `${file}, ABC ${i}`));
88
+ const libraries = [builtinLibrary, playerglobalLibrary, ...(values.air ? [airLibrary] : [])];
89
+ const text = as3Declarations({
90
+ abcs,
91
+ name,
92
+ libraries: [{ abcs: libraries.map((l) => surfaceOf(l, "a library")), classes: "As3Classes" }],
93
+ header: [
94
+ `TypeScript declarations of ${basename(file)}'s classes: each one's public`,
95
+ "members, for @swf2es/runtime's Runtime.prop, setProp and callProp.",
96
+ `Generated by swf2es types${values.air ? " --air" : ""}.`,
97
+ ],
98
+ imports: [
99
+ 'import type { As3Classes } from "@swf2es/player/as3-types";',
100
+ 'import type { avm2 } from "@swf2es/runtime";',
101
+ ],
102
+ ref: "avm2.Ref",
103
+ value: "avm2.Value",
104
+ });
105
+
106
+ const out = values.out;
107
+ if (out === undefined) {
108
+ process.stdout.write(text);
109
+ return;
110
+ }
111
+
112
+ await writing(out, () => writeFile(out, text));
113
+ },
114
+ };
package/src/index.ts CHANGED
@@ -1,4 +1,8 @@
1
- /** The ahead-of-time compiler and avmshell's way of running ABCs as a library, for a host that does without the command. */
1
+ /**
2
+ * The ahead-of-time compiler, avmshell's way of running ABCs and the
3
+ * declarations of ABCs' classes as a library, for a host that does without
4
+ * the command.
5
+ */
2
6
  export {
3
7
  type AbcInput,
4
8
  type ActionsModule,
@@ -13,6 +17,7 @@ export {
13
17
  readInput,
14
18
  sha256,
15
19
  } from "./aot.js";
20
+ export { as3Declarations, type DeclarationsOptions, type DeclaredLibrary } from "./as3-types.js";
16
21
  export {
17
22
  evaluateModule,
18
23
  runShell,