@noverachat/sdk-web 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Novera
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.ko.md ADDED
@@ -0,0 +1,86 @@
1
+ [English](README.md) | [한국어](README.ko.md)
2
+
3
+ # @noverachat/sdk-web
4
+
5
+ NoveraChat용 최소·isomorphic(브라우저 + Node) TypeScript 클라이언트 — WebSocket + REST에 낙관적 UI, 재연결, backfill을 얹었다. 런타임 의존성 0.
6
+
7
+ > [NoveraChat SDK 모노레포](../../README.md)의 한 패키지.
8
+
9
+ ## 설치
10
+
11
+ ```bash
12
+ npm install @noverachat/sdk-web
13
+ # 또는
14
+ pnpm add @noverachat/sdk-web
15
+ ```
16
+
17
+ Node ≥ 18 또는 최신 브라우저 필요 (플랫폼 `fetch` + `WebSocket` 사용).
18
+
19
+ ## 빠른 시작
20
+
21
+ ```ts
22
+ import { NoveraChat } from "@noverachat/sdk-web";
23
+
24
+ const chat = new NoveraChat({
25
+ appId: "app_9f8k2x",
26
+ endpoint: "https://chat.example.com",
27
+ tokenProvider: async () => fetchJwtFromYourServer(),
28
+ });
29
+
30
+ await chat.connect();
31
+
32
+ const room = chat.room("room_123");
33
+
34
+ room.on("message", (msg) => console.log(msg.content));
35
+ room.on("messageUpdated", (msg) => console.log("편집됨", msg.message_id));
36
+ room.on("messageDeleted", (e) => console.log("삭제됨", e.message_id));
37
+
38
+ // 낙관적 전송 — 서버가 배정한 id로 resolve
39
+ const { tempId, messageId } = await room.send("hello");
40
+
41
+ // 읽음 처리(디바운스) + 모더레이션
42
+ room.markRead(await messageId);
43
+ await room.edit(await messageId, { content: "edited" });
44
+ await room.react(await messageId, "emoji_heart");
45
+
46
+ chat.disconnect();
47
+ ```
48
+
49
+ 단계별 안내는 [docs/getting-started/quickstart.ko.md](docs/getting-started/quickstart.ko.md) 참고.
50
+
51
+ ## 핵심 기능
52
+
53
+ - **재연결 WebSocket** — 지수 백오프 + 지터, 재연결 금지 close code 존중
54
+ - **낙관적 UI** — `ack` 시 `temp_id` → 서버 `message_id` 스왑, self-echo 중복 제거
55
+ - **Backfill** — 재연결 후 놓친 메시지를 REST `?since=...`로 재수신
56
+ - **읽음 워터마크 디바운스** — 기본 400ms, BigInt 비교로 단조 증가
57
+ - **타입 있는 이벤트** — `MessageOut`, `ReactionEntry`, `ErrorCode` 등
58
+ - **런타임 의존성 0** — Node·테스트용으로 `fetch` / `WebSocket` 주입 가능
59
+
60
+ ## 문서
61
+
62
+ 전체 문서는 [NoveraChat 문서 사이트](https://dev-chat-docs.novera.town/)에 발행되며, 같은 마크다운이 [`docs/`](docs/) 아래에 있고 여기서 sync된다.
63
+
64
+ | 섹션 | 내용 |
65
+ | --------------------------------- | ----------------------------------------------------------------------- |
66
+ | [시작하기](docs/getting-started/) | 설치, 퀵스타트 |
67
+ | [Core](docs/core/) | 인증(`tokenProvider`), 연결 수명주기, 트랜스포트(REST vs WS), 유저 차단 |
68
+ | [메시징](docs/messaging/) | 전송, 수신, 편집/삭제, 리액션, 히스토리, 검색 |
69
+ | [룸](docs/rooms/) | 룸 파사드, 멤버, 모더레이션, 초대, 공지, 입력 중, 안읽음·읽음 |
70
+ | [푸시](docs/push/) | 디바이스 등록, 룸별 설정 |
71
+ | [레퍼런스](docs/reference/) | `NoveraChat` / `Room` API, 에러 코드 |
72
+
73
+ ### 컨트리뷰터용
74
+
75
+ [`src/generated/`](src/generated/README.ko.md)의 와이어 타입은 [`@noverachat/protocol`](../protocol/README.ko.md)에서 **자동 생성**된다 — 손으로 고치지 말고, 스키마를 바꾼 뒤 `pnpm gen`.
76
+
77
+ SDK를 _고치는_ 사람을 위한 내부 문서 — 발행 사이트엔 미포함:
78
+
79
+ | 문서 | 내용 |
80
+ | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
81
+ | [docs/internal/structure.ko.md](docs/internal/structure.ko.md) | 무엇이 어디에 — 디렉토리·파일 지도, 파일별 책임, 읽기 순서 |
82
+ | [docs/internal/architecture.ko.md](docs/internal/architecture.ko.md) | 코드가 어떻게·왜 분해돼 있나 — 시스템 컨텍스트, 컴포넌트, 런타임 흐름, 설계 결정, 불변식 |
83
+
84
+ ## 상태
85
+
86
+ Alpha. 서버 호환성: `protocol_version: "1.0"`
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ [English](README.md) | [한국어](README.ko.md)
2
+
3
+ # @noverachat/sdk-web
4
+
5
+ Minimal, isomorphic (browser + Node) TypeScript client for NoveraChat — WebSocket + REST with optimistic UI, reconnection, and backfill. Zero runtime dependencies.
6
+
7
+ > Part of the [NoveraChat SDK monorepo](../../README.md).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @noverachat/sdk-web
13
+ # or
14
+ pnpm add @noverachat/sdk-web
15
+ ```
16
+
17
+ Requires Node ≥ 18 or a modern browser (uses platform `fetch` + `WebSocket`).
18
+
19
+ ## Quick start
20
+
21
+ ```ts
22
+ import { NoveraChat } from "@noverachat/sdk-web";
23
+
24
+ const chat = new NoveraChat({
25
+ appId: "app_9f8k2x",
26
+ endpoint: "https://chat.example.com",
27
+ tokenProvider: async () => fetchJwtFromYourServer(),
28
+ });
29
+
30
+ await chat.connect();
31
+
32
+ const room = chat.room("room_123");
33
+
34
+ room.on("message", (msg) => console.log(msg.content));
35
+ room.on("messageUpdated", (msg) => console.log("edited", msg.message_id));
36
+ room.on("messageDeleted", (e) => console.log("deleted", e.message_id));
37
+
38
+ // optimistic send — resolves with the server-assigned id
39
+ const { tempId, messageId } = await room.send("hello");
40
+
41
+ // read receipt (debounced) + moderation
42
+ room.markRead(await messageId);
43
+ await room.edit(await messageId, { content: "edited" });
44
+ await room.react(await messageId, "emoji_heart");
45
+
46
+ chat.disconnect();
47
+ ```
48
+
49
+ See [docs/getting-started/quickstart.md](docs/getting-started/quickstart.md) for a step-by-step walkthrough.
50
+
51
+ ## Key features
52
+
53
+ - **Reconnecting WebSocket** — exponential backoff + jitter, honours no-reconnect close codes
54
+ - **Optimistic UI** — `temp_id` → server `message_id` swap on ack, with self-echo dedup
55
+ - **Backfill** — re-fetch missed messages via REST `?since=...` after reconnect
56
+ - **Read-watermark debouncing** — 400ms default window, monotonic (BigInt-compared)
57
+ - **Typed events** — `MessageOut`, `ReactionEntry`, `ErrorCode`, and more
58
+ - **Zero runtime deps** — pluggable `fetch` / `WebSocket` for Node and testing
59
+
60
+ ## Documentation
61
+
62
+ The full docs are published on the [NoveraChat docs site](https://dev-chat-docs.novera.town/); the same Markdown lives under [`docs/`](docs/) and is synced from here.
63
+
64
+ | Section | Contents |
65
+ | ---------------------------------------- | ------------------------------------------------------------------------------------------- |
66
+ | [Getting started](docs/getting-started/) | Installation, quickstart |
67
+ | [Core](docs/core/) | Authentication (`tokenProvider`), connection lifecycle, transport (REST vs WS), user blocks |
68
+ | [Messaging](docs/messaging/) | Sending, receiving, editing/deleting, reactions, history, search |
69
+ | [Rooms](docs/rooms/) | Room facade, members, moderation, invites, announcements, typing, unread & read receipts |
70
+ | [Push](docs/push/) | Device registration, per-room settings |
71
+ | [Reference](docs/reference/) | `NoveraChat` / `Room` API, error codes |
72
+
73
+ ### For contributors
74
+
75
+ The wire types in [`src/generated/`](src/generated/README.md) are **auto-generated** from [`@noverachat/protocol`](../protocol/README.md) — don't hand-edit them; change the schema and run `pnpm gen`.
76
+
77
+ Internal docs for people working _on_ the SDK — not part of the published site:
78
+
79
+ | Doc | Contents |
80
+ | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
81
+ | [docs/internal/structure.md](docs/internal/structure.md) | What lives where — directory & file map, per-file responsibilities, reading order |
82
+ | [docs/internal/architecture.md](docs/internal/architecture.md) | How the code is decomposed & why — system context, components, runtime flows, design decisions, invariants |
83
+
84
+ ## Status
85
+
86
+ Alpha. Server compatibility: `protocol_version: "1.0"`