@shopify/shop-minis-react 0.1.0 → 0.1.2

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.
Files changed (39) hide show
  1. package/dist/_virtual/index4.js +3 -2
  2. package/dist/_virtual/index4.js.map +1 -1
  3. package/dist/_virtual/index5.js +2 -3
  4. package/dist/_virtual/index5.js.map +1 -1
  5. package/dist/_virtual/index6.js +3 -2
  6. package/dist/_virtual/index6.js.map +1 -1
  7. package/dist/_virtual/index7.js +2 -3
  8. package/dist/_virtual/index7.js.map +1 -1
  9. package/dist/components/atoms/image.js +45 -33
  10. package/dist/components/atoms/image.js.map +1 -1
  11. package/dist/components/commerce/product-card.js +20 -20
  12. package/dist/components/commerce/product-card.js.map +1 -1
  13. package/dist/hooks/events/useOnAppStateChange.js +14 -0
  14. package/dist/hooks/events/useOnAppStateChange.js.map +1 -0
  15. package/dist/hooks/events/useOnMiniBlur.js +14 -0
  16. package/dist/hooks/events/useOnMiniBlur.js.map +1 -0
  17. package/dist/hooks/events/useOnMiniClose.js +14 -0
  18. package/dist/hooks/events/useOnMiniClose.js.map +1 -0
  19. package/dist/hooks/events/useOnMiniFocus.js +14 -0
  20. package/dist/hooks/events/useOnMiniFocus.js.map +1 -0
  21. package/dist/hooks/user/useGenerateUserToken.js +28 -6
  22. package/dist/hooks/user/useGenerateUserToken.js.map +1 -1
  23. package/dist/index.js +114 -106
  24. package/dist/index.js.map +1 -1
  25. package/dist/shop-minis-react/node_modules/.pnpm/@radix-ui_react-use-is-hydrated@0.1.0_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +1 -1
  26. package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js +1 -1
  27. package/dist/shop-minis-react/node_modules/.pnpm/mpd-parser@1.3.1/node_modules/mpd-parser/dist/mpd-parser.es.js +1 -1
  28. package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
  29. package/package.json +2 -2
  30. package/src/components/atoms/image.tsx +34 -4
  31. package/src/components/commerce/product-card.tsx +3 -3
  32. package/src/hooks/events/useOnAppStateChange.ts +20 -0
  33. package/src/hooks/events/useOnMiniBlur.ts +16 -0
  34. package/src/hooks/events/useOnMiniClose.ts +16 -0
  35. package/src/hooks/events/useOnMiniFocus.ts +16 -0
  36. package/src/hooks/index.ts +6 -0
  37. package/src/hooks/user/useGenerateUserToken.test.ts +340 -0
  38. package/src/hooks/user/useGenerateUserToken.ts +72 -2
  39. 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 l, ProductCardFavoriteButton as s, ProductCardImage as u, ProductCardImageContainer as f, ProductCardInfo as x, ProductCardPrice as c, ProductCardTitle as d } from "./components/commerce/product-card.js";
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 v } from "./components/commerce/product-card-skeleton.js";
7
- import { MerchantCardSkeleton as M } from "./components/commerce/merchant-card-skeleton.js";
8
- import { QuantitySelector as b } from "./components/commerce/quantity-selector.js";
9
- import { Search as B, SearchInput as E, SearchProvider as F, SearchResultsList as L } from "./components/commerce/search.js";
10
- import { ImageContentWrapper as y } from "./components/content/image-content-wrapper.js";
11
- import { MinisRouter as H } from "./components/navigation/minis-router.js";
12
- import { TransitionLink as O } from "./components/navigation/transition-link.js";
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 lr, AccordionContent as sr, AccordionItem as ur, AccordionTrigger as fr } from "./components/ui/accordion.js";
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 Rr, AlertDialogPortal as vr, AlertDialogTitle as wr, AlertDialogTrigger as Mr } from "./components/ui/alert-dialog.js";
26
- import { Avatar as br, AvatarFallback as kr, AvatarImage as Br } from "./components/ui/avatar.js";
27
- import { Badge as Fr, badgeVariants as Lr } from "./components/ui/badge.js";
28
- import { Card as yr, CardAction as Gr, CardContent as Hr, CardDescription as Vr, CardFooter as Or, CardHeader as zr, CardTitle as _r } from "./components/ui/card.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 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 se, 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";
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 Re } from "./components/ui/progress.js";
36
- import { RadioGroup as we, RadioGroupItem as Me } from "./components/ui/radio-group.js";
37
- import { ResizableHandle as be, ResizablePanel as ke, ResizablePanelGroup as Be } from "./components/ui/resizable.js";
38
- import { ScrollArea as Fe, ScrollBar as Le } from "./components/ui/scroll-area.js";
39
- import { Select as ye, SelectContent as Ge, SelectGroup as He, SelectItem as Ve, SelectLabel as Oe, SelectScrollDownButton as ze, SelectScrollUpButton as _e, SelectSeparator as We, SelectTrigger as Ye, SelectValue as Ke } from "./components/ui/select.js";
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 lo } from "./hooks/user/useRecentProducts.js";
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 vo } from "./hooks/user/useBuyerAttributes.js";
53
- import { useGenerateUserToken as Mo } from "./hooks/user/useGenerateUserToken.js";
54
- import { useProductListActions as bo } from "./hooks/product/useProductListActions.js";
55
- import { useProductLists as Bo } from "./hooks/product/useProductLists.js";
56
- import { useProductList as Fo } from "./hooks/product/useProductList.js";
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 Go } from "./hooks/product/useProducts.js";
59
- import { useProductVariants as Vo } from "./hooks/product/useProductVariants.js";
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 st } from "./hooks/navigation/useNavigateWithTransition.js";
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 vt } from "./hooks/util/useImagePicker.js";
80
- import { useKeyboardAvoidingView as Mt } from "./hooks/util/useKeyboardAvoidingView.js";
81
- import { MiniEntityNotFoundError as bt, MiniError as kt, MiniNetworkError as Bt, formatError as Et } from "./utils/errors.js";
82
- import { extractBrandTheme as Lt, formatReviewCount as Nt, getFeaturedImages as yt, normalizeRating as Gt } from "./utils/merchant-card.js";
83
- import { parseUrl as Vt } from "./utils/parseUrl.js";
84
- import { fileToDataUri as zt, getResizedImageUrl as _t, getThumbhashDataURL as Wt } from "./utils/image.js";
85
- import { UserState as Kt, UserTokenGenerateUserErrorCode as Qt } from "./shop-minis-platform/src/types/user.js";
86
- import { ContentCreateUserErrorCode as qt } from "./shop-minis-platform/src/types/content.js";
87
- import { Consent as Xt, ConsentStatus as Zt } from "./shop-minis-platform/src/types/permissions.js";
88
- import { Social as ra } from "./shop-minis-platform/src/types/share.js";
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
- lr as Accordion,
91
- sr as AccordionContent,
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
- Rr as AlertDialogOverlay,
105
- vr as AlertDialogPortal,
106
- wr as AlertDialogTitle,
107
- Mr as AlertDialogTrigger,
108
+ Mr as AlertDialogOverlay,
109
+ Rr as AlertDialogPortal,
110
+ vr as AlertDialogTitle,
111
+ wr as AlertDialogTrigger,
108
112
  Cr as AlertTitle,
109
- br as Avatar,
110
- kr as AvatarFallback,
111
- Br as AvatarImage,
112
- Fr as Badge,
113
+ Fr as Avatar,
114
+ Ur as AvatarFallback,
115
+ br as AvatarImage,
116
+ Er as Badge,
113
117
  _ as Button,
114
- yr as Card,
115
- Gr as CardAction,
116
- Hr as CardContent,
117
- Vr as CardDescription,
118
- Or as CardFooter,
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
- Xt as Consent,
128
- Zt as ConsentStatus,
129
- qt as ContentCreateUserErrorCode,
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
- se as Drawer,
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
- y as ImageContentWrapper,
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
- M as MerchantCardSkeleton,
166
- bt as MiniEntityNotFoundError,
167
- kt as MiniError,
168
- Bt as MiniNetworkError,
169
+ w as MerchantCardSkeleton,
170
+ yt as MiniEntityNotFoundError,
171
+ Gt as MiniError,
172
+ Ht as MiniNetworkError,
169
173
  i as MinisContainer,
170
- H as MinisRouter,
174
+ G as MinisRouter,
171
175
  t as NAVIGATION_TYPES,
172
176
  n as ProductCard,
173
177
  m as ProductCardBadge,
174
- l as ProductCardContainer,
175
- s as ProductCardFavoriteButton,
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
- v as ProductCardSkeleton,
184
+ R as ProductCardSkeleton,
181
185
  d as ProductCardTitle,
182
186
  g as ProductLink,
183
- Re as Progress,
184
- b as QuantitySelector,
185
- we as RadioGroup,
186
- Me as RadioGroupItem,
187
- be as ResizableHandle,
188
- ke as ResizablePanel,
189
- Be as ResizablePanelGroup,
190
- Fe as ScrollArea,
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
- B as Search,
193
- E as SearchInput,
194
- F as SearchProvider,
196
+ b as Search,
197
+ k as SearchInput,
198
+ E as SearchProvider,
195
199
  L as SearchResultsList,
196
- ye as Select,
197
- Ge as SelectContent,
198
- He as SelectGroup,
199
- Ve as SelectItem,
200
- Oe as SelectLabel,
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
- ra as Social,
220
+ ma as Social,
217
221
  nr as TextInput,
218
222
  io as Toaster,
219
223
  X as Touchable,
220
- O as TransitionLink,
221
- Kt as UserState,
222
- Qt as UserTokenGenerateUserErrorCode,
224
+ V as TransitionLink,
225
+ ra as UserState,
226
+ ea as UserTokenGenerateUserErrorCode,
223
227
  ir as VideoPlayer,
224
228
  Lr as badgeVariants,
225
- Lt as extractBrandTheme,
226
- zt as fileToDataUri,
227
- Et as formatError,
228
- Nt as formatReviewCount,
229
- yt as getFeaturedImages,
230
- _t as getResizedImageUrl,
231
- Wt as getThumbhashDataURL,
232
- Gt as normalizeRating,
233
- Vt as parseUrl,
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
- vo as useBuyerAttributes,
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
- Mo as useGenerateUserToken,
246
- vt as useImagePicker,
249
+ wo as useGenerateUserToken,
250
+ Rt as useImagePicker,
247
251
  ot as useImageUpload,
248
- Mt as useKeyboardAvoidingView,
249
- st as useNavigateWithTransition,
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
- Fo as useProductList,
254
- bo as useProductListActions,
255
- Bo as useProductLists,
261
+ Eo as useProductList,
262
+ Fo as useProductListActions,
263
+ bo as useProductLists,
256
264
  zo as useProductMedia,
257
265
  Wo as useProductSearch,
258
- Vo as useProductVariants,
259
- Go as useProducts,
260
- lo as useRecentProducts,
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { s as r } from "../../../../../../../../_virtual/index5.js";
1
+ import { s as r } from "../../../../../../../../_virtual/index4.js";
2
2
  function s() {
3
3
  return r.useSyncExternalStore(
4
4
  e,
@@ -1,4 +1,4 @@
1
- import { __module as q } from "../../../../../../../../_virtual/index6.js";
1
+ import { __module as q } from "../../../../../../../../_virtual/index5.js";
2
2
  import { __require as F } from "../../../../../global@4.4.0/node_modules/global/window.js";
3
3
  import { __require as N } from "../../../../../@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/extends.js";
4
4
  import { __require as J } from "../../../../../is-function@1.0.2/node_modules/is-function/index.js";
@@ -2,7 +2,7 @@ import L from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-ut
2
2
  import T from "../../../../../../../_virtual/window.js";
3
3
  import { forEachMediaGroup as Z } from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js";
4
4
  import J from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js";
5
- import { l as Q } from "../../../../../../../_virtual/index7.js";
5
+ import { l as Q } from "../../../../../../../_virtual/index6.js";
6
6
  /*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */
7
7
  const w = (e) => !!e && typeof e == "object", E = (...e) => e.reduce((n, t) => (typeof t != "object" || Object.keys(t).forEach((r) => {
8
8
  Array.isArray(n[r]) && Array.isArray(t[r]) ? n[r] = n[r].concat(t[r]) : w(n[r]) && w(t[r]) ? n[r] = E(n[r], t[r]) : n[r] = t[r];
@@ -1,4 +1,4 @@
1
- import { __exports as i } from "../../../../../../_virtual/index4.js";
1
+ import { __exports as i } from "../../../../../../_virtual/index7.js";
2
2
  var c;
3
3
  function d() {
4
4
  if (c) return i;
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.1.0",
4
+ "version": "0.1.2",
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.2.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",
@@ -1,12 +1,20 @@
1
1
  /* eslint-disable jsx-a11y/alt-text */
2
2
  /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
3
- import {ImgHTMLAttributes, useCallback, useMemo, memo, useState} from 'react'
3
+ import {
4
+ ImgHTMLAttributes,
5
+ useCallback,
6
+ useMemo,
7
+ memo,
8
+ useState,
9
+ useEffect,
10
+ } from 'react'
4
11
 
5
12
  import {cn} from '../../lib/utils'
6
13
  import {getThumbhashDataURL, getResizedImageUrl} from '../../utils'
7
14
 
8
15
  type ImageProps = ImgHTMLAttributes<HTMLImageElement> & {
9
16
  src?: string
17
+ file?: File
10
18
  thumbhash?: string | null
11
19
  aspectRatio?: number | string
12
20
  }
@@ -14,6 +22,7 @@ type ImageProps = ImgHTMLAttributes<HTMLImageElement> & {
14
22
  export const Image = memo(function Image(props: ImageProps) {
15
23
  const {
16
24
  src,
25
+ file,
17
26
  thumbhash,
18
27
  onLoad,
19
28
  className,
@@ -23,6 +32,23 @@ export const Image = memo(function Image(props: ImageProps) {
23
32
  } = props
24
33
 
25
34
  const [isLoaded, setIsLoaded] = useState(false)
35
+ const [blobUrl, setBlobUrl] = useState<string | null>(null)
36
+
37
+ // Create and manage blob URL for File objects
38
+ useEffect(() => {
39
+ if (!file) {
40
+ setBlobUrl(null)
41
+ return
42
+ }
43
+
44
+ const url = URL.createObjectURL(file)
45
+ setBlobUrl(url)
46
+
47
+ // Cleanup on unmount or when file changes
48
+ return () => {
49
+ URL.revokeObjectURL(url)
50
+ }
51
+ }, [file])
26
52
 
27
53
  const thumbhashDataURL = useMemo(
28
54
  () => getThumbhashDataURL(thumbhash ?? undefined),
@@ -37,7 +63,11 @@ export const Image = memo(function Image(props: ImageProps) {
37
63
  [onLoad]
38
64
  )
39
65
 
40
- const resizedImageSrc = useMemo(() => getResizedImageUrl(src), [src])
66
+ // Use blob URL if file is provided, otherwise use src
67
+ const imageSrc = useMemo(() => {
68
+ if (blobUrl) return blobUrl
69
+ return getResizedImageUrl(src)
70
+ }, [blobUrl, src])
41
71
 
42
72
  return (
43
73
  <div
@@ -54,10 +84,10 @@ export const Image = memo(function Image(props: ImageProps) {
54
84
  >
55
85
  <img
56
86
  className={cn(
57
- 'absolute inset-0 opacity-0 object-cover',
87
+ 'absolute inset-0 opacity-0 size-full object-cover',
58
88
  isLoaded && 'opacity-100'
59
89
  )}
60
- src={resizedImageSrc}
90
+ src={imageSrc}
61
91
  onLoad={handleLoad}
62
92
  {...restProps}
63
93
  />
@@ -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('w-full h-full object-cover', className)}
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('w-full h-full', className)}
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 w-full h-full">
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
+ }
@@ -0,0 +1,16 @@
1
+ import {useEffect, useRef} from 'react'
2
+
3
+ export function useOnMiniBlur(callback: () => void) {
4
+ // Using a ref allows the callback to be updated without triggering a re-render
5
+ // This makes the hook nicer to use because developers don't need useCallback
6
+ const callbackRef = useRef(callback)
7
+ callbackRef.current = callback
8
+
9
+ useEffect(() => {
10
+ const listenerId = window.minisEvents.on('MINI_APP_BLUR', () => {
11
+ callbackRef.current()
12
+ })
13
+
14
+ return () => window.minisEvents.off(listenerId)
15
+ }, [])
16
+ }
@@ -0,0 +1,16 @@
1
+ import {useEffect, useRef} from 'react'
2
+
3
+ export function useOnMiniClose(callback: () => void) {
4
+ // Using a ref allows the callback to be updated without triggering a re-render
5
+ // This makes the hook nicer to use because developers don't need useCallback
6
+ const callbackRef = useRef(callback)
7
+ callbackRef.current = callback
8
+
9
+ useEffect(() => {
10
+ const listenerId = window.minisEvents.on('MINI_APP_CLOSE', () => {
11
+ callbackRef.current()
12
+ })
13
+
14
+ return () => window.minisEvents.off(listenerId)
15
+ }, [])
16
+ }
@@ -0,0 +1,16 @@
1
+ import {useEffect, useRef} from 'react'
2
+
3
+ export function useOnMiniFocus(callback: () => void) {
4
+ // Using a ref allows the callback to be updated without triggering a re-render
5
+ // This makes the hook nicer to use because developers don't need useCallback
6
+ const callbackRef = useRef(callback)
7
+ callbackRef.current = callback
8
+
9
+ useEffect(() => {
10
+ const listenerId = window.minisEvents.on('MINI_APP_FOCUS', () => {
11
+ callbackRef.current()
12
+ })
13
+
14
+ return () => window.minisEvents.off(listenerId)
15
+ }, [])
16
+ }
@@ -48,3 +48,9 @@ export * from './util/useErrorScreen'
48
48
  export * from './util/useShare'
49
49
  export * from './util/useImagePicker'
50
50
  export * from './util/useKeyboardAvoidingView'
51
+
52
+ // - Event Hooks
53
+ export * from './events/useOnMiniFocus'
54
+ export * from './events/useOnMiniBlur'
55
+ export * from './events/useOnMiniClose'
56
+ export * from './events/useOnAppStateChange'