@tastic/shell 0.20.0 → 0.21.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/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 }) => {
@@ -415,8 +416,17 @@ var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
415
416
  var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
416
417
  var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
417
418
  var noScreenOptions = () => ({});
419
+ function useFirstScreenGate() {
420
+ const marked = useRef3(false);
421
+ return useCallback6(() => {
422
+ if (marked.current) return;
423
+ marked.current = true;
424
+ requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
425
+ }, []);
426
+ }
418
427
  function AppStack() {
419
428
  const pack = usePack();
429
+ const onFirstLayout = useFirstScreenGate();
420
430
  const { Backdrop } = pack;
421
431
  const { dark } = useAutoPaperTheme();
422
432
  const darkRoot = Backdrop ? true : dark;
@@ -440,14 +450,12 @@ function AppStack() {
440
450
  const base = darkRoot ? DarkTheme : DefaultTheme;
441
451
  return { ...base, colors: { ...base.colors, background: navigationBackground } };
442
452
  }, [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
453
+ return /* @__PURE__ */ jsxs2(View, { style: styles.root, onLayout: onFirstLayout, children: [
454
+ Backdrop && /* @__PURE__ */ jsx10(Backdrop, {}),
455
+ /* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
456
+ /* @__PURE__ */ jsx10(Stack.Screen, { name: "index" }),
457
+ /* @__PURE__ */ jsx10(Stack.Screen, { name: "play/[game]", options: playOptions })
458
+ ] }) })
451
459
  ] });
452
460
  }
453
461
  function GatedApp({ children }) {
@@ -569,7 +577,7 @@ import { CornerActionButtons, PressAwayOverlay, useLettering, usePopoverHost } f
569
577
  import { PlayerSetupPanel, ReadyButton, SharedActionBand } from "@tastic/hud/lobby";
570
578
  import { DualZoneLayout, needsSharedNeutralZone, useDualZoneLayout } from "@tastic/split-screen";
571
579
  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";
580
+ import { useCallback as useCallback9, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef5, useState as useState4 } from "react";
573
581
  import { StyleSheet as StyleSheet3, View as View3 } from "react-native";
574
582
  import { Text } from "react-native-paper";
575
583
  import Animated from "react-native-reanimated";
@@ -683,7 +691,7 @@ function useOpponent() {
683
691
  import { getThirdColor, useAutoPaperTheme as useAutoPaperTheme2, useThemeSettings } from "@rific/auto-paper";
684
692
  import { avoidSeatColorClash, profileSeatColor } from "@tastic/profile";
685
693
  import { useFocusEffect } from "expo-router";
686
- import { useCallback as useCallback8, useEffect as useEffect3, useRef as useRef3 } from "react";
694
+ import { useCallback as useCallback8, useEffect as useEffect3, useRef as useRef4 } from "react";
687
695
  import { useDispatch as useDispatch8, useSelector as useSelector7 } from "react-redux";
688
696
 
689
697
  // src/redux/seatColorsSlice.ts
@@ -724,12 +732,12 @@ function useSeatColors(p2IsHuman) {
724
732
  const p1Color = seatTheme ? remembered.p1 : themeColors.primary;
725
733
  const p2Color = seatTheme ? remembered.p2 : themeColors.secondary;
726
734
  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);
735
+ const p1ProfileRef = useRef4(p1Profile);
736
+ const p2ProfileRef = useRef4(p2Profile);
737
+ const guestColorsRef = useRef4(guestColors);
738
+ const cpuColorRef = useRef4(cpuColor);
739
+ const profileColorsRef = useRef4(profileColors);
740
+ const themeForRef = useRef4(themeFor);
733
741
  useEffect3(() => {
734
742
  p1ProfileRef.current = p1Profile;
735
743
  }, [p1Profile]);
@@ -852,7 +860,7 @@ function LoadoutScreen({ game }) {
852
860
  },
853
861
  [setSeatTwo, setReady]
854
862
  );
855
- const roundSettingsRef = useRef4(loadout.roundSettings);
863
+ const roundSettingsRef = useRef5(loadout.roundSettings);
856
864
  useEffect4(() => {
857
865
  roundSettingsRef.current = loadout.roundSettings;
858
866
  }, [loadout.roundSettings]);
@@ -1067,8 +1075,8 @@ import { IconButton, Pressable } from "@rific/feedback-press";
1067
1075
  import { PressAwayOverlay as PressAwayOverlay2, usePopoverHost as usePopoverHost2, useWellColors, WELL_SHADOW } from "@tastic/hud/chrome";
1068
1076
  import { getProfilePickerContentSize, ProfilePicker } from "@tastic/profile";
1069
1077
  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";
1078
+ import { createContext as createContext5, memo, startTransition, useCallback as useCallback10, useContext as useContext5, useDeferredValue, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef6, useState as useState6 } from "react";
1079
+ import { AppState as AppState2, Platform as Platform5, StyleSheet as StyleSheet4, View as View4 } from "react-native";
1072
1080
  import { Icon, Portal, SegmentedButtons, Text as Text2 } from "react-native-paper";
1073
1081
 
1074
1082
  // src/components/segmentTheme.ts
@@ -1170,7 +1178,7 @@ function HomeScreen() {
1170
1178
  }
1171
1179
  function useResume(game) {
1172
1180
  const pack = usePack();
1173
- const done = useRef5(false);
1181
+ const done = useRef6(false);
1174
1182
  useFocusEffect3(
1175
1183
  useCallback10(() => {
1176
1184
  if (!game || done.current) return;
@@ -1229,6 +1237,10 @@ function HomeMenu() {
1229
1237
  const tab = tabs ? tabs.find((t) => t.label === tabLabel) ?? tabs[0] : null;
1230
1238
  const tabButtons = useMemo6(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle]);
1231
1239
  const tabBar = tab && /* @__PURE__ */ jsx17(SegmentedButtons, { value: tab.label, onValueChange: setTabLabel, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles4.tabs, pack.Backdrop && { backgroundColor: colors.surface }] });
1240
+ 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]);
1241
+ const shownPane = tab?.label ?? ALL_GAMES;
1242
+ const { width: fitWidth, height: fitHeight } = layout.heroFit ?? NO_FIT;
1243
+ 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
1244
  const columnClamp = useClampOnShrink();
1233
1245
  const gridClamp = useClampOnShrink();
1234
1246
  const openGame = useCallback10((game) => openFirstTime(game.id, () => router5.push(game.useLoadout ? loadoutHref(game.id) : playHref(game.id))), [openFirstTime]);
@@ -1242,23 +1254,23 @@ function HomeMenu() {
1242
1254
  const RulesSheet = rulesGame?.Rules;
1243
1255
  return /* @__PURE__ */ jsxs5(View4, { style: [styles4.container, { backgroundColor: bg }], children: [
1244
1256
  /* @__PURE__ */ jsx17(View4, { style: styles4.frame, children: /* @__PURE__ */ jsxs5(RulesHost, { enabled: pack.games.some((game) => game.Rules), children: [
1245
- isWide ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
1257
+ /* @__PURE__ */ jsx17(PreviewsRevealed, { value: previewsRevealed, children: isWide ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
1246
1258
  pressAway,
1247
1259
  /* @__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
1260
  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)) })
1261
+ /* @__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
1262
  ] }),
1251
1263
  /* @__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 }),
1264
+ hero,
1253
1265
  showPicker && /* @__PURE__ */ jsx17(View4, { style: styles4.widePicker, children: picker })
1254
1266
  ] })
1255
1267
  ] }) : /* @__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
1268
  pressAway,
1257
- /* @__PURE__ */ jsx17(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive }),
1269
+ hero,
1258
1270
  showPicker && /* @__PURE__ */ jsx17(View4, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
1259
1271
  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
- ] }),
1272
+ /* @__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 }) }) })
1273
+ ] }) }),
1262
1274
  /* @__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
1275
  /* @__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
1276
  RulesSheet && /* @__PURE__ */ jsx17(RulesSheet, { visible: true, onDismiss: () => setRulesGame(null) })
@@ -1268,12 +1280,39 @@ function HomeMenu() {
1268
1280
  }
1269
1281
  var SEAT_ONE_PICKER = "home-p1";
1270
1282
  var noPickerAlign = () => void 0;
1271
- function isHidden(tab, game) {
1272
- return !!tab && !tab.includes(game);
1283
+ var NO_FIT = { height: 0 };
1284
+ var ALL_GAMES = "__all__";
1285
+ function TabPanes({ panes, shown, buildOthers, style, children }) {
1286
+ const mostGames = Math.max(...panes.map(({ games }) => games.length));
1287
+ const builtGames = useBuiltGames(shown, mostGames, buildOthers && panes.length > 1);
1288
+ return panes.map(({ key, games }) => {
1289
+ const built = builtGames(key);
1290
+ if (built === 0) return null;
1291
+ return /* @__PURE__ */ jsx17(TabPane, { shown: key === shown, style, children: children(games, built) }, key);
1292
+ });
1273
1293
  }
1294
+ function useBuiltGames(shown, total, buildOthers) {
1295
+ const [picked, setPicked] = useState6([shown]);
1296
+ if (!picked.includes(shown)) setPicked([...picked, shown]);
1297
+ const [others, setOthers] = useState6(Platform5.OS === "web" ? total : 0);
1298
+ const building = buildOthers && others < total;
1299
+ useEffect6(() => {
1300
+ if (!building) return;
1301
+ const id = setTimeout(() => startTransition(() => setOthers(others + 1)), others === 0 ? OTHER_PANES_DELAY_MS : OTHER_PANES_STEP_MS);
1302
+ return () => clearTimeout(id);
1303
+ }, [building, others]);
1304
+ return (pane) => pane === shown || picked.includes(pane) ? total : others;
1305
+ }
1306
+ var OTHER_PANES_DELAY_MS = 1200;
1307
+ var OTHER_PANES_STEP_MS = 150;
1308
+ function TabPane({ shown, style, children }) {
1309
+ return /* @__PURE__ */ jsx17(View4, { collapsable: false, "aria-hidden": !shown, style: [style, !shown && styles4.paneHidden], children });
1310
+ }
1311
+ var PreviewsRevealedContext = createContext5(false);
1312
+ var PreviewsRevealed = PreviewsRevealedContext.Provider;
1274
1313
  function useClampOnShrink() {
1275
- const view = useRef5(null);
1276
- const sizes = useRef5({ viewport: 0, offset: 0 });
1314
+ const view = useRef6(null);
1315
+ const sizes = useRef6({ viewport: 0, offset: 0 });
1277
1316
  return useMemo6(
1278
1317
  () => ({
1279
1318
  ref: (instance) => {
@@ -1302,39 +1341,46 @@ function hasRules(game) {
1302
1341
  function RulesHost({ enabled, children }) {
1303
1342
  return enabled ? /* @__PURE__ */ jsx17(Portal.Host, { children }) : /* @__PURE__ */ jsx17(Fragment5, { children });
1304
1343
  }
1344
+ var GameList = memo(function GameList2({ games, built, ...rest }) {
1345
+ return games.slice(0, built).map((game) => /* @__PURE__ */ jsx17(GameRow, { game, ...rest }, game.id));
1346
+ });
1347
+ var GameGrid = memo(function GameGrid2({ games, built, ...rest }) {
1348
+ return games.slice(0, built).map((game) => /* @__PURE__ */ jsx17(GameTile, { game, ...rest }, game.id));
1349
+ });
1305
1350
  var ROW_BLURB_LINES = 3;
1306
- function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1351
+ var GameRow = memo(function GameRow2({ game, dark, p1Color, p2Color, onOpen, onRules }) {
1307
1352
  const { titleStyle } = usePack();
1308
1353
  const well = useWellColors();
1309
1354
  const GameIcon = game.icon;
1310
1355
  return (
1311
1356
  // The rules button sits beside the row's own button, laid over its end, not inside it: a button
1312
1357
  // 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 }) }),
1358
+ /* @__PURE__ */ jsxs5(View4, { children: [
1359
+ /* @__PURE__ */ jsxs5(Pressable, { onPress: () => onOpen(game), style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1360
+ 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
1361
  /* @__PURE__ */ jsxs5(View4, { style: styles4.rowText, children: [
1317
1362
  /* @__PURE__ */ jsx17(Text2, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1318
1363
  /* @__PURE__ */ jsx17(Text2, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
1319
1364
  ] })
1320
1365
  ] }),
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 }) })
1366
+ 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
1367
  ] })
1323
1368
  );
1324
- }
1325
- function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1369
+ });
1370
+ var GameTile = memo(function GameTile2({ game, width, previewWidth, dark, p1Color, p2Color, onOpen, onRules }) {
1326
1371
  const { titleStyle } = usePack();
1327
1372
  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 }),
1373
+ return /* @__PURE__ */ jsxs5(View4, { style: { width }, children: [
1374
+ /* @__PURE__ */ jsxs5(Pressable, { onPress: () => onOpen(game), style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1375
+ /* @__PURE__ */ jsx17(PreviewBox, { game, width: previewWidth, dark, p1Color, p2Color }),
1331
1376
  /* @__PURE__ */ jsx17(Text2, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1332
1377
  /* @__PURE__ */ jsx17(Text2, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
1333
1378
  ] }),
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" }) })
1379
+ 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
1380
  ] });
1336
- }
1337
- function PreviewBox({ game, width, revealed, dark, p1Color, p2Color }) {
1381
+ });
1382
+ function PreviewBox({ game, width, dark, p1Color, p2Color }) {
1383
+ const revealed = useContext5(PreviewsRevealedContext);
1338
1384
  const height = Math.round(width / PREVIEW_ASPECT);
1339
1385
  const { Preview, icon: GameIcon } = game;
1340
1386
  const iconSize = Math.min(height, ROW_ICON_SIZE);
@@ -1364,21 +1410,21 @@ var styles4 = StyleSheet4.create({
1364
1410
  flexWrap: "wrap",
1365
1411
  gap: HOME_GRID_GAP
1366
1412
  },
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.
1413
+ // Solitaire's list: one column.
1372
1414
  list: {
1373
- gap: 14,
1374
- maxWidth: 480,
1375
- width: "100%"
1415
+ gap: 14
1376
1416
  },
1377
- // The list's width, for the tabs over it.
1417
+ // The list's width, and the tabs' over it: never wider than a phone's, centred on a wide screen.
1378
1418
  listWidth: {
1379
1419
  maxWidth: 480,
1380
1420
  width: "100%"
1381
1421
  },
1422
+ // A tab's pane that isn't shown (TabPane): out of the layout, over the shown pane's place, drawing
1423
+ // nothing.
1424
+ paneHidden: Platform5.select({
1425
+ web: { display: "none" },
1426
+ default: { left: 0, opacity: 0, pointerEvents: "none", position: "absolute", right: 0, top: 0 }
1427
+ }),
1382
1428
  picker: {
1383
1429
  alignItems: "center"
1384
1430
  },
@@ -1507,7 +1553,7 @@ var TABS = [
1507
1553
  var LABEL_WIDE_TAB = { flex: 0, flexBasis: "auto", flexGrow: 1, flexShrink: 1 };
1508
1554
  var NO_PACK_TABS = [];
1509
1555
  var EVERYONE = "__everyone__";
1510
- var ALL_GAMES = "__all__";
1556
+ var ALL_GAMES2 = "__all__";
1511
1557
  var tabGroup = (index) => `__tab-group-${index}__`;
1512
1558
  var tabGames = (index) => `__tab-${index}__`;
1513
1559
  var PLAYER_PICKER_ID = "stats-player";
@@ -1533,22 +1579,22 @@ function StatsContent({ pickerHost }) {
1533
1579
  const dispatch = useDispatch10();
1534
1580
  const fg = pack.foreground ?? colors.onBackground;
1535
1581
  const [tab, setTab] = useState7(STATS);
1536
- const [gameId, setGameId] = useState7(ALL_GAMES);
1582
+ const [gameId, setGameId] = useState7(ALL_GAMES2);
1537
1583
  const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
1538
1584
  const statsPlayer = useStatsPlayer();
1539
1585
  const [selectedProfileId, setSelectedProfileId] = useState7(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
1540
1586
  const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
1541
1587
  const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
1542
1588
  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;
1589
+ const games = gameId === ALL_GAMES2 ? pack.games : pickedTab >= 0 ? pack.games.filter((g) => homeTabs[pickedTab].includes(g)) : pack.games.filter((g) => g.id === gameId);
1590
+ const gameIds = gameId === ALL_GAMES2 ? null : games.map((g) => g.id);
1591
+ const oneGameId = gameId === ALL_GAMES2 || pickedTab >= 0 ? null : gameId;
1546
1592
  const packTabs = pack.statsTabs ?? NO_PACK_TABS;
1547
1593
  const packTab = packTabs.find((t) => t.value === tab);
1548
1594
  const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
1549
1595
  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
1596
  const gameOptions = useMemo7(() => {
1551
- const all = { value: ALL_GAMES, label: "All Games", icon: "view-grid-outline" };
1597
+ const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
1552
1598
  const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
1553
1599
  if (!homeTabs) return [all, ...pack.games.map(option)];
1554
1600
  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 +1737,11 @@ function useActiveRound(game, defaults) {
1691
1737
 
1692
1738
  // src/hooks/useBackBlock.ts
1693
1739
  import { usePreventRemove } from "expo-router";
1694
- import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef6, useState as useState8 } from "react";
1740
+ import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef7, useState as useState8 } from "react";
1695
1741
  function useBackBlock(held, onHeld, leave = safeBack) {
1696
- const leavingRef = useRef6(false);
1742
+ const leavingRef = useRef7(false);
1697
1743
  const [leaving, setLeaving] = useState8(false);
1698
- const leaveRef = useRef6(leave);
1744
+ const leaveRef = useRef7(leave);
1699
1745
  useEffect8(() => {
1700
1746
  leaveRef.current = leave;
1701
1747
  });
@@ -1840,7 +1886,7 @@ function forgetProfileAchievements(dropStats) {
1840
1886
 
1841
1887
  // src/gameStats.tsx
1842
1888
  import { createAchievementsSlice, mapUnlocksBySeat, useAchievements } from "@tastic/achievements";
1843
- import { createContext as createContext5, useCallback as useCallback12, useContext as useContext5, useMemo as useMemo8 } from "react";
1889
+ import { createContext as createContext6, useCallback as useCallback12, useContext as useContext6, useMemo as useMemo8 } from "react";
1844
1890
  import { jsx as jsx21 } from "react/jsx-runtime";
1845
1891
  var SEATS = [1, 2];
1846
1892
  function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
@@ -1858,7 +1904,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1858
1904
  };
1859
1905
  const reducer6 = onProfileRemoved(sliceReducer, forgetProfileAchievements(dropProfileStats));
1860
1906
  const profileViews = (stats) => Object.fromEntries(Object.entries(stats.profiles).map(([profileId, bucket]) => [profileId, getProfileStatsView(bucket)]));
1861
- const Context = createContext5(null);
1907
+ const Context = createContext6(null);
1862
1908
  function Provider({ children }) {
1863
1909
  const { stats, unlockedAchievements, recordOutcome, resetAll } = useAchievements({
1864
1910
  catalog,
@@ -1877,7 +1923,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1877
1923
  return /* @__PURE__ */ jsx21(Context.Provider, { value, children });
1878
1924
  }
1879
1925
  function useStats() {
1880
- const ctx = useContext5(Context);
1926
+ const ctx = useContext6(Context);
1881
1927
  if (!ctx) throw new Error(`The ${key} stats are read within their game's Provider`);
1882
1928
  return ctx;
1883
1929
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tastic/shell",
3
- "version": "0.20.0",
3
+ "version": "0.21.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",
@@ -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",
@@ -7,7 +7,7 @@ import { DialogHeaderStyleProvider, LetteringProvider, ScreenFrame } from '@tast
7
7
  import { ProfileColorProvider } from '@tastic/profile'
8
8
  import * as Haptics from 'expo-haptics'
9
9
  import { DarkTheme, DefaultTheme, Stack, ThemeProvider as NavigationThemeProvider } from 'expo-router'
10
- import { ReactNode, useCallback, useMemo } from 'react'
10
+ import { ReactNode, useCallback, useMemo, useRef } from 'react'
11
11
  import { Platform, StyleSheet, View } from 'react-native'
12
12
  import { GestureHandlerRootView } from 'react-native-gesture-handler'
13
13
  import * as RNPaper from 'react-native-paper'
@@ -25,7 +25,7 @@ import { LastActiveGameProvider } from './hooks/useLastActiveGame'
25
25
  import { ProfilesProvider, useProfiles } from './hooks/useProfiles'
26
26
  import { PackProvider, usePack } from './PackContext'
27
27
  import type { PackStore } from './redux/createPackStore'
28
- import { SplashGate } from './splashGate'
28
+ import { markSplashReady, SplashGate } from './splashGate'
29
29
  import type { PackDefinition, PackGameDefinition } from './types'
30
30
 
31
31
  // The pack's root: every provider the shell needs, the pack's games' own providers, and the stack.
@@ -82,8 +82,24 @@ const TRANSPARENT_CONTENT = { backgroundColor: 'transparent' }
82
82
  // empty object without them.
83
83
  const noScreenOptions = () => ({})
84
84
 
85
+ // Holds the splash until the stack's first screen is on the glass. The other gates open in the very commit
86
+ // that starts mounting the stack, and on a slow phone React Native draws that commit a second or more later:
87
+ // the splash faded to the theme's plain background and the first screen landed on it after 1 to 1.4 s (an LG
88
+ // Stylo 6, CardTastic). The stack's layout comes with that commit, whatever screen it opens on, and by the
89
+ // second frame after it Android has mounted it (nothing under a held splash is drawn), so the splash fades
90
+ // straight to the screen.
91
+ function useFirstScreenGate() {
92
+ const marked = useRef(false)
93
+ return useCallback(() => {
94
+ if (marked.current) return
95
+ marked.current = true
96
+ requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady('screen')))
97
+ }, [])
98
+ }
99
+
85
100
  function AppStack() {
86
101
  const pack = usePack()
102
+ const onFirstLayout = useFirstScreenGate()
87
103
  const { Backdrop } = pack
88
104
  const { dark } = useAutoPaperTheme()
89
105
  // Over a backdrop the root stays dark whatever the mode: a backdrop is a dark table (the felt), and a
@@ -114,19 +130,15 @@ function AppStack() {
114
130
  const base = darkRoot ? DarkTheme : DefaultTheme
115
131
  return { ...base, colors: { ...base.colors, background: navigationBackground } }
116
132
  }, [darkRoot, navigationBackground])
117
- const stack = (
118
- <NavigationThemeProvider value={navigationTheme}>
119
- <Stack screenOptions={{ ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }}>
120
- <Stack.Screen name='index' />
121
- <Stack.Screen name='play/[game]' options={playOptions} />
122
- </Stack>
123
- </NavigationThemeProvider>
124
- )
125
- if (!Backdrop) return stack
126
133
  return (
127
- <View style={styles.root}>
128
- <Backdrop />
129
- {stack}
134
+ <View style={styles.root} onLayout={onFirstLayout}>
135
+ {Backdrop && <Backdrop />}
136
+ <NavigationThemeProvider value={navigationTheme}>
137
+ <Stack screenOptions={{ ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }}>
138
+ <Stack.Screen name='index' />
139
+ <Stack.Screen name='play/[game]' options={playOptions} />
140
+ </Stack>
141
+ </NavigationThemeProvider>
130
142
  </View>
131
143
  )
132
144
  }
@@ -20,10 +20,13 @@ interface Props {
20
20
 
21
21
  // Generic UI feedback sounds, wired into every Button/IconButton/etc. in the package (see
22
22
  // useFeedbackHandlers' `fire`, which already gates these on the sound-enabled setting itself -
23
- // no need to re-check it here).
23
+ // no need to re-check it here). With sound off the pools make no players at all (`enabled`): each one
24
+ // costs a slow Android phone about 0.1 s of its launch. Read from the store, since this runs above the
25
+ // FeedbackPressProvider it feeds.
24
26
  function useShellFeedbackSounds(): FeedbackSounds {
25
- const selection = useAudioPool(require('../../assets/sounds/select.wav'))
26
- const notification = useAudioPool(require('../../assets/sounds/notification.wav'))
27
+ const enabled = useSelector((state: ShellState) => state.sound.enabled)
28
+ const selection = useAudioPool(require('../../assets/sounds/select.wav'), { enabled })
29
+ const notification = useAudioPool(require('../../assets/sounds/notification.wav'), { enabled })
27
30
  return { selection, notification }
28
31
  }
29
32