@omg-dev/stream 0.4.30 → 0.4.31

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.mjs CHANGED
@@ -36,7 +36,7 @@ function subscribe(topic, opts) {
36
36
  opts.onStatus?.({ state: "connecting" });
37
37
  fetchEventSource(url, {
38
38
  signal: ctl.signal,
39
- fetch: async (input, init) => {
39
+ fetch: (async (input, init) => {
40
40
  const token = await getToken();
41
41
  const headers = new Headers(init?.headers);
42
42
  headers.set("Authorization", `Bearer ${token}`);
@@ -44,7 +44,7 @@ function subscribe(topic, opts) {
44
44
  ...init,
45
45
  headers
46
46
  });
47
- },
47
+ }),
48
48
  async onopen(res) {
49
49
  if (res.ok && res.headers.get("content-type")?.includes("text/event-stream")) {
50
50
  attempt = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omg-dev/stream",
3
- "version": "0.4.30",
3
+ "version": "0.4.31",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/index.ts CHANGED
@@ -89,12 +89,18 @@ export function subscribe(topic: string, opts: SubscribeOptions): () => void {
89
89
  signal: ctl.signal,
90
90
  // Custom fetch lets us stamp the token fresh on every (re)connection
91
91
  // so callers can rotate tokens without re-subscribing.
92
- fetch: async (input, init) => {
92
+ // fetch-event-source only calls the function, but types the option as the
93
+ // whole global fetch object. Bun adds a static preconnect member, so this
94
+ // explicit adapter keeps one callable implementation across both graphs.
95
+ fetch: (async (
96
+ input: Parameters<typeof fetch>[0],
97
+ init?: Parameters<typeof fetch>[1],
98
+ ) => {
93
99
  const token = await getToken();
94
100
  const headers = new Headers(init?.headers);
95
101
  headers.set("Authorization", `Bearer ${token}`);
96
102
  return fetch(input, { ...init, headers });
97
- },
103
+ }) as unknown as typeof fetch,
98
104
  async onopen(res) {
99
105
  if (res.ok && res.headers.get("content-type")?.includes("text/event-stream")) {
100
106
  attempt = 0;