statocysts 0.4.0 → 0.5.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/dist/browser.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { a as Sender, c as buildSenderRegistry, d as ServiceProvider, f as defineProvider, i as http, l as DefineProviderContext, m as defineTransport, n as slack, o as SenderRegistry, p as Transport, r as HttpPayload, s as SenderUrl, t as json, u as DefineProviderOptions } from "./index-I_frtEQ-.js";
2
- import { FetchOptions } from "ofetch";
3
2
 
4
3
  //#region src/browser.d.ts
5
4
  declare const senderRegistry: SenderRegistry;
6
5
  declare function createSender(urls: SenderUrl[]): Sender;
7
- declare function send(url: string | URL, message: string, options?: FetchOptions): Promise<void>;
6
+ declare function send(url: string | URL, title: string, body?: string): Promise<void>;
8
7
  //#endregion
9
8
  export { DefineProviderContext, DefineProviderOptions, HttpPayload, Sender, SenderRegistry, SenderUrl, ServiceProvider, Transport, buildSenderRegistry, createSender, defineProvider, defineTransport, http, json, send, senderRegistry, slack };
package/dist/browser.js CHANGED
@@ -1,16 +1,19 @@
1
- import { a as defineTransport, i as http, n as json, o as defineProvider, r as slack, s as assert, t as buildSenderRegistry } from "./shared-DsBK2dP_.js";
2
- import { ofetch } from "ofetch";
1
+ import { a as defineTransport, i as http, n as json, o as defineProvider, r as slack, s as assert, t as buildSenderRegistry } from "./shared-vzO3pF63.js";
3
2
 
4
3
  //#region src/browser.ts
5
4
  const senderRegistry = buildSenderRegistry([json, slack]);
6
5
  function createSender(urls) {
7
6
  return senderRegistry(urls);
8
7
  }
9
- async function send(url, message, options) {
8
+ async function send(url, title, body) {
10
9
  const _url = typeof url === "string" ? new URL(url) : url;
11
10
  const provider = senderRegistry.resolveProvider(_url);
12
11
  assert(provider, `Unsupported protocol ${_url.protocol}`);
13
- await ofetch(provider.buildRequest(_url.toString(), message, options), options);
12
+ const messageObj = {
13
+ title,
14
+ body
15
+ };
16
+ await provider.send(_url.toString(), messageObj);
14
17
  }
15
18
 
16
19
  //#endregion
package/dist/index.d.ts CHANGED
@@ -3,6 +3,6 @@ import { a as Sender, c as buildSenderRegistry, d as ServiceProvider, f as defin
3
3
  //#region src/index.d.ts
4
4
  declare const senderRegistry: SenderRegistry;
5
5
  declare function createSender(urls: SenderUrl[]): Sender;
6
- declare function send(url: string | URL, message: string): Promise<void>;
6
+ declare function send(url: string | URL, title: string, body?: string): Promise<void>;
7
7
  //#endregion
8
8
  export { DefineProviderContext, DefineProviderOptions, HttpPayload, Sender, SenderRegistry, SenderUrl, ServiceProvider, Transport, buildSenderRegistry, createSender, defineProvider, defineTransport, http, json, send, senderRegistry, slack };
package/dist/index.js CHANGED
@@ -1,15 +1,18 @@
1
- import { a as defineTransport, i as http, n as json, o as defineProvider, r as slack, s as assert, t as buildSenderRegistry } from "./shared-DsBK2dP_.js";
1
+ import { a as defineTransport, i as http, n as json, o as defineProvider, r as slack, s as assert, t as buildSenderRegistry } from "./shared-vzO3pF63.js";
2
2
 
3
3
  //#region src/index.ts
4
4
  const senderRegistry = buildSenderRegistry([json, slack]);
5
5
  function createSender(urls) {
6
6
  return senderRegistry(urls);
7
7
  }
8
- async function send(url, message) {
8
+ async function send(url, title, body) {
9
9
  const _url = typeof url === "string" ? new URL(url) : url;
10
10
  const provider = senderRegistry.resolveProvider(_url);
11
11
  assert(provider, `Unsupported protocol ${_url.protocol}`);
12
- const messageObj = { title: message };
12
+ const messageObj = {
13
+ title,
14
+ body
15
+ };
13
16
  await provider.send(_url.toString(), messageObj);
14
17
  }
15
18
 
@@ -69,7 +69,23 @@ const slack = defineProvider("slack:", {
69
69
  } else assert(url.pathname.split("/").filter(Boolean).length === 3, "Webhook URL is invalid");
70
70
  let requestUrl;
71
71
  const headers = new Headers([["Content-Type", "application/json"]]);
72
- const body = { text: this.message.title };
72
+ const body = {};
73
+ if (this.message.body) {
74
+ body.blocks = [{
75
+ type: "header",
76
+ text: {
77
+ type: "plain_text",
78
+ text: this.message.title
79
+ }
80
+ }, {
81
+ type: "section",
82
+ text: {
83
+ type: "mrkdwn",
84
+ text: this.message.body
85
+ }
86
+ }];
87
+ body.text = this.message.title;
88
+ } else body.text = this.message.title;
73
89
  if (type === "bot") {
74
90
  const { username: channel, password: token, searchParams } = url;
75
91
  requestUrl = new URL("/api/chat.postMessage", options.botApiBaseUrl);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "statocysts",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "description": "Notification library for JavaScript",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/octoplorer/statocysts",
@@ -45,6 +45,7 @@
45
45
  "node": ">=24.12.0"
46
46
  },
47
47
  "dependencies": {
48
+ "add": "^2.0.6",
48
49
  "defu": "^6.1.4",
49
50
  "ofetch": "^1.5.1",
50
51
  "ufo": "^1.6.1",
@@ -53,9 +54,9 @@
53
54
  "devDependencies": {
54
55
  "@types/node": "^25.0.2",
55
56
  "@vitest/coverage-v8": "4.0.16",
56
- "tsdown": "^0.18.0",
57
+ "tsdown": "^0.18.1",
57
58
  "typescript": "^5.9.3",
58
- "vitest": "^4.0.15"
59
+ "vitest": "^4.0.16"
59
60
  },
60
61
  "scripts": {
61
62
  "lint": "eslint --cache .",