apexify.js 4.8.2 → 4.8.3

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 (128) hide show
  1. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  2. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  3. package/lib/ai/ApexAI.ts +4 -4
  4. package/lib/ai/ApexModules.ts +8 -8
  5. package/lib/ai/modals/electronHub/chatmodels.ts +1 -1
  6. package/lib/ai/modals/electronHub/imageModels.ts +2 -2
  7. package/lib/ai/modals/electronHub/speechModels.ts +1 -1
  8. package/lib/ai/utils.ts +3 -3
  9. package/lib/canvas/ApexPainter.ts +1 -1
  10. package/lib/canvas/utils/Background/bg.ts +1 -1
  11. package/lib/canvas/utils/Charts/charts.ts +1 -1
  12. package/lib/canvas/utils/Custom/customLines.ts +2 -2
  13. package/lib/canvas/utils/General/general functions.ts +1 -1
  14. package/lib/canvas/utils/Image/imageProperties.ts +1 -1
  15. package/lib/canvas/utils/Texts/textProperties.ts +1 -1
  16. package/lib/canvas/utils/utils.ts +8 -8
  17. package/lib/index.ts +5 -5
  18. package/lib/utils.ts +3 -3
  19. package/package.json +5 -5
  20. package/dist/cjs/ai/ApexAI.d.ts +0 -144
  21. package/dist/cjs/ai/ApexAI.js +0 -486
  22. package/dist/cjs/ai/ApexModules.d.ts +0 -52
  23. package/dist/cjs/ai/ApexModules.js +0 -811
  24. package/dist/cjs/ai/functions/readFiles.d.ts +0 -1
  25. package/dist/cjs/ai/functions/readFiles.js +0 -56
  26. package/dist/cjs/ai/functions/tokenizer.d.ts +0 -9
  27. package/dist/cjs/ai/functions/tokenizer.js +0 -60
  28. package/dist/cjs/ai/functions/validOptions.d.ts +0 -21
  29. package/dist/cjs/ai/functions/validOptions.js +0 -93
  30. package/dist/cjs/ai/modals/electronHub/chatmodels.d.ts +0 -6
  31. package/dist/cjs/ai/modals/electronHub/chatmodels.js +0 -44
  32. package/dist/cjs/ai/modals/electronHub/imageModels.d.ts +0 -11
  33. package/dist/cjs/ai/modals/electronHub/imageModels.js +0 -85
  34. package/dist/cjs/ai/modals/electronHub/songModels.d.ts +0 -1
  35. package/dist/cjs/ai/modals/electronHub/songModels.js +0 -1
  36. package/dist/cjs/ai/modals/electronHub/speechModels.d.ts +0 -6
  37. package/dist/cjs/ai/modals/electronHub/speechModels.js +0 -56
  38. package/dist/cjs/ai/modals/electronHub/videoModels.d.ts +0 -5
  39. package/dist/cjs/ai/modals/electronHub/videoModels.js +0 -56
  40. package/dist/cjs/ai/modals/groq/chatgroq.d.ts +0 -8
  41. package/dist/cjs/ai/modals/groq/chatgroq.js +0 -57
  42. package/dist/cjs/ai/modals/groq/imageAnalyzer.d.ts +0 -7
  43. package/dist/cjs/ai/modals/groq/imageAnalyzer.js +0 -75
  44. package/dist/cjs/ai/modals/groq/whisper.d.ts +0 -4
  45. package/dist/cjs/ai/modals/groq/whisper.js +0 -101
  46. package/dist/cjs/ai/modals/hercai/chatModels.d.ts +0 -6
  47. package/dist/cjs/ai/modals/hercai/chatModels.js +0 -19
  48. package/dist/cjs/ai/utils.d.ts +0 -4
  49. package/dist/cjs/ai/utils.js +0 -4
  50. package/dist/cjs/canvas/ApexPainter.d.ts +0 -144
  51. package/dist/cjs/canvas/ApexPainter.js +0 -900
  52. package/dist/cjs/canvas/utils/Background/bg.d.ts +0 -30
  53. package/dist/cjs/canvas/utils/Background/bg.js +0 -151
  54. package/dist/cjs/canvas/utils/Charts/charts.d.ts +0 -7
  55. package/dist/cjs/canvas/utils/Charts/charts.js +0 -455
  56. package/dist/cjs/canvas/utils/Custom/customLines.d.ts +0 -2
  57. package/dist/cjs/canvas/utils/Custom/customLines.js +0 -105
  58. package/dist/cjs/canvas/utils/General/conversion.d.ts +0 -5
  59. package/dist/cjs/canvas/utils/General/conversion.js +0 -26
  60. package/dist/cjs/canvas/utils/General/general functions.d.ts +0 -38
  61. package/dist/cjs/canvas/utils/General/general functions.js +0 -590
  62. package/dist/cjs/canvas/utils/Image/imageProperties.d.ts +0 -114
  63. package/dist/cjs/canvas/utils/Image/imageProperties.js +0 -590
  64. package/dist/cjs/canvas/utils/Texts/textProperties.d.ts +0 -16
  65. package/dist/cjs/canvas/utils/Texts/textProperties.js +0 -154
  66. package/dist/cjs/canvas/utils/types.d.ts +0 -621
  67. package/dist/cjs/canvas/utils/types.js +0 -5
  68. package/dist/cjs/canvas/utils/utils.d.ts +0 -18
  69. package/dist/cjs/canvas/utils/utils.js +0 -17
  70. package/dist/cjs/index.d.ts +0 -28
  71. package/dist/cjs/index.js +0 -67
  72. package/dist/cjs/utils.d.ts +0 -4
  73. package/dist/cjs/utils.js +0 -4
  74. package/dist/esm/ai/ApexAI.d.ts +0 -144
  75. package/dist/esm/ai/ApexAI.js +0 -486
  76. package/dist/esm/ai/ApexModules.d.ts +0 -52
  77. package/dist/esm/ai/ApexModules.js +0 -811
  78. package/dist/esm/ai/functions/readFiles.d.ts +0 -1
  79. package/dist/esm/ai/functions/readFiles.js +0 -56
  80. package/dist/esm/ai/functions/tokenizer.d.ts +0 -9
  81. package/dist/esm/ai/functions/tokenizer.js +0 -60
  82. package/dist/esm/ai/functions/validOptions.d.ts +0 -21
  83. package/dist/esm/ai/functions/validOptions.js +0 -93
  84. package/dist/esm/ai/modals/electronHub/chatmodels.d.ts +0 -6
  85. package/dist/esm/ai/modals/electronHub/chatmodels.js +0 -44
  86. package/dist/esm/ai/modals/electronHub/imageModels.d.ts +0 -11
  87. package/dist/esm/ai/modals/electronHub/imageModels.js +0 -85
  88. package/dist/esm/ai/modals/electronHub/songModels.d.ts +0 -1
  89. package/dist/esm/ai/modals/electronHub/songModels.js +0 -1
  90. package/dist/esm/ai/modals/electronHub/speechModels.d.ts +0 -6
  91. package/dist/esm/ai/modals/electronHub/speechModels.js +0 -56
  92. package/dist/esm/ai/modals/electronHub/videoModels.d.ts +0 -5
  93. package/dist/esm/ai/modals/electronHub/videoModels.js +0 -56
  94. package/dist/esm/ai/modals/groq/chatgroq.d.ts +0 -8
  95. package/dist/esm/ai/modals/groq/chatgroq.js +0 -57
  96. package/dist/esm/ai/modals/groq/imageAnalyzer.d.ts +0 -7
  97. package/dist/esm/ai/modals/groq/imageAnalyzer.js +0 -75
  98. package/dist/esm/ai/modals/groq/whisper.d.ts +0 -4
  99. package/dist/esm/ai/modals/groq/whisper.js +0 -101
  100. package/dist/esm/ai/modals/hercai/chatModels.d.ts +0 -6
  101. package/dist/esm/ai/modals/hercai/chatModels.js +0 -19
  102. package/dist/esm/ai/utils.d.ts +0 -4
  103. package/dist/esm/ai/utils.js +0 -4
  104. package/dist/esm/canvas/ApexPainter.d.ts +0 -144
  105. package/dist/esm/canvas/ApexPainter.js +0 -900
  106. package/dist/esm/canvas/utils/Background/bg.d.ts +0 -30
  107. package/dist/esm/canvas/utils/Background/bg.js +0 -151
  108. package/dist/esm/canvas/utils/Charts/charts.d.ts +0 -7
  109. package/dist/esm/canvas/utils/Charts/charts.js +0 -455
  110. package/dist/esm/canvas/utils/Custom/customLines.d.ts +0 -2
  111. package/dist/esm/canvas/utils/Custom/customLines.js +0 -105
  112. package/dist/esm/canvas/utils/General/conversion.d.ts +0 -5
  113. package/dist/esm/canvas/utils/General/conversion.js +0 -26
  114. package/dist/esm/canvas/utils/General/general functions.d.ts +0 -38
  115. package/dist/esm/canvas/utils/General/general functions.js +0 -590
  116. package/dist/esm/canvas/utils/Image/imageProperties.d.ts +0 -114
  117. package/dist/esm/canvas/utils/Image/imageProperties.js +0 -590
  118. package/dist/esm/canvas/utils/Texts/textProperties.d.ts +0 -16
  119. package/dist/esm/canvas/utils/Texts/textProperties.js +0 -154
  120. package/dist/esm/canvas/utils/types.d.ts +0 -621
  121. package/dist/esm/canvas/utils/types.js +0 -5
  122. package/dist/esm/canvas/utils/utils.d.ts +0 -18
  123. package/dist/esm/canvas/utils/utils.js +0 -17
  124. package/dist/esm/index.d.ts +0 -28
  125. package/dist/esm/index.js +0 -67
  126. package/dist/esm/utils.d.ts +0 -4
  127. package/dist/esm/utils.js +0 -4
  128. package/lib/ai/modals/electronHub/songModels.ts +0 -0
@@ -1,154 +0,0 @@
1
- /**
2
- * The main function that draws text with optional wrapping.
3
- * @param ctx CanvasRenderingContext2D
4
- * @param textOptions TextObject
5
- */
6
- export function drawText(ctx, textOptions) {
7
- ctx.save();
8
- // 1) Apply rotation if any
9
- if (textOptions.rotation && textOptions.rotation !== 0) {
10
- ctx.translate(textOptions.x || 0, textOptions.y || 0);
11
- ctx.rotate((textOptions.rotation * Math.PI) / 180);
12
- }
13
- // 2) Setup font (for measuring and for final draw)
14
- const fontSize = textOptions.fontSize || 16;
15
- const isBold = textOptions.isBold ? 'bold ' : '';
16
- const fontFamily = textOptions.fontName || (textOptions.fontPath ? 'customFont' : 'Arial');
17
- ctx.font = `${isBold}${fontSize}px "${fontFamily}"`;
18
- // 3) Alignment, baseline
19
- ctx.textAlign = textOptions.textAlign || 'left';
20
- ctx.textBaseline = textOptions.textBaseline || 'alphabetic';
21
- // 4) Shadow
22
- if (textOptions.shadow) {
23
- const { color, offsetX, offsetY, blur, opacity } = textOptions.shadow;
24
- ctx.shadowColor = color || 'transparent';
25
- ctx.shadowOffsetX = offsetX || 0;
26
- ctx.shadowOffsetY = offsetY || 0;
27
- ctx.shadowBlur = blur || 0;
28
- ctx.globalAlpha = opacity !== undefined ? opacity : 1;
29
- }
30
- // 5) Opacity
31
- if (textOptions.opacity !== undefined) {
32
- if (textOptions.opacity < 0 || textOptions.opacity > 1) {
33
- throw new Error('Text opacity must be between 0 and 1.');
34
- }
35
- ctx.globalAlpha = textOptions.opacity;
36
- }
37
- // 6) If maxWidth is provided, we do word wrapping
38
- if (textOptions.maxWidth) {
39
- WrappedText(ctx, textOptions.text, textOptions.x || 0, textOptions.y || 0, textOptions.maxWidth, textOptions);
40
- }
41
- else {
42
- // No wrapping needed → just draw stroke + fill
43
- drawStrokeAndFill(ctx, textOptions.text, textOptions.x || 0, textOptions.y || 0, textOptions);
44
- }
45
- ctx.restore();
46
- }
47
- /**
48
- * Handles word-based wrapping. Then draws each line with stroke, fill, gradient, etc.
49
- */
50
- export function WrappedText(ctx, text, startX, startY, maxWidth, options) {
51
- const fontSize = options.fontSize || 16;
52
- const lineHeight = options.lineHeight || fontSize * 1.4;
53
- const maxHeight = options.maxHeight;
54
- const maxLines = maxHeight ? Math.floor(maxHeight / lineHeight) : Infinity;
55
- let currentLine = "";
56
- const words = text.split(" ");
57
- const lines = [];
58
- for (let i = 0; i < words.length; i++) {
59
- const testLine = currentLine ? currentLine + " " + words[i] : words[i];
60
- const testWidth = ctx.measureText(testLine).width;
61
- if (testWidth > maxWidth && currentLine) {
62
- lines.push(currentLine);
63
- currentLine = words[i];
64
- if (lines.length >= maxLines) {
65
- currentLine = "...";
66
- break;
67
- }
68
- }
69
- else {
70
- currentLine = testLine;
71
- }
72
- }
73
- if (currentLine && lines.length < maxLines) {
74
- lines.push(currentLine);
75
- }
76
- // 🔥 Ensure correct text alignment for Arabic & English
77
- ctx.textAlign = options.textAlign || "left";
78
- // 🎯 Draw each line with stroke & fill together
79
- let offsetY = 0;
80
- for (const line of lines) {
81
- drawStrokeAndFill(ctx, line, startX, startY + offsetY, options);
82
- offsetY += lineHeight;
83
- }
84
- }
85
- /**
86
- * Draws a single line with correct alignment. Then uses `drawStrokeAndFill` to apply stroke, fill, etc.
87
- */
88
- function drawLine(ctx, lineText, startX, startY, maxWidth, options) {
89
- let xOffset = startX;
90
- // If user wants 'center' or 'right', we offset by measured width
91
- const measuredWidth = ctx.measureText(lineText).width;
92
- if (options.textAlign === 'center') {
93
- xOffset = startX + (maxWidth / 2) - (measuredWidth / 2);
94
- }
95
- else if (options.textAlign === 'right') {
96
- xOffset = startX + maxWidth - measuredWidth;
97
- }
98
- // Finally, draw stroke+fill for this line
99
- drawStrokeAndFill(ctx, lineText, xOffset, startY, options);
100
- }
101
- /**
102
- * Actually draws stroke (if any) and fill for the given text & position.
103
- */
104
- function drawStrokeAndFill(ctx, text, x, y, options) {
105
- const fontSize = options.fontSize || 16;
106
- const textWidth = ctx.measureText(text).width;
107
- const textHeight = fontSize;
108
- // Apply gradient fill if needed
109
- if (options.gradient) {
110
- const gradientFill = createGradient(ctx, options.gradient, x, y - textHeight, x + textWidth, y);
111
- ctx.fillStyle = gradientFill;
112
- }
113
- else {
114
- ctx.fillStyle = options.color || 'darkgray';
115
- }
116
- // Draw stroke first (if exists)
117
- if (options.stroke) {
118
- ctx.save();
119
- ctx.lineWidth = options.stroke.width || 1;
120
- if (options.stroke.gradient) {
121
- const gradientStroke = createGradient(ctx, options.stroke.gradient, x, y - textHeight, x + textWidth, y);
122
- ctx.strokeStyle = gradientStroke;
123
- }
124
- else {
125
- ctx.strokeStyle = options.stroke.color || options.color || 'darkgray';
126
- }
127
- ctx.strokeText(text, x, y);
128
- ctx.restore();
129
- }
130
- // Then fill
131
- ctx.fillText(text, x, y);
132
- }
133
- /**
134
- * Creates a linear or radial gradient for fill/stroke.
135
- */
136
- export function createGradient(ctx, gradientOptions, startX, startY, endX, endY) {
137
- if (!gradientOptions || !gradientOptions.type || !gradientOptions.colors) {
138
- throw new Error("Invalid gradient options. Provide a valid object with type and colors properties.");
139
- }
140
- let gradient;
141
- if (gradientOptions.type === "linear") {
142
- gradient = ctx.createLinearGradient(startX, startY, endX, endY);
143
- }
144
- else if (gradientOptions.type === "radial") {
145
- gradient = ctx.createRadialGradient(gradientOptions.startX || startX, gradientOptions.startY || startY, gradientOptions.startRadius || 0, gradientOptions.endX || endX, gradientOptions.endY || endY, gradientOptions.endRadius || 0);
146
- }
147
- else {
148
- throw new Error('Unsupported gradient type. Use "linear" or "radial".');
149
- }
150
- for (const colorStop of gradientOptions.colors) {
151
- gradient.addColorStop(colorStop.stop, colorStop.color);
152
- }
153
- return gradient;
154
- }