@vinaverse/react-native 0.1.0-alpha.4 → 0.1.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -0
- package/dist/ask.cjs +58 -0
- package/dist/ask.cjs.map +1 -0
- package/dist/ask.d.cts +25 -0
- package/dist/ask.d.ts +25 -0
- package/dist/ask.js +5 -0
- package/dist/ask.js.map +1 -0
- package/dist/chat.cjs +266 -0
- package/dist/chat.cjs.map +1 -0
- package/dist/chat.d.cts +449 -0
- package/dist/chat.d.ts +449 -0
- package/dist/chat.js +5 -0
- package/dist/chat.js.map +1 -0
- package/dist/chunk-643GOUTG.cjs +75 -0
- package/dist/chunk-643GOUTG.cjs.map +1 -0
- package/dist/chunk-H2Y2YW2Q.cjs +2651 -0
- package/dist/chunk-H2Y2YW2Q.cjs.map +1 -0
- package/dist/chunk-NJWRZ55G.js +254 -0
- package/dist/chunk-NJWRZ55G.js.map +1 -0
- package/dist/chunk-OGPMGGYS.cjs +261 -0
- package/dist/chunk-OGPMGGYS.cjs.map +1 -0
- package/dist/chunk-OWUKWVEZ.cjs +53 -0
- package/dist/chunk-OWUKWVEZ.cjs.map +1 -0
- package/dist/chunk-PRXHS57U.js +40 -0
- package/dist/chunk-PRXHS57U.js.map +1 -0
- package/dist/chunk-PYPO6F7L.cjs +44 -0
- package/dist/chunk-PYPO6F7L.cjs.map +1 -0
- package/dist/chunk-SF6LJTVJ.js +2567 -0
- package/dist/chunk-SF6LJTVJ.js.map +1 -0
- package/dist/chunk-WKRCCPSN.js +48 -0
- package/dist/chunk-WKRCCPSN.js.map +1 -0
- package/dist/chunk-Y7P7DDHD.js +73 -0
- package/dist/chunk-Y7P7DDHD.js.map +1 -0
- package/dist/index.cjs +290 -2299
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -360
- package/dist/index.d.ts +11 -360
- package/dist/index.js +5 -2254
- package/dist/index.js.map +1 -1
- package/dist/launcher.cjs +79 -0
- package/dist/launcher.cjs.map +1 -0
- package/dist/launcher.d.cts +121 -0
- package/dist/launcher.d.ts +121 -0
- package/dist/launcher.js +6 -0
- package/dist/launcher.js.map +1 -0
- package/dist/theme-BhiEGv64.d.cts +35 -0
- package/dist/theme-BhiEGv64.d.ts +35 -0
- package/package.json +114 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme.tsx"],"names":["colors","font","space","radius","motion","size","contrastProblems","createContext","useColorScheme","useMemo","useContext"],"mappings":";;;;;;;;AAsCO,SAAS,WAAA,CACd,MAAA,EACA,SAAA,GAA4B,EAAC,EACtB;AACP,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,MAAA,EAAQ,EAAE,GAAGA,aAAA,CAAO,MAAM,CAAA,EAAG,GAAG,SAAA,CAAU,MAAM,CAAA,EAAE;AAAA,IAClD,IAAA,EAAM;AAAA,MACJ,GAAGC,WAAA;AAAA,MACH,GAAI,UAAU,UAAA,GAAa,EAAE,QAAQ,SAAA,CAAU,UAAA,KAAe;AAAC,KACjE;AAAA,IACA,OAAO,EAAE,GAAGC,YAAA,EAAO,GAAG,UAAU,KAAA,EAAM;AAAA,IACtC,QAAQ,EAAE,GAAGC,aAAA,EAAQ,GAAG,UAAU,MAAA,EAAO;AAAA,YACzCC,aAAA;AAAA,UACAC;AAAA,GACF;AACF;AAGO,SAAS,aAAA,CAAc,SAAA,GAA4B,EAAC,EAAa;AACtE,EAAA,OAAQ,CAAC,OAAA,EAAS,MAAM,CAAA,CAAY,OAAA;AAAA,IAAQ,CAAC,WAC3CC,uBAAA,CAAiB,WAAA,CAAY,QAAQ,SAAS,CAAA,CAAE,MAAM,CAAA,CAAE,GAAA;AAAA,MACtD,CAAC,CAAA,KACC,CAAA,EAAG,MAAM,CAAA,EAAA,EAAK,CAAA,CAAE,UAAU,CAAA,IAAA,EAAO,CAAA,CAAE,UAAU,CAAA,IAAA,EAAO,EAAE,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,UAAA,EAAa,EAAE,OAAO,CAAA,EAAA;AAAA;AAChG,GACF;AACF;AAEA,IAAM,YAAA,mBAA+BC,mBAAA;AAAA,8BACP,OAAO;AACrC,CAAA;AAEO,SAAS,cAAc,KAAA,EAIhB;AACZ,EAAA,MAAM,SAASC,0BAAA,EAAe;AAC9B,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,IAAe,QAAA;AACrC,EAAA,MAAM,SACJ,OAAA,KAAY,QAAA,GAAY,MAAA,KAAW,MAAA,GAAS,SAAS,OAAA,GAAW,OAAA;AAClE,EAAA,MAAM,YAAY,KAAA,CAAM,KAAA;AACxB,EAAA,MAAM,KAAA,GAAQC,aAAA;AAAA,IACZ,MAAM,WAAA,CAAY,MAAA,EAAQ,SAAS,CAAA;AAAA,IACnC,CAAC,QAAQ,SAAS;AAAA,GACpB;AACA,EAAA,sCACG,YAAA,CAAa,QAAA,EAAb,EAAsB,KAAA,EACpB,gBAAM,QAAA,EACT,CAAA;AAEJ;AAEO,SAAS,QAAA,GAAkB;AAChC,EAAA,OAAOC,iBAAW,YAAY,CAAA;AAChC","file":"chunk-OWUKWVEZ.cjs","sourcesContent":["// The theme: the shared design tokens, a tenant's brand on top, light and dark. A tenant changes colors, fonts, radii\n// and spacing; the disclosure bar keeps a legible pair whatever the tenant's colors (see DisclosureBar).\nimport {\n type ColorScheme,\n type Colors,\n colors,\n contrastProblems,\n font,\n motion,\n radius,\n size,\n space,\n} from '@vinaverse/tokens';\nimport { createContext, type ReactNode, useContext, useMemo } from 'react';\nimport { useColorScheme } from 'react-native';\n\nexport interface Theme {\n readonly scheme: ColorScheme;\n readonly colors: Colors;\n readonly font: typeof font & { readonly family?: string };\n readonly space: typeof space;\n readonly radius: typeof radius;\n readonly motion: typeof motion;\n readonly size: typeof size;\n}\n\n/** A tenant's brand: colors per scheme, a font family, radii. Anything left out keeps the Vinaverse default. */\nexport interface ThemeOverrides {\n readonly light?: Partial<Colors>;\n readonly dark?: Partial<Colors>;\n readonly fontFamily?: string;\n readonly radius?: Partial<typeof radius>;\n readonly space?: Partial<typeof space>;\n}\n\nexport type ColorSchemeSetting = 'system' | 'light' | 'dark';\n\n/** The theme for a scheme, with the tenant's overrides on top. */\nexport function createTheme(\n scheme: ColorScheme,\n overrides: ThemeOverrides = {},\n): Theme {\n return {\n scheme,\n colors: { ...colors(scheme), ...overrides[scheme] },\n font: {\n ...font,\n ...(overrides.fontFamily ? { family: overrides.fontFamily } : {}),\n },\n space: { ...space, ...overrides.space },\n radius: { ...radius, ...overrides.radius },\n motion,\n size,\n };\n}\n\n/** The pairs a tenant's colors made hard to read, in either scheme, as messages for a development warning. */\nexport function themeProblems(overrides: ThemeOverrides = {}): string[] {\n return (['light', 'dark'] as const).flatMap((scheme) =>\n contrastProblems(createTheme(scheme, overrides).colors).map(\n (p) =>\n `${scheme}: ${p.foreground} on ${p.background} is ${p.ratio.toFixed(2)}:1, below ${p.minimum}:1`,\n ),\n );\n}\n\nconst ThemeContext = /* @__PURE__ */ createContext<Theme>(\n /* @__PURE__ */ createTheme('light'),\n);\n\nexport function ThemeProvider(props: {\n readonly theme?: ThemeOverrides | undefined;\n readonly colorScheme?: ColorSchemeSetting | undefined;\n readonly children?: ReactNode;\n}): ReactNode {\n const system = useColorScheme();\n const setting = props.colorScheme ?? 'system';\n const scheme: ColorScheme =\n setting === 'system' ? (system === 'dark' ? 'dark' : 'light') : setting;\n const overrides = props.theme;\n const value = useMemo(\n () => createTheme(scheme, overrides),\n [scheme, overrides],\n );\n return (\n <ThemeContext.Provider value={value}>\n {props.children}\n </ThemeContext.Provider>\n );\n}\n\nexport function useTheme(): Theme {\n return useContext(ThemeContext);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { AppState, AccessibilityInfo } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// src/platform.ts
|
|
5
|
+
function useNativeLifecycle(store) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const apply = (state) => store.setForeground(state === "active");
|
|
8
|
+
apply(AppState.currentState);
|
|
9
|
+
const subscription = AppState.addEventListener("change", apply);
|
|
10
|
+
return () => subscription.remove();
|
|
11
|
+
}, [store]);
|
|
12
|
+
}
|
|
13
|
+
function useReducedMotion() {
|
|
14
|
+
const [reduced, setReduced] = useState(false);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
let live = true;
|
|
17
|
+
AccessibilityInfo.isReduceMotionEnabled().then(
|
|
18
|
+
(value) => {
|
|
19
|
+
if (live) setReduced(value);
|
|
20
|
+
},
|
|
21
|
+
() => void 0
|
|
22
|
+
);
|
|
23
|
+
const subscription = AccessibilityInfo.addEventListener(
|
|
24
|
+
"reduceMotionChanged",
|
|
25
|
+
setReduced
|
|
26
|
+
);
|
|
27
|
+
return () => {
|
|
28
|
+
live = false;
|
|
29
|
+
subscription.remove();
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
return reduced;
|
|
33
|
+
}
|
|
34
|
+
function announce(text) {
|
|
35
|
+
if (text) AccessibilityInfo.announceForAccessibility(text);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { announce, useNativeLifecycle, useReducedMotion };
|
|
39
|
+
//# sourceMappingURL=chunk-PRXHS57U.js.map
|
|
40
|
+
//# sourceMappingURL=chunk-PRXHS57U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/platform.ts"],"names":[],"mappings":";;;;AAWO,SAAS,mBAAmB,KAAA,EAA8B;AAC/D,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,QAAQ,CAAC,KAAA,KACb,KAAA,CAAM,aAAA,CAAc,UAAU,QAAQ,CAAA;AACxC,IAAA,KAAA,CAAM,SAAS,YAAY,CAAA;AAC3B,IAAA,MAAM,YAAA,GAAe,QAAA,CAAS,gBAAA,CAAiB,QAAA,EAAU,KAAK,CAAA;AAC9D,IAAA,OAAO,MAAM,aAAa,MAAA,EAAO;AAAA,EACnC,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACZ;AAGO,SAAS,gBAAA,GAA4B;AAC1C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA;AAC5C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,IAAA,GAAO,IAAA;AACX,IAAA,iBAAA,CAAkB,uBAAsB,CAAE,IAAA;AAAA,MACxC,CAAC,KAAA,KAAU;AACT,QAAA,IAAI,IAAA,aAAiB,KAAK,CAAA;AAAA,MAC5B,CAAA;AAAA,MACA,MAAM;AAAA,KACR;AACA,IAAA,MAAM,eAAe,iBAAA,CAAkB,gBAAA;AAAA,MACrC,qBAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,OAAO,MAAM;AACX,MAAA,IAAA,GAAO,KAAA;AACP,MAAA,YAAA,CAAa,MAAA,EAAO;AAAA,IACtB,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,OAAA;AACT;AAGO,SAAS,SAAS,IAAA,EAAoB;AAC3C,EAAA,IAAI,IAAA,EAAM,iBAAA,CAAkB,wBAAA,CAAyB,IAAI,CAAA;AAC3D","file":"chunk-PRXHS57U.js","sourcesContent":["// The React Native platform adapter: what the conversation store learns from the app (foreground, background) and\n// what the kit asks of the platform (reduced motion, screen reader announcements).\nimport { useEffect, useState } from 'react';\nimport { AccessibilityInfo, AppState, type AppStateStatus } from 'react-native';\n\n/** The part of the conversation store the adapter drives. */\nexport interface LifecycleTarget {\n setForeground(foreground: boolean): void;\n}\n\n/** Tells the store when the app comes to the foreground or goes to the background (it pings only in the foreground). */\nexport function useNativeLifecycle(store: LifecycleTarget): void {\n useEffect(() => {\n const apply = (state: AppStateStatus) =>\n store.setForeground(state === 'active');\n apply(AppState.currentState);\n const subscription = AppState.addEventListener('change', apply);\n return () => subscription.remove();\n }, [store]);\n}\n\n/** Whether the person asked for reduced motion: animations and animated scrolling stay off. */\nexport function useReducedMotion(): boolean {\n const [reduced, setReduced] = useState(false);\n useEffect(() => {\n let live = true;\n AccessibilityInfo.isReduceMotionEnabled().then(\n (value) => {\n if (live) setReduced(value);\n },\n () => undefined,\n );\n const subscription = AccessibilityInfo.addEventListener(\n 'reduceMotionChanged',\n setReduced,\n );\n return () => {\n live = false;\n subscription.remove();\n };\n }, []);\n return reduced;\n}\n\n/** Reads a line to a screen reader, without moving focus. */\nexport function announce(text: string): void {\n if (text) AccessibilityInfo.announceForAccessibility(text);\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
|
|
6
|
+
// src/platform.ts
|
|
7
|
+
function useNativeLifecycle(store) {
|
|
8
|
+
react.useEffect(() => {
|
|
9
|
+
const apply = (state) => store.setForeground(state === "active");
|
|
10
|
+
apply(reactNative.AppState.currentState);
|
|
11
|
+
const subscription = reactNative.AppState.addEventListener("change", apply);
|
|
12
|
+
return () => subscription.remove();
|
|
13
|
+
}, [store]);
|
|
14
|
+
}
|
|
15
|
+
function useReducedMotion() {
|
|
16
|
+
const [reduced, setReduced] = react.useState(false);
|
|
17
|
+
react.useEffect(() => {
|
|
18
|
+
let live = true;
|
|
19
|
+
reactNative.AccessibilityInfo.isReduceMotionEnabled().then(
|
|
20
|
+
(value) => {
|
|
21
|
+
if (live) setReduced(value);
|
|
22
|
+
},
|
|
23
|
+
() => void 0
|
|
24
|
+
);
|
|
25
|
+
const subscription = reactNative.AccessibilityInfo.addEventListener(
|
|
26
|
+
"reduceMotionChanged",
|
|
27
|
+
setReduced
|
|
28
|
+
);
|
|
29
|
+
return () => {
|
|
30
|
+
live = false;
|
|
31
|
+
subscription.remove();
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
return reduced;
|
|
35
|
+
}
|
|
36
|
+
function announce(text) {
|
|
37
|
+
if (text) reactNative.AccessibilityInfo.announceForAccessibility(text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.announce = announce;
|
|
41
|
+
exports.useNativeLifecycle = useNativeLifecycle;
|
|
42
|
+
exports.useReducedMotion = useReducedMotion;
|
|
43
|
+
//# sourceMappingURL=chunk-PYPO6F7L.cjs.map
|
|
44
|
+
//# sourceMappingURL=chunk-PYPO6F7L.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/platform.ts"],"names":["useEffect","AppState","useState","AccessibilityInfo"],"mappings":";;;;;;AAWO,SAAS,mBAAmB,KAAA,EAA8B;AAC/D,EAAAA,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,QAAQ,CAAC,KAAA,KACb,KAAA,CAAM,aAAA,CAAc,UAAU,QAAQ,CAAA;AACxC,IAAA,KAAA,CAAMC,qBAAS,YAAY,CAAA;AAC3B,IAAA,MAAM,YAAA,GAAeA,oBAAA,CAAS,gBAAA,CAAiB,QAAA,EAAU,KAAK,CAAA;AAC9D,IAAA,OAAO,MAAM,aAAa,MAAA,EAAO;AAAA,EACnC,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACZ;AAGO,SAAS,gBAAA,GAA4B;AAC1C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAIC,eAAS,KAAK,CAAA;AAC5C,EAAAF,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,IAAA,GAAO,IAAA;AACX,IAAAG,6BAAA,CAAkB,uBAAsB,CAAE,IAAA;AAAA,MACxC,CAAC,KAAA,KAAU;AACT,QAAA,IAAI,IAAA,aAAiB,KAAK,CAAA;AAAA,MAC5B,CAAA;AAAA,MACA,MAAM;AAAA,KACR;AACA,IAAA,MAAM,eAAeA,6BAAA,CAAkB,gBAAA;AAAA,MACrC,qBAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,OAAO,MAAM;AACX,MAAA,IAAA,GAAO,KAAA;AACP,MAAA,YAAA,CAAa,MAAA,EAAO;AAAA,IACtB,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,OAAA;AACT;AAGO,SAAS,SAAS,IAAA,EAAoB;AAC3C,EAAA,IAAI,IAAA,EAAMA,6BAAA,CAAkB,wBAAA,CAAyB,IAAI,CAAA;AAC3D","file":"chunk-PYPO6F7L.cjs","sourcesContent":["// The React Native platform adapter: what the conversation store learns from the app (foreground, background) and\n// what the kit asks of the platform (reduced motion, screen reader announcements).\nimport { useEffect, useState } from 'react';\nimport { AccessibilityInfo, AppState, type AppStateStatus } from 'react-native';\n\n/** The part of the conversation store the adapter drives. */\nexport interface LifecycleTarget {\n setForeground(foreground: boolean): void;\n}\n\n/** Tells the store when the app comes to the foreground or goes to the background (it pings only in the foreground). */\nexport function useNativeLifecycle(store: LifecycleTarget): void {\n useEffect(() => {\n const apply = (state: AppStateStatus) =>\n store.setForeground(state === 'active');\n apply(AppState.currentState);\n const subscription = AppState.addEventListener('change', apply);\n return () => subscription.remove();\n }, [store]);\n}\n\n/** Whether the person asked for reduced motion: animations and animated scrolling stay off. */\nexport function useReducedMotion(): boolean {\n const [reduced, setReduced] = useState(false);\n useEffect(() => {\n let live = true;\n AccessibilityInfo.isReduceMotionEnabled().then(\n (value) => {\n if (live) setReduced(value);\n },\n () => undefined,\n );\n const subscription = AccessibilityInfo.addEventListener(\n 'reduceMotionChanged',\n setReduced,\n );\n return () => {\n live = false;\n subscription.remove();\n };\n }, []);\n return reduced;\n}\n\n/** Reads a line to a screen reader, without moving focus. */\nexport function announce(text: string): void {\n if (text) AccessibilityInfo.announceForAccessibility(text);\n}\n"]}
|