@vio-live/web-sdk 0.1.0 → 0.3.0

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,52 +1,94 @@
1
- # Vio Web SDK
1
+ # @vio-live/web-sdk
2
2
 
3
3
  In-site shoppable + native checkout for editorial commerce sites. Web SDK companion to Vio's iOS, Android (Kotlin) and Apple TV SDKs.
4
4
 
5
- **Status**: scaffolding, under active development. Not yet published to npm.
5
+ Lit **web components** (`<vio-*>`) on top of a headless **core** (cart, checkout, Apple Pay, Klarna, Vio Commerce). Published on npm — **public**, MIT.
6
6
 
7
7
  ## Why this exists
8
8
 
9
- Editorial publishers (magazines, fashion/lifestyle hubs, news sites) typically integrate commerce via **affiliate click-out** — the reader leaves the site to buy on a third-party retailer. That introduces friction and breaks attribution outside the cookie model.
9
+ Editorial publishers typically integrate commerce via **affiliate click-out** — the reader leaves the site to buy on a third-party retailer, which adds friction and breaks attribution outside the cookie model. Vio replaces click-out with **in-site native checkout**: the reader stays in the article, taps a product card, and pays via Apple Pay / Klarna — while the publisher still gets paid through the standard `click_id` + postback model.
10
10
 
11
- Vio replaces click-out with **in-site native checkout**: the reader stays in the article, taps a product card, completes the purchase via Apple Pay / Klarna / Vipps, and the affiliate publisher still gets paid through the standard `click_id` + postback model (Adtraction-compatible by default).
11
+ ## Install
12
12
 
13
- ## Quick start (planned API — components in progress)
13
+ ```bash
14
+ npm install @vio-live/web-sdk
15
+ # The React wrappers also need React 18+ (optional peer dependency):
16
+ npm install react react-dom
17
+ ```
18
+
19
+ ## Quick start — web components
14
20
 
15
21
  ```ts
16
- import { Vio } from 'vio'
17
- import 'vio/ui' // registers <vio-product-carousel>, <vio-product>, etc.
22
+ import { Vio } from '@vio-live/web-sdk'
23
+ import '@vio-live/web-sdk/ui' // registers <vio-product-carousel>, <vio-cart>, …
18
24
 
19
- Vio.init({ apiKey: import.meta.env.VITE_VIO_API_KEY })
25
+ Vio.init({
26
+ apiKey: import.meta.env.VITE_VIO_API_KEY,
27
+ // apiBase, graphqlBase, stripePublishableKey — optional overrides
28
+ })
20
29
  ```
21
30
 
22
31
  ```html
23
- <!-- Drop-in carousel that matches the editorial style of the host site -->
24
32
  <vio-product-carousel
25
- campaign-id="36"
26
- location="news-favorites"
27
- label="REDAKSJONENS FAVORITTER"
28
- heading="Shop Favorittene"
33
+ label="Ukens funn"
34
+ heading="Våre favoritter"
29
35
  disclaimer="annonselenker"
36
+ product-refs="1:408909,1:408910,1:408911"
37
+ currency="NOK"
30
38
  ></vio-product-carousel>
39
+
40
+ <!-- Add once near the root for the slide-in cart + express checkout -->
41
+ <vio-cart></vio-cart>
31
42
  ```
32
43
 
33
- React opt-in:
44
+ `product-refs` is a comma-separated list of `sponsorId:productId` pairs; the carousel fetches them from Vio Commerce and renders the cards.
45
+
46
+ ## React
47
+
48
+ Typed wrappers (built on `@lit/react`). Importing this entry **registers the elements** — no separate `/ui` import needed.
34
49
 
35
50
  ```tsx
36
- import { VioProvider, useCart } from 'vio/react'
51
+ import { Vio } from '@vio-live/web-sdk'
52
+ import { VioProductCarousel, VioCart } from '@vio-live/web-sdk/react'
53
+
54
+ Vio.init({ apiKey: '…' })
55
+
56
+ function Shop() {
57
+ return (
58
+ <>
59
+ <VioProductCarousel
60
+ label="Ukens funn"
61
+ heading="Våre favoritter"
62
+ productRefs="1:408909,1:408910"
63
+ onProductAdd={(e) => console.log('added', e.detail)}
64
+ />
65
+ <VioCart onPaymentSuccess={(e) => console.log('paid', e.detail)} />
66
+ </>
67
+ )
68
+ }
37
69
  ```
38
70
 
39
- ## Architecture
71
+ Wrappers: `VioProduct`, `VioProductCarousel`, `VioProductDetail`, `VioCart`, `VioCheckout`.
40
72
 
73
+ ## Headless / SSR
74
+
75
+ The root and `/core` entries export the framework-agnostic core with **no DOM side-effects** — SSR-safe and **tree-shakeable** (importing one helper pulls only that helper, ~0.5 kB):
76
+
77
+ ```ts
78
+ import { Vio, formatPrice, type Product } from '@vio-live/web-sdk/core'
41
79
  ```
42
- src/
43
- ├── core/ config, Vio + Commerce GraphQL clients, cart, checkout, adtraction
44
- ├── ui/ Web Components + design tokens
45
- └── react/ Optional React hooks + components
46
- ```
47
80
 
48
- Single npm package, single install, single version. Sub-folders are organisational only; the `exports` map allows partial imports for tree-shaking.
81
+ ## Entry points
82
+
83
+ | Import | What you get | Registers `<vio-*>` |
84
+ |---|---|---|
85
+ | `@vio-live/web-sdk` | headless core (`Vio`, managers, types) — tree-shakeable | no |
86
+ | `@vio-live/web-sdk/core` | same as above, explicit | no |
87
+ | `@vio-live/web-sdk/ui` | registers the web components (+ injects design tokens) | yes |
88
+ | `@vio-live/web-sdk/react` | typed React wrappers | yes |
89
+
90
+ > **Registration is explicit.** The root/`core` entries are headless so they tree-shake cleanly. Render the components by importing `/ui` (side-effect) or `/react`. `registerVioElements()` is also exported from `/ui` if you'd rather register manually.
49
91
 
50
- ## Repo
92
+ ## License
51
93
 
52
- Lives in `vio-live/...` (TBD — currently developed locally, not yet pushed).
94
+ MIT © Vio