@edv4h/usketch-session-voting 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +43 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @edv4h/usketch-session-voting
2
+
3
+ [`@edv4h/usketch-plugin-session`](../../plugins/usketch-plugin-session) の基盤に乗る
4
+ **最初のセッション型「投票」**。サーバー権限モデルなので、**サーバー部+クライアント部のペア**を
5
+ 1パッケージにまとめ、サブパス export(`/server` と `/client`)で提供する。
6
+
7
+ ## 特徴
8
+
9
+ - **重複排除**: userId 単位で1票(`multi` 時はトグル、単一選択の再投票は差し替え)。
10
+ - **秘密投票**: 誰が何に入れたかは server-only の `secret` に保持し、`public` には tally しか出さない。
11
+ - **ライフサイクル**: host が「締め切る」(集計確定)→「終了」(全員のパネルから削除)。
12
+ - **React を server バンドルに持ち込まない**: `/server` は protocol のみに依存、`/client` が UI + React。
13
+
14
+ ## 使い方
15
+
16
+ ```ts
17
+ // サーバー(apps/server)
18
+ import { votingServerType } from "@edv4h/usketch-session-voting/server";
19
+ new SessionManager({ /* deps */, types: [votingServerType] });
20
+ ```
21
+
22
+ ```ts
23
+ // クライアント(web)
24
+ import { votingClientType } from "@edv4h/usketch-session-voting/client";
25
+ createSessionPlugin({ wsProvider, userId, boardId, types: [votingClientType] });
26
+ ```
27
+
28
+ 作成 config(`SessionConfig`):
29
+
30
+ ```ts
31
+ { type: "voting", question: string, options: string[], secret?: boolean, multi?: boolean }
32
+ ```
33
+
34
+ ## 主な export
35
+
36
+ | entry | export | 内容 |
37
+ |---|---|---|
38
+ | `/server` | `votingServerType` | `ServerSessionType`(init/reduce/privateFor/close) |
39
+ | `/client` | `votingClientType` | `ClientSessionType`(投票カード+作成フォームの描画) |
40
+ | 両方 | `VotingPublicState` / `VotingConfig` / `VotingPrivateState` | 公開状態・作成 config・自分の投票 |
41
+
42
+ 新しいセッション型(チュートリアル / カードゲーム)は、この構成(`/server` + `/client` のペア)を
43
+ まねて 1 パッケージ足すだけで追加できる。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edv4h/usketch-session-voting",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": {
@@ -15,7 +15,7 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@edv4h/usketch-plugin-session": "0.2.0",
18
+ "@edv4h/usketch-plugin-session": "0.2.1",
19
19
  "@edv4h/usketch-session-protocol": "0.2.0"
20
20
  },
21
21
  "peerDependencies": {