@utilix-tech/sdk 0.28.0 → 0.29.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/CHANGELOG.md +4 -0
- package/README.md +17 -6
- package/dist/{chunk-Y5OOP6WN.js → chunk-CSNTHZHF.js} +90 -1
- package/dist/{chunk-47DTCCQJ.js → chunk-L6V4W4SU.js} +112 -1
- package/dist/index.cjs +200 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{media-cuxfzXxw.d.cts → media-fD8dJ5qR.d.cts} +29 -2
- package/dist/{media-cuxfzXxw.d.ts → media-fD8dJ5qR.d.ts} +29 -2
- package/dist/{network-BJOjJnmY.d.cts → network-D7Epuerc.d.cts} +23 -2
- package/dist/{network-BJOjJnmY.d.ts → network-D7Epuerc.d.ts} +23 -2
- package/dist/tools/media.cjs +111 -0
- package/dist/tools/media.d.cts +1 -1
- package/dist/tools/media.d.ts +1 -1
- package/dist/tools/media.js +1 -1
- package/dist/tools/network.cjs +89 -0
- package/dist/tools/network.d.cts +1 -1
- package/dist/tools/network.d.ts +1 -1
- package/dist/tools/network.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.29.0
|
|
6
|
+
- Add `readPdfPageDimensions` (pdf-page-dimensions): each page's MediaBox width/height (points and inches), rotation, and orientation, walking the Root -> Pages -> Kids tree and inheriting from ancestor nodes, plus a common paper size match (Letter, A4, etc.).
|
|
7
|
+
- Add `parseIpv6Address` (ipv6-compressor): expand an IPv6 address to its full 8-group form or compress it to its RFC 5952 canonical shortest form, classify its address type, and handle an embedded IPv4 suffix or zone ID.
|
|
8
|
+
|
|
5
9
|
## 0.28.0
|
|
6
10
|
- Add `readVideoInfo` (mp4-webm-video-info): duration, resolution, and video/audio codec identifiers from an MP4 (ISO BMFF moov box) or WebM (EBML/Matroska Segment) container header, with no frame decoding or transcoding.
|
|
7
11
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**581 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -372,7 +372,7 @@ calculateRuleOf72(8, "rate-to-years");
|
|
|
372
372
|
import { getStatusCode, isValidIp, isValidIpv4, isValidIpv6,
|
|
373
373
|
searchStatusCodes, buildGeoUrl, countryCodeToFlag,
|
|
374
374
|
parseHar, validateSitemap, validateRobotsTxt,
|
|
375
|
-
parseUserAgent, buildCacheControl } from "@utilix-tech/sdk/network";
|
|
375
|
+
parseUserAgent, buildCacheControl, parseIpv6Address } from "@utilix-tech/sdk/network";
|
|
376
376
|
|
|
377
377
|
getStatusCode(404);
|
|
378
378
|
// { code: 404, text: "Not Found", description: "...", category: "Client Error" }
|
|
@@ -406,6 +406,11 @@ validateRobotsTxt("User-agent: *\nDisallow: /admin\nSitemap: https://example.com
|
|
|
406
406
|
// Build and explain a Cache-Control response header from directives
|
|
407
407
|
buildCacheControl({ visibility: "public", maxAge: 3600, mustRevalidate: true });
|
|
408
408
|
// { header: "public, max-age=3600, must-revalidate", directives: [...], warnings: [] }
|
|
409
|
+
|
|
410
|
+
// Expand/compress an IPv6 address (RFC 5952) and classify its address type
|
|
411
|
+
parseIpv6Address("2001:db8::ff00:42:8329");
|
|
412
|
+
// { expanded: "2001:0db8:0000:0000:0000:ff00:0042:8329", compressed: "2001:db8::ff00:42:8329",
|
|
413
|
+
// groups: [...], zoneId: null, addressType: "documentation" }
|
|
409
414
|
```
|
|
410
415
|
|
|
411
416
|
---
|
|
@@ -561,10 +566,10 @@ analyzeString("café"); // { length: 4, codePoints: [...], ... }
|
|
|
561
566
|
|
|
562
567
|
---
|
|
563
568
|
|
|
564
|
-
### `/media`: Image Header Parsing, EXIF, PDF, WAV, ID3, ICO, FLAC & Video Metadata
|
|
569
|
+
### `/media`: Image Header Parsing, EXIF, PDF Metadata & Page Dimensions, WAV, ID3, ICO, FLAC & Video Metadata
|
|
565
570
|
|
|
566
571
|
```ts
|
|
567
|
-
import { readImageInfo, readExifData, readPdfMetadata, readWavInfo, readId3Tags, readIcoInfo, readFlacInfo, readVideoInfo } from "@utilix-tech/sdk/media";
|
|
572
|
+
import { readImageInfo, readExifData, readPdfMetadata, readPdfPageDimensions, readWavInfo, readId3Tags, readIcoInfo, readFlacInfo, readVideoInfo } from "@utilix-tech/sdk/media";
|
|
568
573
|
|
|
569
574
|
// Reads format, dimensions, bit depth, and alpha channel straight from
|
|
570
575
|
// file bytes: no decoding, no canvas, no image library.
|
|
@@ -584,6 +589,12 @@ const pdfBytes = await fs.promises.readFile("report.pdf");
|
|
|
584
589
|
readPdfMetadata(new Uint8Array(pdfBytes));
|
|
585
590
|
// { version: "1.7", pageCount: 12, title: "Q3 Report", author: "Jane Doe", ... }
|
|
586
591
|
|
|
592
|
+
// Lists each page's MediaBox width/height (points and inches), rotation, and
|
|
593
|
+
// orientation by walking the Root -> Pages -> Kids tree, inheriting from
|
|
594
|
+
// ancestor nodes as the PDF spec requires. Also flags common paper sizes.
|
|
595
|
+
readPdfPageDimensions(new Uint8Array(pdfBytes));
|
|
596
|
+
// { version: "1.7", pageCount: 12, pages: [{ pageNumber: 1, widthPt: 612, heightPt: 792, rotation: 0, orientation: "portrait", paperSize: "Letter" }, ...] }
|
|
597
|
+
|
|
587
598
|
// Reads sample rate, channels, bit depth, and duration from a WAV file's
|
|
588
599
|
// RIFF/fmt/data chunk headers: no audio library required.
|
|
589
600
|
const wavBytes = await fs.promises.readFile("recording.wav");
|
|
@@ -634,14 +645,14 @@ readVideoInfo(new Uint8Array(videoBytes));
|
|
|
634
645
|
| `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, fake data |
|
|
635
646
|
| `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
|
|
636
647
|
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator |
|
|
637
|
-
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing |
|
|
648
|
+
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing, IPv6 address compress/expand |
|
|
638
649
|
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header |
|
|
639
650
|
| `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format, MIME type lookup, GitHub URL parsing |
|
|
640
651
|
| `@utilix-tech/sdk/color` | Hex/RGB/HSL/HSV/CMYK convert, palette generation, contrast check |
|
|
641
652
|
| `@utilix-tech/sdk/css` | CSS gradient, box-shadow, border-radius, keyframe animation generators |
|
|
642
653
|
| `@utilix-tech/sdk/misc` | SVG optimize/sanitize, file size format, Unicode inspector |
|
|
643
654
|
| `@utilix-tech/sdk/ai_agent` | Token estimate/trim, chunk text, extract URLs/JSON/keywords, sanitize HTML, flatten/merge JSON, dedupe lines, validate schema, PII/secret/injection detect, vector similarity |
|
|
644
|
-
| `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading; WAV audio info; ID3 tags; ICO favicon inspection; FLAC metadata reading; MP4/WebM video info |
|
|
655
|
+
| `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading; PDF page dimension/orientation listing; WAV audio info; ID3 tags; ICO favicon inspection; FLAC metadata reading; MP4/WebM video info |
|
|
645
656
|
|
|
646
657
|
---
|
|
647
658
|
|
|
@@ -27,6 +27,7 @@ __export(network_exports, {
|
|
|
27
27
|
parseDnsResponse: () => parseDnsResponse,
|
|
28
28
|
parseGeoResponse: () => parseGeoResponse,
|
|
29
29
|
parseHar: () => parseHar,
|
|
30
|
+
parseIpv6Address: () => parseIpv6Address,
|
|
30
31
|
parseUserAgent: () => parseUserAgent,
|
|
31
32
|
searchHeaders: () => searchHeaders,
|
|
32
33
|
searchStatusCodes: () => searchStatusCodes,
|
|
@@ -1814,5 +1815,93 @@ function buildCacheControl(options = {}) {
|
|
|
1814
1815
|
const snippet = `Cache-Control: ${header}`;
|
|
1815
1816
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
1816
1817
|
}
|
|
1818
|
+
function isValidIpv6HexGroup(g) {
|
|
1819
|
+
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
1820
|
+
}
|
|
1821
|
+
function isValidIpv6Ipv4Quad(quad) {
|
|
1822
|
+
const parts = quad.split(".");
|
|
1823
|
+
if (parts.length !== 4) return false;
|
|
1824
|
+
return parts.every((p) => /^\d{1,3}$/.test(p) && Number(p) <= 255);
|
|
1825
|
+
}
|
|
1826
|
+
function classifyIpv6(groups) {
|
|
1827
|
+
const first = parseInt(groups[0], 16);
|
|
1828
|
+
if (groups.every((g) => g === "0000")) return "unspecified";
|
|
1829
|
+
if (groups.slice(0, 7).every((g) => g === "0000") && groups[7] === "0001") return "loopback";
|
|
1830
|
+
if (groups.slice(0, 4).every((g) => g === "0000") && groups[4] === "0000" && groups[5] === "ffff") return "ipv4-mapped";
|
|
1831
|
+
if (groups[0] === "2001" && groups[1] === "0db8") return "documentation";
|
|
1832
|
+
if ((first & 65280) === 65280) return "multicast";
|
|
1833
|
+
if ((first & 65472) === 65152) return "link-local";
|
|
1834
|
+
if ((first & 65024) === 64512) return "unique-local";
|
|
1835
|
+
return "global-unicast";
|
|
1836
|
+
}
|
|
1837
|
+
function compressIpv6Groups(groups) {
|
|
1838
|
+
const short = groups.map((g) => g.replace(/^0+(?=.)/, ""));
|
|
1839
|
+
let bestStart = -1;
|
|
1840
|
+
let bestLen = 0;
|
|
1841
|
+
let curStart = -1;
|
|
1842
|
+
let curLen = 0;
|
|
1843
|
+
for (let i = 0; i < short.length; i++) {
|
|
1844
|
+
if (short[i] === "0") {
|
|
1845
|
+
if (curStart === -1) curStart = i;
|
|
1846
|
+
curLen++;
|
|
1847
|
+
if (curLen > bestLen) {
|
|
1848
|
+
bestLen = curLen;
|
|
1849
|
+
bestStart = curStart;
|
|
1850
|
+
}
|
|
1851
|
+
} else {
|
|
1852
|
+
curStart = -1;
|
|
1853
|
+
curLen = 0;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
if (bestLen < 2) return short.join(":");
|
|
1857
|
+
const before = short.slice(0, bestStart).join(":");
|
|
1858
|
+
const after = short.slice(bestStart + bestLen).join(":");
|
|
1859
|
+
return `${before}::${after}`;
|
|
1860
|
+
}
|
|
1861
|
+
function parseIpv6Address(input) {
|
|
1862
|
+
let s = input.trim();
|
|
1863
|
+
if (s.startsWith("[") && s.includes("]")) s = s.slice(1, s.indexOf("]"));
|
|
1864
|
+
let zoneId = null;
|
|
1865
|
+
const pctIdx = s.indexOf("%");
|
|
1866
|
+
if (pctIdx !== -1) {
|
|
1867
|
+
zoneId = s.slice(pctIdx + 1);
|
|
1868
|
+
s = s.slice(0, pctIdx);
|
|
1869
|
+
}
|
|
1870
|
+
if (!s) return { error: "Empty address" };
|
|
1871
|
+
const doubleColonCount = (s.match(/::/g) ?? []).length;
|
|
1872
|
+
if (doubleColonCount > 1) return { error: 'Address contains more than one "::"' };
|
|
1873
|
+
const ipv4Match = s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1874
|
+
if (ipv4Match) {
|
|
1875
|
+
const quad = ipv4Match[1];
|
|
1876
|
+
if (!isValidIpv6Ipv4Quad(quad)) return { error: `Invalid embedded IPv4 address: ${quad}` };
|
|
1877
|
+
const parts = quad.split(".").map(Number);
|
|
1878
|
+
const hi = (parts[0] << 8 | parts[1]).toString(16);
|
|
1879
|
+
const lo = (parts[2] << 8 | parts[3]).toString(16);
|
|
1880
|
+
s = s.slice(0, s.length - quad.length) + `${hi}:${lo}`;
|
|
1881
|
+
}
|
|
1882
|
+
let groups;
|
|
1883
|
+
if (s.includes("::")) {
|
|
1884
|
+
const [left, right] = s.split("::");
|
|
1885
|
+
const leftGroups = left ? left.split(":") : [];
|
|
1886
|
+
const rightGroups = right ? right.split(":") : [];
|
|
1887
|
+
const missing = 8 - (leftGroups.length + rightGroups.length);
|
|
1888
|
+
if (missing < 1) return { error: 'The "::" shorthand must represent at least one group of zeros' };
|
|
1889
|
+
if (![...leftGroups, ...rightGroups].every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
1890
|
+
groups = [...leftGroups, ...Array(missing).fill("0"), ...rightGroups];
|
|
1891
|
+
} else {
|
|
1892
|
+
groups = s.split(":");
|
|
1893
|
+
if (groups.length !== 8) return { error: `Expected 8 groups, got ${groups.length}` };
|
|
1894
|
+
if (!groups.every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
1895
|
+
}
|
|
1896
|
+
const expandedGroups = groups.map((g) => g.padStart(4, "0").toLowerCase());
|
|
1897
|
+
const suffix = zoneId ? `%${zoneId}` : "";
|
|
1898
|
+
return {
|
|
1899
|
+
expanded: expandedGroups.join(":") + suffix,
|
|
1900
|
+
compressed: compressIpv6Groups(expandedGroups) + suffix,
|
|
1901
|
+
groups: expandedGroups,
|
|
1902
|
+
zoneId,
|
|
1903
|
+
addressType: classifyIpv6(expandedGroups)
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1817
1906
|
|
|
1818
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, parseHar, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap };
|
|
1907
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap };
|
|
@@ -9,6 +9,7 @@ __export(media_exports, {
|
|
|
9
9
|
readId3Tags: () => readId3Tags,
|
|
10
10
|
readImageInfo: () => readImageInfo,
|
|
11
11
|
readPdfMetadata: () => readPdfMetadata,
|
|
12
|
+
readPdfPageDimensions: () => readPdfPageDimensions,
|
|
12
13
|
readVideoInfo: () => readVideoInfo,
|
|
13
14
|
readWavInfo: () => readWavInfo
|
|
14
15
|
});
|
|
@@ -468,6 +469,116 @@ function readPdfMetadata(bytes) {
|
|
|
468
469
|
encrypted
|
|
469
470
|
};
|
|
470
471
|
}
|
|
472
|
+
var PDF_COMMON_PAPER_SIZES = [
|
|
473
|
+
{ name: "Letter", widthPt: 612, heightPt: 792 },
|
|
474
|
+
{ name: "Legal", widthPt: 612, heightPt: 1008 },
|
|
475
|
+
{ name: "Tabloid", widthPt: 792, heightPt: 1224 },
|
|
476
|
+
{ name: "A3", widthPt: 842, heightPt: 1191 },
|
|
477
|
+
{ name: "A4", widthPt: 595, heightPt: 842 },
|
|
478
|
+
{ name: "A5", widthPt: 420, heightPt: 595 },
|
|
479
|
+
{ name: "B5", widthPt: 499, heightPt: 709 }
|
|
480
|
+
];
|
|
481
|
+
function matchPaperSize(widthPt, heightPt) {
|
|
482
|
+
for (const size of PDF_COMMON_PAPER_SIZES) {
|
|
483
|
+
const w = Math.abs(widthPt - size.widthPt) <= 1;
|
|
484
|
+
const h = Math.abs(heightPt - size.heightPt) <= 1;
|
|
485
|
+
const wSwapped = Math.abs(widthPt - size.heightPt) <= 1;
|
|
486
|
+
const hSwapped = Math.abs(heightPt - size.widthPt) <= 1;
|
|
487
|
+
if (w && h || wSwapped && hSwapped) return size.name;
|
|
488
|
+
}
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
function parsePdfMediaBox(dict) {
|
|
492
|
+
const m = dict.match(/\/MediaBox\s*\[\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*\]/);
|
|
493
|
+
if (!m) return null;
|
|
494
|
+
return [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])];
|
|
495
|
+
}
|
|
496
|
+
function parsePdfRotate(dict) {
|
|
497
|
+
const m = dict.match(/\/Rotate\s+(-?\d+)/);
|
|
498
|
+
return m ? Number(m[1]) : null;
|
|
499
|
+
}
|
|
500
|
+
function buildPdfPageDimension(pageNumber, mediaBox, rotate) {
|
|
501
|
+
const rotation = (rotate % 360 + 360) % 360;
|
|
502
|
+
if (!mediaBox) {
|
|
503
|
+
return { pageNumber, widthPt: null, heightPt: null, widthIn: null, heightIn: null, rotation, orientation: null, paperSize: null };
|
|
504
|
+
}
|
|
505
|
+
const [llx, lly, urx, ury] = mediaBox;
|
|
506
|
+
let widthPt = Math.abs(urx - llx);
|
|
507
|
+
let heightPt = Math.abs(ury - lly);
|
|
508
|
+
if (rotation === 90 || rotation === 270) [widthPt, heightPt] = [heightPt, widthPt];
|
|
509
|
+
const orientation = widthPt === heightPt ? "square" : widthPt > heightPt ? "landscape" : "portrait";
|
|
510
|
+
return {
|
|
511
|
+
pageNumber,
|
|
512
|
+
widthPt: round2(widthPt),
|
|
513
|
+
heightPt: round2(heightPt),
|
|
514
|
+
widthIn: round2(widthPt / 72),
|
|
515
|
+
heightIn: round2(heightPt / 72),
|
|
516
|
+
rotation,
|
|
517
|
+
orientation,
|
|
518
|
+
paperSize: matchPaperSize(widthPt, heightPt)
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function walkPdfPageTree(objMap, nodeBody, inherited, visited, nodeKey, out) {
|
|
522
|
+
if (visited.has(nodeKey)) return;
|
|
523
|
+
visited.add(nodeKey);
|
|
524
|
+
const mediaBox = parsePdfMediaBox(nodeBody) ?? inherited.mediaBox;
|
|
525
|
+
const rotateMatch = parsePdfRotate(nodeBody);
|
|
526
|
+
const rotate = rotateMatch !== null ? rotateMatch : inherited.rotate;
|
|
527
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(nodeBody)) {
|
|
528
|
+
out.push(buildPdfPageDimension(out.length + 1, mediaBox, rotate));
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const kidsMatch = nodeBody.match(/\/Kids\s*\[([^\]]*)\]/);
|
|
532
|
+
if (!kidsMatch) return;
|
|
533
|
+
const kidRefs = [...kidsMatch[1].matchAll(/(\d+)\s+(\d+)\s+R/g)];
|
|
534
|
+
for (const ref of kidRefs) {
|
|
535
|
+
const key = `${ref[1]} ${ref[2]}`;
|
|
536
|
+
const body = objMap.get(key);
|
|
537
|
+
if (body) walkPdfPageTree(objMap, body, { mediaBox, rotate }, visited, key, out);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function readPdfPageDimensions(bytes) {
|
|
541
|
+
if (bytes.length < 8) return { error: "File too small to be a PDF" };
|
|
542
|
+
const header = bytesToLatin1(bytes.subarray(0, 16));
|
|
543
|
+
const versionMatch = header.match(/%PDF-(\d\.\d)/);
|
|
544
|
+
if (!versionMatch) return { error: "Not a valid PDF file (missing %PDF header)" };
|
|
545
|
+
const version = versionMatch[1];
|
|
546
|
+
const text = bytesToLatin1(bytes);
|
|
547
|
+
const objBlocks = [...text.matchAll(/(\d+)\s+(\d+)\s+obj([\s\S]*?)endobj/g)];
|
|
548
|
+
const objMap = /* @__PURE__ */ new Map();
|
|
549
|
+
for (const b of objBlocks) objMap.set(`${b[1]} ${b[2]}`, b[3]);
|
|
550
|
+
const out = [];
|
|
551
|
+
const visited = /* @__PURE__ */ new Set();
|
|
552
|
+
let pagesRootBody = null;
|
|
553
|
+
const trailerMatches = [...text.matchAll(/trailer\s*<<([\s\S]*?)>>/g)];
|
|
554
|
+
if (trailerMatches.length > 0) {
|
|
555
|
+
const trailer = trailerMatches[trailerMatches.length - 1][1];
|
|
556
|
+
const rootRef = trailer.match(/\/Root\s+(\d+)\s+(\d+)\s+R/);
|
|
557
|
+
if (rootRef) {
|
|
558
|
+
const catalogBody = objMap.get(`${rootRef[1]} ${rootRef[2]}`);
|
|
559
|
+
const pagesRef = catalogBody?.match(/\/Pages\s+(\d+)\s+(\d+)\s+R/);
|
|
560
|
+
if (pagesRef) pagesRootBody = objMap.get(`${pagesRef[1]} ${pagesRef[2]}`) ?? null;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (!pagesRootBody) {
|
|
564
|
+
for (const b of objBlocks) {
|
|
565
|
+
if (/\/Type\s*\/Pages\b/.test(b[3]) && !/\/Parent\s+\d+\s+\d+\s+R/.test(b[3])) {
|
|
566
|
+
pagesRootBody = b[3];
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (pagesRootBody) walkPdfPageTree(objMap, pagesRootBody, { mediaBox: null, rotate: 0 }, visited, "root", out);
|
|
572
|
+
if (out.length === 0) {
|
|
573
|
+
for (const b of objBlocks) {
|
|
574
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(b[3])) {
|
|
575
|
+
out.push(buildPdfPageDimension(out.length + 1, parsePdfMediaBox(b[3]), parsePdfRotate(b[3]) ?? 0));
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (out.length === 0) return { error: "Could not locate any page objects in this PDF" };
|
|
580
|
+
return { version, pageCount: out.length, pages: out };
|
|
581
|
+
}
|
|
471
582
|
var AUDIO_FORMAT_LABELS = {
|
|
472
583
|
1: "PCM",
|
|
473
584
|
3: "IEEE float",
|
|
@@ -1110,4 +1221,4 @@ function parseWebm(bytes) {
|
|
|
1110
1221
|
return result;
|
|
1111
1222
|
}
|
|
1112
1223
|
|
|
1113
|
-
export { media_exports, readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readVideoInfo, readWavInfo };
|
|
1224
|
+
export { media_exports, readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readPdfPageDimensions, readVideoInfo, readWavInfo };
|
package/dist/index.cjs
CHANGED
|
@@ -8833,6 +8833,7 @@ __export(network_exports, {
|
|
|
8833
8833
|
parseDnsResponse: () => parseDnsResponse,
|
|
8834
8834
|
parseGeoResponse: () => parseGeoResponse,
|
|
8835
8835
|
parseHar: () => parseHar,
|
|
8836
|
+
parseIpv6Address: () => parseIpv6Address,
|
|
8836
8837
|
parseUserAgent: () => parseUserAgent,
|
|
8837
8838
|
searchHeaders: () => searchHeaders,
|
|
8838
8839
|
searchStatusCodes: () => searchStatusCodes,
|
|
@@ -10620,6 +10621,94 @@ function buildCacheControl(options = {}) {
|
|
|
10620
10621
|
const snippet = `Cache-Control: ${header}`;
|
|
10621
10622
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
10622
10623
|
}
|
|
10624
|
+
function isValidIpv6HexGroup(g) {
|
|
10625
|
+
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
10626
|
+
}
|
|
10627
|
+
function isValidIpv6Ipv4Quad(quad) {
|
|
10628
|
+
const parts = quad.split(".");
|
|
10629
|
+
if (parts.length !== 4) return false;
|
|
10630
|
+
return parts.every((p) => /^\d{1,3}$/.test(p) && Number(p) <= 255);
|
|
10631
|
+
}
|
|
10632
|
+
function classifyIpv6(groups) {
|
|
10633
|
+
const first = parseInt(groups[0], 16);
|
|
10634
|
+
if (groups.every((g) => g === "0000")) return "unspecified";
|
|
10635
|
+
if (groups.slice(0, 7).every((g) => g === "0000") && groups[7] === "0001") return "loopback";
|
|
10636
|
+
if (groups.slice(0, 4).every((g) => g === "0000") && groups[4] === "0000" && groups[5] === "ffff") return "ipv4-mapped";
|
|
10637
|
+
if (groups[0] === "2001" && groups[1] === "0db8") return "documentation";
|
|
10638
|
+
if ((first & 65280) === 65280) return "multicast";
|
|
10639
|
+
if ((first & 65472) === 65152) return "link-local";
|
|
10640
|
+
if ((first & 65024) === 64512) return "unique-local";
|
|
10641
|
+
return "global-unicast";
|
|
10642
|
+
}
|
|
10643
|
+
function compressIpv6Groups(groups) {
|
|
10644
|
+
const short = groups.map((g) => g.replace(/^0+(?=.)/, ""));
|
|
10645
|
+
let bestStart = -1;
|
|
10646
|
+
let bestLen = 0;
|
|
10647
|
+
let curStart = -1;
|
|
10648
|
+
let curLen = 0;
|
|
10649
|
+
for (let i = 0; i < short.length; i++) {
|
|
10650
|
+
if (short[i] === "0") {
|
|
10651
|
+
if (curStart === -1) curStart = i;
|
|
10652
|
+
curLen++;
|
|
10653
|
+
if (curLen > bestLen) {
|
|
10654
|
+
bestLen = curLen;
|
|
10655
|
+
bestStart = curStart;
|
|
10656
|
+
}
|
|
10657
|
+
} else {
|
|
10658
|
+
curStart = -1;
|
|
10659
|
+
curLen = 0;
|
|
10660
|
+
}
|
|
10661
|
+
}
|
|
10662
|
+
if (bestLen < 2) return short.join(":");
|
|
10663
|
+
const before = short.slice(0, bestStart).join(":");
|
|
10664
|
+
const after = short.slice(bestStart + bestLen).join(":");
|
|
10665
|
+
return `${before}::${after}`;
|
|
10666
|
+
}
|
|
10667
|
+
function parseIpv6Address(input) {
|
|
10668
|
+
let s = input.trim();
|
|
10669
|
+
if (s.startsWith("[") && s.includes("]")) s = s.slice(1, s.indexOf("]"));
|
|
10670
|
+
let zoneId = null;
|
|
10671
|
+
const pctIdx = s.indexOf("%");
|
|
10672
|
+
if (pctIdx !== -1) {
|
|
10673
|
+
zoneId = s.slice(pctIdx + 1);
|
|
10674
|
+
s = s.slice(0, pctIdx);
|
|
10675
|
+
}
|
|
10676
|
+
if (!s) return { error: "Empty address" };
|
|
10677
|
+
const doubleColonCount = (s.match(/::/g) ?? []).length;
|
|
10678
|
+
if (doubleColonCount > 1) return { error: 'Address contains more than one "::"' };
|
|
10679
|
+
const ipv4Match = s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
10680
|
+
if (ipv4Match) {
|
|
10681
|
+
const quad = ipv4Match[1];
|
|
10682
|
+
if (!isValidIpv6Ipv4Quad(quad)) return { error: `Invalid embedded IPv4 address: ${quad}` };
|
|
10683
|
+
const parts = quad.split(".").map(Number);
|
|
10684
|
+
const hi = (parts[0] << 8 | parts[1]).toString(16);
|
|
10685
|
+
const lo = (parts[2] << 8 | parts[3]).toString(16);
|
|
10686
|
+
s = s.slice(0, s.length - quad.length) + `${hi}:${lo}`;
|
|
10687
|
+
}
|
|
10688
|
+
let groups;
|
|
10689
|
+
if (s.includes("::")) {
|
|
10690
|
+
const [left, right] = s.split("::");
|
|
10691
|
+
const leftGroups = left ? left.split(":") : [];
|
|
10692
|
+
const rightGroups = right ? right.split(":") : [];
|
|
10693
|
+
const missing = 8 - (leftGroups.length + rightGroups.length);
|
|
10694
|
+
if (missing < 1) return { error: 'The "::" shorthand must represent at least one group of zeros' };
|
|
10695
|
+
if (![...leftGroups, ...rightGroups].every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
10696
|
+
groups = [...leftGroups, ...Array(missing).fill("0"), ...rightGroups];
|
|
10697
|
+
} else {
|
|
10698
|
+
groups = s.split(":");
|
|
10699
|
+
if (groups.length !== 8) return { error: `Expected 8 groups, got ${groups.length}` };
|
|
10700
|
+
if (!groups.every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
10701
|
+
}
|
|
10702
|
+
const expandedGroups = groups.map((g) => g.padStart(4, "0").toLowerCase());
|
|
10703
|
+
const suffix = zoneId ? `%${zoneId}` : "";
|
|
10704
|
+
return {
|
|
10705
|
+
expanded: expandedGroups.join(":") + suffix,
|
|
10706
|
+
compressed: compressIpv6Groups(expandedGroups) + suffix,
|
|
10707
|
+
groups: expandedGroups,
|
|
10708
|
+
zoneId,
|
|
10709
|
+
addressType: classifyIpv6(expandedGroups)
|
|
10710
|
+
};
|
|
10711
|
+
}
|
|
10623
10712
|
|
|
10624
10713
|
// src/tools/api.ts
|
|
10625
10714
|
var api_exports = {};
|
|
@@ -19237,6 +19326,7 @@ __export(media_exports, {
|
|
|
19237
19326
|
readId3Tags: () => readId3Tags,
|
|
19238
19327
|
readImageInfo: () => readImageInfo,
|
|
19239
19328
|
readPdfMetadata: () => readPdfMetadata,
|
|
19329
|
+
readPdfPageDimensions: () => readPdfPageDimensions,
|
|
19240
19330
|
readVideoInfo: () => readVideoInfo,
|
|
19241
19331
|
readWavInfo: () => readWavInfo
|
|
19242
19332
|
});
|
|
@@ -19696,6 +19786,116 @@ function readPdfMetadata(bytes) {
|
|
|
19696
19786
|
encrypted
|
|
19697
19787
|
};
|
|
19698
19788
|
}
|
|
19789
|
+
var PDF_COMMON_PAPER_SIZES = [
|
|
19790
|
+
{ name: "Letter", widthPt: 612, heightPt: 792 },
|
|
19791
|
+
{ name: "Legal", widthPt: 612, heightPt: 1008 },
|
|
19792
|
+
{ name: "Tabloid", widthPt: 792, heightPt: 1224 },
|
|
19793
|
+
{ name: "A3", widthPt: 842, heightPt: 1191 },
|
|
19794
|
+
{ name: "A4", widthPt: 595, heightPt: 842 },
|
|
19795
|
+
{ name: "A5", widthPt: 420, heightPt: 595 },
|
|
19796
|
+
{ name: "B5", widthPt: 499, heightPt: 709 }
|
|
19797
|
+
];
|
|
19798
|
+
function matchPaperSize(widthPt, heightPt) {
|
|
19799
|
+
for (const size of PDF_COMMON_PAPER_SIZES) {
|
|
19800
|
+
const w = Math.abs(widthPt - size.widthPt) <= 1;
|
|
19801
|
+
const h = Math.abs(heightPt - size.heightPt) <= 1;
|
|
19802
|
+
const wSwapped = Math.abs(widthPt - size.heightPt) <= 1;
|
|
19803
|
+
const hSwapped = Math.abs(heightPt - size.widthPt) <= 1;
|
|
19804
|
+
if (w && h || wSwapped && hSwapped) return size.name;
|
|
19805
|
+
}
|
|
19806
|
+
return null;
|
|
19807
|
+
}
|
|
19808
|
+
function parsePdfMediaBox(dict) {
|
|
19809
|
+
const m = dict.match(/\/MediaBox\s*\[\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*\]/);
|
|
19810
|
+
if (!m) return null;
|
|
19811
|
+
return [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])];
|
|
19812
|
+
}
|
|
19813
|
+
function parsePdfRotate(dict) {
|
|
19814
|
+
const m = dict.match(/\/Rotate\s+(-?\d+)/);
|
|
19815
|
+
return m ? Number(m[1]) : null;
|
|
19816
|
+
}
|
|
19817
|
+
function buildPdfPageDimension(pageNumber, mediaBox, rotate) {
|
|
19818
|
+
const rotation = (rotate % 360 + 360) % 360;
|
|
19819
|
+
if (!mediaBox) {
|
|
19820
|
+
return { pageNumber, widthPt: null, heightPt: null, widthIn: null, heightIn: null, rotation, orientation: null, paperSize: null };
|
|
19821
|
+
}
|
|
19822
|
+
const [llx, lly, urx, ury] = mediaBox;
|
|
19823
|
+
let widthPt = Math.abs(urx - llx);
|
|
19824
|
+
let heightPt = Math.abs(ury - lly);
|
|
19825
|
+
if (rotation === 90 || rotation === 270) [widthPt, heightPt] = [heightPt, widthPt];
|
|
19826
|
+
const orientation = widthPt === heightPt ? "square" : widthPt > heightPt ? "landscape" : "portrait";
|
|
19827
|
+
return {
|
|
19828
|
+
pageNumber,
|
|
19829
|
+
widthPt: round22(widthPt),
|
|
19830
|
+
heightPt: round22(heightPt),
|
|
19831
|
+
widthIn: round22(widthPt / 72),
|
|
19832
|
+
heightIn: round22(heightPt / 72),
|
|
19833
|
+
rotation,
|
|
19834
|
+
orientation,
|
|
19835
|
+
paperSize: matchPaperSize(widthPt, heightPt)
|
|
19836
|
+
};
|
|
19837
|
+
}
|
|
19838
|
+
function walkPdfPageTree(objMap, nodeBody, inherited, visited, nodeKey, out) {
|
|
19839
|
+
if (visited.has(nodeKey)) return;
|
|
19840
|
+
visited.add(nodeKey);
|
|
19841
|
+
const mediaBox = parsePdfMediaBox(nodeBody) ?? inherited.mediaBox;
|
|
19842
|
+
const rotateMatch = parsePdfRotate(nodeBody);
|
|
19843
|
+
const rotate = rotateMatch !== null ? rotateMatch : inherited.rotate;
|
|
19844
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(nodeBody)) {
|
|
19845
|
+
out.push(buildPdfPageDimension(out.length + 1, mediaBox, rotate));
|
|
19846
|
+
return;
|
|
19847
|
+
}
|
|
19848
|
+
const kidsMatch = nodeBody.match(/\/Kids\s*\[([^\]]*)\]/);
|
|
19849
|
+
if (!kidsMatch) return;
|
|
19850
|
+
const kidRefs = [...kidsMatch[1].matchAll(/(\d+)\s+(\d+)\s+R/g)];
|
|
19851
|
+
for (const ref of kidRefs) {
|
|
19852
|
+
const key = `${ref[1]} ${ref[2]}`;
|
|
19853
|
+
const body = objMap.get(key);
|
|
19854
|
+
if (body) walkPdfPageTree(objMap, body, { mediaBox, rotate }, visited, key, out);
|
|
19855
|
+
}
|
|
19856
|
+
}
|
|
19857
|
+
function readPdfPageDimensions(bytes) {
|
|
19858
|
+
if (bytes.length < 8) return { error: "File too small to be a PDF" };
|
|
19859
|
+
const header = bytesToLatin1(bytes.subarray(0, 16));
|
|
19860
|
+
const versionMatch = header.match(/%PDF-(\d\.\d)/);
|
|
19861
|
+
if (!versionMatch) return { error: "Not a valid PDF file (missing %PDF header)" };
|
|
19862
|
+
const version2 = versionMatch[1];
|
|
19863
|
+
const text = bytesToLatin1(bytes);
|
|
19864
|
+
const objBlocks = [...text.matchAll(/(\d+)\s+(\d+)\s+obj([\s\S]*?)endobj/g)];
|
|
19865
|
+
const objMap = /* @__PURE__ */ new Map();
|
|
19866
|
+
for (const b of objBlocks) objMap.set(`${b[1]} ${b[2]}`, b[3]);
|
|
19867
|
+
const out = [];
|
|
19868
|
+
const visited = /* @__PURE__ */ new Set();
|
|
19869
|
+
let pagesRootBody = null;
|
|
19870
|
+
const trailerMatches = [...text.matchAll(/trailer\s*<<([\s\S]*?)>>/g)];
|
|
19871
|
+
if (trailerMatches.length > 0) {
|
|
19872
|
+
const trailer = trailerMatches[trailerMatches.length - 1][1];
|
|
19873
|
+
const rootRef = trailer.match(/\/Root\s+(\d+)\s+(\d+)\s+R/);
|
|
19874
|
+
if (rootRef) {
|
|
19875
|
+
const catalogBody = objMap.get(`${rootRef[1]} ${rootRef[2]}`);
|
|
19876
|
+
const pagesRef = catalogBody?.match(/\/Pages\s+(\d+)\s+(\d+)\s+R/);
|
|
19877
|
+
if (pagesRef) pagesRootBody = objMap.get(`${pagesRef[1]} ${pagesRef[2]}`) ?? null;
|
|
19878
|
+
}
|
|
19879
|
+
}
|
|
19880
|
+
if (!pagesRootBody) {
|
|
19881
|
+
for (const b of objBlocks) {
|
|
19882
|
+
if (/\/Type\s*\/Pages\b/.test(b[3]) && !/\/Parent\s+\d+\s+\d+\s+R/.test(b[3])) {
|
|
19883
|
+
pagesRootBody = b[3];
|
|
19884
|
+
break;
|
|
19885
|
+
}
|
|
19886
|
+
}
|
|
19887
|
+
}
|
|
19888
|
+
if (pagesRootBody) walkPdfPageTree(objMap, pagesRootBody, { mediaBox: null, rotate: 0 }, visited, "root", out);
|
|
19889
|
+
if (out.length === 0) {
|
|
19890
|
+
for (const b of objBlocks) {
|
|
19891
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(b[3])) {
|
|
19892
|
+
out.push(buildPdfPageDimension(out.length + 1, parsePdfMediaBox(b[3]), parsePdfRotate(b[3]) ?? 0));
|
|
19893
|
+
}
|
|
19894
|
+
}
|
|
19895
|
+
}
|
|
19896
|
+
if (out.length === 0) return { error: "Could not locate any page objects in this PDF" };
|
|
19897
|
+
return { version: version2, pageCount: out.length, pages: out };
|
|
19898
|
+
}
|
|
19699
19899
|
var AUDIO_FORMAT_LABELS = {
|
|
19700
19900
|
1: "PCM",
|
|
19701
19901
|
3: "IEEE float",
|
package/dist/index.d.cts
CHANGED
|
@@ -6,14 +6,14 @@ export { d as data } from './data-XRb0D7Zn.cjs';
|
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.cjs';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
8
|
export { u as units } from './units-COt5uI20.cjs';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-D7Epuerc.cjs';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.cjs';
|
|
11
11
|
export { c as code } from './code-DaRvff2v.cjs';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.cjs';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.cjs';
|
|
15
15
|
export { a as ai_agent } from './ai_agent-B-c59NXD.cjs';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-fD8dJ5qR.cjs';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@ export { d as data } from './data-XRb0D7Zn.js';
|
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.js';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.js';
|
|
8
8
|
export { u as units } from './units-COt5uI20.js';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-D7Epuerc.js';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.js';
|
|
11
11
|
export { c as code } from './code-DaRvff2v.js';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.js';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.js';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.js';
|
|
15
15
|
export { a as ai_agent } from './ai_agent-B-c59NXD.js';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-fD8dJ5qR.js';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { media_exports as media } from './chunk-
|
|
1
|
+
export { media_exports as media } from './chunk-L6V4W4SU.js';
|
|
2
2
|
export { units_exports as units } from './chunk-I63BCOAG.js';
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
3
|
+
export { network_exports as network } from './chunk-CSNTHZHF.js';
|
|
4
4
|
export { api_exports as api } from './chunk-52ZDKSIX.js';
|
|
5
5
|
export { code_exports as code } from './chunk-LXKIPPDG.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
@@ -64,6 +64,29 @@ interface PdfMetadataError {
|
|
|
64
64
|
* pdf.js or other PDF rendering library required.
|
|
65
65
|
*/
|
|
66
66
|
declare function readPdfMetadata(bytes: Uint8Array): PdfMetadata | PdfMetadataError;
|
|
67
|
+
type PdfPageOrientation = 'portrait' | 'landscape' | 'square' | null;
|
|
68
|
+
interface PdfPageDimension {
|
|
69
|
+
pageNumber: number;
|
|
70
|
+
widthPt: number | null;
|
|
71
|
+
heightPt: number | null;
|
|
72
|
+
widthIn: number | null;
|
|
73
|
+
heightIn: number | null;
|
|
74
|
+
rotation: number;
|
|
75
|
+
orientation: PdfPageOrientation;
|
|
76
|
+
paperSize: string | null;
|
|
77
|
+
}
|
|
78
|
+
interface PdfPageDimensionsResult {
|
|
79
|
+
version: string | null;
|
|
80
|
+
pageCount: number;
|
|
81
|
+
pages: PdfPageDimension[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* List each page's MediaBox width/height (in points and inches), rotation,
|
|
85
|
+
* and orientation, in document order — walking the Root -> Pages -> Kids
|
|
86
|
+
* tree and inheriting /MediaBox / /Rotate from ancestor nodes the way the
|
|
87
|
+
* PDF spec requires. No PDF rendering library required.
|
|
88
|
+
*/
|
|
89
|
+
declare function readPdfPageDimensions(bytes: Uint8Array): PdfPageDimensionsResult | PdfMetadataError;
|
|
67
90
|
interface WavInfo {
|
|
68
91
|
audioFormat: number;
|
|
69
92
|
audioFormatLabel: string;
|
|
@@ -194,6 +217,9 @@ type media_ImageInfo = ImageInfo;
|
|
|
194
217
|
type media_ImageInfoError = ImageInfoError;
|
|
195
218
|
type media_PdfMetadata = PdfMetadata;
|
|
196
219
|
type media_PdfMetadataError = PdfMetadataError;
|
|
220
|
+
type media_PdfPageDimension = PdfPageDimension;
|
|
221
|
+
type media_PdfPageDimensionsResult = PdfPageDimensionsResult;
|
|
222
|
+
type media_PdfPageOrientation = PdfPageOrientation;
|
|
197
223
|
type media_VideoInfo = VideoInfo;
|
|
198
224
|
type media_VideoInfoError = VideoInfoError;
|
|
199
225
|
type media_WavInfo = WavInfo;
|
|
@@ -204,10 +230,11 @@ declare const media_readIcoInfo: typeof readIcoInfo;
|
|
|
204
230
|
declare const media_readId3Tags: typeof readId3Tags;
|
|
205
231
|
declare const media_readImageInfo: typeof readImageInfo;
|
|
206
232
|
declare const media_readPdfMetadata: typeof readPdfMetadata;
|
|
233
|
+
declare const media_readPdfPageDimensions: typeof readPdfPageDimensions;
|
|
207
234
|
declare const media_readVideoInfo: typeof readVideoInfo;
|
|
208
235
|
declare const media_readWavInfo: typeof readWavInfo;
|
|
209
236
|
declare namespace media {
|
|
210
|
-
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_VideoInfo as VideoInfo, type media_VideoInfoError as VideoInfoError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readFlacInfo as readFlacInfo, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readVideoInfo as readVideoInfo, media_readWavInfo as readWavInfo };
|
|
237
|
+
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_PdfPageDimension as PdfPageDimension, type media_PdfPageDimensionsResult as PdfPageDimensionsResult, type media_PdfPageOrientation as PdfPageOrientation, type media_VideoInfo as VideoInfo, type media_VideoInfoError as VideoInfoError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readFlacInfo as readFlacInfo, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readPdfPageDimensions as readPdfPageDimensions, media_readVideoInfo as readVideoInfo, media_readWavInfo as readWavInfo };
|
|
211
238
|
}
|
|
212
239
|
|
|
213
|
-
export { type ExifData as E, type FlacInfo as F, type IcoImageEntry as I, type PdfMetadata as P, type VideoInfo as V, type WavInfo as W, type ExifError as a, type FlacInfoError as b, type IcoInfo as c, type IcoInfoError as d, type Id3Tags as e, type Id3TagsError as f, type ImageFormat as g, type ImageInfo as h, type ImageInfoError as i, type PdfMetadataError as j, type
|
|
240
|
+
export { type ExifData as E, type FlacInfo as F, type IcoImageEntry as I, type PdfMetadata as P, type VideoInfo as V, type WavInfo as W, type ExifError as a, type FlacInfoError as b, type IcoInfo as c, type IcoInfoError as d, type Id3Tags as e, type Id3TagsError as f, type ImageFormat as g, type ImageInfo as h, type ImageInfoError as i, type PdfMetadataError as j, type PdfPageDimension as k, type PdfPageDimensionsResult as l, media as m, type PdfPageOrientation as n, type VideoInfoError as o, type WavInfoError as p, readFlacInfo as q, readExifData as r, readIcoInfo as s, readId3Tags as t, readImageInfo as u, readPdfMetadata as v, readPdfPageDimensions as w, readVideoInfo as x, readWavInfo as y };
|
|
@@ -64,6 +64,29 @@ interface PdfMetadataError {
|
|
|
64
64
|
* pdf.js or other PDF rendering library required.
|
|
65
65
|
*/
|
|
66
66
|
declare function readPdfMetadata(bytes: Uint8Array): PdfMetadata | PdfMetadataError;
|
|
67
|
+
type PdfPageOrientation = 'portrait' | 'landscape' | 'square' | null;
|
|
68
|
+
interface PdfPageDimension {
|
|
69
|
+
pageNumber: number;
|
|
70
|
+
widthPt: number | null;
|
|
71
|
+
heightPt: number | null;
|
|
72
|
+
widthIn: number | null;
|
|
73
|
+
heightIn: number | null;
|
|
74
|
+
rotation: number;
|
|
75
|
+
orientation: PdfPageOrientation;
|
|
76
|
+
paperSize: string | null;
|
|
77
|
+
}
|
|
78
|
+
interface PdfPageDimensionsResult {
|
|
79
|
+
version: string | null;
|
|
80
|
+
pageCount: number;
|
|
81
|
+
pages: PdfPageDimension[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* List each page's MediaBox width/height (in points and inches), rotation,
|
|
85
|
+
* and orientation, in document order — walking the Root -> Pages -> Kids
|
|
86
|
+
* tree and inheriting /MediaBox / /Rotate from ancestor nodes the way the
|
|
87
|
+
* PDF spec requires. No PDF rendering library required.
|
|
88
|
+
*/
|
|
89
|
+
declare function readPdfPageDimensions(bytes: Uint8Array): PdfPageDimensionsResult | PdfMetadataError;
|
|
67
90
|
interface WavInfo {
|
|
68
91
|
audioFormat: number;
|
|
69
92
|
audioFormatLabel: string;
|
|
@@ -194,6 +217,9 @@ type media_ImageInfo = ImageInfo;
|
|
|
194
217
|
type media_ImageInfoError = ImageInfoError;
|
|
195
218
|
type media_PdfMetadata = PdfMetadata;
|
|
196
219
|
type media_PdfMetadataError = PdfMetadataError;
|
|
220
|
+
type media_PdfPageDimension = PdfPageDimension;
|
|
221
|
+
type media_PdfPageDimensionsResult = PdfPageDimensionsResult;
|
|
222
|
+
type media_PdfPageOrientation = PdfPageOrientation;
|
|
197
223
|
type media_VideoInfo = VideoInfo;
|
|
198
224
|
type media_VideoInfoError = VideoInfoError;
|
|
199
225
|
type media_WavInfo = WavInfo;
|
|
@@ -204,10 +230,11 @@ declare const media_readIcoInfo: typeof readIcoInfo;
|
|
|
204
230
|
declare const media_readId3Tags: typeof readId3Tags;
|
|
205
231
|
declare const media_readImageInfo: typeof readImageInfo;
|
|
206
232
|
declare const media_readPdfMetadata: typeof readPdfMetadata;
|
|
233
|
+
declare const media_readPdfPageDimensions: typeof readPdfPageDimensions;
|
|
207
234
|
declare const media_readVideoInfo: typeof readVideoInfo;
|
|
208
235
|
declare const media_readWavInfo: typeof readWavInfo;
|
|
209
236
|
declare namespace media {
|
|
210
|
-
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_VideoInfo as VideoInfo, type media_VideoInfoError as VideoInfoError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readFlacInfo as readFlacInfo, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readVideoInfo as readVideoInfo, media_readWavInfo as readWavInfo };
|
|
237
|
+
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_PdfPageDimension as PdfPageDimension, type media_PdfPageDimensionsResult as PdfPageDimensionsResult, type media_PdfPageOrientation as PdfPageOrientation, type media_VideoInfo as VideoInfo, type media_VideoInfoError as VideoInfoError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readFlacInfo as readFlacInfo, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readPdfPageDimensions as readPdfPageDimensions, media_readVideoInfo as readVideoInfo, media_readWavInfo as readWavInfo };
|
|
211
238
|
}
|
|
212
239
|
|
|
213
|
-
export { type ExifData as E, type FlacInfo as F, type IcoImageEntry as I, type PdfMetadata as P, type VideoInfo as V, type WavInfo as W, type ExifError as a, type FlacInfoError as b, type IcoInfo as c, type IcoInfoError as d, type Id3Tags as e, type Id3TagsError as f, type ImageFormat as g, type ImageInfo as h, type ImageInfoError as i, type PdfMetadataError as j, type
|
|
240
|
+
export { type ExifData as E, type FlacInfo as F, type IcoImageEntry as I, type PdfMetadata as P, type VideoInfo as V, type WavInfo as W, type ExifError as a, type FlacInfoError as b, type IcoInfo as c, type IcoInfoError as d, type Id3Tags as e, type Id3TagsError as f, type ImageFormat as g, type ImageInfo as h, type ImageInfoError as i, type PdfMetadataError as j, type PdfPageDimension as k, type PdfPageDimensionsResult as l, media as m, type PdfPageOrientation as n, type VideoInfoError as o, type WavInfoError as p, readFlacInfo as q, readExifData as r, readIcoInfo as s, readId3Tags as t, readImageInfo as u, readPdfMetadata as v, readPdfPageDimensions as w, readVideoInfo as x, readWavInfo as y };
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
13
|
* - user-agent-parser: parseUserAgent
|
|
14
14
|
* - cache-control-builder: buildCacheControl
|
|
15
|
+
* - ipv6-compressor: parseIpv6Address
|
|
15
16
|
*/
|
|
16
17
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
17
18
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -291,6 +292,23 @@ interface CacheControlResult {
|
|
|
291
292
|
declare function buildCacheControl(options?: CacheControlOptions): CacheControlResult | {
|
|
292
293
|
error: string;
|
|
293
294
|
};
|
|
295
|
+
type Ipv6AddressType = 'unspecified' | 'loopback' | 'link-local' | 'unique-local' | 'multicast' | 'ipv4-mapped' | 'documentation' | 'global-unicast';
|
|
296
|
+
interface Ipv6ParseResult {
|
|
297
|
+
expanded: string;
|
|
298
|
+
compressed: string;
|
|
299
|
+
groups: string[];
|
|
300
|
+
zoneId: string | null;
|
|
301
|
+
addressType: Ipv6AddressType;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Parse an IPv6 address into its expanded (full 8-group) and compressed
|
|
305
|
+
* (RFC 5952 canonical shortest) forms, classify its address type, and
|
|
306
|
+
* separate out an optional zone ID. Understands "::" shorthand and an
|
|
307
|
+
* embedded IPv4 suffix like "::ffff:192.168.1.1".
|
|
308
|
+
*/
|
|
309
|
+
declare function parseIpv6Address(input: string): Ipv6ParseResult | {
|
|
310
|
+
error: string;
|
|
311
|
+
};
|
|
294
312
|
|
|
295
313
|
type network_CacheControlDirective = CacheControlDirective;
|
|
296
314
|
type network_CacheControlOptions = CacheControlOptions;
|
|
@@ -306,6 +324,8 @@ type network_HarParseResult = HarParseResult;
|
|
|
306
324
|
type network_HarSummary = HarSummary;
|
|
307
325
|
type network_HeaderCategory = HeaderCategory;
|
|
308
326
|
type network_HttpHeader = HttpHeader;
|
|
327
|
+
type network_Ipv6AddressType = Ipv6AddressType;
|
|
328
|
+
type network_Ipv6ParseResult = Ipv6ParseResult;
|
|
309
329
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
310
330
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
311
331
|
type network_RobotsGroup = RobotsGroup;
|
|
@@ -341,6 +361,7 @@ declare const network_isValidIpv6: typeof isValidIpv6;
|
|
|
341
361
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
342
362
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
343
363
|
declare const network_parseHar: typeof parseHar;
|
|
364
|
+
declare const network_parseIpv6Address: typeof parseIpv6Address;
|
|
344
365
|
declare const network_parseUserAgent: typeof parseUserAgent;
|
|
345
366
|
declare const network_searchHeaders: typeof searchHeaders;
|
|
346
367
|
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
@@ -352,7 +373,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
352
373
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
353
374
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
354
375
|
declare namespace network {
|
|
355
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
376
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
356
377
|
}
|
|
357
378
|
|
|
358
|
-
export {
|
|
379
|
+
export { parseUserAgent as $, countryCodeToFlag as A, formatCoordinates as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, formatTtl as E, getByCategory as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, getHeader as J, getHeadersByCategory as K, getStatusByCategory as L, getStatusCode as M, isClientError as N, isServerError as O, type ParsedDnsResult as P, isSuccess as Q, type RobotsGroup as R, STATUS_CODES as S, isValidIp as T, type UaDeviceType as U, isValidIpv4 as V, isValidIpv6 as W, parseDnsResponse as X, parseGeoResponse as Y, parseHar as Z, parseIpv6Address as _, type CacheControlOptions as a, searchHeaders as a0, searchStatusCodes as a1, statusCodeToText as a2, typeNumberToLabel as a3, validateDomain as a4, validateHeaderName as a5, validateHeaderValue as a6, validateRobotsTxt as a7, validateSitemap as a8, type CacheControlResult as b, type DnsRecord as c, type DnsRecordType as d, type DnsResponse as e, type HarEntry as f, type HarParseResult as g, type HarSummary as h, type HeaderCategory as i, type HttpHeader as j, type Ipv6ParseResult as k, type ParsedGeoResult as l, type RobotsIssue as m, network as n, type RobotsRule as o, type RobotsValidationResult as p, type SitemapIndexEntry as q, type SitemapIssue as r, type SitemapUrlEntry as s, type SitemapValidationResult as t, type StatusCode as u, type UserAgentInfo as v, buildCacheControl as w, buildDnsQueryUrl as x, buildGeoUrl as y, buildMapUrl as z };
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
13
|
* - user-agent-parser: parseUserAgent
|
|
14
14
|
* - cache-control-builder: buildCacheControl
|
|
15
|
+
* - ipv6-compressor: parseIpv6Address
|
|
15
16
|
*/
|
|
16
17
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
17
18
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -291,6 +292,23 @@ interface CacheControlResult {
|
|
|
291
292
|
declare function buildCacheControl(options?: CacheControlOptions): CacheControlResult | {
|
|
292
293
|
error: string;
|
|
293
294
|
};
|
|
295
|
+
type Ipv6AddressType = 'unspecified' | 'loopback' | 'link-local' | 'unique-local' | 'multicast' | 'ipv4-mapped' | 'documentation' | 'global-unicast';
|
|
296
|
+
interface Ipv6ParseResult {
|
|
297
|
+
expanded: string;
|
|
298
|
+
compressed: string;
|
|
299
|
+
groups: string[];
|
|
300
|
+
zoneId: string | null;
|
|
301
|
+
addressType: Ipv6AddressType;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Parse an IPv6 address into its expanded (full 8-group) and compressed
|
|
305
|
+
* (RFC 5952 canonical shortest) forms, classify its address type, and
|
|
306
|
+
* separate out an optional zone ID. Understands "::" shorthand and an
|
|
307
|
+
* embedded IPv4 suffix like "::ffff:192.168.1.1".
|
|
308
|
+
*/
|
|
309
|
+
declare function parseIpv6Address(input: string): Ipv6ParseResult | {
|
|
310
|
+
error: string;
|
|
311
|
+
};
|
|
294
312
|
|
|
295
313
|
type network_CacheControlDirective = CacheControlDirective;
|
|
296
314
|
type network_CacheControlOptions = CacheControlOptions;
|
|
@@ -306,6 +324,8 @@ type network_HarParseResult = HarParseResult;
|
|
|
306
324
|
type network_HarSummary = HarSummary;
|
|
307
325
|
type network_HeaderCategory = HeaderCategory;
|
|
308
326
|
type network_HttpHeader = HttpHeader;
|
|
327
|
+
type network_Ipv6AddressType = Ipv6AddressType;
|
|
328
|
+
type network_Ipv6ParseResult = Ipv6ParseResult;
|
|
309
329
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
310
330
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
311
331
|
type network_RobotsGroup = RobotsGroup;
|
|
@@ -341,6 +361,7 @@ declare const network_isValidIpv6: typeof isValidIpv6;
|
|
|
341
361
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
342
362
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
343
363
|
declare const network_parseHar: typeof parseHar;
|
|
364
|
+
declare const network_parseIpv6Address: typeof parseIpv6Address;
|
|
344
365
|
declare const network_parseUserAgent: typeof parseUserAgent;
|
|
345
366
|
declare const network_searchHeaders: typeof searchHeaders;
|
|
346
367
|
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
@@ -352,7 +373,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
352
373
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
353
374
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
354
375
|
declare namespace network {
|
|
355
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
376
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
356
377
|
}
|
|
357
378
|
|
|
358
|
-
export {
|
|
379
|
+
export { parseUserAgent as $, countryCodeToFlag as A, formatCoordinates as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, formatTtl as E, getByCategory as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, getHeader as J, getHeadersByCategory as K, getStatusByCategory as L, getStatusCode as M, isClientError as N, isServerError as O, type ParsedDnsResult as P, isSuccess as Q, type RobotsGroup as R, STATUS_CODES as S, isValidIp as T, type UaDeviceType as U, isValidIpv4 as V, isValidIpv6 as W, parseDnsResponse as X, parseGeoResponse as Y, parseHar as Z, parseIpv6Address as _, type CacheControlOptions as a, searchHeaders as a0, searchStatusCodes as a1, statusCodeToText as a2, typeNumberToLabel as a3, validateDomain as a4, validateHeaderName as a5, validateHeaderValue as a6, validateRobotsTxt as a7, validateSitemap as a8, type CacheControlResult as b, type DnsRecord as c, type DnsRecordType as d, type DnsResponse as e, type HarEntry as f, type HarParseResult as g, type HarSummary as h, type HeaderCategory as i, type HttpHeader as j, type Ipv6ParseResult as k, type ParsedGeoResult as l, type RobotsIssue as m, network as n, type RobotsRule as o, type RobotsValidationResult as p, type SitemapIndexEntry as q, type SitemapIssue as r, type SitemapUrlEntry as s, type SitemapValidationResult as t, type StatusCode as u, type UserAgentInfo as v, buildCacheControl as w, buildDnsQueryUrl as x, buildGeoUrl as y, buildMapUrl as z };
|
package/dist/tools/media.cjs
CHANGED
|
@@ -457,6 +457,116 @@ function readPdfMetadata(bytes) {
|
|
|
457
457
|
encrypted
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
|
+
var PDF_COMMON_PAPER_SIZES = [
|
|
461
|
+
{ name: "Letter", widthPt: 612, heightPt: 792 },
|
|
462
|
+
{ name: "Legal", widthPt: 612, heightPt: 1008 },
|
|
463
|
+
{ name: "Tabloid", widthPt: 792, heightPt: 1224 },
|
|
464
|
+
{ name: "A3", widthPt: 842, heightPt: 1191 },
|
|
465
|
+
{ name: "A4", widthPt: 595, heightPt: 842 },
|
|
466
|
+
{ name: "A5", widthPt: 420, heightPt: 595 },
|
|
467
|
+
{ name: "B5", widthPt: 499, heightPt: 709 }
|
|
468
|
+
];
|
|
469
|
+
function matchPaperSize(widthPt, heightPt) {
|
|
470
|
+
for (const size of PDF_COMMON_PAPER_SIZES) {
|
|
471
|
+
const w = Math.abs(widthPt - size.widthPt) <= 1;
|
|
472
|
+
const h = Math.abs(heightPt - size.heightPt) <= 1;
|
|
473
|
+
const wSwapped = Math.abs(widthPt - size.heightPt) <= 1;
|
|
474
|
+
const hSwapped = Math.abs(heightPt - size.widthPt) <= 1;
|
|
475
|
+
if (w && h || wSwapped && hSwapped) return size.name;
|
|
476
|
+
}
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
function parsePdfMediaBox(dict) {
|
|
480
|
+
const m = dict.match(/\/MediaBox\s*\[\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*\]/);
|
|
481
|
+
if (!m) return null;
|
|
482
|
+
return [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])];
|
|
483
|
+
}
|
|
484
|
+
function parsePdfRotate(dict) {
|
|
485
|
+
const m = dict.match(/\/Rotate\s+(-?\d+)/);
|
|
486
|
+
return m ? Number(m[1]) : null;
|
|
487
|
+
}
|
|
488
|
+
function buildPdfPageDimension(pageNumber, mediaBox, rotate) {
|
|
489
|
+
const rotation = (rotate % 360 + 360) % 360;
|
|
490
|
+
if (!mediaBox) {
|
|
491
|
+
return { pageNumber, widthPt: null, heightPt: null, widthIn: null, heightIn: null, rotation, orientation: null, paperSize: null };
|
|
492
|
+
}
|
|
493
|
+
const [llx, lly, urx, ury] = mediaBox;
|
|
494
|
+
let widthPt = Math.abs(urx - llx);
|
|
495
|
+
let heightPt = Math.abs(ury - lly);
|
|
496
|
+
if (rotation === 90 || rotation === 270) [widthPt, heightPt] = [heightPt, widthPt];
|
|
497
|
+
const orientation = widthPt === heightPt ? "square" : widthPt > heightPt ? "landscape" : "portrait";
|
|
498
|
+
return {
|
|
499
|
+
pageNumber,
|
|
500
|
+
widthPt: round2(widthPt),
|
|
501
|
+
heightPt: round2(heightPt),
|
|
502
|
+
widthIn: round2(widthPt / 72),
|
|
503
|
+
heightIn: round2(heightPt / 72),
|
|
504
|
+
rotation,
|
|
505
|
+
orientation,
|
|
506
|
+
paperSize: matchPaperSize(widthPt, heightPt)
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function walkPdfPageTree(objMap, nodeBody, inherited, visited, nodeKey, out) {
|
|
510
|
+
if (visited.has(nodeKey)) return;
|
|
511
|
+
visited.add(nodeKey);
|
|
512
|
+
const mediaBox = parsePdfMediaBox(nodeBody) ?? inherited.mediaBox;
|
|
513
|
+
const rotateMatch = parsePdfRotate(nodeBody);
|
|
514
|
+
const rotate = rotateMatch !== null ? rotateMatch : inherited.rotate;
|
|
515
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(nodeBody)) {
|
|
516
|
+
out.push(buildPdfPageDimension(out.length + 1, mediaBox, rotate));
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
const kidsMatch = nodeBody.match(/\/Kids\s*\[([^\]]*)\]/);
|
|
520
|
+
if (!kidsMatch) return;
|
|
521
|
+
const kidRefs = [...kidsMatch[1].matchAll(/(\d+)\s+(\d+)\s+R/g)];
|
|
522
|
+
for (const ref of kidRefs) {
|
|
523
|
+
const key = `${ref[1]} ${ref[2]}`;
|
|
524
|
+
const body = objMap.get(key);
|
|
525
|
+
if (body) walkPdfPageTree(objMap, body, { mediaBox, rotate }, visited, key, out);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
function readPdfPageDimensions(bytes) {
|
|
529
|
+
if (bytes.length < 8) return { error: "File too small to be a PDF" };
|
|
530
|
+
const header = bytesToLatin1(bytes.subarray(0, 16));
|
|
531
|
+
const versionMatch = header.match(/%PDF-(\d\.\d)/);
|
|
532
|
+
if (!versionMatch) return { error: "Not a valid PDF file (missing %PDF header)" };
|
|
533
|
+
const version = versionMatch[1];
|
|
534
|
+
const text = bytesToLatin1(bytes);
|
|
535
|
+
const objBlocks = [...text.matchAll(/(\d+)\s+(\d+)\s+obj([\s\S]*?)endobj/g)];
|
|
536
|
+
const objMap = /* @__PURE__ */ new Map();
|
|
537
|
+
for (const b of objBlocks) objMap.set(`${b[1]} ${b[2]}`, b[3]);
|
|
538
|
+
const out = [];
|
|
539
|
+
const visited = /* @__PURE__ */ new Set();
|
|
540
|
+
let pagesRootBody = null;
|
|
541
|
+
const trailerMatches = [...text.matchAll(/trailer\s*<<([\s\S]*?)>>/g)];
|
|
542
|
+
if (trailerMatches.length > 0) {
|
|
543
|
+
const trailer = trailerMatches[trailerMatches.length - 1][1];
|
|
544
|
+
const rootRef = trailer.match(/\/Root\s+(\d+)\s+(\d+)\s+R/);
|
|
545
|
+
if (rootRef) {
|
|
546
|
+
const catalogBody = objMap.get(`${rootRef[1]} ${rootRef[2]}`);
|
|
547
|
+
const pagesRef = catalogBody?.match(/\/Pages\s+(\d+)\s+(\d+)\s+R/);
|
|
548
|
+
if (pagesRef) pagesRootBody = objMap.get(`${pagesRef[1]} ${pagesRef[2]}`) ?? null;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
if (!pagesRootBody) {
|
|
552
|
+
for (const b of objBlocks) {
|
|
553
|
+
if (/\/Type\s*\/Pages\b/.test(b[3]) && !/\/Parent\s+\d+\s+\d+\s+R/.test(b[3])) {
|
|
554
|
+
pagesRootBody = b[3];
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (pagesRootBody) walkPdfPageTree(objMap, pagesRootBody, { mediaBox: null, rotate: 0 }, visited, "root", out);
|
|
560
|
+
if (out.length === 0) {
|
|
561
|
+
for (const b of objBlocks) {
|
|
562
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(b[3])) {
|
|
563
|
+
out.push(buildPdfPageDimension(out.length + 1, parsePdfMediaBox(b[3]), parsePdfRotate(b[3]) ?? 0));
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
if (out.length === 0) return { error: "Could not locate any page objects in this PDF" };
|
|
568
|
+
return { version, pageCount: out.length, pages: out };
|
|
569
|
+
}
|
|
460
570
|
var AUDIO_FORMAT_LABELS = {
|
|
461
571
|
1: "PCM",
|
|
462
572
|
3: "IEEE float",
|
|
@@ -1105,5 +1215,6 @@ exports.readIcoInfo = readIcoInfo;
|
|
|
1105
1215
|
exports.readId3Tags = readId3Tags;
|
|
1106
1216
|
exports.readImageInfo = readImageInfo;
|
|
1107
1217
|
exports.readPdfMetadata = readPdfMetadata;
|
|
1218
|
+
exports.readPdfPageDimensions = readPdfPageDimensions;
|
|
1108
1219
|
exports.readVideoInfo = readVideoInfo;
|
|
1109
1220
|
exports.readWavInfo = readWavInfo;
|
package/dist/tools/media.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, V as VideoInfo,
|
|
1
|
+
export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, k as PdfPageDimension, l as PdfPageDimensionsResult, n as PdfPageOrientation, V as VideoInfo, o as VideoInfoError, W as WavInfo, p as WavInfoError, r as readExifData, q as readFlacInfo, s as readIcoInfo, t as readId3Tags, u as readImageInfo, v as readPdfMetadata, w as readPdfPageDimensions, x as readVideoInfo, y as readWavInfo } from '../media-fD8dJ5qR.cjs';
|
package/dist/tools/media.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, V as VideoInfo,
|
|
1
|
+
export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, k as PdfPageDimension, l as PdfPageDimensionsResult, n as PdfPageOrientation, V as VideoInfo, o as VideoInfoError, W as WavInfo, p as WavInfoError, r as readExifData, q as readFlacInfo, s as readIcoInfo, t as readId3Tags, u as readImageInfo, v as readPdfMetadata, w as readPdfPageDimensions, x as readVideoInfo, y as readWavInfo } from '../media-fD8dJ5qR.js';
|
package/dist/tools/media.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readVideoInfo, readWavInfo } from '../chunk-
|
|
1
|
+
export { readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readPdfPageDimensions, readVideoInfo, readWavInfo } from '../chunk-L6V4W4SU.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/network.cjs
CHANGED
|
@@ -1777,6 +1777,94 @@ function buildCacheControl(options = {}) {
|
|
|
1777
1777
|
const snippet = `Cache-Control: ${header}`;
|
|
1778
1778
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
1779
1779
|
}
|
|
1780
|
+
function isValidIpv6HexGroup(g) {
|
|
1781
|
+
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
1782
|
+
}
|
|
1783
|
+
function isValidIpv6Ipv4Quad(quad) {
|
|
1784
|
+
const parts = quad.split(".");
|
|
1785
|
+
if (parts.length !== 4) return false;
|
|
1786
|
+
return parts.every((p) => /^\d{1,3}$/.test(p) && Number(p) <= 255);
|
|
1787
|
+
}
|
|
1788
|
+
function classifyIpv6(groups) {
|
|
1789
|
+
const first = parseInt(groups[0], 16);
|
|
1790
|
+
if (groups.every((g) => g === "0000")) return "unspecified";
|
|
1791
|
+
if (groups.slice(0, 7).every((g) => g === "0000") && groups[7] === "0001") return "loopback";
|
|
1792
|
+
if (groups.slice(0, 4).every((g) => g === "0000") && groups[4] === "0000" && groups[5] === "ffff") return "ipv4-mapped";
|
|
1793
|
+
if (groups[0] === "2001" && groups[1] === "0db8") return "documentation";
|
|
1794
|
+
if ((first & 65280) === 65280) return "multicast";
|
|
1795
|
+
if ((first & 65472) === 65152) return "link-local";
|
|
1796
|
+
if ((first & 65024) === 64512) return "unique-local";
|
|
1797
|
+
return "global-unicast";
|
|
1798
|
+
}
|
|
1799
|
+
function compressIpv6Groups(groups) {
|
|
1800
|
+
const short = groups.map((g) => g.replace(/^0+(?=.)/, ""));
|
|
1801
|
+
let bestStart = -1;
|
|
1802
|
+
let bestLen = 0;
|
|
1803
|
+
let curStart = -1;
|
|
1804
|
+
let curLen = 0;
|
|
1805
|
+
for (let i = 0; i < short.length; i++) {
|
|
1806
|
+
if (short[i] === "0") {
|
|
1807
|
+
if (curStart === -1) curStart = i;
|
|
1808
|
+
curLen++;
|
|
1809
|
+
if (curLen > bestLen) {
|
|
1810
|
+
bestLen = curLen;
|
|
1811
|
+
bestStart = curStart;
|
|
1812
|
+
}
|
|
1813
|
+
} else {
|
|
1814
|
+
curStart = -1;
|
|
1815
|
+
curLen = 0;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (bestLen < 2) return short.join(":");
|
|
1819
|
+
const before = short.slice(0, bestStart).join(":");
|
|
1820
|
+
const after = short.slice(bestStart + bestLen).join(":");
|
|
1821
|
+
return `${before}::${after}`;
|
|
1822
|
+
}
|
|
1823
|
+
function parseIpv6Address(input) {
|
|
1824
|
+
let s = input.trim();
|
|
1825
|
+
if (s.startsWith("[") && s.includes("]")) s = s.slice(1, s.indexOf("]"));
|
|
1826
|
+
let zoneId = null;
|
|
1827
|
+
const pctIdx = s.indexOf("%");
|
|
1828
|
+
if (pctIdx !== -1) {
|
|
1829
|
+
zoneId = s.slice(pctIdx + 1);
|
|
1830
|
+
s = s.slice(0, pctIdx);
|
|
1831
|
+
}
|
|
1832
|
+
if (!s) return { error: "Empty address" };
|
|
1833
|
+
const doubleColonCount = (s.match(/::/g) ?? []).length;
|
|
1834
|
+
if (doubleColonCount > 1) return { error: 'Address contains more than one "::"' };
|
|
1835
|
+
const ipv4Match = s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1836
|
+
if (ipv4Match) {
|
|
1837
|
+
const quad = ipv4Match[1];
|
|
1838
|
+
if (!isValidIpv6Ipv4Quad(quad)) return { error: `Invalid embedded IPv4 address: ${quad}` };
|
|
1839
|
+
const parts = quad.split(".").map(Number);
|
|
1840
|
+
const hi = (parts[0] << 8 | parts[1]).toString(16);
|
|
1841
|
+
const lo = (parts[2] << 8 | parts[3]).toString(16);
|
|
1842
|
+
s = s.slice(0, s.length - quad.length) + `${hi}:${lo}`;
|
|
1843
|
+
}
|
|
1844
|
+
let groups;
|
|
1845
|
+
if (s.includes("::")) {
|
|
1846
|
+
const [left, right] = s.split("::");
|
|
1847
|
+
const leftGroups = left ? left.split(":") : [];
|
|
1848
|
+
const rightGroups = right ? right.split(":") : [];
|
|
1849
|
+
const missing = 8 - (leftGroups.length + rightGroups.length);
|
|
1850
|
+
if (missing < 1) return { error: 'The "::" shorthand must represent at least one group of zeros' };
|
|
1851
|
+
if (![...leftGroups, ...rightGroups].every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
1852
|
+
groups = [...leftGroups, ...Array(missing).fill("0"), ...rightGroups];
|
|
1853
|
+
} else {
|
|
1854
|
+
groups = s.split(":");
|
|
1855
|
+
if (groups.length !== 8) return { error: `Expected 8 groups, got ${groups.length}` };
|
|
1856
|
+
if (!groups.every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
1857
|
+
}
|
|
1858
|
+
const expandedGroups = groups.map((g) => g.padStart(4, "0").toLowerCase());
|
|
1859
|
+
const suffix = zoneId ? `%${zoneId}` : "";
|
|
1860
|
+
return {
|
|
1861
|
+
expanded: expandedGroups.join(":") + suffix,
|
|
1862
|
+
compressed: compressIpv6Groups(expandedGroups) + suffix,
|
|
1863
|
+
groups: expandedGroups,
|
|
1864
|
+
zoneId,
|
|
1865
|
+
addressType: classifyIpv6(expandedGroups)
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1780
1868
|
|
|
1781
1869
|
exports.DNS_RECORD_TYPES = DNS_RECORD_TYPES;
|
|
1782
1870
|
exports.HTTP_HEADERS = HTTP_HEADERS;
|
|
@@ -1802,6 +1890,7 @@ exports.isValidIpv6 = isValidIpv6;
|
|
|
1802
1890
|
exports.parseDnsResponse = parseDnsResponse;
|
|
1803
1891
|
exports.parseGeoResponse = parseGeoResponse;
|
|
1804
1892
|
exports.parseHar = parseHar;
|
|
1893
|
+
exports.parseIpv6Address = parseIpv6Address;
|
|
1805
1894
|
exports.parseUserAgent = parseUserAgent;
|
|
1806
1895
|
exports.searchHeaders = searchHeaders;
|
|
1807
1896
|
exports.searchStatusCodes = searchStatusCodes;
|
package/dist/tools/network.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, P as ParsedDnsResult,
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as RobotsGroup, m as RobotsIssue, o as RobotsRule, p as RobotsValidationResult, S as STATUS_CODES, q as SitemapIndexEntry, r as SitemapIssue, s as SitemapUrlEntry, t as SitemapValidationResult, u as StatusCode, U as UaDeviceType, v as UserAgentInfo, w as buildCacheControl, x as buildDnsQueryUrl, y as buildGeoUrl, z as buildMapUrl, A as countryCodeToFlag, B as formatCoordinates, E as formatTtl, F as getByCategory, J as getHeader, K as getHeadersByCategory, L as getStatusByCategory, M as getStatusCode, N as isClientError, O as isServerError, Q as isSuccess, T as isValidIp, V as isValidIpv4, W as isValidIpv6, X as parseDnsResponse, Y as parseGeoResponse, Z as parseHar, _ as parseIpv6Address, $ as parseUserAgent, a0 as searchHeaders, a1 as searchStatusCodes, a2 as statusCodeToText, a3 as typeNumberToLabel, a4 as validateDomain, a5 as validateHeaderName, a6 as validateHeaderValue, a7 as validateRobotsTxt, a8 as validateSitemap } from '../network-D7Epuerc.cjs';
|
package/dist/tools/network.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, P as ParsedDnsResult,
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as RobotsGroup, m as RobotsIssue, o as RobotsRule, p as RobotsValidationResult, S as STATUS_CODES, q as SitemapIndexEntry, r as SitemapIssue, s as SitemapUrlEntry, t as SitemapValidationResult, u as StatusCode, U as UaDeviceType, v as UserAgentInfo, w as buildCacheControl, x as buildDnsQueryUrl, y as buildGeoUrl, z as buildMapUrl, A as countryCodeToFlag, B as formatCoordinates, E as formatTtl, F as getByCategory, J as getHeader, K as getHeadersByCategory, L as getStatusByCategory, M as getStatusCode, N as isClientError, O as isServerError, Q as isSuccess, T as isValidIp, V as isValidIpv4, W as isValidIpv6, X as parseDnsResponse, Y as parseGeoResponse, Z as parseHar, _ as parseIpv6Address, $ as parseUserAgent, a0 as searchHeaders, a1 as searchStatusCodes, a2 as statusCodeToText, a3 as typeNumberToLabel, a4 as validateDomain, a5 as validateHeaderName, a6 as validateHeaderValue, a7 as validateRobotsTxt, a8 as validateSitemap } from '../network-D7Epuerc.js';
|
package/dist/tools/network.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-
|
|
1
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-CSNTHZHF.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "154+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
|
|
5
5
|
"author": "Utilix <hello@utilix.tech>",
|
|
6
6
|
"license": "MIT",
|