@tastic/shell 0.8.3 → 0.10.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 CHANGED
@@ -32,7 +32,8 @@ package ecosystem, on [`@tastic/hud`](https://github.com/jayrdeaton/react-native
32
32
  - **What a game builds on**: `createPlayerSettings` (its settings and controls, kept per player),
33
33
  `createGameStats` (its stats and achievements), `createGameGuideSlice` (which version of its How to
34
34
  Play a player has seen), `onProfileRemoved` (forget a deleted profile), `useActiveRound`,
35
- `useProfiles`, `useSeatColors`, `SettingsDialog`, `safeBack` and `imageGameIcon`.
35
+ `useProfiles`, `useSeatColors`, `SettingsDialog`, `safeBack`, `useBackBlock` (Android's and the
36
+ browser's back mid-match open Quit Match?) and `imageGameIcon`.
36
37
 
37
38
  ## Install
38
39
 
@@ -118,7 +119,7 @@ PuckTastic and DuelTastic draw what they always did:
118
119
  | `useScreenOptions?` | A hook returning stack screen options (`StackScreenOptions`), merged after the shell's own (a status bar style of the pack's own, Reduce Motion's crossfade). The shell's already follow the app's theme, and stay dark over a `Backdrop`. |
119
120
  | `useFeedbackSounds?` | A hook returning the two sounds every button plays (`FeedbackSounds`: `selection`, `notification`), in place of the shell's two wavs. |
120
121
  | `Toaster?` | The pack's own toaster, drawn in a frame over the whole app (inside the safe area) in place of the shell's. The toast provider is given no Paper, so nothing portals it out of the frame. |
121
- | `edgeGuard?` | `false` leaves Edge Guard out of Settings (no edge controls, no Edge Guard plugin). |
122
+ | `edgeGuard?` | `false` leaves Edge Guard out of Settings (no edge controls, no Edge Guard plugin), and out of the play screens' options on Android. |
122
123
  | `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. |
123
124
  | `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. |
124
125
  | `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. |
@@ -146,6 +147,7 @@ What a game can leave out or add, each optional, so a two-seat game sets none of
146
147
  | Field | |
147
148
  | --- | --- |
148
149
  | 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. |
150
+ | 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. |
149
151
  | 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`. |
150
152
  | no `cpuDifficulty` (in `GameLoadout`) | A CPU with no levels: player 1's opponent menu offers one plain CPU. |
151
153
  | `resumable` | A cold launch drops the player back into its play screen if they left the app there rather than backing out of it. The shell remembers only which game (`lastActiveGame`); the game saves and restores its own board. |
@@ -212,6 +214,39 @@ the window's middle.
212
214
  it stops; up all match at a computer.
213
215
  - **Look:** a 24 icon in the theme's full contrast on a translucent chip of the page's color.
214
216
 
217
+ ### Back mid-match (`useBackBlock`)
218
+
219
+ `useBackBlock(held, onHeld)` holds a play screen while `held`: every way off it but the `quit` it
220
+ returns (Android's hardware or gesture back, the browser's back, a link) runs `onHeld` instead. Hand it
221
+ the same test the back chip's Quit Match? asks with, and `requestBack` from `@tastic/hud`'s
222
+ `useQuitConfirmation`, so a system back opens the same Quit Match? the chip does; use `quit` for
223
+ Quit Match?'s and Paused's own Quit, which `safeBack` alone would be stopped by.
224
+
225
+ ```tsx
226
+ const hasProgressRef = useRef(false)
227
+ const { confirmVisible, requestBack, cancelBack } = useQuitConfirmation(() => hasProgressRef.current, safeBack)
228
+ // ... the game's state hook, which needs `paused` from confirmVisible ...
229
+ const hasProgress = phase !== 'gameOver' && (scores[0] > 0 || scores[1] > 0)
230
+ useEffect(() => {
231
+ hasProgressRef.current = hasProgress
232
+ })
233
+ const quit = useBackBlock(hasProgress, requestBack)
234
+
235
+ <ConfirmDialog visible={confirmVisible} title='Quit Match?' onConfirm={quit} onCancel={cancelBack} />
236
+ ```
237
+
238
+ - `held` is a plain boolean read as the screen renders (expo-router has to know before a back comes
239
+ in), so a game whose progress comes from a state hook that itself needs Quit Match?'s `paused` calls
240
+ this after that hook, and mirrors the value into the getter it gives `useQuitConfirmation`.
241
+ - Off when there's nothing to lose (0-0, Game Over), so a back there leaves at once, as the chip does.
242
+ - `quit` goes back (`safeBack`) unless a third argument, `leave`, says where: `useBackBlock(held,
243
+ onHeld, leave)`. For a Quit Match? that more than one thing opens, such as a back and a Home button
244
+ that goes to Home past the screen underneath, pass a `leave` that reads which one opened it
245
+ (`() => router.dismissTo('/')` for Home). It's read when `quit` runs, so it can change between
246
+ renders.
247
+ - While it's on, the web also asks before the page unloads (expo-router's `usePreventRemove` adds a
248
+ `beforeunload` handler with it). iOS's swipe back is off on every screen anyway.
249
+
215
250
  ## Peer dependencies
216
251
 
217
252
  None are bundled. The floors are the versions PuckTastic and DuelTastic ran the shell on when it
@@ -238,7 +273,7 @@ became a package (the lower of the two where they differ).
238
273
  | `@tastic/profile` | >=0.16.2 | profiles, the seat buttons, seat colors |
239
274
  | `@tastic/achievements` | >=0.6.0 | `createGameStats`, `forgetProfileAchievements` |
240
275
  | `@tastic/split-screen` | >=0.5.5 | the 2 Player loadout's two halves |
241
- | `@tastic/edge-guard` | >=0.1.5 | Edge Guard during play |
276
+ | `@tastic/edge-guard` | >=0.2.0 | Edge Guard during play (`useEdgeGestureGuard` on iOS, `edgeGuardScreenOptions` on Android) |
242
277
 
243
278
  The two UI sounds every button plays (`assets/sounds/select.wav` and `notification.wav`) ship with the
244
279
  package.
package/dist/index.d.mts CHANGED
@@ -445,6 +445,8 @@ declare function useAppSettings(): {
445
445
 
446
446
  declare function useAtComputer(): boolean;
447
447
 
448
+ declare function useBackBlock(held: boolean, onHeld: () => void, leave?: () => void): () => void;
449
+
448
450
  declare function useOpponent(): {
449
451
  seatTwo: SeatTwo;
450
452
  setSeatTwo: (seatTwo: SeatTwo) => void;
@@ -579,5 +581,5 @@ declare function createPlayerSettings<S extends WithControls<C>, C>({ id, defaul
579
581
  };
580
582
  };
581
583
 
582
- export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, 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, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
584
+ export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, 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 };
583
585
  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
@@ -445,6 +445,8 @@ declare function useAppSettings(): {
445
445
 
446
446
  declare function useAtComputer(): boolean;
447
447
 
448
+ declare function useBackBlock(held: boolean, onHeld: () => void, leave?: () => void): () => void;
449
+
448
450
  declare function useOpponent(): {
449
451
  seatTwo: SeatTwo;
450
452
  setSeatTwo: (seatTwo: SeatTwo) => void;
@@ -579,5 +581,5 @@ declare function createPlayerSettings<S extends WithControls<C>, C>({ id, defaul
579
581
  };
580
582
  };
581
583
 
582
- export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, 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, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
584
+ export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, 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 };
583
585
  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.js CHANGED
@@ -73,6 +73,7 @@ __export(index_exports, {
73
73
  useActiveRound: () => useActiveRound,
74
74
  useAppSettings: () => useAppSettings,
75
75
  useAtComputer: () => useAtComputer,
76
+ useBackBlock: () => useBackBlock,
76
77
  useGameGuide: () => useGameGuide,
77
78
  useOpponent: () => useOpponent,
78
79
  usePack: () => usePack,
@@ -102,12 +103,13 @@ function usePackGame(id) {
102
103
  var import_auto_paper2 = require("@rific/auto-paper");
103
104
  var import_feedback_press2 = require("@rific/feedback-press");
104
105
  var import_toaster2 = require("@rific/toaster");
105
- var import_core4 = require("@tastic/core");
106
+ var import_core5 = require("@tastic/core");
107
+ var import_edge_guard2 = require("@tastic/edge-guard");
106
108
  var import_chrome2 = require("@tastic/hud/chrome");
107
109
  var import_profile3 = require("@tastic/profile");
108
110
  var Haptics = __toESM(require("expo-haptics"));
109
111
  var import_expo_router = require("expo-router");
110
- var import_react8 = require("react");
112
+ var import_react9 = require("react");
111
113
  var import_react_native3 = require("react-native");
112
114
  var import_react_native_gesture_handler = require("react-native-gesture-handler");
113
115
  var RNPaper2 = __toESM(require("react-native-paper"));
@@ -146,8 +148,9 @@ function roundModeFor(seatTwo) {
146
148
  return seatTwo === "person" ? "twoPlayer" : seatTwo === "nobody" ? "solo" : "vsCpu";
147
149
  }
148
150
  function seatTwoFor(saved, choices) {
149
- if (!choices) return "nobody";
150
- return choices.includes(saved) ? saved : "cpu";
151
+ if (!choices?.length) return "nobody";
152
+ if (choices.includes(saved)) return saved;
153
+ return choices.includes("cpu") ? "cpu" : choices[0];
151
154
  }
152
155
  function humanSeatsFor(mode) {
153
156
  return mode === "twoPlayer" ? [1, 2] : [1];
@@ -319,26 +322,56 @@ function WindowControlsInsets({ children }) {
319
322
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_safe_area_context.SafeAreaInsetsContext.Provider, { value: vertical, children });
320
323
  }
321
324
 
322
- // src/hooks/useLastActiveGame.tsx
325
+ // src/hooks/useAppSettings.ts
323
326
  var import_react6 = require("react");
324
327
  var import_react_redux4 = require("react-redux");
325
328
 
326
- // src/redux/lastActiveGameSlice.ts
329
+ // src/redux/appSettingsSlice.ts
327
330
  var import_core3 = require("@rific/core");
328
- var { actions, reducer } = (0, import_core3.createSettingsSlice)("lastActiveGame", { initialState: { gameId: null } });
329
- var lastActiveGameActions = actions;
330
- var lastActiveGameSlice_default = reducer;
331
+ var DEFAULT_APP_SETTINGS = {
332
+ deferBottomEdgeGestures: false
333
+ };
334
+ var { actions, reducer } = (0, import_core3.createSettingsSlice)("appSettings", {
335
+ initialState: DEFAULT_APP_SETTINGS,
336
+ initializeMode: "merge",
337
+ fieldSetters: []
338
+ });
339
+ var appSettingsActions = actions;
340
+ var appSettingsSlice_default = reducer;
341
+
342
+ // src/hooks/useAppSettings.ts
343
+ function useAppSettings() {
344
+ const settings = (0, import_react_redux4.useSelector)((state) => state.appSettings);
345
+ const dispatch = (0, import_react_redux4.useDispatch)();
346
+ const setSettings = (0, import_react6.useCallback)(
347
+ (patch) => {
348
+ dispatch(appSettingsActions.initialize(patch));
349
+ },
350
+ [dispatch]
351
+ );
352
+ return { settings, setSettings };
353
+ }
354
+
355
+ // src/hooks/useLastActiveGame.tsx
356
+ var import_react7 = require("react");
357
+ var import_react_redux5 = require("react-redux");
358
+
359
+ // src/redux/lastActiveGameSlice.ts
360
+ var import_core4 = require("@rific/core");
361
+ var { actions: actions2, reducer: reducer2 } = (0, import_core4.createSettingsSlice)("lastActiveGame", { initialState: { gameId: null } });
362
+ var lastActiveGameActions = actions2;
363
+ var lastActiveGameSlice_default = reducer2;
331
364
 
332
365
  // src/hooks/useLastActiveGame.tsx
333
366
  var import_jsx_runtime8 = require("react/jsx-runtime");
334
- var LastActiveGameContext = (0, import_react6.createContext)(null);
367
+ var LastActiveGameContext = (0, import_react7.createContext)(null);
335
368
  function LastActiveGameProvider({ children }) {
336
- const store = (0, import_react_redux4.useStore)();
337
- const dispatch = (0, import_react_redux4.useDispatch)();
338
- const [initial] = (0, import_react6.useState)(() => store.getState().lastActiveGame?.gameId ?? null);
339
- const pendingResume = (0, import_react6.useRef)(initial);
340
- const persisted = (0, import_react6.useRef)(initial);
341
- const value = (0, import_react6.useMemo)(
369
+ const store = (0, import_react_redux5.useStore)();
370
+ const dispatch = (0, import_react_redux5.useDispatch)();
371
+ const [initial] = (0, import_react7.useState)(() => store.getState().lastActiveGame?.gameId ?? null);
372
+ const pendingResume = (0, import_react7.useRef)(initial);
373
+ const persisted = (0, import_react7.useRef)(initial);
374
+ const value = (0, import_react7.useMemo)(
342
375
  () => ({
343
376
  consumeResumeGame: () => {
344
377
  const game = pendingResume.current;
@@ -366,33 +399,33 @@ function LastActiveGameProvider({ children }) {
366
399
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LastActiveGameContext.Provider, { value, children });
367
400
  }
368
401
  function useLastActiveGame() {
369
- const ctx = (0, import_react6.useContext)(LastActiveGameContext);
402
+ const ctx = (0, import_react7.useContext)(LastActiveGameContext);
370
403
  if (!ctx) throw new Error("useLastActiveGame must be used within a LastActiveGameProvider");
371
404
  return ctx;
372
405
  }
373
406
 
374
407
  // src/hooks/useProfiles.tsx
375
408
  var import_profile2 = require("@tastic/profile");
376
- var import_react7 = require("react");
377
- var import_react_redux5 = require("react-redux");
409
+ var import_react8 = require("react");
410
+ var import_react_redux6 = require("react-redux");
378
411
 
379
412
  // src/redux/profileSelectionSlice.ts
380
413
  var import_profile = require("@tastic/profile");
381
414
  var defaultProfileSelectionState = { 1: null, 2: null };
382
- var { actions: actions2, reducer: reducer2 } = (0, import_profile.createProfileSelectionSlice)("pack", defaultProfileSelectionState);
383
- var profileSelectionActions = actions2;
384
- var profileSelectionSlice_default = reducer2;
415
+ var { actions: actions3, reducer: reducer3 } = (0, import_profile.createProfileSelectionSlice)("pack", defaultProfileSelectionState);
416
+ var profileSelectionActions = actions3;
417
+ var profileSelectionSlice_default = reducer3;
385
418
 
386
419
  // src/hooks/useProfiles.tsx
387
420
  var import_jsx_runtime9 = require("react/jsx-runtime");
388
421
  var SHARED_GROUP_ID = "group.com.infinitetoken.tastic";
389
- var ProfilesContext = (0, import_react7.createContext)(null);
422
+ var ProfilesContext = (0, import_react8.createContext)(null);
390
423
  function ProfilesProvider({ children }) {
391
- const profiles = (0, import_react_redux5.useSelector)((state) => state.profiles);
392
- const lastSelected = (0, import_react_redux5.useSelector)((state) => state.profileSelection);
393
- const dispatch = (0, import_react_redux5.useDispatch)();
394
- const [loaded, setLoaded] = (0, import_react7.useState)(false);
395
- (0, import_react7.useEffect)(() => {
424
+ const profiles = (0, import_react_redux6.useSelector)((state) => state.profiles);
425
+ const lastSelected = (0, import_react_redux6.useSelector)((state) => state.profileSelection);
426
+ const dispatch = (0, import_react_redux6.useDispatch)();
427
+ const [loaded, setLoaded] = (0, import_react8.useState)(false);
428
+ (0, import_react8.useEffect)(() => {
396
429
  let cancelled = false;
397
430
  (0, import_profile2.resolveInitialProfiles)(SHARED_GROUP_ID, profiles).then((resolved) => {
398
431
  if (cancelled) return;
@@ -406,7 +439,7 @@ function ProfilesProvider({ children }) {
406
439
  }, []);
407
440
  const { syncToShared } = (0, import_profile2.useSharedProfilesSync)({
408
441
  groupId: SHARED_GROUP_ID,
409
- onRemoteChange: (0, import_react7.useCallback)(
442
+ onRemoteChange: (0, import_react8.useCallback)(
410
443
  (remote) => {
411
444
  dispatch(import_profile2.profilesActions.setAll(remote));
412
445
  dispatch(profileSelectionActions.pruneToRoster(remote.map((p) => p.id)));
@@ -414,7 +447,7 @@ function ProfilesProvider({ children }) {
414
447
  [dispatch]
415
448
  )
416
449
  });
417
- const createProfile = (0, import_react7.useCallback)(
450
+ const createProfile = (0, import_react8.useCallback)(
418
451
  (input) => {
419
452
  const record = (0, import_profile2.createProfileRecord)(input);
420
453
  dispatch(import_profile2.profilesActions.add(record));
@@ -423,14 +456,14 @@ function ProfilesProvider({ children }) {
423
456
  },
424
457
  [profiles, dispatch, syncToShared]
425
458
  );
426
- const updateProfile = (0, import_react7.useCallback)(
459
+ const updateProfile = (0, import_react8.useCallback)(
427
460
  (id, patch) => {
428
461
  dispatch(import_profile2.profilesActions.update({ id, patch }));
429
462
  syncToShared(profiles.map((p) => p.id === id ? { ...p, ...patch, updatedAt: Date.now() } : p));
430
463
  },
431
464
  [profiles, dispatch, syncToShared]
432
465
  );
433
- const deleteProfile = (0, import_react7.useCallback)(
466
+ const deleteProfile = (0, import_react8.useCallback)(
434
467
  (id) => {
435
468
  dispatch(import_profile2.profilesActions.remove(id));
436
469
  syncToShared(profiles.filter((p) => p.id !== id));
@@ -438,7 +471,7 @@ function ProfilesProvider({ children }) {
438
471
  },
439
472
  [profiles, dispatch, syncToShared]
440
473
  );
441
- const selectProfile = (0, import_react7.useCallback)(
474
+ const selectProfile = (0, import_react8.useCallback)(
442
475
  (seat, profileId) => {
443
476
  dispatch(profileSelectionActions.select({ profileId, seat }));
444
477
  },
@@ -447,7 +480,7 @@ function ProfilesProvider({ children }) {
447
480
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProfilesContext.Provider, { value: { profiles, lastSelected, loaded, createProfile, updateProfile, deleteProfile, selectProfile }, children });
448
481
  }
449
482
  function useProfiles() {
450
- const ctx = (0, import_react7.useContext)(ProfilesContext);
483
+ const ctx = (0, import_react8.useContext)(ProfilesContext);
451
484
  if (!ctx) throw new Error("useProfiles must be used within a ProfilesProvider");
452
485
  return ctx;
453
486
  }
@@ -463,19 +496,23 @@ function AppStack() {
463
496
  const { Backdrop } = pack;
464
497
  const { dark } = (0, import_auto_paper2.useAutoPaperTheme)();
465
498
  const darkRoot = Backdrop ? true : dark;
466
- const rootBackground = (0, import_core4.useThemedRootBackground)(darkRoot, false);
499
+ const rootBackground = (0, import_core5.useThemedRootBackground)(darkRoot, false);
467
500
  const statusBarStyle = darkRoot ? "light" : "dark";
468
501
  const packOptions = (pack.useScreenOptions ?? noScreenOptions)();
469
502
  const backdropOptions = Backdrop ? { contentStyle: TRANSPARENT_CONTENT, animation: import_react_native3.Platform.select({ android: "fade" }) } : void 0;
470
- const playOptions = (0, import_react8.useCallback)(
503
+ const { edgeGuard = true } = pack;
504
+ const { deferBottomEdgeGestures } = useAppSettings().settings;
505
+ const edgeGuardOptions = (0, import_react9.useMemo)(() => (0, import_edge_guard2.edgeGuardScreenOptions)(edgeGuard && deferBottomEdgeGestures), [edgeGuard, deferBottomEdgeGestures]);
506
+ const playOptions = (0, import_react9.useCallback)(
471
507
  ({ route }) => {
472
508
  const id = route.params?.game;
473
- return pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
509
+ const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
510
+ return { ...statusBarOptions, ...edgeGuardOptions };
474
511
  },
475
- [pack.games]
512
+ [pack.games, edgeGuardOptions]
476
513
  );
477
514
  const navigationBackground = Backdrop ? TRANSPARENT_CONTENT.backgroundColor : rootBackground.contentStyle.backgroundColor;
478
- const navigationTheme = (0, import_react8.useMemo)(() => {
515
+ const navigationTheme = (0, import_react9.useMemo)(() => {
479
516
  const base = darkRoot ? import_expo_router.DarkTheme : import_expo_router.DefaultTheme;
480
517
  return { ...base, colors: { ...base.colors, background: navigationBackground } };
481
518
  }, [darkRoot, navigationBackground]);
@@ -499,7 +536,7 @@ function HapticGatedToastProvider({ children }) {
499
536
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_toaster2.ToastProvider, { haptics: settings.vibrate ? Haptics : void 0, paper: PackToasterComponent ? void 0 : RNPaper2, children });
500
537
  }
501
538
  function RotatingToaster() {
502
- const renderFrame = (0, import_react8.useCallback)(
539
+ const renderFrame = (0, import_react9.useCallback)(
503
540
  (toasts) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_chrome2.RotatedFrame, { rotatedSafeArea: true, passThrough: true, children: toasts }),
504
541
  []
505
542
  );
@@ -513,7 +550,7 @@ function GameProviders({ games, children }) {
513
550
  }
514
551
  function PreviewColors({ previewColor, children }) {
515
552
  const { dark } = (0, import_auto_paper2.useAutoPaperTheme)();
516
- const preview = (0, import_react8.useCallback)((hex) => previewColor(hex, dark), [previewColor, dark]);
553
+ const preview = (0, import_react9.useCallback)((hex) => previewColor(hex, dark), [previewColor, dark]);
517
554
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_profile3.ProfileColorProvider, { preview, children });
518
555
  }
519
556
  function PackRoot({ pack, children }) {
@@ -559,7 +596,7 @@ var import_react_redux9 = require("react-redux");
559
596
  // src/components/OpponentPicker.tsx
560
597
  var import_lobby = require("@tastic/hud/lobby");
561
598
  var import_profile4 = require("@tastic/profile");
562
- var import_react9 = require("react");
599
+ var import_react10 = require("react");
563
600
  var import_react_native4 = require("react-native");
564
601
  var import_jsx_runtime11 = require("react/jsx-runtime");
565
602
  var CPU_PREFIX = "cpu:";
@@ -574,7 +611,7 @@ function getOpponentPopoverId(idPrefix) {
574
611
  function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChange, cpuDifficulty, color, onColorChange, swatches, takenColor, allowSwapTaken, dark, previewValue, triggerStyle, usePickerAlign }) {
575
612
  const drawn = previewValue ? previewValue(color) : color;
576
613
  const cpuOptions = cpuDifficulty?.options;
577
- const options = (0, import_react9.useMemo)(() => {
614
+ const options = (0, import_react10.useMemo)(() => {
578
615
  const list = [];
579
616
  if (choices.includes("cpu")) list.push(...cpuOptions ? cpuOptions.map((o) => ({ value: `${CPU_PREFIX}${o.value}`, label: o.label, icon: o.icon })) : [{ value: CPU_PREFIX, label: "CPU", icon: CPU_ICON }]);
580
617
  if (choices.includes("nobody")) list.push({ value: NOBODY, label: "Solo", icon: NOBODY_ICON, dividerBefore: true });
@@ -612,38 +649,6 @@ var styles2 = import_react_native4.StyleSheet.create({
612
649
  // src/components/SettingsDialog.tsx
613
650
  var import_toaster3 = require("@rific/toaster");
614
651
  var import_chrome3 = require("@tastic/hud/chrome");
615
-
616
- // src/hooks/useAppSettings.ts
617
- var import_react10 = require("react");
618
- var import_react_redux6 = require("react-redux");
619
-
620
- // src/redux/appSettingsSlice.ts
621
- var import_core5 = require("@rific/core");
622
- var DEFAULT_APP_SETTINGS = {
623
- deferBottomEdgeGestures: false
624
- };
625
- var { actions: actions3, reducer: reducer3 } = (0, import_core5.createSettingsSlice)("appSettings", {
626
- initialState: DEFAULT_APP_SETTINGS,
627
- initializeMode: "merge",
628
- fieldSetters: []
629
- });
630
- var appSettingsActions = actions3;
631
- var appSettingsSlice_default = reducer3;
632
-
633
- // src/hooks/useAppSettings.ts
634
- function useAppSettings() {
635
- const settings = (0, import_react_redux6.useSelector)((state) => state.appSettings);
636
- const dispatch = (0, import_react_redux6.useDispatch)();
637
- const setSettings = (0, import_react10.useCallback)(
638
- (patch) => {
639
- dispatch(appSettingsActions.initialize(patch));
640
- },
641
- [dispatch]
642
- );
643
- return { settings, setSettings };
644
- }
645
-
646
- // src/components/SettingsDialog.tsx
647
652
  var import_jsx_runtime12 = require("react/jsx-runtime");
648
653
  var noSettingsRules = () => null;
649
654
  function SettingsDialog({ visible, onDismiss, onShowHowToPlay, children }) {
@@ -1646,11 +1651,33 @@ var styles6 = import_react_native12.StyleSheet.create({
1646
1651
  var import_react_redux11 = require("react-redux");
1647
1652
  function useActiveRound(game, defaults) {
1648
1653
  const round = (0, import_react_redux11.useSelector)((state) => state.liveplay.activeRound);
1649
- const seated = !!usePackGame(game)?.seatTwo;
1650
- if (!round || round.game !== game) return { mode: seated ? "vsCpu" : "solo", settings: defaults };
1654
+ const choices = usePackGame(game)?.seatTwo;
1655
+ if (!round || round.game !== game) return { mode: roundModeFor(seatTwoFor(DEFAULT_OPPONENT.seatTwo, choices)), settings: defaults };
1651
1656
  return { mode: round.mode, settings: { ...defaults, ...round.settings } };
1652
1657
  }
1653
1658
 
1659
+ // src/hooks/useBackBlock.ts
1660
+ var import_expo_router7 = require("expo-router");
1661
+ var import_react19 = require("react");
1662
+ function useBackBlock(held, onHeld, leave = import_core8.safeBack) {
1663
+ const leavingRef = (0, import_react19.useRef)(false);
1664
+ const [leaving, setLeaving] = (0, import_react19.useState)(false);
1665
+ const leaveRef = (0, import_react19.useRef)(leave);
1666
+ (0, import_react19.useEffect)(() => {
1667
+ leaveRef.current = leave;
1668
+ });
1669
+ (0, import_expo_router7.usePreventRemove)(held && !leaving, ({ repeat }) => {
1670
+ if (leavingRef.current) {
1671
+ setLeaving(true);
1672
+ repeat();
1673
+ } else onHeld();
1674
+ });
1675
+ return (0, import_react19.useCallback)(() => {
1676
+ leavingRef.current = true;
1677
+ leaveRef.current();
1678
+ }, []);
1679
+ }
1680
+
1654
1681
  // src/redux/createPackStore.ts
1655
1682
  var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
1656
1683
  var import_toolkit = require("@reduxjs/toolkit");
@@ -1785,7 +1812,7 @@ function forgetProfileAchievements(dropStats) {
1785
1812
 
1786
1813
  // src/gameStats.tsx
1787
1814
  var import_achievements2 = require("@tastic/achievements");
1788
- var import_react19 = require("react");
1815
+ var import_react20 = require("react");
1789
1816
  var import_jsx_runtime20 = require("react/jsx-runtime");
1790
1817
  var SEATS = [1, 2];
1791
1818
  function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
@@ -1803,7 +1830,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1803
1830
  };
1804
1831
  const reducer6 = onProfileRemoved(sliceReducer, forgetProfileAchievements(dropProfileStats));
1805
1832
  const profileViews = (stats) => Object.fromEntries(Object.entries(stats.profiles).map(([profileId, bucket]) => [profileId, getProfileStatsView(bucket)]));
1806
- const Context = (0, import_react19.createContext)(null);
1833
+ const Context = (0, import_react20.createContext)(null);
1807
1834
  function Provider({ children }) {
1808
1835
  const { stats, unlockedAchievements, recordOutcome, resetAll } = (0, import_achievements2.useAchievements)({
1809
1836
  catalog,
@@ -1811,18 +1838,18 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1811
1838
  actions: actions6,
1812
1839
  profileViews
1813
1840
  });
1814
- const record = (0, import_react19.useCallback)(
1841
+ const record = (0, import_react20.useCallback)(
1815
1842
  (update, profileIds) => {
1816
1843
  const result = recordOutcome(update);
1817
1844
  return { device: result.device, profiles: (0, import_achievements2.mapUnlocksBySeat)(SEATS, profileIds, result.profiles) };
1818
1845
  },
1819
1846
  [recordOutcome]
1820
1847
  );
1821
- const value = (0, import_react19.useMemo)(() => ({ stats, unlockedAchievements, record, resetAll }), [stats, unlockedAchievements, record, resetAll]);
1848
+ const value = (0, import_react20.useMemo)(() => ({ stats, unlockedAchievements, record, resetAll }), [stats, unlockedAchievements, record, resetAll]);
1822
1849
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Context.Provider, { value, children });
1823
1850
  }
1824
1851
  function useStats() {
1825
- const ctx = (0, import_react19.useContext)(Context);
1852
+ const ctx = (0, import_react20.useContext)(Context);
1826
1853
  if (!ctx) throw new Error(`The ${key} stats are read within their game's Provider`);
1827
1854
  return ctx;
1828
1855
  }
@@ -1830,7 +1857,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1830
1857
  }
1831
1858
 
1832
1859
  // src/playerSettings.ts
1833
- var import_react20 = require("react");
1860
+ var import_react21 = require("react");
1834
1861
  var import_react_redux12 = require("react-redux");
1835
1862
  var SEATS2 = [1, 2];
1836
1863
  function seatPlayerKey(selection, seat) {
@@ -1874,8 +1901,8 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
1874
1901
  const saved = (0, import_react_redux12.useSelector)((state) => state[settingsKey]);
1875
1902
  const controls = (0, import_react_redux12.useSelector)((state) => state[controlsKey]);
1876
1903
  const dispatch = (0, import_react_redux12.useDispatch)();
1877
- const settings = (0, import_react20.useMemo)(() => compose(saved, controls, selection, seatTwoIsPerson), [saved, controls, selection, seatTwoIsPerson]);
1878
- const setSettings = (0, import_react20.useCallback)(
1904
+ const settings = (0, import_react21.useMemo)(() => compose(saved, controls, selection, seatTwoIsPerson), [saved, controls, selection, seatTwoIsPerson]);
1905
+ const setSettings = (0, import_react21.useCallback)(
1879
1906
  (next) => {
1880
1907
  const { controlScheme, ...changes } = next;
1881
1908
  if (Object.keys(changes).length > 0) dispatch(patch(seatPlayerKey(selection, 1), changes));
@@ -1936,6 +1963,7 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
1936
1963
  useActiveRound,
1937
1964
  useAppSettings,
1938
1965
  useAtComputer,
1966
+ useBackBlock,
1939
1967
  useGameGuide,
1940
1968
  useOpponent,
1941
1969
  usePack,
package/dist/index.mjs CHANGED
@@ -26,11 +26,12 @@ import { useAutoPaperTheme } from "@rific/auto-paper";
26
26
  import { useHapticSettings } from "@rific/feedback-press";
27
27
  import { Toaster, ToastProvider } from "@rific/toaster";
28
28
  import { useThemedRootBackground } from "@tastic/core";
29
+ import { edgeGuardScreenOptions } from "@tastic/edge-guard";
29
30
  import { RotatedFrame } from "@tastic/hud/chrome";
30
31
  import { ProfileColorProvider } from "@tastic/profile";
31
32
  import * as Haptics from "expo-haptics";
32
33
  import { DarkTheme, DefaultTheme, Stack, ThemeProvider as NavigationThemeProvider } from "expo-router";
33
- import { useCallback as useCallback5, useMemo as useMemo3 } from "react";
34
+ import { useCallback as useCallback6, useMemo as useMemo3 } from "react";
34
35
  import { Platform as Platform3, StyleSheet, View } from "react-native";
35
36
  import { GestureHandlerRootView } from "react-native-gesture-handler";
36
37
  import * as RNPaper2 from "react-native-paper";
@@ -69,8 +70,9 @@ function roundModeFor(seatTwo) {
69
70
  return seatTwo === "person" ? "twoPlayer" : seatTwo === "nobody" ? "solo" : "vsCpu";
70
71
  }
71
72
  function seatTwoFor(saved, choices) {
72
- if (!choices) return "nobody";
73
- return choices.includes(saved) ? saved : "cpu";
73
+ if (!choices?.length) return "nobody";
74
+ if (choices.includes(saved)) return saved;
75
+ return choices.includes("cpu") ? "cpu" : choices[0];
74
76
  }
75
77
  function humanSeatsFor(mode) {
76
78
  return mode === "twoPlayer" ? [1, 2] : [1];
@@ -242,22 +244,52 @@ function WindowControlsInsets({ children }) {
242
244
  return /* @__PURE__ */ jsx7(SafeAreaInsetsContext.Provider, { value: vertical, children });
243
245
  }
244
246
 
247
+ // src/hooks/useAppSettings.ts
248
+ import { useCallback as useCallback4 } from "react";
249
+ import { useDispatch as useDispatch4, useSelector as useSelector4 } from "react-redux";
250
+
251
+ // src/redux/appSettingsSlice.ts
252
+ import { createSettingsSlice } from "@rific/core";
253
+ var DEFAULT_APP_SETTINGS = {
254
+ deferBottomEdgeGestures: false
255
+ };
256
+ var { actions, reducer } = createSettingsSlice("appSettings", {
257
+ initialState: DEFAULT_APP_SETTINGS,
258
+ initializeMode: "merge",
259
+ fieldSetters: []
260
+ });
261
+ var appSettingsActions = actions;
262
+ var appSettingsSlice_default = reducer;
263
+
264
+ // src/hooks/useAppSettings.ts
265
+ function useAppSettings() {
266
+ const settings = useSelector4((state) => state.appSettings);
267
+ const dispatch = useDispatch4();
268
+ const setSettings = useCallback4(
269
+ (patch) => {
270
+ dispatch(appSettingsActions.initialize(patch));
271
+ },
272
+ [dispatch]
273
+ );
274
+ return { settings, setSettings };
275
+ }
276
+
245
277
  // src/hooks/useLastActiveGame.tsx
246
278
  import { createContext as createContext3, useContext as useContext3, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
247
- import { useDispatch as useDispatch4, useStore as useStore2 } from "react-redux";
279
+ import { useDispatch as useDispatch5, useStore as useStore2 } from "react-redux";
248
280
 
249
281
  // src/redux/lastActiveGameSlice.ts
250
- import { createSettingsSlice } from "@rific/core";
251
- var { actions, reducer } = createSettingsSlice("lastActiveGame", { initialState: { gameId: null } });
252
- var lastActiveGameActions = actions;
253
- var lastActiveGameSlice_default = reducer;
282
+ import { createSettingsSlice as createSettingsSlice2 } from "@rific/core";
283
+ var { actions: actions2, reducer: reducer2 } = createSettingsSlice2("lastActiveGame", { initialState: { gameId: null } });
284
+ var lastActiveGameActions = actions2;
285
+ var lastActiveGameSlice_default = reducer2;
254
286
 
255
287
  // src/hooks/useLastActiveGame.tsx
256
288
  import { jsx as jsx8 } from "react/jsx-runtime";
257
289
  var LastActiveGameContext = createContext3(null);
258
290
  function LastActiveGameProvider({ children }) {
259
291
  const store = useStore2();
260
- const dispatch = useDispatch4();
292
+ const dispatch = useDispatch5();
261
293
  const [initial] = useState2(() => store.getState().lastActiveGame?.gameId ?? null);
262
294
  const pendingResume = useRef2(initial);
263
295
  const persisted = useRef2(initial);
@@ -296,24 +328,24 @@ function useLastActiveGame() {
296
328
 
297
329
  // src/hooks/useProfiles.tsx
298
330
  import { createProfileRecord, profilesActions, resolveInitialProfiles, useSharedProfilesSync } from "@tastic/profile";
299
- import { createContext as createContext4, useCallback as useCallback4, useContext as useContext4, useEffect as useEffect2, useState as useState3 } from "react";
300
- import { useDispatch as useDispatch5, useSelector as useSelector4 } from "react-redux";
331
+ import { createContext as createContext4, useCallback as useCallback5, useContext as useContext4, useEffect as useEffect2, useState as useState3 } from "react";
332
+ import { useDispatch as useDispatch6, useSelector as useSelector5 } from "react-redux";
301
333
 
302
334
  // src/redux/profileSelectionSlice.ts
303
335
  import { createProfileSelectionSlice } from "@tastic/profile";
304
336
  var defaultProfileSelectionState = { 1: null, 2: null };
305
- var { actions: actions2, reducer: reducer2 } = createProfileSelectionSlice("pack", defaultProfileSelectionState);
306
- var profileSelectionActions = actions2;
307
- var profileSelectionSlice_default = reducer2;
337
+ var { actions: actions3, reducer: reducer3 } = createProfileSelectionSlice("pack", defaultProfileSelectionState);
338
+ var profileSelectionActions = actions3;
339
+ var profileSelectionSlice_default = reducer3;
308
340
 
309
341
  // src/hooks/useProfiles.tsx
310
342
  import { jsx as jsx9 } from "react/jsx-runtime";
311
343
  var SHARED_GROUP_ID = "group.com.infinitetoken.tastic";
312
344
  var ProfilesContext = createContext4(null);
313
345
  function ProfilesProvider({ children }) {
314
- const profiles = useSelector4((state) => state.profiles);
315
- const lastSelected = useSelector4((state) => state.profileSelection);
316
- const dispatch = useDispatch5();
346
+ const profiles = useSelector5((state) => state.profiles);
347
+ const lastSelected = useSelector5((state) => state.profileSelection);
348
+ const dispatch = useDispatch6();
317
349
  const [loaded, setLoaded] = useState3(false);
318
350
  useEffect2(() => {
319
351
  let cancelled = false;
@@ -329,7 +361,7 @@ function ProfilesProvider({ children }) {
329
361
  }, []);
330
362
  const { syncToShared } = useSharedProfilesSync({
331
363
  groupId: SHARED_GROUP_ID,
332
- onRemoteChange: useCallback4(
364
+ onRemoteChange: useCallback5(
333
365
  (remote) => {
334
366
  dispatch(profilesActions.setAll(remote));
335
367
  dispatch(profileSelectionActions.pruneToRoster(remote.map((p) => p.id)));
@@ -337,7 +369,7 @@ function ProfilesProvider({ children }) {
337
369
  [dispatch]
338
370
  )
339
371
  });
340
- const createProfile = useCallback4(
372
+ const createProfile = useCallback5(
341
373
  (input) => {
342
374
  const record = createProfileRecord(input);
343
375
  dispatch(profilesActions.add(record));
@@ -346,14 +378,14 @@ function ProfilesProvider({ children }) {
346
378
  },
347
379
  [profiles, dispatch, syncToShared]
348
380
  );
349
- const updateProfile = useCallback4(
381
+ const updateProfile = useCallback5(
350
382
  (id, patch) => {
351
383
  dispatch(profilesActions.update({ id, patch }));
352
384
  syncToShared(profiles.map((p) => p.id === id ? { ...p, ...patch, updatedAt: Date.now() } : p));
353
385
  },
354
386
  [profiles, dispatch, syncToShared]
355
387
  );
356
- const deleteProfile = useCallback4(
388
+ const deleteProfile = useCallback5(
357
389
  (id) => {
358
390
  dispatch(profilesActions.remove(id));
359
391
  syncToShared(profiles.filter((p) => p.id !== id));
@@ -361,7 +393,7 @@ function ProfilesProvider({ children }) {
361
393
  },
362
394
  [profiles, dispatch, syncToShared]
363
395
  );
364
- const selectProfile = useCallback4(
396
+ const selectProfile = useCallback5(
365
397
  (seat, profileId) => {
366
398
  dispatch(profileSelectionActions.select({ profileId, seat }));
367
399
  },
@@ -390,12 +422,16 @@ function AppStack() {
390
422
  const statusBarStyle = darkRoot ? "light" : "dark";
391
423
  const packOptions = (pack.useScreenOptions ?? noScreenOptions)();
392
424
  const backdropOptions = Backdrop ? { contentStyle: TRANSPARENT_CONTENT, animation: Platform3.select({ android: "fade" }) } : void 0;
393
- const playOptions = useCallback5(
425
+ const { edgeGuard = true } = pack;
426
+ const { deferBottomEdgeGestures } = useAppSettings().settings;
427
+ const edgeGuardOptions = useMemo3(() => edgeGuardScreenOptions(edgeGuard && deferBottomEdgeGestures), [edgeGuard, deferBottomEdgeGestures]);
428
+ const playOptions = useCallback6(
394
429
  ({ route }) => {
395
430
  const id = route.params?.game;
396
- return pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
431
+ const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
432
+ return { ...statusBarOptions, ...edgeGuardOptions };
397
433
  },
398
- [pack.games]
434
+ [pack.games, edgeGuardOptions]
399
435
  );
400
436
  const navigationBackground = Backdrop ? TRANSPARENT_CONTENT.backgroundColor : rootBackground.contentStyle.backgroundColor;
401
437
  const navigationTheme = useMemo3(() => {
@@ -422,7 +458,7 @@ function HapticGatedToastProvider({ children }) {
422
458
  return /* @__PURE__ */ jsx10(ToastProvider, { haptics: settings.vibrate ? Haptics : void 0, paper: PackToasterComponent ? void 0 : RNPaper2, children });
423
459
  }
424
460
  function RotatingToaster() {
425
- const renderFrame = useCallback5(
461
+ const renderFrame = useCallback6(
426
462
  (toasts) => /* @__PURE__ */ jsx10(RotatedFrame, { rotatedSafeArea: true, passThrough: true, children: toasts }),
427
463
  []
428
464
  );
@@ -436,7 +472,7 @@ function GameProviders({ games, children }) {
436
472
  }
437
473
  function PreviewColors({ previewColor, children }) {
438
474
  const { dark } = useAutoPaperTheme();
439
- const preview = useCallback5((hex) => previewColor(hex, dark), [previewColor, dark]);
475
+ const preview = useCallback6((hex) => previewColor(hex, dark), [previewColor, dark]);
440
476
  return /* @__PURE__ */ jsx10(ProfileColorProvider, { preview, children });
441
477
  }
442
478
  function PackRoot({ pack, children }) {
@@ -535,38 +571,6 @@ var styles2 = StyleSheet2.create({
535
571
  // src/components/SettingsDialog.tsx
536
572
  import { useUpdateErrorToast as useUpdateErrorToast2 } from "@rific/toaster";
537
573
  import { BaseSettingsDialog } from "@tastic/hud/chrome";
538
-
539
- // src/hooks/useAppSettings.ts
540
- import { useCallback as useCallback6 } from "react";
541
- import { useDispatch as useDispatch6, useSelector as useSelector5 } from "react-redux";
542
-
543
- // src/redux/appSettingsSlice.ts
544
- import { createSettingsSlice as createSettingsSlice2 } from "@rific/core";
545
- var DEFAULT_APP_SETTINGS = {
546
- deferBottomEdgeGestures: false
547
- };
548
- var { actions: actions3, reducer: reducer3 } = createSettingsSlice2("appSettings", {
549
- initialState: DEFAULT_APP_SETTINGS,
550
- initializeMode: "merge",
551
- fieldSetters: []
552
- });
553
- var appSettingsActions = actions3;
554
- var appSettingsSlice_default = reducer3;
555
-
556
- // src/hooks/useAppSettings.ts
557
- function useAppSettings() {
558
- const settings = useSelector5((state) => state.appSettings);
559
- const dispatch = useDispatch6();
560
- const setSettings = useCallback6(
561
- (patch) => {
562
- dispatch(appSettingsActions.initialize(patch));
563
- },
564
- [dispatch]
565
- );
566
- return { settings, setSettings };
567
- }
568
-
569
- // src/components/SettingsDialog.tsx
570
574
  import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
571
575
  var noSettingsRules = () => null;
572
576
  function SettingsDialog({ visible, onDismiss, onShowHowToPlay, children }) {
@@ -1569,11 +1573,33 @@ var styles6 = StyleSheet6.create({
1569
1573
  import { useSelector as useSelector8 } from "react-redux";
1570
1574
  function useActiveRound(game, defaults) {
1571
1575
  const round = useSelector8((state) => state.liveplay.activeRound);
1572
- const seated = !!usePackGame(game)?.seatTwo;
1573
- if (!round || round.game !== game) return { mode: seated ? "vsCpu" : "solo", settings: defaults };
1576
+ const choices = usePackGame(game)?.seatTwo;
1577
+ if (!round || round.game !== game) return { mode: roundModeFor(seatTwoFor(DEFAULT_OPPONENT.seatTwo, choices)), settings: defaults };
1574
1578
  return { mode: round.mode, settings: { ...defaults, ...round.settings } };
1575
1579
  }
1576
1580
 
1581
+ // src/hooks/useBackBlock.ts
1582
+ import { usePreventRemove } from "expo-router";
1583
+ import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef6, useState as useState8 } from "react";
1584
+ function useBackBlock(held, onHeld, leave = safeBack) {
1585
+ const leavingRef = useRef6(false);
1586
+ const [leaving, setLeaving] = useState8(false);
1587
+ const leaveRef = useRef6(leave);
1588
+ useEffect8(() => {
1589
+ leaveRef.current = leave;
1590
+ });
1591
+ usePreventRemove(held && !leaving, ({ repeat }) => {
1592
+ if (leavingRef.current) {
1593
+ setLeaving(true);
1594
+ repeat();
1595
+ } else onHeld();
1596
+ });
1597
+ return useCallback11(() => {
1598
+ leavingRef.current = true;
1599
+ leaveRef.current();
1600
+ }, []);
1601
+ }
1602
+
1577
1603
  // src/redux/createPackStore.ts
1578
1604
  import AsyncStorage from "@react-native-async-storage/async-storage";
1579
1605
  import { combineReducers, configureStore } from "@reduxjs/toolkit";
@@ -1708,7 +1734,7 @@ function forgetProfileAchievements(dropStats) {
1708
1734
 
1709
1735
  // src/gameStats.tsx
1710
1736
  import { createAchievementsSlice, mapUnlocksBySeat, useAchievements } from "@tastic/achievements";
1711
- import { createContext as createContext5, useCallback as useCallback11, useContext as useContext5, useMemo as useMemo8 } from "react";
1737
+ import { createContext as createContext5, useCallback as useCallback12, useContext as useContext5, useMemo as useMemo8 } from "react";
1712
1738
  import { jsx as jsx20 } from "react/jsx-runtime";
1713
1739
  var SEATS = [1, 2];
1714
1740
  function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
@@ -1734,7 +1760,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1734
1760
  actions: actions6,
1735
1761
  profileViews
1736
1762
  });
1737
- const record = useCallback11(
1763
+ const record = useCallback12(
1738
1764
  (update, profileIds) => {
1739
1765
  const result = recordOutcome(update);
1740
1766
  return { device: result.device, profiles: mapUnlocksBySeat(SEATS, profileIds, result.profiles) };
@@ -1753,7 +1779,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1753
1779
  }
1754
1780
 
1755
1781
  // src/playerSettings.ts
1756
- import { useCallback as useCallback12, useMemo as useMemo9 } from "react";
1782
+ import { useCallback as useCallback13, useMemo as useMemo9 } from "react";
1757
1783
  import { useDispatch as useDispatch11, useSelector as useSelector9 } from "react-redux";
1758
1784
  var SEATS2 = [1, 2];
1759
1785
  function seatPlayerKey(selection, seat) {
@@ -1798,7 +1824,7 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
1798
1824
  const controls = useSelector9((state) => state[controlsKey]);
1799
1825
  const dispatch = useDispatch11();
1800
1826
  const settings = useMemo9(() => compose(saved, controls, selection, seatTwoIsPerson), [saved, controls, selection, seatTwoIsPerson]);
1801
- const setSettings = useCallback12(
1827
+ const setSettings = useCallback13(
1802
1828
  (next) => {
1803
1829
  const { controlScheme, ...changes } = next;
1804
1830
  if (Object.keys(changes).length > 0) dispatch(patch(seatPlayerKey(selection, 1), changes));
@@ -1858,6 +1884,7 @@ export {
1858
1884
  useActiveRound,
1859
1885
  useAppSettings,
1860
1886
  useAtComputer,
1887
+ useBackBlock,
1861
1888
  useGameGuide,
1862
1889
  useOpponent,
1863
1890
  usePack,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tastic/shell",
3
- "version": "0.8.3",
3
+ "version": "0.10.0",
4
4
  "description": "The app around a pack of React Native games, two-seat or for one player: Home, the loadout, the stats screen, Profiles and Settings, the pack's Redux store and its root providers, driven by one PackDefinition",
5
5
  "keywords": [
6
6
  "react-native",
@@ -85,7 +85,7 @@
85
85
  "@rific/updater": "^0.8.0",
86
86
  "@tastic/achievements": "^0.6.0",
87
87
  "@tastic/core": "^0.16.0",
88
- "@tastic/edge-guard": "^0.1.5",
88
+ "@tastic/edge-guard": "^0.2.0",
89
89
  "@tastic/hud": "^0.29.0",
90
90
  "@tastic/profile": "^0.18.0",
91
91
  "@tastic/split-screen": "^0.5.5",
@@ -102,6 +102,7 @@
102
102
  "expo-font": "~58.0.10",
103
103
  "expo-haptics": "~58.0.7",
104
104
  "expo-keep-awake": "~58.0.3",
105
+ "expo-linking": "~58.0.17",
105
106
  "expo-router": "~58.0.30",
106
107
  "expo-splash-screen": "~58.0.13",
107
108
  "expo-system-ui": "~58.0.6",
@@ -136,7 +137,7 @@
136
137
  "@rific/toaster": ">=0.10.1",
137
138
  "@tastic/achievements": ">=0.6.0",
138
139
  "@tastic/core": ">=0.16.0",
139
- "@tastic/edge-guard": ">=0.1.5",
140
+ "@tastic/edge-guard": ">=0.2.0",
140
141
  "@tastic/hud": ">=0.29.0",
141
142
  "@tastic/profile": ">=0.18.0",
142
143
  "@tastic/split-screen": ">=0.5.5",
@@ -2,6 +2,7 @@ import { useAutoPaperTheme } from '@rific/auto-paper'
2
2
  import { useHapticSettings } from '@rific/feedback-press'
3
3
  import { Toaster, ToastProvider } from '@rific/toaster'
4
4
  import { useThemedRootBackground } from '@tastic/core'
5
+ import { edgeGuardScreenOptions } from '@tastic/edge-guard'
5
6
  import { RotatedFrame } from '@tastic/hud/chrome'
6
7
  import { ProfileColorProvider } from '@tastic/profile'
7
8
  import * as Haptics from 'expo-haptics'
@@ -19,6 +20,7 @@ import { Providers } from './components/Providers'
19
20
  import { Theme } from './components/Theme'
20
21
  import { UpdateDialog } from './components/UpdateDialog'
21
22
  import { WindowControlsInsets } from './components/WindowControlsInsets'
23
+ import { useAppSettings } from './hooks/useAppSettings'
22
24
  import { LastActiveGameProvider } from './hooks/useLastActiveGame'
23
25
  import { ProfilesProvider, useProfiles } from './hooks/useProfiles'
24
26
  import { PackProvider, usePack } from './PackContext'
@@ -44,6 +46,13 @@ import type { PackDefinition, PackGameDefinition } from './types'
44
46
  // auto-paper's Provider statusBar={false}). A play screen hides the bar for the whole round (a screen's
45
47
  // own options win over screenOptions); index is listed first so it stays the stack's first route. A
46
48
  // game with keepStatusBar (Solitaire's) keeps the stack's bar instead.
49
+ //
50
+ // Edge Guard's Android half rides on the same options: with it on, @tastic/edge-guard's
51
+ // edgeGuardScreenOptions hides both bars on a play screen in sticky immersive mode, so a swipe from
52
+ // any edge only brings them back for a moment (iOS's half is Providers' EdgeGuardBridge). For the whole
53
+ // play screen, not just a live round: hiding a bar changes the safe area, so flipping it as a round
54
+ // starts or pauses would resize anything a game lays out from the insets mid-match. On Android it
55
+ // hides the status bar of a keepStatusBar game too, since a visible one pulls the shade in one swipe.
47
56
  const PLAY_OPTIONS = { statusBarHidden: true }
48
57
  const KEEP_STATUS_BAR_OPTIONS = {}
49
58
 
@@ -79,12 +88,16 @@ function AppStack() {
79
88
  // the outgoing screen opaque for ~450ms while the new one slides over it, which would show Home
80
89
  // straight through a transparent play screen. iOS keeps its own push.
81
90
  const backdropOptions = Backdrop ? { contentStyle: TRANSPARENT_CONTENT, animation: Platform.select({ android: 'fade' as const }) } : undefined
91
+ const { edgeGuard = true } = pack
92
+ const { deferBottomEdgeGestures } = useAppSettings().settings
93
+ const edgeGuardOptions = useMemo(() => edgeGuardScreenOptions(edgeGuard && deferBottomEdgeGestures), [edgeGuard, deferBottomEdgeGestures])
82
94
  const playOptions = useCallback(
83
95
  ({ route }: { route: { params?: object } }) => {
84
96
  const id = (route.params as { game?: string } | undefined)?.game
85
- return pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS
97
+ const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS
98
+ return { ...statusBarOptions, ...edgeGuardOptions }
86
99
  },
87
- [pack.games]
100
+ [pack.games, edgeGuardOptions]
88
101
  )
89
102
  const navigationBackground = Backdrop ? TRANSPARENT_CONTENT.backgroundColor : rootBackground.contentStyle.backgroundColor
90
103
  const navigationTheme = useMemo(() => {
@@ -53,8 +53,9 @@ export function GuideHost({ children }: Props) {
53
53
  const seenVersion = useSelector((state: ShellState) => (packGuide ?? gameGuide)?.selectVersionSeen(state) ?? 0)
54
54
  const dispatch = useDispatch()
55
55
 
56
- // The seat-2 choice the cards describe: the one the player last picked, the CPU in a game that has
57
- // no room for it (a saved 'nobody' in a game without a solo mode), or nobody in a game for one.
56
+ // The seat-2 choice the cards describe: the one the player last picked, or where the game doesn't
57
+ // offer it the CPU (a saved 'nobody' in a game without a solo mode) or, in a game with no CPU, its
58
+ // first choice; nobody in a game for one.
58
59
  const mode = roundModeFor(seatTwoFor(seatTwo, game?.seatTwo))
59
60
  const steps = useMemo(() => (packGuide ? packGuide.getSteps({ touch }) : gameGuide ? gameGuide.getSteps(input, { touch, mode }) : []), [packGuide, gameGuide, input, touch, mode])
60
61
  const onSeen = useCallback(
@@ -1,16 +1,18 @@
1
1
  import { useSelector } from 'react-redux'
2
2
 
3
3
  import { usePackGame } from '../PackContext'
4
+ import { DEFAULT_OPPONENT } from '../redux/opponentSlice'
4
5
  import type { ShellState } from '../redux/shellState'
5
- import type { RoundMode } from '../types'
6
+ import { type RoundMode, roundModeFor, seatTwoFor } from '../types'
6
7
 
7
8
  // The round a play screen is playing: committed by the loadout when every human player readied up
8
9
  // (see liveplaySlice.ts). A play screen reached without one (a direct link, a web reload, or a game
9
- // with no loadout, which Home opens straight away) plays its game's defaults: against the CPU, or
10
- // solo in a game with no seat 2 (GameDefinition.seatTwo).
10
+ // with no loadout, which Home opens straight away) plays its game's defaults: a fresh install's seat
11
+ // 2 as that game reads it (seatTwoFor), so against the CPU, solo in a game with no seat 2
12
+ // (GameDefinition.seatTwo), and the game's first choice in one without a CPU.
11
13
  export function useActiveRound<S extends object>(game: string, defaults: S): { mode: RoundMode; settings: S } {
12
14
  const round = useSelector((state: ShellState) => state.liveplay.activeRound)
13
- const seated = !!usePackGame(game)?.seatTwo
14
- if (!round || round.game !== game) return { mode: seated ? 'vsCpu' : 'solo', settings: defaults }
15
+ const choices = usePackGame(game)?.seatTwo
16
+ if (!round || round.game !== game) return { mode: roundModeFor(seatTwoFor(DEFAULT_OPPONENT.seatTwo, choices)), settings: defaults }
15
17
  return { mode: round.mode, settings: { ...defaults, ...(round.settings as Partial<S>) } }
16
18
  }
@@ -0,0 +1,47 @@
1
+ import { usePreventRemove } from 'expo-router'
2
+ import { useCallback, useEffect, useRef, useState } from 'react'
3
+
4
+ import { safeBack } from '../navigation'
5
+
6
+ // Holds a play screen while `held`: every way off it but the returned `quit` (Android's hardware or
7
+ // gesture back, the browser's back, a link) runs `onHeld` instead, which in a game is the
8
+ // `requestBack` from @tastic/hud's useQuitConfirmation, so it opens the same Quit Match? the back chip
9
+ // does (audit F093: Android's back and the browser's back left a match at once). iOS's swipe back is
10
+ // already off on every screen (RootLayout's useThemedRootBackground). `held` is a plain boolean read
11
+ // as the screen renders, not useQuitConfirmation's lazy getter, since expo-router needs to know before
12
+ // a back comes in; a game whose progress comes from a state hook that needs Quit Match?'s `paused`
13
+ // calls this after that hook, with the same test it hands useQuitConfirmation. Off at Game Over, so
14
+ // a back there leaves at once, as the chip does.
15
+ //
16
+ // `leave` is where `quit` goes: safeBack unless the game says otherwise. A game whose Quit Match? can
17
+ // be opened from more than one place (CardTastic's tables: a back, or their Home button, which goes
18
+ // to Home past the setup screen) passes a function that reads which one opened it. It's read when
19
+ // `quit` runs, so it can change from render to render.
20
+ //
21
+ // The block stops every navigation off the screen while it's on, Quit's own included, so `quit` marks
22
+ // the way out first and the block lets that one through with `repeat` (expo-router's way to carry on
23
+ // with a navigation it stopped). The block goes off in the same handler as `repeat`, the order
24
+ // expo-router documents (it warns otherwise): turned off any sooner, it can stand aside after it has
25
+ // stopped the navigation and no longer hand it to this callback, so Quit would do nothing. That was a
26
+ // real bug in DuelTastic (2026-11-06), whose copy this is.
27
+ //
28
+ // While it's on, the web also asks before the page unloads (expo-router's usePreventRemove adds a
29
+ // beforeunload handler with it).
30
+ export function useBackBlock(held: boolean, onHeld: () => void, leave: () => void = safeBack): () => void {
31
+ const leavingRef = useRef(false)
32
+ const [leaving, setLeaving] = useState(false)
33
+ const leaveRef = useRef(leave)
34
+ useEffect(() => {
35
+ leaveRef.current = leave
36
+ })
37
+ usePreventRemove(held && !leaving, ({ repeat }) => {
38
+ if (leavingRef.current) {
39
+ setLeaving(true)
40
+ repeat()
41
+ } else onHeld()
42
+ })
43
+ return useCallback(() => {
44
+ leavingRef.current = true
45
+ leaveRef.current()
46
+ }, [])
47
+ }
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export { SettingsDialog, type SettingsDialogProps } from './components/SettingsD
20
20
  export { useActiveRound } from './hooks/useActiveRound'
21
21
  export { useAppSettings } from './hooks/useAppSettings'
22
22
  export { useAtComputer } from './hooks/useAtComputer'
23
+ export { useBackBlock } from './hooks/useBackBlock'
23
24
  export { useOpponent } from './hooks/useOpponent'
24
25
  export { ProfilesProvider, useProfiles } from './hooks/useProfiles'
25
26
  export { useSeatColors } from './hooks/useSeatColors'
@@ -5,8 +5,8 @@ import type { SeatTwo } from '../types'
5
5
  // Who sits in seat 2, for the whole pack: picked from player 1's opponent button in any game's loadout and
6
6
  // kept from one game to the next and across relaunches, since it's usually the same two people.
7
7
  // A fresh install starts on the CPU, so one person (App Review included) can tap a game and play.
8
- // A game without 'nobody' among its seat-2 choices treats a saved 'nobody' as the CPU (see
9
- // types.ts' seatTwoFor).
8
+ // A game that doesn't offer the saved choice reads it as the CPU, or as its first choice in a game
9
+ // with no CPU, so a fresh install opens a CPU-less game on that (see types.ts' seatTwoFor).
10
10
  export interface OpponentState {
11
11
  seatTwo: SeatTwo
12
12
  }
package/src/types.ts CHANGED
@@ -24,12 +24,15 @@ export function roundModeFor(seatTwo: SeatTwo): RoundMode {
24
24
  return seatTwo === 'person' ? 'twoPlayer' : seatTwo === 'nobody' ? 'solo' : 'vsCpu'
25
25
  }
26
26
 
27
- // Seat 2's saved choice in one game (GameDefinition.seatTwo): a saved 'nobody' reads as the CPU in a
28
- // game without a solo mode, and so does anything else the game doesn't offer. A game with no seat 2
29
- // at all (no seatTwo) is always nobody, so it plays solo.
27
+ // Seat 2's saved choice in one game (GameDefinition.seatTwo). The saved choice is the whole pack's, so
28
+ // a game can be handed one it doesn't offer: that reads as the CPU where the game has one (a saved
29
+ // 'nobody' in a game without a solo mode), and as the game's first choice where it has none (a fresh
30
+ // install's saved CPU, in a game offering ['nobody', 'person'], is Solo). A game with no seat 2 at all
31
+ // (no seatTwo) is always nobody, so it plays solo.
30
32
  export function seatTwoFor(saved: SeatTwo, choices: readonly SeatTwo[] | undefined): SeatTwo {
31
- if (!choices) return 'nobody'
32
- return choices.includes(saved) ? saved : 'cpu'
33
+ if (!choices?.length) return 'nobody'
34
+ if (choices.includes(saved)) return saved
35
+ return choices.includes('cpu') ? 'cpu' : choices[0]
33
36
  }
34
37
 
35
38
  // The players who take part in a round and have to press Ready: a CPU and nobody don't.