@4bitlabs/sci0 5.0.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +25 -26
- package/dist/index.js +11 -46
- package/dist/models/cel.d.ts +7 -4
- package/dist/models/cel.d.ts.map +1 -1
- package/dist/models/cursor.d.ts +6 -3
- package/dist/models/cursor.d.ts.map +1 -1
- package/dist/models/draw-codes.d.ts +4 -5
- package/dist/models/draw-codes.d.ts.map +1 -1
- package/dist/models/draw-command.d.ts +5 -2
- package/dist/models/draw-command.d.ts.map +1 -1
- package/dist/models/draw-commands.d.ts +16 -46
- package/dist/models/draw-commands.d.ts.map +1 -1
- package/dist/models/draw-mode.d.ts +21 -18
- package/dist/models/draw-mode.d.ts.map +1 -1
- package/dist/models/draw-mode.js +20 -25
- package/dist/models/draw-mode.js.map +1 -1
- package/dist/models/font-face.d.ts +7 -4
- package/dist/models/font-face.d.ts.map +1 -1
- package/dist/models/pattern-code.d.ts +4 -5
- package/dist/models/pattern-code.d.ts.map +1 -1
- package/dist/models/pic.d.ts +6 -3
- package/dist/models/pic.d.ts.map +1 -1
- package/dist/models/resource-header.d.ts +12 -9
- package/dist/models/resource-header.d.ts.map +1 -1
- package/dist/models/resource-id.d.ts +10 -5
- package/dist/models/resource-id.d.ts.map +1 -1
- package/dist/models/resource-id.js +28 -36
- package/dist/models/resource-id.js.map +1 -1
- package/dist/models/resource-map.d.ts +7 -4
- package/dist/models/resource-map.d.ts.map +1 -1
- package/dist/models/resource-type.d.ts +5 -2
- package/dist/models/resource-type.d.ts.map +1 -1
- package/dist/models/resource-types.d.ts +15 -10
- package/dist/models/resource-types.d.ts.map +1 -1
- package/dist/models/resource-types.js +17 -13
- package/dist/models/resource-types.js.map +1 -1
- package/dist/models/view.d.ts +16 -13
- package/dist/models/view.d.ts.map +1 -1
- package/dist/parsers/compression.d.ts +4 -1
- package/dist/parsers/compression.d.ts.map +1 -1
- package/dist/parsers/compression.js +36 -54
- package/dist/parsers/compression.js.map +1 -1
- package/dist/parsers/mapping.d.ts +5 -3
- package/dist/parsers/mapping.d.ts.map +1 -1
- package/dist/parsers/mapping.js +18 -23
- package/dist/parsers/mapping.js.map +1 -1
- package/dist/parsers/parse-cel.js +26 -29
- package/dist/parsers/parse-cel.js.map +1 -1
- package/dist/parsers/parse-cursor-options.d.ts +10 -7
- package/dist/parsers/parse-cursor-options.d.ts.map +1 -1
- package/dist/parsers/parse-cursor.d.ts +6 -3
- package/dist/parsers/parse-cursor.d.ts.map +1 -1
- package/dist/parsers/parse-cursor.js +34 -36
- package/dist/parsers/parse-cursor.js.map +1 -1
- package/dist/parsers/parse-font-options.d.ts +6 -3
- package/dist/parsers/parse-font-options.d.ts.map +1 -1
- package/dist/parsers/parse-font.d.ts +6 -3
- package/dist/parsers/parse-font.d.ts.map +1 -1
- package/dist/parsers/parse-font.js +27 -30
- package/dist/parsers/parse-font.js.map +1 -1
- package/dist/parsers/parse-pic.d.ts +8 -5
- package/dist/parsers/parse-pic.d.ts.map +1 -1
- package/dist/parsers/parse-pic.js +22 -28
- package/dist/parsers/parse-pic.js.map +1 -1
- package/dist/parsers/parse-view.d.ts +5 -2
- package/dist/parsers/parse-view.d.ts.map +1 -1
- package/dist/parsers/parse-view.js +45 -41
- package/dist/parsers/parse-view.js.map +1 -1
- package/dist/parsers/pic/handlers.js +272 -208
- package/dist/parsers/pic/handlers.js.map +1 -1
- package/dist/parsers/pic/op-codes.js +37 -45
- package/dist/parsers/pic/op-codes.js.map +1 -1
- package/dist/parsers/pic/pic-state.js +16 -8
- package/dist/parsers/pic/pic-state.js.map +1 -1
- package/dist/parsers/pic/points.js +19 -45
- package/dist/parsers/pic/points.js.map +1 -1
- package/dist/parsers/resource-header.d.ts +6 -3
- package/dist/parsers/resource-header.d.ts.map +1 -1
- package/dist/parsers/resource-header.js +15 -20
- package/dist/parsers/resource-header.js.map +1 -1
- package/dist/utils/exhaustive.js +5 -4
- package/dist/utils/exhaustive.js.map +1 -1
- package/dist/utils/repeat.js +5 -7
- package/dist/utils/repeat.js.map +1 -1
- package/package.json +17 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/models/cel.js +0 -3
- package/dist/models/cel.js.map +0 -1
- package/dist/models/cursor.js +0 -3
- package/dist/models/cursor.js.map +0 -1
- package/dist/models/draw-codes.js +0 -3
- package/dist/models/draw-codes.js.map +0 -1
- package/dist/models/draw-command.js +0 -3
- package/dist/models/draw-command.js.map +0 -1
- package/dist/models/draw-commands.js +0 -3
- package/dist/models/draw-commands.js.map +0 -1
- package/dist/models/font-face.js +0 -3
- package/dist/models/font-face.js.map +0 -1
- package/dist/models/pattern-code.js +0 -3
- package/dist/models/pattern-code.js.map +0 -1
- package/dist/models/pic.js +0 -3
- package/dist/models/pic.js.map +0 -1
- package/dist/models/resource-header.js +0 -3
- package/dist/models/resource-header.js.map +0 -1
- package/dist/models/resource-map.js +0 -3
- package/dist/models/resource-map.js.map +0 -1
- package/dist/models/resource-type.js +0 -3
- package/dist/models/resource-type.js.map +0 -1
- package/dist/models/view.js +0 -3
- package/dist/models/view.js.map +0 -1
- package/dist/parsers/parse-cel.d.ts +0 -3
- package/dist/parsers/parse-cel.d.ts.map +0 -1
- package/dist/parsers/parse-cursor-options.js +0 -3
- package/dist/parsers/parse-cursor-options.js.map +0 -1
- package/dist/parsers/parse-font-options.js +0 -3
- package/dist/parsers/parse-font-options.js.map +0 -1
- package/dist/parsers/pic/handlers.d.ts +0 -8
- package/dist/parsers/pic/handlers.d.ts.map +0 -1
- package/dist/parsers/pic/op-codes.d.ts +0 -32
- package/dist/parsers/pic/op-codes.d.ts.map +0 -1
- package/dist/parsers/pic/pic-state.d.ts +0 -10
- package/dist/parsers/pic/pic-state.d.ts.map +0 -1
- package/dist/parsers/pic/points.d.ts +0 -6
- package/dist/parsers/pic/points.d.ts.map +0 -1
- package/dist/utils/exhaustive.d.ts +0 -2
- package/dist/utils/exhaustive.d.ts.map +0 -1
- package/dist/utils/repeat.d.ts +0 -2
- package/dist/utils/repeat.d.ts.map +0 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CURSOR_TYPE, FONT_TYPE, MEMORY_TYPE, PATCH_TYPE, PIC_TYPE, SCRIPT_TYPE, SOUND_TYPE, TEXT_TYPE, VIEW_TYPE, VOCAB_TYPE } from "./resource-types.js";
|
|
2
|
+
//#region src/models/resource-type.d.ts
|
|
3
|
+
type ResourceType = typeof VIEW_TYPE | typeof PIC_TYPE | typeof SCRIPT_TYPE | typeof TEXT_TYPE | typeof SOUND_TYPE | typeof MEMORY_TYPE | typeof VOCAB_TYPE | typeof FONT_TYPE | typeof CURSOR_TYPE | typeof PATCH_TYPE;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ResourceType };
|
|
3
6
|
//# sourceMappingURL=resource-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-type.d.ts","
|
|
1
|
+
{"version":3,"file":"resource-type.d.ts","names":[],"sources":["../../src/models/resource-type.ts"],"mappings":";;KAaY,sBACD,mBACA,kBACA,qBACA,mBACA,oBACA,qBACA,oBACA,mBACA,qBACA"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
declare namespace resource_types_d_exports {
|
|
2
|
+
export { CURSOR_TYPE, FONT_TYPE, MEMORY_TYPE, PATCH_TYPE, PIC_TYPE, SCRIPT_TYPE, SOUND_TYPE, TEXT_TYPE, VIEW_TYPE, VOCAB_TYPE };
|
|
3
|
+
}
|
|
4
|
+
declare const VIEW_TYPE: 0;
|
|
5
|
+
declare const PIC_TYPE: 1;
|
|
6
|
+
declare const SCRIPT_TYPE: 2;
|
|
7
|
+
declare const TEXT_TYPE: 3;
|
|
8
|
+
declare const SOUND_TYPE: 4;
|
|
9
|
+
declare const MEMORY_TYPE: 5;
|
|
10
|
+
declare const VOCAB_TYPE: 6;
|
|
11
|
+
declare const FONT_TYPE: 7;
|
|
12
|
+
declare const CURSOR_TYPE: 8;
|
|
13
|
+
declare const PATCH_TYPE: 9;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { CURSOR_TYPE, FONT_TYPE, MEMORY_TYPE, PATCH_TYPE, PIC_TYPE, SCRIPT_TYPE, SOUND_TYPE, TEXT_TYPE, VIEW_TYPE, VOCAB_TYPE, resource_types_d_exports };
|
|
11
16
|
//# sourceMappingURL=resource-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-types.d.ts","
|
|
1
|
+
{"version":3,"file":"resource-types.d.ts","names":[],"sources":["../../src/models/resource-types.ts"],"mappings":";;;cAAa;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region src/models/resource-types.ts
|
|
3
|
+
var resource_types_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
CURSOR_TYPE: () => 8,
|
|
5
|
+
FONT_TYPE: () => 7,
|
|
6
|
+
MEMORY_TYPE: () => 5,
|
|
7
|
+
PATCH_TYPE: () => 9,
|
|
8
|
+
PIC_TYPE: () => 1,
|
|
9
|
+
SCRIPT_TYPE: () => 2,
|
|
10
|
+
SOUND_TYPE: () => 4,
|
|
11
|
+
TEXT_TYPE: () => 3,
|
|
12
|
+
VIEW_TYPE: () => 0,
|
|
13
|
+
VOCAB_TYPE: () => 6
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { resource_types_exports };
|
|
17
|
+
|
|
14
18
|
//# sourceMappingURL=resource-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-types.js","
|
|
1
|
+
{"version":3,"file":"resource-types.js","names":[],"sources":["../../src/models/resource-types.ts"],"sourcesContent":["export const VIEW_TYPE = 0 as const;\nexport const PIC_TYPE = 1 as const;\nexport const SCRIPT_TYPE = 2 as const;\nexport const TEXT_TYPE = 3 as const;\nexport const SOUND_TYPE = 4 as const;\nexport const MEMORY_TYPE = 5 as const;\nexport const VOCAB_TYPE = 6 as const;\nexport const FONT_TYPE = 7 as const;\nexport const CURSOR_TYPE = 8 as const;\nexport const PATCH_TYPE = 9 as const;\n"],"mappings":""}
|
package/dist/models/view.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { Cel } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { Cel } from "./cel.js";
|
|
2
|
+
//#region src/models/view.d.ts
|
|
3
|
+
interface Loop {
|
|
4
|
+
readonly frames: Cel[];
|
|
5
|
+
readonly isMirrored: boolean;
|
|
6
|
+
readonly bounds: {
|
|
7
|
+
readonly left: number;
|
|
8
|
+
readonly top: number;
|
|
9
|
+
readonly right: number;
|
|
10
|
+
readonly bottom: number;
|
|
11
|
+
readonly width: number;
|
|
12
|
+
readonly height: number;
|
|
13
|
+
};
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
type View = Loop[];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Loop, View };
|
|
15
18
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","
|
|
1
|
+
{"version":3,"file":"view.d.ts","names":[],"sources":["../../src/models/view.ts"],"mappings":";;UAEiB;WACN,QAAQ;WACR;WACA;aACE;aACA;aACA;aACA;aACA;aACA;;;KAID,OAAO"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/parsers/compression.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Decompress resource payload bytes with a specific algorithm.
|
|
3
4
|
*
|
|
@@ -22,5 +23,7 @@
|
|
|
22
23
|
* @param bytes The compressed bytes to decompress.
|
|
23
24
|
* @returns Decompressed payload data.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
declare const decompress: (engine: "sci0" | "sci01", algorithm: number, bytes: Uint8Array) => Uint8Array;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { decompress };
|
|
26
29
|
//# sourceMappingURL=compression.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compression.d.ts","
|
|
1
|
+
{"version":3,"file":"compression.d.ts","names":[],"sources":["../../src/parsers/compression.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;cAmDa,aACX,0BACA,mBACA,OAAO,eACN"}
|
|
@@ -1,61 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { exhaustive } from "../utils/exhaustive.js";
|
|
2
|
+
import { unpack } from "@4bitlabs/codecs/huffman";
|
|
3
|
+
import { unpack as unpack$1 } from "@4bitlabs/codecs/lzw";
|
|
4
|
+
import { unpack as unpack$2 } from "@4bitlabs/codecs/comp3";
|
|
5
|
+
//#region src/parsers/compression.ts
|
|
6
|
+
const sci0Supported = (it) => typeof it === "number" && Number.isInteger(it) && [
|
|
7
|
+
0,
|
|
8
|
+
1,
|
|
9
|
+
2
|
|
10
|
+
].includes(it);
|
|
11
|
+
const sci01Supported = (it) => typeof it === "number" && Number.isInteger(it) && [
|
|
12
|
+
0,
|
|
13
|
+
1,
|
|
14
|
+
2
|
|
15
|
+
].includes(it);
|
|
10
16
|
const SCI0 = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
0: (bytes) => bytes,
|
|
18
|
+
1: (bytes) => unpack$1(bytes, {
|
|
19
|
+
literalWidth: 8,
|
|
20
|
+
order: "lsb"
|
|
21
|
+
}),
|
|
22
|
+
2: (bytes) => unpack(bytes)
|
|
14
23
|
};
|
|
15
24
|
const SCI01 = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
0: (bytes) => bytes,
|
|
26
|
+
1: (bytes) => unpack(bytes),
|
|
27
|
+
2: (bytes) => unpack$2(bytes)
|
|
19
28
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Decompress resource payload bytes with a specific algorithm.
|
|
22
|
-
*
|
|
23
|
-
* #### SCI0 algorithm
|
|
24
|
-
* | | |
|
|
25
|
-
* | --- | --- |
|
|
26
|
-
* | 0 | _no compression_ |
|
|
27
|
-
* | 1 | LZW (8-bit/lsb) |
|
|
28
|
-
* | 2 | Huffman |
|
|
29
|
-
*
|
|
30
|
-
* #### SCI01 algorithm
|
|
31
|
-
* | | |
|
|
32
|
-
* | --- | --- |
|
|
33
|
-
* | 0 | _no compression_ |
|
|
34
|
-
* | 1 | Huffman |
|
|
35
|
-
* | 2 | COMP3 |
|
|
36
|
-
*
|
|
37
|
-
* @see {@link ResourceHeader.compression}
|
|
38
|
-
*
|
|
39
|
-
* @param engine Select between engine type: `sci0` or `sci01`.
|
|
40
|
-
* @param algorithm The decompression method.
|
|
41
|
-
* @param bytes The compressed bytes to decompress.
|
|
42
|
-
* @returns Decompressed payload data.
|
|
43
|
-
*/
|
|
44
29
|
const decompress = (engine, algorithm, bytes) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return SCI01[algorithm](bytes);
|
|
55
|
-
}
|
|
56
|
-
default:
|
|
57
|
-
(0, exhaustive_1.exhaustive)('unsupported engine/compression', engine);
|
|
58
|
-
}
|
|
30
|
+
switch (engine) {
|
|
31
|
+
case "sci0":
|
|
32
|
+
if (!sci0Supported(algorithm)) throw new Error(`unsupported compression algorithm: ${algorithm.toString(10)}`);
|
|
33
|
+
return SCI0[algorithm](bytes);
|
|
34
|
+
case "sci01":
|
|
35
|
+
if (!sci01Supported(algorithm)) throw new Error(`unsupported compression algorithm: ${algorithm.toString(10)}`);
|
|
36
|
+
return SCI01[algorithm](bytes);
|
|
37
|
+
default: exhaustive("unsupported engine/compression", engine);
|
|
38
|
+
}
|
|
59
39
|
};
|
|
60
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
export { decompress };
|
|
42
|
+
|
|
61
43
|
//# sourceMappingURL=compression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compression.js","
|
|
1
|
+
{"version":3,"file":"compression.js","names":["unpackLzw","unpackHuffman","unpackComp3"],"sources":["../../src/parsers/compression.ts"],"sourcesContent":["import { unpack as unpackHuffman } from '@4bitlabs/codecs/huffman';\nimport { unpack as unpackLzw } from '@4bitlabs/codecs/lzw';\nimport { unpack as unpackComp3 } from '@4bitlabs/codecs/comp3';\nimport { exhaustive } from '../utils/exhaustive.js';\n\ntype Sci0Algorithms = 0 | 1 | 2;\ntype Sci01Algorithms = 0 | 1 | 2;\ntype DecompressFn = (bytes: Uint8Array) => Uint8Array;\n\nconst sci0Supported = (it: unknown): it is Sci0Algorithms =>\n typeof it === 'number' && Number.isInteger(it) && [0, 1, 2].includes(it);\n\nconst sci01Supported = (it: unknown): it is Sci01Algorithms =>\n typeof it === 'number' && Number.isInteger(it) && [0, 1, 2].includes(it);\n\nconst SCI0: Record<Sci0Algorithms, DecompressFn> = {\n 0: (bytes) => bytes,\n 1: (bytes) => unpackLzw(bytes, { literalWidth: 8, order: 'lsb' }),\n 2: (bytes) => unpackHuffman(bytes),\n};\n\nconst SCI01: Record<Sci01Algorithms, DecompressFn> = {\n 0: (bytes) => bytes,\n 1: (bytes) => unpackHuffman(bytes),\n 2: (bytes) => unpackComp3(bytes),\n};\n\n/**\n * Decompress resource payload bytes with a specific algorithm.\n *\n * #### SCI0 algorithm\n * | | |\n * | --- | --- |\n * | 0 | _no compression_ |\n * | 1 | LZW (8-bit/lsb) |\n * | 2 | Huffman |\n *\n * #### SCI01 algorithm\n * | | |\n * | --- | --- |\n * | 0 | _no compression_ |\n * | 1 | Huffman |\n * | 2 | COMP3 |\n *\n * @see {@link ResourceHeader.compression}\n *\n * @param engine Select between engine type: `sci0` or `sci01`.\n * @param algorithm The decompression method.\n * @param bytes The compressed bytes to decompress.\n * @returns Decompressed payload data.\n */\nexport const decompress = (\n engine: 'sci0' | 'sci01',\n algorithm: number,\n bytes: Uint8Array,\n): Uint8Array => {\n switch (engine) {\n case 'sci0': {\n if (!sci0Supported(algorithm))\n throw new Error(\n `unsupported compression algorithm: ${algorithm.toString(10)}`,\n );\n return SCI0[algorithm](bytes);\n }\n case 'sci01': {\n if (!sci01Supported(algorithm))\n throw new Error(\n `unsupported compression algorithm: ${algorithm.toString(10)}`,\n );\n return SCI01[algorithm](bytes);\n }\n default:\n exhaustive('unsupported engine/compression', engine);\n }\n};\n"],"mappings":";;;;;AASA,MAAM,iBAAiB,OACrB,OAAO,OAAO,YAAY,OAAO,UAAU,EAAE,KAAK;CAAC;CAAG;CAAG;AAAC,CAAC,CAAC,SAAS,EAAE;AAEzE,MAAM,kBAAkB,OACtB,OAAO,OAAO,YAAY,OAAO,UAAU,EAAE,KAAK;CAAC;CAAG;CAAG;AAAC,CAAC,CAAC,SAAS,EAAE;AAEzE,MAAM,OAA6C;CACjD,IAAI,UAAU;CACd,IAAI,UAAUA,SAAU,OAAO;EAAE,cAAc;EAAG,OAAO;CAAM,CAAC;CAChE,IAAI,UAAUC,OAAc,KAAK;AACnC;AAEA,MAAM,QAA+C;CACnD,IAAI,UAAU;CACd,IAAI,UAAUA,OAAc,KAAK;CACjC,IAAI,UAAUC,SAAY,KAAK;AACjC;AA0BA,MAAa,cACX,QACA,WACA,UACe;CACf,QAAQ,QAAR;EACE,KAAK;GACH,IAAI,CAAC,cAAc,SAAS,GAC1B,MAAM,IAAI,MACR,sCAAsC,UAAU,SAAS,EAAE,GAC7D;GACF,OAAO,KAAK,UAAU,CAAC,KAAK;EAE9B,KAAK;GACH,IAAI,CAAC,eAAe,SAAS,GAC3B,MAAM,IAAI,MACR,sCAAsC,UAAU,SAAS,EAAE,GAC7D;GACF,OAAO,MAAM,UAAU,CAAC,KAAK;EAE/B,SACE,WAAW,kCAAkC,MAAM;CACvD;AACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ResourceMap } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ResourceMap } from "../models/resource-map.js";
|
|
2
|
+
//#region src/parsers/mapping.d.ts
|
|
3
|
+
declare const parseAllMappings: (bytes: Uint8Array) => ResourceMap[];
|
|
4
|
+
//#endregion
|
|
5
|
+
export { parseAllMappings };
|
|
4
6
|
//# sourceMappingURL=mapping.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","names":[],"sources":["../../src/parsers/mapping.ts"],"mappings":";;cAuBa,mBAAoB,OAAO,eAAa"}
|
package/dist/parsers/mapping.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.consume = consume;
|
|
5
|
-
const HEAD_END_TOKEN = ~0 >>> 16;
|
|
6
|
-
const TAIL_END_TOKEN = ~0 >>> 0;
|
|
1
|
+
//#region src/parsers/mapping.ts
|
|
2
|
+
const HEAD_END_TOKEN = 65535;
|
|
3
|
+
const TAIL_END_TOKEN = -1 >>> 0;
|
|
7
4
|
function* consume(bytes) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
}
|
|
5
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6
|
+
for (let offset = 0; offset + 5 < bytes.length; offset += 6) {
|
|
7
|
+
const head = view.getUint16(offset, true);
|
|
8
|
+
const tail = view.getUint32(offset + 2, true);
|
|
9
|
+
if (HEAD_END_TOKEN === head && TAIL_END_TOKEN === tail) return;
|
|
10
|
+
yield {
|
|
11
|
+
id: head,
|
|
12
|
+
file: tail >>> 26,
|
|
13
|
+
offset: tail & 67108863
|
|
14
|
+
};
|
|
15
|
+
}
|
|
21
16
|
}
|
|
22
|
-
const parseAllMappings = (bytes) => [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const parseAllMappings = (bytes) => [...consume(bytes)];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { consume, parseAllMappings };
|
|
20
|
+
|
|
26
21
|
//# sourceMappingURL=mapping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.js","
|
|
1
|
+
{"version":3,"file":"mapping.js","names":[],"sources":["../../src/parsers/mapping.ts"],"sourcesContent":["import type { ResourceMap } from '../models/resource-map.js';\n\nconst HEAD_END_TOKEN = ~0 >>> 16;\nconst TAIL_END_TOKEN = ~0 >>> 0;\n\nexport function* consume(bytes: Uint8Array): IterableIterator<ResourceMap> {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n for (let offset = 0; offset + 5 < bytes.length; offset += 6) {\n const head = view.getUint16(offset, true);\n const tail = view.getUint32(offset + 2, true);\n\n const isEnd = HEAD_END_TOKEN === head && TAIL_END_TOKEN === tail;\n if (isEnd) return;\n\n yield {\n id: head,\n file: tail >>> 26,\n offset: tail & 0b11_1111_1111_1111_1111_1111_1111,\n };\n }\n}\n\nexport const parseAllMappings = (bytes: Uint8Array): ResourceMap[] => [\n ...consume(bytes),\n];\n"],"mappings":";AAEA,MAAM,iBAAiB;AACvB,MAAM,iBAAiB,OAAO;AAE9B,UAAiB,QAAQ,OAAkD;CACzE,MAAM,OAAO,IAAI,SAAS,MAAM,QAAQ,MAAM,YAAY,MAAM,UAAU;CAE1E,KAAK,IAAI,SAAS,GAAG,SAAS,IAAI,MAAM,QAAQ,UAAU,GAAG;EAC3D,MAAM,OAAO,KAAK,UAAU,QAAQ,IAAI;EACxC,MAAM,OAAO,KAAK,UAAU,SAAS,GAAG,IAAI;EAG5C,IADc,mBAAmB,QAAQ,mBAAmB,MACjD;EAEX,MAAM;GACJ,IAAI;GACJ,MAAM,SAAS;GACf,QAAQ,OAAO;EACjB;CACF;AACF;AAEA,MAAa,oBAAoB,UAAqC,CACpE,GAAG,QAAQ,KAAK,CAClB"}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.parseCel = void 0;
|
|
4
|
-
const image_1 = require("@4bitlabs/image");
|
|
1
|
+
import { createIndexedPixelData } from "@4bitlabs/image";
|
|
2
|
+
//#region src/parsers/parse-cel.ts
|
|
5
3
|
const parseCel = (frameView) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
dx,
|
|
28
|
-
dy,
|
|
29
|
-
};
|
|
4
|
+
const [width, height] = [frameView.getUint16(0, true), frameView.getUint16(2, true)];
|
|
5
|
+
const [dx, dy] = [frameView.getInt8(4), frameView.getInt8(5)];
|
|
6
|
+
const keyColor = frameView.getUint8(6);
|
|
7
|
+
const total = width * height;
|
|
8
|
+
const img = createIndexedPixelData(width, height);
|
|
9
|
+
let idx = 0;
|
|
10
|
+
for (let i = 0; i < total;) {
|
|
11
|
+
const data = frameView.getUint8(7 + idx);
|
|
12
|
+
idx += 1;
|
|
13
|
+
const [color, repeat] = [data & 15, data >>> 4];
|
|
14
|
+
for (let r = 0; r < repeat; r++) {
|
|
15
|
+
img.pixels[i] = color;
|
|
16
|
+
i += 1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...img,
|
|
21
|
+
keyColor,
|
|
22
|
+
dx,
|
|
23
|
+
dy
|
|
24
|
+
};
|
|
30
25
|
};
|
|
31
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
export { parseCel };
|
|
28
|
+
|
|
32
29
|
//# sourceMappingURL=parse-cel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cel.js","
|
|
1
|
+
{"version":3,"file":"parse-cel.js","names":[],"sources":["../../src/parsers/parse-cel.ts"],"sourcesContent":["import { createIndexedPixelData } from '@4bitlabs/image';\nimport type { Cel } from '../models/cel.js';\n\nexport const parseCel = (frameView: DataView): Cel => {\n const [width, height] = [\n frameView.getUint16(0, true),\n frameView.getUint16(2, true),\n ];\n const [dx, dy] = [frameView.getInt8(4), frameView.getInt8(5)];\n const keyColor = frameView.getUint8(6);\n\n const total = width * height;\n const img = createIndexedPixelData(width, height);\n\n let idx = 0;\n for (let i = 0; i < total; ) {\n const data = frameView.getUint8(7 + idx);\n idx += 1;\n const [color, repeat] = [data & 0xf, data >>> 4];\n for (let r = 0; r < repeat; r++) {\n img.pixels[i] = color;\n i += 1;\n }\n }\n\n return {\n ...img,\n keyColor,\n dx,\n dy,\n };\n};\n"],"mappings":";;AAGA,MAAa,YAAY,cAA6B;CACpD,MAAM,CAAC,OAAO,UAAU,CACtB,UAAU,UAAU,GAAG,IAAI,GAC3B,UAAU,UAAU,GAAG,IAAI,CAC7B;CACA,MAAM,CAAC,IAAI,MAAM,CAAC,UAAU,QAAQ,CAAC,GAAG,UAAU,QAAQ,CAAC,CAAC;CAC5D,MAAM,WAAW,UAAU,SAAS,CAAC;CAErC,MAAM,QAAQ,QAAQ;CACtB,MAAM,MAAM,uBAAuB,OAAO,MAAM;CAEhD,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,QAAS;EAC3B,MAAM,OAAO,UAAU,SAAS,IAAI,GAAG;EACvC,OAAO;EACP,MAAM,CAAC,OAAO,UAAU,CAAC,OAAO,IAAK,SAAS,CAAC;EAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;GAC/B,IAAI,OAAO,KAAK;GAChB,KAAK;EACP;CACF;CAEA,OAAO;EACL,GAAG;EACH;EACA;EACA;CACF;AACF"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/parsers/parse-cursor-options.d.ts
|
|
2
|
+
interface ParseCursorOptions {
|
|
3
|
+
mapping?: {
|
|
4
|
+
black: number;
|
|
5
|
+
gray: number;
|
|
6
|
+
white: number;
|
|
7
|
+
keyColor: number;
|
|
8
|
+
};
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ParseCursorOptions };
|
|
9
12
|
//# sourceMappingURL=parse-cursor-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cursor-options.d.ts","
|
|
1
|
+
{"version":3,"file":"parse-cursor-options.d.ts","names":[],"sources":["../../src/parsers/parse-cursor-options.ts"],"mappings":";UAAiB;EACf;IACE;IACA;IACA;IACA"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ParseCursorOptions } from "./parse-cursor-options.js";
|
|
2
|
+
import { Cursor } from "../models/cursor.js";
|
|
3
|
+
//#region src/parsers/parse-cursor.d.ts
|
|
4
|
+
declare const parseCursor: (source: Uint8Array, options?: ParseCursorOptions) => Cursor;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { parseCursor };
|
|
4
7
|
//# sourceMappingURL=parse-cursor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cursor.d.ts","
|
|
1
|
+
{"version":3,"file":"parse-cursor.d.ts","names":[],"sources":["../../src/parsers/parse-cursor.ts"],"mappings":";;;cAWa,cACX,QAAQ,YACR,UAAS,uBACR"}
|
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.parseCursor = void 0;
|
|
4
|
-
const image_1 = require("@4bitlabs/image");
|
|
1
|
+
import { createIndexedPixelData } from "@4bitlabs/image";
|
|
2
|
+
//#region src/parsers/parse-cursor.ts
|
|
5
3
|
const DEFAULT_MAPPING = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
black: 0,
|
|
5
|
+
white: 15,
|
|
6
|
+
gray: 7,
|
|
7
|
+
keyColor: 13
|
|
10
8
|
};
|
|
11
9
|
const parseCursor = (source, options = {}) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
hotspot,
|
|
38
|
-
};
|
|
10
|
+
const { mapping = DEFAULT_MAPPING } = options;
|
|
11
|
+
const { keyColor } = mapping;
|
|
12
|
+
const colorLut = [
|
|
13
|
+
mapping.black,
|
|
14
|
+
mapping.white,
|
|
15
|
+
mapping.keyColor,
|
|
16
|
+
mapping.gray
|
|
17
|
+
];
|
|
18
|
+
const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
|
|
19
|
+
const hotspot = [view.getUint16(0, true), view.getUint16(2, true)];
|
|
20
|
+
const img = createIndexedPixelData(16, 16, { keyColor });
|
|
21
|
+
const stride = 16;
|
|
22
|
+
for (let y = 0; y < 16; y++) for (let x = 0; x < 16; x++) {
|
|
23
|
+
const idx = 4 + y * 2;
|
|
24
|
+
const tx = view.getUint16(idx, true);
|
|
25
|
+
const clr = view.getUint16(idx + 32, true);
|
|
26
|
+
const a = tx >> 15 - x & 1;
|
|
27
|
+
const b = clr >> 15 - x & 1;
|
|
28
|
+
const value = a << 1 | b;
|
|
29
|
+
img.pixels[x + y * stride] = colorLut[value];
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...img,
|
|
33
|
+
hotspot
|
|
34
|
+
};
|
|
39
35
|
};
|
|
40
|
-
|
|
36
|
+
//#endregion
|
|
37
|
+
export { parseCursor };
|
|
38
|
+
|
|
41
39
|
//# sourceMappingURL=parse-cursor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cursor.js","
|
|
1
|
+
{"version":3,"file":"parse-cursor.js","names":[],"sources":["../../src/parsers/parse-cursor.ts"],"sourcesContent":["import { createIndexedPixelData } from '@4bitlabs/image';\nimport type { Cursor } from '../models/cursor.js';\nimport type { ParseCursorOptions } from './parse-cursor-options.js';\n\nconst DEFAULT_MAPPING = {\n black: 0x00,\n white: 0x0f,\n gray: 0x07,\n keyColor: 0x0d,\n};\n\nexport const parseCursor = (\n source: Uint8Array,\n options: ParseCursorOptions = {},\n): Cursor => {\n const { mapping = DEFAULT_MAPPING } = options;\n const { keyColor } = mapping;\n const colorLut = [\n mapping.black,\n mapping.white,\n mapping.keyColor,\n mapping.gray,\n ];\n\n const view = new DataView(\n source.buffer,\n source.byteOffset,\n source.byteLength,\n );\n\n const hotspot = [view.getUint16(0, true), view.getUint16(2, true)] as const;\n\n const img = createIndexedPixelData(16, 16, { keyColor });\n const stride = 16;\n for (let y = 0; y < 16; y++) {\n for (let x = 0; x < 16; x++) {\n const idx = 4 + y * 2;\n\n const tx = view.getUint16(idx, true);\n const clr = view.getUint16(idx + 32, true);\n\n const a = (tx >> (15 - x)) & 1;\n const b = (clr >> (15 - x)) & 1;\n const value = (a << 1) | b;\n img.pixels[x + y * stride] = colorLut[value];\n }\n }\n\n return {\n ...img,\n hotspot,\n };\n};\n"],"mappings":";;AAIA,MAAM,kBAAkB;CACtB,OAAO;CACP,OAAO;CACP,MAAM;CACN,UAAU;AACZ;AAEA,MAAa,eACX,QACA,UAA8B,CAAC,MACpB;CACX,MAAM,EAAE,UAAU,oBAAoB;CACtC,MAAM,EAAE,aAAa;CACrB,MAAM,WAAW;EACf,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACV;CAEA,MAAM,OAAO,IAAI,SACf,OAAO,QACP,OAAO,YACP,OAAO,UACT;CAEA,MAAM,UAAU,CAAC,KAAK,UAAU,GAAG,IAAI,GAAG,KAAK,UAAU,GAAG,IAAI,CAAC;CAEjE,MAAM,MAAM,uBAAuB,IAAI,IAAI,EAAE,SAAS,CAAC;CACvD,MAAM,SAAS;CACf,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KACtB,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;EAC3B,MAAM,MAAM,IAAI,IAAI;EAEpB,MAAM,KAAK,KAAK,UAAU,KAAK,IAAI;EACnC,MAAM,MAAM,KAAK,UAAU,MAAM,IAAI,IAAI;EAEzC,MAAM,IAAK,MAAO,KAAK,IAAM;EAC7B,MAAM,IAAK,OAAQ,KAAK,IAAM;EAC9B,MAAM,QAAS,KAAK,IAAK;EACzB,IAAI,OAAO,IAAI,IAAI,UAAU,SAAS;CACxC;CAGF,OAAO;EACL,GAAG;EACH;CACF;AACF"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/parsers/parse-font-options.d.ts
|
|
2
|
+
interface ParseFontOptions {
|
|
3
|
+
color?: number;
|
|
4
|
+
keyColor?: number;
|
|
4
5
|
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { ParseFontOptions };
|
|
5
8
|
//# sourceMappingURL=parse-font-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-font-options.d.ts","
|
|
1
|
+
{"version":3,"file":"parse-font-options.d.ts","names":[],"sources":["../../src/parsers/parse-font-options.ts"],"mappings":";UAAiB;EACf;EACA"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ParseFontOptions } from "./parse-font-options.js";
|
|
2
|
+
import { FontFace } from "../models/font-face.js";
|
|
3
|
+
//#region src/parsers/parse-font.d.ts
|
|
4
|
+
declare const parseFont: (source: Uint8Array, options?: ParseFontOptions) => FontFace;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { parseFont };
|
|
4
7
|
//# sourceMappingURL=parse-font.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-font.d.ts","
|
|
1
|
+
{"version":3,"file":"parse-font.d.ts","names":[],"sources":["../../src/parsers/parse-font.ts"],"mappings":";;;cAKa,YACX,QAAQ,YACR,UAAS,qBACR"}
|