react-native-glance-chat 0.0.0-stage → 0.1.3

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 (46) hide show
  1. package/GlanceChat.podspec +20 -0
  2. package/LICENSE +20 -0
  3. package/README.md +50 -2
  4. package/android/build.gradle +104 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/glancechat/GlanceChatModuleImpl.kt +174 -0
  7. package/android/src/main/java/com/glancechat/GlanceChatOverlayHostView.kt +39 -0
  8. package/android/src/main/java/com/glancechat/GlanceChatOverlayViewManager.kt +74 -0
  9. package/android/src/main/java/com/glancechat/GlanceChatPackage.kt +40 -0
  10. package/android/src/main/java/com/glancechat/GlanceMixAndMatchWidgetViewManager.kt +142 -0
  11. package/android/src/main/java/com/glancechat/GlancePdpSuggestionsViewManager.kt +40 -0
  12. package/android/src/main/java/com/glancechat/GlanceProductTryOnWidgetViewManager.kt +145 -0
  13. package/android/src/main/java/com/glancechat/UrlBrandLogoProvider.kt +24 -0
  14. package/android/src/newarch/java/com/glancechat/GlanceChatModule.kt +44 -0
  15. package/android/src/oldarch/java/com/glancechat/GlanceChatModule.kt +59 -0
  16. package/ios/GlanceChat.h +5 -0
  17. package/ios/GlanceChat.mm +21 -0
  18. package/lib/module/GlanceChatOverlayNativeComponent.ts +22 -0
  19. package/lib/module/GlanceMixAndMatchWidgetNativeComponent.ts +21 -0
  20. package/lib/module/GlancePdpSuggestionsNativeComponent.ts +9 -0
  21. package/lib/module/GlanceProductTryOnWidgetNativeComponent.ts +18 -0
  22. package/lib/module/NativeGlanceChat.js +20 -0
  23. package/lib/module/NativeGlanceChat.js.map +1 -0
  24. package/lib/module/index.js +65 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/package.json +1 -0
  27. package/lib/typescript/package.json +1 -0
  28. package/lib/typescript/src/GlanceChatOverlayNativeComponent.d.ts +18 -0
  29. package/lib/typescript/src/GlanceChatOverlayNativeComponent.d.ts.map +1 -0
  30. package/lib/typescript/src/GlanceMixAndMatchWidgetNativeComponent.d.ts +17 -0
  31. package/lib/typescript/src/GlanceMixAndMatchWidgetNativeComponent.d.ts.map +1 -0
  32. package/lib/typescript/src/GlancePdpSuggestionsNativeComponent.d.ts +6 -0
  33. package/lib/typescript/src/GlancePdpSuggestionsNativeComponent.d.ts.map +1 -0
  34. package/lib/typescript/src/GlanceProductTryOnWidgetNativeComponent.d.ts +14 -0
  35. package/lib/typescript/src/GlanceProductTryOnWidgetNativeComponent.d.ts.map +1 -0
  36. package/lib/typescript/src/NativeGlanceChat.d.ts +79 -0
  37. package/lib/typescript/src/NativeGlanceChat.d.ts.map +1 -0
  38. package/lib/typescript/src/index.d.ts +34 -0
  39. package/lib/typescript/src/index.d.ts.map +1 -0
  40. package/package.json +126 -4
  41. package/src/GlanceChatOverlayNativeComponent.ts +22 -0
  42. package/src/GlanceMixAndMatchWidgetNativeComponent.ts +21 -0
  43. package/src/GlancePdpSuggestionsNativeComponent.ts +9 -0
  44. package/src/GlanceProductTryOnWidgetNativeComponent.ts +18 -0
  45. package/src/NativeGlanceChat.ts +96 -0
  46. package/src/index.tsx +78 -0
@@ -0,0 +1,79 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypesNamespace';
3
+ /**
4
+ * Configuration passed to {@link Spec.initialize}. Mirrors the native
5
+ * `GlanceChatConfig.Builder` — only the client-facing fields. The SDK derives
6
+ * Firebase credentials, endpoints, and auth URLs internally per environment.
7
+ */
8
+ export type GlanceChatConfig = {
9
+ environment: string;
10
+ storeHandle: string;
11
+ brandName?: string;
12
+ brandLogoUrl?: string;
13
+ productDeeplinkBaseUrl?: string;
14
+ };
15
+ /** Payload for the {@link Spec.onProductClick} event. */
16
+ export type ProductClickEvent = {
17
+ productId: string;
18
+ name: string;
19
+ };
20
+ /**
21
+ * Payload for {@link Spec.onTryOnStatesChanged}: a map of variantId -> status
22
+ * string (e.g. 'IDLE' | 'GENERATING' | 'READY' | 'FAILED'). Codegen does not
23
+ * support Map, so it is serialized as a plain object.
24
+ */
25
+ export type TryOnStatesEvent = {
26
+ states: {
27
+ [variantId: string]: string;
28
+ };
29
+ };
30
+ export interface Spec extends TurboModule {
31
+ /**
32
+ * Initialize the SDK. The native `Context` / root view controller is resolved
33
+ * internally, so it is not part of this signature. Must be called once before
34
+ * any other method.
35
+ *
36
+ * `userId` is an optional host-supplied identifier (e.g. the app's logged-in
37
+ * user id). The SDK uses it only as the device/user identifier when minting its
38
+ * guest token — it does NOT authenticate the user or skip Glance onboarding.
39
+ * When omitted, the SDK falls back to the device id.
40
+ */
41
+ initialize(partnerId: string, config: GlanceChatConfig, userId?: string | null): void;
42
+ /** Tear down the SDK and release resources. */
43
+ destroy(): void;
44
+ /** Whether {@link initialize} has completed. */
45
+ isInitialized(): boolean;
46
+ /** Whether the user is currently logged in. */
47
+ isLoggedIn(): boolean;
48
+ /**
49
+ * Update the current page context (e.g. 'PLP' / 'PDP') and its metadata so the
50
+ * SDK can drive nudges and prefetch the product feed.
51
+ */
52
+ setPageContext(context: string, metadata: {
53
+ [key: string]: string;
54
+ }): void;
55
+ /** Clear the current page context. */
56
+ clearPageContext(): void;
57
+ /** Close the chat surface if open. */
58
+ closeChat(): void;
59
+ /** Open the chat pre-filled with a suggestion. */
60
+ openChatWithSuggestion(suggestion: string): void;
61
+ /** Handle a deep link; returns true if the SDK consumed it. */
62
+ handleDeepLink(uri: string): boolean;
63
+ /**
64
+ * Start the onboarding flow (consent → selfie → avatar creation) directly, e.g.
65
+ * from a "create your avatar" entry point. No-op when not initialized.
66
+ */
67
+ startOnboarding(variantId?: string | null): void;
68
+ /** Emitted when the user taps a product inside SDK UI. */
69
+ readonly onProductClick: EventEmitter<ProductClickEvent>;
70
+ /** Emitted when the SDK requests the host to open a deeplink URL. */
71
+ readonly onDeeplinkClick: EventEmitter<string>;
72
+ /** Emitted whenever the try-on state map changes. */
73
+ readonly onTryOnStatesChanged: EventEmitter<TryOnStatesEvent>;
74
+ /** Emitted when the auth session expires and the host should re-authenticate. */
75
+ readonly onSessionExpired: EventEmitter<void>;
76
+ }
77
+ declare const _default: Spec;
78
+ export default _default;
79
+ //# sourceMappingURL=NativeGlanceChat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeGlanceChat.d.ts","sourceRoot":"","sources":["../../../src/NativeGlanceChat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AAGvF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACzC,CAAC;AAEF,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;;;;;;;;OASG;IACH,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,EACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,IAAI,CAAC;IAER,+CAA+C;IAC/C,OAAO,IAAI,IAAI,CAAC;IAEhB,gDAAgD;IAChD,aAAa,IAAI,OAAO,CAAC;IAEzB,+CAA+C;IAC/C,UAAU,IAAI,OAAO,CAAC;IAEtB;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAE3E,sCAAsC;IACtC,gBAAgB,IAAI,IAAI,CAAC;IAEzB,sCAAsC;IACtC,SAAS,IAAI,IAAI,CAAC;IAElB,kDAAkD;IAClD,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjD,+DAA+D;IAC/D,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAErC;;;OAGG;IACH,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAEjD,0DAA0D;IAC1D,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAEzD,qEAAqE;IACrE,QAAQ,CAAC,eAAe,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAE/C,qDAAqD;IACrD,QAAQ,CAAC,oBAAoB,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAE9D,iFAAiF;IACjF,QAAQ,CAAC,gBAAgB,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CAC/C;;AAED,wBAAoE"}
@@ -0,0 +1,34 @@
1
+ import type { GlanceChatConfig, ProductClickEvent, TryOnStatesEvent } from './NativeGlanceChat';
2
+ export type { GlanceChatConfig, ProductClickEvent, TryOnStatesEvent };
3
+ export { default as GlanceChatOverlay } from './GlanceChatOverlayNativeComponent';
4
+ export { default as GlanceProductTryOnWidget } from './GlanceProductTryOnWidgetNativeComponent';
5
+ export { default as GlanceMixAndMatchWidget } from './GlanceMixAndMatchWidgetNativeComponent';
6
+ export { default as GlancePdpSuggestions } from './GlancePdpSuggestionsNativeComponent';
7
+ /** Environments the SDK supports. */
8
+ export declare const GlanceEnvironment: {
9
+ readonly DEVELOPMENT: "DEVELOPMENT";
10
+ readonly UAT: "UAT";
11
+ readonly PRODUCTION: "PRODUCTION";
12
+ };
13
+ export type GlanceEnvironment = (typeof GlanceEnvironment)[keyof typeof GlanceEnvironment];
14
+ /**
15
+ * Imperative API for the Glance Chat SDK. Thin wrapper over the native
16
+ * TurboModule; see `docs/REACT_NATIVE_INTEGRATION.md` in the Helios-Android repo.
17
+ */
18
+ export declare const Glance: {
19
+ initialize(partnerId: string, config: GlanceChatConfig, userId?: string | null): void;
20
+ destroy(): void;
21
+ isInitialized(): boolean;
22
+ isLoggedIn(): boolean;
23
+ setPageContext(context: string, metadata?: Record<string, string>): void;
24
+ clearPageContext(): void;
25
+ closeChat(): void;
26
+ openChatWithSuggestion(suggestion: string): void;
27
+ handleDeepLink(uri: string): boolean;
28
+ startOnboarding(variantId?: string): void;
29
+ onProductClick(listener: (event: ProductClickEvent) => void): import("react-native").EventSubscription;
30
+ onDeeplinkClick(listener: (uri: string) => void): import("react-native").EventSubscription;
31
+ onTryOnStatesChanged(listener: (event: TryOnStatesEvent) => void): import("react-native").EventSubscription;
32
+ onSessionExpired(listener: () => void): import("react-native").EventSubscription;
33
+ };
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAGtE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAChG,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAExF,qCAAqC;AACrC,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AACX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,MAAM;0BAEJ,MAAM,UACT,gBAAgB,WACf,MAAM,GAAG,IAAI,GACrB,IAAI;eAGI,IAAI;qBAGE,OAAO;kBAGV,OAAO;4BAGG,MAAM,aAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAQ,IAAI;wBAGxD,IAAI;iBAGX,IAAI;uCAGkB,MAAM,GAAG,IAAI;wBAG5B,MAAM,GAAG,OAAO;gCAGR,MAAM,GAAG,IAAI;6BAKhB,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI;8BAGjC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI;mCAGhB,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI;+BAGrC,MAAM,IAAI;CAGtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,128 @@
1
1
  {
2
2
  "name": "react-native-glance-chat",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "React Native wrapper for the Glance Chat SDK (Android + iOS)",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "react-native-glance-chat-source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "example": "yarn workspace react-native-glance-chat-example",
36
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
37
+ "prepare": "bob build",
38
+ "typecheck": "tsc",
39
+ "lint": "eslint \"**/*.{js,ts,tsx}\""
40
+ },
41
+ "keywords": [
42
+ "react-native",
43
+ "ios",
44
+ "android"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/inmobi-glance/react-native-glance-chat.git"
49
+ },
50
+ "author": "Glance <bx@glance.com> (https://github.com/inmobi-glance)",
51
+ "license": "MIT",
52
+ "bugs": {
53
+ "url": "https://github.com/inmobi-glance/react-native-glance-chat/issues"
54
+ },
55
+ "homepage": "https://github.com/inmobi-glance/react-native-glance-chat#readme",
56
+ "publishConfig": {
57
+ "registry": "https://registry.npmjs.org/",
58
+ "access": "public"
59
+ },
60
+ "devDependencies": {
61
+ "@eslint/compat": "^2.1.0",
62
+ "@eslint/eslintrc": "^3.3.5",
63
+ "@eslint/js": "^10.0.1",
64
+ "@react-native/babel-preset": "0.85.0",
65
+ "@react-native/eslint-config": "0.85.0",
66
+ "@types/react": "^19.2.0",
67
+ "del-cli": "^7.0.0",
68
+ "eslint": "^9.39.4",
69
+ "eslint-config-prettier": "^10.1.8",
70
+ "eslint-plugin-ft-flow": "^3.0.11",
71
+ "eslint-plugin-prettier": "^5.5.6",
72
+ "prettier": "^3.8.3",
73
+ "react": "19.2.3",
74
+ "react-native": "0.85.0",
75
+ "react-native-builder-bob": "^0.41.0",
76
+ "turbo": "^2.9.16",
77
+ "typescript": "^6.0.3"
78
+ },
79
+ "peerDependencies": {
80
+ "react": "*",
81
+ "react-native": "*"
82
+ },
83
+ "workspaces": [
84
+ "example"
85
+ ],
86
+ "packageManager": "yarn@4.11.0+sha512.4e54aeace9141df2f0177c266b05ec50dc044638157dae128c471ba65994ac802122d7ab35bcd9e81641228b7dcf24867d28e750e0bcae8a05277d600008ad54",
87
+ "react-native-builder-bob": {
88
+ "source": "src",
89
+ "output": "lib",
90
+ "targets": [
91
+ [
92
+ "module",
93
+ {
94
+ "esm": true
95
+ }
96
+ ],
97
+ [
98
+ "typescript",
99
+ {
100
+ "project": "tsconfig.build.json"
101
+ }
102
+ ]
103
+ ]
104
+ },
105
+ "codegenConfig": {
106
+ "name": "GlanceChatSpec",
107
+ "type": "all",
108
+ "jsSrcsDir": "src",
109
+ "android": {
110
+ "javaPackageName": "com.glancechat"
111
+ }
112
+ },
113
+ "prettier": {
114
+ "quoteProps": "consistent",
115
+ "singleQuote": true,
116
+ "tabWidth": 2,
117
+ "trailingComma": "es5",
118
+ "useTabs": false
119
+ },
120
+ "create-react-native-library": {
121
+ "type": "turbo-module",
122
+ "languages": "kotlin-objc",
123
+ "tools": [
124
+ "eslint"
125
+ ],
126
+ "version": "0.63.0"
127
+ }
128
+ }
@@ -0,0 +1,22 @@
1
+ import type { ViewProps, HostComponent } from 'react-native';
2
+ import { codegenNativeComponent } from 'react-native';
3
+
4
+ export interface NativeProps extends ViewProps {
5
+ /**
6
+ * Optional brand logo URL rendered in the chat header. Replaces the native
7
+ * `BrandLogoProvider` interface (which cannot cross the bridge) with a
8
+ * serializable prop; the native side builds a provider that loads the URL.
9
+ */
10
+ brandLogoUrl?: string;
11
+
12
+ /**
13
+ * When false, hides the chat FAB/dialog, AI Store, and All Looks UI entirely —
14
+ * only onboarding and the try-on result screen remain. Defaults to true (chat
15
+ * enabled) so existing consumers are unaffected.
16
+ */
17
+ chatEnabled?: boolean;
18
+ }
19
+
20
+ export default codegenNativeComponent<NativeProps>(
21
+ 'GlanceChatOverlayView'
22
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,21 @@
1
+ import type { ViewProps, HostComponent } from 'react-native';
2
+ import type { BubblingEventHandler } from 'react-native/Libraries/Types/CodegenTypesNamespace';
3
+ import { codegenNativeComponent } from 'react-native';
4
+
5
+ export type AddToCartEvent = Readonly<{
6
+ productId: string;
7
+ size: string;
8
+ }>;
9
+
10
+ export interface NativeProps extends ViewProps {
11
+ /** Merchant variant id of the anchor product the tray recommends for. */
12
+ variantId: string;
13
+ /** Whether the widget is interactive. Defaults to true on the native side. */
14
+ enabled?: boolean;
15
+ /** Fired when a size is confirmed in the add-to-cart sheet. */
16
+ onAddToCartClick?: BubblingEventHandler<AddToCartEvent> | null;
17
+ }
18
+
19
+ export default codegenNativeComponent<NativeProps>(
20
+ 'GlanceMixAndMatchWidgetView'
21
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,9 @@
1
+ import type { ViewProps, HostComponent } from 'react-native';
2
+ import { codegenNativeComponent } from 'react-native';
3
+
4
+ // PDP suggestions widget takes no configurable props (pure UI driven by page context).
5
+ export interface NativeProps extends ViewProps {}
6
+
7
+ export default codegenNativeComponent<NativeProps>(
8
+ 'GlancePdpSuggestionsView'
9
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,18 @@
1
+ import type { ViewProps, HostComponent } from 'react-native';
2
+ import type { BubblingEventHandler } from 'react-native/Libraries/Types/CodegenTypesNamespace';
3
+ import { codegenNativeComponent } from 'react-native';
4
+
5
+ type PressEvent = Readonly<{}>;
6
+
7
+ export interface NativeProps extends ViewProps {
8
+ /** Merchant variant id the widget kicks off a try-on / feed fetch for. */
9
+ variantId: string;
10
+ /** Whether the widget is interactive. Defaults to true on the native side. */
11
+ enabled?: boolean;
12
+ /** Fired when the widget is tapped (maps to the native onClick lambda). */
13
+ onPress?: BubblingEventHandler<PressEvent> | null;
14
+ }
15
+
16
+ export default codegenNativeComponent<NativeProps>(
17
+ 'GlanceProductTryOnWidgetView'
18
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,96 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypesNamespace';
3
+ import { TurboModuleRegistry } from 'react-native';
4
+
5
+ /**
6
+ * Configuration passed to {@link Spec.initialize}. Mirrors the native
7
+ * `GlanceChatConfig.Builder` — only the client-facing fields. The SDK derives
8
+ * Firebase credentials, endpoints, and auth URLs internally per environment.
9
+ */
10
+ export type GlanceChatConfig = {
11
+ environment: string; // 'DEVELOPMENT' | 'UAT' | 'PRODUCTION'
12
+ storeHandle: string;
13
+ brandName?: string;
14
+ brandLogoUrl?: string;
15
+ productDeeplinkBaseUrl?: string;
16
+ };
17
+
18
+ /** Payload for the {@link Spec.onProductClick} event. */
19
+ export type ProductClickEvent = {
20
+ productId: string;
21
+ name: string;
22
+ };
23
+
24
+ /**
25
+ * Payload for {@link Spec.onTryOnStatesChanged}: a map of variantId -> status
26
+ * string (e.g. 'IDLE' | 'GENERATING' | 'READY' | 'FAILED'). Codegen does not
27
+ * support Map, so it is serialized as a plain object.
28
+ */
29
+ export type TryOnStatesEvent = {
30
+ states: { [variantId: string]: string };
31
+ };
32
+
33
+ export interface Spec extends TurboModule {
34
+ /**
35
+ * Initialize the SDK. The native `Context` / root view controller is resolved
36
+ * internally, so it is not part of this signature. Must be called once before
37
+ * any other method.
38
+ *
39
+ * `userId` is an optional host-supplied identifier (e.g. the app's logged-in
40
+ * user id). The SDK uses it only as the device/user identifier when minting its
41
+ * guest token — it does NOT authenticate the user or skip Glance onboarding.
42
+ * When omitted, the SDK falls back to the device id.
43
+ */
44
+ initialize(
45
+ partnerId: string,
46
+ config: GlanceChatConfig,
47
+ userId?: string | null
48
+ ): void;
49
+
50
+ /** Tear down the SDK and release resources. */
51
+ destroy(): void;
52
+
53
+ /** Whether {@link initialize} has completed. */
54
+ isInitialized(): boolean;
55
+
56
+ /** Whether the user is currently logged in. */
57
+ isLoggedIn(): boolean;
58
+
59
+ /**
60
+ * Update the current page context (e.g. 'PLP' / 'PDP') and its metadata so the
61
+ * SDK can drive nudges and prefetch the product feed.
62
+ */
63
+ setPageContext(context: string, metadata: { [key: string]: string }): void;
64
+
65
+ /** Clear the current page context. */
66
+ clearPageContext(): void;
67
+
68
+ /** Close the chat surface if open. */
69
+ closeChat(): void;
70
+
71
+ /** Open the chat pre-filled with a suggestion. */
72
+ openChatWithSuggestion(suggestion: string): void;
73
+
74
+ /** Handle a deep link; returns true if the SDK consumed it. */
75
+ handleDeepLink(uri: string): boolean;
76
+
77
+ /**
78
+ * Start the onboarding flow (consent → selfie → avatar creation) directly, e.g.
79
+ * from a "create your avatar" entry point. No-op when not initialized.
80
+ */
81
+ startOnboarding(variantId?: string | null): void;
82
+
83
+ /** Emitted when the user taps a product inside SDK UI. */
84
+ readonly onProductClick: EventEmitter<ProductClickEvent>;
85
+
86
+ /** Emitted when the SDK requests the host to open a deeplink URL. */
87
+ readonly onDeeplinkClick: EventEmitter<string>;
88
+
89
+ /** Emitted whenever the try-on state map changes. */
90
+ readonly onTryOnStatesChanged: EventEmitter<TryOnStatesEvent>;
91
+
92
+ /** Emitted when the auth session expires and the host should re-authenticate. */
93
+ readonly onSessionExpired: EventEmitter<void>;
94
+ }
95
+
96
+ export default TurboModuleRegistry.getEnforcing<Spec>('GlanceChat');
package/src/index.tsx ADDED
@@ -0,0 +1,78 @@
1
+ import GlanceChat from './NativeGlanceChat';
2
+ import type {
3
+ GlanceChatConfig,
4
+ ProductClickEvent,
5
+ TryOnStatesEvent,
6
+ } from './NativeGlanceChat';
7
+
8
+ export type { GlanceChatConfig, ProductClickEvent, TryOnStatesEvent };
9
+
10
+ // Native UI components (Fabric). Each hosts the corresponding SDK Composable.
11
+ export { default as GlanceChatOverlay } from './GlanceChatOverlayNativeComponent';
12
+ export { default as GlanceProductTryOnWidget } from './GlanceProductTryOnWidgetNativeComponent';
13
+ export { default as GlanceMixAndMatchWidget } from './GlanceMixAndMatchWidgetNativeComponent';
14
+ export { default as GlancePdpSuggestions } from './GlancePdpSuggestionsNativeComponent';
15
+
16
+ /** Environments the SDK supports. */
17
+ export const GlanceEnvironment = {
18
+ DEVELOPMENT: 'DEVELOPMENT',
19
+ UAT: 'UAT',
20
+ PRODUCTION: 'PRODUCTION',
21
+ } as const;
22
+ export type GlanceEnvironment =
23
+ (typeof GlanceEnvironment)[keyof typeof GlanceEnvironment];
24
+
25
+ /**
26
+ * Imperative API for the Glance Chat SDK. Thin wrapper over the native
27
+ * TurboModule; see `docs/REACT_NATIVE_INTEGRATION.md` in the Helios-Android repo.
28
+ */
29
+ export const Glance = {
30
+ initialize(
31
+ partnerId: string,
32
+ config: GlanceChatConfig,
33
+ userId?: string | null
34
+ ): void {
35
+ GlanceChat.initialize(partnerId, config, userId ?? null);
36
+ },
37
+ destroy(): void {
38
+ GlanceChat.destroy();
39
+ },
40
+ isInitialized(): boolean {
41
+ return GlanceChat.isInitialized();
42
+ },
43
+ isLoggedIn(): boolean {
44
+ return GlanceChat.isLoggedIn();
45
+ },
46
+ setPageContext(context: string, metadata: Record<string, string> = {}): void {
47
+ GlanceChat.setPageContext(context, metadata);
48
+ },
49
+ clearPageContext(): void {
50
+ GlanceChat.clearPageContext();
51
+ },
52
+ closeChat(): void {
53
+ GlanceChat.closeChat();
54
+ },
55
+ openChatWithSuggestion(suggestion: string): void {
56
+ GlanceChat.openChatWithSuggestion(suggestion);
57
+ },
58
+ handleDeepLink(uri: string): boolean {
59
+ return GlanceChat.handleDeepLink(uri);
60
+ },
61
+ startOnboarding(variantId?: string): void {
62
+ GlanceChat.startOnboarding(variantId);
63
+ },
64
+
65
+ // --- Event subscriptions -------------------------------------------------
66
+ onProductClick(listener: (event: ProductClickEvent) => void) {
67
+ return GlanceChat.onProductClick(listener);
68
+ },
69
+ onDeeplinkClick(listener: (uri: string) => void) {
70
+ return GlanceChat.onDeeplinkClick(listener);
71
+ },
72
+ onTryOnStatesChanged(listener: (event: TryOnStatesEvent) => void) {
73
+ return GlanceChat.onTryOnStatesChanged(listener);
74
+ },
75
+ onSessionExpired(listener: () => void) {
76
+ return GlanceChat.onSessionExpired(listener);
77
+ },
78
+ };