@bgord/bun 1.3.1 → 1.4.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.
Files changed (45) hide show
  1. package/dist/command-envelope.d.ts +1 -1
  2. package/dist/csv-stringifier.adapter.d.ts +1 -1
  3. package/dist/image-alpha-sharp.adapter.d.ts +1 -0
  4. package/dist/image-alpha-sharp.adapter.d.ts.map +1 -1
  5. package/dist/image-alpha-sharp.adapter.js +18 -77
  6. package/dist/image-alpha-sharp.adapter.js.map +1 -1
  7. package/dist/image-blur-sharp.adapter.d.ts +1 -0
  8. package/dist/image-blur-sharp.adapter.d.ts.map +1 -1
  9. package/dist/image-blur-sharp.adapter.js +14 -73
  10. package/dist/image-blur-sharp.adapter.js.map +1 -1
  11. package/dist/image-compressor-sharp.adapter.d.ts +1 -0
  12. package/dist/image-compressor-sharp.adapter.d.ts.map +1 -1
  13. package/dist/image-compressor-sharp.adapter.js +15 -74
  14. package/dist/image-compressor-sharp.adapter.js.map +1 -1
  15. package/dist/image-exif-clear-sharp.adapter.d.ts +1 -0
  16. package/dist/image-exif-clear-sharp.adapter.d.ts.map +1 -1
  17. package/dist/image-exif-clear-sharp.adapter.js +12 -71
  18. package/dist/image-exif-clear-sharp.adapter.js.map +1 -1
  19. package/dist/image-formatter-sharp.adapter.d.ts +1 -0
  20. package/dist/image-formatter-sharp.adapter.d.ts.map +1 -1
  21. package/dist/image-formatter-sharp.adapter.js +17 -76
  22. package/dist/image-formatter-sharp.adapter.js.map +1 -1
  23. package/dist/image-info-sharp.adapter.d.ts +1 -0
  24. package/dist/image-info-sharp.adapter.d.ts.map +1 -1
  25. package/dist/image-info-sharp.adapter.js +14 -73
  26. package/dist/image-info-sharp.adapter.js.map +1 -1
  27. package/dist/image-processor-sharp.adapter.d.ts +1 -0
  28. package/dist/image-processor-sharp.adapter.d.ts.map +1 -1
  29. package/dist/image-processor-sharp.adapter.js +28 -87
  30. package/dist/image-processor-sharp.adapter.js.map +1 -1
  31. package/dist/image-resizer-sharp.adapter.d.ts +1 -0
  32. package/dist/image-resizer-sharp.adapter.d.ts.map +1 -1
  33. package/dist/image-resizer-sharp.adapter.js +23 -82
  34. package/dist/image-resizer-sharp.adapter.js.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +20 -14
  37. package/readme.md +1 -1
  38. package/src/image-alpha-sharp.adapter.ts +9 -3
  39. package/src/image-blur-sharp.adapter.ts +7 -2
  40. package/src/image-compressor-sharp.adapter.ts +7 -2
  41. package/src/image-exif-clear-sharp.adapter.ts +6 -1
  42. package/src/image-formatter-sharp.adapter.ts +7 -2
  43. package/src/image-info-sharp.adapter.ts +6 -1
  44. package/src/image-processor-sharp.adapter.ts +7 -2
  45. package/src/image-resizer-sharp.adapter.ts +7 -2
@@ -7,7 +7,7 @@ type Dependencies = {
7
7
  export declare const CommandEnvelopeSchema: {
8
8
  id: import("zod").ZodUUID;
9
9
  correlationId: import("zod").ZodUUID;
10
- createdAt: import("better-auth/*").$ZodBranded<import("zod").ZodNumber, "TimestampValue">;
10
+ createdAt: import("better-auth").$ZodBranded<import("zod").ZodNumber, "TimestampValue">;
11
11
  };
12
12
  export declare const createCommandEnvelope: (deps: Dependencies) => {
13
13
  readonly id: string;
@@ -1,5 +1,5 @@
1
1
  import type { CsvColumnType, CsvRowType, CsvStringifierPort } from "./csv-stringifier.port";
2
2
  export declare class CsvStringifierAdapter implements CsvStringifierPort {
3
- process(columns: CsvColumnType[], data: CsvRowType[]): import("csv-stringify/.").Stringifier;
3
+ process(columns: CsvColumnType[], data: CsvRowType[]): import("csv-stringify").Stringifier;
4
4
  }
5
5
  //# sourceMappingURL=csv-stringifier.adapter.d.ts.map
@@ -6,6 +6,7 @@ type Dependencies = {
6
6
  export declare class ImageAlphaSharpAdapter implements ImageAlphaPort {
7
7
  private readonly deps;
8
8
  constructor(deps: Dependencies);
9
+ private load;
9
10
  flatten(recipe: ImageAlphaStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
10
11
  }
11
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"image-alpha-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-alpha-sharp.adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,sBAAuB,YAAW,cAAc;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAEzC,OAAO,CAAC,MAAM,EAAE,kBAAkB;CAqBzC"}
1
+ {"version":3,"file":"image-alpha-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-alpha-sharp.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,sBAAuB,YAAW,cAAc;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;YAEjC,IAAI;IAIZ,OAAO,CAAC,MAAM,EAAE,kBAAkB;CAwBzC"}
@@ -1,86 +1,27 @@
1
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
- if (value !== null && value !== void 0) {
3
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose, inner;
5
- if (async) {
6
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
- dispose = value[Symbol.asyncDispose];
8
- }
9
- if (dispose === void 0) {
10
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
- dispose = value[Symbol.dispose];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
- env.stack.push({ value: value, dispose: dispose, async: async });
17
- }
18
- else if (async) {
19
- env.stack.push({ async: true });
20
- }
21
- return value;
22
- };
23
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
- return function (env) {
25
- function fail(e) {
26
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
- env.hasError = true;
28
- }
29
- var r, s = 0;
30
- function next() {
31
- while (r = env.stack.pop()) {
32
- try {
33
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
- if (r.dispose) {
35
- var result = r.dispose.call(r.value);
36
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
- }
38
- else s |= 1;
39
- }
40
- catch (e) {
41
- fail(e);
42
- }
43
- }
44
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
- if (env.hasError) throw env.error;
46
- }
47
- return next();
48
- };
49
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- });
53
- import sharp from "sharp";
54
1
  export class ImageAlphaSharpAdapter {
55
2
  deps;
56
3
  constructor(deps) {
57
4
  this.deps = deps;
58
5
  }
6
+ async load() {
7
+ return (await import("sharp")).default;
8
+ }
59
9
  async flatten(recipe) {
60
- const env_1 = { stack: [], error: void 0, hasError: false };
61
- try {
62
- const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
63
- const filename = final.getFilename();
64
- const temporary = final.withFilename(filename.withSuffix("-flattened"));
65
- const extension = final.getFilename().getExtension();
66
- const format = (extension === "jpg" ? "jpeg" : extension);
67
- const pipeline = sharp(recipe.input.get());
68
- const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
69
- await pipeline
70
- .rotate()
71
- .flatten({ background: recipe.background })
72
- .toFormat(format)
73
- .toFile(temporary.get());
74
- await this.deps.FileRenamer.rename(temporary, final);
75
- return final;
76
- }
77
- catch (e_1) {
78
- env_1.error = e_1;
79
- env_1.hasError = true;
80
- }
81
- finally {
82
- __disposeResources(env_1);
83
- }
10
+ const sharp = await this.load();
11
+ const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
12
+ const filename = final.getFilename();
13
+ const temporary = final.withFilename(filename.withSuffix("-flattened"));
14
+ const extension = final.getFilename().getExtension();
15
+ const format = (extension === "jpg" ? "jpeg" : extension);
16
+ const pipeline = sharp(recipe.input.get());
17
+ using _pipeline_dispose = { [Symbol.dispose]: () => pipeline.destroy() };
18
+ await pipeline
19
+ .rotate()
20
+ .flatten({ background: recipe.background })
21
+ .toFormat(format)
22
+ .toFile(temporary.get());
23
+ await this.deps.FileRenamer.rename(temporary, final);
24
+ return final;
84
25
  }
85
26
  }
86
27
  //# sourceMappingURL=image-alpha-sharp.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-alpha-sharp.adapter.js","sourceRoot":"","sources":["../src/image-alpha-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,OAAO,sBAAsB;IACJ;IAA7B,YAA6B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAEnD,KAAK,CAAC,OAAO,CAAC,MAA0B;;;YACtC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAE/E,MAAM,QAAQ,GAAG,KAAK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I,EAAE,CAAC;QAEhC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAE/E,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;QAExE,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAqC,CAAC;QAE9F,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3C,MAAM,iBAAiB,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QAEzE,MAAM,QAAQ;aACX,MAAM,EAAE;aACR,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;aAC1C,QAAQ,CAAC,MAAM,CAAC;aAChB,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;QAE3B,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -6,6 +6,7 @@ type Dependencies = {
6
6
  export declare class ImageBlurSharpAdapter implements ImageBlurPort {
7
7
  private readonly deps;
8
8
  constructor(deps: Dependencies);
9
+ private load;
9
10
  blur(recipe: ImageBlurStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
10
11
  }
11
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"image-blur-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-blur-sharp.adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,qBAAsB,YAAW,aAAa;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAEzC,IAAI,CAAC,MAAM,EAAE,iBAAiB;CAiBrC"}
1
+ {"version":3,"file":"image-blur-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-blur-sharp.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,qBAAsB,YAAW,aAAa;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;YAEjC,IAAI;IAIZ,IAAI,CAAC,MAAM,EAAE,iBAAiB;CAmBrC"}
@@ -1,82 +1,23 @@
1
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
- if (value !== null && value !== void 0) {
3
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose, inner;
5
- if (async) {
6
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
- dispose = value[Symbol.asyncDispose];
8
- }
9
- if (dispose === void 0) {
10
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
- dispose = value[Symbol.dispose];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
- env.stack.push({ value: value, dispose: dispose, async: async });
17
- }
18
- else if (async) {
19
- env.stack.push({ async: true });
20
- }
21
- return value;
22
- };
23
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
- return function (env) {
25
- function fail(e) {
26
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
- env.hasError = true;
28
- }
29
- var r, s = 0;
30
- function next() {
31
- while (r = env.stack.pop()) {
32
- try {
33
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
- if (r.dispose) {
35
- var result = r.dispose.call(r.value);
36
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
- }
38
- else s |= 1;
39
- }
40
- catch (e) {
41
- fail(e);
42
- }
43
- }
44
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
- if (env.hasError) throw env.error;
46
- }
47
- return next();
48
- };
49
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- });
53
- import sharp from "sharp";
54
1
  export class ImageBlurSharpAdapter {
55
2
  deps;
56
3
  constructor(deps) {
57
4
  this.deps = deps;
58
5
  }
6
+ async load() {
7
+ return (await import("sharp")).default;
8
+ }
59
9
  async blur(recipe) {
60
- const env_1 = { stack: [], error: void 0, hasError: false };
61
- try {
62
- const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
63
- const filename = final.getFilename();
64
- const temporary = final.withFilename(filename.withSuffix("-blurred"));
65
- const extension = final.getFilename().getExtension();
66
- const format = (extension === "jpg" ? "jpeg" : extension);
67
- const pipeline = sharp(recipe.input.get());
68
- const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
69
- await pipeline.rotate().blur(recipe.sigma).toFormat(format).toFile(temporary.get());
70
- await this.deps.FileRenamer.rename(temporary, final);
71
- return final;
72
- }
73
- catch (e_1) {
74
- env_1.error = e_1;
75
- env_1.hasError = true;
76
- }
77
- finally {
78
- __disposeResources(env_1);
79
- }
10
+ const sharp = await this.load();
11
+ const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
12
+ const filename = final.getFilename();
13
+ const temporary = final.withFilename(filename.withSuffix("-blurred"));
14
+ const extension = final.getFilename().getExtension();
15
+ const format = (extension === "jpg" ? "jpeg" : extension);
16
+ const pipeline = sharp(recipe.input.get());
17
+ using _sharp_ = { [Symbol.dispose]: () => pipeline.destroy() };
18
+ await pipeline.rotate().blur(recipe.sigma).toFormat(format).toFile(temporary.get());
19
+ await this.deps.FileRenamer.rename(temporary, final);
20
+ return final;
80
21
  }
81
22
  }
82
23
  //# sourceMappingURL=image-blur-sharp.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-blur-sharp.adapter.js","sourceRoot":"","sources":["../src/image-blur-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,OAAO,qBAAqB;IACH;IAA7B,YAA6B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAEnD,KAAK,CAAC,IAAI,CAAC,MAAyB;;;YAClC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAE/E,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC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/E,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;QAEtE,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAqC,CAAC;QAE9F,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QAE/D,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;QACpF,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -6,6 +6,7 @@ type Dependencies = {
6
6
  export declare class ImageCompressorSharpAdapter implements ImageCompressorPort {
7
7
  private readonly deps;
8
8
  constructor(deps: Dependencies);
9
+ private load;
9
10
  private static readonly DEFAULT_QUALITY;
10
11
  compress(recipe: ImageCompressorStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"image-compressor-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-compressor-sharp.adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,2BAA4B,YAAW,mBAAmB;IACzD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAE/C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAM;IAEvC,QAAQ,CAAC,MAAM,EAAE,uBAAuB;CAkB/C"}
1
+ {"version":3,"file":"image-compressor-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-compressor-sharp.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,2BAA4B,YAAW,mBAAmB;IACzD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;YAEjC,IAAI;IAIlB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAM;IAEvC,QAAQ,CAAC,MAAM,EAAE,uBAAuB;CAoB/C"}
@@ -1,84 +1,25 @@
1
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
- if (value !== null && value !== void 0) {
3
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose, inner;
5
- if (async) {
6
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
- dispose = value[Symbol.asyncDispose];
8
- }
9
- if (dispose === void 0) {
10
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
- dispose = value[Symbol.dispose];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
- env.stack.push({ value: value, dispose: dispose, async: async });
17
- }
18
- else if (async) {
19
- env.stack.push({ async: true });
20
- }
21
- return value;
22
- };
23
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
- return function (env) {
25
- function fail(e) {
26
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
- env.hasError = true;
28
- }
29
- var r, s = 0;
30
- function next() {
31
- while (r = env.stack.pop()) {
32
- try {
33
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
- if (r.dispose) {
35
- var result = r.dispose.call(r.value);
36
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
- }
38
- else s |= 1;
39
- }
40
- catch (e) {
41
- fail(e);
42
- }
43
- }
44
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
- if (env.hasError) throw env.error;
46
- }
47
- return next();
48
- };
49
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- });
53
- import sharp from "sharp";
54
1
  export class ImageCompressorSharpAdapter {
55
2
  deps;
56
3
  constructor(deps) {
57
4
  this.deps = deps;
58
5
  }
6
+ async load() {
7
+ return (await import("sharp")).default;
8
+ }
59
9
  static DEFAULT_QUALITY = 85;
60
10
  async compress(recipe) {
61
- const env_1 = { stack: [], error: void 0, hasError: false };
62
- try {
63
- const quality = recipe.quality ?? ImageCompressorSharpAdapter.DEFAULT_QUALITY;
64
- const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
65
- const filename = final.getFilename();
66
- const temporary = final.withFilename(filename.withSuffix("-compressed"));
67
- const extension = final.getFilename().getExtension();
68
- const format = (extension === "jpg" ? "jpeg" : extension);
69
- const pipeline = sharp(recipe.input.get());
70
- const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
71
- await pipeline.rotate().toFormat(format, { quality }).toFile(temporary.get());
72
- await this.deps.FileRenamer.rename(temporary, final);
73
- return final;
74
- }
75
- catch (e_1) {
76
- env_1.error = e_1;
77
- env_1.hasError = true;
78
- }
79
- finally {
80
- __disposeResources(env_1);
81
- }
11
+ const sharp = await this.load();
12
+ const quality = recipe.quality ?? ImageCompressorSharpAdapter.DEFAULT_QUALITY;
13
+ const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
14
+ const filename = final.getFilename();
15
+ const temporary = final.withFilename(filename.withSuffix("-compressed"));
16
+ const extension = final.getFilename().getExtension();
17
+ const format = (extension === "jpg" ? "jpeg" : extension);
18
+ const pipeline = sharp(recipe.input.get());
19
+ using _sharp_ = { [Symbol.dispose]: () => pipeline.destroy() };
20
+ await pipeline.rotate().toFormat(format, { quality }).toFile(temporary.get());
21
+ await this.deps.FileRenamer.rename(temporary, final);
22
+ return final;
82
23
  }
83
24
  }
84
25
  //# sourceMappingURL=image-compressor-sharp.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-compressor-sharp.adapter.js","sourceRoot":"","sources":["../src/image-compressor-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,OAAO,2BAA2B;IACT;IAA7B,YAA6B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAE3C,MAAM,CAAU,eAAe,GAAG,EAAE,CAAC;IAE7C,KAAK,CAAC,QAAQ,CAAC,MAA+B;;;YAC5C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,2BAA2B,CAAC,eAAe,CAAC;YAE9E,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC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8
8
  constructor(deps: Dependencies);
9
+ private load;
9
10
  clear(recipe: ImageExifClearStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
10
11
  }
11
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"image-exif-clear-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-exif-clear-sharp.adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAE1F,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,0BAA2B,YAAW,kBAAkB;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAEzC,KAAK,CAAC,MAAM,EAAE,sBAAsB;CAc3C"}
1
+ {"version":3,"file":"image-exif-clear-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-exif-clear-sharp.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAE1F,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,0BAA2B,YAAW,kBAAkB;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;YAEjC,IAAI;IAIZ,KAAK,CAAC,MAAM,EAAE,sBAAsB;CAgB3C"}
@@ -1,80 +1,21 @@
1
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
- if (value !== null && value !== void 0) {
3
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose, inner;
5
- if (async) {
6
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
- dispose = value[Symbol.asyncDispose];
8
- }
9
- if (dispose === void 0) {
10
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
- dispose = value[Symbol.dispose];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
- env.stack.push({ value: value, dispose: dispose, async: async });
17
- }
18
- else if (async) {
19
- env.stack.push({ async: true });
20
- }
21
- return value;
22
- };
23
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
- return function (env) {
25
- function fail(e) {
26
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
- env.hasError = true;
28
- }
29
- var r, s = 0;
30
- function next() {
31
- while (r = env.stack.pop()) {
32
- try {
33
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
- if (r.dispose) {
35
- var result = r.dispose.call(r.value);
36
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
- }
38
- else s |= 1;
39
- }
40
- catch (e) {
41
- fail(e);
42
- }
43
- }
44
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
- if (env.hasError) throw env.error;
46
- }
47
- return next();
48
- };
49
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- });
53
- import sharp from "sharp";
54
1
  export class ImageExifClearSharpAdapter {
55
2
  deps;
56
3
  constructor(deps) {
57
4
  this.deps = deps;
58
5
  }
6
+ async load() {
7
+ return (await import("sharp")).default;
8
+ }
59
9
  async clear(recipe) {
60
- const env_1 = { stack: [], error: void 0, hasError: false };
61
- try {
62
- const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
63
- const filename = final.getFilename();
64
- const temporary = final.withFilename(filename.withSuffix("-exif-cleared"));
65
- const pipeline = sharp(recipe.input.get());
66
- const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
67
- await pipeline.rotate().toFile(temporary.get());
68
- await this.deps.FileRenamer.rename(temporary, final);
69
- return final;
70
- }
71
- catch (e_1) {
72
- env_1.error = e_1;
73
- env_1.hasError = true;
74
- }
75
- finally {
76
- __disposeResources(env_1);
77
- }
10
+ const sharp = await this.load();
11
+ const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
12
+ const filename = final.getFilename();
13
+ const temporary = final.withFilename(filename.withSuffix("-exif-cleared"));
14
+ const pipeline = sharp(recipe.input.get());
15
+ using _sharp_ = { [Symbol.dispose]: () => pipeline.destroy() };
16
+ await pipeline.rotate().toFile(temporary.get());
17
+ await this.deps.FileRenamer.rename(temporary, final);
18
+ return final;
78
19
  }
79
20
  }
80
21
  //# sourceMappingURL=image-exif-clear-sharp.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-exif-clear-sharp.adapter.js","sourceRoot":"","sources":["../src/image-exif-clear-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,OAAO,0BAA0B;IACR;IAA7B,YAA6B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAEnD,KAAK,CAAC,KAAK,CAAC,MAA8B;;;YACxC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAE/E,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC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,MAAM,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QAE/D,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;QAChD,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -8,6 +8,7 @@ type Dependencies = {
8
8
  export declare class ImageFormatterSharpAdapter implements ImageFormatterPort {
9
9
  private readonly deps;
10
10
  constructor(deps: Dependencies);
11
+ private load;
11
12
  format(recipe: ImageFormatterStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
12
13
  }
13
14
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"image-formatter-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-formatter-sharp.adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAC;IAAC,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAEnF,qBAAa,0BAA2B,YAAW,kBAAkB;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAEzC,MAAM,CAAC,MAAM,EAAE,sBAAsB;CAuB5C"}
1
+ {"version":3,"file":"image-formatter-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-formatter-sharp.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAC;IAAC,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAEnF,qBAAa,0BAA2B,YAAW,kBAAkB;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;YAEjC,IAAI;IAIZ,MAAM,CAAC,MAAM,EAAE,sBAAsB;CAyB5C"}
@@ -1,86 +1,27 @@
1
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
- if (value !== null && value !== void 0) {
3
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose, inner;
5
- if (async) {
6
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
- dispose = value[Symbol.asyncDispose];
8
- }
9
- if (dispose === void 0) {
10
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
- dispose = value[Symbol.dispose];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
- env.stack.push({ value: value, dispose: dispose, async: async });
17
- }
18
- else if (async) {
19
- env.stack.push({ async: true });
20
- }
21
- return value;
22
- };
23
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
- return function (env) {
25
- function fail(e) {
26
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
- env.hasError = true;
28
- }
29
- var r, s = 0;
30
- function next() {
31
- while (r = env.stack.pop()) {
32
- try {
33
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
- if (r.dispose) {
35
- var result = r.dispose.call(r.value);
36
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
- }
38
- else s |= 1;
39
- }
40
- catch (e) {
41
- fail(e);
42
- }
43
- }
44
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
- if (env.hasError) throw env.error;
46
- }
47
- return next();
48
- };
49
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- });
53
- import sharp from "sharp";
54
1
  export class ImageFormatterSharpAdapter {
55
2
  deps;
56
3
  constructor(deps) {
57
4
  this.deps = deps;
58
5
  }
6
+ async load() {
7
+ return (await import("sharp")).default;
8
+ }
59
9
  async format(recipe) {
60
- const env_1 = { stack: [], error: void 0, hasError: false };
61
- try {
62
- const final = recipe.strategy === "output_path"
63
- ? recipe.output
64
- : recipe.input.withFilename(recipe.input.getFilename().withExtension(recipe.to));
65
- const temporary = final.withFilename(final.getFilename().withSuffix("-formatted"));
66
- const extension = final.getFilename().getExtension();
67
- const encoder = (extension === "jpg" ? "jpeg" : extension);
68
- const pipeline = sharp((recipe.strategy === "output_path" ? recipe.input : recipe.input).get());
69
- const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
70
- await pipeline.toFormat(encoder).toFile(temporary.get());
71
- await this.deps.FileRenamer.rename(temporary, final);
72
- if (recipe.strategy === "in_place" && final.get() !== recipe.input.get()) {
73
- await this.deps.FileCleaner.delete(recipe.input.get());
74
- }
75
- return final;
76
- }
77
- catch (e_1) {
78
- env_1.error = e_1;
79
- env_1.hasError = true;
80
- }
81
- finally {
82
- __disposeResources(env_1);
10
+ const sharp = await this.load();
11
+ const final = recipe.strategy === "output_path"
12
+ ? recipe.output
13
+ : recipe.input.withFilename(recipe.input.getFilename().withExtension(recipe.to));
14
+ const temporary = final.withFilename(final.getFilename().withSuffix("-formatted"));
15
+ const extension = final.getFilename().getExtension();
16
+ const encoder = (extension === "jpg" ? "jpeg" : extension);
17
+ const pipeline = sharp((recipe.strategy === "output_path" ? recipe.input : recipe.input).get());
18
+ using _sharp_ = { [Symbol.dispose]: () => pipeline.destroy() };
19
+ await pipeline.toFormat(encoder).toFile(temporary.get());
20
+ await this.deps.FileRenamer.rename(temporary, final);
21
+ if (recipe.strategy === "in_place" && final.get() !== recipe.input.get()) {
22
+ await this.deps.FileCleaner.delete(recipe.input.get());
83
23
  }
24
+ return final;
84
25
  }
85
26
  }
86
27
  //# sourceMappingURL=image-formatter-sharp.adapter.js.map