apexify.js 4.8.1 → 4.8.2

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 (255) hide show
  1. package/dist/cjs/ai/ApexAI.d.ts +0 -1
  2. package/dist/cjs/ai/ApexAI.js +56 -64
  3. package/dist/cjs/ai/ApexModules.d.ts +0 -1
  4. package/dist/cjs/ai/ApexModules.js +25 -33
  5. package/dist/cjs/ai/functions/readFiles.d.ts +0 -1
  6. package/dist/cjs/ai/functions/readFiles.js +11 -51
  7. package/dist/cjs/ai/functions/tokenizer.d.ts +0 -1
  8. package/dist/cjs/ai/functions/tokenizer.js +1 -5
  9. package/dist/cjs/ai/functions/validOptions.d.ts +0 -1
  10. package/dist/cjs/ai/functions/validOptions.js +13 -23
  11. package/dist/cjs/ai/modals/electronHub/chatmodels.d.ts +0 -1
  12. package/dist/cjs/ai/modals/electronHub/chatmodels.js +5 -12
  13. package/dist/cjs/ai/modals/electronHub/imageModels.d.ts +0 -1
  14. package/dist/cjs/ai/modals/electronHub/imageModels.js +10 -17
  15. package/dist/cjs/ai/modals/electronHub/songModels.d.ts +0 -1
  16. package/dist/cjs/ai/modals/electronHub/songModels.js +1 -3
  17. package/dist/cjs/ai/modals/electronHub/speechModels.d.ts +0 -1
  18. package/dist/cjs/ai/modals/electronHub/speechModels.js +7 -14
  19. package/dist/cjs/ai/modals/electronHub/videoModels.d.ts +0 -1
  20. package/dist/cjs/ai/modals/electronHub/videoModels.js +5 -12
  21. package/dist/cjs/ai/modals/groq/chatgroq.d.ts +0 -1
  22. package/dist/cjs/ai/modals/groq/chatgroq.js +4 -11
  23. package/dist/cjs/ai/modals/groq/imageAnalyzer.d.ts +0 -1
  24. package/dist/cjs/ai/modals/groq/imageAnalyzer.js +9 -16
  25. package/dist/cjs/ai/modals/groq/whisper.d.ts +0 -1
  26. package/dist/cjs/ai/modals/groq/whisper.js +20 -27
  27. package/dist/cjs/ai/modals/hercai/chatModels.d.ts +0 -1
  28. package/dist/cjs/ai/modals/hercai/chatModels.js +3 -7
  29. package/dist/cjs/ai/utils.d.ts +4 -6
  30. package/dist/cjs/ai/utils.js +4 -17
  31. package/dist/cjs/canvas/ApexPainter.d.ts +1 -2
  32. package/dist/cjs/canvas/ApexPainter.js +93 -101
  33. package/dist/cjs/canvas/utils/Background/bg.d.ts +1 -2
  34. package/dist/cjs/canvas/utils/Background/bg.js +8 -18
  35. package/dist/cjs/canvas/utils/Charts/charts.d.ts +1 -2
  36. package/dist/cjs/canvas/utils/Charts/charts.js +14 -23
  37. package/dist/cjs/canvas/utils/Custom/customLines.d.ts +1 -2
  38. package/dist/cjs/canvas/utils/Custom/customLines.js +4 -8
  39. package/dist/cjs/canvas/utils/General/conversion.d.ts +0 -1
  40. package/dist/cjs/canvas/utils/General/conversion.js +7 -15
  41. package/dist/cjs/canvas/utils/General/general functions.d.ts +1 -2
  42. package/dist/cjs/canvas/utils/General/general functions.js +48 -64
  43. package/dist/cjs/canvas/utils/Image/imageProperties.d.ts +1 -2
  44. package/dist/cjs/canvas/utils/Image/imageProperties.js +9 -21
  45. package/dist/cjs/canvas/utils/Texts/textProperties.d.ts +1 -2
  46. package/dist/cjs/canvas/utils/Texts/textProperties.js +3 -9
  47. package/dist/cjs/canvas/utils/types.d.ts +0 -1
  48. package/dist/cjs/canvas/utils/types.js +1 -3
  49. package/dist/cjs/canvas/utils/utils.d.ts +8 -9
  50. package/dist/cjs/canvas/utils/utils.js +8 -44
  51. package/dist/cjs/index.d.ts +5 -6
  52. package/dist/cjs/index.js +15 -65
  53. package/dist/cjs/utils.d.ts +3 -4
  54. package/dist/cjs/utils.js +4 -16
  55. package/dist/esm/ai/ApexAI.d.ts +0 -1
  56. package/dist/esm/ai/ApexAI.js +56 -64
  57. package/dist/esm/ai/ApexModules.d.ts +0 -1
  58. package/dist/esm/ai/ApexModules.js +25 -33
  59. package/dist/esm/ai/functions/readFiles.d.ts +0 -1
  60. package/dist/esm/ai/functions/readFiles.js +11 -51
  61. package/dist/esm/ai/functions/tokenizer.d.ts +0 -1
  62. package/dist/esm/ai/functions/tokenizer.js +1 -5
  63. package/dist/esm/ai/functions/validOptions.d.ts +0 -1
  64. package/dist/esm/ai/functions/validOptions.js +13 -23
  65. package/dist/esm/ai/modals/electronHub/chatmodels.d.ts +0 -1
  66. package/dist/esm/ai/modals/electronHub/chatmodels.js +5 -12
  67. package/dist/esm/ai/modals/electronHub/imageModels.d.ts +0 -1
  68. package/dist/esm/ai/modals/electronHub/imageModels.js +10 -17
  69. package/dist/esm/ai/modals/electronHub/songModels.d.ts +0 -1
  70. package/dist/esm/ai/modals/electronHub/songModels.js +1 -3
  71. package/dist/esm/ai/modals/electronHub/speechModels.d.ts +0 -1
  72. package/dist/esm/ai/modals/electronHub/speechModels.js +7 -14
  73. package/dist/esm/ai/modals/electronHub/videoModels.d.ts +0 -1
  74. package/dist/esm/ai/modals/electronHub/videoModels.js +5 -12
  75. package/dist/esm/ai/modals/groq/chatgroq.d.ts +0 -1
  76. package/dist/esm/ai/modals/groq/chatgroq.js +4 -11
  77. package/dist/esm/ai/modals/groq/imageAnalyzer.d.ts +0 -1
  78. package/dist/esm/ai/modals/groq/imageAnalyzer.js +9 -16
  79. package/dist/esm/ai/modals/groq/whisper.d.ts +0 -1
  80. package/dist/esm/ai/modals/groq/whisper.js +20 -27
  81. package/dist/esm/ai/modals/hercai/chatModels.d.ts +0 -1
  82. package/dist/esm/ai/modals/hercai/chatModels.js +3 -7
  83. package/dist/esm/ai/utils.d.ts +4 -6
  84. package/dist/esm/ai/utils.js +4 -17
  85. package/dist/esm/canvas/ApexPainter.d.ts +1 -2
  86. package/dist/esm/canvas/ApexPainter.js +93 -101
  87. package/dist/esm/canvas/utils/Background/bg.d.ts +1 -2
  88. package/dist/esm/canvas/utils/Background/bg.js +8 -18
  89. package/dist/esm/canvas/utils/Charts/charts.d.ts +1 -2
  90. package/dist/esm/canvas/utils/Charts/charts.js +14 -23
  91. package/dist/esm/canvas/utils/Custom/customLines.d.ts +1 -2
  92. package/dist/esm/canvas/utils/Custom/customLines.js +4 -8
  93. package/dist/esm/canvas/utils/General/conversion.d.ts +0 -1
  94. package/dist/esm/canvas/utils/General/conversion.js +7 -15
  95. package/dist/esm/canvas/utils/General/general functions.d.ts +1 -2
  96. package/dist/esm/canvas/utils/General/general functions.js +48 -64
  97. package/dist/esm/canvas/utils/Image/imageProperties.d.ts +1 -2
  98. package/dist/esm/canvas/utils/Image/imageProperties.js +9 -21
  99. package/dist/esm/canvas/utils/Texts/textProperties.d.ts +1 -2
  100. package/dist/esm/canvas/utils/Texts/textProperties.js +3 -9
  101. package/dist/esm/canvas/utils/types.d.ts +0 -1
  102. package/dist/esm/canvas/utils/types.js +1 -3
  103. package/dist/esm/canvas/utils/utils.d.ts +8 -9
  104. package/dist/esm/canvas/utils/utils.js +8 -44
  105. package/dist/esm/index.d.ts +5 -6
  106. package/dist/esm/index.js +15 -65
  107. package/dist/esm/utils.d.ts +3 -4
  108. package/dist/esm/utils.js +4 -16
  109. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  110. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  111. package/lib/ai/ApexAI.ts +2 -2
  112. package/lib/ai/ApexModules.ts +8 -8
  113. package/lib/ai/modals/electronHub/chatmodels.ts +1 -1
  114. package/lib/ai/modals/electronHub/imageModels.ts +2 -2
  115. package/lib/ai/modals/electronHub/speechModels.ts +1 -1
  116. package/lib/ai/utils.ts +3 -5
  117. package/lib/canvas/ApexPainter.ts +4 -4
  118. package/lib/canvas/utils/Background/bg.ts +1 -1
  119. package/lib/canvas/utils/Charts/charts.ts +1 -1
  120. package/lib/canvas/utils/Custom/customLines.ts +2 -2
  121. package/lib/canvas/utils/General/general functions.ts +1 -1
  122. package/lib/canvas/utils/Image/imageProperties.ts +1 -1
  123. package/lib/canvas/utils/Texts/textProperties.ts +1 -1
  124. package/lib/canvas/utils/utils.ts +8 -8
  125. package/lib/index.ts +5 -5
  126. package/lib/utils.ts +3 -3
  127. package/package.json +7 -5
  128. package/dist/cjs/ai/ApexAI.d.ts.map +0 -1
  129. package/dist/cjs/ai/ApexAI.js.map +0 -1
  130. package/dist/cjs/ai/ApexModules.d.ts.map +0 -1
  131. package/dist/cjs/ai/ApexModules.js.map +0 -1
  132. package/dist/cjs/ai/functions/readFiles.d.ts.map +0 -1
  133. package/dist/cjs/ai/functions/readFiles.js.map +0 -1
  134. package/dist/cjs/ai/functions/tokenizer.d.ts.map +0 -1
  135. package/dist/cjs/ai/functions/tokenizer.js.map +0 -1
  136. package/dist/cjs/ai/functions/typeWriter.d.ts +0 -2
  137. package/dist/cjs/ai/functions/typeWriter.d.ts.map +0 -1
  138. package/dist/cjs/ai/functions/typeWriter.js +0 -24
  139. package/dist/cjs/ai/functions/typeWriter.js.map +0 -1
  140. package/dist/cjs/ai/functions/validOptions.d.ts.map +0 -1
  141. package/dist/cjs/ai/functions/validOptions.js.map +0 -1
  142. package/dist/cjs/ai/modals/electronHub/chatmodels.d.ts.map +0 -1
  143. package/dist/cjs/ai/modals/electronHub/chatmodels.js.map +0 -1
  144. package/dist/cjs/ai/modals/electronHub/imageModels.d.ts.map +0 -1
  145. package/dist/cjs/ai/modals/electronHub/imageModels.js.map +0 -1
  146. package/dist/cjs/ai/modals/electronHub/songModels.d.ts.map +0 -1
  147. package/dist/cjs/ai/modals/electronHub/songModels.js.map +0 -1
  148. package/dist/cjs/ai/modals/electronHub/speechModels.d.ts.map +0 -1
  149. package/dist/cjs/ai/modals/electronHub/speechModels.js.map +0 -1
  150. package/dist/cjs/ai/modals/electronHub/videoModels.d.ts.map +0 -1
  151. package/dist/cjs/ai/modals/electronHub/videoModels.js.map +0 -1
  152. package/dist/cjs/ai/modals/groq/chatgroq.d.ts.map +0 -1
  153. package/dist/cjs/ai/modals/groq/chatgroq.js.map +0 -1
  154. package/dist/cjs/ai/modals/groq/imageAnalyzer.d.ts.map +0 -1
  155. package/dist/cjs/ai/modals/groq/imageAnalyzer.js.map +0 -1
  156. package/dist/cjs/ai/modals/groq/whisper.d.ts.map +0 -1
  157. package/dist/cjs/ai/modals/groq/whisper.js.map +0 -1
  158. package/dist/cjs/ai/modals/hercai/chatModels.d.ts.map +0 -1
  159. package/dist/cjs/ai/modals/hercai/chatModels.js.map +0 -1
  160. package/dist/cjs/ai/utils.d.ts.map +0 -1
  161. package/dist/cjs/ai/utils.js.map +0 -1
  162. package/dist/cjs/canvas/ApexPainter.d.ts.map +0 -1
  163. package/dist/cjs/canvas/ApexPainter.js.map +0 -1
  164. package/dist/cjs/canvas/Themes/Level-Up/levelup.d.ts +0 -11
  165. package/dist/cjs/canvas/Themes/Level-Up/levelup.d.ts.map +0 -1
  166. package/dist/cjs/canvas/Themes/Level-Up/levelup.js +0 -163
  167. package/dist/cjs/canvas/Themes/Level-Up/levelup.js.map +0 -1
  168. package/dist/cjs/canvas/utils/Background/bg.d.ts.map +0 -1
  169. package/dist/cjs/canvas/utils/Background/bg.js.map +0 -1
  170. package/dist/cjs/canvas/utils/Charts/charts.d.ts.map +0 -1
  171. package/dist/cjs/canvas/utils/Charts/charts.js.map +0 -1
  172. package/dist/cjs/canvas/utils/Custom/customLines.d.ts.map +0 -1
  173. package/dist/cjs/canvas/utils/Custom/customLines.js.map +0 -1
  174. package/dist/cjs/canvas/utils/General/conversion.d.ts.map +0 -1
  175. package/dist/cjs/canvas/utils/General/conversion.js.map +0 -1
  176. package/dist/cjs/canvas/utils/General/general functions.d.ts.map +0 -1
  177. package/dist/cjs/canvas/utils/General/general functions.js.map +0 -1
  178. package/dist/cjs/canvas/utils/Image/imageProperties.d.ts.map +0 -1
  179. package/dist/cjs/canvas/utils/Image/imageProperties.js.map +0 -1
  180. package/dist/cjs/canvas/utils/Texts/textProperties.d.ts.map +0 -1
  181. package/dist/cjs/canvas/utils/Texts/textProperties.js.map +0 -1
  182. package/dist/cjs/canvas/utils/types.d.ts.map +0 -1
  183. package/dist/cjs/canvas/utils/types.js.map +0 -1
  184. package/dist/cjs/canvas/utils/utils.d.ts.map +0 -1
  185. package/dist/cjs/canvas/utils/utils.js.map +0 -1
  186. package/dist/cjs/index.d.ts.map +0 -1
  187. package/dist/cjs/index.js.map +0 -1
  188. package/dist/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  189. package/dist/cjs/utils.d.ts.map +0 -1
  190. package/dist/cjs/utils.js.map +0 -1
  191. package/dist/esm/ai/ApexAI.d.ts.map +0 -1
  192. package/dist/esm/ai/ApexAI.js.map +0 -1
  193. package/dist/esm/ai/ApexModules.d.ts.map +0 -1
  194. package/dist/esm/ai/ApexModules.js.map +0 -1
  195. package/dist/esm/ai/functions/readFiles.d.ts.map +0 -1
  196. package/dist/esm/ai/functions/readFiles.js.map +0 -1
  197. package/dist/esm/ai/functions/tokenizer.d.ts.map +0 -1
  198. package/dist/esm/ai/functions/tokenizer.js.map +0 -1
  199. package/dist/esm/ai/functions/typeWriter.d.ts +0 -2
  200. package/dist/esm/ai/functions/typeWriter.d.ts.map +0 -1
  201. package/dist/esm/ai/functions/typeWriter.js +0 -24
  202. package/dist/esm/ai/functions/typeWriter.js.map +0 -1
  203. package/dist/esm/ai/functions/validOptions.d.ts.map +0 -1
  204. package/dist/esm/ai/functions/validOptions.js.map +0 -1
  205. package/dist/esm/ai/modals/electronHub/chatmodels.d.ts.map +0 -1
  206. package/dist/esm/ai/modals/electronHub/chatmodels.js.map +0 -1
  207. package/dist/esm/ai/modals/electronHub/imageModels.d.ts.map +0 -1
  208. package/dist/esm/ai/modals/electronHub/imageModels.js.map +0 -1
  209. package/dist/esm/ai/modals/electronHub/songModels.d.ts.map +0 -1
  210. package/dist/esm/ai/modals/electronHub/songModels.js.map +0 -1
  211. package/dist/esm/ai/modals/electronHub/speechModels.d.ts.map +0 -1
  212. package/dist/esm/ai/modals/electronHub/speechModels.js.map +0 -1
  213. package/dist/esm/ai/modals/electronHub/videoModels.d.ts.map +0 -1
  214. package/dist/esm/ai/modals/electronHub/videoModels.js.map +0 -1
  215. package/dist/esm/ai/modals/groq/chatgroq.d.ts.map +0 -1
  216. package/dist/esm/ai/modals/groq/chatgroq.js.map +0 -1
  217. package/dist/esm/ai/modals/groq/imageAnalyzer.d.ts.map +0 -1
  218. package/dist/esm/ai/modals/groq/imageAnalyzer.js.map +0 -1
  219. package/dist/esm/ai/modals/groq/whisper.d.ts.map +0 -1
  220. package/dist/esm/ai/modals/groq/whisper.js.map +0 -1
  221. package/dist/esm/ai/modals/hercai/chatModels.d.ts.map +0 -1
  222. package/dist/esm/ai/modals/hercai/chatModels.js.map +0 -1
  223. package/dist/esm/ai/utils.d.ts.map +0 -1
  224. package/dist/esm/ai/utils.js.map +0 -1
  225. package/dist/esm/canvas/ApexPainter.d.ts.map +0 -1
  226. package/dist/esm/canvas/ApexPainter.js.map +0 -1
  227. package/dist/esm/canvas/Themes/Level-Up/levelup.d.ts +0 -11
  228. package/dist/esm/canvas/Themes/Level-Up/levelup.d.ts.map +0 -1
  229. package/dist/esm/canvas/Themes/Level-Up/levelup.js +0 -163
  230. package/dist/esm/canvas/Themes/Level-Up/levelup.js.map +0 -1
  231. package/dist/esm/canvas/utils/Background/bg.d.ts.map +0 -1
  232. package/dist/esm/canvas/utils/Background/bg.js.map +0 -1
  233. package/dist/esm/canvas/utils/Charts/charts.d.ts.map +0 -1
  234. package/dist/esm/canvas/utils/Charts/charts.js.map +0 -1
  235. package/dist/esm/canvas/utils/Custom/customLines.d.ts.map +0 -1
  236. package/dist/esm/canvas/utils/Custom/customLines.js.map +0 -1
  237. package/dist/esm/canvas/utils/General/conversion.d.ts.map +0 -1
  238. package/dist/esm/canvas/utils/General/conversion.js.map +0 -1
  239. package/dist/esm/canvas/utils/General/general functions.d.ts.map +0 -1
  240. package/dist/esm/canvas/utils/General/general functions.js.map +0 -1
  241. package/dist/esm/canvas/utils/Image/imageProperties.d.ts.map +0 -1
  242. package/dist/esm/canvas/utils/Image/imageProperties.js.map +0 -1
  243. package/dist/esm/canvas/utils/Texts/textProperties.d.ts.map +0 -1
  244. package/dist/esm/canvas/utils/Texts/textProperties.js.map +0 -1
  245. package/dist/esm/canvas/utils/types.d.ts.map +0 -1
  246. package/dist/esm/canvas/utils/types.js.map +0 -1
  247. package/dist/esm/canvas/utils/utils.d.ts.map +0 -1
  248. package/dist/esm/canvas/utils/utils.js.map +0 -1
  249. package/dist/esm/index.d.ts.map +0 -1
  250. package/dist/esm/index.js.map +0 -1
  251. package/dist/esm/tsconfig.esm.tsbuildinfo +0 -1
  252. package/dist/esm/utils.d.ts.map +0 -1
  253. package/dist/esm/utils.js.map +0 -1
  254. package/lib/ai/functions/typeWriter.ts +0 -24
  255. package/lib/canvas/Themes/Level-Up/levelup.ts +0 -183
@@ -1,18 +1,12 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ApexPainter = void 0;
7
- const canvas_1 = require("@napi-rs/canvas");
8
- const gifencoder_1 = __importDefault(require("gifencoder"));
9
- const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
10
- const stream_1 = require("stream");
11
- const axios_1 = __importDefault(require("axios"));
12
- const fs_1 = __importDefault(require("fs"));
13
- const path_1 = __importDefault(require("path"));
14
- const utils_1 = require("./utils/utils");
15
- class ApexPainter {
1
+ import { createCanvas, loadImage, GlobalFonts } from "@napi-rs/canvas";
2
+ import GIFEncoder from "gifencoder";
3
+ import ffmpeg from 'fluent-ffmpeg';
4
+ import { PassThrough } from "stream";
5
+ import axios from 'axios';
6
+ import fs from "fs";
7
+ import path from "path";
8
+ import { drawBackgroundGradient, drawBackgroundColor, customBackground, customLines, applyRotation, applyStroke, applyShadow, imageRadius, drawShape, drawText, converter, resizingImg, applyColorFilters, imgEffects, verticalBarChart, pieChart, lineChart, cropInner, cropOuter, bgRemoval, detectColors, removeColor, dataURL, base64, arrayBuffer, blob, url, backgroundRadius } from "./utils/utils.js";
9
+ export class ApexPainter {
16
10
  format;
17
11
  constructor({ type } = { type: 'buffer' }) {
18
12
  this.format = { type: type || 'buffer' };
@@ -27,30 +21,30 @@ class ApexPainter {
27
21
  */
28
22
  async createCanvas(canvas) {
29
23
  const { width = 500, height = 500, x = 0, y = 0, rotation = 0, borderRadius = 0, customBg, gradientBg, stroke, shadow, borderPosition = 'all', opacity = 1, zoom, blur } = canvas;
30
- const canvasInstance = (0, canvas_1.createCanvas)(width, height);
24
+ const canvasInstance = createCanvas(width, height);
31
25
  const ctx = canvasInstance.getContext('2d');
32
26
  if (!ctx) {
33
27
  throw new Error('Unable to get 2D rendering context from canvas');
34
28
  }
35
29
  ctx.globalAlpha = opacity;
36
- (0, utils_1.applyRotation)(ctx, rotation, x, y, width, height);
37
- (0, utils_1.applyShadow)(ctx, shadow, x, y, width, height);
30
+ applyRotation(ctx, rotation, x, y, width, height);
31
+ applyShadow(ctx, shadow, x, y, width, height);
38
32
  ctx.save();
39
33
  if (borderRadius) {
40
- (0, utils_1.backgroundRadius)(ctx, x, y, width, height, borderRadius, borderPosition);
34
+ backgroundRadius(ctx, x, y, width, height, borderRadius, borderPosition);
41
35
  }
42
36
  ctx.translate(x, y);
43
37
  if (customBg) {
44
- await (0, utils_1.customBackground)(ctx, canvas, zoom, blur);
38
+ await customBackground(ctx, canvas, zoom, blur);
45
39
  }
46
40
  else if (gradientBg) {
47
- await (0, utils_1.drawBackgroundGradient)(ctx, canvas, zoom, blur);
41
+ await drawBackgroundGradient(ctx, canvas, zoom, blur);
48
42
  }
49
43
  else {
50
- await (0, utils_1.drawBackgroundColor)(ctx, canvas, zoom, blur);
44
+ await drawBackgroundColor(ctx, canvas, zoom, blur);
51
45
  }
52
46
  ctx.restore();
53
- (0, utils_1.applyStroke)(ctx, stroke, x, y, width, height);
47
+ applyStroke(ctx, stroke, x, y, width, height);
54
48
  return { buffer: canvasInstance.toBuffer('image/png'), canvas };
55
49
  }
56
50
  /**
@@ -65,10 +59,10 @@ class ApexPainter {
65
59
  }
66
60
  let baseImage;
67
61
  if (Buffer.isBuffer(canvasBuffer)) {
68
- baseImage = await (0, canvas_1.loadImage)(canvasBuffer);
62
+ baseImage = await loadImage(canvasBuffer);
69
63
  }
70
64
  else if (canvasBuffer.buffer) {
71
- baseImage = await (0, canvas_1.loadImage)(canvasBuffer.buffer);
65
+ baseImage = await loadImage(canvasBuffer.buffer);
72
66
  }
73
67
  else {
74
68
  throw new Error('Invalid canvasBuffer provided; expected Buffer or CanvasResults with a buffer');
@@ -76,7 +70,7 @@ class ApexPainter {
76
70
  if (!baseImage) {
77
71
  throw new Error('Unable to load base image from the provided buffer');
78
72
  }
79
- const canvas = (0, canvas_1.createCanvas)(baseImage.width, baseImage.height);
73
+ const canvas = createCanvas(baseImage.width, baseImage.height);
80
74
  const ctx = canvas.getContext('2d');
81
75
  if (!ctx) {
82
76
  throw new Error('Unable to get 2D rendering context from canvas');
@@ -94,10 +88,10 @@ class ApexPainter {
94
88
  }
95
89
  let existingImage;
96
90
  if (Buffer.isBuffer(buffer)) {
97
- existingImage = await (0, canvas_1.loadImage)(buffer);
91
+ existingImage = await loadImage(buffer);
98
92
  }
99
93
  else if (buffer && buffer.buffer) {
100
- existingImage = await (0, canvas_1.loadImage)(buffer.buffer);
94
+ existingImage = await loadImage(buffer.buffer);
101
95
  }
102
96
  else {
103
97
  throw new Error('Invalid canvasBuffer provided. It should be a Buffer or CanvasResults object with a buffer');
@@ -105,15 +99,15 @@ class ApexPainter {
105
99
  if (!existingImage) {
106
100
  throw new Error('Unable to load image from buffer');
107
101
  }
108
- const canvas = (0, canvas_1.createCanvas)(existingImage.width, existingImage.height);
102
+ const canvas = createCanvas(existingImage.width, existingImage.height);
109
103
  const ctx = canvas.getContext("2d");
110
104
  ctx.drawImage(existingImage, 0, 0);
111
105
  for (const textOptions of textOptionsArray) {
112
106
  const mergedTextOptions = textOptions;
113
107
  if (mergedTextOptions.fontPath) {
114
- canvas_1.GlobalFonts.registerFromPath(path_1.default.join(process.cwd(), mergedTextOptions.fontPath), (mergedTextOptions.fontName || 'customFont'));
108
+ GlobalFonts.registerFromPath(path.join(process.cwd(), mergedTextOptions.fontPath), (mergedTextOptions.fontName || 'customFont'));
115
109
  }
116
- (0, utils_1.drawText)(ctx, mergedTextOptions);
110
+ drawText(ctx, mergedTextOptions);
117
111
  }
118
112
  return canvas.toBuffer("image/png");
119
113
  }
@@ -129,10 +123,10 @@ class ApexPainter {
129
123
  }
130
124
  let existingImage;
131
125
  if (Buffer.isBuffer(buffer)) {
132
- existingImage = await (0, canvas_1.loadImage)(buffer);
126
+ existingImage = await loadImage(buffer);
133
127
  }
134
128
  else if (buffer && buffer.buffer) {
135
- existingImage = await (0, canvas_1.loadImage)(buffer.buffer);
129
+ existingImage = await loadImage(buffer.buffer);
136
130
  }
137
131
  else {
138
132
  throw new Error('Invalid canvasBuffer provided. It should be a Buffer or CanvasResults object with a buffer');
@@ -140,10 +134,10 @@ class ApexPainter {
140
134
  if (!existingImage) {
141
135
  throw new Error('Unable to load image from buffer');
142
136
  }
143
- const canvas = (0, canvas_1.createCanvas)(existingImage.width, existingImage.height);
137
+ const canvas = createCanvas(existingImage.width, existingImage.height);
144
138
  const ctx = canvas.getContext("2d");
145
139
  ctx.drawImage(existingImage, 0, 0);
146
- (0, utils_1.customLines)(ctx, options);
140
+ customLines(ctx, options);
147
141
  return canvas.toBuffer("image/png");
148
142
  }
149
143
  catch (error) {
@@ -153,16 +147,16 @@ class ApexPainter {
153
147
  }
154
148
  async createGIF(gifFrames, options) {
155
149
  async function resizeImage(image, targetWidth, targetHeight) {
156
- const canvas = (0, canvas_1.createCanvas)(targetWidth, targetHeight);
150
+ const canvas = createCanvas(targetWidth, targetHeight);
157
151
  const ctx = canvas.getContext("2d");
158
152
  ctx.drawImage(image, 0, 0, targetWidth, targetHeight);
159
153
  return canvas;
160
154
  }
161
155
  function createOutputStream(outputFile) {
162
- return fs_1.default.createWriteStream(outputFile);
156
+ return fs.createWriteStream(outputFile);
163
157
  }
164
158
  function createBufferStream() {
165
- const bufferStream = new stream_1.PassThrough();
159
+ const bufferStream = new PassThrough();
166
160
  const chunks = [];
167
161
  bufferStream.on('data', (chunk) => {
168
162
  chunks.push(chunk);
@@ -204,21 +198,21 @@ class ApexPainter {
204
198
  validateOptions(options);
205
199
  const canvasWidth = options.width || 1200;
206
200
  const canvasHeight = options.height || 1200;
207
- const encoder = new gifencoder_1.default(canvasWidth, canvasHeight);
201
+ const encoder = new GIFEncoder(canvasWidth, canvasHeight);
208
202
  const outputStream = options.outputFile ? createOutputStream(options.outputFile) : createBufferStream();
209
203
  encoder.createReadStream().pipe(outputStream);
210
204
  encoder.start();
211
205
  encoder.setRepeat(options.repeat || 0);
212
206
  encoder.setQuality(options.quality || 10);
213
- const canvas = (0, canvas_1.createCanvas)(canvasWidth, canvasHeight);
207
+ const canvas = createCanvas(canvasWidth, canvasHeight);
214
208
  const ctx = canvas.getContext("2d");
215
209
  for (const frame of gifFrames) {
216
- const image = await (0, canvas_1.loadImage)(frame.background);
210
+ const image = await loadImage(frame.background);
217
211
  const resizedImage = await resizeImage(image, canvasWidth, canvasHeight);
218
212
  ctx.clearRect(0, 0, canvas.width, canvas.height);
219
213
  ctx.drawImage(resizedImage, 0, 0);
220
214
  if (options.watermark?.enable) {
221
- const watermark = await (0, canvas_1.loadImage)(options.watermark.url);
215
+ const watermark = await loadImage(options.watermark.url);
222
216
  ctx.drawImage(watermark, 10, canvasHeight - watermark.height - 10);
223
217
  }
224
218
  if (options.textOverlay) {
@@ -258,35 +252,35 @@ class ApexPainter {
258
252
  }
259
253
  }
260
254
  async resize(resizeOptions) {
261
- return (0, utils_1.resizingImg)(resizeOptions);
255
+ return resizingImg(resizeOptions);
262
256
  }
263
257
  async imgConverter(source, newExtension) {
264
- return (0, utils_1.converter)(source, newExtension);
258
+ return converter(source, newExtension);
265
259
  }
266
260
  async effects(source, filters) {
267
- return (0, utils_1.imgEffects)(source, filters);
261
+ return imgEffects(source, filters);
268
262
  }
269
263
  async colorsFilter(source, filterColor, opacity) {
270
- return (0, utils_1.applyColorFilters)(source, filterColor, opacity);
264
+ return applyColorFilters(source, filterColor, opacity);
271
265
  }
272
266
  async colorAnalysis(source) {
273
- return (0, utils_1.detectColors)(source);
267
+ return detectColors(source);
274
268
  }
275
269
  async colorsRemover(source, colorToRemove) {
276
- return (0, utils_1.removeColor)(source, colorToRemove);
270
+ return removeColor(source, colorToRemove);
277
271
  }
278
272
  async removeBackground(imageURL, apiKey) {
279
- return (0, utils_1.bgRemoval)(imageURL, apiKey);
273
+ return bgRemoval(imageURL, apiKey);
280
274
  }
281
275
  async blend(layers, baseImageBuffer, defaultBlendMode = 'source-over') {
282
276
  try {
283
- const baseImage = await (0, canvas_1.loadImage)(baseImageBuffer);
284
- const canvas = (0, canvas_1.createCanvas)(baseImage.width, baseImage.height);
277
+ const baseImage = await loadImage(baseImageBuffer);
278
+ const canvas = createCanvas(baseImage.width, baseImage.height);
285
279
  const ctx = canvas.getContext('2d');
286
280
  ctx.globalCompositeOperation = defaultBlendMode;
287
281
  ctx.drawImage(baseImage, 0, 0);
288
282
  for (const layer of layers) {
289
- const layerImage = await (0, canvas_1.loadImage)(layer.image);
283
+ const layerImage = await loadImage(layer.image);
290
284
  ctx.globalAlpha = layer.opacity !== undefined ? layer.opacity : 1.0;
291
285
  ctx.globalCompositeOperation = layer.blendMode;
292
286
  ctx.drawImage(layerImage, layer.position?.x || 0, layer.position?.y || 0);
@@ -312,7 +306,7 @@ class ApexPainter {
312
306
  case 'bar':
313
307
  switch (chartNumber) {
314
308
  case 1:
315
- return await (0, utils_1.verticalBarChart)(data);
309
+ return await verticalBarChart(data);
316
310
  case 2:
317
311
  throw new Error('Type 2 is still under development.');
318
312
  default:
@@ -321,7 +315,7 @@ class ApexPainter {
321
315
  case 'line':
322
316
  switch (chartNumber) {
323
317
  case 1:
324
- return await (0, utils_1.lineChart)(data);
318
+ return await lineChart(data);
325
319
  case 2:
326
320
  throw new Error('Type 2 is still under development.');
327
321
  default:
@@ -330,7 +324,7 @@ class ApexPainter {
330
324
  case 'pie':
331
325
  switch (chartNumber) {
332
326
  case 1:
333
- return await (0, utils_1.pieChart)(data);
327
+ return await pieChart(data);
334
328
  case 2:
335
329
  throw new Error('Type 2 is still under development.');
336
330
  default:
@@ -347,10 +341,10 @@ class ApexPainter {
347
341
  if (!options.coordinates || options.coordinates.length < 3)
348
342
  throw new Error('The "coordinates" option is needed. Please provide coordinates to crop the image.');
349
343
  if (options.crop === 'outer') {
350
- return await (0, utils_1.cropOuter)(options);
344
+ return await cropOuter(options);
351
345
  }
352
346
  else if (options.crop === 'inner') {
353
- return await (0, utils_1.cropInner)(options);
347
+ return await cropInner(options);
354
348
  }
355
349
  else {
356
350
  throw new Error('Invalid crop option. Please specify "inner" or "outer".');
@@ -371,17 +365,17 @@ class ApexPainter {
371
365
  const shapeNames = ['circle', 'square', 'triangle', 'pentagon', 'hexagon', 'heptagon', 'octagon', 'star', 'kite', 'arrow', 'star', 'oval', 'heart', 'diamond', 'trapezoid', 'cloud'];
372
366
  const isShape = shapeNames.includes(source.toLowerCase());
373
367
  if (isShape) {
374
- (0, utils_1.drawShape)(ctx, { source, x, y, width, height, opacity, rotation, borderRadius, stroke, shadow, isFilled, color, gradient, borderPosition, filling });
368
+ drawShape(ctx, { source, x, y, width, height, opacity, rotation, borderRadius, stroke, shadow, isFilled, color, gradient, borderPosition, filling });
375
369
  return;
376
370
  }
377
371
  let loadedImage;
378
372
  try {
379
373
  if (source.startsWith('http')) {
380
- loadedImage = await (0, canvas_1.loadImage)(source);
374
+ loadedImage = await loadImage(source);
381
375
  }
382
376
  else {
383
- const imagePath = path_1.default.resolve(process.cwd(), source);
384
- loadedImage = await (0, canvas_1.loadImage)(imagePath);
377
+ const imagePath = path.resolve(process.cwd(), source);
378
+ loadedImage = await loadImage(imagePath);
385
379
  }
386
380
  }
387
381
  catch (e) {
@@ -404,49 +398,49 @@ class ApexPainter {
404
398
  if (blur > 0) {
405
399
  ctx.filter = `blur(${blur}px)`;
406
400
  }
407
- (0, utils_1.applyRotation)(ctx, rotation, x, y, width, height);
408
- (0, utils_1.applyShadow)(ctx, shadow, x, y, width, height);
401
+ applyRotation(ctx, rotation, x, y, width, height);
402
+ applyShadow(ctx, shadow, x, y, width, height);
409
403
  if (perspective) {
410
404
  throw new Error('Under construction');
411
405
  }
412
- (0, utils_1.imageRadius)(ctx, loadedImage, x, y, width, height, borderRadius, borderPosition);
406
+ imageRadius(ctx, loadedImage, x, y, width, height, borderRadius, borderPosition);
413
407
  ctx.globalAlpha = 1.0;
414
408
  if (stroke?.opacity)
415
409
  ctx.globalAlpha = stroke.opacity;
416
- (0, utils_1.applyStroke)(ctx, stroke, x, y, width, height, undefined);
410
+ applyStroke(ctx, stroke, x, y, width, height, undefined);
417
411
  ctx.globalAlpha = 1.0;
418
412
  ctx.restore();
419
413
  }
420
414
  async extractFrames(videoSource, options) {
421
415
  const frames = [];
422
- const frameDir = path_1.default.join(__dirname, 'frames');
423
- if (!fs_1.default.existsSync(frameDir)) {
424
- fs_1.default.mkdirSync(frameDir);
416
+ const frameDir = path.join(__dirname, 'frames');
417
+ if (!fs.existsSync(frameDir)) {
418
+ fs.mkdirSync(frameDir);
425
419
  }
426
- const videoPath = typeof videoSource === 'string' ? videoSource : path_1.default.join(frameDir, 'temp-video.mp4');
420
+ const videoPath = typeof videoSource === 'string' ? videoSource : path.join(frameDir, 'temp-video.mp4');
427
421
  if (Buffer.isBuffer(videoSource)) {
428
- fs_1.default.writeFileSync(videoPath, videoSource);
422
+ fs.writeFileSync(videoPath, videoSource);
429
423
  }
430
424
  else if (videoSource.startsWith('http')) {
431
- await (0, axios_1.default)({
425
+ await axios({
432
426
  method: 'get',
433
427
  url: videoSource,
434
428
  responseType: 'arraybuffer'
435
429
  })
436
430
  .then((response) => {
437
- fs_1.default.writeFileSync(videoPath, response.data);
431
+ fs.writeFileSync(videoPath, response.data);
438
432
  })
439
433
  .catch(err => {
440
434
  throw new Error(`Error downloading video: ${err.message}`);
441
435
  });
442
436
  }
443
- else if (!fs_1.default.existsSync(videoPath)) {
437
+ else if (!fs.existsSync(videoPath)) {
444
438
  throw new Error("Video file not found at specified path.");
445
439
  }
446
440
  function processVideoExtraction(videoPath, frames, options, resolve, reject) {
447
441
  const outputFormat = options.outputFormat || 'jpg';
448
442
  const outputFileTemplate = `frame-%03d.${outputFormat}`;
449
- (0, fluent_ffmpeg_1.default)(videoPath)
443
+ ffmpeg(videoPath)
450
444
  .on('end', () => {
451
445
  console.log('Frames extracted successfully.');
452
446
  resolve(frames);
@@ -456,8 +450,8 @@ class ApexPainter {
456
450
  reject(err);
457
451
  })
458
452
  .outputOptions([`-vf fps=1/${options.interval / 1000}`, `-q:v 2`])
459
- .saveToFile(path_1.default.join(frameDir, outputFileTemplate));
460
- fluent_ffmpeg_1.default.ffprobe(videoPath, (err, metadata) => {
453
+ .saveToFile(path.join(frameDir, outputFileTemplate));
454
+ ffmpeg.ffprobe(videoPath, (err, metadata) => {
461
455
  if (err) {
462
456
  return reject(err);
463
457
  }
@@ -471,7 +465,7 @@ class ApexPainter {
471
465
  continue;
472
466
  }
473
467
  frames.push({
474
- source: path_1.default.join(frameDir, `frame-${String(i).padStart(3, '0')}.${outputFormat}`),
468
+ source: path.join(frameDir, `frame-${String(i).padStart(3, '0')}.${outputFormat}`),
475
469
  isRemote: false
476
470
  });
477
471
  }
@@ -488,8 +482,8 @@ class ApexPainter {
488
482
  * @returns {Promise<Buffer>} - The adjusted image buffer.
489
483
  */
490
484
  async patterns(buffer, options) {
491
- const img = await (0, canvas_1.loadImage)(buffer);
492
- const canvas = (0, canvas_1.createCanvas)(img.width, img.height);
485
+ const img = await loadImage(buffer);
486
+ const canvas = createCanvas(img.width, img.height);
493
487
  const ctx = canvas.getContext('2d');
494
488
  ctx.drawImage(img, 0, 0);
495
489
  const x = options.x || 0;
@@ -555,7 +549,7 @@ class ApexPainter {
555
549
  else {
556
550
  grad = ctx.createRadialGradient((gradient.startX || width / 2) + x, (gradient.startY || height / 2) + y, gradient.startRadius || 0, (gradient.endX || width / 2) + x, (gradient.endY || height / 2) + y, gradient.endRadius || Math.max(width, height));
557
551
  }
558
- gradient.colors.forEach(stop => {
552
+ gradient.colors.forEach((stop) => {
559
553
  grad.addColorStop(stop.stop, stop.color);
560
554
  });
561
555
  ctx.fillStyle = grad;
@@ -667,7 +661,7 @@ class ApexPainter {
667
661
  if (!options.customPatternImage) {
668
662
  throw new Error('Custom pattern image path is required for custom patterns.');
669
663
  }
670
- const patternImage = await (0, canvas_1.loadImage)(options.customPatternImage);
664
+ const patternImage = await loadImage(options.customPatternImage);
671
665
  const pattern = ctx.createPattern(patternImage, 'repeat');
672
666
  ctx.fillStyle = pattern;
673
667
  ctx.translate(x, y);
@@ -718,12 +712,12 @@ class ApexPainter {
718
712
  ctx.restore();
719
713
  }
720
714
  async masking(source, maskSource, options = { type: "alpha" }) {
721
- const img = await (0, canvas_1.loadImage)(source);
722
- const mask = await (0, canvas_1.loadImage)(maskSource);
723
- const canvas = (0, canvas_1.createCanvas)(img.width, img.height);
715
+ const img = await loadImage(source);
716
+ const mask = await loadImage(maskSource);
717
+ const canvas = createCanvas(img.width, img.height);
724
718
  const ctx = canvas.getContext("2d");
725
719
  ctx.drawImage(img, 0, 0, img.width, img.height);
726
- const maskCanvas = (0, canvas_1.createCanvas)(img.width, img.height);
720
+ const maskCanvas = createCanvas(img.width, img.height);
727
721
  const maskCtx = maskCanvas.getContext("2d");
728
722
  maskCtx.drawImage(mask, 0, 0, img.width, img.height);
729
723
  const maskData = maskCtx.getImageData(0, 0, img.width, img.height);
@@ -751,8 +745,8 @@ class ApexPainter {
751
745
  return canvas.toBuffer("image/png");
752
746
  }
753
747
  async gradientBlend(source, options) {
754
- const img = await (0, canvas_1.loadImage)(source);
755
- const canvas = (0, canvas_1.createCanvas)(img.width, img.height);
748
+ const img = await loadImage(source);
749
+ const canvas = createCanvas(img.width, img.height);
756
750
  const ctx = canvas.getContext("2d");
757
751
  ctx.drawImage(img, 0, 0, img.width, img.height);
758
752
  let gradient;
@@ -776,7 +770,7 @@ class ApexPainter {
776
770
  ctx.globalCompositeOperation = options.blendMode ?? "multiply";
777
771
  ctx.fillRect(0, 0, img.width, img.height);
778
772
  if (options.maskSource) {
779
- const mask = await (0, canvas_1.loadImage)(options.maskSource);
773
+ const mask = await loadImage(options.maskSource);
780
774
  ctx.globalCompositeOperation = "destination-in";
781
775
  ctx.drawImage(mask, 0, 0, img.width, img.height);
782
776
  }
@@ -794,8 +788,8 @@ class ApexPainter {
794
788
  if (!options.gifPath) {
795
789
  throw new Error("GIF generation enabled but no gifPath provided.");
796
790
  }
797
- encoder = new gifencoder_1.default(defaultWidth, defaultHeight);
798
- gifStream = fs_1.default.createWriteStream(options.gifPath);
791
+ encoder = new GIFEncoder(defaultWidth, defaultHeight);
792
+ gifStream = fs.createWriteStream(options.gifPath);
799
793
  encoder.createReadStream().pipe(gifStream);
800
794
  encoder.start();
801
795
  encoder.setRepeat(0);
@@ -805,7 +799,7 @@ class ApexPainter {
805
799
  const frame = frames[i];
806
800
  const width = frame.width || defaultWidth;
807
801
  const height = frame.height || defaultHeight;
808
- const canvas = (0, canvas_1.createCanvas)(width, height);
802
+ const canvas = createCanvas(width, height);
809
803
  const ctx = canvas.getContext('2d');
810
804
  if (!isNode) {
811
805
  canvas.width = width;
@@ -830,14 +824,14 @@ class ApexPainter {
830
824
  else if (type === 'radial') {
831
825
  gradient = ctx.createRadialGradient(startX || width / 2, startY || height / 2, startRadius || 0, endX || width / 2, endY || height / 2, endRadius || Math.max(width, height));
832
826
  }
833
- colors.forEach(colorStop => {
827
+ colors.forEach((colorStop) => {
834
828
  if (gradient)
835
829
  gradient.addColorStop(colorStop.stop, colorStop.color);
836
830
  });
837
831
  fillStyle = gradient;
838
832
  }
839
833
  if (frame.pattern) {
840
- const patternImage = await (0, canvas_1.loadImage)(frame.pattern.source);
834
+ const patternImage = await loadImage(frame.pattern.source);
841
835
  const pattern = ctx.createPattern(patternImage, frame.pattern.repeat || 'repeat');
842
836
  fillStyle = pattern;
843
837
  }
@@ -849,7 +843,7 @@ class ApexPainter {
849
843
  ctx.fillRect(0, 0, width, height);
850
844
  }
851
845
  if (frame.source) {
852
- const image = await (0, canvas_1.loadImage)(frame.source);
846
+ const image = await loadImage(frame.source);
853
847
  ctx.globalCompositeOperation = frame.blendMode || 'source-over';
854
848
  ctx.drawImage(image, 0, 0, width, height);
855
849
  }
@@ -890,19 +884,17 @@ class ApexPainter {
890
884
  case 'buffer':
891
885
  return results;
892
886
  case 'url':
893
- return await (0, utils_1.url)(results);
887
+ return await url(results);
894
888
  case 'dataURL':
895
- return (0, utils_1.dataURL)(results);
889
+ return dataURL(results);
896
890
  case 'blob':
897
- return (0, utils_1.blob)(results);
891
+ return blob(results);
898
892
  case 'base64':
899
- return (0, utils_1.base64)(results);
893
+ return base64(results);
900
894
  case 'arraybuffer':
901
- return (0, utils_1.arrayBuffer)(results);
895
+ return arrayBuffer(results);
902
896
  default:
903
897
  throw new Error('Unsupported format');
904
898
  }
905
899
  }
906
900
  }
907
- exports.ApexPainter = ApexPainter;
908
- //# sourceMappingURL=ApexPainter.js.map
@@ -1,5 +1,5 @@
1
1
  import { SKRSContext2D } from "@napi-rs/canvas";
2
- import { CanvasConfig } from "../types";
2
+ import { CanvasConfig } from "../types.js";
3
3
  interface ZoomConfig {
4
4
  scale?: number;
5
5
  x?: number;
@@ -28,4 +28,3 @@ export declare function drawBackgroundColor(ctx: SKRSContext2D, canvas: CanvasCo
28
28
  export declare function customBackground(ctx: SKRSContext2D, canvas: CanvasConfig, zoom?: ZoomConfig, blur?: number): Promise<void>;
29
29
  export declare function backgroundRadius(ctx: SKRSContext2D, x: number, y: number, width: number, height: number, borderRadius: number | "circular", borderPosition?: string): void;
30
30
  export {};
31
- //# sourceMappingURL=bg.d.ts.map
@@ -1,21 +1,12 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.drawBackgroundGradient = drawBackgroundGradient;
7
- exports.drawBackgroundColor = drawBackgroundColor;
8
- exports.customBackground = customBackground;
9
- exports.backgroundRadius = backgroundRadius;
10
- const canvas_1 = require("@napi-rs/canvas");
11
- const path_1 = __importDefault(require("path"));
1
+ import { loadImage } from "@napi-rs/canvas";
2
+ import path from "path";
12
3
  /**
13
4
  * Draws a gradient background on the canvas with optional zoom support.
14
5
  * @param ctx The canvas rendering context.
15
6
  * @param canvas The canvas configuration object.
16
7
  * @param zoom Optional zoom configuration.
17
8
  */
18
- async function drawBackgroundGradient(ctx, canvas, zoom, blur) {
9
+ export async function drawBackgroundGradient(ctx, canvas, zoom, blur) {
19
10
  if (canvas.gradientBg) {
20
11
  const { type, startX = 0, startY = 0, endX = canvas.width || 500, endY = canvas.height || 500, startRadius = 0, endRadius = 0, colors } = canvas.gradientBg;
21
12
  if (!colors || colors.length === 0) {
@@ -56,7 +47,7 @@ async function drawBackgroundGradient(ctx, canvas, zoom, blur) {
56
47
  * @param canvas The canvas configuration object.
57
48
  * @param zoom Optional zoom configuration.
58
49
  */
59
- async function drawBackgroundColor(ctx, canvas, zoom, blur) {
50
+ export async function drawBackgroundColor(ctx, canvas, zoom, blur) {
60
51
  const canvasWidth = canvas.width || 500;
61
52
  const canvasHeight = canvas.height || 500;
62
53
  ctx.save();
@@ -83,7 +74,7 @@ async function drawBackgroundColor(ctx, canvas, zoom, blur) {
83
74
  * @param canvas The canvas configuration object.
84
75
  * @param zoom Optional zoom configuration.
85
76
  */
86
- async function customBackground(ctx, canvas, zoom, blur) {
77
+ export async function customBackground(ctx, canvas, zoom, blur) {
87
78
  if (canvas.customBg) {
88
79
  try {
89
80
  let imageBuffer;
@@ -91,9 +82,9 @@ async function customBackground(ctx, canvas, zoom, blur) {
91
82
  imageBuffer = canvas.customBg;
92
83
  }
93
84
  else {
94
- imageBuffer = path_1.default.join(process.cwd(), canvas.customBg);
85
+ imageBuffer = path.join(process.cwd(), canvas.customBg);
95
86
  }
96
- const image = await (0, canvas_1.loadImage)(imageBuffer);
87
+ const image = await loadImage(imageBuffer);
97
88
  const imgWidth = image.width;
98
89
  const imgHeight = image.height;
99
90
  const canvasWidth = canvas.width || imgWidth;
@@ -121,7 +112,7 @@ async function customBackground(ctx, canvas, zoom, blur) {
121
112
  }
122
113
  }
123
114
  }
124
- function backgroundRadius(ctx, x, y, width, height, borderRadius, borderPosition = "all") {
115
+ export function backgroundRadius(ctx, x, y, width, height, borderRadius, borderPosition = "all") {
125
116
  ctx.beginPath();
126
117
  if (borderRadius === "circular") {
127
118
  const circleRadius = Math.min(width, height) / 2;
@@ -158,4 +149,3 @@ function backgroundRadius(ctx, x, y, width, height, borderRadius, borderPosition
158
149
  ctx.closePath();
159
150
  ctx.clip();
160
151
  }
161
- //# sourceMappingURL=bg.js.map
@@ -1,8 +1,7 @@
1
- import { barChart_1, PieChartData, LineChartConfig, DataPoint } from "../types";
1
+ import { barChart_1, PieChartData, LineChartConfig, DataPoint } from "../types.js";
2
2
  export declare function verticalBarChart(data: barChart_1): Promise<Buffer<ArrayBufferLike> | undefined>;
3
3
  export declare function pieChart(pieChartData: PieChartData): Promise<Buffer>;
4
4
  export declare function lineChart(data: {
5
5
  data: DataPoint[][];
6
6
  lineConfig: LineChartConfig;
7
7
  }): Promise<Buffer>;
8
- //# sourceMappingURL=charts.d.ts.map