pdf-parser.js 5.3.1 → 5.3.3

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.
@@ -407,7 +407,9 @@ function decodeRefinementRegion(width, height, params, mq, contexts) {
407
407
  }
408
408
  //#endregion
409
409
  exports.GENERIC_CONTEXT_BITS = GENERIC_CONTEXT_BITS;
410
+ exports.GENERIC_TEMPLATES = GENERIC_TEMPLATES;
410
411
  exports.NOMINAL_REFINEMENT_AT = NOMINAL_REFINEMENT_AT;
411
412
  exports.REFINEMENT_CONTEXT_BITS = REFINEMENT_CONTEXT_BITS;
413
+ exports.REFINEMENT_TEMPLATES = REFINEMENT_TEMPLATES;
412
414
  exports.decodeGenericRegion = decodeGenericRegion;
413
415
  exports.decodeRefinementRegion = decodeRefinementRegion;
@@ -5,6 +5,15 @@ interface Jbig2AtPixel {
5
5
  readonly x: number;
6
6
  readonly y: number;
7
7
  }
8
+ type TemplatePosition = {
9
+ readonly kind: "fixed";
10
+ readonly dx: number;
11
+ readonly dy: number;
12
+ } | {
13
+ readonly kind: "at";
14
+ readonly index: number;
15
+ };
16
+ declare const GENERIC_TEMPLATES: readonly (readonly TemplatePosition[])[];
8
17
  declare const GENERIC_CONTEXT_BITS: readonly number[];
9
18
  interface GenericRegionParams {
10
19
  readonly template: number;
@@ -12,6 +21,22 @@ interface GenericRegionParams {
12
21
  readonly at: readonly Jbig2AtPixel[];
13
22
  }
14
23
  declare function decodeGenericRegion(width: number, height: number, params: GenericRegionParams, mq: MqDecoder, contexts: ArithContexts): Jbig2Bitmap;
24
+ type RefinementPosition = {
25
+ readonly source: "destination";
26
+ readonly dx: number;
27
+ readonly dy: number;
28
+ } | {
29
+ readonly source: "reference";
30
+ readonly dx: number;
31
+ readonly dy: number;
32
+ } | {
33
+ readonly source: "destination-at";
34
+ readonly index: number;
35
+ } | {
36
+ readonly source: "reference-at";
37
+ readonly index: number;
38
+ };
39
+ declare const REFINEMENT_TEMPLATES: readonly (readonly RefinementPosition[])[];
15
40
  declare const REFINEMENT_CONTEXT_BITS: readonly number[];
16
41
  declare const NOMINAL_REFINEMENT_AT: readonly Jbig2AtPixel[];
17
42
  interface RefinementRegionParams {
@@ -24,4 +49,4 @@ interface RefinementRegionParams {
24
49
  }
25
50
  declare function decodeRefinementRegion(width: number, height: number, params: RefinementRegionParams, mq: MqDecoder, contexts: ArithContexts): Jbig2Bitmap;
26
51
  //#endregion
27
- export { GENERIC_CONTEXT_BITS, GenericRegionParams, Jbig2AtPixel, NOMINAL_REFINEMENT_AT, REFINEMENT_CONTEXT_BITS, RefinementRegionParams, decodeGenericRegion, decodeRefinementRegion };
52
+ export { GENERIC_CONTEXT_BITS, GENERIC_TEMPLATES, GenericRegionParams, Jbig2AtPixel, NOMINAL_REFINEMENT_AT, REFINEMENT_CONTEXT_BITS, REFINEMENT_TEMPLATES, RefinementRegionParams, decodeGenericRegion, decodeRefinementRegion };
@@ -5,6 +5,15 @@ interface Jbig2AtPixel {
5
5
  readonly x: number;
6
6
  readonly y: number;
7
7
  }
8
+ type TemplatePosition = {
9
+ readonly kind: "fixed";
10
+ readonly dx: number;
11
+ readonly dy: number;
12
+ } | {
13
+ readonly kind: "at";
14
+ readonly index: number;
15
+ };
16
+ declare const GENERIC_TEMPLATES: readonly (readonly TemplatePosition[])[];
8
17
  declare const GENERIC_CONTEXT_BITS: readonly number[];
9
18
  interface GenericRegionParams {
10
19
  readonly template: number;
@@ -12,6 +21,22 @@ interface GenericRegionParams {
12
21
  readonly at: readonly Jbig2AtPixel[];
13
22
  }
14
23
  declare function decodeGenericRegion(width: number, height: number, params: GenericRegionParams, mq: MqDecoder, contexts: ArithContexts): Jbig2Bitmap;
24
+ type RefinementPosition = {
25
+ readonly source: "destination";
26
+ readonly dx: number;
27
+ readonly dy: number;
28
+ } | {
29
+ readonly source: "reference";
30
+ readonly dx: number;
31
+ readonly dy: number;
32
+ } | {
33
+ readonly source: "destination-at";
34
+ readonly index: number;
35
+ } | {
36
+ readonly source: "reference-at";
37
+ readonly index: number;
38
+ };
39
+ declare const REFINEMENT_TEMPLATES: readonly (readonly RefinementPosition[])[];
15
40
  declare const REFINEMENT_CONTEXT_BITS: readonly number[];
16
41
  declare const NOMINAL_REFINEMENT_AT: readonly Jbig2AtPixel[];
17
42
  interface RefinementRegionParams {
@@ -24,4 +49,4 @@ interface RefinementRegionParams {
24
49
  }
25
50
  declare function decodeRefinementRegion(width: number, height: number, params: RefinementRegionParams, mq: MqDecoder, contexts: ArithContexts): Jbig2Bitmap;
26
51
  //#endregion
27
- export { GENERIC_CONTEXT_BITS, GenericRegionParams, Jbig2AtPixel, NOMINAL_REFINEMENT_AT, REFINEMENT_CONTEXT_BITS, RefinementRegionParams, decodeGenericRegion, decodeRefinementRegion };
52
+ export { GENERIC_CONTEXT_BITS, GENERIC_TEMPLATES, GenericRegionParams, Jbig2AtPixel, NOMINAL_REFINEMENT_AT, REFINEMENT_CONTEXT_BITS, REFINEMENT_TEMPLATES, RefinementRegionParams, decodeGenericRegion, decodeRefinementRegion };
@@ -405,4 +405,4 @@ function decodeRefinementRegion(width, height, params, mq, contexts) {
405
405
  return bitmap;
406
406
  }
407
407
  //#endregion
408
- export { GENERIC_CONTEXT_BITS, NOMINAL_REFINEMENT_AT, REFINEMENT_CONTEXT_BITS, decodeGenericRegion, decodeRefinementRegion };
408
+ export { GENERIC_CONTEXT_BITS, GENERIC_TEMPLATES, NOMINAL_REFINEMENT_AT, REFINEMENT_CONTEXT_BITS, REFINEMENT_TEMPLATES, decodeGenericRegion, decodeRefinementRegion };
@@ -227,8 +227,8 @@ function inverseReversibleComponentTransform(planes) {
227
227
  const u = planes[1];
228
228
  const v = planes[2];
229
229
  if (y === void 0 || u === void 0 || v === void 0) return;
230
- for (let i = 0; i < y.length; i++) {
231
- const green = (y[i] ?? 0) - Math.floor(((u[i] ?? 0) + (v[i] ?? 0)) / RCT_GREEN_RECOVERY_DIVISOR);
230
+ for (const [i, luma] of y.entries()) {
231
+ const green = luma - Math.floor(((u[i] ?? 0) + (v[i] ?? 0)) / RCT_GREEN_RECOVERY_DIVISOR);
232
232
  const red = (v[i] ?? 0) + green;
233
233
  const blue = (u[i] ?? 0) + green;
234
234
  y[i] = red;
@@ -245,8 +245,7 @@ function inverseIrreversibleComponentTransform(planes) {
245
245
  const cb = planes[1];
246
246
  const cr = planes[2];
247
247
  if (y === void 0 || cb === void 0 || cr === void 0) return;
248
- for (let i = 0; i < y.length; i++) {
249
- const luma = y[i] ?? 0;
248
+ for (const [i, luma] of y.entries()) {
250
249
  const blueDiff = cb[i] ?? 0;
251
250
  const redDiff = cr[i] ?? 0;
252
251
  y[i] = luma + ICT_RED_FROM_CR * redDiff;
@@ -226,8 +226,8 @@ function inverseReversibleComponentTransform(planes) {
226
226
  const u = planes[1];
227
227
  const v = planes[2];
228
228
  if (y === void 0 || u === void 0 || v === void 0) return;
229
- for (let i = 0; i < y.length; i++) {
230
- const green = (y[i] ?? 0) - Math.floor(((u[i] ?? 0) + (v[i] ?? 0)) / RCT_GREEN_RECOVERY_DIVISOR);
229
+ for (const [i, luma] of y.entries()) {
230
+ const green = luma - Math.floor(((u[i] ?? 0) + (v[i] ?? 0)) / RCT_GREEN_RECOVERY_DIVISOR);
231
231
  const red = (v[i] ?? 0) + green;
232
232
  const blue = (u[i] ?? 0) + green;
233
233
  y[i] = red;
@@ -244,8 +244,7 @@ function inverseIrreversibleComponentTransform(planes) {
244
244
  const cb = planes[1];
245
245
  const cr = planes[2];
246
246
  if (y === void 0 || cb === void 0 || cr === void 0) return;
247
- for (let i = 0; i < y.length; i++) {
248
- const luma = y[i] ?? 0;
247
+ for (const [i, luma] of y.entries()) {
249
248
  const blueDiff = cb[i] ?? 0;
250
249
  const redDiff = cr[i] ?? 0;
251
250
  y[i] = luma + ICT_RED_FROM_CR * redDiff;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdf-parser.js",
3
- "version": "5.3.1",
3
+ "version": "5.3.3",
4
4
  "description": "Hand-written, dependency-minimal PDF codec: parses arbitrary real-world PDFs and generates new ones, built on its own codec-owned LayoutDocument item model and Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {