@bb-studio/exr 0.1.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/LICENSE +21 -0
- package/README.md +63 -0
- package/THIRD_PARTY_LICENSES.md +32 -0
- package/dist/browser/dwaDecodeWorker.js +1184 -0
- package/dist/browser/dwaDecodeWorker.js.map +1 -0
- package/dist/browser/index.d.ts +86 -0
- package/dist/browser/index.js +3170 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/zipDecodeWorker.js +57 -0
- package/dist/browser/zipDecodeWorker.js.map +1 -0
- package/dist/index.cjs +4627 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +121 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +4592 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
type ExrEventPhase = 'parse' | 'decode' | 'encode';
|
|
2
|
+
type ExrEventLevel = 'info' | 'warn' | 'error';
|
|
3
|
+
declare const EXR_EVENT_CODES: readonly ["parse.magic.invalid", "parse.magic.ok", "parse.version.ok", "parse.part.ok", "parse.complete", "decode.setup", "decode.offsets.read", "decode.chunk.part_mismatch", "decode.chunk.trailing_bytes", "decode.complete", "encode.setup", "encode.part.complete", "encode.complete"];
|
|
4
|
+
type ExrEventCode = (typeof EXR_EVENT_CODES)[number];
|
|
5
|
+
interface ExrEvent {
|
|
6
|
+
phase: ExrEventPhase;
|
|
7
|
+
level: ExrEventLevel;
|
|
8
|
+
code: ExrEventCode;
|
|
9
|
+
message: string;
|
|
10
|
+
metrics?: Record<string, string | number>;
|
|
11
|
+
}
|
|
12
|
+
type ExrEventCallback = (event: ExrEvent) => void;
|
|
13
|
+
interface EventCapableOptions {
|
|
14
|
+
onEvent?: ExrEventCallback;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ExrBinaryInput = ArrayBuffer | Uint8Array;
|
|
18
|
+
declare function toArrayBuffer(input: ExrBinaryInput): ArrayBuffer;
|
|
19
|
+
|
|
20
|
+
type ExrPixelType = 0 | 1 | 2;
|
|
21
|
+
type ExrCompression = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
22
|
+
|
|
23
|
+
interface ExrChannel {
|
|
24
|
+
name: string;
|
|
25
|
+
pixelType: ExrPixelType | number;
|
|
26
|
+
pLinear: number;
|
|
27
|
+
xSampling: number;
|
|
28
|
+
ySampling: number;
|
|
29
|
+
}
|
|
30
|
+
interface ExrWindow {
|
|
31
|
+
xMin: number;
|
|
32
|
+
yMin: number;
|
|
33
|
+
xMax: number;
|
|
34
|
+
yMax: number;
|
|
35
|
+
}
|
|
36
|
+
interface ExrPart {
|
|
37
|
+
id: number;
|
|
38
|
+
attributes: Record<string, unknown>;
|
|
39
|
+
channels: ExrChannel[];
|
|
40
|
+
dataWindow?: ExrWindow;
|
|
41
|
+
displayWindow?: ExrWindow;
|
|
42
|
+
compression?: ExrCompression | number;
|
|
43
|
+
type?: string;
|
|
44
|
+
}
|
|
45
|
+
interface ExrStructure {
|
|
46
|
+
magic: number;
|
|
47
|
+
version: number;
|
|
48
|
+
flags: number;
|
|
49
|
+
isMultipart: boolean;
|
|
50
|
+
parts: ExrPart[];
|
|
51
|
+
headerEndOffset: number;
|
|
52
|
+
}
|
|
53
|
+
type ParseExrOptions = EventCapableOptions;
|
|
54
|
+
interface DecodeExrPartOptions extends EventCapableOptions {
|
|
55
|
+
partId: number;
|
|
56
|
+
predecodedZipBlocks?: Map<number, Uint8Array>;
|
|
57
|
+
predecodedDwaBlocks?: Map<number, Uint8Array>;
|
|
58
|
+
}
|
|
59
|
+
interface DecodedChannel {
|
|
60
|
+
pixelType: number;
|
|
61
|
+
xSampling: number;
|
|
62
|
+
ySampling: number;
|
|
63
|
+
sampledWidth: number;
|
|
64
|
+
sampledHeight: number;
|
|
65
|
+
sampleOriginX: number;
|
|
66
|
+
sampleOriginY: number;
|
|
67
|
+
data: Float32Array;
|
|
68
|
+
}
|
|
69
|
+
interface DecodedPart {
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
channels: Record<string, DecodedChannel>;
|
|
73
|
+
}
|
|
74
|
+
interface WriteExrChannelInput {
|
|
75
|
+
name: string;
|
|
76
|
+
pixelType: ExrPixelType | number;
|
|
77
|
+
data: Float32Array;
|
|
78
|
+
pLinear?: number;
|
|
79
|
+
xSampling?: number;
|
|
80
|
+
ySampling?: number;
|
|
81
|
+
}
|
|
82
|
+
interface WriteExrPartInput {
|
|
83
|
+
channels: WriteExrChannelInput[];
|
|
84
|
+
compression: ExrCompression | number;
|
|
85
|
+
dataWindow: ExrWindow;
|
|
86
|
+
displayWindow?: ExrWindow;
|
|
87
|
+
name?: string;
|
|
88
|
+
type?: string;
|
|
89
|
+
}
|
|
90
|
+
interface WriteExrInput {
|
|
91
|
+
parts: WriteExrPartInput[];
|
|
92
|
+
}
|
|
93
|
+
type WriteExrOptions = EventCapableOptions;
|
|
94
|
+
|
|
95
|
+
type ExrErrorCode = 'BUFFER_TOO_SMALL' | 'INVALID_MAGIC' | 'TRUNCATED_FILE' | 'MALFORMED_HEADER' | 'PART_NOT_FOUND' | 'UNSUPPORTED_PART_TYPE' | 'UNSUPPORTED_COMPRESSION' | 'MISSING_DATA_WINDOW' | 'MALFORMED_OFFSET_TABLE' | 'MALFORMED_CHUNK' | 'DECOMPRESSION_FAILED' | 'INVALID_WRITE_INPUT' | 'UNSUPPORTED_WRITE_COMPRESSION' | 'ENCODING_FAILED';
|
|
96
|
+
declare class ExrError extends Error {
|
|
97
|
+
readonly code: ExrErrorCode;
|
|
98
|
+
readonly details?: Record<string, string | number>;
|
|
99
|
+
constructor(code: ExrErrorCode, message: string, details?: Record<string, string | number>);
|
|
100
|
+
}
|
|
101
|
+
declare function isExrError(value: unknown): value is ExrError;
|
|
102
|
+
|
|
103
|
+
declare function parseExrStructure(bufferInput: ExrBinaryInput, options?: ParseExrOptions): ExrStructure;
|
|
104
|
+
declare const parseExr: typeof parseExrStructure;
|
|
105
|
+
|
|
106
|
+
declare function decodeExrPart(bufferInput: ExrBinaryInput, structure: ExrStructure, options: DecodeExrPartOptions): DecodedPart;
|
|
107
|
+
|
|
108
|
+
interface ReadExrOptions extends ParseExrOptions {
|
|
109
|
+
partId?: number;
|
|
110
|
+
decode?: Omit<DecodeExrPartOptions, 'partId' | 'onEvent'>;
|
|
111
|
+
}
|
|
112
|
+
interface ReadExrResult {
|
|
113
|
+
structure: ExrStructure;
|
|
114
|
+
part: DecodedPart;
|
|
115
|
+
partId: number;
|
|
116
|
+
}
|
|
117
|
+
declare function readExr(buffer: ExrBinaryInput, options?: ReadExrOptions): ReadExrResult;
|
|
118
|
+
|
|
119
|
+
declare function writeExr(input: WriteExrInput, options?: WriteExrOptions): Uint8Array;
|
|
120
|
+
|
|
121
|
+
export { type DecodeExrPartOptions, type DecodedChannel, type DecodedPart, EXR_EVENT_CODES, type EventCapableOptions, type ExrBinaryInput, type ExrChannel, type ExrCompression, ExrError, type ExrErrorCode, type ExrEvent, type ExrEventCallback, type ExrEventCode, type ExrEventLevel, type ExrEventPhase, type ExrPart, type ExrPixelType, type ExrStructure, type ExrWindow, type ParseExrOptions, type ReadExrOptions, type ReadExrResult, type WriteExrChannelInput, type WriteExrInput, type WriteExrOptions, type WriteExrPartInput, decodeExrPart, isExrError, parseExr, parseExrStructure, readExr, toArrayBuffer, writeExr };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
type ExrEventPhase = 'parse' | 'decode' | 'encode';
|
|
2
|
+
type ExrEventLevel = 'info' | 'warn' | 'error';
|
|
3
|
+
declare const EXR_EVENT_CODES: readonly ["parse.magic.invalid", "parse.magic.ok", "parse.version.ok", "parse.part.ok", "parse.complete", "decode.setup", "decode.offsets.read", "decode.chunk.part_mismatch", "decode.chunk.trailing_bytes", "decode.complete", "encode.setup", "encode.part.complete", "encode.complete"];
|
|
4
|
+
type ExrEventCode = (typeof EXR_EVENT_CODES)[number];
|
|
5
|
+
interface ExrEvent {
|
|
6
|
+
phase: ExrEventPhase;
|
|
7
|
+
level: ExrEventLevel;
|
|
8
|
+
code: ExrEventCode;
|
|
9
|
+
message: string;
|
|
10
|
+
metrics?: Record<string, string | number>;
|
|
11
|
+
}
|
|
12
|
+
type ExrEventCallback = (event: ExrEvent) => void;
|
|
13
|
+
interface EventCapableOptions {
|
|
14
|
+
onEvent?: ExrEventCallback;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ExrBinaryInput = ArrayBuffer | Uint8Array;
|
|
18
|
+
declare function toArrayBuffer(input: ExrBinaryInput): ArrayBuffer;
|
|
19
|
+
|
|
20
|
+
type ExrPixelType = 0 | 1 | 2;
|
|
21
|
+
type ExrCompression = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
22
|
+
|
|
23
|
+
interface ExrChannel {
|
|
24
|
+
name: string;
|
|
25
|
+
pixelType: ExrPixelType | number;
|
|
26
|
+
pLinear: number;
|
|
27
|
+
xSampling: number;
|
|
28
|
+
ySampling: number;
|
|
29
|
+
}
|
|
30
|
+
interface ExrWindow {
|
|
31
|
+
xMin: number;
|
|
32
|
+
yMin: number;
|
|
33
|
+
xMax: number;
|
|
34
|
+
yMax: number;
|
|
35
|
+
}
|
|
36
|
+
interface ExrPart {
|
|
37
|
+
id: number;
|
|
38
|
+
attributes: Record<string, unknown>;
|
|
39
|
+
channels: ExrChannel[];
|
|
40
|
+
dataWindow?: ExrWindow;
|
|
41
|
+
displayWindow?: ExrWindow;
|
|
42
|
+
compression?: ExrCompression | number;
|
|
43
|
+
type?: string;
|
|
44
|
+
}
|
|
45
|
+
interface ExrStructure {
|
|
46
|
+
magic: number;
|
|
47
|
+
version: number;
|
|
48
|
+
flags: number;
|
|
49
|
+
isMultipart: boolean;
|
|
50
|
+
parts: ExrPart[];
|
|
51
|
+
headerEndOffset: number;
|
|
52
|
+
}
|
|
53
|
+
type ParseExrOptions = EventCapableOptions;
|
|
54
|
+
interface DecodeExrPartOptions extends EventCapableOptions {
|
|
55
|
+
partId: number;
|
|
56
|
+
predecodedZipBlocks?: Map<number, Uint8Array>;
|
|
57
|
+
predecodedDwaBlocks?: Map<number, Uint8Array>;
|
|
58
|
+
}
|
|
59
|
+
interface DecodedChannel {
|
|
60
|
+
pixelType: number;
|
|
61
|
+
xSampling: number;
|
|
62
|
+
ySampling: number;
|
|
63
|
+
sampledWidth: number;
|
|
64
|
+
sampledHeight: number;
|
|
65
|
+
sampleOriginX: number;
|
|
66
|
+
sampleOriginY: number;
|
|
67
|
+
data: Float32Array;
|
|
68
|
+
}
|
|
69
|
+
interface DecodedPart {
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
channels: Record<string, DecodedChannel>;
|
|
73
|
+
}
|
|
74
|
+
interface WriteExrChannelInput {
|
|
75
|
+
name: string;
|
|
76
|
+
pixelType: ExrPixelType | number;
|
|
77
|
+
data: Float32Array;
|
|
78
|
+
pLinear?: number;
|
|
79
|
+
xSampling?: number;
|
|
80
|
+
ySampling?: number;
|
|
81
|
+
}
|
|
82
|
+
interface WriteExrPartInput {
|
|
83
|
+
channels: WriteExrChannelInput[];
|
|
84
|
+
compression: ExrCompression | number;
|
|
85
|
+
dataWindow: ExrWindow;
|
|
86
|
+
displayWindow?: ExrWindow;
|
|
87
|
+
name?: string;
|
|
88
|
+
type?: string;
|
|
89
|
+
}
|
|
90
|
+
interface WriteExrInput {
|
|
91
|
+
parts: WriteExrPartInput[];
|
|
92
|
+
}
|
|
93
|
+
type WriteExrOptions = EventCapableOptions;
|
|
94
|
+
|
|
95
|
+
type ExrErrorCode = 'BUFFER_TOO_SMALL' | 'INVALID_MAGIC' | 'TRUNCATED_FILE' | 'MALFORMED_HEADER' | 'PART_NOT_FOUND' | 'UNSUPPORTED_PART_TYPE' | 'UNSUPPORTED_COMPRESSION' | 'MISSING_DATA_WINDOW' | 'MALFORMED_OFFSET_TABLE' | 'MALFORMED_CHUNK' | 'DECOMPRESSION_FAILED' | 'INVALID_WRITE_INPUT' | 'UNSUPPORTED_WRITE_COMPRESSION' | 'ENCODING_FAILED';
|
|
96
|
+
declare class ExrError extends Error {
|
|
97
|
+
readonly code: ExrErrorCode;
|
|
98
|
+
readonly details?: Record<string, string | number>;
|
|
99
|
+
constructor(code: ExrErrorCode, message: string, details?: Record<string, string | number>);
|
|
100
|
+
}
|
|
101
|
+
declare function isExrError(value: unknown): value is ExrError;
|
|
102
|
+
|
|
103
|
+
declare function parseExrStructure(bufferInput: ExrBinaryInput, options?: ParseExrOptions): ExrStructure;
|
|
104
|
+
declare const parseExr: typeof parseExrStructure;
|
|
105
|
+
|
|
106
|
+
declare function decodeExrPart(bufferInput: ExrBinaryInput, structure: ExrStructure, options: DecodeExrPartOptions): DecodedPart;
|
|
107
|
+
|
|
108
|
+
interface ReadExrOptions extends ParseExrOptions {
|
|
109
|
+
partId?: number;
|
|
110
|
+
decode?: Omit<DecodeExrPartOptions, 'partId' | 'onEvent'>;
|
|
111
|
+
}
|
|
112
|
+
interface ReadExrResult {
|
|
113
|
+
structure: ExrStructure;
|
|
114
|
+
part: DecodedPart;
|
|
115
|
+
partId: number;
|
|
116
|
+
}
|
|
117
|
+
declare function readExr(buffer: ExrBinaryInput, options?: ReadExrOptions): ReadExrResult;
|
|
118
|
+
|
|
119
|
+
declare function writeExr(input: WriteExrInput, options?: WriteExrOptions): Uint8Array;
|
|
120
|
+
|
|
121
|
+
export { type DecodeExrPartOptions, type DecodedChannel, type DecodedPart, EXR_EVENT_CODES, type EventCapableOptions, type ExrBinaryInput, type ExrChannel, type ExrCompression, ExrError, type ExrErrorCode, type ExrEvent, type ExrEventCallback, type ExrEventCode, type ExrEventLevel, type ExrEventPhase, type ExrPart, type ExrPixelType, type ExrStructure, type ExrWindow, type ParseExrOptions, type ReadExrOptions, type ReadExrResult, type WriteExrChannelInput, type WriteExrInput, type WriteExrOptions, type WriteExrPartInput, decodeExrPart, isExrError, parseExr, parseExrStructure, readExr, toArrayBuffer, writeExr };
|