@shopify/shop-minis-react 0.0.36 → 0.1.1
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/dist/_virtual/index2.js +4 -4
- package/dist/_virtual/index3.js +4 -4
- package/dist/components/atoms/image.js +5 -5
- package/dist/components/atoms/image.js.map +1 -1
- package/dist/components/commerce/product-card.js +20 -20
- package/dist/components/commerce/product-card.js.map +1 -1
- package/dist/hooks/events/useOnAppStateChange.js +14 -0
- package/dist/hooks/events/useOnAppStateChange.js.map +1 -0
- package/dist/hooks/events/useOnMiniBlur.js +14 -0
- package/dist/hooks/events/useOnMiniBlur.js.map +1 -0
- package/dist/hooks/events/useOnMiniClose.js +14 -0
- package/dist/hooks/events/useOnMiniClose.js.map +1 -0
- package/dist/hooks/events/useOnMiniFocus.js +14 -0
- package/dist/hooks/events/useOnMiniFocus.js.map +1 -0
- package/dist/hooks/navigation/useShopNavigation.js +12 -10
- package/dist/hooks/navigation/useShopNavigation.js.map +1 -1
- package/dist/hooks/user/useGenerateUserToken.js +28 -6
- package/dist/hooks/user/useGenerateUserToken.js.map +1 -1
- package/dist/index.js +114 -106
- package/dist/index.js.map +1 -1
- package/dist/mocks.js +11 -10
- package/dist/mocks.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/package.json +2 -2
- package/src/components/atoms/image.tsx +1 -1
- package/src/components/commerce/product-card.tsx +3 -3
- package/src/hooks/events/useOnAppStateChange.ts +20 -0
- package/src/hooks/events/useOnMiniBlur.ts +16 -0
- package/src/hooks/events/useOnMiniClose.ts +16 -0
- package/src/hooks/events/useOnMiniFocus.ts +16 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/navigation/useShopNavigation.ts +6 -0
- package/src/hooks/user/useGenerateUserToken.test.ts +340 -0
- package/src/hooks/user/useGenerateUserToken.ts +72 -2
- package/src/mocks.ts +1 -0
- package/src/stories/ImageContentWrapper.stories.tsx +1 -4
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { DATA_NAVIGATION_TYPE_ATTRIBUTE as o, NAVIGATION_TYPES as t } from "./types/index.js";
|
|
2
2
|
import { MinisContainer as i } from "./components/MinisContainer.js";
|
|
3
|
-
import { ProductCard as n, ProductCardBadge as m, ProductCardContainer as
|
|
3
|
+
import { ProductCard as n, ProductCardBadge as m, ProductCardContainer as s, ProductCardFavoriteButton as l, ProductCardImage as u, ProductCardImageContainer as f, ProductCardInfo as x, ProductCardPrice as c, ProductCardTitle as d } from "./components/commerce/product-card.js";
|
|
4
4
|
import { ProductLink as g } from "./components/commerce/product-link.js";
|
|
5
5
|
import { MerchantCard as D, MerchantCardContainer as A, MerchantCardHeader as P, MerchantCardInfo as h, MerchantCardName as T, MerchantCardRating as I } from "./components/commerce/merchant-card.js";
|
|
6
|
-
import { ProductCardSkeleton as
|
|
7
|
-
import { MerchantCardSkeleton as
|
|
8
|
-
import { QuantitySelector as
|
|
9
|
-
import { Search as
|
|
10
|
-
import { ImageContentWrapper as
|
|
11
|
-
import { MinisRouter as
|
|
12
|
-
import { TransitionLink as
|
|
6
|
+
import { ProductCardSkeleton as R } from "./components/commerce/product-card-skeleton.js";
|
|
7
|
+
import { MerchantCardSkeleton as w } from "./components/commerce/merchant-card-skeleton.js";
|
|
8
|
+
import { QuantitySelector as F } from "./components/commerce/quantity-selector.js";
|
|
9
|
+
import { Search as b, SearchInput as k, SearchProvider as E, SearchResultsList as L } from "./components/commerce/search.js";
|
|
10
|
+
import { ImageContentWrapper as O } from "./components/content/image-content-wrapper.js";
|
|
11
|
+
import { MinisRouter as G } from "./components/navigation/minis-router.js";
|
|
12
|
+
import { TransitionLink as V } from "./components/navigation/transition-link.js";
|
|
13
13
|
import { Button as _ } from "./components/atoms/button.js";
|
|
14
14
|
import { FavoriteButton as Y } from "./components/atoms/favorite-button.js";
|
|
15
15
|
import { IconButton as Q } from "./components/atoms/icon-button.js";
|
|
@@ -20,28 +20,28 @@ import { AlertDialogAtom as er } from "./components/atoms/alert-dialog.js";
|
|
|
20
20
|
import { List as tr } from "./components/atoms/list.js";
|
|
21
21
|
import { VideoPlayer as ir } from "./components/atoms/video-player.js";
|
|
22
22
|
import { TextInput as nr } from "./components/atoms/text-input.js";
|
|
23
|
-
import { Accordion as
|
|
23
|
+
import { Accordion as sr, AccordionContent as lr, AccordionItem as ur, AccordionTrigger as fr } from "./components/ui/accordion.js";
|
|
24
24
|
import { Alert as cr, AlertDescription as dr, AlertTitle as Cr } from "./components/ui/alert.js";
|
|
25
|
-
import { AlertDialog as Sr, AlertDialogAction as Dr, AlertDialogCancel as Ar, AlertDialogContent as Pr, AlertDialogDescription as hr, AlertDialogFooter as Tr, AlertDialogHeader as Ir, AlertDialogOverlay as
|
|
26
|
-
import { Avatar as
|
|
27
|
-
import { Badge as
|
|
28
|
-
import { Card as
|
|
25
|
+
import { AlertDialog as Sr, AlertDialogAction as Dr, AlertDialogCancel as Ar, AlertDialogContent as Pr, AlertDialogDescription as hr, AlertDialogFooter as Tr, AlertDialogHeader as Ir, AlertDialogOverlay as Mr, AlertDialogPortal as Rr, AlertDialogTitle as vr, AlertDialogTrigger as wr } from "./components/ui/alert-dialog.js";
|
|
26
|
+
import { Avatar as Fr, AvatarFallback as Ur, AvatarImage as br } from "./components/ui/avatar.js";
|
|
27
|
+
import { Badge as Er, badgeVariants as Lr } from "./components/ui/badge.js";
|
|
28
|
+
import { Card as Or, CardAction as yr, CardContent as Gr, CardDescription as Hr, CardFooter as Vr, CardHeader as zr, CardTitle as _r } from "./components/ui/card.js";
|
|
29
29
|
import { Carousel as Yr, CarouselContent as Kr, CarouselItem as Qr, CarouselNext as jr, CarouselPrevious as qr } from "./components/ui/carousel.js";
|
|
30
30
|
import { Checkbox as Xr } from "./components/ui/checkbox.js";
|
|
31
31
|
import { Dialog as $r, DialogClose as re, DialogContent as ee, DialogDescription as oe, DialogFooter as te, DialogHeader as ae, DialogOverlay as ie, DialogPortal as pe, DialogTitle as ne, DialogTrigger as me } from "./components/ui/dialog.js";
|
|
32
|
-
import { Drawer as
|
|
32
|
+
import { Drawer as le, DrawerClose as ue, DrawerContent as fe, DrawerDescription as xe, DrawerFooter as ce, DrawerHeader as de, DrawerOverlay as Ce, DrawerPortal as ge, DrawerTitle as Se, DrawerTrigger as De } from "./components/ui/drawer.js";
|
|
33
33
|
import { Input as Pe } from "./components/ui/input.js";
|
|
34
34
|
import { Label as Te } from "./components/ui/label.js";
|
|
35
|
-
import { Progress as
|
|
36
|
-
import { RadioGroup as
|
|
37
|
-
import { ResizableHandle as
|
|
38
|
-
import { ScrollArea as
|
|
39
|
-
import { Select as
|
|
35
|
+
import { Progress as Me } from "./components/ui/progress.js";
|
|
36
|
+
import { RadioGroup as ve, RadioGroupItem as we } from "./components/ui/radio-group.js";
|
|
37
|
+
import { ResizableHandle as Fe, ResizablePanel as Ue, ResizablePanelGroup as be } from "./components/ui/resizable.js";
|
|
38
|
+
import { ScrollArea as Ee, ScrollBar as Le } from "./components/ui/scroll-area.js";
|
|
39
|
+
import { Select as Oe, SelectContent as ye, SelectGroup as Ge, SelectItem as He, SelectLabel as Ve, SelectScrollDownButton as ze, SelectScrollUpButton as _e, SelectSeparator as We, SelectTrigger as Ye, SelectValue as Ke } from "./components/ui/select.js";
|
|
40
40
|
import { Separator as je } from "./components/ui/separator.js";
|
|
41
41
|
import { Sheet as Je, SheetClose as Xe, SheetContent as Ze, SheetDescription as $e, SheetFooter as ro, SheetHeader as eo, SheetTitle as oo, SheetTrigger as to } from "./components/ui/sheet.js";
|
|
42
42
|
import { Toaster as io } from "./components/ui/sonner.js";
|
|
43
43
|
import { Skeleton as no } from "./components/ui/skeleton.js";
|
|
44
|
-
import { useRecentProducts as
|
|
44
|
+
import { useRecentProducts as so } from "./hooks/user/useRecentProducts.js";
|
|
45
45
|
import { useRecentShops as uo } from "./hooks/user/useRecentShops.js";
|
|
46
46
|
import { useSavedProducts as xo } from "./hooks/user/useSavedProducts.js";
|
|
47
47
|
import { useSavedProductsActions as Co } from "./hooks/user/useSavedProductsActions.js";
|
|
@@ -49,14 +49,14 @@ import { useFollowedShops as So } from "./hooks/user/useFollowedShops.js";
|
|
|
49
49
|
import { useFollowedShopsActions as Ao } from "./hooks/user/useFollowedShopsActions.js";
|
|
50
50
|
import { useCurrentUser as ho } from "./hooks/user/useCurrentUser.js";
|
|
51
51
|
import { useOrders as Io } from "./hooks/user/useOrders.js";
|
|
52
|
-
import { useBuyerAttributes as
|
|
53
|
-
import { useGenerateUserToken as
|
|
54
|
-
import { useProductListActions as
|
|
55
|
-
import { useProductLists as
|
|
56
|
-
import { useProductList as
|
|
52
|
+
import { useBuyerAttributes as Ro } from "./hooks/user/useBuyerAttributes.js";
|
|
53
|
+
import { useGenerateUserToken as wo } from "./hooks/user/useGenerateUserToken.js";
|
|
54
|
+
import { useProductListActions as Fo } from "./hooks/product/useProductListActions.js";
|
|
55
|
+
import { useProductLists as bo } from "./hooks/product/useProductLists.js";
|
|
56
|
+
import { useProductList as Eo } from "./hooks/product/useProductList.js";
|
|
57
57
|
import { useProduct as No } from "./hooks/product/useProduct.js";
|
|
58
|
-
import { useProducts as
|
|
59
|
-
import { useProductVariants as
|
|
58
|
+
import { useProducts as yo } from "./hooks/product/useProducts.js";
|
|
59
|
+
import { useProductVariants as Ho } from "./hooks/product/useProductVariants.js";
|
|
60
60
|
import { useProductMedia as zo } from "./hooks/product/useProductMedia.js";
|
|
61
61
|
import { useProductSearch as Wo } from "./hooks/product/useProductSearch.js";
|
|
62
62
|
import { useRecommendedProducts as Ko } from "./hooks/product/useRecommendedProducts.js";
|
|
@@ -68,7 +68,7 @@ import { useImageUpload as ot } from "./hooks/storage/useImageUpload.js";
|
|
|
68
68
|
import { useShopNavigation as at } from "./hooks/navigation/useShopNavigation.js";
|
|
69
69
|
import { useCloseMini as pt } from "./hooks/navigation/useCloseMini.js";
|
|
70
70
|
import { useDeeplink as mt } from "./hooks/navigation/useDeeplink.js";
|
|
71
|
-
import { useNavigateWithTransition as
|
|
71
|
+
import { useNavigateWithTransition as lt } from "./hooks/navigation/useNavigateWithTransition.js";
|
|
72
72
|
import { useShop as ft } from "./hooks/shop/useShop.js";
|
|
73
73
|
import { useShopCartActions as ct } from "./hooks/shop/useShopCartActions.js";
|
|
74
74
|
import { useRecommendedShops as Ct } from "./hooks/shop/useRecommendedShops.js";
|
|
@@ -76,19 +76,23 @@ import { useCreateImageContent as St } from "./hooks/content/useCreateImageConte
|
|
|
76
76
|
import { useErrorToast as At } from "./hooks/util/useErrorToast.js";
|
|
77
77
|
import { useErrorScreen as ht } from "./hooks/util/useErrorScreen.js";
|
|
78
78
|
import { useShare as It } from "./hooks/util/useShare.js";
|
|
79
|
-
import { useImagePicker as
|
|
80
|
-
import { useKeyboardAvoidingView as
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
79
|
+
import { useImagePicker as Rt } from "./hooks/util/useImagePicker.js";
|
|
80
|
+
import { useKeyboardAvoidingView as wt } from "./hooks/util/useKeyboardAvoidingView.js";
|
|
81
|
+
import { useOnMiniFocus as Ft } from "./hooks/events/useOnMiniFocus.js";
|
|
82
|
+
import { useOnMiniBlur as bt } from "./hooks/events/useOnMiniBlur.js";
|
|
83
|
+
import { useOnMiniClose as Et } from "./hooks/events/useOnMiniClose.js";
|
|
84
|
+
import { useOnAppStateChange as Nt } from "./hooks/events/useOnAppStateChange.js";
|
|
85
|
+
import { MiniEntityNotFoundError as yt, MiniError as Gt, MiniNetworkError as Ht, formatError as Vt } from "./utils/errors.js";
|
|
86
|
+
import { extractBrandTheme as _t, formatReviewCount as Wt, getFeaturedImages as Yt, normalizeRating as Kt } from "./utils/merchant-card.js";
|
|
87
|
+
import { parseUrl as jt } from "./utils/parseUrl.js";
|
|
88
|
+
import { fileToDataUri as Jt, getResizedImageUrl as Xt, getThumbhashDataURL as Zt } from "./utils/image.js";
|
|
89
|
+
import { UserState as ra, UserTokenGenerateUserErrorCode as ea } from "./shop-minis-platform/src/types/user.js";
|
|
90
|
+
import { ContentCreateUserErrorCode as ta } from "./shop-minis-platform/src/types/content.js";
|
|
91
|
+
import { Consent as ia, ConsentStatus as pa } from "./shop-minis-platform/src/types/permissions.js";
|
|
92
|
+
import { Social as ma } from "./shop-minis-platform/src/types/share.js";
|
|
89
93
|
export {
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
sr as Accordion,
|
|
95
|
+
lr as AccordionContent,
|
|
92
96
|
ur as AccordionItem,
|
|
93
97
|
fr as AccordionTrigger,
|
|
94
98
|
cr as Alert,
|
|
@@ -101,21 +105,21 @@ export {
|
|
|
101
105
|
hr as AlertDialogDescription,
|
|
102
106
|
Tr as AlertDialogFooter,
|
|
103
107
|
Ir as AlertDialogHeader,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
Mr as AlertDialogOverlay,
|
|
109
|
+
Rr as AlertDialogPortal,
|
|
110
|
+
vr as AlertDialogTitle,
|
|
111
|
+
wr as AlertDialogTrigger,
|
|
108
112
|
Cr as AlertTitle,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
Fr as Avatar,
|
|
114
|
+
Ur as AvatarFallback,
|
|
115
|
+
br as AvatarImage,
|
|
116
|
+
Er as Badge,
|
|
113
117
|
_ as Button,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
Or as Card,
|
|
119
|
+
yr as CardAction,
|
|
120
|
+
Gr as CardContent,
|
|
121
|
+
Hr as CardDescription,
|
|
122
|
+
Vr as CardFooter,
|
|
119
123
|
zr as CardHeader,
|
|
120
124
|
_r as CardTitle,
|
|
121
125
|
Yr as Carousel,
|
|
@@ -124,9 +128,9 @@ export {
|
|
|
124
128
|
jr as CarouselNext,
|
|
125
129
|
qr as CarouselPrevious,
|
|
126
130
|
Xr as Checkbox,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
ia as Consent,
|
|
132
|
+
pa as ConsentStatus,
|
|
133
|
+
ta as ContentCreateUserErrorCode,
|
|
130
134
|
o as DATA_NAVIGATION_TYPE_ATTRIBUTE,
|
|
131
135
|
$r as Dialog,
|
|
132
136
|
re as DialogClose,
|
|
@@ -138,7 +142,7 @@ export {
|
|
|
138
142
|
pe as DialogPortal,
|
|
139
143
|
ne as DialogTitle,
|
|
140
144
|
me as DialogTrigger,
|
|
141
|
-
|
|
145
|
+
le as Drawer,
|
|
142
146
|
ue as DrawerClose,
|
|
143
147
|
fe as DrawerContent,
|
|
144
148
|
xe as DrawerDescription,
|
|
@@ -151,7 +155,7 @@ export {
|
|
|
151
155
|
Y as FavoriteButton,
|
|
152
156
|
Q as IconButton,
|
|
153
157
|
q as Image,
|
|
154
|
-
|
|
158
|
+
O as ImageContentWrapper,
|
|
155
159
|
Pe as Input,
|
|
156
160
|
Te as Label,
|
|
157
161
|
tr as List,
|
|
@@ -162,42 +166,42 @@ export {
|
|
|
162
166
|
h as MerchantCardInfo,
|
|
163
167
|
T as MerchantCardName,
|
|
164
168
|
I as MerchantCardRating,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
w as MerchantCardSkeleton,
|
|
170
|
+
yt as MiniEntityNotFoundError,
|
|
171
|
+
Gt as MiniError,
|
|
172
|
+
Ht as MiniNetworkError,
|
|
169
173
|
i as MinisContainer,
|
|
170
|
-
|
|
174
|
+
G as MinisRouter,
|
|
171
175
|
t as NAVIGATION_TYPES,
|
|
172
176
|
n as ProductCard,
|
|
173
177
|
m as ProductCardBadge,
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
s as ProductCardContainer,
|
|
179
|
+
l as ProductCardFavoriteButton,
|
|
176
180
|
u as ProductCardImage,
|
|
177
181
|
f as ProductCardImageContainer,
|
|
178
182
|
x as ProductCardInfo,
|
|
179
183
|
c as ProductCardPrice,
|
|
180
|
-
|
|
184
|
+
R as ProductCardSkeleton,
|
|
181
185
|
d as ProductCardTitle,
|
|
182
186
|
g as ProductLink,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
Me as Progress,
|
|
188
|
+
F as QuantitySelector,
|
|
189
|
+
ve as RadioGroup,
|
|
190
|
+
we as RadioGroupItem,
|
|
191
|
+
Fe as ResizableHandle,
|
|
192
|
+
Ue as ResizablePanel,
|
|
193
|
+
be as ResizablePanelGroup,
|
|
194
|
+
Ee as ScrollArea,
|
|
191
195
|
Le as ScrollBar,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
b as Search,
|
|
197
|
+
k as SearchInput,
|
|
198
|
+
E as SearchProvider,
|
|
195
199
|
L as SearchResultsList,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
Oe as Select,
|
|
201
|
+
ye as SelectContent,
|
|
202
|
+
Ge as SelectGroup,
|
|
203
|
+
He as SelectItem,
|
|
204
|
+
Ve as SelectLabel,
|
|
201
205
|
ze as SelectScrollDownButton,
|
|
202
206
|
_e as SelectScrollUpButton,
|
|
203
207
|
We as SelectSeparator,
|
|
@@ -213,26 +217,26 @@ export {
|
|
|
213
217
|
oo as SheetTitle,
|
|
214
218
|
to as SheetTrigger,
|
|
215
219
|
no as Skeleton,
|
|
216
|
-
|
|
220
|
+
ma as Social,
|
|
217
221
|
nr as TextInput,
|
|
218
222
|
io as Toaster,
|
|
219
223
|
X as Touchable,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
V as TransitionLink,
|
|
225
|
+
ra as UserState,
|
|
226
|
+
ea as UserTokenGenerateUserErrorCode,
|
|
223
227
|
ir as VideoPlayer,
|
|
224
228
|
Lr as badgeVariants,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
_t as extractBrandTheme,
|
|
230
|
+
Jt as fileToDataUri,
|
|
231
|
+
Vt as formatError,
|
|
232
|
+
Wt as formatReviewCount,
|
|
233
|
+
Yt as getFeaturedImages,
|
|
234
|
+
Xt as getResizedImageUrl,
|
|
235
|
+
Zt as getThumbhashDataURL,
|
|
236
|
+
Kt as normalizeRating,
|
|
237
|
+
jt as parseUrl,
|
|
234
238
|
Zo as useAsyncStorage,
|
|
235
|
-
|
|
239
|
+
Ro as useBuyerAttributes,
|
|
236
240
|
pt as useCloseMini,
|
|
237
241
|
St as useCreateImageContent,
|
|
238
242
|
Jo as useCuratedProducts,
|
|
@@ -242,22 +246,26 @@ export {
|
|
|
242
246
|
At as useErrorToast,
|
|
243
247
|
So as useFollowedShops,
|
|
244
248
|
Ao as useFollowedShopsActions,
|
|
245
|
-
|
|
246
|
-
|
|
249
|
+
wo as useGenerateUserToken,
|
|
250
|
+
Rt as useImagePicker,
|
|
247
251
|
ot as useImageUpload,
|
|
248
|
-
|
|
249
|
-
|
|
252
|
+
wt as useKeyboardAvoidingView,
|
|
253
|
+
lt as useNavigateWithTransition,
|
|
254
|
+
Nt as useOnAppStateChange,
|
|
255
|
+
bt as useOnMiniBlur,
|
|
256
|
+
Et as useOnMiniClose,
|
|
257
|
+
Ft as useOnMiniFocus,
|
|
250
258
|
Io as useOrders,
|
|
251
259
|
jo as usePopularProducts,
|
|
252
260
|
No as useProduct,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
261
|
+
Eo as useProductList,
|
|
262
|
+
Fo as useProductListActions,
|
|
263
|
+
bo as useProductLists,
|
|
256
264
|
zo as useProductMedia,
|
|
257
265
|
Wo as useProductSearch,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
266
|
+
Ho as useProductVariants,
|
|
267
|
+
yo as useProducts,
|
|
268
|
+
so as useRecentProducts,
|
|
261
269
|
uo as useRecentShops,
|
|
262
270
|
Ko as useRecommendedProducts,
|
|
263
271
|
Ct as useRecommendedShops,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/mocks.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UserState as p } from "./shop-minis-platform/src/types/user.js";
|
|
2
|
-
const e = (t, o, r = "99.99",
|
|
2
|
+
const e = (t, o, r = "99.99", s) => ({
|
|
3
3
|
id: t,
|
|
4
4
|
title: o,
|
|
5
5
|
price: { amount: r, currencyCode: "USD" },
|
|
6
|
-
...
|
|
7
|
-
compareAtPrice: { amount:
|
|
6
|
+
...s && {
|
|
7
|
+
compareAtPrice: { amount: s, currencyCode: "USD" }
|
|
8
8
|
},
|
|
9
9
|
reviewAnalytics: { averageRating: 4.5, reviewCount: 10 },
|
|
10
10
|
shop: i("shop1", "Mock Shop"),
|
|
@@ -40,7 +40,7 @@ const e = (t, o, r = "99.99", d) => ({
|
|
|
40
40
|
}, a = (t = !1) => ({
|
|
41
41
|
hasNextPage: t,
|
|
42
42
|
endCursor: t ? "cursor123" : null
|
|
43
|
-
}),
|
|
43
|
+
}), d = (t, o, r = []) => ({
|
|
44
44
|
id: t,
|
|
45
45
|
publicId: `public-${t}`,
|
|
46
46
|
name: o,
|
|
@@ -126,20 +126,20 @@ function u() {
|
|
|
126
126
|
reportContentImpression: void 0,
|
|
127
127
|
getProductLists: {
|
|
128
128
|
data: [
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
d("list-1", "Wishlist"),
|
|
130
|
+
d("list-2", "Favorites")
|
|
131
131
|
],
|
|
132
132
|
pageInfo: a()
|
|
133
133
|
},
|
|
134
134
|
getProductList: {
|
|
135
|
-
data:
|
|
135
|
+
data: d("list-1", "Wishlist", [
|
|
136
136
|
e("prod-1", "Sample Product")
|
|
137
137
|
]),
|
|
138
138
|
pageInfo: a()
|
|
139
139
|
},
|
|
140
|
-
addProductList:
|
|
140
|
+
addProductList: d("list-3", "New List"),
|
|
141
141
|
removeProductList: void 0,
|
|
142
|
-
renameProductList:
|
|
142
|
+
renameProductList: d("list-1", "Updated Wishlist"),
|
|
143
143
|
addProductListItem: void 0,
|
|
144
144
|
removeProductListItem: void 0,
|
|
145
145
|
getRecommendedProducts: {
|
|
@@ -313,7 +313,8 @@ function u() {
|
|
|
313
313
|
expiresAt: "2025-01-01",
|
|
314
314
|
userState: p.VERIFIED
|
|
315
315
|
}
|
|
316
|
-
}
|
|
316
|
+
},
|
|
317
|
+
navigateToCart: void 0
|
|
317
318
|
}, o = {};
|
|
318
319
|
for (const r in t)
|
|
319
320
|
Object.prototype.hasOwnProperty.call(t, r) && (o[r] = l(
|
package/dist/mocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.js","sources":["../src/mocks.ts"],"sourcesContent":["import {Product, Gender, UserState} from '@shopify/shop-minis-platform'\nimport {ShopActions} from '@shopify/shop-minis-platform/actions'\n\n// Helper functions for common data structures\nexport const createProduct = (\n id: string,\n title: string,\n price = '99.99',\n compareAtPrice?: string\n): Product => ({\n id,\n title,\n price: {amount: price, currencyCode: 'USD'},\n ...(compareAtPrice && {\n compareAtPrice: {amount: compareAtPrice, currencyCode: 'USD'},\n }),\n reviewAnalytics: {averageRating: 4.5, reviewCount: 10},\n shop: createShop('shop1', 'Mock Shop'),\n defaultVariantId: `variant-${id}`,\n isFavorited: false,\n featuredImage: {\n url: `https://cdn.shopify.com/static/sample-images/teapot.jpg`,\n altText: title,\n },\n})\n\nexport const createShop = (\n id: string,\n name: string,\n options?: {\n themeType?: 'coverImage' | 'brandColor' | 'logoColor' | 'none'\n withBrandSettings?: boolean\n primaryColor?: string\n logoDominantColor?: string\n logoAverageColor?: string\n coverDominantColor?: string\n wordmarkUrl?: string\n coverImageUrl?: string\n featuredImagesLimit?: number\n }\n) => {\n // Determine theme configuration\n const themeType = options?.themeType || 'none'\n const shouldHaveBrandSettings =\n options?.withBrandSettings || themeType !== 'none'\n\n // Generate featured images\n const featuredImagesCount = options?.featuredImagesLimit || 3\n const featuredImages = Array.from({length: featuredImagesCount}, (_, i) => ({\n url: `https://picsum.photos/400/400?random=${id}-${i}`,\n sensitive: false,\n altText: `${name} featured image ${i + 1}`,\n }))\n\n // Configure colors based on theme type\n const getThemeColors = () => {\n switch (themeType) {\n case 'coverImage':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor || '#FF6B35',\n }\n case 'brandColor':\n return {\n primary: options?.primaryColor || '#27AE60',\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n case 'logoColor':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor || '#E74C3C',\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n default:\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n }\n }\n\n // Configure header theme\n const createHeaderTheme = () => {\n if (themeType === 'coverImage' || options?.coverImageUrl) {\n return {\n id: `header-theme-${id}`,\n coverImage: {\n url:\n options?.coverImageUrl ||\n 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop',\n altText: `${name} cover image`,\n sensitive: false,\n thumbhash: 'k9oGHQRnh493V4dIeHeXh4h3iIeI',\n },\n wordmark:\n options?.wordmarkUrl || themeType === 'coverImage'\n ? {\n url:\n options?.wordmarkUrl ||\n 'https://merrypeople.com/cdn/shop/files/Transparent_Background_1.png?v=1696465429&width=1024',\n altText: `${name} wordmark`,\n sensitive: false,\n }\n : undefined,\n }\n }\n\n if (options?.wordmarkUrl) {\n return {\n id: `header-theme-${id}`,\n wordmark: {\n url: options.wordmarkUrl,\n altText: `${name} wordmark`,\n sensitive: false,\n },\n }\n }\n\n return undefined\n }\n\n return {\n id,\n name,\n primaryDomain: {\n url: `https://${name.toLowerCase().replace(/\\s+/g, '-')}.com`,\n },\n reviewAnalytics: {averageRating: 4.3, reviewCount: 50},\n visualTheme: {\n id: `visual-theme-${id}`,\n featuredImages,\n logoImage: {\n url: `https://picsum.photos/100/100?random=${id}`,\n sensitive: false,\n },\n brandSettings: shouldHaveBrandSettings\n ? {\n id: `brand-settings-${id}`,\n colors: {\n id: `colors-${id}`,\n ...getThemeColors(),\n },\n headerTheme: createHeaderTheme(),\n }\n : undefined,\n },\n }\n}\n\nconst createPagination = (hasNext = false) => ({\n hasNextPage: hasNext,\n endCursor: hasNext ? 'cursor123' : null,\n})\n\nconst createProductList = (id: string, name: string, products: any[] = []) => ({\n id,\n publicId: `public-${id}`,\n name,\n products,\n})\n\n// Helper type to extract the data type from a ShopAction\ntype ShopActionDataType<T> = T extends (\n ...args: any[]\n) => Promise<{ok: true; data: infer R} | {ok: false; error: any}>\n ? R\n : never\n\nfunction makeMockMethod<K extends keyof ShopActions>(\n key: K,\n result: ShopActionDataType<ShopActions[K]>\n): ShopActions[K] {\n return ((params: Parameters<ShopActions[K]>[0]) => {\n console.log(`[Mock Action] ${String(key)}`, params)\n return Promise.resolve({ok: true as const, data: result})\n }) as ShopActions[K]\n}\n\nexport function makeMockActions(): ShopActions {\n const results: {\n [K in keyof ShopActions]: ShopActionDataType<ShopActions[K]>\n } = {\n translateContentUp: undefined,\n translateContentDown: undefined,\n followShop: true,\n unfollowShop: false,\n favorite: undefined,\n unfavorite: undefined,\n getShopAppInformation: {\n appVersion: '1.0.0',\n buildNumber: '12345',\n buildId: 'dev-build-123',\n },\n productRecommendationImpression: undefined,\n productRecommendationClick: undefined,\n hideEntryPoint: undefined,\n closeMini: undefined,\n getAccountInformation: {\n status: 'available',\n value: 'user@example.com',\n },\n getCurrentUser: {\n data: {\n displayName: 'John Doe',\n avatarImage: {url: 'https://example.com/avatar.jpg'},\n },\n },\n createOrderAttribution: undefined,\n addToCart: undefined,\n buyProduct: undefined,\n buyProducts: undefined,\n showErrorScreen: undefined,\n showErrorToast: undefined,\n getDeeplinkPaths: {\n matchers: ['/products', '/collections', '/cart'],\n },\n navigateToDeeplink: undefined,\n navigateToShop: undefined,\n navigateToProduct: undefined,\n navigateToOrder: undefined,\n navigateToCheckout: undefined,\n createImageUploadLink: {\n targets: [\n {\n url: 'https://example.com/upload',\n resourceUrl: 'https://example.com/resource',\n parameters: [{name: 'key', value: 'upload-123'}],\n },\n ],\n },\n completeImageUpload: {\n files: [\n {\n id: 'file-123',\n fileStatus: 'READY',\n image: {url: 'https://example.com/image.jpg'},\n },\n ],\n },\n getPersistedItem: 'stored-value',\n setPersistedItem: undefined,\n removePersistedItem: undefined,\n getAllPersistedKeys: ['key1', 'key2', 'key3'],\n clearPersistedItems: undefined,\n getInternalPersistedItem: 'internal-value',\n setInternalPersistedItem: undefined,\n removeInternalPersistedItem: undefined,\n getAllInternalPersistedKeys: ['internal-key1', 'internal-key2'],\n clearInternalPersistedItems: undefined,\n getSecret: 'secret-value',\n setSecret: undefined,\n removeSecret: undefined,\n reportInteraction: undefined,\n reportImpression: undefined,\n reportContentImpression: undefined,\n getProductLists: {\n data: [\n createProductList('list-1', 'Wishlist'),\n createProductList('list-2', 'Favorites'),\n ],\n pageInfo: createPagination(),\n },\n getProductList: {\n data: createProductList('list-1', 'Wishlist', [\n createProduct('prod-1', 'Sample Product'),\n ]),\n pageInfo: createPagination(),\n },\n addProductList: createProductList('list-3', 'New List'),\n removeProductList: undefined,\n renameProductList: createProductList('list-1', 'Updated Wishlist'),\n addProductListItem: undefined,\n removeProductListItem: undefined,\n getRecommendedProducts: {\n data: [\n createProduct('rec-1', 'Recommended Product 1', '79.99'),\n createProduct('rec-2', 'Recommended Product 2', '129.99'),\n createProduct('rec-3', 'Recommended Product 3', '129.99'),\n createProduct('rec-4', 'Recommended Product 4', '29.99'),\n createProduct('rec-5', 'Recommended Product 5', '39.99'),\n createProduct('rec-6', 'Recommended Product 6', '49.99'),\n createProduct('rec-7', 'Recommended Product 7', '59.99'),\n createProduct('rec-8', 'Recommended Product 8', '69.99'),\n createProduct('rec-9', 'Recommended Product 9', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecommendedShops: {\n data: [\n createShop('shop-1', 'Amazing Store'),\n createShop('shop-2', 'Best Deals Shop'),\n ],\n pageInfo: createPagination(),\n },\n searchProductsByShop: {\n data: [\n createProduct('search-1', 'Search Result 1', '59.99'),\n createProduct('search-2', 'Search Result 2', '89.99'),\n ],\n pageInfo: createPagination(),\n },\n getOrders: {\n data: [\n {\n id: 'order-1',\n name: '#1001',\n lineItems: [\n {\n productTitle: 'Sample Product',\n variantTitle: 'Medium',\n quantity: 2,\n product: null,\n },\n ],\n shop: createShop('shop-1', 'Sample Shop'),\n },\n ],\n pageInfo: createPagination(),\n },\n getBuyerAttributes: {\n data: {\n genderAffinity: 'NEUTRAL' as Gender,\n categoryAffinities: [\n {id: 'cat1', name: 'Electronics'},\n {id: 'cat2', name: 'Clothing'},\n ],\n },\n },\n showFeedbackSheet: undefined,\n getPopularProducts: {\n data: [\n createProduct('pop-1', 'The Hero Snowboard', '702.95'),\n createProduct('pop-2', 'Snow Jacket', '605.95', '702.00'),\n createProduct('pop-3', 'Winter Gloves', '89.95'),\n createProduct('pop-4', 'Summer Gloves', '89.95'),\n createProduct('pop-5', 'Spring Gloves', '89.95'),\n createProduct('pop-6', 'Playstation 5', '499.95'),\n createProduct('pop-7', 'Xbox Series X', '499.95'),\n createProduct('pop-8', 'Nintendo Switch', '299.95'),\n createProduct('pop-9', 'Playstation 4', '299.95'),\n createProduct('pop-10', 'Nintendo 3DS', '89.95'),\n ],\n pageInfo: createPagination(),\n },\n share: {\n message: 'Shared!',\n success: true,\n },\n shareSingle: {\n message: 'Shared!',\n success: true,\n },\n getCuratedProducts: {\n data: [\n createProduct('cur-1', 'Curated Product 1', '79.99'),\n createProduct('cur-2', 'Curated Product 2', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getSavedProducts: {\n data: [createProduct('saved-1', 'Saved Product 1', '49.99')],\n pageInfo: createPagination(),\n },\n getRecentProducts: {\n data: [createProduct('recent-1', 'Recent Product 1', '59.99')],\n pageInfo: createPagination(),\n },\n getProductSearch: {\n data: [createProduct('search-3', 'Search Product 3', '39.99')],\n pageInfo: createPagination(),\n },\n getProducts: {data: [createProduct('prod-2', 'Product 2', '19.99')]},\n getProduct: {data: createProduct('prod-1', 'Sample Product')},\n getProductVariants: {\n data: [\n {\n id: 'variant-1',\n isFavorited: false,\n image: {url: 'https://example.com/variant-1.jpg'},\n price: {amount: '19.99', currencyCode: 'USD'},\n compareAtPrice: {amount: '29.99', currencyCode: 'USD'},\n },\n ],\n pageInfo: createPagination(),\n },\n getProductMedia: {\n data: [\n {\n id: 'media-1',\n image: {url: 'https://example.com/media-1.jpg'},\n mediaContentType: 'IMAGE',\n alt: 'Sample product image',\n },\n ],\n pageInfo: createPagination(),\n },\n getShop: {data: createShop('shop-1', 'Sample Shop')},\n getRecentShops: {\n data: [createShop('recent-shop-1', 'Recent Shop 1')],\n pageInfo: createPagination(),\n },\n getFollowedShops: {\n data: [createShop('followed-shop-1', 'Followed Shop 1')],\n pageInfo: createPagination(),\n },\n previewProductInAr: undefined,\n createContent: {\n data: {\n publicId: 'content-123',\n externalId: null,\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n description: 'This is a mock content item',\n visibility: ['DISCOVERABLE'],\n shareableUrl: 'https://example.com/content/123',\n products: null,\n },\n },\n getContent: {\n data: [\n {\n publicId: 'content-123',\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n visibility: ['DISCOVERABLE'],\n },\n ],\n },\n generateUserToken: {\n data: {\n token: 'user-token-123',\n expiresAt: '2025-01-01',\n userState: UserState.VERIFIED,\n },\n },\n } as const\n\n const mock: Partial<ShopActions> = {}\n for (const key in results) {\n if (Object.prototype.hasOwnProperty.call(results, key)) {\n // @ts-expect-error: dynamic assignment is safe due to exhaustive mapping\n mock[key] = makeMockMethod(\n key as keyof ShopActions,\n results[key as keyof typeof results]\n )\n }\n }\n return mock as ShopActions\n}\n\n// Detect if running on a mobile device\nconst isMobile = (): boolean => {\n const userAgent = navigator.userAgent.toLowerCase()\n const isIOS = /iphone|ipad|ipod/.test(userAgent)\n const isAndroid = /android/.test(userAgent)\n\n return isIOS || isAndroid\n}\n\nexport const injectMocks = ({force}: {force?: boolean} = {}) => {\n // Only inject mocks if we aren't on a mobile device or we force it\n if (isMobile() && !force) {\n return\n }\n\n if (!window.minisSDK) {\n window.minisSDK = makeMockActions()\n window.minisParams = {\n handle: 'mock-handle',\n initialUrl: '/mock-initial-url',\n platform: 'web',\n }\n }\n}\n"],"names":["createProduct","id","title","price","compareAtPrice","createShop","name","options","featuredImages","_","i","createPagination","hasNext","createProductList","products","makeMockMethod","key","result","params","makeMockActions","results","UserState","mock","isMobile","userAgent","isIOS","isAndroid","injectMocks","force"],"mappings":";AAIO,MAAMA,IAAgB,CAC3BC,GACAC,GACAC,IAAQ,SACRC,OACa;AAAA,EACb,IAAAH;AAAA,EACA,OAAAC;AAAA,EACA,OAAO,EAAC,QAAQC,GAAO,cAAc,MAAK;AAAA,EAC1C,GAAIC,KAAkB;AAAA,IACpB,gBAAgB,EAAC,QA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AAQJ,CAA2B;AAAA,IACrC;AAGG,SAAAM;AACT;AAGA,MAAMC,IAAW,MAAe;AACxB,QAAAC,IAAY,UAAU,UAAU,YAAY,GAC5CC,IAAQ,mBAAmB,KAAKD,CAAS,GACzCE,IAAY,UAAU,KAAKF,CAAS;AAE1C,SAAOC,KAASC;AAClB,GAEaC,IAAc,CAAC,EAAC,OAAAC,EAAK,IAAuB,OAAO;AAE1D,EAAAL,EAAA,KAAc,CAACK,KAId,OAAO,aACV,OAAO,WAAWT,EAAgB,GAClC,OAAO,cAAc;AAAA,IACnB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"mocks.js","sources":["../src/mocks.ts"],"sourcesContent":["import {Product, Gender, UserState} from '@shopify/shop-minis-platform'\nimport {ShopActions} from '@shopify/shop-minis-platform/actions'\n\n// Helper functions for common data structures\nexport const createProduct = (\n id: string,\n title: string,\n price = '99.99',\n compareAtPrice?: string\n): Product => ({\n id,\n title,\n price: {amount: price, currencyCode: 'USD'},\n ...(compareAtPrice && {\n compareAtPrice: {amount: compareAtPrice, currencyCode: 'USD'},\n }),\n reviewAnalytics: {averageRating: 4.5, reviewCount: 10},\n shop: createShop('shop1', 'Mock Shop'),\n defaultVariantId: `variant-${id}`,\n isFavorited: false,\n featuredImage: {\n url: `https://cdn.shopify.com/static/sample-images/teapot.jpg`,\n altText: title,\n },\n})\n\nexport const createShop = (\n id: string,\n name: string,\n options?: {\n themeType?: 'coverImage' | 'brandColor' | 'logoColor' | 'none'\n withBrandSettings?: boolean\n primaryColor?: string\n logoDominantColor?: string\n logoAverageColor?: string\n coverDominantColor?: string\n wordmarkUrl?: string\n coverImageUrl?: string\n featuredImagesLimit?: number\n }\n) => {\n // Determine theme configuration\n const themeType = options?.themeType || 'none'\n const shouldHaveBrandSettings =\n options?.withBrandSettings || themeType !== 'none'\n\n // Generate featured images\n const featuredImagesCount = options?.featuredImagesLimit || 3\n const featuredImages = Array.from({length: featuredImagesCount}, (_, i) => ({\n url: `https://picsum.photos/400/400?random=${id}-${i}`,\n sensitive: false,\n altText: `${name} featured image ${i + 1}`,\n }))\n\n // Configure colors based on theme type\n const getThemeColors = () => {\n switch (themeType) {\n case 'coverImage':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor || '#FF6B35',\n }\n case 'brandColor':\n return {\n primary: options?.primaryColor || '#27AE60',\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n case 'logoColor':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor || '#E74C3C',\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n default:\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n }\n }\n\n // Configure header theme\n const createHeaderTheme = () => {\n if (themeType === 'coverImage' || options?.coverImageUrl) {\n return {\n id: `header-theme-${id}`,\n coverImage: {\n url:\n options?.coverImageUrl ||\n 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop',\n altText: `${name} cover image`,\n sensitive: false,\n thumbhash: 'k9oGHQRnh493V4dIeHeXh4h3iIeI',\n },\n wordmark:\n options?.wordmarkUrl || themeType === 'coverImage'\n ? {\n url:\n options?.wordmarkUrl ||\n 'https://merrypeople.com/cdn/shop/files/Transparent_Background_1.png?v=1696465429&width=1024',\n altText: `${name} wordmark`,\n sensitive: false,\n }\n : undefined,\n }\n }\n\n if (options?.wordmarkUrl) {\n return {\n id: `header-theme-${id}`,\n wordmark: {\n url: options.wordmarkUrl,\n altText: `${name} wordmark`,\n sensitive: false,\n },\n }\n }\n\n return undefined\n }\n\n return {\n id,\n name,\n primaryDomain: {\n url: `https://${name.toLowerCase().replace(/\\s+/g, '-')}.com`,\n },\n reviewAnalytics: {averageRating: 4.3, reviewCount: 50},\n visualTheme: {\n id: `visual-theme-${id}`,\n featuredImages,\n logoImage: {\n url: `https://picsum.photos/100/100?random=${id}`,\n sensitive: false,\n },\n brandSettings: shouldHaveBrandSettings\n ? {\n id: `brand-settings-${id}`,\n colors: {\n id: `colors-${id}`,\n ...getThemeColors(),\n },\n headerTheme: createHeaderTheme(),\n }\n : undefined,\n },\n }\n}\n\nconst createPagination = (hasNext = false) => ({\n hasNextPage: hasNext,\n endCursor: hasNext ? 'cursor123' : null,\n})\n\nconst createProductList = (id: string, name: string, products: any[] = []) => ({\n id,\n publicId: `public-${id}`,\n name,\n products,\n})\n\n// Helper type to extract the data type from a ShopAction\ntype ShopActionDataType<T> = T extends (\n ...args: any[]\n) => Promise<{ok: true; data: infer R} | {ok: false; error: any}>\n ? R\n : never\n\nfunction makeMockMethod<K extends keyof ShopActions>(\n key: K,\n result: ShopActionDataType<ShopActions[K]>\n): ShopActions[K] {\n return ((params: Parameters<ShopActions[K]>[0]) => {\n console.log(`[Mock Action] ${String(key)}`, params)\n return Promise.resolve({ok: true as const, data: result})\n }) as ShopActions[K]\n}\n\nexport function makeMockActions(): ShopActions {\n const results: {\n [K in keyof ShopActions]: ShopActionDataType<ShopActions[K]>\n } = {\n translateContentUp: undefined,\n translateContentDown: undefined,\n followShop: true,\n unfollowShop: false,\n favorite: undefined,\n unfavorite: undefined,\n getShopAppInformation: {\n appVersion: '1.0.0',\n buildNumber: '12345',\n buildId: 'dev-build-123',\n },\n productRecommendationImpression: undefined,\n productRecommendationClick: undefined,\n hideEntryPoint: undefined,\n closeMini: undefined,\n getAccountInformation: {\n status: 'available',\n value: 'user@example.com',\n },\n getCurrentUser: {\n data: {\n displayName: 'John Doe',\n avatarImage: {url: 'https://example.com/avatar.jpg'},\n },\n },\n createOrderAttribution: undefined,\n addToCart: undefined,\n buyProduct: undefined,\n buyProducts: undefined,\n showErrorScreen: undefined,\n showErrorToast: undefined,\n getDeeplinkPaths: {\n matchers: ['/products', '/collections', '/cart'],\n },\n navigateToDeeplink: undefined,\n navigateToShop: undefined,\n navigateToProduct: undefined,\n navigateToOrder: undefined,\n navigateToCheckout: undefined,\n createImageUploadLink: {\n targets: [\n {\n url: 'https://example.com/upload',\n resourceUrl: 'https://example.com/resource',\n parameters: [{name: 'key', value: 'upload-123'}],\n },\n ],\n },\n completeImageUpload: {\n files: [\n {\n id: 'file-123',\n fileStatus: 'READY',\n image: {url: 'https://example.com/image.jpg'},\n },\n ],\n },\n getPersistedItem: 'stored-value',\n setPersistedItem: undefined,\n removePersistedItem: undefined,\n getAllPersistedKeys: ['key1', 'key2', 'key3'],\n clearPersistedItems: undefined,\n getInternalPersistedItem: 'internal-value',\n setInternalPersistedItem: undefined,\n removeInternalPersistedItem: undefined,\n getAllInternalPersistedKeys: ['internal-key1', 'internal-key2'],\n clearInternalPersistedItems: undefined,\n getSecret: 'secret-value',\n setSecret: undefined,\n removeSecret: undefined,\n reportInteraction: undefined,\n reportImpression: undefined,\n reportContentImpression: undefined,\n getProductLists: {\n data: [\n createProductList('list-1', 'Wishlist'),\n createProductList('list-2', 'Favorites'),\n ],\n pageInfo: createPagination(),\n },\n getProductList: {\n data: createProductList('list-1', 'Wishlist', [\n createProduct('prod-1', 'Sample Product'),\n ]),\n pageInfo: createPagination(),\n },\n addProductList: createProductList('list-3', 'New List'),\n removeProductList: undefined,\n renameProductList: createProductList('list-1', 'Updated Wishlist'),\n addProductListItem: undefined,\n removeProductListItem: undefined,\n getRecommendedProducts: {\n data: [\n createProduct('rec-1', 'Recommended Product 1', '79.99'),\n createProduct('rec-2', 'Recommended Product 2', '129.99'),\n createProduct('rec-3', 'Recommended Product 3', '129.99'),\n createProduct('rec-4', 'Recommended Product 4', '29.99'),\n createProduct('rec-5', 'Recommended Product 5', '39.99'),\n createProduct('rec-6', 'Recommended Product 6', '49.99'),\n createProduct('rec-7', 'Recommended Product 7', '59.99'),\n createProduct('rec-8', 'Recommended Product 8', '69.99'),\n createProduct('rec-9', 'Recommended Product 9', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecommendedShops: {\n data: [\n createShop('shop-1', 'Amazing Store'),\n createShop('shop-2', 'Best Deals Shop'),\n ],\n pageInfo: createPagination(),\n },\n searchProductsByShop: {\n data: [\n createProduct('search-1', 'Search Result 1', '59.99'),\n createProduct('search-2', 'Search Result 2', '89.99'),\n ],\n pageInfo: createPagination(),\n },\n getOrders: {\n data: [\n {\n id: 'order-1',\n name: '#1001',\n lineItems: [\n {\n productTitle: 'Sample Product',\n variantTitle: 'Medium',\n quantity: 2,\n product: null,\n },\n ],\n shop: createShop('shop-1', 'Sample Shop'),\n },\n ],\n pageInfo: createPagination(),\n },\n getBuyerAttributes: {\n data: {\n genderAffinity: 'NEUTRAL' as Gender,\n categoryAffinities: [\n {id: 'cat1', name: 'Electronics'},\n {id: 'cat2', name: 'Clothing'},\n ],\n },\n },\n showFeedbackSheet: undefined,\n getPopularProducts: {\n data: [\n createProduct('pop-1', 'The Hero Snowboard', '702.95'),\n createProduct('pop-2', 'Snow Jacket', '605.95', '702.00'),\n createProduct('pop-3', 'Winter Gloves', '89.95'),\n createProduct('pop-4', 'Summer Gloves', '89.95'),\n createProduct('pop-5', 'Spring Gloves', '89.95'),\n createProduct('pop-6', 'Playstation 5', '499.95'),\n createProduct('pop-7', 'Xbox Series X', '499.95'),\n createProduct('pop-8', 'Nintendo Switch', '299.95'),\n createProduct('pop-9', 'Playstation 4', '299.95'),\n createProduct('pop-10', 'Nintendo 3DS', '89.95'),\n ],\n pageInfo: createPagination(),\n },\n share: {\n message: 'Shared!',\n success: true,\n },\n shareSingle: {\n message: 'Shared!',\n success: true,\n },\n getCuratedProducts: {\n data: [\n createProduct('cur-1', 'Curated Product 1', '79.99'),\n createProduct('cur-2', 'Curated Product 2', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getSavedProducts: {\n data: [createProduct('saved-1', 'Saved Product 1', '49.99')],\n pageInfo: createPagination(),\n },\n getRecentProducts: {\n data: [createProduct('recent-1', 'Recent Product 1', '59.99')],\n pageInfo: createPagination(),\n },\n getProductSearch: {\n data: [createProduct('search-3', 'Search Product 3', '39.99')],\n pageInfo: createPagination(),\n },\n getProducts: {data: [createProduct('prod-2', 'Product 2', '19.99')]},\n getProduct: {data: createProduct('prod-1', 'Sample Product')},\n getProductVariants: {\n data: [\n {\n id: 'variant-1',\n isFavorited: false,\n image: {url: 'https://example.com/variant-1.jpg'},\n price: {amount: '19.99', currencyCode: 'USD'},\n compareAtPrice: {amount: '29.99', currencyCode: 'USD'},\n },\n ],\n pageInfo: createPagination(),\n },\n getProductMedia: {\n data: [\n {\n id: 'media-1',\n image: {url: 'https://example.com/media-1.jpg'},\n mediaContentType: 'IMAGE',\n alt: 'Sample product image',\n },\n ],\n pageInfo: createPagination(),\n },\n getShop: {data: createShop('shop-1', 'Sample Shop')},\n getRecentShops: {\n data: [createShop('recent-shop-1', 'Recent Shop 1')],\n pageInfo: createPagination(),\n },\n getFollowedShops: {\n data: [createShop('followed-shop-1', 'Followed Shop 1')],\n pageInfo: createPagination(),\n },\n previewProductInAr: undefined,\n createContent: {\n data: {\n publicId: 'content-123',\n externalId: null,\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n description: 'This is a mock content item',\n visibility: ['DISCOVERABLE'],\n shareableUrl: 'https://example.com/content/123',\n products: null,\n },\n },\n getContent: {\n data: [\n {\n publicId: 'content-123',\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n visibility: ['DISCOVERABLE'],\n },\n ],\n },\n generateUserToken: {\n data: {\n token: 'user-token-123',\n expiresAt: '2025-01-01',\n userState: UserState.VERIFIED,\n },\n },\n navigateToCart: undefined,\n } as const\n\n const mock: Partial<ShopActions> = {}\n for (const key in results) {\n if (Object.prototype.hasOwnProperty.call(results, key)) {\n // @ts-expect-error: dynamic assignment is safe due to exhaustive mapping\n mock[key] = makeMockMethod(\n key as keyof ShopActions,\n results[key as keyof typeof results]\n )\n }\n }\n return mock as ShopActions\n}\n\n// Detect if running on a mobile device\nconst isMobile = (): boolean => {\n const userAgent = navigator.userAgent.toLowerCase()\n const isIOS = /iphone|ipad|ipod/.test(userAgent)\n const isAndroid = /android/.test(userAgent)\n\n return isIOS || isAndroid\n}\n\nexport const injectMocks = ({force}: {force?: boolean} = {}) => {\n // Only inject mocks if we aren't on a mobile device or we force it\n if (isMobile() && !force) {\n return\n }\n\n if (!window.minisSDK) {\n window.minisSDK = makeMockActions()\n window.minisParams = {\n handle: 'mock-handle',\n initialUrl: '/mock-initial-url',\n platform: 'web',\n }\n }\n}\n"],"names":["createProduct","id","title","price","compareAtPrice","createShop","name","options","featuredImages","_","i","createPagination","hasNext","createProductList","products","makeMockMethod","key","result","params","makeMockActions","results","UserState","mock","isMobile","userAgent","isIOS","isAndroid","injectMocks","force"],"mappings":";AAIO,MAAMA,IAAgB,CAC3BC,GACAC,GACAC,IAAQ,SACRC,OACa;AAAA,EACb,IAAAH;AAAA,EACA,OAAAC;AAAA,EACA,OAAO,EAAC,QAAQC,GAAO,cAAc,MAAK;AAAA,EAC1C,GAAIC,KAAkB;AAAA,IACpB,gBAAgB,EAAC,QAAQA,GAAgB,cAAc,MAAK;AAAA,EAC9D;AAAA,EACA,iBAAiB,EAAC,eAAe,KAAK,aAAa,GAAE;AAAA,EACrD,MAAMC,EAAW,SAAS,WAAW;AAAA,EACrC,kBAAkB,WAAWJ,CAAE;AAAA,EAC/B,aAAa;AAAA,EACb,eAAe;AAAA,IACb,KAAK;AAAA,IACL,SAASC;AAAA,EAAA;AAEb,IAEaG,IAAa,CACxBJ,GACAK,GACAC,MAWG;AAQG,QAAAC,IAAiB,MAAM,KAAK,EAAC,QAAQ,EAAmB,GAAG,CAAC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OAAO,cAAc;AAAA,IACnB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAEJ;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import S from "../../../../../../../_virtual/window.js";
|
|
2
2
|
import B from "../../../../../../../_virtual/document.js";
|
|
3
|
-
import il from "../../../../../../../_virtual/
|
|
3
|
+
import il from "../../../../../../../_virtual/index3.js";
|
|
4
4
|
import ao from "../../../../../../../_virtual/browser-index.js";
|
|
5
5
|
import xe from "../../../../@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js";
|
|
6
6
|
import Kc from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/resolve-url.js";
|
package/dist/utils/colors.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/shop-minis-react",
|
|
3
3
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typescript": ">=5.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@shopify/shop-minis-platform": "0.
|
|
41
|
+
"@shopify/shop-minis-platform": "0.3.0",
|
|
42
42
|
"@tailwindcss/vite": "4.1.8",
|
|
43
43
|
"@types/color": "3.0.6",
|
|
44
44
|
"@types/lodash": "4.17.20",
|
|
@@ -121,7 +121,7 @@ function ProductCardImage({className, ...props}: React.ComponentProps<'img'>) {
|
|
|
121
121
|
alt={alt}
|
|
122
122
|
aspectRatio={1}
|
|
123
123
|
thumbhash={thumbhash}
|
|
124
|
-
className={cn('
|
|
124
|
+
className={cn('size-full object-cover', className)}
|
|
125
125
|
{...props}
|
|
126
126
|
/>
|
|
127
127
|
) : (
|
|
@@ -129,7 +129,7 @@ function ProductCardImage({className, ...props}: React.ComponentProps<'img'>) {
|
|
|
129
129
|
data-slot="product-card-image"
|
|
130
130
|
src={src}
|
|
131
131
|
alt={alt}
|
|
132
|
-
className={cn('
|
|
132
|
+
className={cn('size-full', className)}
|
|
133
133
|
{...props}
|
|
134
134
|
/>
|
|
135
135
|
)
|
|
@@ -140,7 +140,7 @@ function ProductCardImage({className, ...props}: React.ComponentProps<'img'>) {
|
|
|
140
140
|
)
|
|
141
141
|
|
|
142
142
|
return (
|
|
143
|
-
<div className="bg-gray-100 flex items-center justify-center
|
|
143
|
+
<div className="bg-gray-100 flex items-center justify-center size-full">
|
|
144
144
|
{src ? (
|
|
145
145
|
renderImageElement(src)
|
|
146
146
|
) : (
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {useEffect, useRef} from 'react'
|
|
2
|
+
|
|
3
|
+
import {type AppStateChangePayload} from '@shopify/shop-minis-platform/events'
|
|
4
|
+
|
|
5
|
+
export function useOnAppStateChange(
|
|
6
|
+
callback: (payload: AppStateChangePayload) => void
|
|
7
|
+
) {
|
|
8
|
+
// Using a ref allows the callback to be updated without triggering a re-render
|
|
9
|
+
// This makes the hook nicer to use because developers don't need useCallback
|
|
10
|
+
const callbackRef = useRef(callback)
|
|
11
|
+
callbackRef.current = callback
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const listenerId = window.minisEvents.on('APP_STATE_CHANGE', payload => {
|
|
15
|
+
callbackRef.current(payload)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
return () => window.minisEvents.off(listenerId)
|
|
19
|
+
}, [])
|
|
20
|
+
}
|