apexify.js 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tsbuildinfo +1 -1
- package/README.md +4 -802
- package/change logs.md +19 -0
- package/dist/ai/ApexAI.d.ts +15 -6
- package/dist/ai/ApexAI.d.ts.map +1 -1
- package/dist/ai/ApexAI.js +110 -32
- package/dist/ai/ApexAI.js.map +1 -1
- package/dist/ai/buttons/tools.d.ts.map +1 -1
- package/dist/ai/buttons/tools.js +1 -1
- package/dist/ai/buttons/tools.js.map +1 -1
- package/dist/ai/functions/aivoice.d.ts +1 -0
- package/dist/ai/functions/aivoice.d.ts.map +1 -0
- package/dist/ai/functions/aivoice.js +2 -0
- package/dist/ai/functions/aivoice.js.map +1 -0
- package/dist/ai/functions/draw.d.ts +1 -1
- package/dist/ai/functions/draw.d.ts.map +1 -1
- package/dist/ai/functions/draw.js +12 -1
- package/dist/ai/functions/draw.js.map +1 -1
- package/dist/ai/functions/generateVoiceResponse.d.ts +1 -1
- package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -1
- package/dist/ai/functions/generateVoiceResponse.js +3 -3
- package/dist/ai/functions/generateVoiceResponse.js.map +1 -1
- package/dist/ai/models.d.ts +1 -1
- package/dist/ai/models.d.ts.map +1 -1
- package/dist/ai/models.js +46 -28
- package/dist/ai/models.js.map +1 -1
- package/dist/ai/utils.d.ts.map +1 -1
- package/dist/ai/utils.js.map +1 -1
- package/dist/canvas/ApexPainter.d.ts +10 -10
- package/dist/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/canvas/ApexPainter.js +21 -26
- package/dist/canvas/ApexPainter.js.map +1 -1
- package/dist/canvas/utils/bg.d.ts +1 -2
- package/dist/canvas/utils/bg.d.ts.map +1 -1
- package/dist/canvas/utils/bg.js +2 -5
- package/dist/canvas/utils/bg.js.map +1 -1
- package/dist/canvas/utils/charts.js +26 -26
- package/dist/canvas/utils/charts.js.map +1 -1
- package/dist/canvas/utils/general functions.d.ts +7 -7
- package/dist/canvas/utils/general functions.d.ts.map +1 -1
- package/dist/canvas/utils/general functions.js +47 -52
- package/dist/canvas/utils/general functions.js.map +1 -1
- package/dist/canvas/utils/types.d.ts +1 -3
- package/dist/canvas/utils/types.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/lib/ai/ApexAI.ts +550 -0
- package/lib/ai/buttons/drawMenu.ts +361 -0
- package/lib/ai/buttons/tools.ts +550 -0
- package/lib/ai/functions/chunkString.ts +3 -0
- package/lib/ai/functions/draw.ts +440 -0
- package/lib/ai/functions/generateVoiceResponse.ts +177 -0
- package/lib/ai/functions/imageReader.ts +24 -0
- package/lib/ai/functions/readFiles.ts +34 -0
- package/lib/ai/functions/readImagess.ts +41 -0
- package/lib/ai/functions/shouldDrawImage.ts +7 -0
- package/lib/ai/functions/typeWriter.ts +24 -0
- package/lib/ai/models.ts +589 -0
- package/lib/ai/utils.ts +23 -0
- package/lib/canvas/ApexPainter.ts +572 -0
- package/lib/canvas/utils/bg.ts +79 -0
- package/lib/canvas/utils/charts.ts +524 -0
- package/lib/canvas/utils/circular.ts +17 -0
- package/lib/canvas/utils/customLines.ts +49 -0
- package/lib/canvas/utils/general functions.ts +434 -0
- package/lib/canvas/utils/imageProperties.ts +403 -0
- package/lib/canvas/utils/radius.ts +26 -0
- package/lib/canvas/utils/textProperties.ts +68 -0
- package/lib/canvas/utils/types.ts +417 -0
- package/lib/canvas/utils/utils.ts +59 -0
- package/lib/index.ts +88 -0
- package/lib/utils.ts +8 -0
- package/package.json +15 -2
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for the canvas.
|
|
3
|
+
* @param {number} width - The width of the canvas.
|
|
4
|
+
* @param {number} height - The height of the canvas.
|
|
5
|
+
* @param {string} customBg - The URL or local path to the custom background image.
|
|
6
|
+
* @param {string} colorBg - The background color of the canvas.
|
|
7
|
+
* @param {object} gradientBg - The gradient settings for the canvas background.
|
|
8
|
+
* @param {number | string} borderRadius - The border radius of the canvas.
|
|
9
|
+
*/
|
|
10
|
+
export interface CanvasConfig {
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
x?: number;
|
|
14
|
+
y?: number;
|
|
15
|
+
customBg?: string;
|
|
16
|
+
colorBg?: string | 'transparent';
|
|
17
|
+
gradientBg?: {
|
|
18
|
+
type?: string | 'linear' | 'radial' | undefined;
|
|
19
|
+
startX?: number;
|
|
20
|
+
startY?: number;
|
|
21
|
+
startRadius?: number;
|
|
22
|
+
endRadius?: number;
|
|
23
|
+
endX?: number;
|
|
24
|
+
endY?: number;
|
|
25
|
+
colors?: { stop?: number; color?: string }[];
|
|
26
|
+
};
|
|
27
|
+
stroke?: {
|
|
28
|
+
color?: string;
|
|
29
|
+
width?: number;
|
|
30
|
+
position?: number;
|
|
31
|
+
borderRadius?: number | string | "circular";
|
|
32
|
+
};
|
|
33
|
+
shadow?: {
|
|
34
|
+
color?: string;
|
|
35
|
+
offsetX?: number;
|
|
36
|
+
offsetY?: number;
|
|
37
|
+
blur?: number;
|
|
38
|
+
opacity?: number;
|
|
39
|
+
};
|
|
40
|
+
rotation?: number;
|
|
41
|
+
borderRadius?: number | string | "circular";
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Properties of an image or shape to be drawn on the canvas.
|
|
46
|
+
* @param {string} source - URL or path to the image or shape name.
|
|
47
|
+
* @param {number} width - The width of the image or shape.
|
|
48
|
+
* @param {number} height - The height of the image or shape.
|
|
49
|
+
* @param {number} x - The x-coordinate of the image or shape.
|
|
50
|
+
* @param {number} y - The y-coordinate of the image or shape.
|
|
51
|
+
* @param {boolean} isFilled - Whether the shape is filled or not (Only applicable if source is a shape name).
|
|
52
|
+
* @param {string} color - The color of the shape (Only applicable if source is a shape name).
|
|
53
|
+
* @param {object} gradient - The gradient settings for the shape (Only applicable if source is a shape name).
|
|
54
|
+
* @param {number} rotation - Rotation angle in degrees.
|
|
55
|
+
* @param {number | string} borderRadius - The border radius of the image or shape.
|
|
56
|
+
* @param {object} stroke - The stroke properties.
|
|
57
|
+
* @param {string} stroke.color - The color of the stroke.
|
|
58
|
+
* @param {number} stroke.width - The width of the stroke.
|
|
59
|
+
* @param {number} stroke.position - Space between stroke and the image it's stroked on.
|
|
60
|
+
* @param {number | string} stroke.borderRadius - The border radius of the stroke.
|
|
61
|
+
* @param {object} shadow - The shadow properties.
|
|
62
|
+
* @param {string} shadow.color - The color of the shadow.
|
|
63
|
+
* @param {number} shadow.offsetX - The horizontal offset of the shadow.
|
|
64
|
+
* @param {number} shadow.offsetY - The vertical offset of the shadow.
|
|
65
|
+
* @param {number} shadow.blur - The blur radius of the shadow.
|
|
66
|
+
* @param {number} shadow.opacity - The opacity of the shadow.
|
|
67
|
+
* @param {number | string} shadow.borderRadius - The border radius of the shadow.
|
|
68
|
+
*/
|
|
69
|
+
export interface ImageProperties {
|
|
70
|
+
source: string;
|
|
71
|
+
width?: number;
|
|
72
|
+
height?: number;
|
|
73
|
+
x?: number;
|
|
74
|
+
y?: number;
|
|
75
|
+
isFilled?: boolean;
|
|
76
|
+
color?: string;
|
|
77
|
+
gradient?: {
|
|
78
|
+
type?: string | 'linear' | 'radial' | undefined;
|
|
79
|
+
startX?: number;
|
|
80
|
+
startY?: number;
|
|
81
|
+
startRadius?: number;
|
|
82
|
+
endRadius?: number;
|
|
83
|
+
endX?: number;
|
|
84
|
+
endY?: number;
|
|
85
|
+
colors?: { stop?: number; color?: string }[];
|
|
86
|
+
};
|
|
87
|
+
rotation?: number;
|
|
88
|
+
borderRadius?: number | string | "circular" ;
|
|
89
|
+
stroke?: {
|
|
90
|
+
color?: string;
|
|
91
|
+
width?: number;
|
|
92
|
+
position?: number;
|
|
93
|
+
borderRadius?: number | string | "circular";
|
|
94
|
+
};
|
|
95
|
+
shadow?: {
|
|
96
|
+
color?: string;
|
|
97
|
+
offsetX?: number;
|
|
98
|
+
offsetY?: number;
|
|
99
|
+
blur?: number;
|
|
100
|
+
opacity?: number;
|
|
101
|
+
borderRadius?: number | string | "circular";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export interface TextObject {
|
|
106
|
+
text?: string;
|
|
107
|
+
x?: number;
|
|
108
|
+
y?: number;
|
|
109
|
+
fontPath?: string;
|
|
110
|
+
fontName?: string;
|
|
111
|
+
fontSize?: number;
|
|
112
|
+
isBold?: boolean;
|
|
113
|
+
color?: string;
|
|
114
|
+
maxWidth?: number;
|
|
115
|
+
lineHeight?: number;
|
|
116
|
+
textAlign?: CanvasTextAlign;
|
|
117
|
+
textBaseline?: CanvasTextBaseline;
|
|
118
|
+
shadow?: {
|
|
119
|
+
color?: string;
|
|
120
|
+
offsetX?: number;
|
|
121
|
+
offsetY?: number;
|
|
122
|
+
blur?: number;
|
|
123
|
+
opacity?: number;
|
|
124
|
+
};
|
|
125
|
+
stroke?: {
|
|
126
|
+
color?: string;
|
|
127
|
+
width?: number;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Represents an image object.
|
|
133
|
+
* @param source The source of the image.
|
|
134
|
+
* @param isRemote Indicates whether the image is remote or local.
|
|
135
|
+
*/
|
|
136
|
+
export interface ImageObject {
|
|
137
|
+
source: string;
|
|
138
|
+
isRemote: boolean;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Options for creating a GIF.
|
|
143
|
+
* @param outputFormat The format of the output ('file', 'base64', 'attachment', or 'buffer').
|
|
144
|
+
* @param outputFile The file path if output format is 'file'.
|
|
145
|
+
* @param width The width of the GIF.
|
|
146
|
+
* @param height The height of the GIF.
|
|
147
|
+
* @param repeat The number of times the GIF should repeat.
|
|
148
|
+
* @param quality The quality of the GIF.
|
|
149
|
+
* @param delay The delay between frames in milliseconds.
|
|
150
|
+
* @param watermark The watermark settings.
|
|
151
|
+
* @param textOverlay The text overlay settings.
|
|
152
|
+
* @param basDir The base directory for files.
|
|
153
|
+
*/
|
|
154
|
+
export interface GIFOptions {
|
|
155
|
+
outputFormat: 'file' | 'base64' | 'attachment' | 'buffer' | string;
|
|
156
|
+
outputFile?: string;
|
|
157
|
+
width?: number;
|
|
158
|
+
height?: number;
|
|
159
|
+
repeat?: number;
|
|
160
|
+
quality?: number;
|
|
161
|
+
delay?: number;
|
|
162
|
+
watermark?: {
|
|
163
|
+
enable: boolean;
|
|
164
|
+
url: string;
|
|
165
|
+
};
|
|
166
|
+
textOverlay?: {
|
|
167
|
+
text: string;
|
|
168
|
+
fontName?: string;
|
|
169
|
+
fontPath?: string;
|
|
170
|
+
fontSize?: number;
|
|
171
|
+
fontColor?: string;
|
|
172
|
+
x?: number;
|
|
173
|
+
y?: number;
|
|
174
|
+
};
|
|
175
|
+
basDir?: any;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Results of creating a GIF.
|
|
180
|
+
* @param buffer The buffer containing the GIF data.
|
|
181
|
+
* @param base64 The base64 representation of the GIF.
|
|
182
|
+
* @param attachment The attachment containing the GIF stream.
|
|
183
|
+
*/
|
|
184
|
+
export interface GIFResults {
|
|
185
|
+
buffer?: Buffer;
|
|
186
|
+
base64?: string;
|
|
187
|
+
attachment?: { attachment: NodeJS.ReadableStream | any; name: string };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Custom options for drawing.
|
|
192
|
+
* @param startCoordinates The starting coordinates.
|
|
193
|
+
* @param endCoordinates The ending coordinates.
|
|
194
|
+
* @param lineStyle The style of the line.
|
|
195
|
+
*/
|
|
196
|
+
export interface CustomOptions {
|
|
197
|
+
startCoordinates: {
|
|
198
|
+
x: number;
|
|
199
|
+
y: number;
|
|
200
|
+
};
|
|
201
|
+
endCoordinates: {
|
|
202
|
+
x: number;
|
|
203
|
+
y: number;
|
|
204
|
+
};
|
|
205
|
+
lineStyle?: {
|
|
206
|
+
width?: number;
|
|
207
|
+
color?: string;
|
|
208
|
+
lineRadius?: number | string;
|
|
209
|
+
stroke?: {
|
|
210
|
+
color?: string;
|
|
211
|
+
width?: number;
|
|
212
|
+
lineRadius?: number | string;
|
|
213
|
+
};
|
|
214
|
+
shadow?: {
|
|
215
|
+
offsetX?: number;
|
|
216
|
+
offsetY?: number;
|
|
217
|
+
blur?: number;
|
|
218
|
+
color?: string;
|
|
219
|
+
lineRadius?: number | string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface ChartData {
|
|
225
|
+
height?: number;
|
|
226
|
+
width?: number;
|
|
227
|
+
widthPerc?: number;
|
|
228
|
+
heightPerc?: number;
|
|
229
|
+
title?: {
|
|
230
|
+
title?: string;
|
|
231
|
+
color?: string;
|
|
232
|
+
size?: number;
|
|
233
|
+
};
|
|
234
|
+
bg?: {
|
|
235
|
+
image?: string;
|
|
236
|
+
bgColor?: string;
|
|
237
|
+
};
|
|
238
|
+
grid?: {
|
|
239
|
+
enable: boolean;
|
|
240
|
+
color?: string;
|
|
241
|
+
width?: number;
|
|
242
|
+
};
|
|
243
|
+
axis?: {
|
|
244
|
+
color?: string;
|
|
245
|
+
size?: number;
|
|
246
|
+
};
|
|
247
|
+
labels?: {
|
|
248
|
+
color?: string;
|
|
249
|
+
fontSize?: number;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface DataPoint {
|
|
254
|
+
label: string;
|
|
255
|
+
barColor?: string;
|
|
256
|
+
stroke?: {
|
|
257
|
+
color?: string;
|
|
258
|
+
width?: number;
|
|
259
|
+
}
|
|
260
|
+
value: number;
|
|
261
|
+
position: {
|
|
262
|
+
startsXLabel: number;
|
|
263
|
+
endsXLabel: number;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface barChart_1 {
|
|
268
|
+
chartData?: ChartData;
|
|
269
|
+
xLabels: number[];
|
|
270
|
+
yLabels: number[];
|
|
271
|
+
data: {
|
|
272
|
+
xAxis: DataPoint[];
|
|
273
|
+
yAxis: number[];
|
|
274
|
+
keys?: { [color: string]: string };
|
|
275
|
+
keyColor?: string;
|
|
276
|
+
xTitle?: string;
|
|
277
|
+
yTitle?: string;
|
|
278
|
+
labelStyle?: {
|
|
279
|
+
color?: string;
|
|
280
|
+
size?: number;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
export interface bgConfig {
|
|
287
|
+
width?: number;
|
|
288
|
+
height?: number;
|
|
289
|
+
bgcolor?: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface KeyBoxConfig {
|
|
293
|
+
width?: number;
|
|
294
|
+
height?: number;
|
|
295
|
+
radius?: number;
|
|
296
|
+
bgcolor?: string;
|
|
297
|
+
x?: number;
|
|
298
|
+
y?: number;
|
|
299
|
+
content?: KeyBoxContent;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface KeyBoxContent {
|
|
303
|
+
keyTitle?: {
|
|
304
|
+
text?: string;
|
|
305
|
+
fontSize?: number;
|
|
306
|
+
x?: number;
|
|
307
|
+
y?: number;
|
|
308
|
+
};
|
|
309
|
+
keys?: {
|
|
310
|
+
x?: number;
|
|
311
|
+
y?: number;
|
|
312
|
+
fontSize?: number;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface StrokeConfig {
|
|
317
|
+
color?: string;
|
|
318
|
+
size?: number;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface TitleConfig {
|
|
322
|
+
text?: string;
|
|
323
|
+
color?: string;
|
|
324
|
+
fontSize?: number;
|
|
325
|
+
x?: number;
|
|
326
|
+
y?: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface PieDataConfig {
|
|
330
|
+
x?: number;
|
|
331
|
+
y?: number;
|
|
332
|
+
stroke?: StrokeConfig;
|
|
333
|
+
title?: TitleConfig;
|
|
334
|
+
boxes?: {
|
|
335
|
+
labelDistance?: number;
|
|
336
|
+
width?: number;
|
|
337
|
+
height?: number;
|
|
338
|
+
fontSize?: number;
|
|
339
|
+
labelColor?: string;
|
|
340
|
+
boxColor?: string;
|
|
341
|
+
strokeColor?: string;
|
|
342
|
+
|
|
343
|
+
};
|
|
344
|
+
radius?: number;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface PieConfig {
|
|
348
|
+
canvas?: bgConfig;
|
|
349
|
+
keyBox?: KeyBoxConfig;
|
|
350
|
+
pieData?: PieDataConfig;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface DataItem {
|
|
354
|
+
label: string;
|
|
355
|
+
color: string;
|
|
356
|
+
value: number;
|
|
357
|
+
key: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface PieChartData {
|
|
361
|
+
data?: DataItem[];
|
|
362
|
+
pieConfig?: PieConfig;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
export interface DataPoint {
|
|
367
|
+
label: string;
|
|
368
|
+
y: number;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export interface LineChartConfig {
|
|
372
|
+
yLabels: string[];
|
|
373
|
+
fillArea: { color: string }[];
|
|
374
|
+
lineColor: string[];
|
|
375
|
+
plot: {
|
|
376
|
+
enable: boolean;
|
|
377
|
+
color: string[];
|
|
378
|
+
size: number;
|
|
379
|
+
};
|
|
380
|
+
lineTension: number[];
|
|
381
|
+
grid: {
|
|
382
|
+
type: 'vertical' | 'horizontal' | 'both' | string;
|
|
383
|
+
color: string;
|
|
384
|
+
width: number;
|
|
385
|
+
};
|
|
386
|
+
keys: { [color: string]: string };
|
|
387
|
+
keysConfig: {
|
|
388
|
+
radius?: number;
|
|
389
|
+
keyPadding?: number;
|
|
390
|
+
textPadding?: number;
|
|
391
|
+
lineWidth?: number;
|
|
392
|
+
fontColor?: string;
|
|
393
|
+
}
|
|
394
|
+
canvas?: {
|
|
395
|
+
bgColor?: string;
|
|
396
|
+
fontColor?: string;
|
|
397
|
+
fontSize?: number;
|
|
398
|
+
width?: number;
|
|
399
|
+
height?: number;
|
|
400
|
+
image?: string;
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
export interface cropCoordinate {
|
|
407
|
+
from: { x: number; y: number };
|
|
408
|
+
to: { x: number; y: number };
|
|
409
|
+
tension?: number;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export interface cropOptions {
|
|
413
|
+
coordinates: cropCoordinate[];
|
|
414
|
+
imageSource: string;
|
|
415
|
+
crop: 'inner' | 'outer' | string;
|
|
416
|
+
radius: 'circular' | number | string;
|
|
417
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exported utilities for handling canvas configurations and drawing operations.
|
|
3
|
+
* @param CanvasConfig The configuration options for the canvas.
|
|
4
|
+
* @param radiusBorder The function for applying a radius border to the canvas.
|
|
5
|
+
* @param circularBorder The function for applying a circular border to the canvas.
|
|
6
|
+
* @param drawBackgroundColor The function for drawing a solid background color on the canvas.
|
|
7
|
+
* @param drawBackgroundGradient The function for drawing a gradient background on the canvas.
|
|
8
|
+
* @param customBackground The function for drawing a custom background image on the canvas.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import { CanvasConfig, ImageProperties, TextObject, ImageObject, GIFOptions, GIFResults, CustomOptions, cropOptions } from "./types";
|
|
14
|
+
import { radiusBorder } from "./radius";
|
|
15
|
+
import { circularBorder } from "./circular";
|
|
16
|
+
import { drawBackgroundColor, drawBackgroundGradient, customBackground } from "./bg";
|
|
17
|
+
import { applyRotation, imageRadius, applyStroke, applyShadow, objectRadius, drawShape} from './imageProperties'
|
|
18
|
+
import { drawText, WrappedText } from "./textProperties";
|
|
19
|
+
import { loadImages, resizingImg, converter, applyColorFilters, imgEffects, cropOuter, cropInner, detectColors, removeColor, bgRemoval } from './general functions';
|
|
20
|
+
import { customLines } from "./customLines";
|
|
21
|
+
import { verticalBarChart, pieChart, lineChart } from './charts'
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
CanvasConfig,
|
|
25
|
+
ImageProperties,
|
|
26
|
+
TextObject,
|
|
27
|
+
ImageObject,
|
|
28
|
+
GIFOptions,
|
|
29
|
+
GIFResults,
|
|
30
|
+
CustomOptions,
|
|
31
|
+
cropOptions,
|
|
32
|
+
radiusBorder,
|
|
33
|
+
customLines,
|
|
34
|
+
circularBorder,
|
|
35
|
+
drawBackgroundColor,
|
|
36
|
+
drawBackgroundGradient,
|
|
37
|
+
customBackground,
|
|
38
|
+
applyRotation,
|
|
39
|
+
imageRadius,
|
|
40
|
+
applyStroke,
|
|
41
|
+
applyShadow,
|
|
42
|
+
objectRadius,
|
|
43
|
+
drawShape,
|
|
44
|
+
drawText,
|
|
45
|
+
WrappedText,
|
|
46
|
+
loadImages,
|
|
47
|
+
resizingImg,
|
|
48
|
+
converter,
|
|
49
|
+
applyColorFilters,
|
|
50
|
+
imgEffects,
|
|
51
|
+
verticalBarChart,
|
|
52
|
+
pieChart,
|
|
53
|
+
lineChart,
|
|
54
|
+
cropInner,
|
|
55
|
+
cropOuter,
|
|
56
|
+
detectColors,
|
|
57
|
+
removeColor,
|
|
58
|
+
bgRemoval
|
|
59
|
+
};
|
package/lib/index.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as child_process from "child_process";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
|
|
6
|
+
const CYAN: string = "\x1b[36m";
|
|
7
|
+
const RESET: string = "\x1b[0m";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const nodeVersion = process.version;
|
|
12
|
+
|
|
13
|
+
let sharpVersion;
|
|
14
|
+
if (compareVersions(nodeVersion, ">=", "v18.17.0")) {
|
|
15
|
+
sharpVersion = "^0.32.0";
|
|
16
|
+
} else {
|
|
17
|
+
sharpVersion = "^0.30.0";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function compareVersions(version1: string, operator: string, version2: string): boolean {
|
|
21
|
+
const v1 = parseNodeVersion(version1);
|
|
22
|
+
const v2 = parseNodeVersion(version2);
|
|
23
|
+
|
|
24
|
+
switch (operator) {
|
|
25
|
+
case ">":
|
|
26
|
+
return v1 > v2;
|
|
27
|
+
case ">=":
|
|
28
|
+
return v1 >= v2;
|
|
29
|
+
case "<":
|
|
30
|
+
return v1 < v2;
|
|
31
|
+
case "<=":
|
|
32
|
+
return v1 <= v2;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error("Invalid comparison operator");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function parseNodeVersion(version: string): number {
|
|
39
|
+
const parts = version.slice(1).split(".");
|
|
40
|
+
return parseInt(parts[0], 10) * 10000 +
|
|
41
|
+
parseInt(parts[1], 10) * 100 +
|
|
42
|
+
parseInt(parts[2], 10);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let installCommand;
|
|
46
|
+
if (process.env.npm_execpath && process.env.npm_execpath.includes("yarn")) {
|
|
47
|
+
installCommand = `yarn add sharp@${sharpVersion}`;
|
|
48
|
+
} else if (process.env.npm_execpath && process.env.npm_execpath.includes("pnpm")) {
|
|
49
|
+
installCommand = `pnpm add sharp@${sharpVersion}`;
|
|
50
|
+
} else if (process.env.npm_execpath && process.env.npm_execpath.includes("bun")) {
|
|
51
|
+
installCommand = `bun add sharp@${sharpVersion}`;
|
|
52
|
+
} else {
|
|
53
|
+
installCommand = `npm install sharp@${sharpVersion}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
child_process.execSync(installCommand, {stdio: 'inherit'});
|
|
57
|
+
|
|
58
|
+
const packageJsonPath: string = path.resolve(process.cwd(), "package.json");
|
|
59
|
+
const packageJson: any = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
60
|
+
|
|
61
|
+
const getLibraryVersion = function(library: string): string {
|
|
62
|
+
const dependencies: any = packageJson.dependencies || {};
|
|
63
|
+
const devDependencies: any = packageJson.devDependencies || {};
|
|
64
|
+
const version: string = (dependencies[library] || devDependencies[library] || "").replace(/^(\^|~)/, "") || "Not installed";
|
|
65
|
+
return version;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
axios
|
|
69
|
+
.get("https://registry.npmjs.com/-/v1/search?text=apexify.js")
|
|
70
|
+
.then(function(response: any) {
|
|
71
|
+
const version: string = response.data.objects[0]?.package?.version;
|
|
72
|
+
if (version && getLibraryVersion("apexify.js") !== version) {
|
|
73
|
+
console.error(CYAN +
|
|
74
|
+
"Error: Please update apexify.js to the latest version (" + version + ")." +
|
|
75
|
+
RESET);
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.catch(function(error: any) {});
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
import { ApexAI, ApexChat, ApexImagine, ApexPainter } from "./utils";
|
|
82
|
+
|
|
83
|
+
export { ApexPainter, ApexAI, ApexImagine, ApexChat };
|
|
84
|
+
export default { ApexPainter, ApexAI, ApexImagine, ApexChat };
|
|
85
|
+
|
|
86
|
+
export async function apexAI() {
|
|
87
|
+
throw new Error('This Function is deprecated. Please use ApexAI instead. Refer to the documentation for further information.')
|
|
88
|
+
}
|
package/lib/utils.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ApexPainter } from "./canvas/ApexPainter";
|
|
2
|
+
import { ApexAI } from "./ai/ApexAI";
|
|
3
|
+
import { ApexChat, ApexImagine } from "./ai/utils";
|
|
4
|
+
|
|
5
|
+
export { ApexPainter, ApexAI, ApexImagine, ApexChat };
|
|
6
|
+
export default { ApexPainter, ApexAI, ApexImagine, ApexChat };
|
|
7
|
+
|
|
8
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apexify.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Ai and Canvas library. Supports typescript and javascript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,12 +8,25 @@
|
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"watch": "tsc -w",
|
|
10
10
|
"start": "node ./dist/index.js",
|
|
11
|
-
"
|
|
11
|
+
"dev": " ts-node ./lib/index.ts"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"manipulation",
|
|
15
15
|
"node-charts",
|
|
16
16
|
"canvas-charts",
|
|
17
|
+
"pixman",
|
|
18
|
+
"cairo",
|
|
19
|
+
"image",
|
|
20
|
+
"html5",
|
|
21
|
+
"pdf",
|
|
22
|
+
"napi-rs",
|
|
23
|
+
"NAPI",
|
|
24
|
+
"N-API",
|
|
25
|
+
"Rust",
|
|
26
|
+
"node-addon",
|
|
27
|
+
"node-addon-api",
|
|
28
|
+
"svg",
|
|
29
|
+
"skia",
|
|
17
30
|
"canvas-node",
|
|
18
31
|
"line charts",
|
|
19
32
|
"pie charts",
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"incremental": true,
|
|
4
|
+
"composite": true,
|
|
5
|
+
"tsBuildInfoFile": "./.tsbuildinfo",
|
|
6
|
+
"target": "es2018",
|
|
7
|
+
"module": "commonjs",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"outDir": "./dist",
|
|
13
|
+
"rootDir": "./lib",
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"skipLibCheck": true
|
|
18
|
+
},
|
|
19
|
+
"include": ["./lib/", "lib/index.ts"],
|
|
20
|
+
"exclude": ["node_modules"]
|
|
21
|
+
}
|