@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 +66 -24
- package/dist/chunk-NP2KCM7X.js +3859 -0
- package/dist/chunk-NP2KCM7X.js.map +1 -0
- package/dist/{chunk-4CCGE7DE.js → chunk-NWORYWIL.js} +2649 -1711
- package/dist/chunk-NWORYWIL.js.map +1 -0
- package/dist/chunk-PBQSHIID.js +3 -0
- package/dist/{chunk-GGM2AIK5.js.map → chunk-PBQSHIID.js.map} +1 -1
- package/dist/core/index.d.ts +314 -12
- package/dist/core/index.js +2 -2
- package/dist/index.d.ts +1 -4
- package/dist/index.js +2 -3
- package/dist/react/index.d.ts +23 -0
- package/dist/react/index.js +74 -0
- package/dist/react/index.js.map +1 -0
- package/dist/ui/index.d.ts +29 -4
- package/dist/ui/index.js +136 -2
- package/dist/ui/index.js.map +1 -1
- package/dist/{vio-checkout-D8B4Upk8.d.ts → vio-checkout-T9R5hpDx.d.ts} +137 -10
- package/package.json +18 -2
- package/dist/chunk-4CCGE7DE.js.map +0 -1
- package/dist/chunk-5SPY7TH6.js +0 -1618
- package/dist/chunk-5SPY7TH6.js.map +0 -1
- package/dist/chunk-GGM2AIK5.js +0 -3
package/README.md
CHANGED
|
@@ -1,52 +1,94 @@
|
|
|
1
|
-
#
|
|
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
|
-
**
|
|
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
|
|
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
|
-
|
|
11
|
+
## Install
|
|
12
12
|
|
|
13
|
-
|
|
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'
|
|
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({
|
|
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
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
92
|
+
## License
|
|
51
93
|
|
|
52
|
-
|
|
94
|
+
MIT © Vio
|