geotiff 3.0.0 → 3.0.2

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.
Files changed (160) hide show
  1. package/dist-browser/geotiff.js +3 -2
  2. package/dist-browser/geotiff.js.map +1 -1
  3. package/dist-module/compression/basedecoder.d.ts +4 -0
  4. package/dist-module/compression/basedecoder.d.ts.map +1 -1
  5. package/dist-module/compression/basedecoder.js +6 -0
  6. package/dist-module/compression/index.d.ts +4 -4
  7. package/dist-module/compression/index.d.ts.map +1 -1
  8. package/dist-module/compression/index.js +4 -4
  9. package/dist-module/compression/jpeg.d.ts +6 -1
  10. package/dist-module/compression/jpeg.d.ts.map +1 -1
  11. package/dist-module/compression/jpeg.js +50 -5
  12. package/dist-module/compression/lzw.js +1 -1
  13. package/dist-module/compression/webimage.d.ts +1 -1
  14. package/dist-module/compression/webimage.d.ts.map +1 -1
  15. package/dist-module/compression/webimage.js +1 -1
  16. package/dist-module/dataslice.d.ts.map +1 -1
  17. package/dist-module/dataslice.js +2 -2
  18. package/dist-module/dataview64.d.ts +2 -2
  19. package/dist-module/dataview64.d.ts.map +1 -1
  20. package/dist-module/dataview64.js +4 -4
  21. package/dist-module/geotiff.d.ts +171 -45
  22. package/dist-module/geotiff.d.ts.map +1 -1
  23. package/dist-module/geotiff.js +119 -20
  24. package/dist-module/geotiffimage.d.ts +79 -112
  25. package/dist-module/geotiffimage.d.ts.map +1 -1
  26. package/dist-module/geotiffimage.js +99 -71
  27. package/dist-module/geotiffwriter.js +2 -2
  28. package/dist-module/globals.d.ts +48 -40
  29. package/dist-module/globals.d.ts.map +1 -1
  30. package/dist-module/globals.js +14 -10
  31. package/dist-module/imagefiledirectory.d.ts +2 -2
  32. package/dist-module/imagefiledirectory.d.ts.map +1 -1
  33. package/dist-module/imagefiledirectory.js +23 -12
  34. package/dist-module/logging.js +7 -7
  35. package/dist-module/pool.js +1 -1
  36. package/dist-module/predictor.js +1 -1
  37. package/dist-module/resample.d.ts +18 -18
  38. package/dist-module/resample.d.ts.map +1 -1
  39. package/dist-module/resample.js +12 -12
  40. package/dist-module/source/basesource.d.ts +7 -7
  41. package/dist-module/source/basesource.d.ts.map +1 -1
  42. package/dist-module/source/basesource.js +7 -7
  43. package/dist-module/source/blockedsource.d.ts +10 -10
  44. package/dist-module/source/blockedsource.d.ts.map +1 -1
  45. package/dist-module/source/blockedsource.js +12 -9
  46. package/dist-module/source/client/base.d.ts +8 -10
  47. package/dist-module/source/client/base.d.ts.map +1 -1
  48. package/dist-module/source/client/base.js +4 -3
  49. package/dist-module/source/client/fetch.d.ts +2 -7
  50. package/dist-module/source/client/fetch.d.ts.map +1 -1
  51. package/dist-module/source/client/fetch.js +7 -2
  52. package/dist-module/source/client/http.d.ts +4 -1
  53. package/dist-module/source/client/http.d.ts.map +1 -1
  54. package/dist-module/source/client/http.js +4 -4
  55. package/dist-module/source/client/xhr.d.ts +4 -1
  56. package/dist-module/source/client/xhr.d.ts.map +1 -1
  57. package/dist-module/source/client/xhr.js +1 -1
  58. package/dist-module/source/file.js +4 -4
  59. package/dist-module/source/filereader.js +1 -1
  60. package/dist-module/source/httputils.d.ts +14 -6
  61. package/dist-module/source/httputils.d.ts.map +1 -1
  62. package/dist-module/source/httputils.js +13 -12
  63. package/dist-module/source/remote.d.ts +31 -22
  64. package/dist-module/source/remote.d.ts.map +1 -1
  65. package/dist-module/source/remote.js +37 -13
  66. package/dist-module/utils.d.ts +7 -1
  67. package/dist-module/utils.d.ts.map +1 -1
  68. package/dist-module/utils.js +6 -0
  69. package/dist-module/worker/create.js +1 -1
  70. package/dist-node/compression/basedecoder.d.ts +4 -0
  71. package/dist-node/compression/basedecoder.d.ts.map +1 -1
  72. package/dist-node/compression/basedecoder.js +6 -0
  73. package/dist-node/compression/basedecoder.js.map +1 -1
  74. package/dist-node/compression/index.d.ts +4 -4
  75. package/dist-node/compression/index.d.ts.map +1 -1
  76. package/dist-node/compression/index.js +4 -4
  77. package/dist-node/compression/jpeg.d.ts +6 -1
  78. package/dist-node/compression/jpeg.d.ts.map +1 -1
  79. package/dist-node/compression/jpeg.js +50 -5
  80. package/dist-node/compression/jpeg.js.map +1 -1
  81. package/dist-node/compression/lzw.js +1 -1
  82. package/dist-node/compression/lzw.js.map +1 -1
  83. package/dist-node/compression/webimage.js +1 -1
  84. package/dist-node/compression/webimage.js.map +1 -1
  85. package/dist-node/dataslice.js +2 -2
  86. package/dist-node/dataslice.js.map +1 -1
  87. package/dist-node/dataview64.d.ts +2 -2
  88. package/dist-node/dataview64.d.ts.map +1 -1
  89. package/dist-node/dataview64.js +4 -4
  90. package/dist-node/dataview64.js.map +1 -1
  91. package/dist-node/geotiff.d.ts +171 -45
  92. package/dist-node/geotiff.d.ts.map +1 -1
  93. package/dist-node/geotiff.js +118 -20
  94. package/dist-node/geotiff.js.map +1 -1
  95. package/dist-node/geotiffimage.d.ts +80 -113
  96. package/dist-node/geotiffimage.d.ts.map +1 -1
  97. package/dist-node/geotiffimage.js +99 -71
  98. package/dist-node/geotiffimage.js.map +1 -1
  99. package/dist-node/geotiffwriter.js +2 -2
  100. package/dist-node/geotiffwriter.js.map +1 -1
  101. package/dist-node/globals.d.ts +48 -40
  102. package/dist-node/globals.d.ts.map +1 -1
  103. package/dist-node/globals.js +14 -10
  104. package/dist-node/globals.js.map +1 -1
  105. package/dist-node/imagefiledirectory.d.ts +2 -2
  106. package/dist-node/imagefiledirectory.d.ts.map +1 -1
  107. package/dist-node/imagefiledirectory.js +23 -12
  108. package/dist-node/imagefiledirectory.js.map +1 -1
  109. package/dist-node/logging.js +7 -7
  110. package/dist-node/logging.js.map +1 -1
  111. package/dist-node/pool.js +1 -1
  112. package/dist-node/pool.js.map +1 -1
  113. package/dist-node/predictor.js +1 -1
  114. package/dist-node/predictor.js.map +1 -1
  115. package/dist-node/resample.d.ts +18 -18
  116. package/dist-node/resample.d.ts.map +1 -1
  117. package/dist-node/resample.js +12 -12
  118. package/dist-node/source/basesource.d.ts +7 -7
  119. package/dist-node/source/basesource.d.ts.map +1 -1
  120. package/dist-node/source/basesource.js +7 -7
  121. package/dist-node/source/basesource.js.map +1 -1
  122. package/dist-node/source/blockedsource.d.ts +10 -10
  123. package/dist-node/source/blockedsource.d.ts.map +1 -1
  124. package/dist-node/source/blockedsource.js +12 -9
  125. package/dist-node/source/blockedsource.js.map +1 -1
  126. package/dist-node/source/client/base.d.ts +8 -10
  127. package/dist-node/source/client/base.d.ts.map +1 -1
  128. package/dist-node/source/client/base.js +4 -3
  129. package/dist-node/source/client/base.js.map +1 -1
  130. package/dist-node/source/client/fetch.d.ts +2 -6
  131. package/dist-node/source/client/fetch.d.ts.map +1 -1
  132. package/dist-node/source/client/fetch.js +7 -2
  133. package/dist-node/source/client/fetch.js.map +1 -1
  134. package/dist-node/source/client/http.d.ts +4 -1
  135. package/dist-node/source/client/http.d.ts.map +1 -1
  136. package/dist-node/source/client/http.js +4 -4
  137. package/dist-node/source/client/http.js.map +1 -1
  138. package/dist-node/source/client/xhr.d.ts +4 -1
  139. package/dist-node/source/client/xhr.d.ts.map +1 -1
  140. package/dist-node/source/client/xhr.js +1 -1
  141. package/dist-node/source/client/xhr.js.map +1 -1
  142. package/dist-node/source/file.js +4 -4
  143. package/dist-node/source/file.js.map +1 -1
  144. package/dist-node/source/filereader.js +1 -1
  145. package/dist-node/source/filereader.js.map +1 -1
  146. package/dist-node/source/httputils.d.ts +14 -6
  147. package/dist-node/source/httputils.d.ts.map +1 -1
  148. package/dist-node/source/httputils.js +13 -12
  149. package/dist-node/source/httputils.js.map +1 -1
  150. package/dist-node/source/remote.d.ts +31 -22
  151. package/dist-node/source/remote.d.ts.map +1 -1
  152. package/dist-node/source/remote.js +37 -13
  153. package/dist-node/source/remote.js.map +1 -1
  154. package/dist-node/utils.d.ts +7 -1
  155. package/dist-node/utils.d.ts.map +1 -1
  156. package/dist-node/utils.js +6 -0
  157. package/dist-node/utils.js.map +1 -1
  158. package/dist-node/worker/create.js +1 -1
  159. package/dist-node/worker/create.js.map +1 -1
  160. package/package.json +3 -54
@@ -1,6 +1,10 @@
1
1
  export default class BaseDecoder {
2
2
  constructor(parameters: any);
3
3
  parameters: any;
4
+ /**
5
+ * @abstract
6
+ */
7
+ decodeBlock(_buffer: any): void;
4
8
  decode(buffer: any): Promise<any>;
5
9
  }
6
10
  //# sourceMappingURL=basedecoder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"basedecoder.d.ts","sourceRoot":"","sources":["../../src/compression/basedecoder.js"],"names":[],"mappings":"AAEA;IACE,6BAEC;IADC,gBAA4B;IAG9B,kCAaC;CACF"}
1
+ {"version":3,"file":"basedecoder.d.ts","sourceRoot":"","sources":["../../src/compression/basedecoder.js"],"names":[],"mappings":"AAEA;IACE,6BAEC;IADC,gBAA4B;IAG9B;;OAEG;IACH,gCAEC;IAED,kCAaC;CACF"}
@@ -3,6 +3,12 @@ export default class BaseDecoder {
3
3
  constructor(parameters) {
4
4
  this.parameters = parameters;
5
5
  }
6
+ /**
7
+ * @abstract
8
+ */
9
+ decodeBlock(_buffer) {
10
+ throw new Error('decodeBlock not implemented');
11
+ }
6
12
  async decode(buffer) {
7
13
  const decoded = await this.decodeBlock(buffer);
8
14
  const { tileWidth, tileHeight, predictor, bitsPerSample, planarConfiguration, } = this.parameters;
@@ -6,10 +6,10 @@
6
6
  * Register a decoder for a specific compression method or a range of compressions
7
7
  * @param {(NumberOrUndefined|(NumberOrUndefined[]))} cases ids of the compression methods to register for
8
8
  * @param {function():Promise} importFn the function to import the decoder
9
- * @param {function():Promise} decoderParameterFn
9
+ * @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise} decoderParameterFn
10
10
  * @param {boolean} preferWorker_ Whether to prefer running the decoder in a worker
11
11
  */
12
- export function addDecoder(cases: (NumberOrUndefined | (NumberOrUndefined[])), importFn: () => Promise<any>, decoderParameterFn?: () => Promise<any>, preferWorker_?: boolean): void;
12
+ export function addDecoder(cases: (NumberOrUndefined | (NumberOrUndefined[])), importFn: () => Promise<any>, decoderParameterFn?: (arg0: import("../imagefiledirectory").ImageFileDirectory) => Promise<any>, preferWorker_?: boolean): void;
13
13
  /**
14
14
  * Get the required decoder parameters for a specific compression method
15
15
  * @param {NumberOrUndefined} compression
@@ -25,10 +25,10 @@ export function getDecoderParameters(compression: NumberOrUndefined, fileDirecto
25
25
  export function getDecoder(compression: number, decoderParameters: DecoderParameters): Promise<import("./basedecoder.js").default>;
26
26
  /**
27
27
  * Whether to prefer running the decoder in a worker
28
- * @param {object} fileDirectory the file directory of the image
28
+ * @param {number|undefined} compression the compression method identifier
29
29
  * @returns {boolean}
30
30
  */
31
- export function preferWorker(compression: any): boolean;
31
+ export function preferWorker(compression: number | undefined): boolean;
32
32
  export type DecoderParameters = {
33
33
  tileWidth: number;
34
34
  tileHeight: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compression/index.js"],"names":[],"mappings":"AA6BA;;;GAGG;AAEH;;;;;;GAMG;AACH,kCALW,CAAC,iBAAiB,GAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,YACzC,kBAAkB,uBAClB,kBAAkB,kBAClB,OAAO,QASjB;AAED;;;;GAIG;AACH,kDAHW,iBAAiB,iBACjB,OAAO,0BAA0B,EAAE,kBAAkB,gBAQ/D;AAED;;;;;GAKG;AACH,wCAJW,MAAM,qBACN,iBAAiB,GACf,OAAO,CAAC,OAAO,kBAAkB,EAAE,OAAO,CAAC,CASvD;AAED;;;;GAIG;AACH,gDAFa,OAAO,CAOnB;;eApFa,MAAM;gBACN,MAAM;yBACN,MAAM;mBACN,MAAM;eACN,MAAM;;;;;gCAuBP,CAAC,MAAM,GAAC,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compression/index.js"],"names":[],"mappings":"AA6BA;;;GAGG;AAEH;;;;;;GAMG;AACH,kCALW,CAAC,iBAAiB,GAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,YACzC,kBAAkB,uBAClB,CAAS,IAAkD,EAAlD,OAAO,uBAAuB,EAAE,kBAAkB,iBAAS,kBACpE,OAAO,QASjB;AAED;;;;GAIG;AACH,kDAHW,iBAAiB,iBACjB,OAAO,0BAA0B,EAAE,kBAAkB,gBAQ/D;AAED;;;;;GAKG;AACH,wCAJW,MAAM,qBACN,iBAAiB,GACf,OAAO,CAAC,OAAO,kBAAkB,EAAE,OAAO,CAAC,CASvD;AAED;;;;GAIG;AACH,0CAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAOnB;;eApFa,MAAM;gBACN,MAAM;yBACN,MAAM;mBACN,MAAM;eACN,MAAM;;;;;gCAuBP,CAAC,MAAM,GAAC,SAAS,CAAC"}
@@ -9,8 +9,8 @@ const registry = new Map();
9
9
  */
10
10
  /**
11
11
  * Default decoder parameter retrieval function
12
- * @param {import('../imagefiledirectory.js').ImageFileDirectory} fileDirectory
13
- * @returns {DecoderParameters}
12
+ * @param {import("../imagefiledirectory").ImageFileDirectory} fileDirectory
13
+ * @returns {Promise<DecoderParameters>}
14
14
  */
15
15
  async function defaultDecoderParameterFn(fileDirectory) {
16
16
  const isTiled = !fileDirectory.hasTag('StripOffsets');
@@ -30,7 +30,7 @@ async function defaultDecoderParameterFn(fileDirectory) {
30
30
  * Register a decoder for a specific compression method or a range of compressions
31
31
  * @param {(NumberOrUndefined|(NumberOrUndefined[]))} cases ids of the compression methods to register for
32
32
  * @param {function():Promise} importFn the function to import the decoder
33
- * @param {function():Promise} decoderParameterFn
33
+ * @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise} decoderParameterFn
34
34
  * @param {boolean} preferWorker_ Whether to prefer running the decoder in a worker
35
35
  */
36
36
  export function addDecoder(cases, importFn, decoderParameterFn = defaultDecoderParameterFn, preferWorker_ = true) {
@@ -69,7 +69,7 @@ export async function getDecoder(compression, decoderParameters) {
69
69
  }
70
70
  /**
71
71
  * Whether to prefer running the decoder in a worker
72
- * @param {object} fileDirectory the file directory of the image
72
+ * @param {number|undefined} compression the compression method identifier
73
73
  * @returns {boolean}
74
74
  */
75
75
  export function preferWorker(compression) {
@@ -2,6 +2,11 @@ export default class JpegDecoder extends BaseDecoder {
2
2
  reader: JpegStreamReader;
3
3
  decodeBlock(buffer: any): ArrayBuffer;
4
4
  }
5
+ export type HuffmanNode = (number | HuffmanNode)[];
6
+ export type Code = {
7
+ children: HuffmanNode;
8
+ index: number;
9
+ };
5
10
  import BaseDecoder from './basedecoder.js';
6
11
  declare class JpegStreamReader {
7
12
  jfif: {
@@ -25,8 +30,8 @@ declare class JpegStreamReader {
25
30
  quantizationTables: any[];
26
31
  huffmanTablesAC: any[];
27
32
  huffmanTablesDC: any[];
33
+ frames: any[];
28
34
  resetFrames(): void;
29
- frames: any[] | undefined;
30
35
  parse(data: any): void;
31
36
  resetInterval: number | undefined;
32
37
  getResult(): Uint8Array<ArrayBuffer>;
@@ -1 +1 @@
1
- {"version":3,"file":"jpeg.d.ts","sourceRoot":"","sources":["../../src/compression/jpeg.js"],"names":[],"mappings":"AAk3BA;IAGI,yBAAoC;IAMtC,sCAIC;CACF;wBAh4BuB,kBAAkB;AAwjB1C;IAEI;;;;;;;;;;;aAAgB;IAChB;;;;;aAAiB;IAEjB,0BAA4B;IAC5B,uBAAyB;IACzB,uBAAyB;IAI3B,oBAEC;IADC,0BAAgB;IAGlB,uBA0PC;IA5CO,kCAAiC;IA8CzC,qCA4CC;CACF"}
1
+ {"version":3,"file":"jpeg.d.ts","sourceRoot":"","sources":["../../src/compression/jpeg.js"],"names":[],"mappings":"AAg6BA;IAGI,yBAAoC;IAMtC,sCAIC;CACF;0BA13Ba,CAAC,MAAM,GAAC,WAAW,CAAC,EAAE;mBACtB;IAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC;wBArD5B,kBAAkB;AAqmB1C;IAEI;;;;;;;;;;;aAAgB;IAChB;;;;;aAAiB;IAEjB,0BAA4B;IAC5B,uBAAyB;IACzB,uBAAyB;IACzB,cAAgB;IAGlB,oBAEC;IAED,uBA2PC;IA5CO,kCAAiC;IA8CzC,qCA4CC;CACF"}
@@ -45,22 +45,38 @@ const dctCos6 = 1567; // cos(6*pi/16)
45
45
  const dctSin6 = 3784; // sin(6*pi/16)
46
46
  const dctSqrt2 = 5793; // sqrt(2)
47
47
  const dctSqrt1d2 = 2896; // sqrt(2) / 2
48
+ /** @typedef {(number|HuffmanNode)[]} HuffmanNode */
49
+ /** @typedef {{children: HuffmanNode, index: number}} Code */
50
+ /**
51
+ * @param {Uint8Array<ArrayBuffer>} codeLengths
52
+ * @param {Uint8Array<ArrayBuffer>} values
53
+ * @returns {HuffmanNode}
54
+ */
48
55
  function buildHuffmanTable(codeLengths, values) {
49
56
  let k = 0;
57
+ /** @type {Array<Code>} */
50
58
  const code = [];
51
59
  let length = 16;
52
60
  while (length > 0 && !codeLengths[length - 1]) {
53
61
  --length;
54
62
  }
55
63
  code.push({ children: [], index: 0 });
64
+ /** @type {Code|undefined} */
56
65
  let p = code[0];
66
+ /** @type {Code|undefined} */
57
67
  let q;
58
68
  for (let i = 0; i < length; i++) {
59
69
  for (let j = 0; j < codeLengths[i]; j++) {
60
70
  p = code.pop();
71
+ if (!p) {
72
+ throw new Error('buildHuffmanTable: codeLength mismatch');
73
+ }
61
74
  p.children[p.index] = values[k];
62
75
  while (p.index > 0) {
63
76
  p = code.pop();
77
+ if (!p) {
78
+ throw new Error('buildHuffmanTable: codeLength mismatch');
79
+ }
64
80
  }
65
81
  p.index++;
66
82
  code.push(p);
@@ -131,6 +147,9 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
131
147
  }
132
148
  function receiveAndExtend(length) {
133
149
  const n = receive(length);
150
+ if (n === undefined) {
151
+ return undefined;
152
+ }
134
153
  if (n >= 1 << (length - 1)) {
135
154
  return n;
136
155
  }
@@ -144,6 +163,9 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
144
163
  let k = 1;
145
164
  while (k < 64) {
146
165
  const rs = decodeHuffman(component.huffmanTableAC);
166
+ if (rs === null) {
167
+ throw new Error('Unexpected end of data in AC coefficient decoding');
168
+ }
147
169
  const s = rs & 15;
148
170
  const r = rs >> 4;
149
171
  if (s === 0) {
@@ -162,7 +184,11 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
162
184
  }
163
185
  function decodeDCFirst(component, zz) {
164
186
  const t = decodeHuffman(component.huffmanTableDC);
165
- const diff = t === 0 ? 0 : (receiveAndExtend(t) << successive);
187
+ const value = receiveAndExtend(t);
188
+ if (value === undefined) {
189
+ throw new Error('Unexpected end of data in DC coefficient decoding');
190
+ }
191
+ const diff = t === 0 ? 0 : (value << successive);
166
192
  component.pred += diff;
167
193
  zz[0] = component.pred;
168
194
  }
@@ -179,11 +205,18 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
179
205
  const e = spectralEnd;
180
206
  while (k <= e) {
181
207
  const rs = decodeHuffman(component.huffmanTableAC);
208
+ if (rs === null) {
209
+ throw new Error('Unexpected end of data in AC coefficient decoding');
210
+ }
182
211
  const s = rs & 15;
183
212
  const r = rs >> 4;
184
213
  if (s === 0) {
185
214
  if (r < 15) {
186
- eobrun = receive(r) + (1 << r) - 1;
215
+ const value = receive(r);
216
+ if (value === undefined) {
217
+ throw new Error('Unexpected end of data in AC coefficient decoding');
218
+ }
219
+ eobrun = value + (1 << r) - 1;
187
220
  break;
188
221
  }
189
222
  k += 16;
@@ -191,7 +224,11 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
191
224
  else {
192
225
  k += r;
193
226
  const z = dctZigZag[k];
194
- zz[z] = receiveAndExtend(s) * (1 << successive);
227
+ const value = receiveAndExtend(s);
228
+ if (value === undefined) {
229
+ throw new Error('Unexpected end of data in AC coefficient decoding');
230
+ }
231
+ zz[z] = value * (1 << successive);
195
232
  k++;
196
233
  }
197
234
  }
@@ -208,11 +245,18 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
208
245
  switch (successiveACState) {
209
246
  case 0: { // initial state
210
247
  const rs = decodeHuffman(component.huffmanTableAC);
248
+ if (rs === null) {
249
+ throw new Error('Unexpected end of data in AC coefficient decoding');
250
+ }
211
251
  const s = rs & 15;
212
252
  r = rs >> 4;
213
253
  if (s === 0) {
214
254
  if (r < 15) {
215
- eobrun = receive(r) + (1 << r);
255
+ const value = receive(r);
256
+ if (value === undefined) {
257
+ throw new Error('Unexpected end of data in AC coefficient decoding');
258
+ }
259
+ eobrun = value + (1 << r);
216
260
  successiveACState = 4;
217
261
  }
218
262
  else {
@@ -547,7 +591,7 @@ class JpegStreamReader {
547
591
  this.quantizationTables = [];
548
592
  this.huffmanTablesAC = [];
549
593
  this.huffmanTablesDC = [];
550
- this.resetFrames();
594
+ this.frames = [];
551
595
  }
552
596
  resetFrames() {
553
597
  this.frames = [];
@@ -699,6 +743,7 @@ class JpegStreamReader {
699
743
  scanLines: readUint16(),
700
744
  samplesPerLine: readUint16(),
701
745
  components: {},
746
+ /** @type {any[]} */
702
747
  componentsOrder: [],
703
748
  };
704
749
  const componentsCount = data[offset++];
@@ -122,6 +122,6 @@ function decompress(input) {
122
122
  }
123
123
  export default class LZWDecoder extends BaseDecoder {
124
124
  decodeBlock(buffer) {
125
- return decompress(buffer, false).buffer;
125
+ return decompress(buffer).buffer;
126
126
  }
127
127
  }
@@ -5,7 +5,7 @@
5
5
  * formats like WebP when supported.
6
6
  */
7
7
  export default class WebImageDecoder extends BaseDecoder {
8
- decodeBlock(buffer: any): Promise<any>;
8
+ decodeBlock(buffer: any): Promise<ArrayBuffer>;
9
9
  }
10
10
  import BaseDecoder from './basedecoder.js';
11
11
  //# sourceMappingURL=webimage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webimage.d.ts","sourceRoot":"","sources":["../../src/compression/webimage.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IAUE,uCAoCC;CACF;wBAvDuB,kBAAkB"}
1
+ {"version":3,"file":"webimage.d.ts","sourceRoot":"","sources":["../../src/compression/webimage.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IAUE,+CAoCC;CACF;wBAvDuB,kBAAkB"}
@@ -29,7 +29,7 @@ export default class WebImageDecoder extends BaseDecoder {
29
29
  }
30
30
  // Draw the image onto the canvas to extract the pixel data.
31
31
  // Note: createImageBitmap always returns RGBA data.
32
- const ctx = canvas.getContext('2d');
32
+ const ctx = /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d'));
33
33
  ctx.drawImage(imageBitmap, 0, 0);
34
34
  const imageData = ctx.getImageData(0, 0, imageBitmap.width, imageBitmap.height).data;
35
35
  // Return the correct channels to the caller
@@ -1 +1 @@
1
- {"version":3,"file":"dataslice.d.ts","sourceRoot":"","sources":["../src/dataslice.js"],"names":[],"mappings":"AAAA;IACE,iFAKC;IAJC,yBAA0C;IAC1C,kBAA+B;IAC/B,mBAAiC;IACjC,cAAuB;IAGzB,uBAEC;IAED,oBAEC;IAED,wBAEC;IAED,mBAEC;IAED,kBAEC;IAED,0CAEC;IAED,+BAIC;IAED,8BAIC;IAED,gCAIC;IAED,+BAIC;IAED,gCAIC;IAED,+BAIC;IAED,iCAIC;IAED,iCAIC;IAED,gCAuBC;IAGD,+BAyBC;IAED,gCAKC;CACF"}
1
+ {"version":3,"file":"dataslice.d.ts","sourceRoot":"","sources":["../src/dataslice.js"],"names":[],"mappings":"AAAA;IACE,iFAKC;IAJC,yBAA0C;IAC1C,kBAA+B;IAC/B,mBAAiC;IACjC,cAAuB;IAGzB,uBAEC;IAED,oBAEC;IAED,wBAEC;IAED,mBAEC;IAED,kBAEC;IAED,0CAEC;IAED,+BAEC;IAED,8BAEC;IAED,gCAIC;IAED,+BAIC;IAED,gCAIC;IAED,+BAIC;IAED,iCAIC;IAED,iCAIC;IAED,gCAuBC;IAGD,+BAyBC;IAED,gCAKC;CACF"}
@@ -24,10 +24,10 @@ export default class DataSlice {
24
24
  return this.sliceOffset <= offset && this.sliceTop >= offset + length;
25
25
  }
26
26
  readUint8(offset) {
27
- return this._dataView.getUint8(offset - this._sliceOffset, this._littleEndian);
27
+ return this._dataView.getUint8(offset - this._sliceOffset);
28
28
  }
29
29
  readInt8(offset) {
30
- return this._dataView.getInt8(offset - this._sliceOffset, this._littleEndian);
30
+ return this._dataView.getInt8(offset - this._sliceOffset);
31
31
  }
32
32
  readUint16(offset) {
33
33
  return this._dataView.getUint16(offset - this._sliceOffset, this._littleEndian);
@@ -4,8 +4,8 @@ export default class DataView64 {
4
4
  get buffer(): any;
5
5
  getUint64(offset: any, littleEndian: any): number;
6
6
  getInt64(offset: any, littleEndian: any): number;
7
- getUint8(offset: any, littleEndian: any): number;
8
- getInt8(offset: any, littleEndian: any): number;
7
+ getUint8(offset: any): number;
8
+ getInt8(offset: any): number;
9
9
  getUint16(offset: any, littleEndian: any): number;
10
10
  getInt16(offset: any, littleEndian: any): number;
11
11
  getUint32(offset: any, littleEndian: any): number;
@@ -1 +1 @@
1
- {"version":3,"file":"dataview64.d.ts","sourceRoot":"","sources":["../src/dataview64.js"],"names":[],"mappings":"AAEA;IACE,8BAEC;IADC,yBAA0C;IAG5C,kBAEC;IAED,kDAuBC;IAGD,iDAsBC;IAED,iDAEC;IAED,gDAEC;IAED,kDAEC;IAED,iDAEC;IAED,kDAEC;IAED,iDAEC;IAED,mDAEC;IAED,mDAEC;IAED,mDAEC;CACF"}
1
+ {"version":3,"file":"dataview64.d.ts","sourceRoot":"","sources":["../src/dataview64.js"],"names":[],"mappings":"AAEA;IACE,8BAEC;IADC,yBAA0C;IAG5C,kBAEC;IAED,kDAuBC;IAGD,iDAsBC;IAED,8BAEC;IAED,6BAEC;IAED,kDAEC;IAED,iDAEC;IAED,kDAEC;IAED,iDAEC;IAED,mDAEC;IAED,mDAEC;IAED,mDAEC;CACF"}
@@ -50,11 +50,11 @@ export default class DataView64 {
50
50
  }
51
51
  return value;
52
52
  }
53
- getUint8(offset, littleEndian) {
54
- return this._dataView.getUint8(offset, littleEndian);
53
+ getUint8(offset) {
54
+ return this._dataView.getUint8(offset);
55
55
  }
56
- getInt8(offset, littleEndian) {
57
- return this._dataView.getInt8(offset, littleEndian);
56
+ getInt8(offset) {
57
+ return this._dataView.getInt8(offset);
58
58
  }
59
59
  getUint16(offset, littleEndian) {
60
60
  return this._dataView.getUint16(offset, littleEndian);