welcomize 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sploov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ <div align="center">
2
+
3
+ # 🃏 Welcomize
4
+
5
+ **Create stunning, customizable welcome images for your Discord communities in milliseconds.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/welcomize?style=flat-square&color=5865F2)](https://www.npmjs.com/package/welcomize)
8
+ [![Downloads](https://img.shields.io/npm/dt/welcomize?style=flat-square&color=blue)](https://www.npmjs.com/package/welcomize)
9
+ [![License](https://img.shields.io/npm/l/welcomize?style=flat-square&color=green)](https://github.com/sploov/welcomize/blob/main/LICENSE)
10
+ [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
11
+
12
+ <br />
13
+
14
+ <img src="./assets/modern.png" width="800" alt="Welcomize Modern Theme Preview" />
15
+
16
+ <br />
17
+
18
+ [**Installation**](#-installation) •
19
+ [**Quick Start**](#-quick-start) •
20
+ [**Themes**](#-themes) •
21
+ [**API Reference**](#-api-reference) •
22
+ [**Contributing**](#-contributing)
23
+
24
+ </div>
25
+
26
+ ---
27
+
28
+ ## ✨ Features
29
+
30
+ - **🚀 High Performance:** Powered by `@napi-rs/canvas` for blazing fast image generation.
31
+ - **🎨 Pre-built Themes:** Comes with `Classic`, `Modern`, and `Clean` themes out of the box.
32
+ - **🛠 Fully Customizable:** Control colors, fonts, backgrounds, and layouts.
33
+ - **📘 TypeScript:** Written in TypeScript with full type definitions included.
34
+ - **📦 Lightweight:** Zero heavy dependencies (uses pre-compiled binaries).
35
+
36
+ ---
37
+
38
+ ## 📦 Installation
39
+
40
+ Install `welcomize` using your favorite package manager:
41
+
42
+ ```bash
43
+ # npm
44
+ npm install welcomize
45
+
46
+ # yarn
47
+ yarn add welcomize
48
+
49
+ # pnpm
50
+ pnpm add welcomize
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 🚀 Quick Start
56
+
57
+ Generate your first welcome card in just a few lines of code.
58
+
59
+ ```typescript
60
+ import { Welcomize } from 'welcomize';
61
+ import { AttachmentBuilder } from 'discord.js';
62
+
63
+ // 1. Create the card
64
+ const card = new Welcomize({
65
+ username: 'SploovDev',
66
+ avatarUrl: 'https://github.com/sploov.png',
67
+ theme: 'modern',
68
+ title: 'Welcome!',
69
+ subtitle: 'To the Sploov Community',
70
+ borderColor: '#5865F2'
71
+ });
72
+
73
+ // 2. Render to buffer
74
+ const buffer = await card.render();
75
+
76
+ // 3. Send to Discord
77
+ const attachment = new AttachmentBuilder(buffer, { name: 'welcome.png' });
78
+ channel.send({ files: [attachment] });
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 🎨 Themes
84
+
85
+ Welcomize comes with beautiful built-in themes.
86
+
87
+ ### 🔹 Modern
88
+ A sleek, gradient-based design with a glowing avatar.
89
+ <img src="./assets/modern.png" width="100%" style="border-radius: 10px; margin-bottom: 20px;" alt="Modern Theme" />
90
+
91
+ ```typescript
92
+ new Welcomize({ theme: 'modern', borderColor: '#00FFFF', ... });
93
+ ```
94
+
95
+ ### 🔹 Clean
96
+ Minimalist, bright, and professional.
97
+ <img src="./assets/clean.png" width="100%" style="border-radius: 10px; margin-bottom: 20px;" alt="Clean Theme" />
98
+
99
+ ```typescript
100
+ new Welcomize({ theme: 'clean', borderColor: '#FF5733', ... });
101
+ ```
102
+
103
+ ### 🔹 Classic
104
+ The timeless solid-color Discord style.
105
+ <img src="./assets/classic.png" width="100%" style="border-radius: 10px; margin-bottom: 20px;" alt="Classic Theme" />
106
+
107
+ ```typescript
108
+ new Welcomize({ theme: 'classic', backgroundColor: '#23272A', ... });
109
+ ```
110
+
111
+ ---
112
+
113
+ ## ⚙️ API Reference
114
+
115
+ ### `WelcomizeOptions`
116
+
117
+ | Option | Type | Default | Description |
118
+ | :--- | :--- | :--- | :--- |
119
+ | `username` | `string` | **Required** | The username to display. |
120
+ | `avatarUrl` | `string` | **Required** | The user's avatar URL (png/jpg). |
121
+ | `theme` | `Theme` | `'classic'` | `'classic'`, `'modern'`, or `'clean'`. |
122
+ | `title` | `string` | `'Welcome'` | Main heading text. |
123
+ | `subtitle` | `string` | `'To the server!'` | Subtitle/message text. |
124
+ | `backgroundColor` | `string` | *Theme Default* | Hex color background. |
125
+ | `textColor` | `string` | `'#FFFFFF'` | Hex color for text. |
126
+ | `borderColor` | `string` | *Theme Default* | Accent/Border color. |
127
+ | `fontPath` | `string` | `undefined` | Custom font file path. |
128
+
129
+ ---
130
+
131
+ ## 🤝 Contributing
132
+
133
+ We love contributions! Please read our [Contributing Guide](CONTRIBUTING.md) to get started.
134
+
135
+ 1. Fork the repo.
136
+ 2. Create your feature branch.
137
+ 3. Commit your changes.
138
+ 4. Push to the branch.
139
+ 5. Open a Pull Request.
140
+
141
+ ---
142
+
143
+ <div align="center">
144
+
145
+ Made with ❤️ by the **Sploov** Team
146
+
147
+ [GitHub](https://github.com/sploov) • [Issues](https://github.com/sploov/welcomize/issues)
148
+
149
+ </div>
@@ -0,0 +1,11 @@
1
+ import { WelcomizeOptions } from './types';
2
+ export declare class Welcomize {
3
+ private options;
4
+ private width;
5
+ private height;
6
+ constructor(options: WelcomizeOptions);
7
+ render(): Promise<Buffer>;
8
+ private drawClassic;
9
+ private drawModern;
10
+ private drawClean;
11
+ }
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Welcomize = void 0;
4
+ const canvas_1 = require("@napi-rs/canvas");
5
+ const utils_1 = require("./utils");
6
+ class Welcomize {
7
+ constructor(options) {
8
+ this.width = 800;
9
+ this.height = 300;
10
+ this.options = {
11
+ theme: 'classic',
12
+ title: 'Welcome',
13
+ subtitle: 'To the server!',
14
+ backgroundColor: '#23272A',
15
+ textColor: '#FFFFFF',
16
+ borderColor: '#7289DA',
17
+ ...options
18
+ };
19
+ }
20
+ async render() {
21
+ const canvas = (0, canvas_1.createCanvas)(this.width, this.height);
22
+ const ctx = canvas.getContext('2d');
23
+ // Load Avatar
24
+ let avatar;
25
+ try {
26
+ avatar = await (0, canvas_1.loadImage)(this.options.avatarUrl);
27
+ }
28
+ catch (e) {
29
+ throw new Error('Failed to load avatar image.');
30
+ }
31
+ switch (this.options.theme) {
32
+ case 'modern':
33
+ this.drawModern(ctx, avatar);
34
+ break;
35
+ case 'clean':
36
+ this.drawClean(ctx, avatar);
37
+ break;
38
+ case 'classic':
39
+ default:
40
+ this.drawClassic(ctx, avatar);
41
+ break;
42
+ }
43
+ return canvas.toBuffer('image/png');
44
+ }
45
+ drawClassic(ctx, avatar) {
46
+ // Background
47
+ ctx.fillStyle = this.options.backgroundColor;
48
+ ctx.fillRect(0, 0, this.width, this.height);
49
+ // Border
50
+ ctx.strokeStyle = this.options.borderColor;
51
+ ctx.lineWidth = 15;
52
+ ctx.strokeRect(0, 0, this.width, this.height);
53
+ // Avatar
54
+ const avatarRadius = 100;
55
+ const avatarX = 150;
56
+ const avatarY = this.height / 2;
57
+ ctx.save();
58
+ ctx.beginPath();
59
+ ctx.arc(avatarX, avatarY, avatarRadius + 5, 0, Math.PI * 2);
60
+ ctx.fillStyle = this.options.borderColor;
61
+ ctx.fill();
62
+ ctx.restore();
63
+ (0, utils_1.drawCircularImage)(ctx, avatar, avatarX, avatarY, avatarRadius);
64
+ // Text
65
+ ctx.fillStyle = this.options.textColor;
66
+ ctx.textAlign = 'left';
67
+ // Welcome
68
+ ctx.font = 'bold 60px sans-serif';
69
+ ctx.fillText(this.options.title, 300, 130);
70
+ // Username
71
+ ctx.font = '40px sans-serif';
72
+ ctx.fillText(this.options.username, 300, 190);
73
+ // Subtitle
74
+ ctx.fillStyle = '#CCCCCC';
75
+ ctx.font = '25px sans-serif';
76
+ ctx.fillText(this.options.subtitle, 300, 230);
77
+ }
78
+ drawModern(ctx, avatar) {
79
+ // Gradient Background
80
+ const gradient = ctx.createLinearGradient(0, 0, this.width, this.height);
81
+ gradient.addColorStop(0, '#0F2027');
82
+ gradient.addColorStop(0.5, '#203A43');
83
+ gradient.addColorStop(1, '#2C5364');
84
+ ctx.fillStyle = gradient;
85
+ ctx.fillRect(0, 0, this.width, this.height);
86
+ // Decoration
87
+ ctx.fillStyle = 'rgba(255, 255, 255, 0.1)';
88
+ ctx.beginPath();
89
+ ctx.arc(this.width, 0, 300, 0, Math.PI * 2);
90
+ ctx.fill();
91
+ ctx.beginPath();
92
+ ctx.arc(0, this.height, 200, 0, Math.PI * 2);
93
+ ctx.fill();
94
+ // Avatar (Centered)
95
+ const avatarRadius = 90;
96
+ const avatarX = this.width / 2;
97
+ const avatarY = 110;
98
+ // Glow
99
+ ctx.shadowColor = this.options.borderColor;
100
+ ctx.shadowBlur = 25;
101
+ (0, utils_1.drawCircularImage)(ctx, avatar, avatarX, avatarY, avatarRadius);
102
+ ctx.shadowBlur = 0; // Reset shadow
103
+ // Text
104
+ ctx.fillStyle = this.options.textColor;
105
+ ctx.textAlign = 'center';
106
+ ctx.font = 'bold 50px sans-serif';
107
+ ctx.fillText(`Welcome, ${this.options.username}`, this.width / 2, 240);
108
+ ctx.font = '25px sans-serif';
109
+ ctx.fillStyle = '#AAAAAA';
110
+ ctx.fillText(this.options.subtitle, this.width / 2, 275);
111
+ }
112
+ drawClean(ctx, avatar) {
113
+ // Background (Light usually, or custom)
114
+ const bgColor = this.options.backgroundColor === '#23272A' ? '#FFFFFF' : this.options.backgroundColor;
115
+ const textColor = this.options.textColor === '#FFFFFF' ? '#333333' : this.options.textColor;
116
+ ctx.fillStyle = bgColor;
117
+ ctx.fillRect(0, 0, this.width, this.height);
118
+ // Accent Bar
119
+ ctx.fillStyle = this.options.borderColor;
120
+ ctx.fillRect(0, 0, 20, this.height);
121
+ // Avatar (Rounded Rect)
122
+ const avatarSize = 200;
123
+ const avatarX = 60;
124
+ const avatarY = (this.height - avatarSize) / 2;
125
+ // Shadow for avatar
126
+ ctx.shadowColor = 'rgba(0,0,0,0.3)';
127
+ ctx.shadowBlur = 10;
128
+ ctx.shadowOffsetX = 5;
129
+ ctx.shadowOffsetY = 5;
130
+ (0, utils_1.drawRoundedImage)(ctx, avatar, avatarX, avatarY, avatarSize, avatarSize, 20);
131
+ ctx.shadowColor = 'transparent';
132
+ // Text
133
+ ctx.fillStyle = textColor;
134
+ ctx.textAlign = 'left';
135
+ ctx.font = 'bold 70px sans-serif';
136
+ ctx.fillText('WELCOME', 300, 140);
137
+ ctx.fillStyle = this.options.borderColor;
138
+ ctx.font = '40px sans-serif';
139
+ ctx.fillText(this.options.username, 300, 200);
140
+ }
141
+ }
142
+ exports.Welcomize = Welcomize;
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './Welcomize';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./Welcomize"), exports);
@@ -0,0 +1,12 @@
1
+ export type Theme = 'classic' | 'modern' | 'clean';
2
+ export interface WelcomizeOptions {
3
+ username: string;
4
+ avatarUrl: string;
5
+ theme?: Theme;
6
+ title?: string;
7
+ subtitle?: string;
8
+ backgroundColor?: string;
9
+ textColor?: string;
10
+ borderColor?: string;
11
+ fontPath?: string;
12
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { SKRSContext2D, Image } from '@napi-rs/canvas';
2
+ export declare function drawRoundedImage(ctx: SKRSContext2D, image: Image, x: number, y: number, width: number, height: number, radius: number): void;
3
+ export declare function drawCircularImage(ctx: SKRSContext2D, image: Image, x: number, y: number, radius: number): void;
package/dist/utils.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.drawRoundedImage = drawRoundedImage;
4
+ exports.drawCircularImage = drawCircularImage;
5
+ function drawRoundedImage(ctx, image, x, y, width, height, radius) {
6
+ ctx.save();
7
+ ctx.beginPath();
8
+ ctx.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 1.5);
9
+ ctx.arc(x + width - radius, y + radius, radius, Math.PI * 1.5, Math.PI * 2);
10
+ ctx.arc(x + width - radius, y + height - radius, radius, 0, Math.PI * 0.5);
11
+ ctx.arc(x + radius, y + height - radius, radius, Math.PI * 0.5, Math.PI);
12
+ ctx.closePath();
13
+ ctx.clip();
14
+ ctx.drawImage(image, x, y, width, height);
15
+ ctx.restore();
16
+ }
17
+ function drawCircularImage(ctx, image, x, y, radius) {
18
+ ctx.save();
19
+ ctx.beginPath();
20
+ ctx.arc(x, y, radius, 0, Math.PI * 2, true);
21
+ ctx.closePath();
22
+ ctx.clip();
23
+ // drawImage takes top-left corner, so subtract radius
24
+ ctx.drawImage(image, x - radius, y - radius, radius * 2, radius * 2);
25
+ ctx.restore();
26
+ }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "welcomize",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "rimraf dist && tsc",
12
+ "prepublishOnly": "npm run build",
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/sploov/welcomize.git"
18
+ },
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "type": "commonjs",
23
+ "bugs": {
24
+ "url": "https://github.com/sploov/welcomize/issues"
25
+ },
26
+ "homepage": "https://github.com/sploov/welcomize#readme",
27
+ "dependencies": {
28
+ "@napi-rs/canvas": "^0.1.88"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^25.0.3",
32
+ "rimraf": "^6.1.2",
33
+ "ts-node": "^10.9.2",
34
+ "typescript": "^5.9.3"
35
+ }
36
+ }