@utilix-tech/sdk 0.46.0 → 0.48.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 +8 -0
- package/README.md +35 -10
- package/dist/{chunk-L6V4W4SU.js → chunk-226EH3ZI.js} +87 -1
- package/dist/{chunk-JR354NH4.js → chunk-4TIY6COQ.js} +64 -1
- package/dist/{chunk-7PEKYLRB.js → chunk-Y7YY733Z.js} +98 -1
- package/dist/{data-BKpEOcOX.d.ts → data-BJVJ879p.d.cts} +30 -2
- package/dist/{data-BKpEOcOX.d.cts → data-BJVJ879p.d.ts} +30 -2
- package/dist/index.cjs +253 -7
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{media-fD8dJ5qR.d.cts → media-BUvwm4wU.d.cts} +27 -2
- package/dist/{media-fD8dJ5qR.d.ts → media-BUvwm4wU.d.ts} +27 -2
- package/dist/{network-Bzm1tjMA.d.cts → network-DelcJeJa.d.cts} +70 -2
- package/dist/{network-Bzm1tjMA.d.ts → network-DelcJeJa.d.ts} +70 -2
- package/dist/tools/data.cjs +63 -0
- package/dist/tools/data.d.cts +1 -1
- package/dist/tools/data.d.ts +1 -1
- package/dist/tools/data.js +1 -1
- package/dist/tools/media.cjs +86 -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 +97 -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/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var yaml2 = require('js-yaml');
|
|
4
4
|
var crypto = require('crypto');
|
|
5
5
|
var md5 = require('blueimp-md5');
|
|
6
6
|
var bcrypt = require('bcryptjs');
|
|
@@ -28,7 +28,7 @@ function _interopNamespace(e) {
|
|
|
28
28
|
return Object.freeze(n);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var yaml2__namespace = /*#__PURE__*/_interopNamespace(yaml2);
|
|
32
32
|
var md5__default = /*#__PURE__*/_interopDefault(md5);
|
|
33
33
|
var bcrypt__default = /*#__PURE__*/_interopDefault(bcrypt);
|
|
34
34
|
var QRCode__default = /*#__PURE__*/_interopDefault(QRCode);
|
|
@@ -867,7 +867,7 @@ function yamlToJson(input, pretty = true) {
|
|
|
867
867
|
try {
|
|
868
868
|
const trimmed = input.trim();
|
|
869
869
|
if (trimmed === "") return JSON.stringify(null, null, pretty ? 2 : void 0);
|
|
870
|
-
const parsed =
|
|
870
|
+
const parsed = yaml2__namespace.load(trimmed);
|
|
871
871
|
const value = parsed === void 0 ? null : parsed;
|
|
872
872
|
return JSON.stringify(value, null, pretty ? 2 : void 0);
|
|
873
873
|
} catch (err) {
|
|
@@ -877,7 +877,7 @@ function yamlToJson(input, pretty = true) {
|
|
|
877
877
|
function jsonToYaml(input) {
|
|
878
878
|
try {
|
|
879
879
|
const parsed = JSON.parse(input);
|
|
880
|
-
return
|
|
880
|
+
return yaml2__namespace.dump(parsed);
|
|
881
881
|
} catch (err) {
|
|
882
882
|
return { error: err instanceof Error ? err.message : String(err) };
|
|
883
883
|
}
|
|
@@ -5186,6 +5186,7 @@ __export(data_exports, {
|
|
|
5186
5186
|
parseSubtitleTimestamp: () => parseSubtitleTimestamp,
|
|
5187
5187
|
parseSubtitles: () => parseSubtitles,
|
|
5188
5188
|
parseXmlToObject: () => parseXmlToObject,
|
|
5189
|
+
resolveYamlAnchors: () => resolveYamlAnchors,
|
|
5189
5190
|
serializeSubtitles: () => serializeSubtitles,
|
|
5190
5191
|
shiftSubtitles: () => shiftSubtitles,
|
|
5191
5192
|
stringifyIni: () => stringifyIni,
|
|
@@ -5205,7 +5206,7 @@ function validateYaml(input) {
|
|
|
5205
5206
|
}
|
|
5206
5207
|
try {
|
|
5207
5208
|
const docs = [];
|
|
5208
|
-
|
|
5209
|
+
yaml2__namespace.loadAll(input, (doc) => docs.push(doc));
|
|
5209
5210
|
const first = docs[0];
|
|
5210
5211
|
const keyCount = first && typeof first === "object" && first !== null ? Object.keys(first).length : 0;
|
|
5211
5212
|
return { valid: true, documentCount: docs.length, keyCount };
|
|
@@ -5239,7 +5240,7 @@ function _yamlCountKeys(value) {
|
|
|
5239
5240
|
function getYamlStats(input) {
|
|
5240
5241
|
if (!input.trim()) return { lines: 0, keys: 0, depth: 0 };
|
|
5241
5242
|
try {
|
|
5242
|
-
const doc =
|
|
5243
|
+
const doc = yaml2__namespace.load(input);
|
|
5243
5244
|
return {
|
|
5244
5245
|
lines: input.split("\n").length,
|
|
5245
5246
|
keys: _yamlCountKeys(doc),
|
|
@@ -6706,6 +6707,68 @@ function findCsvDuplicateRows(input, options) {
|
|
|
6706
6707
|
uniqueRowCount: parsed.rows.length - duplicateRowCount + duplicateGroups.length
|
|
6707
6708
|
};
|
|
6708
6709
|
}
|
|
6710
|
+
var _YAML_ANCHOR_RE = /(?:^|\s)&([A-Za-z0-9_.-]+)/g;
|
|
6711
|
+
var _YAML_ALIAS_RE = /(?:^|\s)\*([A-Za-z0-9_.-]+)/g;
|
|
6712
|
+
function _stripYamlLineComment(line) {
|
|
6713
|
+
let inSingle = false;
|
|
6714
|
+
let inDouble = false;
|
|
6715
|
+
for (let i = 0; i < line.length; i++) {
|
|
6716
|
+
const ch = line[i];
|
|
6717
|
+
if (ch === "'" && !inDouble) {
|
|
6718
|
+
inSingle = !inSingle;
|
|
6719
|
+
} else if (ch === '"' && !inSingle) {
|
|
6720
|
+
inDouble = !inDouble;
|
|
6721
|
+
} else if (ch === "#" && !inSingle && !inDouble && (i === 0 || /\s/.test(line[i - 1]))) {
|
|
6722
|
+
return line.slice(0, i);
|
|
6723
|
+
}
|
|
6724
|
+
}
|
|
6725
|
+
return line;
|
|
6726
|
+
}
|
|
6727
|
+
function resolveYamlAnchors(yamlText) {
|
|
6728
|
+
if (!yamlText || !yamlText.trim()) return { error: "Input is empty" };
|
|
6729
|
+
const anchorDefs = [];
|
|
6730
|
+
const referencedNames = /* @__PURE__ */ new Set();
|
|
6731
|
+
let aliasCount = 0;
|
|
6732
|
+
const lines = yamlText.split("\n");
|
|
6733
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6734
|
+
const line = _stripYamlLineComment(lines[i]);
|
|
6735
|
+
const lineNum = i + 1;
|
|
6736
|
+
_YAML_ANCHOR_RE.lastIndex = 0;
|
|
6737
|
+
let m;
|
|
6738
|
+
while ((m = _YAML_ANCHOR_RE.exec(line)) !== null) {
|
|
6739
|
+
anchorDefs.push({ name: m[1], line: lineNum });
|
|
6740
|
+
}
|
|
6741
|
+
_YAML_ALIAS_RE.lastIndex = 0;
|
|
6742
|
+
while ((m = _YAML_ALIAS_RE.exec(line)) !== null) {
|
|
6743
|
+
referencedNames.add(m[1]);
|
|
6744
|
+
aliasCount++;
|
|
6745
|
+
}
|
|
6746
|
+
}
|
|
6747
|
+
let parsed;
|
|
6748
|
+
try {
|
|
6749
|
+
parsed = yaml2__namespace.load(yamlText);
|
|
6750
|
+
} catch (e) {
|
|
6751
|
+
const err = e;
|
|
6752
|
+
return { error: err.reason ?? err.message };
|
|
6753
|
+
}
|
|
6754
|
+
let resolvedYaml;
|
|
6755
|
+
try {
|
|
6756
|
+
resolvedYaml = yaml2__namespace.dump(parsed, { noRefs: true, lineWidth: -1 });
|
|
6757
|
+
} catch (e) {
|
|
6758
|
+
return { error: e instanceof Error ? e.message : String(e) };
|
|
6759
|
+
}
|
|
6760
|
+
const anchors = anchorDefs.map((a) => ({
|
|
6761
|
+
name: a.name,
|
|
6762
|
+
line: a.line,
|
|
6763
|
+
referenced: referencedNames.has(a.name)
|
|
6764
|
+
}));
|
|
6765
|
+
const seenAnchorNames = [];
|
|
6766
|
+
for (const a of anchorDefs) {
|
|
6767
|
+
if (!seenAnchorNames.includes(a.name)) seenAnchorNames.push(a.name);
|
|
6768
|
+
}
|
|
6769
|
+
const unusedAnchors = seenAnchorNames.filter((name) => !referencedNames.has(name));
|
|
6770
|
+
return { resolvedYaml, anchors, unusedAnchors, aliasCount };
|
|
6771
|
+
}
|
|
6709
6772
|
|
|
6710
6773
|
// src/tools/generators.ts
|
|
6711
6774
|
var generators_exports = {};
|
|
@@ -10193,6 +10256,7 @@ __export(network_exports, {
|
|
|
10193
10256
|
analyzeEmailHeaders: () => analyzeEmailHeaders,
|
|
10194
10257
|
buildCacheControl: () => buildCacheControl,
|
|
10195
10258
|
buildClientHints: () => buildClientHints,
|
|
10259
|
+
buildContentDisposition: () => buildContentDisposition,
|
|
10196
10260
|
buildDnsQueryUrl: () => buildDnsQueryUrl,
|
|
10197
10261
|
buildGeoUrl: () => buildGeoUrl,
|
|
10198
10262
|
buildLinkHeader: () => buildLinkHeader,
|
|
@@ -10217,6 +10281,7 @@ __export(network_exports, {
|
|
|
10217
10281
|
isValidIpv4: () => isValidIpv42,
|
|
10218
10282
|
isValidIpv6: () => isValidIpv6,
|
|
10219
10283
|
parseClientHintHeaders: () => parseClientHintHeaders,
|
|
10284
|
+
parseContentDisposition: () => parseContentDisposition,
|
|
10220
10285
|
parseContentRangeHeader: () => parseContentRangeHeader,
|
|
10221
10286
|
parseDnsResponse: () => parseDnsResponse,
|
|
10222
10287
|
parseGeoResponse: () => parseGeoResponse,
|
|
@@ -10227,6 +10292,7 @@ __export(network_exports, {
|
|
|
10227
10292
|
parseVaryHeader: () => parseVaryHeader,
|
|
10228
10293
|
searchHeaders: () => searchHeaders,
|
|
10229
10294
|
searchStatusCodes: () => searchStatusCodes,
|
|
10295
|
+
splitSitemap: () => splitSitemap,
|
|
10230
10296
|
statusCodeToText: () => statusCodeToText,
|
|
10231
10297
|
typeNumberToLabel: () => typeNumberToLabel,
|
|
10232
10298
|
validateDomain: () => validateDomain,
|
|
@@ -11732,6 +11798,53 @@ function validateSitemap(xml) {
|
|
|
11732
11798
|
const valid = !issues.some((i) => i.severity === "error");
|
|
11733
11799
|
return { type, urlCount: entries.length, entries, issues, valid };
|
|
11734
11800
|
}
|
|
11801
|
+
var SITEMAP_SPLITTER_MAX_URLS_PER_FILE = 5e4;
|
|
11802
|
+
function escapeXmlUrl(url) {
|
|
11803
|
+
return url.replace(/&(?!amp;|lt;|gt;|apos;|quot;|#\d+;)/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
11804
|
+
}
|
|
11805
|
+
function splitSitemap(urlsText, options) {
|
|
11806
|
+
const urls = (urlsText ?? "").split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
11807
|
+
if (urls.length === 0) return { error: "No URLs provided" };
|
|
11808
|
+
for (let i = 0; i < urls.length; i++) {
|
|
11809
|
+
if (!/^https?:\/\//i.test(urls[i])) {
|
|
11810
|
+
return { error: `Line ${i + 1}: "${urls[i]}" is not an absolute URL starting with http:// or https://` };
|
|
11811
|
+
}
|
|
11812
|
+
}
|
|
11813
|
+
if (!options || !/^https?:\/\//i.test(options.baseUrl ?? "")) {
|
|
11814
|
+
return { error: "baseUrl must be an absolute URL starting with http:// or https://" };
|
|
11815
|
+
}
|
|
11816
|
+
const baseUrl = options.baseUrl.replace(/\/+$/, "") + "/";
|
|
11817
|
+
let urlsPerFile = options.urlsPerFile ?? SITEMAP_SPLITTER_MAX_URLS_PER_FILE;
|
|
11818
|
+
if (urlsPerFile <= 0) urlsPerFile = SITEMAP_SPLITTER_MAX_URLS_PER_FILE;
|
|
11819
|
+
if (urlsPerFile > SITEMAP_SPLITTER_MAX_URLS_PER_FILE) urlsPerFile = SITEMAP_SPLITTER_MAX_URLS_PER_FILE;
|
|
11820
|
+
const filePrefix = (options.filePrefix || "sitemap").replace(/[^A-Za-z0-9_-]/g, "");
|
|
11821
|
+
const files = [];
|
|
11822
|
+
for (let i = 0; i < urls.length; i += urlsPerFile) {
|
|
11823
|
+
const chunk = urls.slice(i, i + urlsPerFile);
|
|
11824
|
+
const fileIndex = files.length + 1;
|
|
11825
|
+
const filename = `${filePrefix}-${fileIndex}.xml`;
|
|
11826
|
+
const urlLines = chunk.map((url) => ` <url>
|
|
11827
|
+
<loc>${escapeXmlUrl(url)}</loc>
|
|
11828
|
+
</url>`).join("\n");
|
|
11829
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
11830
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
11831
|
+
${urlLines}
|
|
11832
|
+
</urlset>
|
|
11833
|
+
`;
|
|
11834
|
+
files.push({ filename, urlCount: chunk.length, xml });
|
|
11835
|
+
}
|
|
11836
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
11837
|
+
const indexEntries = files.map((f) => ` <sitemap>
|
|
11838
|
+
<loc>${escapeXmlUrl(baseUrl + f.filename)}</loc>
|
|
11839
|
+
<lastmod>${today}</lastmod>
|
|
11840
|
+
</sitemap>`).join("\n");
|
|
11841
|
+
const indexXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
11842
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
11843
|
+
${indexEntries}
|
|
11844
|
+
</sitemapindex>
|
|
11845
|
+
`;
|
|
11846
|
+
return { files, indexXml, totalUrls: urls.length };
|
|
11847
|
+
}
|
|
11735
11848
|
var KNOWN_ROBOTS_DIRECTIVES = /* @__PURE__ */ new Set(["user-agent", "disallow", "allow", "sitemap", "crawl-delay", "host"]);
|
|
11736
11849
|
function validateRobotsTxt(text) {
|
|
11737
11850
|
if (!text || !text.trim()) return { error: "Input is empty" };
|
|
@@ -12858,6 +12971,53 @@ function parseClientHintHeaders(rawHeaders) {
|
|
|
12858
12971
|
}
|
|
12859
12972
|
return { hints, unrecognized };
|
|
12860
12973
|
}
|
|
12974
|
+
function encodeRFC5987ValueChars(value) {
|
|
12975
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase());
|
|
12976
|
+
}
|
|
12977
|
+
function buildContentDisposition(options = {}) {
|
|
12978
|
+
const type = options.type ?? "attachment";
|
|
12979
|
+
if (type !== "inline" && type !== "attachment") return { error: 'type must be "inline" or "attachment"' };
|
|
12980
|
+
if (!options.filename) return { header: type, type, filenameEncoded: false };
|
|
12981
|
+
const filename = options.filename;
|
|
12982
|
+
if (filename.includes("/") || filename.includes("\\")) return { error: "filename must not contain path separators" };
|
|
12983
|
+
const isAscii = /^[\x20-\x7e]*$/.test(filename);
|
|
12984
|
+
const asciiFallback = filename.replace(/[^\x20-\x7e]/g, "_").replace(/(["\\])/g, "\\$1");
|
|
12985
|
+
let header = `${type}; filename="${asciiFallback}"`;
|
|
12986
|
+
let filenameEncoded = false;
|
|
12987
|
+
if (!isAscii) {
|
|
12988
|
+
header += `; filename*=UTF-8''${encodeRFC5987ValueChars(filename)}`;
|
|
12989
|
+
filenameEncoded = true;
|
|
12990
|
+
}
|
|
12991
|
+
return { header, type, filename, filenameEncoded };
|
|
12992
|
+
}
|
|
12993
|
+
function parseContentDisposition(header) {
|
|
12994
|
+
if (typeof header !== "string" || header.trim() === "") return { error: "header is required" };
|
|
12995
|
+
const parts = header.split(";").map((p) => p.trim()).filter(Boolean);
|
|
12996
|
+
const type = parts[0]?.toLowerCase();
|
|
12997
|
+
if (!type) return { error: "Could not parse a disposition type from the header" };
|
|
12998
|
+
const params = {};
|
|
12999
|
+
for (let i = 1; i < parts.length; i++) {
|
|
13000
|
+
const eq = parts[i].indexOf("=");
|
|
13001
|
+
if (eq === -1) continue;
|
|
13002
|
+
const key = parts[i].slice(0, eq).trim().toLowerCase();
|
|
13003
|
+
let value = parts[i].slice(eq + 1).trim();
|
|
13004
|
+
if (value.startsWith('"') && value.endsWith('"')) value = value.slice(1, -1).replace(/\\(.)/g, "$1");
|
|
13005
|
+
params[key] = value;
|
|
13006
|
+
}
|
|
13007
|
+
let filename = params.filename;
|
|
13008
|
+
let filenameIsExtended = false;
|
|
13009
|
+
if (params["filename*"]) {
|
|
13010
|
+
const match = params["filename*"].match(/^([^']*)'([^']*)'(.*)$/);
|
|
13011
|
+
if (match) {
|
|
13012
|
+
try {
|
|
13013
|
+
filename = decodeURIComponent(match[3]);
|
|
13014
|
+
filenameIsExtended = true;
|
|
13015
|
+
} catch {
|
|
13016
|
+
}
|
|
13017
|
+
}
|
|
13018
|
+
}
|
|
13019
|
+
return { type, filename, filenameIsExtended, params };
|
|
13020
|
+
}
|
|
12861
13021
|
|
|
12862
13022
|
// src/tools/api.ts
|
|
12863
13023
|
var api_exports = {};
|
|
@@ -16244,7 +16404,7 @@ function parseSpec(input) {
|
|
|
16244
16404
|
raw = JSON.parse(input);
|
|
16245
16405
|
} catch {
|
|
16246
16406
|
try {
|
|
16247
|
-
raw =
|
|
16407
|
+
raw = yaml2.load(input);
|
|
16248
16408
|
} catch (e) {
|
|
16249
16409
|
return { error: `Failed to parse input as JSON or YAML: ${String(e)}` };
|
|
16250
16410
|
}
|
|
@@ -21806,6 +21966,7 @@ function lintToolSchema(jsonText) {
|
|
|
21806
21966
|
// src/tools/media.ts
|
|
21807
21967
|
var media_exports = {};
|
|
21808
21968
|
__export(media_exports, {
|
|
21969
|
+
inspectGifFrames: () => inspectGifFrames,
|
|
21809
21970
|
readExifData: () => readExifData,
|
|
21810
21971
|
readFlacInfo: () => readFlacInfo,
|
|
21811
21972
|
readIcoInfo: () => readIcoInfo,
|
|
@@ -23023,6 +23184,91 @@ function parseWebm(bytes) {
|
|
|
23023
23184
|
}
|
|
23024
23185
|
return result;
|
|
23025
23186
|
}
|
|
23187
|
+
function skipGifSubBlocks(bytes, offset) {
|
|
23188
|
+
while (offset < bytes.length) {
|
|
23189
|
+
const len = bytes[offset];
|
|
23190
|
+
offset += 1;
|
|
23191
|
+
if (len === 0) break;
|
|
23192
|
+
offset += len;
|
|
23193
|
+
}
|
|
23194
|
+
return offset;
|
|
23195
|
+
}
|
|
23196
|
+
function inspectGifFrames(bytes) {
|
|
23197
|
+
if (bytes.length < 13) return { error: "File too small to be a valid GIF file" };
|
|
23198
|
+
const signature = Buffer.from(bytes.subarray(0, 6)).toString("ascii");
|
|
23199
|
+
if (signature !== "GIF87a" && signature !== "GIF89a") return { error: "Not a valid GIF file (missing GIF87a/GIF89a signature)" };
|
|
23200
|
+
const version2 = signature.slice(3);
|
|
23201
|
+
const width = readU16LE(bytes, 6);
|
|
23202
|
+
const height = readU16LE(bytes, 8);
|
|
23203
|
+
const packed = bytes[10];
|
|
23204
|
+
const hasGlobalColorTable = (packed & 128) !== 0;
|
|
23205
|
+
const globalColorTableSize = hasGlobalColorTable ? 2 << (packed & 7) : 0;
|
|
23206
|
+
let offset = 13;
|
|
23207
|
+
if (hasGlobalColorTable) offset += globalColorTableSize * 3;
|
|
23208
|
+
let frameCount = 0;
|
|
23209
|
+
let loopCount = null;
|
|
23210
|
+
let totalDurationMs = 0;
|
|
23211
|
+
let hasTransparency = false;
|
|
23212
|
+
let pendingDelay = 0;
|
|
23213
|
+
while (offset < bytes.length) {
|
|
23214
|
+
const blockType = bytes[offset];
|
|
23215
|
+
if (blockType === 59) break;
|
|
23216
|
+
if (blockType === 33) {
|
|
23217
|
+
const label = bytes[offset + 1];
|
|
23218
|
+
offset += 2;
|
|
23219
|
+
if (label === 249) {
|
|
23220
|
+
const subLen = bytes[offset] ?? 0;
|
|
23221
|
+
if (subLen >= 4) {
|
|
23222
|
+
const flags = bytes[offset + 1];
|
|
23223
|
+
pendingDelay = readU16LE(bytes, offset + 2);
|
|
23224
|
+
if (flags & 1) hasTransparency = true;
|
|
23225
|
+
}
|
|
23226
|
+
offset += 1 + subLen;
|
|
23227
|
+
offset = skipGifSubBlocks(bytes, offset);
|
|
23228
|
+
} else if (label === 255) {
|
|
23229
|
+
const blockSize = bytes[offset] ?? 0;
|
|
23230
|
+
const appId = Buffer.from(bytes.subarray(offset + 1, offset + 1 + Math.min(blockSize, 11))).toString("ascii");
|
|
23231
|
+
offset += 1 + blockSize;
|
|
23232
|
+
if (appId === "NETSCAPE2.0") {
|
|
23233
|
+
const subLen = bytes[offset] ?? 0;
|
|
23234
|
+
if (subLen >= 3 && bytes[offset + 1] === 1) {
|
|
23235
|
+
loopCount = readU16LE(bytes, offset + 2);
|
|
23236
|
+
}
|
|
23237
|
+
}
|
|
23238
|
+
offset = skipGifSubBlocks(bytes, offset);
|
|
23239
|
+
} else {
|
|
23240
|
+
offset = skipGifSubBlocks(bytes, offset);
|
|
23241
|
+
}
|
|
23242
|
+
} else if (blockType === 44) {
|
|
23243
|
+
if (offset + 10 > bytes.length) return { error: "Truncated image descriptor" };
|
|
23244
|
+
frameCount++;
|
|
23245
|
+
totalDurationMs += pendingDelay * 10;
|
|
23246
|
+
pendingDelay = 0;
|
|
23247
|
+
const packedImg = bytes[offset + 9];
|
|
23248
|
+
const hasLocalColorTable = (packedImg & 128) !== 0;
|
|
23249
|
+
const localColorTableSize = hasLocalColorTable ? 2 << (packedImg & 7) : 0;
|
|
23250
|
+
offset += 10;
|
|
23251
|
+
if (hasLocalColorTable) offset += localColorTableSize * 3;
|
|
23252
|
+
offset += 1;
|
|
23253
|
+
offset = skipGifSubBlocks(bytes, offset);
|
|
23254
|
+
} else {
|
|
23255
|
+
break;
|
|
23256
|
+
}
|
|
23257
|
+
}
|
|
23258
|
+
if (frameCount === 0) return { error: "No image data blocks found in this GIF file" };
|
|
23259
|
+
return {
|
|
23260
|
+
version: version2,
|
|
23261
|
+
width,
|
|
23262
|
+
height,
|
|
23263
|
+
frameCount,
|
|
23264
|
+
animated: frameCount > 1,
|
|
23265
|
+
loopCount,
|
|
23266
|
+
totalDurationMs,
|
|
23267
|
+
hasGlobalColorTable,
|
|
23268
|
+
globalColorTableSize,
|
|
23269
|
+
hasTransparency
|
|
23270
|
+
};
|
|
23271
|
+
}
|
|
23026
23272
|
|
|
23027
23273
|
// src/index.ts
|
|
23028
23274
|
var version = "0.1.0";
|
package/dist/index.d.cts
CHANGED
|
@@ -2,18 +2,18 @@ export { j as json } from './json-Ta9JykSB.cjs';
|
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CJjlvqS_.cjs';
|
|
4
4
|
export { t as text } from './text-DWUcY8H1.cjs';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-BJVJ879p.cjs';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.cjs';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
8
|
export { u as units } from './units-DU4Pisfx.cjs';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-DelcJeJa.cjs';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.cjs';
|
|
11
11
|
export { c as code } from './code-KXoRsHtl.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-CmrVjvYH.cjs';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-BUvwm4wU.cjs';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,18 +2,18 @@ export { j as json } from './json-Ta9JykSB.js';
|
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.js';
|
|
3
3
|
export { h as hashing } from './hashing-CJjlvqS_.js';
|
|
4
4
|
export { t as text } from './text-DWUcY8H1.js';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-BJVJ879p.js';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.js';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.js';
|
|
8
8
|
export { u as units } from './units-DU4Pisfx.js';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-DelcJeJa.js';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.js';
|
|
11
11
|
export { c as code } from './code-KXoRsHtl.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-CmrVjvYH.js';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-BUvwm4wU.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-226EH3ZI.js';
|
|
2
2
|
export { units_exports as units } from './chunk-KMQHBUYO.js';
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
3
|
+
export { network_exports as network } from './chunk-Y7YY733Z.js';
|
|
4
4
|
export { api_exports as api } from './chunk-52ZDKSIX.js';
|
|
5
5
|
export { code_exports as code } from './chunk-JL7YTXRB.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
@@ -11,7 +11,7 @@ export { json_exports as json } from './chunk-WVEKRKGU.js';
|
|
|
11
11
|
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-PET2CGTH.js';
|
|
13
13
|
export { text_exports as text } from './chunk-P7TXG7CI.js';
|
|
14
|
-
export { data_exports as data } from './chunk-
|
|
14
|
+
export { data_exports as data } from './chunk-4TIY6COQ.js';
|
|
15
15
|
export { generators_exports as generators } from './chunk-3TYWIX3B.js';
|
|
16
16
|
export { time_exports as time } from './chunk-IEPWZERQ.js';
|
|
17
17
|
import './chunk-MLKGABMK.js';
|
|
@@ -202,11 +202,35 @@ interface VideoInfoError {
|
|
|
202
202
|
* only the moov box (MP4) or Segment/Info/Tracks elements (WebM) are read.
|
|
203
203
|
*/
|
|
204
204
|
declare function readVideoInfo(bytes: Uint8Array): VideoInfo | VideoInfoError;
|
|
205
|
+
interface GifInfo {
|
|
206
|
+
version: '87a' | '89a';
|
|
207
|
+
width: number;
|
|
208
|
+
height: number;
|
|
209
|
+
frameCount: number;
|
|
210
|
+
animated: boolean;
|
|
211
|
+
loopCount: number | null;
|
|
212
|
+
totalDurationMs: number;
|
|
213
|
+
hasGlobalColorTable: boolean;
|
|
214
|
+
globalColorTableSize: number;
|
|
215
|
+
hasTransparency: boolean;
|
|
216
|
+
}
|
|
217
|
+
interface GifInfoError {
|
|
218
|
+
error: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Walk a GIF87a/89a file's block structure (image descriptors, graphic
|
|
222
|
+
* control extensions, the NETSCAPE2.0 application extension) to report
|
|
223
|
+
* frame count, total animation duration, and loop count, without decoding
|
|
224
|
+
* any LZW-compressed pixel data.
|
|
225
|
+
*/
|
|
226
|
+
declare function inspectGifFrames(bytes: Uint8Array): GifInfo | GifInfoError;
|
|
205
227
|
|
|
206
228
|
type media_ExifData = ExifData;
|
|
207
229
|
type media_ExifError = ExifError;
|
|
208
230
|
type media_FlacInfo = FlacInfo;
|
|
209
231
|
type media_FlacInfoError = FlacInfoError;
|
|
232
|
+
type media_GifInfo = GifInfo;
|
|
233
|
+
type media_GifInfoError = GifInfoError;
|
|
210
234
|
type media_IcoImageEntry = IcoImageEntry;
|
|
211
235
|
type media_IcoInfo = IcoInfo;
|
|
212
236
|
type media_IcoInfoError = IcoInfoError;
|
|
@@ -224,6 +248,7 @@ type media_VideoInfo = VideoInfo;
|
|
|
224
248
|
type media_VideoInfoError = VideoInfoError;
|
|
225
249
|
type media_WavInfo = WavInfo;
|
|
226
250
|
type media_WavInfoError = WavInfoError;
|
|
251
|
+
declare const media_inspectGifFrames: typeof inspectGifFrames;
|
|
227
252
|
declare const media_readExifData: typeof readExifData;
|
|
228
253
|
declare const media_readFlacInfo: typeof readFlacInfo;
|
|
229
254
|
declare const media_readIcoInfo: typeof readIcoInfo;
|
|
@@ -234,7 +259,7 @@ declare const media_readPdfPageDimensions: typeof readPdfPageDimensions;
|
|
|
234
259
|
declare const media_readVideoInfo: typeof readVideoInfo;
|
|
235
260
|
declare const media_readWavInfo: typeof readWavInfo;
|
|
236
261
|
declare namespace media {
|
|
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 };
|
|
262
|
+
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_GifInfo as GifInfo, type media_GifInfoError as GifInfoError, 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_inspectGifFrames as inspectGifFrames, 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 };
|
|
238
263
|
}
|
|
239
264
|
|
|
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
|
|
265
|
+
export { readWavInfo as A, type ExifData as E, type FlacInfo as F, type GifInfo as G, 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 GifInfoError as c, type IcoInfo as d, type IcoInfoError as e, type Id3Tags as f, type Id3TagsError as g, type ImageFormat as h, type ImageInfo as i, type ImageInfoError as j, type PdfMetadataError as k, type PdfPageDimension as l, media as m, type PdfPageDimensionsResult as n, type PdfPageOrientation as o, type VideoInfoError as p, type WavInfoError as q, inspectGifFrames as r, readExifData as s, readFlacInfo as t, readIcoInfo as u, readId3Tags as v, readImageInfo as w, readPdfMetadata as x, readPdfPageDimensions as y, readVideoInfo as z };
|
|
@@ -202,11 +202,35 @@ interface VideoInfoError {
|
|
|
202
202
|
* only the moov box (MP4) or Segment/Info/Tracks elements (WebM) are read.
|
|
203
203
|
*/
|
|
204
204
|
declare function readVideoInfo(bytes: Uint8Array): VideoInfo | VideoInfoError;
|
|
205
|
+
interface GifInfo {
|
|
206
|
+
version: '87a' | '89a';
|
|
207
|
+
width: number;
|
|
208
|
+
height: number;
|
|
209
|
+
frameCount: number;
|
|
210
|
+
animated: boolean;
|
|
211
|
+
loopCount: number | null;
|
|
212
|
+
totalDurationMs: number;
|
|
213
|
+
hasGlobalColorTable: boolean;
|
|
214
|
+
globalColorTableSize: number;
|
|
215
|
+
hasTransparency: boolean;
|
|
216
|
+
}
|
|
217
|
+
interface GifInfoError {
|
|
218
|
+
error: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Walk a GIF87a/89a file's block structure (image descriptors, graphic
|
|
222
|
+
* control extensions, the NETSCAPE2.0 application extension) to report
|
|
223
|
+
* frame count, total animation duration, and loop count, without decoding
|
|
224
|
+
* any LZW-compressed pixel data.
|
|
225
|
+
*/
|
|
226
|
+
declare function inspectGifFrames(bytes: Uint8Array): GifInfo | GifInfoError;
|
|
205
227
|
|
|
206
228
|
type media_ExifData = ExifData;
|
|
207
229
|
type media_ExifError = ExifError;
|
|
208
230
|
type media_FlacInfo = FlacInfo;
|
|
209
231
|
type media_FlacInfoError = FlacInfoError;
|
|
232
|
+
type media_GifInfo = GifInfo;
|
|
233
|
+
type media_GifInfoError = GifInfoError;
|
|
210
234
|
type media_IcoImageEntry = IcoImageEntry;
|
|
211
235
|
type media_IcoInfo = IcoInfo;
|
|
212
236
|
type media_IcoInfoError = IcoInfoError;
|
|
@@ -224,6 +248,7 @@ type media_VideoInfo = VideoInfo;
|
|
|
224
248
|
type media_VideoInfoError = VideoInfoError;
|
|
225
249
|
type media_WavInfo = WavInfo;
|
|
226
250
|
type media_WavInfoError = WavInfoError;
|
|
251
|
+
declare const media_inspectGifFrames: typeof inspectGifFrames;
|
|
227
252
|
declare const media_readExifData: typeof readExifData;
|
|
228
253
|
declare const media_readFlacInfo: typeof readFlacInfo;
|
|
229
254
|
declare const media_readIcoInfo: typeof readIcoInfo;
|
|
@@ -234,7 +259,7 @@ declare const media_readPdfPageDimensions: typeof readPdfPageDimensions;
|
|
|
234
259
|
declare const media_readVideoInfo: typeof readVideoInfo;
|
|
235
260
|
declare const media_readWavInfo: typeof readWavInfo;
|
|
236
261
|
declare namespace media {
|
|
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 };
|
|
262
|
+
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_GifInfo as GifInfo, type media_GifInfoError as GifInfoError, 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_inspectGifFrames as inspectGifFrames, 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 };
|
|
238
263
|
}
|
|
239
264
|
|
|
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
|
|
265
|
+
export { readWavInfo as A, type ExifData as E, type FlacInfo as F, type GifInfo as G, 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 GifInfoError as c, type IcoInfo as d, type IcoInfoError as e, type Id3Tags as f, type Id3TagsError as g, type ImageFormat as h, type ImageInfo as i, type ImageInfoError as j, type PdfMetadataError as k, type PdfPageDimension as l, media as m, type PdfPageDimensionsResult as n, type PdfPageOrientation as o, type VideoInfoError as p, type WavInfoError as q, inspectGifFrames as r, readExifData as s, readFlacInfo as t, readIcoInfo as u, readId3Tags as v, readImageInfo as w, readPdfMetadata as x, readPdfPageDimensions as y, readVideoInfo as z };
|