@uzuhq/code-sdk 0.8.12 → 0.9.0
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 +184 -76
- package/dist/dev-globals.d.ts +1 -1
- package/dist/{dev-hooks-7UDN8Xac.d.ts → dev-hooks-D30dnLtR.d.ts} +75 -17
- package/dist/index.d.ts +161 -12
- package/dist/index.js +573 -101
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as GAME_START, A as Emit, B as ServerOnlyActionContext, C as ActionContext, D as Deadline, E as DEFAULT_ICON_URLS, F as ServerActionContext, G as UpdateContext, H as SetupArgs, I as ServerActionHandler, J as Pause, K as DEFAULT_VOICE_PLAN, L as ServerActionMap, M as Seat, N as SeededRandom, O as DeadlineArgs, P as ServerActionArgs, Q as Duration, R as ServerEvent, S as ActionArgs, T as ActionMap, U as SetupContext, V as ServerOnlyActionHandlerFn, W as UpdateArgs, X as VoicePlan, Y as SeatId, Z as VoicePlanArgs, _ as GameConfig, a as createDevHooks, b as SeatKind, c as applyJsonMergePatch, d as getPredictionWarnings, et as GameTime, f as BridgeChannel, g as EventSubscription, h as EventHandler, i as attachDevHooks, j as GameLogic, k as DeadlineContext, l as applyJsonPatch, m as ConnectionState, n as RunHandle, nt as plus, o as JsonMergePatch, p as BridgeMessage, q as MicPolicy, r as UzuDevHooks, rt as sub, s as JsonPatchOp, t as DevHooksCtx, tt as minus, u as PredictionWarning, v as PayloadMap, w as ActionHandler, x as SendAction, y as PlayScreenMessage, z as ServerOnlyAction } from "./dev-hooks-D30dnLtR.js";
|
|
2
2
|
//#region ../engine-core/src/json-patch.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* @docs
|
|
@@ -53,11 +53,151 @@ declare const isServerOnlyAction: <S>(handler: ActionHandler<S> | ServerActionHa
|
|
|
53
53
|
*/
|
|
54
54
|
declare const gameTime: () => GameTime;
|
|
55
55
|
//#endregion
|
|
56
|
-
//#region src/
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
//#region src/presence-types.d.ts
|
|
57
|
+
/** マイクの状態。サーバーが配る方針と、本人の操作を合わせた結果。 */
|
|
58
|
+
type Mic = {
|
|
59
|
+
status: 'open';
|
|
60
|
+
} |
|
|
61
|
+
/** scenario = 場面の頭で切られたまま。本人は戻せる。 */
|
|
62
|
+
{
|
|
63
|
+
status: 'muted';
|
|
64
|
+
by: 'self' | 'scenario';
|
|
65
|
+
} |
|
|
66
|
+
/** 場面の間は本人も解除できない。 */
|
|
67
|
+
{
|
|
68
|
+
status: 'locked';
|
|
69
|
+
} |
|
|
70
|
+
/** ライブ配信の観戦者。聴くだけで話せない。 */
|
|
71
|
+
{
|
|
72
|
+
status: 'listen-only';
|
|
73
|
+
};
|
|
74
|
+
type Quality = 'good' | 'poor';
|
|
75
|
+
/**
|
|
76
|
+
* 接続と通話の状態。誰か (名前・キャラクター) は名簿 (setup の players / state) から、
|
|
77
|
+
* 自分の席 ID と席種は `onState` の引数から引く。同じ情報を 2 か所に持たせない。
|
|
78
|
+
*/
|
|
79
|
+
type Presence = {
|
|
80
|
+
/** 観測席でも必ずある。 */
|
|
81
|
+
me: Me;
|
|
82
|
+
/** 自分以外のプレイヤー。キーは席 ID。 */
|
|
83
|
+
others: Record<SeatId, Other>;
|
|
84
|
+
/** 観測席 (観戦・進行管理) は人数と、今話している人だけ。 */
|
|
85
|
+
observers: {
|
|
86
|
+
count: number;
|
|
87
|
+
speaking: ObserverRef[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/** 観測席は名簿にいないので、話している人を出すための最小限だけ持つ。 */
|
|
91
|
+
type ObserverRef = {
|
|
92
|
+
id: SeatId;
|
|
93
|
+
nickname: string;
|
|
94
|
+
};
|
|
95
|
+
type Me = {
|
|
96
|
+
/** 自分のゲームの接続。since は端末の時刻 (ms)。 */
|
|
97
|
+
connection: {
|
|
98
|
+
status: 'online';
|
|
99
|
+
} | {
|
|
100
|
+
status: 'connecting' | 'reconnecting' | 'offline';
|
|
101
|
+
since: number;
|
|
102
|
+
};
|
|
103
|
+
voice:
|
|
104
|
+
/** 卓が通話を使わない / この端末は通話に入らない (エミュレータなど)。 */
|
|
105
|
+
{
|
|
106
|
+
status: 'off';
|
|
107
|
+
reason: 'table' | 'this-device';
|
|
108
|
+
} | {
|
|
109
|
+
status: 'connecting' | 'reconnecting';
|
|
110
|
+
since: number;
|
|
111
|
+
} | {
|
|
112
|
+
status: 'failed';
|
|
113
|
+
reason: 'mic-permission' | 'network';
|
|
114
|
+
since: number;
|
|
115
|
+
} | {
|
|
116
|
+
status: 'here';
|
|
117
|
+
room: string | null;
|
|
118
|
+
mic: Mic;
|
|
119
|
+
speaking: boolean;
|
|
120
|
+
quality: Quality;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* 自分以外のプレイヤー。出すのは声が届くかだけ。
|
|
125
|
+
*
|
|
126
|
+
* ゲームの接続は出さない。アプリが裏に回るとゲーム画面は止まるが、通話は続くので、
|
|
127
|
+
* 接続で判断すると、話せている人を「いない」と扱ってしまう。
|
|
128
|
+
*/
|
|
129
|
+
type Other = {
|
|
130
|
+
voice: {
|
|
131
|
+
status: 'off';
|
|
132
|
+
} |
|
|
133
|
+
/** 自分と同じ部屋で聞こえている。 */
|
|
134
|
+
{
|
|
135
|
+
status: 'here';
|
|
136
|
+
mic: Mic;
|
|
137
|
+
speaking: boolean;
|
|
138
|
+
quality: Quality;
|
|
139
|
+
} |
|
|
140
|
+
/** 本人の申告で、別の部屋にいる。 */
|
|
141
|
+
{
|
|
142
|
+
status: 'elsewhere';
|
|
143
|
+
room: string | null;
|
|
144
|
+
} |
|
|
145
|
+
/**
|
|
146
|
+
* 声が届かない。本人の通話が切れた (サーバーが確定した) か、自分と同じ部屋にいるはずなのに
|
|
147
|
+
* この端末で聞こえなくなった。since は届かなくなった端末の時刻 (ms)。
|
|
148
|
+
*/
|
|
149
|
+
{
|
|
150
|
+
status: 'lost';
|
|
151
|
+
since: number;
|
|
152
|
+
} |
|
|
153
|
+
/**
|
|
154
|
+
* 自分が通話にいない / 本人の申告が届かず、自分にも聞こえていない
|
|
155
|
+
* (まだ一度も入っていない人もここ)。
|
|
156
|
+
*/
|
|
157
|
+
{
|
|
158
|
+
status: 'unknown';
|
|
159
|
+
reason: 'me-not-connected' | 'no-report';
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
type ConnectionStatus = Me['connection']['status'];
|
|
163
|
+
type VoiceStatus = Me['voice']['status'] | Other['voice']['status'];
|
|
164
|
+
/** 変わったところ。自分の変化も入る (seatId は自分の席 ID)。発話とミュートは入らない。 */
|
|
165
|
+
type PresenceChange =
|
|
166
|
+
/** 自分のゲームの接続だけ。他の人の接続は出さない。 */
|
|
167
|
+
{
|
|
168
|
+
kind: 'connection';
|
|
169
|
+
seatId: SeatId;
|
|
170
|
+
from: ConnectionStatus;
|
|
171
|
+
to: ConnectionStatus;
|
|
172
|
+
} | {
|
|
173
|
+
kind: 'voice';
|
|
174
|
+
seatId: SeatId;
|
|
175
|
+
from: VoiceStatus;
|
|
176
|
+
to: VoiceStatus;
|
|
177
|
+
} | {
|
|
178
|
+
kind: 'observers';
|
|
179
|
+
from: number;
|
|
180
|
+
to: number;
|
|
181
|
+
};
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/presence.d.ts
|
|
184
|
+
type PresenceListener = (presence: Presence, changes: PresenceChange[]) => void;
|
|
185
|
+
type PauseListener = (pause: Pause) => void;
|
|
186
|
+
/** 今の接続と通話の状態。 */
|
|
187
|
+
declare const getPresence: () => Presence;
|
|
188
|
+
/**
|
|
189
|
+
* 接続と通話の状態が変わったときに呼ばれる。値全体と、変わったところの一覧を渡す。
|
|
190
|
+
* 発話やミュートの変化では `changes` は空で、値だけが新しくなる。
|
|
191
|
+
* 戻り値を呼ぶと、呼ばれなくなる。
|
|
192
|
+
*/
|
|
193
|
+
declare const onPresenceChange: (listener: PresenceListener) => (() => void);
|
|
194
|
+
/** 今止まっているか、止まっていればその理由。止まっていなければ null。 */
|
|
195
|
+
declare const getPause: () => Pause;
|
|
196
|
+
/**
|
|
197
|
+
* 止まった・再開したときに呼ばれる。理由は今後増えることがあるので、知らない理由でも止まって
|
|
198
|
+
* いるものとして扱う。戻り値を呼ぶと、呼ばれなくなる。
|
|
199
|
+
*/
|
|
200
|
+
declare const onPauseChange: (listener: PauseListener) => (() => void);
|
|
61
201
|
//#endregion
|
|
62
202
|
//#region src/reconnectable-ws.d.ts
|
|
63
203
|
/**
|
|
@@ -178,7 +318,6 @@ declare const onInsetsChange: (cb: (insets: UzuInsets) => void) => (() => void);
|
|
|
178
318
|
//#endregion
|
|
179
319
|
//#region src/index.d.ts
|
|
180
320
|
type GameMessageHandler = (payload: Record<string, unknown>) => void;
|
|
181
|
-
type PlayersChangedHandler = (players: Record<string, PlayerVoiceState>) => void;
|
|
182
321
|
declare const isHosted: boolean;
|
|
183
322
|
declare const init: (_opts?: {
|
|
184
323
|
playerCount?: number;
|
|
@@ -196,8 +335,20 @@ declare const on: (type: string, handler: GameMessageHandler) => void;
|
|
|
196
335
|
declare const playSound: (sound: string) => void;
|
|
197
336
|
declare const playBgm: (sound: string) => void;
|
|
198
337
|
declare const stopBgm: () => void;
|
|
199
|
-
|
|
200
|
-
|
|
338
|
+
/**
|
|
339
|
+
* 観測席 (観戦・進行管理) が聴く通話の部屋を選ぶ。null は全体の部屋。
|
|
340
|
+
*
|
|
341
|
+
* プレイヤーの部屋はロジックの `voicePlan` が決めるので、プレイヤー席では何も起きない。
|
|
342
|
+
*/
|
|
343
|
+
declare const setListeningRoom: (room: string | null) => void;
|
|
344
|
+
/**
|
|
345
|
+
* 本人のマイクをミュートする。
|
|
346
|
+
*
|
|
347
|
+
* 作品からできるのはミュートだけで、外すことはできない。外すのは本人が HUD のマイクボタンで
|
|
348
|
+
* 行う。勝手にマイクを開くと、本人の知らないうちに声が他の人へ届いてしまうため。
|
|
349
|
+
* 場面ごとに決まったミュートは `voicePlan` の `mic` で宣言する。
|
|
350
|
+
*/
|
|
351
|
+
declare const muteMic: () => void;
|
|
201
352
|
/**
|
|
202
353
|
* 振動の強さ。
|
|
203
354
|
*
|
|
@@ -267,8 +418,6 @@ declare const gameReady: () => void;
|
|
|
267
418
|
* ```
|
|
268
419
|
*/
|
|
269
420
|
declare const finishGame: () => void;
|
|
270
|
-
/** Flutter からの playersChanged メッセージを受信するハンドラを登録する。 */
|
|
271
|
-
declare const onPlayersChanged: (handler: PlayersChangedHandler) => void;
|
|
272
421
|
/**
|
|
273
422
|
* `A` に既定値が要る。 TypeScript は型引数の部分推論ができないので、 既定が無いと
|
|
274
423
|
* 既存の `run<State>({…})` が「2 つ必要」で落ちる。 既定を置けば型引数を書かない
|
|
@@ -280,4 +429,4 @@ declare const onPlayersChanged: (handler: PlayersChangedHandler) => void;
|
|
|
280
429
|
*/
|
|
281
430
|
declare const run: <S, A extends ActionMap<S> = ActionMap<S>, SA extends ServerActionMap<S> = Record<never, never>>(config: GameConfig<S, A, SA>) => void;
|
|
282
431
|
//#endregion
|
|
283
|
-
export { type ActionArgs, type ActionContext, type ActionHandler, type ActionMap, type BridgeChannel, type BridgeMessage, type
|
|
432
|
+
export { type ActionArgs, type ActionContext, type ActionHandler, type ActionMap, type BridgeChannel, type BridgeMessage, type ConnectionState, type ConnectionStatus, DEFAULT_ICON_URLS, DEFAULT_VOICE_PLAN, type Deadline, type DeadlineArgs, type DeadlineContext, type DevHooksCtx, type Duration, type Emit, type EventHandler, type EventSubscription, GAME_START, type GameConfig, type GameLogic, type GameTime, HapticKind, type Insets, type JsonMergePatch, type JsonPatchOp, type Me, type Mic, type MicPolicy, type ObserverRef, type Operation, type Other, type Pause, type PayloadMap, type PlayScreenMessage, type PredictionWarning, type Presence, type PresenceChange, type Quality, type ReconnectableWSOptions, ReconnectableWebSocket, type RunHandle, type Seat, type SeatId, 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, type VoicePlan, type VoicePlanArgs, type VoiceStatus, applyJsonMergePatch, applyJsonPatch, attachDevHooks, createDevHooks, finishGame, firstFrameReady, gameReady, gameTime, getInsets, getPause, getPredictionWarnings, getPresence, haptic, init, isHosted, isServerOnlyAction, minus, muteMic, on, onInsetsChange, onPauseChange, onPresenceChange, playBgm, playSound, plus, run, send, serverOnly, setListeningRoom, stopBgm, sub };
|