@azuro-org/images-generator 1.2.0 → 1.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/dist/index-82868da9.js +19637 -0
- package/dist/index.es.js +1 -4
- package/dist/templates/_template/index.d.ts +1 -1
- package/dist/templates/bet-nft/index.d.ts +1 -1
- package/dist/templates/bet-nft/index.html +0 -1
- package/dist/templates/bet-nft/index.js +1 -1
- package/dist/templates/bet-og/index.d.ts +1 -1
- package/dist/templates/bet-og/index.js +1 -1
- package/dist/templates/combo-bet-og/index.d.ts +1 -1
- package/dist/templates/combo-bet-og/index.js +1 -1
- package/dist/templates/freebet/index.d.ts +1 -1
- package/dist/templates/freebet/index.js +1 -1
- package/dist/templates/trendle-social/images/bg.png +0 -0
- package/dist/templates/trendle-social/images/business.png +0 -0
- package/dist/templates/trendle-social/images/crypto.png +0 -0
- package/dist/templates/trendle-social/images/culture.png +0 -0
- package/dist/templates/trendle-social/images/fomo.png +0 -0
- package/dist/templates/trendle-social/images/logo.png +0 -0
- package/dist/templates/trendle-social/images/politics.png +0 -0
- package/dist/templates/trendle-social/index.d.ts +35 -0
- package/dist/templates/trendle-social/index.html +217 -0
- package/dist/templates/trendle-social/index.js +57 -0
- package/dist/templates/trendle-trading/images/arrow-down.png +0 -0
- package/dist/templates/trendle-trading/images/arrow-up.png +0 -0
- package/dist/templates/trendle-trading/images/logo.png +0 -0
- package/dist/templates/trendle-trading/images/loss.png +0 -0
- package/dist/templates/trendle-trading/images/profit.png +0 -0
- package/dist/templates/trendle-trading/index.d.ts +15 -0
- package/dist/templates/trendle-trading/index.html +233 -0
- package/dist/templates/trendle-trading/index.js +47 -0
- package/dist/utils/generateImage.d.ts +4 -8
- package/dist/utils/types.d.ts +2 -2
- package/lib/index-de0b52f4.js +19637 -0
- package/lib/index.js +1 -4
- package/lib/templates/_template/index.d.ts +1 -1
- package/lib/templates/bet-nft/index.d.ts +1 -1
- package/lib/templates/bet-nft/index.html +0 -1
- package/lib/templates/bet-nft/index.js +1 -1
- package/lib/templates/bet-og/index.d.ts +1 -1
- package/lib/templates/bet-og/index.js +2 -2
- package/lib/templates/combo-bet-og/index.d.ts +1 -1
- package/lib/templates/combo-bet-og/index.js +1 -1
- package/lib/templates/freebet/index.d.ts +1 -1
- package/lib/templates/freebet/index.js +1 -1
- package/lib/templates/trendle-social/images/bg.png +0 -0
- package/lib/templates/trendle-social/images/business.png +0 -0
- package/lib/templates/trendle-social/images/crypto.png +0 -0
- package/lib/templates/trendle-social/images/culture.png +0 -0
- package/lib/templates/trendle-social/images/fomo.png +0 -0
- package/lib/templates/trendle-social/images/logo.png +0 -0
- package/lib/templates/trendle-social/images/politics.png +0 -0
- package/lib/templates/trendle-social/index.d.ts +35 -0
- package/lib/templates/trendle-social/index.html +217 -0
- package/lib/templates/trendle-social/index.js +57 -0
- package/lib/templates/trendle-trading/images/arrow-down.png +0 -0
- package/lib/templates/trendle-trading/images/arrow-up.png +0 -0
- package/lib/templates/trendle-trading/images/logo.png +0 -0
- package/lib/templates/trendle-trading/images/loss.png +0 -0
- package/lib/templates/trendle-trading/images/profit.png +0 -0
- package/lib/templates/trendle-trading/index.d.ts +15 -0
- package/lib/templates/trendle-trading/index.html +233 -0
- package/lib/templates/trendle-trading/index.js +47 -0
- package/lib/utils/generateImage.d.ts +4 -8
- package/lib/utils/types.d.ts +2 -2
- package/package.json +4 -3
- package/tsconfig.json +3 -0
- package/dist/index-cd3884c7.js +0 -4216
- package/lib/index-9642de53.js +0 -4216
|
@@ -0,0 +1,233 @@
|
|
|
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
|
+
.bg {
|
|
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
|
+
</style>
|
|
207
|
+
</head>
|
|
208
|
+
<body>
|
|
209
|
+
<div class="card flex flex-col justify-between">
|
|
210
|
+
<img class="bg" src={bgImage} alt="">
|
|
211
|
+
<img src="{logo}" class="logo" alt="">
|
|
212
|
+
<div>
|
|
213
|
+
<div class="trend flex items-center">
|
|
214
|
+
<div class="trend__img flex items-center justify-center">
|
|
215
|
+
<img src="{trendImage}" alt="">
|
|
216
|
+
</div>
|
|
217
|
+
<div>
|
|
218
|
+
<div class="trend__title">{trendTitle}</div>
|
|
219
|
+
<div class="trend__badge">
|
|
220
|
+
<img class="arrow" src="{arrowImage}" alt="">
|
|
221
|
+
<span>{positionInfo}</span>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
<div class="pnl">{pnl}%</div>
|
|
226
|
+
</div>
|
|
227
|
+
<div class="code">
|
|
228
|
+
<div class="code__text">Referral code</div>
|
|
229
|
+
<div class="code__link">{refferalLink}</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
</body>
|
|
233
|
+
</html>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';var index=require('../../index-de0b52f4.js'),path=require('path');require('fs'),require('util'),require('stream'),require('http'),require('https'),require('url'),require('crypto'),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 = {
|
|
2
|
+
'profit': {
|
|
3
|
+
bg: 'images/profit.png',
|
|
4
|
+
arrow: 'images/arrow-up.png',
|
|
5
|
+
bgColor: '#72FF4B',
|
|
6
|
+
},
|
|
7
|
+
'loss': {
|
|
8
|
+
bg: '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 index._(void 0, void 0, void 0, function () {
|
|
18
|
+
var trend, pnl, position, referralUrl, isProfit, _a, bg, arrow, bgColor, leverage, isLong, html, logo, bgImage, arrowImage, trendImage, positionInfo;
|
|
19
|
+
return index.a(this, function (_b) {
|
|
20
|
+
switch (_b.label) {
|
|
21
|
+
case 0:
|
|
22
|
+
trend = props.trend, pnl = props.pnl, position = props.position, referralUrl = props.referralUrl;
|
|
23
|
+
isProfit = pnl > 0;
|
|
24
|
+
_a = isProfit ? cardTypes.profit : cardTypes.loss, bg = _a.bg, arrow = _a.arrow, bgColor = _a.bgColor;
|
|
25
|
+
leverage = position.leverage, isLong = position.isLong;
|
|
26
|
+
html = index.g(path__default["default"].join(__dirname, 'index.html'));
|
|
27
|
+
logo = index.b(path__default["default"].resolve(__dirname, 'images/logo.png'));
|
|
28
|
+
bgImage = index.b(path__default["default"].resolve(__dirname, bg));
|
|
29
|
+
arrowImage = index.b(path__default["default"].resolve(__dirname, arrow));
|
|
30
|
+
return [4 /*yield*/, index.d(trend.image)];
|
|
31
|
+
case 1:
|
|
32
|
+
trendImage = _b.sent();
|
|
33
|
+
positionInfo = "".concat(isLong ? ' Up' : ' Down', ", Boost x").concat(leverage);
|
|
34
|
+
return [2 /*return*/, html
|
|
35
|
+
.replace('{logo}', logo)
|
|
36
|
+
.replace('--card-bg-color', bgColor)
|
|
37
|
+
.replace('{bgImage}', bgImage)
|
|
38
|
+
.replace('{trendImage}', trendImage)
|
|
39
|
+
.replace('{trendTitle}', trend.title)
|
|
40
|
+
.replace('{positionInfo}', positionInfo)
|
|
41
|
+
.replace('{arrowImage}', arrowImage)
|
|
42
|
+
.replace('{refferalLink}', referralUrl)
|
|
43
|
+
.replace('{pnl}', pnl > 0 ? "+".concat(pnl) : "".concat(pnl))];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}); }
|
|
47
|
+
};module.exports=template;
|
|
@@ -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
|
|
11
|
-
|
|
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:
|
|
13
|
+
props: P;
|
|
18
14
|
modifyPuppeteerOptions?(options: PuppeteerInitialOptions): PuppeteerOptions;
|
|
19
15
|
};
|
|
20
|
-
export default function generateImage<
|
|
16
|
+
export default function generateImage<P>(props: GenerateImageProps<P>): Promise<Uint8Array | undefined>;
|
|
21
17
|
export {};
|
package/lib/utils/types.d.ts
CHANGED
|
@@ -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:
|
|
7
|
+
html: (props: Props) => string | Promise<string>;
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/images-generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.1",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"main": "lib/index.js",
|
|
11
11
|
"types": "lib/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "rimraf ./test/images &&
|
|
13
|
+
"test": "rimraf ./test/images && tsx ./test/index.ts",
|
|
14
14
|
"dev": "rollup -c ./rollup.config.js -w",
|
|
15
15
|
"build": "rimraf ./dist && rimraf ./lib && rollup -c ./rollup.config.js --compact",
|
|
16
16
|
"build-and-test": "npm run build && npm run test",
|
|
17
17
|
"prepublishOnly": "npm run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"axios": "^
|
|
20
|
+
"axios": "^1.12.2",
|
|
21
21
|
"builtin-modules": "^3.2.0",
|
|
22
22
|
"dayjs": "^1.11.7",
|
|
23
23
|
"puppeteer": "^24.4.0"
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"rollup-plugin-copy": "^3.4.0",
|
|
43
43
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
44
44
|
"tslib": "^2.4.1",
|
|
45
|
+
"tsx": "^4.20.6",
|
|
45
46
|
"typescript": "^4.6.2"
|
|
46
47
|
}
|
|
47
48
|
}
|