@azuro-org/images-generator 1.0.7 → 1.0.9
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 +2 -2
- package/dist/index.es.js +12 -3
- package/dist/templates/bet-og/index.html +1 -10
- package/dist/templates/freebet/index.d.ts +1 -1
- package/dist/templates/freebet/index.html +3 -3
- package/dist/templates/freebet/index.js +2 -2
- package/lib/index.js +12 -3
- package/lib/templates/bet-og/index.html +1 -10
- package/lib/templates/freebet/index.d.ts +1 -1
- package/lib/templates/freebet/index.html +3 -3
- package/lib/templates/freebet/index.js +2 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -36,8 +36,8 @@ type PuppeteerInitialOptions = {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
generateImage({
|
|
39
|
-
output?: string //
|
|
40
|
-
filename?: string // default "image"
|
|
39
|
+
output?: string // the folder path where the image will be generated
|
|
40
|
+
filename?: string // image name, default is "image"
|
|
41
41
|
props: any
|
|
42
42
|
modifyPuppeteerOptions?(options: PuppeteerInitialOptions): PuppeteerOptions
|
|
43
43
|
})
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import puppeteer from'puppeteer';/******************************************************************************
|
|
1
|
+
import fs from'fs';import puppeteer from'puppeteer';/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -79,10 +79,16 @@ function __generator(thisArg, body) {
|
|
|
79
79
|
return [4 /*yield*/, browser.newPage()];
|
|
80
80
|
case 3:
|
|
81
81
|
page = _d.sent();
|
|
82
|
-
return [4 /*yield*/, page.setViewport({
|
|
82
|
+
return [4 /*yield*/, page.setViewport({
|
|
83
|
+
width: width,
|
|
84
|
+
height: height,
|
|
85
|
+
deviceScaleFactor: scaleFactor,
|
|
86
|
+
})];
|
|
83
87
|
case 4:
|
|
84
88
|
_d.sent();
|
|
85
|
-
return [4 /*yield*/, page.
|
|
89
|
+
return [4 /*yield*/, page.goto("data:text/html;charset=UTF-8,".concat(encodeURIComponent(html)), {
|
|
90
|
+
waitUntil: 'networkidle0',
|
|
91
|
+
})];
|
|
86
92
|
case 5:
|
|
87
93
|
_d.sent();
|
|
88
94
|
return [4 /*yield*/, page.$('body')
|
|
@@ -97,6 +103,9 @@ function __generator(thisArg, body) {
|
|
|
97
103
|
_d.label = 8;
|
|
98
104
|
case 8:
|
|
99
105
|
if (!output) return [3 /*break*/, 12];
|
|
106
|
+
if (!fs.existsSync(output)) {
|
|
107
|
+
fs.mkdirSync(output);
|
|
108
|
+
}
|
|
100
109
|
filePath = "".concat(output.replace(/\/$/, ''), "/").concat(filename.replace(/\..+$/, ''), ".").concat(type);
|
|
101
110
|
return [4 /*yield*/, content.screenshot({ path: filePath })];
|
|
102
111
|
case 9:
|
|
@@ -4,17 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
|
7
|
+
<link href="//raw.githubusercontent.com/Azuro-protocol/public-assets/main/fonts/fivo-sans-modern/style.css" rel="stylesheet" />
|
|
7
8
|
<style>
|
|
8
|
-
@font-face {
|
|
9
|
-
font-weight: 700;
|
|
10
|
-
font-family: 'Fivo Sans Modern';
|
|
11
|
-
font-style: normal;
|
|
12
|
-
src: url('/fonts/fivo-sans-modern/bold.woff2') format('woff2'),
|
|
13
|
-
url('/fonts/fivo-sans-modern/bold.woff') format('woff');
|
|
14
|
-
font-display: swap;
|
|
15
|
-
unicode-range: U+000-5FF; /* Latin glyphs */
|
|
16
|
-
}
|
|
17
|
-
|
|
18
9
|
html {
|
|
19
10
|
font-family: 'Inter', sans-serif;
|
|
20
11
|
font-weight: 500;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
height: 250px;
|
|
11
11
|
margin: 0;
|
|
12
12
|
padding: 0;
|
|
13
|
+
background-color: #2d2f34;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
.image {
|
|
@@ -17,13 +18,12 @@
|
|
|
17
18
|
height: 250px;
|
|
18
19
|
padding-top: 75px;
|
|
19
20
|
padding-left: 30px;
|
|
20
|
-
font-family: 'Fivo Sans Modern';
|
|
21
|
+
font-family: 'Fivo Sans Modern', sans-serif;
|
|
21
22
|
font-weight: 700;
|
|
22
23
|
background-size: cover;
|
|
23
24
|
background-position: center;
|
|
24
25
|
overflow: hidden;
|
|
25
26
|
box-sizing: border-box;
|
|
26
|
-
border-radius: 10px;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.amount {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
<body>
|
|
55
55
|
<div class="image" style="background-image: url({bgImage});">
|
|
56
56
|
<div class="amount">
|
|
57
|
-
<div class="text-gradient">{amount}
|
|
57
|
+
<div class="text-gradient">{amount}</div>
|
|
58
58
|
<span>freebet!</span>
|
|
59
59
|
</div>
|
|
60
60
|
<div class="date">Valid until {date}</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
2
|
width: 416,
|
|
3
3
|
height: 250,
|
|
4
|
-
type: '
|
|
4
|
+
type: 'jpeg',
|
|
5
5
|
scaleFactor: 2,
|
|
6
6
|
html: function (props) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7
7
|
var amount, date, html, bgImage;
|
|
@@ -11,7 +11,7 @@ import {_ as __awaiter,a as __generator,g as getFile,b as getBase64Image}from'..
|
|
|
11
11
|
bgImage = getBase64Image(path.resolve(__dirname, 'images/bg.png'));
|
|
12
12
|
return [2 /*return*/, html
|
|
13
13
|
.replace('{bgImage}', bgImage)
|
|
14
|
-
.replace('{amount}',
|
|
14
|
+
.replace('{amount}', amount)
|
|
15
15
|
.replace('{date}', date)];
|
|
16
16
|
});
|
|
17
17
|
}); }
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var puppeteer=require('puppeteer');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var puppeteer__default=/*#__PURE__*/_interopDefaultLegacy(puppeteer);/******************************************************************************
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var fs=require('fs'),puppeteer=require('puppeteer');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var puppeteer__default=/*#__PURE__*/_interopDefaultLegacy(puppeteer);/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -79,10 +79,16 @@ function __generator(thisArg, body) {
|
|
|
79
79
|
return [4 /*yield*/, browser.newPage()];
|
|
80
80
|
case 3:
|
|
81
81
|
page = _d.sent();
|
|
82
|
-
return [4 /*yield*/, page.setViewport({
|
|
82
|
+
return [4 /*yield*/, page.setViewport({
|
|
83
|
+
width: width,
|
|
84
|
+
height: height,
|
|
85
|
+
deviceScaleFactor: scaleFactor,
|
|
86
|
+
})];
|
|
83
87
|
case 4:
|
|
84
88
|
_d.sent();
|
|
85
|
-
return [4 /*yield*/, page.
|
|
89
|
+
return [4 /*yield*/, page.goto("data:text/html;charset=UTF-8,".concat(encodeURIComponent(html)), {
|
|
90
|
+
waitUntil: 'networkidle0',
|
|
91
|
+
})];
|
|
86
92
|
case 5:
|
|
87
93
|
_d.sent();
|
|
88
94
|
return [4 /*yield*/, page.$('body')
|
|
@@ -97,6 +103,9 @@ function __generator(thisArg, body) {
|
|
|
97
103
|
_d.label = 8;
|
|
98
104
|
case 8:
|
|
99
105
|
if (!output) return [3 /*break*/, 12];
|
|
106
|
+
if (!fs__default["default"].existsSync(output)) {
|
|
107
|
+
fs__default["default"].mkdirSync(output);
|
|
108
|
+
}
|
|
100
109
|
filePath = "".concat(output.replace(/\/$/, ''), "/").concat(filename.replace(/\..+$/, ''), ".").concat(type);
|
|
101
110
|
return [4 /*yield*/, content.screenshot({ path: filePath })];
|
|
102
111
|
case 9:
|
|
@@ -4,17 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
|
7
|
+
<link href="//raw.githubusercontent.com/Azuro-protocol/public-assets/main/fonts/fivo-sans-modern/style.css" rel="stylesheet" />
|
|
7
8
|
<style>
|
|
8
|
-
@font-face {
|
|
9
|
-
font-weight: 700;
|
|
10
|
-
font-family: 'Fivo Sans Modern';
|
|
11
|
-
font-style: normal;
|
|
12
|
-
src: url('/fonts/fivo-sans-modern/bold.woff2') format('woff2'),
|
|
13
|
-
url('/fonts/fivo-sans-modern/bold.woff') format('woff');
|
|
14
|
-
font-display: swap;
|
|
15
|
-
unicode-range: U+000-5FF; /* Latin glyphs */
|
|
16
|
-
}
|
|
17
|
-
|
|
18
9
|
html {
|
|
19
10
|
font-family: 'Inter', sans-serif;
|
|
20
11
|
font-weight: 500;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
height: 250px;
|
|
11
11
|
margin: 0;
|
|
12
12
|
padding: 0;
|
|
13
|
+
background-color: #2d2f34;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
.image {
|
|
@@ -17,13 +18,12 @@
|
|
|
17
18
|
height: 250px;
|
|
18
19
|
padding-top: 75px;
|
|
19
20
|
padding-left: 30px;
|
|
20
|
-
font-family: 'Fivo Sans Modern';
|
|
21
|
+
font-family: 'Fivo Sans Modern', sans-serif;
|
|
21
22
|
font-weight: 700;
|
|
22
23
|
background-size: cover;
|
|
23
24
|
background-position: center;
|
|
24
25
|
overflow: hidden;
|
|
25
26
|
box-sizing: border-box;
|
|
26
|
-
border-radius: 10px;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.amount {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
<body>
|
|
55
55
|
<div class="image" style="background-image: url({bgImage});">
|
|
56
56
|
<div class="amount">
|
|
57
|
-
<div class="text-gradient">{amount}
|
|
57
|
+
<div class="text-gradient">{amount}</div>
|
|
58
58
|
<span>freebet!</span>
|
|
59
59
|
</div>
|
|
60
60
|
<div class="date">Valid until {date}</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
2
|
width: 416,
|
|
3
3
|
height: 250,
|
|
4
|
-
type: '
|
|
4
|
+
type: 'jpeg',
|
|
5
5
|
scaleFactor: 2,
|
|
6
6
|
html: function (props) { return index._(void 0, void 0, void 0, function () {
|
|
7
7
|
var amount, date, html, bgImage;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
bgImage = index.b(path__default["default"].resolve(__dirname, 'images/bg.png'));
|
|
12
12
|
return [2 /*return*/, html
|
|
13
13
|
.replace('{bgImage}', bgImage)
|
|
14
|
-
.replace('{amount}',
|
|
14
|
+
.replace('{amount}', amount)
|
|
15
15
|
.replace('{date}', date)];
|
|
16
16
|
});
|
|
17
17
|
}); }
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/images-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": "
|
|
7
|
-
"npm": "
|
|
6
|
+
"node": ">=16.15.1",
|
|
7
|
+
"npm": ">=8.11.0"
|
|
8
8
|
},
|
|
9
9
|
"module": "dist/index.es.js",
|
|
10
10
|
"main": "lib/index.js",
|
|
11
11
|
"types": "lib/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
+
"test": "rimraf ./test/images && node ./test",
|
|
13
14
|
"dev": "rollup -c ./rollup.config.js -w",
|
|
14
15
|
"build": "rimraf ./dist && rimraf ./lib && rollup -c ./rollup.config.js --compact",
|
|
15
16
|
"build-and-test": "npm run build && npm run test",
|
|
16
|
-
"
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"axios": "^0.26.1",
|