@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.js
CHANGED
|
@@ -77,6 +77,7 @@ __export(index_exports, {
|
|
|
77
77
|
useAtComputer: () => useAtComputer,
|
|
78
78
|
useBackBlock: () => useBackBlock,
|
|
79
79
|
useGameGuide: () => useGameGuide,
|
|
80
|
+
useGuideCovering: () => useGuideCovering,
|
|
80
81
|
useOpponent: () => useOpponent,
|
|
81
82
|
usePack: () => usePack,
|
|
82
83
|
usePackGame: () => usePackGame,
|
|
@@ -111,7 +112,7 @@ var import_chrome2 = require("@tastic/hud/chrome");
|
|
|
111
112
|
var import_profile3 = require("@tastic/profile");
|
|
112
113
|
var Haptics = __toESM(require("expo-haptics"));
|
|
113
114
|
var import_expo_router = require("expo-router");
|
|
114
|
-
var
|
|
115
|
+
var import_react10 = require("react");
|
|
115
116
|
var import_react_native3 = require("react-native");
|
|
116
117
|
var import_react_native_gesture_handler = require("react-native-gesture-handler");
|
|
117
118
|
var RNPaper2 = __toESM(require("react-native-paper"));
|
|
@@ -140,6 +141,10 @@ function Fonts({ children }) {
|
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
// src/components/GuideHost.tsx
|
|
144
|
+
var import_react3 = require("react");
|
|
145
|
+
var import_react_redux2 = require("react-redux");
|
|
146
|
+
|
|
147
|
+
// src/components/GuideCards.tsx
|
|
143
148
|
var import_core = require("@tastic/core");
|
|
144
149
|
var import_guide = require("@tastic/hud/guide");
|
|
145
150
|
var import_react2 = require("react");
|
|
@@ -159,84 +164,74 @@ function humanSeatsFor(mode) {
|
|
|
159
164
|
}
|
|
160
165
|
var GUEST_PLAYER_ID = "guest";
|
|
161
166
|
|
|
162
|
-
// src/components/
|
|
167
|
+
// src/components/GuideCards.tsx
|
|
163
168
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
164
169
|
var PACK_GUIDE = "__pack__";
|
|
170
|
+
function startSubject(pack, game) {
|
|
171
|
+
if (game.guide) return game.guide.atStart ? game.id : null;
|
|
172
|
+
return pack.guide ? PACK_GUIDE : null;
|
|
173
|
+
}
|
|
174
|
+
function guideFor(pack, subject) {
|
|
175
|
+
return subject === PACK_GUIDE ? pack.guide : pack.games.find((g) => g.id === subject)?.guide;
|
|
176
|
+
}
|
|
165
177
|
var NO_INPUT = {};
|
|
166
|
-
|
|
167
|
-
function GuideHost({ children }) {
|
|
178
|
+
function GuideCards({ subject, visible, onClose }) {
|
|
168
179
|
const pack = usePack();
|
|
169
|
-
const [subject, setSubject] = (0, import_react2.useState)(() => pack.guide ? PACK_GUIDE : pack.games.find((g) => g.guide)?.id ?? null);
|
|
170
180
|
const packGuide = subject === PACK_GUIDE ? pack.guide : void 0;
|
|
171
181
|
const game = subject === PACK_GUIDE ? void 0 : pack.games.find((g) => g.id === subject);
|
|
172
182
|
const gameGuide = game?.guide;
|
|
183
|
+
const guide = packGuide ?? gameGuide;
|
|
173
184
|
const touch = (0, import_core.useIsTouchPrimaryDevice)();
|
|
174
185
|
const seatTwo = (0, import_react_redux.useSelector)((state) => state.opponent.seatTwo);
|
|
175
186
|
const input = (0, import_react_redux.useSelector)((state) => gameGuide ? gameGuide.selectInput(state) : NO_INPUT, import_react_redux.shallowEqual);
|
|
176
|
-
const
|
|
187
|
+
const seen = (0, import_react_redux.useSelector)((state) => !guide || guide.selectVersionSeen(state) >= guide.version);
|
|
177
188
|
const dispatch = (0, import_react_redux.useDispatch)();
|
|
178
189
|
const mode = roundModeFor(seatTwoFor(seatTwo, game?.seatTwo));
|
|
179
190
|
const steps = (0, import_react2.useMemo)(() => packGuide ? packGuide.getSteps({ touch }) : gameGuide ? gameGuide.getSteps(input, { touch, mode }) : [], [packGuide, gameGuide, input, touch, mode]);
|
|
180
|
-
const
|
|
181
|
-
(version)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
);
|
|
187
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_guide.GuideProvider, { steps, currentVersion: (packGuide ?? gameGuide)?.version ?? 0, seenVersion, onSeen, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GameGuideBridge, { onPick: setSubject, children }) });
|
|
191
|
+
const close = (0, import_react2.useCallback)(() => {
|
|
192
|
+
if (guide && !seen) dispatch(guide.markSeen(guide.version));
|
|
193
|
+
onClose?.();
|
|
194
|
+
}, [guide, seen, dispatch, onClose]);
|
|
195
|
+
const Dialog = pack.HowToPlay ?? import_guide.HowToPlayDialog;
|
|
196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dialog, { visible, steps, onFinish: close, onSkip: close });
|
|
188
197
|
}
|
|
189
|
-
|
|
198
|
+
|
|
199
|
+
// src/components/GuideHost.tsx
|
|
200
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
201
|
+
var GameGuideContext = (0, import_react3.createContext)(null);
|
|
202
|
+
function GuideHost({ children }) {
|
|
190
203
|
const pack = usePack();
|
|
191
|
-
const store = (0,
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const wasOpen = (0, import_react2.useRef)(false);
|
|
195
|
-
const packAutoShown = (0, import_react2.useRef)(false);
|
|
196
|
-
(0, import_react2.useEffect)(() => {
|
|
197
|
-
if (wasOpen.current && !isOpen && pendingNext.current) {
|
|
198
|
-
const next = pendingNext.current;
|
|
199
|
-
pendingNext.current = null;
|
|
200
|
-
next();
|
|
201
|
-
}
|
|
202
|
-
wasOpen.current = isOpen;
|
|
203
|
-
}, [isOpen]);
|
|
204
|
-
const openFor = (0, import_react2.useCallback)(
|
|
204
|
+
const store = (0, import_react_redux2.useStore)();
|
|
205
|
+
const [shown, setShown] = (0, import_react3.useState)(null);
|
|
206
|
+
const openFor = (0, import_react3.useCallback)(
|
|
205
207
|
(gameId) => {
|
|
206
|
-
if (
|
|
207
|
-
onPick(gameId);
|
|
208
|
-
open();
|
|
208
|
+
if (guideFor(pack, gameId)) setShown({ subject: gameId });
|
|
209
209
|
},
|
|
210
|
-
[pack
|
|
210
|
+
[pack]
|
|
211
211
|
);
|
|
212
|
-
const openFirstTime = (0,
|
|
212
|
+
const openFirstTime = (0, import_react3.useCallback)(
|
|
213
213
|
(gameId, next) => {
|
|
214
214
|
const guide = pack.games.find((g) => g.id === gameId)?.guide;
|
|
215
|
-
if (!guide || guide.selectVersionSeen(store.getState()) >= guide.version)
|
|
216
|
-
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
pendingNext.current = next;
|
|
220
|
-
openFor(gameId);
|
|
215
|
+
if (!guide || guide.atStart || guide.selectVersionSeen(store.getState()) >= guide.version) next();
|
|
216
|
+
else setShown({ subject: gameId, next });
|
|
221
217
|
},
|
|
222
|
-
[pack, store
|
|
218
|
+
[pack, store]
|
|
223
219
|
);
|
|
224
|
-
const openPack = (0,
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GameGuideContext.Provider, { value, children });
|
|
220
|
+
const openPack = (0, import_react3.useCallback)(() => {
|
|
221
|
+
if (pack.guide) setShown({ subject: PACK_GUIDE });
|
|
222
|
+
}, [pack]);
|
|
223
|
+
const handleClose = (0, import_react3.useCallback)(() => {
|
|
224
|
+
setShown(null);
|
|
225
|
+
shown?.next?.();
|
|
226
|
+
}, [shown]);
|
|
227
|
+
const value = (0, import_react3.useMemo)(() => ({ openFirstTime, openFor, openPack }), [openFirstTime, openFor, openPack]);
|
|
228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(GameGuideContext.Provider, { value, children: [
|
|
229
|
+
children,
|
|
230
|
+
shown && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GuideCards, { subject: shown.subject, visible: true, onClose: handleClose })
|
|
231
|
+
] });
|
|
237
232
|
}
|
|
238
233
|
function useGameGuide() {
|
|
239
|
-
const ctx = (0,
|
|
234
|
+
const ctx = (0, import_react3.useContext)(GameGuideContext);
|
|
240
235
|
if (!ctx) throw new Error("useGameGuide must be used within a GuideHost");
|
|
241
236
|
return ctx;
|
|
242
237
|
}
|
|
@@ -247,42 +242,42 @@ var import_feedback_press = require("@rific/feedback-press");
|
|
|
247
242
|
var import_audio = require("@rific/feedback-press/audio");
|
|
248
243
|
var import_edge_guard = require("@tastic/edge-guard");
|
|
249
244
|
var ExpoKeepAwake = __toESM(require("expo-keep-awake"));
|
|
250
|
-
var
|
|
245
|
+
var import_react4 = require("react");
|
|
251
246
|
var RNPaper = __toESM(require("react-native-paper"));
|
|
252
|
-
var
|
|
253
|
-
var
|
|
254
|
-
var
|
|
247
|
+
var import_react_redux3 = require("react-redux");
|
|
248
|
+
var import_react5 = require("redux-persist/integration/react");
|
|
249
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
255
250
|
function useShellFeedbackSounds() {
|
|
256
|
-
const enabled = (0,
|
|
251
|
+
const enabled = (0, import_react_redux3.useSelector)((state) => state.sound.enabled);
|
|
257
252
|
const selection = (0, import_audio.useAudioPool)(require("./select-MLBNNA4N.wav"), { enabled });
|
|
258
253
|
const notification = (0, import_audio.useAudioPool)(require("./notification-CGGFPYK7.wav"), { enabled });
|
|
259
254
|
return { selection, notification };
|
|
260
255
|
}
|
|
261
256
|
var FeedbackBridge = ({ children }) => {
|
|
262
|
-
const haptic = (0,
|
|
263
|
-
const sound = (0,
|
|
264
|
-
const dispatch = (0,
|
|
265
|
-
const onChange = (0,
|
|
266
|
-
const onSoundChange = (0,
|
|
257
|
+
const haptic = (0, import_react_redux3.useSelector)((state) => state.haptic);
|
|
258
|
+
const sound = (0, import_react_redux3.useSelector)((state) => state.sound);
|
|
259
|
+
const dispatch = (0, import_react_redux3.useDispatch)();
|
|
260
|
+
const onChange = (0, import_react4.useCallback)((next) => dispatch(import_feedback_press.hapticActions.initialize(next)), [dispatch]);
|
|
261
|
+
const onSoundChange = (0, import_react4.useCallback)((next) => dispatch(import_feedback_press.soundActions.initialize(next)), [dispatch]);
|
|
267
262
|
const { useFeedbackSounds = useShellFeedbackSounds } = usePack();
|
|
268
263
|
const sounds = useFeedbackSounds();
|
|
269
264
|
const bridgeProps = (0, import_feedback_press.useFeedbackBridgeProps)({ initialValue: haptic, onChange, soundInitialValue: sound, onSoundChange, sound: sounds });
|
|
270
|
-
return /* @__PURE__ */ (0,
|
|
265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_feedback_press.FeedbackPressProvider, { ...bridgeProps, paper: RNPaper, children });
|
|
271
266
|
};
|
|
272
267
|
var EdgeGuardBridge = ({ children }) => {
|
|
273
|
-
const deferBottomEdgeGestures = (0,
|
|
274
|
-
const activelyPlaying = (0,
|
|
268
|
+
const deferBottomEdgeGestures = (0, import_react_redux3.useSelector)((state) => state.appSettings.deferBottomEdgeGestures);
|
|
269
|
+
const activelyPlaying = (0, import_react_redux3.useSelector)((state) => state.liveplay.activelyPlaying);
|
|
275
270
|
(0, import_edge_guard.useEdgeGestureGuard)(deferBottomEdgeGestures && activelyPlaying);
|
|
276
|
-
return /* @__PURE__ */ (0,
|
|
271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children });
|
|
277
272
|
};
|
|
278
273
|
var KeepAwakeBridge = ({ children }) => {
|
|
279
|
-
const keepAwake = (0,
|
|
280
|
-
const dispatch = (0,
|
|
281
|
-
const onChange = (0,
|
|
282
|
-
return /* @__PURE__ */ (0,
|
|
274
|
+
const keepAwake = (0, import_react_redux3.useSelector)((state) => state.keepAwake);
|
|
275
|
+
const dispatch = (0, import_react_redux3.useDispatch)();
|
|
276
|
+
const onChange = (0, import_react4.useCallback)((settings) => dispatch(import_core2.keepAwakeActions.initialize(settings)), [dispatch]);
|
|
277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core2.KeepAwakeProvider, { expoKeepAwake: ExpoKeepAwake, initialValue: keepAwake, onChange, children });
|
|
283
278
|
};
|
|
284
279
|
function Providers({ store, persistor, children }) {
|
|
285
|
-
return /* @__PURE__ */ (0,
|
|
280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_redux3.Provider, { store, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.PersistGate, { persistor, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EdgeGuardBridge, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FeedbackBridge, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(KeepAwakeBridge, { children }) }) }) }) });
|
|
286
281
|
}
|
|
287
282
|
|
|
288
283
|
// src/components/Theme.tsx
|
|
@@ -290,44 +285,44 @@ var import_masked_view = __toESM(require("@react-native-masked-view/masked-view"
|
|
|
290
285
|
var import_auto_paper = require("@rific/auto-paper");
|
|
291
286
|
var ExpoBlur = __toESM(require("expo-blur"));
|
|
292
287
|
var SplashScreen = __toESM(require("expo-splash-screen"));
|
|
293
|
-
var
|
|
288
|
+
var import_react6 = require("react");
|
|
294
289
|
var import_react_native_reanimated = __toESM(require("react-native-reanimated"));
|
|
295
|
-
var
|
|
296
|
-
var
|
|
290
|
+
var import_react_redux4 = require("react-redux");
|
|
291
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
297
292
|
SplashScreen.preventAutoHideAsync();
|
|
298
293
|
SplashScreen.setOptions({ fade: true, duration: 400 });
|
|
299
294
|
function Theme({ children }) {
|
|
300
295
|
const { fontFamily } = usePack();
|
|
301
|
-
const settings = (0,
|
|
302
|
-
const dispatch = (0,
|
|
303
|
-
const onReady = (0,
|
|
304
|
-
const onChange = (0,
|
|
296
|
+
const settings = (0, import_react_redux4.useSelector)((state) => state.theme, import_react_redux4.shallowEqual);
|
|
297
|
+
const dispatch = (0, import_react_redux4.useDispatch)();
|
|
298
|
+
const onReady = (0, import_react6.useCallback)(() => markSplashReady("theme"), []);
|
|
299
|
+
const onChange = (0, import_react6.useCallback)((next) => dispatch(import_auto_paper.themeActions.initialize(next)), [dispatch]);
|
|
305
300
|
const bridgeProps = (0, import_auto_paper.useThemeBridgeProps)({ initialValue: settings, onChange, onReady });
|
|
306
|
-
return /* @__PURE__ */ (0,
|
|
301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_auto_paper.Provider, { ...bridgeProps, expoBlur: ExpoBlur, maskedView: import_masked_view.default, statusBar: false, reanimated: import_react_native_reanimated.default, fontFamily, children });
|
|
307
302
|
}
|
|
308
303
|
|
|
309
304
|
// src/components/UpdateDialog.tsx
|
|
310
305
|
var import_toaster = require("@rific/toaster");
|
|
311
306
|
var import_chrome = require("@tastic/hud/chrome");
|
|
312
|
-
var
|
|
307
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
313
308
|
function UpdateDialog() {
|
|
314
309
|
const onError = (0, import_toaster.useUpdateErrorToast)();
|
|
315
|
-
return /* @__PURE__ */ (0,
|
|
310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_chrome.UpdateDialog, { onError });
|
|
316
311
|
}
|
|
317
312
|
|
|
318
313
|
// src/components/WindowControlsInsets.tsx
|
|
319
314
|
var import_react_native2 = require("react-native");
|
|
320
315
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
321
|
-
var
|
|
316
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
322
317
|
function WindowControlsInsets({ children }) {
|
|
323
318
|
const vertical = (0, import_react_native_safe_area_context.useSafeAreaInsets)({ cornerAdaptation: "vertical" });
|
|
324
|
-
if (import_react_native2.Platform.OS !== "ios" || !import_react_native2.Platform.isPad) return /* @__PURE__ */ (0,
|
|
325
|
-
return /* @__PURE__ */ (0,
|
|
319
|
+
if (import_react_native2.Platform.OS !== "ios" || !import_react_native2.Platform.isPad) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
|
|
320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native_safe_area_context.SafeAreaInsetsContext.Provider, { value: vertical, children });
|
|
326
321
|
}
|
|
327
322
|
|
|
328
323
|
// src/hooks/useAppSettings.ts
|
|
329
|
-
var
|
|
330
|
-
var
|
|
324
|
+
var import_react7 = require("react");
|
|
325
|
+
var import_react_redux5 = require("react-redux");
|
|
331
326
|
|
|
332
327
|
// src/redux/appSettingsSlice.ts
|
|
333
328
|
var import_core3 = require("@rific/core");
|
|
@@ -344,9 +339,9 @@ var appSettingsSlice_default = reducer;
|
|
|
344
339
|
|
|
345
340
|
// src/hooks/useAppSettings.ts
|
|
346
341
|
function useAppSettings() {
|
|
347
|
-
const settings = (0,
|
|
348
|
-
const dispatch = (0,
|
|
349
|
-
const setSettings = (0,
|
|
342
|
+
const settings = (0, import_react_redux5.useSelector)((state) => state.appSettings);
|
|
343
|
+
const dispatch = (0, import_react_redux5.useDispatch)();
|
|
344
|
+
const setSettings = (0, import_react7.useCallback)(
|
|
350
345
|
(patch) => {
|
|
351
346
|
dispatch(appSettingsActions.initialize(patch));
|
|
352
347
|
},
|
|
@@ -356,8 +351,8 @@ function useAppSettings() {
|
|
|
356
351
|
}
|
|
357
352
|
|
|
358
353
|
// src/hooks/useLastActiveGame.tsx
|
|
359
|
-
var
|
|
360
|
-
var
|
|
354
|
+
var import_react8 = require("react");
|
|
355
|
+
var import_react_redux6 = require("react-redux");
|
|
361
356
|
|
|
362
357
|
// src/redux/lastActiveGameSlice.ts
|
|
363
358
|
var import_core4 = require("@rific/core");
|
|
@@ -366,17 +361,17 @@ var lastActiveGameActions = actions2;
|
|
|
366
361
|
var lastActiveGameSlice_default = reducer2;
|
|
367
362
|
|
|
368
363
|
// src/hooks/useLastActiveGame.tsx
|
|
369
|
-
var
|
|
370
|
-
var LastActiveGameContext = (0,
|
|
364
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
365
|
+
var LastActiveGameContext = (0, import_react8.createContext)(null);
|
|
371
366
|
function LastActiveGameProvider({ children }) {
|
|
372
|
-
const store = (0,
|
|
373
|
-
const dispatch = (0,
|
|
374
|
-
const [initial] = (0,
|
|
375
|
-
const pendingResume = (0,
|
|
376
|
-
const persisted = (0,
|
|
377
|
-
const resume = (0,
|
|
378
|
-
const resumeListeners = (0,
|
|
379
|
-
const value = (0,
|
|
367
|
+
const store = (0, import_react_redux6.useStore)();
|
|
368
|
+
const dispatch = (0, import_react_redux6.useDispatch)();
|
|
369
|
+
const [initial] = (0, import_react8.useState)(() => store.getState().lastActiveGame?.gameId ?? null);
|
|
370
|
+
const pendingResume = (0, import_react8.useRef)(initial);
|
|
371
|
+
const persisted = (0, import_react8.useRef)(initial);
|
|
372
|
+
const resume = (0, import_react8.useRef)("idle");
|
|
373
|
+
const resumeListeners = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
|
|
374
|
+
const value = (0, import_react8.useMemo)(() => {
|
|
380
375
|
const setResume = (next) => {
|
|
381
376
|
if (resume.current === next) return;
|
|
382
377
|
resume.current = next;
|
|
@@ -416,18 +411,18 @@ function LastActiveGameProvider({ children }) {
|
|
|
416
411
|
}
|
|
417
412
|
};
|
|
418
413
|
}, [dispatch]);
|
|
419
|
-
return /* @__PURE__ */ (0,
|
|
414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LastActiveGameContext.Provider, { value, children });
|
|
420
415
|
}
|
|
421
416
|
function useLastActiveGame() {
|
|
422
|
-
const ctx = (0,
|
|
417
|
+
const ctx = (0, import_react8.useContext)(LastActiveGameContext);
|
|
423
418
|
if (!ctx) throw new Error("useLastActiveGame must be used within a LastActiveGameProvider");
|
|
424
419
|
return ctx;
|
|
425
420
|
}
|
|
426
421
|
|
|
427
422
|
// src/hooks/useProfiles.tsx
|
|
428
423
|
var import_profile2 = require("@tastic/profile");
|
|
429
|
-
var
|
|
430
|
-
var
|
|
424
|
+
var import_react9 = require("react");
|
|
425
|
+
var import_react_redux7 = require("react-redux");
|
|
431
426
|
|
|
432
427
|
// src/redux/profileSelectionSlice.ts
|
|
433
428
|
var import_profile = require("@tastic/profile");
|
|
@@ -437,15 +432,15 @@ var profileSelectionActions = actions3;
|
|
|
437
432
|
var profileSelectionSlice_default = reducer3;
|
|
438
433
|
|
|
439
434
|
// src/hooks/useProfiles.tsx
|
|
440
|
-
var
|
|
435
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
441
436
|
var SHARED_GROUP_ID = "group.com.infinitetoken.tastic";
|
|
442
|
-
var ProfilesContext = (0,
|
|
437
|
+
var ProfilesContext = (0, import_react9.createContext)(null);
|
|
443
438
|
function ProfilesProvider({ children }) {
|
|
444
|
-
const profiles = (0,
|
|
445
|
-
const lastSelected = (0,
|
|
446
|
-
const dispatch = (0,
|
|
447
|
-
const [loaded, setLoaded] = (0,
|
|
448
|
-
(0,
|
|
439
|
+
const profiles = (0, import_react_redux7.useSelector)((state) => state.profiles);
|
|
440
|
+
const lastSelected = (0, import_react_redux7.useSelector)((state) => state.profileSelection);
|
|
441
|
+
const dispatch = (0, import_react_redux7.useDispatch)();
|
|
442
|
+
const [loaded, setLoaded] = (0, import_react9.useState)(false);
|
|
443
|
+
(0, import_react9.useEffect)(() => {
|
|
449
444
|
let cancelled = false;
|
|
450
445
|
(0, import_profile2.resolveInitialProfiles)(SHARED_GROUP_ID, profiles).then((resolved) => {
|
|
451
446
|
if (cancelled) return;
|
|
@@ -459,7 +454,7 @@ function ProfilesProvider({ children }) {
|
|
|
459
454
|
}, []);
|
|
460
455
|
const { syncToShared } = (0, import_profile2.useSharedProfilesSync)({
|
|
461
456
|
groupId: SHARED_GROUP_ID,
|
|
462
|
-
onRemoteChange: (0,
|
|
457
|
+
onRemoteChange: (0, import_react9.useCallback)(
|
|
463
458
|
(remote) => {
|
|
464
459
|
dispatch(import_profile2.profilesActions.setAll(remote));
|
|
465
460
|
dispatch(profileSelectionActions.pruneToRoster(remote.map((p) => p.id)));
|
|
@@ -467,7 +462,7 @@ function ProfilesProvider({ children }) {
|
|
|
467
462
|
[dispatch]
|
|
468
463
|
)
|
|
469
464
|
});
|
|
470
|
-
const createProfile = (0,
|
|
465
|
+
const createProfile = (0, import_react9.useCallback)(
|
|
471
466
|
(input) => {
|
|
472
467
|
const record = (0, import_profile2.createProfileRecord)(input);
|
|
473
468
|
dispatch(import_profile2.profilesActions.add(record));
|
|
@@ -476,14 +471,14 @@ function ProfilesProvider({ children }) {
|
|
|
476
471
|
},
|
|
477
472
|
[profiles, dispatch, syncToShared]
|
|
478
473
|
);
|
|
479
|
-
const updateProfile = (0,
|
|
474
|
+
const updateProfile = (0, import_react9.useCallback)(
|
|
480
475
|
(id, patch) => {
|
|
481
476
|
dispatch(import_profile2.profilesActions.update({ id, patch }));
|
|
482
477
|
syncToShared(profiles.map((p) => p.id === id ? { ...p, ...patch, updatedAt: Date.now() } : p));
|
|
483
478
|
},
|
|
484
479
|
[profiles, dispatch, syncToShared]
|
|
485
480
|
);
|
|
486
|
-
const deleteProfile = (0,
|
|
481
|
+
const deleteProfile = (0, import_react9.useCallback)(
|
|
487
482
|
(id) => {
|
|
488
483
|
dispatch(import_profile2.profilesActions.remove(id));
|
|
489
484
|
syncToShared(profiles.filter((p) => p.id !== id));
|
|
@@ -491,22 +486,22 @@ function ProfilesProvider({ children }) {
|
|
|
491
486
|
},
|
|
492
487
|
[profiles, dispatch, syncToShared]
|
|
493
488
|
);
|
|
494
|
-
const selectProfile = (0,
|
|
489
|
+
const selectProfile = (0, import_react9.useCallback)(
|
|
495
490
|
(seat, profileId) => {
|
|
496
491
|
dispatch(profileSelectionActions.select({ profileId, seat }));
|
|
497
492
|
},
|
|
498
493
|
[dispatch]
|
|
499
494
|
);
|
|
500
|
-
return /* @__PURE__ */ (0,
|
|
495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ProfilesContext.Provider, { value: { profiles, lastSelected, loaded, createProfile, updateProfile, deleteProfile, selectProfile }, children });
|
|
501
496
|
}
|
|
502
497
|
function useProfiles() {
|
|
503
|
-
const ctx = (0,
|
|
498
|
+
const ctx = (0, import_react9.useContext)(ProfilesContext);
|
|
504
499
|
if (!ctx) throw new Error("useProfiles must be used within a ProfilesProvider");
|
|
505
500
|
return ctx;
|
|
506
501
|
}
|
|
507
502
|
|
|
508
503
|
// src/RootLayout.tsx
|
|
509
|
-
var
|
|
504
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
510
505
|
var PLAY_OPTIONS = { statusBarHidden: true };
|
|
511
506
|
var KEEP_STATUS_BAR_OPTIONS = {};
|
|
512
507
|
var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
|
|
@@ -515,8 +510,8 @@ var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
|
|
|
515
510
|
var noScreenOptions = () => ({});
|
|
516
511
|
function useFirstScreenGate() {
|
|
517
512
|
const { resumeState, subscribeResume } = useLastActiveGame();
|
|
518
|
-
const marked = (0,
|
|
519
|
-
return (0,
|
|
513
|
+
const marked = (0, import_react10.useRef)(false);
|
|
514
|
+
return (0, import_react10.useCallback)(() => {
|
|
520
515
|
if (marked.current) return;
|
|
521
516
|
marked.current = true;
|
|
522
517
|
const mark = () => requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
|
|
@@ -537,7 +532,7 @@ function useFirstScreenGate() {
|
|
|
537
532
|
}
|
|
538
533
|
function useResumeShown() {
|
|
539
534
|
const { endResume } = useLastActiveGame();
|
|
540
|
-
return (0,
|
|
535
|
+
return (0, import_react10.useCallback)(
|
|
541
536
|
({ route }) => ({
|
|
542
537
|
transitionEnd: (event) => {
|
|
543
538
|
if (route.name === PLAY_ROUTE && !event.data?.closing) endResume();
|
|
@@ -560,8 +555,8 @@ function AppStack() {
|
|
|
560
555
|
const backdropOptions = Backdrop ? { contentStyle: TRANSPARENT_CONTENT, animation: import_react_native3.Platform.select({ android: "fade" }) } : void 0;
|
|
561
556
|
const { edgeGuard = true } = pack;
|
|
562
557
|
const { deferBottomEdgeGestures } = useAppSettings().settings;
|
|
563
|
-
const edgeGuardOptions = (0,
|
|
564
|
-
const playOptions = (0,
|
|
558
|
+
const edgeGuardOptions = (0, import_react10.useMemo)(() => (0, import_edge_guard2.edgeGuardScreenOptions)(edgeGuard && deferBottomEdgeGestures), [edgeGuard, deferBottomEdgeGestures]);
|
|
559
|
+
const playOptions = (0, import_react10.useCallback)(
|
|
565
560
|
({ route }) => {
|
|
566
561
|
const id = route.params?.game;
|
|
567
562
|
const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
|
|
@@ -570,58 +565,58 @@ function AppStack() {
|
|
|
570
565
|
[pack.games, edgeGuardOptions]
|
|
571
566
|
);
|
|
572
567
|
const navigationBackground = Backdrop ? TRANSPARENT_CONTENT.backgroundColor : rootBackground.contentStyle.backgroundColor;
|
|
573
|
-
const navigationTheme = (0,
|
|
568
|
+
const navigationTheme = (0, import_react10.useMemo)(() => {
|
|
574
569
|
const base = darkRoot ? import_expo_router.DarkTheme : import_expo_router.DefaultTheme;
|
|
575
570
|
return { ...base, colors: { ...base.colors, background: navigationBackground } };
|
|
576
571
|
}, [darkRoot, navigationBackground]);
|
|
577
|
-
return /* @__PURE__ */ (0,
|
|
578
|
-
Backdrop && /* @__PURE__ */ (0,
|
|
579
|
-
/* @__PURE__ */ (0,
|
|
580
|
-
/* @__PURE__ */ (0,
|
|
581
|
-
/* @__PURE__ */ (0,
|
|
572
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native3.View, { style: styles.root, onLayout: onFirstLayout, children: [
|
|
573
|
+
Backdrop && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Backdrop, {}),
|
|
574
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_expo_router.ThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_expo_router.Stack, { screenListeners, screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
|
|
575
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_expo_router.Stack.Screen, { name: "index" }),
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_expo_router.Stack.Screen, { name: PLAY_ROUTE, options: playOptions })
|
|
582
577
|
] }) })
|
|
583
578
|
] });
|
|
584
579
|
}
|
|
585
580
|
function GatedApp({ children }) {
|
|
586
581
|
const { loaded } = useProfiles();
|
|
587
|
-
return /* @__PURE__ */ (0,
|
|
582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SplashGate, { gate: "profiles", ready: loaded, children });
|
|
588
583
|
}
|
|
589
584
|
function HapticGatedToastProvider({ children }) {
|
|
590
585
|
const { settings } = (0, import_feedback_press2.useHapticSettings)();
|
|
591
586
|
const { Toaster: PackToasterComponent } = usePack();
|
|
592
|
-
return /* @__PURE__ */ (0,
|
|
587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_toaster2.ToastProvider, { haptics: settings.vibrate ? Haptics : void 0, paper: PackToasterComponent ? void 0 : RNPaper2, children });
|
|
593
588
|
}
|
|
594
589
|
function FramedToaster() {
|
|
595
|
-
const renderFrame = (0,
|
|
596
|
-
return /* @__PURE__ */ (0,
|
|
590
|
+
const renderFrame = (0, import_react10.useCallback)((toasts) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_chrome2.ScreenFrame, { passThrough: true, children: toasts }), []);
|
|
591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_toaster2.Toaster, { historyButton: null, clearButton: null, limit: 1, renderFrame });
|
|
597
592
|
}
|
|
598
593
|
function PackToaster({ Toaster: PackToasterComponent }) {
|
|
599
|
-
return /* @__PURE__ */ (0,
|
|
594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native3.View, { style: import_react_native3.StyleSheet.absoluteFill, pointerEvents: "box-none", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_chrome2.ScreenFrame, { passThrough: true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PackToasterComponent, {}) }) });
|
|
600
595
|
}
|
|
601
596
|
function GameProviders({ games, children }) {
|
|
602
|
-
return games.reduceRight((inner, game) => game.Provider ? /* @__PURE__ */ (0,
|
|
597
|
+
return games.reduceRight((inner, game) => game.Provider ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(game.Provider, { children: inner }, game.id) : inner, children);
|
|
603
598
|
}
|
|
604
599
|
function PreviewColors({ previewColor, children }) {
|
|
605
600
|
const { dark } = (0, import_auto_paper2.useAutoPaperTheme)();
|
|
606
|
-
const preview = (0,
|
|
607
|
-
return /* @__PURE__ */ (0,
|
|
601
|
+
const preview = (0, import_react10.useCallback)((hex) => previewColor(hex, dark), [previewColor, dark]);
|
|
602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_profile3.ProfileColorProvider, { preview, children });
|
|
608
603
|
}
|
|
609
604
|
function PackRoot({ pack, children }) {
|
|
610
605
|
const { Provider, previewColor } = pack;
|
|
611
|
-
const inner = Provider ? /* @__PURE__ */ (0,
|
|
612
|
-
return previewColor ? /* @__PURE__ */ (0,
|
|
606
|
+
const inner = Provider ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Provider, { children }) : children;
|
|
607
|
+
return previewColor ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewColors, { previewColor, children: inner }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: inner });
|
|
613
608
|
}
|
|
614
609
|
function DialogTitles({ children }) {
|
|
615
610
|
const { titleStyle, labelStyle } = usePack();
|
|
616
|
-
const lettered = /* @__PURE__ */ (0,
|
|
611
|
+
const lettered = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_chrome2.LetteringProvider, { title: titleStyle, label: labelStyle, children });
|
|
617
612
|
if (!titleStyle) return lettered;
|
|
618
|
-
return /* @__PURE__ */ (0,
|
|
613
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_chrome2.DialogHeaderStyleProvider, { tone: "standard", titleStyle, children: lettered });
|
|
619
614
|
}
|
|
620
615
|
function RootLayout({ pack, store, persistor }) {
|
|
621
|
-
return /* @__PURE__ */ (0,
|
|
622
|
-
/* @__PURE__ */ (0,
|
|
623
|
-
pack.Toaster ? /* @__PURE__ */ (0,
|
|
624
|
-
/* @__PURE__ */ (0,
|
|
616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native_gesture_handler.GestureHandlerRootView, { style: styles.root, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native_safe_area_context2.SafeAreaProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(WindowControlsInsets, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PackProvider, { pack, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Fonts, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Providers, { store, persistor, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogTitles, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Theme, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ProfilesProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LastActiveGameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GameProviders, { games: pack.games, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PackRoot, { pack, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GatedApp, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(HapticGatedToastProvider, { children: [
|
|
617
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GuideHost, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AppStack, {}) }),
|
|
618
|
+
pack.Toaster ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PackToaster, { Toaster: pack.Toaster }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FramedToaster, {}),
|
|
619
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(UpdateDialog, {})
|
|
625
620
|
] }) }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
626
621
|
}
|
|
627
622
|
var styles = import_react_native3.StyleSheet.create({
|
|
@@ -652,24 +647,24 @@ var seatParam = (value) => value === "1" ? 1 : value === "2" ? 2 : null;
|
|
|
652
647
|
var import_chrome3 = require("@tastic/hud/chrome");
|
|
653
648
|
var import_profile4 = require("@tastic/profile");
|
|
654
649
|
var import_expo_router3 = require("expo-router");
|
|
655
|
-
var
|
|
650
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
656
651
|
var ROSTER_MAX_WIDTH = 640;
|
|
657
652
|
function ProfilesRoute() {
|
|
658
653
|
const { seat } = (0, import_expo_router3.useLocalSearchParams)();
|
|
659
654
|
const opener = seatParam(seat);
|
|
660
655
|
const { profiles } = useProfiles();
|
|
661
656
|
const { Backdrop, foreground } = usePack();
|
|
662
|
-
return /* @__PURE__ */ (0,
|
|
657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_chrome3.ScreenFrame, { maxContentWidth: ROSTER_MAX_WIDTH, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_profile4.ProfilesScreen, { profiles, onEdit: (id) => import_expo_router3.router.push(profileHref(id, id === import_profile4.NEW_PROFILE_ID ? opener : null)), onBack: import_core6.safeBack, fg: foreground, bg: Backdrop ? "transparent" : void 0 }) });
|
|
663
658
|
}
|
|
664
659
|
|
|
665
660
|
// src/screens/EditProfileRoute.tsx
|
|
666
|
-
var
|
|
661
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
667
662
|
function EditProfileRoute() {
|
|
668
663
|
const { id, seat } = (0, import_expo_router4.useLocalSearchParams)();
|
|
669
664
|
const opener = seatParam(seat);
|
|
670
665
|
const { profiles, createProfile, updateProfile, deleteProfile, selectProfile } = useProfiles();
|
|
671
666
|
const { Backdrop, foreground, newProfileColor, ProfileSections } = usePack();
|
|
672
|
-
return /* @__PURE__ */ (0,
|
|
667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_chrome4.ScreenFrame, { portalHost: true, maxContentWidth: ROSTER_MAX_WIDTH, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
673
668
|
import_profile5.EditProfileScreen,
|
|
674
669
|
{
|
|
675
670
|
profileId: id,
|
|
@@ -684,36 +679,65 @@ function EditProfileRoute() {
|
|
|
684
679
|
onBack: import_core6.safeBack,
|
|
685
680
|
fg: foreground,
|
|
686
681
|
bg: Backdrop ? "transparent" : void 0,
|
|
687
|
-
sections: ProfileSections ? (profile) => /* @__PURE__ */ (0,
|
|
682
|
+
sections: ProfileSections ? (profile) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ProfileSections, { profile }) : void 0
|
|
688
683
|
}
|
|
689
684
|
) });
|
|
690
685
|
}
|
|
691
686
|
|
|
692
687
|
// src/screens/GameRoute.tsx
|
|
693
|
-
var
|
|
694
|
-
var
|
|
688
|
+
var import_expo_router9 = require("expo-router");
|
|
689
|
+
var import_react16 = require("react");
|
|
695
690
|
var import_react_native7 = require("react-native");
|
|
696
691
|
|
|
692
|
+
// src/components/StartGuide.tsx
|
|
693
|
+
var import_expo_router5 = require("expo-router");
|
|
694
|
+
var import_react11 = require("react");
|
|
695
|
+
var import_react_redux8 = require("react-redux");
|
|
696
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
697
|
+
var GUIDE_DELAY_MS = 700;
|
|
698
|
+
var GuideCoveringContext = (0, import_react11.createContext)(false);
|
|
699
|
+
function useGuideCovering() {
|
|
700
|
+
return (0, import_react11.useContext)(GuideCoveringContext);
|
|
701
|
+
}
|
|
702
|
+
function StartGuide({ game, enabled, children }) {
|
|
703
|
+
const pack = usePack();
|
|
704
|
+
const focused = (0, import_expo_router5.useIsFocused)();
|
|
705
|
+
const subject = enabled ? startSubject(pack, game) : null;
|
|
706
|
+
const guide = guideFor(pack, subject);
|
|
707
|
+
const covering = (0, import_react_redux8.useSelector)((state) => !!guide && guide.selectVersionSeen(state) < guide.version);
|
|
708
|
+
const [due, setDue] = (0, import_react11.useState)(false);
|
|
709
|
+
const waiting = covering && focused && !due;
|
|
710
|
+
(0, import_react11.useEffect)(() => {
|
|
711
|
+
if (!waiting) return;
|
|
712
|
+
const timeout = setTimeout(() => setDue(true), GUIDE_DELAY_MS);
|
|
713
|
+
return () => clearTimeout(timeout);
|
|
714
|
+
}, [waiting]);
|
|
715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(GuideCoveringContext.Provider, { value: covering, children: [
|
|
716
|
+
children,
|
|
717
|
+
subject !== null && covering && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(GuideCards, { subject, visible: due && focused })
|
|
718
|
+
] });
|
|
719
|
+
}
|
|
720
|
+
|
|
697
721
|
// src/screens/LoadoutScreen.tsx
|
|
698
722
|
var import_auto_paper5 = require("@rific/auto-paper");
|
|
699
723
|
var import_core10 = require("@tastic/core");
|
|
700
724
|
var import_chrome6 = require("@tastic/hud/chrome");
|
|
701
725
|
var import_lobby2 = require("@tastic/hud/lobby");
|
|
702
726
|
var import_split_screen = require("@tastic/split-screen");
|
|
703
|
-
var
|
|
704
|
-
var
|
|
727
|
+
var import_expo_router8 = require("expo-router");
|
|
728
|
+
var import_react15 = require("react");
|
|
705
729
|
var import_react_native6 = require("react-native");
|
|
706
730
|
var import_react_native_paper = require("react-native-paper");
|
|
707
731
|
var import_react_native_reanimated2 = __toESM(require("react-native-reanimated"));
|
|
708
732
|
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
709
|
-
var
|
|
733
|
+
var import_react_redux11 = require("react-redux");
|
|
710
734
|
|
|
711
735
|
// src/components/OpponentPicker.tsx
|
|
712
736
|
var import_lobby = require("@tastic/hud/lobby");
|
|
713
737
|
var import_profile6 = require("@tastic/profile");
|
|
714
|
-
var
|
|
738
|
+
var import_react12 = require("react");
|
|
715
739
|
var import_react_native4 = require("react-native");
|
|
716
|
-
var
|
|
740
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
717
741
|
var CPU_PREFIX = "cpu:";
|
|
718
742
|
var NOBODY = "nobody";
|
|
719
743
|
var PERSON = "person";
|
|
@@ -726,7 +750,7 @@ function getOpponentPopoverId(idPrefix) {
|
|
|
726
750
|
function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChange, cpuDifficulty, color, onColorChange, swatches, takenColor, allowSwapTaken, dark, previewValue, triggerStyle, usePickerAlign }) {
|
|
727
751
|
const drawn = previewValue ? previewValue(color) : color;
|
|
728
752
|
const cpuOptions = cpuDifficulty?.options;
|
|
729
|
-
const options = (0,
|
|
753
|
+
const options = (0, import_react12.useMemo)(() => {
|
|
730
754
|
const list = [];
|
|
731
755
|
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 }]);
|
|
732
756
|
if (choices.includes("nobody")) list.push({ value: NOBODY, label: "Solo", icon: NOBODY_ICON, dividerBefore: true });
|
|
@@ -748,7 +772,7 @@ function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChange, cpu
|
|
|
748
772
|
const size = (0, import_profile6.getOptionPickerContentSize)(options, colorSection);
|
|
749
773
|
const useAlign = usePickerAlign ?? import_lobby.useZoneClampedAlign;
|
|
750
774
|
const align = useAlign(host.openId === pickerId, size.width, size.height);
|
|
751
|
-
return /* @__PURE__ */ (0,
|
|
775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native4.View, { style: [styles2.button, host.openId === pickerId && styles2.buttonOpen], children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_profile6.OptionPicker, { id: pickerId, host, caption: "Opponent", options, value, onChange: handleChange, color: drawn, dark, icon, colorSection, alignOverride: align, triggerStyle }) });
|
|
752
776
|
}
|
|
753
777
|
var styles2 = import_react_native4.StyleSheet.create({
|
|
754
778
|
// Its own column, so a row of seat buttons doesn't stretch the pill to the tallest of them.
|
|
@@ -764,8 +788,8 @@ var styles2 = import_react_native4.StyleSheet.create({
|
|
|
764
788
|
// src/components/SettingsDialog.tsx
|
|
765
789
|
var import_toaster3 = require("@rific/toaster");
|
|
766
790
|
var import_chrome5 = require("@tastic/hud/chrome");
|
|
767
|
-
var
|
|
768
|
-
var
|
|
791
|
+
var import_expo_router6 = require("expo-router");
|
|
792
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
769
793
|
var noSettingsRules = () => null;
|
|
770
794
|
function SettingsDialog({ visible, onDismiss, onShowHowToPlay, showProfile = false, children }) {
|
|
771
795
|
const onUpdateError = (0, import_toaster3.useUpdateErrorToast)();
|
|
@@ -774,11 +798,11 @@ function SettingsDialog({ visible, onDismiss, onShowHowToPlay, showProfile = fal
|
|
|
774
798
|
const rules = useSettingsRules();
|
|
775
799
|
const { profiles, lastSelected } = useProfiles();
|
|
776
800
|
const seatOne = profiles.find((profile) => profile.id === lastSelected[1]) ?? null;
|
|
777
|
-
const profileRow = showProfile ? seatOne ? { onShowProfiles: () =>
|
|
801
|
+
const profileRow = showProfile ? seatOne ? { onShowProfiles: () => import_expo_router6.router.push(profileHref(seatOne.id)), profilesRow: { label: "Profile", caption: seatOne.name, icon: "account-outline" } } : { onShowProfiles: () => import_expo_router6.router.push(profilesHref(1)) } : {};
|
|
778
802
|
const edgeGuardProps = edgeGuard ? { deferBottomEdgeGestures: settings.deferBottomEdgeGestures, onDeferBottomEdgeGestures: (value) => setSettings({ deferBottomEdgeGestures: value }) } : {};
|
|
779
|
-
return /* @__PURE__ */ (0,
|
|
803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_chrome5.BaseSettingsDialog, { visible, onDismiss, version: otaVersion, ...edgeGuardProps, onUpdateError, onShowHowToPlay, ...profileRow, leading: rules, children: [
|
|
780
804
|
children,
|
|
781
|
-
SettingsSections && /* @__PURE__ */ (0,
|
|
805
|
+
SettingsSections && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SettingsSections, {})
|
|
782
806
|
] });
|
|
783
807
|
}
|
|
784
808
|
|
|
@@ -791,8 +815,8 @@ function useAtComputer() {
|
|
|
791
815
|
}
|
|
792
816
|
|
|
793
817
|
// src/hooks/useOpponent.ts
|
|
794
|
-
var
|
|
795
|
-
var
|
|
818
|
+
var import_react13 = require("react");
|
|
819
|
+
var import_react_redux9 = require("react-redux");
|
|
796
820
|
|
|
797
821
|
// src/redux/opponentSlice.ts
|
|
798
822
|
var import_core8 = require("@rific/core");
|
|
@@ -805,18 +829,18 @@ var opponentSlice_default = reducer4;
|
|
|
805
829
|
|
|
806
830
|
// src/hooks/useOpponent.ts
|
|
807
831
|
function useOpponent() {
|
|
808
|
-
const seatTwo = (0,
|
|
809
|
-
const dispatch = (0,
|
|
810
|
-
const setSeatTwo = (0,
|
|
832
|
+
const seatTwo = (0, import_react_redux9.useSelector)((state) => state.opponent.seatTwo);
|
|
833
|
+
const dispatch = (0, import_react_redux9.useDispatch)();
|
|
834
|
+
const setSeatTwo = (0, import_react13.useCallback)((next) => dispatch(opponentActions.setSeatTwo(next)), [dispatch]);
|
|
811
835
|
return { seatTwo, setSeatTwo };
|
|
812
836
|
}
|
|
813
837
|
|
|
814
838
|
// src/hooks/useSeatColors.ts
|
|
815
839
|
var import_auto_paper4 = require("@rific/auto-paper");
|
|
816
840
|
var import_profile8 = require("@tastic/profile");
|
|
817
|
-
var
|
|
818
|
-
var
|
|
819
|
-
var
|
|
841
|
+
var import_expo_router7 = require("expo-router");
|
|
842
|
+
var import_react14 = require("react");
|
|
843
|
+
var import_react_redux10 = require("react-redux");
|
|
820
844
|
|
|
821
845
|
// src/redux/seatColorsSlice.ts
|
|
822
846
|
var import_profile7 = require("@tastic/profile");
|
|
@@ -841,10 +865,10 @@ function useSeatColors(p2IsHuman) {
|
|
|
841
865
|
const { profiles, lastSelected } = useProfiles();
|
|
842
866
|
const { seatColors, seatTheme } = usePack();
|
|
843
867
|
const seatDefaultColors = [seatColors[1], seatColors[2]];
|
|
844
|
-
const dispatch = (0,
|
|
845
|
-
const guestColors = (0,
|
|
846
|
-
const cpuColor = (0,
|
|
847
|
-
const profileColors = (0,
|
|
868
|
+
const dispatch = (0, import_react_redux10.useDispatch)();
|
|
869
|
+
const guestColors = (0, import_react_redux10.useSelector)((state) => state.seatColors.lastGuestColor);
|
|
870
|
+
const cpuColor = (0, import_react_redux10.useSelector)((state) => state.seatColors.lastCpuColor);
|
|
871
|
+
const profileColors = (0, import_react_redux10.useSelector)((state) => state.seatColors.profileColors);
|
|
848
872
|
const p1Profile = profiles.find((p) => p.id === lastSelected[1]) ?? null;
|
|
849
873
|
const p2Profile = p2IsHuman ? profiles.find((p) => p.id === lastSelected[2]) ?? null : null;
|
|
850
874
|
const rememberedColors = (p1Prof, p2Prof, picks, guest, cpu) => {
|
|
@@ -855,43 +879,43 @@ function useSeatColors(p2IsHuman) {
|
|
|
855
879
|
const remembered = rememberedColors(p1Profile, p2Profile, profileColors, guestColors, cpuColor);
|
|
856
880
|
const p1Color = seatTheme ? remembered.p1 : themeColors.primary;
|
|
857
881
|
const p2Color = seatTheme ? remembered.p2 : themeColors.secondary;
|
|
858
|
-
const themeFor = (0,
|
|
859
|
-
const p1ProfileRef = (0,
|
|
860
|
-
const p2ProfileRef = (0,
|
|
861
|
-
const guestColorsRef = (0,
|
|
862
|
-
const cpuColorRef = (0,
|
|
863
|
-
const profileColorsRef = (0,
|
|
864
|
-
const themeForRef = (0,
|
|
865
|
-
(0,
|
|
882
|
+
const themeFor = (0, import_react14.useCallback)((p1, p2) => seatTheme ? seatTheme({ 1: p1, 2: p2 }, dark) : { color: { primary: p1, secondary: p2, tertiary: (0, import_auto_paper4.getThirdColor)(p1, p2) } }, [seatTheme, dark]);
|
|
883
|
+
const p1ProfileRef = (0, import_react14.useRef)(p1Profile);
|
|
884
|
+
const p2ProfileRef = (0, import_react14.useRef)(p2Profile);
|
|
885
|
+
const guestColorsRef = (0, import_react14.useRef)(guestColors);
|
|
886
|
+
const cpuColorRef = (0, import_react14.useRef)(cpuColor);
|
|
887
|
+
const profileColorsRef = (0, import_react14.useRef)(profileColors);
|
|
888
|
+
const themeForRef = (0, import_react14.useRef)(themeFor);
|
|
889
|
+
(0, import_react14.useEffect)(() => {
|
|
866
890
|
p1ProfileRef.current = p1Profile;
|
|
867
891
|
}, [p1Profile]);
|
|
868
|
-
(0,
|
|
892
|
+
(0, import_react14.useEffect)(() => {
|
|
869
893
|
p2ProfileRef.current = p2Profile;
|
|
870
894
|
}, [p2Profile]);
|
|
871
|
-
(0,
|
|
895
|
+
(0, import_react14.useEffect)(() => {
|
|
872
896
|
guestColorsRef.current = guestColors;
|
|
873
897
|
}, [guestColors]);
|
|
874
|
-
(0,
|
|
898
|
+
(0, import_react14.useEffect)(() => {
|
|
875
899
|
cpuColorRef.current = cpuColor;
|
|
876
900
|
}, [cpuColor]);
|
|
877
|
-
(0,
|
|
901
|
+
(0, import_react14.useEffect)(() => {
|
|
878
902
|
profileColorsRef.current = profileColors;
|
|
879
903
|
}, [profileColors]);
|
|
880
|
-
(0,
|
|
904
|
+
(0, import_react14.useEffect)(() => {
|
|
881
905
|
themeForRef.current = themeFor;
|
|
882
906
|
}, [themeFor]);
|
|
883
|
-
(0,
|
|
907
|
+
(0, import_react14.useEffect)(() => {
|
|
884
908
|
const next = themeFor(remembered.p1, remembered.p2);
|
|
885
909
|
if (sameTheme(themeSettings, next)) return;
|
|
886
910
|
setThemeColor(next);
|
|
887
911
|
}, [lastSelected[1], lastSelected[2], p2IsHuman, guestColors, cpuColor, profileColors, profiles.length, dark]);
|
|
888
|
-
(0,
|
|
889
|
-
(0,
|
|
912
|
+
(0, import_expo_router7.useFocusEffect)(
|
|
913
|
+
(0, import_react14.useCallback)(() => {
|
|
890
914
|
const next = rememberedColors(p1ProfileRef.current, p2ProfileRef.current, profileColorsRef.current, guestColorsRef.current, cpuColorRef.current);
|
|
891
915
|
setThemeColor(themeForRef.current(next.p1, next.p2));
|
|
892
916
|
}, [lastSelected[1], lastSelected[2], p2IsHuman, setThemeColor])
|
|
893
917
|
);
|
|
894
|
-
const persistSeatColor = (0,
|
|
918
|
+
const persistSeatColor = (0, import_react14.useCallback)(
|
|
895
919
|
(seat, hex) => {
|
|
896
920
|
const profile = seat === 1 ? p1Profile : p2Profile;
|
|
897
921
|
if (profile) {
|
|
@@ -906,7 +930,7 @@ function useSeatColors(p2IsHuman) {
|
|
|
906
930
|
},
|
|
907
931
|
[p1Profile, p2Profile, p2IsHuman, dispatch]
|
|
908
932
|
);
|
|
909
|
-
const handleP1ColorChange = (0,
|
|
933
|
+
const handleP1ColorChange = (0, import_react14.useCallback)(
|
|
910
934
|
(hex) => {
|
|
911
935
|
const swapped = hex.toLowerCase() === p2Color.toLowerCase();
|
|
912
936
|
const nextP2 = swapped ? p1Color : p2Color;
|
|
@@ -916,7 +940,7 @@ function useSeatColors(p2IsHuman) {
|
|
|
916
940
|
},
|
|
917
941
|
[setThemeColor, themeFor, p1Color, p2Color, persistSeatColor]
|
|
918
942
|
);
|
|
919
|
-
const handleP2ColorChange = (0,
|
|
943
|
+
const handleP2ColorChange = (0, import_react14.useCallback)(
|
|
920
944
|
(hex) => {
|
|
921
945
|
const swapped = hex.toLowerCase() === p1Color.toLowerCase();
|
|
922
946
|
const nextP1 = swapped ? p2Color : p1Color;
|
|
@@ -938,7 +962,7 @@ var liveplayActions = actions5;
|
|
|
938
962
|
var liveplaySlice_default = reducer5;
|
|
939
963
|
|
|
940
964
|
// src/screens/LoadoutScreen.tsx
|
|
941
|
-
var
|
|
965
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
942
966
|
var PANEL_SWAP_FADE_MS = 180;
|
|
943
967
|
var P1_CONTROL_ID = "p1-control";
|
|
944
968
|
var P2_CONTROL_ID = "p2-control";
|
|
@@ -951,7 +975,7 @@ function LoadoutScreen({ game }) {
|
|
|
951
975
|
const { seatTwo: savedSeatTwo, setSeatTwo } = useOpponent();
|
|
952
976
|
const seatTwo = seatTwoFor(savedSeatTwo, game.seatTwo);
|
|
953
977
|
const mode = roundModeFor(seatTwo);
|
|
954
|
-
const humanSeats = (0,
|
|
978
|
+
const humanSeats = (0, import_react15.useMemo)(() => humanSeatsFor(mode), [mode]);
|
|
955
979
|
const p2IsHuman = mode === "twoPlayer";
|
|
956
980
|
const p2Exists = mode !== "solo";
|
|
957
981
|
const loadout = game.useLoadout(mode);
|
|
@@ -963,44 +987,44 @@ function LoadoutScreen({ game }) {
|
|
|
963
987
|
const panelMode = p2IsHuman ? twoPlayerMode : orientationMode;
|
|
964
988
|
const { panelLayout, panelFadeStyle } = (0, import_split_screen.useDualZoneLayout)(panelMode, false, true, false, PANEL_SWAP_FADE_MS);
|
|
965
989
|
const playersRowFade = panelFadeStyle;
|
|
966
|
-
const [settingsOpen, setSettingsOpen] = (0,
|
|
990
|
+
const [settingsOpen, setSettingsOpen] = (0, import_react15.useState)(false);
|
|
967
991
|
const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
|
|
968
992
|
const { title: lettering } = (0, import_chrome6.useLettering)();
|
|
969
993
|
const { colors: themeColors, dark } = (0, import_auto_paper5.useAutoPaperTheme)();
|
|
970
994
|
const { p1Color, p2Color, handleP1ColorChange, handleP2ColorChange } = useSeatColors(p2IsHuman);
|
|
971
|
-
const dispatch = (0,
|
|
972
|
-
const handleP1ProfileSelect = (0,
|
|
973
|
-
const handleP2ProfileSelect = (0,
|
|
974
|
-
const [ready, setReady] = (0,
|
|
975
|
-
(0,
|
|
976
|
-
(0,
|
|
995
|
+
const dispatch = (0, import_react_redux11.useDispatch)();
|
|
996
|
+
const handleP1ProfileSelect = (0, import_react15.useCallback)((profile) => selectProfile(1, profile?.id ?? null), [selectProfile]);
|
|
997
|
+
const handleP2ProfileSelect = (0, import_react15.useCallback)((profile) => selectProfile(2, profile?.id ?? null), [selectProfile]);
|
|
998
|
+
const [ready, setReady] = (0, import_react15.useState)({ 1: false, 2: false });
|
|
999
|
+
(0, import_expo_router8.useFocusEffect)(
|
|
1000
|
+
(0, import_react15.useCallback)(() => {
|
|
977
1001
|
setReady({ 1: false, 2: false });
|
|
978
1002
|
}, [setReady])
|
|
979
1003
|
);
|
|
980
|
-
const changeSeatTwo = (0,
|
|
1004
|
+
const changeSeatTwo = (0, import_react15.useCallback)(
|
|
981
1005
|
(next) => {
|
|
982
1006
|
setReady({ 1: false, 2: false });
|
|
983
1007
|
setSeatTwo(next);
|
|
984
1008
|
},
|
|
985
1009
|
[setSeatTwo, setReady]
|
|
986
1010
|
);
|
|
987
|
-
const roundSettingsRef = (0,
|
|
988
|
-
(0,
|
|
1011
|
+
const roundSettingsRef = (0, import_react15.useRef)(loadout.roundSettings);
|
|
1012
|
+
(0, import_react15.useEffect)(() => {
|
|
989
1013
|
roundSettingsRef.current = loadout.roundSettings;
|
|
990
1014
|
}, [loadout.roundSettings]);
|
|
991
|
-
(0,
|
|
1015
|
+
(0, import_react15.useEffect)(() => {
|
|
992
1016
|
if (!humanSeats.every((s) => ready[s])) return;
|
|
993
1017
|
dispatch(liveplayActions.setActiveRound({ game: game.id, mode, settings: roundSettingsRef.current }));
|
|
994
|
-
|
|
1018
|
+
import_expo_router8.router.push(playHref(game.id));
|
|
995
1019
|
}, [ready, humanSeats, game.id, mode, dispatch]);
|
|
996
1020
|
const bg = pack.Backdrop ? "transparent" : dark ? "#000000" : "#FFFFFF";
|
|
997
1021
|
const fg = pack.foreground ?? (dark ? "#FFFFFF" : "#000000");
|
|
998
1022
|
const fgMuted = (pack.foreground && halfOf(pack.foreground)) ?? (dark ? "rgba(255,255,255,0.5)" : "rgba(0,0,0,0.5)");
|
|
999
1023
|
const { previewColor } = pack;
|
|
1000
|
-
const seatPreview = (0,
|
|
1024
|
+
const seatPreview = (0, import_react15.useMemo)(() => previewColor ? (hex) => previewColor(hex, dark) : void 0, [previewColor, dark]);
|
|
1001
1025
|
const p1Drawn = seatPreview ? seatPreview(p1Color) : p1Color;
|
|
1002
1026
|
const p2Drawn = seatPreview ? seatPreview(p2Color) : p2Color;
|
|
1003
|
-
const triggerStyle = (0,
|
|
1027
|
+
const triggerStyle = (0, import_react15.useMemo)(() => pack.Backdrop ? [styles3.pill, { backgroundColor: themeColors.surface }] : void 0, [pack.Backdrop, themeColors.surface]);
|
|
1004
1028
|
const readySurface = pack.Backdrop ? themeColors.surface : void 0;
|
|
1005
1029
|
const isPortrait = panelLayout.orientationMode === "faceToFace";
|
|
1006
1030
|
const showMetaInSharedBand = (0, import_split_screen.needsSharedNeutralZone)(panelLayout.orientationMode, humanSeats.length);
|
|
@@ -1014,21 +1038,21 @@ function LoadoutScreen({ game }) {
|
|
|
1014
1038
|
const controlLook = { accentColor: themeColors.tertiary, mutedColor: fgMuted, dark };
|
|
1015
1039
|
const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn });
|
|
1016
1040
|
const p1Caption = p2IsHuman ? "Player 1" : "Player";
|
|
1017
|
-
const p1Panel = /* @__PURE__ */ (0,
|
|
1018
|
-
const opponentPicker = game.seatTwo && /* @__PURE__ */ (0,
|
|
1041
|
+
const p1Panel = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lobby2.PlayerSetupPanel, { idPrefix: "p1", caption: p1Caption, host: controlsHost, color: p1Color, onColorChange: handleP1ColorChange, swatches: import_auto_paper5.defaultColors, 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: () => import_expo_router8.router.push(profilesHref(1)), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
|
|
1042
|
+
const opponentPicker = game.seatTwo && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(OpponentPicker, { idPrefix: "p1", host: controlsHost, choices: game.seatTwo, seatTwo, onSeatTwoChange: changeSeatTwo, cpuDifficulty: loadout.cpuDifficulty, color: p2Color, onColorChange: handleP2ColorChange, swatches: import_auto_paper5.defaultColors, takenColor: p1Color, allowSwapTaken: mode === "vsCpu", dark, previewValue: seatPreview, triggerStyle, usePickerAlign: seatPickerAlign }, `opponent-${layoutKey}`);
|
|
1019
1043
|
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }));
|
|
1020
1044
|
const readyInOptions = !p2IsHuman && !!loadout.drawsReady;
|
|
1021
|
-
const seatButtons = /* @__PURE__ */ (0,
|
|
1022
|
-
/* @__PURE__ */ (0,
|
|
1045
|
+
const seatButtons = /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native6.View, { style: [styles3.seatOneButtons, p1PickerOpen && styles3.raised], children: [
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native_reanimated2.default.View, { style: [styles3.playersRow, p1PickerOpen && styles3.raised, !p2IsHuman && playersRowFade], children: [
|
|
1023
1047
|
p1Panel,
|
|
1024
1048
|
opponentPicker
|
|
1025
1049
|
] }),
|
|
1026
|
-
p1Control && /* @__PURE__ */ (0,
|
|
1050
|
+
p1Control && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native6.View, { style: [styles3.controlRow, p1ControlOpen && styles3.raised], children: p1Control })
|
|
1027
1051
|
] });
|
|
1028
1052
|
const seatsInOptions = !p2IsHuman && !!loadout.placesSeats;
|
|
1029
|
-
const seatOne = /* @__PURE__ */ (0,
|
|
1053
|
+
const seatOne = /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native6.View, { style: [styles3.seatOne, !p2IsHuman && styles3.seatOneAlone, p1PickerOpen && !seatsInOptions && styles3.raised], children: [
|
|
1030
1054
|
!seatsInOptions && seatButtons,
|
|
1031
|
-
!readyInOptions && /* @__PURE__ */ (0,
|
|
1055
|
+
!readyInOptions && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lobby2.ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
1032
1056
|
] });
|
|
1033
1057
|
const optionsRow = loadout.options({
|
|
1034
1058
|
host: controlsHost,
|
|
@@ -1044,16 +1068,16 @@ function LoadoutScreen({ game }) {
|
|
|
1044
1068
|
onReset: showMetaInSharedBand ? void 0 : loadout.reset
|
|
1045
1069
|
});
|
|
1046
1070
|
const optionsPopoverOpen = controlsHost.openId !== null && loadout.optionIds.includes(controlsHost.openId);
|
|
1047
|
-
const sharedControls = showMetaInSharedBand ? /* @__PURE__ */ (0,
|
|
1071
|
+
const sharedControls = showMetaInSharedBand ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lobby2.SharedActionBand, { onBack: import_core6.safeBack, onSettings: () => setSettingsOpen(true), onRandomize: loadout.randomize, onReset: loadout.reset, fg, popoverOpen: optionsPopoverOpen, children: optionsRow }) : optionsRow;
|
|
1048
1072
|
const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : void 0;
|
|
1049
|
-
const p2Panel = p2IsHuman && /* @__PURE__ */ (0,
|
|
1050
|
-
return /* @__PURE__ */ (0,
|
|
1051
|
-
/* @__PURE__ */ (0,
|
|
1052
|
-
/* @__PURE__ */ (0,
|
|
1053
|
-
p2ZoneStyle && /* @__PURE__ */ (0,
|
|
1054
|
-
!showMetaInSharedBand && /* @__PURE__ */ (0,
|
|
1055
|
-
!showMetaInSharedBand && /* @__PURE__ */ (0,
|
|
1056
|
-
p2IsHuman ? /* @__PURE__ */ (0,
|
|
1073
|
+
const p2Panel = p2IsHuman && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lobby2.PlayerSetupPanel, { idPrefix: "p2", caption: "Player 2", host: p2Host, color: p2Color, onColorChange: handleP2ColorChange, swatches: import_auto_paper5.defaultColors, 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");
|
|
1074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native6.View, { style: [styles3.container, { backgroundColor: bg }], children: [
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native6.View, { style: [styles3.frame, !showMetaInSharedBand && { paddingTop: HEADER_TOP + HEADER_ROW_HEIGHT + insets.top }], children: [
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_chrome6.PressAwayOverlay, { active: controlsHost.openId !== null, onPress: controlsHost.close }),
|
|
1077
|
+
p2ZoneStyle && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_chrome6.PressAwayOverlay, { active: controlsHost.openId !== null || p2Host.openId !== null, onPress: p2Host.close, style: p2ZoneStyle }),
|
|
1078
|
+
!showMetaInSharedBand && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_chrome6.CornerActionButtons, { onBack: import_core6.safeBack, onSettings: () => setSettingsOpen(true), fg, insets }),
|
|
1079
|
+
!showMetaInSharedBand && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native6.View, { style: [styles3.headerTitle, { top: HEADER_TOP + insets.top, left: HEADER_TITLE_LEFT + insets.left, right: HEADER_TITLE_RIGHT + insets.right }], pointerEvents: "none", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper.Text, { variant: "headlineSmall", numberOfLines: 1, accessibilityRole: "header", style: [styles3.title, { color: fg }, lettering], children: game.title }) }),
|
|
1080
|
+
p2IsHuman ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1057
1081
|
import_split_screen.DualZoneLayout,
|
|
1058
1082
|
{
|
|
1059
1083
|
panelLayout,
|
|
@@ -1065,12 +1089,12 @@ function LoadoutScreen({ game }) {
|
|
|
1065
1089
|
p2Elevated: p2Host.openId !== null,
|
|
1066
1090
|
sharedElevated: optionsPopoverOpen
|
|
1067
1091
|
}
|
|
1068
|
-
) : /* @__PURE__ */ (0,
|
|
1069
|
-
seatsInOptions ? /* @__PURE__ */ (0,
|
|
1092
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native6.View, { style: styles3.stackedZone, children: [
|
|
1093
|
+
seatsInOptions ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native6.View, { style: p1PickerOpen && styles3.raised, children: sharedControls }) : sharedControls,
|
|
1070
1094
|
!(seatsInOptions && readyInOptions) && seatOne
|
|
1071
1095
|
] })
|
|
1072
1096
|
] }),
|
|
1073
|
-
/* @__PURE__ */ (0,
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SettingsDialog, { visible: settingsOpen, onDismiss: () => setSettingsOpen(false), onShowHowToPlay: () => openFor(game.id), showProfile: true })
|
|
1074
1098
|
] });
|
|
1075
1099
|
}
|
|
1076
1100
|
function halfOf(color) {
|
|
@@ -1160,29 +1184,29 @@ var styles3 = import_react_native6.StyleSheet.create({
|
|
|
1160
1184
|
});
|
|
1161
1185
|
|
|
1162
1186
|
// src/screens/GameRoute.tsx
|
|
1163
|
-
var
|
|
1187
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1164
1188
|
function LoadoutRoute() {
|
|
1165
|
-
const { game: id } = (0,
|
|
1189
|
+
const { game: id } = (0, import_expo_router9.useLocalSearchParams)();
|
|
1166
1190
|
const game = usePackGame(id);
|
|
1167
|
-
if (!game) return /* @__PURE__ */ (0,
|
|
1168
|
-
if (!hasLoadout(game)) return /* @__PURE__ */ (0,
|
|
1169
|
-
return /* @__PURE__ */ (0,
|
|
1191
|
+
if (!game) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_expo_router9.Redirect, { href: "/" });
|
|
1192
|
+
if (!hasLoadout(game)) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_expo_router9.Redirect, { href: playHref(game.id) });
|
|
1193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(LoadoutScreen, { game }, game.id);
|
|
1170
1194
|
}
|
|
1171
1195
|
function hasLoadout(game) {
|
|
1172
1196
|
return !!game.useLoadout;
|
|
1173
1197
|
}
|
|
1174
|
-
function PlayRoute() {
|
|
1175
|
-
const { game: id } = (0,
|
|
1198
|
+
function PlayRoute({ guide = true } = {}) {
|
|
1199
|
+
const { game: id } = (0, import_expo_router9.useLocalSearchParams)();
|
|
1176
1200
|
const game = usePackGame(id);
|
|
1177
1201
|
useResumePoint(game?.resumable ? game.id : null);
|
|
1178
1202
|
useResumeUp();
|
|
1179
|
-
if (!game) return /* @__PURE__ */ (0,
|
|
1203
|
+
if (!game) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_expo_router9.Redirect, { href: "/" });
|
|
1180
1204
|
const { PlayScreen } = game;
|
|
1181
|
-
return /* @__PURE__ */ (0,
|
|
1205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(StartGuide, { game, enabled: guide, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PlayScreen, {}) }, game.id);
|
|
1182
1206
|
}
|
|
1183
1207
|
function useResumeUp() {
|
|
1184
1208
|
const { playScreenUp } = useLastActiveGame();
|
|
1185
|
-
(0,
|
|
1209
|
+
(0, import_react16.useEffect)(() => {
|
|
1186
1210
|
let frame = requestAnimationFrame(() => {
|
|
1187
1211
|
frame = requestAnimationFrame(playScreenUp);
|
|
1188
1212
|
});
|
|
@@ -1192,7 +1216,7 @@ function useResumeUp() {
|
|
|
1192
1216
|
var playScreensUp = 0;
|
|
1193
1217
|
function useResumePoint(gameId) {
|
|
1194
1218
|
const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame();
|
|
1195
|
-
(0,
|
|
1219
|
+
(0, import_react16.useEffect)(() => {
|
|
1196
1220
|
if (!gameId) return;
|
|
1197
1221
|
playScreensUp += 1;
|
|
1198
1222
|
setLastActiveGame(gameId);
|
|
@@ -1208,8 +1232,8 @@ var import_auto_paper6 = require("@rific/auto-paper");
|
|
|
1208
1232
|
var import_feedback_press3 = require("@rific/feedback-press");
|
|
1209
1233
|
var import_chrome7 = require("@tastic/hud/chrome");
|
|
1210
1234
|
var import_profile9 = require("@tastic/profile");
|
|
1211
|
-
var
|
|
1212
|
-
var
|
|
1235
|
+
var import_expo_router10 = require("expo-router");
|
|
1236
|
+
var import_react18 = require("react");
|
|
1213
1237
|
var import_react_native9 = require("react-native");
|
|
1214
1238
|
var import_react_native_paper2 = require("react-native-paper");
|
|
1215
1239
|
|
|
@@ -1218,11 +1242,11 @@ var SEGMENT_THEME = { roundness: 3.8 };
|
|
|
1218
1242
|
var SEGMENT_RADIUS = 5 * SEGMENT_THEME.roundness;
|
|
1219
1243
|
|
|
1220
1244
|
// src/hooks/useFrozenWhileHidden.ts
|
|
1221
|
-
var
|
|
1245
|
+
var import_react17 = require("react");
|
|
1222
1246
|
function useFrozenWhileHidden(value, hidden) {
|
|
1223
|
-
const [prevHidden, setPrevHidden] = (0,
|
|
1224
|
-
const [prevValue, setPrevValue] = (0,
|
|
1225
|
-
const [frozen, setFrozen] = (0,
|
|
1247
|
+
const [prevHidden, setPrevHidden] = (0, import_react17.useState)(hidden);
|
|
1248
|
+
const [prevValue, setPrevValue] = (0, import_react17.useState)(value);
|
|
1249
|
+
const [frozen, setFrozen] = (0, import_react17.useState)(value);
|
|
1226
1250
|
if (hidden !== prevHidden) {
|
|
1227
1251
|
setPrevHidden(hidden);
|
|
1228
1252
|
if (hidden) setFrozen(prevValue);
|
|
@@ -1295,39 +1319,35 @@ function useHomeLayout(withPicker = true) {
|
|
|
1295
1319
|
}
|
|
1296
1320
|
|
|
1297
1321
|
// src/screens/HomeScreen.tsx
|
|
1298
|
-
var
|
|
1322
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1299
1323
|
function HomeScreen() {
|
|
1300
1324
|
const pack = usePack();
|
|
1301
1325
|
const { consumeResumeGame } = useLastActiveGame();
|
|
1302
|
-
const
|
|
1303
|
-
const [resumeGame] = (0, import_react16.useState)(() => {
|
|
1326
|
+
const [resumeGame] = (0, import_react18.useState)(() => {
|
|
1304
1327
|
const id = consumeResumeGame();
|
|
1305
1328
|
return pack.games.find((g) => g.id === id && g.resumable) ?? null;
|
|
1306
1329
|
});
|
|
1307
|
-
(0, import_react16.useEffect)(() => {
|
|
1308
|
-
if (!resumeGame) autoShowPack();
|
|
1309
|
-
}, [resumeGame, autoShowPack]);
|
|
1310
1330
|
useResume(resumeGame);
|
|
1311
|
-
return useMenuShown(!!resumeGame) ? /* @__PURE__ */ (0,
|
|
1331
|
+
return useMenuShown(!!resumeGame) ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(HomeMenu, {}) : null;
|
|
1312
1332
|
}
|
|
1313
1333
|
function useResume(game) {
|
|
1314
1334
|
const pack = usePack();
|
|
1315
|
-
const done = (0,
|
|
1316
|
-
(0,
|
|
1317
|
-
(0,
|
|
1335
|
+
const done = (0, import_react18.useRef)(false);
|
|
1336
|
+
(0, import_expo_router10.useFocusEffect)(
|
|
1337
|
+
(0, import_react18.useCallback)(() => {
|
|
1318
1338
|
if (!game || done.current) return;
|
|
1319
1339
|
done.current = true;
|
|
1320
|
-
if (game.useLoadout)
|
|
1321
|
-
|
|
1340
|
+
if (game.useLoadout) import_expo_router10.router.push(loadoutHref(game.id));
|
|
1341
|
+
import_expo_router10.router.push(pack.resumeHref?.(game.id) ?? playHref(game.id));
|
|
1322
1342
|
}, [game, pack])
|
|
1323
1343
|
);
|
|
1324
1344
|
}
|
|
1325
1345
|
function useMenuShown(resuming) {
|
|
1326
1346
|
const { beginResume, endResume, resumeState, subscribeResume } = useLastActiveGame();
|
|
1327
|
-
const isFocused = (0,
|
|
1328
|
-
const [covered, setCovered] = (0,
|
|
1347
|
+
const isFocused = (0, import_expo_router10.useIsFocused)();
|
|
1348
|
+
const [covered, setCovered] = (0, import_react18.useState)(false);
|
|
1329
1349
|
if (resuming && !covered && !isFocused) setCovered(true);
|
|
1330
|
-
(0,
|
|
1350
|
+
(0, import_react18.useLayoutEffect)(() => {
|
|
1331
1351
|
if (!resuming) return;
|
|
1332
1352
|
beginResume();
|
|
1333
1353
|
const id = setTimeout(endResume, RESUME_SHOWN_MAX_MS);
|
|
@@ -1336,9 +1356,9 @@ function useMenuShown(resuming) {
|
|
|
1336
1356
|
endResume();
|
|
1337
1357
|
};
|
|
1338
1358
|
}, [resuming, beginResume, endResume]);
|
|
1339
|
-
const onItsWay = (0,
|
|
1359
|
+
const onItsWay = (0, import_react18.useSyncExternalStore)(subscribeResume, resumeState, resumeState) !== "idle";
|
|
1340
1360
|
const gameShown = covered && !onItsWay;
|
|
1341
|
-
return (0,
|
|
1361
|
+
return (0, import_react18.useDeferredValue)(!resuming || gameShown || covered && isFocused);
|
|
1342
1362
|
}
|
|
1343
1363
|
var RESUME_SHOWN_MAX_MS = 4e3;
|
|
1344
1364
|
function HomeMenu() {
|
|
@@ -1348,11 +1368,11 @@ function HomeMenu() {
|
|
|
1348
1368
|
const { insets } = layout;
|
|
1349
1369
|
const { dark, colors } = (0, import_auto_paper6.useAutoPaperTheme)();
|
|
1350
1370
|
const { openFirstTime, openFor, openPack } = useGameGuide();
|
|
1351
|
-
const [settingsOpen, setSettingsOpen] = (0,
|
|
1352
|
-
const [rulesGame, setRulesGame] = (0,
|
|
1353
|
-
const isFocused = (0,
|
|
1354
|
-
const [appState, setAppState] = (0,
|
|
1355
|
-
(0,
|
|
1371
|
+
const [settingsOpen, setSettingsOpen] = (0, import_react18.useState)(false);
|
|
1372
|
+
const [rulesGame, setRulesGame] = (0, import_react18.useState)(null);
|
|
1373
|
+
const isFocused = (0, import_expo_router10.useIsFocused)();
|
|
1374
|
+
const [appState, setAppState] = (0, import_react18.useState)(import_react_native9.AppState.currentState);
|
|
1375
|
+
(0, import_react18.useEffect)(() => {
|
|
1356
1376
|
const subscription = import_react_native9.AppState.addEventListener("change", setAppState);
|
|
1357
1377
|
return () => subscription.remove();
|
|
1358
1378
|
}, []);
|
|
@@ -1364,65 +1384,65 @@ function HomeMenu() {
|
|
|
1364
1384
|
const selectedProfile = profiles.find((p) => p.id === lastSelected[1]) ?? null;
|
|
1365
1385
|
const tiled = pack.games.some((game) => game.Preview);
|
|
1366
1386
|
const isWide = useFrozenWhileHidden(tiled && layout.isWide, !isFocused);
|
|
1367
|
-
const [previewsRevealed, setPreviewsRevealed] = (0,
|
|
1368
|
-
(0,
|
|
1387
|
+
const [previewsRevealed, setPreviewsRevealed] = (0, import_react18.useState)(false);
|
|
1388
|
+
(0, import_react18.useEffect)(() => {
|
|
1369
1389
|
if (!tiled) return;
|
|
1370
1390
|
const id = requestAnimationFrame(() => setPreviewsRevealed(true));
|
|
1371
1391
|
return () => cancelAnimationFrame(id);
|
|
1372
1392
|
}, [tiled]);
|
|
1373
1393
|
const closePicker = pickerHost.close;
|
|
1374
|
-
(0,
|
|
1394
|
+
(0, import_react18.useEffect)(() => {
|
|
1375
1395
|
closePicker();
|
|
1376
1396
|
}, [isWide, layout.windowWidth, layout.windowHeight, closePicker]);
|
|
1377
1397
|
const bg = pack.Backdrop ? "transparent" : dark ? "#000000" : "#FFFFFF";
|
|
1378
1398
|
const fg = pack.foreground ?? (dark ? "#FFFFFF" : "#000000");
|
|
1379
1399
|
const { previewColor } = pack;
|
|
1380
1400
|
const p1Drawn = previewColor ? previewColor(p1Color, dark) : p1Color;
|
|
1381
|
-
const triggerStyle = (0,
|
|
1401
|
+
const triggerStyle = (0, import_react18.useMemo)(() => pack.Backdrop ? [styles4.pill, { backgroundColor: colors.surface }] : void 0, [pack.Backdrop, colors.surface]);
|
|
1382
1402
|
const tabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
|
|
1383
|
-
const [tabLabel, setTabLabel] = (0,
|
|
1403
|
+
const [tabLabel, setTabLabel] = (0, import_react18.useState)(() => tabs?.[0].label ?? null);
|
|
1384
1404
|
const tab = tabs ? tabs.find((t) => t.label === tabLabel) ?? tabs[0] : null;
|
|
1385
|
-
const tabButtons = (0,
|
|
1386
|
-
const tabBar = tab && /* @__PURE__ */ (0,
|
|
1387
|
-
const panes = (0,
|
|
1405
|
+
const tabButtons = (0, import_react18.useMemo)(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle]);
|
|
1406
|
+
const tabBar = tab && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.SegmentedButtons, { value: tab.label, onValueChange: setTabLabel, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles4.tabs, pack.Backdrop && { backgroundColor: colors.surface }] });
|
|
1407
|
+
const panes = (0, import_react18.useMemo)(() => tabs ? tabs.map((t) => ({ key: t.label, games: pack.games.filter(t.includes) })) : [{ key: ALL_GAMES, games: pack.games }], [tabs, pack.games]);
|
|
1388
1408
|
const shownPane = tab?.label ?? ALL_GAMES;
|
|
1389
1409
|
const { width: fitWidth, height: fitHeight } = layout.heroFit ?? NO_FIT;
|
|
1390
|
-
const hero = (0,
|
|
1410
|
+
const hero = (0, import_react18.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive, fit: isWide && fitWidth !== void 0 ? { width: fitWidth, height: fitHeight } : void 0 }), [pack, fg, p1Color, p2Color, heroActive, isWide, fitWidth, fitHeight]);
|
|
1391
1411
|
const columnClamp = useClampOnShrink();
|
|
1392
1412
|
const gridClamp = useClampOnShrink();
|
|
1393
|
-
const openGame = (0,
|
|
1394
|
-
const openRules = (0,
|
|
1413
|
+
const openGame = (0, import_react18.useCallback)((game) => openFirstTime(game.id, () => import_expo_router10.router.push(game.useLoadout ? loadoutHref(game.id) : playHref(game.id))), [openFirstTime]);
|
|
1414
|
+
const openRules = (0, import_react18.useCallback)((game) => game.Rules ? setRulesGame(game) : openFor(game.id), [openFor]);
|
|
1395
1415
|
const colorSection = { value: p1Color, onChange: handleP1ColorChange, swatches: import_auto_paper6.defaultColors, caption: selectedProfile ? pack.colorCaption : void 0, previewValue: previewColor ? (hex) => previewColor(hex, dark) : void 0 };
|
|
1396
1416
|
const usePickerAlign = pack.usePickerAlign ?? noPickerAlign;
|
|
1397
1417
|
const pickerSize = (0, import_profile9.getProfilePickerContentSize)(profiles.length, true, colorSection);
|
|
1398
1418
|
const pickerAlign = usePickerAlign(pickerHost.openId === `${SEAT_ONE_PICKER}-profile`, pickerSize.width, pickerSize.height);
|
|
1399
|
-
const picker = /* @__PURE__ */ (0,
|
|
1400
|
-
const pressAway = /* @__PURE__ */ (0,
|
|
1419
|
+
const picker = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_profile9.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: () => import_expo_router10.router.push(profilesHref(1)), colorSection, alignOverride: pickerAlign, triggerStyle });
|
|
1420
|
+
const pressAway = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_chrome7.PressAwayOverlay, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles4.pressAway });
|
|
1401
1421
|
const RulesSheet = rulesGame?.Rules;
|
|
1402
|
-
return /* @__PURE__ */ (0,
|
|
1403
|
-
/* @__PURE__ */ (0,
|
|
1404
|
-
/* @__PURE__ */ (0,
|
|
1422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_native9.View, { style: [styles4.container, { backgroundColor: bg }], children: [
|
|
1423
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: styles4.frame, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(RulesHost, { enabled: pack.games.some((game) => game.Rules), children: [
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PreviewsRevealed, { value: previewsRevealed, children: isWide ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
1405
1425
|
pressAway,
|
|
1406
|
-
/* @__PURE__ */ (0,
|
|
1407
|
-
tabBar && /* @__PURE__ */ (0,
|
|
1408
|
-
/* @__PURE__ */ (0,
|
|
1426
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_auto_paper6.FadingScrollView, { ...tab && gridClamp, style: [styles4.wideRightPane, { left: layout.paddingLeft + layout.leftPaneWidth + HOME_WIDE_PANE_GAP }], contentContainerStyle: { paddingTop: 16 + insets.top, paddingBottom: 16 + insets.bottom, paddingRight: layout.paddingRight }, children: [
|
|
1427
|
+
tabBar && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: [styles4.wideTabs, { width: layout.rightPaneWidth }], children: tabBar }),
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: { width: layout.rightPaneWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.grid, children: (games, built) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GameGrid, { games, built, width: layout.tileWidth, previewWidth: layout.previewWidth, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
|
|
1409
1429
|
] }),
|
|
1410
|
-
/* @__PURE__ */ (0,
|
|
1430
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_native9.View, { style: [styles4.wideLeftPane, { left: layout.paddingLeft, width: layout.leftPaneWidth, paddingTop: HOME_TOP_BAND + insets.top, paddingBottom: 16 + insets.bottom }, pickerHost.openId !== null && styles4.pickerOpen], children: [
|
|
1411
1431
|
hero,
|
|
1412
|
-
showPicker && /* @__PURE__ */ (0,
|
|
1432
|
+
showPicker && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: styles4.widePicker, children: picker })
|
|
1413
1433
|
] })
|
|
1414
|
-
] }) : /* @__PURE__ */ (0,
|
|
1434
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_auto_paper6.FadingScrollView, { ...tab && columnClamp, style: styles4.scroll, contentContainerStyle: [styles4.content, { paddingTop: 56 + insets.top, paddingBottom: 24 + insets.bottom, paddingLeft: 16 + insets.left, paddingRight: 16 + insets.right }], children: [
|
|
1415
1435
|
pressAway,
|
|
1416
1436
|
hero,
|
|
1417
|
-
showPicker && /* @__PURE__ */ (0,
|
|
1418
|
-
tabBar && /* @__PURE__ */ (0,
|
|
1419
|
-
/* @__PURE__ */ (0,
|
|
1437
|
+
showPicker && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
|
|
1438
|
+
tabBar && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: styles4.listWidth, children: tabBar }),
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: styles4.listWidth, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.list, children: (games, built) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GameList, { games, built, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
|
|
1420
1440
|
] }) }),
|
|
1421
|
-
/* @__PURE__ */ (0,
|
|
1422
|
-
/* @__PURE__ */ (0,
|
|
1423
|
-
RulesSheet && /* @__PURE__ */ (0,
|
|
1441
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_feedback_press3.IconButton, { icon: "trophy", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, left: 8 + insets.left }], onPress: () => import_expo_router10.router.push(STATS_HREF), accessibilityLabel: "Stats & Achievements" }),
|
|
1442
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_feedback_press3.IconButton, { icon: "cog", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, right: 8 + insets.right }], onPress: () => setSettingsOpen(true), accessibilityLabel: "Settings" }),
|
|
1443
|
+
RulesSheet && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RulesSheet, { visible: true, onDismiss: () => setRulesGame(null) })
|
|
1424
1444
|
] }) }),
|
|
1425
|
-
/* @__PURE__ */ (0,
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SettingsDialog, { visible: settingsOpen, onDismiss: () => setSettingsOpen(false), onShowHowToPlay: pack.guide ? openPack : void 0, showProfile: true })
|
|
1426
1446
|
] });
|
|
1427
1447
|
}
|
|
1428
1448
|
var SEAT_ONE_PICKER = "home-p1";
|
|
@@ -1435,17 +1455,17 @@ function TabPanes({ panes, shown, buildOthers, style, children }) {
|
|
|
1435
1455
|
return panes.map(({ key, games }) => {
|
|
1436
1456
|
const built = builtGames(key);
|
|
1437
1457
|
if (built === 0) return null;
|
|
1438
|
-
return /* @__PURE__ */ (0,
|
|
1458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TabPane, { shown: key === shown, style, children: children(games, built) }, key);
|
|
1439
1459
|
});
|
|
1440
1460
|
}
|
|
1441
1461
|
function useBuiltGames(shown, total, buildOthers) {
|
|
1442
|
-
const [picked, setPicked] = (0,
|
|
1462
|
+
const [picked, setPicked] = (0, import_react18.useState)([shown]);
|
|
1443
1463
|
if (!picked.includes(shown)) setPicked([...picked, shown]);
|
|
1444
|
-
const [others, setOthers] = (0,
|
|
1464
|
+
const [others, setOthers] = (0, import_react18.useState)(import_react_native9.Platform.OS === "web" ? total : 0);
|
|
1445
1465
|
const building = buildOthers && others < total;
|
|
1446
|
-
(0,
|
|
1466
|
+
(0, import_react18.useEffect)(() => {
|
|
1447
1467
|
if (!building) return;
|
|
1448
|
-
const id = setTimeout(() => (0,
|
|
1468
|
+
const id = setTimeout(() => (0, import_react18.startTransition)(() => setOthers(others + 1)), others === 0 ? OTHER_PANES_DELAY_MS : OTHER_PANES_STEP_MS);
|
|
1449
1469
|
return () => clearTimeout(id);
|
|
1450
1470
|
}, [building, others]);
|
|
1451
1471
|
return (pane) => pane === shown || picked.includes(pane) ? total : others;
|
|
@@ -1453,14 +1473,14 @@ function useBuiltGames(shown, total, buildOthers) {
|
|
|
1453
1473
|
var OTHER_PANES_DELAY_MS = 1200;
|
|
1454
1474
|
var OTHER_PANES_STEP_MS = 150;
|
|
1455
1475
|
function TabPane({ shown, style, children }) {
|
|
1456
|
-
return /* @__PURE__ */ (0,
|
|
1476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { collapsable: false, "aria-hidden": !shown, style: [style, !shown && styles4.paneHidden], children });
|
|
1457
1477
|
}
|
|
1458
|
-
var PreviewsRevealedContext = (0,
|
|
1478
|
+
var PreviewsRevealedContext = (0, import_react18.createContext)(false);
|
|
1459
1479
|
var PreviewsRevealed = PreviewsRevealedContext.Provider;
|
|
1460
1480
|
function useClampOnShrink() {
|
|
1461
|
-
const view = (0,
|
|
1462
|
-
const sizes = (0,
|
|
1463
|
-
return (0,
|
|
1481
|
+
const view = (0, import_react18.useRef)(null);
|
|
1482
|
+
const sizes = (0, import_react18.useRef)({ viewport: 0, offset: 0 });
|
|
1483
|
+
return (0, import_react18.useMemo)(
|
|
1464
1484
|
() => ({
|
|
1465
1485
|
ref: (instance) => {
|
|
1466
1486
|
view.current = instance;
|
|
@@ -1486,52 +1506,52 @@ function hasRules(game) {
|
|
|
1486
1506
|
return !!(game.Rules || game.guide);
|
|
1487
1507
|
}
|
|
1488
1508
|
function RulesHost({ enabled, children }) {
|
|
1489
|
-
return enabled ? /* @__PURE__ */ (0,
|
|
1509
|
+
return enabled ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.Portal.Host, { children }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
1490
1510
|
}
|
|
1491
|
-
var GameList = (0,
|
|
1492
|
-
return games.slice(0, built).map((game) => /* @__PURE__ */ (0,
|
|
1511
|
+
var GameList = (0, import_react18.memo)(function GameList2({ games, built, ...rest }) {
|
|
1512
|
+
return games.slice(0, built).map((game) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GameRow, { game, ...rest }, game.id));
|
|
1493
1513
|
});
|
|
1494
|
-
var GameGrid = (0,
|
|
1495
|
-
return games.slice(0, built).map((game) => /* @__PURE__ */ (0,
|
|
1514
|
+
var GameGrid = (0, import_react18.memo)(function GameGrid2({ games, built, ...rest }) {
|
|
1515
|
+
return games.slice(0, built).map((game) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GameTile, { game, ...rest }, game.id));
|
|
1496
1516
|
});
|
|
1497
1517
|
var ROW_BLURB_LINES = 3;
|
|
1498
|
-
var GameRow = (0,
|
|
1518
|
+
var GameRow = (0, import_react18.memo)(function GameRow2({ game, dark, p1Color, p2Color, onOpen, onRules }) {
|
|
1499
1519
|
const { titleStyle } = usePack();
|
|
1500
1520
|
const well = (0, import_chrome7.useWellColors)();
|
|
1501
1521
|
const GameIcon = game.icon;
|
|
1502
1522
|
return (
|
|
1503
1523
|
// The rules button sits beside the row's own button, laid over its end, not inside it: a button
|
|
1504
1524
|
// inside a button is invalid on the web.
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1506
|
-
/* @__PURE__ */ (0,
|
|
1507
|
-
game.Preview ? /* @__PURE__ */ (0,
|
|
1508
|
-
/* @__PURE__ */ (0,
|
|
1509
|
-
/* @__PURE__ */ (0,
|
|
1510
|
-
/* @__PURE__ */ (0,
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_native9.View, { children: [
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_feedback_press3.Pressable, { onPress: () => onOpen(game), style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1527
|
+
game.Preview ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, dark, p1Color, p2Color }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_native9.View, { style: styles4.rowText, children: [
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.Text, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.Text, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
|
|
1511
1531
|
] })
|
|
1512
1532
|
] }),
|
|
1513
|
-
hasRules(game) && /* @__PURE__ */ (0,
|
|
1533
|
+
hasRules(game) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_feedback_press3.Pressable, { onPress: () => onRules(game), style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
|
|
1514
1534
|
] })
|
|
1515
1535
|
);
|
|
1516
1536
|
});
|
|
1517
|
-
var GameTile = (0,
|
|
1537
|
+
var GameTile = (0, import_react18.memo)(function GameTile2({ game, width, previewWidth, dark, p1Color, p2Color, onOpen, onRules }) {
|
|
1518
1538
|
const { titleStyle } = usePack();
|
|
1519
1539
|
const well = (0, import_chrome7.useWellColors)();
|
|
1520
|
-
return /* @__PURE__ */ (0,
|
|
1521
|
-
/* @__PURE__ */ (0,
|
|
1522
|
-
/* @__PURE__ */ (0,
|
|
1523
|
-
/* @__PURE__ */ (0,
|
|
1524
|
-
/* @__PURE__ */ (0,
|
|
1540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_native9.View, { style: { width }, children: [
|
|
1541
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_feedback_press3.Pressable, { onPress: () => onOpen(game), style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1542
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PreviewBox, { game, width: previewWidth, dark, p1Color, p2Color }),
|
|
1543
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.Text, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1544
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.Text, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
|
|
1525
1545
|
] }),
|
|
1526
|
-
hasRules(game) && /* @__PURE__ */ (0,
|
|
1546
|
+
hasRules(game) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_feedback_press3.Pressable, { onPress: () => onRules(game), style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
|
|
1527
1547
|
] });
|
|
1528
1548
|
});
|
|
1529
1549
|
function PreviewBox({ game, width, dark, p1Color, p2Color }) {
|
|
1530
|
-
const revealed = (0,
|
|
1550
|
+
const revealed = (0, import_react18.useContext)(PreviewsRevealedContext);
|
|
1531
1551
|
const height = Math.round(width / PREVIEW_ASPECT);
|
|
1532
1552
|
const { Preview, icon: GameIcon } = game;
|
|
1533
1553
|
const iconSize = Math.min(height, ROW_ICON_SIZE);
|
|
1534
|
-
return /* @__PURE__ */ (0,
|
|
1554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: [styles4.preview, { width, height, backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: Preview ? revealed && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Preview, { width, height, p1Color, p2Color, dark }) : GameIcon && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native9.View, { style: [styles4.previewIcon, { width: iconSize, height: iconSize, borderRadius: iconSize * 0.22 }], children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GameIcon, { size: iconSize, p1Color, p2Color, dark }) }) });
|
|
1535
1555
|
}
|
|
1536
1556
|
var ROW_ICON_SIZE = 56;
|
|
1537
1557
|
var ICON_LIGHT_BG = "#FAFAFA";
|
|
@@ -1684,16 +1704,16 @@ var styles4 = import_react_native9.StyleSheet.create({
|
|
|
1684
1704
|
var import_auto_paper7 = require("@rific/auto-paper");
|
|
1685
1705
|
var import_chrome8 = require("@tastic/hud/chrome");
|
|
1686
1706
|
var import_profile10 = require("@tastic/profile");
|
|
1687
|
-
var
|
|
1688
|
-
var
|
|
1707
|
+
var import_expo_router11 = require("expo-router");
|
|
1708
|
+
var import_react20 = require("react");
|
|
1689
1709
|
var import_react_native10 = require("react-native");
|
|
1690
1710
|
var import_react_native_paper3 = require("react-native-paper");
|
|
1691
1711
|
var import_react_native_safe_area_context5 = require("react-native-safe-area-context");
|
|
1692
|
-
var
|
|
1712
|
+
var import_react_redux12 = require("react-redux");
|
|
1693
1713
|
|
|
1694
1714
|
// src/components/Staged.tsx
|
|
1695
|
-
var
|
|
1696
|
-
var
|
|
1715
|
+
var import_react19 = require("react");
|
|
1716
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1697
1717
|
function onShown(run) {
|
|
1698
1718
|
let idle;
|
|
1699
1719
|
let frame = requestAnimationFrame(() => {
|
|
@@ -1708,17 +1728,17 @@ function onShown(run) {
|
|
|
1708
1728
|
};
|
|
1709
1729
|
}
|
|
1710
1730
|
function Staged({ first = 1, step = 1, children }) {
|
|
1711
|
-
const parts = (0,
|
|
1712
|
-
const [drawn, setDrawn] = (0,
|
|
1713
|
-
(0,
|
|
1731
|
+
const parts = (0, import_react19.useMemo)(() => import_react19.Children.toArray(children), [children]);
|
|
1732
|
+
const [drawn, setDrawn] = (0, import_react19.useState)(first);
|
|
1733
|
+
(0, import_react19.useEffect)(() => {
|
|
1714
1734
|
if (drawn >= parts.length) return;
|
|
1715
1735
|
return onShown(() => setDrawn(drawn + step));
|
|
1716
1736
|
}, [drawn, parts.length, step]);
|
|
1717
|
-
return /* @__PURE__ */ (0,
|
|
1737
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: parts.slice(0, drawn) });
|
|
1718
1738
|
}
|
|
1719
1739
|
|
|
1720
1740
|
// src/screens/StatsScreen.tsx
|
|
1721
|
-
var
|
|
1741
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1722
1742
|
var STATS = "stats";
|
|
1723
1743
|
var ACHIEVEMENTS = "achievements";
|
|
1724
1744
|
var TABS = [
|
|
@@ -1738,10 +1758,10 @@ var MANAGE_OPTION = { value: MANAGE, label: "Manage", icon: "account-cog-outline
|
|
|
1738
1758
|
var STATS_MAX_WIDTH = 640;
|
|
1739
1759
|
function StatsScreen() {
|
|
1740
1760
|
const pickerHost = (0, import_chrome8.usePopoverHost)();
|
|
1741
|
-
return /* @__PURE__ */ (0,
|
|
1761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(StatsPressAway, { host: pickerHost, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_chrome8.ScreenFrame, { portalHost: true, maxContentWidth: STATS_MAX_WIDTH, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(StatsContent, { pickerHost }) }) });
|
|
1742
1762
|
}
|
|
1743
1763
|
function StatsPressAway({ host, children }) {
|
|
1744
|
-
return /* @__PURE__ */ (0,
|
|
1764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native10.View, { testID: "stats-press-away", style: styles5.screen, onStartShouldSetResponder: () => host.openId !== null, onResponderRelease: host.close, children });
|
|
1745
1765
|
}
|
|
1746
1766
|
var useNoPackReset = () => null;
|
|
1747
1767
|
var noPickerAlign2 = () => void 0;
|
|
@@ -1751,13 +1771,13 @@ function StatsContent({ pickerHost }) {
|
|
|
1751
1771
|
const { dark, colors } = (0, import_auto_paper7.useAutoPaperTheme)();
|
|
1752
1772
|
const insets = (0, import_react_native_safe_area_context5.useSafeAreaInsets)();
|
|
1753
1773
|
const { profiles, lastSelected } = useProfiles();
|
|
1754
|
-
const dispatch = (0,
|
|
1774
|
+
const dispatch = (0, import_react_redux12.useDispatch)();
|
|
1755
1775
|
const fg = pack.foreground ?? colors.onBackground;
|
|
1756
|
-
const [tab, setTab] = (0,
|
|
1757
|
-
const [gameId, setGameId] = (0,
|
|
1776
|
+
const [tab, setTab] = (0, import_react20.useState)(STATS);
|
|
1777
|
+
const [gameId, setGameId] = (0, import_react20.useState)(ALL_GAMES2);
|
|
1758
1778
|
const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
|
|
1759
1779
|
const statsPlayer = useStatsPlayer();
|
|
1760
|
-
const [selectedProfileId, setSelectedProfileId] = (0,
|
|
1780
|
+
const [selectedProfileId, setSelectedProfileId] = (0, import_react20.useState)(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
|
|
1761
1781
|
const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
|
|
1762
1782
|
const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
|
|
1763
1783
|
const pickedTab = homeTabs?.findIndex((_, index) => gameId === tabGames(index)) ?? -1;
|
|
@@ -1767,14 +1787,14 @@ function StatsContent({ pickerHost }) {
|
|
|
1767
1787
|
const packTabs = pack.statsTabs ?? NO_PACK_TABS;
|
|
1768
1788
|
const packTab = packTabs.find((t) => t.value === tab);
|
|
1769
1789
|
const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
|
|
1770
|
-
const playerOptions = (0,
|
|
1771
|
-
const gameOptions = (0,
|
|
1790
|
+
const playerOptions = (0, import_react20.useMemo)(() => [{ value: EVERYONE, label: "Everyone", icon: "account-group" }, ...pack.guestStats && profiles.length > 0 ? [{ value: GUEST_PLAYER_ID, label: "Guest", icon: "account-outline" }] : [], ...profiles.map((p) => ({ value: p.id, label: p.name, icon: "account", color: pack.previewColor ? pack.previewColor(p.color, dark) : p.color })), MANAGE_OPTION], [profiles, pack, dark]);
|
|
1791
|
+
const gameOptions = (0, import_react20.useMemo)(() => {
|
|
1772
1792
|
const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
|
|
1773
1793
|
const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
|
|
1774
1794
|
if (!homeTabs) return [all, ...pack.games.map(option)];
|
|
1775
1795
|
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)] }))];
|
|
1776
1796
|
}, [pack.games, homeTabs]);
|
|
1777
|
-
const tabButtons = (0,
|
|
1797
|
+
const tabButtons = (0, import_react20.useMemo)(() => {
|
|
1778
1798
|
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;
|
|
1779
1799
|
return pack.labelStyle ? buttons.map((button) => ({ ...button, labelStyle: pack.labelStyle })) : buttons;
|
|
1780
1800
|
}, [packTabs, pack.labelStyle]);
|
|
@@ -1790,16 +1810,16 @@ function StatsContent({ pickerHost }) {
|
|
|
1790
1810
|
const surface = pack.Backdrop ? { backgroundColor: colors.surface } : void 0;
|
|
1791
1811
|
const triggerStyle = pack.Backdrop ? [styles5.pill, surface] : void 0;
|
|
1792
1812
|
const PackTabContent = packTab?.Content;
|
|
1793
|
-
return /* @__PURE__ */ (0,
|
|
1794
|
-
/* @__PURE__ */ (0,
|
|
1795
|
-
/* @__PURE__ */ (0,
|
|
1796
|
-
/* @__PURE__ */ (0,
|
|
1797
|
-
/* @__PURE__ */ (0,
|
|
1798
|
-
showGamePicker && /* @__PURE__ */ (0,
|
|
1813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_chrome8.BaseStatsScreen, { title, titleStyle: pack.titleStyle, onBack: import_core6.safeBack, insets, onReset: reset.onReset, resetLabel: reset.label, resetConfirmTitle: reset.title, resetConfirmBody: reset.body, fg: pack.foreground, bg: pack.Backdrop ? "transparent" : void 0, children: [
|
|
1814
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_chrome8.PressAwayOverlay, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles5.pressAway }),
|
|
1815
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native_paper3.SegmentedButtons, { value: tab, onValueChange: setTab, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles5.tabs, surface] }),
|
|
1816
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react_native10.View, { style: [styles5.filters, pickerHost.openId !== null && styles5.filtersOpen], onStartShouldSetResponder: () => pickerHost.openId !== null, children: [
|
|
1817
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_profile10.OptionPicker, { id: PLAYER_PICKER_ID, host: pickerHost, options: playerOptions, value: profileId ?? EVERYONE, onChange: (value) => value === MANAGE ? import_expo_router11.router.push(PROFILES_HREF) : setSelectedProfileId(value === EVERYONE ? null : value), color: colors.primary, dark, icon: profileId ? "account" : "account-group", caption: "Player", alignOverride: playerAlign, triggerStyle }),
|
|
1818
|
+
showGamePicker && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_profile10.OptionPicker, { 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 })
|
|
1799
1819
|
] }),
|
|
1800
|
-
tab === STATS && pack.StatsSections && /* @__PURE__ */ (0,
|
|
1801
|
-
PackTabContent && /* @__PURE__ */ (0,
|
|
1802
|
-
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */ (0,
|
|
1820
|
+
tab === STATS && pack.StatsSections && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(pack.StatsSections, { profileId, gameId: oneGameId, gameIds }),
|
|
1821
|
+
PackTabContent && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PackTabContent, { profileId, gameId: oneGameId, gameIds }),
|
|
1822
|
+
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(pack.AchievementList, { profileId }) : (tab === STATS || tab === ACHIEVEMENTS) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Staged, { first: tab === STATS && pack.StatsSections ? 0 : 1, children: games.map((game) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(GameStats, { game, tab, profileId, showTitle: games.length > 1 && pack.statsGameTitles !== false, titleColor: fg }, game.id)) }, `${tab} ${gameId}`)
|
|
1803
1823
|
] });
|
|
1804
1824
|
}
|
|
1805
1825
|
function resetFor(pack, packReset, profileId, profiles, games, resetGames) {
|
|
@@ -1815,9 +1835,9 @@ function GameStats({ game, tab, profileId, showTitle, titleColor }) {
|
|
|
1815
1835
|
const { StatsSections, AchievementList } = game;
|
|
1816
1836
|
const Sections = tab === STATS ? StatsSections : AchievementList;
|
|
1817
1837
|
if (!Sections) return null;
|
|
1818
|
-
return /* @__PURE__ */ (0,
|
|
1819
|
-
showTitle && /* @__PURE__ */ (0,
|
|
1820
|
-
/* @__PURE__ */ (0,
|
|
1838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react_native10.View, { style: styles5.game, children: [
|
|
1839
|
+
showTitle && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native_paper3.Text, { variant: "titleLarge", style: [styles5.gameTitle, { color: titleColor }, titleStyle], children: game.title }),
|
|
1840
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Sections, { profileId })
|
|
1821
1841
|
] });
|
|
1822
1842
|
}
|
|
1823
1843
|
var styles5 = import_react_native10.StyleSheet.create({
|
|
@@ -1855,21 +1875,21 @@ var styles5 = import_react_native10.StyleSheet.create({
|
|
|
1855
1875
|
|
|
1856
1876
|
// src/components/imageGameIcon.tsx
|
|
1857
1877
|
var import_react_native11 = require("react-native");
|
|
1858
|
-
var
|
|
1878
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1859
1879
|
function imageGameIcon(images) {
|
|
1860
1880
|
return function ImageGameIcon({ size, dark }) {
|
|
1861
|
-
return /* @__PURE__ */ (0,
|
|
1881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_react_native11.Image, { source: dark ? images.dark : images.light, style: { height: size, width: size }, accessibilityIgnoresInvertColors: true });
|
|
1862
1882
|
};
|
|
1863
1883
|
}
|
|
1864
1884
|
|
|
1865
1885
|
// src/components/MatchChips.tsx
|
|
1866
1886
|
var import_auto_paper8 = require("@rific/auto-paper");
|
|
1867
1887
|
var import_feedback_press4 = require("@rific/feedback-press");
|
|
1868
|
-
var
|
|
1888
|
+
var import_react21 = require("react");
|
|
1869
1889
|
var import_react_native12 = require("react-native");
|
|
1870
1890
|
var import_react_native_reanimated3 = __toESM(require("react-native-reanimated"));
|
|
1871
1891
|
var import_react_native_safe_area_context6 = require("react-native-safe-area-context");
|
|
1872
|
-
var
|
|
1892
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1873
1893
|
var MATCH_CHIPS_FADE_MS = 150;
|
|
1874
1894
|
var CHIP_SIZE = 48;
|
|
1875
1895
|
var EDGE_PAD = 8;
|
|
@@ -1880,7 +1900,7 @@ function MatchChips({ playing, faceToFace, centerLineY, onBack, onSettings }) {
|
|
|
1880
1900
|
const atComputer = useAtComputer();
|
|
1881
1901
|
const visible = atComputer || !playing;
|
|
1882
1902
|
const opacity = (0, import_react_native_reanimated3.useSharedValue)(visible ? 1 : 0);
|
|
1883
|
-
(0,
|
|
1903
|
+
(0, import_react21.useEffect)(() => {
|
|
1884
1904
|
opacity.value = (0, import_react_native_reanimated3.withTiming)(visible ? 1 : 0, { duration: MATCH_CHIPS_FADE_MS });
|
|
1885
1905
|
}, [visible]);
|
|
1886
1906
|
const fadeStyle = (0, import_react_native_reanimated3.useAnimatedStyle)(() => ({ opacity: opacity.value }));
|
|
@@ -1891,9 +1911,9 @@ function MatchChips({ playing, faceToFace, centerLineY, onBack, onSettings }) {
|
|
|
1891
1911
|
const backSlot = { top, left: EDGE_PAD + insets.left };
|
|
1892
1912
|
const settingsSlot = { top, right: EDGE_PAD + insets.right };
|
|
1893
1913
|
const pointerEvents = visible ? "box-none" : "none";
|
|
1894
|
-
return /* @__PURE__ */ (0,
|
|
1895
|
-
/* @__PURE__ */ (0,
|
|
1896
|
-
/* @__PURE__ */ (0,
|
|
1914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_native_reanimated3.default.View, { pointerEvents, style: [styles6.slot, backSlot, fadeStyle], testID: "match-chips-back", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_feedback_press4.IconButton, { icon: "arrow-left", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onBack, accessibilityLabel: "Back" }) }),
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_native_reanimated3.default.View, { pointerEvents, style: [styles6.slot, settingsSlot, fadeStyle], testID: "match-chips-settings", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_feedback_press4.IconButton, { icon: "cog", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onSettings, accessibilityLabel: "Settings" }) })
|
|
1897
1917
|
] });
|
|
1898
1918
|
}
|
|
1899
1919
|
var styles6 = import_react_native12.StyleSheet.create({
|
|
@@ -1902,31 +1922,31 @@ var styles6 = import_react_native12.StyleSheet.create({
|
|
|
1902
1922
|
});
|
|
1903
1923
|
|
|
1904
1924
|
// src/hooks/useActiveRound.ts
|
|
1905
|
-
var
|
|
1925
|
+
var import_react_redux13 = require("react-redux");
|
|
1906
1926
|
function useActiveRound(game, defaults) {
|
|
1907
|
-
const round = (0,
|
|
1927
|
+
const round = (0, import_react_redux13.useSelector)((state) => state.liveplay.activeRound);
|
|
1908
1928
|
const choices = usePackGame(game)?.seatTwo;
|
|
1909
1929
|
if (!round || round.game !== game) return { mode: roundModeFor(seatTwoFor(DEFAULT_OPPONENT.seatTwo, choices)), settings: defaults };
|
|
1910
1930
|
return { mode: round.mode, settings: { ...defaults, ...round.settings } };
|
|
1911
1931
|
}
|
|
1912
1932
|
|
|
1913
1933
|
// src/hooks/useBackBlock.ts
|
|
1914
|
-
var
|
|
1915
|
-
var
|
|
1934
|
+
var import_expo_router12 = require("expo-router");
|
|
1935
|
+
var import_react22 = require("react");
|
|
1916
1936
|
function useBackBlock(held, onHeld, leave = import_core6.safeBack) {
|
|
1917
|
-
const leavingRef = (0,
|
|
1918
|
-
const [leaving, setLeaving] = (0,
|
|
1919
|
-
const leaveRef = (0,
|
|
1920
|
-
(0,
|
|
1937
|
+
const leavingRef = (0, import_react22.useRef)(false);
|
|
1938
|
+
const [leaving, setLeaving] = (0, import_react22.useState)(false);
|
|
1939
|
+
const leaveRef = (0, import_react22.useRef)(leave);
|
|
1940
|
+
(0, import_react22.useEffect)(() => {
|
|
1921
1941
|
leaveRef.current = leave;
|
|
1922
1942
|
});
|
|
1923
|
-
(0,
|
|
1943
|
+
(0, import_expo_router12.usePreventRemove)(held && !leaving, ({ repeat }) => {
|
|
1924
1944
|
if (leavingRef.current) {
|
|
1925
1945
|
setLeaving(true);
|
|
1926
1946
|
repeat();
|
|
1927
1947
|
} else onHeld();
|
|
1928
1948
|
});
|
|
1929
|
-
return (0,
|
|
1949
|
+
return (0, import_react22.useCallback)(() => {
|
|
1930
1950
|
leavingRef.current = true;
|
|
1931
1951
|
leaveRef.current();
|
|
1932
1952
|
}, []);
|
|
@@ -2061,8 +2081,8 @@ function forgetProfileAchievements(dropStats) {
|
|
|
2061
2081
|
|
|
2062
2082
|
// src/gameStats.tsx
|
|
2063
2083
|
var import_achievements2 = require("@tastic/achievements");
|
|
2064
|
-
var
|
|
2065
|
-
var
|
|
2084
|
+
var import_react23 = require("react");
|
|
2085
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2066
2086
|
var SEATS = [1, 2];
|
|
2067
2087
|
function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
|
|
2068
2088
|
const { actions: actions6, reducer: sliceReducer } = (0, import_achievements2.createAchievementsSlice)({
|
|
@@ -2079,7 +2099,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
2079
2099
|
};
|
|
2080
2100
|
const reducer6 = onProfileRemoved(sliceReducer, forgetProfileAchievements(dropProfileStats));
|
|
2081
2101
|
const profileViews = (stats) => Object.fromEntries(Object.entries(stats.profiles).map(([profileId, bucket]) => [profileId, getProfileStatsView(bucket)]));
|
|
2082
|
-
const Context = (0,
|
|
2102
|
+
const Context = (0, import_react23.createContext)(null);
|
|
2083
2103
|
function Provider({ children }) {
|
|
2084
2104
|
const { stats, unlockedAchievements, recordOutcome, resetAll } = (0, import_achievements2.useAchievements)({
|
|
2085
2105
|
catalog,
|
|
@@ -2087,18 +2107,18 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
2087
2107
|
actions: actions6,
|
|
2088
2108
|
profileViews
|
|
2089
2109
|
});
|
|
2090
|
-
const record = (0,
|
|
2110
|
+
const record = (0, import_react23.useCallback)(
|
|
2091
2111
|
(update, profileIds) => {
|
|
2092
2112
|
const result = recordOutcome(update);
|
|
2093
2113
|
return { device: result.device, profiles: (0, import_achievements2.mapUnlocksBySeat)(SEATS, profileIds, result.profiles) };
|
|
2094
2114
|
},
|
|
2095
2115
|
[recordOutcome]
|
|
2096
2116
|
);
|
|
2097
|
-
const value = (0,
|
|
2098
|
-
return /* @__PURE__ */ (0,
|
|
2117
|
+
const value = (0, import_react23.useMemo)(() => ({ stats, unlockedAchievements, record, resetAll }), [stats, unlockedAchievements, record, resetAll]);
|
|
2118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Context.Provider, { value, children });
|
|
2099
2119
|
}
|
|
2100
2120
|
function useStats() {
|
|
2101
|
-
const ctx = (0,
|
|
2121
|
+
const ctx = (0, import_react23.useContext)(Context);
|
|
2102
2122
|
if (!ctx) throw new Error(`The ${key} stats are read within their game's Provider`);
|
|
2103
2123
|
return ctx;
|
|
2104
2124
|
}
|
|
@@ -2106,8 +2126,8 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
2106
2126
|
}
|
|
2107
2127
|
|
|
2108
2128
|
// src/playerSettings.ts
|
|
2109
|
-
var
|
|
2110
|
-
var
|
|
2129
|
+
var import_react24 = require("react");
|
|
2130
|
+
var import_react_redux14 = require("react-redux");
|
|
2111
2131
|
var SEATS2 = [1, 2];
|
|
2112
2132
|
function seatPlayerKey(selection, seat) {
|
|
2113
2133
|
return selection[seat] ?? `guest:${seat}`;
|
|
@@ -2145,13 +2165,13 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
|
|
|
2145
2165
|
return compose(root[settingsKey], root[controlsKey], state.profileSelection, state.opponent.seatTwo === "person");
|
|
2146
2166
|
}
|
|
2147
2167
|
function useSettings() {
|
|
2148
|
-
const selection = (0,
|
|
2149
|
-
const seatTwoIsPerson = (0,
|
|
2150
|
-
const saved = (0,
|
|
2151
|
-
const controls = (0,
|
|
2152
|
-
const dispatch = (0,
|
|
2153
|
-
const settings = (0,
|
|
2154
|
-
const setSettings = (0,
|
|
2168
|
+
const selection = (0, import_react_redux14.useSelector)((state) => state.profileSelection);
|
|
2169
|
+
const seatTwoIsPerson = (0, import_react_redux14.useSelector)((state) => state.opponent.seatTwo === "person");
|
|
2170
|
+
const saved = (0, import_react_redux14.useSelector)((state) => state[settingsKey]);
|
|
2171
|
+
const controls = (0, import_react_redux14.useSelector)((state) => state[controlsKey]);
|
|
2172
|
+
const dispatch = (0, import_react_redux14.useDispatch)();
|
|
2173
|
+
const settings = (0, import_react24.useMemo)(() => compose(saved, controls, selection, seatTwoIsPerson), [saved, controls, selection, seatTwoIsPerson]);
|
|
2174
|
+
const setSettings = (0, import_react24.useCallback)(
|
|
2155
2175
|
(next) => {
|
|
2156
2176
|
const { controlScheme, ...changes } = next;
|
|
2157
2177
|
if (Object.keys(changes).length > 0) dispatch(patch(seatPlayerKey(selection, 1), changes));
|
|
@@ -2216,6 +2236,7 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
|
|
|
2216
2236
|
useAtComputer,
|
|
2217
2237
|
useBackBlock,
|
|
2218
2238
|
useGameGuide,
|
|
2239
|
+
useGuideCovering,
|
|
2219
2240
|
useOpponent,
|
|
2220
2241
|
usePack,
|
|
2221
2242
|
usePackGame,
|