-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathindex.ts
43 lines (41 loc) · 980 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {
ShippingForm,
PaymentForm,
Checkout,
Cart,
CartCount,
} from './components/index'
import start, { cart, count, shopify } from './bootstrap'
import Client from 'hanzo.js'
import getStore from './stores'
export * from './components/index'
export { default as start, cart, count, shopify } from './bootstrap'
export { default as Client } from 'hanzo.js'
export { default as getStore } from './stores'
if (typeof window !== 'undefined') {
window['ShopJS'] = {
Client,
ShippingForm,
PaymentForm,
Checkout,
start,
cart,
count,
shopify,
getStore,
set: (...args) => {
const s = getStore()
if (!s) {
throw new Error('Use ShopJS.start before setting any items')
}
s.commerce.set.apply(s.commerce, (args as any))
},
clear: () => {
const s = getStore()
if (!s) {
throw new Error('Use ShopJS.start before setting any items')
}
s.commerce.clear()
}
}
}