@tastic/shell 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -9
- package/dist/index.d.mts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +421 -400
- package/dist/index.mjs +341 -321
- package/package.json +1 -1
- package/src/components/GuideCards.tsx +63 -0
- package/src/components/GuideHost.tsx +36 -97
- package/src/components/StartGuide.tsx +46 -0
- package/src/index.ts +1 -0
- package/src/screens/GameRoute.tsx +10 -2
- package/src/screens/HomeScreen.tsx +4 -9
- package/src/types.ts +20 -11
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
|
|
34
|
+
import { useCallback as useCallback7, useMemo as useMemo4, useRef as useRef2 } 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";
|
|
@@ -60,10 +60,14 @@ function Fonts({ children }) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// src/components/GuideHost.tsx
|
|
63
|
+
import { createContext as createContext2, useCallback as useCallback2, useContext as useContext2, useMemo as useMemo2, useState } from "react";
|
|
64
|
+
import { useStore } from "react-redux";
|
|
65
|
+
|
|
66
|
+
// src/components/GuideCards.tsx
|
|
63
67
|
import { useIsTouchPrimaryDevice } from "@tastic/core";
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import { shallowEqual, useDispatch, useSelector
|
|
68
|
+
import { HowToPlayDialog } from "@tastic/hud/guide";
|
|
69
|
+
import { useCallback, useMemo } from "react";
|
|
70
|
+
import { shallowEqual, useDispatch, useSelector } from "react-redux";
|
|
67
71
|
|
|
68
72
|
// src/types.ts
|
|
69
73
|
function roundModeFor(seatTwo) {
|
|
@@ -79,81 +83,71 @@ function humanSeatsFor(mode) {
|
|
|
79
83
|
}
|
|
80
84
|
var GUEST_PLAYER_ID = "guest";
|
|
81
85
|
|
|
82
|
-
// src/components/
|
|
86
|
+
// src/components/GuideCards.tsx
|
|
83
87
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
84
88
|
var PACK_GUIDE = "__pack__";
|
|
89
|
+
function startSubject(pack, game) {
|
|
90
|
+
if (game.guide) return game.guide.atStart ? game.id : null;
|
|
91
|
+
return pack.guide ? PACK_GUIDE : null;
|
|
92
|
+
}
|
|
93
|
+
function guideFor(pack, subject) {
|
|
94
|
+
return subject === PACK_GUIDE ? pack.guide : pack.games.find((g) => g.id === subject)?.guide;
|
|
95
|
+
}
|
|
85
96
|
var NO_INPUT = {};
|
|
86
|
-
|
|
87
|
-
function GuideHost({ children }) {
|
|
97
|
+
function GuideCards({ subject, visible, onClose }) {
|
|
88
98
|
const pack = usePack();
|
|
89
|
-
const [subject, setSubject] = useState(() => pack.guide ? PACK_GUIDE : pack.games.find((g) => g.guide)?.id ?? null);
|
|
90
99
|
const packGuide = subject === PACK_GUIDE ? pack.guide : void 0;
|
|
91
100
|
const game = subject === PACK_GUIDE ? void 0 : pack.games.find((g) => g.id === subject);
|
|
92
101
|
const gameGuide = game?.guide;
|
|
102
|
+
const guide = packGuide ?? gameGuide;
|
|
93
103
|
const touch = useIsTouchPrimaryDevice();
|
|
94
104
|
const seatTwo = useSelector((state) => state.opponent.seatTwo);
|
|
95
105
|
const input = useSelector((state) => gameGuide ? gameGuide.selectInput(state) : NO_INPUT, shallowEqual);
|
|
96
|
-
const
|
|
106
|
+
const seen = useSelector((state) => !guide || guide.selectVersionSeen(state) >= guide.version);
|
|
97
107
|
const dispatch = useDispatch();
|
|
98
108
|
const mode = roundModeFor(seatTwoFor(seatTwo, game?.seatTwo));
|
|
99
109
|
const steps = useMemo(() => packGuide ? packGuide.getSteps({ touch }) : gameGuide ? gameGuide.getSteps(input, { touch, mode }) : [], [packGuide, gameGuide, input, touch, mode]);
|
|
100
|
-
const
|
|
101
|
-
(version)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
);
|
|
107
|
-
return /* @__PURE__ */ jsx3(GuideProvider, { steps, currentVersion: (packGuide ?? gameGuide)?.version ?? 0, seenVersion, onSeen, children: /* @__PURE__ */ jsx3(GameGuideBridge, { onPick: setSubject, children }) });
|
|
110
|
+
const close = useCallback(() => {
|
|
111
|
+
if (guide && !seen) dispatch(guide.markSeen(guide.version));
|
|
112
|
+
onClose?.();
|
|
113
|
+
}, [guide, seen, dispatch, onClose]);
|
|
114
|
+
const Dialog = pack.HowToPlay ?? HowToPlayDialog;
|
|
115
|
+
return /* @__PURE__ */ jsx3(Dialog, { visible, steps, onFinish: close, onSkip: close });
|
|
108
116
|
}
|
|
109
|
-
|
|
117
|
+
|
|
118
|
+
// src/components/GuideHost.tsx
|
|
119
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
120
|
+
var GameGuideContext = createContext2(null);
|
|
121
|
+
function GuideHost({ children }) {
|
|
110
122
|
const pack = usePack();
|
|
111
123
|
const store = useStore();
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const wasOpen = useRef(false);
|
|
115
|
-
const packAutoShown = useRef(false);
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
if (wasOpen.current && !isOpen && pendingNext.current) {
|
|
118
|
-
const next = pendingNext.current;
|
|
119
|
-
pendingNext.current = null;
|
|
120
|
-
next();
|
|
121
|
-
}
|
|
122
|
-
wasOpen.current = isOpen;
|
|
123
|
-
}, [isOpen]);
|
|
124
|
-
const openFor = useCallback(
|
|
124
|
+
const [shown, setShown] = useState(null);
|
|
125
|
+
const openFor = useCallback2(
|
|
125
126
|
(gameId) => {
|
|
126
|
-
if (
|
|
127
|
-
onPick(gameId);
|
|
128
|
-
open();
|
|
127
|
+
if (guideFor(pack, gameId)) setShown({ subject: gameId });
|
|
129
128
|
},
|
|
130
|
-
[pack
|
|
129
|
+
[pack]
|
|
131
130
|
);
|
|
132
|
-
const openFirstTime =
|
|
131
|
+
const openFirstTime = useCallback2(
|
|
133
132
|
(gameId, next) => {
|
|
134
133
|
const guide = pack.games.find((g) => g.id === gameId)?.guide;
|
|
135
|
-
if (!guide || guide.selectVersionSeen(store.getState()) >= guide.version)
|
|
136
|
-
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
pendingNext.current = next;
|
|
140
|
-
openFor(gameId);
|
|
134
|
+
if (!guide || guide.atStart || guide.selectVersionSeen(store.getState()) >= guide.version) next();
|
|
135
|
+
else setShown({ subject: gameId, next });
|
|
141
136
|
},
|
|
142
|
-
[pack, store
|
|
137
|
+
[pack, store]
|
|
143
138
|
);
|
|
144
|
-
const openPack =
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return /* @__PURE__ */ jsx3(GameGuideContext.Provider, { value, children });
|
|
139
|
+
const openPack = useCallback2(() => {
|
|
140
|
+
if (pack.guide) setShown({ subject: PACK_GUIDE });
|
|
141
|
+
}, [pack]);
|
|
142
|
+
const handleClose = useCallback2(() => {
|
|
143
|
+
setShown(null);
|
|
144
|
+
shown?.next?.();
|
|
145
|
+
}, [shown]);
|
|
146
|
+
const value = useMemo2(() => ({ openFirstTime, openFor, openPack }), [openFirstTime, openFor, openPack]);
|
|
147
|
+
return /* @__PURE__ */ jsxs2(GameGuideContext.Provider, { value, children: [
|
|
148
|
+
children,
|
|
149
|
+
shown && /* @__PURE__ */ jsx4(GuideCards, { subject: shown.subject, visible: true, onClose: handleClose })
|
|
150
|
+
] });
|
|
157
151
|
}
|
|
158
152
|
function useGameGuide() {
|
|
159
153
|
const ctx = useContext2(GameGuideContext);
|
|
@@ -167,11 +161,11 @@ import { FeedbackPressProvider, hapticActions, soundActions, useFeedbackBridgePr
|
|
|
167
161
|
import { useAudioPool } from "@rific/feedback-press/audio";
|
|
168
162
|
import { useEdgeGestureGuard } from "@tastic/edge-guard";
|
|
169
163
|
import * as ExpoKeepAwake from "expo-keep-awake";
|
|
170
|
-
import { useCallback as
|
|
164
|
+
import { useCallback as useCallback3 } from "react";
|
|
171
165
|
import * as RNPaper from "react-native-paper";
|
|
172
166
|
import { Provider as ReduxProvider, useDispatch as useDispatch2, useSelector as useSelector2 } from "react-redux";
|
|
173
167
|
import { PersistGate } from "redux-persist/integration/react";
|
|
174
|
-
import { Fragment as Fragment2, jsx as
|
|
168
|
+
import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
|
|
175
169
|
function useShellFeedbackSounds() {
|
|
176
170
|
const enabled = useSelector2((state) => state.sound.enabled);
|
|
177
171
|
const selection = useAudioPool(__require("./select-MLBNNA4N.wav"), { enabled });
|
|
@@ -182,27 +176,27 @@ var FeedbackBridge = ({ children }) => {
|
|
|
182
176
|
const haptic = useSelector2((state) => state.haptic);
|
|
183
177
|
const sound = useSelector2((state) => state.sound);
|
|
184
178
|
const dispatch = useDispatch2();
|
|
185
|
-
const onChange =
|
|
186
|
-
const onSoundChange =
|
|
179
|
+
const onChange = useCallback3((next) => dispatch(hapticActions.initialize(next)), [dispatch]);
|
|
180
|
+
const onSoundChange = useCallback3((next) => dispatch(soundActions.initialize(next)), [dispatch]);
|
|
187
181
|
const { useFeedbackSounds = useShellFeedbackSounds } = usePack();
|
|
188
182
|
const sounds = useFeedbackSounds();
|
|
189
183
|
const bridgeProps = useFeedbackBridgeProps({ initialValue: haptic, onChange, soundInitialValue: sound, onSoundChange, sound: sounds });
|
|
190
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ jsx5(FeedbackPressProvider, { ...bridgeProps, paper: RNPaper, children });
|
|
191
185
|
};
|
|
192
186
|
var EdgeGuardBridge = ({ children }) => {
|
|
193
187
|
const deferBottomEdgeGestures = useSelector2((state) => state.appSettings.deferBottomEdgeGestures);
|
|
194
188
|
const activelyPlaying = useSelector2((state) => state.liveplay.activelyPlaying);
|
|
195
189
|
useEdgeGestureGuard(deferBottomEdgeGestures && activelyPlaying);
|
|
196
|
-
return /* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children });
|
|
197
191
|
};
|
|
198
192
|
var KeepAwakeBridge = ({ children }) => {
|
|
199
193
|
const keepAwake = useSelector2((state) => state.keepAwake);
|
|
200
194
|
const dispatch = useDispatch2();
|
|
201
|
-
const onChange =
|
|
202
|
-
return /* @__PURE__ */
|
|
195
|
+
const onChange = useCallback3((settings) => dispatch(keepAwakeActions.initialize(settings)), [dispatch]);
|
|
196
|
+
return /* @__PURE__ */ jsx5(KeepAwakeProvider, { expoKeepAwake: ExpoKeepAwake, initialValue: keepAwake, onChange, children });
|
|
203
197
|
};
|
|
204
198
|
function Providers({ store, persistor, children }) {
|
|
205
|
-
return /* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ jsx5(ReduxProvider, { store, children: /* @__PURE__ */ jsx5(PersistGate, { persistor, children: /* @__PURE__ */ jsx5(EdgeGuardBridge, { children: /* @__PURE__ */ jsx5(FeedbackBridge, { children: /* @__PURE__ */ jsx5(KeepAwakeBridge, { children }) }) }) }) });
|
|
206
200
|
}
|
|
207
201
|
|
|
208
202
|
// src/components/Theme.tsx
|
|
@@ -210,43 +204,43 @@ import MaskedView from "@react-native-masked-view/masked-view";
|
|
|
210
204
|
import { Provider as AutoPaperProvider, themeActions, useThemeBridgeProps } from "@rific/auto-paper";
|
|
211
205
|
import * as ExpoBlur from "expo-blur";
|
|
212
206
|
import * as SplashScreen from "expo-splash-screen";
|
|
213
|
-
import { useCallback as
|
|
207
|
+
import { useCallback as useCallback4 } from "react";
|
|
214
208
|
import Reanimated from "react-native-reanimated";
|
|
215
209
|
import { shallowEqual as shallowEqual2, useDispatch as useDispatch3, useSelector as useSelector3 } from "react-redux";
|
|
216
|
-
import { jsx as
|
|
210
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
217
211
|
SplashScreen.preventAutoHideAsync();
|
|
218
212
|
SplashScreen.setOptions({ fade: true, duration: 400 });
|
|
219
213
|
function Theme({ children }) {
|
|
220
214
|
const { fontFamily } = usePack();
|
|
221
215
|
const settings = useSelector3((state) => state.theme, shallowEqual2);
|
|
222
216
|
const dispatch = useDispatch3();
|
|
223
|
-
const onReady =
|
|
224
|
-
const onChange =
|
|
217
|
+
const onReady = useCallback4(() => markSplashReady("theme"), []);
|
|
218
|
+
const onChange = useCallback4((next) => dispatch(themeActions.initialize(next)), [dispatch]);
|
|
225
219
|
const bridgeProps = useThemeBridgeProps({ initialValue: settings, onChange, onReady });
|
|
226
|
-
return /* @__PURE__ */
|
|
220
|
+
return /* @__PURE__ */ jsx6(AutoPaperProvider, { ...bridgeProps, expoBlur: ExpoBlur, maskedView: MaskedView, statusBar: false, reanimated: Reanimated, fontFamily, children });
|
|
227
221
|
}
|
|
228
222
|
|
|
229
223
|
// src/components/UpdateDialog.tsx
|
|
230
224
|
import { useUpdateErrorToast } from "@rific/toaster";
|
|
231
225
|
import { UpdateDialog as SharedUpdateDialog } from "@tastic/hud/chrome";
|
|
232
|
-
import { jsx as
|
|
226
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
233
227
|
function UpdateDialog() {
|
|
234
228
|
const onError = useUpdateErrorToast();
|
|
235
|
-
return /* @__PURE__ */
|
|
229
|
+
return /* @__PURE__ */ jsx7(SharedUpdateDialog, { onError });
|
|
236
230
|
}
|
|
237
231
|
|
|
238
232
|
// src/components/WindowControlsInsets.tsx
|
|
239
233
|
import { Platform as Platform2 } from "react-native";
|
|
240
234
|
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
|
|
241
|
-
import { Fragment as Fragment3, jsx as
|
|
235
|
+
import { Fragment as Fragment3, jsx as jsx8 } from "react/jsx-runtime";
|
|
242
236
|
function WindowControlsInsets({ children }) {
|
|
243
237
|
const vertical = useSafeAreaInsets({ cornerAdaptation: "vertical" });
|
|
244
|
-
if (Platform2.OS !== "ios" || !Platform2.isPad) return /* @__PURE__ */
|
|
245
|
-
return /* @__PURE__ */
|
|
238
|
+
if (Platform2.OS !== "ios" || !Platform2.isPad) return /* @__PURE__ */ jsx8(Fragment3, { children });
|
|
239
|
+
return /* @__PURE__ */ jsx8(SafeAreaInsetsContext.Provider, { value: vertical, children });
|
|
246
240
|
}
|
|
247
241
|
|
|
248
242
|
// src/hooks/useAppSettings.ts
|
|
249
|
-
import { useCallback as
|
|
243
|
+
import { useCallback as useCallback5 } from "react";
|
|
250
244
|
import { useDispatch as useDispatch4, useSelector as useSelector4 } from "react-redux";
|
|
251
245
|
|
|
252
246
|
// src/redux/appSettingsSlice.ts
|
|
@@ -266,7 +260,7 @@ var appSettingsSlice_default = reducer;
|
|
|
266
260
|
function useAppSettings() {
|
|
267
261
|
const settings = useSelector4((state) => state.appSettings);
|
|
268
262
|
const dispatch = useDispatch4();
|
|
269
|
-
const setSettings =
|
|
263
|
+
const setSettings = useCallback5(
|
|
270
264
|
(patch) => {
|
|
271
265
|
dispatch(appSettingsActions.initialize(patch));
|
|
272
266
|
},
|
|
@@ -276,7 +270,7 @@ function useAppSettings() {
|
|
|
276
270
|
}
|
|
277
271
|
|
|
278
272
|
// src/hooks/useLastActiveGame.tsx
|
|
279
|
-
import { createContext as createContext3, useContext as useContext3, useMemo as
|
|
273
|
+
import { createContext as createContext3, useContext as useContext3, useMemo as useMemo3, useRef, useState as useState2 } from "react";
|
|
280
274
|
import { useDispatch as useDispatch5, useStore as useStore2 } from "react-redux";
|
|
281
275
|
|
|
282
276
|
// src/redux/lastActiveGameSlice.ts
|
|
@@ -286,17 +280,17 @@ var lastActiveGameActions = actions2;
|
|
|
286
280
|
var lastActiveGameSlice_default = reducer2;
|
|
287
281
|
|
|
288
282
|
// src/hooks/useLastActiveGame.tsx
|
|
289
|
-
import { jsx as
|
|
283
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
290
284
|
var LastActiveGameContext = createContext3(null);
|
|
291
285
|
function LastActiveGameProvider({ children }) {
|
|
292
286
|
const store = useStore2();
|
|
293
287
|
const dispatch = useDispatch5();
|
|
294
288
|
const [initial] = useState2(() => store.getState().lastActiveGame?.gameId ?? null);
|
|
295
|
-
const pendingResume =
|
|
296
|
-
const persisted =
|
|
297
|
-
const resume =
|
|
298
|
-
const resumeListeners =
|
|
299
|
-
const value =
|
|
289
|
+
const pendingResume = useRef(initial);
|
|
290
|
+
const persisted = useRef(initial);
|
|
291
|
+
const resume = useRef("idle");
|
|
292
|
+
const resumeListeners = useRef(/* @__PURE__ */ new Set());
|
|
293
|
+
const value = useMemo3(() => {
|
|
300
294
|
const setResume = (next) => {
|
|
301
295
|
if (resume.current === next) return;
|
|
302
296
|
resume.current = next;
|
|
@@ -336,7 +330,7 @@ function LastActiveGameProvider({ children }) {
|
|
|
336
330
|
}
|
|
337
331
|
};
|
|
338
332
|
}, [dispatch]);
|
|
339
|
-
return /* @__PURE__ */
|
|
333
|
+
return /* @__PURE__ */ jsx9(LastActiveGameContext.Provider, { value, children });
|
|
340
334
|
}
|
|
341
335
|
function useLastActiveGame() {
|
|
342
336
|
const ctx = useContext3(LastActiveGameContext);
|
|
@@ -346,7 +340,7 @@ function useLastActiveGame() {
|
|
|
346
340
|
|
|
347
341
|
// src/hooks/useProfiles.tsx
|
|
348
342
|
import { createProfileRecord, profilesActions, resolveInitialProfiles, useSharedProfilesSync } from "@tastic/profile";
|
|
349
|
-
import { createContext as createContext4, useCallback as
|
|
343
|
+
import { createContext as createContext4, useCallback as useCallback6, useContext as useContext4, useEffect, useState as useState3 } from "react";
|
|
350
344
|
import { useDispatch as useDispatch6, useSelector as useSelector5 } from "react-redux";
|
|
351
345
|
|
|
352
346
|
// src/redux/profileSelectionSlice.ts
|
|
@@ -357,7 +351,7 @@ var profileSelectionActions = actions3;
|
|
|
357
351
|
var profileSelectionSlice_default = reducer3;
|
|
358
352
|
|
|
359
353
|
// src/hooks/useProfiles.tsx
|
|
360
|
-
import { jsx as
|
|
354
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
361
355
|
var SHARED_GROUP_ID = "group.com.infinitetoken.tastic";
|
|
362
356
|
var ProfilesContext = createContext4(null);
|
|
363
357
|
function ProfilesProvider({ children }) {
|
|
@@ -365,7 +359,7 @@ function ProfilesProvider({ children }) {
|
|
|
365
359
|
const lastSelected = useSelector5((state) => state.profileSelection);
|
|
366
360
|
const dispatch = useDispatch6();
|
|
367
361
|
const [loaded, setLoaded] = useState3(false);
|
|
368
|
-
|
|
362
|
+
useEffect(() => {
|
|
369
363
|
let cancelled = false;
|
|
370
364
|
resolveInitialProfiles(SHARED_GROUP_ID, profiles).then((resolved) => {
|
|
371
365
|
if (cancelled) return;
|
|
@@ -379,7 +373,7 @@ function ProfilesProvider({ children }) {
|
|
|
379
373
|
}, []);
|
|
380
374
|
const { syncToShared } = useSharedProfilesSync({
|
|
381
375
|
groupId: SHARED_GROUP_ID,
|
|
382
|
-
onRemoteChange:
|
|
376
|
+
onRemoteChange: useCallback6(
|
|
383
377
|
(remote) => {
|
|
384
378
|
dispatch(profilesActions.setAll(remote));
|
|
385
379
|
dispatch(profileSelectionActions.pruneToRoster(remote.map((p) => p.id)));
|
|
@@ -387,7 +381,7 @@ function ProfilesProvider({ children }) {
|
|
|
387
381
|
[dispatch]
|
|
388
382
|
)
|
|
389
383
|
});
|
|
390
|
-
const createProfile =
|
|
384
|
+
const createProfile = useCallback6(
|
|
391
385
|
(input) => {
|
|
392
386
|
const record = createProfileRecord(input);
|
|
393
387
|
dispatch(profilesActions.add(record));
|
|
@@ -396,14 +390,14 @@ function ProfilesProvider({ children }) {
|
|
|
396
390
|
},
|
|
397
391
|
[profiles, dispatch, syncToShared]
|
|
398
392
|
);
|
|
399
|
-
const updateProfile =
|
|
393
|
+
const updateProfile = useCallback6(
|
|
400
394
|
(id, patch) => {
|
|
401
395
|
dispatch(profilesActions.update({ id, patch }));
|
|
402
396
|
syncToShared(profiles.map((p) => p.id === id ? { ...p, ...patch, updatedAt: Date.now() } : p));
|
|
403
397
|
},
|
|
404
398
|
[profiles, dispatch, syncToShared]
|
|
405
399
|
);
|
|
406
|
-
const deleteProfile =
|
|
400
|
+
const deleteProfile = useCallback6(
|
|
407
401
|
(id) => {
|
|
408
402
|
dispatch(profilesActions.remove(id));
|
|
409
403
|
syncToShared(profiles.filter((p) => p.id !== id));
|
|
@@ -411,13 +405,13 @@ function ProfilesProvider({ children }) {
|
|
|
411
405
|
},
|
|
412
406
|
[profiles, dispatch, syncToShared]
|
|
413
407
|
);
|
|
414
|
-
const selectProfile =
|
|
408
|
+
const selectProfile = useCallback6(
|
|
415
409
|
(seat, profileId) => {
|
|
416
410
|
dispatch(profileSelectionActions.select({ profileId, seat }));
|
|
417
411
|
},
|
|
418
412
|
[dispatch]
|
|
419
413
|
);
|
|
420
|
-
return /* @__PURE__ */
|
|
414
|
+
return /* @__PURE__ */ jsx10(ProfilesContext.Provider, { value: { profiles, lastSelected, loaded, createProfile, updateProfile, deleteProfile, selectProfile }, children });
|
|
421
415
|
}
|
|
422
416
|
function useProfiles() {
|
|
423
417
|
const ctx = useContext4(ProfilesContext);
|
|
@@ -426,7 +420,7 @@ function useProfiles() {
|
|
|
426
420
|
}
|
|
427
421
|
|
|
428
422
|
// src/RootLayout.tsx
|
|
429
|
-
import { Fragment as Fragment4, jsx as
|
|
423
|
+
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
430
424
|
var PLAY_OPTIONS = { statusBarHidden: true };
|
|
431
425
|
var KEEP_STATUS_BAR_OPTIONS = {};
|
|
432
426
|
var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
|
|
@@ -435,8 +429,8 @@ var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
|
|
|
435
429
|
var noScreenOptions = () => ({});
|
|
436
430
|
function useFirstScreenGate() {
|
|
437
431
|
const { resumeState, subscribeResume } = useLastActiveGame();
|
|
438
|
-
const marked =
|
|
439
|
-
return
|
|
432
|
+
const marked = useRef2(false);
|
|
433
|
+
return useCallback7(() => {
|
|
440
434
|
if (marked.current) return;
|
|
441
435
|
marked.current = true;
|
|
442
436
|
const mark = () => requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
|
|
@@ -457,7 +451,7 @@ function useFirstScreenGate() {
|
|
|
457
451
|
}
|
|
458
452
|
function useResumeShown() {
|
|
459
453
|
const { endResume } = useLastActiveGame();
|
|
460
|
-
return
|
|
454
|
+
return useCallback7(
|
|
461
455
|
({ route }) => ({
|
|
462
456
|
transitionEnd: (event) => {
|
|
463
457
|
if (route.name === PLAY_ROUTE && !event.data?.closing) endResume();
|
|
@@ -480,8 +474,8 @@ function AppStack() {
|
|
|
480
474
|
const backdropOptions = Backdrop ? { contentStyle: TRANSPARENT_CONTENT, animation: Platform3.select({ android: "fade" }) } : void 0;
|
|
481
475
|
const { edgeGuard = true } = pack;
|
|
482
476
|
const { deferBottomEdgeGestures } = useAppSettings().settings;
|
|
483
|
-
const edgeGuardOptions =
|
|
484
|
-
const playOptions =
|
|
477
|
+
const edgeGuardOptions = useMemo4(() => edgeGuardScreenOptions(edgeGuard && deferBottomEdgeGestures), [edgeGuard, deferBottomEdgeGestures]);
|
|
478
|
+
const playOptions = useCallback7(
|
|
485
479
|
({ route }) => {
|
|
486
480
|
const id = route.params?.game;
|
|
487
481
|
const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
|
|
@@ -490,58 +484,58 @@ function AppStack() {
|
|
|
490
484
|
[pack.games, edgeGuardOptions]
|
|
491
485
|
);
|
|
492
486
|
const navigationBackground = Backdrop ? TRANSPARENT_CONTENT.backgroundColor : rootBackground.contentStyle.backgroundColor;
|
|
493
|
-
const navigationTheme =
|
|
487
|
+
const navigationTheme = useMemo4(() => {
|
|
494
488
|
const base = darkRoot ? DarkTheme : DefaultTheme;
|
|
495
489
|
return { ...base, colors: { ...base.colors, background: navigationBackground } };
|
|
496
490
|
}, [darkRoot, navigationBackground]);
|
|
497
|
-
return /* @__PURE__ */
|
|
498
|
-
Backdrop && /* @__PURE__ */
|
|
499
|
-
/* @__PURE__ */
|
|
500
|
-
/* @__PURE__ */
|
|
501
|
-
/* @__PURE__ */
|
|
491
|
+
return /* @__PURE__ */ jsxs3(View, { style: styles.root, onLayout: onFirstLayout, children: [
|
|
492
|
+
Backdrop && /* @__PURE__ */ jsx11(Backdrop, {}),
|
|
493
|
+
/* @__PURE__ */ jsx11(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs3(Stack, { screenListeners, screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
|
|
494
|
+
/* @__PURE__ */ jsx11(Stack.Screen, { name: "index" }),
|
|
495
|
+
/* @__PURE__ */ jsx11(Stack.Screen, { name: PLAY_ROUTE, options: playOptions })
|
|
502
496
|
] }) })
|
|
503
497
|
] });
|
|
504
498
|
}
|
|
505
499
|
function GatedApp({ children }) {
|
|
506
500
|
const { loaded } = useProfiles();
|
|
507
|
-
return /* @__PURE__ */
|
|
501
|
+
return /* @__PURE__ */ jsx11(SplashGate, { gate: "profiles", ready: loaded, children });
|
|
508
502
|
}
|
|
509
503
|
function HapticGatedToastProvider({ children }) {
|
|
510
504
|
const { settings } = useHapticSettings();
|
|
511
505
|
const { Toaster: PackToasterComponent } = usePack();
|
|
512
|
-
return /* @__PURE__ */
|
|
506
|
+
return /* @__PURE__ */ jsx11(ToastProvider, { haptics: settings.vibrate ? Haptics : void 0, paper: PackToasterComponent ? void 0 : RNPaper2, children });
|
|
513
507
|
}
|
|
514
508
|
function FramedToaster() {
|
|
515
|
-
const renderFrame =
|
|
516
|
-
return /* @__PURE__ */
|
|
509
|
+
const renderFrame = useCallback7((toasts) => /* @__PURE__ */ jsx11(ScreenFrame, { passThrough: true, children: toasts }), []);
|
|
510
|
+
return /* @__PURE__ */ jsx11(Toaster, { historyButton: null, clearButton: null, limit: 1, renderFrame });
|
|
517
511
|
}
|
|
518
512
|
function PackToaster({ Toaster: PackToasterComponent }) {
|
|
519
|
-
return /* @__PURE__ */
|
|
513
|
+
return /* @__PURE__ */ jsx11(View, { style: StyleSheet.absoluteFill, pointerEvents: "box-none", children: /* @__PURE__ */ jsx11(ScreenFrame, { passThrough: true, children: /* @__PURE__ */ jsx11(PackToasterComponent, {}) }) });
|
|
520
514
|
}
|
|
521
515
|
function GameProviders({ games, children }) {
|
|
522
|
-
return games.reduceRight((inner, game) => game.Provider ? /* @__PURE__ */
|
|
516
|
+
return games.reduceRight((inner, game) => game.Provider ? /* @__PURE__ */ jsx11(game.Provider, { children: inner }, game.id) : inner, children);
|
|
523
517
|
}
|
|
524
518
|
function PreviewColors({ previewColor, children }) {
|
|
525
519
|
const { dark } = useAutoPaperTheme();
|
|
526
|
-
const preview =
|
|
527
|
-
return /* @__PURE__ */
|
|
520
|
+
const preview = useCallback7((hex) => previewColor(hex, dark), [previewColor, dark]);
|
|
521
|
+
return /* @__PURE__ */ jsx11(ProfileColorProvider, { preview, children });
|
|
528
522
|
}
|
|
529
523
|
function PackRoot({ pack, children }) {
|
|
530
524
|
const { Provider, previewColor } = pack;
|
|
531
|
-
const inner = Provider ? /* @__PURE__ */
|
|
532
|
-
return previewColor ? /* @__PURE__ */
|
|
525
|
+
const inner = Provider ? /* @__PURE__ */ jsx11(Provider, { children }) : children;
|
|
526
|
+
return previewColor ? /* @__PURE__ */ jsx11(PreviewColors, { previewColor, children: inner }) : /* @__PURE__ */ jsx11(Fragment4, { children: inner });
|
|
533
527
|
}
|
|
534
528
|
function DialogTitles({ children }) {
|
|
535
529
|
const { titleStyle, labelStyle } = usePack();
|
|
536
|
-
const lettered = /* @__PURE__ */
|
|
530
|
+
const lettered = /* @__PURE__ */ jsx11(LetteringProvider, { title: titleStyle, label: labelStyle, children });
|
|
537
531
|
if (!titleStyle) return lettered;
|
|
538
|
-
return /* @__PURE__ */
|
|
532
|
+
return /* @__PURE__ */ jsx11(DialogHeaderStyleProvider, { tone: "standard", titleStyle, children: lettered });
|
|
539
533
|
}
|
|
540
534
|
function RootLayout({ pack, store, persistor }) {
|
|
541
|
-
return /* @__PURE__ */
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
pack.Toaster ? /* @__PURE__ */
|
|
544
|
-
/* @__PURE__ */
|
|
535
|
+
return /* @__PURE__ */ jsx11(GestureHandlerRootView, { style: styles.root, children: /* @__PURE__ */ jsx11(SafeAreaProvider, { children: /* @__PURE__ */ jsx11(WindowControlsInsets, { children: /* @__PURE__ */ jsx11(PackProvider, { pack, children: /* @__PURE__ */ jsx11(Fonts, { children: /* @__PURE__ */ jsx11(Providers, { store, persistor, children: /* @__PURE__ */ jsx11(DialogTitles, { children: /* @__PURE__ */ jsx11(Theme, { children: /* @__PURE__ */ jsx11(ProfilesProvider, { children: /* @__PURE__ */ jsx11(LastActiveGameProvider, { children: /* @__PURE__ */ jsx11(GameProviders, { games: pack.games, children: /* @__PURE__ */ jsx11(PackRoot, { pack, children: /* @__PURE__ */ jsx11(GatedApp, { children: /* @__PURE__ */ jsxs3(HapticGatedToastProvider, { children: [
|
|
536
|
+
/* @__PURE__ */ jsx11(GuideHost, { children: /* @__PURE__ */ jsx11(AppStack, {}) }),
|
|
537
|
+
pack.Toaster ? /* @__PURE__ */ jsx11(PackToaster, { Toaster: pack.Toaster }) : /* @__PURE__ */ jsx11(FramedToaster, {}),
|
|
538
|
+
/* @__PURE__ */ jsx11(UpdateDialog, {})
|
|
545
539
|
] }) }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
546
540
|
}
|
|
547
541
|
var styles = StyleSheet.create({
|
|
@@ -572,24 +566,24 @@ var seatParam = (value) => value === "1" ? 1 : value === "2" ? 2 : null;
|
|
|
572
566
|
import { ScreenFrame as ScreenFrame2 } from "@tastic/hud/chrome";
|
|
573
567
|
import { NEW_PROFILE_ID, ProfilesScreen } from "@tastic/profile";
|
|
574
568
|
import { router as router2, useLocalSearchParams } from "expo-router";
|
|
575
|
-
import { jsx as
|
|
569
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
576
570
|
var ROSTER_MAX_WIDTH = 640;
|
|
577
571
|
function ProfilesRoute() {
|
|
578
572
|
const { seat } = useLocalSearchParams();
|
|
579
573
|
const opener = seatParam(seat);
|
|
580
574
|
const { profiles } = useProfiles();
|
|
581
575
|
const { Backdrop, foreground } = usePack();
|
|
582
|
-
return /* @__PURE__ */
|
|
576
|
+
return /* @__PURE__ */ jsx12(ScreenFrame2, { maxContentWidth: ROSTER_MAX_WIDTH, children: /* @__PURE__ */ jsx12(ProfilesScreen, { profiles, onEdit: (id) => router2.push(profileHref(id, id === NEW_PROFILE_ID ? opener : null)), onBack: safeBack, fg: foreground, bg: Backdrop ? "transparent" : void 0 }) });
|
|
583
577
|
}
|
|
584
578
|
|
|
585
579
|
// src/screens/EditProfileRoute.tsx
|
|
586
|
-
import { jsx as
|
|
580
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
587
581
|
function EditProfileRoute() {
|
|
588
582
|
const { id, seat } = useLocalSearchParams2();
|
|
589
583
|
const opener = seatParam(seat);
|
|
590
584
|
const { profiles, createProfile, updateProfile, deleteProfile, selectProfile } = useProfiles();
|
|
591
585
|
const { Backdrop, foreground, newProfileColor, ProfileSections } = usePack();
|
|
592
|
-
return /* @__PURE__ */
|
|
586
|
+
return /* @__PURE__ */ jsx13(ScreenFrame3, { portalHost: true, maxContentWidth: ROSTER_MAX_WIDTH, children: /* @__PURE__ */ jsx13(
|
|
593
587
|
EditProfileScreen,
|
|
594
588
|
{
|
|
595
589
|
profileId: id,
|
|
@@ -604,7 +598,7 @@ function EditProfileRoute() {
|
|
|
604
598
|
onBack: safeBack,
|
|
605
599
|
fg: foreground,
|
|
606
600
|
bg: Backdrop ? "transparent" : void 0,
|
|
607
|
-
sections: ProfileSections ? (profile) => /* @__PURE__ */
|
|
601
|
+
sections: ProfileSections ? (profile) => /* @__PURE__ */ jsx13(ProfileSections, { profile }) : void 0
|
|
608
602
|
}
|
|
609
603
|
) });
|
|
610
604
|
}
|
|
@@ -614,6 +608,35 @@ import { Redirect, useLocalSearchParams as useLocalSearchParams3 } from "expo-ro
|
|
|
614
608
|
import { useEffect as useEffect5 } from "react";
|
|
615
609
|
import { AppState } from "react-native";
|
|
616
610
|
|
|
611
|
+
// src/components/StartGuide.tsx
|
|
612
|
+
import { useIsFocused } from "expo-router";
|
|
613
|
+
import { createContext as createContext5, useContext as useContext5, useEffect as useEffect2, useState as useState4 } from "react";
|
|
614
|
+
import { useSelector as useSelector6 } from "react-redux";
|
|
615
|
+
import { jsx as jsx14, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
616
|
+
var GUIDE_DELAY_MS = 700;
|
|
617
|
+
var GuideCoveringContext = createContext5(false);
|
|
618
|
+
function useGuideCovering() {
|
|
619
|
+
return useContext5(GuideCoveringContext);
|
|
620
|
+
}
|
|
621
|
+
function StartGuide({ game, enabled, children }) {
|
|
622
|
+
const pack = usePack();
|
|
623
|
+
const focused = useIsFocused();
|
|
624
|
+
const subject = enabled ? startSubject(pack, game) : null;
|
|
625
|
+
const guide = guideFor(pack, subject);
|
|
626
|
+
const covering = useSelector6((state) => !!guide && guide.selectVersionSeen(state) < guide.version);
|
|
627
|
+
const [due, setDue] = useState4(false);
|
|
628
|
+
const waiting = covering && focused && !due;
|
|
629
|
+
useEffect2(() => {
|
|
630
|
+
if (!waiting) return;
|
|
631
|
+
const timeout = setTimeout(() => setDue(true), GUIDE_DELAY_MS);
|
|
632
|
+
return () => clearTimeout(timeout);
|
|
633
|
+
}, [waiting]);
|
|
634
|
+
return /* @__PURE__ */ jsxs4(GuideCoveringContext.Provider, { value: covering, children: [
|
|
635
|
+
children,
|
|
636
|
+
subject !== null && covering && /* @__PURE__ */ jsx14(GuideCards, { subject, visible: due && focused })
|
|
637
|
+
] });
|
|
638
|
+
}
|
|
639
|
+
|
|
617
640
|
// src/screens/LoadoutScreen.tsx
|
|
618
641
|
import { defaultColors as defaultColors2, getRgb, useAutoPaperTheme as useAutoPaperTheme3 } from "@rific/auto-paper";
|
|
619
642
|
import { useOrientationState } from "@tastic/core";
|
|
@@ -621,7 +644,7 @@ import { CornerActionButtons, PressAwayOverlay, useLettering, usePopoverHost } f
|
|
|
621
644
|
import { PlayerSetupPanel, ReadyButton, SharedActionBand } from "@tastic/hud/lobby";
|
|
622
645
|
import { DualZoneLayout, needsSharedNeutralZone, useDualZoneLayout } from "@tastic/split-screen";
|
|
623
646
|
import { router as router4, useFocusEffect as useFocusEffect2 } from "expo-router";
|
|
624
|
-
import { useCallback as
|
|
647
|
+
import { useCallback as useCallback10, useEffect as useEffect4, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
|
|
625
648
|
import { StyleSheet as StyleSheet3, View as View3 } from "react-native";
|
|
626
649
|
import { Text } from "react-native-paper";
|
|
627
650
|
import Animated from "react-native-reanimated";
|
|
@@ -631,9 +654,9 @@ import { useDispatch as useDispatch9 } from "react-redux";
|
|
|
631
654
|
// src/components/OpponentPicker.tsx
|
|
632
655
|
import { useZoneClampedAlign } from "@tastic/hud/lobby";
|
|
633
656
|
import { getOptionPickerContentSize, OptionPicker } from "@tastic/profile";
|
|
634
|
-
import { useMemo as
|
|
657
|
+
import { useMemo as useMemo5 } from "react";
|
|
635
658
|
import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
|
|
636
|
-
import { jsx as
|
|
659
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
637
660
|
var CPU_PREFIX = "cpu:";
|
|
638
661
|
var NOBODY = "nobody";
|
|
639
662
|
var PERSON = "person";
|
|
@@ -646,7 +669,7 @@ function getOpponentPopoverId(idPrefix) {
|
|
|
646
669
|
function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChange, cpuDifficulty, color, onColorChange, swatches, takenColor, allowSwapTaken, dark, previewValue, triggerStyle, usePickerAlign }) {
|
|
647
670
|
const drawn = previewValue ? previewValue(color) : color;
|
|
648
671
|
const cpuOptions = cpuDifficulty?.options;
|
|
649
|
-
const options =
|
|
672
|
+
const options = useMemo5(() => {
|
|
650
673
|
const list = [];
|
|
651
674
|
if (choices.includes("cpu")) list.push(...cpuOptions ? cpuOptions.map((o) => ({ value: `${CPU_PREFIX}${o.value}`, label: o.label, icon: o.icon })) : [{ value: CPU_PREFIX, label: "CPU", icon: CPU_ICON }]);
|
|
652
675
|
if (choices.includes("nobody")) list.push({ value: NOBODY, label: "Solo", icon: NOBODY_ICON, dividerBefore: true });
|
|
@@ -668,7 +691,7 @@ function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChange, cpu
|
|
|
668
691
|
const size = getOptionPickerContentSize(options, colorSection);
|
|
669
692
|
const useAlign = usePickerAlign ?? useZoneClampedAlign;
|
|
670
693
|
const align = useAlign(host.openId === pickerId, size.width, size.height);
|
|
671
|
-
return /* @__PURE__ */
|
|
694
|
+
return /* @__PURE__ */ jsx15(View2, { style: [styles2.button, host.openId === pickerId && styles2.buttonOpen], children: /* @__PURE__ */ jsx15(OptionPicker, { id: pickerId, host, caption: "Opponent", options, value, onChange: handleChange, color: drawn, dark, icon, colorSection, alignOverride: align, triggerStyle }) });
|
|
672
695
|
}
|
|
673
696
|
var styles2 = StyleSheet2.create({
|
|
674
697
|
// Its own column, so a row of seat buttons doesn't stretch the pill to the tallest of them.
|
|
@@ -685,7 +708,7 @@ var styles2 = StyleSheet2.create({
|
|
|
685
708
|
import { useUpdateErrorToast as useUpdateErrorToast2 } from "@rific/toaster";
|
|
686
709
|
import { BaseSettingsDialog } from "@tastic/hud/chrome";
|
|
687
710
|
import { router as router3 } from "expo-router";
|
|
688
|
-
import { jsx as
|
|
711
|
+
import { jsx as jsx16, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
689
712
|
var noSettingsRules = () => null;
|
|
690
713
|
function SettingsDialog({ visible, onDismiss, onShowHowToPlay, showProfile = false, children }) {
|
|
691
714
|
const onUpdateError = useUpdateErrorToast2();
|
|
@@ -696,9 +719,9 @@ function SettingsDialog({ visible, onDismiss, onShowHowToPlay, showProfile = fal
|
|
|
696
719
|
const seatOne = profiles.find((profile) => profile.id === lastSelected[1]) ?? null;
|
|
697
720
|
const profileRow = showProfile ? seatOne ? { onShowProfiles: () => router3.push(profileHref(seatOne.id)), profilesRow: { label: "Profile", caption: seatOne.name, icon: "account-outline" } } : { onShowProfiles: () => router3.push(profilesHref(1)) } : {};
|
|
698
721
|
const edgeGuardProps = edgeGuard ? { deferBottomEdgeGestures: settings.deferBottomEdgeGestures, onDeferBottomEdgeGestures: (value) => setSettings({ deferBottomEdgeGestures: value }) } : {};
|
|
699
|
-
return /* @__PURE__ */
|
|
722
|
+
return /* @__PURE__ */ jsxs5(BaseSettingsDialog, { visible, onDismiss, version: otaVersion, ...edgeGuardProps, onUpdateError, onShowHowToPlay, ...profileRow, leading: rules, children: [
|
|
700
723
|
children,
|
|
701
|
-
SettingsSections && /* @__PURE__ */
|
|
724
|
+
SettingsSections && /* @__PURE__ */ jsx16(SettingsSections, {})
|
|
702
725
|
] });
|
|
703
726
|
}
|
|
704
727
|
|
|
@@ -711,8 +734,8 @@ function useAtComputer() {
|
|
|
711
734
|
}
|
|
712
735
|
|
|
713
736
|
// src/hooks/useOpponent.ts
|
|
714
|
-
import { useCallback as
|
|
715
|
-
import { useDispatch as useDispatch7, useSelector as
|
|
737
|
+
import { useCallback as useCallback8 } from "react";
|
|
738
|
+
import { useDispatch as useDispatch7, useSelector as useSelector7 } from "react-redux";
|
|
716
739
|
|
|
717
740
|
// src/redux/opponentSlice.ts
|
|
718
741
|
import { createSettingsSlice as createSettingsSlice3 } from "@rific/core";
|
|
@@ -725,9 +748,9 @@ var opponentSlice_default = reducer4;
|
|
|
725
748
|
|
|
726
749
|
// src/hooks/useOpponent.ts
|
|
727
750
|
function useOpponent() {
|
|
728
|
-
const seatTwo =
|
|
751
|
+
const seatTwo = useSelector7((state) => state.opponent.seatTwo);
|
|
729
752
|
const dispatch = useDispatch7();
|
|
730
|
-
const setSeatTwo =
|
|
753
|
+
const setSeatTwo = useCallback8((next) => dispatch(opponentActions.setSeatTwo(next)), [dispatch]);
|
|
731
754
|
return { seatTwo, setSeatTwo };
|
|
732
755
|
}
|
|
733
756
|
|
|
@@ -735,8 +758,8 @@ function useOpponent() {
|
|
|
735
758
|
import { getThirdColor, useAutoPaperTheme as useAutoPaperTheme2, useThemeSettings } from "@rific/auto-paper";
|
|
736
759
|
import { avoidSeatColorClash, profileSeatColor } from "@tastic/profile";
|
|
737
760
|
import { useFocusEffect } from "expo-router";
|
|
738
|
-
import { useCallback as
|
|
739
|
-
import { useDispatch as useDispatch8, useSelector as
|
|
761
|
+
import { useCallback as useCallback9, useEffect as useEffect3, useRef as useRef3 } from "react";
|
|
762
|
+
import { useDispatch as useDispatch8, useSelector as useSelector8 } from "react-redux";
|
|
740
763
|
|
|
741
764
|
// src/redux/seatColorsSlice.ts
|
|
742
765
|
import { createSeatColorsSlice } from "@tastic/profile";
|
|
@@ -762,9 +785,9 @@ function useSeatColors(p2IsHuman) {
|
|
|
762
785
|
const { seatColors, seatTheme } = usePack();
|
|
763
786
|
const seatDefaultColors = [seatColors[1], seatColors[2]];
|
|
764
787
|
const dispatch = useDispatch8();
|
|
765
|
-
const guestColors =
|
|
766
|
-
const cpuColor =
|
|
767
|
-
const profileColors =
|
|
788
|
+
const guestColors = useSelector8((state) => state.seatColors.lastGuestColor);
|
|
789
|
+
const cpuColor = useSelector8((state) => state.seatColors.lastCpuColor);
|
|
790
|
+
const profileColors = useSelector8((state) => state.seatColors.profileColors);
|
|
768
791
|
const p1Profile = profiles.find((p) => p.id === lastSelected[1]) ?? null;
|
|
769
792
|
const p2Profile = p2IsHuman ? profiles.find((p) => p.id === lastSelected[2]) ?? null : null;
|
|
770
793
|
const rememberedColors = (p1Prof, p2Prof, picks, guest, cpu) => {
|
|
@@ -775,13 +798,13 @@ function useSeatColors(p2IsHuman) {
|
|
|
775
798
|
const remembered = rememberedColors(p1Profile, p2Profile, profileColors, guestColors, cpuColor);
|
|
776
799
|
const p1Color = seatTheme ? remembered.p1 : themeColors.primary;
|
|
777
800
|
const p2Color = seatTheme ? remembered.p2 : themeColors.secondary;
|
|
778
|
-
const themeFor =
|
|
779
|
-
const p1ProfileRef =
|
|
780
|
-
const p2ProfileRef =
|
|
781
|
-
const guestColorsRef =
|
|
782
|
-
const cpuColorRef =
|
|
783
|
-
const profileColorsRef =
|
|
784
|
-
const themeForRef =
|
|
801
|
+
const themeFor = useCallback9((p1, p2) => seatTheme ? seatTheme({ 1: p1, 2: p2 }, dark) : { color: { primary: p1, secondary: p2, tertiary: getThirdColor(p1, p2) } }, [seatTheme, dark]);
|
|
802
|
+
const p1ProfileRef = useRef3(p1Profile);
|
|
803
|
+
const p2ProfileRef = useRef3(p2Profile);
|
|
804
|
+
const guestColorsRef = useRef3(guestColors);
|
|
805
|
+
const cpuColorRef = useRef3(cpuColor);
|
|
806
|
+
const profileColorsRef = useRef3(profileColors);
|
|
807
|
+
const themeForRef = useRef3(themeFor);
|
|
785
808
|
useEffect3(() => {
|
|
786
809
|
p1ProfileRef.current = p1Profile;
|
|
787
810
|
}, [p1Profile]);
|
|
@@ -806,12 +829,12 @@ function useSeatColors(p2IsHuman) {
|
|
|
806
829
|
setThemeColor(next);
|
|
807
830
|
}, [lastSelected[1], lastSelected[2], p2IsHuman, guestColors, cpuColor, profileColors, profiles.length, dark]);
|
|
808
831
|
useFocusEffect(
|
|
809
|
-
|
|
832
|
+
useCallback9(() => {
|
|
810
833
|
const next = rememberedColors(p1ProfileRef.current, p2ProfileRef.current, profileColorsRef.current, guestColorsRef.current, cpuColorRef.current);
|
|
811
834
|
setThemeColor(themeForRef.current(next.p1, next.p2));
|
|
812
835
|
}, [lastSelected[1], lastSelected[2], p2IsHuman, setThemeColor])
|
|
813
836
|
);
|
|
814
|
-
const persistSeatColor =
|
|
837
|
+
const persistSeatColor = useCallback9(
|
|
815
838
|
(seat, hex) => {
|
|
816
839
|
const profile = seat === 1 ? p1Profile : p2Profile;
|
|
817
840
|
if (profile) {
|
|
@@ -826,7 +849,7 @@ function useSeatColors(p2IsHuman) {
|
|
|
826
849
|
},
|
|
827
850
|
[p1Profile, p2Profile, p2IsHuman, dispatch]
|
|
828
851
|
);
|
|
829
|
-
const handleP1ColorChange =
|
|
852
|
+
const handleP1ColorChange = useCallback9(
|
|
830
853
|
(hex) => {
|
|
831
854
|
const swapped = hex.toLowerCase() === p2Color.toLowerCase();
|
|
832
855
|
const nextP2 = swapped ? p1Color : p2Color;
|
|
@@ -836,7 +859,7 @@ function useSeatColors(p2IsHuman) {
|
|
|
836
859
|
},
|
|
837
860
|
[setThemeColor, themeFor, p1Color, p2Color, persistSeatColor]
|
|
838
861
|
);
|
|
839
|
-
const handleP2ColorChange =
|
|
862
|
+
const handleP2ColorChange = useCallback9(
|
|
840
863
|
(hex) => {
|
|
841
864
|
const swapped = hex.toLowerCase() === p1Color.toLowerCase();
|
|
842
865
|
const nextP1 = swapped ? p2Color : p1Color;
|
|
@@ -858,7 +881,7 @@ var liveplayActions = actions5;
|
|
|
858
881
|
var liveplaySlice_default = reducer5;
|
|
859
882
|
|
|
860
883
|
// src/screens/LoadoutScreen.tsx
|
|
861
|
-
import { jsx as
|
|
884
|
+
import { jsx as jsx17, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
862
885
|
var PANEL_SWAP_FADE_MS = 180;
|
|
863
886
|
var P1_CONTROL_ID = "p1-control";
|
|
864
887
|
var P2_CONTROL_ID = "p2-control";
|
|
@@ -871,7 +894,7 @@ function LoadoutScreen({ game }) {
|
|
|
871
894
|
const { seatTwo: savedSeatTwo, setSeatTwo } = useOpponent();
|
|
872
895
|
const seatTwo = seatTwoFor(savedSeatTwo, game.seatTwo);
|
|
873
896
|
const mode = roundModeFor(seatTwo);
|
|
874
|
-
const humanSeats =
|
|
897
|
+
const humanSeats = useMemo6(() => humanSeatsFor(mode), [mode]);
|
|
875
898
|
const p2IsHuman = mode === "twoPlayer";
|
|
876
899
|
const p2Exists = mode !== "solo";
|
|
877
900
|
const loadout = game.useLoadout(mode);
|
|
@@ -883,28 +906,28 @@ function LoadoutScreen({ game }) {
|
|
|
883
906
|
const panelMode = p2IsHuman ? twoPlayerMode : orientationMode;
|
|
884
907
|
const { panelLayout, panelFadeStyle } = useDualZoneLayout(panelMode, false, true, false, PANEL_SWAP_FADE_MS);
|
|
885
908
|
const playersRowFade = panelFadeStyle;
|
|
886
|
-
const [settingsOpen, setSettingsOpen] =
|
|
909
|
+
const [settingsOpen, setSettingsOpen] = useState5(false);
|
|
887
910
|
const insets = useSafeAreaInsets2();
|
|
888
911
|
const { title: lettering } = useLettering();
|
|
889
912
|
const { colors: themeColors, dark } = useAutoPaperTheme3();
|
|
890
913
|
const { p1Color, p2Color, handleP1ColorChange, handleP2ColorChange } = useSeatColors(p2IsHuman);
|
|
891
914
|
const dispatch = useDispatch9();
|
|
892
|
-
const handleP1ProfileSelect =
|
|
893
|
-
const handleP2ProfileSelect =
|
|
894
|
-
const [ready, setReady] =
|
|
915
|
+
const handleP1ProfileSelect = useCallback10((profile) => selectProfile(1, profile?.id ?? null), [selectProfile]);
|
|
916
|
+
const handleP2ProfileSelect = useCallback10((profile) => selectProfile(2, profile?.id ?? null), [selectProfile]);
|
|
917
|
+
const [ready, setReady] = useState5({ 1: false, 2: false });
|
|
895
918
|
useFocusEffect2(
|
|
896
|
-
|
|
919
|
+
useCallback10(() => {
|
|
897
920
|
setReady({ 1: false, 2: false });
|
|
898
921
|
}, [setReady])
|
|
899
922
|
);
|
|
900
|
-
const changeSeatTwo =
|
|
923
|
+
const changeSeatTwo = useCallback10(
|
|
901
924
|
(next) => {
|
|
902
925
|
setReady({ 1: false, 2: false });
|
|
903
926
|
setSeatTwo(next);
|
|
904
927
|
},
|
|
905
928
|
[setSeatTwo, setReady]
|
|
906
929
|
);
|
|
907
|
-
const roundSettingsRef =
|
|
930
|
+
const roundSettingsRef = useRef4(loadout.roundSettings);
|
|
908
931
|
useEffect4(() => {
|
|
909
932
|
roundSettingsRef.current = loadout.roundSettings;
|
|
910
933
|
}, [loadout.roundSettings]);
|
|
@@ -917,10 +940,10 @@ function LoadoutScreen({ game }) {
|
|
|
917
940
|
const fg = pack.foreground ?? (dark ? "#FFFFFF" : "#000000");
|
|
918
941
|
const fgMuted = (pack.foreground && halfOf(pack.foreground)) ?? (dark ? "rgba(255,255,255,0.5)" : "rgba(0,0,0,0.5)");
|
|
919
942
|
const { previewColor } = pack;
|
|
920
|
-
const seatPreview =
|
|
943
|
+
const seatPreview = useMemo6(() => previewColor ? (hex) => previewColor(hex, dark) : void 0, [previewColor, dark]);
|
|
921
944
|
const p1Drawn = seatPreview ? seatPreview(p1Color) : p1Color;
|
|
922
945
|
const p2Drawn = seatPreview ? seatPreview(p2Color) : p2Color;
|
|
923
|
-
const triggerStyle =
|
|
946
|
+
const triggerStyle = useMemo6(() => pack.Backdrop ? [styles3.pill, { backgroundColor: themeColors.surface }] : void 0, [pack.Backdrop, themeColors.surface]);
|
|
924
947
|
const readySurface = pack.Backdrop ? themeColors.surface : void 0;
|
|
925
948
|
const isPortrait = panelLayout.orientationMode === "faceToFace";
|
|
926
949
|
const showMetaInSharedBand = needsSharedNeutralZone(panelLayout.orientationMode, humanSeats.length);
|
|
@@ -934,21 +957,21 @@ function LoadoutScreen({ game }) {
|
|
|
934
957
|
const controlLook = { accentColor: themeColors.tertiary, mutedColor: fgMuted, dark };
|
|
935
958
|
const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn });
|
|
936
959
|
const p1Caption = p2IsHuman ? "Player 1" : "Player";
|
|
937
|
-
const p1Panel = /* @__PURE__ */
|
|
938
|
-
const opponentPicker = game.seatTwo && /* @__PURE__ */
|
|
960
|
+
const p1Panel = /* @__PURE__ */ jsx17(PlayerSetupPanel, { idPrefix: "p1", caption: p1Caption, host: controlsHost, color: p1Color, onColorChange: handleP1ColorChange, swatches: defaultColors2, takenColor: p2Exists ? p2Color : void 0, allowSwapTaken: mode === "vsCpu", colorCaption: pack.colorCaption, isHuman: true, dark, showReadyButton: false, profiles, selectedProfileId: lastSelected[1], takenProfileId: p2IsHuman ? lastSelected[2] : null, guestLabel: pack.guestLabel ?? "P1", nullLabel: pack.nullLabel, onProfileSelect: handleP1ProfileSelect, onManageProfiles: () => router4.push(profilesHref(1)), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
|
|
961
|
+
const opponentPicker = game.seatTwo && /* @__PURE__ */ jsx17(OpponentPicker, { idPrefix: "p1", host: controlsHost, choices: game.seatTwo, seatTwo, onSeatTwoChange: changeSeatTwo, cpuDifficulty: loadout.cpuDifficulty, color: p2Color, onColorChange: handleP2ColorChange, swatches: defaultColors2, takenColor: p1Color, allowSwapTaken: mode === "vsCpu", dark, previewValue: seatPreview, triggerStyle, usePickerAlign: seatPickerAlign }, `opponent-${layoutKey}`);
|
|
939
962
|
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }));
|
|
940
963
|
const readyInOptions = !p2IsHuman && !!loadout.drawsReady;
|
|
941
|
-
const seatButtons = /* @__PURE__ */
|
|
942
|
-
/* @__PURE__ */
|
|
964
|
+
const seatButtons = /* @__PURE__ */ jsxs6(View3, { style: [styles3.seatOneButtons, p1PickerOpen && styles3.raised], children: [
|
|
965
|
+
/* @__PURE__ */ jsxs6(Animated.View, { style: [styles3.playersRow, p1PickerOpen && styles3.raised, !p2IsHuman && playersRowFade], children: [
|
|
943
966
|
p1Panel,
|
|
944
967
|
opponentPicker
|
|
945
968
|
] }),
|
|
946
|
-
p1Control && /* @__PURE__ */
|
|
969
|
+
p1Control && /* @__PURE__ */ jsx17(View3, { style: [styles3.controlRow, p1ControlOpen && styles3.raised], children: p1Control })
|
|
947
970
|
] });
|
|
948
971
|
const seatsInOptions = !p2IsHuman && !!loadout.placesSeats;
|
|
949
|
-
const seatOne = /* @__PURE__ */
|
|
972
|
+
const seatOne = /* @__PURE__ */ jsxs6(View3, { style: [styles3.seatOne, !p2IsHuman && styles3.seatOneAlone, p1PickerOpen && !seatsInOptions && styles3.raised], children: [
|
|
950
973
|
!seatsInOptions && seatButtons,
|
|
951
|
-
!readyInOptions && /* @__PURE__ */
|
|
974
|
+
!readyInOptions && /* @__PURE__ */ jsx17(ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
952
975
|
] });
|
|
953
976
|
const optionsRow = loadout.options({
|
|
954
977
|
host: controlsHost,
|
|
@@ -964,16 +987,16 @@ function LoadoutScreen({ game }) {
|
|
|
964
987
|
onReset: showMetaInSharedBand ? void 0 : loadout.reset
|
|
965
988
|
});
|
|
966
989
|
const optionsPopoverOpen = controlsHost.openId !== null && loadout.optionIds.includes(controlsHost.openId);
|
|
967
|
-
const sharedControls = showMetaInSharedBand ? /* @__PURE__ */
|
|
990
|
+
const sharedControls = showMetaInSharedBand ? /* @__PURE__ */ jsx17(SharedActionBand, { onBack: safeBack, onSettings: () => setSettingsOpen(true), onRandomize: loadout.randomize, onReset: loadout.reset, fg, popoverOpen: optionsPopoverOpen, children: optionsRow }) : optionsRow;
|
|
968
991
|
const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : void 0;
|
|
969
|
-
const p2Panel = p2IsHuman && /* @__PURE__ */
|
|
970
|
-
return /* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
/* @__PURE__ */
|
|
973
|
-
p2ZoneStyle && /* @__PURE__ */
|
|
974
|
-
!showMetaInSharedBand && /* @__PURE__ */
|
|
975
|
-
!showMetaInSharedBand && /* @__PURE__ */
|
|
976
|
-
p2IsHuman ? /* @__PURE__ */
|
|
992
|
+
const p2Panel = p2IsHuman && /* @__PURE__ */ jsx17(PlayerSetupPanel, { idPrefix: "p2", caption: "Player 2", host: p2Host, color: p2Color, onColorChange: handleP2ColorChange, swatches: defaultColors2, takenColor: p1Color, colorCaption: pack.colorCaption, isHuman: true, ready: ready[2], onToggleReady: () => setReady((r) => ({ ...r, 2: !r[2] })), dark, secondPicker: p2Control, secondPickerId: p2Control ? P2_CONTROL_ID : void 0, profiles, selectedProfileId: lastSelected[2], takenProfileId: lastSelected[1], guestLabel: pack.guestLabel ?? "P2", nullLabel: pack.nullLabel, onProfileSelect: handleP2ProfileSelect, previewValue: seatPreview, triggerStyle, readySurfaceColor: readySurface }, "p2-zones");
|
|
993
|
+
return /* @__PURE__ */ jsxs6(View3, { style: [styles3.container, { backgroundColor: bg }], children: [
|
|
994
|
+
/* @__PURE__ */ jsxs6(View3, { style: [styles3.frame, !showMetaInSharedBand && { paddingTop: HEADER_TOP + HEADER_ROW_HEIGHT + insets.top }], children: [
|
|
995
|
+
/* @__PURE__ */ jsx17(PressAwayOverlay, { active: controlsHost.openId !== null, onPress: controlsHost.close }),
|
|
996
|
+
p2ZoneStyle && /* @__PURE__ */ jsx17(PressAwayOverlay, { active: controlsHost.openId !== null || p2Host.openId !== null, onPress: p2Host.close, style: p2ZoneStyle }),
|
|
997
|
+
!showMetaInSharedBand && /* @__PURE__ */ jsx17(CornerActionButtons, { onBack: safeBack, onSettings: () => setSettingsOpen(true), fg, insets }),
|
|
998
|
+
!showMetaInSharedBand && /* @__PURE__ */ jsx17(View3, { style: [styles3.headerTitle, { top: HEADER_TOP + insets.top, left: HEADER_TITLE_LEFT + insets.left, right: HEADER_TITLE_RIGHT + insets.right }], pointerEvents: "none", children: /* @__PURE__ */ jsx17(Text, { variant: "headlineSmall", numberOfLines: 1, accessibilityRole: "header", style: [styles3.title, { color: fg }, lettering], children: game.title }) }),
|
|
999
|
+
p2IsHuman ? /* @__PURE__ */ jsx17(
|
|
977
1000
|
DualZoneLayout,
|
|
978
1001
|
{
|
|
979
1002
|
panelLayout,
|
|
@@ -985,12 +1008,12 @@ function LoadoutScreen({ game }) {
|
|
|
985
1008
|
p2Elevated: p2Host.openId !== null,
|
|
986
1009
|
sharedElevated: optionsPopoverOpen
|
|
987
1010
|
}
|
|
988
|
-
) : /* @__PURE__ */
|
|
989
|
-
seatsInOptions ? /* @__PURE__ */
|
|
1011
|
+
) : /* @__PURE__ */ jsxs6(View3, { style: styles3.stackedZone, children: [
|
|
1012
|
+
seatsInOptions ? /* @__PURE__ */ jsx17(View3, { style: p1PickerOpen && styles3.raised, children: sharedControls }) : sharedControls,
|
|
990
1013
|
!(seatsInOptions && readyInOptions) && seatOne
|
|
991
1014
|
] })
|
|
992
1015
|
] }),
|
|
993
|
-
/* @__PURE__ */
|
|
1016
|
+
/* @__PURE__ */ jsx17(SettingsDialog, { visible: settingsOpen, onDismiss: () => setSettingsOpen(false), onShowHowToPlay: () => openFor(game.id), showProfile: true })
|
|
994
1017
|
] });
|
|
995
1018
|
}
|
|
996
1019
|
function halfOf(color) {
|
|
@@ -1080,25 +1103,25 @@ var styles3 = StyleSheet3.create({
|
|
|
1080
1103
|
});
|
|
1081
1104
|
|
|
1082
1105
|
// src/screens/GameRoute.tsx
|
|
1083
|
-
import { jsx as
|
|
1106
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1084
1107
|
function LoadoutRoute() {
|
|
1085
1108
|
const { game: id } = useLocalSearchParams3();
|
|
1086
1109
|
const game = usePackGame(id);
|
|
1087
|
-
if (!game) return /* @__PURE__ */
|
|
1088
|
-
if (!hasLoadout(game)) return /* @__PURE__ */
|
|
1089
|
-
return /* @__PURE__ */
|
|
1110
|
+
if (!game) return /* @__PURE__ */ jsx18(Redirect, { href: "/" });
|
|
1111
|
+
if (!hasLoadout(game)) return /* @__PURE__ */ jsx18(Redirect, { href: playHref(game.id) });
|
|
1112
|
+
return /* @__PURE__ */ jsx18(LoadoutScreen, { game }, game.id);
|
|
1090
1113
|
}
|
|
1091
1114
|
function hasLoadout(game) {
|
|
1092
1115
|
return !!game.useLoadout;
|
|
1093
1116
|
}
|
|
1094
|
-
function PlayRoute() {
|
|
1117
|
+
function PlayRoute({ guide = true } = {}) {
|
|
1095
1118
|
const { game: id } = useLocalSearchParams3();
|
|
1096
1119
|
const game = usePackGame(id);
|
|
1097
1120
|
useResumePoint(game?.resumable ? game.id : null);
|
|
1098
1121
|
useResumeUp();
|
|
1099
|
-
if (!game) return /* @__PURE__ */
|
|
1122
|
+
if (!game) return /* @__PURE__ */ jsx18(Redirect, { href: "/" });
|
|
1100
1123
|
const { PlayScreen } = game;
|
|
1101
|
-
return /* @__PURE__ */
|
|
1124
|
+
return /* @__PURE__ */ jsx18(StartGuide, { game, enabled: guide, children: /* @__PURE__ */ jsx18(PlayScreen, {}) }, game.id);
|
|
1102
1125
|
}
|
|
1103
1126
|
function useResumeUp() {
|
|
1104
1127
|
const { playScreenUp } = useLastActiveGame();
|
|
@@ -1128,8 +1151,8 @@ import { defaultColors as defaultColors3, FadingScrollView, useAutoPaperTheme as
|
|
|
1128
1151
|
import { IconButton, Pressable } from "@rific/feedback-press";
|
|
1129
1152
|
import { PressAwayOverlay as PressAwayOverlay2, usePopoverHost as usePopoverHost2, useWellColors, WELL_SHADOW } from "@tastic/hud/chrome";
|
|
1130
1153
|
import { getProfilePickerContentSize, ProfilePicker } from "@tastic/profile";
|
|
1131
|
-
import { router as router5, useFocusEffect as useFocusEffect3, useIsFocused } from "expo-router";
|
|
1132
|
-
import { createContext as
|
|
1154
|
+
import { router as router5, useFocusEffect as useFocusEffect3, useIsFocused as useIsFocused2 } from "expo-router";
|
|
1155
|
+
import { createContext as createContext6, memo, startTransition, useCallback as useCallback11, useContext as useContext6, useDeferredValue, useEffect as useEffect6, useLayoutEffect, useMemo as useMemo7, useRef as useRef5, useState as useState7, useSyncExternalStore } from "react";
|
|
1133
1156
|
import { AppState as AppState2, Platform as Platform5, StyleSheet as StyleSheet4, View as View4 } from "react-native";
|
|
1134
1157
|
import { Icon, Portal, SegmentedButtons, Text as Text2 } from "react-native-paper";
|
|
1135
1158
|
|
|
@@ -1138,11 +1161,11 @@ var SEGMENT_THEME = { roundness: 3.8 };
|
|
|
1138
1161
|
var SEGMENT_RADIUS = 5 * SEGMENT_THEME.roundness;
|
|
1139
1162
|
|
|
1140
1163
|
// src/hooks/useFrozenWhileHidden.ts
|
|
1141
|
-
import { useState as
|
|
1164
|
+
import { useState as useState6 } from "react";
|
|
1142
1165
|
function useFrozenWhileHidden(value, hidden) {
|
|
1143
|
-
const [prevHidden, setPrevHidden] =
|
|
1144
|
-
const [prevValue, setPrevValue] =
|
|
1145
|
-
const [frozen, setFrozen] =
|
|
1166
|
+
const [prevHidden, setPrevHidden] = useState6(hidden);
|
|
1167
|
+
const [prevValue, setPrevValue] = useState6(value);
|
|
1168
|
+
const [frozen, setFrozen] = useState6(value);
|
|
1146
1169
|
if (hidden !== prevHidden) {
|
|
1147
1170
|
setPrevHidden(hidden);
|
|
1148
1171
|
if (hidden) setFrozen(prevValue);
|
|
@@ -1215,26 +1238,22 @@ function useHomeLayout(withPicker = true) {
|
|
|
1215
1238
|
}
|
|
1216
1239
|
|
|
1217
1240
|
// src/screens/HomeScreen.tsx
|
|
1218
|
-
import { Fragment as Fragment5, jsx as
|
|
1241
|
+
import { Fragment as Fragment5, jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1219
1242
|
function HomeScreen() {
|
|
1220
1243
|
const pack = usePack();
|
|
1221
1244
|
const { consumeResumeGame } = useLastActiveGame();
|
|
1222
|
-
const
|
|
1223
|
-
const [resumeGame] = useState6(() => {
|
|
1245
|
+
const [resumeGame] = useState7(() => {
|
|
1224
1246
|
const id = consumeResumeGame();
|
|
1225
1247
|
return pack.games.find((g) => g.id === id && g.resumable) ?? null;
|
|
1226
1248
|
});
|
|
1227
|
-
useEffect6(() => {
|
|
1228
|
-
if (!resumeGame) autoShowPack();
|
|
1229
|
-
}, [resumeGame, autoShowPack]);
|
|
1230
1249
|
useResume(resumeGame);
|
|
1231
|
-
return useMenuShown(!!resumeGame) ? /* @__PURE__ */
|
|
1250
|
+
return useMenuShown(!!resumeGame) ? /* @__PURE__ */ jsx19(HomeMenu, {}) : null;
|
|
1232
1251
|
}
|
|
1233
1252
|
function useResume(game) {
|
|
1234
1253
|
const pack = usePack();
|
|
1235
|
-
const done =
|
|
1254
|
+
const done = useRef5(false);
|
|
1236
1255
|
useFocusEffect3(
|
|
1237
|
-
|
|
1256
|
+
useCallback11(() => {
|
|
1238
1257
|
if (!game || done.current) return;
|
|
1239
1258
|
done.current = true;
|
|
1240
1259
|
if (game.useLoadout) router5.push(loadoutHref(game.id));
|
|
@@ -1244,8 +1263,8 @@ function useResume(game) {
|
|
|
1244
1263
|
}
|
|
1245
1264
|
function useMenuShown(resuming) {
|
|
1246
1265
|
const { beginResume, endResume, resumeState, subscribeResume } = useLastActiveGame();
|
|
1247
|
-
const isFocused =
|
|
1248
|
-
const [covered, setCovered] =
|
|
1266
|
+
const isFocused = useIsFocused2();
|
|
1267
|
+
const [covered, setCovered] = useState7(false);
|
|
1249
1268
|
if (resuming && !covered && !isFocused) setCovered(true);
|
|
1250
1269
|
useLayoutEffect(() => {
|
|
1251
1270
|
if (!resuming) return;
|
|
@@ -1268,10 +1287,10 @@ function HomeMenu() {
|
|
|
1268
1287
|
const { insets } = layout;
|
|
1269
1288
|
const { dark, colors } = useAutoPaperTheme4();
|
|
1270
1289
|
const { openFirstTime, openFor, openPack } = useGameGuide();
|
|
1271
|
-
const [settingsOpen, setSettingsOpen] =
|
|
1272
|
-
const [rulesGame, setRulesGame] =
|
|
1273
|
-
const isFocused =
|
|
1274
|
-
const [appState, setAppState] =
|
|
1290
|
+
const [settingsOpen, setSettingsOpen] = useState7(false);
|
|
1291
|
+
const [rulesGame, setRulesGame] = useState7(null);
|
|
1292
|
+
const isFocused = useIsFocused2();
|
|
1293
|
+
const [appState, setAppState] = useState7(AppState2.currentState);
|
|
1275
1294
|
useEffect6(() => {
|
|
1276
1295
|
const subscription = AppState2.addEventListener("change", setAppState);
|
|
1277
1296
|
return () => subscription.remove();
|
|
@@ -1284,7 +1303,7 @@ function HomeMenu() {
|
|
|
1284
1303
|
const selectedProfile = profiles.find((p) => p.id === lastSelected[1]) ?? null;
|
|
1285
1304
|
const tiled = pack.games.some((game) => game.Preview);
|
|
1286
1305
|
const isWide = useFrozenWhileHidden(tiled && layout.isWide, !isFocused);
|
|
1287
|
-
const [previewsRevealed, setPreviewsRevealed] =
|
|
1306
|
+
const [previewsRevealed, setPreviewsRevealed] = useState7(false);
|
|
1288
1307
|
useEffect6(() => {
|
|
1289
1308
|
if (!tiled) return;
|
|
1290
1309
|
const id = requestAnimationFrame(() => setPreviewsRevealed(true));
|
|
@@ -1298,51 +1317,51 @@ function HomeMenu() {
|
|
|
1298
1317
|
const fg = pack.foreground ?? (dark ? "#FFFFFF" : "#000000");
|
|
1299
1318
|
const { previewColor } = pack;
|
|
1300
1319
|
const p1Drawn = previewColor ? previewColor(p1Color, dark) : p1Color;
|
|
1301
|
-
const triggerStyle =
|
|
1320
|
+
const triggerStyle = useMemo7(() => pack.Backdrop ? [styles4.pill, { backgroundColor: colors.surface }] : void 0, [pack.Backdrop, colors.surface]);
|
|
1302
1321
|
const tabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
|
|
1303
|
-
const [tabLabel, setTabLabel] =
|
|
1322
|
+
const [tabLabel, setTabLabel] = useState7(() => tabs?.[0].label ?? null);
|
|
1304
1323
|
const tab = tabs ? tabs.find((t) => t.label === tabLabel) ?? tabs[0] : null;
|
|
1305
|
-
const tabButtons =
|
|
1306
|
-
const tabBar = tab && /* @__PURE__ */
|
|
1307
|
-
const panes =
|
|
1324
|
+
const tabButtons = useMemo7(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle]);
|
|
1325
|
+
const tabBar = tab && /* @__PURE__ */ jsx19(SegmentedButtons, { value: tab.label, onValueChange: setTabLabel, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles4.tabs, pack.Backdrop && { backgroundColor: colors.surface }] });
|
|
1326
|
+
const panes = useMemo7(() => tabs ? tabs.map((t) => ({ key: t.label, games: pack.games.filter(t.includes) })) : [{ key: ALL_GAMES, games: pack.games }], [tabs, pack.games]);
|
|
1308
1327
|
const shownPane = tab?.label ?? ALL_GAMES;
|
|
1309
1328
|
const { width: fitWidth, height: fitHeight } = layout.heroFit ?? NO_FIT;
|
|
1310
|
-
const hero =
|
|
1329
|
+
const hero = useMemo7(() => /* @__PURE__ */ jsx19(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
1330
|
const columnClamp = useClampOnShrink();
|
|
1312
1331
|
const gridClamp = useClampOnShrink();
|
|
1313
|
-
const openGame =
|
|
1314
|
-
const openRules =
|
|
1332
|
+
const openGame = useCallback11((game) => openFirstTime(game.id, () => router5.push(game.useLoadout ? loadoutHref(game.id) : playHref(game.id))), [openFirstTime]);
|
|
1333
|
+
const openRules = useCallback11((game) => game.Rules ? setRulesGame(game) : openFor(game.id), [openFor]);
|
|
1315
1334
|
const colorSection = { value: p1Color, onChange: handleP1ColorChange, swatches: defaultColors3, caption: selectedProfile ? pack.colorCaption : void 0, previewValue: previewColor ? (hex) => previewColor(hex, dark) : void 0 };
|
|
1316
1335
|
const usePickerAlign = pack.usePickerAlign ?? noPickerAlign;
|
|
1317
1336
|
const pickerSize = getProfilePickerContentSize(profiles.length, true, colorSection);
|
|
1318
1337
|
const pickerAlign = usePickerAlign(pickerHost.openId === `${SEAT_ONE_PICKER}-profile`, pickerSize.width, pickerSize.height);
|
|
1319
|
-
const picker = /* @__PURE__ */
|
|
1320
|
-
const pressAway = /* @__PURE__ */
|
|
1338
|
+
const picker = /* @__PURE__ */ jsx19(ProfilePicker, { idPrefix: SEAT_ONE_PICKER, host: pickerHost, caption: "Player", profiles, selectedId: lastSelected[1], color: p1Drawn, dark, guestLabel: pack.guestLabel ?? "P1", nullLabel: pack.nullLabel, onSelect: (profile) => selectProfile(1, profile?.id ?? null), onManage: () => router5.push(profilesHref(1)), colorSection, alignOverride: pickerAlign, triggerStyle });
|
|
1339
|
+
const pressAway = /* @__PURE__ */ jsx19(PressAwayOverlay2, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles4.pressAway });
|
|
1321
1340
|
const RulesSheet = rulesGame?.Rules;
|
|
1322
|
-
return /* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */
|
|
1324
|
-
/* @__PURE__ */
|
|
1341
|
+
return /* @__PURE__ */ jsxs7(View4, { style: [styles4.container, { backgroundColor: bg }], children: [
|
|
1342
|
+
/* @__PURE__ */ jsx19(View4, { style: styles4.frame, children: /* @__PURE__ */ jsxs7(RulesHost, { enabled: pack.games.some((game) => game.Rules), children: [
|
|
1343
|
+
/* @__PURE__ */ jsx19(PreviewsRevealed, { value: previewsRevealed, children: isWide ? /* @__PURE__ */ jsxs7(Fragment5, { children: [
|
|
1325
1344
|
pressAway,
|
|
1326
|
-
/* @__PURE__ */
|
|
1327
|
-
tabBar && /* @__PURE__ */
|
|
1328
|
-
/* @__PURE__ */
|
|
1345
|
+
/* @__PURE__ */ jsxs7(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: [
|
|
1346
|
+
tabBar && /* @__PURE__ */ jsx19(View4, { style: [styles4.wideTabs, { width: layout.rightPaneWidth }], children: tabBar }),
|
|
1347
|
+
/* @__PURE__ */ jsx19(View4, { style: { width: layout.rightPaneWidth }, children: /* @__PURE__ */ jsx19(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.grid, children: (games, built) => /* @__PURE__ */ jsx19(GameGrid, { games, built, width: layout.tileWidth, previewWidth: layout.previewWidth, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
|
|
1329
1348
|
] }),
|
|
1330
|
-
/* @__PURE__ */
|
|
1349
|
+
/* @__PURE__ */ jsxs7(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: [
|
|
1331
1350
|
hero,
|
|
1332
|
-
showPicker && /* @__PURE__ */
|
|
1351
|
+
showPicker && /* @__PURE__ */ jsx19(View4, { style: styles4.widePicker, children: picker })
|
|
1333
1352
|
] })
|
|
1334
|
-
] }) : /* @__PURE__ */
|
|
1353
|
+
] }) : /* @__PURE__ */ jsxs7(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
1354
|
pressAway,
|
|
1336
1355
|
hero,
|
|
1337
|
-
showPicker && /* @__PURE__ */
|
|
1338
|
-
tabBar && /* @__PURE__ */
|
|
1339
|
-
/* @__PURE__ */
|
|
1356
|
+
showPicker && /* @__PURE__ */ jsx19(View4, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
|
|
1357
|
+
tabBar && /* @__PURE__ */ jsx19(View4, { style: styles4.listWidth, children: tabBar }),
|
|
1358
|
+
/* @__PURE__ */ jsx19(View4, { style: styles4.listWidth, children: /* @__PURE__ */ jsx19(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.list, children: (games, built) => /* @__PURE__ */ jsx19(GameList, { games, built, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
|
|
1340
1359
|
] }) }),
|
|
1341
|
-
/* @__PURE__ */
|
|
1342
|
-
/* @__PURE__ */
|
|
1343
|
-
RulesSheet && /* @__PURE__ */
|
|
1360
|
+
/* @__PURE__ */ jsx19(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" }),
|
|
1361
|
+
/* @__PURE__ */ jsx19(IconButton, { icon: "cog", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, right: 8 + insets.right }], onPress: () => setSettingsOpen(true), accessibilityLabel: "Settings" }),
|
|
1362
|
+
RulesSheet && /* @__PURE__ */ jsx19(RulesSheet, { visible: true, onDismiss: () => setRulesGame(null) })
|
|
1344
1363
|
] }) }),
|
|
1345
|
-
/* @__PURE__ */
|
|
1364
|
+
/* @__PURE__ */ jsx19(SettingsDialog, { visible: settingsOpen, onDismiss: () => setSettingsOpen(false), onShowHowToPlay: pack.guide ? openPack : void 0, showProfile: true })
|
|
1346
1365
|
] });
|
|
1347
1366
|
}
|
|
1348
1367
|
var SEAT_ONE_PICKER = "home-p1";
|
|
@@ -1355,13 +1374,13 @@ function TabPanes({ panes, shown, buildOthers, style, children }) {
|
|
|
1355
1374
|
return panes.map(({ key, games }) => {
|
|
1356
1375
|
const built = builtGames(key);
|
|
1357
1376
|
if (built === 0) return null;
|
|
1358
|
-
return /* @__PURE__ */
|
|
1377
|
+
return /* @__PURE__ */ jsx19(TabPane, { shown: key === shown, style, children: children(games, built) }, key);
|
|
1359
1378
|
});
|
|
1360
1379
|
}
|
|
1361
1380
|
function useBuiltGames(shown, total, buildOthers) {
|
|
1362
|
-
const [picked, setPicked] =
|
|
1381
|
+
const [picked, setPicked] = useState7([shown]);
|
|
1363
1382
|
if (!picked.includes(shown)) setPicked([...picked, shown]);
|
|
1364
|
-
const [others, setOthers] =
|
|
1383
|
+
const [others, setOthers] = useState7(Platform5.OS === "web" ? total : 0);
|
|
1365
1384
|
const building = buildOthers && others < total;
|
|
1366
1385
|
useEffect6(() => {
|
|
1367
1386
|
if (!building) return;
|
|
@@ -1373,14 +1392,14 @@ function useBuiltGames(shown, total, buildOthers) {
|
|
|
1373
1392
|
var OTHER_PANES_DELAY_MS = 1200;
|
|
1374
1393
|
var OTHER_PANES_STEP_MS = 150;
|
|
1375
1394
|
function TabPane({ shown, style, children }) {
|
|
1376
|
-
return /* @__PURE__ */
|
|
1395
|
+
return /* @__PURE__ */ jsx19(View4, { collapsable: false, "aria-hidden": !shown, style: [style, !shown && styles4.paneHidden], children });
|
|
1377
1396
|
}
|
|
1378
|
-
var PreviewsRevealedContext =
|
|
1397
|
+
var PreviewsRevealedContext = createContext6(false);
|
|
1379
1398
|
var PreviewsRevealed = PreviewsRevealedContext.Provider;
|
|
1380
1399
|
function useClampOnShrink() {
|
|
1381
|
-
const view =
|
|
1382
|
-
const sizes =
|
|
1383
|
-
return
|
|
1400
|
+
const view = useRef5(null);
|
|
1401
|
+
const sizes = useRef5({ viewport: 0, offset: 0 });
|
|
1402
|
+
return useMemo7(
|
|
1384
1403
|
() => ({
|
|
1385
1404
|
ref: (instance) => {
|
|
1386
1405
|
view.current = instance;
|
|
@@ -1406,13 +1425,13 @@ function hasRules(game) {
|
|
|
1406
1425
|
return !!(game.Rules || game.guide);
|
|
1407
1426
|
}
|
|
1408
1427
|
function RulesHost({ enabled, children }) {
|
|
1409
|
-
return enabled ? /* @__PURE__ */
|
|
1428
|
+
return enabled ? /* @__PURE__ */ jsx19(Portal.Host, { children }) : /* @__PURE__ */ jsx19(Fragment5, { children });
|
|
1410
1429
|
}
|
|
1411
1430
|
var GameList = memo(function GameList2({ games, built, ...rest }) {
|
|
1412
|
-
return games.slice(0, built).map((game) => /* @__PURE__ */
|
|
1431
|
+
return games.slice(0, built).map((game) => /* @__PURE__ */ jsx19(GameRow, { game, ...rest }, game.id));
|
|
1413
1432
|
});
|
|
1414
1433
|
var GameGrid = memo(function GameGrid2({ games, built, ...rest }) {
|
|
1415
|
-
return games.slice(0, built).map((game) => /* @__PURE__ */
|
|
1434
|
+
return games.slice(0, built).map((game) => /* @__PURE__ */ jsx19(GameTile, { game, ...rest }, game.id));
|
|
1416
1435
|
});
|
|
1417
1436
|
var ROW_BLURB_LINES = 3;
|
|
1418
1437
|
var GameRow = memo(function GameRow2({ game, dark, p1Color, p2Color, onOpen, onRules }) {
|
|
@@ -1422,36 +1441,36 @@ var GameRow = memo(function GameRow2({ game, dark, p1Color, p2Color, onOpen, onR
|
|
|
1422
1441
|
return (
|
|
1423
1442
|
// The rules button sits beside the row's own button, laid over its end, not inside it: a button
|
|
1424
1443
|
// inside a button is invalid on the web.
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
game.Preview ? /* @__PURE__ */
|
|
1428
|
-
/* @__PURE__ */
|
|
1429
|
-
/* @__PURE__ */
|
|
1430
|
-
/* @__PURE__ */
|
|
1444
|
+
/* @__PURE__ */ jsxs7(View4, { children: [
|
|
1445
|
+
/* @__PURE__ */ jsxs7(Pressable, { onPress: () => onOpen(game), style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1446
|
+
game.Preview ? /* @__PURE__ */ jsx19(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, dark, p1Color, p2Color }) : /* @__PURE__ */ jsx19(View4, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ jsx19(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
|
|
1447
|
+
/* @__PURE__ */ jsxs7(View4, { style: styles4.rowText, children: [
|
|
1448
|
+
/* @__PURE__ */ jsx19(Text2, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1449
|
+
/* @__PURE__ */ jsx19(Text2, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
|
|
1431
1450
|
] })
|
|
1432
1451
|
] }),
|
|
1433
|
-
hasRules(game) && /* @__PURE__ */
|
|
1452
|
+
hasRules(game) && /* @__PURE__ */ jsx19(Pressable, { onPress: () => onRules(game), style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx19(Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
|
|
1434
1453
|
] })
|
|
1435
1454
|
);
|
|
1436
1455
|
});
|
|
1437
1456
|
var GameTile = memo(function GameTile2({ game, width, previewWidth, dark, p1Color, p2Color, onOpen, onRules }) {
|
|
1438
1457
|
const { titleStyle } = usePack();
|
|
1439
1458
|
const well = useWellColors();
|
|
1440
|
-
return /* @__PURE__ */
|
|
1441
|
-
/* @__PURE__ */
|
|
1442
|
-
/* @__PURE__ */
|
|
1443
|
-
/* @__PURE__ */
|
|
1444
|
-
/* @__PURE__ */
|
|
1459
|
+
return /* @__PURE__ */ jsxs7(View4, { style: { width }, children: [
|
|
1460
|
+
/* @__PURE__ */ jsxs7(Pressable, { onPress: () => onOpen(game), style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1461
|
+
/* @__PURE__ */ jsx19(PreviewBox, { game, width: previewWidth, dark, p1Color, p2Color }),
|
|
1462
|
+
/* @__PURE__ */ jsx19(Text2, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1463
|
+
/* @__PURE__ */ jsx19(Text2, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
|
|
1445
1464
|
] }),
|
|
1446
|
-
hasRules(game) && /* @__PURE__ */
|
|
1465
|
+
hasRules(game) && /* @__PURE__ */ jsx19(Pressable, { onPress: () => onRules(game), style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx19(Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
|
|
1447
1466
|
] });
|
|
1448
1467
|
});
|
|
1449
1468
|
function PreviewBox({ game, width, dark, p1Color, p2Color }) {
|
|
1450
|
-
const revealed =
|
|
1469
|
+
const revealed = useContext6(PreviewsRevealedContext);
|
|
1451
1470
|
const height = Math.round(width / PREVIEW_ASPECT);
|
|
1452
1471
|
const { Preview, icon: GameIcon } = game;
|
|
1453
1472
|
const iconSize = Math.min(height, ROW_ICON_SIZE);
|
|
1454
|
-
return /* @__PURE__ */
|
|
1473
|
+
return /* @__PURE__ */ jsx19(View4, { style: [styles4.preview, { width, height, backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: Preview ? revealed && /* @__PURE__ */ jsx19(Preview, { width, height, p1Color, p2Color, dark }) : GameIcon && /* @__PURE__ */ jsx19(View4, { style: [styles4.previewIcon, { width: iconSize, height: iconSize, borderRadius: iconSize * 0.22 }], children: /* @__PURE__ */ jsx19(GameIcon, { size: iconSize, p1Color, p2Color, dark }) }) });
|
|
1455
1474
|
}
|
|
1456
1475
|
var ROW_ICON_SIZE = 56;
|
|
1457
1476
|
var ICON_LIGHT_BG = "#FAFAFA";
|
|
@@ -1605,15 +1624,15 @@ import { useAutoPaperTheme as useAutoPaperTheme5 } from "@rific/auto-paper";
|
|
|
1605
1624
|
import { BaseStatsScreen, PressAwayOverlay as PressAwayOverlay3, ScreenFrame as ScreenFrame4, usePopoverHost as usePopoverHost3 } from "@tastic/hud/chrome";
|
|
1606
1625
|
import { getOptionPickerContentSize as getOptionPickerContentSize2, OptionPicker as OptionPicker2 } from "@tastic/profile";
|
|
1607
1626
|
import { router as router6 } from "expo-router";
|
|
1608
|
-
import { useMemo as
|
|
1627
|
+
import { useMemo as useMemo9, useState as useState9 } from "react";
|
|
1609
1628
|
import { StyleSheet as StyleSheet5, View as View5 } from "react-native";
|
|
1610
1629
|
import { SegmentedButtons as SegmentedButtons2, Text as Text3 } from "react-native-paper";
|
|
1611
1630
|
import { useSafeAreaInsets as useSafeAreaInsets4 } from "react-native-safe-area-context";
|
|
1612
1631
|
import { useDispatch as useDispatch10 } from "react-redux";
|
|
1613
1632
|
|
|
1614
1633
|
// src/components/Staged.tsx
|
|
1615
|
-
import { Children, useEffect as useEffect7, useMemo as
|
|
1616
|
-
import { Fragment as Fragment6, jsx as
|
|
1634
|
+
import { Children, useEffect as useEffect7, useMemo as useMemo8, useState as useState8 } from "react";
|
|
1635
|
+
import { Fragment as Fragment6, jsx as jsx20 } from "react/jsx-runtime";
|
|
1617
1636
|
function onShown(run) {
|
|
1618
1637
|
let idle;
|
|
1619
1638
|
let frame = requestAnimationFrame(() => {
|
|
@@ -1628,17 +1647,17 @@ function onShown(run) {
|
|
|
1628
1647
|
};
|
|
1629
1648
|
}
|
|
1630
1649
|
function Staged({ first = 1, step = 1, children }) {
|
|
1631
|
-
const parts =
|
|
1632
|
-
const [drawn, setDrawn] =
|
|
1650
|
+
const parts = useMemo8(() => Children.toArray(children), [children]);
|
|
1651
|
+
const [drawn, setDrawn] = useState8(first);
|
|
1633
1652
|
useEffect7(() => {
|
|
1634
1653
|
if (drawn >= parts.length) return;
|
|
1635
1654
|
return onShown(() => setDrawn(drawn + step));
|
|
1636
1655
|
}, [drawn, parts.length, step]);
|
|
1637
|
-
return /* @__PURE__ */
|
|
1656
|
+
return /* @__PURE__ */ jsx20(Fragment6, { children: parts.slice(0, drawn) });
|
|
1638
1657
|
}
|
|
1639
1658
|
|
|
1640
1659
|
// src/screens/StatsScreen.tsx
|
|
1641
|
-
import { jsx as
|
|
1660
|
+
import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1642
1661
|
var STATS = "stats";
|
|
1643
1662
|
var ACHIEVEMENTS = "achievements";
|
|
1644
1663
|
var TABS = [
|
|
@@ -1658,10 +1677,10 @@ var MANAGE_OPTION = { value: MANAGE, label: "Manage", icon: "account-cog-outline
|
|
|
1658
1677
|
var STATS_MAX_WIDTH = 640;
|
|
1659
1678
|
function StatsScreen() {
|
|
1660
1679
|
const pickerHost = usePopoverHost3();
|
|
1661
|
-
return /* @__PURE__ */
|
|
1680
|
+
return /* @__PURE__ */ jsx21(StatsPressAway, { host: pickerHost, children: /* @__PURE__ */ jsx21(ScreenFrame4, { portalHost: true, maxContentWidth: STATS_MAX_WIDTH, children: /* @__PURE__ */ jsx21(StatsContent, { pickerHost }) }) });
|
|
1662
1681
|
}
|
|
1663
1682
|
function StatsPressAway({ host, children }) {
|
|
1664
|
-
return /* @__PURE__ */
|
|
1683
|
+
return /* @__PURE__ */ jsx21(View5, { testID: "stats-press-away", style: styles5.screen, onStartShouldSetResponder: () => host.openId !== null, onResponderRelease: host.close, children });
|
|
1665
1684
|
}
|
|
1666
1685
|
var useNoPackReset = () => null;
|
|
1667
1686
|
var noPickerAlign2 = () => void 0;
|
|
@@ -1673,11 +1692,11 @@ function StatsContent({ pickerHost }) {
|
|
|
1673
1692
|
const { profiles, lastSelected } = useProfiles();
|
|
1674
1693
|
const dispatch = useDispatch10();
|
|
1675
1694
|
const fg = pack.foreground ?? colors.onBackground;
|
|
1676
|
-
const [tab, setTab] =
|
|
1677
|
-
const [gameId, setGameId] =
|
|
1695
|
+
const [tab, setTab] = useState9(STATS);
|
|
1696
|
+
const [gameId, setGameId] = useState9(ALL_GAMES2);
|
|
1678
1697
|
const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
|
|
1679
1698
|
const statsPlayer = useStatsPlayer();
|
|
1680
|
-
const [selectedProfileId, setSelectedProfileId] =
|
|
1699
|
+
const [selectedProfileId, setSelectedProfileId] = useState9(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
|
|
1681
1700
|
const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
|
|
1682
1701
|
const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
|
|
1683
1702
|
const pickedTab = homeTabs?.findIndex((_, index) => gameId === tabGames(index)) ?? -1;
|
|
@@ -1687,14 +1706,14 @@ function StatsContent({ pickerHost }) {
|
|
|
1687
1706
|
const packTabs = pack.statsTabs ?? NO_PACK_TABS;
|
|
1688
1707
|
const packTab = packTabs.find((t) => t.value === tab);
|
|
1689
1708
|
const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
|
|
1690
|
-
const playerOptions =
|
|
1691
|
-
const gameOptions =
|
|
1709
|
+
const playerOptions = useMemo9(() => [{ 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]);
|
|
1710
|
+
const gameOptions = useMemo9(() => {
|
|
1692
1711
|
const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
|
|
1693
1712
|
const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
|
|
1694
1713
|
if (!homeTabs) return [all, ...pack.games.map(option)];
|
|
1695
1714
|
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)] }))];
|
|
1696
1715
|
}, [pack.games, homeTabs]);
|
|
1697
|
-
const tabButtons =
|
|
1716
|
+
const tabButtons = useMemo9(() => {
|
|
1698
1717
|
const buttons = packTabs.length > 0 ? [{ value: STATS, label: "Stats" }, ...packTabs.map(({ value, label }) => ({ value, label })), { value: ACHIEVEMENTS, label: "Achievements" }].map((button) => ({ ...button, style: LABEL_WIDE_TAB })) : TABS;
|
|
1699
1718
|
return pack.labelStyle ? buttons.map((button) => ({ ...button, labelStyle: pack.labelStyle })) : buttons;
|
|
1700
1719
|
}, [packTabs, pack.labelStyle]);
|
|
@@ -1710,16 +1729,16 @@ function StatsContent({ pickerHost }) {
|
|
|
1710
1729
|
const surface = pack.Backdrop ? { backgroundColor: colors.surface } : void 0;
|
|
1711
1730
|
const triggerStyle = pack.Backdrop ? [styles5.pill, surface] : void 0;
|
|
1712
1731
|
const PackTabContent = packTab?.Content;
|
|
1713
|
-
return /* @__PURE__ */
|
|
1714
|
-
/* @__PURE__ */
|
|
1715
|
-
/* @__PURE__ */
|
|
1716
|
-
/* @__PURE__ */
|
|
1717
|
-
/* @__PURE__ */
|
|
1718
|
-
showGamePicker && /* @__PURE__ */
|
|
1732
|
+
return /* @__PURE__ */ jsxs8(BaseStatsScreen, { title, titleStyle: pack.titleStyle, onBack: safeBack, insets, onReset: reset.onReset, resetLabel: reset.label, resetConfirmTitle: reset.title, resetConfirmBody: reset.body, fg: pack.foreground, bg: pack.Backdrop ? "transparent" : void 0, children: [
|
|
1733
|
+
/* @__PURE__ */ jsx21(PressAwayOverlay3, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles5.pressAway }),
|
|
1734
|
+
/* @__PURE__ */ jsx21(SegmentedButtons2, { value: tab, onValueChange: setTab, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles5.tabs, surface] }),
|
|
1735
|
+
/* @__PURE__ */ jsxs8(View5, { style: [styles5.filters, pickerHost.openId !== null && styles5.filtersOpen], onStartShouldSetResponder: () => pickerHost.openId !== null, children: [
|
|
1736
|
+
/* @__PURE__ */ jsx21(OptionPicker2, { id: PLAYER_PICKER_ID, host: pickerHost, options: playerOptions, value: profileId ?? EVERYONE, onChange: (value) => value === MANAGE ? router6.push(PROFILES_HREF) : setSelectedProfileId(value === EVERYONE ? null : value), color: colors.primary, dark, icon: profileId ? "account" : "account-group", caption: "Player", alignOverride: playerAlign, triggerStyle }),
|
|
1737
|
+
showGamePicker && /* @__PURE__ */ jsx21(OptionPicker2, { id: GAME_PICKER_ID, host: pickerHost, options: gameOptions, value: gameId, onChange: setGameId, color: colors.primary, dark, icon: "view-grid-outline", caption: "Game", alignOverride: gameAlign, triggerStyle })
|
|
1719
1738
|
] }),
|
|
1720
|
-
tab === STATS && pack.StatsSections && /* @__PURE__ */
|
|
1721
|
-
PackTabContent && /* @__PURE__ */
|
|
1722
|
-
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */
|
|
1739
|
+
tab === STATS && pack.StatsSections && /* @__PURE__ */ jsx21(pack.StatsSections, { profileId, gameId: oneGameId, gameIds }),
|
|
1740
|
+
PackTabContent && /* @__PURE__ */ jsx21(PackTabContent, { profileId, gameId: oneGameId, gameIds }),
|
|
1741
|
+
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */ jsx21(pack.AchievementList, { profileId }) : (tab === STATS || tab === ACHIEVEMENTS) && /* @__PURE__ */ jsx21(Staged, { first: tab === STATS && pack.StatsSections ? 0 : 1, children: games.map((game) => /* @__PURE__ */ jsx21(GameStats, { game, tab, profileId, showTitle: games.length > 1 && pack.statsGameTitles !== false, titleColor: fg }, game.id)) }, `${tab} ${gameId}`)
|
|
1723
1742
|
] });
|
|
1724
1743
|
}
|
|
1725
1744
|
function resetFor(pack, packReset, profileId, profiles, games, resetGames) {
|
|
@@ -1735,9 +1754,9 @@ function GameStats({ game, tab, profileId, showTitle, titleColor }) {
|
|
|
1735
1754
|
const { StatsSections, AchievementList } = game;
|
|
1736
1755
|
const Sections = tab === STATS ? StatsSections : AchievementList;
|
|
1737
1756
|
if (!Sections) return null;
|
|
1738
|
-
return /* @__PURE__ */
|
|
1739
|
-
showTitle && /* @__PURE__ */
|
|
1740
|
-
/* @__PURE__ */
|
|
1757
|
+
return /* @__PURE__ */ jsxs8(View5, { style: styles5.game, children: [
|
|
1758
|
+
showTitle && /* @__PURE__ */ jsx21(Text3, { variant: "titleLarge", style: [styles5.gameTitle, { color: titleColor }, titleStyle], children: game.title }),
|
|
1759
|
+
/* @__PURE__ */ jsx21(Sections, { profileId })
|
|
1741
1760
|
] });
|
|
1742
1761
|
}
|
|
1743
1762
|
var styles5 = StyleSheet5.create({
|
|
@@ -1775,10 +1794,10 @@ var styles5 = StyleSheet5.create({
|
|
|
1775
1794
|
|
|
1776
1795
|
// src/components/imageGameIcon.tsx
|
|
1777
1796
|
import { Image } from "react-native";
|
|
1778
|
-
import { jsx as
|
|
1797
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1779
1798
|
function imageGameIcon(images) {
|
|
1780
1799
|
return function ImageGameIcon({ size, dark }) {
|
|
1781
|
-
return /* @__PURE__ */
|
|
1800
|
+
return /* @__PURE__ */ jsx22(Image, { source: dark ? images.dark : images.light, style: { height: size, width: size }, accessibilityIgnoresInvertColors: true });
|
|
1782
1801
|
};
|
|
1783
1802
|
}
|
|
1784
1803
|
|
|
@@ -1789,7 +1808,7 @@ import { useEffect as useEffect8 } from "react";
|
|
|
1789
1808
|
import { StyleSheet as StyleSheet6, useWindowDimensions as useWindowDimensions2 } from "react-native";
|
|
1790
1809
|
import Animated2, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
1791
1810
|
import { useSafeAreaInsets as useSafeAreaInsets5 } from "react-native-safe-area-context";
|
|
1792
|
-
import { Fragment as Fragment7, jsx as
|
|
1811
|
+
import { Fragment as Fragment7, jsx as jsx23, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1793
1812
|
var MATCH_CHIPS_FADE_MS = 150;
|
|
1794
1813
|
var CHIP_SIZE = 48;
|
|
1795
1814
|
var EDGE_PAD = 8;
|
|
@@ -1811,9 +1830,9 @@ function MatchChips({ playing, faceToFace, centerLineY, onBack, onSettings }) {
|
|
|
1811
1830
|
const backSlot = { top, left: EDGE_PAD + insets.left };
|
|
1812
1831
|
const settingsSlot = { top, right: EDGE_PAD + insets.right };
|
|
1813
1832
|
const pointerEvents = visible ? "box-none" : "none";
|
|
1814
|
-
return /* @__PURE__ */
|
|
1815
|
-
/* @__PURE__ */
|
|
1816
|
-
/* @__PURE__ */
|
|
1833
|
+
return /* @__PURE__ */ jsxs9(Fragment7, { children: [
|
|
1834
|
+
/* @__PURE__ */ jsx23(Animated2.View, { pointerEvents, style: [styles6.slot, backSlot, fadeStyle], testID: "match-chips-back", children: /* @__PURE__ */ jsx23(IconButton2, { icon: "arrow-left", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onBack, accessibilityLabel: "Back" }) }),
|
|
1835
|
+
/* @__PURE__ */ jsx23(Animated2.View, { pointerEvents, style: [styles6.slot, settingsSlot, fadeStyle], testID: "match-chips-settings", children: /* @__PURE__ */ jsx23(IconButton2, { icon: "cog", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onSettings, accessibilityLabel: "Settings" }) })
|
|
1817
1836
|
] });
|
|
1818
1837
|
}
|
|
1819
1838
|
var styles6 = StyleSheet6.create({
|
|
@@ -1822,9 +1841,9 @@ var styles6 = StyleSheet6.create({
|
|
|
1822
1841
|
});
|
|
1823
1842
|
|
|
1824
1843
|
// src/hooks/useActiveRound.ts
|
|
1825
|
-
import { useSelector as
|
|
1844
|
+
import { useSelector as useSelector9 } from "react-redux";
|
|
1826
1845
|
function useActiveRound(game, defaults) {
|
|
1827
|
-
const round =
|
|
1846
|
+
const round = useSelector9((state) => state.liveplay.activeRound);
|
|
1828
1847
|
const choices = usePackGame(game)?.seatTwo;
|
|
1829
1848
|
if (!round || round.game !== game) return { mode: roundModeFor(seatTwoFor(DEFAULT_OPPONENT.seatTwo, choices)), settings: defaults };
|
|
1830
1849
|
return { mode: round.mode, settings: { ...defaults, ...round.settings } };
|
|
@@ -1832,11 +1851,11 @@ function useActiveRound(game, defaults) {
|
|
|
1832
1851
|
|
|
1833
1852
|
// src/hooks/useBackBlock.ts
|
|
1834
1853
|
import { usePreventRemove } from "expo-router";
|
|
1835
|
-
import { useCallback as
|
|
1854
|
+
import { useCallback as useCallback12, useEffect as useEffect9, useRef as useRef6, useState as useState10 } from "react";
|
|
1836
1855
|
function useBackBlock(held, onHeld, leave = safeBack) {
|
|
1837
|
-
const leavingRef =
|
|
1838
|
-
const [leaving, setLeaving] =
|
|
1839
|
-
const leaveRef =
|
|
1856
|
+
const leavingRef = useRef6(false);
|
|
1857
|
+
const [leaving, setLeaving] = useState10(false);
|
|
1858
|
+
const leaveRef = useRef6(leave);
|
|
1840
1859
|
useEffect9(() => {
|
|
1841
1860
|
leaveRef.current = leave;
|
|
1842
1861
|
});
|
|
@@ -1846,7 +1865,7 @@ function useBackBlock(held, onHeld, leave = safeBack) {
|
|
|
1846
1865
|
repeat();
|
|
1847
1866
|
} else onHeld();
|
|
1848
1867
|
});
|
|
1849
|
-
return
|
|
1868
|
+
return useCallback12(() => {
|
|
1850
1869
|
leavingRef.current = true;
|
|
1851
1870
|
leaveRef.current();
|
|
1852
1871
|
}, []);
|
|
@@ -1981,8 +2000,8 @@ function forgetProfileAchievements(dropStats) {
|
|
|
1981
2000
|
|
|
1982
2001
|
// src/gameStats.tsx
|
|
1983
2002
|
import { createAchievementsSlice, mapUnlocksBySeat, useAchievements } from "@tastic/achievements";
|
|
1984
|
-
import { createContext as
|
|
1985
|
-
import { jsx as
|
|
2003
|
+
import { createContext as createContext7, useCallback as useCallback13, useContext as useContext7, useMemo as useMemo10 } from "react";
|
|
2004
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
1986
2005
|
var SEATS = [1, 2];
|
|
1987
2006
|
function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
|
|
1988
2007
|
const { actions: actions6, reducer: sliceReducer } = createAchievementsSlice({
|
|
@@ -1999,7 +2018,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
1999
2018
|
};
|
|
2000
2019
|
const reducer6 = onProfileRemoved(sliceReducer, forgetProfileAchievements(dropProfileStats));
|
|
2001
2020
|
const profileViews = (stats) => Object.fromEntries(Object.entries(stats.profiles).map(([profileId, bucket]) => [profileId, getProfileStatsView(bucket)]));
|
|
2002
|
-
const Context =
|
|
2021
|
+
const Context = createContext7(null);
|
|
2003
2022
|
function Provider({ children }) {
|
|
2004
2023
|
const { stats, unlockedAchievements, recordOutcome, resetAll } = useAchievements({
|
|
2005
2024
|
catalog,
|
|
@@ -2007,18 +2026,18 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
2007
2026
|
actions: actions6,
|
|
2008
2027
|
profileViews
|
|
2009
2028
|
});
|
|
2010
|
-
const record =
|
|
2029
|
+
const record = useCallback13(
|
|
2011
2030
|
(update, profileIds) => {
|
|
2012
2031
|
const result = recordOutcome(update);
|
|
2013
2032
|
return { device: result.device, profiles: mapUnlocksBySeat(SEATS, profileIds, result.profiles) };
|
|
2014
2033
|
},
|
|
2015
2034
|
[recordOutcome]
|
|
2016
2035
|
);
|
|
2017
|
-
const value =
|
|
2018
|
-
return /* @__PURE__ */
|
|
2036
|
+
const value = useMemo10(() => ({ stats, unlockedAchievements, record, resetAll }), [stats, unlockedAchievements, record, resetAll]);
|
|
2037
|
+
return /* @__PURE__ */ jsx24(Context.Provider, { value, children });
|
|
2019
2038
|
}
|
|
2020
2039
|
function useStats() {
|
|
2021
|
-
const ctx =
|
|
2040
|
+
const ctx = useContext7(Context);
|
|
2022
2041
|
if (!ctx) throw new Error(`The ${key} stats are read within their game's Provider`);
|
|
2023
2042
|
return ctx;
|
|
2024
2043
|
}
|
|
@@ -2026,8 +2045,8 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
2026
2045
|
}
|
|
2027
2046
|
|
|
2028
2047
|
// src/playerSettings.ts
|
|
2029
|
-
import { useCallback as
|
|
2030
|
-
import { useDispatch as useDispatch11, useSelector as
|
|
2048
|
+
import { useCallback as useCallback14, useMemo as useMemo11 } from "react";
|
|
2049
|
+
import { useDispatch as useDispatch11, useSelector as useSelector10 } from "react-redux";
|
|
2031
2050
|
var SEATS2 = [1, 2];
|
|
2032
2051
|
function seatPlayerKey(selection, seat) {
|
|
2033
2052
|
return selection[seat] ?? `guest:${seat}`;
|
|
@@ -2065,13 +2084,13 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
|
|
|
2065
2084
|
return compose(root[settingsKey], root[controlsKey], state.profileSelection, state.opponent.seatTwo === "person");
|
|
2066
2085
|
}
|
|
2067
2086
|
function useSettings() {
|
|
2068
|
-
const selection =
|
|
2069
|
-
const seatTwoIsPerson =
|
|
2070
|
-
const saved =
|
|
2071
|
-
const controls =
|
|
2087
|
+
const selection = useSelector10((state) => state.profileSelection);
|
|
2088
|
+
const seatTwoIsPerson = useSelector10((state) => state.opponent.seatTwo === "person");
|
|
2089
|
+
const saved = useSelector10((state) => state[settingsKey]);
|
|
2090
|
+
const controls = useSelector10((state) => state[controlsKey]);
|
|
2072
2091
|
const dispatch = useDispatch11();
|
|
2073
|
-
const settings =
|
|
2074
|
-
const setSettings =
|
|
2092
|
+
const settings = useMemo11(() => compose(saved, controls, selection, seatTwoIsPerson), [saved, controls, selection, seatTwoIsPerson]);
|
|
2093
|
+
const setSettings = useCallback14(
|
|
2075
2094
|
(next) => {
|
|
2076
2095
|
const { controlScheme, ...changes } = next;
|
|
2077
2096
|
if (Object.keys(changes).length > 0) dispatch(patch(seatPlayerKey(selection, 1), changes));
|
|
@@ -2135,6 +2154,7 @@ export {
|
|
|
2135
2154
|
useAtComputer,
|
|
2136
2155
|
useBackBlock,
|
|
2137
2156
|
useGameGuide,
|
|
2157
|
+
useGuideCovering,
|
|
2138
2158
|
useOpponent,
|
|
2139
2159
|
usePack,
|
|
2140
2160
|
usePackGame,
|