hrvclan 1.0.2 → 1.0.5
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/package.json +4 -3
- package/readme.md +68 -17
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hrvclan",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Generate leaderboard card images
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "Generate leaderboard card images",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"keywords": [
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"axios": "^1.13.5",
|
|
18
|
+
"hrvclan": "^1.0.2",
|
|
18
19
|
"node-fetch": "^3.3.2",
|
|
19
20
|
"puppeteer": "^24.37.2"
|
|
20
21
|
},
|
|
@@ -28,6 +29,6 @@
|
|
|
28
29
|
],
|
|
29
30
|
"repository": {
|
|
30
31
|
"type": "git",
|
|
31
|
-
"url": "https://github.com/
|
|
32
|
+
"url": "https://github.com/mtheintrude23/hrvclan.git"
|
|
32
33
|
}
|
|
33
34
|
}
|
package/readme.md
CHANGED
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
# 📊 Leaderboard HTML → PNG Renderer (CommonJS)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- Encode dữ liệu leaderboard
|
|
6
|
-
- Gửi lên API HTML
|
|
7
|
-
- Render trang HTML
|
|
8
|
-
- Chụp màn hình thành ảnh PNG
|
|
9
|
-
- Lưu file về máy
|
|
10
|
-
|
|
11
|
-
Hoạt động với **CommonJS (`require`)**, không dùng ESModule.
|
|
3
|
+
Action With **CommonJS (`require`)**, not use ESModule.
|
|
12
4
|
|
|
13
5
|
---
|
|
14
6
|
|
|
15
|
-
# 🚀 1.
|
|
7
|
+
# 🚀 1. Mandatory Requirements
|
|
16
8
|
|
|
17
9
|
- Node.js >= 18
|
|
18
|
-
-
|
|
19
|
-
- Windows / Linux / VPS
|
|
10
|
+
- CommonJS and not use ESModules
|
|
11
|
+
- Windows / Linux / VPS have run it
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
Check Node Version:
|
|
22
14
|
|
|
23
15
|
```bash
|
|
24
16
|
node -v
|
|
25
17
|
```
|
|
26
18
|
# 2. How to use
|
|
27
|
-
## Bước 1:
|
|
19
|
+
## Bước 1: Install Module
|
|
28
20
|
```
|
|
29
21
|
npm install hrvclan
|
|
30
22
|
```
|
|
@@ -36,12 +28,71 @@ const {
|
|
|
36
28
|
saveLeaderboardImage
|
|
37
29
|
} = require('hrvclan');
|
|
38
30
|
```
|
|
39
|
-
## Bước 3:
|
|
31
|
+
## Bước 3: Test It Out
|
|
40
32
|
```
|
|
33
|
+
const fs = require("fs");
|
|
34
|
+
|
|
35
|
+
// Import
|
|
36
|
+
const {
|
|
37
|
+
getLeaderboardCardUrl,
|
|
38
|
+
fetchLeaderboardCardImage,
|
|
39
|
+
saveLeaderboardImage
|
|
40
|
+
} = require("hrvclan");
|
|
41
|
+
|
|
42
|
+
// Example Data
|
|
43
|
+
const entries = [
|
|
44
|
+
{
|
|
45
|
+
name: "example_jack",
|
|
46
|
+
score: 9999,
|
|
47
|
+
avatar: "https://i.pravatar.cc/150?img=1"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "example_nam",
|
|
51
|
+
score: 7200,
|
|
52
|
+
avatar: "https://i.pravatar.cc/150?img=2"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "example_linh",
|
|
56
|
+
score: 5500,
|
|
57
|
+
avatar: "https://i.pravatar.cc/150?img=3"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "example_hoa",
|
|
61
|
+
score: 3000,
|
|
62
|
+
avatar: "https://i.pravatar.cc/150?img=4"
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
|
|
41
66
|
async function run() {
|
|
42
|
-
|
|
43
|
-
|
|
67
|
+
try {
|
|
68
|
+
// Method 1: Get Link
|
|
69
|
+
console.log("🔗 URL");
|
|
70
|
+
const url = getLeaderboardCardUrl(entries);
|
|
71
|
+
console.log(url);
|
|
72
|
+
|
|
73
|
+
console.log("📸 Rendering the image...");
|
|
74
|
+
|
|
75
|
+
// Method 2: Save Directly
|
|
76
|
+
await saveLeaderboardImage(entries, "./leaderboard.png");
|
|
77
|
+
|
|
78
|
+
console.log("✅ Saved Files leaderboard.png");
|
|
79
|
+
|
|
80
|
+
// Method 3: Get Buffer Image (like method 2)
|
|
81
|
+
const buffer = await fetchLeaderboardCardImage(entries, {
|
|
82
|
+
width: 1080,
|
|
83
|
+
height: 1920,
|
|
84
|
+
fullPage: false
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
fs.writeFileSync("leaderboard-buffer.png", buffer);
|
|
88
|
+
|
|
89
|
+
console.log("✅ Saved files leaderboard-buffer.png");
|
|
90
|
+
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.error("❌ Error:", err);
|
|
93
|
+
}
|
|
44
94
|
}
|
|
45
95
|
|
|
46
96
|
run();
|
|
97
|
+
|
|
47
98
|
```
|