@uploadista/flow-images-sharp 0.0.3 → 0.0.6

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/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@uploadista/core/errors`);c=s(c);let l=require(`@uploadista/core/flow`);l=s(l);let u=require(`effect`);u=s(u);let d=require(`sharp`);d=s(d);const f=e=>{switch(e){case`fill`:return`cover`;case`contain`:return`contain`}},p=u.Layer.succeed(l.ImagePlugin,l.ImagePlugin.of({optimize:(e,{quality:t,format:n})=>u.Effect.gen(function*(){let r=yield*u.Effect.tryPromise({try:async()=>await(0,d.default)(e).toFormat(n,{quality:t}).toBuffer(),catch:e=>c.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:e})});return new Uint8Array(r)}),resize:(e,{width:t,height:n,fit:r})=>u.Effect.gen(function*(){if(!t&&!n)throw Error(`Either width or height must be specified for resize`);let i=f(r),a=yield*u.Effect.tryPromise({try:async()=>await(0,d.default)(e).resize(t,n,{fit:i}).toBuffer(),catch:e=>c.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:e})});return new Uint8Array(a)})}));exports.imagePlugin=p;
@@ -0,0 +1,8 @@
1
+ import { ImagePlugin } from "@uploadista/core/flow";
2
+ import { Layer } from "effect";
3
+
4
+ //#region src/image-plugin.d.ts
5
+ declare const imagePlugin: Layer.Layer<ImagePlugin, never, never>;
6
+ //#endregion
7
+ export { imagePlugin };
8
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/image-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAca,aAAW,KAAA,CAAA,MAAA"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,8 @@
1
- export * from "./image-plugin";
1
+ import { ImagePlugin } from "@uploadista/core/flow";
2
+ import { Layer } from "effect";
3
+
4
+ //#region src/image-plugin.d.ts
5
+ declare const imagePlugin: Layer.Layer<ImagePlugin, never, never>;
6
+ //#endregion
7
+ export { imagePlugin };
2
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/image-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAca,aAAW,KAAA,CAAA,MAAA"}
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- export * from "./image-plugin";
1
+ import{UploadistaError as e}from"@uploadista/core/errors";import{ImagePlugin as t}from"@uploadista/core/flow";import{Effect as n,Layer as r}from"effect";import i from"sharp";const a=e=>{switch(e){case`fill`:return`cover`;case`contain`:return`contain`}},o=r.succeed(t,t.of({optimize:(t,{quality:r,format:a})=>n.gen(function*(){let o=yield*n.tryPromise({try:async()=>await i(t).toFormat(a,{quality:r}).toBuffer(),catch:t=>e.fromCode(`UNKNOWN_ERROR`,{cause:t})});return new Uint8Array(o)}),resize:(t,{width:r,height:o,fit:s})=>n.gen(function*(){if(!r&&!o)throw Error(`Either width or height must be specified for resize`);let c=a(s),l=yield*n.tryPromise({try:async()=>await i(t).resize(r,o,{fit:c}).toBuffer(),catch:t=>e.fromCode(`UNKNOWN_ERROR`,{cause:t})});return new Uint8Array(l)})}));export{o as imagePlugin};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/image-plugin.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport { ImagePlugin } from \"@uploadista/core/flow\";\nimport { Effect, Layer } from \"effect\";\nimport sharp from \"sharp\";\n\nconst mapFitToSharp = (fit: \"fill\" | \"contain\" | \"cover\") => {\n switch (fit) {\n case \"fill\":\n return \"cover\";\n case \"contain\":\n return \"contain\";\n }\n};\n\nexport const imagePlugin = Layer.succeed(\n ImagePlugin,\n ImagePlugin.of({\n optimize: (inputBytes, { quality, format }) => {\n return Effect.gen(function* () {\n const outputBytes = yield* Effect.tryPromise({\n try: async () =>\n await sharp(inputBytes).toFormat(format, { quality }).toBuffer(),\n catch: (error) => {\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause: error,\n });\n },\n });\n return new Uint8Array(outputBytes);\n });\n },\n resize: (inputBytes, { width, height, fit }) => {\n return Effect.gen(function* () {\n if (!width && !height) {\n throw new Error(\n \"Either width or height must be specified for resize\",\n );\n }\n\n const sharpFit = mapFitToSharp(fit);\n const outputBytes = yield* Effect.tryPromise({\n try: async () =>\n await sharp(inputBytes)\n .resize(width, height, { fit: sharpFit })\n .toBuffer(),\n catch: (error) => {\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause: error,\n });\n },\n });\n\n return new Uint8Array(outputBytes);\n });\n },\n }),\n);\n"],"mappings":"8KAKA,MAAM,EAAiB,GAAsC,CAC3D,OAAQ,EAAR,CACE,IAAK,OACH,MAAO,QACT,IAAK,UACH,MAAO,YAIA,EAAc,EAAM,QAC/B,EACA,EAAY,GAAG,CACb,UAAW,EAAY,CAAE,UAAS,YACzB,EAAO,IAAI,WAAa,CAC7B,IAAM,EAAc,MAAO,EAAO,WAAW,CAC3C,IAAK,SACH,MAAM,EAAM,EAAW,CAAC,SAAS,EAAQ,CAAE,UAAS,CAAC,CAAC,UAAU,CAClE,MAAQ,GACC,EAAgB,SAAS,gBAAiB,CAC/C,MAAO,EACR,CAAC,CAEL,CAAC,CACF,OAAO,IAAI,WAAW,EAAY,EAClC,CAEJ,QAAS,EAAY,CAAE,QAAO,SAAQ,SAC7B,EAAO,IAAI,WAAa,CAC7B,GAAI,CAAC,GAAS,CAAC,EACb,MAAU,MACR,sDACD,CAGH,IAAM,EAAW,EAAc,EAAI,CAC7B,EAAc,MAAO,EAAO,WAAW,CAC3C,IAAK,SACH,MAAM,EAAM,EAAW,CACpB,OAAO,EAAO,EAAQ,CAAE,IAAK,EAAU,CAAC,CACxC,UAAU,CACf,MAAQ,GACC,EAAgB,SAAS,gBAAiB,CAC/C,MAAO,EACR,CAAC,CAEL,CAAC,CAEF,OAAO,IAAI,WAAW,EAAY,EAClC,CAEL,CAAC,CACH"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/flow-images-sharp",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.6",
5
5
  "description": "Sharp image processing service for Uploadista Flow",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -17,15 +17,16 @@
17
17
  "effect": "3.18.4",
18
18
  "tinycolor2": "1.6.0",
19
19
  "zod": "4.1.12",
20
- "@uploadista/core": "0.0.3"
20
+ "@uploadista/core": "0.0.6"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/node": "24.8.1",
23
+ "@types/node": "24.9.1",
24
24
  "@types/tinycolor2": "1.4.6",
25
- "@uploadista/typescript-config": "0.0.3"
25
+ "tsdown": "0.15.9",
26
+ "@uploadista/typescript-config": "0.0.6"
26
27
  },
27
28
  "scripts": {
28
- "build": "tsc -b",
29
+ "build": "tsdown",
29
30
  "format": "biome format --write ./src",
30
31
  "lint": "biome lint --write ./src",
31
32
  "check": "biome check --write ./src"
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: "src/index.ts",
6
+ },
7
+ minify: true,
8
+ format: ["esm", "cjs"],
9
+ dts: true,
10
+ outDir: "dist",
11
+ });
@@ -1,5 +0,0 @@
1
-
2
- 
3
- > @uploadista/flow-images-sharp@0.0.2 build /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/flow/images/sharp
4
- > tsc -b
5
-
@@ -1,4 +0,0 @@
1
- import { ImagePlugin } from "@uploadista/core/flow";
2
- import { Layer } from "effect";
3
- export declare const imagePlugin: Layer.Layer<ImagePlugin, never, never>;
4
- //# sourceMappingURL=image-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-plugin.d.ts","sourceRoot":"","sources":["../src/image-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAYvC,eAAO,MAAM,WAAW,wCA0CvB,CAAC"}
@@ -1,46 +0,0 @@
1
- import { UploadistaError } from "@uploadista/core/errors";
2
- import { ImagePlugin } from "@uploadista/core/flow";
3
- import { Effect, Layer } from "effect";
4
- import sharp from "sharp";
5
- const mapFitToSharp = (fit) => {
6
- switch (fit) {
7
- case "fill":
8
- return "cover";
9
- case "contain":
10
- return "contain";
11
- }
12
- };
13
- export const imagePlugin = Layer.succeed(ImagePlugin, ImagePlugin.of({
14
- optimize: (inputBytes, { quality, format }) => {
15
- return Effect.gen(function* () {
16
- const outputBytes = yield* Effect.tryPromise({
17
- try: async () => await sharp(inputBytes).toFormat(format, { quality }).toBuffer(),
18
- catch: (error) => {
19
- return UploadistaError.fromCode("UNKNOWN_ERROR", {
20
- cause: error,
21
- });
22
- },
23
- });
24
- return new Uint8Array(outputBytes);
25
- });
26
- },
27
- resize: (inputBytes, { width, height, fit }) => {
28
- return Effect.gen(function* () {
29
- if (!width && !height) {
30
- throw new Error("Either width or height must be specified for resize");
31
- }
32
- const sharpFit = mapFitToSharp(fit);
33
- const outputBytes = yield* Effect.tryPromise({
34
- try: async () => await sharp(inputBytes)
35
- .resize(width, height, { fit: sharpFit })
36
- .toBuffer(),
37
- catch: (error) => {
38
- return UploadistaError.fromCode("UNKNOWN_ERROR", {
39
- cause: error,
40
- });
41
- },
42
- });
43
- return new Uint8Array(outputBytes);
44
- });
45
- },
46
- }));
@@ -1 +0,0 @@
1
- {"root":["./src/image-plugin.ts","./src/index.ts"],"version":"5.9.3"}