@shopify/shop-minis-react 0.0.19 → 0.0.20

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 (44) hide show
  1. package/dist/components/MinisContainer.js +13 -11
  2. package/dist/components/MinisContainer.js.map +1 -1
  3. package/dist/components/atoms/list.js +52 -0
  4. package/dist/components/atoms/list.js.map +1 -0
  5. package/dist/components/atoms/pagination.js +10 -0
  6. package/dist/components/atoms/pagination.js.map +1 -0
  7. package/dist/components/atoms/tracking-pixel.js +32 -0
  8. package/dist/components/atoms/tracking-pixel.js.map +1 -0
  9. package/dist/index.js +187 -185
  10. package/dist/index.js.map +1 -1
  11. package/dist/internal/useShopActions.js.map +1 -1
  12. package/dist/internal/useShopActionsDataFetching.js +26 -26
  13. package/dist/internal/useShopActionsDataFetching.js.map +1 -1
  14. package/dist/internal/useShopActionsPaginatedDataFetching.js.map +1 -1
  15. package/dist/mocks.js +267 -0
  16. package/dist/mocks.js.map +1 -0
  17. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +8 -0
  18. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js.map +1 -0
  19. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js +13 -0
  20. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js.map +1 -0
  21. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +8 -0
  22. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js.map +1 -0
  23. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +9 -0
  24. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js.map +1 -0
  25. package/dist/shop-minis-react/node_modules/.pnpm/memoize-one@5.2.1/node_modules/memoize-one/dist/memoize-one.esm.js +28 -0
  26. package/dist/shop-minis-react/node_modules/.pnpm/memoize-one@5.2.1/node_modules/memoize-one/dist/memoize-one.esm.js.map +1 -0
  27. package/dist/shop-minis-react/node_modules/.pnpm/react-intersection-observer@9.16.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-intersection-observer/dist/index.js +135 -0
  28. package/dist/shop-minis-react/node_modules/.pnpm/react-intersection-observer@9.16.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-intersection-observer/dist/index.js.map +1 -0
  29. package/dist/shop-minis-react/node_modules/.pnpm/react-window@1.8.11_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-window/dist/index.esm.js +375 -0
  30. package/dist/shop-minis-react/node_modules/.pnpm/react-window@1.8.11_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-window/dist/index.esm.js.map +1 -0
  31. package/dist/shop-minis-react.css +1 -0
  32. package/package.json +9 -4
  33. package/src/components/MinisContainer.tsx +4 -1
  34. package/src/components/atoms/list.tsx +101 -0
  35. package/src/components/atoms/pagination.tsx +19 -0
  36. package/src/components/atoms/tracking-pixel.tsx +40 -0
  37. package/src/components/index.ts +1 -0
  38. package/src/index.css +1 -0
  39. package/src/internal/useShopActions.ts +1 -1
  40. package/src/internal/useShopActionsDataFetching.ts +6 -7
  41. package/src/internal/useShopActionsPaginatedDataFetching.ts +3 -6
  42. package/src/mocks.ts +20 -8
  43. package/src/stories/List.stories.tsx +68 -0
  44. package/src/styles/utilities.css +22 -0
@@ -1,38 +1,38 @@
1
1
  import { useState as b, useCallback as u, useMemo as v, useEffect as M } from "react";
2
2
  import { MiniError as P, formatError as V } from "../utils/errors.js";
3
- const A = (d, c, f) => {
4
- const [o, n] = b({
3
+ const A = (c, d, f) => {
4
+ const [n, l] = b({
5
5
  data: null,
6
6
  loading: !0,
7
7
  error: null
8
8
  }), h = f?.skip === !0, { validator: g, hook: t } = f, w = u(
9
- (l) => {
9
+ (s) => {
10
10
  try {
11
- return g?.(l), null;
12
- } catch (s) {
13
- return s ?? new P({
11
+ return g?.(s), null;
12
+ } catch (e) {
13
+ return e instanceof Error ? e : new P({
14
14
  hook: t,
15
15
  message: "Validation failed"
16
16
  });
17
17
  }
18
18
  },
19
19
  [g, t]
20
- ), y = v(() => c, [JSON.stringify(c)]), a = u(
21
- async (l, {
22
- setLoading: s = !0,
20
+ ), y = v(() => d, [JSON.stringify(d)]), a = u(
21
+ async (s, {
22
+ setLoading: e = !0,
23
23
  setError: p = !0,
24
- resetOnError: m = !0,
24
+ resetOnError: E = !0,
25
25
  throwOnError: O = !0
26
26
  } = {}) => {
27
- let E = null, i = null;
28
- n((r) => ({
27
+ let m = null, i = null;
28
+ l((r) => ({
29
29
  ...r,
30
- loading: s ? !0 : r.loading
30
+ loading: e ? !0 : r.loading
31
31
  }));
32
32
  try {
33
- const r = await d({ ...y, ...l });
33
+ const r = await c({ ...y, ...s });
34
34
  if (r.ok)
35
- i = w(r.data.data), n((S) => ({
35
+ i = w(r.data.data), l((S) => ({
36
36
  ...S,
37
37
  data: r.data.data,
38
38
  loading: !1,
@@ -41,17 +41,17 @@ const A = (d, c, f) => {
41
41
  else
42
42
  throw r.error;
43
43
  } catch (r) {
44
- E = V({ hook: t }, r);
44
+ m = V({ hook: t }, r);
45
45
  }
46
- const e = i || E;
47
- if (e && (p || m) && n((r) => ({
48
- data: m ? null : r.data,
46
+ const o = i || m;
47
+ if (o && (p || E) && l((r) => ({
48
+ data: E ? null : r.data,
49
49
  loading: !1,
50
- error: e
51
- })), e && O)
52
- throw e;
50
+ error: o
51
+ })), o && O)
52
+ throw o;
53
53
  },
54
- [d, y, t, w]
54
+ [c, y, t, w]
55
55
  ), k = u(async () => {
56
56
  await a({ fetchPolicy: "network-only" }, {
57
57
  setLoading: !1,
@@ -67,9 +67,9 @@ const A = (d, c, f) => {
67
67
  }
68
68
  );
69
69
  }, [a, h]), {
70
- data: o.data,
71
- loading: o.loading,
72
- error: o.error,
70
+ data: n.data,
71
+ loading: n.loading,
72
+ error: n.error,
73
73
  refetch: k
74
74
  };
75
75
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useShopActionsDataFetching.js","sources":["../../src/internal/useShopActionsDataFetching.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {ShopActionResult} from '@shopify/shop-minis-platform/actions'\n\nimport {DataHookFetchPolicy, DataHookReturnsBase} from '../types'\nimport {formatError, MiniError} from '../utils/errors'\n\nexport interface ShopActionsDataFetchingResult<R> extends DataHookReturnsBase {\n data: R | null\n}\n\nexport const useShopActionsDataFetching = <\n S = unknown,\n P extends {fetchPolicy?: DataHookFetchPolicy} = {\n fetchPolicy?: DataHookFetchPolicy\n },\n>(\n action: (params: P) => Promise<ShopActionResult<{data: S}>>,\n params: P,\n options: {\n skip?: boolean\n hook?: string\n validator?: (data: S) => void\n }\n): ShopActionsDataFetchingResult<S> => {\n const [state, setState] = useState<{\n data: S | null\n loading: boolean\n error: Error | null\n }>({\n data: null,\n loading: true,\n error: null,\n })\n\n const skip = options?.skip === true\n const {validator, hook} = options\n const runValidator = useCallback(\n (dataToValidate: S) => {\n try {\n validator?.(dataToValidate)\n return null\n } catch (err) {\n return (\n err ??\n new MiniError({\n hook,\n message: 'Validation failed',\n })\n )\n }\n },\n [validator, hook]\n )\n\n // Params object is recreated on every render, so we need to memoize it.\n // We don't know what's inside the params object, but we can stringify it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableParams = useMemo(() => params, [JSON.stringify(params)])\n\n // There's a lot of complexity here because each type of fetch has different side effects if we are trying to\n // stay close to how Apollo client works. eg:\n // - Initial fetch: set loading, set error, set data, reset on error (don't throw)\n // - change params fetch: set loading, set error, set data, reset on error (don't throw)\n // - refetch fetch: don't set loading, set error, update data, leave data as is was on error (also throw)\n // - fetchMore fetch: don't set loading, don't set error, update data, leave data as is was on error (also throw)\n const fetch = useCallback(\n async (\n extraParams?: Partial<P>,\n {\n setLoading = true,\n setError = true,\n resetOnError = true,\n throwOnError = true,\n }: {\n setLoading?: boolean\n setError?: boolean\n resetOnError?: boolean\n throwOnError?: boolean\n } = {}\n ) => {\n let queryError: Error | null = null\n let validationError: Error | null = null\n\n setState(curState => ({\n ...curState,\n loading: setLoading ? true : curState.loading,\n }))\n\n try {\n const result = await action({...stableParams, ...extraParams})\n\n if (result.ok) {\n validationError = runValidator(result.data.data)\n\n setState(curState => ({\n ...curState,\n data: result.data.data,\n loading: false,\n error: validationError ?? null,\n }))\n } else {\n throw result.error\n }\n } catch (err) {\n queryError = formatError({hook}, err)\n }\n\n const error = validationError || queryError\n\n if (error && (setError || resetOnError)) {\n setState(curState => ({\n data: resetOnError ? null : curState.data,\n loading: false,\n error,\n }))\n }\n\n if (error && throwOnError) {\n throw error\n }\n },\n [action, stableParams, hook, runValidator]\n )\n\n const refetch = useCallback(async () => {\n await fetch({fetchPolicy: 'network-only'} as Partial<P>, {\n setLoading: false,\n resetOnError: false,\n throwOnError: true,\n })\n }, [fetch])\n\n useEffect(() => {\n if (skip) return\n\n fetch(\n {},\n {\n throwOnError: false,\n }\n )\n }, [fetch, skip])\n\n return {\n data: state.data,\n loading: state.loading,\n error: state.error,\n refetch,\n }\n}\n"],"names":["useShopActionsDataFetching","action","params","options","state","setState","useState","skip","validator","hook","runValidator","useCallback","dataToValidate","err","MiniError","stableParams","useMemo","fetch","extraParams","setLoading","setError","resetOnError","throwOnError","queryError","validationError","curState","result","formatError","error","refetch","useEffect"],"mappings":";;AAWO,MAAMA,IAA6B,CAMxCC,GACAC,GACAC,MAKqC;AACrC,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAIvB;AAAA,IACD,MAAM;AAAA,IACN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AAA,QACpB,MAAMJ,IAAe,OAAOI,EAAS;AAAA,QACrC,SAAS;AAAA,QACT,OAAAG;AAAA,MAAA,EACA,GAGAA,KAASN;AACL,cAAAM;AAAA,IAEV;AAAA,IACA,CAAC3B,GAAQc,GAAcN,GAAMC,CAAY;AAAA,EAC3C,GAEMmB,IAAUlB,EAAY,YAAY;AACtC,UAAMM,EAAM,EAAC,aAAa,kBAA+B;AAAA,MACvD,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,cAAc;AAAA,IAAA,CACf;AAAA,EAAA,GACA,CAACA,CAAK,CAAC;AAEV,SAAAa,EAAU,MAAM;AACd,IAAIvB,KAEJU;AAAA,MACE,CAAC;AAAA,MACD;AAAA,QACE,cAAc;AAAA,MAAA;AAAA,IAElB;AAAA,EAAA,GACC,CAACA,GAAOV,CAAI,CAAC,GAET;AAAA,IACL,MAAMH,EAAM;AAAA,IACZ,SAASA,EAAM;AAAA,IACf,OAAOA,EAAM;AAAA,IACb,SAAAyB;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useShopActionsDataFetching.js","sources":["../../src/internal/useShopActionsDataFetching.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {ShopActionResult} from '@shopify/shop-minis-platform/actions'\n\nimport {DataHookFetchPolicy, DataHookReturnsBase} from '../types'\nimport {formatError, MiniError} from '../utils/errors'\n\nexport interface ShopActionsDataFetchingResult<R> extends DataHookReturnsBase {\n data: R | null\n}\n\nexport const useShopActionsDataFetching = <\n S = unknown,\n P extends {fetchPolicy?: DataHookFetchPolicy} = {\n fetchPolicy?: DataHookFetchPolicy\n },\n>(\n action: (params: P) => Promise<ShopActionResult<{data: S}>>,\n params: P,\n options: {\n skip?: boolean\n hook?: string\n validator?: (data: S) => void\n }\n): ShopActionsDataFetchingResult<S> => {\n const [state, setState] = useState<{\n data: S | null\n loading: boolean\n error: Error | null\n }>({\n data: null,\n loading: true,\n error: null,\n })\n\n const skip = options?.skip === true\n const {validator, hook} = options\n const runValidator = useCallback(\n (dataToValidate: S) => {\n try {\n validator?.(dataToValidate)\n return null\n } catch (err) {\n if (err instanceof Error) return err\n\n return new MiniError({\n hook,\n message: 'Validation failed',\n })\n }\n },\n [validator, hook]\n )\n\n // Params object is recreated on every render, so we need to memoize it.\n // We don't know what's inside the params object, but we can stringify it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableParams = useMemo(() => params, [JSON.stringify(params)])\n\n // There's a lot of complexity here because each type of fetch has different side effects if we are trying to\n // stay close to how Apollo client works. eg:\n // - Initial fetch: set loading, set error, set data, reset on error (don't throw)\n // - change params fetch: set loading, set error, set data, reset on error (don't throw)\n // - refetch fetch: don't set loading, set error, update data, leave data as is was on error (also throw)\n // - fetchMore fetch: don't set loading, don't set error, update data, leave data as is was on error (also throw)\n const fetch = useCallback(\n async (\n extraParams?: Partial<P>,\n {\n setLoading = true,\n setError = true,\n resetOnError = true,\n throwOnError = true,\n }: {\n setLoading?: boolean\n setError?: boolean\n resetOnError?: boolean\n throwOnError?: boolean\n } = {}\n ) => {\n let queryError: Error | null = null\n let validationError: Error | null = null\n\n setState(curState => ({\n ...curState,\n loading: setLoading ? true : curState.loading,\n }))\n\n try {\n const result = await action({...stableParams, ...extraParams})\n\n if (result.ok) {\n validationError = runValidator(result.data.data)\n\n setState(curState => ({\n ...curState,\n data: result.data.data,\n loading: false,\n error: validationError ?? null,\n }))\n } else {\n throw result.error\n }\n } catch (err) {\n queryError = formatError({hook}, err)\n }\n\n const error = validationError || queryError\n\n if (error && (setError || resetOnError)) {\n setState(curState => ({\n data: resetOnError ? null : curState.data,\n loading: false,\n error,\n }))\n }\n\n if (error && throwOnError) {\n throw error\n }\n },\n [action, stableParams, hook, runValidator]\n )\n\n const refetch = useCallback(async () => {\n await fetch({fetchPolicy: 'network-only'} as Partial<P>, {\n setLoading: false,\n resetOnError: false,\n throwOnError: true,\n })\n }, [fetch])\n\n useEffect(() => {\n if (skip) return\n\n fetch(\n {},\n {\n throwOnError: false,\n }\n )\n }, [fetch, skip])\n\n return {\n data: state.data,\n loading: state.loading,\n error: state.error,\n refetch,\n }\n}\n"],"names":["useShopActionsDataFetching","action","params","options","state","setState","useState","skip","validator","hook","runValidator","useCallback","dataToValidate","err","MiniError","stableParams","useMemo","fetch","extraParams","setLoading","setError","resetOnError","throwOnError","queryError","validationError","curState","result","formatError","error","refetch","useEffect"],"mappings":";;AAWO,MAAMA,IAA6B,CAMxCC,GACAC,GACAC,MAKqC;AACrC,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAIvB;AAAA,IACD,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EAAA,CACR,GAEKC,IAAOJ,GAAS,SAAS,IACzB,EAAC,WAAAK,GAAW,MAAAC,EAAA,IAAQN,GACpBO,IAAeC;AAAA,IACnB,CAACC,MAAsB;AACjB,UAAA;AACF,eAAAJ,IAAYI,CAAc,GACnB;AAAA,eACAC,GAAK;AACR,eAAAA,aAAe,QAAcA,IAE1B,IAAIC,EAAU;AAAA,UACnB,MAAAL;AAAA,UACA,SAAS;AAAA,QAAA,CACV;AAAA,MAAA;AAAA,IAEL;AAAA,IACA,CAACD,GAAWC,CAAI;AAAA,EAClB,GAKMM,IAAeC,EAAQ,MAAMd,GAAQ,CAAC,KAAK,UAAUA,CAAM,CAAC,CAAC,GAQ7De,IAAQN;AAAA,IACZ,OACEO,GACA;AAAA,MACE,YAAAC,IAAa;AAAA,MACb,UAAAC,IAAW;AAAA,MACX,cAAAC,IAAe;AAAA,MACf,cAAAC,IAAe;AAAA,IACjB,IAKI,OACD;AACH,UAAIC,IAA2B,MAC3BC,IAAgC;AAEpC,MAAAnB,EAAS,CAAaoB,OAAA;AAAA,QACpB,GAAGA;AAAA,QACH,SAASN,IAAa,KAAOM,EAAS;AAAA,MAAA,EACtC;AAEE,UAAA;AACI,cAAAC,IAAS,MAAMzB,EAAO,EAAC,GAAGc,GAAc,GAAGG,GAAY;AAE7D,YAAIQ,EAAO;AACS,UAAAF,IAAAd,EAAagB,EAAO,KAAK,IAAI,GAE/CrB,EAAS,CAAaoB,OAAA;AAAA,YACpB,GAAGA;AAAA,YACH,MAAMC,EAAO,KAAK;AAAA,YAClB,SAAS;AAAA,YACT,OAAOF,KAAmB;AAAA,UAAA,EAC1B;AAAA;AAEF,gBAAME,EAAO;AAAA,eAERb,GAAK;AACZ,QAAAU,IAAaI,EAAY,EAAC,MAAAlB,EAAI,GAAGI,CAAG;AAAA,MAAA;AAGtC,YAAMe,IAAQJ,KAAmBD;AAUjC,UARIK,MAAUR,KAAYC,MACxBhB,EAAS,CAAaoB,OAAA;AAAA,QACpB,MAAMJ,IAAe,OAAOI,EAAS;AAAA,QACrC,SAAS;AAAA,QACT,OAAAG;AAAA,MAAA,EACA,GAGAA,KAASN;AACL,cAAAM;AAAA,IAEV;AAAA,IACA,CAAC3B,GAAQc,GAAcN,GAAMC,CAAY;AAAA,EAC3C,GAEMmB,IAAUlB,EAAY,YAAY;AACtC,UAAMM,EAAM,EAAC,aAAa,kBAA+B;AAAA,MACvD,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,cAAc;AAAA,IAAA,CACf;AAAA,EAAA,GACA,CAACA,CAAK,CAAC;AAEV,SAAAa,EAAU,MAAM;AACd,IAAIvB,KAEJU;AAAA,MACE,CAAC;AAAA,MACD;AAAA,QACE,cAAc;AAAA,MAAA;AAAA,IAElB;AAAA,EAAA,GACC,CAACA,GAAOV,CAAI,CAAC,GAET;AAAA,IACL,MAAMH,EAAM;AAAA,IACZ,SAASA,EAAM;AAAA,IACf,OAAOA,EAAM;AAAA,IACb,SAAAyB;AAAA,EACF;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useShopActionsPaginatedDataFetching.js","sources":["../../src/internal/useShopActionsPaginatedDataFetching.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {\n DataHookFetchPolicy,\n PaginatedDataHookReturnsBase,\n PaginationInfo,\n ShopAction,\n} from '../types'\nimport {formatError, MiniError} from '../utils/errors'\n\nexport interface ShopActionsDataFetchingResult<S>\n extends PaginatedDataHookReturnsBase {\n data: S | null\n}\n\nexport const useShopActionsPaginatedDataFetching = <\n S = unknown,\n P extends {after?: string; fetchPolicy?: DataHookFetchPolicy} = {\n after?: undefined\n fetchPolicy?: DataHookFetchPolicy\n },\n>(\n action: ShopAction<P, {data: S; pageInfo: PaginationInfo}>,\n params: P,\n options: {\n skip?: boolean\n hook?: string\n validator?: (data: S) => void\n }\n): ShopActionsDataFetchingResult<S> => {\n const [state, setState] = useState<{\n data: S | null\n pageInfo: PaginationInfo\n loading: boolean\n error: Error | null\n }>({\n data: null,\n pageInfo: {hasNextPage: false, endCursor: null},\n loading: false,\n error: null,\n })\n\n const skip = options?.skip === true\n const {validator, hook} = options\n const runValidator = useCallback(\n (dataToValidate: S): Error | null => {\n try {\n validator?.(dataToValidate)\n return null\n } catch (err) {\n if (err instanceof Error) return err\n\n return new MiniError({\n hook,\n message: 'Validation failed',\n })\n }\n },\n [validator, hook]\n )\n\n // Params object is recreated on every render, so we need to memoize it.\n // We don't know what's inside the params object, but we can stringify it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableParams = useMemo(() => params, [JSON.stringify(params)])\n\n // There's a lot of complexity here because each type of fetch has different side effects if we are trying to\n // stay close to how Apollo client works. eg:\n // - Initial fetch: set loading, set error, set data, reset on error (don't throw)\n // - change params fetch: set loading, set error, set data, reset on error (don't throw)\n // - refetch fetch: don't set loading, set error, update data, leave data as is was on error (also throw)\n // - fetchMore fetch: don't set loading, don't set error, update data, leave data as is was on error (also throw)\n const fetch = useCallback(\n async (\n extraParams?: Partial<P>,\n {\n setLoading = true,\n setError = true,\n resetOnError = true,\n throwOnError = true,\n appendData = false,\n }: {\n setLoading?: boolean\n setError?: boolean\n resetOnError?: boolean\n throwOnError?: boolean\n appendData?: boolean\n } = {}\n ) => {\n let queryError: Error | null = null\n let validationError: Error | null = null\n\n setState(curState => ({\n ...curState,\n loading: setLoading ? true : curState.loading,\n }))\n\n try {\n const result = await action({...stableParams, ...extraParams})\n\n if (result.ok) {\n validationError = runValidator(result.data.data)\n\n setState(curState => {\n let newData = result.data.data\n\n if (\n appendData &&\n curState.data &&\n Array.isArray(curState.data) &&\n Array.isArray(result.data.data)\n ) {\n newData = [...curState.data, ...result.data.data] as S\n }\n\n return {\n ...curState,\n data: newData,\n pageInfo: result.data.pageInfo,\n loading: false,\n error: validationError ?? null,\n }\n })\n } else {\n throw result.error\n }\n } catch (err) {\n console.log('caught 1', err)\n queryError = formatError({hook}, err)\n }\n\n const error = validationError || queryError\n\n if (error && (setError || resetOnError)) {\n setState(curState => ({\n data: resetOnError ? null : curState.data,\n pageInfo: resetOnError\n ? {hasNextPage: false, endCursor: null}\n : curState.pageInfo,\n loading: false,\n error,\n }))\n }\n\n if (error && throwOnError) {\n throw error\n }\n },\n [action, stableParams, hook, runValidator]\n )\n\n const refetch = useCallback(async () => {\n await fetch({fetchPolicy: 'network-only'} as Partial<P>, {\n setLoading: false,\n resetOnError: false,\n throwOnError: true,\n })\n }, [fetch])\n\n const fetchMore = useCallback(async () => {\n if (!state.pageInfo.hasNextPage || !state.pageInfo.endCursor) return\n\n await fetch({after: state.pageInfo.endCursor} as Partial<P>, {\n setLoading: false,\n setError: false,\n resetOnError: false,\n throwOnError: true,\n appendData: true,\n })\n }, [state.pageInfo.hasNextPage, state.pageInfo.endCursor, fetch])\n\n useEffect(() => {\n if (skip) return\n\n fetch(\n {},\n {\n throwOnError: false,\n }\n )\n }, [fetch, skip])\n\n return {\n data: state.data,\n loading: state.loading,\n error: state.error,\n hasNextPage: state.pageInfo.hasNextPage,\n refetch,\n fetchMore,\n }\n}\n"],"names":["useShopActionsPaginatedDataFetching","action","params","options","state","setState","useState","skip","validator","hook","runValidator","useCallback","dataToValidate","err","MiniError","stableParams","useMemo","fetch","extraParams","setLoading","setError","resetOnError","throwOnError","appendData","queryError","validationError","curState","result","newData","formatError","error","refetch","fetchMore","useEff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U,MAAM;AACd,IAAI1B,KAEJU;AAAA,MACE,CAAC;AAAA,MACD;AAAA,QACE,cAAc;AAAA,MAAA;AAAA,IAElB;AAAA,EAAA,GACC,CAACA,GAAOV,CAAI,CAAC,GAET;AAAA,IACL,MAAMH,EAAM;AAAA,IACZ,SAASA,EAAM;AAAA,IACf,OAAOA,EAAM;AAAA,IACb,aAAaA,EAAM,SAAS;AAAA,IAC5B,SAAA2B;AAAA,IACA,WAAAC;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useShopActionsPaginatedDataFetching.js","sources":["../../src/internal/useShopActionsPaginatedDataFetching.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {ShopAction, PaginationInfo} from '@shopify/shop-minis-platform/actions'\n\nimport {DataHookFetchPolicy, PaginatedDataHookReturnsBase} from '../types'\nimport {formatError, MiniError} from '../utils/errors'\n\nexport interface ShopActionsDataFetchingResult<S>\n extends PaginatedDataHookReturnsBase {\n data: S | null\n}\n\nexport const useShopActionsPaginatedDataFetching = <\n S = unknown,\n P extends {after?: string; fetchPolicy?: DataHookFetchPolicy} = {\n after?: undefined\n fetchPolicy?: DataHookFetchPolicy\n },\n>(\n action: ShopAction<P, {data: S; pageInfo: PaginationInfo}>,\n params: P,\n options: {\n skip?: boolean\n hook?: string\n validator?: (data: S) => void\n }\n): ShopActionsDataFetchingResult<S> => {\n const [state, setState] = useState<{\n data: S | null\n pageInfo: PaginationInfo\n loading: boolean\n error: Error | null\n }>({\n data: null,\n pageInfo: {hasNextPage: false, endCursor: null},\n loading: false,\n error: null,\n })\n\n const skip = options?.skip === true\n const {validator, hook} = options\n const runValidator = useCallback(\n (dataToValidate: S): Error | null => {\n try {\n validator?.(dataToValidate)\n return null\n } catch (err) {\n if (err instanceof Error) return err\n\n return new MiniError({\n hook,\n message: 'Validation failed',\n })\n }\n },\n [validator, hook]\n )\n\n // Params object is recreated on every render, so we need to memoize it.\n // We don't know what's inside the params object, but we can stringify it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableParams = useMemo(() => params, [JSON.stringify(params)])\n\n // There's a lot of complexity here because each type of fetch has different side effects if we are trying to\n // stay close to how Apollo client works. eg:\n // - Initial fetch: set loading, set error, set data, reset on error (don't throw)\n // - change params fetch: set loading, set error, set data, reset on error (don't throw)\n // - refetch fetch: don't set loading, set error, update data, leave data as is was on error (also throw)\n // - fetchMore fetch: don't set loading, don't set error, update data, leave data as is was on error (also throw)\n const fetch = useCallback(\n async (\n extraParams?: Partial<P>,\n {\n setLoading = true,\n setError = true,\n resetOnError = true,\n throwOnError = true,\n appendData = false,\n }: {\n setLoading?: boolean\n setError?: boolean\n resetOnError?: boolean\n throwOnError?: boolean\n appendData?: boolean\n } = {}\n ) => {\n let queryError: Error | null = null\n let validationError: Error | null = null\n\n setState(curState => ({\n ...curState,\n loading: setLoading ? true : curState.loading,\n }))\n\n try {\n const result = await action({...stableParams, ...extraParams})\n\n if (result.ok) {\n validationError = runValidator(result.data.data)\n\n setState(curState => {\n let newData = result.data.data\n\n if (\n appendData &&\n curState.data &&\n Array.isArray(curState.data) &&\n Array.isArray(result.data.data)\n ) {\n newData = [...curState.data, ...result.data.data] as S\n }\n\n return {\n ...curState,\n data: newData,\n pageInfo: result.data.pageInfo,\n loading: false,\n error: validationError ?? null,\n }\n })\n } else {\n throw result.error\n }\n } catch (err) {\n console.log('caught 1', err)\n queryError = formatError({hook}, err)\n }\n\n const error = validationError || queryError\n\n if (error && (setError || resetOnError)) {\n setState(curState => ({\n data: resetOnError ? null : curState.data,\n pageInfo: resetOnError\n ? {hasNextPage: false, endCursor: null}\n : curState.pageInfo,\n loading: false,\n error,\n }))\n }\n\n if (error && throwOnError) {\n throw error\n }\n },\n [action, stableParams, hook, runValidator]\n )\n\n const refetch = useCallback(async () => {\n await fetch({fetchPolicy: 'network-only'} as Partial<P>, {\n setLoading: false,\n resetOnError: false,\n throwOnError: true,\n })\n }, [fetch])\n\n const fetchMore = useCallback(async () => {\n if (!state.pageInfo.hasNextPage || !state.pageInfo.endCursor) return\n\n await fetch({after: state.pageInfo.endCursor} as Partial<P>, {\n setLoading: false,\n setError: false,\n resetOnError: false,\n throwOnError: true,\n appendData: true,\n })\n }, [state.pageInfo.hasNextPage, state.pageInfo.endCursor, fetch])\n\n useEffect(() => {\n if (skip) return\n\n fetch(\n {},\n {\n throwOnError: false,\n }\n )\n }, [fetch, skip])\n\n return {\n data: state.data,\n loading: state.loading,\n error: state.error,\n hasNextPage: state.pageInfo.hasNextPage,\n refetch,\n fetchMore,\n }\n}\n"],"names":["useShopActionsPaginatedDataFetching","action","params","options","state","setState","useState","skip","validator","hook","runValidator","useCallback","dataToValidate","err","MiniError","stableParams","useMemo","fetch","extraParams","setLoading","setError","resetOnError","throwOnError","appendData","queryError","validationError","curState","result","newData","formatError","error","refetch","fetchMore","useEffect"],"mappings":";;AAYO,MAAMA,IAAsC,CAOjDC,GACAC,GACAC,MAKqC;AACrC,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAKvB;AAAA,IACD,MAAM;AAAA,IACN,UAAU,EAAC,aAAa,IAAO,WAAW,KAAI;AAAA,IAC9C,SAAS;AAAA,IACT,OAAO;AAAA,EAAA,CACR,GAEKC,IAAOJ,GAAS,SAAS,IACzB,EAAC,WAAAK,GAAW,MAAAC,EAAA,IAAQN,GACpBO,IAAeC;AAAA,IACnB,CAACC,MAAoC;AAC/B,UAAA;AACF,eAAAJ,IAAYI,CAAc,GACnB;AAAA,eACAC,GAAK;AACR,eAAAA,aAAe,QAAcA,IAE1B,IAAIC,EAAU;AAAA,UACnB,MAAAL;AAAA,UACA,SAAS;AAAA,QAAA,CACV;AAAA,MAAA;AAAA,IAEL;AAAA,IACA,CAACD,GAAWC,CAAI;AAAA,EAClB,GAKMM,IAAeC,EAAQ,MAAMd,GAAQ,CAAC,KAAK,UAAUA,CAAM,CAAC,CAAC,GAQ7De,IAAQN;AAAA,IACZ,OACEO,GACA;AAAA,MACE,YAAAC,IAAa;AAAA,MACb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Y;AAAA,EAC3C,GAEMqB,IAAUpB,EAAY,YAAY;AACtC,UAAMM,EAAM,EAAC,aAAa,kBAA+B;AAAA,MACvD,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,cAAc;AAAA,IAAA,CACf;AAAA,EAAA,GACA,CAACA,CAAK,CAAC,GAEJe,IAAYrB,EAAY,YAAY;AACxC,IAAI,CAACP,EAAM,SAAS,eAAe,CAACA,EAAM,SAAS,aAEnD,MAAMa,EAAM,EAAC,OAAOb,EAAM,SAAS,aAA0B;AAAA,MAC3D,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,IAAA,CACb;AAAA,EAAA,GACA,CAACA,EAAM,SAAS,aAAaA,EAAM,SAAS,WAAWa,CAAK,CAAC;AAEhE,SAAAgB,EAAU,MAAM;AACd,IAAI1B,KAEJU;AAAA,MACE,CAAC;AAAA,MACD;AAAA,QACE,cAAc;AAAA,MAAA;AAAA,IAElB;AAAA,EAAA,GACC,CAACA,GAAOV,CAAI,CAAC,GAET;AAAA,IACL,MAAMH,EAAM;AAAA,IACZ,SAASA,EAAM;AAAA,IACf,OAAOA,EAAM;AAAA,IACb,aAAaA,EAAM,SAAS;AAAA,IAC5B,SAAA2B;AAAA,IACA,WAAAC;AAAA,EACF;AACF;"}
package/dist/mocks.js ADDED
@@ -0,0 +1,267 @@
1
+ const t = (e, a, r = "99.99", d) => ({
2
+ id: e,
3
+ title: a,
4
+ price: { amount: r, currencyCode: "USD" },
5
+ ...d && {
6
+ compareAtPrice: { amount: d, currencyCode: "USD" }
7
+ },
8
+ reviewAnalytics: { averageRating: 4.5, reviewCount: 10 },
9
+ shop: { id: "shop1", name: "Mock Shop" },
10
+ defaultVariantId: `variant-${e}`,
11
+ isFavorited: !1,
12
+ featuredImage: { url: "https://picsum.photos/400/400", altText: a }
13
+ }), i = (e, a) => ({
14
+ id: e,
15
+ name: a,
16
+ isFollowing: !1,
17
+ primaryDomain: {
18
+ url: `https://${a.toLowerCase().replace(/\s+/g, "-")}.com`
19
+ },
20
+ reviewAnalytics: { averageRating: 4.3, reviewCount: 50 },
21
+ visualTheme: {
22
+ id: "visual-theme-1",
23
+ featuredImages: [{ url: "https://picsum.photos/400/400", sensitive: !1 }],
24
+ logoImage: { url: "https://picsum.photos/100/400", sensitive: !1 }
25
+ }
26
+ }), o = (e = !1) => ({
27
+ hasNextPage: e,
28
+ endCursor: e ? "cursor123" : null
29
+ }), s = (e, a, r = []) => ({
30
+ id: e,
31
+ publicId: `public-${e}`,
32
+ name: a,
33
+ products: r
34
+ });
35
+ function n(e, a) {
36
+ return (r) => (console.log(`[Mock Action] ${String(e)}`, r), Promise.resolve({ ok: !0, data: a }));
37
+ }
38
+ function c() {
39
+ const e = {
40
+ followShop: !0,
41
+ unfollowShop: !1,
42
+ favorite: void 0,
43
+ unfavorite: void 0,
44
+ getShopAppInformation: {
45
+ appVersion: "1.0.0",
46
+ buildNumber: "12345",
47
+ buildId: "dev-build-123"
48
+ },
49
+ productRecommendationImpression: void 0,
50
+ productRecommendationClick: void 0,
51
+ hideEntryPoint: void 0,
52
+ closeMini: void 0,
53
+ getAccountInformation: {
54
+ status: "available",
55
+ value: "user@example.com"
56
+ },
57
+ getCurrentUser: {
58
+ data: {
59
+ displayName: "John Doe",
60
+ avatarImage: { url: "https://example.com/avatar.jpg" }
61
+ }
62
+ },
63
+ createOrderAttribution: void 0,
64
+ addToCart: void 0,
65
+ buyProduct: void 0,
66
+ buyProducts: void 0,
67
+ showErrorScreen: void 0,
68
+ showErrorToast: void 0,
69
+ getDeeplinkPaths: {
70
+ matchers: ["/products", "/collections", "/cart"]
71
+ },
72
+ navigateToDeeplink: void 0,
73
+ navigateToShop: void 0,
74
+ navigateToProduct: void 0,
75
+ navigateToOrder: void 0,
76
+ navigateToCheckout: void 0,
77
+ createImageUploadLink: {
78
+ targets: [
79
+ {
80
+ url: "https://example.com/upload",
81
+ resourceUrl: "https://example.com/resource",
82
+ parameters: [{ name: "key", value: "upload-123" }]
83
+ }
84
+ ]
85
+ },
86
+ completeImageUpload: {
87
+ files: [
88
+ {
89
+ id: "file-123",
90
+ fileStatus: "READY",
91
+ image: { url: "https://example.com/image.jpg" }
92
+ }
93
+ ]
94
+ },
95
+ getPersistedItem: "stored-value",
96
+ setPersistedItem: void 0,
97
+ removePersistedItem: void 0,
98
+ getAllPersistedKeys: ["key1", "key2", "key3"],
99
+ clearPersistedItems: void 0,
100
+ getInternalPersistedItem: "internal-value",
101
+ setInternalPersistedItem: void 0,
102
+ removeInternalPersistedItem: void 0,
103
+ getAllInternalPersistedKeys: ["internal-key1", "internal-key2"],
104
+ clearInternalPersistedItems: void 0,
105
+ getSecret: "secret-value",
106
+ setSecret: void 0,
107
+ removeSecret: void 0,
108
+ reportInteraction: void 0,
109
+ reportImpression: void 0,
110
+ reportContentImpression: void 0,
111
+ getProductLists: {
112
+ data: [
113
+ s("list-1", "Wishlist"),
114
+ s("list-2", "Favorites")
115
+ ],
116
+ pageInfo: o()
117
+ },
118
+ getProductList: {
119
+ data: s("list-1", "Wishlist", [
120
+ t("prod-1", "Sample Product")
121
+ ]),
122
+ pageInfo: o()
123
+ },
124
+ addProductList: s("list-3", "New List"),
125
+ removeProductList: void 0,
126
+ renameProductList: s("list-1", "Updated Wishlist"),
127
+ addProductListItem: void 0,
128
+ removeProductListItem: void 0,
129
+ getRecommendedProducts: {
130
+ data: [
131
+ t("rec-1", "Recommended Product 1", "79.99"),
132
+ t("rec-2", "Recommended Product 2", "129.99")
133
+ ],
134
+ pageInfo: o()
135
+ },
136
+ getRecommendedShops: {
137
+ data: [
138
+ i("shop-1", "Amazing Store"),
139
+ i("shop-2", "Best Deals Shop")
140
+ ],
141
+ pageInfo: o()
142
+ },
143
+ searchProductsByShop: {
144
+ data: [
145
+ t("search-1", "Search Result 1", "59.99"),
146
+ t("search-2", "Search Result 2", "89.99")
147
+ ],
148
+ pageInfo: o()
149
+ },
150
+ getOrders: {
151
+ data: [
152
+ {
153
+ id: "order-1",
154
+ name: "#1001",
155
+ lineItems: [
156
+ {
157
+ productTitle: "Sample Product",
158
+ variantTitle: "Medium",
159
+ quantity: 2,
160
+ product: null
161
+ }
162
+ ],
163
+ shop: i("shop-1", "Sample Shop")
164
+ }
165
+ ],
166
+ pageInfo: o()
167
+ },
168
+ getBuyerAttributes: {
169
+ data: {
170
+ genderAffinity: "NEUTRAL",
171
+ categoryAffinities: [
172
+ { id: "cat1", name: "Electronics" },
173
+ { id: "cat2", name: "Clothing" }
174
+ ]
175
+ }
176
+ },
177
+ showFeedbackSheet: void 0,
178
+ getPopularProducts: {
179
+ data: [
180
+ t("pop-1", "The Hero Snowboard", "702.95"),
181
+ t("pop-2", "Snow Jacket", "605.95", "702.00"),
182
+ t("pop-3", "Winter Gloves", "89.95")
183
+ ],
184
+ pageInfo: o()
185
+ },
186
+ share: {
187
+ message: "Shared!",
188
+ success: !0
189
+ },
190
+ getCuratedProducts: {
191
+ data: [
192
+ t("cur-1", "Curated Product 1", "79.99"),
193
+ t("cur-2", "Curated Product 2", "129.99")
194
+ ],
195
+ pageInfo: o()
196
+ },
197
+ getSavedProducts: {
198
+ data: [t("saved-1", "Saved Product 1", "49.99")],
199
+ pageInfo: o()
200
+ },
201
+ getRecentProducts: {
202
+ data: [t("recent-1", "Recent Product 1", "59.99")],
203
+ pageInfo: o()
204
+ },
205
+ getProductSearch: {
206
+ data: [t("search-3", "Search Product 3", "39.99")],
207
+ pageInfo: o()
208
+ },
209
+ getProducts: { data: [t("prod-2", "Product 2", "19.99")] },
210
+ getProduct: { data: t("prod-1", "Sample Product") },
211
+ getProductVariants: {
212
+ data: [
213
+ {
214
+ id: "variant-1",
215
+ isFavorited: !1,
216
+ image: { url: "https://example.com/variant-1.jpg" },
217
+ price: { amount: "19.99", currencyCode: "USD" },
218
+ compareAtPrice: { amount: "29.99", currencyCode: "USD" }
219
+ }
220
+ ],
221
+ pageInfo: o()
222
+ },
223
+ getProductMedia: {
224
+ data: [
225
+ {
226
+ id: "media-1",
227
+ image: { url: "https://example.com/media-1.jpg" },
228
+ mediaContentType: "IMAGE",
229
+ alt: "Sample product image"
230
+ }
231
+ ],
232
+ pageInfo: o()
233
+ },
234
+ getShop: { data: i("shop-1", "Sample Shop") },
235
+ getRecentShops: {
236
+ data: [i("recent-shop-1", "Recent Shop 1")],
237
+ pageInfo: o()
238
+ },
239
+ getFollowedShops: {
240
+ data: [i("followed-shop-1", "Followed Shop 1")],
241
+ pageInfo: o()
242
+ },
243
+ previewProductInAr: void 0
244
+ }, a = {};
245
+ for (const r in e)
246
+ Object.prototype.hasOwnProperty.call(e, r) && (a[r] = n(
247
+ r,
248
+ e[r]
249
+ ));
250
+ return a;
251
+ }
252
+ const l = () => {
253
+ const e = navigator.userAgent.toLowerCase(), a = /iphone|ipad|ipod/.test(e), r = /android/.test(e);
254
+ return a || r;
255
+ }, p = () => {
256
+ l() || window.minisSDK || (window.minisSDK = c(), window.minisParams = {
257
+ handle: "mock-handle",
258
+ initialUrl: "/mock-initial-url",
259
+ platform: "web"
260
+ });
261
+ };
262
+ export {
263
+ t as createProduct,
264
+ i as createShop,
265
+ p as injectMocks
266
+ };
267
+ //# sourceMappingURL=mocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.js","sources":["../src/mocks.ts"],"sourcesContent":["import {Product, Gender} 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: {id: 'shop1', name: 'Mock Shop'},\n defaultVariantId: `variant-${id}`,\n isFavorited: false,\n featuredImage: {url: `https://picsum.photos/400/400`, altText: title},\n})\n\nexport const createShop = (id: string, name: string) => ({\n id,\n name,\n isFollowing: false,\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-1',\n featuredImages: [{url: `https://picsum.photos/400/400`, sensitive: false}],\n logoImage: {url: `https://picsum.photos/100/400`, sensitive: false},\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\nfunction makeMockActions(): ShopActions {\n const results: {\n [K in keyof ShopActions]: ShopActionDataType<ShopActions[K]>\n } = {\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 ],\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 ],\n pageInfo: createPagination(),\n },\n share: {\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 } 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 = () => {\n // Only inject mocks if we aren't on a mobile device\n if (isMobile()) {\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","createPagination","hasNext","createProductList","products","makeMockMethod","key","result","params","makeMockActions","results","mock","isMobile","userAgent","isIOS","isAndroid","injectMocks"],"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,MAAM,EAAC,IAAI,SAAS,MAAM,YAAW;AAAA,EACrC,kBAAkB,WAAWH,CAAE;AAAA,EAC/B,aAAa;AAAA,EACb,eAAe,EAAC,KAAK,iCAAiC,SAASC,EAAK;AACtE,IAEaG,IAAa,CA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AAM;AAAA,QACJ;AAAA,UACE,IAAI;AAAA,UACJ,OAAO,EAAC,KAAK,kCAAiC;AAAA,UAC9C,kBAAkB;AAAA,UAClB,KAAK;AAAA,QAAA;AAAA,MAET;AAAA,MACA,UAAUA,EAAiB;AAAA,IAC7B;AAAA,IACA,SAAS,EAAC,MAAMF,EAAW,UAAU,aAAa,EAAC;AAAA,IACnD,gBAAgB;AAAA,MACd,MAAM,CAACA,EAAW,iBAAiB,eAAe,CAAC;AAAA,MACnD,UAAUE,EAAiB;AAAA,IAC7B;AAAA,IACA,kBAAkB;AAAA,MAChB,MAAM,CAACF,EAAW,mBAAmB,iBAAiB,CAAC;AAAA,MACvD,UAAUE,EAAiB;AAAA,IAC7B;AAAA,IACA,oBAAoB;AAAA,EACtB,GAEMU,IAA6B,CAAC;AACpC,aAAWL,KAAOI;AAChB,IAAI,OAAO,UAAU,eAAe,KAAKA,GAASJ,CAAG,MAEnDK,EAAKL,CAAG,IAAID;AAAA,MACVC;AAAA,MACAI,EAAQJ,CAA2B;AAAA,IACrC;AAGG,SAAAK;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,MAAM;AAE/B,EAAIJ,OAIC,OAAO,aACV,OAAO,WAAWH,EAAgB,GAClC,OAAO,cAAc;AAAA,IACnB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAEJ;"}
@@ -0,0 +1,8 @@
1
+ function i(e) {
2
+ if (e === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3
+ return e;
4
+ }
5
+ export {
6
+ i as default
7
+ };
8
+ //# sourceMappingURL=assertThisInitialized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertThisInitialized.js","sources":["../../../../../../../../../../node_modules/.pnpm/@babel+runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js"],"sourcesContent":["function _assertThisInitialized(e) {\n if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n return e;\n}\nexport { _assertThisInitialized as default };"],"names":["_assertThisInitialized"],"mappings":"AAAA,SAASA,EAAuB,GAAG;AACjC,MAAe,MAAX,OAAc,OAAM,IAAI,eAAe,2DAA2D;AACtG,SAAO;AACT;","x_google_ignoreList":[0]}
@@ -0,0 +1,13 @@
1
+ function e() {
2
+ return e = Object.assign ? Object.assign.bind() : function(t) {
3
+ for (var n = 1; n < arguments.length; n++) {
4
+ var a = arguments[n];
5
+ for (var r in a) ({}).hasOwnProperty.call(a, r) && (t[r] = a[r]);
6
+ }
7
+ return t;
8
+ }, e.apply(null, arguments);
9
+ }
10
+ export {
11
+ e as default
12
+ };
13
+ //# sourceMappingURL=extends.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extends.js","sources":["../../../../../../../../../../node_modules/.pnpm/@babel+runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js"],"sourcesContent":["function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };"],"names":["_extends","n","e","t"],"mappings":"AAAA,SAASA,IAAW;AAClB,SAAOA,IAAW,OAAO,SAAS,OAAO,OAAO,KAAI,IAAK,SAAUC,GAAG;AACpE,aAASC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AACzC,UAAIC,IAAI,UAAUD,CAAC;AACnB,eAAS,KAAKC,EAAG,EAAC,CAAE,GAAE,eAAe,KAAKA,GAAG,CAAC,MAAMF,EAAE,CAAC,IAAIE,EAAE,CAAC;AAAA,IACpE;AACI,WAAOF;AAAA,EACR,GAAED,EAAS,MAAM,MAAM,SAAS;AACnC;","x_google_ignoreList":[0]}
@@ -0,0 +1,8 @@
1
+ import e from "./setPrototypeOf.js";
2
+ function p(o, t) {
3
+ o.prototype = Object.create(t.prototype), o.prototype.constructor = o, e(o, t);
4
+ }
5
+ export {
6
+ p as default
7
+ };
8
+ //# sourceMappingURL=inheritsLoose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inheritsLoose.js","sources":["../../../../../../../../../../node_modules/.pnpm/@babel+runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"],"sourcesContent":["import setPrototypeOf from \"./setPrototypeOf.js\";\nfunction _inheritsLoose(t, o) {\n t.prototype = Object.create(o.prototype), t.prototype.constructor = t, setPrototypeOf(t, o);\n}\nexport { _inheritsLoose as default };"],"names":["_inheritsLoose","t","o","setPrototypeOf"],"mappings":";AACA,SAASA,EAAeC,GAAGC,GAAG;AAC5B,EAAAD,EAAE,YAAY,OAAO,OAAOC,EAAE,SAAS,GAAGD,EAAE,UAAU,cAAcA,GAAGE,EAAeF,GAAGC,CAAC;AAC5F;","x_google_ignoreList":[0]}
@@ -0,0 +1,9 @@
1
+ function e(o, r) {
2
+ return e = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, n) {
3
+ return t.__proto__ = n, t;
4
+ }, e(o, r);
5
+ }
6
+ export {
7
+ e as default
8
+ };
9
+ //# sourceMappingURL=setPrototypeOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setPrototypeOf.js","sources":["../../../../../../../../../../node_modules/.pnpm/@babel+runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js"],"sourcesContent":["function _setPrototypeOf(t, e) {\n return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {\n return t.__proto__ = e, t;\n }, _setPrototypeOf(t, e);\n}\nexport { _setPrototypeOf as default };"],"names":["_setPrototypeOf","t","e"],"mappings":"AAAA,SAASA,EAAgBC,GAAGC,GAAG;AAC7B,SAAOF,IAAkB,OAAO,iBAAiB,OAAO,eAAe,KAAM,IAAG,SAAU,GAAGE,GAAG;AAC9F,WAAO,EAAE,YAAYA,GAAG;AAAA,EAC5B,GAAKF,EAAgBC,GAAGC,CAAC;AACzB;","x_google_ignoreList":[0]}
@@ -0,0 +1,28 @@
1
+ var s = Number.isNaN || function(r) {
2
+ return typeof r == "number" && r !== r;
3
+ };
4
+ function o(e, r) {
5
+ return !!(e === r || s(e) && s(r));
6
+ }
7
+ function g(e, r) {
8
+ if (e.length !== r.length)
9
+ return !1;
10
+ for (var t = 0; t < e.length; t++)
11
+ if (!o(e[t], r[t]))
12
+ return !1;
13
+ return !0;
14
+ }
15
+ function h(e, r) {
16
+ r === void 0 && (r = g);
17
+ var t, f = [], u, l = !1;
18
+ function i() {
19
+ for (var n = [], a = 0; a < arguments.length; a++)
20
+ n[a] = arguments[a];
21
+ return l && t === this && r(n, f) || (u = e.apply(this, n), l = !0, t = this, f = n), u;
22
+ }
23
+ return i;
24
+ }
25
+ export {
26
+ h as default
27
+ };
28
+ //# sourceMappingURL=memoize-one.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize-one.esm.js","sources":["../../../../../../../../node_modules/.pnpm/memoize-one@5.2.1/node_modules/memoize-one/dist/memoize-one.esm.js"],"sourcesContent":["var safeIsNaN = Number.isNaN ||\n function ponyfill(value) {\n return typeof value === 'number' && value !== value;\n };\nfunction isEqual(first, second) {\n if (first === second) {\n return true;\n }\n if (safeIsNaN(first) && safeIsNaN(second)) {\n return true;\n }\n return false;\n}\nfunction areInputsEqual(newInputs, lastInputs) {\n if (newInputs.length !== lastInputs.length) {\n return false;\n }\n for (var i = 0; i < newInputs.length; i++) {\n if (!isEqual(newInputs[i], lastInputs[i])) {\n return false;\n }\n }\n return true;\n}\n\nfunction memoizeOne(resultFn, isEqual) {\n if (isEqual === void 0) { isEqual = areInputsEqual; }\n var lastThis;\n var lastArgs = [];\n var lastResult;\n var calledOnce = false;\n function memoized() {\n var newArgs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n newArgs[_i] = arguments[_i];\n }\n if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {\n return lastResult;\n }\n lastResult = resultFn.apply(this, newArgs);\n calledOnce = true;\n lastThis = this;\n lastArgs = newArgs;\n return lastResult;\n }\n return memoized;\n}\n\nexport default memoizeOne;\n"],"names":["safeIsNaN","value","isEqual","first","second","areInputsEqual","newInputs","lastInputs","i","memoizeOne","resultFn","lastThis","lastArgs","lastResult","calledOnce","memoized","newArgs","_i"],"mappings":"AAAA,IAAIA,IAAY,OAAO,SACnB,SAAkBC,GAAO;AACrB,SAAO,OAAOA,KAAU,YAAYA,MAAUA;AACjD;AACL,SAASC,EAAQC,GAAOC,GAAQ;AAI5B,SAHI,GAAAD,MAAUC,KAGVJ,EAAUG,CAAK,KAAKH,EAAUI,CAAM;AAI5C;AACA,SAASC,EAAeC,GAAWC,GAAY;AAC3C,MAAID,EAAU,WAAWC,EAAW;AAChC,WAAO;AAEX,WAASC,IAAI,GAAGA,IAAIF,EAAU,QAAQE;AAClC,QAAI,CAACN,EAAQI,EAAUE,CAAC,GAAGD,EAAWC,CAAC,CAAC;AACpC,aAAO;AAGf,SAAO;AACX;AAEA,SAASC,EAAWC,GAAUR,GAAS;AACnC,EAAIA,MAAY,WAAUA,IAAUG;AACpC,MAAIM,GACAC,IAAW,CAAE,GACbC,GACAC,IAAa;AACjB,WAASC,IAAW;AAEhB,aADIC,IAAU,CAAE,GACPC,IAAK,GAAGA,IAAK,UAAU,QAAQA;AACpC,MAAAD,EAAQC,CAAE,IAAI,UAAUA,CAAE;AAE9B,WAAIH,KAAcH,MAAa,QAAQT,EAAQc,GAASJ,CAAQ,MAGhEC,IAAaH,EAAS,MAAM,MAAMM,CAAO,GACzCF,IAAa,IACbH,IAAW,MACXC,IAAWI,IACJH;AAAA,EACf;AACI,SAAOE;AACX;","x_google_ignoreList":[0]}