@gem-sdk/core 12.0.0-dev.144 → 12.0.0-dev.150
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/cjs/hooks/shop.js +1 -1
- package/dist/esm/hooks/shop.js +1 -1
- package/package.json +3 -3
package/dist/cjs/hooks/shop.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("react"),t=require("swr"),
|
|
2
|
+
"use strict";var e=require("react"),t=require("swr"),r=require("../contexts/ShopContext.js");const o=()=>{let e=r.useShopStore(e=>e.provider),t=r.useShopStore(e=>e.storefrontToken),o=r.useShopStore(e=>e.storefrontUrl);return{provider:e,storefrontToken:t,storefrontUrl:o}};exports.useCheckoutUrl=function(e){let{storefrontToken:t}=o();if(e)return t?`${e}?access_token=${t}`:e},exports.useConnectedShopify=function(){let{storefrontToken:e}=o();return!!e},exports.useCurrency=()=>{let t=r.useShopStore(e=>e.currency),o=r.useShopStore(e=>e.changeCurrency);return e.useMemo(()=>({currency:t,changeCurrency:o}),[t,o])},exports.useEditorMode=()=>r.useShopStore(e=>e.mode),exports.useIsSampleProduct=function(){let{storefrontToken:e}=o(),t=r.useShopStore(e=>e.isStorefront);return t&&!e},exports.useIsStorefrontProduct=function(){return r.useShopStore(e=>e.isStorefront)},exports.useLocale=()=>{let t=r.useShopStore(e=>e.locale),o=r.useShopStore(e=>e.changeLocale);return e.useMemo(()=>({locale:t,changeLocale:o}),[t,o])},exports.useMatchMutate=()=>{let{cache:e,mutate:r}=t.useSWRConfig(),o=["query/products","query/collection","query/product"];return(t,s)=>{if(!(e instanceof Map))throw Error("matchMutate requires the cache provider to be a Map instance");let u=[];e.forEach((e,r)=>{t.test(r)&&u.push(r)});let n=u.map(t=>{let u=e.get(t),n=o.some(e=>t.includes(e));return n?r(t,void 0,s):r(t,u?.data,s)});return Promise.all(n)}},exports.useMobileOnly=()=>r.useShopStore(e=>e.mobileOnly),exports.useMoneyFormat=()=>{let t=r.useShopStore(e=>e.moneyFormat),o=r.useShopStore(e=>e.moneyWithCurrencyFormat);return e.useMemo(()=>({moneyFormat:t,moneyWithCurrencyFormat:o}),[t,o])},exports.usePageType=()=>{let t=r.useShopStore(e=>e.pageType);return e.useMemo(()=>t||"STATIC",[t])},exports.usePluginEnable=()=>r.useShopStore(e=>e.plugins),exports.useStoreFront=o,exports.useSwatches=()=>{let t=r.useShopStore(e=>e.swatches),o=r.useShopStore(e=>e.changeSwatches);return e.useMemo(()=>({swatches:t,changeSwatches:o}),[t,o])},exports.useTimezone=()=>{let t=r.useShopStore(e=>e.timezone);return e.useMemo(()=>({timezone:t}),[t])};
|
package/dist/esm/hooks/shop.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useMemo as e}from"react";import{useSWRConfig as t}from"swr";import{useShopStore as r}from"../contexts/ShopContext.js";let o=()=>{let t=r(e=>e.locale),o=r(e=>e.changeLocale);return e(()=>({locale:t,changeLocale:o}),[t,o])},n=()=>{let t=r(e=>e.currency),o=r(e=>e.changeCurrency);return e(()=>({currency:t,changeCurrency:o}),[t,o])},u=()=>{let t=r(e=>e.timezone);return e(()=>({timezone:t}),[t])},s=()=>{let t=r(e=>e.moneyFormat),o=r(e=>e.moneyWithCurrencyFormat);return e(()=>({moneyFormat:t,moneyWithCurrencyFormat:o}),[t,o])},c=()=>{let t=r(e=>e.swatches),o=r(e=>e.changeSwatches);return e(()=>({swatches:t,changeSwatches:o}),[t,o])},l=()=>{let t=r(e=>e.pageType);return e(()=>t||"STATIC",[t])},a=()=>{let e=r(e=>e.provider),t=r(e=>e.storefrontToken),o=r(e=>e.storefrontUrl);return{provider:e,storefrontToken:t,storefrontUrl:o}},i=()=>r(e=>e.plugins),m=()=>r(e=>e.mode),p=()=>r(e=>e.mobileOnly),f=()=>{let{cache:e,mutate:r}=t(),o=["query/products","query/collection"];return(t,n)=>{if(!(e instanceof Map))throw Error("matchMutate requires the cache provider to be a Map instance");let u=[];e.forEach((e,r)=>{t.test(r)&&u.push(r)});let s=u.map(t=>{let u=e.get(t),s=o.some(e=>t.includes(e));return s?r(t,void 0,n):r(t,u?.data,n)});return Promise.all(s)}};function h(){let{storefrontToken:e}=a();return!!e}function y(){let{storefrontToken:e}=a(),t=r(e=>e.isStorefront);return t&&!e}function d(){return r(e=>e.isStorefront)}function S(e){let{storefrontToken:t}=a();if(e)return t?`${e}?access_token=${t}`:e}export{S as useCheckoutUrl,h as useConnectedShopify,n as useCurrency,m as useEditorMode,y as useIsSampleProduct,d as useIsStorefrontProduct,o as useLocale,f as useMatchMutate,p as useMobileOnly,s as useMoneyFormat,l as usePageType,i as usePluginEnable,a as useStoreFront,c as useSwatches,u as useTimezone};
|
|
2
|
+
import{useMemo as e}from"react";import{useSWRConfig as t}from"swr";import{useShopStore as r}from"../contexts/ShopContext.js";let o=()=>{let t=r(e=>e.locale),o=r(e=>e.changeLocale);return e(()=>({locale:t,changeLocale:o}),[t,o])},n=()=>{let t=r(e=>e.currency),o=r(e=>e.changeCurrency);return e(()=>({currency:t,changeCurrency:o}),[t,o])},u=()=>{let t=r(e=>e.timezone);return e(()=>({timezone:t}),[t])},s=()=>{let t=r(e=>e.moneyFormat),o=r(e=>e.moneyWithCurrencyFormat);return e(()=>({moneyFormat:t,moneyWithCurrencyFormat:o}),[t,o])},c=()=>{let t=r(e=>e.swatches),o=r(e=>e.changeSwatches);return e(()=>({swatches:t,changeSwatches:o}),[t,o])},l=()=>{let t=r(e=>e.pageType);return e(()=>t||"STATIC",[t])},a=()=>{let e=r(e=>e.provider),t=r(e=>e.storefrontToken),o=r(e=>e.storefrontUrl);return{provider:e,storefrontToken:t,storefrontUrl:o}},i=()=>r(e=>e.plugins),m=()=>r(e=>e.mode),p=()=>r(e=>e.mobileOnly),f=()=>{let{cache:e,mutate:r}=t(),o=["query/products","query/collection","query/product"];return(t,n)=>{if(!(e instanceof Map))throw Error("matchMutate requires the cache provider to be a Map instance");let u=[];e.forEach((e,r)=>{t.test(r)&&u.push(r)});let s=u.map(t=>{let u=e.get(t),s=o.some(e=>t.includes(e));return s?r(t,void 0,n):r(t,u?.data,n)});return Promise.all(s)}};function h(){let{storefrontToken:e}=a();return!!e}function y(){let{storefrontToken:e}=a(),t=r(e=>e.isStorefront);return t&&!e}function d(){return r(e=>e.isStorefront)}function S(e){let{storefrontToken:t}=a();if(e)return t?`${e}?access_token=${t}`:e}export{S as useCheckoutUrl,h as useConnectedShopify,n as useCurrency,m as useEditorMode,y as useIsSampleProduct,d as useIsStorefrontProduct,o as useLocale,f as useMatchMutate,p as useMobileOnly,s as useMoneyFormat,l as usePageType,i as usePluginEnable,a as useStoreFront,c as useSwatches,u as useTimezone};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "12.0.0-dev.
|
|
3
|
+
"version": "12.0.0-dev.150",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"type-check": "yarn tsc --noEmit"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@gem-sdk/adapter-shopify": "12.0.0-dev.
|
|
32
|
-
"@gem-sdk/styles": "12.0.0-dev.
|
|
31
|
+
"@gem-sdk/adapter-shopify": "12.0.0-dev.150",
|
|
32
|
+
"@gem-sdk/styles": "12.0.0-dev.150",
|
|
33
33
|
"@types/classnames": "2.3.4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|