@tastic/shell 0.22.0 → 0.23.1

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
@@ -43,7 +43,7 @@ package ecosystem, on [`@tastic/hud`](https://github.com/jayrdeaton/react-native
43
43
  kept per player), `createGameStats` (its stats and achievements), `createGameGuideSlice` (which
44
44
  version of its How to Play a player has seen), `onProfileRemoved` (forget a deleted profile),
45
45
  `usePack` and `usePackGame`, `useActiveRound`, `useProfiles`, `useSeatColors`, `useOpponent`,
46
- `useAppSettings`, `useGameGuide`, `useAtComputer`, `roundModeFor`, `humanSeatsFor`, `seatTwoFor`,
46
+ `useAppSettings`, `useGameGuide`, `useGuideCovering`, `useAtComputer`, `roundModeFor`, `humanSeatsFor`, `seatTwoFor`,
47
47
  `MatchChips`, `SettingsDialog`, `safeBack`, `useBackBlock` (Android's and the browser's back
48
48
  mid-match open Quit Match?), `Staged` (a long page a few parts at a time) and `imageGameIcon` (see [Hooks and helpers](#hooks-and-helpers)).
49
49
 
@@ -136,7 +136,8 @@ PuckTastic and DuelTastic draw what they always did:
136
136
  | `edgeGuard?` | `false` leaves Edge Guard out of Settings (no edge controls, no Edge Guard plugin), and out of the play screens' options on Android. |
137
137
  | `seatTheme?` | `(colors, dark) => ({ color, harmony })`: the theme the seats' colors make (a muted seed from seat 1's color), applied whenever they or dark mode change and as a fresh install's theme, in place of a triad of the raw colors. With it, `useSeatColors` reads each seat's color from where it's remembered (`seatColors`) rather than from the theme. |
138
138
  | `previewColor?` | `(hex, dark) => string`: how every profile color is drawn (the seat buttons and their swatches on Home and in the loadouts, a loadout's Ready button and seat controls, each `ProfileChip`), mounted as `@tastic/profile`'s `ProfileColorProvider`. Saved colors stay as picked. |
139
- | `guide?` | The pack's own How to Play (`PackGuide`: `version`, `selectVersionSeen`, `markSeen`, `getSteps({ touch })`), for cards that teach every game at once: shown on Home's first launch (never while a cold launch resumes a game), replayed from Home's Settings, never in a play screen. Its seen version is a key of the pack's own. |
139
+ | `guide?` | The pack's own How to Play (`PackGuide`: `version`, `selectVersionSeen`, `markSeen`, `getSteps({ touch })`), for cards that teach every game with none of its own at once: shown over the board the first time any of those games is started (0.23.0; on Home's first launch before), and replayed from Home's Settings. Each of those games' play screens holds while `useGuideCovering()` is true (see [How to Play](#how-to-play)). Its seen version is a key of the pack's own. |
140
+ | `HowToPlay?` | The dialog every set of How to Play cards is drawn in (hud's `HowToPlayDialogProps`), in place of hud's `HowToPlayDialog`: a pack's own around it, such as a theme that keeps its titles readable (0.23.0). |
140
141
  | `guestLabel?`, `nullLabel?` | Seat 1's button on Home and in every loadout: the chip's label for a guest (default `'P1'`) and the guest row's in its menu. A 2 Player loadout's seat 2 button takes the same two (its guest default `'P2'`). |
141
142
  | `guestStats?` | The stats screen keeps a guest's stats under `GUEST_PLAYER_ID` (`'guest'`): a Guest entry between Everyone and the profiles once a profile exists, and the screen opens on seat 1's player. Without it the screen opens on Everyone, where guests count. |
142
143
  | `useStatsPlayer?` | A hook returning the profile id the stats screen opens on, for a pack that keeps its own idea of who is playing (AlphaTastic's active player). Null, or an id not on the roster, opens on Everyone. Takes precedence over `guestStats`' opening on seat 1. |
@@ -167,14 +168,14 @@ What a game can leave out or add, each optional, so a two-seat game sets none of
167
168
  | --- | --- |
168
169
  | no `seatTwo` (nor `sideBySideWhenWide`) | A game for one player: its loadout has no opponent button, every round is solo (`useActiveRound` falls back to `'solo'`), and its How to Play describes a solo round. |
169
170
  | no `'cpu'` in `seatTwo` | A game with no CPU, such as `['nobody', 'person']`. Seat 2's saved choice is the whole pack's and starts on the CPU, so `seatTwoFor` reads a choice a game doesn't offer as the CPU where it has one, and as its first choice where it has none: a fresh install opens this game's loadout on that choice, its How to Play describes it, and `useActiveRound` falls back to it. The saved choice only changes when player 1 picks another. |
170
- | no `useLoadout` | Nothing to set up first: Home opens its play screen straight away, after its How to Play the first time, and a link to its loadout plays it. Its rule variants go in its play screen's Settings: `<SettingsDialog>` takes `children`. |
171
+ | no `useLoadout` | Nothing to set up first: Home opens its play screen straight away, after its How to Play the first time (where that isn't over its board), and a link to its loadout plays it. Its rule variants go in its play screen's Settings: `<SettingsDialog>` takes `children`. |
171
172
  | no `cpuDifficulty` (in `GameLoadout`) | A CPU with no levels: player 1's opponent menu offers one plain CPU. |
172
173
  | `resumable` | A cold launch drops the player back into its play screen if they left the app there rather than backing out of it, with its loadout (when it has one) and Home beneath it, as if they'd walked there, so every way back is a pop. The shell remembers only which game (`lastActiveGame`); the game saves and restores its own board. |
173
174
  | `Preview` | Drawn on Home in place of the icon (`GamePreviewProps`: `width`, `height`, the seats' colors, `dark`), in a box of `PREVIEW_ASPECT` (360:200), a frame after Home first paints. While any game has one, Home shows tiles: rows upright, and on a wide screen a grid beside the hero and seat 1's button. A game without one keeps its icon. |
174
175
  | no `icon` | Only with a `Preview`, which Home draws in its place. |
175
176
  | no `Provider` | A game whose stats live in the pack's own `Provider`. |
176
177
  | no `AchievementList`, no `resetStats` | A game whose achievements are in the pack's one list, and whose stats the pack resets (`PackDefinition.AchievementList`, `resetStats`). |
177
- | no `guide` (`GuidelessGameDefinition`) | A game the pack's own `guide` teaches: its tile opens without cards the first time. A `GameDefinition` keeps `guide` required, so a pack's code that reads its games' cards keeps compiling; `PackDefinition.games` takes either (`PackGameDefinition`). |
178
+ | no `guide` (`GuidelessGameDefinition`) | A game the pack's own `guide` teaches: its tile opens without cards, and the pack's open over its board the first time any such game is started. A `GameDefinition` keeps `guide` required, so a pack's code that reads its games' cards keeps compiling; `PackDefinition.games` takes either (`PackGameDefinition`). |
178
179
  | `Rules` | Its tile's rules button opens this sheet (`GameRulesProps`: `visible`, `onDismiss`) in place of its How to Play. It portals into a host inside Home's frame, so it's laid out against Home's safe area. |
179
180
  | `keepStatusBar` | Its play screen keeps the status bar. Unset, every play screen hides it for the whole round. |
180
181
 
@@ -199,7 +200,8 @@ A game's `guide` (`GameGuide`) builds its How to Play cards from the live settin
199
200
  `selectVersionSeen(state)` and `markSeen(version)` (from `createGameGuideSlice`), `selectInput(state)`
200
201
  (the settings the cards read, as a flat object, compared shallowly) and `getSteps(input, { touch,
201
202
  mode })`, hud's `GuideStep`s for a touch-first device or not and the round (`RoundMode`) seat 2's
202
- saved choice makes in this game (`seatTwoFor`).
203
+ saved choice makes in this game (`seatTwoFor`). `atStart` (optional) opens them over the board
204
+ instead of on the tile's first tap (see [How to Play](#how-to-play)).
203
205
 
204
206
  ### `createPackStore`
205
207
 
@@ -291,10 +293,12 @@ actions and defaults are exported for a pack's own code and its tests.
291
293
  - `useAppSettings()`: `{ settings, setSettings(patch) }`, the pack-wide settings (`AppSettings`). A
292
294
  patch changes only the fields it names.
293
295
  - `useGameGuide()`: How to Play. `openFirstTime(gameId, next)` shows a game's cards if this player
294
- hasn't finished or skipped this version, then runs `next` once they close (at once otherwise);
295
- `openFor(gameId)` shows them now; `openPack()` shows the pack's own `guide`; `autoShowPack()` shows
296
- it once per session while unseen (Home's first launch). A game with no cards of its own opens
297
- nothing.
296
+ hasn't finished or skipped this version, then runs `next` once they close (at once otherwise, and
297
+ for a game whose cards open over its board); `openFor(gameId)` shows them now; `openPack()` shows
298
+ the pack's own `guide`. A game with no cards of its own opens nothing.
299
+ - `useGuideCovering()`: true from a play screen's first frame until its How to Play cards are closed,
300
+ the first time the game is started, in a game whose cards open over its board (see [How to
301
+ Play](#how-to-play)); false everywhere else.
298
302
  - `useAtComputer()`: true on the web without a touch-first screen (`@tastic/core`'s
299
303
  `useIsTouchPrimaryDevice`), where `sideBySideAtComputer` and `MatchChips` see a computer.
300
304
  - `roundModeFor(seatTwo)`: `'cpu'` is `'vsCpu'`, `'person'` `'twoPlayer'` and `'nobody'` `'solo'`.
@@ -308,6 +312,37 @@ actions and defaults are exported for a pack's own code and its tests.
308
312
  then the pack's `SettingsSections` under them.
309
313
  - `safeBack()`: back, or Home (`/`) where there's nothing to go back to.
310
314
 
315
+ ### How to Play
316
+
317
+ A game's cards open by themselves once for each version, in one of two places:
318
+
319
+ - **On its tile's first tap on Home**, before its loadout (the default). Home has one reader, before
320
+ anyone is seated, so it suits a game two people play face to face on one phone, and nothing in the
321
+ game has to wait.
322
+ - **Over its board, the first time it's started** (0.23.0): a `guide` with `atStart: true`, or a game
323
+ with no cards of its own in a pack with a `guide`. They come up 0.7 seconds after the board
324
+ (`PlayRoute`), however the player got there: Ready, a link, a relaunch into the board. The card is
325
+ upright, as Quit Match?, Paused and Settings are over a match. Leaving before they're closed counts
326
+ as nothing seen.
327
+
328
+ Over a board the game has to hold itself: `useGuideCovering()` is true from the play screen's first
329
+ frame until the cards are closed, and whatever stops the game under its Settings stops for it too (its
330
+ clock, its countdown, its CPU, its input, any card of its own such as a hand-off).
331
+
332
+ ```tsx
333
+ import { useGuideCovering } from '@tastic/shell'
334
+
335
+ const covered = useGuideCovering()
336
+ const paused = settingsOpen || confirmVisible || backgroundPaused || covered
337
+ ```
338
+
339
+ `<PlayRoute guide={false} />` opens none over a play whose clock can't be held (CardTastic's Daily
340
+ Deals, timed by the server from the tap that starts one): they stay unseen, for the next play.
341
+
342
+ Either way they replay from the tile's rules button (in a game without `Rules`) and its loadout's
343
+ Settings, and the pack's own from Home's Settings; finishing or skipping a replay counts as having seen
344
+ them.
345
+
311
346
  ### On every pack (0.2.0)
312
347
 
313
348
  Six fixes CardTastic's move brought to every pack's screens: Home's press-away overlay sits in the
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { ComponentType, ReactNode, ComponentProps } from 'react';
3
3
  import * as _rific_auto_paper from '@rific/auto-paper';
4
4
  import { ThemeAppearance, ThemeSettings } from '@rific/auto-paper';
5
5
  import { PopoverHost, AlignResult } from '@tastic/hud/chrome';
6
- import { GuideStep } from '@tastic/hud/guide';
6
+ import { GuideStep, HowToPlayDialogProps } from '@tastic/hud/guide';
7
7
  import { MenuOption } from '@tastic/hud/lobby';
8
8
  import * as _tastic_profile from '@tastic/profile';
9
9
  import { profilesReducer, Profile, CreateProfileInput, SeatColorsState as SeatColorsState$1 } from '@tastic/profile';
@@ -175,6 +175,7 @@ interface GameGuide {
175
175
  touch: boolean;
176
176
  mode: RoundMode;
177
177
  }) => GuideStep[];
178
+ atStart?: boolean;
178
179
  }
179
180
  interface GameIconProps {
180
181
  size: number;
@@ -302,6 +303,7 @@ interface PackDefinition {
302
303
  seatTheme?: (colors: Record<Seat, string>, dark: boolean) => Pick<ThemeSettings, 'color' | 'harmony'>;
303
304
  previewColor?: (hex: string, dark: boolean) => string;
304
305
  guide?: PackGuide;
306
+ HowToPlay?: ComponentType<HowToPlayDialogProps>;
305
307
  guestLabel?: string;
306
308
  nullLabel?: string;
307
309
  guestStats?: boolean;
@@ -387,7 +389,9 @@ declare function RootLayout({ pack, store, persistor }: RootLayoutProps): react.
387
389
  declare function EditProfileRoute(): react.JSX.Element;
388
390
 
389
391
  declare function LoadoutRoute(): react.JSX.Element;
390
- declare function PlayRoute(): react.JSX.Element;
392
+ declare function PlayRoute({ guide }?: {
393
+ guide?: boolean;
394
+ }): react.JSX.Element;
391
395
 
392
396
  declare function HomeScreen(): react.JSX.Element | null;
393
397
 
@@ -401,7 +405,6 @@ interface GameGuideContextValue {
401
405
  openFirstTime: (gameId: string, next: () => void) => void;
402
406
  openFor: (gameId: string) => void;
403
407
  openPack: () => void;
404
- autoShowPack: () => void;
405
408
  }
406
409
  declare function useGameGuide(): GameGuideContextValue;
407
410
 
@@ -450,6 +453,8 @@ interface Props$1 {
450
453
  }
451
454
  declare function Staged({ first, step, children }: Props$1): react.JSX.Element;
452
455
 
456
+ declare function useGuideCovering(): boolean;
457
+
453
458
  declare function useActiveRound<S extends object>(game: string, defaults: S): {
454
459
  mode: RoundMode;
455
460
  settings: S;
@@ -598,5 +603,5 @@ declare function createPlayerSettings<S extends WithControls<C>, C>({ id, defaul
598
603
  };
599
604
  };
600
605
 
601
- export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, Staged, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
606
+ export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, Staged, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useGuideCovering, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
602
607
  export type { ActiveRound, AppSettings, FeedbackSounds, GameDefinition, GameGuide, GameGuideState, GameIconProps, GameLoadout, GamePreviewProps, GameRulesProps, GuidelessGameDefinition, HeroTitleProps, HomeTab, LiveplaySliceState, LoadoutOptionsProps, MatchChipsProps, OpponentState, PackDefinition, PackGameDefinition, PackGuide, PackStatsReset, PackStatsSectionsProps, PackStatsTab, PackStore, PackStoreConfig, PackStoreSource, PickerAlign, PlayerControlsState, PlayerSettingsState, ProfileSelectionState, RecordResult, RoundMode, Seat, SeatColorsState, SeatControlLook, SeatTwo, SettingsDialogProps, ShellState, StackScreenOptions };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ComponentType, ReactNode, ComponentProps } from 'react';
3
3
  import * as _rific_auto_paper from '@rific/auto-paper';
4
4
  import { ThemeAppearance, ThemeSettings } from '@rific/auto-paper';
5
5
  import { PopoverHost, AlignResult } from '@tastic/hud/chrome';
6
- import { GuideStep } from '@tastic/hud/guide';
6
+ import { GuideStep, HowToPlayDialogProps } from '@tastic/hud/guide';
7
7
  import { MenuOption } from '@tastic/hud/lobby';
8
8
  import * as _tastic_profile from '@tastic/profile';
9
9
  import { profilesReducer, Profile, CreateProfileInput, SeatColorsState as SeatColorsState$1 } from '@tastic/profile';
@@ -175,6 +175,7 @@ interface GameGuide {
175
175
  touch: boolean;
176
176
  mode: RoundMode;
177
177
  }) => GuideStep[];
178
+ atStart?: boolean;
178
179
  }
179
180
  interface GameIconProps {
180
181
  size: number;
@@ -302,6 +303,7 @@ interface PackDefinition {
302
303
  seatTheme?: (colors: Record<Seat, string>, dark: boolean) => Pick<ThemeSettings, 'color' | 'harmony'>;
303
304
  previewColor?: (hex: string, dark: boolean) => string;
304
305
  guide?: PackGuide;
306
+ HowToPlay?: ComponentType<HowToPlayDialogProps>;
305
307
  guestLabel?: string;
306
308
  nullLabel?: string;
307
309
  guestStats?: boolean;
@@ -387,7 +389,9 @@ declare function RootLayout({ pack, store, persistor }: RootLayoutProps): react.
387
389
  declare function EditProfileRoute(): react.JSX.Element;
388
390
 
389
391
  declare function LoadoutRoute(): react.JSX.Element;
390
- declare function PlayRoute(): react.JSX.Element;
392
+ declare function PlayRoute({ guide }?: {
393
+ guide?: boolean;
394
+ }): react.JSX.Element;
391
395
 
392
396
  declare function HomeScreen(): react.JSX.Element | null;
393
397
 
@@ -401,7 +405,6 @@ interface GameGuideContextValue {
401
405
  openFirstTime: (gameId: string, next: () => void) => void;
402
406
  openFor: (gameId: string) => void;
403
407
  openPack: () => void;
404
- autoShowPack: () => void;
405
408
  }
406
409
  declare function useGameGuide(): GameGuideContextValue;
407
410
 
@@ -450,6 +453,8 @@ interface Props$1 {
450
453
  }
451
454
  declare function Staged({ first, step, children }: Props$1): react.JSX.Element;
452
455
 
456
+ declare function useGuideCovering(): boolean;
457
+
453
458
  declare function useActiveRound<S extends object>(game: string, defaults: S): {
454
459
  mode: RoundMode;
455
460
  settings: S;
@@ -598,5 +603,5 @@ declare function createPlayerSettings<S extends WithControls<C>, C>({ id, defaul
598
603
  };
599
604
  };
600
605
 
601
- export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, Staged, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
606
+ export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, Staged, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useGuideCovering, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
602
607
  export type { ActiveRound, AppSettings, FeedbackSounds, GameDefinition, GameGuide, GameGuideState, GameIconProps, GameLoadout, GamePreviewProps, GameRulesProps, GuidelessGameDefinition, HeroTitleProps, HomeTab, LiveplaySliceState, LoadoutOptionsProps, MatchChipsProps, OpponentState, PackDefinition, PackGameDefinition, PackGuide, PackStatsReset, PackStatsSectionsProps, PackStatsTab, PackStore, PackStoreConfig, PackStoreSource, PickerAlign, PlayerControlsState, PlayerSettingsState, ProfileSelectionState, RecordResult, RoundMode, Seat, SeatColorsState, SeatControlLook, SeatTwo, SettingsDialogProps, ShellState, StackScreenOptions };