@spirobel/mininext 0.3.1 → 0.3.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.
package/dist/url.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /// <reference types="bun-types" />
3
3
  import type { Server, WebSocketHandler } from "bun";
4
4
  import { html, json, dangerjson, HtmlString } from "./html";
5
- import type { DangerJsonInHtml, JsonString, JsonStringValues } from "./html";
5
+ import type { BasedHtml, DangerJsonInHtml, JsonString, JsonStringValues } from "./html";
6
6
  export type Form = {
7
7
  post: boolean;
8
8
  urlencoded: boolean;
@@ -193,6 +193,13 @@ export declare class url {
193
193
  * @param wsObject the websocketsocket object {@link WebSocketHandler}
194
194
  */
195
195
  static setWebsocket<T = undefined>(wsObject: WebSocketHandler<T>): void;
196
+ /**
197
+ * Send a message to all connected {@link ServerWebSocket} subscribed to a topic
198
+ * @param topic The topic to publish to
199
+ * @param message The data to send
200
+ * @returns 0 if the message was dropped, -1 if backpressure was applied, or the number of bytes sent.
201
+ */
202
+ static publishHtml(topic: string, message: BasedHtml): number;
196
203
  /**
197
204
  * Fetch handler that is called by the server when a request is made to any of the urls.
198
205
  * @param {Request} req - The Request object.
package/dist/url.js CHANGED
@@ -395,6 +395,15 @@ export class url {
395
395
  static setWebsocket(wsObject) {
396
396
  url.websocket = wsObject;
397
397
  }
398
+ /**
399
+ * Send a message to all connected {@link ServerWebSocket} subscribed to a topic
400
+ * @param topic The topic to publish to
401
+ * @param message The data to send
402
+ * @returns 0 if the message was dropped, -1 if backpressure was applied, or the number of bytes sent.
403
+ */
404
+ static publishHtml(topic, message) {
405
+ return url.server.publish(topic, message);
406
+ }
398
407
  /**
399
408
  * Fetch handler that is called by the server when a request is made to any of the urls.
400
409
  * @param {Request} req - The Request object.
package/mininext/url.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { Server, WebSocketHandler } from "bun";
2
2
  import { htmlResponder, html, json, dangerjson, HtmlString } from "./html";
3
- import type { DangerJsonInHtml, JsonString, JsonStringValues } from "./html";
3
+ import type {
4
+ BasedHtml,
5
+ DangerJsonInHtml,
6
+ JsonString,
7
+ JsonStringValues,
8
+ } from "./html";
4
9
  export type Form = {
5
10
  post: boolean;
6
11
  urlencoded: boolean;
@@ -497,7 +502,15 @@ export class url {
497
502
  static setWebsocket<T = undefined>(wsObject: WebSocketHandler<T>) {
498
503
  url.websocket = wsObject as WebSocketHandler;
499
504
  }
500
-
505
+ /**
506
+ * Send a message to all connected {@link ServerWebSocket} subscribed to a topic
507
+ * @param topic The topic to publish to
508
+ * @param message The data to send
509
+ * @returns 0 if the message was dropped, -1 if backpressure was applied, or the number of bytes sent.
510
+ */
511
+ static publishHtml(topic: string, message: BasedHtml) {
512
+ return url.server.publish(topic, message as string);
513
+ }
501
514
  /**
502
515
  * Fetch handler that is called by the server when a request is made to any of the urls.
503
516
  * @param {Request} req - The Request object.
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  },
14
14
  "files": ["dist", "mininext"],
15
- "version": "0.3.1",
15
+ "version": "0.3.2",
16
16
  "devDependencies": {
17
17
  "@types/bun": "latest"
18
18
  },