@adminide-stack/yantra-mobile 12.0.172-alpha.0 → 12.0.172-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.
Files changed (63) hide show
  1. package/lib/components/GatewayConnector/GatewayConnector.js +10 -4
  2. package/lib/components/GatewayConnector/GatewayConnector.js.map +1 -1
  3. package/lib/components/GatewayConnector/GatewayStatusSheet.js +174 -0
  4. package/lib/components/GatewayConnector/GatewayStatusSheet.js.map +1 -0
  5. package/lib/components/GatewayToolbarButtonMobile.js +6 -2
  6. package/lib/components/GatewayToolbarButtonMobile.js.map +1 -1
  7. package/lib/config/env-config.js +12 -3
  8. package/lib/config/env-config.js.map +1 -1
  9. package/lib/features/apps/nativeAppHandoff.js +31 -13
  10. package/lib/features/apps/nativeAppHandoff.js.map +1 -1
  11. package/lib/features/chat/PromptFillBar.js +153 -0
  12. package/lib/features/chat/PromptFillBar.js.map +1 -0
  13. package/lib/features/chat/promptBlanks.js +120 -0
  14. package/lib/features/chat/promptBlanks.js.map +1 -0
  15. package/lib/features/chat/savedReply.js +11 -0
  16. package/lib/features/chat/savedReply.js.map +1 -0
  17. package/lib/features/games/GameInviteCard.js +93 -0
  18. package/lib/features/games/GameInviteCard.js.map +1 -0
  19. package/lib/features/games/cubeforge3D.js +75 -4
  20. package/lib/features/games/cubeforge3D.js.map +1 -1
  21. package/lib/features/games/cubeforgeFriends.js +112 -0
  22. package/lib/features/games/cubeforgeFriends.js.map +1 -0
  23. package/lib/features/games/gameInvite.js +13 -0
  24. package/lib/features/games/gameInvite.js.map +1 -0
  25. package/lib/features/games/useCubeforgeFriends.js +63 -0
  26. package/lib/features/games/useCubeforgeFriends.js.map +1 -0
  27. package/lib/features/games/vendored/core/cubeforge/nativeWorlds.js +68 -0
  28. package/lib/features/games/vendored/core/cubeforge/nativeWorlds.js.map +1 -0
  29. package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js +10 -0
  30. package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js.map +1 -0
  31. package/lib/features/games/vendored/ui/GamesRoot.js +69 -5
  32. package/lib/features/games/vendored/ui/GamesRoot.js.map +1 -1
  33. package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js +296 -0
  34. package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js.map +1 -0
  35. package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js +1 -1
  36. package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js.map +1 -1
  37. package/lib/features/messaging/ChatComponents.js +12 -4
  38. package/lib/features/messaging/ChatComponents.js.map +1 -1
  39. package/lib/features/messaging/messageCards.js +22 -0
  40. package/lib/features/messaging/messageCards.js.map +1 -0
  41. package/lib/features/travel/TravelAgentChatPane.js +9 -1
  42. package/lib/features/travel/TravelAgentChatPane.js.map +1 -1
  43. package/lib/hooks/useCdecliAutoConnect.js +8 -1
  44. package/lib/hooks/useCdecliAutoConnect.js.map +1 -1
  45. package/lib/hooks/useCdecliChannel.js +142 -49
  46. package/lib/hooks/useCdecliChannel.js.map +1 -1
  47. package/lib/hooks/useChatApi.js +21 -10
  48. package/lib/hooks/useChatApi.js.map +1 -1
  49. package/lib/hooks/useChatStream.js +18 -5
  50. package/lib/hooks/useChatStream.js.map +1 -1
  51. package/lib/module.js +2 -1
  52. package/lib/module.js.map +1 -1
  53. package/lib/screens/Chat/index.js +23 -15
  54. package/lib/screens/Chat/index.js.map +1 -1
  55. package/lib/screens/GamesNative/index.js +48 -3
  56. package/lib/screens/GamesNative/index.js.map +1 -1
  57. package/lib/screens/Home/HomeScreen.js +147 -33
  58. package/lib/screens/Home/HomeScreen.js.map +1 -1
  59. package/lib/screens/Home/components/HomeSuggestions.js +1 -1
  60. package/lib/screens/Home/components/HomeSuggestions.js.map +1 -1
  61. package/lib/screens/Home/components/homeCatalog.js +68 -16
  62. package/lib/screens/Home/components/homeCatalog.js.map +1 -1
  63. package/package.json +2 -2
@@ -0,0 +1,153 @@
1
+ import {jsxs,jsx}from'react/jsx-runtime';import {useMemo}from'react';import {StyleSheet,View,Pressable,ScrollView}from'react-native';import {Feather}from'@expo/vector-icons';import {Text}from'@admin-layout/gluestack-ui-mobile';import {mobileColors}from'../../theme/mobileTokens.js';import {fillTokens,blankLabel}from'./promptBlanks.js';function PromptFillBar({
2
+ fill,
3
+ isDark,
4
+ onSelectBlank,
5
+ onPickAnswer,
6
+ onEditAll,
7
+ onCancel
8
+ }) {
9
+ var _a, _b;
10
+ const colors = mobileColors(isDark);
11
+ const tokens = useMemo(() => fillTokens(fill.template), [fill.template]);
12
+ const ink = isDark ? colors.primary : "#9a3412";
13
+ const answers = (_b = (_a = fill.guides[fill.active]) == null ? void 0 : _a.suggestions) != null ? _b : [];
14
+ return /* @__PURE__ */ jsxs(View, { style: styles.wrap, children: [
15
+ /* @__PURE__ */ jsxs(View, { style: styles.top, children: [
16
+ /* @__PURE__ */ jsxs(View, { style: styles.sentence, children: [
17
+ tokens.map((token, i) => {
18
+ if (token.kind === "word") {
19
+ return /* @__PURE__ */ jsx(Text, { style: [styles.word, {
20
+ color: colors.textMuted
21
+ }], children: token.text }, i);
22
+ }
23
+ const answer = fill.answers[token.index].trim();
24
+ const active = token.index === fill.active;
25
+ const label = blankLabel(fill.blanks[token.index]);
26
+ return /* @__PURE__ */ jsxs(View, { style: styles.pillRow, children: [
27
+ /* @__PURE__ */ jsx(Pressable, { onPress: () => onSelectBlank(token.index), hitSlop: 8, accessibilityRole: "button", accessibilityState: {
28
+ selected: active
29
+ }, accessibilityLabel: answer ? `${label}: ${answer}. Change` : `Fill in ${label}`, style: [styles.pill, {
30
+ backgroundColor: colors.primarySoft,
31
+ borderColor: "transparent"
32
+ }, active && {
33
+ borderColor: colors.primary
34
+ }, !active && !answer && {
35
+ borderColor: colors.primaryBorder
36
+ }], children: /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.pillText, {
37
+ color: answer ? colors.text : ink
38
+ }], children: answer || label }) }),
39
+ token.tail ? /* @__PURE__ */ jsx(Text, { style: [styles.word, styles.tail, {
40
+ color: colors.textMuted
41
+ }], children: token.tail }) : null
42
+ ] }, i);
43
+ }),
44
+ /* @__PURE__ */ jsx(Pressable, { onPress: onEditAll, hitSlop: 8, accessibilityRole: "button", accessibilityLabel: "Edit the whole message", style: styles.editAll, children: /* @__PURE__ */ jsx(Text, { style: [styles.editAllText, {
45
+ color: ink
46
+ }], children: "Edit text" }) })
47
+ ] }),
48
+ /* @__PURE__ */ jsx(Pressable, { onPress: onCancel, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: "Cancel this shortcut", style: ({
49
+ pressed
50
+ }) => [styles.cancel, pressed && styles.pressed], children: /* @__PURE__ */ jsx(Feather, { name: "x", size: 18, color: colors.textMuted }) })
51
+ ] }),
52
+ answers.length > 0 ? /* @__PURE__ */ jsx(
53
+ ScrollView,
54
+ {
55
+ horizontal: true,
56
+ showsHorizontalScrollIndicator: false,
57
+ keyboardShouldPersistTaps: "always",
58
+ contentContainerStyle: styles.chips,
59
+ children: answers.map((answer) => {
60
+ const on = fill.answers[fill.active].trim() === answer;
61
+ return /* @__PURE__ */ jsx(Pressable, { onPress: () => onPickAnswer(answer), accessibilityRole: "button", accessibilityState: {
62
+ selected: on
63
+ }, accessibilityLabel: `Use ${answer}`, style: ({
64
+ pressed
65
+ }) => [styles.chip, {
66
+ borderColor: on ? colors.primary : colors.border
67
+ }, on && {
68
+ backgroundColor: colors.primarySoft
69
+ }, pressed && styles.pressed], children: /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.chipText, {
70
+ color: colors.text
71
+ }], children: answer }) }, answer);
72
+ })
73
+ }
74
+ ) : null
75
+ ] });
76
+ }
77
+ const LINE = 30;
78
+ const styles = StyleSheet.create({
79
+ wrap: {
80
+ gap: 10,
81
+ paddingBottom: 4
82
+ },
83
+ top: {
84
+ flexDirection: "row",
85
+ alignItems: "flex-start",
86
+ gap: 6
87
+ },
88
+ sentence: {
89
+ flex: 1,
90
+ flexDirection: "row",
91
+ flexWrap: "wrap",
92
+ alignItems: "center",
93
+ columnGap: 4
94
+ },
95
+ word: {
96
+ fontSize: 15,
97
+ lineHeight: LINE
98
+ },
99
+ tail: {
100
+ marginLeft: 1
101
+ },
102
+ pillRow: {
103
+ flexDirection: "row",
104
+ alignItems: "center",
105
+ maxWidth: "100%"
106
+ },
107
+ pill: {
108
+ height: LINE - 2,
109
+ marginVertical: 1,
110
+ paddingHorizontal: 9,
111
+ borderRadius: 8,
112
+ borderWidth: 1.5,
113
+ justifyContent: "center",
114
+ flexShrink: 1
115
+ },
116
+ pillText: {
117
+ fontSize: 15,
118
+ fontWeight: "600"
119
+ },
120
+ editAll: {
121
+ height: LINE,
122
+ justifyContent: "center",
123
+ marginLeft: 4
124
+ },
125
+ editAllText: {
126
+ fontSize: 13,
127
+ fontWeight: "600"
128
+ },
129
+ cancel: {
130
+ width: 28,
131
+ height: 28,
132
+ alignItems: "center",
133
+ justifyContent: "center"
134
+ },
135
+ pressed: {
136
+ opacity: 0.6
137
+ },
138
+ chips: {
139
+ gap: 8,
140
+ paddingRight: 8
141
+ },
142
+ chip: {
143
+ height: 36,
144
+ paddingHorizontal: 14,
145
+ borderRadius: 18,
146
+ borderWidth: 1,
147
+ justifyContent: "center"
148
+ },
149
+ chipText: {
150
+ fontSize: 14,
151
+ fontWeight: "500"
152
+ }
153
+ });export{PromptFillBar};//# sourceMappingURL=PromptFillBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromptFillBar.js","sources":["../../../src/features/chat/PromptFillBar.tsx"],"sourcesContent":["/**\n * Answering a Home shortcut's blank by touch. The sentence sits above the composer with the blank as\n * a pill that fills in as the person types; the composer's own field is the answer, already focused,\n * and the answers people most often give are one tap away.\n *\n * Nothing here is selected inside the sentence: drag handles over the text were fiddly, and a stray\n * tap lost the selection. \"Edit text\" hands the whole message to the composer for changing the rest.\n */\nimport React, { useMemo } from 'react';\nimport { Pressable, ScrollView, StyleSheet, View } from 'react-native';\nimport { Feather } from '@expo/vector-icons';\nimport { Text } from '@admin-layout/gluestack-ui-mobile';\nimport { mobileColors } from '../../theme/mobileTokens';\nimport { blankLabel, fillTokens, type PromptFill } from './promptBlanks';\n\nexport interface PromptFillBarProps {\n fill: PromptFill;\n isDark: boolean;\n onSelectBlank: (index: number) => void;\n onPickAnswer: (answer: string) => void;\n onEditAll: () => void;\n onCancel: () => void;\n}\n\nexport function PromptFillBar({ fill, isDark, onSelectBlank, onPickAnswer, onEditAll, onCancel }: PromptFillBarProps) {\n const colors = mobileColors(isDark);\n const tokens = useMemo(() => fillTokens(fill.template), [fill.template]);\n // Orange on its own tint is too faint for a label this size on a light composer.\n const ink = isDark ? colors.primary : '#9a3412';\n const answers = fill.guides[fill.active]?.suggestions ?? [];\n\n return (\n <View style={styles.wrap}>\n <View style={styles.top}>\n <View style={styles.sentence}>\n {tokens.map((token, i) => {\n if (token.kind === 'word') {\n return (\n <Text key={i} style={[styles.word, { color: colors.textMuted }]}>\n {token.text}\n </Text>\n );\n }\n const answer = fill.answers[token.index].trim();\n const active = token.index === fill.active;\n const label = blankLabel(fill.blanks[token.index]);\n return (\n <View key={i} style={styles.pillRow}>\n <Pressable\n onPress={() => onSelectBlank(token.index)}\n hitSlop={8}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: active }}\n accessibilityLabel={answer ? `${label}: ${answer}. Change` : `Fill in ${label}`}\n style={[\n styles.pill,\n { backgroundColor: colors.primarySoft, borderColor: 'transparent' },\n active && { borderColor: colors.primary },\n !active && !answer && { borderColor: colors.primaryBorder },\n ]}\n >\n <Text\n numberOfLines={1}\n style={[styles.pillText, { color: answer ? colors.text : ink }]}\n >\n {answer || label}\n </Text>\n </Pressable>\n {token.tail ? (\n <Text style={[styles.word, styles.tail, { color: colors.textMuted }]}>\n {token.tail}\n </Text>\n ) : null}\n </View>\n );\n })}\n <Pressable\n onPress={onEditAll}\n hitSlop={8}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Edit the whole message\"\n style={styles.editAll}\n >\n <Text style={[styles.editAllText, { color: ink }]}>Edit text</Text>\n </Pressable>\n </View>\n <Pressable\n onPress={onCancel}\n hitSlop={10}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Cancel this shortcut\"\n style={({ pressed }) => [styles.cancel, pressed && styles.pressed]}\n >\n <Feather name=\"x\" size={18} color={colors.textMuted} />\n </Pressable>\n </View>\n {answers.length > 0 ? (\n <ScrollView\n horizontal\n showsHorizontalScrollIndicator={false}\n // A chip takes the first tap, with the keyboard up.\n keyboardShouldPersistTaps=\"always\"\n contentContainerStyle={styles.chips}\n >\n {answers.map((answer) => {\n const on = fill.answers[fill.active].trim() === answer;\n return (\n <Pressable\n key={answer}\n onPress={() => onPickAnswer(answer)}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: on }}\n accessibilityLabel={`Use ${answer}`}\n style={({ pressed }) => [\n styles.chip,\n { borderColor: on ? colors.primary : colors.border },\n on && { backgroundColor: colors.primarySoft },\n pressed && styles.pressed,\n ]}\n >\n <Text numberOfLines={1} style={[styles.chipText, { color: colors.text }]}>\n {answer}\n </Text>\n </Pressable>\n );\n })}\n </ScrollView>\n ) : null}\n </View>\n );\n}\n\nconst LINE = 30;\n\nconst styles = StyleSheet.create({\n wrap: { gap: 10, paddingBottom: 4 },\n top: { flexDirection: 'row', alignItems: 'flex-start', gap: 6 },\n sentence: { flex: 1, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', columnGap: 4 },\n word: { fontSize: 15, lineHeight: LINE },\n tail: { marginLeft: 1 },\n pillRow: { flexDirection: 'row', alignItems: 'center', maxWidth: '100%' },\n pill: {\n height: LINE - 2,\n marginVertical: 1,\n paddingHorizontal: 9,\n borderRadius: 8,\n borderWidth: 1.5,\n justifyContent: 'center',\n flexShrink: 1,\n },\n pillText: { fontSize: 15, fontWeight: '600' },\n editAll: { height: LINE, justifyContent: 'center', marginLeft: 4 },\n editAllText: { fontSize: 13, fontWeight: '600' },\n cancel: { width: 28, height: 28, alignItems: 'center', justifyContent: 'center' },\n pressed: { opacity: 0.6 },\n chips: { gap: 8, paddingRight: 8 },\n chip: { height: 36, paddingHorizontal: 14, borderRadius: 18, borderWidth: 1, justifyContent: 'center' },\n chipText: { fontSize: 14, fontWeight: '500' },\n});\n"],"names":[],"mappings":"gVAsBO,SAAS,aAAc,CAAA;AAAA,EAC5B,IAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAuB,EAAA;AA7BvB,EAAA,IAAA,EAAA,EAAA,EAAA;AA8BE,EAAM,MAAA,MAAA,GAAS,aAAa,MAAM,CAAA;AAClC,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,MAAM,UAAW,CAAA,IAAA,CAAK,QAAQ,CAAG,EAAA,CAAC,IAAK,CAAA,QAAQ,CAAC,CAAA;AAEvE,EAAM,MAAA,GAAA,GAAM,MAAS,GAAA,MAAA,CAAO,OAAU,GAAA,SAAA;AACtC,EAAM,MAAA,OAAA,GAAA,CAAU,gBAAK,MAAO,CAAA,IAAA,CAAK,MAAM,CAAvB,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAA0B,WAA1B,KAAA,IAAA,GAAA,EAAA,GAAyC,EAAC;AAC1D,EAAA,uBAAQ,IAAA,CAAA,IAAA,EAAA,EAAK,KAAO,EAAA,MAAA,CAAO,IACjB,EAAA,QAAA,EAAA;AAAA,oBAAC,IAAA,CAAA,IAAA,EAAA,EAAK,KAAO,EAAA,MAAA,CAAO,GAChB,EAAA,QAAA,EAAA;AAAA,sBAAC,IAAA,CAAA,IAAA,EAAA,EAAK,KAAO,EAAA,MAAA,CAAO,QACf,EAAA,QAAA,EAAA;AAAA,QAAO,MAAA,CAAA,GAAA,CAAI,CAAC,KAAA,EAAO,CAAM,KAAA;AACpC,UAAI,IAAA,KAAA,CAAM,SAAS,MAAQ,EAAA;AACzB,YAAA,uBAAQ,GAAA,CAAA,IAAA,EAAA,EAAa,K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AAO,EAAA;AAAA,IACL,GAAK,EAAA,CAAA;AAAA,IACL,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,MAAQ,EAAA,EAAA;AAAA,IACR,iBAAmB,EAAA,EAAA;AAAA,IACnB,YAAc,EAAA,EAAA;AAAA,IACd,WAAa,EAAA,CAAA;AAAA,IACb,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
@@ -0,0 +1,120 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const BLANK = /\[[^[\]\n]{1,60}\]/g;
21
+ function promptBlanks(template) {
22
+ return Array.from(template.matchAll(BLANK), (m) => {
23
+ var _a, _b;
24
+ return {
25
+ start: (_a = m.index) != null ? _a : 0,
26
+ end: ((_b = m.index) != null ? _b : 0) + m[0].length,
27
+ text: m[0]
28
+ };
29
+ });
30
+ }
31
+ function firstUnfilledBlank(text, template) {
32
+ if (!template) return null;
33
+ for (const blank of promptBlanks(template)) {
34
+ const at = text.indexOf(blank.text);
35
+ if (at >= 0) return {
36
+ start: at,
37
+ end: at + blank.text.length,
38
+ text: blank.text
39
+ };
40
+ }
41
+ return null;
42
+ }
43
+ function promptParts(template) {
44
+ const parts = [];
45
+ let at = 0;
46
+ promptBlanks(template).forEach((blank, index) => {
47
+ if (blank.start > at) parts.push({
48
+ kind: "text",
49
+ text: template.slice(at, blank.start)
50
+ });
51
+ parts.push({
52
+ kind: "blank",
53
+ index
54
+ });
55
+ at = blank.end;
56
+ });
57
+ if (at < template.length) parts.push({
58
+ kind: "text",
59
+ text: template.slice(at)
60
+ });
61
+ return parts;
62
+ }
63
+ function blankLabel(blank) {
64
+ return blank.text.slice(1, -1);
65
+ }
66
+ function startFill(template, guides = []) {
67
+ const blanks = promptBlanks(template);
68
+ if (!blanks.length) return null;
69
+ return {
70
+ template,
71
+ blanks,
72
+ guides: blanks.map((_, i) => guides[i]),
73
+ answers: blanks.map(() => ""),
74
+ active: 0
75
+ };
76
+ }
77
+ function answerBlank(fill, text, index = fill.active) {
78
+ const answers = [...fill.answers];
79
+ answers[index] = text.replace(/\s*\n\s*/g, " ");
80
+ return __spreadProps(__spreadValues({}, fill), {
81
+ answers
82
+ });
83
+ }
84
+ function isFillComplete(fill) {
85
+ return fill.answers.every((answer) => answer.trim().length > 0);
86
+ }
87
+ function nextEmptyBlank(fill) {
88
+ const {
89
+ answers,
90
+ active
91
+ } = fill;
92
+ for (let step = 1; step < answers.length; step += 1) {
93
+ const index = (active + step) % answers.length;
94
+ if (!answers[index].trim()) return index;
95
+ }
96
+ return -1;
97
+ }
98
+ function filledPrompt(fill) {
99
+ return promptParts(fill.template).map((part) => part.kind === "text" ? part.text : fill.answers[part.index].trim() || fill.blanks[part.index].text).join("");
100
+ }
101
+ function fillTokens(template) {
102
+ const tokens = [];
103
+ promptParts(template).forEach((part) => {
104
+ if (part.kind === "blank") {
105
+ tokens.push({
106
+ kind: "blank",
107
+ index: part.index
108
+ });
109
+ return;
110
+ }
111
+ const words = part.text.split(/\s+/).filter(Boolean);
112
+ const last = tokens[tokens.length - 1];
113
+ if ((last == null ? void 0 : last.kind) === "blank" && !/^\s/.test(part.text) && words.length) last.tail = words.shift();
114
+ words.forEach((text) => tokens.push({
115
+ kind: "word",
116
+ text
117
+ }));
118
+ });
119
+ return tokens;
120
+ }export{answerBlank,blankLabel,fillTokens,filledPrompt,firstUnfilledBlank,isFillComplete,nextEmptyBlank,promptBlanks,promptParts,startFill};//# sourceMappingURL=promptBlanks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptBlanks.js","sources":["../../../src/features/chat/promptBlanks.ts"],"sourcesContent":["/**\n * The part of a starter prompt the person fills in, written `[your idea]`.\n *\n * A Home shortcut that names something only the person knows (\"my idea\", \"this\n * paper\", \"this topic\") used to go out as written and came back as \"I need the\n * idea first\": deep search ran one query and found no sources, the poster turn\n * asked for the paper. Now the blank is answered on its own, in one field with\n * answers a tap away (see PromptFillBar), and Send waits for it. Replacing a\n * selection inside a sentence was fiddly on a phone: drag handles over the text,\n * and a stray tap dropped the selection.\n *\n * Only the blanks of the shortcut's own prompt count, so brackets the person\n * types themselves never hold a message back.\n */\n\n/** One blank: `[...]` on one line, short enough to be a hint and not a passage. */\nconst BLANK = /\\[[^[\\]\\n]{1,60}\\]/g;\n\nexport interface PromptBlank {\n start: number;\n /** Exclusive. */\n end: number;\n text: string;\n}\n\n/** The blanks a template prompt has, in order. */\nexport function promptBlanks(template: string): PromptBlank[] {\n return Array.from(template.matchAll(BLANK), (m) => ({\n start: m.index ?? 0,\n end: (m.index ?? 0) + m[0].length,\n text: m[0],\n }));\n}\n\n/**\n * The first of the template's blanks still in the text as the template wrote it,\n * or null when every blank has been filled in (or there was no template).\n */\nexport function firstUnfilledBlank(text: string, template: string | null | undefined): PromptBlank | null {\n if (!template) return null;\n for (const blank of promptBlanks(template)) {\n const at = text.indexOf(blank.text);\n if (at >= 0) return { start: at, end: at + blank.text.length, text: blank.text };\n }\n return null;\n}\n\n/** What a shortcut says about one of its blanks: the question, and answers one tap away. */\nexport interface BlankGuide {\n ask: string;\n suggestions?: readonly string[];\n}\n\n/** A shortcut being answered: its blanks, what is typed for each, and the one the field is on. */\nexport interface PromptFill {\n template: string;\n blanks: PromptBlank[];\n guides: readonly (BlankGuide | undefined)[];\n answers: string[];\n active: number;\n}\n\nexport type PromptPart = { kind: 'text'; text: string } | { kind: 'blank'; index: number };\n\n/** The prompt in reading order: the words around each blank, and the blanks by position. */\nexport function promptParts(template: string): PromptPart[] {\n const parts: PromptPart[] = [];\n let at = 0;\n promptBlanks(template).forEach((blank, index) => {\n if (blank.start > at) parts.push({ kind: 'text', text: template.slice(at, blank.start) });\n parts.push({ kind: 'blank', index });\n at = blank.end;\n });\n if (at < template.length) parts.push({ kind: 'text', text: template.slice(at) });\n return parts;\n}\n\n/** The blank as a person reads it: `[your idea]` is \"your idea\". */\nexport function blankLabel(blank: PromptBlank): string {\n return blank.text.slice(1, -1);\n}\n\n/** Answering starts here, or null when the prompt has nothing to fill in. */\nexport function startFill(template: string, guides: readonly BlankGuide[] = []): PromptFill | null {\n const blanks = promptBlanks(template);\n if (!blanks.length) return null;\n return { template, blanks, guides: blanks.map((_, i) => guides[i]), answers: blanks.map(() => ''), active: 0 };\n}\n\n/** The active blank's answer changed. An answer stays on one line: the composer's field is multiline. */\nexport function answerBlank(fill: PromptFill, text: string, index = fill.active): PromptFill {\n const answers = [...fill.answers];\n answers[index] = text.replace(/\\s*\\n\\s*/g, ' ');\n return { ...fill, answers };\n}\n\nexport function isFillComplete(fill: PromptFill): boolean {\n return fill.answers.every((answer) => answer.trim().length > 0);\n}\n\n/** The next blank still empty after the active one, wrapping round; -1 when the rest are answered. */\nexport function nextEmptyBlank(fill: PromptFill): number {\n const { answers, active } = fill;\n for (let step = 1; step < answers.length; step += 1) {\n const index = (active + step) % answers.length;\n if (!answers[index].trim()) return index;\n }\n return -1;\n}\n\n/** The prompt with what has been answered so far; a blank not answered yet keeps its `[placeholder]`. */\nexport function filledPrompt(fill: PromptFill): string {\n return promptParts(fill.template)\n .map((part) =>\n part.kind === 'text' ? part.text : fill.answers[part.index].trim() || fill.blanks[part.index].text,\n )\n .join('');\n}\n\nexport type FillToken = { kind: 'word'; text: string } | { kind: 'blank'; index: number; tail?: string };\n\n/** Words wrap one at a time so a pill sits in the line like a word; a comma after a blank stays on it. */\nexport function fillTokens(template: string): FillToken[] {\n const tokens: FillToken[] = [];\n promptParts(template).forEach((part) => {\n if (part.kind === 'blank') {\n tokens.push({ kind: 'blank', index: part.index });\n return;\n }\n const words = part.text.split(/\\s+/).filter(Boolean);\n const last = tokens[tokens.length - 1];\n if (last?.kind === 'blank' && !/^\\s/.test(part.text) && words.length) last.tail = words.shift();\n words.forEach((text) => tokens.push({ kind: 'word', text }));\n });\n return tokens;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAM,KAAQ,GAAA,qBAAA;AASP,SAAS,aAAa,QAAiC,EAAA;AAC5D,EAAA,OAAO,MAAM,IAAK,CAAA,QAAA,CAAS,QAAS,CAAA,KAAK,GAAG,CAAE,CAAA,KAAA;AA1BhD,IAAA,IAAA,EAAA,EAAA,EAAA;AA0BoD,IAAA,OAAA;AAAA,MAChD,KAAA,EAAA,CAAO,EAAE,GAAA,CAAA,CAAA,KAAA,KAAF,IAAW,GAAA,EAAA,GAAA,CAAA;AAAA,MAClB,OAAM,EAAE,GAAA,CAAA,CAAA,KAAA,KAAF,YAAW,CAAK,IAAA,CAAA,CAAE,CAAC,CAAE,CAAA,MAAA;AAAA,MAC3B,IAAA,EAAM,EAAE,CAAC;AAAA,KACX;AAAA,GAAE,CAAA;AACJ;AAMgB,SAAA,kBAAA,CAAmB,MAAc,QAAyD,EAAA;AACxG,EAAI,IAAA,CAAC,UAAiB,OAAA,IAAA;AACtB,EAAW,KAAA,MAAA,KAAA,IAAS,YAAa,CAAA,QAAQ,CAAG,EAAA;AAC1C,IAAA,MAAM,EAAK,GAAA,IAA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Set(thread.map((row) => row.id));
3
+ }
4
+ function savedReplyFor(thread, seenIds) {
5
+ for (let i = thread.length - 1; i >= 0; i -= 1) {
6
+ const row = thread[i];
7
+ if (row.role === "user") return null;
8
+ if (row.role === "assistant" && row.content.trim()) return seenIds.has(row.id) ? null : row.content;
9
+ }
10
+ return null;
11
+ }export{savedReplyFor,seenRowIds};//# sourceMappingURL=savedReply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"savedReply.js","sources":["../../../src/features/chat/savedReply.ts"],"sourcesContent":["/**\n * Finding a turn's reply in the saved thread when its push never arrived.\n *\n * A turn's final reply reaches the phone once, as a subscription push. When the\n * phone is locked or the app is in the background, iOS suspends the socket, and\n * a reply pushed then is lost for good. The chat kept the turn running\n * (\"Connecting dots...\") minutes after the reply had been saved. The saved\n * thread is the record, so the round can be closed from it.\n */\n\n/** One row of the saved thread, oldest first, as `useChatMessages` returns it. */\nexport interface SavedThreadRow {\n id: string;\n role: 'user' | 'assistant' | 'system';\n content: string;\n}\n\n/** The ids of the rows a round could already see when it opened. */\nexport function seenRowIds(thread: readonly Pick<SavedThreadRow, 'id'>[]): ReadonlySet<string> {\n return new Set(thread.map((row) => row.id));\n}\n\n/**\n * The reply a round left in the saved thread: the newest assistant post after the\n * newest user post. It counts only if the round had not seen that post when it\n * opened. Until the server writes this turn's posts, the thread still ends with\n * the reply to the turn before, and that reply must not answer this one.\n * Returns null while the thread holds no such reply.\n */\nexport function savedReplyFor(thread: readonly SavedThreadRow[], seenIds: ReadonlySet<string>): string | null {\n for (let i = thread.length - 1; i >= 0; i -= 1) {\n const row = thread[i];\n if (row.role === 'user') return null;\n if (row.role === 'assistant' && row.content.trim()) return seenIds.has(row.id) ? null : row.content;\n }\n return null;\n}\n"],"names":[],"mappings":"AAkBO,SAAS,WAAW,MAAoE,EAAA;AAC7F,EAAA,OAAO,IAAI,GAAI,CAAA,MAAA,CAAO,IAAI,CAAO,GAAA,KAAA,GAAA,CAAI,EAAE,CAAC,CAAA;AAC1C;AASgB,SAAA,aAAA,CAAc,QAAmC,OAA6C,EAAA;AAC5G,EAAA,KAAA,IAAS,IAAI,MAAO,CAAA,MAAA,GAAS,GAAG,CAAK,IAAA,CAAA,EAAG,KAAK,CAAG,EAAA;AAC9C,IAAM,MAAA,GAAA,GAAM,OAAO,CAAC,CAAA;AACpB,IAAI,IAAA,GAAA,CAAI,IAAS,KAAA,MAAA,EAAe,OAAA,IAAA;AAChC,IAAA,IAAI,GAAI,CAAA,IAAA,KAAS,WAAe,IAAA,GAAA,CAAI,QAAQ,IAAK,EAAA,EAAU,OAAA,OAAA,CAAQ,GAAI,CAAA,GAAA,CAAI,EAAE,CAAA,GAAI,OAAO,GAAI,CAAA,OAAA;AAAA;AAE9F,EAAO,OAAA,IAAA;AACT"}
@@ -0,0 +1,93 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';import {StyleSheet,Pressable,View,Text}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {navigationRef}from'@common-stack/client-react';import {CommonActions}from'@react-navigation/native';import {registerMessageCard}from'../messaging/messageCards.js';import {parseInviteMessage}from'./gameInvite.js';const GAMES_ROUTE = "MainStack.GamesNative";
2
+ function openInvite(code) {
3
+ if (!navigationRef.isReady()) return;
4
+ navigationRef.dispatch(CommonActions.navigate({
5
+ name: GAMES_ROUTE,
6
+ params: {
7
+ cubeforgeInvite: code,
8
+ inviteAt: Date.now()
9
+ }
10
+ }));
11
+ }
12
+ function GameInviteCard({
13
+ invite,
14
+ context,
15
+ onJoin = openInvite
16
+ }) {
17
+ const {
18
+ accentColor,
19
+ metaColor,
20
+ textColor
21
+ } = context;
22
+ return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: `Join the Cubeforge world ${invite.worldName}`, onPress: () => onJoin(invite.code), style: ({
23
+ pressed
24
+ }) => [styles.card, pressed && styles.pressed], children: [
25
+ /* @__PURE__ */ jsxs(View, { style: styles.row, children: [
26
+ /* @__PURE__ */ jsx(View, { style: [styles.icon, {
27
+ backgroundColor: accentColor
28
+ }], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "cube-outline", size: 24, color: "#ffffff" }) }),
29
+ /* @__PURE__ */ jsxs(View, { style: styles.text, children: [
30
+ /* @__PURE__ */ jsx(Text, { style: [styles.kicker, {
31
+ color: metaColor
32
+ }], children: "Cubeforge world" }),
33
+ /* @__PURE__ */ jsx(Text, { style: [styles.title, {
34
+ color: textColor
35
+ }], numberOfLines: 2, children: invite.worldName })
36
+ ] })
37
+ ] }),
38
+ /* @__PURE__ */ jsx(View, { style: [styles.button, {
39
+ backgroundColor: accentColor
40
+ }], children: /* @__PURE__ */ jsx(Text, { style: styles.buttonLabel, children: "Join" }) })
41
+ ] });
42
+ }
43
+ function renderGameInviteCard(context) {
44
+ const invite = parseInviteMessage(context.body);
45
+ return invite ? /* @__PURE__ */ jsx(GameInviteCard, { invite, context }) : null;
46
+ }
47
+ function registerGameInviteCard() {
48
+ return registerMessageCard(renderGameInviteCard);
49
+ }
50
+ const styles = StyleSheet.create({
51
+ card: {
52
+ minWidth: 220,
53
+ gap: 10,
54
+ paddingTop: 2,
55
+ paddingBottom: 2
56
+ },
57
+ pressed: {
58
+ opacity: 0.85
59
+ },
60
+ row: {
61
+ flexDirection: "row",
62
+ alignItems: "center",
63
+ gap: 10
64
+ },
65
+ icon: {
66
+ width: 44,
67
+ height: 44,
68
+ borderRadius: 10,
69
+ alignItems: "center",
70
+ justifyContent: "center"
71
+ },
72
+ text: {
73
+ flexShrink: 1
74
+ },
75
+ kicker: {
76
+ fontSize: 12
77
+ },
78
+ title: {
79
+ fontSize: 16,
80
+ fontWeight: "600"
81
+ },
82
+ button: {
83
+ minHeight: 44,
84
+ borderRadius: 10,
85
+ alignItems: "center",
86
+ justifyContent: "center"
87
+ },
88
+ buttonLabel: {
89
+ color: "#ffffff",
90
+ fontSize: 15,
91
+ fontWeight: "600"
92
+ }
93
+ });export{GameInviteCard,registerGameInviteCard,renderGameInviteCard};//# sourceMappingURL=GameInviteCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameInviteCard.js","sources":["../../../src/features/games/GameInviteCard.tsx"],"sourcesContent":["/**\n * The join card for a Cubeforge invite in chat. Tapping it opens the shared\n * world on the Games screen.\n */\nimport * as React from 'react';\nimport { Pressable, StyleSheet, Text, View } from 'react-native';\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport { navigationRef } from '@common-stack/client-react';\nimport { CommonActions } from '@react-navigation/native';\nimport { registerMessageCard, type MessageCardContext } from '../messaging/messageCards';\nimport { parseInviteMessage, type GameInvite } from './gameInvite';\n\nconst GAMES_ROUTE = 'MainStack.GamesNative';\n\nfunction openInvite(code: string): void {\n if (!navigationRef.isReady()) return;\n navigationRef.dispatch(\n CommonActions.navigate({ name: GAMES_ROUTE, params: { cubeforgeInvite: code, inviteAt: Date.now() } }),\n );\n}\n\nexport function GameInviteCard({\n invite,\n context,\n onJoin = openInvite,\n}: {\n invite: GameInvite;\n context: MessageCardContext;\n onJoin?: (code: string) => void;\n}) {\n const { accentColor, metaColor, textColor } = context;\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={`Join the Cubeforge world ${invite.worldName}`}\n onPress={() => onJoin(invite.code)}\n style={({ pressed }) => [styles.card, pressed && styles.pressed]}\n >\n <View style={styles.row}>\n <View style={[styles.icon, { backgroundColor: accentColor }]}>\n <MaterialCommunityIcons name=\"cube-outline\" size={24} color=\"#ffffff\" />\n </View>\n <View style={styles.text}>\n <Text style={[styles.kicker, { color: metaColor }]}>Cubeforge world</Text>\n <Text style={[styles.title, { color: textColor }]} numberOfLines={2}>\n {invite.worldName}\n </Text>\n </View>\n </View>\n <View style={[styles.button, { backgroundColor: accentColor }]}>\n <Text style={styles.buttonLabel}>Join</Text>\n </View>\n </Pressable>\n );\n}\n\nexport function renderGameInviteCard(context: MessageCardContext): React.ReactNode | null {\n const invite = parseInviteMessage(context.body);\n return invite ? <GameInviteCard invite={invite} context={context} /> : null;\n}\n\nexport function registerGameInviteCard(): () => void {\n return registerMessageCard(renderGameInviteCard);\n}\n\nconst styles = StyleSheet.create({\n card: { minWidth: 220, gap: 10, paddingTop: 2, paddingBottom: 2 },\n pressed: { opacity: 0.85 },\n row: { flexDirection: 'row', alignItems: 'center', gap: 10 },\n icon: { width: 44, height: 44, borderRadius: 10, alignItems: 'center', justifyContent: 'center' },\n text: { flexShrink: 1 },\n kicker: { fontSize: 12 },\n title: { fontSize: 16, fontWeight: '600' },\n button: { minHeight: 44, borderRadius: 10, alignItems: 'center', justifyContent: 'center' },\n buttonLabel: { color: '#ffffff', fontSize: 15, fontWeight: '600' },\n});\n"],"names":[],"mappings":"uXAWA,MAAM,WAAc,GAAA,uBAAA;AACpB,SAAS,WAAW,IAAoB,EAAA;AACtC,EAAI,IAAA,CAAC,aAAc,CAAA,OAAA,EAAW,EAAA;AAC9B,EAAc,aAAA,CAAA,QAAA,CAAS,cAAc,QAAS,CAAA;AAAA,IAC5C,IAAM,EAAA,WAAA;AAAA,IACN,MAAQ,EAAA;AAAA,MACN,eAAiB,EAAA,IAAA;AAAA,MACjB,QAAA,EAAU,KAAK,GAAI;AAAA;AACrB,GACD,CAAC,CAAA;AACJ;AACO,SAAS,cAAe,CAAA;AAAA,EAC7B,MAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAS,GAAA;AACX,CAIG,EAAA;AACD,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACE,GAAA,OAAA;AACJ,EAAA,4BAAQ,SAAU,EAAA,EAAA,iBAAA,EAAkB,QAAS,EAAA,kBAAA,EAAoB,4BAA4B,MAAO,CAAA,SAAS,CAAI,CAAA,EAAA,OAAA,EAAS,MAAM,MAAO,CAAA,MAAA,CAAO,IAAI,CAAA,EAAG,OAAO,CAAC;AAAA,IAC3J;AAAA,QACI,CAAC,MAAA,CAAO,MAAM,OAAW,IAAA,MAAA,CAAO,OAAO,CACnC,EAAA,QAAA,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AA,EAAgB,SAAkB,CAAK,GAAA,IAAA;AACzE;AACO,SAAS,sBAAqC,GAAA;AACnD,EAAA,OAAO,oBAAoB,oBAAoB,CAAA;AACjD;AACA,MAAM,MAAA,GAAS,WAAW,MAAO,CAAA;AAAA,EAC/B,IAAM,EAAA;AAAA,IACJ,QAAU,EAAA,GAAA;AAAA,IACV,GAAK,EAAA,EAAA;AAAA,IACL,UAAY,EAAA,CAAA;AAAA,IACZ,aAAe,EAAA;AAAA,GACjB;AAAA,EACA,OAAS,EAAA;AAAA,IACP,OAAS,EAAA;AAAA,GACX;AAAA,EACA,GAAK,EAAA;AAAA,IACH,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,GAAK,EAAA;AAAA,GACP;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,KAAO,EAAA,EAAA;AAAA,IACP,MAAQ,EAAA,EAAA;AAAA,IACR,YAAc,EAAA,EAAA;AAAA,IACd,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,UAAY,EAAA;AAAA,GACd;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,SAAW,EAAA,EAAA;AAAA,IACX,YAAc,EAAA,EAAA;AAAA,IACd,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,WAAa,EAAA;AAAA,IACX,KAAO,EAAA,SAAA;AAAA,IACP,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
@@ -1,4 +1,32 @@
1
- import {jsx}from'react/jsx-runtime';import {Platform,StyleSheet}from'react-native';import {requireOptionalNativeModule,requireNativeViewManager}from'expo-modules-core';import {SafeAreaView}from'react-native-safe-area-context';let cached;
1
+ import {jsxs,jsx}from'react/jsx-runtime';import*as React from'react';import {Platform,StyleSheet,Modal,KeyboardAvoidingView,Pressable,View,TextInput,Text}from'react-native';import {requireOptionalNativeModule,requireNativeViewManager}from'expo-modules-core';import {SafeAreaView}from'react-native-safe-area-context';const MAX_CHAT_CHARS = 200;
2
+ const nativeModule = () => Platform.OS === "ios" ? requireOptionalNativeModule("YantraCubeforge") : null;
3
+ function cubeforgeFriendsSupported() {
4
+ var _a;
5
+ return typeof ((_a = nativeModule()) == null ? void 0 : _a.deleteWorld) === "function";
6
+ }
7
+ function deleteCubeforgeSave(worldKey) {
8
+ var _a, _b;
9
+ (_b = (_a = nativeModule()) == null ? void 0 : _a.deleteWorld) == null ? void 0 : _b.call(_a, worldKey);
10
+ }
11
+ function ChatBar({
12
+ onSend,
13
+ onClose
14
+ }) {
15
+ const [draft, setDraft] = React.useState("");
16
+ const send = () => {
17
+ const text = draft.trim();
18
+ if (text) onSend(text);
19
+ onClose();
20
+ };
21
+ return /* @__PURE__ */ jsx(Modal, { transparent: true, visible: true, animationType: "fade", onRequestClose: onClose, children: /* @__PURE__ */ jsxs(KeyboardAvoidingView, { behavior: "padding", style: styles.fillClear, children: [
22
+ /* @__PURE__ */ jsx(Pressable, { accessibilityLabel: "Close chat", style: styles.fillClear, onPress: onClose }),
23
+ /* @__PURE__ */ jsxs(View, { style: styles.chatBar, children: [
24
+ /* @__PURE__ */ jsx(TextInput, { autoFocus: true, value: draft, onChangeText: setDraft, onSubmitEditing: send, maxLength: MAX_CHAT_CHARS, placeholder: "Message everyone here", placeholderTextColor: "#94a3b8", returnKeyType: "send", style: styles.chatInput }),
25
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Send", onPress: send, style: styles.chatSend, children: /* @__PURE__ */ jsx(Text, { style: styles.chatSendLabel, children: "Send" }) })
26
+ ] })
27
+ ] }) });
28
+ }
29
+ let cached;
2
30
  function cubeforge3DComponent() {
3
31
  if (cached !== void 0) return cached;
4
32
  cached = null;
@@ -9,9 +37,20 @@ function cubeforge3DComponent() {
9
37
  cached = function Cubeforge3D({
10
38
  seed,
11
39
  worldKey,
12
- onExit
40
+ room,
41
+ onExit,
42
+ onRoomClosed,
43
+ onTokenExpired
13
44
  }) {
14
- return /* @__PURE__ */ jsx(SafeAreaView, { edges: ["bottom", "left", "right"], style: styles.fill, children: /* @__PURE__ */ jsx(NativeCubeforge, { style: styles.fill, seed, worldKey, onExit }) });
45
+ const engine = React.useRef(null);
46
+ const [chatting, setChatting] = React.useState(false);
47
+ return /* @__PURE__ */ jsxs(SafeAreaView, { edges: ["bottom", "left", "right"], style: styles.fill, children: [
48
+ /* @__PURE__ */ jsx(NativeCubeforge, { ref: engine, style: styles.fill, seed, worldKey, room, onExit, onOpenChat: () => setChatting(true), onRoomClosed: () => onRoomClosed == null ? void 0 : onRoomClosed(), onTokenExpired: () => onTokenExpired == null ? void 0 : onTokenExpired() }),
49
+ chatting ? /* @__PURE__ */ jsx(ChatBar, { onSend: (text) => {
50
+ var _a;
51
+ (_a = engine.current) == null ? void 0 : _a.sendChat(text).catch(() => void 0);
52
+ }, onClose: () => setChatting(false) }) : null
53
+ ] });
15
54
  };
16
55
  } catch (e) {
17
56
  cached = null;
@@ -22,5 +61,37 @@ const styles = StyleSheet.create({
22
61
  fill: {
23
62
  flex: 1,
24
63
  backgroundColor: "#000"
64
+ },
65
+ fillClear: {
66
+ flex: 1
67
+ },
68
+ chatBar: {
69
+ flexDirection: "row",
70
+ alignItems: "center",
71
+ gap: 8,
72
+ padding: 10,
73
+ backgroundColor: "#12161b"
74
+ },
75
+ chatInput: {
76
+ flex: 1,
77
+ minHeight: 44,
78
+ borderRadius: 10,
79
+ paddingHorizontal: 12,
80
+ color: "#f1f5f9",
81
+ backgroundColor: "#242b33",
82
+ fontSize: 16
83
+ },
84
+ chatSend: {
85
+ minHeight: 44,
86
+ minWidth: 64,
87
+ borderRadius: 10,
88
+ alignItems: "center",
89
+ justifyContent: "center",
90
+ backgroundColor: "#3f7fbf"
91
+ },
92
+ chatSendLabel: {
93
+ color: "#ffffff",
94
+ fontSize: 15,
95
+ fontWeight: "600"
25
96
  }
26
- });export{cubeforge3DComponent};//# sourceMappingURL=cubeforge3D.js.map
97
+ });export{cubeforge3DComponent,cubeforgeFriendsSupported,deleteCubeforgeSave};//# sourceMappingURL=cubeforge3D.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cubeforge3D.js","sources":["../../../src/features/games/cubeforge3D.tsx"],"sourcesContent":["/**\n * Cubeforge 3D: the native Rust + Metal engine (portable-devices/mobile/modules/\n * yantra-cubeforge, iOS only) as the `cubeforge3D` component Yantra Games shows\n * behind \"Play in 3D\".\n *\n * Optional on purpose: an over-the-air JS update can reach a binary built\n * before the module existed, and Android has none. Both read as \"no module\",\n * and Yantra Games then simply hides \"Play in 3D\".\n */\nimport * as React from 'react';\nimport { Platform, StyleSheet, type ViewProps } from 'react-native';\nimport { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modules-core';\nimport { SafeAreaView } from 'react-native-safe-area-context';\nimport type { Cubeforge3DProps } from './vendored';\n\ninterface NativeCubeforgeProps extends ViewProps {\n seed: number;\n worldKey: string;\n onExit: () => void;\n}\n\nlet cached: React.ComponentType<Cubeforge3DProps> | null | undefined;\n\n/** The 3D component when this binary ships the engine, otherwise null. */\nexport function cubeforge3DComponent(): React.ComponentType<Cubeforge3DProps> | null {\n if (cached !== undefined) return cached;\n cached = null;\n if (Platform.OS !== 'ios') return cached;\n try {\n if (!requireOptionalNativeModule('YantraCubeforge')) return cached;\n const NativeCubeforge = requireNativeViewManager<NativeCubeforgeProps>('YantraCubeforge');\n cached = function Cubeforge3D({ seed, worldKey, onExit }: Cubeforge3DProps) {\n // The engine draws edge to edge; keep its HUD clear of the home indicator.\n return (\n <SafeAreaView edges={['bottom', 'left', 'right']} style={styles.fill}>\n <NativeCubeforge style={styles.fill} seed={seed} worldKey={worldKey} onExit={onExit} />\n </SafeAreaView>\n );\n };\n } catch {\n cached = null;\n }\n return cached;\n}\n\nconst styles = StyleSheet.create({\n fill: { flex: 1, backgroundColor: '#000' },\n});\n"],"names":[],"mappings":"kOAmBA,IAAI,MAAA;AAGG,SAAS,oBAAqE,GAAA;AACnF,EAAI,IAAA,MAAA,KAAW,QAAkB,OAAA,MAAA;AACjC,EAAS,MAAA,GAAA,IAAA;AACT,EAAI,IAAA,QAAA,CAAS,EAAO,KAAA,KAAA,EAAc,OAAA,MAAA;AAClC,EAAI,IAAA;AACF,IAAA,IAAI,CAAC,2BAAA,CAA4B,iBAAiB,CAAA,EAAU,OAAA,MAAA;AAC5D,IAAM,MAAA,eAAA,GAAkB,yBAA+C,iBAAiB,CAAA;AACxF,IAAA,MAAA,GAAS,SAAS,WAAY,CAAA;AAAA,MAC5B,IAAA;AAAA,MACA,QAAA;AAAA,MACA;AAAA,KACmB,EAAA;AAEnB,MAAA,2BAAQ,YAAa,EAAA,EAAA,KAAA,EAAO,CAAC,QAAU,EAAA,MAAA,EAAQ,OAAO,CAAG,EAAA,KAAA,EAAO,OAAO,IACzD,EAAA,QAAA,kBAAA,GAAA,CAAC,mBAAgB,KAAO,EAAA,MAAA,CAAO,MAAM,IAAY,EAAA,QAAA,EAAoB,QAAgB,CACzF,EAAA,CAAA;AAAA,KACZ;AAAA,GACM,CAAA,OAAA,CAAA,EAAA;AACN,IAAS,MAAA,GAAA,IAAA;AAAA;AAEX,EAAO,OAAA,MAAA;AACT;AACA,MAAM,MAAA,GAAS,WAAW,MAAO,CAAA;AAAA,EAC/B,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,CAAA;AAAA,IACN,eAAiB,EAAA;AAAA;AAErB,CAAC,CAAA"}
1
+ {"version":3,"file":"cubeforge3D.js","sources":["../../../src/features/games/cubeforge3D.tsx"],"sourcesContent":["/**\n * Cubeforge 3D: the native Rust + Metal engine (portable-devices/mobile/modules/\n * yantra-cubeforge, iOS only) as the `cubeforge3D` component Yantra Games shows\n * behind \"Play in 3D\".\n *\n * Optional on purpose: an over-the-air JS update can reach a binary built\n * before the module existed, and Android has none. Both read as \"no module\",\n * and Yantra Games then simply hides \"Play in 3D\".\n */\nimport * as React from 'react';\nimport {\n KeyboardAvoidingView,\n Modal,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n View,\n type ViewProps,\n} from 'react-native';\nimport { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modules-core';\nimport { SafeAreaView } from 'react-native-safe-area-context';\nimport type { Cubeforge3DProps } from './vendored';\n\ninterface NativeCubeforgeProps extends ViewProps {\n seed: number;\n worldKey: string;\n room?: Cubeforge3DProps['room'];\n onExit: () => void;\n onOpenChat: () => void;\n onRoomClosed: () => void;\n onTokenExpired: () => void;\n}\n\ninterface NativeCubeforgeHandle {\n sendChat: (text: string) => Promise<boolean>;\n}\n\ntype NativeCubeforgeView = React.ComponentType<NativeCubeforgeProps & React.RefAttributes<NativeCubeforgeHandle>>;\n\ninterface NativeCubeforgeModule {\n deleteWorld?: (worldKey: string) => void;\n}\n\nconst MAX_CHAT_CHARS = 200;\n\nconst nativeModule = (): NativeCubeforgeModule | null =>\n Platform.OS === 'ios' ? requireOptionalNativeModule<NativeCubeforgeModule>('YantraCubeforge') : null;\n\n/** Whether this binary's engine can join shared worlds. Older ones cannot. */\nexport function cubeforgeFriendsSupported(): boolean {\n return typeof nativeModule()?.deleteWorld === 'function';\n}\n\n/** Remove a 3D world's save from this device. */\nexport function deleteCubeforgeSave(worldKey: string): void {\n nativeModule()?.deleteWorld?.(worldKey);\n}\n\nfunction ChatBar({ onSend, onClose }: { onSend: (text: string) => void; onClose: () => void }) {\n const [draft, setDraft] = React.useState('');\n const send = () => {\n const text = draft.trim();\n if (text) onSend(text);\n onClose();\n };\n return (\n <Modal transparent visible animationType=\"fade\" onRequestClose={onClose}>\n <KeyboardAvoidingView behavior=\"padding\" style={styles.fillClear}>\n <Pressable accessibilityLabel=\"Close chat\" style={styles.fillClear} onPress={onClose} />\n <View style={styles.chatBar}>\n <TextInput\n autoFocus\n value={draft}\n onChangeText={setDraft}\n onSubmitEditing={send}\n maxLength={MAX_CHAT_CHARS}\n placeholder=\"Message everyone here\"\n placeholderTextColor=\"#94a3b8\"\n returnKeyType=\"send\"\n style={styles.chatInput}\n />\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Send\"\n onPress={send}\n style={styles.chatSend}\n >\n <Text style={styles.chatSendLabel}>Send</Text>\n </Pressable>\n </View>\n </KeyboardAvoidingView>\n </Modal>\n );\n}\n\nlet cached: React.ComponentType<Cubeforge3DProps> | null | undefined;\n\n/** The 3D component when this binary ships the engine, otherwise null. */\nexport function cubeforge3DComponent(): React.ComponentType<Cubeforge3DProps> | null {\n if (cached !== undefined) return cached;\n cached = null;\n if (Platform.OS !== 'ios') return cached;\n try {\n if (!requireOptionalNativeModule('YantraCubeforge')) return cached;\n const NativeCubeforge = requireNativeViewManager<NativeCubeforgeProps>(\n 'YantraCubeforge',\n ) as unknown as NativeCubeforgeView;\n cached = function Cubeforge3D({\n seed,\n worldKey,\n room,\n onExit,\n onRoomClosed,\n onTokenExpired,\n }: Cubeforge3DProps) {\n const engine = React.useRef<NativeCubeforgeHandle>(null);\n const [chatting, setChatting] = React.useState(false);\n // The engine draws edge to edge; keep its HUD clear of the home indicator.\n return (\n <SafeAreaView edges={['bottom', 'left', 'right']} style={styles.fill}>\n <NativeCubeforge\n ref={engine}\n style={styles.fill}\n seed={seed}\n worldKey={worldKey}\n room={room}\n onExit={onExit}\n onOpenChat={() => setChatting(true)}\n onRoomClosed={() => onRoomClosed?.()}\n onTokenExpired={() => onTokenExpired?.()}\n />\n {chatting ? (\n <ChatBar\n onSend={(text) => {\n engine.current?.sendChat(text).catch(() => undefined);\n }}\n onClose={() => setChatting(false)}\n />\n ) : null}\n </SafeAreaView>\n );\n };\n } catch {\n cached = null;\n }\n return cached;\n}\n\nconst styles = StyleSheet.create({\n fill: { flex: 1, backgroundColor: '#000' },\n fillClear: { flex: 1 },\n chatBar: { flexDirection: 'row', alignItems: 'center', gap: 8, padding: 10, backgroundColor: '#12161b' },\n chatInput: {\n flex: 1,\n minHeight: 44,\n borderRadius: 10,\n paddingHorizontal: 12,\n color: '#f1f5f9',\n backgroundColor: '#242b33',\n fontSize: 16,\n },\n chatSend: {\n minHeight: 44,\n minWidth: 64,\n borderRadius: 10,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: '#3f7fbf',\n },\n chatSendLabel: { color: '#ffffff', fontSize: 15, fontWeight: '600' },\n});\n"],"names":[],"mappings":"4TA8BA,MAAM,cAAiB,GAAA,GAAA;AACvB,MAAM,eAAe,MAAoC,QAAA,CAAS,OAAO,KAAQ,GAAA,2BAAA,CAAmD,iBAAiB,CAAI,GAAA,IAAA;AAGlJ,SAAS,yBAAqC,GAAA;AAlCrD,EAAA,IAAA,EAAA;AAmCE,EAAA,OAAO,QAAO,CAAA,EAAA,GAAA,YAAA,EAAA,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAgB,WAAgB,CAAA,KAAA,UAAA;AAChD;AAGO,SAAS,oBAAoB,QAAwB,EAAA;AAvC5D,EAAA,IAAA,EAAA,EAAA,EAAA;AAwCE,EAAa,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,YAAA,EAAA,KAAb,IAAgB,GAAA,MAAA,GAAA,EAAA,CAAA,WAAA,KAAhB,IAA8B,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAA,EAAA,EAAA,QAAA,CAAA;AAChC;AACA,SAAS,OAAQ,CAAA;AAAA,EACf,MAAA;AAAA,EACA;AACF,CAGG,EAAA;AACD,EAAA,MAAM,CAAC,KAAO,EAAA,QAAQ,CAAI,GAAA,KAAA,CAAM,SAAS,EAAE,CAAA;AAC3C,EAAA,MAAM,OAAO,MAAM;AACjB,IAAM,MAAA,IAAA,GAAO,MAAM,IAAK,EAAA;AACxB,IAAI,IAAA,IAAA,SAAa,IAAI,C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