byte-codec 1.1.12 → 1.2.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/README.md +10 -10
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/package.json +3 -11
package/README.md
CHANGED
|
@@ -42,16 +42,16 @@ To run a single test file, pass its path to vitest directly, e.g. `pnpm exec vit
|
|
|
42
42
|
|
|
43
43
|
## What it provides
|
|
44
44
|
|
|
45
|
-
| Module
|
|
46
|
-
|
|
47
|
-
| `bytes/writer`
|
|
48
|
-
| `bytes/reader`
|
|
49
|
-
| `bytes/crc32`
|
|
50
|
-
| `bytes/flate`
|
|
51
|
-
| `image/png-encode` | `encodePng` (raw RGB/RGBA pixels → PNG bytes)
|
|
52
|
-
| `image/png-decode` | `decodePng` (PNG bytes → raw pixels), `RawImage`
|
|
53
|
-
| `image/png-filter` | `filterScanlines`, `unfilterScanlines` (the five PNG scanline filters)
|
|
54
|
-
| `image/jpeg-info`
|
|
45
|
+
| Module | Exports |
|
|
46
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------- |
|
|
47
|
+
| `bytes/writer` | `ByteWriter` (chunked growable byte-output builder), `concatBytes` |
|
|
48
|
+
| `bytes/reader` | `ByteReader` (sequential big/little-endian byte reader), `isAsciiWhitespace` |
|
|
49
|
+
| `bytes/crc32` | `crc32` (IEEE 802.3 / ZIP / PNG polynomial table-driven CRC-32) |
|
|
50
|
+
| `bytes/flate` | `deflate`, `inflate`, `inflateTolerant` (fflate-backed DEFLATE compression/decompression with a safety cap) |
|
|
51
|
+
| `image/png-encode` | `encodePng` (raw RGB/RGBA pixels → PNG bytes) |
|
|
52
|
+
| `image/png-decode` | `decodePng` (PNG bytes → raw pixels), `RawImage` |
|
|
53
|
+
| `image/png-filter` | `filterScanlines`, `unfilterScanlines` (the five PNG scanline filters) |
|
|
54
|
+
| `image/jpeg-info` | `readJpegInfo` (JPEG header reader: dimensions, components, progressive flag — no sample decoding) |
|
|
55
55
|
|
|
56
56
|
## Conventions
|
|
57
57
|
|
package/dist/index.d.cts
CHANGED
|
@@ -3,12 +3,12 @@ declare class ByteWriter {
|
|
|
3
3
|
private readonly chunks;
|
|
4
4
|
private byteLength;
|
|
5
5
|
get length(): number;
|
|
6
|
-
writeBytes(bytes: Uint8Array
|
|
6
|
+
writeBytes(bytes: Uint8Array): void;
|
|
7
7
|
writeByte(byte: number): void;
|
|
8
8
|
writeAscii(text: string): void;
|
|
9
9
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
10
10
|
}
|
|
11
|
-
declare function concatBytes(chunks: readonly Uint8Array
|
|
11
|
+
declare function concatBytes(chunks: readonly Uint8Array[]): Uint8Array<ArrayBuffer>;
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/bytes/reader.d.ts
|
|
14
14
|
declare function isAsciiWhitespace(byte: number | undefined): boolean;
|
|
@@ -58,14 +58,14 @@ declare function decodePng(bytes: Uint8Array<ArrayBuffer>, options?: PngDecodeOp
|
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/image/png-encode.d.ts
|
|
60
60
|
interface PngEncodeOptions {
|
|
61
|
-
readonly filter?:
|
|
61
|
+
readonly filter?: "none" | "adaptive";
|
|
62
62
|
}
|
|
63
63
|
declare function encodePng(image: RawImage, options?: PngEncodeOptions): Uint8Array<ArrayBuffer>;
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/image/png-filter.d.ts
|
|
66
66
|
type PngFilterType = 0 | 1 | 2 | 3 | 4;
|
|
67
67
|
declare function unfilterScanlines(data: Uint8Array<ArrayBuffer>, height: number, bytesPerRow: number, bpp: number): Uint8Array<ArrayBuffer>;
|
|
68
|
-
declare function filterScanlines(raw: Uint8Array<ArrayBuffer>, height: number, bytesPerRow: number, bpp: number, strategy?:
|
|
68
|
+
declare function filterScanlines(raw: Uint8Array<ArrayBuffer>, height: number, bytesPerRow: number, bpp: number, strategy?: "none" | "adaptive"): Uint8Array<ArrayBuffer>;
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/image/jpeg-info.d.ts
|
|
71
71
|
interface JpegInfo {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ declare class ByteWriter {
|
|
|
3
3
|
private readonly chunks;
|
|
4
4
|
private byteLength;
|
|
5
5
|
get length(): number;
|
|
6
|
-
writeBytes(bytes: Uint8Array
|
|
6
|
+
writeBytes(bytes: Uint8Array): void;
|
|
7
7
|
writeByte(byte: number): void;
|
|
8
8
|
writeAscii(text: string): void;
|
|
9
9
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
10
10
|
}
|
|
11
|
-
declare function concatBytes(chunks: readonly Uint8Array
|
|
11
|
+
declare function concatBytes(chunks: readonly Uint8Array[]): Uint8Array<ArrayBuffer>;
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/bytes/reader.d.ts
|
|
14
14
|
declare function isAsciiWhitespace(byte: number | undefined): boolean;
|
|
@@ -58,14 +58,14 @@ declare function decodePng(bytes: Uint8Array<ArrayBuffer>, options?: PngDecodeOp
|
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/image/png-encode.d.ts
|
|
60
60
|
interface PngEncodeOptions {
|
|
61
|
-
readonly filter?:
|
|
61
|
+
readonly filter?: "none" | "adaptive";
|
|
62
62
|
}
|
|
63
63
|
declare function encodePng(image: RawImage, options?: PngEncodeOptions): Uint8Array<ArrayBuffer>;
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/image/png-filter.d.ts
|
|
66
66
|
type PngFilterType = 0 | 1 | 2 | 3 | 4;
|
|
67
67
|
declare function unfilterScanlines(data: Uint8Array<ArrayBuffer>, height: number, bytesPerRow: number, bpp: number): Uint8Array<ArrayBuffer>;
|
|
68
|
-
declare function filterScanlines(raw: Uint8Array<ArrayBuffer>, height: number, bytesPerRow: number, bpp: number, strategy?:
|
|
68
|
+
declare function filterScanlines(raw: Uint8Array<ArrayBuffer>, height: number, bytesPerRow: number, bpp: number, strategy?: "none" | "adaptive"): Uint8Array<ArrayBuffer>;
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/image/jpeg-info.d.ts
|
|
71
71
|
interface JpegInfo {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "byte-codec",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Generic byte-level primitives (ByteWriter, ByteReader, CRC-32, deflate/inflate) and PNG/JPEG image encoding/decoding with zero PDF knowledge — the shared utility package for the documents.js family.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -53,8 +53,9 @@
|
|
|
53
53
|
"lint": "turbo run _lint",
|
|
54
54
|
"_lint": "eslint . --fix --cache --max-warnings 0",
|
|
55
55
|
"lint:check": "eslint . --max-warnings 0",
|
|
56
|
-
"typecheck": "turbo run _typecheck",
|
|
56
|
+
"typecheck": "turbo run _typecheck _typecheck:attw",
|
|
57
57
|
"_typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.node.json",
|
|
58
|
+
"_typecheck:attw": "attw --pack",
|
|
58
59
|
"test": "turbo run _test",
|
|
59
60
|
"_test": "vitest run",
|
|
60
61
|
"test:watch": "vitest",
|
|
@@ -69,22 +70,13 @@
|
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
71
72
|
"@cloudflare/vitest-pool-workers": "^0.20.1",
|
|
72
|
-
"@commitlint/cli": "^21.2.1",
|
|
73
|
-
"@commitlint/config-conventional": "^21.2.0",
|
|
74
|
-
"@eslint/js": "^10.0.1",
|
|
75
|
-
"@semantic-release/changelog": "^7.0.0",
|
|
76
|
-
"@semantic-release/git": "^11.0.1",
|
|
77
73
|
"@types/node": "^26.1.2",
|
|
78
74
|
"eslint": "^10.8.0",
|
|
79
|
-
"globals": "^17.8.0",
|
|
80
75
|
"husky": "^9.1.7",
|
|
81
|
-
"lint-staged": "^17.2.0",
|
|
82
76
|
"publint": "^0.3.21",
|
|
83
|
-
"semantic-release": "^25.0.8",
|
|
84
77
|
"tsdown": "^0.22.13",
|
|
85
78
|
"turbo": "^2.10.8",
|
|
86
79
|
"typescript": "^6.0.3",
|
|
87
|
-
"typescript-eslint": "^8.65.0",
|
|
88
80
|
"vitest": "^4.1.10"
|
|
89
81
|
},
|
|
90
82
|
"lint-staged": {
|