@swf2es/format 0.1.31 → 0.1.32
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/dist/api-versions.d.ts +16 -3
- package/dist/api-versions.d.ts.map +1 -1
- package/dist/api-versions.js +61 -4
- package/dist/api-versions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api-versions.ts +67 -4
- package/src/index.ts +7 -1
package/dist/api-versions.d.ts
CHANGED
|
@@ -4,9 +4,22 @@ export declare const API_VERSION = 50;
|
|
|
4
4
|
export declare const AIR_API_VERSION = 51;
|
|
5
5
|
/**
|
|
6
6
|
* `version` if ABCs can run at it, a version of either series, as
|
|
7
|
-
* avmshell's -api names them (
|
|
8
|
-
*
|
|
9
|
-
* never take two different
|
|
7
|
+
* avmshell's -api names them (0, VM_ALLVERSIONS, which a Flash Player root
|
|
8
|
+
* of SWF 9 runs at, up to AIR_API_VERSION); else a RangeError, so that the
|
|
9
|
+
* compiler, which keeps a byte, and the runtime never take two different
|
|
10
|
+
* versions for one.
|
|
10
11
|
*/
|
|
11
12
|
export declare function checkApiVersion(version: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether an API version is of AIR's series: from FP_10_2 (10) up the odd
|
|
15
|
+
* ones; below, all but FP_10_0 (2), FP_10_0_32 (5) and FP_10_1 (7), as
|
|
16
|
+
* api-versions.h interleaves them. VM_ALLVERSIONS (0), in both, counts as
|
|
17
|
+
* Flash Player's, which is the series a root that runs at it has.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isAirApiVersion(version: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The API version a root SWF of `swfVersion` runs at, and everything it
|
|
22
|
+
* loads with it, in Flash Player's series or, with `air`, AIR's.
|
|
23
|
+
*/
|
|
24
|
+
export declare function apiVersionOf(swfVersion: number, air?: boolean): number;
|
|
12
25
|
//# sourceMappingURL=api-versions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-versions.d.ts","sourceRoot":"","sources":["../src/api-versions.ts"],"names":[],"mappings":"AAKA,+FAA+F;AAC/F,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,8DAA8D;AAC9D,eAAO,MAAM,eAAe,KAAK,CAAC;AAKlC;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"api-versions.d.ts","sourceRoot":"","sources":["../src/api-versions.ts"],"names":[],"mappings":"AAKA,+FAA+F;AAC/F,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,8DAA8D;AAC9D,eAAO,MAAM,eAAe,KAAK,CAAC;AAKlC;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAMxD;AAqCD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,UAAQ,GAAG,MAAM,CAOpE"}
|
package/dist/api-versions.js
CHANGED
|
@@ -10,14 +10,71 @@ export const AIR_API_VERSION = 51;
|
|
|
10
10
|
const API_INTERNAL = 52;
|
|
11
11
|
/**
|
|
12
12
|
* `version` if ABCs can run at it, a version of either series, as
|
|
13
|
-
* avmshell's -api names them (
|
|
14
|
-
*
|
|
15
|
-
* never take two different
|
|
13
|
+
* avmshell's -api names them (0, VM_ALLVERSIONS, which a Flash Player root
|
|
14
|
+
* of SWF 9 runs at, up to AIR_API_VERSION); else a RangeError, so that the
|
|
15
|
+
* compiler, which keeps a byte, and the runtime never take two different
|
|
16
|
+
* versions for one.
|
|
16
17
|
*/
|
|
17
18
|
export function checkApiVersion(version) {
|
|
18
|
-
if (!Number.isInteger(version) || version <
|
|
19
|
+
if (!Number.isInteger(version) || version < 0 || version >= API_INTERNAL) {
|
|
19
20
|
throw new RangeError(`swf2es: no ABC runs at API version ${version}`);
|
|
20
21
|
}
|
|
21
22
|
return version;
|
|
22
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether an API version is of AIR's series: from FP_10_2 (10) up the odd
|
|
26
|
+
* ones; below, all but FP_10_0 (2), FP_10_0_32 (5) and FP_10_1 (7), as
|
|
27
|
+
* api-versions.h interleaves them. VM_ALLVERSIONS (0), in both, counts as
|
|
28
|
+
* Flash Player's, which is the series a root that runs at it has.
|
|
29
|
+
*/
|
|
30
|
+
export function isAirApiVersion(version) {
|
|
31
|
+
if (version >= 10) {
|
|
32
|
+
return (version & 1) === 1;
|
|
33
|
+
}
|
|
34
|
+
return version !== 0 && version !== 2 && version !== 5 && version !== 7;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The API version of a root SWF of each version, by series: Flash
|
|
38
|
+
* Player's by api-versions.h's names, AIR's as adl (AIR 51.5) runs such a
|
|
39
|
+
* root, by which marked names it sees, for SWF 9 to 26; past 26 no name is
|
|
40
|
+
* marked later to tell, and the rows go on as before. A row per SWF
|
|
41
|
+
* version, from 9 up; a version below the first row runs at the first
|
|
42
|
+
* row's, one past the last at the series' latest, so measuring a later
|
|
43
|
+
* player extends the table by rows.
|
|
44
|
+
*/
|
|
45
|
+
const BY_SWF_VERSION = [
|
|
46
|
+
[9, 0, 1], // VM_ALLVERSIONS, AIR_1_0
|
|
47
|
+
[10, 7, 9], // FP_10_1, AIR_2_5 (Ruffle has AIR_2_0; adl shows AIR 2.5's names)
|
|
48
|
+
[11, 10, 11], // FP_10_2, AIR_2_6
|
|
49
|
+
[12, 12, 13], // SWF_12, AIR_2_7
|
|
50
|
+
[13, 14, 15],
|
|
51
|
+
[14, 16, 17],
|
|
52
|
+
[15, 18, 19],
|
|
53
|
+
[16, 20, 21],
|
|
54
|
+
[17, 22, 23],
|
|
55
|
+
[18, 24, 25],
|
|
56
|
+
[19, 26, 27],
|
|
57
|
+
[20, 28, 29],
|
|
58
|
+
[21, 30, 31],
|
|
59
|
+
[22, 32, 33],
|
|
60
|
+
[23, 34, 35],
|
|
61
|
+
[24, 36, 37],
|
|
62
|
+
[25, 38, 39],
|
|
63
|
+
[26, 40, 41],
|
|
64
|
+
[27, 42, 43],
|
|
65
|
+
[28, 44, 45],
|
|
66
|
+
[29, 46, 47],
|
|
67
|
+
[30, 48, 49],
|
|
68
|
+
[31, 50, 51], // SWF_31, AIR_20_0
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* The API version a root SWF of `swfVersion` runs at, and everything it
|
|
72
|
+
* loads with it, in Flash Player's series or, with `air`, AIR's.
|
|
73
|
+
*/
|
|
74
|
+
export function apiVersionOf(swfVersion, air = false) {
|
|
75
|
+
const first = BY_SWF_VERSION[0][0];
|
|
76
|
+
const row = BY_SWF_VERSION[Math.max(Math.trunc(swfVersion), first) - first] ??
|
|
77
|
+
BY_SWF_VERSION[BY_SWF_VERSION.length - 1];
|
|
78
|
+
return air ? row[2] : row[1];
|
|
79
|
+
}
|
|
23
80
|
//# sourceMappingURL=api-versions.js.map
|
package/dist/api-versions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-versions.js","sourceRoot":"","sources":["../src/api-versions.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,kEAAkE;AAClE,uDAAuD;AAEvD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,8DAA8D;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,6EAA6E;AAC7E,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"api-versions.js","sourceRoot":"","sources":["../src/api-versions.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,kEAAkE;AAClE,uDAAuD;AAEvD,+FA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
@@ -12,7 +12,7 @@ export { abcReferences } from "./abc-names.js";
|
|
|
12
12
|
export { type Class as AbcClass, type Meta as AbcMeta, type Method as AbcMethod, type Param as AbcParam, readSurface as readAbcSurface, type Script as AbcScript, type Surface as AbcSurface, type Trait as AbcTrait, type Value as AbcValue, } from "./abc-surface.js";
|
|
13
13
|
export { type ActionBlock, type ActionList, type ActionOwner, ButtonCondition, ClipEvent, readActions, } from "./actions.js";
|
|
14
14
|
export { type AirDescriptor, readAirDescriptor } from "./air-descriptor.js";
|
|
15
|
-
export { AIR_API_VERSION, API_VERSION, checkApiVersion } from "./api-versions.js";
|
|
15
|
+
export { AIR_API_VERSION, API_VERSION, apiVersionOf, checkApiVersion, isAirApiVersion, } from "./api-versions.js";
|
|
16
16
|
export { type Bitmap, isBitmapTag, readBitmap } from "./bitmap.js";
|
|
17
17
|
export { BUTTON_DOWN, BUTTON_HIT_TEST, BUTTON_OVER, BUTTON_UP, type Button, type ButtonRecord, readButton, } from "./button.js";
|
|
18
18
|
export { CompressedDataError, CompressedDataTooLargeError, decompressSwf, decompressSwfPrefix, deflateCompress, LZMA_HEADER, lzmaByteArrayCompress, lzmaByteArrayUncompress, type ZlibLevel, zlibCompress, zlibUncompress, } from "./compression.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,KAAK,KAAK,IAAI,QAAQ,EACtB,KAAK,IAAI,IAAI,OAAO,EACpB,KAAK,MAAM,IAAI,SAAS,EACxB,KAAK,KAAK,IAAI,QAAQ,EACtB,WAAW,IAAI,cAAc,EAC7B,KAAK,MAAM,IAAI,SAAS,EACxB,KAAK,OAAO,IAAI,UAAU,EAC1B,KAAK,KAAK,IAAI,QAAQ,EACtB,KAAK,KAAK,IA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BAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,KAAK,EACL,KAAK,IAAI,EACT,OAAO,EACP,aAAa,EACb,QAAQ,EACR,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,SAAS,EACT,KAAK,GAAG,GACT,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { abcReferences } from "./abc-names.js";
|
|
|
12
12
|
export { readSurface as readAbcSurface, } from "./abc-surface.js";
|
|
13
13
|
export { ButtonCondition, ClipEvent, readActions, } from "./actions.js";
|
|
14
14
|
export { readAirDescriptor } from "./air-descriptor.js";
|
|
15
|
-
export { AIR_API_VERSION, API_VERSION, checkApiVersion } from "./api-versions.js";
|
|
15
|
+
export { AIR_API_VERSION, API_VERSION, apiVersionOf, checkApiVersion, isAirApiVersion, } from "./api-versions.js";
|
|
16
16
|
export { isBitmapTag, readBitmap } from "./bitmap.js";
|
|
17
17
|
export { BUTTON_DOWN, BUTTON_HIT_TEST, BUTTON_OVER, BUTTON_UP, readButton, } from "./button.js";
|
|
18
18
|
export { CompressedDataError, CompressedDataTooLargeError, decompressSwf, decompressSwfPrefix, deflateCompress, LZMA_HEADER, lzmaByteArrayCompress, lzmaByteArrayUncompress, zlibCompress, zlibUncompress, } from "./compression.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAKL,WAAW,IAAI,cAAc,GAK9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIL,eAAe,EACf,SAAS,EACT,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAsB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAKL,WAAW,IAAI,cAAc,GAK9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIL,eAAe,EACf,SAAS,EACT,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAsB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAe,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,SAAS,EAGT,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,uBAAuB,EAEvB,YAAY,EACZ,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,cAAc,EACd,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACT,UAAU,EACV,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,eAAe,GAEhB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoB,WAAW,EAAkB,MAAM,cAAc,CAAC;AAC7E,OAAO,EAKL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EAET,QAAQ,EAMR,KAAK,EAOL,YAAY,EACZ,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAKL,QAAQ,EAIR,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,SAAS,GAGV,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,eAAe,EACf,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,GAOf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,KAAK,EAEL,OAAO,EACP,aAAa,EACb,QAAQ,EAIR,SAAS,GAEV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAIL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,cAAc,GAGf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAiB,QAAQ,EAAE,MAAM,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swf2es/format",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "SWF, ABC and AVM1 action parsers shared by the compiler and the player",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"swf",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"LICENSE.third-party"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@swf2es/native": "0.1.
|
|
34
|
+
"@swf2es/native": "0.1.32"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/api-versions.ts
CHANGED
|
@@ -14,14 +14,77 @@ const API_INTERNAL = 52;
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* `version` if ABCs can run at it, a version of either series, as
|
|
17
|
-
* avmshell's -api names them (
|
|
18
|
-
*
|
|
19
|
-
* never take two different
|
|
17
|
+
* avmshell's -api names them (0, VM_ALLVERSIONS, which a Flash Player root
|
|
18
|
+
* of SWF 9 runs at, up to AIR_API_VERSION); else a RangeError, so that the
|
|
19
|
+
* compiler, which keeps a byte, and the runtime never take two different
|
|
20
|
+
* versions for one.
|
|
20
21
|
*/
|
|
21
22
|
export function checkApiVersion(version: number): number {
|
|
22
|
-
if (!Number.isInteger(version) || version <
|
|
23
|
+
if (!Number.isInteger(version) || version < 0 || version >= API_INTERNAL) {
|
|
23
24
|
throw new RangeError(`swf2es: no ABC runs at API version ${version}`);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
return version;
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Whether an API version is of AIR's series: from FP_10_2 (10) up the odd
|
|
32
|
+
* ones; below, all but FP_10_0 (2), FP_10_0_32 (5) and FP_10_1 (7), as
|
|
33
|
+
* api-versions.h interleaves them. VM_ALLVERSIONS (0), in both, counts as
|
|
34
|
+
* Flash Player's, which is the series a root that runs at it has.
|
|
35
|
+
*/
|
|
36
|
+
export function isAirApiVersion(version: number): boolean {
|
|
37
|
+
if (version >= 10) {
|
|
38
|
+
return (version & 1) === 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return version !== 0 && version !== 2 && version !== 5 && version !== 7;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The API version of a root SWF of each version, by series: Flash
|
|
46
|
+
* Player's by api-versions.h's names, AIR's as adl (AIR 51.5) runs such a
|
|
47
|
+
* root, by which marked names it sees, for SWF 9 to 26; past 26 no name is
|
|
48
|
+
* marked later to tell, and the rows go on as before. A row per SWF
|
|
49
|
+
* version, from 9 up; a version below the first row runs at the first
|
|
50
|
+
* row's, one past the last at the series' latest, so measuring a later
|
|
51
|
+
* player extends the table by rows.
|
|
52
|
+
*/
|
|
53
|
+
const BY_SWF_VERSION: readonly (readonly [swf: number, flashPlayer: number, air: number])[] = [
|
|
54
|
+
[9, 0, 1], // VM_ALLVERSIONS, AIR_1_0
|
|
55
|
+
[10, 7, 9], // FP_10_1, AIR_2_5 (Ruffle has AIR_2_0; adl shows AIR 2.5's names)
|
|
56
|
+
[11, 10, 11], // FP_10_2, AIR_2_6
|
|
57
|
+
[12, 12, 13], // SWF_12, AIR_2_7
|
|
58
|
+
[13, 14, 15],
|
|
59
|
+
[14, 16, 17],
|
|
60
|
+
[15, 18, 19],
|
|
61
|
+
[16, 20, 21],
|
|
62
|
+
[17, 22, 23],
|
|
63
|
+
[18, 24, 25],
|
|
64
|
+
[19, 26, 27],
|
|
65
|
+
[20, 28, 29],
|
|
66
|
+
[21, 30, 31],
|
|
67
|
+
[22, 32, 33],
|
|
68
|
+
[23, 34, 35],
|
|
69
|
+
[24, 36, 37],
|
|
70
|
+
[25, 38, 39],
|
|
71
|
+
[26, 40, 41],
|
|
72
|
+
[27, 42, 43],
|
|
73
|
+
[28, 44, 45],
|
|
74
|
+
[29, 46, 47],
|
|
75
|
+
[30, 48, 49],
|
|
76
|
+
[31, 50, 51], // SWF_31, AIR_20_0
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The API version a root SWF of `swfVersion` runs at, and everything it
|
|
81
|
+
* loads with it, in Flash Player's series or, with `air`, AIR's.
|
|
82
|
+
*/
|
|
83
|
+
export function apiVersionOf(swfVersion: number, air = false): number {
|
|
84
|
+
const first = BY_SWF_VERSION[0][0];
|
|
85
|
+
const row =
|
|
86
|
+
BY_SWF_VERSION[Math.max(Math.trunc(swfVersion), first) - first] ??
|
|
87
|
+
BY_SWF_VERSION[BY_SWF_VERSION.length - 1];
|
|
88
|
+
|
|
89
|
+
return air ? row[2] : row[1];
|
|
90
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -30,7 +30,13 @@ export {
|
|
|
30
30
|
readActions,
|
|
31
31
|
} from "./actions.js";
|
|
32
32
|
export { type AirDescriptor, readAirDescriptor } from "./air-descriptor.js";
|
|
33
|
-
export {
|
|
33
|
+
export {
|
|
34
|
+
AIR_API_VERSION,
|
|
35
|
+
API_VERSION,
|
|
36
|
+
apiVersionOf,
|
|
37
|
+
checkApiVersion,
|
|
38
|
+
isAirApiVersion,
|
|
39
|
+
} from "./api-versions.js";
|
|
34
40
|
export { type Bitmap, isBitmapTag, readBitmap } from "./bitmap.js";
|
|
35
41
|
export {
|
|
36
42
|
BUTTON_DOWN,
|