@utilix-tech/sdk 0.3.1 → 0.5.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/README.md +34 -12
- package/dist/{api-8aZtWhSj.d.cts → api-Xl7OzIgq.d.cts} +35 -2
- package/dist/{api-8aZtWhSj.d.ts → api-Xl7OzIgq.d.ts} +35 -2
- package/dist/{chunk-UC656APA.js → chunk-DNCOIO5N.js} +64 -1
- package/dist/{chunk-HFRTZE7T.js → chunk-Q3B3YWOA.js} +51 -1
- package/dist/{chunk-3BAHSW4C.js → chunk-V5JKVDBA.js} +60 -1
- package/dist/chunk-WWKPLYEP.js +277 -0
- package/dist/{data-rMjWNiOJ.d.cts → data-CakDxAcT.d.cts} +36 -2
- package/dist/{data-rMjWNiOJ.d.ts → data-CakDxAcT.d.ts} +36 -2
- package/dist/index.cjs +316 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/media-D-K5aZnq.d.cts +53 -0
- package/dist/media-D-K5aZnq.d.ts +53 -0
- package/dist/{network-CNtmrDeN.d.cts → network-DwyAjwJS.d.cts} +39 -2
- package/dist/{network-CNtmrDeN.d.ts → network-DwyAjwJS.d.ts} +39 -2
- package/dist/tools/api.cjs +50 -0
- package/dist/tools/api.d.cts +1 -1
- package/dist/tools/api.d.ts +1 -1
- package/dist/tools/api.js +1 -1
- 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 +143 -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 +59 -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/chunk-N7C52YGL.js +0 -134
- package/dist/media-DF2cx3pK.d.cts +0 -28
- package/dist/media-DF2cx3pK.d.ts +0 -28
package/dist/chunk-N7C52YGL.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { __export } from './chunk-MLKGABMK.js';
|
|
2
|
-
|
|
3
|
-
// src/tools/media.ts
|
|
4
|
-
var media_exports = {};
|
|
5
|
-
__export(media_exports, {
|
|
6
|
-
readImageInfo: () => readImageInfo
|
|
7
|
-
});
|
|
8
|
-
function readU32BE(bytes, offset) {
|
|
9
|
-
return (bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
|
|
10
|
-
}
|
|
11
|
-
function readI32LE(bytes, offset) {
|
|
12
|
-
return bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] << 24;
|
|
13
|
-
}
|
|
14
|
-
var PNG_COLOR_TYPES = {
|
|
15
|
-
0: "grayscale",
|
|
16
|
-
2: "rgb",
|
|
17
|
-
3: "palette",
|
|
18
|
-
4: "grayscale+alpha",
|
|
19
|
-
6: "rgba"
|
|
20
|
-
};
|
|
21
|
-
function readPng(bytes) {
|
|
22
|
-
if (bytes.length < 33) return { error: "Truncated PNG file" };
|
|
23
|
-
const width = readU32BE(bytes, 16);
|
|
24
|
-
const height = readU32BE(bytes, 20);
|
|
25
|
-
const bitDepth = bytes[24];
|
|
26
|
-
const colorTypeNum = bytes[25];
|
|
27
|
-
const colorType = PNG_COLOR_TYPES[colorTypeNum] ?? "unknown";
|
|
28
|
-
const hasAlpha = colorTypeNum === 4 || colorTypeNum === 6;
|
|
29
|
-
return { format: "png", width, height, bitDepth, colorType, hasAlpha };
|
|
30
|
-
}
|
|
31
|
-
function readGif(bytes) {
|
|
32
|
-
if (bytes.length < 10) return { error: "Truncated GIF file" };
|
|
33
|
-
const width = bytes[6] | bytes[7] << 8;
|
|
34
|
-
const height = bytes[8] | bytes[9] << 8;
|
|
35
|
-
return { format: "gif", width, height };
|
|
36
|
-
}
|
|
37
|
-
function readBmp(bytes) {
|
|
38
|
-
if (bytes.length < 30) return { error: "Truncated BMP file" };
|
|
39
|
-
const width = readI32LE(bytes, 18);
|
|
40
|
-
const heightRaw = readI32LE(bytes, 22);
|
|
41
|
-
const bitDepth = bytes[28] | bytes[29] << 8;
|
|
42
|
-
return { format: "bmp", width: Math.abs(width), height: Math.abs(heightRaw), bitDepth };
|
|
43
|
-
}
|
|
44
|
-
function readWebp(bytes) {
|
|
45
|
-
if (bytes.length < 16) return { error: "Truncated WebP file" };
|
|
46
|
-
const fourCC = String.fromCharCode(bytes[12], bytes[13], bytes[14], bytes[15]);
|
|
47
|
-
if (fourCC === "VP8 ") {
|
|
48
|
-
if (bytes.length < 30) return { error: "Truncated WebP file" };
|
|
49
|
-
const width = (bytes[26] | bytes[27] << 8) & 16383;
|
|
50
|
-
const height = (bytes[28] | bytes[29] << 8) & 16383;
|
|
51
|
-
return { format: "webp", width, height };
|
|
52
|
-
}
|
|
53
|
-
if (fourCC === "VP8L") {
|
|
54
|
-
if (bytes.length < 25) return { error: "Truncated WebP file" };
|
|
55
|
-
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
56
|
-
const width = (bits & 16383) + 1;
|
|
57
|
-
const height = (bits >>> 14 & 16383) + 1;
|
|
58
|
-
const hasAlpha = !!(bits >>> 28 & 1);
|
|
59
|
-
return { format: "webp", width, height, hasAlpha };
|
|
60
|
-
}
|
|
61
|
-
if (fourCC === "VP8X") {
|
|
62
|
-
if (bytes.length < 30) return { error: "Truncated WebP file" };
|
|
63
|
-
const flags = bytes[20];
|
|
64
|
-
const hasAlpha = !!(flags & 16);
|
|
65
|
-
const width = (bytes[24] | bytes[25] << 8 | bytes[26] << 16) + 1;
|
|
66
|
-
const height = (bytes[27] | bytes[28] << 8 | bytes[29] << 16) + 1;
|
|
67
|
-
return { format: "webp", width, height, hasAlpha };
|
|
68
|
-
}
|
|
69
|
-
return { error: "Unrecognized WebP chunk format" };
|
|
70
|
-
}
|
|
71
|
-
var JPEG_SOF_MARKERS = /* @__PURE__ */ new Set([
|
|
72
|
-
192,
|
|
73
|
-
193,
|
|
74
|
-
194,
|
|
75
|
-
195,
|
|
76
|
-
197,
|
|
77
|
-
198,
|
|
78
|
-
199,
|
|
79
|
-
201,
|
|
80
|
-
202,
|
|
81
|
-
203,
|
|
82
|
-
205,
|
|
83
|
-
206,
|
|
84
|
-
207
|
|
85
|
-
]);
|
|
86
|
-
function readJpeg(bytes) {
|
|
87
|
-
let offset = 2;
|
|
88
|
-
while (offset < bytes.length - 1) {
|
|
89
|
-
if (bytes[offset] !== 255) {
|
|
90
|
-
offset++;
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const marker = bytes[offset + 1];
|
|
94
|
-
if (marker === 216 || marker === 1 || marker >= 208 && marker <= 215) {
|
|
95
|
-
offset += 2;
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (marker === 217) break;
|
|
99
|
-
if (offset + 3 >= bytes.length) break;
|
|
100
|
-
const segmentLength = bytes[offset + 2] << 8 | bytes[offset + 3];
|
|
101
|
-
if (JPEG_SOF_MARKERS.has(marker)) {
|
|
102
|
-
if (offset + 9 >= bytes.length) return { error: "Truncated JPEG SOF segment" };
|
|
103
|
-
const bitDepth = bytes[offset + 4];
|
|
104
|
-
const height = bytes[offset + 5] << 8 | bytes[offset + 6];
|
|
105
|
-
const width = bytes[offset + 7] << 8 | bytes[offset + 8];
|
|
106
|
-
const components = bytes[offset + 9];
|
|
107
|
-
const colorType = components === 1 ? "grayscale" : components === 3 ? "rgb" : components === 4 ? "cmyk" : "unknown";
|
|
108
|
-
return { format: "jpeg", width, height, bitDepth, colorType };
|
|
109
|
-
}
|
|
110
|
-
offset += 2 + segmentLength;
|
|
111
|
-
}
|
|
112
|
-
return { error: "No SOF marker found in JPEG (file may be corrupt)" };
|
|
113
|
-
}
|
|
114
|
-
function readImageInfo(bytes) {
|
|
115
|
-
if (bytes.length < 10) return { error: "File too small to determine format" };
|
|
116
|
-
if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71 && bytes[4] === 13 && bytes[5] === 10 && bytes[6] === 26 && bytes[7] === 10) {
|
|
117
|
-
return readPng(bytes);
|
|
118
|
-
}
|
|
119
|
-
if (bytes[0] === 71 && bytes[1] === 73 && bytes[2] === 70) {
|
|
120
|
-
return readGif(bytes);
|
|
121
|
-
}
|
|
122
|
-
if (bytes[0] === 66 && bytes[1] === 77) {
|
|
123
|
-
return readBmp(bytes);
|
|
124
|
-
}
|
|
125
|
-
if (bytes[0] === 82 && bytes[1] === 73 && bytes[2] === 70 && bytes[3] === 70 && bytes[8] === 87 && bytes[9] === 69 && bytes[10] === 66 && bytes[11] === 80) {
|
|
126
|
-
return readWebp(bytes);
|
|
127
|
-
}
|
|
128
|
-
if (bytes[0] === 255 && bytes[1] === 216) {
|
|
129
|
-
return readJpeg(bytes);
|
|
130
|
-
}
|
|
131
|
-
return { error: "Unrecognized image format. Supported formats: PNG, JPEG, GIF, WebP, BMP" };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export { media_exports, readImageInfo };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp' | 'bmp';
|
|
2
|
-
interface ImageInfo {
|
|
3
|
-
format: ImageFormat;
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
bitDepth?: number;
|
|
7
|
-
colorType?: string;
|
|
8
|
-
hasAlpha?: boolean;
|
|
9
|
-
}
|
|
10
|
-
interface ImageInfoError {
|
|
11
|
-
error: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Read image format, dimensions, and basic color info straight from file
|
|
15
|
-
* bytes — no decoding, no image library, no canvas. Supports PNG, JPEG,
|
|
16
|
-
* GIF, WebP, and BMP.
|
|
17
|
-
*/
|
|
18
|
-
declare function readImageInfo(bytes: Uint8Array): ImageInfo | ImageInfoError;
|
|
19
|
-
|
|
20
|
-
type media_ImageFormat = ImageFormat;
|
|
21
|
-
type media_ImageInfo = ImageInfo;
|
|
22
|
-
type media_ImageInfoError = ImageInfoError;
|
|
23
|
-
declare const media_readImageInfo: typeof readImageInfo;
|
|
24
|
-
declare namespace media {
|
|
25
|
-
export { type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, media_readImageInfo as readImageInfo };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { type ImageFormat as I, type ImageInfo as a, type ImageInfoError as b, media as m, readImageInfo as r };
|
package/dist/media-DF2cx3pK.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp' | 'bmp';
|
|
2
|
-
interface ImageInfo {
|
|
3
|
-
format: ImageFormat;
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
bitDepth?: number;
|
|
7
|
-
colorType?: string;
|
|
8
|
-
hasAlpha?: boolean;
|
|
9
|
-
}
|
|
10
|
-
interface ImageInfoError {
|
|
11
|
-
error: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Read image format, dimensions, and basic color info straight from file
|
|
15
|
-
* bytes — no decoding, no image library, no canvas. Supports PNG, JPEG,
|
|
16
|
-
* GIF, WebP, and BMP.
|
|
17
|
-
*/
|
|
18
|
-
declare function readImageInfo(bytes: Uint8Array): ImageInfo | ImageInfoError;
|
|
19
|
-
|
|
20
|
-
type media_ImageFormat = ImageFormat;
|
|
21
|
-
type media_ImageInfo = ImageInfo;
|
|
22
|
-
type media_ImageInfoError = ImageInfoError;
|
|
23
|
-
declare const media_readImageInfo: typeof readImageInfo;
|
|
24
|
-
declare namespace media {
|
|
25
|
-
export { type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, media_readImageInfo as readImageInfo };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { type ImageFormat as I, type ImageInfo as a, type ImageInfoError as b, media as m, readImageInfo as r };
|