@gravito/signal 3.0.0 → 3.0.3

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/dist/index.js CHANGED
@@ -61,7 +61,7 @@ var init_ReactRenderer = __esm({
61
61
  };
62
62
  }
63
63
  stripHtml(html) {
64
- return html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
64
+ return html.replace(/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi, "").replace(/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
65
65
  }
66
66
  };
67
67
  }
@@ -37322,7 +37322,7 @@ var init_VueRenderer = __esm({
37322
37322
  };
37323
37323
  }
37324
37324
  stripHtml(html) {
37325
- return html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
37325
+ return html.replace(/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi, "").replace(/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
37326
37326
  }
37327
37327
  };
37328
37328
  }
@@ -37402,7 +37402,7 @@ var HtmlRenderer = class {
37402
37402
  };
37403
37403
  }
37404
37404
  stripHtml(html) {
37405
- return html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
37405
+ return html.replace(/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi, "").replace(/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
37406
37406
  }
37407
37407
  };
37408
37408
 
@@ -37436,34 +37436,74 @@ var Mailable = class {
37436
37436
  renderData = {};
37437
37437
  config;
37438
37438
  // ===== Fluent API (Envelope Construction) =====
37439
+ /**
37440
+ * Set the sender address for the email.
37441
+ *
37442
+ * @param address - Email address or Address object.
37443
+ */
37439
37444
  from(address) {
37440
37445
  this.envelope.from = typeof address === "string" ? { address } : address;
37441
37446
  return this;
37442
37447
  }
37448
+ /**
37449
+ * Set the primary recipient(s) for the email.
37450
+ *
37451
+ * @param address - Single address, address object, or array of either.
37452
+ */
37443
37453
  to(address) {
37444
37454
  this.envelope.to = this.normalizeAddressArray(address);
37445
37455
  return this;
37446
37456
  }
37457
+ /**
37458
+ * Set the carbon copy (CC) recipient(s).
37459
+ *
37460
+ * @param address - Single address, address object, or array of either.
37461
+ */
37447
37462
  cc(address) {
37448
37463
  this.envelope.cc = this.normalizeAddressArray(address);
37449
37464
  return this;
37450
37465
  }
37466
+ /**
37467
+ * Set the blind carbon copy (BCC) recipient(s).
37468
+ *
37469
+ * @param address - Single address, address object, or array of either.
37470
+ */
37451
37471
  bcc(address) {
37452
37472
  this.envelope.bcc = this.normalizeAddressArray(address);
37453
37473
  return this;
37454
37474
  }
37475
+ /**
37476
+ * Set the reply-to address.
37477
+ *
37478
+ * @param address - Email address or Address object.
37479
+ */
37455
37480
  replyTo(address) {
37456
37481
  this.envelope.replyTo = typeof address === "string" ? { address } : address;
37457
37482
  return this;
37458
37483
  }
37484
+ /**
37485
+ * Set the subject line for the email.
37486
+ *
37487
+ * @param subject - The email subject.
37488
+ */
37459
37489
  subject(subject) {
37460
37490
  this.envelope.subject = subject;
37461
37491
  return this;
37462
37492
  }
37493
+ /**
37494
+ * Set the email priority.
37495
+ *
37496
+ * @param level - Priority level ('high', 'normal', or 'low').
37497
+ */
37463
37498
  emailPriority(level) {
37464
37499
  this.envelope.priority = level;
37465
37500
  return this;
37466
37501
  }
37502
+ /**
37503
+ * Attach a file to the email.
37504
+ *
37505
+ * @param attachment - Attachment configuration object.
37506
+ */
37467
37507
  attach(attachment) {
37468
37508
  this.envelope.attachments = this.envelope.attachments || [];
37469
37509
  this.envelope.attachments.push(attachment);
@@ -37472,6 +37512,8 @@ var Mailable = class {
37472
37512
  // ===== Content Methods (Renderer Selection) =====
37473
37513
  /**
37474
37514
  * Set the content using raw HTML string.
37515
+ *
37516
+ * @param content - The HTML content string.
37475
37517
  */
37476
37518
  html(content) {
37477
37519
  this.renderer = new HtmlRenderer(content);
@@ -37479,8 +37521,9 @@ var Mailable = class {
37479
37521
  }
37480
37522
  /**
37481
37523
  * Set the content using an OrbitPrism template.
37482
- * @param template Template name (relative to viewsDir/emails)
37483
- * @param data Data to pass to the template
37524
+ *
37525
+ * @param template - Template name (relative to viewsDir/emails).
37526
+ * @param data - Optional data to pass to the template.
37484
37527
  */
37485
37528
  view(template, data) {
37486
37529
  this.renderer = new TemplateRenderer(template, void 0);
@@ -37490,6 +37533,10 @@ var Mailable = class {
37490
37533
  /**
37491
37534
  * Set the content using a React component.
37492
37535
  * Dynamically imports ReactRenderer to avoid hard dependency errors if React is not installed.
37536
+ *
37537
+ * @param component - The React component to render.
37538
+ * @param props - Optional props for the component.
37539
+ * @param deps - Optional dependencies (React, ReactDOMServer) if not globally available.
37493
37540
  */
37494
37541
  react(component, props, deps) {
37495
37542
  this.rendererResolver = async () => {
@@ -37501,6 +37548,10 @@ var Mailable = class {
37501
37548
  /**
37502
37549
  * Set the content using a Vue component.
37503
37550
  * Dynamically imports VueRenderer to avoid hard dependency errors if Vue is not installed.
37551
+ *
37552
+ * @param component - The Vue component to render.
37553
+ * @param props - Optional props for the component.
37554
+ * @param deps - Optional dependencies (Vue, VueServerRenderer) if not globally available.
37504
37555
  */
37505
37556
  vue(component, props, deps) {
37506
37557
  this.rendererResolver = async () => {
@@ -37510,28 +37561,45 @@ var Mailable = class {
37510
37561
  return this;
37511
37562
  }
37512
37563
  // ===== Queueable Implementation =====
37564
+ /** The name of the queue to push this mailable to. */
37513
37565
  queueName;
37566
+ /** The connection name for the queue. */
37514
37567
  connectionName;
37568
+ /** Delay in seconds before the message is sent. */
37515
37569
  delaySeconds;
37570
+ /** Priority of the message in the queue. */
37516
37571
  priority;
37572
+ /**
37573
+ * Set the queue name for this mailable.
37574
+ */
37517
37575
  onQueue(queue) {
37518
37576
  this.queueName = queue;
37519
37577
  return this;
37520
37578
  }
37579
+ /**
37580
+ * Set the connection name for this mailable.
37581
+ */
37521
37582
  onConnection(connection) {
37522
37583
  this.connectionName = connection;
37523
37584
  return this;
37524
37585
  }
37586
+ /**
37587
+ * Set a delay for the queued mailable.
37588
+ */
37525
37589
  delay(seconds) {
37526
37590
  this.delaySeconds = seconds;
37527
37591
  return this;
37528
37592
  }
37593
+ /**
37594
+ * Set the priority for the queued mailable.
37595
+ */
37529
37596
  withPriority(priority) {
37530
37597
  this.priority = priority;
37531
37598
  return this;
37532
37599
  }
37533
37600
  /**
37534
37601
  * Queue the mailable for sending.
37602
+ * Attempts to resolve the mail service from the PlanetCore container.
37535
37603
  */
37536
37604
  async queue() {
37537
37605
  try {
@@ -37549,6 +37617,8 @@ var Mailable = class {
37549
37617
  translator;
37550
37618
  /**
37551
37619
  * Set the locale for the message.
37620
+ *
37621
+ * @param locale - Valid locale string (e.g., 'en', 'zh-TW').
37552
37622
  */
37553
37623
  locale(locale) {
37554
37624
  this.currentLocale = locale;
@@ -37556,12 +37626,17 @@ var Mailable = class {
37556
37626
  }
37557
37627
  /**
37558
37628
  * Internal: Set the translator function (called by OrbitSignal)
37629
+ * @internal
37559
37630
  */
37560
37631
  setTranslator(translator) {
37561
37632
  this.translator = translator;
37562
37633
  }
37563
37634
  /**
37564
37635
  * Translate a string using the configured translator.
37636
+ *
37637
+ * @param key - Translation key.
37638
+ * @param replace - Interpolation variables.
37639
+ * @returns Translated string or the key if translator is missing.
37565
37640
  */
37566
37641
  t(key, replace) {
37567
37642
  if (this.translator) {
@@ -37572,6 +37647,7 @@ var Mailable = class {
37572
37647
  // ===== Internal Systems =====
37573
37648
  /**
37574
37649
  * Compile the envelope based on config defaults and mailable settings.
37650
+ * Called by OrbitSignal before rendering/sending.
37575
37651
  */
37576
37652
  async buildEnvelope(configPromise) {
37577
37653
  const config = await Promise.resolve(configPromise);
@@ -37604,7 +37680,8 @@ var Mailable = class {
37604
37680
  return envelope;
37605
37681
  }
37606
37682
  /**
37607
- * execute the renderer
37683
+ * Execute the renderer and produce HTML/Text content.
37684
+ * @returns Object containing rendered html and optional text content.
37608
37685
  */
37609
37686
  async renderContent() {
37610
37687
  if (!this.renderer && this.rendererResolver) {
@@ -37993,7 +38070,7 @@ var OrbitSignal = class {
37993
38070
  });
37994
38071
  devServer.register(core);
37995
38072
  }
37996
- core.container.singleton("mail", () => this);
38073
+ core.container.instance("mail", this);
37997
38074
  core.adapter.use("*", async (c, next) => {
37998
38075
  c.set("mail", this);
37999
38076
  return await next();
@@ -38001,10 +38078,6 @@ var OrbitSignal = class {
38001
38078
  }
38002
38079
  /**
38003
38080
  * Send a mailable instance
38004
- *
38005
- * @param mailable - The mailable object to send.
38006
- * @returns A promise that resolves when the email is sent.
38007
- * @throws {Error} If the message is missing "from" or "to" addresses, or if no transport is configured.
38008
38081
  */
38009
38082
  async send(mailable) {
38010
38083
  const envelope = await mailable.buildEnvelope(this.config);
package/dist/index.mjs CHANGED
@@ -59,7 +59,7 @@ var HtmlRenderer = class {
59
59
  };
60
60
  }
61
61
  stripHtml(html) {
62
- return html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
62
+ return html.replace(/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi, "").replace(/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
63
63
  }
64
64
  };
65
65
 
@@ -93,34 +93,74 @@ var Mailable = class {
93
93
  renderData = {};
94
94
  config;
95
95
  // ===== Fluent API (Envelope Construction) =====
96
+ /**
97
+ * Set the sender address for the email.
98
+ *
99
+ * @param address - Email address or Address object.
100
+ */
96
101
  from(address) {
97
102
  this.envelope.from = typeof address === "string" ? { address } : address;
98
103
  return this;
99
104
  }
105
+ /**
106
+ * Set the primary recipient(s) for the email.
107
+ *
108
+ * @param address - Single address, address object, or array of either.
109
+ */
100
110
  to(address) {
101
111
  this.envelope.to = this.normalizeAddressArray(address);
102
112
  return this;
103
113
  }
114
+ /**
115
+ * Set the carbon copy (CC) recipient(s).
116
+ *
117
+ * @param address - Single address, address object, or array of either.
118
+ */
104
119
  cc(address) {
105
120
  this.envelope.cc = this.normalizeAddressArray(address);
106
121
  return this;
107
122
  }
123
+ /**
124
+ * Set the blind carbon copy (BCC) recipient(s).
125
+ *
126
+ * @param address - Single address, address object, or array of either.
127
+ */
108
128
  bcc(address) {
109
129
  this.envelope.bcc = this.normalizeAddressArray(address);
110
130
  return this;
111
131
  }
132
+ /**
133
+ * Set the reply-to address.
134
+ *
135
+ * @param address - Email address or Address object.
136
+ */
112
137
  replyTo(address) {
113
138
  this.envelope.replyTo = typeof address === "string" ? { address } : address;
114
139
  return this;
115
140
  }
141
+ /**
142
+ * Set the subject line for the email.
143
+ *
144
+ * @param subject - The email subject.
145
+ */
116
146
  subject(subject) {
117
147
  this.envelope.subject = subject;
118
148
  return this;
119
149
  }
150
+ /**
151
+ * Set the email priority.
152
+ *
153
+ * @param level - Priority level ('high', 'normal', or 'low').
154
+ */
120
155
  emailPriority(level) {
121
156
  this.envelope.priority = level;
122
157
  return this;
123
158
  }
159
+ /**
160
+ * Attach a file to the email.
161
+ *
162
+ * @param attachment - Attachment configuration object.
163
+ */
124
164
  attach(attachment) {
125
165
  this.envelope.attachments = this.envelope.attachments || [];
126
166
  this.envelope.attachments.push(attachment);
@@ -129,6 +169,8 @@ var Mailable = class {
129
169
  // ===== Content Methods (Renderer Selection) =====
130
170
  /**
131
171
  * Set the content using raw HTML string.
172
+ *
173
+ * @param content - The HTML content string.
132
174
  */
133
175
  html(content) {
134
176
  this.renderer = new HtmlRenderer(content);
@@ -136,8 +178,9 @@ var Mailable = class {
136
178
  }
137
179
  /**
138
180
  * Set the content using an OrbitPrism template.
139
- * @param template Template name (relative to viewsDir/emails)
140
- * @param data Data to pass to the template
181
+ *
182
+ * @param template - Template name (relative to viewsDir/emails).
183
+ * @param data - Optional data to pass to the template.
141
184
  */
142
185
  view(template, data) {
143
186
  this.renderer = new TemplateRenderer(template, void 0);
@@ -147,10 +190,14 @@ var Mailable = class {
147
190
  /**
148
191
  * Set the content using a React component.
149
192
  * Dynamically imports ReactRenderer to avoid hard dependency errors if React is not installed.
193
+ *
194
+ * @param component - The React component to render.
195
+ * @param props - Optional props for the component.
196
+ * @param deps - Optional dependencies (React, ReactDOMServer) if not globally available.
150
197
  */
151
198
  react(component, props, deps) {
152
199
  this.rendererResolver = async () => {
153
- const { ReactRenderer } = await import("./ReactRenderer-CMCAOEPH.mjs");
200
+ const { ReactRenderer } = await import("./ReactRenderer-KYNA4WKE.mjs");
154
201
  return new ReactRenderer(component, props, deps);
155
202
  };
156
203
  return this;
@@ -158,37 +205,58 @@ var Mailable = class {
158
205
  /**
159
206
  * Set the content using a Vue component.
160
207
  * Dynamically imports VueRenderer to avoid hard dependency errors if Vue is not installed.
208
+ *
209
+ * @param component - The Vue component to render.
210
+ * @param props - Optional props for the component.
211
+ * @param deps - Optional dependencies (Vue, VueServerRenderer) if not globally available.
161
212
  */
162
213
  vue(component, props, deps) {
163
214
  this.rendererResolver = async () => {
164
- const { VueRenderer } = await import("./VueRenderer-DWTCD2RF.mjs");
215
+ const { VueRenderer } = await import("./VueRenderer-IIR5SYTM.mjs");
165
216
  return new VueRenderer(component, props, deps);
166
217
  };
167
218
  return this;
168
219
  }
169
220
  // ===== Queueable Implementation =====
221
+ /** The name of the queue to push this mailable to. */
170
222
  queueName;
223
+ /** The connection name for the queue. */
171
224
  connectionName;
225
+ /** Delay in seconds before the message is sent. */
172
226
  delaySeconds;
227
+ /** Priority of the message in the queue. */
173
228
  priority;
229
+ /**
230
+ * Set the queue name for this mailable.
231
+ */
174
232
  onQueue(queue) {
175
233
  this.queueName = queue;
176
234
  return this;
177
235
  }
236
+ /**
237
+ * Set the connection name for this mailable.
238
+ */
178
239
  onConnection(connection) {
179
240
  this.connectionName = connection;
180
241
  return this;
181
242
  }
243
+ /**
244
+ * Set a delay for the queued mailable.
245
+ */
182
246
  delay(seconds) {
183
247
  this.delaySeconds = seconds;
184
248
  return this;
185
249
  }
250
+ /**
251
+ * Set the priority for the queued mailable.
252
+ */
186
253
  withPriority(priority) {
187
254
  this.priority = priority;
188
255
  return this;
189
256
  }
190
257
  /**
191
258
  * Queue the mailable for sending.
259
+ * Attempts to resolve the mail service from the PlanetCore container.
192
260
  */
193
261
  async queue() {
194
262
  try {
@@ -206,6 +274,8 @@ var Mailable = class {
206
274
  translator;
207
275
  /**
208
276
  * Set the locale for the message.
277
+ *
278
+ * @param locale - Valid locale string (e.g., 'en', 'zh-TW').
209
279
  */
210
280
  locale(locale) {
211
281
  this.currentLocale = locale;
@@ -213,12 +283,17 @@ var Mailable = class {
213
283
  }
214
284
  /**
215
285
  * Internal: Set the translator function (called by OrbitSignal)
286
+ * @internal
216
287
  */
217
288
  setTranslator(translator) {
218
289
  this.translator = translator;
219
290
  }
220
291
  /**
221
292
  * Translate a string using the configured translator.
293
+ *
294
+ * @param key - Translation key.
295
+ * @param replace - Interpolation variables.
296
+ * @returns Translated string or the key if translator is missing.
222
297
  */
223
298
  t(key, replace) {
224
299
  if (this.translator) {
@@ -229,6 +304,7 @@ var Mailable = class {
229
304
  // ===== Internal Systems =====
230
305
  /**
231
306
  * Compile the envelope based on config defaults and mailable settings.
307
+ * Called by OrbitSignal before rendering/sending.
232
308
  */
233
309
  async buildEnvelope(configPromise) {
234
310
  const config = await Promise.resolve(configPromise);
@@ -261,7 +337,8 @@ var Mailable = class {
261
337
  return envelope;
262
338
  }
263
339
  /**
264
- * execute the renderer
340
+ * Execute the renderer and produce HTML/Text content.
341
+ * @returns Object containing rendered html and optional text content.
265
342
  */
266
343
  async renderContent() {
267
344
  if (!this.renderer && this.rendererResolver) {
@@ -650,7 +727,7 @@ var OrbitSignal = class {
650
727
  });
651
728
  devServer.register(core);
652
729
  }
653
- core.container.singleton("mail", () => this);
730
+ core.container.instance("mail", this);
654
731
  core.adapter.use("*", async (c, next) => {
655
732
  c.set("mail", this);
656
733
  return await next();
@@ -658,10 +735,6 @@ var OrbitSignal = class {
658
735
  }
659
736
  /**
660
737
  * Send a mailable instance
661
- *
662
- * @param mailable - The mailable object to send.
663
- * @returns A promise that resolves when the email is sent.
664
- * @throws {Error} If the message is missing "from" or "to" addresses, or if no transport is configured.
665
738
  */
666
739
  async send(mailable) {
667
740
  const envelope = await mailable.buildEnvelope(this.config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/signal",
3
- "version": "3.0.0",
3
+ "version": "3.0.3",
4
4
  "description": "Powerful email framework for Gravito applications with Dev UI and multi-renderer support.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",