@azuro-org/images-generator 1.2.0 → 1.3.1

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 (92) hide show
  1. package/dist/index-82868da9.js +19637 -0
  2. package/dist/index.es.js +1 -4
  3. package/dist/templates/_template/index.d.ts +1 -1
  4. package/dist/templates/bet-nft/index.d.ts +1 -1
  5. package/dist/templates/bet-nft/index.html +0 -1
  6. package/dist/templates/bet-nft/index.js +1 -1
  7. package/dist/templates/bet-og/index.d.ts +1 -1
  8. package/dist/templates/bet-og/index.js +1 -1
  9. package/dist/templates/combo-bet-og/index.d.ts +1 -1
  10. package/dist/templates/combo-bet-og/index.js +1 -1
  11. package/dist/templates/freebet/index.d.ts +1 -1
  12. package/dist/templates/freebet/index.js +1 -1
  13. package/dist/templates/trendle-social/images/bg-business.png +0 -0
  14. package/dist/templates/trendle-social/images/bg-crypto.png +0 -0
  15. package/dist/templates/trendle-social/images/bg-culture.png +0 -0
  16. package/dist/templates/trendle-social/images/bg-fomo.png +0 -0
  17. package/dist/templates/trendle-social/images/bg-politics.png +0 -0
  18. package/dist/templates/trendle-social/images/business.png +0 -0
  19. package/dist/templates/trendle-social/images/crypto.png +0 -0
  20. package/dist/templates/trendle-social/images/culture.png +0 -0
  21. package/dist/templates/trendle-social/images/fomo.png +0 -0
  22. package/dist/templates/trendle-social/images/politics.png +0 -0
  23. package/dist/templates/trendle-social/images/stamp.png +0 -0
  24. package/dist/templates/trendle-social/index.d.ts +30 -0
  25. package/dist/templates/trendle-social/index.html +209 -0
  26. package/dist/templates/trendle-social/index.js +50 -0
  27. package/dist/templates/trendle-trading/images/arrow-down.png +0 -0
  28. package/dist/templates/trendle-trading/images/arrow-up.png +0 -0
  29. package/dist/templates/trendle-trading/images/bg.png +0 -0
  30. package/dist/templates/trendle-trading/images/crash.png +0 -0
  31. package/dist/templates/trendle-trading/images/drake.png +0 -0
  32. package/dist/templates/trendle-trading/images/elon.png +0 -0
  33. package/dist/templates/trendle-trading/images/lewis.png +0 -0
  34. package/dist/templates/trendle-trading/images/logo.png +0 -0
  35. package/dist/templates/trendle-trading/images/loss.png +0 -0
  36. package/dist/templates/trendle-trading/images/mark.png +0 -0
  37. package/dist/templates/trendle-trading/images/obama.png +0 -0
  38. package/dist/templates/trendle-trading/images/profit.png +0 -0
  39. package/dist/templates/trendle-trading/images/tramp.png +0 -0
  40. package/dist/templates/trendle-trading/index.d.ts +16 -0
  41. package/dist/templates/trendle-trading/index.html +249 -0
  42. package/dist/templates/trendle-trading/index.js +51 -0
  43. package/dist/utils/generateImage.d.ts +4 -8
  44. package/dist/utils/types.d.ts +2 -2
  45. package/lib/index-de0b52f4.js +19637 -0
  46. package/lib/index.js +1 -4
  47. package/lib/templates/_template/index.d.ts +1 -1
  48. package/lib/templates/bet-nft/index.d.ts +1 -1
  49. package/lib/templates/bet-nft/index.html +0 -1
  50. package/lib/templates/bet-nft/index.js +1 -1
  51. package/lib/templates/bet-og/index.d.ts +1 -1
  52. package/lib/templates/bet-og/index.js +2 -2
  53. package/lib/templates/combo-bet-og/index.d.ts +1 -1
  54. package/lib/templates/combo-bet-og/index.js +1 -1
  55. package/lib/templates/freebet/index.d.ts +1 -1
  56. package/lib/templates/freebet/index.js +1 -1
  57. package/lib/templates/trendle-social/images/bg-business.png +0 -0
  58. package/lib/templates/trendle-social/images/bg-crypto.png +0 -0
  59. package/lib/templates/trendle-social/images/bg-culture.png +0 -0
  60. package/lib/templates/trendle-social/images/bg-fomo.png +0 -0
  61. package/lib/templates/trendle-social/images/bg-politics.png +0 -0
  62. package/lib/templates/trendle-social/images/business.png +0 -0
  63. package/lib/templates/trendle-social/images/crypto.png +0 -0
  64. package/lib/templates/trendle-social/images/culture.png +0 -0
  65. package/lib/templates/trendle-social/images/fomo.png +0 -0
  66. package/lib/templates/trendle-social/images/politics.png +0 -0
  67. package/lib/templates/trendle-social/images/stamp.png +0 -0
  68. package/lib/templates/trendle-social/index.d.ts +30 -0
  69. package/lib/templates/trendle-social/index.html +209 -0
  70. package/lib/templates/trendle-social/index.js +50 -0
  71. package/lib/templates/trendle-trading/images/arrow-down.png +0 -0
  72. package/lib/templates/trendle-trading/images/arrow-up.png +0 -0
  73. package/lib/templates/trendle-trading/images/bg.png +0 -0
  74. package/lib/templates/trendle-trading/images/crash.png +0 -0
  75. package/lib/templates/trendle-trading/images/drake.png +0 -0
  76. package/lib/templates/trendle-trading/images/elon.png +0 -0
  77. package/lib/templates/trendle-trading/images/lewis.png +0 -0
  78. package/lib/templates/trendle-trading/images/logo.png +0 -0
  79. package/lib/templates/trendle-trading/images/loss.png +0 -0
  80. package/lib/templates/trendle-trading/images/mark.png +0 -0
  81. package/lib/templates/trendle-trading/images/obama.png +0 -0
  82. package/lib/templates/trendle-trading/images/profit.png +0 -0
  83. package/lib/templates/trendle-trading/images/tramp.png +0 -0
  84. package/lib/templates/trendle-trading/index.d.ts +16 -0
  85. package/lib/templates/trendle-trading/index.html +249 -0
  86. package/lib/templates/trendle-trading/index.js +51 -0
  87. package/lib/utils/generateImage.d.ts +4 -8
  88. package/lib/utils/types.d.ts +2 -2
  89. package/package.json +4 -3
  90. package/tsconfig.json +3 -0
  91. package/dist/index-cd3884c7.js +0 -4216
  92. package/lib/index-9642de53.js +0 -4216
@@ -0,0 +1,249 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&family=Mona+Sans:wdth,wght@75..125,700&display=swap" rel="stylesheet">
7
+ <style>
8
+ html {
9
+ font-family: 'Inter', sans-serif;
10
+ font-weight: 500;
11
+ color: #000;
12
+ }
13
+
14
+ html, body {
15
+ margin: 0;
16
+ width: fit-content;
17
+ }
18
+
19
+ .mona-sans {
20
+ font-family: "Mona Sans", sans-serif;
21
+ font-optical-sizing: auto;
22
+ font-style: normal;
23
+ }
24
+
25
+ * {
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ .flex {
30
+ display: flex;
31
+ }
32
+
33
+ .flex-wrap {
34
+ flex-wrap: wrap;
35
+ }
36
+
37
+ .flex-1 {
38
+ flex: 1 1 0;
39
+ }
40
+
41
+ .flex-auto {
42
+ flex: 1 1 auto;
43
+ }
44
+
45
+ .flex-none {
46
+ flex: none;
47
+ }
48
+
49
+ .items-center {
50
+ align-items: center;
51
+ }
52
+
53
+ .items-start {
54
+ align-items: flex-start;
55
+ }
56
+
57
+ .items-end {
58
+ align-items: flex-end;
59
+ }
60
+
61
+ .items-baseline {
62
+ align-items: baseline;
63
+ }
64
+
65
+ .items-stretch {
66
+ align-items: stretch;
67
+ }
68
+
69
+ .self-auto {
70
+ align-self: auto;
71
+ }
72
+
73
+ .self-start {
74
+ align-self: flex-start;
75
+ }
76
+
77
+ .self-end {
78
+ align-self: flex-end;
79
+ }
80
+
81
+ .self-center {
82
+ align-self: center;
83
+ }
84
+
85
+ .self-stretch {
86
+ align-self: stretch;
87
+ }
88
+
89
+ .justify-around {
90
+ justify-content: space-around;
91
+ }
92
+
93
+ .justify-between {
94
+ justify-content: space-between;
95
+ }
96
+
97
+ .justify-center {
98
+ justify-content: center;
99
+ }
100
+
101
+ .justify-start {
102
+ justify-content: flex-start;
103
+ }
104
+
105
+ .justify-end {
106
+ justify-content: flex-end;
107
+ }
108
+
109
+ .flex-row {
110
+ flex-direction: row;
111
+ }
112
+
113
+ .flex-col {
114
+ flex-direction: column;
115
+ }
116
+
117
+ .flex-col-reverse {
118
+ flex-direction: column-reverse;
119
+ }
120
+
121
+ .text-upper {
122
+ text-transform: uppercase;
123
+ }
124
+
125
+ .text-center {
126
+ text-align: center;
127
+ }
128
+
129
+ .card {
130
+ background: --card-bg-color;
131
+ width: 1200px;
132
+ height: 800px;
133
+ padding: 32px 32px 26px;
134
+ position: relative;
135
+ }
136
+
137
+ .logo {
138
+ height: 38px;
139
+ width: 266px;
140
+ display: block;
141
+ }
142
+
143
+ .trend {
144
+ /* margin-top: 108px; */
145
+ }
146
+
147
+ .trend__img {
148
+ margin-right: 20px;
149
+ width: 80px;
150
+ height: 80px;
151
+ border-radius: 100%;
152
+ overflow: hidden;
153
+ }
154
+
155
+ .trend__img > img {
156
+ width: 100%;
157
+ }
158
+
159
+ .trend__title {
160
+ font-size: 32px;
161
+ line-height: 100%;
162
+ }
163
+
164
+ .trend__badge {
165
+ background-color: rgba(0, 0, 0, 0.2);
166
+ padding: 6px 12px 8px 8px;
167
+ border-radius: 5px;
168
+ font-size: 24px;
169
+ line-height: 100%;
170
+ margin-top: 10px;
171
+ }
172
+
173
+ .pnl {
174
+ margin-top: 22px;
175
+ font-size: 120px;
176
+ line-height: 100%;
177
+ font-weight: 700;
178
+ }
179
+
180
+ .code__text {
181
+ color: rgba(0, 0, 0, 0.8);
182
+ font-size: 24px;
183
+ line-height: 100%;
184
+ opacity: 50%;
185
+ }
186
+
187
+ .code__link {
188
+ margin-top: 4px;
189
+ font-size: 28px;
190
+ line-height: 37px;
191
+ }
192
+
193
+ .right-img {
194
+ position: absolute;
195
+ top: 0px;
196
+ right: 0px;
197
+ height: 100%;
198
+ }
199
+
200
+ .arrow {
201
+ width: 24px;
202
+ height: 24px;
203
+ margin-top: 2px;
204
+ margin-bottom: -3px;
205
+ }
206
+
207
+ .person-img {
208
+ position: absolute;
209
+ height: 100%;
210
+ top: 0px;
211
+ right: 0px;
212
+ mix-blend-mode: multiply;
213
+ }
214
+
215
+ .bg-img {
216
+ position: absolute;
217
+ top: 0px;
218
+ width: 100%;
219
+ }
220
+ </style>
221
+ </head>
222
+ <body>
223
+ <div class="card flex flex-col justify-between">
224
+ <img class="bg-img" src={bgImg} alt="">
225
+ <img class="right-img" src={rightImg} alt="">
226
+ <img class="person-img" src={personImg} alt="">
227
+ <img src="{logo}" class="logo" alt="">
228
+ <div>
229
+ <div class="trend flex items-center">
230
+ <div class="trend__img flex items-center justify-center">
231
+ <img src="{trendImage}" alt="">
232
+ </div>
233
+ <div>
234
+ <div class="trend__title">{trendTitle}</div>
235
+ <div class="trend__badge">
236
+ <img class="arrow" src="{arrowImage}" alt="">
237
+ <span>{positionInfo}</span>
238
+ </div>
239
+ </div>
240
+ </div>
241
+ <div class="pnl">{pnl}%</div>
242
+ </div>
243
+ <div class="code">
244
+ <div class="code__text">Referral code</div>
245
+ <div class="code__link">{refferalLink}</div>
246
+ </div>
247
+ </div>
248
+ </body>
249
+ </html>
@@ -0,0 +1,51 @@
1
+ import {_ as __awaiter,a as __generator,g as getFile,b as getBase64Image,d as downloadImage}from'../../index-82868da9.js';import path from'path';import'fs';import'util';import'stream';import'http';import'https';import'url';import'crypto';import'assert';import'tty';import'zlib';import'events';var cardTypes = {
2
+ 'profit': {
3
+ rightImg: 'images/profit.png',
4
+ arrow: 'images/arrow-up.png',
5
+ bgColor: '#72FF4B',
6
+ },
7
+ 'loss': {
8
+ rightImg: 'images/loss.png',
9
+ arrow: 'images/arrow-down.png',
10
+ bgColor: '#FF604B',
11
+ }
12
+ };
13
+ var template = {
14
+ width: 670,
15
+ height: 445,
16
+ type: 'jpeg',
17
+ html: function (props) { return __awaiter(void 0, void 0, void 0, function () {
18
+ var type, trend, pnl, position, referralUrl, isProfit, _a, rightImg, arrow, bgColor, leverage, isLong, html, logo, bgImage, rightImage, personImage, arrowImage, trendImage, positionInfo;
19
+ return __generator(this, function (_b) {
20
+ switch (_b.label) {
21
+ case 0:
22
+ type = props.type, trend = props.trend, pnl = props.pnl, position = props.position, referralUrl = props.referralUrl;
23
+ isProfit = pnl > 0;
24
+ _a = isProfit ? cardTypes.profit : cardTypes.loss, rightImg = _a.rightImg, arrow = _a.arrow, bgColor = _a.bgColor;
25
+ leverage = position.leverage, isLong = position.isLong;
26
+ html = getFile(path.join(__dirname, 'index.html'));
27
+ logo = getBase64Image(path.resolve(__dirname, 'images/logo.png'));
28
+ bgImage = getBase64Image(path.resolve(__dirname, 'images/bg.png'));
29
+ rightImage = getBase64Image(path.resolve(__dirname, rightImg));
30
+ personImage = getBase64Image(path.resolve(__dirname, "images/".concat(type, ".png")));
31
+ arrowImage = getBase64Image(path.resolve(__dirname, arrow));
32
+ return [4 /*yield*/, downloadImage(trend.image)];
33
+ case 1:
34
+ trendImage = _b.sent();
35
+ positionInfo = "".concat(isLong ? ' Up' : ' Down', ", Boost x").concat(leverage);
36
+ return [2 /*return*/, html
37
+ .replace('{logo}', logo)
38
+ .replace('--card-bg-color', bgColor)
39
+ .replace('{bgImg}', bgImage)
40
+ .replace('{rightImg}', rightImage)
41
+ .replace('{personImg}', personImage)
42
+ .replace('{trendImage}', trendImage)
43
+ .replace('{trendTitle}', trend.title)
44
+ .replace('{positionInfo}', positionInfo)
45
+ .replace('{arrowImage}', arrowImage)
46
+ .replace('{refferalLink}', referralUrl)
47
+ .replace('{pnl}', pnl > 0 ? "+".concat(pnl) : "".concat(pnl))];
48
+ }
49
+ });
50
+ }); }
51
+ };export{template as default};
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import puppeteer from 'puppeteer';
3
2
  import { type Template } from './types';
4
3
  type PuppeteerOptions = Parameters<typeof puppeteer.launch>[0];
@@ -7,15 +6,12 @@ type PuppeteerInitialOptions = {
7
6
  devtools: boolean;
8
7
  args: string[];
9
8
  };
10
- type GenerateImageResult<T> = T extends {
11
- output: string;
12
- } ? void : (string | Buffer);
13
- type GenerateImageProps = {
14
- template: Template;
9
+ type GenerateImageProps<P> = {
10
+ template: Template<P>;
15
11
  output?: string;
16
12
  filename?: string;
17
- props: any;
13
+ props: P;
18
14
  modifyPuppeteerOptions?(options: PuppeteerInitialOptions): PuppeteerOptions;
19
15
  };
20
- export default function generateImage<T extends GenerateImageProps>(props: T): Promise<GenerateImageResult<T> | undefined>;
16
+ export default function generateImage<P>(props: GenerateImageProps<P>): Promise<Uint8Array | undefined>;
21
17
  export {};
@@ -1,8 +1,8 @@
1
- export type Template = {
1
+ export type Template<Props> = {
2
2
  headless?: boolean;
3
3
  width: number;
4
4
  height: number;
5
5
  type: 'png' | 'jpeg';
6
6
  scaleFactor?: 1 | 2;
7
- html: (props: any) => string | Promise<string>;
7
+ html: (props: Props) => string | Promise<string>;
8
8
  };