@gravito/signal 1.0.0-alpha.2

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.
Files changed (50) hide show
  1. package/README.md +129 -0
  2. package/dist/OrbitMail-2Z7ZTKYA.mjs +7 -0
  3. package/dist/OrbitMail-BGV32HWN.mjs +7 -0
  4. package/dist/OrbitMail-FUYZQSAV.mjs +7 -0
  5. package/dist/OrbitMail-NAPCRK7B.mjs +7 -0
  6. package/dist/OrbitMail-REGJ276B.mjs +7 -0
  7. package/dist/OrbitMail-TCFBJWDT.mjs +7 -0
  8. package/dist/OrbitMail-XZZW6U4N.mjs +7 -0
  9. package/dist/OrbitSignal-ZKKMEC27.mjs +7 -0
  10. package/dist/ReactRenderer-L5INVYKT.mjs +27 -0
  11. package/dist/VueRenderer-S65ZARRI.mjs +37129 -0
  12. package/dist/VueRenderer-Z5PRVBNH.mjs +37298 -0
  13. package/dist/chunk-3U2CYJO5.mjs +367 -0
  14. package/dist/chunk-3XFC4T6M.mjs +392 -0
  15. package/dist/chunk-6DZX6EAA.mjs +37 -0
  16. package/dist/chunk-DT3R2TNV.mjs +367 -0
  17. package/dist/chunk-GADWIVC4.mjs +400 -0
  18. package/dist/chunk-HHKFAMSE.mjs +380 -0
  19. package/dist/chunk-OKRNL6PN.mjs +400 -0
  20. package/dist/chunk-ULN3GMY2.mjs +367 -0
  21. package/dist/chunk-XAWO7RSP.mjs +398 -0
  22. package/dist/index.d.mts +278 -0
  23. package/dist/index.d.ts +278 -0
  24. package/dist/index.js +38150 -0
  25. package/dist/index.mjs +316 -0
  26. package/package.json +73 -0
  27. package/src/Mailable.ts +245 -0
  28. package/src/OrbitSignal.ts +158 -0
  29. package/src/Queueable.ts +9 -0
  30. package/src/dev/DevMailbox.ts +64 -0
  31. package/src/dev/DevServer.ts +89 -0
  32. package/src/dev/ui/mailbox.ts +68 -0
  33. package/src/dev/ui/preview.ts +59 -0
  34. package/src/dev/ui/shared.ts +46 -0
  35. package/src/index.ts +20 -0
  36. package/src/renderers/HtmlRenderer.ts +22 -0
  37. package/src/renderers/ReactRenderer.ts +35 -0
  38. package/src/renderers/Renderer.ts +11 -0
  39. package/src/renderers/TemplateRenderer.ts +34 -0
  40. package/src/renderers/VueRenderer.ts +37 -0
  41. package/src/transports/LogTransport.ts +17 -0
  42. package/src/transports/MemoryTransport.ts +11 -0
  43. package/src/transports/SesTransport.ts +56 -0
  44. package/src/transports/SmtpTransport.ts +50 -0
  45. package/src/transports/Transport.ts +8 -0
  46. package/src/types.ts +71 -0
  47. package/tests/mailable.test.ts +77 -0
  48. package/tests/renderers.test.ts +56 -0
  49. package/tests/transports.test.ts +52 -0
  50. package/tsconfig.json +19 -0
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+
2
+ # Orbit Mail
3
+
4
+ A powerful, multi-driver email framework for Gravito applications. Supports HTML, Template, React, and Vue renderers, with built-in development tools.
5
+
6
+ ## Features
7
+
8
+ - **Multi-Driver Transport**: SMTP, AWS SES, Log, Memory.
9
+ - **Content Renderers**:
10
+ - Raw HTML
11
+ - OrbitPrism Templates
12
+ - React Components (lazy-loaded)
13
+ - Vue Components (lazy-loaded)
14
+ - **Development Mode**: Intercept emails and view them in a built-in UI (`/__mail`).
15
+ - **Flexible API**: Fluent interface for building emails.
16
+ - **Queue Support**: Built-in `Queueable` interface for async sending.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ bun add @gravito/signal
22
+ ```
23
+
24
+ For AWS SES support:
25
+ ```bash
26
+ bun add @aws-sdk/client-ses
27
+ ```
28
+
29
+ ## Basic Usage
30
+
31
+ ### Configuration
32
+
33
+ Configure OrbitSignal in your generic startup or creation logic:
34
+
35
+ ```typescript
36
+ import { OrbitSignal, SmtpTransport } from '@gravito/signal';
37
+
38
+ const mail = OrbitSignal.configure({
39
+ from: { name: 'My App', address: 'noreply@myapp.com' },
40
+ transport: new SmtpTransport({
41
+ host: 'smtp.mailtrap.io',
42
+ port: 2525,
43
+ auth: { user: '...', pass: '...' }
44
+ }),
45
+ devMode: process.env.NODE_ENV === 'development',
46
+ });
47
+
48
+ // Install into PlanetCore
49
+ mail.install(core);
50
+ ```
51
+
52
+ ### Creating Mailables
53
+
54
+ Extend the `Mailable` class to create email definitions.
55
+
56
+ ```typescript
57
+ import { Mailable } from '@gravito/signal';
58
+
59
+ export class WelcomeEmail extends Mailable {
60
+ constructor(private user: User) {
61
+ super();
62
+ }
63
+
64
+ build() {
65
+ return this
66
+ .to(this.user.email)
67
+ .subject('Welcome to Gravito!')
68
+ .view('emails/welcome', { name: this.user.name });
69
+ }
70
+ }
71
+ ```
72
+
73
+ ### Sending Email
74
+
75
+ ```typescript
76
+ import { WelcomeEmail } from './mail/WelcomeEmail';
77
+
78
+ // In a controller/handler
79
+ await new WelcomeEmail(user).renderContent(); // Validate content
80
+ await context.get('mail').send(new WelcomeEmail(user));
81
+ ```
82
+
83
+ ### Queueing Email
84
+
85
+ OrbitSignal supports queuing mail for background processing.
86
+
87
+ ```typescript
88
+ const email = new WelcomeEmail(user)
89
+ .onQueue('high-priority')
90
+ .delay(60);
91
+
92
+ // Queue the email
93
+ await email.queue();
94
+ ```
95
+
96
+ ## Transports
97
+
98
+ ### SMTP
99
+ Standard SMTP transport using `nodemailer`.
100
+
101
+ ### AWS SES
102
+ Send via Amazon SES API.
103
+
104
+ ```typescript
105
+ import { SesTransport } from '@gravito/signal';
106
+
107
+ const transport = new SesTransport({
108
+ region: 'us-east-1',
109
+ accessKeyId: '...', // Optional if using environment variables
110
+ secretAccessKey: '...'
111
+ });
112
+ ```
113
+
114
+ ### Log
115
+ Logs email content to the console (useful for debugging).
116
+
117
+ ### Memory
118
+ Stores emails in memory (used by Dev Mode).
119
+
120
+ ## Renderers
121
+
122
+ - **html(string)**: Raw HTML string.
123
+ - **view(template, data)**: Uses generic template engine.
124
+ - **react(Component, props)**: Renders a React component to HTML.
125
+ - **vue(Component, props)**: Renders a Vue component to HTML.
126
+
127
+ ## License
128
+
129
+ MIT
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitMail
3
+ } from "./chunk-XAWO7RSP.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitMail
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitMail
3
+ } from "./chunk-DT3R2TNV.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitMail
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitMail
3
+ } from "./chunk-OKRNL6PN.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitMail
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitMail
3
+ } from "./chunk-HHKFAMSE.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitMail
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitMail
3
+ } from "./chunk-3XFC4T6M.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitMail
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitMail
3
+ } from "./chunk-3U2CYJO5.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitMail
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitMail
3
+ } from "./chunk-ULN3GMY2.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitMail
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OrbitSignal
3
+ } from "./chunk-GADWIVC4.mjs";
4
+ import "./chunk-6DZX6EAA.mjs";
5
+ export {
6
+ OrbitSignal
7
+ };
@@ -0,0 +1,27 @@
1
+ import "./chunk-6DZX6EAA.mjs";
2
+
3
+ // src/renderers/ReactRenderer.ts
4
+ import { createElement } from "react";
5
+ import { renderToStaticMarkup } from "react-dom/server";
6
+ var ReactRenderer = class {
7
+ constructor(component, props) {
8
+ this.component = component;
9
+ this.props = props;
10
+ }
11
+ async render(data) {
12
+ const mergedProps = { ...this.props, ...data };
13
+ const element = createElement(this.component, mergedProps);
14
+ const html = renderToStaticMarkup(element);
15
+ const fullHtml = html.startsWith("<!DOCTYPE") ? html : `<!DOCTYPE html>${html}`;
16
+ return {
17
+ html: fullHtml,
18
+ text: this.stripHtml(html)
19
+ };
20
+ }
21
+ stripHtml(html) {
22
+ return html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
23
+ }
24
+ };
25
+ export {
26
+ ReactRenderer
27
+ };