@dovetail-ts/transport-sse 0.0.0-stage → 1.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # @dovetail-ts/transport-sse
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 21b3dbf: Publish through OIDC trusted publishing only, with the Ember Workbench release kit. Each version from this release on has npm provenance.
8
+ - Updated dependencies [21b3dbf]
9
+ - @dovetail-ts/protocol@1.0.1
10
+
11
+ ## 1.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - 480744b: First release of Dovetail: real-time and offline sync for Ember.
16
+
17
+ - `@dovetail-ts/core`: the connection life cycle, live store subscriptions, the optimistic ledger with rebase and rollback, the offline write queue in IndexedDB with a leader tab and dead letters, `DocSession` and `PresenceRoom`.
18
+ - `@dovetail-ts/warp-drive`: the store feed into WarpDrive.
19
+ - `@dovetail-ts/crdt`, `crdt-yjs`, `crdt-loro` and `crdt-automerge`: one `DocEngine` interface with three engines.
20
+ - `@dovetail-ts/tiptap`: co-editing in Tiptap 3 with carets, per-user undo, versions and comment threads.
21
+ - `@dovetail-ts/ember`, `notifications` and `inspector`: presence and status components, the inbox, toasts and activity feeds, and a dev panel.
22
+ - `@dovetail-ts/server`, the transports (`transport-ws`, `transport-sse`, `transport-cable`) and `conformance`: a Node server and one wire protocol that the Rails gems also pass.
23
+ - Adapters for Hocuspocus, Liveblocks, PartyKit and Supabase, and integrations for Switchyard, Millwork, Benchdog and Lattice. The Neon adapter is not in 1.0: it waits for a stable Neon Realtime client (1.1).
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [480744b]
28
+ - @dovetail-ts/protocol@1.0.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joe Gaudet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # @dovetail-ts/transport-sse
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The SSE transport. The server frames arrive on one event stream (read with `parseSse` and
4
+ `readText` of `@ember-marquetry/sse`). Each client frame goes in its own POST, in order.
5
+
6
+ Part of [Dovetail](https://joegaudet.com/dovetail/). Not released yet.
7
+
8
+ ```ts
9
+ import { SseTransport } from '@dovetail-ts/transport-sse'
10
+
11
+ const transport = new SseTransport({ url: 'https://example.com/dovetail/sse' })
12
+ await transport.open()
13
+ ```
14
+
15
+ Options: `url`, `fetch`, `headers` and `limits`. `open()` resolves on the `open` event of the
16
+ stream. The POSTs go to `<url>`, with the connection id in the
17
+ `Dovetail-Connection` header, not in the URL. Give the `Authorization` header in `headers`: the
18
+ server needs the same header on the stream and on each POST. A failed POST or a stream that stops closes the
19
+ transport. A transport opens once and does not reconnect. `sendText(text)` sends a frame as it
20
+ is, for tests and proxies.
@@ -0,0 +1,28 @@
1
+ import type { ClientMessage, ClientTransport, CloseInfo, Limits, ServerMessage } from '@dovetail-ts/protocol';
2
+ export interface SseTransportOptions {
3
+ /**
4
+ * The SSE endpoint, as `https://example.com/dovetail/sse`. The POSTs go to the same URL, with
5
+ * the connection id in the `Dovetail-Connection` header. Give the `Authorization` header in
6
+ * `headers`: the server needs the same one on the stream and on each POST.
7
+ */
8
+ url: string;
9
+ /** Default: the global `fetch`. */
10
+ fetch?: (input: string, init?: RequestInit) => Promise<Response>;
11
+ /** More headers for each request. */
12
+ headers?: Record<string, string>;
13
+ /** The limits for the frames of the server. */
14
+ limits?: Partial<Limits>;
15
+ }
16
+ export declare class SseTransport implements ClientTransport {
17
+ #private;
18
+ constructor(options: SseTransportOptions);
19
+ get isOpen(): boolean;
20
+ /** Opens the stream, and resolves on its `open` event. A transport opens once. */
21
+ open(): Promise<void>;
22
+ send(message: ClientMessage): void;
23
+ /** Sends one frame as it is. For tests and proxies: `send` is the normal way. */
24
+ sendText(text: string): void;
25
+ close(code?: number, reason?: string): void;
26
+ onMessage(listener: (message: ServerMessage) => void): () => void;
27
+ onClose(listener: (info: CloseInfo) => void): () => void;
28
+ }
package/dist/index.js ADDED
@@ -0,0 +1,114 @@
1
+ import { parseSse, readText } from '@ember-marquetry/sse';
2
+ import { encodeMessage, parseMessage } from '@dovetail-ts/protocol';
3
+
4
+ // src/index.ts
5
+ var SseTransport = class {
6
+ #options;
7
+ #abort = new AbortController();
8
+ #started = false;
9
+ #open = false;
10
+ #connection = "";
11
+ #posts = Promise.resolve();
12
+ #messages = /* @__PURE__ */ new Set();
13
+ #closes = /* @__PURE__ */ new Set();
14
+ constructor(options) {
15
+ this.#options = options;
16
+ }
17
+ get isOpen() {
18
+ return this.#open;
19
+ }
20
+ #fetch(input, init) {
21
+ return (this.#options.fetch ?? globalThis.fetch)(input, {
22
+ ...init,
23
+ headers: { ...this.#options.headers, ...init.headers },
24
+ signal: this.#abort.signal
25
+ });
26
+ }
27
+ /** Opens the stream, and resolves on its `open` event. A transport opens once. */
28
+ async open() {
29
+ if (this.#started) throw new Error("SseTransport: open only once");
30
+ this.#started = true;
31
+ const response = await this.#fetch(this.#options.url, {
32
+ headers: { accept: "text/event-stream" }
33
+ });
34
+ if (!response.ok || !response.body) {
35
+ this.#abort.abort();
36
+ throw new Error(`SseTransport: the endpoint answered ${response.status}`);
37
+ }
38
+ const events = parseSse(readText(response.body));
39
+ const first = await events.next();
40
+ const connection = first.done ? void 0 : connectionOf(first.value);
41
+ if (!connection) {
42
+ this.#abort.abort();
43
+ throw new Error("SseTransport: the stream did not start with an open event");
44
+ }
45
+ this.#connection = connection;
46
+ this.#open = true;
47
+ void this.#pump(events);
48
+ }
49
+ send(message) {
50
+ this.sendText(encodeMessage(message));
51
+ }
52
+ /** Sends one frame as it is. For tests and proxies: `send` is the normal way. */
53
+ sendText(text) {
54
+ if (!this.#open) throw new Error("SseTransport: the transport is not open");
55
+ this.#posts = this.#posts.then(async () => {
56
+ if (!this.#open) return;
57
+ try {
58
+ const response = await this.#fetch(this.#options.url, {
59
+ method: "POST",
60
+ headers: { "content-type": "application/json", "dovetail-connection": this.#connection },
61
+ body: text
62
+ });
63
+ if (!response.ok) this.#closed({ code: 1011, reason: "a POST failed", wasClean: false });
64
+ } catch {
65
+ this.#closed({ code: 1006, reason: "a POST failed", wasClean: false });
66
+ }
67
+ });
68
+ }
69
+ close(code = 1e3, reason = "") {
70
+ this.#closed({ code, reason, wasClean: true });
71
+ }
72
+ onMessage(listener) {
73
+ this.#messages.add(listener);
74
+ return () => this.#messages.delete(listener);
75
+ }
76
+ onClose(listener) {
77
+ this.#closes.add(listener);
78
+ return () => this.#closes.delete(listener);
79
+ }
80
+ async #pump(events) {
81
+ try {
82
+ for await (const event of events) {
83
+ if (!this.#open) return;
84
+ if (event.event !== "message") continue;
85
+ const result = parseMessage(event.data, { from: "server", limits: this.#options.limits });
86
+ if (!result.ok) {
87
+ return this.#closed({ code: 1007, reason: result.error.message, wasClean: false });
88
+ }
89
+ for (const listener of [...this.#messages]) listener(result.message);
90
+ }
91
+ } catch {
92
+ }
93
+ this.#closed({ code: 1006, reason: "the stream closed", wasClean: false });
94
+ }
95
+ #closed(info) {
96
+ if (!this.#open) return;
97
+ this.#open = false;
98
+ this.#abort.abort();
99
+ for (const listener of [...this.#closes]) listener(info);
100
+ }
101
+ };
102
+ function connectionOf(event) {
103
+ if (event.event !== "open") return void 0;
104
+ try {
105
+ const { connection } = JSON.parse(event.data);
106
+ return typeof connection === "string" && connection.length > 0 ? connection : void 0;
107
+ } catch {
108
+ return void 0;
109
+ }
110
+ }
111
+
112
+ export { SseTransport };
113
+ //# sourceMappingURL=index.js.map
114
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AA6BO,IAAM,eAAN,MAA8C;AAAA,EAC1C,QAAA;AAAA,EACA,MAAA,GAAS,IAAI,eAAA,EAAgB;AAAA,EACtC,QAAA,GAAW,KAAA;AAAA,EACX,KAAA,GAAQ,KAAA;AAAA,EACR,WAAA,GAAc,EAAA;AAAA,EACd,MAAA,GAA2B,QAAQ,OAAA,EAAQ;AAAA,EAC3C,SAAA,uBAAgB,GAAA,EAAsC;AAAA,EACtD,OAAA,uBAAc,GAAA,EAA+B;AAAA,EAE7C,YAAY,OAAA,EAA8B;AACxC,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EAClB;AAAA,EAEA,IAAI,MAAA,GAAkB;AACpB,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA,EAEA,MAAA,CAAO,OAAe,IAAA,EAAsC;AAC1D,IAAA,OAAA,CAAQ,IAAA,CAAK,QAAA,CAAS,KAAA,IAAS,UAAA,CAAW,OAAO,KAAA,EAAO;AAAA,MACtD,GAAG,IAAA;AAAA,MACH,OAAA,EAAS,EAAE,GAAG,IAAA,CAAK,SAAS,OAAA,EAAS,G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zD;AACF;AAEA,SAAS,aAAa,KAAA,EAAqC;AACzD,EAAA,IAAI,KAAA,CAAM,KAAA,KAAU,MAAA,EAAQ,OAAO,MAAA;AACnC,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,UAAA,EAAW,GAAI,IAAA,CAAK,KAAA,CAAM,MAAM,IAAI,CAAA;AAC5C,IAAA,OAAO,OAAO,UAAA,KAAe,QAAA,IAAY,UAAA,CAAW,MAAA,GAAS,IAAI,UAAA,GAAa,KAAA,CAAA;AAAA,EAChF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF","file":"index.js","sourcesContent":["// The SSE transport (ADR 0012). The server frames arrive on one event stream. Each client\n// frame goes in its own POST, one at a time, so the server gets them in order. The transport\n// does not reconnect: the Connection of @dovetail-ts/core makes a new transport for that.\nimport { parseSse, readText } from '@ember-marquetry/sse'\nimport type { SseEvent } from '@ember-marquetry/sse'\nimport { encodeMessage, parseMessage } from '@dovetail-ts/protocol'\nimport type {\n ClientMessage,\n ClientTransport,\n CloseInfo,\n Limits,\n ServerMessage,\n} from '@dovetail-ts/protocol'\n\nexport interface SseTransportOptions {\n /**\n * The SSE endpoint, as `https://example.com/dovetail/sse`. The POSTs go to the same URL, with\n * the connection id in the `Dovetail-Connection` header. Give the `Authorization` header in\n * `headers`: the server needs the same one on the stream and on each POST.\n */\n url: string\n /** Default: the global `fetch`. */\n fetch?: (input: string, init?: RequestInit) => Promise<Response>\n /** More headers for each request. */\n headers?: Record<string, string>\n /** The limits for the frames of the server. */\n limits?: Partial<Limits>\n}\n\nexport class SseTransport implements ClientTransport {\n readonly #options: SseTransportOptions\n readonly #abort = new AbortController()\n #started = false\n #open = false\n #connection = ''\n #posts: Promise<unknown> = Promise.resolve()\n #messages = new Set<(message: ServerMessage) => void>()\n #closes = new Set<(info: CloseInfo) => void>()\n\n constructor(options: SseTransportOptions) {\n this.#options = options\n }\n\n get isOpen(): boolean {\n return this.#open\n }\n\n #fetch(input: string, init: RequestInit): Promise<Response> {\n return (this.#options.fetch ?? globalThis.fetch)(input, {\n ...init,\n headers: { ...this.#options.headers, ...(init.headers as Record<string, string>) },\n signal: this.#abort.signal,\n })\n }\n\n /** Opens the stream, and resolves on its `open` event. A transport opens once. */\n async open(): Promise<void> {\n if (this.#started) throw new Error('SseTransport: open only once')\n this.#started = true\n const response = await this.#fetch(this.#options.url, {\n headers: { accept: 'text/event-stream' },\n })\n if (!response.ok || !response.body) {\n this.#abort.abort()\n throw new Error(`SseTransport: the endpoint answered ${response.status}`)\n }\n const events = parseSse(readText(response.body))\n const first = await events.next()\n const connection = first.done ? undefined : connectionOf(first.value)\n if (!connection) {\n this.#abort.abort()\n throw new Error('SseTransport: the stream did not start with an open event')\n }\n this.#connection = connection\n this.#open = true\n void this.#pump(events)\n }\n\n send(message: ClientMessage): void {\n this.sendText(encodeMessage(message))\n }\n\n /** Sends one frame as it is. For tests and proxies: `send` is the normal way. */\n sendText(text: string): void {\n if (!this.#open) throw new Error('SseTransport: the transport is not open')\n this.#posts = this.#posts.then(async () => {\n if (!this.#open) return\n try {\n const response = await this.#fetch(this.#options.url, {\n method: 'POST',\n headers: { 'content-type': 'application/json', 'dovetail-connection': this.#connection },\n body: text,\n })\n if (!response.ok) this.#closed({ code: 1011, reason: 'a POST failed', wasClean: false })\n } catch {\n this.#closed({ code: 1006, reason: 'a POST failed', wasClean: false })\n }\n })\n }\n\n close(code = 1000, reason = ''): void {\n this.#closed({ code, reason, wasClean: true })\n }\n\n onMessage(listener: (message: ServerMessage) => void): () => void {\n this.#messages.add(listener)\n return () => this.#messages.delete(listener)\n }\n\n onClose(listener: (info: CloseInfo) => void): () => void {\n this.#closes.add(listener)\n return () => this.#closes.delete(listener)\n }\n\n async #pump(events: AsyncGenerator<SseEvent>): Promise<void> {\n try {\n for await (const event of events) {\n if (!this.#open) return\n if (event.event !== 'message') continue\n const result = parseMessage(event.data, { from: 'server', limits: this.#options.limits })\n if (!result.ok) {\n return this.#closed({ code: 1007, reason: result.error.message, wasClean: false })\n }\n for (const listener of [...this.#messages]) listener(result.message)\n }\n } catch {\n // The stream broke. The close below reports it.\n }\n this.#closed({ code: 1006, reason: 'the stream closed', wasClean: false })\n }\n\n #closed(info: CloseInfo): void {\n if (!this.#open) return\n this.#open = false\n this.#abort.abort()\n for (const listener of [...this.#closes]) listener(info)\n }\n}\n\nfunction connectionOf(event: SseEvent): string | undefined {\n if (event.event !== 'open') return undefined\n try {\n const { connection } = JSON.parse(event.data) as { connection?: unknown }\n return typeof connection === 'string' && connection.length > 0 ? connection : undefined\n } catch {\n return undefined\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@dovetail-ts/transport-sse",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.1",
4
+ "description": "The SSE transport. It uses parseSse and readText from @ember-marquetry/sse.",
5
+ "license": "MIT",
6
+ "author": "Joe Gaudet <joe@joegaudet.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/joegaudet/dovetail.git",
10
+ "directory": "packages/transport-sse"
11
+ },
12
+ "homepage": "https://joegaudet.com/dovetail/",
13
+ "bugs": "https://github.com/joegaudet/dovetail/issues",
14
+ "keywords": [
15
+ "realtime",
16
+ "offline",
17
+ "sync",
18
+ "crdt"
19
+ ],
20
+ "type": "module",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "CHANGELOG.md",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "sideEffects": false,
36
+ "dependencies": {
37
+ "@dovetail-ts/protocol": "1.0.1",
38
+ "@ember-marquetry/sse": "^1.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "tsup": "^8.5.1"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.12.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc --build --force && tsup"
51
+ }
6
52
  }