pdf-parser.js 4.8.10 → 4.8.12

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 (49) hide show
  1. package/dist/annotations.cjs +16 -16
  2. package/dist/annotations.js +16 -16
  3. package/dist/cff-probe.cjs +1 -1
  4. package/dist/cff-probe.js +1 -1
  5. package/dist/crypto/rc4.cjs +4 -5
  6. package/dist/crypto/rc4.js +4 -5
  7. package/dist/crypto/sha2.cjs +10 -10
  8. package/dist/crypto/sha2.js +10 -10
  9. package/dist/encrypt-write.cjs +0 -1
  10. package/dist/encrypt-write.js +0 -1
  11. package/dist/font-style.cjs +9 -11
  12. package/dist/font-style.js +9 -11
  13. package/dist/glyf-contours-OSdG6Edr.d.ts +13 -0
  14. package/dist/glyf-contours-zRQbj-Yp.d.cts +13 -0
  15. package/dist/glyf-contours.d.cts +1 -12
  16. package/dist/glyf-contours.d.ts +1 -12
  17. package/dist/glyf-nXC-IDRW.d.cts +33 -0
  18. package/dist/glyf-vMGtP1pb.d.ts +33 -0
  19. package/dist/glyf.d.cts +1 -32
  20. package/dist/glyf.d.ts +1 -32
  21. package/dist/image/jp2-boxes.cjs +12 -15
  22. package/dist/image/jp2-boxes.js +12 -15
  23. package/dist/image/jpeg2000-codestream.cjs +13 -12
  24. package/dist/image/jpeg2000-codestream.d.cts +11 -1
  25. package/dist/image/jpeg2000-codestream.d.ts +11 -1
  26. package/dist/image/jpeg2000-codestream.js +13 -13
  27. package/dist/image/jpeg2000-dwt.cjs +23 -17
  28. package/dist/image/jpeg2000-dwt.d.cts +13 -1
  29. package/dist/image/jpeg2000-dwt.d.ts +13 -1
  30. package/dist/image/jpeg2000-dwt.js +18 -18
  31. package/dist/math-content-write.cjs +3 -6
  32. package/dist/math-content-write.js +3 -6
  33. package/dist/math-stretch.cjs +0 -1
  34. package/dist/math-stretch.js +0 -1
  35. package/dist/navigation.cjs +0 -8
  36. package/dist/navigation.js +0 -8
  37. package/dist/raster.cjs +34 -41
  38. package/dist/raster.d.cts +21 -1
  39. package/dist/raster.d.ts +21 -1
  40. package/dist/raster.js +32 -42
  41. package/dist/read.cjs +1 -1
  42. package/dist/read.js +1 -1
  43. package/dist/serialize.cjs +1 -5
  44. package/dist/serialize.js +1 -5
  45. package/dist/write.cjs +1 -5
  46. package/dist/write.js +2 -6
  47. package/dist/xmp.cjs +3 -3
  48. package/dist/xmp.js +3 -3
  49. package/package.json +1 -1
@@ -5,21 +5,21 @@ const require_pdf_text = require("./pdf-text.cjs");
5
5
  const require_serialize = require("./serialize.cjs");
6
6
  const require_matrix = require("./matrix.cjs");
7
7
  //#region src/annotations.ts
8
- const SEMANTIC_SUBTYPES = /* @__PURE__ */ new Set([
9
- "Text",
10
- "FreeText",
11
- "Highlight",
12
- "Underline",
13
- "StrikeOut",
14
- "Squiggly"
15
- ]);
16
- const OWNED_ELSEWHERE_SUBTYPES = /* @__PURE__ */ new Set([
17
- "Link",
18
- "FileAttachment",
19
- "Widget",
20
- "Popup"
21
- ]);
22
8
  function readPageAnnotations(page, pageMatrix, resolver, sink) {
9
+ const semanticSubtypes = /* @__PURE__ */ new Set([
10
+ "Text",
11
+ "FreeText",
12
+ "Highlight",
13
+ "Underline",
14
+ "StrikeOut",
15
+ "Squiggly"
16
+ ]);
17
+ const ownedElsewhereSubtypes = /* @__PURE__ */ new Set([
18
+ "Link",
19
+ "FileAttachment",
20
+ "Widget",
21
+ "Popup"
22
+ ]);
23
23
  const annotsArr = require_objects.asArray(require_objects.dictGet(page, "Annots"));
24
24
  if (annotsArr === void 0) return [];
25
25
  const annotations = [];
@@ -27,7 +27,7 @@ function readPageAnnotations(page, pageMatrix, resolver, sink) {
27
27
  const annot = resolver.resolveDict(annotRef);
28
28
  if (annot === void 0) continue;
29
29
  const subtype = require_objects.asName(require_objects.dictGet(annot, "Subtype"));
30
- if (subtype === void 0 || OWNED_ELSEWHERE_SUBTYPES.has(subtype)) continue;
30
+ if (subtype === void 0 || ownedElsewhereSubtypes.has(subtype)) continue;
31
31
  if (subtype === "Text" && annotString(annot, "T") === "documents.js:notes") continue;
32
32
  const rectArr = require_objects.asArray(require_objects.dictGet(annot, "Rect"));
33
33
  if (rectArr === void 0) {
@@ -62,7 +62,7 @@ function readPageAnnotations(page, pageMatrix, resolver, sink) {
62
62
  ...contents !== void 0 ? { contents } : {},
63
63
  ...author !== void 0 ? { author } : {},
64
64
  ...modifiedIso !== void 0 ? { modifiedIso } : {},
65
- ...SEMANTIC_SUBTYPES.has(subtype) ? markupFields(annot, pageMatrix) : { source: {
65
+ ...semanticSubtypes.has(subtype) ? markupFields(annot, pageMatrix) : { source: {
66
66
  format: "pdf",
67
67
  xml: require_serialize.serializeObjectToText(annot)
68
68
  } }
@@ -4,21 +4,21 @@ import { decodePdfString, parsePdfDate } from "./pdf-text.js";
4
4
  import { serializeObjectToText } from "./serialize.js";
5
5
  import { applyMatrix } from "./matrix.js";
6
6
  //#region src/annotations.ts
7
- const SEMANTIC_SUBTYPES = /* @__PURE__ */ new Set([
8
- "Text",
9
- "FreeText",
10
- "Highlight",
11
- "Underline",
12
- "StrikeOut",
13
- "Squiggly"
14
- ]);
15
- const OWNED_ELSEWHERE_SUBTYPES = /* @__PURE__ */ new Set([
16
- "Link",
17
- "FileAttachment",
18
- "Widget",
19
- "Popup"
20
- ]);
21
7
  function readPageAnnotations(page, pageMatrix, resolver, sink) {
8
+ const semanticSubtypes = /* @__PURE__ */ new Set([
9
+ "Text",
10
+ "FreeText",
11
+ "Highlight",
12
+ "Underline",
13
+ "StrikeOut",
14
+ "Squiggly"
15
+ ]);
16
+ const ownedElsewhereSubtypes = /* @__PURE__ */ new Set([
17
+ "Link",
18
+ "FileAttachment",
19
+ "Widget",
20
+ "Popup"
21
+ ]);
22
22
  const annotsArr = asArray(dictGet(page, "Annots"));
23
23
  if (annotsArr === void 0) return [];
24
24
  const annotations = [];
@@ -26,7 +26,7 @@ function readPageAnnotations(page, pageMatrix, resolver, sink) {
26
26
  const annot = resolver.resolveDict(annotRef);
27
27
  if (annot === void 0) continue;
28
28
  const subtype = asName(dictGet(annot, "Subtype"));
29
- if (subtype === void 0 || OWNED_ELSEWHERE_SUBTYPES.has(subtype)) continue;
29
+ if (subtype === void 0 || ownedElsewhereSubtypes.has(subtype)) continue;
30
30
  if (subtype === "Text" && annotString(annot, "T") === "documents.js:notes") continue;
31
31
  const rectArr = asArray(dictGet(annot, "Rect"));
32
32
  if (rectArr === void 0) {
@@ -61,7 +61,7 @@ function readPageAnnotations(page, pageMatrix, resolver, sink) {
61
61
  ...contents !== void 0 ? { contents } : {},
62
62
  ...author !== void 0 ? { author } : {},
63
63
  ...modifiedIso !== void 0 ? { modifiedIso } : {},
64
- ...SEMANTIC_SUBTYPES.has(subtype) ? markupFields(annot, pageMatrix) : { source: {
64
+ ...semanticSubtypes.has(subtype) ? markupFields(annot, pageMatrix) : { source: {
65
65
  format: "pdf",
66
66
  xml: serializeObjectToText(annot)
67
67
  } }
@@ -17,7 +17,7 @@ function probeCff(bytes) {
17
17
  const headerSize = require_sfnt.u8(bytes, CFF_HEADER_SIZE_OFFSET);
18
18
  if (majorVersion !== CFF_MAJOR_VERSION || headerSize < CFF_HEADER_SIZE) return;
19
19
  const nameIndex = require_cff.readCffIndex(bytes, headerSize);
20
- if (nameIndex === void 0 || nameIndex.count === 0) return;
20
+ if (nameIndex === void 0) return;
21
21
  const nameBytes = nameIndex.entry(0);
22
22
  if (nameBytes === void 0) return;
23
23
  const topDictBytes = require_cff.readCffIndex(bytes, nameIndex.endOffset)?.entry(0);
package/dist/cff-probe.js CHANGED
@@ -16,7 +16,7 @@ function probeCff(bytes) {
16
16
  const headerSize = u8(bytes, CFF_HEADER_SIZE_OFFSET);
17
17
  if (majorVersion !== CFF_MAJOR_VERSION || headerSize < CFF_HEADER_SIZE) return;
18
18
  const nameIndex = readCffIndex(bytes, headerSize);
19
- if (nameIndex === void 0 || nameIndex.count === 0) return;
19
+ if (nameIndex === void 0) return;
20
20
  const nameBytes = nameIndex.entry(0);
21
21
  if (nameBytes === void 0) return;
22
22
  const topDictBytes = readCffIndex(bytes, nameIndex.endOffset)?.entry(0);
@@ -2,8 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/crypto/rc4.ts
3
3
  const STATE_SIZE = 256;
4
4
  function rc4(key, data) {
5
- const state = new Uint8Array(STATE_SIZE);
6
- for (let i = 0; i < STATE_SIZE; i++) state[i] = i;
5
+ const state = Uint8Array.from({ length: STATE_SIZE }, (_, i) => i);
7
6
  if (key.length === 0) return Uint8Array.from(data);
8
7
  let j = 0;
9
8
  for (let i = 0; i < STATE_SIZE; i++) {
@@ -15,14 +14,14 @@ function rc4(key, data) {
15
14
  const out = new Uint8Array(data.length);
16
15
  let x = 0;
17
16
  let y = 0;
18
- for (let n = 0; n < data.length; n++) {
17
+ data.forEach((byte, n) => {
19
18
  x = x + 1 & 255;
20
19
  y = y + state[x] & 255;
21
20
  const swap = state[x];
22
21
  state[x] = state[y];
23
22
  state[y] = swap;
24
- out[n] = data[n] ^ state[state[x] + state[y] & 255];
25
- }
23
+ out[n] = byte ^ state[state[x] + state[y] & 255];
24
+ });
26
25
  return out;
27
26
  }
28
27
  //#endregion
@@ -1,8 +1,7 @@
1
1
  //#region src/crypto/rc4.ts
2
2
  const STATE_SIZE = 256;
3
3
  function rc4(key, data) {
4
- const state = new Uint8Array(STATE_SIZE);
5
- for (let i = 0; i < STATE_SIZE; i++) state[i] = i;
4
+ const state = Uint8Array.from({ length: STATE_SIZE }, (_, i) => i);
6
5
  if (key.length === 0) return Uint8Array.from(data);
7
6
  let j = 0;
8
7
  for (let i = 0; i < STATE_SIZE; i++) {
@@ -14,14 +13,14 @@ function rc4(key, data) {
14
13
  const out = new Uint8Array(data.length);
15
14
  let x = 0;
16
15
  let y = 0;
17
- for (let n = 0; n < data.length; n++) {
16
+ data.forEach((byte, n) => {
18
17
  x = x + 1 & 255;
19
18
  y = y + state[x] & 255;
20
19
  const swap = state[x];
21
20
  state[x] = state[y];
22
21
  state[y] = swap;
23
- out[n] = data[n] ^ state[state[x] + state[y] & 255];
24
- }
22
+ out[n] = byte ^ state[state[x] + state[y] & 255];
23
+ });
25
24
  return out;
26
25
  }
27
26
  //#endregion
@@ -118,7 +118,7 @@ function padBigEndian(bytes, blockBytes, lengthBytes) {
118
118
  padded.set(bytes);
119
119
  padded[bytes.length] = 128;
120
120
  let bitLength = bytes.length * 8;
121
- for (let i = 0; i < lengthBytes && bitLength > 0; i++) {
121
+ for (let i = 0; i < lengthBytes; i++) {
122
122
  padded[paddedLength - 1 - i] = bitLength % 256;
123
123
  bitLength = Math.floor(bitLength / 256);
124
124
  }
@@ -132,17 +132,18 @@ function sha256(bytes) {
132
132
  const state = Uint32Array.from(H256);
133
133
  const w = new Uint32Array(SHA256_ROUNDS);
134
134
  for (let offset = 0; offset < padded.length; offset += SHA256_BLOCK_BYTES) {
135
- for (let t = 0; t < WORDS_PER_BLOCK; t++) {
135
+ w.set(Array.from({ length: WORDS_PER_BLOCK }, (_, t) => {
136
136
  const at = offset + t * 4;
137
- w[t] = (padded[at] << 24 | padded[at + 1] << 16 | padded[at + 2] << 8 | padded[at + 3]) >>> 0;
138
- }
139
- for (let t = WORDS_PER_BLOCK; t < SHA256_ROUNDS; t++) {
137
+ return (padded[at] << 24 | padded[at + 1] << 16 | padded[at + 2] << 8 | padded[at + 3]) >>> 0;
138
+ }));
139
+ Array.from({ length: SHA256_ROUNDS }, (_, t) => {
140
+ if (t < WORDS_PER_BLOCK) return;
140
141
  const x = w[t - 15];
141
142
  const y = w[t - 2];
142
143
  const s0 = rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3;
143
144
  const s1 = rotr32(y, 17) ^ rotr32(y, 19) ^ y >>> 10;
144
145
  w[t] = w[t - 16] + s0 + w[t - 7] + s1 >>> 0;
145
- }
146
+ });
146
147
  let a = state[0];
147
148
  let b = state[1];
148
149
  let c = state[2];
@@ -175,16 +176,15 @@ function sha256(bytes) {
175
176
  g,
176
177
  h
177
178
  ];
178
- for (let i = 0; i < state.length; i++) state[i] = state[i] + next[i] >>> 0;
179
+ state.set(state.map((value, i) => value + next[i] >>> 0));
179
180
  }
180
181
  const digest = new Uint8Array(state.length * 4);
181
- for (let i = 0; i < state.length; i++) {
182
- const word = state[i];
182
+ state.forEach((word, i) => {
183
183
  digest[i * 4] = word >>> 24 & 255;
184
184
  digest[i * 4 + 1] = word >>> 16 & 255;
185
185
  digest[i * 4 + 2] = word >>> 8 & 255;
186
186
  digest[i * 4 + 3] = word & 255;
187
- }
187
+ });
188
188
  return digest;
189
189
  }
190
190
  function readWord32(bytes, offset) {
@@ -117,7 +117,7 @@ function padBigEndian(bytes, blockBytes, lengthBytes) {
117
117
  padded.set(bytes);
118
118
  padded[bytes.length] = 128;
119
119
  let bitLength = bytes.length * 8;
120
- for (let i = 0; i < lengthBytes && bitLength > 0; i++) {
120
+ for (let i = 0; i < lengthBytes; i++) {
121
121
  padded[paddedLength - 1 - i] = bitLength % 256;
122
122
  bitLength = Math.floor(bitLength / 256);
123
123
  }
@@ -131,17 +131,18 @@ function sha256(bytes) {
131
131
  const state = Uint32Array.from(H256);
132
132
  const w = new Uint32Array(SHA256_ROUNDS);
133
133
  for (let offset = 0; offset < padded.length; offset += SHA256_BLOCK_BYTES) {
134
- for (let t = 0; t < WORDS_PER_BLOCK; t++) {
134
+ w.set(Array.from({ length: WORDS_PER_BLOCK }, (_, t) => {
135
135
  const at = offset + t * 4;
136
- w[t] = (padded[at] << 24 | padded[at + 1] << 16 | padded[at + 2] << 8 | padded[at + 3]) >>> 0;
137
- }
138
- for (let t = WORDS_PER_BLOCK; t < SHA256_ROUNDS; t++) {
136
+ return (padded[at] << 24 | padded[at + 1] << 16 | padded[at + 2] << 8 | padded[at + 3]) >>> 0;
137
+ }));
138
+ Array.from({ length: SHA256_ROUNDS }, (_, t) => {
139
+ if (t < WORDS_PER_BLOCK) return;
139
140
  const x = w[t - 15];
140
141
  const y = w[t - 2];
141
142
  const s0 = rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3;
142
143
  const s1 = rotr32(y, 17) ^ rotr32(y, 19) ^ y >>> 10;
143
144
  w[t] = w[t - 16] + s0 + w[t - 7] + s1 >>> 0;
144
- }
145
+ });
145
146
  let a = state[0];
146
147
  let b = state[1];
147
148
  let c = state[2];
@@ -174,16 +175,15 @@ function sha256(bytes) {
174
175
  g,
175
176
  h
176
177
  ];
177
- for (let i = 0; i < state.length; i++) state[i] = state[i] + next[i] >>> 0;
178
+ state.set(state.map((value, i) => value + next[i] >>> 0));
178
179
  }
179
180
  const digest = new Uint8Array(state.length * 4);
180
- for (let i = 0; i < state.length; i++) {
181
- const word = state[i];
181
+ state.forEach((word, i) => {
182
182
  digest[i * 4] = word >>> 24 & 255;
183
183
  digest[i * 4 + 1] = word >>> 16 & 255;
184
184
  digest[i * 4 + 2] = word >>> 8 & 255;
185
185
  digest[i * 4 + 3] = word & 255;
186
- }
186
+ });
187
187
  return digest;
188
188
  }
189
189
  function readWord32(bytes, offset) {
@@ -94,7 +94,6 @@ function encryptAes(key, data) {
94
94
  return require_bytes_writer.concatBytes([iv, require_crypto_aes.aesCbcEncrypt(key, iv, padded)]);
95
95
  }
96
96
  function applyEncryptMethod(method, fileKey, perObjectKeys, bytes, num, gen) {
97
- if (method === "identity") return bytes;
98
97
  const key = perObjectKeys ? require_encrypt.objectKey(fileKey, num, gen, method) : fileKey;
99
98
  return method === "rc4" ? require_crypto_rc4.rc4(key, bytes) : encryptAes(key, bytes);
100
99
  }
@@ -93,7 +93,6 @@ function encryptAes(key, data) {
93
93
  return concatBytes([iv, aesCbcEncrypt(key, iv, padded)]);
94
94
  }
95
95
  function applyEncryptMethod(method, fileKey, perObjectKeys, bytes, num, gen) {
96
- if (method === "identity") return bytes;
97
96
  const key = perObjectKeys ? objectKey(fileKey, num, gen, method) : fileKey;
98
97
  return method === "rc4" ? rc4(key, bytes) : encryptAes(key, bytes);
99
98
  }
@@ -1,16 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/font-style.ts
3
- const SUBSET_TAG_PATTERN = /^[A-Z]{6}\+/;
4
- const KNOWN_STYLE_SUFFIXES = [
5
- "BoldItalic",
6
- "BoldOblique",
7
- "Bold",
8
- "Italic",
9
- "Oblique",
10
- "Regular"
11
- ];
12
3
  function stripStyleSuffix(name) {
13
- for (const suffix of KNOWN_STYLE_SUFFIXES) {
4
+ for (const suffix of [
5
+ "BoldItalic",
6
+ "BoldOblique",
7
+ "Bold",
8
+ "Italic",
9
+ "Oblique",
10
+ "Regular"
11
+ ]) {
14
12
  const commaPattern = new RegExp(`,${suffix}$`, "i");
15
13
  const hyphenPattern = new RegExp(`-${suffix}$`, "i");
16
14
  if (commaPattern.test(name)) return name.replace(commaPattern, "");
@@ -19,7 +17,7 @@ function stripStyleSuffix(name) {
19
17
  return name;
20
18
  }
21
19
  function styleFromBaseFontName(baseFont, flags) {
22
- const withoutSubset = baseFont.replace(SUBSET_TAG_PATTERN, "");
20
+ const withoutSubset = baseFont.replace(/^[A-Z]{6}\+/, "");
23
21
  const lower = withoutSubset.toLowerCase();
24
22
  const nameBold = lower.includes("bold");
25
23
  const nameItalic = /italic|oblique/.test(lower);
@@ -1,15 +1,13 @@
1
1
  //#region src/font-style.ts
2
- const SUBSET_TAG_PATTERN = /^[A-Z]{6}\+/;
3
- const KNOWN_STYLE_SUFFIXES = [
4
- "BoldItalic",
5
- "BoldOblique",
6
- "Bold",
7
- "Italic",
8
- "Oblique",
9
- "Regular"
10
- ];
11
2
  function stripStyleSuffix(name) {
12
- for (const suffix of KNOWN_STYLE_SUFFIXES) {
3
+ for (const suffix of [
4
+ "BoldItalic",
5
+ "BoldOblique",
6
+ "Bold",
7
+ "Italic",
8
+ "Oblique",
9
+ "Regular"
10
+ ]) {
13
11
  const commaPattern = new RegExp(`,${suffix}$`, "i");
14
12
  const hyphenPattern = new RegExp(`-${suffix}$`, "i");
15
13
  if (commaPattern.test(name)) return name.replace(commaPattern, "");
@@ -18,7 +16,7 @@ function stripStyleSuffix(name) {
18
16
  return name;
19
17
  }
20
18
  function styleFromBaseFontName(baseFont, flags) {
21
- const withoutSubset = baseFont.replace(SUBSET_TAG_PATTERN, "");
19
+ const withoutSubset = baseFont.replace(/^[A-Z]{6}\+/, "");
22
20
  const lower = withoutSubset.toLowerCase();
23
21
  const nameBold = lower.includes("bold");
24
22
  const nameItalic = /italic|oblique/.test(lower);
@@ -0,0 +1,13 @@
1
+ import { r as GlyfTable } from "./glyf-vMGtP1pb.js";
2
+ //#region src/glyf-contours.d.ts
3
+ interface GlyphContourPoint {
4
+ readonly x: number;
5
+ readonly y: number;
6
+ readonly onCurve: boolean;
7
+ }
8
+ interface GlyphOutline {
9
+ readonly contours: readonly (readonly GlyphContourPoint[])[];
10
+ }
11
+ declare function decodeGlyphOutline(glyf: GlyfTable, glyphId: number): GlyphOutline | undefined;
12
+ //#endregion
13
+ export { GlyphOutline as n, decodeGlyphOutline as r, GlyphContourPoint as t };
@@ -0,0 +1,13 @@
1
+ import { r as GlyfTable } from "./glyf-nXC-IDRW.cjs";
2
+ //#region src/glyf-contours.d.ts
3
+ interface GlyphContourPoint {
4
+ readonly x: number;
5
+ readonly y: number;
6
+ readonly onCurve: boolean;
7
+ }
8
+ interface GlyphOutline {
9
+ readonly contours: readonly (readonly GlyphContourPoint[])[];
10
+ }
11
+ declare function decodeGlyphOutline(glyf: GlyfTable, glyphId: number): GlyphOutline | undefined;
12
+ //#endregion
13
+ export { GlyphOutline as n, decodeGlyphOutline as r, GlyphContourPoint as t };
@@ -1,13 +1,2 @@
1
- import { GlyfTable } from "./glyf.cjs";
2
- //#region src/glyf-contours.d.ts
3
- interface GlyphContourPoint {
4
- readonly x: number;
5
- readonly y: number;
6
- readonly onCurve: boolean;
7
- }
8
- interface GlyphOutline {
9
- readonly contours: readonly (readonly GlyphContourPoint[])[];
10
- }
11
- declare function decodeGlyphOutline(glyf: GlyfTable, glyphId: number): GlyphOutline | undefined;
12
- //#endregion
1
+ import { n as GlyphOutline, r as decodeGlyphOutline, t as GlyphContourPoint } from "./glyf-contours-zRQbj-Yp.cjs";
13
2
  export { GlyphContourPoint, GlyphOutline, decodeGlyphOutline };
@@ -1,13 +1,2 @@
1
- import { GlyfTable } from "./glyf.js";
2
- //#region src/glyf-contours.d.ts
3
- interface GlyphContourPoint {
4
- readonly x: number;
5
- readonly y: number;
6
- readonly onCurve: boolean;
7
- }
8
- interface GlyphOutline {
9
- readonly contours: readonly (readonly GlyphContourPoint[])[];
10
- }
11
- declare function decodeGlyphOutline(glyf: GlyfTable, glyphId: number): GlyphOutline | undefined;
12
- //#endregion
1
+ import { n as GlyphOutline, r as decodeGlyphOutline, t as GlyphContourPoint } from "./glyf-contours-OSdG6Edr.js";
13
2
  export { GlyphContourPoint, GlyphOutline, decodeGlyphOutline };
@@ -0,0 +1,33 @@
1
+ import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
2
+ import { t as SfntFont } from "./sfnt-V08bb5ut.cjs";
3
+ //#region src/glyf.d.ts
4
+ interface GlyphHeader {
5
+ readonly numberOfContours: number;
6
+ readonly xMin: number;
7
+ readonly yMin: number;
8
+ readonly xMax: number;
9
+ readonly yMax: number;
10
+ }
11
+ interface CompositeComponent {
12
+ readonly flags: number;
13
+ readonly glyphIndex: number;
14
+ readonly argument1: number;
15
+ readonly argument2: number;
16
+ readonly argsAreXyValues: boolean;
17
+ readonly transform: readonly [number, number, number, number] | undefined;
18
+ }
19
+ interface GlyfTable {
20
+ readonly numGlyphs: number;
21
+ glyphBytes(glyphId: number): Uint8Array<ArrayBuffer> | undefined;
22
+ glyphHeader(glyphId: number): GlyphHeader | undefined;
23
+ compositeComponents(glyphId: number): readonly CompositeComponent[] | undefined;
24
+ glyphInkBounds(glyphId: number): GlyphInkBounds | undefined;
25
+ }
26
+ interface GlyfOptions {
27
+ readonly numGlyphs: number;
28
+ readonly indexToLocFormat: 0 | 1;
29
+ }
30
+ declare function parseLoca(font: SfntFont, options: GlyfOptions): readonly number[] | undefined;
31
+ declare function parseGlyf(font: SfntFont, options: GlyfOptions): GlyfTable | undefined;
32
+ //#endregion
33
+ export { parseGlyf as a, GlyphHeader as i, GlyfOptions as n, parseLoca as o, GlyfTable as r, CompositeComponent as t };
@@ -0,0 +1,33 @@
1
+ import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
2
+ import { t as SfntFont } from "./sfnt-V08bb5ut.js";
3
+ //#region src/glyf.d.ts
4
+ interface GlyphHeader {
5
+ readonly numberOfContours: number;
6
+ readonly xMin: number;
7
+ readonly yMin: number;
8
+ readonly xMax: number;
9
+ readonly yMax: number;
10
+ }
11
+ interface CompositeComponent {
12
+ readonly flags: number;
13
+ readonly glyphIndex: number;
14
+ readonly argument1: number;
15
+ readonly argument2: number;
16
+ readonly argsAreXyValues: boolean;
17
+ readonly transform: readonly [number, number, number, number] | undefined;
18
+ }
19
+ interface GlyfTable {
20
+ readonly numGlyphs: number;
21
+ glyphBytes(glyphId: number): Uint8Array<ArrayBuffer> | undefined;
22
+ glyphHeader(glyphId: number): GlyphHeader | undefined;
23
+ compositeComponents(glyphId: number): readonly CompositeComponent[] | undefined;
24
+ glyphInkBounds(glyphId: number): GlyphInkBounds | undefined;
25
+ }
26
+ interface GlyfOptions {
27
+ readonly numGlyphs: number;
28
+ readonly indexToLocFormat: 0 | 1;
29
+ }
30
+ declare function parseLoca(font: SfntFont, options: GlyfOptions): readonly number[] | undefined;
31
+ declare function parseGlyf(font: SfntFont, options: GlyfOptions): GlyfTable | undefined;
32
+ //#endregion
33
+ export { parseGlyf as a, GlyphHeader as i, GlyfOptions as n, parseLoca as o, GlyfTable as r, CompositeComponent as t };
package/dist/glyf.d.cts CHANGED
@@ -1,33 +1,2 @@
1
- import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
2
- import { t as SfntFont } from "./sfnt-V08bb5ut.cjs";
3
- //#region src/glyf.d.ts
4
- interface GlyphHeader {
5
- readonly numberOfContours: number;
6
- readonly xMin: number;
7
- readonly yMin: number;
8
- readonly xMax: number;
9
- readonly yMax: number;
10
- }
11
- interface CompositeComponent {
12
- readonly flags: number;
13
- readonly glyphIndex: number;
14
- readonly argument1: number;
15
- readonly argument2: number;
16
- readonly argsAreXyValues: boolean;
17
- readonly transform: readonly [number, number, number, number] | undefined;
18
- }
19
- interface GlyfTable {
20
- readonly numGlyphs: number;
21
- glyphBytes(glyphId: number): Uint8Array<ArrayBuffer> | undefined;
22
- glyphHeader(glyphId: number): GlyphHeader | undefined;
23
- compositeComponents(glyphId: number): readonly CompositeComponent[] | undefined;
24
- glyphInkBounds(glyphId: number): GlyphInkBounds | undefined;
25
- }
26
- interface GlyfOptions {
27
- readonly numGlyphs: number;
28
- readonly indexToLocFormat: 0 | 1;
29
- }
30
- declare function parseLoca(font: SfntFont, options: GlyfOptions): readonly number[] | undefined;
31
- declare function parseGlyf(font: SfntFont, options: GlyfOptions): GlyfTable | undefined;
32
- //#endregion
1
+ import { a as parseGlyf, i as GlyphHeader, n as GlyfOptions, o as parseLoca, r as GlyfTable, t as CompositeComponent } from "./glyf-nXC-IDRW.cjs";
33
2
  export { CompositeComponent, GlyfOptions, GlyfTable, GlyphHeader, parseGlyf, parseLoca };
package/dist/glyf.d.ts CHANGED
@@ -1,33 +1,2 @@
1
- import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
2
- import { t as SfntFont } from "./sfnt-V08bb5ut.js";
3
- //#region src/glyf.d.ts
4
- interface GlyphHeader {
5
- readonly numberOfContours: number;
6
- readonly xMin: number;
7
- readonly yMin: number;
8
- readonly xMax: number;
9
- readonly yMax: number;
10
- }
11
- interface CompositeComponent {
12
- readonly flags: number;
13
- readonly glyphIndex: number;
14
- readonly argument1: number;
15
- readonly argument2: number;
16
- readonly argsAreXyValues: boolean;
17
- readonly transform: readonly [number, number, number, number] | undefined;
18
- }
19
- interface GlyfTable {
20
- readonly numGlyphs: number;
21
- glyphBytes(glyphId: number): Uint8Array<ArrayBuffer> | undefined;
22
- glyphHeader(glyphId: number): GlyphHeader | undefined;
23
- compositeComponents(glyphId: number): readonly CompositeComponent[] | undefined;
24
- glyphInkBounds(glyphId: number): GlyphInkBounds | undefined;
25
- }
26
- interface GlyfOptions {
27
- readonly numGlyphs: number;
28
- readonly indexToLocFormat: 0 | 1;
29
- }
30
- declare function parseLoca(font: SfntFont, options: GlyfOptions): readonly number[] | undefined;
31
- declare function parseGlyf(font: SfntFont, options: GlyfOptions): GlyfTable | undefined;
32
- //#endregion
1
+ import { a as parseGlyf, i as GlyphHeader, n as GlyfOptions, o as parseLoca, r as GlyfTable, t as CompositeComponent } from "./glyf-vMGtP1pb.js";
33
2
  export { CompositeComponent, GlyfOptions, GlyfTable, GlyphHeader, parseGlyf, parseLoca };
@@ -12,17 +12,8 @@ const BOX_PALETTE = 1885564018;
12
12
  const BOX_COMPONENT_MAPPING = 1668112752;
13
13
  const BOX_CHANNEL_DEFINITION = 1667523942;
14
14
  const BOX_CONTIGUOUS_CODESTREAM = 1785737827;
15
- const ENUMERATED_COLOUR_SPACES = /* @__PURE__ */ new Map([
16
- [12, "cmyk"],
17
- [14, "cielab"],
18
- [16, "srgb"],
19
- [17, "greyscale"],
20
- [18, "sycc"],
21
- [20, "e-srgb"],
22
- [24, "rommrgb"]
23
- ]);
24
15
  function looksLikeBareCodestream(data) {
25
- return data.length >= 4 && data[0] === 255 && data[1] === 79 && data[2] === 255 && data[3] === 81;
16
+ return data[0] === 255 && data[1] === 79 && data[2] === 255 && data[3] === 81;
26
17
  }
27
18
  function readUint32(data, offset) {
28
19
  const b0 = data[offset];
@@ -73,7 +64,6 @@ function readImageHeader(data, start, end) {
73
64
  };
74
65
  }
75
66
  function readChannelDefinitions(data, start, end) {
76
- if (end - start < 2) return [];
77
67
  const count = (data[start] ?? 0) << 8 | (data[start + 1] ?? 0);
78
68
  const definitions = [];
79
69
  for (let i = 0; i < count; i++) {
@@ -91,7 +81,7 @@ function readJp2HeaderBox(data, start, end, into) {
91
81
  let offset = start;
92
82
  for (;;) {
93
83
  const box = readBox(data, offset, end);
94
- if (box === void 0 || box.nextBoxStart <= offset) return;
84
+ if (box === void 0) return;
95
85
  if (box.type === BOX_IMAGE_HEADER) into.imageHeader = readImageHeader(data, box.payloadStart, box.payloadEnd);
96
86
  else if (box.type === BOX_COLOUR_SPECIFICATION && into.colourSpace === void 0 && into.iccProfile === void 0) readColourSpecification(data, box.payloadStart, box.payloadEnd, into);
97
87
  else if (box.type === BOX_PALETTE || box.type === BOX_COMPONENT_MAPPING) into.hasPalette = true;
@@ -100,10 +90,17 @@ function readJp2HeaderBox(data, start, end, into) {
100
90
  }
101
91
  }
102
92
  function readColourSpecification(data, start, end, into) {
103
- if (end - start < 3) return;
104
93
  const method = data[start] ?? 0;
105
94
  if (method === 1) {
106
- if (end - start >= 7) into.colourSpace = ENUMERATED_COLOUR_SPACES.get(readUint32(data, start + 3));
95
+ if (end - start >= 7) into.colourSpace = (/* @__PURE__ */ new Map([
96
+ [12, "cmyk"],
97
+ [14, "cielab"],
98
+ [16, "srgb"],
99
+ [17, "greyscale"],
100
+ [18, "sycc"],
101
+ [20, "e-srgb"],
102
+ [24, "rommrgb"]
103
+ ])).get(readUint32(data, start + 3));
107
104
  return;
108
105
  }
109
106
  if (method === 2 && end - start > 3) into.iccProfile = data.subarray(start + 3, end);
@@ -123,7 +120,7 @@ function parseJp2Container(data) {
123
120
  let sawSignature = false;
124
121
  for (;;) {
125
122
  const box = readBox(data, offset, data.length);
126
- if (box === void 0 || box.nextBoxStart <= offset) break;
123
+ if (box === void 0) break;
127
124
  if (box.type === BOX_SIGNATURE) sawSignature = true;
128
125
  else if (box.type === BOX_JP2_HEADER) readJp2HeaderBox(data, box.payloadStart, box.payloadEnd, contents);
129
126
  else if (box.type === BOX_CONTIGUOUS_CODESTREAM && codestream === void 0) codestream = data.subarray(box.payloadStart, box.payloadEnd);