@tastic/shell 0.9.0 → 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
@@ -119,7 +119,7 @@ PuckTastic and DuelTastic draw what they always did:
119
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`. |
120
120
  | `useFeedbackSounds?` | A hook returning the two sounds every button plays (`FeedbackSounds`: `selection`, `notification`), in place of the shell's two wavs. |
121
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. |
122
- | `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. |
123
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. |
124
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. |
125
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. |
@@ -239,6 +239,11 @@ const quit = useBackBlock(hasProgress, requestBack)
239
239
  in), so a game whose progress comes from a state hook that itself needs Quit Match?'s `paused` calls
240
240
  this after that hook, and mirrors the value into the getter it gives `useQuitConfirmation`.
241
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.
242
247
  - While it's on, the web also asks before the page unloads (expo-router's `usePreventRemove` adds a
243
248
  `beforeunload` handler with it). iOS's swipe back is off on every screen anyway.
244
249
 
@@ -268,7 +273,7 @@ became a package (the lower of the two where they differ).
268
273
  | `@tastic/profile` | >=0.16.2 | profiles, the seat buttons, seat colors |
269
274
  | `@tastic/achievements` | >=0.6.0 | `createGameStats`, `forgetProfileAchievements` |
270
275
  | `@tastic/split-screen` | >=0.5.5 | the 2 Player loadout's two halves |
271
- | `@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) |
272
277
 
273
278
  The two UI sounds every button plays (`assets/sounds/select.wav` and `notification.wav`) ship with the
274
279
  package.
package/dist/index.d.mts CHANGED
@@ -445,7 +445,7 @@ declare function useAppSettings(): {
445
445
 
446
446
  declare function useAtComputer(): boolean;
447
447
 
448
- declare function useBackBlock(held: boolean, onHeld: () => void): () => void;
448
+ declare function useBackBlock(held: boolean, onHeld: () => void, leave?: () => void): () => void;
449
449
 
450
450
  declare function useOpponent(): {
451
451
  seatTwo: SeatTwo;
package/dist/index.d.ts CHANGED
@@ -445,7 +445,7 @@ declare function useAppSettings(): {
445
445
 
446
446
  declare function useAtComputer(): boolean;
447
447
 
448
- declare function useBackBlock(held: boolean, onHeld: () => void): () => void;
448
+ declare function useBackBlock(held: boolean, onHeld: () => void, leave?: () => void): () => void;
449
449
 
450
450
  declare function useOpponent(): {
451
451
  seatTwo: SeatTwo;
package/dist/index.js CHANGED
@@ -103,12 +103,13 @@ function usePackGame(id) {
103
103
  var import_auto_paper2 = require("@rific/auto-paper");
104
104
  var import_feedback_press2 = require("@rific/feedback-press");
105
105
  var import_toaster2 = require("@rific/toaster");
106
- var import_core4 = require("@tastic/core");
106
+ var import_core5 = require("@tastic/core");
107
+ var import_edge_guard2 = require("@tastic/edge-guard");
107
108
  var import_chrome2 = require("@tastic/hud/chrome");
108
109
  var import_profile3 = require("@tastic/profile");
109
110
  var Haptics = __toESM(require("expo-haptics"));
110
111
  var import_expo_router = require("expo-router");
111
- var import_react8 = require("react");
112
+ var import_react9 = require("react");
112
113
  var import_react_native3 = require("react-native");
113
114
  var import_react_native_gesture_handler = require("react-native-gesture-handler");
114
115
  var RNPaper2 = __toESM(require("react-native-paper"));
@@ -321,26 +322,56 @@ function WindowControlsInsets({ children }) {
321
322
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_safe_area_context.SafeAreaInsetsContext.Provider, { value: vertical, children });
322
323
  }
323
324
 
324
- // src/hooks/useLastActiveGame.tsx
325
+ // src/hooks/useAppSettings.ts
325
326
  var import_react6 = require("react");
326
327
  var import_react_redux4 = require("react-redux");
327
328
 
328
- // src/redux/lastActiveGameSlice.ts
329
+ // src/redux/appSettingsSlice.ts
329
330
  var import_core3 = require("@rific/core");
330
- var { actions, reducer } = (0, import_core3.createSettingsSlice)("lastActiveGame", { initialState: { gameId: null } });
331
- var lastActiveGameActions = actions;
332
- 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;
333
364
 
334
365
  // src/hooks/useLastActiveGame.tsx
335
366
  var import_jsx_runtime8 = require("react/jsx-runtime");
336
- var LastActiveGameContext = (0, import_react6.createContext)(null);
367
+ var LastActiveGameContext = (0, import_react7.createContext)(null);
337
368
  function LastActiveGameProvider({ children }) {
338
- const store = (0, import_react_redux4.useStore)();
339
- const dispatch = (0, import_react_redux4.useDispatch)();
340
- const [initial] = (0, import_react6.useState)(() => store.getState().lastActiveGame?.gameId ?? null);
341
- const pendingResume = (0, import_react6.useRef)(initial);
342
- const persisted = (0, import_react6.useRef)(initial);
343
- 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)(
344
375
  () => ({
345
376
  consumeResumeGame: () => {
346
377
  const game = pendingResume.current;
@@ -368,33 +399,33 @@ function LastActiveGameProvider({ children }) {
368
399
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LastActiveGameContext.Provider, { value, children });
369
400
  }
370
401
  function useLastActiveGame() {
371
- const ctx = (0, import_react6.useContext)(LastActiveGameContext);
402
+ const ctx = (0, import_react7.useContext)(LastActiveGameContext);
372
403
  if (!ctx) throw new Error("useLastActiveGame must be used within a LastActiveGameProvider");
373
404
  return ctx;
374
405
  }
375
406
 
376
407
  // src/hooks/useProfiles.tsx
377
408
  var import_profile2 = require("@tastic/profile");
378
- var import_react7 = require("react");
379
- var import_react_redux5 = require("react-redux");
409
+ var import_react8 = require("react");
410
+ var import_react_redux6 = require("react-redux");
380
411
 
381
412
  // src/redux/profileSelectionSlice.ts
382
413
  var import_profile = require("@tastic/profile");
383
414
  var defaultProfileSelectionState = { 1: null, 2: null };
384
- var { actions: actions2, reducer: reducer2 } = (0, import_profile.createProfileSelectionSlice)("pack", defaultProfileSelectionState);
385
- var profileSelectionActions = actions2;
386
- 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;
387
418
 
388
419
  // src/hooks/useProfiles.tsx
389
420
  var import_jsx_runtime9 = require("react/jsx-runtime");
390
421
  var SHARED_GROUP_ID = "group.com.infinitetoken.tastic";
391
- var ProfilesContext = (0, import_react7.createContext)(null);
422
+ var ProfilesContext = (0, import_react8.createContext)(null);
392
423
  function ProfilesProvider({ children }) {
393
- const profiles = (0, import_react_redux5.useSelector)((state) => state.profiles);
394
- const lastSelected = (0, import_react_redux5.useSelector)((state) => state.profileSelection);
395
- const dispatch = (0, import_react_redux5.useDispatch)();
396
- const [loaded, setLoaded] = (0, import_react7.useState)(false);
397
- (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)(() => {
398
429
  let cancelled = false;
399
430
  (0, import_profile2.resolveInitialProfiles)(SHARED_GROUP_ID, profiles).then((resolved) => {
400
431
  if (cancelled) return;
@@ -408,7 +439,7 @@ function ProfilesProvider({ children }) {
408
439
  }, []);
409
440
  const { syncToShared } = (0, import_profile2.useSharedProfilesSync)({
410
441
  groupId: SHARED_GROUP_ID,
411
- onRemoteChange: (0, import_react7.useCallback)(
442
+ onRemoteChange: (0, import_react8.useCallback)(
412
443
  (remote) => {
413
444
  dispatch(import_profile2.profilesActions.setAll(remote));
414
445
  dispatch(profileSelectionActions.pruneToRoster(remote.map((p) => p.id)));
@@ -416,7 +447,7 @@ function ProfilesProvider({ children }) {
416
447
  [dispatch]
417
448
  )
418
449
  });
419
- const createProfile = (0, import_react7.useCallback)(
450
+ const createProfile = (0, import_react8.useCallback)(
420
451
  (input) => {
421
452
  const record = (0, import_profile2.createProfileRecord)(input);
422
453
  dispatch(import_profile2.profilesActions.add(record));
@@ -425,14 +456,14 @@ function ProfilesProvider({ children }) {
425
456
  },
426
457
  [profiles, dispatch, syncToShared]
427
458
  );
428
- const updateProfile = (0, import_react7.useCallback)(
459
+ const updateProfile = (0, import_react8.useCallback)(
429
460
  (id, patch) => {
430
461
  dispatch(import_profile2.profilesActions.update({ id, patch }));
431
462
  syncToShared(profiles.map((p) => p.id === id ? { ...p, ...patch, updatedAt: Date.now() } : p));
432
463
  },
433
464
  [profiles, dispatch, syncToShared]
434
465
  );
435
- const deleteProfile = (0, import_react7.useCallback)(
466
+ const deleteProfile = (0, import_react8.useCallback)(
436
467
  (id) => {
437
468
  dispatch(import_profile2.profilesActions.remove(id));
438
469
  syncToShared(profiles.filter((p) => p.id !== id));
@@ -440,7 +471,7 @@ function ProfilesProvider({ children }) {
440
471
  },
441
472
  [profiles, dispatch, syncToShared]
442
473
  );
443
- const selectProfile = (0, import_react7.useCallback)(
474
+ const selectProfile = (0, import_react8.useCallback)(
444
475
  (seat, profileId) => {
445
476
  dispatch(profileSelectionActions.select({ profileId, seat }));
446
477
  },
@@ -449,7 +480,7 @@ function ProfilesProvider({ children }) {
449
480
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProfilesContext.Provider, { value: { profiles, lastSelected, loaded, createProfile, updateProfile, deleteProfile, selectProfile }, children });
450
481
  }
451
482
  function useProfiles() {
452
- const ctx = (0, import_react7.useContext)(ProfilesContext);
483
+ const ctx = (0, import_react8.useContext)(ProfilesContext);
453
484
  if (!ctx) throw new Error("useProfiles must be used within a ProfilesProvider");
454
485
  return ctx;
455
486
  }
@@ -465,19 +496,23 @@ function AppStack() {
465
496
  const { Backdrop } = pack;
466
497
  const { dark } = (0, import_auto_paper2.useAutoPaperTheme)();
467
498
  const darkRoot = Backdrop ? true : dark;
468
- const rootBackground = (0, import_core4.useThemedRootBackground)(darkRoot, false);
499
+ const rootBackground = (0, import_core5.useThemedRootBackground)(darkRoot, false);
469
500
  const statusBarStyle = darkRoot ? "light" : "dark";
470
501
  const packOptions = (pack.useScreenOptions ?? noScreenOptions)();
471
502
  const backdropOptions = Backdrop ? { contentStyle: TRANSPARENT_CONTENT, animation: import_react_native3.Platform.select({ android: "fade" }) } : void 0;
472
- 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)(
473
507
  ({ route }) => {
474
508
  const id = route.params?.game;
475
- 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 };
476
511
  },
477
- [pack.games]
512
+ [pack.games, edgeGuardOptions]
478
513
  );
479
514
  const navigationBackground = Backdrop ? TRANSPARENT_CONTENT.backgroundColor : rootBackground.contentStyle.backgroundColor;
480
- const navigationTheme = (0, import_react8.useMemo)(() => {
515
+ const navigationTheme = (0, import_react9.useMemo)(() => {
481
516
  const base = darkRoot ? import_expo_router.DarkTheme : import_expo_router.DefaultTheme;
482
517
  return { ...base, colors: { ...base.colors, background: navigationBackground } };
483
518
  }, [darkRoot, navigationBackground]);
@@ -501,7 +536,7 @@ function HapticGatedToastProvider({ children }) {
501
536
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_toaster2.ToastProvider, { haptics: settings.vibrate ? Haptics : void 0, paper: PackToasterComponent ? void 0 : RNPaper2, children });
502
537
  }
503
538
  function RotatingToaster() {
504
- const renderFrame = (0, import_react8.useCallback)(
539
+ const renderFrame = (0, import_react9.useCallback)(
505
540
  (toasts) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_chrome2.RotatedFrame, { rotatedSafeArea: true, passThrough: true, children: toasts }),
506
541
  []
507
542
  );
@@ -515,7 +550,7 @@ function GameProviders({ games, children }) {
515
550
  }
516
551
  function PreviewColors({ previewColor, children }) {
517
552
  const { dark } = (0, import_auto_paper2.useAutoPaperTheme)();
518
- 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]);
519
554
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_profile3.ProfileColorProvider, { preview, children });
520
555
  }
521
556
  function PackRoot({ pack, children }) {
@@ -561,7 +596,7 @@ var import_react_redux9 = require("react-redux");
561
596
  // src/components/OpponentPicker.tsx
562
597
  var import_lobby = require("@tastic/hud/lobby");
563
598
  var import_profile4 = require("@tastic/profile");
564
- var import_react9 = require("react");
599
+ var import_react10 = require("react");
565
600
  var import_react_native4 = require("react-native");
566
601
  var import_jsx_runtime11 = require("react/jsx-runtime");
567
602
  var CPU_PREFIX = "cpu:";
@@ -576,7 +611,7 @@ function getOpponentPopoverId(idPrefix) {
576
611
  function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChange, cpuDifficulty, color, onColorChange, swatches, takenColor, allowSwapTaken, dark, previewValue, triggerStyle, usePickerAlign }) {
577
612
  const drawn = previewValue ? previewValue(color) : color;
578
613
  const cpuOptions = cpuDifficulty?.options;
579
- const options = (0, import_react9.useMemo)(() => {
614
+ const options = (0, import_react10.useMemo)(() => {
580
615
  const list = [];
581
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 }]);
582
617
  if (choices.includes("nobody")) list.push({ value: NOBODY, label: "Solo", icon: NOBODY_ICON, dividerBefore: true });
@@ -614,38 +649,6 @@ var styles2 = import_react_native4.StyleSheet.create({
614
649
  // src/components/SettingsDialog.tsx
615
650
  var import_toaster3 = require("@rific/toaster");
616
651
  var import_chrome3 = require("@tastic/hud/chrome");
617
-
618
- // src/hooks/useAppSettings.ts
619
- var import_react10 = require("react");
620
- var import_react_redux6 = require("react-redux");
621
-
622
- // src/redux/appSettingsSlice.ts
623
- var import_core5 = require("@rific/core");
624
- var DEFAULT_APP_SETTINGS = {
625
- deferBottomEdgeGestures: false
626
- };
627
- var { actions: actions3, reducer: reducer3 } = (0, import_core5.createSettingsSlice)("appSettings", {
628
- initialState: DEFAULT_APP_SETTINGS,
629
- initializeMode: "merge",
630
- fieldSetters: []
631
- });
632
- var appSettingsActions = actions3;
633
- var appSettingsSlice_default = reducer3;
634
-
635
- // src/hooks/useAppSettings.ts
636
- function useAppSettings() {
637
- const settings = (0, import_react_redux6.useSelector)((state) => state.appSettings);
638
- const dispatch = (0, import_react_redux6.useDispatch)();
639
- const setSettings = (0, import_react10.useCallback)(
640
- (patch) => {
641
- dispatch(appSettingsActions.initialize(patch));
642
- },
643
- [dispatch]
644
- );
645
- return { settings, setSettings };
646
- }
647
-
648
- // src/components/SettingsDialog.tsx
649
652
  var import_jsx_runtime12 = require("react/jsx-runtime");
650
653
  var noSettingsRules = () => null;
651
654
  function SettingsDialog({ visible, onDismiss, onShowHowToPlay, children }) {
@@ -1656,9 +1659,13 @@ function useActiveRound(game, defaults) {
1656
1659
  // src/hooks/useBackBlock.ts
1657
1660
  var import_expo_router7 = require("expo-router");
1658
1661
  var import_react19 = require("react");
1659
- function useBackBlock(held, onHeld) {
1662
+ function useBackBlock(held, onHeld, leave = import_core8.safeBack) {
1660
1663
  const leavingRef = (0, import_react19.useRef)(false);
1661
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
+ });
1662
1669
  (0, import_expo_router7.usePreventRemove)(held && !leaving, ({ repeat }) => {
1663
1670
  if (leavingRef.current) {
1664
1671
  setLeaving(true);
@@ -1667,7 +1674,7 @@ function useBackBlock(held, onHeld) {
1667
1674
  });
1668
1675
  return (0, import_react19.useCallback)(() => {
1669
1676
  leavingRef.current = true;
1670
- (0, import_core8.safeBack)();
1677
+ leaveRef.current();
1671
1678
  }, []);
1672
1679
  }
1673
1680
 
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";
@@ -243,22 +244,52 @@ function WindowControlsInsets({ children }) {
243
244
  return /* @__PURE__ */ jsx7(SafeAreaInsetsContext.Provider, { value: vertical, children });
244
245
  }
245
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
+
246
277
  // src/hooks/useLastActiveGame.tsx
247
278
  import { createContext as createContext3, useContext as useContext3, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
248
- import { useDispatch as useDispatch4, useStore as useStore2 } from "react-redux";
279
+ import { useDispatch as useDispatch5, useStore as useStore2 } from "react-redux";
249
280
 
250
281
  // src/redux/lastActiveGameSlice.ts
251
- import { createSettingsSlice } from "@rific/core";
252
- var { actions, reducer } = createSettingsSlice("lastActiveGame", { initialState: { gameId: null } });
253
- var lastActiveGameActions = actions;
254
- 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;
255
286
 
256
287
  // src/hooks/useLastActiveGame.tsx
257
288
  import { jsx as jsx8 } from "react/jsx-runtime";
258
289
  var LastActiveGameContext = createContext3(null);
259
290
  function LastActiveGameProvider({ children }) {
260
291
  const store = useStore2();
261
- const dispatch = useDispatch4();
292
+ const dispatch = useDispatch5();
262
293
  const [initial] = useState2(() => store.getState().lastActiveGame?.gameId ?? null);
263
294
  const pendingResume = useRef2(initial);
264
295
  const persisted = useRef2(initial);
@@ -297,24 +328,24 @@ function useLastActiveGame() {
297
328
 
298
329
  // src/hooks/useProfiles.tsx
299
330
  import { createProfileRecord, profilesActions, resolveInitialProfiles, useSharedProfilesSync } from "@tastic/profile";
300
- import { createContext as createContext4, useCallback as useCallback4, useContext as useContext4, useEffect as useEffect2, useState as useState3 } from "react";
301
- 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";
302
333
 
303
334
  // src/redux/profileSelectionSlice.ts
304
335
  import { createProfileSelectionSlice } from "@tastic/profile";
305
336
  var defaultProfileSelectionState = { 1: null, 2: null };
306
- var { actions: actions2, reducer: reducer2 } = createProfileSelectionSlice("pack", defaultProfileSelectionState);
307
- var profileSelectionActions = actions2;
308
- var profileSelectionSlice_default = reducer2;
337
+ var { actions: actions3, reducer: reducer3 } = createProfileSelectionSlice("pack", defaultProfileSelectionState);
338
+ var profileSelectionActions = actions3;
339
+ var profileSelectionSlice_default = reducer3;
309
340
 
310
341
  // src/hooks/useProfiles.tsx
311
342
  import { jsx as jsx9 } from "react/jsx-runtime";
312
343
  var SHARED_GROUP_ID = "group.com.infinitetoken.tastic";
313
344
  var ProfilesContext = createContext4(null);
314
345
  function ProfilesProvider({ children }) {
315
- const profiles = useSelector4((state) => state.profiles);
316
- const lastSelected = useSelector4((state) => state.profileSelection);
317
- const dispatch = useDispatch5();
346
+ const profiles = useSelector5((state) => state.profiles);
347
+ const lastSelected = useSelector5((state) => state.profileSelection);
348
+ const dispatch = useDispatch6();
318
349
  const [loaded, setLoaded] = useState3(false);
319
350
  useEffect2(() => {
320
351
  let cancelled = false;
@@ -330,7 +361,7 @@ function ProfilesProvider({ children }) {
330
361
  }, []);
331
362
  const { syncToShared } = useSharedProfilesSync({
332
363
  groupId: SHARED_GROUP_ID,
333
- onRemoteChange: useCallback4(
364
+ onRemoteChange: useCallback5(
334
365
  (remote) => {
335
366
  dispatch(profilesActions.setAll(remote));
336
367
  dispatch(profileSelectionActions.pruneToRoster(remote.map((p) => p.id)));
@@ -338,7 +369,7 @@ function ProfilesProvider({ children }) {
338
369
  [dispatch]
339
370
  )
340
371
  });
341
- const createProfile = useCallback4(
372
+ const createProfile = useCallback5(
342
373
  (input) => {
343
374
  const record = createProfileRecord(input);
344
375
  dispatch(profilesActions.add(record));
@@ -347,14 +378,14 @@ function ProfilesProvider({ children }) {
347
378
  },
348
379
  [profiles, dispatch, syncToShared]
349
380
  );
350
- const updateProfile = useCallback4(
381
+ const updateProfile = useCallback5(
351
382
  (id, patch) => {
352
383
  dispatch(profilesActions.update({ id, patch }));
353
384
  syncToShared(profiles.map((p) => p.id === id ? { ...p, ...patch, updatedAt: Date.now() } : p));
354
385
  },
355
386
  [profiles, dispatch, syncToShared]
356
387
  );
357
- const deleteProfile = useCallback4(
388
+ const deleteProfile = useCallback5(
358
389
  (id) => {
359
390
  dispatch(profilesActions.remove(id));
360
391
  syncToShared(profiles.filter((p) => p.id !== id));
@@ -362,7 +393,7 @@ function ProfilesProvider({ children }) {
362
393
  },
363
394
  [profiles, dispatch, syncToShared]
364
395
  );
365
- const selectProfile = useCallback4(
396
+ const selectProfile = useCallback5(
366
397
  (seat, profileId) => {
367
398
  dispatch(profileSelectionActions.select({ profileId, seat }));
368
399
  },
@@ -391,12 +422,16 @@ function AppStack() {
391
422
  const statusBarStyle = darkRoot ? "light" : "dark";
392
423
  const packOptions = (pack.useScreenOptions ?? noScreenOptions)();
393
424
  const backdropOptions = Backdrop ? { contentStyle: TRANSPARENT_CONTENT, animation: Platform3.select({ android: "fade" }) } : void 0;
394
- 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(
395
429
  ({ route }) => {
396
430
  const id = route.params?.game;
397
- 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 };
398
433
  },
399
- [pack.games]
434
+ [pack.games, edgeGuardOptions]
400
435
  );
401
436
  const navigationBackground = Backdrop ? TRANSPARENT_CONTENT.backgroundColor : rootBackground.contentStyle.backgroundColor;
402
437
  const navigationTheme = useMemo3(() => {
@@ -423,7 +458,7 @@ function HapticGatedToastProvider({ children }) {
423
458
  return /* @__PURE__ */ jsx10(ToastProvider, { haptics: settings.vibrate ? Haptics : void 0, paper: PackToasterComponent ? void 0 : RNPaper2, children });
424
459
  }
425
460
  function RotatingToaster() {
426
- const renderFrame = useCallback5(
461
+ const renderFrame = useCallback6(
427
462
  (toasts) => /* @__PURE__ */ jsx10(RotatedFrame, { rotatedSafeArea: true, passThrough: true, children: toasts }),
428
463
  []
429
464
  );
@@ -437,7 +472,7 @@ function GameProviders({ games, children }) {
437
472
  }
438
473
  function PreviewColors({ previewColor, children }) {
439
474
  const { dark } = useAutoPaperTheme();
440
- const preview = useCallback5((hex) => previewColor(hex, dark), [previewColor, dark]);
475
+ const preview = useCallback6((hex) => previewColor(hex, dark), [previewColor, dark]);
441
476
  return /* @__PURE__ */ jsx10(ProfileColorProvider, { preview, children });
442
477
  }
443
478
  function PackRoot({ pack, children }) {
@@ -536,38 +571,6 @@ var styles2 = StyleSheet2.create({
536
571
  // src/components/SettingsDialog.tsx
537
572
  import { useUpdateErrorToast as useUpdateErrorToast2 } from "@rific/toaster";
538
573
  import { BaseSettingsDialog } from "@tastic/hud/chrome";
539
-
540
- // src/hooks/useAppSettings.ts
541
- import { useCallback as useCallback6 } from "react";
542
- import { useDispatch as useDispatch6, useSelector as useSelector5 } from "react-redux";
543
-
544
- // src/redux/appSettingsSlice.ts
545
- import { createSettingsSlice as createSettingsSlice2 } from "@rific/core";
546
- var DEFAULT_APP_SETTINGS = {
547
- deferBottomEdgeGestures: false
548
- };
549
- var { actions: actions3, reducer: reducer3 } = createSettingsSlice2("appSettings", {
550
- initialState: DEFAULT_APP_SETTINGS,
551
- initializeMode: "merge",
552
- fieldSetters: []
553
- });
554
- var appSettingsActions = actions3;
555
- var appSettingsSlice_default = reducer3;
556
-
557
- // src/hooks/useAppSettings.ts
558
- function useAppSettings() {
559
- const settings = useSelector5((state) => state.appSettings);
560
- const dispatch = useDispatch6();
561
- const setSettings = useCallback6(
562
- (patch) => {
563
- dispatch(appSettingsActions.initialize(patch));
564
- },
565
- [dispatch]
566
- );
567
- return { settings, setSettings };
568
- }
569
-
570
- // src/components/SettingsDialog.tsx
571
574
  import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
572
575
  var noSettingsRules = () => null;
573
576
  function SettingsDialog({ visible, onDismiss, onShowHowToPlay, children }) {
@@ -1577,10 +1580,14 @@ function useActiveRound(game, defaults) {
1577
1580
 
1578
1581
  // src/hooks/useBackBlock.ts
1579
1582
  import { usePreventRemove } from "expo-router";
1580
- import { useCallback as useCallback11, useRef as useRef6, useState as useState8 } from "react";
1581
- function useBackBlock(held, onHeld) {
1583
+ import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef6, useState as useState8 } from "react";
1584
+ function useBackBlock(held, onHeld, leave = safeBack) {
1582
1585
  const leavingRef = useRef6(false);
1583
1586
  const [leaving, setLeaving] = useState8(false);
1587
+ const leaveRef = useRef6(leave);
1588
+ useEffect8(() => {
1589
+ leaveRef.current = leave;
1590
+ });
1584
1591
  usePreventRemove(held && !leaving, ({ repeat }) => {
1585
1592
  if (leavingRef.current) {
1586
1593
  setLeaving(true);
@@ -1589,7 +1596,7 @@ function useBackBlock(held, onHeld) {
1589
1596
  });
1590
1597
  return useCallback11(() => {
1591
1598
  leavingRef.current = true;
1592
- safeBack();
1599
+ leaveRef.current();
1593
1600
  }, []);
1594
1601
  }
1595
1602
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tastic/shell",
3
- "version": "0.9.0",
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",
@@ -137,7 +137,7 @@
137
137
  "@rific/toaster": ">=0.10.1",
138
138
  "@tastic/achievements": ">=0.6.0",
139
139
  "@tastic/core": ">=0.16.0",
140
- "@tastic/edge-guard": ">=0.1.5",
140
+ "@tastic/edge-guard": ">=0.2.0",
141
141
  "@tastic/hud": ">=0.29.0",
142
142
  "@tastic/profile": ">=0.18.0",
143
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(() => {
@@ -1,5 +1,5 @@
1
1
  import { usePreventRemove } from 'expo-router'
2
- import { useCallback, useRef, useState } from 'react'
2
+ import { useCallback, useEffect, useRef, useState } from 'react'
3
3
 
4
4
  import { safeBack } from '../navigation'
5
5
 
@@ -13,6 +13,11 @@ import { safeBack } from '../navigation'
13
13
  // calls this after that hook, with the same test it hands useQuitConfirmation. Off at Game Over, so
14
14
  // a back there leaves at once, as the chip does.
15
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
+ //
16
21
  // The block stops every navigation off the screen while it's on, Quit's own included, so `quit` marks
17
22
  // the way out first and the block lets that one through with `repeat` (expo-router's way to carry on
18
23
  // with a navigation it stopped). The block goes off in the same handler as `repeat`, the order
@@ -22,9 +27,13 @@ import { safeBack } from '../navigation'
22
27
  //
23
28
  // While it's on, the web also asks before the page unloads (expo-router's usePreventRemove adds a
24
29
  // beforeunload handler with it).
25
- export function useBackBlock(held: boolean, onHeld: () => void): () => void {
30
+ export function useBackBlock(held: boolean, onHeld: () => void, leave: () => void = safeBack): () => void {
26
31
  const leavingRef = useRef(false)
27
32
  const [leaving, setLeaving] = useState(false)
33
+ const leaveRef = useRef(leave)
34
+ useEffect(() => {
35
+ leaveRef.current = leave
36
+ })
28
37
  usePreventRemove(held && !leaving, ({ repeat }) => {
29
38
  if (leavingRef.current) {
30
39
  setLeaving(true)
@@ -33,6 +42,6 @@ export function useBackBlock(held: boolean, onHeld: () => void): () => void {
33
42
  })
34
43
  return useCallback(() => {
35
44
  leavingRef.current = true
36
- safeBack()
45
+ leaveRef.current()
37
46
  }, [])
38
47
  }