@azuro-org/images-generator 2.0.3 → 2.0.4

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 (58) hide show
  1. package/dist/generator.d.ts +15 -0
  2. package/dist/index.es.js +1 -1
  3. package/dist/templates/trendle-trading/images/arrow-down.png +0 -0
  4. package/dist/templates/trendle-trading/images/arrow-up.png +0 -0
  5. package/dist/templates/trendle-trading/images/default.png +0 -0
  6. package/dist/templates/trendle-trading/index.d.ts +4 -5
  7. package/dist/templates/trendle-trading/index.html +123 -79
  8. package/dist/templates/trendle-trading/index.js +41 -15
  9. package/dist/templates/trendle-trading/utils/generateShapeAvatar.d.ts +2 -0
  10. package/lib/generator.d.ts +15 -0
  11. package/lib/index.js +1 -1
  12. package/lib/templates/trendle-trading/images/arrow-down.png +0 -0
  13. package/lib/templates/trendle-trading/images/arrow-up.png +0 -0
  14. package/lib/templates/trendle-trading/images/default.png +0 -0
  15. package/lib/templates/trendle-trading/index.d.ts +4 -5
  16. package/lib/templates/trendle-trading/index.html +123 -79
  17. package/lib/templates/trendle-trading/index.js +41 -15
  18. package/lib/templates/trendle-trading/utils/generateShapeAvatar.d.ts +2 -0
  19. package/package.json +1 -1
  20. package/tsconfig.json +6 -1
  21. package/dist/templates/trendle-trading/images/arnold.png +0 -0
  22. package/dist/templates/trendle-trading/images/bg.png +0 -0
  23. package/dist/templates/trendle-trading/images/crash.png +0 -0
  24. package/dist/templates/trendle-trading/images/drake.png +0 -0
  25. package/dist/templates/trendle-trading/images/elon-2.png +0 -0
  26. package/dist/templates/trendle-trading/images/elon.png +0 -0
  27. package/dist/templates/trendle-trading/images/lewis.png +0 -0
  28. package/dist/templates/trendle-trading/images/loss.png +0 -0
  29. package/dist/templates/trendle-trading/images/macron.png +0 -0
  30. package/dist/templates/trendle-trading/images/mark.png +0 -0
  31. package/dist/templates/trendle-trading/images/obama.png +0 -0
  32. package/dist/templates/trendle-trading/images/person-1.png +0 -0
  33. package/dist/templates/trendle-trading/images/person-2.png +0 -0
  34. package/dist/templates/trendle-trading/images/powell.png +0 -0
  35. package/dist/templates/trendle-trading/images/profit.png +0 -0
  36. package/dist/templates/trendle-trading/images/sydney.png +0 -0
  37. package/dist/templates/trendle-trading/images/taylor.png +0 -0
  38. package/dist/templates/trendle-trading/images/tramp-2.png +0 -0
  39. package/dist/templates/trendle-trading/images/tramp.png +0 -0
  40. package/lib/templates/trendle-trading/images/arnold.png +0 -0
  41. package/lib/templates/trendle-trading/images/bg.png +0 -0
  42. package/lib/templates/trendle-trading/images/crash.png +0 -0
  43. package/lib/templates/trendle-trading/images/drake.png +0 -0
  44. package/lib/templates/trendle-trading/images/elon-2.png +0 -0
  45. package/lib/templates/trendle-trading/images/elon.png +0 -0
  46. package/lib/templates/trendle-trading/images/lewis.png +0 -0
  47. package/lib/templates/trendle-trading/images/loss.png +0 -0
  48. package/lib/templates/trendle-trading/images/macron.png +0 -0
  49. package/lib/templates/trendle-trading/images/mark.png +0 -0
  50. package/lib/templates/trendle-trading/images/obama.png +0 -0
  51. package/lib/templates/trendle-trading/images/person-1.png +0 -0
  52. package/lib/templates/trendle-trading/images/person-2.png +0 -0
  53. package/lib/templates/trendle-trading/images/powell.png +0 -0
  54. package/lib/templates/trendle-trading/images/profit.png +0 -0
  55. package/lib/templates/trendle-trading/images/sydney.png +0 -0
  56. package/lib/templates/trendle-trading/images/taylor.png +0 -0
  57. package/lib/templates/trendle-trading/images/tramp-2.png +0 -0
  58. package/lib/templates/trendle-trading/images/tramp.png +0 -0
@@ -4,12 +4,27 @@ interface GeneratorOptions {
4
4
  timeout?: number;
5
5
  args?: string[];
6
6
  }
7
+ /**
8
+ * Options for a single image generation.
9
+ */
7
10
  interface GenerateOptions {
11
+ /** JPEG quality 1–100 (ignored for PNG). Default 85. */
8
12
  quality?: number;
13
+ /** Screenshot the full scrollable page instead of just the viewport. Default false. */
9
14
  fullPage?: boolean;
15
+ /** Wait for document.fonts.ready before taking the screenshot so webfonts are applied. Default true. */
10
16
  waitForFonts?: boolean;
17
+ /** Max ms to wait for content/font loading. Default 2000. */
11
18
  waitTimeout?: number;
19
+ /**
20
+ * When to consider the page content "loaded" before screenshot.
21
+ * - `domcontentloaded` – DOM ready, resources (images, fonts) may still load. Fastest. Default.
22
+ * - `load` – load event fired (images, stylesheets, etc. loaded).
23
+ * - `networkidle0` – no network requests for 500ms.
24
+ * - `networkidle2` – at most 2 network requests for 500ms.
25
+ */
12
26
  waitUntil?: 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
27
+ /** If true, do not add an extra delay for CSS animations. Default true. */
13
28
  skipAnimations?: boolean;
14
29
  }
15
30
  type GenerateProps<P> = {
package/dist/index.es.js CHANGED
@@ -180,7 +180,7 @@ function __generator(thisArg, body) {
180
180
  throw new Error('Invalid template: missing required properties');
181
181
  }
182
182
  width = template.width, height = template.height, type = template.type, getHtml = template.html;
183
- _d = options.quality, quality = _d === void 0 ? type === 'jpeg' ? 85 : undefined : _d, _e = options.fullPage, fullPage = _e === void 0 ? false : _e, _f = options.waitForFonts, waitForFonts = _f === void 0 ? true : _f, _g = options.waitTimeout, waitTimeout = _g === void 0 ? 2000 : _g, _h = options.waitUntil, waitUntil = _h === void 0 ? 'domcontentloaded' : _h, _j = options.skipAnimations, skipAnimations = _j === void 0 ? true : _j;
183
+ _d = options.quality, quality = _d === void 0 ? type === 'jpeg' ? 85 : undefined : _d, _e = options.fullPage, fullPage = _e === void 0 ? false : _e, _f = options.waitForFonts, waitForFonts = _f === void 0 ? true : _f, _g = options.waitTimeout, waitTimeout = _g === void 0 ? 2000 : _g, _h = options.waitUntil, waitUntil = _h === void 0 ? 'load' : _h, _j = options.skipAnimations, skipAnimations = _j === void 0 ? true : _j;
184
184
  _l.label = 7;
185
185
  case 7:
186
186
  _l.trys.push([7, 20, , 21]);
@@ -1,16 +1,15 @@
1
1
  import { type Template } from '../../utils';
2
- type Person = 'obama' | 'drake' | 'crash' | 'sydney' | 'tramp' | 'elon' | 'lewis' | 'mark' | 'powell' | 'macron' | 'arnold' | 'person-1' | 'tramp-2' | 'elon-2' | 'person-2' | 'taylor';
3
2
  export type Props = {
4
- type: Person;
3
+ accountAddress: string;
5
4
  trend: {
6
- image: string;
5
+ image: string | undefined;
7
6
  title: string;
8
7
  };
9
8
  position: {
10
9
  leverage: number;
11
10
  isLong: boolean;
12
- openLevel: number;
13
- exitLevel: number | undefined;
11
+ openLevel: string;
12
+ exitLevel: string | undefined;
14
13
  };
15
14
  pnl: number;
16
15
  };
@@ -4,8 +4,10 @@
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="preconnect" href="https://fonts.googleapis.com">
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
7
9
  <link
8
- href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&family=Mona+Sans:wdth,wght@75..125,700&display=swap"
10
+ href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;700&family=Inter:wght@500;600&family=Mona+Sans:wdth,wght@125,700&display=swap"
9
11
  rel="stylesheet">
10
12
  <style>
11
13
  html {
@@ -26,6 +28,13 @@
26
28
  font-style: normal;
27
29
  }
28
30
 
31
+ .geist-mono {
32
+ font-family: "Geist Mono", monospace;
33
+ font-optical-sizing: auto;
34
+ font-weight: 400;
35
+ font-style: normal;
36
+ }
37
+
29
38
  * {
30
39
  box-sizing: border-box;
31
40
  }
@@ -130,60 +139,40 @@
130
139
  text-transform: uppercase;
131
140
  }
132
141
 
142
+ .text-underline {
143
+ text-decoration: underline;
144
+ }
145
+
133
146
  .text-center {
134
147
  text-align: center;
135
148
  }
136
149
 
150
+ .text-bold {
151
+ font-weight: 700;
152
+ }
153
+
137
154
  .card {
138
155
  background: --card-bg-color;
139
156
  width: 1200px;
140
- height: 630px;
141
- padding: 48px;
157
+ height: 675px;
158
+ padding: 40px 36px 30px;
142
159
  position: relative;
160
+ color: white;
143
161
  }
144
162
 
145
163
  .logo {
146
- height: 38px;
147
- width: 266px;
164
+ height: 24px;
165
+ width: 156px;
148
166
  display: block;
149
- }
150
-
151
- .trend {
152
- /* margin-top: 108px; */
153
- }
154
-
155
- .trend__img {
156
- margin-right: 20px;
157
- width: 80px;
158
- height: 80px;
159
- border-radius: 100%;
160
- overflow: hidden;
161
- }
162
-
163
- .trend__img>img {
164
- width: 100%;
165
- }
166
-
167
- .trend__title {
168
- font-size: 32px;
169
- line-height: 100%;
170
- }
171
-
172
- .trend__badge {
173
- background-color: rgba(0, 0, 0, 0.2);
174
- padding: 6px 12px 8px 8px;
175
- border-radius: 5px;
176
- font-size: 24px;
177
- line-height: 100%;
178
- margin-top: 10px;
179
- width: fit-content;
167
+ margin-right: 45px;
180
168
  }
181
169
 
182
170
  .pnl {
183
- margin-top: 22px;
184
- font-size: 120px;
185
- line-height: 100%;
171
+ font-size: 72px;
172
+ line-height: 90%;
186
173
  font-weight: 700;
174
+ font-stretch: 125%;
175
+ color: --card-bg-color;
187
176
  }
188
177
 
189
178
  .right-img {
@@ -196,8 +185,10 @@
196
185
  .arrow {
197
186
  width: 24px;
198
187
  height: 24px;
199
- margin-top: 3px;
200
- margin-bottom: -3px;
188
+ margin-top: -4px;
189
+ margin-bottom: -4px;
190
+ margin-right: -4px;
191
+ margin-left: -6px;
201
192
  }
202
193
 
203
194
  .person-img {
@@ -208,67 +199,120 @@
208
199
  mix-blend-mode: multiply;
209
200
  }
210
201
 
211
- .bg-img {
212
- position: absolute;
213
- top: 0px;
214
- left: 0px;
215
- width: 100%;
202
+ .box {
203
+ background: #0F0F0F;
204
+ border-radius: 33px;
205
+ height: 100%;
206
+ width: fit-content;
207
+ padding: 30px 30px 55px;
208
+ min-width: 550px;
209
+ position: relative;
216
210
  }
217
211
 
218
- .level-wrapper {
212
+ .box-bottom {
219
213
  margin-top: 30px;
220
214
  }
221
215
 
222
- .level-title {
223
- opacity: 50%;
224
- color: #000000CC;
216
+ .wrapper {
217
+ width: 100%;
218
+ padding-top: 24px;
219
+ border-top: 1px solid #494949;
220
+ }
221
+
222
+ .wrapper+.wrapper {
223
+ margin-left: 24px;
224
+ }
225
+
226
+ .text {
225
227
  font-size: 24px;
226
228
  line-height: 100%;
227
229
  }
228
230
 
229
- .level-content {
230
- margin-top: 6px;
231
- font-size: 28px;
232
- line-height: 37.86px;
231
+ .text-gray {
232
+ color: #707070;
233
233
  }
234
234
 
235
- .level-box {
236
- margin-left: 125px;
235
+ .mt-45 {
236
+ margin-top: 45px;
237
+ }
238
+
239
+ .mt-12 {
240
+ margin-top: 12px;
241
+ }
242
+
243
+ .text-black {
244
+ color: #0F0F0F;
245
+ }
246
+
247
+ .account {
248
+ font-size: 30px;
249
+ line-height: 80%;
250
+ }
251
+
252
+ .avatar {
253
+ border: 1px solid #2A2A2A;
254
+ border-radius: 100%;
255
+ width: 64px;
256
+ height: 64px;
257
+ margin-right: 16px;
258
+ }
259
+
260
+ .avatar img {
261
+ width: 50%;
262
+ }
263
+
264
+ .text-semibold {
265
+ font-weight: 600;
266
+ }
267
+
268
+ .text-nowrap {
269
+ white-space: nowrap;
237
270
  }
238
271
  </style>
239
272
  </head>
240
273
 
241
274
  <body>
242
275
  <div class="card flex flex-col justify-between">
243
- <img class="bg-img" src={bgImg} alt="">
244
- <img class="right-img" src={rightImg} alt="">
245
- <img class="person-img" src={personImg} alt="">
246
- <img src="{logo}" class="logo" alt="">
247
- <div>
248
- <div class="trend flex items-center">
249
- <div class="trend__img flex items-center justify-center">
250
- <img src="{trendImage}" alt="">
251
- </div>
252
- <div>
253
- <div class="trend__title">{trendTitle}</div>
254
- <div class="trend__badge">
255
- <img class="arrow" src="{arrowImage}" alt="">
256
- <span>{positionInfo}</span>
257
- </div>
276
+ <img class="person-img" src={trendImage} alt="">
277
+ <div class="box flex flex-col justify-between">
278
+ <div class="flex items-center">
279
+ <div class="avatar flex items-center justify-center">
280
+ <img src="{avatar}" alt="">
258
281
  </div>
282
+ <div class="account">{account}</div>
259
283
  </div>
260
- <div class="pnl">{pnl}%</div>
261
- <div class="level-wrapper flex items-center">
262
- <div>
263
- <div class="level-title">Entry level:</div>
264
- <div class="level-content">{openLevel}</div>
284
+ <div>
285
+ <div class="wrapper flex justify-between">
286
+ <div class="pnl mona-sans">{pnl}%</div>
287
+ <div class="text text-gray">PnL</div>
265
288
  </div>
266
- <div class="level-box {exitLevelClass}">
267
- <div class="level-title">Exit level:</div>
268
- <div class="level-content">{exitLevel}</div>
289
+ <div class="flex mt-45 text">
290
+ <div class="wrapper">
291
+ <div class="text-semibold text-nowrap">{trendTitle}</div>
292
+ <div class="mt-12">
293
+ <img class="arrow" src="{arrowImage}" alt="">
294
+ <span class="text-gray">{positionInfo}</span>
295
+ </div>
296
+ </div>
297
+ <div class="wrapper">
298
+ <div class="flex justify-between">
299
+ <div class="text-gray">Entry:</div>
300
+ <div class="text-semibold">{openLevel}</div>
301
+ </div>
302
+ <div class="flex justify-between mt-12 {exitLevelClass}">
303
+ <div class="text-gray">Exit:</div>
304
+ <div class="text-semibold">{exitLevel}</div>
305
+ </div>
306
+ </div>
269
307
  </div>
270
308
  </div>
271
309
  </div>
310
+ <div class="box-bottom flex items-end">
311
+ <img src="{logo}" class="logo" alt="">
312
+ <div class="text-upper geist-mono text-black">trade attention on <span
313
+ class="text-underline text-bold">Trendle.fi</span>
314
+ </div>
315
+ </div>
272
316
  </div>
273
317
  </body>
274
318
 
@@ -1,10 +1,31 @@
1
- import {_ as __awaiter,a as __generator,g as getFile,b as getBase64Image,d as downloadImage}from'../../index-6ec143bc.js';import path from'path';import'fs';import'util';import'stream';import'http';import'https';import'url';import'crypto';import'http2';import'assert';import'tty';import'zlib';import'events';var cardTypes = {
1
+ import {_ as __awaiter,a as __generator,b as getBase64Image,g as getFile,d as downloadImage}from'../../index-6ec143bc.js';import path from'path';import'fs';import'util';import'stream';import'http';import'https';import'url';import'crypto';import'http2';import'assert';import'tty';import'zlib';import'events';var hashCode = function (str) {
2
+ return Array.from(str).reduce(function (hash, c) { return (hash << 5) - hash + c.charCodeAt(0); }, 0);
3
+ };
4
+ var generateShapeAvatar = function (address, size, scale) {
5
+ if (size === void 0) { size = 6; }
6
+ if (scale === void 0) { scale = 10; }
7
+ var hash = Math.abs(hashCode(address.toLowerCase()));
8
+ var color = "hsl(".concat(hash % 360, ", 60%, 55%)");
9
+ var svg = "<svg xmlns='http://www.w3.org/2000/svg' width='".concat(size * scale, "' height='").concat(size * scale, "'>");
10
+ for (var y = 0; y < size; y++) {
11
+ for (var x = 0; x < Math.ceil(size / 2); x++) {
12
+ if (((hash >> (x + y * size)) & 1) === 1) {
13
+ var rx = x * scale;
14
+ var ry = y * scale;
15
+ var symX = (size - x - 1) * scale;
16
+ svg += "<rect x='".concat(rx, "' y='").concat(ry, "' width='").concat(scale, "' height='").concat(scale, "' fill='").concat(color, "'/>");
17
+ svg += "<rect x='".concat(symX, "' y='").concat(ry, "' width='").concat(scale, "' height='").concat(scale, "' fill='").concat(color, "'/>");
18
+ }
19
+ }
20
+ }
21
+ svg += '</svg>';
22
+ var avatar = "data:image/svg+xml;utf8,".concat(encodeURIComponent(svg));
23
+ return avatar;
24
+ };var cardTypes = {
2
25
  'profit': {
3
- rightImg: 'images/profit.png',
4
26
  bgColor: '#72FF4B',
5
27
  },
6
28
  'loss': {
7
- rightImg: 'images/loss.png',
8
29
  bgColor: '#FF604B',
9
30
  }
10
31
  };
@@ -13,30 +34,35 @@ var template = {
13
34
  height: 630,
14
35
  type: 'jpeg',
15
36
  html: function (props) { return __awaiter(void 0, void 0, void 0, function () {
16
- var type, trend, pnl, position, isProfit, _a, rightImg, bgColor, leverage, isLong, openLevel, exitLevel, html, logo, bgImage, rightImage, personImage, arrowImage, trendImage, positionInfo;
37
+ var accountAddress, trend, pnl, position, isProfit, bgColor, leverage, isLong, openLevel, exitLevel, html, logo, arrowImage, trendImage, _a, positionInfo, avatar;
17
38
  return __generator(this, function (_b) {
18
39
  switch (_b.label) {
19
40
  case 0:
20
- type = props.type, trend = props.trend, pnl = props.pnl, position = props.position;
41
+ accountAddress = props.accountAddress, trend = props.trend, pnl = props.pnl, position = props.position;
21
42
  isProfit = pnl > 0;
22
- _a = isProfit ? cardTypes.profit : cardTypes.loss, rightImg = _a.rightImg, bgColor = _a.bgColor;
43
+ bgColor = (isProfit ? cardTypes.profit : cardTypes.loss).bgColor;
23
44
  leverage = position.leverage, isLong = position.isLong, openLevel = position.openLevel, exitLevel = position.exitLevel;
24
45
  html = getFile(path.join(__dirname, 'index.html'));
25
46
  logo = getBase64Image(path.resolve(__dirname, 'images/logo.png'));
26
- bgImage = getBase64Image(path.resolve(__dirname, 'images/bg.png'));
27
- rightImage = getBase64Image(path.resolve(__dirname, rightImg));
28
- personImage = getBase64Image(path.resolve(__dirname, "images/".concat(type, ".png")));
29
47
  arrowImage = getBase64Image(path.resolve(__dirname, isLong ? 'images/arrow-up.png' : 'images/arrow-down.png'));
48
+ if (!trend.image) return [3 /*break*/, 2];
30
49
  return [4 /*yield*/, downloadImage(trend.image)];
31
50
  case 1:
32
- trendImage = _b.sent();
33
- positionInfo = "".concat(isLong ? ' Up' : ' Down', ", Boost x").concat(leverage);
51
+ _a = _b.sent();
52
+ return [3 /*break*/, 3];
53
+ case 2:
54
+ _a = getBase64Image(path.resolve(__dirname, 'images/default.png'));
55
+ _b.label = 3;
56
+ case 3:
57
+ trendImage = _a;
58
+ positionInfo = "".concat(isLong ? 'Up' : 'Down', ", X").concat(leverage, " Boost");
59
+ avatar = generateShapeAvatar(accountAddress);
34
60
  return [2 /*return*/, html
35
61
  .replace('{logo}', logo)
36
- .replace('--card-bg-color', bgColor)
37
- .replace('{bgImg}', bgImage)
38
- .replace('{rightImg}', rightImage)
39
- .replace('{personImg}', personImage)
62
+ .replace('{account}', "".concat(accountAddress.substr(0, 6), "...").concat(accountAddress.substr(-1 * 6)))
63
+ .replace('{avatar}', avatar)
64
+ .replaceAll('--card-bg-color', bgColor)
65
+ .replace('{personImg}', trendImage)
40
66
  .replace('{trendImage}', trendImage)
41
67
  .replace('{trendTitle}', trend.title)
42
68
  .replace('{positionInfo}', positionInfo)
@@ -0,0 +1,2 @@
1
+ declare const generateShapeAvatar: (address: string, size?: number, scale?: number) => string;
2
+ export default generateShapeAvatar;
@@ -4,12 +4,27 @@ interface GeneratorOptions {
4
4
  timeout?: number;
5
5
  args?: string[];
6
6
  }
7
+ /**
8
+ * Options for a single image generation.
9
+ */
7
10
  interface GenerateOptions {
11
+ /** JPEG quality 1–100 (ignored for PNG). Default 85. */
8
12
  quality?: number;
13
+ /** Screenshot the full scrollable page instead of just the viewport. Default false. */
9
14
  fullPage?: boolean;
15
+ /** Wait for document.fonts.ready before taking the screenshot so webfonts are applied. Default true. */
10
16
  waitForFonts?: boolean;
17
+ /** Max ms to wait for content/font loading. Default 2000. */
11
18
  waitTimeout?: number;
19
+ /**
20
+ * When to consider the page content "loaded" before screenshot.
21
+ * - `domcontentloaded` – DOM ready, resources (images, fonts) may still load. Fastest. Default.
22
+ * - `load` – load event fired (images, stylesheets, etc. loaded).
23
+ * - `networkidle0` – no network requests for 500ms.
24
+ * - `networkidle2` – at most 2 network requests for 500ms.
25
+ */
12
26
  waitUntil?: 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
27
+ /** If true, do not add an extra delay for CSS animations. Default true. */
13
28
  skipAnimations?: boolean;
14
29
  }
15
30
  type GenerateProps<P> = {
package/lib/index.js CHANGED
@@ -180,7 +180,7 @@ function __generator(thisArg, body) {
180
180
  throw new Error('Invalid template: missing required properties');
181
181
  }
182
182
  width = template.width, height = template.height, type = template.type, getHtml = template.html;
183
- _d = options.quality, quality = _d === void 0 ? type === 'jpeg' ? 85 : undefined : _d, _e = options.fullPage, fullPage = _e === void 0 ? false : _e, _f = options.waitForFonts, waitForFonts = _f === void 0 ? true : _f, _g = options.waitTimeout, waitTimeout = _g === void 0 ? 2000 : _g, _h = options.waitUntil, waitUntil = _h === void 0 ? 'domcontentloaded' : _h, _j = options.skipAnimations, skipAnimations = _j === void 0 ? true : _j;
183
+ _d = options.quality, quality = _d === void 0 ? type === 'jpeg' ? 85 : undefined : _d, _e = options.fullPage, fullPage = _e === void 0 ? false : _e, _f = options.waitForFonts, waitForFonts = _f === void 0 ? true : _f, _g = options.waitTimeout, waitTimeout = _g === void 0 ? 2000 : _g, _h = options.waitUntil, waitUntil = _h === void 0 ? 'load' : _h, _j = options.skipAnimations, skipAnimations = _j === void 0 ? true : _j;
184
184
  _l.label = 7;
185
185
  case 7:
186
186
  _l.trys.push([7, 20, , 21]);
@@ -1,16 +1,15 @@
1
1
  import { type Template } from '../../utils';
2
- type Person = 'obama' | 'drake' | 'crash' | 'sydney' | 'tramp' | 'elon' | 'lewis' | 'mark' | 'powell' | 'macron' | 'arnold' | 'person-1' | 'tramp-2' | 'elon-2' | 'person-2' | 'taylor';
3
2
  export type Props = {
4
- type: Person;
3
+ accountAddress: string;
5
4
  trend: {
6
- image: string;
5
+ image: string | undefined;
7
6
  title: string;
8
7
  };
9
8
  position: {
10
9
  leverage: number;
11
10
  isLong: boolean;
12
- openLevel: number;
13
- exitLevel: number | undefined;
11
+ openLevel: string;
12
+ exitLevel: string | undefined;
14
13
  };
15
14
  pnl: number;
16
15
  };
@@ -4,8 +4,10 @@
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="preconnect" href="https://fonts.googleapis.com">
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
7
9
  <link
8
- href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&family=Mona+Sans:wdth,wght@75..125,700&display=swap"
10
+ href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;700&family=Inter:wght@500;600&family=Mona+Sans:wdth,wght@125,700&display=swap"
9
11
  rel="stylesheet">
10
12
  <style>
11
13
  html {
@@ -26,6 +28,13 @@
26
28
  font-style: normal;
27
29
  }
28
30
 
31
+ .geist-mono {
32
+ font-family: "Geist Mono", monospace;
33
+ font-optical-sizing: auto;
34
+ font-weight: 400;
35
+ font-style: normal;
36
+ }
37
+
29
38
  * {
30
39
  box-sizing: border-box;
31
40
  }
@@ -130,60 +139,40 @@
130
139
  text-transform: uppercase;
131
140
  }
132
141
 
142
+ .text-underline {
143
+ text-decoration: underline;
144
+ }
145
+
133
146
  .text-center {
134
147
  text-align: center;
135
148
  }
136
149
 
150
+ .text-bold {
151
+ font-weight: 700;
152
+ }
153
+
137
154
  .card {
138
155
  background: --card-bg-color;
139
156
  width: 1200px;
140
- height: 630px;
141
- padding: 48px;
157
+ height: 675px;
158
+ padding: 40px 36px 30px;
142
159
  position: relative;
160
+ color: white;
143
161
  }
144
162
 
145
163
  .logo {
146
- height: 38px;
147
- width: 266px;
164
+ height: 24px;
165
+ width: 156px;
148
166
  display: block;
149
- }
150
-
151
- .trend {
152
- /* margin-top: 108px; */
153
- }
154
-
155
- .trend__img {
156
- margin-right: 20px;
157
- width: 80px;
158
- height: 80px;
159
- border-radius: 100%;
160
- overflow: hidden;
161
- }
162
-
163
- .trend__img>img {
164
- width: 100%;
165
- }
166
-
167
- .trend__title {
168
- font-size: 32px;
169
- line-height: 100%;
170
- }
171
-
172
- .trend__badge {
173
- background-color: rgba(0, 0, 0, 0.2);
174
- padding: 6px 12px 8px 8px;
175
- border-radius: 5px;
176
- font-size: 24px;
177
- line-height: 100%;
178
- margin-top: 10px;
179
- width: fit-content;
167
+ margin-right: 45px;
180
168
  }
181
169
 
182
170
  .pnl {
183
- margin-top: 22px;
184
- font-size: 120px;
185
- line-height: 100%;
171
+ font-size: 72px;
172
+ line-height: 90%;
186
173
  font-weight: 700;
174
+ font-stretch: 125%;
175
+ color: --card-bg-color;
187
176
  }
188
177
 
189
178
  .right-img {
@@ -196,8 +185,10 @@
196
185
  .arrow {
197
186
  width: 24px;
198
187
  height: 24px;
199
- margin-top: 3px;
200
- margin-bottom: -3px;
188
+ margin-top: -4px;
189
+ margin-bottom: -4px;
190
+ margin-right: -4px;
191
+ margin-left: -6px;
201
192
  }
202
193
 
203
194
  .person-img {
@@ -208,67 +199,120 @@
208
199
  mix-blend-mode: multiply;
209
200
  }
210
201
 
211
- .bg-img {
212
- position: absolute;
213
- top: 0px;
214
- left: 0px;
215
- width: 100%;
202
+ .box {
203
+ background: #0F0F0F;
204
+ border-radius: 33px;
205
+ height: 100%;
206
+ width: fit-content;
207
+ padding: 30px 30px 55px;
208
+ min-width: 550px;
209
+ position: relative;
216
210
  }
217
211
 
218
- .level-wrapper {
212
+ .box-bottom {
219
213
  margin-top: 30px;
220
214
  }
221
215
 
222
- .level-title {
223
- opacity: 50%;
224
- color: #000000CC;
216
+ .wrapper {
217
+ width: 100%;
218
+ padding-top: 24px;
219
+ border-top: 1px solid #494949;
220
+ }
221
+
222
+ .wrapper+.wrapper {
223
+ margin-left: 24px;
224
+ }
225
+
226
+ .text {
225
227
  font-size: 24px;
226
228
  line-height: 100%;
227
229
  }
228
230
 
229
- .level-content {
230
- margin-top: 6px;
231
- font-size: 28px;
232
- line-height: 37.86px;
231
+ .text-gray {
232
+ color: #707070;
233
233
  }
234
234
 
235
- .level-box {
236
- margin-left: 125px;
235
+ .mt-45 {
236
+ margin-top: 45px;
237
+ }
238
+
239
+ .mt-12 {
240
+ margin-top: 12px;
241
+ }
242
+
243
+ .text-black {
244
+ color: #0F0F0F;
245
+ }
246
+
247
+ .account {
248
+ font-size: 30px;
249
+ line-height: 80%;
250
+ }
251
+
252
+ .avatar {
253
+ border: 1px solid #2A2A2A;
254
+ border-radius: 100%;
255
+ width: 64px;
256
+ height: 64px;
257
+ margin-right: 16px;
258
+ }
259
+
260
+ .avatar img {
261
+ width: 50%;
262
+ }
263
+
264
+ .text-semibold {
265
+ font-weight: 600;
266
+ }
267
+
268
+ .text-nowrap {
269
+ white-space: nowrap;
237
270
  }
238
271
  </style>
239
272
  </head>
240
273
 
241
274
  <body>
242
275
  <div class="card flex flex-col justify-between">
243
- <img class="bg-img" src={bgImg} alt="">
244
- <img class="right-img" src={rightImg} alt="">
245
- <img class="person-img" src={personImg} alt="">
246
- <img src="{logo}" class="logo" alt="">
247
- <div>
248
- <div class="trend flex items-center">
249
- <div class="trend__img flex items-center justify-center">
250
- <img src="{trendImage}" alt="">
251
- </div>
252
- <div>
253
- <div class="trend__title">{trendTitle}</div>
254
- <div class="trend__badge">
255
- <img class="arrow" src="{arrowImage}" alt="">
256
- <span>{positionInfo}</span>
257
- </div>
276
+ <img class="person-img" src={trendImage} alt="">
277
+ <div class="box flex flex-col justify-between">
278
+ <div class="flex items-center">
279
+ <div class="avatar flex items-center justify-center">
280
+ <img src="{avatar}" alt="">
258
281
  </div>
282
+ <div class="account">{account}</div>
259
283
  </div>
260
- <div class="pnl">{pnl}%</div>
261
- <div class="level-wrapper flex items-center">
262
- <div>
263
- <div class="level-title">Entry level:</div>
264
- <div class="level-content">{openLevel}</div>
284
+ <div>
285
+ <div class="wrapper flex justify-between">
286
+ <div class="pnl mona-sans">{pnl}%</div>
287
+ <div class="text text-gray">PnL</div>
265
288
  </div>
266
- <div class="level-box {exitLevelClass}">
267
- <div class="level-title">Exit level:</div>
268
- <div class="level-content">{exitLevel}</div>
289
+ <div class="flex mt-45 text">
290
+ <div class="wrapper">
291
+ <div class="text-semibold text-nowrap">{trendTitle}</div>
292
+ <div class="mt-12">
293
+ <img class="arrow" src="{arrowImage}" alt="">
294
+ <span class="text-gray">{positionInfo}</span>
295
+ </div>
296
+ </div>
297
+ <div class="wrapper">
298
+ <div class="flex justify-between">
299
+ <div class="text-gray">Entry:</div>
300
+ <div class="text-semibold">{openLevel}</div>
301
+ </div>
302
+ <div class="flex justify-between mt-12 {exitLevelClass}">
303
+ <div class="text-gray">Exit:</div>
304
+ <div class="text-semibold">{exitLevel}</div>
305
+ </div>
306
+ </div>
269
307
  </div>
270
308
  </div>
271
309
  </div>
310
+ <div class="box-bottom flex items-end">
311
+ <img src="{logo}" class="logo" alt="">
312
+ <div class="text-upper geist-mono text-black">trade attention on <span
313
+ class="text-underline text-bold">Trendle.fi</span>
314
+ </div>
315
+ </div>
272
316
  </div>
273
317
  </body>
274
318
 
@@ -1,10 +1,31 @@
1
- 'use strict';var index=require('../../index-efa024cc.js'),path=require('path');require('fs'),require('util'),require('stream'),require('http'),require('https'),require('url'),require('crypto'),require('http2'),require('assert'),require('tty'),require('zlib'),require('events');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var cardTypes = {
1
+ 'use strict';var index=require('../../index-efa024cc.js'),path=require('path');require('fs'),require('util'),require('stream'),require('http'),require('https'),require('url'),require('crypto'),require('http2'),require('assert'),require('tty'),require('zlib'),require('events');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var hashCode = function (str) {
2
+ return Array.from(str).reduce(function (hash, c) { return (hash << 5) - hash + c.charCodeAt(0); }, 0);
3
+ };
4
+ var generateShapeAvatar = function (address, size, scale) {
5
+ if (size === void 0) { size = 6; }
6
+ if (scale === void 0) { scale = 10; }
7
+ var hash = Math.abs(hashCode(address.toLowerCase()));
8
+ var color = "hsl(".concat(hash % 360, ", 60%, 55%)");
9
+ var svg = "<svg xmlns='http://www.w3.org/2000/svg' width='".concat(size * scale, "' height='").concat(size * scale, "'>");
10
+ for (var y = 0; y < size; y++) {
11
+ for (var x = 0; x < Math.ceil(size / 2); x++) {
12
+ if (((hash >> (x + y * size)) & 1) === 1) {
13
+ var rx = x * scale;
14
+ var ry = y * scale;
15
+ var symX = (size - x - 1) * scale;
16
+ svg += "<rect x='".concat(rx, "' y='").concat(ry, "' width='").concat(scale, "' height='").concat(scale, "' fill='").concat(color, "'/>");
17
+ svg += "<rect x='".concat(symX, "' y='").concat(ry, "' width='").concat(scale, "' height='").concat(scale, "' fill='").concat(color, "'/>");
18
+ }
19
+ }
20
+ }
21
+ svg += '</svg>';
22
+ var avatar = "data:image/svg+xml;utf8,".concat(encodeURIComponent(svg));
23
+ return avatar;
24
+ };var cardTypes = {
2
25
  'profit': {
3
- rightImg: 'images/profit.png',
4
26
  bgColor: '#72FF4B',
5
27
  },
6
28
  'loss': {
7
- rightImg: 'images/loss.png',
8
29
  bgColor: '#FF604B',
9
30
  }
10
31
  };
@@ -13,30 +34,35 @@ var template = {
13
34
  height: 630,
14
35
  type: 'jpeg',
15
36
  html: function (props) { return index._(void 0, void 0, void 0, function () {
16
- var type, trend, pnl, position, isProfit, _a, rightImg, bgColor, leverage, isLong, openLevel, exitLevel, html, logo, bgImage, rightImage, personImage, arrowImage, trendImage, positionInfo;
37
+ var accountAddress, trend, pnl, position, isProfit, bgColor, leverage, isLong, openLevel, exitLevel, html, logo, arrowImage, trendImage, _a, positionInfo, avatar;
17
38
  return index.a(this, function (_b) {
18
39
  switch (_b.label) {
19
40
  case 0:
20
- type = props.type, trend = props.trend, pnl = props.pnl, position = props.position;
41
+ accountAddress = props.accountAddress, trend = props.trend, pnl = props.pnl, position = props.position;
21
42
  isProfit = pnl > 0;
22
- _a = isProfit ? cardTypes.profit : cardTypes.loss, rightImg = _a.rightImg, bgColor = _a.bgColor;
43
+ bgColor = (isProfit ? cardTypes.profit : cardTypes.loss).bgColor;
23
44
  leverage = position.leverage, isLong = position.isLong, openLevel = position.openLevel, exitLevel = position.exitLevel;
24
45
  html = index.g(path__default["default"].join(__dirname, 'index.html'));
25
46
  logo = index.b(path__default["default"].resolve(__dirname, 'images/logo.png'));
26
- bgImage = index.b(path__default["default"].resolve(__dirname, 'images/bg.png'));
27
- rightImage = index.b(path__default["default"].resolve(__dirname, rightImg));
28
- personImage = index.b(path__default["default"].resolve(__dirname, "images/".concat(type, ".png")));
29
47
  arrowImage = index.b(path__default["default"].resolve(__dirname, isLong ? 'images/arrow-up.png' : 'images/arrow-down.png'));
48
+ if (!trend.image) return [3 /*break*/, 2];
30
49
  return [4 /*yield*/, index.d(trend.image)];
31
50
  case 1:
32
- trendImage = _b.sent();
33
- positionInfo = "".concat(isLong ? ' Up' : ' Down', ", Boost x").concat(leverage);
51
+ _a = _b.sent();
52
+ return [3 /*break*/, 3];
53
+ case 2:
54
+ _a = index.b(path__default["default"].resolve(__dirname, 'images/default.png'));
55
+ _b.label = 3;
56
+ case 3:
57
+ trendImage = _a;
58
+ positionInfo = "".concat(isLong ? 'Up' : 'Down', ", X").concat(leverage, " Boost");
59
+ avatar = generateShapeAvatar(accountAddress);
34
60
  return [2 /*return*/, html
35
61
  .replace('{logo}', logo)
36
- .replace('--card-bg-color', bgColor)
37
- .replace('{bgImg}', bgImage)
38
- .replace('{rightImg}', rightImage)
39
- .replace('{personImg}', personImage)
62
+ .replace('{account}', "".concat(accountAddress.substr(0, 6), "...").concat(accountAddress.substr(-1 * 6)))
63
+ .replace('{avatar}', avatar)
64
+ .replaceAll('--card-bg-color', bgColor)
65
+ .replace('{personImg}', trendImage)
40
66
  .replace('{trendImage}', trendImage)
41
67
  .replace('{trendTitle}', trend.title)
42
68
  .replace('{positionInfo}', positionInfo)
@@ -0,0 +1,2 @@
1
+ declare const generateShapeAvatar: (address: string, size?: number, scale?: number) => string;
2
+ export default generateShapeAvatar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azuro-org/images-generator",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "license": "ISC",
5
5
  "engines": {
6
6
  "node": ">=16.15.1",
package/tsconfig.json CHANGED
@@ -4,7 +4,12 @@
4
4
  "target": "es5",
5
5
  "module": "esnext",
6
6
  "moduleResolution": "node",
7
- "lib": [ "es2017", "es7", "es6", "dom" ],
7
+ "lib": [
8
+ "es2021",
9
+ "es7",
10
+ "es6",
11
+ "dom"
12
+ ],
8
13
  "strict": true,
9
14
  "declaration": true,
10
15
  "esModuleInterop": true