@vitraun/react-native 0.1.0 → 0.2.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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # @vitraun/react-native
2
2
 
3
- Official Vitraun Try-On adapter for React Native apps. The SDK calls **embed-init**, loads the returned **`vtoUrl`** in a WebView, and forwards cart events to your app.
3
+ Official Vitraun Virtual Try-On adapter for **React Native** apps.
4
4
 
5
- The integrator **does not** hardcode the try-on URL.
5
+ Embeds try-on via WebView. The integrator **does not** hardcode the try-on URL — the SDK calls **embed-init**, receives **`vtoUrl`**, and loads that URL in a WebView.
6
+
7
+ For **web** storefronts, use [`@vitraun/webar`](../webar/README.md) instead.
6
8
 
7
9
  ## Install
8
10
 
@@ -10,18 +12,11 @@ The integrator **does not** hardcode the try-on URL.
10
12
  npm install @vitraun/react-native react-native-webview
11
13
  ```
12
14
 
13
- Peer dependencies: `react`, `react-native`, `react-native-webview`.
15
+ Peer dependencies: `react` (≥18), `react-native` (≥0.72), `react-native-webview` (≥13).
14
16
 
15
- ## Prerequisites (Vitraun panel)
17
+ Depends on [`@vitraun/core`](../core) for embed-init HTTP helpers.
16
18
 
17
- - Register **merchant ID** and **widget ID**
18
- - Enable **`allowWebView`** on the channel
19
- - Register **iOS bundle ID** and/or **Android package name**
20
- - Add camera permission:
21
- - iOS: `NSCameraUsageDescription` in `Info.plist`
22
- - Android: `CAMERA` in `AndroidManifest.xml`
23
-
24
- ## Usage
19
+ ## Quick start
25
20
 
26
21
  ```tsx
27
22
  import { VitraunTryOn } from '@vitraun/react-native'
@@ -30,10 +25,10 @@ export const TryOnScreen = () => (
30
25
  <VitraunTryOn
31
26
  merchantId="vtrn-mch-key-00000000-0000-4000-8000-000000000001"
32
27
  widgetId="vtrn-wdg-key-00000000-0000-4000-8000-000000000002"
33
- lang="pt-BR"
28
+ lang="en-US"
34
29
  platform="ios"
35
- bundleId="com.sua.loja"
36
- packageName="com.sua.loja"
30
+ bundleId="com.your.store"
31
+ packageName="com.your.store"
37
32
  isolatedSku="8028997081552"
38
33
  basketOpensIn="event"
39
34
  checkoutOpensIn="event"
@@ -51,7 +46,70 @@ export const TryOnScreen = () => (
51
46
  )
52
47
  ```
53
48
 
54
- ## Init without UI
49
+ ## How it works
50
+
51
+ 1. The app renders `VitraunTryOn` (or calls `initializeVitraunSession`).
52
+ 2. The SDK triggers try-on by calling embed-init before the WebView loads.
53
+ 3. A WebView loads **`vtoUrl`** only; an injected bridge forwards **`postMessage`** events to `onEvent`.
54
+
55
+ Shared embed-init logic lives in [`@vitraun/core`](../core).
56
+
57
+ ## Panel prerequisites
58
+
59
+ - Register **merchant ID** and **widget ID** in the Vitraun panel
60
+ - Enable **`allowWebView`** on the channel
61
+ - Register **iOS bundle ID** and/or **Android package name**
62
+ - Add camera permission:
63
+ - iOS: `NSCameraUsageDescription` in `Info.plist`
64
+ - Android: `CAMERA` in `AndroidManifest.xml`
65
+
66
+ ## Configuration
67
+
68
+ | Option | Required | Description |
69
+ |--------|----------|-------------|
70
+ | `merchantId` | Yes | Public merchant key (`vtrn-mch-key-…`) |
71
+ | `widgetId` | Yes | Public widget key (`vtrn-wdg-key-…`) |
72
+ | `lang` | No | Locale (default `en-US`) |
73
+ | `env` | No | Environment segment (empty = production; e.g. `staging`) |
74
+ | `isolatedSku` | No | Single-product (PDP) mode |
75
+ | `applySkus` | No | SKUs pre-applied on open |
76
+ | `basketOpensIn` | No | `blank`, `self`, or `event` |
77
+ | `checkoutOpensIn` | No | `blank`, `self`, or `event` |
78
+ | `platform` | No | Sent in embed-init `app.platform` (e.g. `ios`, `android`) |
79
+ | `bundleId` | No | iOS bundle ID (panel allowlist) |
80
+ | `packageName` | No | Android package name (panel allowlist) |
81
+ | `onEvent` | No | Cart / checkout / ready callbacks |
82
+ | `onError` | No | Embed-init or load failure |
83
+ | `onReady` | No | Called when WebView URL is ready |
84
+
85
+
86
+
87
+ ## Events
88
+
89
+ | Event | Typical use |
90
+ |-------|-------------|
91
+ | `addToCart` | Add SKU to cart |
92
+ | `removeFromCart` | Remove line item |
93
+ | `redirectToCart` | Open checkout |
94
+ | `analysisFinished` | Camera / analysis ready |
95
+
96
+ ```tsx
97
+ <VitraunTryOn
98
+ merchantId="..."
99
+ widgetId="..."
100
+ onEvent={(event) => {
101
+ console.log(event.type, event.detail)
102
+ }}
103
+ />
104
+ ```
105
+
106
+ ```ts
107
+ import { VITRAUN_VTO_DEFAULT_EVENT_TYPES } from '@vitraun/react-native'
108
+ ```
109
+
110
+ ## Advanced usage
111
+
112
+ Init without the built-in component (custom WebView wrapper or preload):
55
113
 
56
114
  ```ts
57
115
  import { initializeVitraunSession } from '@vitraun/react-native'
@@ -61,30 +119,30 @@ const session = await initializeVitraunSession({
61
119
  merchantId: 'vtrn-mch-key-...',
62
120
  widgetId: 'vtrn-wdg-key-...',
63
121
  lang: 'en-US',
64
- app: { platform: 'android', packageName: 'com.sua.loja' },
122
+ app: { platform: 'android', packageName: 'com.your.store' },
65
123
  },
66
124
  })
67
125
 
68
- // session.vtoUrl — load in your own WebView if needed
126
+ // session.vtoUrl — load in your WebView
127
+ // session.sessionToken — embed session JWT when required by channel
69
128
  ```
70
129
 
71
- ## Staging
130
+ Lower-level hook:
72
131
 
73
- ```tsx
74
- <VitraunTryOn env="staging" merchantId="..." widgetId="..." />
132
+ ```ts
133
+ import { useVitraunInit } from '@vitraun/react-native'
75
134
  ```
76
135
 
77
- ## Events
78
-
79
- Same contract as `@vitraun/webar`:
136
+ ## Distribution
80
137
 
81
- - `addToCart`
82
- - `removeFromCart`
83
- - `redirectToCart`
84
- - `analysisFinished`
138
+ Published via **npm** only (`npm install @vitraun/react-native`). There is no CDN script bundle for this package.
85
139
 
86
- ## Related docs
140
+ ## Package exports
87
141
 
88
- - Mobile HTTP contract: [`../docs/mobile-sdk-contract.md`](../docs/mobile-sdk-contract.md)
89
- - iOS native stub: [`../ios/README.md`](../ios/README.md)
90
- - Android native stub: [`../android/README.md`](../android/README.md)
142
+ | Export | Description |
143
+ |--------|-------------|
144
+ | `VitraunTryOn` | WebView component with embed-init |
145
+ | `useVitraunInit` | Embed-init hook (loading / error / session) |
146
+ | `initializeVitraunSession` | Init without UI (re-export from core) |
147
+ | `handleVitraunWebViewMessage` | Parse `WebView` `onMessage` payload |
148
+ | `buildInjectedJavaScriptBeforeContentLoaded` | Bridge + optional native config inject |
package/dist/index.d.ts CHANGED
@@ -42,6 +42,8 @@ export type VitraunTryOnProps = {
42
42
  basketOpensIn?: VitraunTryOnBasketOpensIn
43
43
  checkoutOpensIn?: VitraunTryOnCheckoutOpensIn
44
44
  useSimplePage?: boolean
45
+ /** Desktop QR handoff; no effect on mobile WebView (already on phone). */
46
+ useQrCode?: boolean
45
47
  showDetails?: boolean
46
48
  showProductPrice?: boolean
47
49
  priceFrom?: number | null
package/dist/index.js CHANGED
@@ -93,6 +93,9 @@ var buildNativeConfigOverrides = (props) => {
93
93
  if (props.useSimplePage != null) {
94
94
  overrides.useSimplePage = props.useSimplePage;
95
95
  }
96
+ if (props.useQrCode != null) {
97
+ overrides.useQrCode = props.useQrCode;
98
+ }
96
99
  if (props.showDetails != null) {
97
100
  overrides.showDetails = props.showDetails;
98
101
  }
@@ -265,6 +268,7 @@ var VitraunTryOn = (props) => {
265
268
  basketOpensIn,
266
269
  checkoutOpensIn,
267
270
  useSimplePage,
271
+ useQrCode,
268
272
  showDetails,
269
273
  showProductPrice,
270
274
  priceFrom,
@@ -343,6 +347,7 @@ var VitraunTryOn = (props) => {
343
347
  checkoutOpensIn,
344
348
  flow,
345
349
  useSimplePage,
350
+ useQrCode,
346
351
  showDetails,
347
352
  showProductPrice,
348
353
  priceFrom,
@@ -358,6 +363,7 @@ var VitraunTryOn = (props) => {
358
363
  checkoutOpensIn,
359
364
  flow,
360
365
  useSimplePage,
366
+ useQrCode,
361
367
  showDetails,
362
368
  showProductPrice,
363
369
  priceFrom,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitraun/react-native",
3
- "version": "0.1.0",
3
+ "version": "0.2.6",
4
4
  "description": "Vitraun Try-On React Native adapter (WebView + embed-init bridge)",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "repository": {