@battle-racing/br-common-lib 6.2.0-rc.8 → 6.2.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.
Files changed (75) hide show
  1. package/.claude/settings.local.json +8 -0
  2. package/dist/data/all-tutorial-steps.js +37 -0
  3. package/dist/domains/arcade/Arcade.const.d.ts +9 -0
  4. package/dist/domains/arcade/Arcade.const.js +12 -0
  5. package/dist/domains/arcade/Arcade.schema.d.ts +83 -0
  6. package/dist/domains/arcade/Arcade.schema.js +48 -0
  7. package/dist/domains/arcade/Arcade.types.d.ts +11 -0
  8. package/dist/domains/arcade/Arcade.types.js +2 -0
  9. package/dist/domains/arcade/index.d.ts +3 -0
  10. package/dist/domains/arcade/index.js +19 -0
  11. package/dist/domains/command/Command.schema.d.ts +24 -4
  12. package/dist/domains/command/Command.schema.js +10 -2
  13. package/dist/domains/flow/Flow.schema.d.ts +10 -2
  14. package/dist/domains/game/Game.schema.d.ts +1 -1
  15. package/dist/domains/game/Game.schema.js +1 -1
  16. package/dist/domains/game/battle/Battle.schema.d.ts +1 -2
  17. package/dist/domains/game/battle/Battle.schema.js +0 -1
  18. package/dist/domains/game/race/Race.schema.d.ts +2 -3
  19. package/dist/domains/game/race/Race.schema.js +0 -1
  20. package/dist/domains/gameTrack/GameTrack.schema.d.ts +4 -0
  21. package/dist/domains/gameTrack/GameTrack.schema.js +2 -0
  22. package/dist/domains/hardware/KartHardwareState.schema.d.ts +4 -1
  23. package/dist/domains/hardware/KartHardwareState.schema.js +2 -1
  24. package/dist/domains/hardware/ModuleStatus.schema.d.ts +5 -0
  25. package/dist/domains/hardware/rgb/RGB.const.d.ts +4 -0
  26. package/dist/domains/hardware/rgb/RGB.const.js +5 -1
  27. package/dist/domains/hardware/rgb/RGB.schema.d.ts +21 -0
  28. package/dist/domains/hardware/rgb/RGB.schema.js +8 -1
  29. package/dist/domains/hardware/rgb/RGB.types.d.ts +3 -1
  30. package/dist/domains/hardware/screen/ScreenDebug.schema.d.ts +4 -1
  31. package/dist/domains/kart/Kart.schema.d.ts +4 -1
  32. package/dist/domains/powerUp/PowerUp.schema.d.ts +30 -6
  33. package/dist/domains/socket/clientToServer/SocketArcadeMachineClientToServerEventsParams.d.ts +13 -0
  34. package/dist/domains/socket/clientToServer/SocketArcadeMachineClientToServerEventsParams.js +2 -0
  35. package/dist/domains/socket/inputs/SocketArcadeMachineAuthInput.d.ts +7 -0
  36. package/dist/domains/socket/inputs/SocketArcadeMachineAuthInput.js +10 -0
  37. package/dist/domains/socket/serverToClient/SocketArcadeMachineServerToClientEventsParams.d.ts +9 -0
  38. package/dist/domains/socket/serverToClient/SocketArcadeMachineServerToClientEventsParams.js +2 -0
  39. package/dist/domains/socket/serverToClient/SocketWebAppServerToClientEventsParams.d.ts +4 -0
  40. package/dist/domains/socket/utils/SocketParamsToEventsWithAck.d.ts +5 -0
  41. package/dist/domains/socket/utils/SocketParamsToEventsWithAck.js +2 -0
  42. package/dist/domains/tutorial/Tutorial.const.d.ts +0 -2
  43. package/dist/domains/tutorial/Tutorial.const.js +1 -16
  44. package/dist/domains/tutorial/Tutorial.schema.d.ts +45 -31
  45. package/dist/domains/tutorial/Tutorial.schema.js +21 -23
  46. package/dist/domains/tutorial/Tutorial.types.d.ts +4 -2
  47. package/dist/domains/tutorial/TutorialConfig.schema.d.ts +33 -6
  48. package/dist/domains/tutorial/TutorialConfig.schema.js +1 -0
  49. package/dist/domains/utils/Utils.schema.d.ts +2 -0
  50. package/dist/domains/utils/Utils.schema.js +8 -3
  51. package/dist/domains/wallet/Wallet.const.d.ts +4 -0
  52. package/dist/domains/wallet/Wallet.const.js +7 -0
  53. package/dist/domains/wallet/Wallet.schema.d.ts +57 -0
  54. package/dist/domains/wallet/Wallet.schema.js +43 -0
  55. package/dist/domains/wallet/Wallet.types.d.ts +9 -0
  56. package/dist/domains/wallet/Wallet.types.js +2 -0
  57. package/dist/domains/wallet/index.d.ts +3 -0
  58. package/dist/domains/wallet/index.js +19 -0
  59. package/package.json +1 -1
  60. package/src/data/all-tutorial-steps.ts +41 -0
  61. package/src/domains/command/Command.schema.ts +10 -2
  62. package/src/domains/game/Game.schema.ts +1 -1
  63. package/src/domains/game/battle/Battle.schema.ts +0 -1
  64. package/src/domains/game/race/Race.schema.ts +0 -1
  65. package/src/domains/gameTrack/GameTrack.schema.ts +2 -0
  66. package/src/domains/hardware/KartHardwareState.schema.ts +3 -2
  67. package/src/domains/hardware/rgb/RGB.const.ts +5 -0
  68. package/src/domains/hardware/rgb/RGB.schema.ts +10 -1
  69. package/src/domains/hardware/rgb/RGB.types.ts +4 -0
  70. package/src/domains/socket/serverToClient/SocketWebAppServerToClientEventsParams.ts +2 -0
  71. package/src/domains/tutorial/Tutorial.const.ts +0 -16
  72. package/src/domains/tutorial/Tutorial.schema.ts +22 -22
  73. package/src/domains/tutorial/Tutorial.types.ts +6 -3
  74. package/src/domains/tutorial/TutorialConfig.schema.ts +1 -0
  75. package/src/domains/utils/Utils.schema.ts +8 -3
@@ -28,6 +28,11 @@ export declare const moduleStatusSchema: z.ZodUnion<readonly [z.ZodObject<{
28
28
  DACVoltage: z.ZodNumber;
29
29
  currentDefaultSpeedConfig: z.ZodNumber;
30
30
  }, z.core.$strip>, z.ZodObject<{
31
+ label: z.ZodEnum<{
32
+ readonly FRONT: "front";
33
+ readonly BACK: "back";
34
+ }>;
35
+ address: z.ZodNumber;
31
36
  rgbStatus: z.ZodEnum<{
32
37
  readonly SHOWING_COLOR: "Showing Color";
33
38
  readonly NOT_CONFIGURED: "Not Configured";
@@ -10,3 +10,7 @@ export declare const RGB_ACTION_COMMANDS: {
10
10
  readonly EXEC: "Exec";
11
11
  readonly CONFIGURE: "Configure";
12
12
  };
13
+ export declare const RGB_MODULE_LABEL: {
14
+ readonly FRONT: "front";
15
+ readonly BACK: "back";
16
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RGB_ACTION_COMMANDS = exports.RGB_STATUS = void 0;
3
+ exports.RGB_MODULE_LABEL = exports.RGB_ACTION_COMMANDS = exports.RGB_STATUS = void 0;
4
4
  exports.RGB_STATUS = {
5
5
  SHOWING_COLOR: 'Showing Color',
6
6
  NOT_CONFIGURED: 'Not Configured',
@@ -13,3 +13,7 @@ exports.RGB_ACTION_COMMANDS = {
13
13
  EXEC: 'Exec',
14
14
  CONFIGURE: 'Configure',
15
15
  };
16
+ exports.RGB_MODULE_LABEL = {
17
+ FRONT: 'front',
18
+ BACK: 'back',
19
+ };
@@ -11,7 +11,20 @@ export declare const rgbActionCommandSchema: z.ZodEnum<{
11
11
  readonly EXEC: "Exec";
12
12
  readonly CONFIGURE: "Configure";
13
13
  }>;
14
+ export declare const rgbModuleLabelSchema: z.ZodEnum<{
15
+ readonly FRONT: "front";
16
+ readonly BACK: "back";
17
+ }>;
18
+ export declare const rgbTargetsSchema: z.ZodOptional<z.ZodArray<z.ZodEnum<{
19
+ readonly FRONT: "front";
20
+ readonly BACK: "back";
21
+ }>>>;
14
22
  export declare const rgbModuleStatusSchema: z.ZodObject<{
23
+ label: z.ZodEnum<{
24
+ readonly FRONT: "front";
25
+ readonly BACK: "back";
26
+ }>;
27
+ address: z.ZodNumber;
15
28
  rgbStatus: z.ZodEnum<{
16
29
  readonly SHOWING_COLOR: "Showing Color";
17
30
  readonly NOT_CONFIGURED: "Not Configured";
@@ -52,6 +65,10 @@ export declare const rgbConfigurationOptionsSchema: z.ZodObject<{
52
65
  }>;
53
66
  brightness: z.ZodNumber;
54
67
  effectTime: z.ZodNumber;
68
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
69
+ readonly FRONT: "front";
70
+ readonly BACK: "back";
71
+ }>>>;
55
72
  }, z.core.$strip>;
56
73
  export declare const rgbShowEffectOptionsSchema: z.ZodObject<{
57
74
  effect: z.ZodEnum<{
@@ -74,4 +91,8 @@ export declare const rgbShowEffectOptionsSchema: z.ZodObject<{
74
91
  readonly EMERGENCY_EFFECT: "Emergency Effect";
75
92
  readonly WAIT_EFFECT: "Wait Effect";
76
93
  }>;
94
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
95
+ readonly FRONT: "front";
96
+ readonly BACK: "back";
97
+ }>>>;
77
98
  }, z.core.$strip>;
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rgbShowEffectOptionsSchema = exports.rgbConfigurationOptionsSchema = exports.rgbModuleStatusSchema = exports.rgbActionCommandSchema = exports.rgbStatusSchema = void 0;
3
+ exports.rgbShowEffectOptionsSchema = exports.rgbConfigurationOptionsSchema = exports.rgbModuleStatusSchema = exports.rgbTargetsSchema = exports.rgbModuleLabelSchema = exports.rgbActionCommandSchema = exports.rgbStatusSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const color_1 = require("../../color");
6
6
  const kart_effect_1 = require("../../hardware/kart-effect");
7
7
  const RGB_const_1 = require("./RGB.const");
8
8
  exports.rgbStatusSchema = zod_1.z.enum(RGB_const_1.RGB_STATUS);
9
9
  exports.rgbActionCommandSchema = zod_1.z.enum(RGB_const_1.RGB_ACTION_COMMANDS);
10
+ exports.rgbModuleLabelSchema = zod_1.z.enum(RGB_const_1.RGB_MODULE_LABEL);
11
+ // When targets is missing the command goes to every configured RGB module
12
+ exports.rgbTargetsSchema = zod_1.z.array(exports.rgbModuleLabelSchema).min(1).optional();
10
13
  exports.rgbModuleStatusSchema = zod_1.z.object({
14
+ label: exports.rgbModuleLabelSchema,
15
+ address: zod_1.z.number(),
11
16
  rgbStatus: exports.rgbStatusSchema,
12
17
  kartColor: color_1.colorNameSchema,
13
18
  });
@@ -15,7 +20,9 @@ exports.rgbConfigurationOptionsSchema = zod_1.z.object({
15
20
  kartColor: color_1.colorNameSchema,
16
21
  brightness: zod_1.z.number().min(0).max(100),
17
22
  effectTime: zod_1.z.number().min(1).max(25),
23
+ targets: exports.rgbTargetsSchema,
18
24
  });
19
25
  exports.rgbShowEffectOptionsSchema = zod_1.z.object({
20
26
  effect: kart_effect_1.kartEffectSchema,
27
+ targets: exports.rgbTargetsSchema,
21
28
  });
@@ -1,7 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { rgbActionCommandSchema, rgbConfigurationOptionsSchema, rgbModuleStatusSchema, rgbShowEffectOptionsSchema, rgbStatusSchema } from './RGB.schema';
2
+ import { rgbActionCommandSchema, rgbConfigurationOptionsSchema, rgbModuleLabelSchema, rgbModuleStatusSchema, rgbShowEffectOptionsSchema, rgbStatusSchema, rgbTargetsSchema } from './RGB.schema';
3
3
  export type RGBStatus = z.infer<typeof rgbStatusSchema>;
4
4
  export type RGBModuleStatus = z.infer<typeof rgbModuleStatusSchema>;
5
5
  export type RGBConfigurationOptions = z.infer<typeof rgbConfigurationOptionsSchema>;
6
6
  export type RGBShowEffectOptions = z.infer<typeof rgbShowEffectOptionsSchema>;
7
7
  export type RGBActionCommand = z.infer<typeof rgbActionCommandSchema>;
8
+ export type RGBModuleLabel = z.infer<typeof rgbModuleLabelSchema>;
9
+ export type RGBTargets = z.infer<typeof rgbTargetsSchema>;
@@ -13,7 +13,10 @@ export declare const screenDebugViewInputSchema: z.ZodObject<{
13
13
  current: z.ZodNumber;
14
14
  configured: z.ZodNumber;
15
15
  }, z.core.$strip>>;
16
- rgb: z.ZodNullable<z.ZodEnum<{
16
+ rgb: z.ZodRecord<z.ZodEnum<{
17
+ readonly FRONT: "front";
18
+ readonly BACK: "back";
19
+ }> & z.core.$partial, z.ZodEnum<{
17
20
  readonly SHOWING_COLOR: "Showing Color";
18
21
  readonly NOT_CONFIGURED: "Not Configured";
19
22
  readonly CONFIGURING_RGB: "Configuring RGB";
@@ -79,7 +79,10 @@ export declare const kartSchema: z.ZodObject<{
79
79
  current: z.ZodNumber;
80
80
  configured: z.ZodNumber;
81
81
  }, z.core.$strip>>;
82
- rgb: z.ZodNullable<z.ZodEnum<{
82
+ rgb: z.ZodRecord<z.ZodEnum<{
83
+ readonly FRONT: "front";
84
+ readonly BACK: "back";
85
+ }> & z.core.$partial, z.ZodEnum<{
83
86
  readonly SHOWING_COLOR: "Showing Color";
84
87
  readonly NOT_CONFIGURED: "Not Configured";
85
88
  readonly CONFIGURING_RGB: "Configuring RGB";
@@ -240,6 +240,10 @@ export declare const powerUpCommandSchema: z.ZodIntersection<z.ZodUnion<readonly
240
240
  }>;
241
241
  brightness: z.ZodNumber;
242
242
  effectTime: z.ZodNumber;
243
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
244
+ readonly FRONT: "front";
245
+ readonly BACK: "back";
246
+ }>>>;
243
247
  }, z.core.$strip>;
244
248
  }, z.core.$strip>, z.ZodObject<{
245
249
  module: z.ZodLiteral<"rgb">;
@@ -265,6 +269,10 @@ export declare const powerUpCommandSchema: z.ZodIntersection<z.ZodUnion<readonly
265
269
  readonly EMERGENCY_EFFECT: "Emergency Effect";
266
270
  readonly WAIT_EFFECT: "Wait Effect";
267
271
  }>;
272
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
273
+ readonly FRONT: "front";
274
+ readonly BACK: "back";
275
+ }>>>;
268
276
  }, z.core.$strip>;
269
277
  }, z.core.$strip>]>, z.ZodUnion<readonly [z.ZodObject<{
270
278
  module: z.ZodLiteral<"speed">;
@@ -283,8 +291,8 @@ export declare const powerUpCommandSchema: z.ZodIntersection<z.ZodUnion<readonly
283
291
  module: z.ZodLiteral<"speed">;
284
292
  action: z.ZodLiteral<"configure">;
285
293
  params: z.ZodObject<{
286
- defaultSpeed: z.ZodNumber;
287
- timeDuration: z.ZodNumber;
294
+ defaultSpeed: z.ZodUnion<readonly [z.ZodNumber, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodString]>]>;
295
+ timeDuration: z.ZodUnion<readonly [z.ZodNumber, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodString]>]>;
288
296
  }, z.core.$strip>;
289
297
  }, z.core.$strip>]>, z.ZodUnion<readonly [z.ZodObject<{
290
298
  module: z.ZodLiteral<"leftStarBackLaser">;
@@ -1244,6 +1252,10 @@ export declare const powerUpSchema: z.ZodObject<{
1244
1252
  }>;
1245
1253
  brightness: z.ZodNumber;
1246
1254
  effectTime: z.ZodNumber;
1255
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1256
+ readonly FRONT: "front";
1257
+ readonly BACK: "back";
1258
+ }>>>;
1247
1259
  }, z.core.$strip>;
1248
1260
  }, z.core.$strip>, z.ZodObject<{
1249
1261
  module: z.ZodLiteral<"rgb">;
@@ -1269,6 +1281,10 @@ export declare const powerUpSchema: z.ZodObject<{
1269
1281
  readonly EMERGENCY_EFFECT: "Emergency Effect";
1270
1282
  readonly WAIT_EFFECT: "Wait Effect";
1271
1283
  }>;
1284
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1285
+ readonly FRONT: "front";
1286
+ readonly BACK: "back";
1287
+ }>>>;
1272
1288
  }, z.core.$strip>;
1273
1289
  }, z.core.$strip>]>, z.ZodUnion<readonly [z.ZodObject<{
1274
1290
  module: z.ZodLiteral<"speed">;
@@ -1287,8 +1303,8 @@ export declare const powerUpSchema: z.ZodObject<{
1287
1303
  module: z.ZodLiteral<"speed">;
1288
1304
  action: z.ZodLiteral<"configure">;
1289
1305
  params: z.ZodObject<{
1290
- defaultSpeed: z.ZodNumber;
1291
- timeDuration: z.ZodNumber;
1306
+ defaultSpeed: z.ZodUnion<readonly [z.ZodNumber, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodString]>]>;
1307
+ timeDuration: z.ZodUnion<readonly [z.ZodNumber, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodString]>]>;
1292
1308
  }, z.core.$strip>;
1293
1309
  }, z.core.$strip>]>, z.ZodUnion<readonly [z.ZodObject<{
1294
1310
  module: z.ZodLiteral<"leftStarBackLaser">;
@@ -2228,6 +2244,10 @@ export declare const powerUpSchema: z.ZodObject<{
2228
2244
  }>;
2229
2245
  brightness: z.ZodNumber;
2230
2246
  effectTime: z.ZodNumber;
2247
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
2248
+ readonly FRONT: "front";
2249
+ readonly BACK: "back";
2250
+ }>>>;
2231
2251
  }, z.core.$strip>;
2232
2252
  }, z.core.$strip>, z.ZodObject<{
2233
2253
  module: z.ZodLiteral<"rgb">;
@@ -2253,6 +2273,10 @@ export declare const powerUpSchema: z.ZodObject<{
2253
2273
  readonly EMERGENCY_EFFECT: "Emergency Effect";
2254
2274
  readonly WAIT_EFFECT: "Wait Effect";
2255
2275
  }>;
2276
+ targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
2277
+ readonly FRONT: "front";
2278
+ readonly BACK: "back";
2279
+ }>>>;
2256
2280
  }, z.core.$strip>;
2257
2281
  }, z.core.$strip>]>, z.ZodUnion<readonly [z.ZodObject<{
2258
2282
  module: z.ZodLiteral<"speed">;
@@ -2271,8 +2295,8 @@ export declare const powerUpSchema: z.ZodObject<{
2271
2295
  module: z.ZodLiteral<"speed">;
2272
2296
  action: z.ZodLiteral<"configure">;
2273
2297
  params: z.ZodObject<{
2274
- defaultSpeed: z.ZodNumber;
2275
- timeDuration: z.ZodNumber;
2298
+ defaultSpeed: z.ZodUnion<readonly [z.ZodNumber, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodString]>]>;
2299
+ timeDuration: z.ZodUnion<readonly [z.ZodNumber, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodString]>]>;
2276
2300
  }, z.core.$strip>;
2277
2301
  }, z.core.$strip>]>, z.ZodUnion<readonly [z.ZodObject<{
2278
2302
  module: z.ZodLiteral<"leftStarBackLaser">;
@@ -0,0 +1,13 @@
1
+ import type { ArcadeSession, FinishArcadeSessionInput } from '../../arcade';
2
+ import type { Response } from '../../response';
3
+ import type { ArcadeSessionStartedPayload } from '../serverToClient';
4
+ export interface SocketArcadeMachineClientToServerEventsParams {
5
+ 'arcade-machine:session:start-anonymous': undefined;
6
+ 'arcade-machine:session:finish': FinishArcadeSessionInput;
7
+ }
8
+ export interface SocketArcadeMachineClientToServerAckResponses {
9
+ 'arcade-machine:session:start-anonymous': Response<ArcadeSessionStartedPayload>;
10
+ 'arcade-machine:session:finish': Response<{
11
+ session: ArcadeSession;
12
+ }>;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ /** Sent by the arcade machine in the socket.io handshake `auth` field */
3
+ export declare const socketArcadeMachineAuthInputSchema: z.ZodObject<{
4
+ machineId: z.ZodString;
5
+ secret: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export type SocketArcadeMachineAuthInput = z.infer<typeof socketArcadeMachineAuthInputSchema>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.socketArcadeMachineAuthInputSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const arcade_1 = require("../../arcade");
6
+ /** Sent by the arcade machine in the socket.io handshake `auth` field */
7
+ exports.socketArcadeMachineAuthInputSchema = zod_1.z.object({
8
+ machineId: arcade_1.arcadeMachineIdSchema,
9
+ secret: zod_1.z.string().min(1),
10
+ });
@@ -0,0 +1,9 @@
1
+ import type { ArcadeSession } from '../../arcade';
2
+ export type ArcadeSessionStartedPayload = {
3
+ session: ArcadeSession;
4
+ playerName?: string;
5
+ };
6
+ export interface SocketArcadeMachineServerToClientEventsParams {
7
+ /** A session was opened for this machine (e.g. a user scanned the machine QR) */
8
+ 'arcade-machine:session:started': ArcadeSessionStartedPayload;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,6 +3,7 @@ import type { GameTrack } from '../../gameTrack';
3
3
  import type { Kart } from '../../kart';
4
4
  import type { CheckpointEvent } from '../../kartTracking';
5
5
  import type { Response } from '../../response';
6
+ import type { TutorialSession } from '../../tutorial';
6
7
  import type { MacAddressGameTrackConnections } from '../inputs';
7
8
  import type { SocketHardwareOnDataEventsParams } from '../SocketHardwareOnDataEventsParams';
8
9
  export interface SocketWebAppServerToClientEventsParams {
@@ -20,6 +21,9 @@ export interface SocketWebAppServerToClientEventsParams {
20
21
  'game:changed': {
21
22
  game: Game;
22
23
  };
24
+ 'tutorial:session:changed': {
25
+ session: TutorialSession;
26
+ };
23
27
  'gameTracks:onGameTrackUpdated': GameTrack[];
24
28
  'gameTracks:connectedRasperries': {
25
29
  macAddress: string;
@@ -0,0 +1,5 @@
1
+ export type SocketAck<Response> = (response: Response) => void;
2
+ /** Like SocketParamsToEvents, but every event receives an ack callback as last argument */
3
+ export type SocketParamsToEventsWithAck<Event, Ack extends Record<keyof Event, unknown>> = {
4
+ [EventKey in keyof Event]: Event[EventKey] extends undefined ? (ack: SocketAck<Ack[EventKey]>) => void : (payload: Event[EventKey], ack: SocketAck<Ack[EventKey]>) => void;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -51,5 +51,3 @@ export declare const TUTORIAL_CHECKPOINT_TARGET: {
51
51
  export declare const TUTORIAL_INPUT_SIGNAL_TYPE: {
52
52
  readonly STEERING_WHEEL_BUTTON_PRESSED: "SteeringWheelButtonPressed";
53
53
  };
54
- export declare const DRIVING_TUTORIAL_STEPS: readonly ["Pedal", "DriveToControls", "HudOverview", "PowerUpWaiting", "PowerUpNitroReady", "PowerUpReturnToHud"];
55
- export declare const isDrivingTutorialStep: (step?: string | null) => boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDrivingTutorialStep = exports.DRIVING_TUTORIAL_STEPS = exports.TUTORIAL_INPUT_SIGNAL_TYPE = exports.TUTORIAL_CHECKPOINT_TARGET = exports.TUTORIAL_STEERING_WHEEL_BUTTON = exports.TUTORIAL_LISTEN_EVENT_ON = exports.TUTORIAL_PHASE_ID = exports.TUTORIAL_STATUS = exports.TUTORIAL_SCREEN_STEP = void 0;
3
+ exports.TUTORIAL_INPUT_SIGNAL_TYPE = exports.TUTORIAL_CHECKPOINT_TARGET = exports.TUTORIAL_STEERING_WHEEL_BUTTON = exports.TUTORIAL_LISTEN_EVENT_ON = exports.TUTORIAL_PHASE_ID = exports.TUTORIAL_STATUS = exports.TUTORIAL_SCREEN_STEP = void 0;
4
4
  exports.TUTORIAL_SCREEN_STEP = {
5
5
  COUNTDOWN: 'Countdown',
6
6
  WELCOME: 'Welcome',
@@ -54,18 +54,3 @@ exports.TUTORIAL_CHECKPOINT_TARGET = {
54
54
  exports.TUTORIAL_INPUT_SIGNAL_TYPE = {
55
55
  STEERING_WHEEL_BUTTON_PRESSED: 'SteeringWheelButtonPressed',
56
56
  };
57
- exports.DRIVING_TUTORIAL_STEPS = [
58
- exports.TUTORIAL_SCREEN_STEP.PEDAL,
59
- exports.TUTORIAL_SCREEN_STEP.DRIVE_TO_CONTROLS,
60
- exports.TUTORIAL_SCREEN_STEP.HUD_OVERVIEW,
61
- exports.TUTORIAL_SCREEN_STEP.POWER_UP_WAITING,
62
- exports.TUTORIAL_SCREEN_STEP.POWER_UP_NITRO_READY,
63
- exports.TUTORIAL_SCREEN_STEP.POWER_UP_RETURN_TO_HUD,
64
- ];
65
- const isDrivingTutorialStep = (step) => {
66
- if (!step) {
67
- return false;
68
- }
69
- return exports.DRIVING_TUTORIAL_STEPS.includes(step);
70
- };
71
- exports.isDrivingTutorialStep = isDrivingTutorialStep;
@@ -43,6 +43,10 @@ export declare const tutorialSteeringWheelButtonSchema: z.ZodEnum<{
43
43
  left: "left";
44
44
  right: "right";
45
45
  }>;
46
+ export declare const tutorialInputButtonSchema: z.ZodEnum<{
47
+ left: "left";
48
+ right: "right";
49
+ }>;
46
50
  export declare const tutorialCheckpointTargetSchema: z.ZodEnum<{
47
51
  TRACK: "TRACK";
48
52
  POWER_UP: "POWER_UP";
@@ -124,7 +128,7 @@ export declare const tutorialKartSnapshotSchema: z.ZodObject<{
124
128
  }>>>;
125
129
  latestCheckpointId: z.ZodOptional<z.ZodString>;
126
130
  latestCheckpointProgress: z.ZodOptional<z.ZodNumber>;
127
- updatedAtISO: z.ZodString;
131
+ updatedAtISO: z.ZodISODateTime;
128
132
  }, z.core.$strip>;
129
133
  export declare const tutorialInputSignalTypeSchema: z.ZodEnum<{
130
134
  SteeringWheelButtonPressed: "SteeringWheelButtonPressed";
@@ -134,17 +138,16 @@ export declare const tutorialKartEventBaseSchema: z.ZodObject<{
134
138
  deviceId: z.ZodString;
135
139
  revision: z.ZodNumber;
136
140
  sequence: z.ZodNumber;
137
- originTimestampISO: z.ZodString;
141
+ originTimestampISO: z.ZodISODateTime;
138
142
  }, z.core.$strip>;
139
143
  export declare const tutorialSteeringWheelButtonPressedSchema: z.ZodObject<{
140
144
  tutorialSessionId: z.ZodString;
141
145
  deviceId: z.ZodString;
142
146
  revision: z.ZodNumber;
143
147
  sequence: z.ZodNumber;
144
- originTimestampISO: z.ZodString;
148
+ originTimestampISO: z.ZodISODateTime;
145
149
  type: z.ZodLiteral<"SteeringWheelButtonPressed">;
146
150
  button: z.ZodEnum<{
147
- any: "any";
148
151
  left: "left";
149
152
  right: "right";
150
153
  }>;
@@ -154,10 +157,9 @@ export declare const tutorialInputSignalSchema: z.ZodDiscriminatedUnion<[z.ZodOb
154
157
  deviceId: z.ZodString;
155
158
  revision: z.ZodNumber;
156
159
  sequence: z.ZodNumber;
157
- originTimestampISO: z.ZodString;
160
+ originTimestampISO: z.ZodISODateTime;
158
161
  type: z.ZodLiteral<"SteeringWheelButtonPressed">;
159
162
  button: z.ZodEnum<{
160
- any: "any";
161
163
  left: "left";
162
164
  right: "right";
163
165
  }>;
@@ -169,7 +171,7 @@ export declare const tutorialConfigurationSchema: z.ZodObject<{
169
171
  speedConfig: z.ZodOptional<z.ZodNumber>;
170
172
  }, z.core.$strip>;
171
173
  export declare const tutorialParticipantSchema: z.ZodObject<{
172
- deviceId: z.ZodString;
174
+ kartGuid: z.ZodString;
173
175
  playerId: z.ZodOptional<z.ZodString>;
174
176
  status: z.ZodEnum<{
175
177
  COMPLETED: "COMPLETED";
@@ -217,13 +219,17 @@ export declare const tutorialParticipantSchema: z.ZodObject<{
217
219
  total: z.ZodNumber;
218
220
  }, z.core.$strip>>;
219
221
  totalDurationSeconds: z.ZodDefault<z.ZodNumber>;
220
- startedAtISO: z.ZodOptional<z.ZodString>;
221
- updatedAtISO: z.ZodString;
222
+ startedAtISO: z.ZodOptional<z.ZodISODateTime>;
223
+ updatedAtISO: z.ZodISODateTime;
222
224
  }, z.core.$strip>;
223
225
  export declare const tutorialSessionSchema: z.ZodObject<{
224
226
  id: z.ZodString;
225
227
  gameTurnId: z.ZodOptional<z.ZodString>;
226
- gameId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
228
+ gameId: z.ZodNumber;
229
+ gameType: z.ZodEnum<{
230
+ readonly Race: "Race";
231
+ readonly Battle: "Battle";
232
+ }>;
227
233
  status: z.ZodEnum<{
228
234
  COMPLETED: "COMPLETED";
229
235
  PENDING: "PENDING";
@@ -232,7 +238,7 @@ export declare const tutorialSessionSchema: z.ZodObject<{
232
238
  SKIPPED: "SKIPPED";
233
239
  }>;
234
240
  participants: z.ZodArray<z.ZodObject<{
235
- deviceId: z.ZodString;
241
+ kartGuid: z.ZodString;
236
242
  playerId: z.ZodOptional<z.ZodString>;
237
243
  status: z.ZodEnum<{
238
244
  COMPLETED: "COMPLETED";
@@ -280,29 +286,37 @@ export declare const tutorialSessionSchema: z.ZodObject<{
280
286
  total: z.ZodNumber;
281
287
  }, z.core.$strip>>;
282
288
  totalDurationSeconds: z.ZodDefault<z.ZodNumber>;
283
- startedAtISO: z.ZodOptional<z.ZodString>;
284
- updatedAtISO: z.ZodString;
289
+ startedAtISO: z.ZodOptional<z.ZodISODateTime>;
290
+ updatedAtISO: z.ZodISODateTime;
285
291
  }, z.core.$strip>>;
286
- createdAtISO: z.ZodString;
287
- updatedAtISO: z.ZodString;
292
+ createdAtISO: z.ZodISODateTime;
293
+ updatedAtISO: z.ZodISODateTime;
288
294
  }, z.core.$strip>;
289
- export declare const startOperatorTutorialSchema: z.ZodObject<{
290
- gameId: z.ZodNumber;
291
- gameType: z.ZodEnum<{
292
- Race: "Race";
293
- Battle: "Battle";
294
- }>;
295
+ export declare const startRaceTutorialSchema: z.ZodObject<{
296
+ laps: z.ZodNumber;
297
+ coins: z.ZodNumber;
298
+ kartsGuids: z.ZodArray<z.ZodString>;
299
+ powerUpsIds: z.ZodArray<z.ZodString>;
300
+ time: z.ZodNumber;
301
+ speedConfig: z.ZodNumber;
302
+ playerKartMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
303
+ tutorialConfigId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
304
+ tutorialParams: z.ZodOptional<z.ZodObject<{
305
+ laps: z.ZodDefault<z.ZodNumber>;
306
+ coins: z.ZodDefault<z.ZodNumber>;
307
+ time: z.ZodDefault<z.ZodNumber>;
308
+ speedConfig: z.ZodOptional<z.ZodNumber>;
309
+ }, z.core.$strip>>;
310
+ }, z.core.$strip>;
311
+ export declare const startBattleTutorialSchema: z.ZodObject<{
312
+ lives: z.ZodNumber;
313
+ coins: z.ZodNumber;
314
+ kartsGuids: z.ZodArray<z.ZodString>;
315
+ powerUpsIds: z.ZodArray<z.ZodString>;
316
+ time: z.ZodNumber;
317
+ speedConfig: z.ZodNumber;
318
+ playerKartMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
295
319
  tutorialConfigId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
296
- params: z.ZodObject<{
297
- laps: z.ZodOptional<z.ZodNumber>;
298
- lives: z.ZodOptional<z.ZodNumber>;
299
- coins: z.ZodNumber;
300
- kartsGuids: z.ZodArray<z.ZodString>;
301
- powerUpsIds: z.ZodArray<z.ZodString>;
302
- time: z.ZodNumber;
303
- speedConfig: z.ZodNumber;
304
- playerKartMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
305
- }, z.core.$strip>;
306
320
  tutorialParams: z.ZodOptional<z.ZodObject<{
307
321
  laps: z.ZodDefault<z.ZodNumber>;
308
322
  coins: z.ZodDefault<z.ZodNumber>;
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startOperatorTutorialSchema = exports.tutorialSessionSchema = exports.tutorialParticipantSchema = exports.tutorialConfigurationSchema = exports.tutorialInputSignalSchema = exports.tutorialSteeringWheelButtonPressedSchema = exports.tutorialKartEventBaseSchema = exports.tutorialInputSignalTypeSchema = exports.tutorialKartSnapshotSchema = exports.tutorialCheckpointTargetSchema = exports.tutorialSteeringWheelButtonSchema = exports.tutorialListenEventOnSchema = exports.tutorialPhaseIdSchema = exports.tutorialStatusSchema = exports.tutorialScreenStepSchema = void 0;
3
+ exports.startBattleTutorialSchema = exports.startRaceTutorialSchema = exports.tutorialSessionSchema = exports.tutorialParticipantSchema = exports.tutorialConfigurationSchema = exports.tutorialInputSignalSchema = exports.tutorialSteeringWheelButtonPressedSchema = exports.tutorialKartEventBaseSchema = exports.tutorialInputSignalTypeSchema = exports.tutorialKartSnapshotSchema = exports.tutorialCheckpointTargetSchema = exports.tutorialInputButtonSchema = exports.tutorialSteeringWheelButtonSchema = exports.tutorialListenEventOnSchema = exports.tutorialPhaseIdSchema = exports.tutorialStatusSchema = exports.tutorialScreenStepSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const Battle_schema_1 = require("../game/battle/Battle.schema");
6
+ const Game_schema_1 = require("../game/Game.schema");
7
+ const Race_schema_1 = require("../game/race/Race.schema");
5
8
  const ScreenTutorial_schema_1 = require("../hardware/screen/ScreenTutorial.schema");
6
9
  const Tutorial_const_1 = require("./Tutorial.const");
7
10
  exports.tutorialScreenStepSchema = zod_1.z.enum([
@@ -48,6 +51,10 @@ exports.tutorialSteeringWheelButtonSchema = zod_1.z.enum([
48
51
  Tutorial_const_1.TUTORIAL_STEERING_WHEEL_BUTTON.LEFT,
49
52
  Tutorial_const_1.TUTORIAL_STEERING_WHEEL_BUTTON.ANY,
50
53
  ]);
54
+ exports.tutorialInputButtonSchema = zod_1.z.enum([
55
+ Tutorial_const_1.TUTORIAL_STEERING_WHEEL_BUTTON.RIGHT,
56
+ Tutorial_const_1.TUTORIAL_STEERING_WHEEL_BUTTON.LEFT,
57
+ ]);
51
58
  exports.tutorialCheckpointTargetSchema = zod_1.z.enum([
52
59
  Tutorial_const_1.TUTORIAL_CHECKPOINT_TARGET.TRACK,
53
60
  Tutorial_const_1.TUTORIAL_CHECKPOINT_TARGET.POWER_UP,
@@ -67,7 +74,7 @@ exports.tutorialKartSnapshotSchema = zod_1.z.object({
67
74
  awaitingCheckpointTarget: exports.tutorialCheckpointTargetSchema.nullable().optional(),
68
75
  latestCheckpointId: zod_1.z.string().optional(),
69
76
  latestCheckpointProgress: zod_1.z.number().optional(),
70
- updatedAtISO: zod_1.z.string().datetime(),
77
+ updatedAtISO: zod_1.z.iso.datetime(),
71
78
  });
72
79
  exports.tutorialInputSignalTypeSchema = zod_1.z.enum([Tutorial_const_1.TUTORIAL_INPUT_SIGNAL_TYPE.STEERING_WHEEL_BUTTON_PRESSED]);
73
80
  exports.tutorialKartEventBaseSchema = zod_1.z.object({
@@ -75,11 +82,11 @@ exports.tutorialKartEventBaseSchema = zod_1.z.object({
75
82
  deviceId: zod_1.z.string().min(1),
76
83
  revision: zod_1.z.number().int().nonnegative(),
77
84
  sequence: zod_1.z.number().int().nonnegative(),
78
- originTimestampISO: zod_1.z.string().datetime(),
85
+ originTimestampISO: zod_1.z.iso.datetime(),
79
86
  });
80
87
  exports.tutorialSteeringWheelButtonPressedSchema = exports.tutorialKartEventBaseSchema.extend({
81
88
  type: zod_1.z.literal(Tutorial_const_1.TUTORIAL_INPUT_SIGNAL_TYPE.STEERING_WHEEL_BUTTON_PRESSED),
82
- button: exports.tutorialSteeringWheelButtonSchema,
89
+ button: exports.tutorialInputButtonSchema,
83
90
  });
84
91
  exports.tutorialInputSignalSchema = zod_1.z.discriminatedUnion('type', [exports.tutorialSteeringWheelButtonPressedSchema]);
85
92
  exports.tutorialConfigurationSchema = zod_1.z.object({
@@ -89,7 +96,7 @@ exports.tutorialConfigurationSchema = zod_1.z.object({
89
96
  speedConfig: zod_1.z.number().int().min(20).max(100).optional(),
90
97
  });
91
98
  exports.tutorialParticipantSchema = zod_1.z.object({
92
- deviceId: zod_1.z.string().min(1),
99
+ kartGuid: zod_1.z.string().min(1),
93
100
  playerId: zod_1.z.string().optional(),
94
101
  status: exports.tutorialStatusSchema,
95
102
  currentPhaseId: exports.tutorialPhaseIdSchema,
@@ -108,31 +115,22 @@ exports.tutorialParticipantSchema = zod_1.z.object({
108
115
  })
109
116
  .optional(),
110
117
  totalDurationSeconds: zod_1.z.number().int().default(180),
111
- startedAtISO: zod_1.z.string().optional(),
112
- updatedAtISO: zod_1.z.string(),
118
+ startedAtISO: zod_1.z.iso.datetime().optional(),
119
+ updatedAtISO: zod_1.z.iso.datetime(),
113
120
  });
114
121
  exports.tutorialSessionSchema = zod_1.z.object({
115
122
  id: zod_1.z.string().min(1),
116
123
  gameTurnId: zod_1.z.string().optional(),
117
- gameId: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional(),
124
+ gameId: zod_1.z.number().int(),
125
+ gameType: Game_schema_1.gameTypeSchema,
118
126
  status: exports.tutorialStatusSchema,
119
127
  participants: zod_1.z.array(exports.tutorialParticipantSchema),
120
- createdAtISO: zod_1.z.string(),
121
- updatedAtISO: zod_1.z.string(),
128
+ createdAtISO: zod_1.z.iso.datetime(),
129
+ updatedAtISO: zod_1.z.iso.datetime(),
122
130
  });
123
- exports.startOperatorTutorialSchema = zod_1.z.object({
124
- gameId: zod_1.z.number().int(),
125
- gameType: zod_1.z.enum(['Race', 'Battle']),
131
+ const startTutorialOptionsSchema = zod_1.z.object({
126
132
  tutorialConfigId: zod_1.z.string().optional().default('BR_TUTORIAL_DEFAULT'),
127
- params: zod_1.z.object({
128
- laps: zod_1.z.number().int().optional(),
129
- lives: zod_1.z.number().int().optional(),
130
- coins: zod_1.z.number().int().min(0).max(254),
131
- kartsGuids: zod_1.z.array(zod_1.z.string()).min(1),
132
- powerUpsIds: zod_1.z.array(zod_1.z.string()).min(1),
133
- time: zod_1.z.number().int().min(30).max(1200),
134
- speedConfig: zod_1.z.number().int().min(20).max(100),
135
- playerKartMap: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
136
- }),
137
133
  tutorialParams: exports.tutorialConfigurationSchema.optional(),
138
134
  });
135
+ exports.startRaceTutorialSchema = Race_schema_1.startRaceSchema.extend(startTutorialOptionsSchema.shape);
136
+ exports.startBattleTutorialSchema = Battle_schema_1.startBattleSchema.extend(startTutorialOptionsSchema.shape);
@@ -1,10 +1,11 @@
1
1
  import { z } from 'zod';
2
- import { tutorialInputSignalSchema, tutorialInputSignalTypeSchema, tutorialKartSnapshotSchema, tutorialListenEventOnSchema, tutorialCheckpointTargetSchema, tutorialPhaseIdSchema, tutorialScreenStepSchema, tutorialStatusSchema, tutorialSteeringWheelButtonPressedSchema, tutorialSteeringWheelButtonSchema, tutorialConfigurationSchema, tutorialParticipantSchema, tutorialSessionSchema, startOperatorTutorialSchema } from './Tutorial.schema';
2
+ import { tutorialInputSignalSchema, tutorialInputSignalTypeSchema, tutorialKartSnapshotSchema, tutorialListenEventOnSchema, tutorialCheckpointTargetSchema, tutorialPhaseIdSchema, tutorialScreenStepSchema, tutorialStatusSchema, tutorialSteeringWheelButtonPressedSchema, tutorialSteeringWheelButtonSchema, tutorialInputButtonSchema, tutorialConfigurationSchema, tutorialParticipantSchema, tutorialSessionSchema, startRaceTutorialSchema, startBattleTutorialSchema } from './Tutorial.schema';
3
3
  export type TutorialScreenStep = z.infer<typeof tutorialScreenStepSchema>;
4
4
  export type TutorialStatus = z.infer<typeof tutorialStatusSchema>;
5
5
  export type TutorialPhaseId = z.infer<typeof tutorialPhaseIdSchema>;
6
6
  export type TutorialListenEventOn = z.infer<typeof tutorialListenEventOnSchema>;
7
7
  export type TutorialSteeringWheelButton = z.infer<typeof tutorialSteeringWheelButtonSchema>;
8
+ export type TutorialInputButton = z.infer<typeof tutorialInputButtonSchema>;
8
9
  export type TutorialCheckpointTarget = z.infer<typeof tutorialCheckpointTargetSchema>;
9
10
  export type TutorialKartSnapshot = z.infer<typeof tutorialKartSnapshotSchema>;
10
11
  export type TutorialInputSignalType = z.infer<typeof tutorialInputSignalTypeSchema>;
@@ -13,4 +14,5 @@ export type TutorialInputSignal = z.infer<typeof tutorialInputSignalSchema>;
13
14
  export type TutorialConfiguration = z.infer<typeof tutorialConfigurationSchema>;
14
15
  export type TutorialParticipant = z.infer<typeof tutorialParticipantSchema>;
15
16
  export type TutorialSession = z.infer<typeof tutorialSessionSchema>;
16
- export type StartOperatorTutorial = z.infer<typeof startOperatorTutorialSchema>;
17
+ export type StartRaceTutorial = z.infer<typeof startRaceTutorialSchema>;
18
+ export type StartBattleTutorial = z.infer<typeof startBattleTutorialSchema>;