@adminide-stack/yantra-mobile 12.0.175 → 12.0.176-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/features/agent-chat/NativeAgentChat.js +2 -1
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/canvas/CanvasAgentChatPane.js +1 -1
- package/lib/features/canvas/CanvasAgentChatPane.js.map +1 -1
- package/lib/features/chat/ChatTranscript.js +28 -12
- package/lib/features/chat/ChatTranscript.js.map +1 -1
- package/lib/features/chat/MessageActionBar.js +1 -1
- package/lib/features/chat/MessageActionBar.js.map +1 -1
- package/lib/features/design/surface/DesignAgentChatPane.js +10 -3
- package/lib/features/design/surface/DesignAgentChatPane.js.map +1 -1
- package/lib/features/games/cubeforge3D.js +41 -15
- package/lib/features/games/cubeforge3D.js.map +1 -1
- package/lib/features/games/cubeforgeFriends.js +17 -1
- package/lib/features/games/cubeforgeFriends.js.map +1 -1
- package/lib/features/games/cubeforgeHelper.js +5 -4
- package/lib/features/games/cubeforgeHelper.js.map +1 -1
- package/lib/features/games/gameInvite.js +6 -1
- package/lib/features/games/gameInvite.js.map +1 -1
- package/lib/features/games/gameNotifications.js +9 -0
- package/lib/features/games/gameNotifications.js.map +1 -0
- package/lib/features/games/gameOrientation.js +10 -0
- package/lib/features/games/gameOrientation.js.map +1 -0
- package/lib/features/games/useCubeforgeFriends.js +86 -38
- package/lib/features/games/useCubeforgeFriends.js.map +1 -1
- package/lib/features/games/vendored/core/cubeforge/gamePreferences.js +13 -0
- package/lib/features/games/vendored/core/cubeforge/gamePreferences.js.map +1 -0
- package/lib/features/games/vendored/core/cubeforge/openingMemory.js +31 -0
- package/lib/features/games/vendored/core/cubeforge/openingMemory.js.map +1 -0
- package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js +66 -2
- package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js.map +1 -1
- package/lib/features/games/vendored/ui/GamesRoot.js +85 -7
- package/lib/features/games/vendored/ui/GamesRoot.js.map +1 -1
- package/lib/features/games/vendored/ui/components/primitives.js +1 -1
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js +188 -16
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js.map +1 -1
- package/lib/features/games/vendored/ui/screens/HowToPlayScreen.js +474 -0
- package/lib/features/games/vendored/ui/screens/HowToPlayScreen.js.map +1 -0
- package/lib/features/reporting/ReportAiContentButton.js +15 -0
- package/lib/features/reporting/ReportAiContentButton.js.map +1 -0
- package/lib/features/reporting/reportAiContent.js +111 -0
- package/lib/features/reporting/reportAiContent.js.map +1 -0
- package/lib/features/resume/ResumeAgentChatPane.js +1 -1
- package/lib/features/resume/ResumeAgentChatPane.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/screens/Account/index.js +19 -4
- package/lib/screens/Account/index.js.map +1 -1
- package/lib/screens/GamesNative/index.js +4 -3
- package/lib/screens/GamesNative/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {useRef,useMemo}from'react';import {useApolloClient,gql}from'@apollo/client/index.js';import {config}from'../../config/env-config.js';import {useCanvasSession}from'../canvas/useCanvasSession.js';import {toConversation}from'../messaging/chatModel.js';import {SEND_MESSAGE_MUTATION,CHANNELS_QUERY}from'../messaging/chatOperations.js';import {NATIVE_CHAT_CHANNELS_QUERY_VARS,isNativeMessengerChannel}from'../messaging/nativeChatChannelQuery.js';import {useChatViewer}from'../messaging/useChatViewer.js';import {createCubeforgeFriends,waitForToken}from'./cubeforgeFriends.js';const FALLBACK_PLAYER_NAME = "Player";
|
|
1
|
+
import {useRef,useMemo}from'react';import {useApolloClient,gql}from'@apollo/client/index.js';import {config}from'../../config/env-config.js';import {useCanvasSession}from'../canvas/useCanvasSession.js';import {pickAuthor,displayNameOf,toEpoch,toConversation}from'../messaging/chatModel.js';import {SEND_MESSAGE_MUTATION,MESSAGES_QUERY,CHANNELS_QUERY}from'../messaging/chatOperations.js';import {NATIVE_CHAT_CHANNELS_QUERY_VARS,isNativeMessengerChannel}from'../messaging/nativeChatChannelQuery.js';import {useChatViewer}from'../messaging/useChatViewer.js';import {createCubeforgeFriends,waitForToken}from'./cubeforgeFriends.js';const FALLBACK_PLAYER_NAME = "Player";
|
|
2
|
+
const INVITE_CHATS_SCANNED = 10;
|
|
3
|
+
const INVITE_MESSAGES_SCANNED = 30;
|
|
2
4
|
function useCubeforgeFriends() {
|
|
3
5
|
const client = useApolloClient();
|
|
4
6
|
const {
|
|
@@ -18,26 +20,9 @@ function useCubeforgeFriends() {
|
|
|
18
20
|
token,
|
|
19
21
|
renew
|
|
20
22
|
};
|
|
21
|
-
return useMemo(() =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
token: current,
|
|
26
|
-
renew: mint
|
|
27
|
-
} = latest.current;
|
|
28
|
-
if (current && !forceNew) return current;
|
|
29
|
-
const minted = await mint();
|
|
30
|
-
if (minted || forceNew) return minted;
|
|
31
|
-
return waitForToken(() => latest.current.token);
|
|
32
|
-
},
|
|
33
|
-
playerName: () => {
|
|
34
|
-
var _a, _b;
|
|
35
|
-
return ((_b = (_a = latest.current.viewer) == null ? void 0 : _a.displayName) == null ? void 0 : _b.trim()) || FALLBACK_PLAYER_NAME;
|
|
36
|
-
},
|
|
37
|
-
listChats: async () => {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
const viewerId = (_a = latest.current.viewer) == null ? void 0 : _a.userId;
|
|
40
|
-
if (!viewerId) return [];
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
const loadChats = async (viewerId) => {
|
|
25
|
+
var _a;
|
|
41
26
|
const {
|
|
42
27
|
data
|
|
43
28
|
} = await client.query({
|
|
@@ -45,22 +30,85 @@ function useCubeforgeFriends() {
|
|
|
45
30
|
variables: NATIVE_CHAT_CHANNELS_QUERY_VARS,
|
|
46
31
|
fetchPolicy: "network-only"
|
|
47
32
|
});
|
|
48
|
-
return ((
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
33
|
+
return ((_a = data.channelsByUser) != null ? _a : []).filter((c) => isNativeMessengerChannel(c)).map((c) => toConversation(c, viewerId));
|
|
34
|
+
};
|
|
35
|
+
return createCubeforgeFriends({
|
|
36
|
+
graphqlUrl: config.GAMES_SUBGRAPH_URL,
|
|
37
|
+
getToken: async (forceNew) => {
|
|
38
|
+
const {
|
|
39
|
+
token: current,
|
|
40
|
+
renew: mint
|
|
41
|
+
} = latest.current;
|
|
42
|
+
if (current && !forceNew) return current;
|
|
43
|
+
const minted = await mint();
|
|
44
|
+
if (minted || forceNew) return minted;
|
|
45
|
+
return waitForToken(() => latest.current.token);
|
|
46
|
+
},
|
|
47
|
+
playerName: () => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return ((_b = (_a = latest.current.viewer) == null ? void 0 : _a.displayName) == null ? void 0 : _b.trim()) || FALLBACK_PLAYER_NAME;
|
|
50
|
+
},
|
|
51
|
+
listChats: async () => {
|
|
52
|
+
var _a;
|
|
53
|
+
const viewerId = (_a = latest.current.viewer) == null ? void 0 : _a.userId;
|
|
54
|
+
if (!viewerId) return [];
|
|
55
|
+
return (await loadChats(viewerId)).map((c) => ({
|
|
56
|
+
id: c.id,
|
|
57
|
+
title: c.title,
|
|
58
|
+
detail: c.isDirect ? "Person" : `Group, ${c.members.length} members`
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
recentChatMessages: async () => {
|
|
62
|
+
const viewerId = await waitForToken(() => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
return (_b = (_a = latest.current.viewer) == null ? void 0 : _a.userId) != null ? _b : null;
|
|
65
|
+
});
|
|
66
|
+
if (!viewerId) return [];
|
|
67
|
+
const chats = (await loadChats(viewerId)).slice(0, INVITE_CHATS_SCANNED);
|
|
68
|
+
const pages = await Promise.all(chats.map(async (chat) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
try {
|
|
71
|
+
const {
|
|
72
|
+
data
|
|
73
|
+
} = await client.query({
|
|
74
|
+
query: gql(MESSAGES_QUERY),
|
|
75
|
+
variables: {
|
|
76
|
+
channelId: chat.id,
|
|
77
|
+
limit: INVITE_MESSAGES_SCANNED,
|
|
78
|
+
skip: 0
|
|
79
|
+
},
|
|
80
|
+
// Reading for invites must not disturb the chat screen's own copy.
|
|
81
|
+
fetchPolicy: "no-cache"
|
|
82
|
+
});
|
|
83
|
+
return ((_b = (_a = data.messages) == null ? void 0 : _a.data) != null ? _b : []).filter((post) => Boolean(post) && !(post == null ? void 0 : post.deletedAt)).map((post) => {
|
|
84
|
+
var _a2;
|
|
85
|
+
const author = pickAuthor(post);
|
|
86
|
+
const mine = Boolean(author == null ? void 0 : author.id) && String(author == null ? void 0 : author.id) === viewerId;
|
|
87
|
+
const sender = chat.isDirect ? chat.title : displayNameOf(author);
|
|
88
|
+
return {
|
|
89
|
+
body: (_a2 = post.message) != null ? _a2 : "",
|
|
90
|
+
from: mine ? null : sender,
|
|
91
|
+
chatTitle: chat.title,
|
|
92
|
+
sentAt: toEpoch(post.createdAt)
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
} catch (e) {
|
|
96
|
+
return [];
|
|
61
97
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
98
|
+
}));
|
|
99
|
+
return pages.flat();
|
|
100
|
+
},
|
|
101
|
+
sendToChat: async (chatId, text) => {
|
|
102
|
+
await client.mutate({
|
|
103
|
+
mutation: gql(SEND_MESSAGE_MUTATION),
|
|
104
|
+
variables: {
|
|
105
|
+
channelId: chatId,
|
|
106
|
+
messageInput: {
|
|
107
|
+
content: text
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}, [client]);
|
|
66
114
|
}export{useCubeforgeFriends};//# sourceMappingURL=useCubeforgeFriends.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCubeforgeFriends.js","sources":["../../../src/features/games/useCubeforgeFriends.ts"],"sourcesContent":["/** Shared Cubeforge worlds and chat invites for the signed-in person. */\nimport { useMemo, useRef } from 'react';\nimport { gql, useApolloClient } from '@apollo/client';\nimport { config } from '../../config/env-config';\nimport { useCanvasSession } from '../canvas/useCanvasSession';\nimport {
|
|
1
|
+
{"version":3,"file":"useCubeforgeFriends.js","sources":["../../../src/features/games/useCubeforgeFriends.ts"],"sourcesContent":["/** Shared Cubeforge worlds and chat invites for the signed-in person. */\nimport { useMemo, useRef } from 'react';\nimport { gql, useApolloClient } from '@apollo/client';\nimport { config } from '../../config/env-config';\nimport { useCanvasSession } from '../canvas/useCanvasSession';\nimport {\n displayNameOf,\n pickAuthor,\n toConversation,\n toEpoch,\n type WireChannel,\n type WirePost,\n} from '../messaging/chatModel';\nimport { CHANNELS_QUERY, MESSAGES_QUERY, SEND_MESSAGE_MUTATION } from '../messaging/chatOperations';\nimport { isNativeMessengerChannel, NATIVE_CHAT_CHANNELS_QUERY_VARS } from '../messaging/nativeChatChannelQuery';\nimport { useChatViewer } from '../messaging/useChatViewer';\nimport { createCubeforgeFriends, waitForToken } from './cubeforgeFriends';\nimport type { CubeforgeFriends, InviteChat } from './vendored';\n\nconst FALLBACK_PLAYER_NAME = 'Player';\n/** How far back to look for invites: the most recent chats, and the latest messages in each. */\nconst INVITE_CHATS_SCANNED = 10;\nconst INVITE_MESSAGES_SCANNED = 30;\n\nexport function useCubeforgeFriends(): CubeforgeFriends {\n const client = useApolloClient();\n const { viewer } = useChatViewer();\n const { token, renew } = useCanvasSession();\n const latest = useRef({ viewer, token, renew });\n latest.current = { viewer, token, renew };\n\n return useMemo(() => {\n const loadChats = async (viewerId: string) => {\n const { data } = await client.query<{ channelsByUser?: (WireChannel | null)[] | null }>({\n query: gql(CHANNELS_QUERY),\n variables: NATIVE_CHAT_CHANNELS_QUERY_VARS,\n fetchPolicy: 'network-only',\n });\n return (data.channelsByUser ?? [])\n .filter((c): c is WireChannel => isNativeMessengerChannel(c))\n .map((c) => toConversation(c, viewerId));\n };\n\n return createCubeforgeFriends({\n graphqlUrl: config.GAMES_SUBGRAPH_URL,\n getToken: async (forceNew) => {\n const { token: current, renew: mint } = latest.current;\n if (current && !forceNew) return current;\n const minted = await mint();\n if (minted || forceNew) return minted;\n // Null is \"not yet\": the session mints by itself once the org and project load.\n return waitForToken(() => latest.current.token);\n },\n playerName: () => latest.current.viewer?.displayName?.trim() || FALLBACK_PLAYER_NAME,\n listChats: async (): Promise<InviteChat[]> => {\n const viewerId = latest.current.viewer?.userId;\n if (!viewerId) return [];\n return (await loadChats(viewerId)).map((c) => ({\n id: c.id,\n title: c.title,\n detail: c.isDirect ? 'Person' : `Group, ${c.members.length} members`,\n }));\n },\n recentChatMessages: async () => {\n // Games can open before the person's profile has loaded.\n const viewerId = await waitForToken(() => latest.current.viewer?.userId ?? null);\n if (!viewerId) return [];\n const chats = (await loadChats(viewerId)).slice(0, INVITE_CHATS_SCANNED);\n const pages = await Promise.all(\n chats.map(async (chat) => {\n try {\n const { data } = await client.query<{\n messages?: { data?: (WirePost | null)[] | null } | null;\n }>({\n query: gql(MESSAGES_QUERY),\n variables: { channelId: chat.id, limit: INVITE_MESSAGES_SCANNED, skip: 0 },\n // Reading for invites must not disturb the chat screen's own copy.\n fetchPolicy: 'no-cache',\n });\n return (data.messages?.data ?? [])\n .filter((post): post is WirePost => Boolean(post) && !post?.deletedAt)\n .map((post) => {\n const author = pickAuthor(post);\n const mine = Boolean(author?.id) && String(author?.id) === viewerId;\n // A person's own chat already carries the name this player knows them by.\n const sender = chat.isDirect ? chat.title : displayNameOf(author);\n return {\n body: post.message ?? '',\n from: mine ? null : sender,\n chatTitle: chat.title,\n sentAt: toEpoch(post.createdAt),\n };\n });\n } catch {\n return [];\n }\n }),\n );\n return pages.flat();\n },\n sendToChat: async (chatId, text) => {\n await client.mutate({\n mutation: gql(SEND_MESSAGE_MUTATION),\n variables: { channelId: chatId, messageInput: { content: text } },\n });\n },\n });\n }, [client]);\n}\n"],"names":["_a"],"mappings":"mnBAWA,MAAM,oBAAuB,GAAA,QAAA;AAE7B,MAAM,oBAAuB,GAAA,EAAA;AAC7B,MAAM,uBAA0B,GAAA,EAAA;AACzB,SAAS,mBAAwC,GAAA;AACtD,EAAA,MAAM,SAAS,eAAgB,EAAA;AAC/B,EAAM,MAAA;AAAA,IACJ;AAAA,MACE,aAAc,EAAA;AAClB,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA;AAAA,MACE,gBAAiB,EAAA;AACrB,EAAA,MAAM,SAAS,MAAO,CAAA;AAAA,IACpB,MAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACD,CAAA;AACD,EAAA,MAAA,CAAO,OAAU,GAAA;AAAA,IACf,MAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAM,MAAA,SAAA,GAAY,OAAO,QAAqB,KAAA;AAnClD,MAAA,IAAA,EAAA;AAoCM,MAAM,MAAA;AAAA,QACJ;AAAA,OACF,GAAI,MAAM,MAAA,CAAO,KAEd,CAAA;AAAA,QACD,KAAA,EAAO,IAAI,cAAc,CAAA;AAAA,QACzB,SAAW,EAAA,+BAAA;AAAA,QACX,WAAa,EAAA;AAAA,OACd,CAAA;AACD,MAAA,OAAA,CAAA,CAAQ,UAAK,cAAL,KAAA,IAAA,GAAA,EAAA,GAAuB,EAAC,EAAG,OAAO,CAAC,CAAA,KAAwB,wBAAyB,CAAA,CAAC,CAAC,CAAE,CAAA,GAAA,CAAI,OAAK,cAAe,CAAA,CAAA,EAAG,QAAQ,CAAC,CAAA;AAAA,KACtI;AACA,IAAA,OAAO,sBAAuB,CAAA;AAAA,MAC5B,YAAY,MAAO,CAAA,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AA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAA,EAAE,KAAK,MAAO,CAAA,MAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAQ,EAAE,CAAM,KAAA,QAAA;AAE3D,cAAA,MAAM,SAAS,IAAK,CAAA,QAAA,GAAW,IAAK,CAAA,KAAA,GAAQ,cAAc,MAAM,CAAA;AAChE,cAAO,OAAA;AAAA,gBACL,IAAMA,EAAAA,CAAAA,GAAAA,GAAA,IAAK,CAAA,OAAA,KAAL,OAAAA,GAAgB,GAAA,EAAA;AAAA,gBACtB,IAAA,EAAM,OAAO,IAAO,GAAA,MAAA;AAAA,gBACpB,WAAW,IAAK,CAAA,KAAA;AAAA,gBAChB,MAAA,EAAQ,OAAQ,CAAA,IAAA,CAAK,SAAS;AAAA,eAChC;AAAA,aACD,CAAA;AAAA,WACK,CAAA,OAAA,CAAA,EAAA;AACN,YAAA,OAAO,EAAC;AAAA;AACV,SACD,CAAC,CAAA;AACF,QAAA,OAAO,MAAM,IAAK,EAAA;AAAA,OACpB;AAAA,MACA,UAAA,EAAY,OAAO,MAAA,EAAQ,IAAS,KAAA;AAClC,QAAA,MAAM,OAAO,MAAO,CAAA;AAAA,UAClB,QAAA,EAAU,IAAI,qBAAqB,CAAA;AAAA,UACnC,SAAW,EAAA;AAAA,YACT,SAAW,EAAA,MAAA;AAAA,YACX,YAAc,EAAA;AAAA,cACZ,OAAS,EAAA;AAAA;AACX;AACF,SACD,CAAA;AAAA;AACH,KACD,CAAA;AAAA,GACH,EAAG,CAAC,MAAM,CAAC,CAAA;AACb"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const DEFAULT_GAME_ORIENTATION = "landscape";
|
|
2
|
+
const ORIENTATION_KEY = "yantra-games:cubeforge3d-orientation";
|
|
3
|
+
class GamePreferences {
|
|
4
|
+
constructor(storage) {
|
|
5
|
+
this.storage = storage;
|
|
6
|
+
}
|
|
7
|
+
async orientation() {
|
|
8
|
+
return await this.storage.getItem(ORIENTATION_KEY) === "portrait" ? "portrait" : DEFAULT_GAME_ORIENTATION;
|
|
9
|
+
}
|
|
10
|
+
async setOrientation(orientation) {
|
|
11
|
+
await this.storage.setItem(ORIENTATION_KEY, orientation);
|
|
12
|
+
}
|
|
13
|
+
}export{DEFAULT_GAME_ORIENTATION,GamePreferences};//# sourceMappingURL=gamePreferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gamePreferences.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/gamePreferences.ts"],"sourcesContent":["/** The player's own choices for Cubeforge, kept on this device. */\nimport type { KeyValueStorage } from '../storage/storage';\n\n/** How the phone is held in a world. Sideways shows more of it; upright is easier one-handed. */\nexport type GameOrientation = 'landscape' | 'portrait';\n\nexport const DEFAULT_GAME_ORIENTATION: GameOrientation = 'landscape';\n\nconst ORIENTATION_KEY = 'yantra-games:cubeforge3d-orientation';\n\nexport class GamePreferences {\n constructor(private readonly storage: KeyValueStorage) {}\n\n async orientation(): Promise<GameOrientation> {\n return (await this.storage.getItem(ORIENTATION_KEY)) === 'portrait' ? 'portrait' : DEFAULT_GAME_ORIENTATION;\n }\n\n async setOrientation(orientation: GameOrientation): Promise<void> {\n await this.storage.setItem(ORIENTATION_KEY, orientation);\n }\n}\n"],"names":[],"mappings":"AAKO,MAAM,wBAA4C,GAAA;AACzD,MAAM,eAAkB,GAAA,sCAAA;AACjB,MAAM,eAAgB,CAAA;AAAA,EAC3B,YAA6B,OAA0B,EAAA;AAA1B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAA2B,EACxD,MAAM,WAAwC,GAAA;AAC5C,IAAA,OAAQ,MAAM,IAAK,CAAA,OAAA,CAAQ,QAAQ,eAAe,CAAA,KAAO,aAAa,UAAa,GAAA,wBAAA;AAAA;AACrF,EACA,MAAM,eAAe,WAA6C,EAAA;AAChE,IAAA,MAAM,IAAK,CAAA,OAAA,CAAQ,OAAQ,CAAA,eAAA,EAAiB,WAAW,CAAA;AAAA;AAE3D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const HOW_TO_KEY = "yantra-games:cubeforge3d-how-to-seen";
|
|
2
|
+
const INVITES_KEY = "yantra-games:cubeforge3d-invites-seen";
|
|
3
|
+
const MAX_REMEMBERED_INVITES = 50;
|
|
4
|
+
class OpeningMemory {
|
|
5
|
+
constructor(storage) {
|
|
6
|
+
this.storage = storage;
|
|
7
|
+
}
|
|
8
|
+
async hasSeenHowTo() {
|
|
9
|
+
return await this.storage.getItem(HOW_TO_KEY) === "1";
|
|
10
|
+
}
|
|
11
|
+
async markHowToSeen() {
|
|
12
|
+
await this.storage.setItem(HOW_TO_KEY, "1");
|
|
13
|
+
}
|
|
14
|
+
async seenInvites() {
|
|
15
|
+
return new Set(await this.readInvites());
|
|
16
|
+
}
|
|
17
|
+
/** Remembers these codes, so an invite only interrupts opening the game once. */
|
|
18
|
+
async markInvitesSeen(codes) {
|
|
19
|
+
const merged = [.../* @__PURE__ */ new Set([...codes, ...await this.readInvites()])].slice(0, MAX_REMEMBERED_INVITES);
|
|
20
|
+
await this.storage.setItem(INVITES_KEY, JSON.stringify(merged));
|
|
21
|
+
}
|
|
22
|
+
async readInvites() {
|
|
23
|
+
var _a;
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse((_a = await this.storage.getItem(INVITES_KEY)) != null ? _a : "[]");
|
|
26
|
+
return Array.isArray(parsed) ? parsed.filter((code) => typeof code === "string") : [];
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}export{OpeningMemory};//# sourceMappingURL=openingMemory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openingMemory.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/openingMemory.ts"],"sourcesContent":["/** What a player has already been shown when opening Cubeforge, kept on this device. */\nimport type { KeyValueStorage } from '../storage/storage';\n\nconst HOW_TO_KEY = 'yantra-games:cubeforge3d-how-to-seen';\nconst INVITES_KEY = 'yantra-games:cubeforge3d-invites-seen';\nconst MAX_REMEMBERED_INVITES = 50;\n\nexport class OpeningMemory {\n constructor(private readonly storage: KeyValueStorage) {}\n\n async hasSeenHowTo(): Promise<boolean> {\n return (await this.storage.getItem(HOW_TO_KEY)) === '1';\n }\n\n async markHowToSeen(): Promise<void> {\n await this.storage.setItem(HOW_TO_KEY, '1');\n }\n\n async seenInvites(): Promise<Set<string>> {\n return new Set(await this.readInvites());\n }\n\n /** Remembers these codes, so an invite only interrupts opening the game once. */\n async markInvitesSeen(codes: readonly string[]): Promise<void> {\n const merged = [...new Set([...codes, ...(await this.readInvites())])].slice(0, MAX_REMEMBERED_INVITES);\n await this.storage.setItem(INVITES_KEY, JSON.stringify(merged));\n }\n\n private async readInvites(): Promise<string[]> {\n try {\n const parsed: unknown = JSON.parse((await this.storage.getItem(INVITES_KEY)) ?? '[]');\n return Array.isArray(parsed) ? parsed.filter((code): code is string => typeof code === 'string') : [];\n } catch {\n return [];\n }\n }\n}\n"],"names":[],"mappings":"AAEA,MAAM,UAAa,GAAA,sCAAA;AACnB,MAAM,WAAc,GAAA,uCAAA;AACpB,MAAM,sBAAyB,GAAA,EAAA;AACxB,MAAM,aAAc,CAAA;AAAA,EACzB,YAA6B,OAA0B,EAAA;AAA1B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAA2B,EACxD,MAAM,YAAiC,GAAA;AACrC,IAAA,OAAQ,MAAM,IAAA,CAAK,OAAQ,CAAA,OAAA,CAAQ,UAAU,CAAO,KAAA,GAAA;AAAA;AACtD,EACA,MAAM,aAA+B,GAAA;AACnC,IAAA,MAAM,IAAK,CAAA,OAAA,CAAQ,OAAQ,CAAA,UAAA,EAAY,GAAG,CAAA;AAAA;AAC5C,EACA,MAAM,WAAoC,GAAA;AACxC,IAAA,OAAO,IAAI,GAAA,CAAI,MAAM,IAAA,CAAK,aAAa,CAAA;AAAA;AACzC;AAAA,EAGA,MAAM,gBAAgB,KAAyC,EAAA;AAC7D,IAAA,MAAM,SAAS,CAAC,uBAAO,GAAI,CAAA,CAAC,GAAG,KAAO,EAAA,GAAI,MAAM,IAAA,CAAK,aAAc,CAAC,CAAC,CAAE,CAAA,KAAA,CAAM,GAAG,sBAAsB,CAAA;AACtG,IAAA,MAAM,KAAK,OAAQ,CAAA,OAAA,CAAQ,aAAa,IAAK,CAAA,SAAA,CAAU,MAAM,CAAC,CAAA;AAAA;AAChE,EACA,MAAc,WAAiC,GAAA;AAtBjD,IAAA,IAAA,EAAA;AAuBI,IAAI,IAAA;AACF,MAAM,MAAA,MAAA,GAAkB,IAAK,CAAA,KAAA,CAAA,CAAO,EAAM,GAAA,MAAA,IAAA,CAAK,QAAQ,OAAQ,CAAA,WAAW,CAAtC,KAAA,IAAA,GAAA,EAAA,GAA4C,IAAI,CAAA;AACpF,MAAA,OAAO,KAAM,CAAA,OAAA,CAAQ,MAAM,CAAA,GAAI,MAAO,CAAA,MAAA,CAAO,CAAC,IAAA,KAAyB,OAAO,IAAA,KAAS,QAAQ,CAAA,GAAI,EAAC;AAAA,KAC9F,CAAA,OAAA,CAAA,EAAA;AACN,MAAA,OAAO,EAAC;AAAA;AACV;AAEJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const CODE = /^[2-9A-HJKMNP-Z]{8,}$/;
|
|
1
|
+
import {hasDefaultName}from'./helper.js';const CODE = /^[2-9A-HJKMNP-Z]{8,}$/;
|
|
2
2
|
function parseInviteCode(input) {
|
|
3
3
|
var _a;
|
|
4
4
|
const last = (_a = input.trim().split(/[/?#=]/).filter(Boolean).pop()) != null ? _a : "";
|
|
@@ -7,4 +7,68 @@ function parseInviteCode(input) {
|
|
|
7
7
|
}
|
|
8
8
|
function sharedWorldKey(worldId) {
|
|
9
9
|
return `room-${worldId.toLowerCase().replace(/[^a-z0-9_-]+/g, "-")}`;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
|
+
const DEFAULT_SHARED_WORLD_NAME = "Our world";
|
|
12
|
+
const DAY_MS = 24 * 60 * 60 * 1e3;
|
|
13
|
+
const INVITE_LIFETIME_MS = 3 * DAY_MS;
|
|
14
|
+
const MAX_WAITING_INVITES = 3;
|
|
15
|
+
function waitingInvites(invites, worlds, now) {
|
|
16
|
+
const joined = new Set(worlds.map((world) => world.inviteCode));
|
|
17
|
+
const counted = /* @__PURE__ */ new Set();
|
|
18
|
+
const waiting = [];
|
|
19
|
+
for (const invite of [...invites].sort((a, b) => b.sentAt - a.sentAt)) {
|
|
20
|
+
if (invite.from === null || counted.has(invite.from)) continue;
|
|
21
|
+
counted.add(invite.from);
|
|
22
|
+
if (!joined.has(invite.code) && now - invite.sentAt <= INVITE_LIFETIME_MS) waiting.push(invite);
|
|
23
|
+
}
|
|
24
|
+
return waiting.slice(0, MAX_WAITING_INVITES);
|
|
25
|
+
}
|
|
26
|
+
function joinNames(names) {
|
|
27
|
+
if (names.length <= 2) return names.join(" and ");
|
|
28
|
+
return `${names[0]} and ${names.length - 1} others`;
|
|
29
|
+
}
|
|
30
|
+
function describeSharedWorld(world, invites) {
|
|
31
|
+
var _a;
|
|
32
|
+
const players = `${world.memberCount} player${world.memberCount === 1 ? "" : "s"}`;
|
|
33
|
+
const about = invites.filter((invite) => invite.code === world.inviteCode);
|
|
34
|
+
const unnamed = hasDefaultName(world.name);
|
|
35
|
+
if (!world.ownedByMe) {
|
|
36
|
+
const from = (_a = about.find((invite) => invite.from !== null)) == null ? void 0 : _a.from;
|
|
37
|
+
if (!from) return {
|
|
38
|
+
title: world.name,
|
|
39
|
+
detail: `Shared with you, ${players}`
|
|
40
|
+
};
|
|
41
|
+
return unnamed ? {
|
|
42
|
+
title: `${from}'s world`,
|
|
43
|
+
detail: `Invited you, ${players}`
|
|
44
|
+
} : {
|
|
45
|
+
title: world.name,
|
|
46
|
+
detail: `Invited by ${from}, ${players}`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const sentTo = [...new Set(about.filter((invite) => invite.from === null).map((invite) => invite.chatTitle))];
|
|
50
|
+
if (sentTo.length === 0) return {
|
|
51
|
+
title: world.name,
|
|
52
|
+
detail: `Started by you, ${players}`
|
|
53
|
+
};
|
|
54
|
+
const people = joinNames(sentTo);
|
|
55
|
+
if (!unnamed) return {
|
|
56
|
+
title: world.name,
|
|
57
|
+
detail: `You invited ${people}, ${players}`
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
title: `World with ${people}`,
|
|
61
|
+
detail: world.memberCount === 1 ? "Nobody has joined yet" : players
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function sortSharedWorlds(worlds) {
|
|
65
|
+
const isEmpty = (world) => world.ownedByMe && world.memberCount <= 1;
|
|
66
|
+
return {
|
|
67
|
+
withFriends: worlds.filter((world) => !isEmpty(world)),
|
|
68
|
+
justMine: worlds.filter(isEmpty)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function reusableSharedWorld(worlds) {
|
|
72
|
+
var _a;
|
|
73
|
+
return (_a = worlds.find((world) => world.ownedByMe && world.memberCount <= 1 && hasDefaultName(world.name) && Boolean(world.inviteCode))) != null ? _a : null;
|
|
74
|
+
}export{DEFAULT_SHARED_WORLD_NAME,describeSharedWorld,parseInviteCode,reusableSharedWorld,sharedWorldKey,sortSharedWorlds,waitingInvites};//# sourceMappingURL=sharedWorlds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedWorlds.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/sharedWorlds.ts"],"sourcesContent":["/**\n * Playing Cubeforge 3D with friends. The host app implements `CubeforgeFriends`\n * over its own backend and chat, so this package stays free of both.\n */\n\nexport interface SharedWorld {\n id: string;\n name: string;\n /** World seed; the server is the authority once connected. */\n seed: number;\n memberCount: number;\n inviteCode: string | null;\n ownedByMe: boolean;\n}\n\n/** A chat group or person who can receive an invite. */\nexport interface InviteChat {\n id: string;\n title: string;\n detail: string;\n}\n\n/** What the engine needs to enter a shared world. */\nexport interface RoomAccess {\n /** `wss://host/rooms/<worldId>`. */\n url: string;\n token: string;\n playerName: string;\n}\n\nexport interface CubeforgeFriends {\n listWorlds(): Promise<SharedWorld[]>;\n createWorld(name: string, chatId: string): Promise<SharedWorld>;\n joinWorld(inviteCode: string): Promise<SharedWorld>;\n leaveWorld(world: SharedWorld): Promise<void>;\n deleteWorld(world: SharedWorld): Promise<void>;\n /** Hosts that predate world names leave this out. */\n renameWorld?(world: SharedWorld, name: string): Promise<void>;\n listChats(): Promise<InviteChat[]>;\n /** Post a join card for `world` into the chat. */\n inviteToChat(world: SharedWorld, chatId: string): Promise<void>;\n /** `renewToken` asks for new credentials after the old token expired. */\n roomAccess(world: SharedWorld, options?: { renewToken?: boolean }): Promise<RoomAccess>;\n}\n\nconst CODE = /^[2-9A-HJKMNP-Z]{8,}$/;\n\n/**\n * The invite code in what someone typed or pasted: a bare code in any case, or\n * a link ending in one. Returns null when there is no valid code.\n */\nexport function parseInviteCode(input: string): string | null {\n const last =\n input\n .trim()\n .split(/[/?#=]/)\n .filter(Boolean)\n .pop() ?? '';\n const code = last.replace(/[\\s-]/g, '').toUpperCase();\n return CODE.test(code) ? code : null;\n}\n\n/** The save file name for a shared world on this device. */\nexport function sharedWorldKey(worldId: string): string {\n return `room-${worldId.toLowerCase().replace(/[^a-z0-9_-]+/g, '-')}`;\n}\n"],"names":[],"mappings":"AA6CA,MAAM,IAAO,GAAA,uBAAA;AAMN,SAAS,gBAAgB,KAA8B,EAAA;AAnD9D,EAAA,IAAA,EAAA;AAoDE,EAAA,MAAM,IAAO,GAAA,CAAA,EAAA,GAAA,KAAA,CAAM,IAAK,EAAA,CAAE,KAAM,CAAA,QAAQ,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA,CAAE,GAAI,EAAA,KAAjD,IAAsD,GAAA,EAAA,GAAA,EAAA;AACnE,EAAA,MAAM,OAAO,IAAK,CAAA,OAAA,CAAQ,QAAU,EAAA,EAAE,EAAE,WAAY,EAAA;AACpD,EAAA,OAAO,IAAK,CAAA,IAAA,CAAK,IAAI,CAAA,GAAI,IAAO,GAAA,IAAA;AAClC;AAGO,SAAS,eAAe,OAAyB,EAAA;AACtD,EAAA,OAAO,QAAQ,OAAQ,CAAA,WAAA,GAAc,OAAQ,CAAA,eAAA,EAAiB,GAAG,CAAC,CAAA,CAAA;AACpE"}
|
|
1
|
+
{"version":3,"file":"sharedWorlds.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/sharedWorlds.ts"],"sourcesContent":["/**\n * Playing Cubeforge 3D with friends. The host app implements `CubeforgeFriends`\n * over its own backend and chat, so this package stays free of both.\n */\nimport { hasDefaultName } from './helper';\n\nexport interface SharedWorld {\n id: string;\n name: string;\n /** World seed; the server is the authority once connected. */\n seed: number;\n memberCount: number;\n inviteCode: string | null;\n ownedByMe: boolean;\n}\n\n/** A chat group or person who can receive an invite. */\nexport interface InviteChat {\n id: string;\n title: string;\n detail: string;\n}\n\n/** A Cubeforge invite found in one of this player's chats. */\nexport interface WorldInvite {\n code: string;\n worldName: string;\n /** Who sent it, or null when this player did. */\n from: string | null;\n /** The person or group it was sent to, as the chat is titled. */\n chatTitle: string;\n /** Epoch milliseconds. */\n sentAt: number;\n}\n\n/** This phone's notifications, so a friend's invite arrives while the game is closed. */\nexport interface GameNotifications {\n status: 'granted' | 'denied' | 'undetermined' | 'unsupported';\n /** Asks the phone. Resolves once it has answered. */\n enable(): Promise<unknown>;\n /** After a refusal the phone will not ask again, so this opens Settings instead. */\n openSettings?(): Promise<void>;\n}\n\n/** What the engine needs to enter a shared world. */\nexport interface RoomAccess {\n /** `wss://host/rooms/<worldId>`. */\n url: string;\n token: string;\n playerName: string;\n}\n\nexport interface CubeforgeFriends {\n listWorlds(): Promise<SharedWorld[]>;\n createWorld(name: string, chatId: string): Promise<SharedWorld>;\n joinWorld(inviteCode: string): Promise<SharedWorld>;\n leaveWorld(world: SharedWorld): Promise<void>;\n deleteWorld(world: SharedWorld): Promise<void>;\n /** Hosts that predate world names leave this out. */\n renameWorld?(world: SharedWorld, name: string): Promise<void>;\n listChats(): Promise<InviteChat[]>;\n /** Invites in the player's recent chats. Hosts without chat leave this out. */\n listInvites?(): Promise<WorldInvite[]>;\n /** Post a join card for `world` into the chat. */\n inviteToChat(world: SharedWorld, chatId: string): Promise<void>;\n /** `renewToken` asks for new credentials after the old token expired. */\n roomAccess(world: SharedWorld, options?: { renewToken?: boolean }): Promise<RoomAccess>;\n}\n\nconst CODE = /^[2-9A-HJKMNP-Z]{8,}$/;\n\n/**\n * The invite code in what someone typed or pasted: a bare code in any case, or\n * a link ending in one. Returns null when there is no valid code.\n */\nexport function parseInviteCode(input: string): string | null {\n const last =\n input\n .trim()\n .split(/[/?#=]/)\n .filter(Boolean)\n .pop() ?? '';\n const code = last.replace(/[\\s-]/g, '').toUpperCase();\n return CODE.test(code) ? code : null;\n}\n\n/** The save file name for a shared world on this device. */\nexport function sharedWorldKey(worldId: string): string {\n return `room-${worldId.toLowerCase().replace(/[^a-z0-9_-]+/g, '-')}`;\n}\n\n/** What a world is called when the player does not name it. */\nexport const DEFAULT_SHARED_WORLD_NAME = 'Our world';\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst INVITE_LIFETIME_MS = 3 * DAY_MS;\nconst MAX_WAITING_INVITES = 3;\n\n/**\n * Invites this player has not acted on. Only the newest from each person counts:\n * someone who tries again usually means a new world, and the older invite would\n * lead somewhere they have already left.\n */\nexport function waitingInvites(\n invites: readonly WorldInvite[],\n worlds: readonly SharedWorld[],\n now: number,\n): WorldInvite[] {\n const joined = new Set(worlds.map((world) => world.inviteCode));\n const counted = new Set<string>();\n const waiting: WorldInvite[] = [];\n for (const invite of [...invites].sort((a, b) => b.sentAt - a.sentAt)) {\n if (invite.from === null || counted.has(invite.from)) continue;\n counted.add(invite.from);\n if (!joined.has(invite.code) && now - invite.sentAt <= INVITE_LIFETIME_MS) waiting.push(invite);\n }\n return waiting.slice(0, MAX_WAITING_INVITES);\n}\n\nfunction joinNames(names: readonly string[]): string {\n if (names.length <= 2) return names.join(' and ');\n return `${names[0]} and ${names.length - 1} others`;\n}\n\n/**\n * How to show a world in a list where most are called \"Our world\": by the people\n * it is with. A name someone actually chose stays as the title.\n */\nexport function describeSharedWorld(\n world: SharedWorld,\n invites: readonly WorldInvite[],\n): { title: string; detail: string } {\n const players = `${world.memberCount} player${world.memberCount === 1 ? '' : 's'}`;\n const about = invites.filter((invite) => invite.code === world.inviteCode);\n const unnamed = hasDefaultName(world.name);\n if (!world.ownedByMe) {\n const from = about.find((invite) => invite.from !== null)?.from;\n if (!from) return { title: world.name, detail: `Shared with you, ${players}` };\n return unnamed\n ? { title: `${from}'s world`, detail: `Invited you, ${players}` }\n : { title: world.name, detail: `Invited by ${from}, ${players}` };\n }\n const sentTo = [...new Set(about.filter((invite) => invite.from === null).map((invite) => invite.chatTitle))];\n if (sentTo.length === 0) return { title: world.name, detail: `Started by you, ${players}` };\n const people = joinNames(sentTo);\n if (!unnamed) return { title: world.name, detail: `You invited ${people}, ${players}` };\n return { title: `World with ${people}`, detail: world.memberCount === 1 ? 'Nobody has joined yet' : players };\n}\n\n/** Worlds with other people in them come first; the player's empty ones can wait. */\nexport function sortSharedWorlds(worlds: readonly SharedWorld[]): {\n withFriends: SharedWorld[];\n justMine: SharedWorld[];\n} {\n const isEmpty = (world: SharedWorld) => world.ownedByMe && world.memberCount <= 1;\n return { withFriends: worlds.filter((world) => !isEmpty(world)), justMine: worlds.filter(isEmpty) };\n}\n\n/**\n * A world to invite people to instead of starting another: one this player\n * started, nobody has joined and nobody has named.\n */\nexport function reusableSharedWorld(worlds: readonly SharedWorld[]): SharedWorld | null {\n return (\n worlds.find(\n (world) =>\n world.ownedByMe && world.memberCount <= 1 && hasDefaultName(world.name) && Boolean(world.inviteCode),\n ) ?? null\n );\n}\n"],"names":[],"mappings":"yCAoEA,MAAM,IAAO,GAAA,uBAAA;AAMN,SAAS,gBAAgB,KAA8B,EAAA;AA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;AAAA,GACjC;AACF;AAMO,SAAS,oBAAoB,MAAoD,EAAA;AAzKxF,EAAA,IAAA,EAAA;AA0KE,EAAA,OAAA,CAAO,YAAO,IAAK,CAAA,CAAA,KAAA,KAAS,KAAM,CAAA,SAAA,IAAa,MAAM,WAAe,IAAA,CAAA,IAAK,cAAe,CAAA,KAAA,CAAM,IAAI,CAAK,IAAA,OAAA,CAAQ,MAAM,UAAU,CAAC,MAAzH,IAA8H,GAAA,EAAA,GAAA,IAAA;AACvI"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsxs,jsx}from'react/jsx-runtime';import {useMemo,useState,useEffect,useCallback}from'react';import {useColorScheme,View,StyleSheet,Text}from'react-native';import'../core/engine/palette.js';import'../core/lessons/lessons.js';import'../core/cubeforge/items.js';import'../core/cubeforge/recipes.js';import {seedFromString}from'../core/cubeforge/worldgen.js';import {worthNaming,hasDefaultName}from'../core/cubeforge/helper.js';import {nativeWorldKey}from'../core/cubeforge/nativeWorld.js';import {NativeWorldRepository}from'../core/cubeforge/nativeWorlds.js';import {SkinRepository,skinToHex}from'../core/cubeforge/skin.js';import {sharedWorldKey,parseInviteCode}from'../core/cubeforge/sharedWorlds.js';import {Cubeforge3DHomeScreen}from'./screens/Cubeforge3DHomeScreen.js';import {ScreenHeader}from'./screens/ScreenHeader.js';import {SkinEditorScreen}from'./screens/SkinEditorScreen.js';import {createAsyncStorageAdapter}from'./storage/asyncStorageAdapter.js';import {getTheme,spacing}from'./theme.js';var __defProp = Object.defineProperty;
|
|
1
|
+
import {jsxs,jsx}from'react/jsx-runtime';import {useMemo,useState,useEffect,useCallback}from'react';import {useColorScheme,View,StyleSheet,Text,ActivityIndicator}from'react-native';import'../core/engine/palette.js';import'../core/lessons/lessons.js';import'../core/cubeforge/items.js';import'../core/cubeforge/recipes.js';import {seedFromString}from'../core/cubeforge/worldgen.js';import {worthNaming,hasDefaultName}from'../core/cubeforge/helper.js';import {nativeWorldKey}from'../core/cubeforge/nativeWorld.js';import {NativeWorldRepository}from'../core/cubeforge/nativeWorlds.js';import {SkinRepository,skinToHex}from'../core/cubeforge/skin.js';import {sharedWorldKey,parseInviteCode,waitingInvites}from'../core/cubeforge/sharedWorlds.js';import {OpeningMemory}from'../core/cubeforge/openingMemory.js';import {GamePreferences,DEFAULT_GAME_ORIENTATION}from'../core/cubeforge/gamePreferences.js';import {Cubeforge3DHomeScreen}from'./screens/Cubeforge3DHomeScreen.js';import {HowToPlayScreen}from'./screens/HowToPlayScreen.js';import {ScreenHeader}from'./screens/ScreenHeader.js';import {SkinEditorScreen}from'./screens/SkinEditorScreen.js';import {createAsyncStorageAdapter}from'./storage/asyncStorageAdapter.js';import {getTheme,spacing}from'./theme.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -17,6 +17,12 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const OPENING_WAIT_MS = 2500;
|
|
21
|
+
function soonOr(work, fallback, waitMs) {
|
|
22
|
+
return Promise.race([work, new Promise((resolve) => {
|
|
23
|
+
setTimeout(() => resolve(fallback), waitMs);
|
|
24
|
+
})]);
|
|
25
|
+
}
|
|
20
26
|
function YantraGames(props) {
|
|
21
27
|
var _a;
|
|
22
28
|
const {
|
|
@@ -29,7 +35,8 @@ function YantraGames(props) {
|
|
|
29
35
|
onCubeforgeInviteHandled,
|
|
30
36
|
deleteCubeforge3DSave,
|
|
31
37
|
cubeforgeHelper: helper,
|
|
32
|
-
cubeforge3DPicture
|
|
38
|
+
cubeforge3DPicture,
|
|
39
|
+
notifications
|
|
33
40
|
} = props;
|
|
34
41
|
const systemScheme = useColorScheme();
|
|
35
42
|
const theme = getTheme((_a = props.theme) != null ? _a : systemScheme === "dark" ? "dark" : "light");
|
|
@@ -50,10 +57,62 @@ function YantraGames(props) {
|
|
|
50
57
|
const [screen, setScreen] = useState(() => cubeforgeInvite ? {
|
|
51
58
|
name: "worlds"
|
|
52
59
|
} : {
|
|
53
|
-
name: "
|
|
54
|
-
seed: seedFromString(orgName || "default"),
|
|
55
|
-
worldKey: nativeWorldKey(orgName)
|
|
60
|
+
name: "opening"
|
|
56
61
|
});
|
|
62
|
+
const memory = useMemo(() => new OpeningMemory(storage), [storage]);
|
|
63
|
+
const preferences = useMemo(() => new GamePreferences(storage), [storage]);
|
|
64
|
+
const [orientation, setOrientation] = useState(DEFAULT_GAME_ORIENTATION);
|
|
65
|
+
const opening = screen.name === "opening";
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
let live = true;
|
|
68
|
+
preferences.orientation().then((saved) => {
|
|
69
|
+
if (live) setOrientation(saved);
|
|
70
|
+
}).catch(() => void 0);
|
|
71
|
+
return () => {
|
|
72
|
+
live = false;
|
|
73
|
+
};
|
|
74
|
+
}, [preferences]);
|
|
75
|
+
const chooseOrientation = useCallback((next) => {
|
|
76
|
+
setOrientation(next);
|
|
77
|
+
preferences.setOrientation(next).catch(() => void 0);
|
|
78
|
+
}, [preferences]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!opening) return void 0;
|
|
81
|
+
let live = true;
|
|
82
|
+
const newInvites = async () => {
|
|
83
|
+
if (!(friends == null ? void 0 : friends.listInvites)) return [];
|
|
84
|
+
const [shared, invites, seen] = await Promise.all([friends.listWorlds(), friends.listInvites(), memory.seenInvites()]);
|
|
85
|
+
return waitingInvites(invites, shared, Date.now()).filter((invite) => !seen.has(invite.code));
|
|
86
|
+
};
|
|
87
|
+
Promise.all([
|
|
88
|
+
memory.hasSeenHowTo().catch(() => true),
|
|
89
|
+
// Read before the game starts, so a world never opens sideways and then turns.
|
|
90
|
+
preferences.orientation().then((saved) => {
|
|
91
|
+
if (live) setOrientation(saved);
|
|
92
|
+
}).catch(() => void 0),
|
|
93
|
+
soonOr(newInvites().catch(() => []), [], OPENING_WAIT_MS)
|
|
94
|
+
]).then(([seenHowTo, , invites]) => {
|
|
95
|
+
if (!live) return;
|
|
96
|
+
if (invites.length > 0) memory.markInvitesSeen(invites.map((invite) => invite.code)).catch(() => void 0);
|
|
97
|
+
const next = invites.length > 0 ? {
|
|
98
|
+
name: "worlds"
|
|
99
|
+
} : {
|
|
100
|
+
name: "game",
|
|
101
|
+
seed: seedFromString(orgName || "default"),
|
|
102
|
+
worldKey: nativeWorldKey(orgName)
|
|
103
|
+
};
|
|
104
|
+
setScreen((current) => {
|
|
105
|
+
if (current.name !== "opening") return current;
|
|
106
|
+
return seenHowTo ? next : {
|
|
107
|
+
name: "howto",
|
|
108
|
+
after: next
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
}).catch(() => void 0);
|
|
112
|
+
return () => {
|
|
113
|
+
live = false;
|
|
114
|
+
};
|
|
115
|
+
}, [opening, friends, memory, preferences, orgName]);
|
|
57
116
|
const playSolo = useCallback((world) => {
|
|
58
117
|
setScreen({
|
|
59
118
|
name: "game",
|
|
@@ -135,10 +194,29 @@ function YantraGames(props) {
|
|
|
135
194
|
] })
|
|
136
195
|
] });
|
|
137
196
|
}
|
|
197
|
+
if (screen.name === "opening") {
|
|
198
|
+
return /* @__PURE__ */ jsx(View, { style: [styles.fill, styles.message, {
|
|
199
|
+
backgroundColor: theme.bg
|
|
200
|
+
}], children: /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.primary }) });
|
|
201
|
+
}
|
|
202
|
+
if (screen.name === "howto") {
|
|
203
|
+
const {
|
|
204
|
+
after
|
|
205
|
+
} = screen;
|
|
206
|
+
return /* @__PURE__ */ jsx(HowToPlayScreen, { theme, onDone: () => {
|
|
207
|
+
memory.markHowToSeen().catch(() => void 0);
|
|
208
|
+
setScreen(after);
|
|
209
|
+
} });
|
|
210
|
+
}
|
|
138
211
|
if (screen.name === "worlds") {
|
|
139
212
|
return /* @__PURE__ */ jsx(Cubeforge3DHomeScreen, { theme, worlds, friends, onBack: () => onExit == null ? void 0 : onExit(), onPlaySolo: playSolo, onPlayShared: playShared, onDeleteSave: deleteCubeforge3DSave, onEditAvatar: () => setScreen({
|
|
140
213
|
name: "avatar"
|
|
141
|
-
}),
|
|
214
|
+
}), onHowToPlay: () => setScreen({
|
|
215
|
+
name: "howto",
|
|
216
|
+
after: {
|
|
217
|
+
name: "worlds"
|
|
218
|
+
}
|
|
219
|
+
}), notifications, orientation, onOrientationChange: Cubeforge3D ? chooseOrientation : void 0, pictureOf: cubeforge3DPicture, revision: worldsRevision });
|
|
142
220
|
}
|
|
143
221
|
if (screen.name === "avatar") {
|
|
144
222
|
return /* @__PURE__ */ jsx(SkinEditorScreen, { theme, initial: skin, onBack: () => setScreen({
|
|
@@ -160,7 +238,7 @@ function YantraGames(props) {
|
|
|
160
238
|
};
|
|
161
239
|
return /* @__PURE__ */ jsx(Cubeforge3D, { seed: screen.seed, worldKey: screen.worldKey, room: screen.room, skin: skin ? skinToHex(skin) : void 0, onExit: leaveWorld, helper: screen.shared && !screen.shared.ownedByMe ? void 0 : helper, onRoomClosed: () => setScreen({
|
|
162
240
|
name: "worlds"
|
|
163
|
-
}), onTokenExpired: refreshRoom });
|
|
241
|
+
}), onTokenExpired: refreshRoom, orientation });
|
|
164
242
|
}
|
|
165
243
|
const styles = StyleSheet.create({
|
|
166
244
|
fill: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GamesRoot.js","sources":["../../../../../src/features/games/vendored/ui/GamesRoot.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { StyleSheet, Text, useColorScheme, View } from 'react-native';\nimport {\n NativeWorldRepository,\n SkinRepository,\n nativeWorldKey,\n parseInviteCode,\n seedFromString,\n sharedWorldKey,\n skinToHex,\n type CubeforgeFriends,\n type KeyValueStorage,\n type NativeWorld,\n type RoomAccess,\n type SharedWorld,\n hasDefaultName,\n worthNaming,\n type CubeforgeHelper,\n} from '../core';\nimport { Cubeforge3DHomeScreen } from './screens/Cubeforge3DHomeScreen';\nimport { ScreenHeader } from './screens/ScreenHeader';\nimport { SkinEditorScreen } from './screens/SkinEditorScreen';\nimport { createAsyncStorageAdapter } from './storage/asyncStorageAdapter';\nimport { getTheme, spacing, type ThemeMode } from './theme';\n\nexport interface YantraGamesProps {\n /** Organisation the signed-in user is in; each org has its own world. */\n orgName: string;\n /** Called when the user leaves the game (back out to the app). */\n onExit?: () => void;\n /** Force a theme; defaults to the system colour scheme. */\n theme?: ThemeMode;\n /** Override persistence; defaults to AsyncStorage. */\n storage?: KeyValueStorage;\n /**\n * The native first-person Cubeforge (the Rust engine in `native/cubeforge`).\n * It is the game: without one on this device there is nothing to play, and\n * the player is told so.\n */\n cubeforge3D?: React.ComponentType<Cubeforge3DProps>;\n /** Shared worlds and chat invites, when the host offers them. */\n cubeforgeFriends?: CubeforgeFriends;\n /** An invite to accept right away, for example from a tapped chat card. */\n cubeforgeInvite?: string;\n /** Called once `cubeforgeInvite` has been accepted or refused. */\n onCubeforgeInviteHandled?: (error: string | null) => void;\n /** Removes a 3D world's save from this device. */\n deleteCubeforge3DSave?: (worldKey: string) => void;\n /** The AI build helper, when the host can reach one. */\n cubeforgeHelper?: CubeforgeHelper;\n /** Address of a world's saved picture, or null when it has none. */\n cubeforge3DPicture?: (worldKey: string) => string | null;\n}\n\n/** Props the host's native Cubeforge 3D component receives. */\nexport interface Cubeforge3DProps {\n /** Seed for a new world, stable per org. */\n seed: number;\n /** Stable key for the world's save (the org), safe as a file name part. */\n worldKey: string;\n /** Leave the game. `summary` describes the world, when the engine can. */\n onExit: (summary?: string) => void;\n /** The build helper, when this player may change this world. */\n helper?: CubeforgeHelper;\n /** Connect to this shared world; omitted when playing alone. */\n room?: RoomAccess;\n /** The server refused the player for good (removed, deleted, joined elsewhere). */\n onRoomClosed?: () => void;\n /** The token expired; the next `room` carries a fresh one. */\n onTokenExpired?: () => void;\n /** This person's painted avatar as 256 hex digits, when they have one. */\n skin?: string;\n}\n\ntype Screen =\n | { name: 'worlds' }\n | { name: 'avatar' }\n | { name: 'game'; seed: number; worldKey: string; shared?: SharedWorld; room?: RoomAccess };\n\n/**\n * Yantra Games is Cubeforge in 3D: opening it opens the game. Where the host\n * offers friends, leaving a world goes to the list of worlds and Play with\n * friends; otherwise it leaves Games.\n */\nexport function YantraGames(props: YantraGamesProps): React.ReactElement {\n const {\n orgName,\n onExit,\n storage: storageProp,\n cubeforge3D: Cubeforge3D,\n cubeforgeFriends: friends,\n cubeforgeInvite,\n onCubeforgeInviteHandled,\n deleteCubeforge3DSave,\n cubeforgeHelper: helper,\n cubeforge3DPicture,\n } = props;\n const systemScheme = useColorScheme();\n const theme = getTheme(props.theme ?? (systemScheme === 'dark' ? 'dark' : 'light'));\n\n const storage = useMemo(() => storageProp ?? createAsyncStorageAdapter(), [storageProp]);\n const worlds = useMemo(() => new NativeWorldRepository(storage, orgName || 'default'), [storage, orgName]);\n const skins = useMemo(() => new SkinRepository(storage, orgName || 'default'), [storage, orgName]);\n const [skin, setSkin] = useState<number[] | null>(null);\n\n useEffect(() => {\n let live = true;\n skins\n .load()\n .then((cells) => {\n if (live) setSkin(cells);\n })\n .catch(() => undefined);\n return () => {\n live = false;\n };\n }, [skins]);\n\n // Bumped when the helper renames a world, so the list shows it.\n const [worldsRevision, setWorldsRevision] = useState(0);\n\n // An invite goes straight to its world, so it starts from the list, not a solo world.\n const [screen, setScreen] = useState<Screen>(() =>\n cubeforgeInvite\n ? { name: 'worlds' }\n : { name: 'game', seed: seedFromString(orgName || 'default'), worldKey: nativeWorldKey(orgName) },\n );\n\n const playSolo = useCallback((world: NativeWorld) => {\n setScreen({ name: 'game', seed: world.seed, worldKey: world.key });\n }, []);\n\n const playShared = useCallback(\n async (world: SharedWorld) => {\n if (!friends) return;\n const room = await friends.roomAccess(world);\n setScreen({ name: 'game', seed: world.seed, worldKey: sharedWorldKey(world.id), shared: world, room });\n },\n [friends],\n );\n\n // A world nobody has named gets one from what was built in it.\n const nameAfterPlaying = useCallback(\n async (played: Screen, summary: string) => {\n if (played.name !== 'game' || !helper || !worthNaming(summary)) return;\n const { shared, worldKey } = played;\n const current = shared?.name ?? (await worlds.list()).find((w) => w.key === worldKey)?.name;\n if (!current || !hasDefaultName(current)) return;\n if (shared && !(shared.ownedByMe && friends?.renameWorld)) return;\n const name = await helper.nameWorld(summary);\n if (!name) return;\n if (shared) await friends?.renameWorld?.(shared, name);\n else await worlds.rename(worldKey, name);\n setWorldsRevision((n) => n + 1);\n },\n [friends, helper, worlds],\n );\n\n // Fresh credentials for the world in play, after the old token expired.\n const refreshRoom = useCallback(() => {\n if (screen.name !== 'game' || !screen.shared || !friends) return;\n const { shared } = screen;\n friends\n .roomAccess(shared)\n .then((room) => setScreen((s) => (s.name === 'game' && s.shared?.id === shared.id ? { ...s, room } : s)))\n .catch(() => setScreen({ name: 'worlds' }));\n }, [friends, screen]);\n\n // Accept an invite handed in by the host (a tapped chat card).\n useEffect(() => {\n if (!cubeforgeInvite || !friends || !Cubeforge3D) return undefined;\n let live = true;\n const code = parseInviteCode(cubeforgeInvite);\n const accept = async () => {\n if (!code) throw new Error('That invite is not valid.');\n const world = await friends.joinWorld(code);\n if (live) await playShared(world);\n };\n accept()\n .then(() => {\n if (live) onCubeforgeInviteHandled?.(null);\n })\n .catch((e: unknown) => {\n if (live) onCubeforgeInviteHandled?.(e instanceof Error ? e.message : 'Could not join that world.');\n });\n return () => {\n live = false;\n };\n }, [cubeforgeInvite, friends, Cubeforge3D, playShared, onCubeforgeInviteHandled]);\n\n if (!Cubeforge3D) {\n return (\n <View style={[styles.fill, { backgroundColor: theme.bg }]}>\n <ScreenHeader theme={theme} title=\"Cubeforge\" onBack={onExit} backLabel=\"Close\" />\n <View style={styles.message}>\n <Text style={[styles.title, { color: theme.text }]}>Cubeforge is not on this device yet</Text>\n <Text style={[styles.body, { color: theme.textMuted }]}>\n It is a 3D game that needs the latest Yantra app on a 64-bit phone.\n </Text>\n </View>\n </View>\n );\n }\n\n if (screen.name === 'worlds') {\n return (\n <Cubeforge3DHomeScreen\n theme={theme}\n worlds={worlds}\n friends={friends}\n onBack={() => onExit?.()}\n onPlaySolo={playSolo}\n onPlayShared={playShared}\n onDeleteSave={deleteCubeforge3DSave}\n onEditAvatar={() => setScreen({ name: 'avatar' })}\n pictureOf={cubeforge3DPicture}\n revision={worldsRevision}\n />\n );\n }\n\n if (screen.name === 'avatar') {\n return (\n <SkinEditorScreen\n theme={theme}\n initial={skin}\n onBack={() => setScreen({ name: 'worlds' })}\n onSave={(cells) => {\n setSkin(cells);\n void skins.save(cells);\n setScreen({ name: 'worlds' });\n }}\n />\n );\n }\n\n const leaveWorld = (summary?: string) => {\n if (helper && summary) void nameAfterPlaying(screen, summary).catch(() => undefined);\n if (friends) setScreen({ name: 'worlds' });\n else onExit?.();\n };\n\n return (\n <Cubeforge3D\n seed={screen.seed}\n worldKey={screen.worldKey}\n room={screen.room}\n skin={skin ? skinToHex(skin) : undefined}\n onExit={leaveWorld}\n helper={screen.shared && !screen.shared.ownedByMe ? undefined : helper}\n onRoomClosed={() => setScreen({ name: 'worlds' })}\n onTokenExpired={refreshRoom}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n fill: { flex: 1 },\n message: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: spacing.lg, gap: spacing.sm },\n title: { fontSize: 18, fontWeight: '700', textAlign: 'center' },\n body: { fontSize: 15, lineHeight: 21, textAlign: 'center' },\n});\n\nexport default YantraGames;\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AA0EO,SAAS,YAAY,KAA6C,EAAA;AA1EzE,EAAA,IAAA,EAAA;AA2EE,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAS,EAAA,WAAA;AAAA,IACT,WAAa,EAAA,WAAA;AAAA,IACb,gBAAkB,EAAA,OAAA;AAAA,IAClB,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,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA;AAAA,GACR;AAAA,EACA,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,CAAA;AAAA,IACN,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA,QAAA;AAAA,IAChB,SAAS,OAAQ,CAAA,EAAA;AAAA,IACjB,KAAK,OAAQ,CAAA;AAAA,GACf;AAAA,EACA,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,KAAA;AAAA,IACZ,SAAW,EAAA;AAAA,GACb;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,EAAA;AAAA,IACZ,SAAW,EAAA;AAAA;AAEf,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"GamesRoot.js","sources":["../../../../../src/features/games/vendored/ui/GamesRoot.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { ActivityIndicator, StyleSheet, Text, useColorScheme, View } from 'react-native';\nimport {\n DEFAULT_GAME_ORIENTATION,\n GamePreferences,\n NativeWorldRepository,\n OpeningMemory,\n SkinRepository,\n nativeWorldKey,\n parseInviteCode,\n seedFromString,\n sharedWorldKey,\n skinToHex,\n waitingInvites,\n type CubeforgeFriends,\n type KeyValueStorage,\n type NativeWorld,\n type RoomAccess,\n type SharedWorld,\n type WorldInvite,\n hasDefaultName,\n worthNaming,\n type CubeforgeHelper,\n type GameNotifications,\n type GameOrientation,\n} from '../core';\nimport { Cubeforge3DHomeScreen } from './screens/Cubeforge3DHomeScreen';\nimport { HowToPlayScreen } from './screens/HowToPlayScreen';\nimport { ScreenHeader } from './screens/ScreenHeader';\nimport { SkinEditorScreen } from './screens/SkinEditorScreen';\nimport { createAsyncStorageAdapter } from './storage/asyncStorageAdapter';\nimport { getTheme, spacing, type ThemeMode } from './theme';\n\nexport interface YantraGamesProps {\n /** Organisation the signed-in user is in; each org has its own world. */\n orgName: string;\n /** Called when the user leaves the game (back out to the app). */\n onExit?: () => void;\n /** Force a theme; defaults to the system colour scheme. */\n theme?: ThemeMode;\n /** Override persistence; defaults to AsyncStorage. */\n storage?: KeyValueStorage;\n /**\n * The native first-person Cubeforge (the Rust engine in `native/cubeforge`).\n * It is the game: without one on this device there is nothing to play, and\n * the player is told so.\n */\n cubeforge3D?: React.ComponentType<Cubeforge3DProps>;\n /** Shared worlds and chat invites, when the host offers them. */\n cubeforgeFriends?: CubeforgeFriends;\n /** An invite to accept right away, for example from a tapped chat card. */\n cubeforgeInvite?: string;\n /** Called once `cubeforgeInvite` has been accepted or refused. */\n onCubeforgeInviteHandled?: (error: string | null) => void;\n /** Removes a 3D world's save from this device. */\n deleteCubeforge3DSave?: (worldKey: string) => void;\n /** The AI build helper, when the host can reach one. */\n cubeforgeHelper?: CubeforgeHelper;\n /** Address of a world's saved picture, or null when it has none. */\n cubeforge3DPicture?: (worldKey: string) => string | null;\n /** This phone's notifications, when the host can turn them on. */\n notifications?: GameNotifications;\n}\n\n/** Props the host's native Cubeforge 3D component receives. */\nexport interface Cubeforge3DProps {\n /** Seed for a new world, stable per org. */\n seed: number;\n /** Stable key for the world's save (the org), safe as a file name part. */\n worldKey: string;\n /** Leave the game. `summary` describes the world, when the engine can. */\n onExit: (summary?: string) => void;\n /** The build helper, when this player may change this world. */\n helper?: CubeforgeHelper;\n /** Connect to this shared world; omitted when playing alone. */\n room?: RoomAccess;\n /** The server refused the player for good (removed, deleted, joined elsewhere). */\n onRoomClosed?: () => void;\n /** The token expired; the next `room` carries a fresh one. */\n onTokenExpired?: () => void;\n /** This person's painted avatar as 256 hex digits, when they have one. */\n skin?: string;\n /** How to hold the phone in the world; the host turns the screen to match. */\n orientation?: GameOrientation;\n}\n\ntype PlayableScreen =\n | { name: 'worlds' }\n | { name: 'avatar' }\n | { name: 'game'; seed: number; worldKey: string; shared?: SharedWorld; room?: RoomAccess };\n\ntype Screen = PlayableScreen | { name: 'opening' } | { name: 'howto'; after: PlayableScreen };\n\n/** How long opening Games waits to find out whether someone invited this player. */\nconst OPENING_WAIT_MS = 2500;\n\nfunction soonOr<T>(work: Promise<T>, fallback: T, waitMs: number): Promise<T> {\n return Promise.race([\n work,\n new Promise<T>((resolve) => {\n setTimeout(() => resolve(fallback), waitMs);\n }),\n ]);\n}\n\n/**\n * Yantra Games is Cubeforge in 3D: opening it opens the game, unless the player\n * has never been shown how to play or someone has just invited them. Where the\n * host offers friends, leaving a world goes to the list of worlds and Play with\n * friends; otherwise it leaves Games.\n */\nexport function YantraGames(props: YantraGamesProps): React.ReactElement {\n const {\n orgName,\n onExit,\n storage: storageProp,\n cubeforge3D: Cubeforge3D,\n cubeforgeFriends: friends,\n cubeforgeInvite,\n onCubeforgeInviteHandled,\n deleteCubeforge3DSave,\n cubeforgeHelper: helper,\n cubeforge3DPicture,\n notifications,\n } = props;\n const systemScheme = useColorScheme();\n const theme = getTheme(props.theme ?? (systemScheme === 'dark' ? 'dark' : 'light'));\n\n const storage = useMemo(() => storageProp ?? createAsyncStorageAdapter(), [storageProp]);\n const worlds = useMemo(() => new NativeWorldRepository(storage, orgName || 'default'), [storage, orgName]);\n const skins = useMemo(() => new SkinRepository(storage, orgName || 'default'), [storage, orgName]);\n const [skin, setSkin] = useState<number[] | null>(null);\n\n useEffect(() => {\n let live = true;\n skins\n .load()\n .then((cells) => {\n if (live) setSkin(cells);\n })\n .catch(() => undefined);\n return () => {\n live = false;\n };\n }, [skins]);\n\n // Bumped when the helper renames a world, so the list shows it.\n const [worldsRevision, setWorldsRevision] = useState(0);\n\n // An invite goes straight to its world, so it starts from the list, not a solo world.\n const [screen, setScreen] = useState<Screen>(() => (cubeforgeInvite ? { name: 'worlds' } : { name: 'opening' }));\n const memory = useMemo(() => new OpeningMemory(storage), [storage]);\n const preferences = useMemo(() => new GamePreferences(storage), [storage]);\n const [orientation, setOrientation] = useState<GameOrientation>(DEFAULT_GAME_ORIENTATION);\n const opening = screen.name === 'opening';\n\n useEffect(() => {\n let live = true;\n preferences\n .orientation()\n .then((saved) => {\n if (live) setOrientation(saved);\n })\n .catch(() => undefined);\n return () => {\n live = false;\n };\n }, [preferences]);\n\n const chooseOrientation = useCallback(\n (next: GameOrientation) => {\n setOrientation(next);\n preferences.setOrientation(next).catch(() => undefined);\n },\n [preferences],\n );\n\n useEffect(() => {\n if (!opening) return undefined;\n let live = true;\n const newInvites = async (): Promise<WorldInvite[]> => {\n if (!friends?.listInvites) return [];\n const [shared, invites, seen] = await Promise.all([\n friends.listWorlds(),\n friends.listInvites(),\n memory.seenInvites(),\n ]);\n return waitingInvites(invites, shared, Date.now()).filter((invite) => !seen.has(invite.code));\n };\n Promise.all([\n memory.hasSeenHowTo().catch(() => true),\n // Read before the game starts, so a world never opens sideways and then turns.\n preferences\n .orientation()\n .then((saved) => {\n if (live) setOrientation(saved);\n })\n .catch(() => undefined),\n soonOr(\n newInvites().catch(() => []),\n [],\n OPENING_WAIT_MS,\n ),\n ])\n .then(([seenHowTo, , invites]) => {\n if (!live) return;\n if (invites.length > 0)\n memory.markInvitesSeen(invites.map((invite) => invite.code)).catch(() => undefined);\n const next: PlayableScreen =\n invites.length > 0\n ? { name: 'worlds' }\n : {\n name: 'game',\n seed: seedFromString(orgName || 'default'),\n worldKey: nativeWorldKey(orgName),\n };\n setScreen((current) => {\n if (current.name !== 'opening') return current;\n return seenHowTo ? next : { name: 'howto', after: next };\n });\n })\n .catch(() => undefined);\n return () => {\n live = false;\n };\n }, [opening, friends, memory, preferences, orgName]);\n\n const playSolo = useCallback((world: NativeWorld) => {\n setScreen({ name: 'game', seed: world.seed, worldKey: world.key });\n }, []);\n\n const playShared = useCallback(\n async (world: SharedWorld) => {\n if (!friends) return;\n const room = await friends.roomAccess(world);\n setScreen({ name: 'game', seed: world.seed, worldKey: sharedWorldKey(world.id), shared: world, room });\n },\n [friends],\n );\n\n // A world nobody has named gets one from what was built in it.\n const nameAfterPlaying = useCallback(\n async (played: Screen, summary: string) => {\n if (played.name !== 'game' || !helper || !worthNaming(summary)) return;\n const { shared, worldKey } = played;\n const current = shared?.name ?? (await worlds.list()).find((w) => w.key === worldKey)?.name;\n if (!current || !hasDefaultName(current)) return;\n if (shared && !(shared.ownedByMe && friends?.renameWorld)) return;\n const name = await helper.nameWorld(summary);\n if (!name) return;\n if (shared) await friends?.renameWorld?.(shared, name);\n else await worlds.rename(worldKey, name);\n setWorldsRevision((n) => n + 1);\n },\n [friends, helper, worlds],\n );\n\n // Fresh credentials for the world in play, after the old token expired.\n const refreshRoom = useCallback(() => {\n if (screen.name !== 'game' || !screen.shared || !friends) return;\n const { shared } = screen;\n friends\n .roomAccess(shared)\n .then((room) => setScreen((s) => (s.name === 'game' && s.shared?.id === shared.id ? { ...s, room } : s)))\n .catch(() => setScreen({ name: 'worlds' }));\n }, [friends, screen]);\n\n // Accept an invite handed in by the host (a tapped chat card).\n useEffect(() => {\n if (!cubeforgeInvite || !friends || !Cubeforge3D) return undefined;\n let live = true;\n const code = parseInviteCode(cubeforgeInvite);\n const accept = async () => {\n if (!code) throw new Error('That invite is not valid.');\n const world = await friends.joinWorld(code);\n if (live) await playShared(world);\n };\n accept()\n .then(() => {\n if (live) onCubeforgeInviteHandled?.(null);\n })\n .catch((e: unknown) => {\n if (live) onCubeforgeInviteHandled?.(e instanceof Error ? e.message : 'Could not join that world.');\n });\n return () => {\n live = false;\n };\n }, [cubeforgeInvite, friends, Cubeforge3D, playShared, onCubeforgeInviteHandled]);\n\n if (!Cubeforge3D) {\n return (\n <View style={[styles.fill, { backgroundColor: theme.bg }]}>\n <ScreenHeader theme={theme} title=\"Cubeforge\" onBack={onExit} backLabel=\"Close\" />\n <View style={styles.message}>\n <Text style={[styles.title, { color: theme.text }]}>Cubeforge is not on this device yet</Text>\n <Text style={[styles.body, { color: theme.textMuted }]}>\n It is a 3D game that needs the latest Yantra app on a 64-bit phone.\n </Text>\n </View>\n </View>\n );\n }\n\n if (screen.name === 'opening') {\n return (\n <View style={[styles.fill, styles.message, { backgroundColor: theme.bg }]}>\n <ActivityIndicator color={theme.primary} />\n </View>\n );\n }\n\n if (screen.name === 'howto') {\n const { after } = screen;\n return (\n <HowToPlayScreen\n theme={theme}\n onDone={() => {\n memory.markHowToSeen().catch(() => undefined);\n setScreen(after);\n }}\n />\n );\n }\n\n if (screen.name === 'worlds') {\n return (\n <Cubeforge3DHomeScreen\n theme={theme}\n worlds={worlds}\n friends={friends}\n onBack={() => onExit?.()}\n onPlaySolo={playSolo}\n onPlayShared={playShared}\n onDeleteSave={deleteCubeforge3DSave}\n onEditAvatar={() => setScreen({ name: 'avatar' })}\n onHowToPlay={() => setScreen({ name: 'howto', after: { name: 'worlds' } })}\n notifications={notifications}\n orientation={orientation}\n onOrientationChange={Cubeforge3D ? chooseOrientation : undefined}\n pictureOf={cubeforge3DPicture}\n revision={worldsRevision}\n />\n );\n }\n\n if (screen.name === 'avatar') {\n return (\n <SkinEditorScreen\n theme={theme}\n initial={skin}\n onBack={() => setScreen({ name: 'worlds' })}\n onSave={(cells) => {\n setSkin(cells);\n void skins.save(cells);\n setScreen({ name: 'worlds' });\n }}\n />\n );\n }\n\n const leaveWorld = (summary?: string) => {\n if (helper && summary) void nameAfterPlaying(screen, summary).catch(() => undefined);\n if (friends) setScreen({ name: 'worlds' });\n else onExit?.();\n };\n\n return (\n <Cubeforge3D\n seed={screen.seed}\n worldKey={screen.worldKey}\n room={screen.room}\n skin={skin ? skinToHex(skin) : undefined}\n onExit={leaveWorld}\n helper={screen.shared && !screen.shared.ownedByMe ? undefined : helper}\n onRoomClosed={() => setScreen({ name: 'worlds' })}\n onTokenExpired={refreshRoom}\n orientation={orientation}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n fill: { flex: 1 },\n message: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: spacing.lg, gap: spacing.sm },\n title: { fontSize: 18, fontWeight: '700', textAlign: 'center' },\n body: { fontSize: 15, lineHeight: 21, textAlign: 'center' },\n});\n\nexport default YantraGames;\n"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A,MAAA,CAAO,IAAM,EAAA,QAAA,EAAU,MAAO,CAAA,QAAA,EAAU,IAAM,EAAA,MAAA,CAAO,IAAM,EAAA,IAAA,EAAM,OAAO,SAAU,CAAA,IAAI,CAAI,GAAA,MAAA,EAAW,MAAQ,EAAA,UAAA,EAAY,MAAQ,EAAA,MAAA,CAAO,MAAU,IAAA,CAAC,MAAO,CAAA,MAAA,CAAO,SAAY,GAAA,MAAA,GAAY,MAAQ,EAAA,YAAA,EAAc,MAAM,SAAU,CAAA;AAAA,IACvP,IAAM,EAAA;AAAA,GACP,CAAA,EAAG,cAAgB,EAAA,WAAA,EAAa,WAA0B,EAAA,CAAA;AAC7D;AACA,MAAM,MAAA,GAAS,WAAW,MAAO,CAAA;AAAA,EAC/B,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA;AAAA,GACR;AAAA,EACA,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,CAAA;AAAA,IACN,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA,QAAA;AAAA,IAChB,SAAS,OAAQ,CAAA,EAAA;AAAA,IACjB,KAAK,OAAQ,CAAA;AAAA,GACf;AAAA,EACA,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,KAAA;AAAA,IACZ,SAAW,EAAA;AAAA,GACb;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,EAAA;AAAA,IACZ,SAAW,EAAA;AAAA;AAEf,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx,jsxs}from'react/jsx-runtime';import {
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import {Pressable,StyleSheet,Text,View,TextInput}from'react-native';import {spacing,radius}from'../theme.js';function Button(props) {
|
|
2
2
|
const {
|
|
3
3
|
label,
|
|
4
4
|
onPress,
|