@azuro-org/images-generator 0.0.4 → 1.0.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.
package/README.md CHANGED
@@ -4,25 +4,10 @@
4
4
 
5
5
  ```typescript
6
6
  import { generateImage } from '@azuro-org/images-generator';
7
- import template, { type Props } from '@azuro-org/images-generator/dist/templates/bet-nft';
7
+ import template, { type Props } from '@azuro-org/images-generator/lib/templates/bet-nft';
8
8
 
9
9
  const props: Props = {
10
- type: 'match',
11
- sport: 'soccer',
12
- league: 'Leinster Senior League Senior Division',
13
- team1: {
14
- img: 'https://content.bookieratings.net/images/fq/tx/fqtxnf_20181001112329_100x100.png',
15
- name: 'Nizhny Novgorod'
16
- },
17
- team2: {
18
- img: 'https://content.bookieratings.net/images/fq/tx/fqtxnf_20181001112329_100x100.png',
19
- name: 'Lokomotiv Moscow'
20
- },
21
- date: '21.03.2022 8:00 UTC',
22
- betAmount: '100 USDC',
23
- outcome: 'Total Under(2.5)',
24
- betOdds: '2.88',
25
- currentOdds: '1.88'
10
+ // ...
26
11
  }
27
12
 
28
13
  // get image buffer
@@ -41,7 +26,7 @@ generateImage({
41
26
 
42
27
  ## Options
43
28
 
44
- ```
29
+ ```typescript
45
30
  type PuppeteerOptions = Parameters<typeof puppeteer.launch>[0]
46
31
 
47
32
  type PuppeteerInitialOptions = {
@@ -59,6 +44,112 @@ generateImage({
59
44
  ```
60
45
 
61
46
 
47
+ # Examples
48
+
49
+ <details>
50
+ <summary><h3>Bet Opengraph</h3></summary>
51
+ <p>
52
+
53
+ ```typescript
54
+ import { generateImage } from '@azuro-org/images-generator';
55
+ import template from '@azuro-org/images-generator/lib/templates/bet-og';
56
+
57
+ generateImage({
58
+ template,
59
+ props: {
60
+ title: 'Decentralized betting is awesome!',
61
+ game: {
62
+ country: 'International Tournaments',
63
+ league: 'ESL Challenger League North America',
64
+ participants: [
65
+ {
66
+ name: 'WINDINGO',
67
+ image: 'https://content.bookmaker.xyz/avatars/provider-3/4757.png',
68
+ },
69
+ {
70
+ name: 'Los Grandes Academy',
71
+ image: 'https://content.bookmaker.xyz/avatars/provider-3/4739.png',
72
+ },
73
+ ],
74
+ startsAt: Date.now(),
75
+ }
76
+ },
77
+ })
78
+ ```
79
+
80
+ ### Result
81
+
82
+ <p>
83
+ <img src="./src/templates/bet-og/example.jpeg" width="600" />
84
+ </p>
85
+ </p>
86
+ </details>
87
+
88
+ <details>
89
+ <summary><h3>Bet NFT</h3></summary>
90
+ <p>
91
+
92
+ ```typescript
93
+ import { generateImage } from '@azuro-org/images-generator';
94
+ import template from '@azuro-org/images-generator/lib/templates/bet-nft';
95
+
96
+ generateImage({
97
+ template,
98
+ props: {
99
+ type: 'match',
100
+ sport: 'Football',
101
+ league: 'International Tournaments · FIFA - World Cup',
102
+ team1: {
103
+ img: 'https://content.bookmaker.xyz/avatars/provider-3/4757.png',
104
+ name: 'Ecuador',
105
+ },
106
+ team2: {
107
+ img: 'https://content.bookmaker.xyz/avatars/provider-3/4739.png',
108
+ name: 'Senegal',
109
+ },
110
+ date: 'Dec 24, 2020',
111
+ betAmount: '100 xDAI',
112
+ outcome: 'Senegal',
113
+ betOdds: '1.7',
114
+ currentOdds: '1.2',
115
+ },
116
+ })
117
+ ```
118
+
119
+ ### Result
120
+
121
+ <p>
122
+ <img src="./src/templates/bet-nft/example.png" width="255" />
123
+ </p>
124
+ </p>
125
+ </details>
126
+
127
+ <details>
128
+ <summary><h3>Bet Opengraph</h3></summary>
129
+ <p>
130
+
131
+ ```typescript
132
+ import { generateImage } from '@azuro-org/images-generator';
133
+ import template from '@azuro-org/images-generator/lib/templates/freebet';
134
+
135
+ generateImage({
136
+ template,
137
+ props: {
138
+ amount: 5,
139
+ date: '12.01.2022',
140
+ },
141
+ })
142
+ ```
143
+
144
+ ### Result
145
+
146
+ <p>
147
+ <img src="./src/templates/freebet/example.png" width="416" />
148
+ </p>
149
+ </p>
150
+ </details>
151
+
152
+
62
153
  # Contributing
63
154
 
64
155
  ## Add new template
@@ -73,6 +164,8 @@ generateImage({
73
164
  Edit `{your_template_name}/index.ts` file:
74
165
 
75
166
  ```typescript
167
+ import path from 'path'
168
+
76
169
  import { type Template, getFile, downloadImage, createGenerator } from '../../utils'
77
170
 
78
171
  export type Props = {
@@ -88,14 +181,12 @@ const template = {
88
181
  html: async (props: Props) => {
89
182
  const { team1ImageSrc, team2ImageSrc, date } = props
90
183
 
91
- let html = getFile('./index.html')
92
- let css = getFile('./index.css')
184
+ const html = getFile(path.join(__dirname, 'index.html'))
93
185
 
94
186
  const team1Img = await downloadImage(team1ImageSrc)
95
187
  const team2Img = await downloadImage(team2ImageSrc)
96
188
 
97
189
  return html
98
- .replace('.style{}', css)
99
190
  .replace('{image1}', team1Img)
100
191
  .replace('{image2}', team2Img)
101
192
  .replace('{date}', date)
@@ -105,14 +196,6 @@ const template = {
105
196
  export default template
106
197
  ```
107
198
 
108
-
109
- ## `createGenerator` options
110
-
111
- `type: 'png' | 'jpeg'`<br /><br />
112
- `headless: Boolean` - use true to see compiled html in browser<br /><br />
113
- `scaleFactor: 1 | 2` - use 2 if you need to generate x2 sized image
114
-
115
-
116
199
  ## Publish
117
200
 
118
201
  Publish npm package with `npm run publish`. For access to `@azuro-org` scope ask Pavel Ivanov or Stas Onatskiy.
@@ -1,4 +1,4 @@
1
- import fs from'fs';import path from'path';import require$$1$1 from'http';import require$$2 from'https';import require$$0$2 from'url';import require$$3 from'stream';import require$$4 from'assert';import require$$0$1 from'tty';import require$$1 from'util';import require$$0 from'os';import require$$8 from'zlib';/******************************************************************************
1
+ import fs from'fs';import require$$1$1 from'http';import require$$2 from'https';import require$$0$2 from'url';import require$$3 from'stream';import require$$4 from'assert';import require$$0$1 from'tty';import require$$1 from'util';import require$$0 from'os';import require$$8 from'zlib';/******************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -4164,14 +4164,11 @@ axios$2.exports.default = axios$1;(function (module) {
4164
4164
  module.exports = axios$2.exports;
4165
4165
  } (axios$3));
4166
4166
 
4167
- var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);var getPath = function (filePath) {
4168
- return path.join(__dirname, filePath);
4169
- };
4170
- var getFile = function (filePath) {
4171
- return fs.readFileSync(getPath(filePath), 'utf8');
4167
+ var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);var getFile = function (filePath) {
4168
+ return fs.readFileSync(filePath, 'utf8');
4172
4169
  };
4173
4170
  var getBase64Image = function (filePath) {
4174
- return "data:image/png;base64,".concat(fs.readFileSync(getPath(filePath)).toString('base64'));
4171
+ return "data:image/png;base64,".concat(fs.readFileSync(filePath).toString('base64'));
4175
4172
  };
4176
4173
  var downloadImage = function (url) { return __awaiter(void 0, void 0, void 0, function () {
4177
4174
  var base64, response, buffer, err_1;
@@ -1,4 +1,4 @@
1
- import {_ as __awaiter,a as __generator,d as downloadImage,g as getFile,b as getBase64Image}from'../../index-13c8d604.js';import path from'path';import'fs';import'http';import'https';import'url';import'stream';import'assert';import'tty';import'util';import'os';import'zlib';var matchType = {
1
+ import {_ as __awaiter,a as __generator,d as downloadImage,g as getFile,b as getBase64Image}from'../../index-401c8546.js';import path from'path';import'fs';import'http';import'https';import'url';import'stream';import'assert';import'tty';import'util';import'os';import'zlib';var matchType = {
2
2
  'match': 'Waiting for match',
3
3
  'claim': 'Waiting for claim',
4
4
  'claimed': 'Claimed',
@@ -1,4 +1,4 @@
1
- import {c as commonjsGlobal,_ as __awaiter,a as __generator,g as getFile,b as getBase64Image}from'../../index-13c8d604.js';import path from'path';import'fs';import'http';import'https';import'url';import'stream';import'assert';import'tty';import'util';import'os';import'zlib';var dayjs_min = {exports: {}};(function (module, exports) {
1
+ import {c as commonjsGlobal,_ as __awaiter,a as __generator,g as getFile,b as getBase64Image}from'../../index-401c8546.js';import path from'path';import'fs';import'http';import'https';import'url';import'stream';import'assert';import'tty';import'util';import'os';import'zlib';var dayjs_min = {exports: {}};(function (module, exports) {
2
2
  !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
3
3
  } (dayjs_min));
4
4
 
@@ -0,0 +1,7 @@
1
+ import { type Template } from '../../utils';
2
+ export type Props = {
3
+ amount: number | string;
4
+ date: string;
5
+ };
6
+ declare const template: Template;
7
+ export default template;
@@ -0,0 +1,62 @@
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="//raw.githubusercontent.com/Azuro-protocol/public-assets/main/fonts/fivo-sans-modern/style.css" rel="stylesheet" />
7
+ <style>
8
+ html, body {
9
+ width: 416px;
10
+ height: 250px;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+
15
+ .image {
16
+ width: 416px;
17
+ height: 250px;
18
+ padding-top: 75px;
19
+ padding-left: 30px;
20
+ font-family: 'Fivo Sans Modern';
21
+ font-weight: 700;
22
+ background-size: cover;
23
+ background-position: center;
24
+ overflow: hidden;
25
+ border-radius: 10px;
26
+ }
27
+
28
+ .amount {
29
+ font-size: 48px;
30
+ line-height: 50px;
31
+ }
32
+
33
+ .text-gradient {
34
+ background: linear-gradient(271.45deg, #FCBD89 -22.37%, #B78EFF 34.63%, #82FCF4 117.18%), #FFFFFF;
35
+ -webkit-background-clip: text;
36
+ -webkit-text-fill-color: transparent;
37
+ background-clip: text;
38
+ text-fill-color: transparent;
39
+ }
40
+
41
+ .amount span {
42
+ color: #fff;
43
+ }
44
+
45
+ .date {
46
+ margin-top: 8px;
47
+ font-size: 16px;
48
+ line-height: 110%;
49
+ color: #6EE0A3;
50
+ }
51
+ </style>
52
+ </head>
53
+ <body>
54
+ <div class="image" style="background-image: url({bgImage});">
55
+ <div class="amount">
56
+ <div class="text-gradient">{amount} xDAI</div>
57
+ <span>freebet!</span>
58
+ </div>
59
+ <div class="date">Valid until {date}</div>
60
+ </div>
61
+ </body>
62
+ </html>
@@ -0,0 +1,18 @@
1
+ import {_ as __awaiter,a as __generator,g as getFile,b as getBase64Image}from'../../index-401c8546.js';import path from'path';import'fs';import'http';import'https';import'url';import'stream';import'assert';import'tty';import'util';import'os';import'zlib';var template = {
2
+ width: 416,
3
+ height: 250,
4
+ type: 'png',
5
+ scaleFactor: 2,
6
+ html: function (props) { return __awaiter(void 0, void 0, void 0, function () {
7
+ var amount, date, html, bgImage;
8
+ return __generator(this, function (_a) {
9
+ amount = props.amount, date = props.date;
10
+ html = getFile(path.resolve(__dirname, 'index.html'));
11
+ bgImage = getBase64Image(path.resolve(__dirname, 'images/bg.png'));
12
+ return [2 /*return*/, html
13
+ .replace('{bgImage}', bgImage)
14
+ .replace('{amount}', String(amount))
15
+ .replace('{date}', date)];
16
+ });
17
+ }); }
18
+ };export{template as default};
@@ -1,4 +1,3 @@
1
- export declare const getPath: (filePath: string) => string;
2
1
  export declare const getFile: (filePath: string) => string;
3
2
  export declare const getBase64Image: (filePath: string) => string;
4
3
  export declare const downloadImage: (url: string) => Promise<string>;
@@ -1,4 +1,4 @@
1
- 'use strict';var fs=require('fs'),path=require('path'),require$$1$1=require('http'),require$$2=require('https'),require$$0$2=require('url'),require$$3=require('stream'),require$$4=require('assert'),require$$0$1=require('tty'),require$$1=require('util'),require$$0=require('os'),require$$8=require('zlib');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var require$$1__default$1=/*#__PURE__*/_interopDefaultLegacy(require$$1$1);var require$$2__default=/*#__PURE__*/_interopDefaultLegacy(require$$2);var require$$0__default$2=/*#__PURE__*/_interopDefaultLegacy(require$$0$2);var require$$3__default=/*#__PURE__*/_interopDefaultLegacy(require$$3);var require$$4__default=/*#__PURE__*/_interopDefaultLegacy(require$$4);var require$$0__default$1=/*#__PURE__*/_interopDefaultLegacy(require$$0$1);var require$$1__default=/*#__PURE__*/_interopDefaultLegacy(require$$1);var require$$0__default=/*#__PURE__*/_interopDefaultLegacy(require$$0);var require$$8__default=/*#__PURE__*/_interopDefaultLegacy(require$$8);/******************************************************************************
1
+ 'use strict';var fs=require('fs'),require$$1$1=require('http'),require$$2=require('https'),require$$0$2=require('url'),require$$3=require('stream'),require$$4=require('assert'),require$$0$1=require('tty'),require$$1=require('util'),require$$0=require('os'),require$$8=require('zlib');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var require$$1__default$1=/*#__PURE__*/_interopDefaultLegacy(require$$1$1);var require$$2__default=/*#__PURE__*/_interopDefaultLegacy(require$$2);var require$$0__default$2=/*#__PURE__*/_interopDefaultLegacy(require$$0$2);var require$$3__default=/*#__PURE__*/_interopDefaultLegacy(require$$3);var require$$4__default=/*#__PURE__*/_interopDefaultLegacy(require$$4);var require$$0__default$1=/*#__PURE__*/_interopDefaultLegacy(require$$0$1);var require$$1__default=/*#__PURE__*/_interopDefaultLegacy(require$$1);var require$$0__default=/*#__PURE__*/_interopDefaultLegacy(require$$0);var require$$8__default=/*#__PURE__*/_interopDefaultLegacy(require$$8);/******************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -4164,14 +4164,11 @@ axios$2.exports.default = axios$1;(function (module) {
4164
4164
  module.exports = axios$2.exports;
4165
4165
  } (axios$3));
4166
4166
 
4167
- var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);var getPath = function (filePath) {
4168
- return path__default["default"].join(__dirname, filePath);
4169
- };
4170
- var getFile = function (filePath) {
4171
- return fs__default["default"].readFileSync(getPath(filePath), 'utf8');
4167
+ var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);var getFile = function (filePath) {
4168
+ return fs__default["default"].readFileSync(filePath, 'utf8');
4172
4169
  };
4173
4170
  var getBase64Image = function (filePath) {
4174
- return "data:image/png;base64,".concat(fs__default["default"].readFileSync(getPath(filePath)).toString('base64'));
4171
+ return "data:image/png;base64,".concat(fs__default["default"].readFileSync(filePath).toString('base64'));
4175
4172
  };
4176
4173
  var downloadImage = function (url) { return __awaiter(void 0, void 0, void 0, function () {
4177
4174
  var base64, response, buffer, err_1;
@@ -1,4 +1,4 @@
1
- 'use strict';var index=require('../../index-b34515b6.js'),path=require('path');require('fs'),require('http'),require('https'),require('url'),require('stream'),require('assert'),require('tty'),require('util'),require('os'),require('zlib');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var matchType = {
1
+ 'use strict';var index=require('../../index-7f0cb09b.js'),path=require('path');require('fs'),require('http'),require('https'),require('url'),require('stream'),require('assert'),require('tty'),require('util'),require('os'),require('zlib');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var matchType = {
2
2
  'match': 'Waiting for match',
3
3
  'claim': 'Waiting for claim',
4
4
  'claimed': 'Claimed',
@@ -1,4 +1,4 @@
1
- 'use strict';var index=require('../../index-b34515b6.js'),path=require('path');require('fs'),require('http'),require('https'),require('url'),require('stream'),require('assert'),require('tty'),require('util'),require('os'),require('zlib');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var dayjs_min = {exports: {}};(function (module, exports) {
1
+ 'use strict';var index=require('../../index-7f0cb09b.js'),path=require('path');require('fs'),require('http'),require('https'),require('url'),require('stream'),require('assert'),require('tty'),require('util'),require('os'),require('zlib');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var dayjs_min = {exports: {}};(function (module, exports) {
2
2
  !function(t,e){module.exports=e();}(index.c,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
3
3
  } (dayjs_min));
4
4
 
@@ -0,0 +1,7 @@
1
+ import { type Template } from '../../utils';
2
+ export type Props = {
3
+ amount: number | string;
4
+ date: string;
5
+ };
6
+ declare const template: Template;
7
+ export default template;
@@ -0,0 +1,62 @@
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="//raw.githubusercontent.com/Azuro-protocol/public-assets/main/fonts/fivo-sans-modern/style.css" rel="stylesheet" />
7
+ <style>
8
+ html, body {
9
+ width: 416px;
10
+ height: 250px;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+
15
+ .image {
16
+ width: 416px;
17
+ height: 250px;
18
+ padding-top: 75px;
19
+ padding-left: 30px;
20
+ font-family: 'Fivo Sans Modern';
21
+ font-weight: 700;
22
+ background-size: cover;
23
+ background-position: center;
24
+ overflow: hidden;
25
+ border-radius: 10px;
26
+ }
27
+
28
+ .amount {
29
+ font-size: 48px;
30
+ line-height: 50px;
31
+ }
32
+
33
+ .text-gradient {
34
+ background: linear-gradient(271.45deg, #FCBD89 -22.37%, #B78EFF 34.63%, #82FCF4 117.18%), #FFFFFF;
35
+ -webkit-background-clip: text;
36
+ -webkit-text-fill-color: transparent;
37
+ background-clip: text;
38
+ text-fill-color: transparent;
39
+ }
40
+
41
+ .amount span {
42
+ color: #fff;
43
+ }
44
+
45
+ .date {
46
+ margin-top: 8px;
47
+ font-size: 16px;
48
+ line-height: 110%;
49
+ color: #6EE0A3;
50
+ }
51
+ </style>
52
+ </head>
53
+ <body>
54
+ <div class="image" style="background-image: url({bgImage});">
55
+ <div class="amount">
56
+ <div class="text-gradient">{amount} xDAI</div>
57
+ <span>freebet!</span>
58
+ </div>
59
+ <div class="date">Valid until {date}</div>
60
+ </div>
61
+ </body>
62
+ </html>
@@ -0,0 +1,18 @@
1
+ 'use strict';var index=require('../../index-7f0cb09b.js'),path=require('path');require('fs'),require('http'),require('https'),require('url'),require('stream'),require('assert'),require('tty'),require('util'),require('os'),require('zlib');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var template = {
2
+ width: 416,
3
+ height: 250,
4
+ type: 'png',
5
+ scaleFactor: 2,
6
+ html: function (props) { return index._(void 0, void 0, void 0, function () {
7
+ var amount, date, html, bgImage;
8
+ return index.a(this, function (_a) {
9
+ amount = props.amount, date = props.date;
10
+ html = index.g(path__default["default"].resolve(__dirname, 'index.html'));
11
+ bgImage = index.b(path__default["default"].resolve(__dirname, 'images/bg.png'));
12
+ return [2 /*return*/, html
13
+ .replace('{bgImage}', bgImage)
14
+ .replace('{amount}', String(amount))
15
+ .replace('{date}', date)];
16
+ });
17
+ }); }
18
+ };module.exports=template;
@@ -1,4 +1,3 @@
1
- export declare const getPath: (filePath: string) => string;
2
1
  export declare const getFile: (filePath: string) => string;
3
2
  export declare const getBase64Image: (filePath: string) => string;
4
3
  export declare const downloadImage: (url: string) => Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azuro-org/images-generator",
3
- "version": "0.0.4",
3
+ "version": "1.0.1",
4
4
  "license": "ISC",
5
5
  "engines": {
6
6
  "node": "=16.15.1",