@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/README.md CHANGED
@@ -131,7 +131,7 @@ PuckTastic and DuelTastic draw what they always did:
131
131
  | `foreground?` | The color of what those screens draw straight on the background (the hero, the corner buttons, headers), and at half strength a loadout's muted options. Unset is black or white with the theme. |
132
132
  | `Provider?` | Mounted once around How to Play and the stack, inside the store, the theme, profiles and every game's `Provider` (one stats context across the pack's games). |
133
133
  | `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`. They also slide a replaced screen in as a pop (`animationTypeForReplace: 'pop'`) on every screen but a play screen, since a replace there is a way back with nothing beneath to pop to (`safeBack`'s fallback to Home, a `dismissTo` whose screen isn't on the stack). |
134
- | `useFeedbackSounds?` | A hook returning the two sounds every button plays (`FeedbackSounds`: `selection`, `notification`), in place of the shell's two wavs. |
134
+ | `useFeedbackSounds?` | A hook returning the two sounds every button plays (`FeedbackSounds`: `selection`, `notification`), in place of the shell's two wavs. The shell's own make no players while Sound is off; a pack's pools can do the same with `useAudioPool`'s `enabled`, read from the store (`state.sound.enabled`), since the hook runs above feedback-press's provider. |
135
135
  | `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. |
136
136
  | `edgeGuard?` | `false` leaves Edge Guard out of Settings (no edge controls, no Edge Guard plugin), and out of the play screens' options on Android. |
137
137
  | `seatTheme?` | `(colors, dark) => ({ color, harmony })`: the theme the seats' colors make (a muted seed from seat 1's color), applied whenever they or dark mode change and as a fresh install's theme, in place of a triad of the raw colors. With it, `useSeatColors` reads each seat's color from where it's remembered (`seatColors`) rather than from the theme. |
@@ -149,7 +149,7 @@ PuckTastic and DuelTastic draw what they always did:
149
149
  | `usePickerAlign?` | `(open, contentWidth, contentHeight) => AlignResult` (`PickerAlign`), a hook: where seat 1's menu on Home, both seat buttons' menus in a loadout's one-human row (2 Player keeps each menu in its own player's half) and the stats screen's two pickers open. It was added because hud's own placement measured a button in a frame turned by `@tastic/core`'s drawn rotation against the upright window (Solitaire's `useFrameAutoAlign`); nothing turns since core 0.15, so a pack may no longer need one. (A profile's color swatch used it too, until the swatches moved onto the Edit Profile screen.) Unset is hud's placement. |
150
150
  | `resumeHref?` | `(gameId) => Href \| null`: where a cold launch goes back into a resumable game, for a pack with more than one way to be playing it. Null, or unset, is the game's play screen. |
151
151
  | `homePlayerPicker?` | `false` leaves seat 1's button off Home, for a pack whose every game opens a loadout, where the player is picked anyway. |
152
- | `homeTabs?` | Tabs splitting Home's games (`HomeTab`: a `label`, and `includes(game)`, which of the pack's games it shows, in the pack's order): a switch under seat 1's button, or over the grid on a wide screen, on the theme's surface over a `Backdrop`, showing one tab's games at a time. It opens on the first tab and keeps the one picked while Home is covered or the window changes. The other tabs' games stay mounted, hidden, so a switch draws nothing new. A game no tab includes isn't on Home. Unset, or a single tab, shows every game with no switch. Solitaire's: Solitaire (no `seatTwo`) and Two Player. The stats screen's game picker groups its games by them too: All Games, then a row per tab opening its page of an All row (the pill then reads the tab's name) and its games. |
152
+ | `homeTabs?` | Tabs splitting Home's games (`HomeTab`: a `label`, and `includes(game)`, which of the pack's games it shows, in the pack's order): a switch under seat 1's button, or over the grid on a wide screen, on the theme's surface over a `Backdrop`, showing one tab's games at a time. It opens on the first tab and keeps the one picked while Home is covered or the window changes. The other tabs' games are built once Home has been on screen a moment (at once on the web, or when their tab is picked), and stay mounted, hidden, so a switch draws nothing new. A game no tab includes isn't on Home. Unset, or a single tab, shows every game with no switch. Solitaire's: Solitaire (no `seatTwo`) and Two Player. The stats screen's game picker groups its games by them too: All Games, then a row per tab opening its page of an All row (the pill then reads the tab's name) and its games. |
153
153
 
154
154
  ### `GameDefinition`
155
155
 
@@ -392,7 +392,7 @@ what the shell started using (noted in the table).
392
392
  | `react`, `react-native` | >=19.3.0, >=0.88.0 | everything |
393
393
  | `expo-router` | >=58.0.23 | the stack, the routes, `safeBack`, focus effects, the web tab title |
394
394
  | `expo-font`, `@expo/vector-icons` | >=58.0.8, >=15.1.1 | the icon font and the pack's `fonts`, behind the splash screen |
395
- | `expo-splash-screen`, `@rific/splash-gate` | >=58.0.10, >=0.2.3 | holding the splash screen until the theme, fonts and profiles are ready |
395
+ | `expo-splash-screen`, `@rific/splash-gate` | >=58.0.10, >=0.2.3 | holding the splash screen until the theme, fonts and profiles are ready and the first screen is drawn |
396
396
  | `expo-constants` | >=58.0.12 | the web tab title |
397
397
  | `expo-blur`, `@react-native-masked-view/masked-view` | >=58.0.4, >=0.3.2 | auto-paper's blur and its scroll fade, Home's fading scrollers |
398
398
  | `expo-haptics`, `expo-keep-awake` | >=58.0.7, >=58.0.3 | the toaster's haptics, Keep Awake |
@@ -402,7 +402,7 @@ what the shell started using (noted in the table).
402
402
  | `@reduxjs/toolkit`, `redux`, `react-redux`, `redux-persist`, `@react-native-async-storage/async-storage` | >=2.13.0, >=5.0.1, >=9.3.0, >=6.0.0, >=2.2.0 | the store and where it's saved |
403
403
  | `@rific/auto-paper` | >=0.13.4 | the theme |
404
404
  | `@rific/core` | >=0.5.0 | settings slices, Keep Awake, `safeBack` |
405
- | `@rific/feedback-press` | >=0.13.1 | haptic and sound settings, the UI sounds |
405
+ | `@rific/feedback-press` | >=0.15.0 | haptic and sound settings, the UI sounds |
406
406
  | `@rific/toaster` | >=0.10.1 | toasts |
407
407
  | `@tastic/core` | >=0.16.0 | the seat mode from the window's shape, the root background, the test for a computer behind `useAtComputer` (0.16.0's `useIsTouchPrimaryDevice`) |
408
408
  | `@tastic/hud` | >=0.37.0 | Settings, the stats screen, the loadout's panels (its Skia-free `/lobby` entry, new in 0.26.0; 0.27.1's options for a pack drawn on its own backdrop; 0.28.0's Ready pill; 0.29.0's leading Settings sections), How to Play, and `ScreenFrame` around the stats screen, Profiles, Edit Profile and the toaster (0.34.0, where `RotatedFrame` became `ScreenFrame`), a pack's lettering (0.35.0's `LetteringProvider`), Settings' Profile row (0.37.0's `profilesRow`) |
package/dist/index.js CHANGED
@@ -125,7 +125,7 @@ var import_react_native = require("react-native");
125
125
 
126
126
  // src/splashGate.ts
127
127
  var import_splash_gate = require("@rific/splash-gate");
128
- var { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = (0, import_splash_gate.createGate)(["theme", "fonts", "profiles"]);
128
+ var { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = (0, import_splash_gate.createGate)(["theme", "fonts", "profiles", "screen"]);
129
129
 
130
130
  // src/components/Fonts.tsx
131
131
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -252,8 +252,9 @@ var import_react_redux2 = require("react-redux");
252
252
  var import_react4 = require("redux-persist/integration/react");
253
253
  var import_jsx_runtime4 = require("react/jsx-runtime");
254
254
  function useShellFeedbackSounds() {
255
- const selection = (0, import_audio.useAudioPool)(require("./select-MLBNNA4N.wav"));
256
- const notification = (0, import_audio.useAudioPool)(require("./notification-CGGFPYK7.wav"));
255
+ const enabled = (0, import_react_redux2.useSelector)((state) => state.sound.enabled);
256
+ const selection = (0, import_audio.useAudioPool)(require("./select-MLBNNA4N.wav"), { enabled });
257
+ const notification = (0, import_audio.useAudioPool)(require("./notification-CGGFPYK7.wav"), { enabled });
257
258
  return { selection, notification };
258
259
  }
259
260
  var FeedbackBridge = ({ children }) => {
@@ -372,8 +373,15 @@ function LastActiveGameProvider({ children }) {
372
373
  const [initial] = (0, import_react7.useState)(() => store.getState().lastActiveGame?.gameId ?? null);
373
374
  const pendingResume = (0, import_react7.useRef)(initial);
374
375
  const persisted = (0, import_react7.useRef)(initial);
375
- const value = (0, import_react7.useMemo)(
376
- () => ({
376
+ const resume = (0, import_react7.useRef)("idle");
377
+ const resumeListeners = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
378
+ const value = (0, import_react7.useMemo)(() => {
379
+ const setResume = (next) => {
380
+ if (resume.current === next) return;
381
+ resume.current = next;
382
+ resumeListeners.current.forEach((listener) => listener());
383
+ };
384
+ return {
377
385
  consumeResumeGame: () => {
378
386
  const game = pendingResume.current;
379
387
  pendingResume.current = null;
@@ -393,10 +401,20 @@ function LastActiveGameProvider({ children }) {
393
401
  if (persisted.current === null) return;
394
402
  persisted.current = null;
395
403
  dispatch(lastActiveGameActions.setGameId(null));
404
+ },
405
+ beginResume: () => setResume("opening"),
406
+ playScreenUp: () => {
407
+ if (resume.current === "opening") setResume("up");
408
+ },
409
+ endResume: () => setResume("idle"),
410
+ resumeState: () => resume.current,
411
+ subscribeResume: (listener) => {
412
+ const listeners = resumeListeners.current;
413
+ listeners.add(listener);
414
+ return () => void listeners.delete(listener);
396
415
  }
397
- }),
398
- [dispatch]
399
- );
416
+ };
417
+ }, [dispatch]);
400
418
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LastActiveGameContext.Provider, { value, children });
401
419
  }
402
420
  function useLastActiveGame() {
@@ -494,8 +512,44 @@ var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
494
512
  var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
495
513
  var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
496
514
  var noScreenOptions = () => ({});
515
+ function useFirstScreenGate() {
516
+ const { resumeState, subscribeResume } = useLastActiveGame();
517
+ const marked = (0, import_react9.useRef)(false);
518
+ return (0, import_react9.useCallback)(() => {
519
+ if (marked.current) return;
520
+ marked.current = true;
521
+ const mark = () => requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
522
+ requestAnimationFrame(
523
+ () => requestAnimationFrame(() => {
524
+ if (resumeState() !== "opening") {
525
+ markSplashReady("screen");
526
+ return;
527
+ }
528
+ const unsubscribe = subscribeResume(() => {
529
+ if (resumeState() === "opening") return;
530
+ unsubscribe();
531
+ mark();
532
+ });
533
+ })
534
+ );
535
+ }, [resumeState, subscribeResume]);
536
+ }
537
+ function useResumeShown() {
538
+ const { endResume } = useLastActiveGame();
539
+ return (0, import_react9.useCallback)(
540
+ ({ route }) => ({
541
+ transitionEnd: (event) => {
542
+ if (route.name === PLAY_ROUTE && !event.data?.closing) endResume();
543
+ }
544
+ }),
545
+ [endResume]
546
+ );
547
+ }
548
+ var PLAY_ROUTE = "play/[game]";
497
549
  function AppStack() {
498
550
  const pack = usePack();
551
+ const onFirstLayout = useFirstScreenGate();
552
+ const screenListeners = useResumeShown();
499
553
  const { Backdrop } = pack;
500
554
  const { dark } = (0, import_auto_paper2.useAutoPaperTheme)();
501
555
  const darkRoot = Backdrop ? true : dark;
@@ -519,14 +573,12 @@ function AppStack() {
519
573
  const base = darkRoot ? import_expo_router.DarkTheme : import_expo_router.DefaultTheme;
520
574
  return { ...base, colors: { ...base.colors, background: navigationBackground } };
521
575
  }, [darkRoot, navigationBackground]);
522
- const stack = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.ThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_expo_router.Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
523
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: "index" }),
524
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: "play/[game]", options: playOptions })
525
- ] }) });
526
- if (!Backdrop) return stack;
527
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native3.View, { style: styles.root, children: [
528
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Backdrop, {}),
529
- stack
576
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native3.View, { style: styles.root, onLayout: onFirstLayout, children: [
577
+ Backdrop && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Backdrop, {}),
578
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.ThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_expo_router.Stack, { screenListeners, screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
579
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: "index" }),
580
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: PLAY_ROUTE, options: playOptions })
581
+ ] }) })
530
582
  ] });
531
583
  }
532
584
  function GatedApp({ children }) {
@@ -1122,10 +1174,20 @@ function PlayRoute() {
1122
1174
  const { game: id } = (0, import_expo_router8.useLocalSearchParams)();
1123
1175
  const game = usePackGame(id);
1124
1176
  useResumePoint(game?.resumable ? game.id : null);
1177
+ useResumeUp();
1125
1178
  if (!game) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_expo_router8.Redirect, { href: "/" });
1126
1179
  const { PlayScreen } = game;
1127
1180
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PlayScreen, {}, game.id);
1128
1181
  }
1182
+ function useResumeUp() {
1183
+ const { playScreenUp } = useLastActiveGame();
1184
+ (0, import_react14.useEffect)(() => {
1185
+ let frame = requestAnimationFrame(() => {
1186
+ frame = requestAnimationFrame(playScreenUp);
1187
+ });
1188
+ return () => cancelAnimationFrame(frame);
1189
+ }, [playScreenUp]);
1190
+ }
1129
1191
  var playScreensUp = 0;
1130
1192
  function useResumePoint(gameId) {
1131
1193
  const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame();
@@ -1260,11 +1322,24 @@ function useResume(game) {
1260
1322
  );
1261
1323
  }
1262
1324
  function useMenuShown(resuming) {
1325
+ const { beginResume, endResume, resumeState, subscribeResume } = useLastActiveGame();
1263
1326
  const isFocused = (0, import_expo_router9.useIsFocused)();
1264
1327
  const [covered, setCovered] = (0, import_react16.useState)(false);
1265
1328
  if (resuming && !covered && !isFocused) setCovered(true);
1266
- return (0, import_react16.useDeferredValue)(!resuming || covered);
1329
+ (0, import_react16.useLayoutEffect)(() => {
1330
+ if (!resuming) return;
1331
+ beginResume();
1332
+ const id = setTimeout(endResume, RESUME_SHOWN_MAX_MS);
1333
+ return () => {
1334
+ clearTimeout(id);
1335
+ endResume();
1336
+ };
1337
+ }, [resuming, beginResume, endResume]);
1338
+ const onItsWay = (0, import_react16.useSyncExternalStore)(subscribeResume, resumeState, resumeState) !== "idle";
1339
+ const gameShown = covered && !onItsWay;
1340
+ return (0, import_react16.useDeferredValue)(!resuming || gameShown || covered && isFocused);
1267
1341
  }
1342
+ var RESUME_SHOWN_MAX_MS = 4e3;
1268
1343
  function HomeMenu() {
1269
1344
  const pack = usePack();
1270
1345
  const showPicker = pack.homePlayerPicker !== false;
@@ -1308,6 +1383,10 @@ function HomeMenu() {
1308
1383
  const tab = tabs ? tabs.find((t) => t.label === tabLabel) ?? tabs[0] : null;
1309
1384
  const tabButtons = (0, import_react16.useMemo)(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle]);
1310
1385
  const tabBar = tab && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.SegmentedButtons, { value: tab.label, onValueChange: setTabLabel, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles4.tabs, pack.Backdrop && { backgroundColor: colors.surface }] });
1386
+ const panes = (0, import_react16.useMemo)(() => tabs ? tabs.map((t) => ({ key: t.label, games: pack.games.filter(t.includes) })) : [{ key: ALL_GAMES, games: pack.games }], [tabs, pack.games]);
1387
+ const shownPane = tab?.label ?? ALL_GAMES;
1388
+ const { width: fitWidth, height: fitHeight } = layout.heroFit ?? NO_FIT;
1389
+ const hero = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(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]);
1311
1390
  const columnClamp = useClampOnShrink();
1312
1391
  const gridClamp = useClampOnShrink();
1313
1392
  const openGame = (0, import_react16.useCallback)((game) => openFirstTime(game.id, () => import_expo_router9.router.push(game.useLoadout ? loadoutHref(game.id) : playHref(game.id))), [openFirstTime]);
@@ -1321,23 +1400,23 @@ function HomeMenu() {
1321
1400
  const RulesSheet = rulesGame?.Rules;
1322
1401
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { style: [styles4.container, { backgroundColor: bg }], children: [
1323
1402
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: styles4.frame, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(RulesHost, { enabled: pack.games.some((game) => game.Rules), children: [
1324
- isWide ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1403
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PreviewsRevealed, { value: previewsRevealed, children: isWide ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1325
1404
  pressAway,
1326
1405
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_auto_paper6.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: [
1327
1406
  tabBar && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: [styles4.wideTabs, { width: layout.rightPaneWidth }], children: tabBar }),
1328
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: [styles4.grid, { width: layout.rightPaneWidth }], children: pack.games.map((game) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(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)) })
1407
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: { width: layout.rightPaneWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.grid, children: (games, built) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameGrid, { games, built, width: layout.tileWidth, previewWidth: layout.previewWidth, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
1329
1408
  ] }),
1330
1409
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { 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: [
1331
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive, fit: layout.heroFit }),
1410
+ hero,
1332
1411
  showPicker && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: styles4.widePicker, children: picker })
1333
1412
  ] })
1334
1413
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_auto_paper6.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: [
1335
1414
  pressAway,
1336
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive }),
1415
+ hero,
1337
1416
  showPicker && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
1338
1417
  tabBar && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: styles4.listWidth, children: tabBar }),
1339
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: styles4.list, children: pack.games.map((game) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameRow, { game, hidden: isHidden(tab, game), dark, p1Color, p2Color, previewRevealed: previewsRevealed, onPress: () => openGame(game), onRules: hasRules(game) ? () => openRules(game) : void 0 }, game.id)) })
1340
- ] }),
1418
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: styles4.listWidth, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.list, children: (games, built) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameList, { games, built, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
1419
+ ] }) }),
1341
1420
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.IconButton, { icon: "trophy", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, left: 8 + insets.left }], onPress: () => import_expo_router9.router.push(STATS_HREF), accessibilityLabel: "Stats & Achievements" }),
1342
1421
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.IconButton, { icon: "cog", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, right: 8 + insets.right }], onPress: () => setSettingsOpen(true), accessibilityLabel: "Settings" }),
1343
1422
  RulesSheet && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RulesSheet, { visible: true, onDismiss: () => setRulesGame(null) })
@@ -1347,9 +1426,36 @@ function HomeMenu() {
1347
1426
  }
1348
1427
  var SEAT_ONE_PICKER = "home-p1";
1349
1428
  var noPickerAlign = () => void 0;
1350
- function isHidden(tab, game) {
1351
- return !!tab && !tab.includes(game);
1429
+ var NO_FIT = { height: 0 };
1430
+ var ALL_GAMES = "__all__";
1431
+ function TabPanes({ panes, shown, buildOthers, style, children }) {
1432
+ const mostGames = Math.max(...panes.map(({ games }) => games.length));
1433
+ const builtGames = useBuiltGames(shown, mostGames, buildOthers && panes.length > 1);
1434
+ return panes.map(({ key, games }) => {
1435
+ const built = builtGames(key);
1436
+ if (built === 0) return null;
1437
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TabPane, { shown: key === shown, style, children: children(games, built) }, key);
1438
+ });
1352
1439
  }
1440
+ function useBuiltGames(shown, total, buildOthers) {
1441
+ const [picked, setPicked] = (0, import_react16.useState)([shown]);
1442
+ if (!picked.includes(shown)) setPicked([...picked, shown]);
1443
+ const [others, setOthers] = (0, import_react16.useState)(import_react_native9.Platform.OS === "web" ? total : 0);
1444
+ const building = buildOthers && others < total;
1445
+ (0, import_react16.useEffect)(() => {
1446
+ if (!building) return;
1447
+ const id = setTimeout(() => (0, import_react16.startTransition)(() => setOthers(others + 1)), others === 0 ? OTHER_PANES_DELAY_MS : OTHER_PANES_STEP_MS);
1448
+ return () => clearTimeout(id);
1449
+ }, [building, others]);
1450
+ return (pane) => pane === shown || picked.includes(pane) ? total : others;
1451
+ }
1452
+ var OTHER_PANES_DELAY_MS = 1200;
1453
+ var OTHER_PANES_STEP_MS = 150;
1454
+ function TabPane({ shown, style, children }) {
1455
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { collapsable: false, "aria-hidden": !shown, style: [style, !shown && styles4.paneHidden], children });
1456
+ }
1457
+ var PreviewsRevealedContext = (0, import_react16.createContext)(false);
1458
+ var PreviewsRevealed = PreviewsRevealedContext.Provider;
1353
1459
  function useClampOnShrink() {
1354
1460
  const view = (0, import_react16.useRef)(null);
1355
1461
  const sizes = (0, import_react16.useRef)({ viewport: 0, offset: 0 });
@@ -1381,39 +1487,46 @@ function hasRules(game) {
1381
1487
  function RulesHost({ enabled, children }) {
1382
1488
  return enabled ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Portal.Host, { children }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children });
1383
1489
  }
1490
+ var GameList = (0, import_react16.memo)(function GameList2({ games, built, ...rest }) {
1491
+ return games.slice(0, built).map((game) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameRow, { game, ...rest }, game.id));
1492
+ });
1493
+ var GameGrid = (0, import_react16.memo)(function GameGrid2({ games, built, ...rest }) {
1494
+ return games.slice(0, built).map((game) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameTile, { game, ...rest }, game.id));
1495
+ });
1384
1496
  var ROW_BLURB_LINES = 3;
1385
- function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1497
+ var GameRow = (0, import_react16.memo)(function GameRow2({ game, dark, p1Color, p2Color, onOpen, onRules }) {
1386
1498
  const { titleStyle } = usePack();
1387
1499
  const well = (0, import_chrome7.useWellColors)();
1388
1500
  const GameIcon = game.icon;
1389
1501
  return (
1390
1502
  // The rules button sits beside the row's own button, laid over its end, not inside it: a button
1391
1503
  // inside a button is invalid on the web.
1392
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { style: hidden ? styles4.hidden : void 0, children: [
1393
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_feedback_press3.Pressable, { onPress, style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1394
- game.Preview ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, revealed: previewRevealed, dark, p1Color, p2Color }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
1504
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { children: [
1505
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_feedback_press3.Pressable, { onPress: () => onOpen(game), style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1506
+ game.Preview ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, dark, p1Color, p2Color }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
1395
1507
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { style: styles4.rowText, children: [
1396
1508
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1397
1509
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
1398
1510
  ] })
1399
1511
  ] }),
1400
- onRules && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: onRules, style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
1512
+ hasRules(game) && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: () => onRules(game), style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
1401
1513
  ] })
1402
1514
  );
1403
- }
1404
- function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1515
+ });
1516
+ var GameTile = (0, import_react16.memo)(function GameTile2({ game, width, previewWidth, dark, p1Color, p2Color, onOpen, onRules }) {
1405
1517
  const { titleStyle } = usePack();
1406
1518
  const well = (0, import_chrome7.useWellColors)();
1407
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { style: [{ width }, hidden && styles4.hidden], children: [
1408
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_feedback_press3.Pressable, { onPress, style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1409
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PreviewBox, { game, width: previewWidth, revealed: previewRevealed, dark, p1Color, p2Color }),
1519
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { style: { width }, children: [
1520
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_feedback_press3.Pressable, { onPress: () => onOpen(game), style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1521
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PreviewBox, { game, width: previewWidth, dark, p1Color, p2Color }),
1410
1522
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1411
1523
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
1412
1524
  ] }),
1413
- onRules && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: onRules, style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
1525
+ hasRules(game) && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: () => onRules(game), style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
1414
1526
  ] });
1415
- }
1416
- function PreviewBox({ game, width, revealed, dark, p1Color, p2Color }) {
1527
+ });
1528
+ function PreviewBox({ game, width, dark, p1Color, p2Color }) {
1529
+ const revealed = (0, import_react16.useContext)(PreviewsRevealedContext);
1417
1530
  const height = Math.round(width / PREVIEW_ASPECT);
1418
1531
  const { Preview, icon: GameIcon } = game;
1419
1532
  const iconSize = Math.min(height, ROW_ICON_SIZE);
@@ -1443,21 +1556,21 @@ var styles4 = import_react_native9.StyleSheet.create({
1443
1556
  flexWrap: "wrap",
1444
1557
  gap: HOME_GRID_GAP
1445
1558
  },
1446
- // Out of the layout (a grid closes up around it) and hidden from screen readers.
1447
- hidden: {
1448
- display: "none"
1449
- },
1450
- // Solitaire's list: one column, never wider than a phone's, centred on a wide screen.
1559
+ // Solitaire's list: one column.
1451
1560
  list: {
1452
- gap: 14,
1453
- maxWidth: 480,
1454
- width: "100%"
1561
+ gap: 14
1455
1562
  },
1456
- // The list's width, for the tabs over it.
1563
+ // The list's width, and the tabs' over it: never wider than a phone's, centred on a wide screen.
1457
1564
  listWidth: {
1458
1565
  maxWidth: 480,
1459
1566
  width: "100%"
1460
1567
  },
1568
+ // A tab's pane that isn't shown (TabPane): out of the layout, over the shown pane's place, drawing
1569
+ // nothing.
1570
+ paneHidden: import_react_native9.Platform.select({
1571
+ web: { display: "none" },
1572
+ default: { left: 0, opacity: 0, pointerEvents: "none", position: "absolute", right: 0, top: 0 }
1573
+ }),
1461
1574
  picker: {
1462
1575
  alignItems: "center"
1463
1576
  },
@@ -1586,7 +1699,7 @@ var TABS = [
1586
1699
  var LABEL_WIDE_TAB = { flex: 0, flexBasis: "auto", flexGrow: 1, flexShrink: 1 };
1587
1700
  var NO_PACK_TABS = [];
1588
1701
  var EVERYONE = "__everyone__";
1589
- var ALL_GAMES = "__all__";
1702
+ var ALL_GAMES2 = "__all__";
1590
1703
  var tabGroup = (index) => `__tab-group-${index}__`;
1591
1704
  var tabGames = (index) => `__tab-${index}__`;
1592
1705
  var PLAYER_PICKER_ID = "stats-player";
@@ -1612,22 +1725,22 @@ function StatsContent({ pickerHost }) {
1612
1725
  const dispatch = (0, import_react_redux10.useDispatch)();
1613
1726
  const fg = pack.foreground ?? colors.onBackground;
1614
1727
  const [tab, setTab] = (0, import_react17.useState)(STATS);
1615
- const [gameId, setGameId] = (0, import_react17.useState)(ALL_GAMES);
1728
+ const [gameId, setGameId] = (0, import_react17.useState)(ALL_GAMES2);
1616
1729
  const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
1617
1730
  const statsPlayer = useStatsPlayer();
1618
1731
  const [selectedProfileId, setSelectedProfileId] = (0, import_react17.useState)(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
1619
1732
  const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
1620
1733
  const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
1621
1734
  const pickedTab = homeTabs?.findIndex((_, index) => gameId === tabGames(index)) ?? -1;
1622
- const games = gameId === ALL_GAMES ? pack.games : pickedTab >= 0 ? pack.games.filter((g) => homeTabs[pickedTab].includes(g)) : pack.games.filter((g) => g.id === gameId);
1623
- const gameIds = gameId === ALL_GAMES ? null : games.map((g) => g.id);
1624
- const oneGameId = gameId === ALL_GAMES || pickedTab >= 0 ? null : gameId;
1735
+ const games = gameId === ALL_GAMES2 ? pack.games : pickedTab >= 0 ? pack.games.filter((g) => homeTabs[pickedTab].includes(g)) : pack.games.filter((g) => g.id === gameId);
1736
+ const gameIds = gameId === ALL_GAMES2 ? null : games.map((g) => g.id);
1737
+ const oneGameId = gameId === ALL_GAMES2 || pickedTab >= 0 ? null : gameId;
1625
1738
  const packTabs = pack.statsTabs ?? NO_PACK_TABS;
1626
1739
  const packTab = packTabs.find((t) => t.value === tab);
1627
1740
  const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
1628
1741
  const playerOptions = (0, import_react17.useMemo)(() => [{ 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]);
1629
1742
  const gameOptions = (0, import_react17.useMemo)(() => {
1630
- const all = { value: ALL_GAMES, label: "All Games", icon: "view-grid-outline" };
1743
+ const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
1631
1744
  const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
1632
1745
  if (!homeTabs) return [all, ...pack.games.map(option)];
1633
1746
  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)] }))];