@tastic/shell 0.20.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ import { DialogHeaderStyleProvider, LetteringProvider, ScreenFrame } from "@tast
31
31
  import { ProfileColorProvider } from "@tastic/profile";
32
32
  import * as Haptics from "expo-haptics";
33
33
  import { DarkTheme, DefaultTheme, Stack, ThemeProvider as NavigationThemeProvider } from "expo-router";
34
- import { useCallback as useCallback6, useMemo as useMemo3 } from "react";
34
+ import { useCallback as useCallback6, useMemo as useMemo3, useRef as useRef3 } from "react";
35
35
  import { Platform as Platform3, StyleSheet, View } from "react-native";
36
36
  import { GestureHandlerRootView } from "react-native-gesture-handler";
37
37
  import * as RNPaper2 from "react-native-paper";
@@ -46,7 +46,7 @@ import { Platform } from "react-native";
46
46
 
47
47
  // src/splashGate.ts
48
48
  import { createGate } from "@rific/splash-gate";
49
- var { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = createGate(["theme", "fonts", "profiles"]);
49
+ var { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = createGate(["theme", "fonts", "profiles", "screen"]);
50
50
 
51
51
  // src/components/Fonts.tsx
52
52
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
@@ -173,8 +173,9 @@ import { Provider as ReduxProvider, useDispatch as useDispatch2, useSelector as
173
173
  import { PersistGate } from "redux-persist/integration/react";
174
174
  import { Fragment as Fragment2, jsx as jsx4 } from "react/jsx-runtime";
175
175
  function useShellFeedbackSounds() {
176
- const selection = useAudioPool(__require("./select-MLBNNA4N.wav"));
177
- const notification = useAudioPool(__require("./notification-CGGFPYK7.wav"));
176
+ const enabled = useSelector2((state) => state.sound.enabled);
177
+ const selection = useAudioPool(__require("./select-MLBNNA4N.wav"), { enabled });
178
+ const notification = useAudioPool(__require("./notification-CGGFPYK7.wav"), { enabled });
178
179
  return { selection, notification };
179
180
  }
180
181
  var FeedbackBridge = ({ children }) => {
@@ -293,8 +294,15 @@ function LastActiveGameProvider({ children }) {
293
294
  const [initial] = useState2(() => store.getState().lastActiveGame?.gameId ?? null);
294
295
  const pendingResume = useRef2(initial);
295
296
  const persisted = useRef2(initial);
296
- const value = useMemo2(
297
- () => ({
297
+ const resume = useRef2("idle");
298
+ const resumeListeners = useRef2(/* @__PURE__ */ new Set());
299
+ const value = useMemo2(() => {
300
+ const setResume = (next) => {
301
+ if (resume.current === next) return;
302
+ resume.current = next;
303
+ resumeListeners.current.forEach((listener) => listener());
304
+ };
305
+ return {
298
306
  consumeResumeGame: () => {
299
307
  const game = pendingResume.current;
300
308
  pendingResume.current = null;
@@ -314,10 +322,20 @@ function LastActiveGameProvider({ children }) {
314
322
  if (persisted.current === null) return;
315
323
  persisted.current = null;
316
324
  dispatch(lastActiveGameActions.setGameId(null));
325
+ },
326
+ beginResume: () => setResume("opening"),
327
+ playScreenUp: () => {
328
+ if (resume.current === "opening") setResume("up");
329
+ },
330
+ endResume: () => setResume("idle"),
331
+ resumeState: () => resume.current,
332
+ subscribeResume: (listener) => {
333
+ const listeners = resumeListeners.current;
334
+ listeners.add(listener);
335
+ return () => void listeners.delete(listener);
317
336
  }
318
- }),
319
- [dispatch]
320
- );
337
+ };
338
+ }, [dispatch]);
321
339
  return /* @__PURE__ */ jsx8(LastActiveGameContext.Provider, { value, children });
322
340
  }
323
341
  function useLastActiveGame() {
@@ -415,8 +433,44 @@ var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
415
433
  var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
416
434
  var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
417
435
  var noScreenOptions = () => ({});
436
+ function useFirstScreenGate() {
437
+ const { resumeState, subscribeResume } = useLastActiveGame();
438
+ const marked = useRef3(false);
439
+ return useCallback6(() => {
440
+ if (marked.current) return;
441
+ marked.current = true;
442
+ const mark = () => requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
443
+ requestAnimationFrame(
444
+ () => requestAnimationFrame(() => {
445
+ if (resumeState() !== "opening") {
446
+ markSplashReady("screen");
447
+ return;
448
+ }
449
+ const unsubscribe = subscribeResume(() => {
450
+ if (resumeState() === "opening") return;
451
+ unsubscribe();
452
+ mark();
453
+ });
454
+ })
455
+ );
456
+ }, [resumeState, subscribeResume]);
457
+ }
458
+ function useResumeShown() {
459
+ const { endResume } = useLastActiveGame();
460
+ return useCallback6(
461
+ ({ route }) => ({
462
+ transitionEnd: (event) => {
463
+ if (route.name === PLAY_ROUTE && !event.data?.closing) endResume();
464
+ }
465
+ }),
466
+ [endResume]
467
+ );
468
+ }
469
+ var PLAY_ROUTE = "play/[game]";
418
470
  function AppStack() {
419
471
  const pack = usePack();
472
+ const onFirstLayout = useFirstScreenGate();
473
+ const screenListeners = useResumeShown();
420
474
  const { Backdrop } = pack;
421
475
  const { dark } = useAutoPaperTheme();
422
476
  const darkRoot = Backdrop ? true : dark;
@@ -440,14 +494,12 @@ function AppStack() {
440
494
  const base = darkRoot ? DarkTheme : DefaultTheme;
441
495
  return { ...base, colors: { ...base.colors, background: navigationBackground } };
442
496
  }, [darkRoot, navigationBackground]);
443
- const stack = /* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
444
- /* @__PURE__ */ jsx10(Stack.Screen, { name: "index" }),
445
- /* @__PURE__ */ jsx10(Stack.Screen, { name: "play/[game]", options: playOptions })
446
- ] }) });
447
- if (!Backdrop) return stack;
448
- return /* @__PURE__ */ jsxs2(View, { style: styles.root, children: [
449
- /* @__PURE__ */ jsx10(Backdrop, {}),
450
- stack
497
+ return /* @__PURE__ */ jsxs2(View, { style: styles.root, onLayout: onFirstLayout, children: [
498
+ Backdrop && /* @__PURE__ */ jsx10(Backdrop, {}),
499
+ /* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenListeners, screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
500
+ /* @__PURE__ */ jsx10(Stack.Screen, { name: "index" }),
501
+ /* @__PURE__ */ jsx10(Stack.Screen, { name: PLAY_ROUTE, options: playOptions })
502
+ ] }) })
451
503
  ] });
452
504
  }
453
505
  function GatedApp({ children }) {
@@ -569,7 +621,7 @@ import { CornerActionButtons, PressAwayOverlay, useLettering, usePopoverHost } f
569
621
  import { PlayerSetupPanel, ReadyButton, SharedActionBand } from "@tastic/hud/lobby";
570
622
  import { DualZoneLayout, needsSharedNeutralZone, useDualZoneLayout } from "@tastic/split-screen";
571
623
  import { router as router4, useFocusEffect as useFocusEffect2 } from "expo-router";
572
- import { useCallback as useCallback9, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef4, useState as useState4 } from "react";
624
+ import { useCallback as useCallback9, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef5, useState as useState4 } from "react";
573
625
  import { StyleSheet as StyleSheet3, View as View3 } from "react-native";
574
626
  import { Text } from "react-native-paper";
575
627
  import Animated from "react-native-reanimated";
@@ -683,7 +735,7 @@ function useOpponent() {
683
735
  import { getThirdColor, useAutoPaperTheme as useAutoPaperTheme2, useThemeSettings } from "@rific/auto-paper";
684
736
  import { avoidSeatColorClash, profileSeatColor } from "@tastic/profile";
685
737
  import { useFocusEffect } from "expo-router";
686
- import { useCallback as useCallback8, useEffect as useEffect3, useRef as useRef3 } from "react";
738
+ import { useCallback as useCallback8, useEffect as useEffect3, useRef as useRef4 } from "react";
687
739
  import { useDispatch as useDispatch8, useSelector as useSelector7 } from "react-redux";
688
740
 
689
741
  // src/redux/seatColorsSlice.ts
@@ -724,12 +776,12 @@ function useSeatColors(p2IsHuman) {
724
776
  const p1Color = seatTheme ? remembered.p1 : themeColors.primary;
725
777
  const p2Color = seatTheme ? remembered.p2 : themeColors.secondary;
726
778
  const themeFor = useCallback8((p1, p2) => seatTheme ? seatTheme({ 1: p1, 2: p2 }, dark) : { color: { primary: p1, secondary: p2, tertiary: getThirdColor(p1, p2) } }, [seatTheme, dark]);
727
- const p1ProfileRef = useRef3(p1Profile);
728
- const p2ProfileRef = useRef3(p2Profile);
729
- const guestColorsRef = useRef3(guestColors);
730
- const cpuColorRef = useRef3(cpuColor);
731
- const profileColorsRef = useRef3(profileColors);
732
- const themeForRef = useRef3(themeFor);
779
+ const p1ProfileRef = useRef4(p1Profile);
780
+ const p2ProfileRef = useRef4(p2Profile);
781
+ const guestColorsRef = useRef4(guestColors);
782
+ const cpuColorRef = useRef4(cpuColor);
783
+ const profileColorsRef = useRef4(profileColors);
784
+ const themeForRef = useRef4(themeFor);
733
785
  useEffect3(() => {
734
786
  p1ProfileRef.current = p1Profile;
735
787
  }, [p1Profile]);
@@ -852,7 +904,7 @@ function LoadoutScreen({ game }) {
852
904
  },
853
905
  [setSeatTwo, setReady]
854
906
  );
855
- const roundSettingsRef = useRef4(loadout.roundSettings);
907
+ const roundSettingsRef = useRef5(loadout.roundSettings);
856
908
  useEffect4(() => {
857
909
  roundSettingsRef.current = loadout.roundSettings;
858
910
  }, [loadout.roundSettings]);
@@ -1043,10 +1095,20 @@ function PlayRoute() {
1043
1095
  const { game: id } = useLocalSearchParams3();
1044
1096
  const game = usePackGame(id);
1045
1097
  useResumePoint(game?.resumable ? game.id : null);
1098
+ useResumeUp();
1046
1099
  if (!game) return /* @__PURE__ */ jsx16(Redirect, { href: "/" });
1047
1100
  const { PlayScreen } = game;
1048
1101
  return /* @__PURE__ */ jsx16(PlayScreen, {}, game.id);
1049
1102
  }
1103
+ function useResumeUp() {
1104
+ const { playScreenUp } = useLastActiveGame();
1105
+ useEffect5(() => {
1106
+ let frame = requestAnimationFrame(() => {
1107
+ frame = requestAnimationFrame(playScreenUp);
1108
+ });
1109
+ return () => cancelAnimationFrame(frame);
1110
+ }, [playScreenUp]);
1111
+ }
1050
1112
  var playScreensUp = 0;
1051
1113
  function useResumePoint(gameId) {
1052
1114
  const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame();
@@ -1067,8 +1129,8 @@ import { IconButton, Pressable } from "@rific/feedback-press";
1067
1129
  import { PressAwayOverlay as PressAwayOverlay2, usePopoverHost as usePopoverHost2, useWellColors, WELL_SHADOW } from "@tastic/hud/chrome";
1068
1130
  import { getProfilePickerContentSize, ProfilePicker } from "@tastic/profile";
1069
1131
  import { router as router5, useFocusEffect as useFocusEffect3, useIsFocused } from "expo-router";
1070
- import { useCallback as useCallback10, useDeferredValue, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef5, useState as useState6 } from "react";
1071
- import { AppState as AppState2, StyleSheet as StyleSheet4, View as View4 } from "react-native";
1132
+ import { createContext as createContext5, memo, startTransition, useCallback as useCallback10, useContext as useContext5, useDeferredValue, useEffect as useEffect6, useLayoutEffect, useMemo as useMemo6, useRef as useRef6, useState as useState6, useSyncExternalStore } from "react";
1133
+ import { AppState as AppState2, Platform as Platform5, StyleSheet as StyleSheet4, View as View4 } from "react-native";
1072
1134
  import { Icon, Portal, SegmentedButtons, Text as Text2 } from "react-native-paper";
1073
1135
 
1074
1136
  // src/components/segmentTheme.ts
@@ -1170,7 +1232,7 @@ function HomeScreen() {
1170
1232
  }
1171
1233
  function useResume(game) {
1172
1234
  const pack = usePack();
1173
- const done = useRef5(false);
1235
+ const done = useRef6(false);
1174
1236
  useFocusEffect3(
1175
1237
  useCallback10(() => {
1176
1238
  if (!game || done.current) return;
@@ -1181,11 +1243,24 @@ function useResume(game) {
1181
1243
  );
1182
1244
  }
1183
1245
  function useMenuShown(resuming) {
1246
+ const { beginResume, endResume, resumeState, subscribeResume } = useLastActiveGame();
1184
1247
  const isFocused = useIsFocused();
1185
1248
  const [covered, setCovered] = useState6(false);
1186
1249
  if (resuming && !covered && !isFocused) setCovered(true);
1187
- return useDeferredValue(!resuming || covered);
1250
+ useLayoutEffect(() => {
1251
+ if (!resuming) return;
1252
+ beginResume();
1253
+ const id = setTimeout(endResume, RESUME_SHOWN_MAX_MS);
1254
+ return () => {
1255
+ clearTimeout(id);
1256
+ endResume();
1257
+ };
1258
+ }, [resuming, beginResume, endResume]);
1259
+ const onItsWay = useSyncExternalStore(subscribeResume, resumeState, resumeState) !== "idle";
1260
+ const gameShown = covered && !onItsWay;
1261
+ return useDeferredValue(!resuming || gameShown || covered && isFocused);
1188
1262
  }
1263
+ var RESUME_SHOWN_MAX_MS = 4e3;
1189
1264
  function HomeMenu() {
1190
1265
  const pack = usePack();
1191
1266
  const showPicker = pack.homePlayerPicker !== false;
@@ -1229,6 +1304,10 @@ function HomeMenu() {
1229
1304
  const tab = tabs ? tabs.find((t) => t.label === tabLabel) ?? tabs[0] : null;
1230
1305
  const tabButtons = useMemo6(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle]);
1231
1306
  const tabBar = tab && /* @__PURE__ */ jsx17(SegmentedButtons, { value: tab.label, onValueChange: setTabLabel, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles4.tabs, pack.Backdrop && { backgroundColor: colors.surface }] });
1307
+ const panes = useMemo6(() => tabs ? tabs.map((t) => ({ key: t.label, games: pack.games.filter(t.includes) })) : [{ key: ALL_GAMES, games: pack.games }], [tabs, pack.games]);
1308
+ const shownPane = tab?.label ?? ALL_GAMES;
1309
+ const { width: fitWidth, height: fitHeight } = layout.heroFit ?? NO_FIT;
1310
+ const hero = useMemo6(() => /* @__PURE__ */ jsx17(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive, fit: isWide && fitWidth !== void 0 ? { width: fitWidth, height: fitHeight } : void 0 }), [pack, fg, p1Color, p2Color, heroActive, isWide, fitWidth, fitHeight]);
1232
1311
  const columnClamp = useClampOnShrink();
1233
1312
  const gridClamp = useClampOnShrink();
1234
1313
  const openGame = useCallback10((game) => openFirstTime(game.id, () => router5.push(game.useLoadout ? loadoutHref(game.id) : playHref(game.id))), [openFirstTime]);
@@ -1242,23 +1321,23 @@ function HomeMenu() {
1242
1321
  const RulesSheet = rulesGame?.Rules;
1243
1322
  return /* @__PURE__ */ jsxs5(View4, { style: [styles4.container, { backgroundColor: bg }], children: [
1244
1323
  /* @__PURE__ */ jsx17(View4, { style: styles4.frame, children: /* @__PURE__ */ jsxs5(RulesHost, { enabled: pack.games.some((game) => game.Rules), children: [
1245
- isWide ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
1324
+ /* @__PURE__ */ jsx17(PreviewsRevealed, { value: previewsRevealed, children: isWide ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
1246
1325
  pressAway,
1247
1326
  /* @__PURE__ */ jsxs5(FadingScrollView, { ...tab && gridClamp, style: [styles4.wideRightPane, { left: layout.paddingLeft + layout.leftPaneWidth + HOME_WIDE_PANE_GAP }], contentContainerStyle: { paddingTop: 16 + insets.top, paddingBottom: 16 + insets.bottom, paddingRight: layout.paddingRight }, children: [
1248
1327
  tabBar && /* @__PURE__ */ jsx17(View4, { style: [styles4.wideTabs, { width: layout.rightPaneWidth }], children: tabBar }),
1249
- /* @__PURE__ */ jsx17(View4, { style: [styles4.grid, { width: layout.rightPaneWidth }], children: pack.games.map((game) => /* @__PURE__ */ jsx17(GameTile, { game, hidden: isHidden(tab, game), width: layout.tileWidth, previewWidth: layout.previewWidth, previewRevealed: previewsRevealed, dark, p1Color, p2Color, onPress: () => openGame(game), onRules: hasRules(game) ? () => openRules(game) : void 0 }, game.id)) })
1328
+ /* @__PURE__ */ jsx17(View4, { style: { width: layout.rightPaneWidth }, children: /* @__PURE__ */ jsx17(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.grid, children: (games, built) => /* @__PURE__ */ jsx17(GameGrid, { games, built, width: layout.tileWidth, previewWidth: layout.previewWidth, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
1250
1329
  ] }),
1251
1330
  /* @__PURE__ */ jsxs5(View4, { style: [styles4.wideLeftPane, { left: layout.paddingLeft, width: layout.leftPaneWidth, paddingTop: HOME_TOP_BAND + insets.top, paddingBottom: 16 + insets.bottom }, pickerHost.openId !== null && styles4.pickerOpen], children: [
1252
- /* @__PURE__ */ jsx17(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive, fit: layout.heroFit }),
1331
+ hero,
1253
1332
  showPicker && /* @__PURE__ */ jsx17(View4, { style: styles4.widePicker, children: picker })
1254
1333
  ] })
1255
1334
  ] }) : /* @__PURE__ */ jsxs5(FadingScrollView, { ...tab && columnClamp, style: styles4.scroll, contentContainerStyle: [styles4.content, { paddingTop: 56 + insets.top, paddingBottom: 24 + insets.bottom, paddingLeft: 16 + insets.left, paddingRight: 16 + insets.right }], children: [
1256
1335
  pressAway,
1257
- /* @__PURE__ */ jsx17(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive }),
1336
+ hero,
1258
1337
  showPicker && /* @__PURE__ */ jsx17(View4, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
1259
1338
  tabBar && /* @__PURE__ */ jsx17(View4, { style: styles4.listWidth, children: tabBar }),
1260
- /* @__PURE__ */ jsx17(View4, { style: styles4.list, children: pack.games.map((game) => /* @__PURE__ */ jsx17(GameRow, { game, hidden: isHidden(tab, game), dark, p1Color, p2Color, previewRevealed: previewsRevealed, onPress: () => openGame(game), onRules: hasRules(game) ? () => openRules(game) : void 0 }, game.id)) })
1261
- ] }),
1339
+ /* @__PURE__ */ jsx17(View4, { style: styles4.listWidth, children: /* @__PURE__ */ jsx17(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.list, children: (games, built) => /* @__PURE__ */ jsx17(GameList, { games, built, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
1340
+ ] }) }),
1262
1341
  /* @__PURE__ */ jsx17(IconButton, { icon: "trophy", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, left: 8 + insets.left }], onPress: () => router5.push(STATS_HREF), accessibilityLabel: "Stats & Achievements" }),
1263
1342
  /* @__PURE__ */ jsx17(IconButton, { icon: "cog", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, right: 8 + insets.right }], onPress: () => setSettingsOpen(true), accessibilityLabel: "Settings" }),
1264
1343
  RulesSheet && /* @__PURE__ */ jsx17(RulesSheet, { visible: true, onDismiss: () => setRulesGame(null) })
@@ -1268,12 +1347,39 @@ function HomeMenu() {
1268
1347
  }
1269
1348
  var SEAT_ONE_PICKER = "home-p1";
1270
1349
  var noPickerAlign = () => void 0;
1271
- function isHidden(tab, game) {
1272
- return !!tab && !tab.includes(game);
1350
+ var NO_FIT = { height: 0 };
1351
+ var ALL_GAMES = "__all__";
1352
+ function TabPanes({ panes, shown, buildOthers, style, children }) {
1353
+ const mostGames = Math.max(...panes.map(({ games }) => games.length));
1354
+ const builtGames = useBuiltGames(shown, mostGames, buildOthers && panes.length > 1);
1355
+ return panes.map(({ key, games }) => {
1356
+ const built = builtGames(key);
1357
+ if (built === 0) return null;
1358
+ return /* @__PURE__ */ jsx17(TabPane, { shown: key === shown, style, children: children(games, built) }, key);
1359
+ });
1273
1360
  }
1361
+ function useBuiltGames(shown, total, buildOthers) {
1362
+ const [picked, setPicked] = useState6([shown]);
1363
+ if (!picked.includes(shown)) setPicked([...picked, shown]);
1364
+ const [others, setOthers] = useState6(Platform5.OS === "web" ? total : 0);
1365
+ const building = buildOthers && others < total;
1366
+ useEffect6(() => {
1367
+ if (!building) return;
1368
+ const id = setTimeout(() => startTransition(() => setOthers(others + 1)), others === 0 ? OTHER_PANES_DELAY_MS : OTHER_PANES_STEP_MS);
1369
+ return () => clearTimeout(id);
1370
+ }, [building, others]);
1371
+ return (pane) => pane === shown || picked.includes(pane) ? total : others;
1372
+ }
1373
+ var OTHER_PANES_DELAY_MS = 1200;
1374
+ var OTHER_PANES_STEP_MS = 150;
1375
+ function TabPane({ shown, style, children }) {
1376
+ return /* @__PURE__ */ jsx17(View4, { collapsable: false, "aria-hidden": !shown, style: [style, !shown && styles4.paneHidden], children });
1377
+ }
1378
+ var PreviewsRevealedContext = createContext5(false);
1379
+ var PreviewsRevealed = PreviewsRevealedContext.Provider;
1274
1380
  function useClampOnShrink() {
1275
- const view = useRef5(null);
1276
- const sizes = useRef5({ viewport: 0, offset: 0 });
1381
+ const view = useRef6(null);
1382
+ const sizes = useRef6({ viewport: 0, offset: 0 });
1277
1383
  return useMemo6(
1278
1384
  () => ({
1279
1385
  ref: (instance) => {
@@ -1302,39 +1408,46 @@ function hasRules(game) {
1302
1408
  function RulesHost({ enabled, children }) {
1303
1409
  return enabled ? /* @__PURE__ */ jsx17(Portal.Host, { children }) : /* @__PURE__ */ jsx17(Fragment5, { children });
1304
1410
  }
1411
+ var GameList = memo(function GameList2({ games, built, ...rest }) {
1412
+ return games.slice(0, built).map((game) => /* @__PURE__ */ jsx17(GameRow, { game, ...rest }, game.id));
1413
+ });
1414
+ var GameGrid = memo(function GameGrid2({ games, built, ...rest }) {
1415
+ return games.slice(0, built).map((game) => /* @__PURE__ */ jsx17(GameTile, { game, ...rest }, game.id));
1416
+ });
1305
1417
  var ROW_BLURB_LINES = 3;
1306
- function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1418
+ var GameRow = memo(function GameRow2({ game, dark, p1Color, p2Color, onOpen, onRules }) {
1307
1419
  const { titleStyle } = usePack();
1308
1420
  const well = useWellColors();
1309
1421
  const GameIcon = game.icon;
1310
1422
  return (
1311
1423
  // The rules button sits beside the row's own button, laid over its end, not inside it: a button
1312
1424
  // inside a button is invalid on the web.
1313
- /* @__PURE__ */ jsxs5(View4, { style: hidden ? styles4.hidden : void 0, children: [
1314
- /* @__PURE__ */ jsxs5(Pressable, { onPress, style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1315
- game.Preview ? /* @__PURE__ */ jsx17(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, revealed: previewRevealed, dark, p1Color, p2Color }) : /* @__PURE__ */ jsx17(View4, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ jsx17(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
1425
+ /* @__PURE__ */ jsxs5(View4, { children: [
1426
+ /* @__PURE__ */ jsxs5(Pressable, { onPress: () => onOpen(game), style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1427
+ game.Preview ? /* @__PURE__ */ jsx17(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, dark, p1Color, p2Color }) : /* @__PURE__ */ jsx17(View4, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ jsx17(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
1316
1428
  /* @__PURE__ */ jsxs5(View4, { style: styles4.rowText, children: [
1317
1429
  /* @__PURE__ */ jsx17(Text2, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1318
1430
  /* @__PURE__ */ jsx17(Text2, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
1319
1431
  ] })
1320
1432
  ] }),
1321
- onRules && /* @__PURE__ */ jsx17(Pressable, { onPress: onRules, style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
1433
+ hasRules(game) && /* @__PURE__ */ jsx17(Pressable, { onPress: () => onRules(game), style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
1322
1434
  ] })
1323
1435
  );
1324
- }
1325
- function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1436
+ });
1437
+ var GameTile = memo(function GameTile2({ game, width, previewWidth, dark, p1Color, p2Color, onOpen, onRules }) {
1326
1438
  const { titleStyle } = usePack();
1327
1439
  const well = useWellColors();
1328
- return /* @__PURE__ */ jsxs5(View4, { style: [{ width }, hidden && styles4.hidden], children: [
1329
- /* @__PURE__ */ jsxs5(Pressable, { onPress, style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1330
- /* @__PURE__ */ jsx17(PreviewBox, { game, width: previewWidth, revealed: previewRevealed, dark, p1Color, p2Color }),
1440
+ return /* @__PURE__ */ jsxs5(View4, { style: { width }, children: [
1441
+ /* @__PURE__ */ jsxs5(Pressable, { onPress: () => onOpen(game), style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1442
+ /* @__PURE__ */ jsx17(PreviewBox, { game, width: previewWidth, dark, p1Color, p2Color }),
1331
1443
  /* @__PURE__ */ jsx17(Text2, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1332
1444
  /* @__PURE__ */ jsx17(Text2, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
1333
1445
  ] }),
1334
- onRules && /* @__PURE__ */ jsx17(Pressable, { onPress: onRules, style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
1446
+ hasRules(game) && /* @__PURE__ */ jsx17(Pressable, { onPress: () => onRules(game), style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
1335
1447
  ] });
1336
- }
1337
- function PreviewBox({ game, width, revealed, dark, p1Color, p2Color }) {
1448
+ });
1449
+ function PreviewBox({ game, width, dark, p1Color, p2Color }) {
1450
+ const revealed = useContext5(PreviewsRevealedContext);
1338
1451
  const height = Math.round(width / PREVIEW_ASPECT);
1339
1452
  const { Preview, icon: GameIcon } = game;
1340
1453
  const iconSize = Math.min(height, ROW_ICON_SIZE);
@@ -1364,21 +1477,21 @@ var styles4 = StyleSheet4.create({
1364
1477
  flexWrap: "wrap",
1365
1478
  gap: HOME_GRID_GAP
1366
1479
  },
1367
- // Out of the layout (a grid closes up around it) and hidden from screen readers.
1368
- hidden: {
1369
- display: "none"
1370
- },
1371
- // Solitaire's list: one column, never wider than a phone's, centred on a wide screen.
1480
+ // Solitaire's list: one column.
1372
1481
  list: {
1373
- gap: 14,
1374
- maxWidth: 480,
1375
- width: "100%"
1482
+ gap: 14
1376
1483
  },
1377
- // The list's width, for the tabs over it.
1484
+ // The list's width, and the tabs' over it: never wider than a phone's, centred on a wide screen.
1378
1485
  listWidth: {
1379
1486
  maxWidth: 480,
1380
1487
  width: "100%"
1381
1488
  },
1489
+ // A tab's pane that isn't shown (TabPane): out of the layout, over the shown pane's place, drawing
1490
+ // nothing.
1491
+ paneHidden: Platform5.select({
1492
+ web: { display: "none" },
1493
+ default: { left: 0, opacity: 0, pointerEvents: "none", position: "absolute", right: 0, top: 0 }
1494
+ }),
1382
1495
  picker: {
1383
1496
  alignItems: "center"
1384
1497
  },
@@ -1507,7 +1620,7 @@ var TABS = [
1507
1620
  var LABEL_WIDE_TAB = { flex: 0, flexBasis: "auto", flexGrow: 1, flexShrink: 1 };
1508
1621
  var NO_PACK_TABS = [];
1509
1622
  var EVERYONE = "__everyone__";
1510
- var ALL_GAMES = "__all__";
1623
+ var ALL_GAMES2 = "__all__";
1511
1624
  var tabGroup = (index) => `__tab-group-${index}__`;
1512
1625
  var tabGames = (index) => `__tab-${index}__`;
1513
1626
  var PLAYER_PICKER_ID = "stats-player";
@@ -1533,22 +1646,22 @@ function StatsContent({ pickerHost }) {
1533
1646
  const dispatch = useDispatch10();
1534
1647
  const fg = pack.foreground ?? colors.onBackground;
1535
1648
  const [tab, setTab] = useState7(STATS);
1536
- const [gameId, setGameId] = useState7(ALL_GAMES);
1649
+ const [gameId, setGameId] = useState7(ALL_GAMES2);
1537
1650
  const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
1538
1651
  const statsPlayer = useStatsPlayer();
1539
1652
  const [selectedProfileId, setSelectedProfileId] = useState7(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
1540
1653
  const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
1541
1654
  const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
1542
1655
  const pickedTab = homeTabs?.findIndex((_, index) => gameId === tabGames(index)) ?? -1;
1543
- const games = gameId === ALL_GAMES ? pack.games : pickedTab >= 0 ? pack.games.filter((g) => homeTabs[pickedTab].includes(g)) : pack.games.filter((g) => g.id === gameId);
1544
- const gameIds = gameId === ALL_GAMES ? null : games.map((g) => g.id);
1545
- const oneGameId = gameId === ALL_GAMES || pickedTab >= 0 ? null : gameId;
1656
+ const games = gameId === ALL_GAMES2 ? pack.games : pickedTab >= 0 ? pack.games.filter((g) => homeTabs[pickedTab].includes(g)) : pack.games.filter((g) => g.id === gameId);
1657
+ const gameIds = gameId === ALL_GAMES2 ? null : games.map((g) => g.id);
1658
+ const oneGameId = gameId === ALL_GAMES2 || pickedTab >= 0 ? null : gameId;
1546
1659
  const packTabs = pack.statsTabs ?? NO_PACK_TABS;
1547
1660
  const packTab = packTabs.find((t) => t.value === tab);
1548
1661
  const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
1549
1662
  const playerOptions = useMemo7(() => [{ value: EVERYONE, label: "Everyone", icon: "account-group" }, ...pack.guestStats && profiles.length > 0 ? [{ value: GUEST_PLAYER_ID, label: "Guest", icon: "account-outline" }] : [], ...profiles.map((p) => ({ value: p.id, label: p.name, icon: "account", color: pack.previewColor ? pack.previewColor(p.color, dark) : p.color })), MANAGE_OPTION], [profiles, pack, dark]);
1550
1663
  const gameOptions = useMemo7(() => {
1551
- const all = { value: ALL_GAMES, label: "All Games", icon: "view-grid-outline" };
1664
+ const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
1552
1665
  const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
1553
1666
  if (!homeTabs) return [all, ...pack.games.map(option)];
1554
1667
  return [all, ...homeTabs.map((tab2, index) => ({ value: tabGroup(index), label: tab2.label, icon: "folder-outline", options: [{ value: tabGames(index), label: "All", triggerLabel: tab2.label, icon: "view-grid-outline" }, ...pack.games.filter((g) => tab2.includes(g)).map(option)] }))];
@@ -1691,11 +1804,11 @@ function useActiveRound(game, defaults) {
1691
1804
 
1692
1805
  // src/hooks/useBackBlock.ts
1693
1806
  import { usePreventRemove } from "expo-router";
1694
- import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef6, useState as useState8 } from "react";
1807
+ import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef7, useState as useState8 } from "react";
1695
1808
  function useBackBlock(held, onHeld, leave = safeBack) {
1696
- const leavingRef = useRef6(false);
1809
+ const leavingRef = useRef7(false);
1697
1810
  const [leaving, setLeaving] = useState8(false);
1698
- const leaveRef = useRef6(leave);
1811
+ const leaveRef = useRef7(leave);
1699
1812
  useEffect8(() => {
1700
1813
  leaveRef.current = leave;
1701
1814
  });
@@ -1840,7 +1953,7 @@ function forgetProfileAchievements(dropStats) {
1840
1953
 
1841
1954
  // src/gameStats.tsx
1842
1955
  import { createAchievementsSlice, mapUnlocksBySeat, useAchievements } from "@tastic/achievements";
1843
- import { createContext as createContext5, useCallback as useCallback12, useContext as useContext5, useMemo as useMemo8 } from "react";
1956
+ import { createContext as createContext6, useCallback as useCallback12, useContext as useContext6, useMemo as useMemo8 } from "react";
1844
1957
  import { jsx as jsx21 } from "react/jsx-runtime";
1845
1958
  var SEATS = [1, 2];
1846
1959
  function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
@@ -1858,7 +1971,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1858
1971
  };
1859
1972
  const reducer6 = onProfileRemoved(sliceReducer, forgetProfileAchievements(dropProfileStats));
1860
1973
  const profileViews = (stats) => Object.fromEntries(Object.entries(stats.profiles).map(([profileId, bucket]) => [profileId, getProfileStatsView(bucket)]));
1861
- const Context = createContext5(null);
1974
+ const Context = createContext6(null);
1862
1975
  function Provider({ children }) {
1863
1976
  const { stats, unlockedAchievements, recordOutcome, resetAll } = useAchievements({
1864
1977
  catalog,
@@ -1877,7 +1990,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1877
1990
  return /* @__PURE__ */ jsx21(Context.Provider, { value, children });
1878
1991
  }
1879
1992
  function useStats() {
1880
- const ctx = useContext5(Context);
1993
+ const ctx = useContext6(Context);
1881
1994
  if (!ctx) throw new Error(`The ${key} stats are read within their game's Provider`);
1882
1995
  return ctx;
1883
1996
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tastic/shell",
3
- "version": "0.20.0",
3
+ "version": "0.21.1",
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",
@@ -69,22 +69,22 @@
69
69
  "@babel/core": "^7.29.13",
70
70
  "@expo/vector-icons": "^15.1.1",
71
71
  "@infinitetoken/eslint-config": "^0.2.1",
72
- "@infinitetoken/jest-config": "^0.5.2",
72
+ "@infinitetoken/jest-config": "^0.5.3",
73
73
  "@infinitetoken/tsconfig": "^0.7.0",
74
74
  "@react-native-async-storage/async-storage": "2.2.0",
75
75
  "@react-native-masked-view/masked-view": "0.3.2",
76
76
  "@react-native/jest-preset": "^0.88.0",
77
77
  "@reduxjs/toolkit": "^2.14.0",
78
- "@rific/auto-paper": "^0.14.0",
79
- "@rific/core": "^0.5.0",
80
- "@rific/feedback-press": "^0.13.1",
81
- "@rific/focus-chain": "^0.4.8",
82
- "@rific/gestures": "^0.1.3",
83
- "@rific/splash-gate": "^0.2.3",
84
- "@rific/toaster": "^0.12.0",
85
- "@rific/updater": "^0.8.0",
78
+ "@rific/auto-paper": "^0.15.2",
79
+ "@rific/core": "^0.5.2",
80
+ "@rific/feedback-press": "^0.15.0",
81
+ "@rific/focus-chain": "^0.4.9",
82
+ "@rific/gestures": "^0.1.5",
83
+ "@rific/splash-gate": "^0.2.4",
84
+ "@rific/toaster": "^0.14.0",
85
+ "@rific/updater": "^0.9.3",
86
86
  "@tastic/achievements": "^0.6.1",
87
- "@tastic/core": "^0.17.0",
87
+ "@tastic/core": "^0.19.0",
88
88
  "@tastic/edge-guard": "^0.2.1",
89
89
  "@tastic/hud": "^0.40.0",
90
90
  "@tastic/profile": "^0.29.0",
@@ -132,7 +132,7 @@
132
132
  "@reduxjs/toolkit": ">=2.13.0",
133
133
  "@rific/auto-paper": ">=0.13.4",
134
134
  "@rific/core": ">=0.5.0",
135
- "@rific/feedback-press": ">=0.13.1",
135
+ "@rific/feedback-press": ">=0.15.0",
136
136
  "@rific/splash-gate": ">=0.2.3",
137
137
  "@rific/toaster": ">=0.10.1",
138
138
  "@tastic/achievements": ">=0.6.0",