@gbraver-burst-network/browser-sdk 1.9.5 → 1.9.6

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 (38) hide show
  1. package/lib/src/browser-sdk/battle-sdk.d.ts +5 -9
  2. package/lib/src/browser-sdk/battle-sdk.js +33 -10
  3. package/lib/src/browser-sdk/casual-match.d.ts +2 -2
  4. package/lib/src/browser-sdk/private-match.d.ts +3 -3
  5. package/lib/src/index.d.ts +8 -9
  6. package/lib/src/index.js +1 -1
  7. package/lib/src/request/create-private-match-room.d.ts +2 -2
  8. package/lib/src/request/enter-casual-match.d.ts +2 -2
  9. package/lib/src/request/enter-private-match-room.d.ts +2 -2
  10. package/lib/src/response/accept-command.d.ts +4 -2
  11. package/lib/src/response/accept-command.js +8 -9
  12. package/lib/src/response/battle-end.d.ts +3510 -3
  13. package/lib/src/response/battle-end.js +10 -11
  14. package/lib/src/response/battle-progressed.d.ts +3513 -3
  15. package/lib/src/response/battle-progressed.js +11 -14
  16. package/lib/src/response/battle-start.d.ts +4399 -3
  17. package/lib/src/response/battle-start.js +15 -24
  18. package/lib/src/response/cloud-not-private-match-making.d.ts +10 -1
  19. package/lib/src/response/cloud-not-private-match-making.js +8 -9
  20. package/lib/src/response/created-private-match-room.d.ts +13 -1
  21. package/lib/src/response/created-private-match-room.js +9 -11
  22. package/lib/src/response/entered-casual-match.d.ts +10 -2
  23. package/lib/src/response/entered-casual-match.js +8 -9
  24. package/lib/src/response/error.d.ts +1 -0
  25. package/lib/src/response/not-ready-battle-progress.d.ts +10 -2
  26. package/lib/src/response/not-ready-battle-progress.js +8 -9
  27. package/lib/src/response/pong.d.ts +13 -2
  28. package/lib/src/response/pong.js +9 -10
  29. package/lib/src/response/reject-private-match-entry.d.ts +10 -1
  30. package/lib/src/response/reject-private-match-entry.js +8 -7
  31. package/lib/src/response/suddenly-battle-end.d.ts +10 -2
  32. package/lib/src/response/suddenly-battle-end.js +8 -9
  33. package/lib/src/websocket/create-private-match-room.d.ts +2 -2
  34. package/lib/src/websocket/enter-casual-match.d.ts +2 -2
  35. package/lib/src/websocket/enter-private-match-room.d.ts +2 -2
  36. package/package.json +11 -10
  37. /package/lib/src/browser-sdk/{browser-sdk.d.ts → index.d.ts} +0 -0
  38. /package/lib/src/browser-sdk/{browser-sdk.js → index.js} +0 -0
@@ -1,4 +1,4 @@
1
- import type { Command, GameState, Player } from "gbraver-burst-core";
1
+ import { Command, GameState, Player } from "gbraver-burst-core";
2
2
  import { Observable } from "rxjs";
3
3
  import { Battle } from "./battle";
4
4
  /** コンストラクタのパラメータ */
@@ -20,17 +20,13 @@ type Param = {
20
20
  };
21
21
  /** バトルSDK */
22
22
  export declare class BattleSDK implements Battle {
23
+ #private;
23
24
  /** @override */
24
- player: Player;
25
+ readonly player: Player;
25
26
  /** @override */
26
- enemy: Player;
27
+ readonly enemy: Player;
27
28
  /** @override */
28
- initialState: GameState[];
29
- _websocket: WebSocket;
30
- _battleID: string;
31
- _flowID: string;
32
- _isPoller: boolean;
33
- _suddenlyBattleEnd: Observable<unknown>;
29
+ readonly initialState: GameState[];
34
30
  /**
35
31
  * コンストラクタ
36
32
  *
@@ -8,6 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var _BattleSDK_websocket, _BattleSDK_battleID, _BattleSDK_flowID, _BattleSDK_isPoller, _BattleSDK_suddenlyBattleEnd;
11
23
  Object.defineProperty(exports, "__esModule", { value: true });
12
24
  exports.BattleSDK = void 0;
13
25
  const rxjs_1 = require("rxjs");
@@ -22,30 +34,41 @@ class BattleSDK {
22
34
  * @param param パラメータ
23
35
  */
24
36
  constructor(param) {
37
+ /** websocketクライアント */
38
+ _BattleSDK_websocket.set(this, void 0);
39
+ /** バトルID */
40
+ _BattleSDK_battleID.set(this, void 0);
41
+ /** フローID */
42
+ _BattleSDK_flowID.set(this, void 0);
43
+ /** ポーリング実行プレイヤーであるか否か、trueでポーリングする */
44
+ _BattleSDK_isPoller.set(this, void 0);
45
+ /** バトル突然終了通知ストリーム */
46
+ _BattleSDK_suddenlyBattleEnd.set(this, void 0);
25
47
  this.player = param.player;
26
48
  this.enemy = param.enemy;
27
49
  this.initialState = param.initialState;
28
- this._websocket = param.websocket;
29
- this._battleID = param.battleID;
30
- this._flowID = param.initialFlowID;
31
- this._isPoller = param.isPoller;
32
- this._suddenlyBattleEnd = (0, rxjs_1.fromEvent)(this._websocket, "message").pipe((0, rxjs_1.map)((e) => e), (0, rxjs_1.map)((e) => (0, parse_1.parseJSON)(e.data)), (0, rxjs_1.filter)((data) => data), (0, rxjs_1.map)((data) => (0, suddenly_battle_end_1.parseSuddenlyBattleEnd)(data)), (0, rxjs_1.filter)((sudenlyBattleEnd) => !!sudenlyBattleEnd));
50
+ __classPrivateFieldSet(this, _BattleSDK_websocket, param.websocket, "f");
51
+ __classPrivateFieldSet(this, _BattleSDK_battleID, param.battleID, "f");
52
+ __classPrivateFieldSet(this, _BattleSDK_flowID, param.initialFlowID, "f");
53
+ __classPrivateFieldSet(this, _BattleSDK_isPoller, param.isPoller, "f");
54
+ __classPrivateFieldSet(this, _BattleSDK_suddenlyBattleEnd, (0, rxjs_1.fromEvent)(__classPrivateFieldGet(this, _BattleSDK_websocket, "f"), "message").pipe((0, rxjs_1.map)((e) => e), (0, rxjs_1.map)((e) => (0, parse_1.parseJSON)(e.data)), (0, rxjs_1.filter)((data) => data), (0, rxjs_1.map)((data) => (0, suddenly_battle_end_1.parseSuddenlyBattleEnd)(data)), (0, rxjs_1.filter)((sudenlyBattleEnd) => !!sudenlyBattleEnd)), "f");
33
55
  }
34
56
  /** @override */
35
57
  progress(command) {
36
58
  return __awaiter(this, void 0, void 0, function* () {
37
- const result = this._isPoller
38
- ? yield (0, send_command_1.sendCommandWithPolling)(this._websocket, this._battleID, this._flowID, command)
39
- : yield (0, send_command_1.sendCommand)(this._websocket, this._battleID, this._flowID, command);
59
+ const result = __classPrivateFieldGet(this, _BattleSDK_isPoller, "f")
60
+ ? yield (0, send_command_1.sendCommandWithPolling)(__classPrivateFieldGet(this, _BattleSDK_websocket, "f"), __classPrivateFieldGet(this, _BattleSDK_battleID, "f"), __classPrivateFieldGet(this, _BattleSDK_flowID, "f"), command)
61
+ : yield (0, send_command_1.sendCommand)(__classPrivateFieldGet(this, _BattleSDK_websocket, "f"), __classPrivateFieldGet(this, _BattleSDK_battleID, "f"), __classPrivateFieldGet(this, _BattleSDK_flowID, "f"), command);
40
62
  if (result.action === "battle-progressed") {
41
- this._flowID = result.flowID;
63
+ __classPrivateFieldSet(this, _BattleSDK_flowID, result.flowID, "f");
42
64
  }
43
65
  return result.update;
44
66
  });
45
67
  }
46
68
  /** @override */
47
69
  suddenlyBattleNotifier() {
48
- return this._suddenlyBattleEnd;
70
+ return __classPrivateFieldGet(this, _BattleSDK_suddenlyBattleEnd, "f");
49
71
  }
50
72
  }
51
73
  exports.BattleSDK = BattleSDK;
74
+ _BattleSDK_websocket = new WeakMap(), _BattleSDK_battleID = new WeakMap(), _BattleSDK_flowID = new WeakMap(), _BattleSDK_isPoller = new WeakMap(), _BattleSDK_suddenlyBattleEnd = new WeakMap();
@@ -1,4 +1,4 @@
1
- import type { ArmDozerId, PilotId } from "gbraver-burst-core";
1
+ import type { ArmdozerId, PilotId } from "gbraver-burst-core";
2
2
  import type { Battle } from "./battle";
3
3
  /**
4
4
  * カジュアルマッチ
@@ -12,5 +12,5 @@ export interface CasualMatch {
12
12
  * @param pilotId 選択したパイロットID
13
13
  * @return バトル
14
14
  */
15
- startCasualMatch(armdozerId: ArmDozerId, pilotId: PilotId): Promise<Battle>;
15
+ startCasualMatch(armdozerId: ArmdozerId, pilotId: PilotId): Promise<Battle>;
16
16
  }
@@ -1,4 +1,4 @@
1
- import { ArmDozerId, PilotId } from "gbraver-burst-core";
1
+ import { ArmdozerId, PilotId } from "gbraver-burst-core";
2
2
  import { Battle } from "./battle";
3
3
  /** プライベートマッチルーム生成 */
4
4
  export interface PrivateMatchCreate {
@@ -8,7 +8,7 @@ export interface PrivateMatchCreate {
8
8
  * @param pilotId 選択したパイロットのID
9
9
  * @return 生成したプライベートマッチルームのID
10
10
  */
11
- createPrivateMatchRoom(armdozerId: ArmDozerId, pilotId: PilotId): Promise<PrivateMatchRoom>;
11
+ createPrivateMatchRoom(armdozerId: ArmdozerId, pilotId: PilotId): Promise<PrivateMatchRoom>;
12
12
  }
13
13
  /** プライベートマッチルームID */
14
14
  export type PrivateMatchRoomID = string;
@@ -32,5 +32,5 @@ export interface PrivateMatchRoomEnter {
32
32
  * @param pilotId 選択したパイロット
33
33
  * @return マッチング結果
34
34
  */
35
- enterPrivateMatchRoom(roomID: PrivateMatchRoomID, armdozerId: ArmDozerId, pilotId: PilotId): Promise<Battle | null>;
35
+ enterPrivateMatchRoom(roomID: PrivateMatchRoomID, armdozerId: ArmdozerId, pilotId: PilotId): Promise<Battle | null>;
36
36
  }
@@ -1,9 +1,8 @@
1
- export type { Battle } from "./browser-sdk/battle";
2
- export type { BrowserSDK } from "./browser-sdk/browser-sdk";
3
- export { createBrowserSDK } from "./browser-sdk/browser-sdk";
4
- export type { CasualMatch } from "./browser-sdk/casual-match";
5
- export type { LoginCheck, Logout, UniversalLogin } from "./browser-sdk/login";
6
- export type { Ping } from "./browser-sdk/ping";
7
- export type { PrivateMatchCreate, PrivateMatchRoom, PrivateMatchRoomEnter, PrivateMatchRoomID, } from "./browser-sdk/private-match";
8
- export type { LoggedInUserDelete, MailVerify, UserMailGet, UserNameGet, UserPictureGet, } from "./browser-sdk/user";
9
- export type { WebsocketDisconnect, WebsocketErrorNotifier, } from "./browser-sdk/websocket";
1
+ export { BrowserSDK, createBrowserSDK } from "./browser-sdk";
2
+ export { Battle } from "./browser-sdk/battle";
3
+ export { CasualMatch } from "./browser-sdk/casual-match";
4
+ export { LoginCheck, Logout, UniversalLogin } from "./browser-sdk/login";
5
+ export { Ping } from "./browser-sdk/ping";
6
+ export { PrivateMatchCreate, PrivateMatchRoom, PrivateMatchRoomEnter, PrivateMatchRoomID, } from "./browser-sdk/private-match";
7
+ export { LoggedInUserDelete, MailVerify, UserMailGet, UserNameGet, UserPictureGet, } from "./browser-sdk/user";
8
+ export { WebsocketDisconnect, WebsocketErrorNotifier, } from "./browser-sdk/websocket";
package/lib/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createBrowserSDK = void 0;
4
- var browser_sdk_1 = require("./browser-sdk/browser-sdk");
4
+ var browser_sdk_1 = require("./browser-sdk");
5
5
  Object.defineProperty(exports, "createBrowserSDK", { enumerable: true, get: function () { return browser_sdk_1.createBrowserSDK; } });
@@ -1,9 +1,9 @@
1
- import { ArmDozerId, PilotId } from "gbraver-burst-core";
1
+ import { ArmdozerId, PilotId } from "gbraver-burst-core";
2
2
  /** プライベートマッチルーム生成 */
3
3
  export type CreatePrivateMatchRoom = {
4
4
  action: "create-private-match-room";
5
5
  /** 選択したアームドーザのID */
6
- armdozerId: ArmDozerId;
6
+ armdozerId: ArmdozerId;
7
7
  /** 選択したパイロットのID */
8
8
  pilotId: PilotId;
9
9
  };
@@ -1,9 +1,9 @@
1
- import type { ArmDozerId, PilotId } from "gbraver-burst-core";
1
+ import type { ArmdozerId, PilotId } from "gbraver-burst-core";
2
2
  /** カジュアルマッチエントリのリクエストボディ */
3
3
  export type EnterCasualMatch = {
4
4
  action: "enter-casual-match";
5
5
  /** 選択したアームドーザのID */
6
- armdozerId: ArmDozerId;
6
+ armdozerId: ArmdozerId;
7
7
  /** 選択したパイロットのID */
8
8
  pilotId: PilotId;
9
9
  };
@@ -1,4 +1,4 @@
1
- import { ArmDozerId, PilotId } from "gbraver-burst-core";
1
+ import { ArmdozerId, PilotId } from "gbraver-burst-core";
2
2
  import { PrivateMatchRoomID } from "../browser-sdk/private-match";
3
3
  /** プライベートマッチルームエントリ */
4
4
  export type EnterPrivateMatchRoom = {
@@ -6,7 +6,7 @@ export type EnterPrivateMatchRoom = {
6
6
  /** ルームID */
7
7
  roomID: PrivateMatchRoomID;
8
8
  /** 選択したアームドーザID */
9
- armdozerId: ArmDozerId;
9
+ armdozerId: ArmdozerId;
10
10
  /** 選択したパイロットID */
11
11
  pilotId: PilotId;
12
12
  };
@@ -1,12 +1,14 @@
1
+ import { z } from "zod";
1
2
  /** コマンド受取通知 */
2
3
  export type AcceptCommand = {
3
4
  action: "accept-command";
4
5
  };
6
+ /** AcceptCommand zodスキーマ */
7
+ export declare const AcceptCommandSchema: z.ZodSchema<AcceptCommand>;
5
8
  /**
6
9
  * 任意オブジェクトをAcceptCommandにパースする
7
10
  * パースできない場合はnullを返す
8
- *
9
11
  * @param data パース元オブジェクト
10
12
  * @return パース結果
11
13
  */
12
- export declare function parseAcceptCommand(data: any): AcceptCommand | null;
14
+ export declare function parseAcceptCommand(data: unknown): AcceptCommand | null;
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseAcceptCommand = void 0;
3
+ exports.parseAcceptCommand = exports.AcceptCommandSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /** AcceptCommand zodスキーマ */
6
+ exports.AcceptCommandSchema = zod_1.z.object({
7
+ action: zod_1.z.literal("accept-command"),
8
+ });
4
9
  /**
5
10
  * 任意オブジェクトをAcceptCommandにパースする
6
11
  * パースできない場合はnullを返す
7
- *
8
12
  * @param data パース元オブジェクト
9
13
  * @return パース結果
10
14
  */
11
- /* eslint-disable @typescript-eslint/no-explicit-any */
12
15
  function parseAcceptCommand(data) {
13
- /* eslint-enable */
14
- return (data === null || data === void 0 ? void 0 : data.action) === "accept-command"
15
- ? {
16
- action: data.action,
17
- }
18
- : null;
16
+ const result = exports.AcceptCommandSchema.safeParse(data);
17
+ return result.success ? result.data : null;
19
18
  }
20
19
  exports.parseAcceptCommand = parseAcceptCommand;