@ekipnico/image-core 1.0.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/out/index.d.ts +8 -0
- package/out/index.js +21 -0
- package/out/index.js.map +1 -0
- package/package.json +15 -0
package/out/index.d.ts
ADDED
package/out/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export async function resolveInput(input) {
|
|
2
|
+
if (Buffer.isBuffer(input)) {
|
|
3
|
+
return input;
|
|
4
|
+
}
|
|
5
|
+
if ('buffer' in input) {
|
|
6
|
+
return input.buffer;
|
|
7
|
+
}
|
|
8
|
+
if ('url' in input) {
|
|
9
|
+
const response = await fetch(input.url);
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
throw new Error(`Failed to fetch image: ${response.status}`);
|
|
12
|
+
}
|
|
13
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
14
|
+
return Buffer.from(arrayBuffer);
|
|
15
|
+
}
|
|
16
|
+
if ('base64' in input) {
|
|
17
|
+
return Buffer.from(input.base64, 'base64');
|
|
18
|
+
}
|
|
19
|
+
throw new Error('Invalid image input');
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAiB;IAClD,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IAED,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;QACjD,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACzC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ekipnico/image-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared utilities for image-pipeline packages",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "out/index.js",
|
|
7
|
+
"types": "out/index.d.ts",
|
|
8
|
+
"files": ["out"],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
}
|
|
15
|
+
}
|