@uzuhq/code-sdk 0.8.10 → 0.8.11
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 +15 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +19 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -296,6 +296,21 @@ changeRoom(null); // デフォルトルーム(全員が同じ音声チャン
|
|
|
296
296
|
- 初期状態ではすべてのプレイヤーがデフォルトルーム(`null`)に所属する
|
|
297
297
|
- `roomId` に文字列を指定すると、そのプレイヤーは指定ルームへ移動する
|
|
298
298
|
|
|
299
|
+
### `haptic(kind: 'light' | 'medium' | 'heavy'): void`
|
|
300
|
+
|
|
301
|
+
端末を短く振動させる。アプリ内では `navigator.vibrate` が効かないので、代わりにこれを使う。
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
import { haptic } from '@uzuhq/code-sdk';
|
|
305
|
+
|
|
306
|
+
haptic('light'); // 手がかり入手など
|
|
307
|
+
haptic('heavy'); // 画面が揺れる演出など
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
- 長さは指定できない(iOS の触覚は種類でしか選べないため、段階で渡す)
|
|
311
|
+
- 端末の設定で触覚を切っている人には効かない
|
|
312
|
+
- ブラウザで単独で開いたときは `navigator.vibrate` にフォールバックする
|
|
313
|
+
|
|
299
314
|
### `finishGame(): void`
|
|
300
315
|
|
|
301
316
|
ゲームを終えて、この端末のプレイ画面を閉じる。ホストはイベントを終了扱いにし、呼んだプレイヤーを退出させる。
|
package/dist/index.d.ts
CHANGED
|
@@ -198,6 +198,20 @@ declare const playBgm: (sound: string) => void;
|
|
|
198
198
|
declare const stopBgm: () => void;
|
|
199
199
|
declare const setMicEnabled: (enabled: boolean) => void;
|
|
200
200
|
declare const changeRoom: (roomId: string | null) => void;
|
|
201
|
+
/**
|
|
202
|
+
* 振動の強さ。
|
|
203
|
+
*
|
|
204
|
+
* ミリ秒ではなく段階で渡すのは、iOS の触覚が長さを指定できず種類で選ぶ仕組みだから。
|
|
205
|
+
* 段階なら iOS / Android で同じ意味になる。
|
|
206
|
+
*/
|
|
207
|
+
type HapticKind = 'light' | 'medium' | 'heavy';
|
|
208
|
+
/**
|
|
209
|
+
* 端末を短く振動させる。
|
|
210
|
+
*
|
|
211
|
+
* アプリの WebView では `navigator.vibrate` が効かない (iOS には Web から振動させる手段が
|
|
212
|
+
* 無い) ので、ホストへ依頼する。端末の設定で触覚を切っている人には OS 側で効かない。
|
|
213
|
+
*/
|
|
214
|
+
declare const haptic: (kind: HapticKind) => void;
|
|
201
215
|
/**
|
|
202
216
|
* splash 描画完了を Flutter ホストに通知する。
|
|
203
217
|
*
|
|
@@ -266,4 +280,4 @@ declare const onPlayersChanged: (handler: PlayersChangedHandler) => void;
|
|
|
266
280
|
*/
|
|
267
281
|
declare const run: <S, A extends ActionMap<S> = ActionMap<S>, SA extends ServerActionMap<S> = Record<never, never>>(config: GameConfig<S, A, SA>) => void;
|
|
268
282
|
//#endregion
|
|
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 };
|
|
283
|
+
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, HapticKind, 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, haptic, init, isHosted, isPaused, isServerOnlyAction, minus, on, onInsetsChange, onPauseChange, onPlayersChanged, playBgm, playSound, plus, run, send, serverOnly, setMicEnabled, stopBgm, sub };
|
package/dist/index.js
CHANGED
|
@@ -2031,6 +2031,24 @@ const setMicEnabled = (enabled) => {
|
|
|
2031
2031
|
const changeRoom = (roomId) => {
|
|
2032
2032
|
sendRaw("sdk", "changeRoom", { roomId });
|
|
2033
2033
|
};
|
|
2034
|
+
const HAPTIC_FALLBACK_MS = {
|
|
2035
|
+
light: 10,
|
|
2036
|
+
medium: 20,
|
|
2037
|
+
heavy: 30
|
|
2038
|
+
};
|
|
2039
|
+
/**
|
|
2040
|
+
* 端末を短く振動させる。
|
|
2041
|
+
*
|
|
2042
|
+
* アプリの WebView では `navigator.vibrate` が効かない (iOS には Web から振動させる手段が
|
|
2043
|
+
* 無い) ので、ホストへ依頼する。端末の設定で触覚を切っている人には OS 側で効かない。
|
|
2044
|
+
*/
|
|
2045
|
+
const haptic = (kind) => {
|
|
2046
|
+
if (!isHosted) {
|
|
2047
|
+
if ("vibrate" in navigator) navigator.vibrate(HAPTIC_FALLBACK_MS[kind]);
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
sendRaw("sdk", "haptic", { kind });
|
|
2051
|
+
};
|
|
2034
2052
|
/**
|
|
2035
2053
|
* splash 描画完了を Flutter ホストに通知する。
|
|
2036
2054
|
*
|
|
@@ -2226,4 +2244,4 @@ const handleMessage = (msg) => {
|
|
|
2226
2244
|
for (const fn of h) callScenario(`game/${type} ハンドラ`, () => fn(payload));
|
|
2227
2245
|
};
|
|
2228
2246
|
//#endregion
|
|
2229
|
-
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 };
|
|
2247
|
+
export { DEFAULT_ICON_URLS, GAME_START, ReconnectableWebSocket, SeededRandomImpl, applyJsonMergePatch, applyJsonPatch, attachDevHooks, changeRoom, createDevHooks, finishGame, firstFrameReady, gameReady, gameTime, getInsets, getPredictionWarnings, haptic, init, isHosted, isPaused, isServerOnlyAction, minus, on, onInsetsChange, onPauseChange, onPlayersChanged, playBgm, playSound, plus, run, send, serverOnly, setMicEnabled, stopBgm, sub };
|