@uzuhq/code-sdk 0.8.8 → 0.8.9

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/README.md CHANGED
@@ -296,6 +296,24 @@ changeRoom(null); // デフォルトルーム(全員が同じ音声チャン
296
296
  - 初期状態ではすべてのプレイヤーがデフォルトルーム(`null`)に所属する
297
297
  - `roomId` に文字列を指定すると、そのプレイヤーは指定ルームへ移動する
298
298
 
299
+ ### `finishGame(): void`
300
+
301
+ ゲームを終えて、この端末のプレイ画面を閉じる。ホストはイベントを終了扱いにし、呼んだプレイヤーを退出させる。
302
+
303
+ ```ts
304
+ import { finishGame } from '@uzuhq/code-sdk';
305
+
306
+ onState(state) {
307
+ if (state.debriefClosed) finishGame();
308
+ }
309
+ ```
310
+
311
+ - 結果や感想戦を見終えて閉じるときに呼ぶ。勝敗が決まった瞬間 (`gameover` など) に呼ぶと、結果を見る前に画面が閉じる
312
+ - 途中退出は UZU メニューの「退出」が担うので、ゲーム内の exit / quit ボタンには使わない
313
+ - 閉じるのは呼んだ端末だけ。全員を閉じたいときは、終了を表す state を全員へ配り、各端末で呼ぶ
314
+ - 再描画のたびに呼んでもよい (ホストは処理中の 2 回目以降を無視する)
315
+ - 対応していない古いアプリや `uzu dev` では何も起きないので、呼んだあとも画面を操作不能にしない
316
+
299
317
  ### `onPlayersChanged(handler: (players: Record<string, PlayerVoiceState>) => void): void`
300
318
 
301
319
  プレイヤーのリアルタイム状態(音声状態)が変化したときのハンドラを登録する。
package/dist/index.d.ts CHANGED
@@ -232,6 +232,27 @@ declare function firstFrameReady(): void;
232
232
  * ```
233
233
  */
234
234
  declare function gameReady(): void;
235
+ /**
236
+ * ゲームを終えてプレイ画面を閉じるよう Flutter ホストに通知する。
237
+ *
238
+ * 閉じるのは**呼んだ端末だけ**。全員を閉じたいときは、終了を表す state を全員へ配り、
239
+ * 各端末の `onState` から呼ぶ。ホストはイベントを終了扱いにし (finishedAt を立てるのは
240
+ * 最初の 1 人だけ)、呼んだプレイヤーを退出させてから画面を閉じる。
241
+ *
242
+ * 呼び出しタイミング: 結果や感想戦を見終えて閉じるときなど、シナリオとしてゲームが完全に
243
+ * 終わった瞬間。勝敗が決まった瞬間 (`gameover` など) に呼ぶと、結果を見る前に画面が閉じる。
244
+ *
245
+ * 対応していない古いアプリや `uzu dev` harness では何も起きない。呼んだあとも画面を
246
+ * 操作不能にしないこと。
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * onState(state) {
251
+ * if (state.debriefClosed) finishGame();
252
+ * }
253
+ * ```
254
+ */
255
+ declare function finishGame(): void;
235
256
  /** Flutter からの playersChanged メッセージを受信するハンドラを登録する。 */
236
257
  declare function onPlayersChanged(handler: PlayersChangedHandler): void;
237
258
  /**
@@ -245,4 +266,4 @@ declare function onPlayersChanged(handler: PlayersChangedHandler): void;
245
266
  */
246
267
  declare function run<S, A extends ActionMap<S> = ActionMap<S>, SA extends ServerActionMap<S> = Record<never, never>>(config: GameConfig<S, A, SA>): void;
247
268
  //#endregion
248
- export { type ActionArgs, type ActionContext, type ActionHandler, type ActionMap, type BridgeChannel, type BridgeMessage, type ConnectionCallbacks, type ConnectionState, DEFAULT_ICON_URLS, type Deadline, type DeadlineArgs, type DeadlineContext, type DevHooksCtx, type Duration, type Emit, type EventHandler, type EventSubscription, GAME_START, type GameConfig, type GameLogic, type GameTime, type Insets, type JsonMergePatch, type JsonPatchOp, type Operation, type PayloadMap, type PlayScreenMessage, type PlayerVoiceState, type PlayersChangedMessage, type PredictionWarning, type ReconnectableWSOptions, ReconnectableWebSocket, type RunHandle, type Seat, type SeatKind, type SeededRandom, SeededRandomImpl, type SendAction, type ServerActionArgs, type ServerActionContext, type ServerActionHandler, type ServerActionMap, type ServerEvent, type ServerOnlyAction, type ServerOnlyActionContext, type ServerOnlyActionHandlerFn, type SetupArgs, type SetupContext, type UpdateArgs, type UpdateContext, type UzuDevHooks, type UzuInsets, applyJsonMergePatch, applyJsonPatch, attachDevHooks, changeRoom, createDevHooks, firstFrameReady, gameReady, gameTime, getInsets, getPredictionWarnings, init, isHosted, isPaused, isServerOnlyAction, minus, on, onInsetsChange, onPauseChange, onPlayersChanged, playBgm, playSound, plus, run, send, serverOnly, setMicEnabled, stopBgm, sub };
269
+ export { type ActionArgs, type ActionContext, type ActionHandler, type ActionMap, type BridgeChannel, type BridgeMessage, type ConnectionCallbacks, type ConnectionState, DEFAULT_ICON_URLS, type Deadline, type DeadlineArgs, type DeadlineContext, type DevHooksCtx, type Duration, type Emit, type EventHandler, type EventSubscription, GAME_START, type GameConfig, type GameLogic, type GameTime, type Insets, type JsonMergePatch, type JsonPatchOp, type Operation, type PayloadMap, type PlayScreenMessage, type PlayerVoiceState, type PlayersChangedMessage, type PredictionWarning, type ReconnectableWSOptions, ReconnectableWebSocket, type RunHandle, type Seat, type SeatKind, type SeededRandom, SeededRandomImpl, type SendAction, type ServerActionArgs, type ServerActionContext, type ServerActionHandler, type ServerActionMap, type ServerEvent, type ServerOnlyAction, type ServerOnlyActionContext, type ServerOnlyActionHandlerFn, type SetupArgs, type SetupContext, type UpdateArgs, type UpdateContext, type UzuDevHooks, type UzuInsets, applyJsonMergePatch, applyJsonPatch, attachDevHooks, changeRoom, createDevHooks, finishGame, firstFrameReady, gameReady, gameTime, getInsets, getPredictionWarnings, init, isHosted, isPaused, isServerOnlyAction, minus, on, onInsetsChange, onPauseChange, onPlayersChanged, playBgm, playSound, plus, run, send, serverOnly, setMicEnabled, stopBgm, sub };
package/dist/index.js CHANGED
@@ -2075,6 +2075,29 @@ function firstFrameReady() {
2075
2075
  function gameReady() {
2076
2076
  sendRaw("sdk", "gameReady", {});
2077
2077
  }
2078
+ /**
2079
+ * ゲームを終えてプレイ画面を閉じるよう Flutter ホストに通知する。
2080
+ *
2081
+ * 閉じるのは**呼んだ端末だけ**。全員を閉じたいときは、終了を表す state を全員へ配り、
2082
+ * 各端末の `onState` から呼ぶ。ホストはイベントを終了扱いにし (finishedAt を立てるのは
2083
+ * 最初の 1 人だけ)、呼んだプレイヤーを退出させてから画面を閉じる。
2084
+ *
2085
+ * 呼び出しタイミング: 結果や感想戦を見終えて閉じるときなど、シナリオとしてゲームが完全に
2086
+ * 終わった瞬間。勝敗が決まった瞬間 (`gameover` など) に呼ぶと、結果を見る前に画面が閉じる。
2087
+ *
2088
+ * 対応していない古いアプリや `uzu dev` harness では何も起きない。呼んだあとも画面を
2089
+ * 操作不能にしないこと。
2090
+ *
2091
+ * @example
2092
+ * ```ts
2093
+ * onState(state) {
2094
+ * if (state.debriefClosed) finishGame();
2095
+ * }
2096
+ * ```
2097
+ */
2098
+ function finishGame() {
2099
+ sendRaw("sdk", "finishGame", {});
2100
+ }
2078
2101
  /** Flutter からの playersChanged メッセージを受信するハンドラを登録する。 */
2079
2102
  function onPlayersChanged(handler) {
2080
2103
  _playersChangedHandlers.push(handler);
@@ -2196,4 +2219,4 @@ function handleMessage(msg) {
2196
2219
  }
2197
2220
  }
2198
2221
  //#endregion
2199
- export { DEFAULT_ICON_URLS, GAME_START, ReconnectableWebSocket, SeededRandomImpl, applyJsonMergePatch, applyJsonPatch, attachDevHooks, changeRoom, createDevHooks, firstFrameReady, gameReady, gameTime, getInsets, getPredictionWarnings, init, isHosted, isPaused, isServerOnlyAction, minus, on, onInsetsChange, onPauseChange, onPlayersChanged, playBgm, playSound, plus, run, send, serverOnly, setMicEnabled, stopBgm, sub };
2222
+ export { DEFAULT_ICON_URLS, GAME_START, ReconnectableWebSocket, SeededRandomImpl, applyJsonMergePatch, applyJsonPatch, attachDevHooks, changeRoom, createDevHooks, finishGame, firstFrameReady, gameReady, gameTime, getInsets, getPredictionWarnings, init, isHosted, isPaused, isServerOnlyAction, minus, on, onInsetsChange, onPauseChange, onPlayersChanged, playBgm, playSound, plus, run, send, serverOnly, setMicEnabled, stopBgm, sub };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uzuhq/code-sdk",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "description": "UZU PlayScreen SDK - Flutter ↔ JS ゲーム通信ライブラリ",
5
5
  "type": "module",
6
6
  "exports": {