@vinaverse/react-native 0.1.0-alpha.6 → 0.1.0-alpha.8

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 (47) hide show
  1. package/README.md +36 -17
  2. package/dist/ask.cjs +9 -5
  3. package/dist/ask.d.cts +16 -3
  4. package/dist/ask.d.ts +16 -3
  5. package/dist/ask.js +3 -3
  6. package/dist/chat.cjs +76 -73
  7. package/dist/chat.d.cts +31 -8
  8. package/dist/chat.d.ts +31 -8
  9. package/dist/chat.js +2 -3
  10. package/dist/{chunk-OWUKWVEZ.cjs → chunk-6QYDPGRS.cjs} +46 -2
  11. package/dist/chunk-6QYDPGRS.cjs.map +1 -0
  12. package/dist/{chunk-Y7P7DDHD.js → chunk-7KPCO443.js} +13 -12
  13. package/dist/chunk-7KPCO443.js.map +1 -0
  14. package/dist/chunk-EFEXTVIT.js +88 -0
  15. package/dist/chunk-EFEXTVIT.js.map +1 -0
  16. package/dist/{chunk-H2Y2YW2Q.cjs → chunk-EXN5TNLU.cjs} +85 -80
  17. package/dist/chunk-EXN5TNLU.cjs.map +1 -0
  18. package/dist/{chunk-OGPMGGYS.cjs → chunk-MG32E4JI.cjs} +20 -13
  19. package/dist/chunk-MG32E4JI.cjs.map +1 -0
  20. package/dist/{chunk-643GOUTG.cjs → chunk-NMKJ7LIJ.cjs} +14 -13
  21. package/dist/chunk-NMKJ7LIJ.cjs.map +1 -0
  22. package/dist/{chunk-SF6LJTVJ.js → chunk-NXGLI4Y7.js} +39 -38
  23. package/dist/chunk-NXGLI4Y7.js.map +1 -0
  24. package/dist/{chunk-NJWRZ55G.js → chunk-POJP52GE.js} +16 -9
  25. package/dist/chunk-POJP52GE.js.map +1 -0
  26. package/dist/index.cjs +86 -83
  27. package/dist/index.d.cts +3 -3
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.js +4 -5
  30. package/dist/launcher.cjs +14 -11
  31. package/dist/launcher.d.cts +4 -3
  32. package/dist/launcher.d.ts +4 -3
  33. package/dist/launcher.js +3 -4
  34. package/package.json +22 -5
  35. package/dist/chunk-643GOUTG.cjs.map +0 -1
  36. package/dist/chunk-H2Y2YW2Q.cjs.map +0 -1
  37. package/dist/chunk-NJWRZ55G.js.map +0 -1
  38. package/dist/chunk-OGPMGGYS.cjs.map +0 -1
  39. package/dist/chunk-OWUKWVEZ.cjs.map +0 -1
  40. package/dist/chunk-PRXHS57U.js +0 -40
  41. package/dist/chunk-PRXHS57U.js.map +0 -1
  42. package/dist/chunk-PYPO6F7L.cjs +0 -44
  43. package/dist/chunk-PYPO6F7L.cjs.map +0 -1
  44. package/dist/chunk-SF6LJTVJ.js.map +0 -1
  45. package/dist/chunk-WKRCCPSN.js +0 -48
  46. package/dist/chunk-WKRCCPSN.js.map +0 -1
  47. package/dist/chunk-Y7P7DDHD.js.map +0 -1
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkPYPO6F7L_cjs = require('./chunk-PYPO6F7L.cjs');
4
- var chunkOWUKWVEZ_cjs = require('./chunk-OWUKWVEZ.cjs');
3
+ var chunk6QYDPGRS_cjs = require('./chunk-6QYDPGRS.cjs');
5
4
  var react = require('@vinaverse/react');
6
5
  var agent = require('@vinaverse/react/agent');
7
6
  var react$1 = require('react');
@@ -10,13 +9,20 @@ var jsxRuntime = require('react/jsx-runtime');
10
9
 
11
10
  var LAUNCHER_SIZE = 56;
12
11
  function AgentLauncher(props) {
13
- return /* @__PURE__ */ jsxRuntime.jsx(react.CopyProvider, { locale: props.locale, copy: props.copy, children: /* @__PURE__ */ jsxRuntime.jsx(chunkOWUKWVEZ_cjs.ThemeProvider, { theme: props.theme, colorScheme: props.colorScheme, children: /* @__PURE__ */ jsxRuntime.jsx(Launcher, { ...props }) }) });
12
+ return /* @__PURE__ */ jsxRuntime.jsx(react.CopyProvider, { locale: props.locale, copy: props.copy, children: /* @__PURE__ */ jsxRuntime.jsx(chunk6QYDPGRS_cjs.ThemeProvider, { theme: props.theme, colorScheme: props.colorScheme, children: /* @__PURE__ */ jsxRuntime.jsx(Launcher, { ...props }) }) });
14
13
  }
15
14
  function useKeyboardShown() {
16
15
  const [shown, setShown] = react$1.useState(false);
17
16
  react$1.useEffect(() => {
18
- const show = reactNative.Keyboard.addListener("keyboardDidShow", () => setShown(true));
19
- const hide = reactNative.Keyboard.addListener("keyboardDidHide", () => setShown(false));
17
+ const ios = reactNative.Platform.OS === "ios";
18
+ const show = reactNative.Keyboard.addListener(
19
+ ios ? "keyboardWillShow" : "keyboardDidShow",
20
+ () => setShown(true)
21
+ );
22
+ const hide = reactNative.Keyboard.addListener(
23
+ ios ? "keyboardWillHide" : "keyboardDidHide",
24
+ () => setShown(false)
25
+ );
20
26
  return () => {
21
27
  show.remove();
22
28
  hide.remove();
@@ -28,20 +34,21 @@ function Launcher(props) {
28
34
  const { t } = react.useCopy();
29
35
  const name = agent.useAgentName(t("agentFallbackName"));
30
36
  const keyboard = useKeyboardShown();
31
- const reducedMotion = chunkPYPO6F7L_cjs.useReducedMotion();
37
+ const reducedMotion = chunk6QYDPGRS_cjs.useReducedMotion();
38
+ chunk6QYDPGRS_cjs.useAgentSweep(agent.useAgentRuntime());
32
39
  const { route = null, routes, mode } = props;
33
40
  const visible = props.hidden !== true && !(keyboard && props.hideWithKeyboard !== false) && (!routes || route !== null && routes.includes(route));
34
41
  const launcher = agent.useAgentLauncher({
35
42
  subject: props.subject,
36
43
  mode,
37
44
  visible,
38
- onOpen: () => props.onOpen({ route, mode }),
45
+ onOpen: () => props.onOpen({ route, mode, entryPoint: "launcher" }),
39
46
  ...props.storage ? { storage: props.storage } : {},
40
47
  ...props.storageKey ? { storageKey: props.storageKey } : {},
41
48
  ...props.delayMs === void 0 ? {} : { delayMs: props.delayMs }
42
49
  });
43
50
  const text = typeof props.greeting === "function" ? props.greeting(mode) : props.greeting ?? t("launcherGreeting", { agent: name });
44
- const say = props.announce ?? chunkPYPO6F7L_cjs.announce;
51
+ const say = props.announce ?? chunk6QYDPGRS_cjs.announce;
45
52
  const said = react$1.useRef(false);
46
53
  react$1.useEffect(() => {
47
54
  if (!launcher.greets) {
@@ -110,7 +117,7 @@ function Launcher(props) {
110
117
  );
111
118
  }
112
119
  function LauncherEntrance(props) {
113
- const { motion } = chunkOWUKWVEZ_cjs.useTheme();
120
+ const { motion } = chunk6QYDPGRS_cjs.useTheme();
114
121
  const shown = react$1.useRef(new reactNative.Animated.Value(props.reducedMotion ? 1 : 0)).current;
115
122
  react$1.useEffect(() => {
116
123
  if (props.reducedMotion) {
@@ -146,7 +153,7 @@ function LauncherEntrance(props) {
146
153
  );
147
154
  }
148
155
  function LauncherGreeting(props) {
149
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
156
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
150
157
  return /* @__PURE__ */ jsxRuntime.jsxs(
151
158
  reactNative.View,
152
159
  {
@@ -210,7 +217,7 @@ function LauncherGreeting(props) {
210
217
  );
211
218
  }
212
219
  function LauncherButton(props) {
213
- const { colors, font } = chunkOWUKWVEZ_cjs.useTheme();
220
+ const { colors, font } = chunk6QYDPGRS_cjs.useTheme();
214
221
  const { Mark, ring } = props;
215
222
  return /* @__PURE__ */ jsxRuntime.jsx(
216
223
  reactNative.Pressable,
@@ -257,5 +264,5 @@ exports.LauncherButton = LauncherButton;
257
264
  exports.LauncherEntrance = LauncherEntrance;
258
265
  exports.LauncherGreeting = LauncherGreeting;
259
266
  exports.useKeyboardShown = useKeyboardShown;
260
- //# sourceMappingURL=chunk-OGPMGGYS.cjs.map
261
- //# sourceMappingURL=chunk-OGPMGGYS.cjs.map
267
+ //# sourceMappingURL=chunk-MG32E4JI.cjs.map
268
+ //# sourceMappingURL=chunk-MG32E4JI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/AgentLauncher.tsx"],"names":["jsx","CopyProvider","ThemeProvider","useState","useEffect","Platform","Keyboard","useCopy","useAgentName","useReducedMotion","useAgentSweep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AAK,OAAO,WAAA,EAAa,IAAA,CAAK,KAAA,EAAM,GAAI,EAAC;AAAA,QACnE,GAAI,MAAM,MAAA,GACN;AAAA,UACE,SAAA,EAAW,CAAA;AAAA,UACX,WAAA,EAAa,MAAA;AAAA,UACb,aAAA,EAAe,GAAA;AAAA,UACf,YAAA,EAAc,CAAA;AAAA,UACd,YAAA,EAAc,EAAE,KAAA,EAAO,CAAA,EAAG,QAAQ,CAAA;AAAE,YAEtC;AAAC,OACP,CAAA;AAAA,MACA,MAAA,EAAO,2BAAA;AAAA,MAEN,QAAA,EAAA,IAAA,kCACE,IAAA,EAAA,EAAK,IAAA,EAAM,IAAI,KAAA,EAAO,MAAA,CAAO,WAAW,CAAA,mBAEzCnB,cAAA;AAAA,QAACoB,gBAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAO;AAAA,YACL,OAAO,MAAA,CAAO,SAAA;AAAA,YACd,QAAA,EAAU,KAAK,IAAA,CAAK,EAAA;AAAA,YACpB,UAAA,EAAY;AAAA,WACd;AAAA,UAEE,iBAAM,IAAA,CAAK,IAAA,GAAO,CAAC,CAAA,IAAK,KAAK,WAAA;AAAY;AAAA;AAC7C;AAAA,GAEJ;AAEJ","file":"chunk-MG32E4JI.cjs","sourcesContent":["// The agent's floating launcher: a round button over the app's screens and, once per person and mode, a greeting\n// bubble above it, read to screen readers as it appears. Where it shows is a policy: the routes the app allows, never\n// with the keyboard up, never while the app says it should step aside (a sheet, a map). The app places it (`placement`,\n// `style`), gives its brand mark (`Mark`), sets its ring, shadow and the bubble's tail (`appearance`), and can replace\n// the button, the bubble and how they come in (slots, each given the kit's own part; no motion when reduced).\nimport { type CopyOverrides, CopyProvider, useCopy } from '@vinaverse/react';\nimport {\n type GreetingStorage,\n useAgentLauncher,\n useAgentName,\n useAgentRuntime,\n} from '@vinaverse/react/agent';\nimport {\n type ComponentType,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport {\n Animated,\n Keyboard,\n Platform,\n Pressable,\n type StyleProp,\n Text,\n View,\n type ViewStyle,\n} from 'react-native';\nimport {\n announce as platformAnnounce,\n useAgentSweep,\n useReducedMotion,\n} from '../platform.js';\nimport {\n type ColorSchemeSetting,\n type ThemeOverrides,\n ThemeProvider,\n useTheme,\n} from '../theme.js';\n\n/** The launcher's button side, in dp. */\nexport const LAUNCHER_SIZE = 56;\n\n/** The launcher's look: a ring around the button, its shadow, the bubble's tail toward it. */\nexport interface LauncherAppearance {\n /** Default none. */\n readonly ring?: { readonly color: string; readonly width: number } | null;\n /** Default true. */\n readonly shadow?: boolean;\n /** Default true. */\n readonly tail?: boolean;\n}\n\n/** Where it floats: the screen's edge, its distance from the bottom (above a tab bar) and from the side. */\nexport interface LauncherPlacement {\n /** Default `right`. */\n readonly edge?: 'left' | 'right';\n /** Default 16. */\n readonly bottom?: number;\n /** Default 16. */\n readonly inset?: number;\n}\n\nexport interface LauncherButtonProps {\n readonly label: string;\n readonly name: string;\n readonly onPress: () => void;\n readonly Mark:\n | ComponentType<{ readonly size: number; readonly color: string }>\n | undefined;\n readonly ring: { readonly color: string; readonly width: number } | null;\n readonly shadow: boolean;\n}\nexport interface LauncherGreetingProps {\n readonly text: string;\n readonly closeLabel: string;\n readonly onOpen: () => void;\n readonly onClose: () => void;\n readonly tail: boolean;\n readonly edge: 'left' | 'right';\n}\n/** How the button and the bubble come in; `reducedMotion` when the person asked for none. */\nexport interface LauncherEntranceProps {\n readonly part: 'button' | 'greeting';\n readonly reducedMotion: boolean;\n readonly children: ReactNode;\n}\ntype Slot<P> = ComponentType<P & { readonly Default: ComponentType<P> }>;\n\n/** Where the person opened the agent from: the app's route, the mode, and `entryPoint` to give the chat. */\nexport interface LauncherContext {\n readonly route: string | null;\n readonly mode: string;\n readonly entryPoint: 'launcher';\n}\n\nexport interface AgentLauncherProps {\n readonly subject: string | null;\n readonly mode: string;\n readonly onOpen: (from: LauncherContext) => void;\n /** The app's current route; with `routes`, the launcher shows only on those. */\n readonly route?: string | null;\n readonly routes?: readonly string[];\n /** The app says step aside (a sheet is up, a map with its own cards…). */\n readonly hidden?: boolean;\n /** Hidden while the keyboard is up. Default true. */\n readonly hideWithKeyboard?: boolean;\n /** Where it remembers the greeting was shown (the app's preferences store); default: for this launch only. */\n readonly storage?: GreetingStorage;\n /** The storage's key for a person and mode (a record the app already keeps); default `greetedKey`. */\n readonly storageKey?: (subject: string | null, mode: string) => string;\n /** The greeting's words, or by mode; default the copy's `launcherGreeting`. */\n readonly greeting?: string | ((mode: string) => string);\n /** How long after showing the greeting appears. Default 1200 ms. */\n readonly delayMs?: number;\n /** The app's brand mark inside the button; default the agent name's first letter. */\n readonly Mark?: ComponentType<{\n readonly size: number;\n readonly color: string;\n }>;\n /** Reads the greeting to a screen reader as it appears. Default: the platform's. */\n readonly announce?: (text: string) => void;\n readonly components?: {\n readonly Button?: Slot<LauncherButtonProps>;\n readonly Greeting?: Slot<LauncherGreetingProps>;\n /** Default: a short fade and scale; none with reduced motion. */\n readonly Entrance?: Slot<LauncherEntranceProps>;\n };\n readonly appearance?: LauncherAppearance;\n /** Where it floats over the app's screens; `style` comes after it, for anything else. */\n readonly placement?: LauncherPlacement;\n readonly style?: StyleProp<ViewStyle>;\n /** As on the chat: the person's locale, the app's words, theme and color scheme. */\n readonly locale?: string;\n readonly copy?: CopyOverrides;\n readonly theme?: ThemeOverrides;\n readonly colorScheme?: ColorSchemeSetting;\n}\n\nexport function AgentLauncher(props: AgentLauncherProps): ReactNode {\n return (\n <CopyProvider locale={props.locale} copy={props.copy}>\n <ThemeProvider theme={props.theme} colorScheme={props.colorScheme}>\n <Launcher {...props} />\n </ThemeProvider>\n </CopyProvider>\n );\n}\n\n/** Whether the keyboard is up: on iOS from the moment it starts to rise or fall, on Android (no `Will` events) once it has. */\nexport function useKeyboardShown(): boolean {\n const [shown, setShown] = useState(false);\n useEffect(() => {\n const ios = Platform.OS === 'ios';\n const show = Keyboard.addListener(\n ios ? 'keyboardWillShow' : 'keyboardDidShow',\n () => setShown(true),\n );\n const hide = Keyboard.addListener(\n ios ? 'keyboardWillHide' : 'keyboardDidHide',\n () => setShown(false),\n );\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n return shown;\n}\n\nfunction Launcher(props: AgentLauncherProps): ReactNode {\n const { t } = useCopy();\n const name = useAgentName(t('agentFallbackName'));\n const keyboard = useKeyboardShown();\n const reducedMotion = useReducedMotion();\n useAgentSweep(useAgentRuntime());\n const { route = null, routes, mode } = props;\n const visible =\n props.hidden !== true &&\n !(keyboard && props.hideWithKeyboard !== false) &&\n (!routes || (route !== null && routes.includes(route)));\n const launcher = useAgentLauncher({\n subject: props.subject,\n mode,\n visible,\n onOpen: () => props.onOpen({ route, mode, entryPoint: 'launcher' }),\n ...(props.storage ? { storage: props.storage } : {}),\n ...(props.storageKey ? { storageKey: props.storageKey } : {}),\n ...(props.delayMs === undefined ? {} : { delayMs: props.delayMs }),\n });\n const text =\n typeof props.greeting === 'function'\n ? props.greeting(mode)\n : (props.greeting ?? t('launcherGreeting', { agent: name }));\n const say = props.announce ?? platformAnnounce;\n const said = useRef(false);\n useEffect(() => {\n if (!launcher.greets) {\n said.current = false;\n return;\n }\n if (said.current) return;\n said.current = true; // once per greeting, however often the app's `announce` changes\n say(text);\n }, [launcher.greets, text, say]);\n if (!launcher.shows) return null;\n const edge = props.placement?.edge ?? 'right';\n const look = props.appearance ?? {};\n const greeting: LauncherGreetingProps = {\n text,\n closeLabel: t('close'),\n onOpen: launcher.open,\n onClose: launcher.dismiss,\n tail: look.tail !== false,\n edge,\n };\n const button: LauncherButtonProps = {\n label: t('launcherOpen', { agent: name }),\n name,\n onPress: launcher.open,\n Mark: props.Mark,\n ring: look.ring ?? null,\n shadow: look.shadow !== false,\n };\n const { Greeting, Button, Entrance } = props.components ?? {};\n const enter = (part: LauncherEntranceProps['part'], children: ReactNode) =>\n Entrance ? (\n <Entrance\n part={part}\n reducedMotion={reducedMotion}\n Default={LauncherEntrance}\n >\n {children}\n </Entrance>\n ) : (\n <LauncherEntrance part={part} reducedMotion={reducedMotion}>\n {children}\n </LauncherEntrance>\n );\n return (\n <View\n pointerEvents=\"box-none\"\n style={[\n {\n position: 'absolute',\n bottom: props.placement?.bottom ?? 16,\n [edge]: props.placement?.inset ?? 16,\n alignItems: edge === 'right' ? 'flex-end' : 'flex-start',\n gap: 8,\n },\n props.style,\n ]}\n testID=\"vinaverse-launcher\"\n >\n {launcher.greets\n ? enter(\n 'greeting',\n Greeting ? (\n <Greeting {...greeting} Default={LauncherGreeting} />\n ) : (\n <LauncherGreeting {...greeting} />\n ),\n )\n : null}\n {enter(\n 'button',\n Button ? (\n <Button {...button} Default={LauncherButton} />\n ) : (\n <LauncherButton {...button} />\n ),\n )}\n </View>\n );\n}\n\n/** The kit's entrance: a short fade and scale up; none when the person asked for reduced motion. */\nexport function LauncherEntrance(props: LauncherEntranceProps): ReactNode {\n const { motion } = useTheme();\n const shown = useRef(new Animated.Value(props.reducedMotion ? 1 : 0)).current;\n useEffect(() => {\n if (props.reducedMotion) {\n shown.setValue(1);\n return;\n }\n const run = Animated.timing(shown, {\n toValue: 1,\n duration: motion.normal,\n useNativeDriver: true,\n });\n run.start();\n return () => run.stop();\n }, [shown, props.reducedMotion, motion.normal]);\n return (\n <Animated.View\n pointerEvents=\"box-none\"\n style={{\n opacity: shown,\n transform: [\n {\n scale: shown.interpolate({\n inputRange: [0, 1],\n outputRange: [0.9, 1],\n }),\n },\n ],\n }}\n testID={`vinaverse-launcher-entrance-${props.part}`}\n >\n {props.children}\n </Animated.View>\n );\n}\n\n/** The kit's greeting bubble: the words (a tap opens the agent), a close button, and a tail toward the button. */\nexport function LauncherGreeting(props: LauncherGreetingProps): ReactNode {\n const { colors, radius, space, font } = useTheme();\n return (\n <View\n style={{\n maxWidth: 296,\n flexDirection: 'row',\n alignItems: 'flex-start',\n borderRadius: radius.lg,\n backgroundColor: colors.text,\n }}\n testID=\"vinaverse-launcher-greeting\"\n >\n {props.tail ? (\n <View\n accessible={false}\n style={{\n position: 'absolute',\n bottom: -5,\n [props.edge]: LAUNCHER_SIZE / 2 - 6,\n width: 12,\n height: 12,\n backgroundColor: colors.text,\n transform: [{ rotate: '45deg' }],\n }}\n testID=\"vinaverse-launcher-tail\"\n />\n ) : null}\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={props.text}\n onPress={props.onOpen}\n style={{\n flexShrink: 1,\n paddingVertical: space.sm,\n paddingLeft: space.md,\n }}\n >\n <Text style={{ color: colors.background, fontSize: font.size.md }}>\n {props.text}\n </Text>\n </Pressable>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={props.closeLabel}\n onPress={props.onClose}\n style={{\n minWidth: 44,\n minHeight: 44,\n alignItems: 'center',\n justifyContent: 'center',\n }}\n testID=\"vinaverse-launcher-close\"\n >\n <Text style={{ color: colors.background, fontSize: font.size.md }}>\n ×\n </Text>\n </Pressable>\n </View>\n );\n}\n\n/** The kit's round button: the app's mark, else the agent name's first letter; its ring and shadow as asked. */\nexport function LauncherButton(props: LauncherButtonProps): ReactNode {\n const { colors, font } = useTheme();\n const { Mark, ring } = props;\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={props.label}\n onPress={props.onPress}\n style={({ pressed }) => ({\n width: LAUNCHER_SIZE,\n height: LAUNCHER_SIZE,\n borderRadius: LAUNCHER_SIZE / 2,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: colors.primary,\n opacity: pressed ? 0.85 : 1,\n ...(ring ? { borderWidth: ring.width, borderColor: ring.color } : {}),\n ...(props.shadow\n ? {\n elevation: 6,\n shadowColor: '#000',\n shadowOpacity: 0.2,\n shadowRadius: 8,\n shadowOffset: { width: 0, height: 3 },\n }\n : {}),\n })}\n testID=\"vinaverse-launcher-button\"\n >\n {Mark ? (\n <Mark size={34} color={colors.onPrimary} />\n ) : (\n <Text\n style={{\n color: colors.onPrimary,\n fontSize: font.size.lg,\n fontWeight: '600',\n }}\n >\n {(props.name.trim()[0] ?? '?').toUpperCase()}\n </Text>\n )}\n </Pressable>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkOWUKWVEZ_cjs = require('./chunk-OWUKWVEZ.cjs');
3
+ var chunk6QYDPGRS_cjs = require('./chunk-6QYDPGRS.cjs');
4
4
  var react = require('@vinaverse/react');
5
5
  var agent = require('@vinaverse/react/agent');
6
6
  var react$1 = require('react');
@@ -8,33 +8,34 @@ var reactNative = require('react-native');
8
8
  var jsxRuntime = require('react/jsx-runtime');
9
9
 
10
10
  function AskAboutRow(props) {
11
- return /* @__PURE__ */ jsxRuntime.jsx(react.CopyProvider, { locale: props.locale, copy: props.copy, children: /* @__PURE__ */ jsxRuntime.jsx(chunkOWUKWVEZ_cjs.ThemeProvider, { theme: props.theme, colorScheme: props.colorScheme, children: /* @__PURE__ */ jsxRuntime.jsx(Row, { ...props }) }) });
11
+ return /* @__PURE__ */ jsxRuntime.jsx(react.CopyProvider, { locale: props.locale, copy: props.copy, children: /* @__PURE__ */ jsxRuntime.jsx(chunk6QYDPGRS_cjs.ThemeProvider, { theme: props.theme, colorScheme: props.colorScheme, children: /* @__PURE__ */ jsxRuntime.jsx(Row, { ...props }) }) });
12
12
  }
13
13
  function Row(props) {
14
14
  const { t } = react.useCopy();
15
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
15
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
16
16
  const name = agent.useAgentName(t("agentFallbackName"));
17
- const { available } = agent.useAgentFeatures();
18
- const [shows, setShows] = react$1.useState(null);
19
- if (shows === null && available) setShows(true);
17
+ const runtime = agent.useAgentRuntime();
18
+ agent.useAgentStatus();
19
+ chunk6QYDPGRS_cjs.useAgentSweep(runtime);
20
+ const [shows] = react$1.useState(() => !!runtime.getStatus()?.available);
20
21
  if (!shows) return null;
21
- const { Mark } = props;
22
+ const { Mark, appearance: look } = props;
22
23
  return /* @__PURE__ */ jsxRuntime.jsxs(
23
24
  reactNative.Pressable,
24
25
  {
25
26
  accessibilityRole: "button",
26
27
  accessibilityLabel: props.body ? `${props.title}. ${props.body}` : props.title,
27
- onPress: props.onPress,
28
+ onPress: () => props.onPress({ entryPoint: "ask" }),
28
29
  style: ({ pressed }) => ({
29
30
  flexDirection: "row",
30
31
  alignItems: "center",
31
32
  gap: space.md,
32
33
  padding: space.md,
33
34
  borderRadius: radius.lg,
34
- backgroundColor: colors.surface,
35
+ backgroundColor: look?.background ?? colors.surface,
35
36
  opacity: pressed ? 0.85 : 1
36
37
  }),
37
- testID: "vinaverse-ask-about",
38
+ testID: props.testID ?? "vinaverse-ask-about",
38
39
  children: [
39
40
  /* @__PURE__ */ jsxRuntime.jsx(
40
41
  reactNative.View,
@@ -64,12 +65,12 @@ function Row(props) {
64
65
  ),
65
66
  props.body ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textMuted, fontSize: font.size.sm }, children: props.body }) : null
66
67
  ] }),
67
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textMuted, fontSize: font.size.lg }, children: "\u203A" })
68
+ look?.chevron === false ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textMuted, fontSize: font.size.lg }, children: "\u203A" })
68
69
  ]
69
70
  }
70
71
  );
71
72
  }
72
73
 
73
74
  exports.AskAboutRow = AskAboutRow;
74
- //# sourceMappingURL=chunk-643GOUTG.cjs.map
75
- //# sourceMappingURL=chunk-643GOUTG.cjs.map
75
+ //# sourceMappingURL=chunk-NMKJ7LIJ.cjs.map
76
+ //# sourceMappingURL=chunk-NMKJ7LIJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/AskAboutRow.tsx"],"names":["jsx","CopyProvider","ThemeProvider","useCopy","useTheme","useAgentName","useAgentRuntime","useAgentStatus","useAgentSweep","useState","jsxs","Pressable","View","Text"],"mappings":";;;;;;;;;AA+CO,SAAS,YAAY,KAAA,EAAoC;AAC9D,EAAA,uBACEA,cA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A;AAAA,gBACd,QAAA,EAAU,KAAK,IAAA,CAAK,EAAA;AAAA,gBACpB,UAAA,EAAY;AAAA,eACd;AAAA,cAEC,QAAA,EAAA,KAAA,CAAM;AAAA;AAAA,WACT;AAAA,UACC,MAAM,IAAA,mBACLb,cAAA,CAACa,gBAAA,EAAA,EAAK,KAAA,EAAO,EAAE,KAAA,EAAO,MAAA,CAAO,SAAA,EAAW,QAAA,EAAU,KAAK,IAAA,CAAK,EAAA,EAAG,EAC5D,QAAA,EAAA,KAAA,CAAM,MACT,CAAA,GACE;AAAA,SAAA,EACN,CAAA;AAAA,QACC,MAAM,OAAA,KAAY,KAAA,GAAQ,IAAA,mBACzBb,cAAA,CAACa,oBAAK,KAAA,EAAO,EAAE,KAAA,EAAO,MAAA,CAAO,WAAW,QAAA,EAAU,IAAA,CAAK,IAAA,CAAK,EAAA,IAAM,QAAA,EAAA,QAAA,EAElE;AAAA;AAAA;AAAA,GAEJ;AAEJ","file":"chunk-NMKJ7LIJ.cjs","sourcesContent":["// \"Ask the agent about this\" on one of the app's own pages (a professional's, a space's, a booking's): a row that opens\n// the agent told the place. It shows only when the agent is available, decided once as the page draws, from the status\n// already read, so it never appears or disappears under content the person is reading.\nimport { type CopyOverrides, CopyProvider, useCopy } from '@vinaverse/react';\nimport {\n useAgentName,\n useAgentRuntime,\n useAgentStatus,\n} from '@vinaverse/react/agent';\nimport { type ComponentType, type ReactNode, useState } from 'react';\nimport { Pressable, Text, View } from 'react-native';\nimport { useAgentSweep } from '../platform.js';\nimport {\n type ColorSchemeSetting,\n type ThemeOverrides,\n ThemeProvider,\n useTheme,\n} from '../theme.js';\n\n/** The row's look beyond the theme. */\nexport interface AskAboutRowAppearance {\n /** A tint behind the row; default the theme's `surface`. */\n readonly background?: string;\n /** The chevron at the row's end. Default true. */\n readonly chevron?: boolean;\n}\n\nexport interface AskAboutRowProps {\n /** \"Ask Example Agent about Riley Sample\". */\n readonly title: string;\n readonly body?: string;\n /** The person asks: open the chat with `entryPoint` (`ask`), so the session says where it was opened from. */\n readonly onPress: (from: { readonly entryPoint: 'ask' }) => void;\n /** The app's brand mark at the row's start; default the agent name's first letter. */\n readonly Mark?: ComponentType<{\n readonly size: number;\n readonly color: string;\n }>;\n readonly appearance?: AskAboutRowAppearance;\n readonly locale?: string;\n readonly copy?: CopyOverrides;\n readonly theme?: ThemeOverrides;\n readonly colorScheme?: ColorSchemeSetting;\n /** The row's test id. Default `vinaverse-ask-about`. */\n readonly testID?: string;\n}\n\nexport function AskAboutRow(props: AskAboutRowProps): ReactNode {\n return (\n <CopyProvider locale={props.locale} copy={props.copy}>\n <ThemeProvider theme={props.theme} colorScheme={props.colorScheme}>\n <Row {...props} />\n </ThemeProvider>\n </CopyProvider>\n );\n}\n\nfunction Row(props: AskAboutRowProps): ReactNode {\n const { t } = useCopy();\n const { colors, radius, space, font } = useTheme();\n const name = useAgentName(t('agentFallbackName'));\n const runtime = useAgentRuntime();\n useAgentStatus(); // reads the status when none is held, for the pages after this one\n useAgentSweep(runtime);\n // Decided once, as the page draws, from the status already read: an agent unknown or unavailable then stays away for\n // the visit, and the row is never added under content the person is reading.\n const [shows] = useState(() => !!runtime.getStatus()?.available);\n if (!shows) return null;\n const { Mark, appearance: look } = props;\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={\n props.body ? `${props.title}. ${props.body}` : props.title\n }\n onPress={() => props.onPress({ entryPoint: 'ask' })}\n style={({ pressed }) => ({\n flexDirection: 'row',\n alignItems: 'center',\n gap: space.md,\n padding: space.md,\n borderRadius: radius.lg,\n backgroundColor: look?.background ?? colors.surface,\n opacity: pressed ? 0.85 : 1,\n })}\n testID={props.testID ?? 'vinaverse-ask-about'}\n >\n <View\n style={{\n width: 36,\n height: 36,\n borderRadius: 18,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: colors.primary,\n }}\n >\n {Mark ? (\n <Mark size={22} color={colors.onPrimary} />\n ) : (\n <Text style={{ color: colors.onPrimary, fontWeight: '600' }}>\n {(name.trim()[0] ?? '?').toUpperCase()}\n </Text>\n )}\n </View>\n <View style={{ flex: 1, gap: space.xxs }}>\n <Text\n style={{\n color: colors.text,\n fontSize: font.size.md,\n fontWeight: '600',\n }}\n >\n {props.title}\n </Text>\n {props.body ? (\n <Text style={{ color: colors.textMuted, fontSize: font.size.sm }}>\n {props.body}\n </Text>\n ) : null}\n </View>\n {look?.chevron === false ? null : (\n <Text style={{ color: colors.textMuted, fontSize: font.size.lg }}>\n ›\n </Text>\n )}\n </Pressable>\n );\n}\n"]}
@@ -1,7 +1,6 @@
1
- import { useReducedMotion, announce, useNativeLifecycle } from './chunk-PRXHS57U.js';
2
- import { useTheme, themeProblems, ThemeProvider } from './chunk-WKRCCPSN.js';
1
+ import { useTheme, useReducedMotion, announce, useNativeLifecycle, themeProblems, ThemeProvider, useAgentSweep } from './chunk-EFEXTVIT.js';
3
2
  import { useAgentRuntime, useAgentConversation, useAgentName } from '@vinaverse/react/agent';
4
- export { AgentRuntimeProvider, greetedKey, useAgentConversation, useAgentFeatures, useAgentLauncher, useAgentName, useAgentProfile, useAgentRuntime, useAgentStatus } from '@vinaverse/react/agent';
3
+ export { AgentRuntimeProvider, forgetGreeting, greetedKey, useAgentConversation, useAgentFeatures, useAgentLauncher, useAgentName, useAgentProfile, useAgentRuntime, useAgentStatus } from '@vinaverse/react/agent';
5
4
  import { FlashList } from '@shopify/flash-list';
6
5
  import { useCopy, formatMoney, formatTimeRange, useConversationSelector, formatDate, useStreamingText, bannedWordsIn, CopyProvider } from '@vinaverse/react';
7
6
  import { Pressable, ActivityIndicator, Text, View, Image, Linking, TextInput, useWindowDimensions, Platform, KeyboardAvoidingView } from 'react-native';
@@ -321,7 +320,7 @@ function ListingCard(props) {
321
320
  );
322
321
  const hero = photoUrl === failed ? null : photoUrl;
323
322
  const Img = slots.Image ?? Image;
324
- const rating = card.rating ? `\u2605 ${ratingText(card.rating.value_ppm, locale)} (${card.rating.count})` : null;
323
+ const rating = card.rating ? `\u2605 ${ratingText(card.rating.value_ppm, locale)} (${card.rating.count})` : t("ratingNone") || null;
325
324
  const price = card.price_from ? t("priceFrom", {
326
325
  price: formatMoney(
327
326
  card.price_from.amount,
@@ -350,7 +349,7 @@ function ListingCard(props) {
350
349
  accessible: false,
351
350
  testID: `vinaverse-photo-${card.id}`
352
351
  }
353
- ) : imagePolicy?.Placeholder ? /* @__PURE__ */ jsx(View, { style: photo, testID: `vinaverse-placeholder-${card.id}`, children: /* @__PURE__ */ jsx(imagePolicy.Placeholder, { title: card.title }) }) : /* @__PURE__ */ jsx(
352
+ ) : imagePolicy?.Placeholder ? /* @__PURE__ */ jsx(View, { style: photo, testID: `vinaverse-placeholder-${card.id}`, children: /* @__PURE__ */ jsx(imagePolicy.Placeholder, { title: card.title, kind: card.kind }) }) : /* @__PURE__ */ jsx(
354
353
  View,
355
354
  {
356
355
  accessible: false,
@@ -505,7 +504,9 @@ function ProposalCard(props) {
505
504
  props.card.id,
506
505
  () => onProposal(props.card, decision)
507
506
  ).catch(
508
- (error) => handlers.current?.onWarning?.(`Vinaverse proposal: ${String(error)}`)
507
+ (error) => handlers.current?.onWarning?.(`Vinaverse proposal: ${String(error)}`, {
508
+ code: "proposal_failed"
509
+ })
509
510
  );
510
511
  };
511
512
  const fields = proposal.fields.map((f) => {
@@ -627,7 +628,9 @@ function QuestionCard(props) {
627
628
  try {
628
629
  store.answer(held.id, questionId, answer);
629
630
  } catch (error) {
630
- handlers.current?.onWarning?.(`Vinaverse answer: ${String(error)}`);
631
+ handlers.current?.onWarning?.(`Vinaverse answer: ${String(error)}`, {
632
+ code: "answer_failed"
633
+ });
631
634
  }
632
635
  };
633
636
  const locked = held.locked.includes(question.question_id);
@@ -738,7 +741,8 @@ function Answer(props) {
738
741
  if (picked) send({ upload_ref: picked.upload_ref });
739
742
  }).catch(
740
743
  (error) => handlers.current?.onWarning?.(
741
- `Vinaverse photo: ${String(error)}`
744
+ `Vinaverse photo: ${String(error)}`,
745
+ { code: "photo_failed" }
742
746
  )
743
747
  );
744
748
  }
@@ -2199,10 +2203,11 @@ function VinaverseChatProvider(props) {
2199
2203
  useEffect(() => {
2200
2204
  if (!onWarning) return;
2201
2205
  for (const problem of themeProblems(theme))
2202
- onWarning(`Vinaverse theme: ${problem}`);
2206
+ onWarning(`Vinaverse theme: ${problem}`, { code: "theme" });
2203
2207
  for (const key of bannedWordsIn(copy ?? {}))
2204
2208
  onWarning(
2205
- `Vinaverse copy: "${key}" says assistant, bot or crew; the copy says agent.`
2209
+ `Vinaverse copy: "${key}" says assistant, bot or crew; the copy says agent.`,
2210
+ { code: "copy" }
2206
2211
  );
2207
2212
  }, [onWarning, theme, copy]);
2208
2213
  return /* @__PURE__ */ jsx(CopyProvider, { locale: props.locale, copy: props.copy, children: /* @__PURE__ */ jsx(ThemeProvider, { theme: props.theme, colorScheme: props.colorScheme, children: /* @__PURE__ */ jsx(ChatContextProvider, { value, children: props.children }) }) });
@@ -2226,7 +2231,7 @@ function Layout(props) {
2226
2231
  const { direction } = useCopy();
2227
2232
  const { onError } = props;
2228
2233
  const reportError = useMemo(
2229
- () => onError ? (e) => onError(String(e)) : void 0,
2234
+ () => onError ? (e) => onError(String(e), { code: "send_failed" }) : void 0,
2230
2235
  [onError]
2231
2236
  );
2232
2237
  return /* @__PURE__ */ jsxs(
@@ -2296,6 +2301,7 @@ function AgentChat(props) {
2296
2301
  ...chat
2297
2302
  } = props;
2298
2303
  const runtime = useAgentRuntime();
2304
+ useAgentSweep(runtime);
2299
2305
  const { conversation, state, startNew } = useAgentConversation(agentKey, {
2300
2306
  place: place ?? null,
2301
2307
  entryPoint: entryPoint ?? null
@@ -2344,30 +2350,23 @@ function AgentChat(props) {
2344
2350
  conversation: store,
2345
2351
  components: slots
2346
2352
  };
2347
- if (state.failure === "ended")
2348
- return /* @__PURE__ */ jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsx(Centered, { children: Ended ? /* @__PURE__ */ jsx(
2349
- Ended,
2350
- {
2351
- onStartNew: startNew,
2352
- code: state.code,
2353
- Default: DefaultEnded
2354
- }
2355
- ) : /* @__PURE__ */ jsx(DefaultEnded, { onStartNew: startNew, code: state.code }) }) });
2356
- if (state.failure === "unreachable")
2357
- return /* @__PURE__ */ jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsx(Centered, { children: Unreachable ? /* @__PURE__ */ jsx(
2358
- Unreachable,
2359
- {
2360
- onRetry: conversation.retry,
2361
- reason: state.reason,
2362
- Default: DefaultUnreachable
2363
- }
2364
- ) : /* @__PURE__ */ jsx(
2365
- DefaultUnreachable,
2366
- {
2367
- onRetry: conversation.retry,
2368
- reason: state.reason
2369
- }
2370
- ) }) });
2353
+ if (state.failure === "ended") {
2354
+ const own = {
2355
+ onStartNew: startNew,
2356
+ reason: state.reason,
2357
+ code: state.code,
2358
+ onContact
2359
+ };
2360
+ return /* @__PURE__ */ jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsx(Centered, { children: Ended ? /* @__PURE__ */ jsx(Ended, { ...own, Default: DefaultEnded }) : /* @__PURE__ */ jsx(DefaultEnded, { ...own }) }) });
2361
+ }
2362
+ if (state.failure === "unreachable") {
2363
+ const own = {
2364
+ onRetry: conversation.retry,
2365
+ reason: state.reason,
2366
+ onContact
2367
+ };
2368
+ return /* @__PURE__ */ jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsx(Centered, { children: Unreachable ? /* @__PURE__ */ jsx(Unreachable, { ...own, Default: DefaultUnreachable }) : /* @__PURE__ */ jsx(DefaultUnreachable, { ...own }) }) });
2369
+ }
2371
2370
  if (state.failure === "unavailable") {
2372
2371
  const own = {
2373
2372
  reason: state.reason,
@@ -2388,6 +2387,7 @@ function AgentChat(props) {
2388
2387
  store,
2389
2388
  state,
2390
2389
  rate: conversation.rate,
2390
+ canRate: conversation.canRate,
2391
2391
  Footer,
2392
2392
  onOpenPrivacy
2393
2393
  }
@@ -2396,7 +2396,8 @@ function AgentChat(props) {
2396
2396
  );
2397
2397
  }
2398
2398
  function FooterFor(props) {
2399
- const turnId = useConversationSelector(props.store, newestWholeReply);
2399
+ const newest = useConversationSelector(props.store, newestWholeReply);
2400
+ const turnId = newest && props.canRate(newest) ? newest : null;
2400
2401
  const own = {
2401
2402
  turnId,
2402
2403
  rating: turnId ? props.state.ratings.get(turnId) : void 0,
@@ -2563,5 +2564,5 @@ function AgentFooter(props) {
2563
2564
  }
2564
2565
 
2565
2566
  export { ActivityLine, AgentChat, AgentFooter, Avatar, Button, CardActions, CardCarousel, CardFrame, CardView, ChatHeader, ChatSkeleton, Composer, DefaultBubble, DefaultComposer, DefaultEnded, DefaultHeader, DefaultTurnFailed, DefaultUnavailable, DefaultUnavailableScreen, DefaultUnreachable, DisclosureBar, FailureActionButton, InfoCard, LinksCard, ListingCard, MessageBubble, MessageList, NextStepCard, ProposalCard, QuestionCard, Row, StatusBanner, StreamingBubble, SystemRow, TimeSlotsCard, VinaverseChat, VinaverseChatProvider, Welcome, allowedImage, answerText, carousels, defaultCard, fieldText, itemType, monogram, newestWholeReply, ratingText, useChat };
2566
- //# sourceMappingURL=chunk-SF6LJTVJ.js.map
2567
- //# sourceMappingURL=chunk-SF6LJTVJ.js.map
2567
+ //# sourceMappingURL=chunk-NXGLI4Y7.js.map
2568
+ //# sourceMappingURL=chunk-NXGLI4Y7.js.map