@anker-in/shopify-react 1.3.0-beta.10 → 1.3.0-beta.12
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/hooks/index.d.mts +3 -22
- package/dist/hooks/index.d.ts +3 -22
- package/dist/hooks/index.js +4 -65
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +5 -66
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.js +4 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as swr_mutation from 'swr/mutation';
|
|
2
2
|
import { SWRMutationConfiguration } from 'swr/mutation';
|
|
3
3
|
import * as _anker_in_shopify_sdk from '@anker-in/shopify-sdk';
|
|
4
|
-
import { CartLineInput, BuyerIdentityInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { CartLineInput, BuyerIdentityInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedShop, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
5
|
import { h as UseAddToCartOptions, g as AddToCartInput, A as AddToCartLineItem, G as GtmParams, C as BuyNowTrackConfig, e as UseScriptAutoFreeGiftResult, m as PlusMemberShippingMethodConfig, n as PlusMemberSettingsMetafields, D as DeliveryPlusType, o as SelectedPlusMemberVariant } from '../types-C0UyuPrG.mjs';
|
|
6
6
|
export { p as DeliveryCustomData, P as PLUS_MEMBER_TYPE, j as PlusMemberMode, l as PlusMemberShippingMethodMetafields, S as ScriptAutoFreeGiftConfig, k as ShippingMethodMode, U as UseAutoRemoveFreeGiftsOptions, a as UseAutoRemoveFreeGiftsResult, d as isAnyGift, c as isBuyGetGift, i as isFunctionGift, b as isScriptGift, u as useAutoRemoveFreeGifts, f as useScriptAutoFreeGift } from '../types-C0UyuPrG.mjs';
|
|
7
7
|
import * as swr from 'swr';
|
|
@@ -1350,33 +1350,14 @@ interface UseSearchOptions extends SWRConfiguration<SearchResult | undefined> {
|
|
|
1350
1350
|
}
|
|
1351
1351
|
declare function useSearch(options?: UseSearchOptions): swr.SWRResponse<SearchResult | undefined, any, SWRConfiguration<SearchResult | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>)> | undefined>;
|
|
1352
1352
|
|
|
1353
|
-
|
|
1354
|
-
name: string;
|
|
1355
|
-
description?: string;
|
|
1356
|
-
primaryDomain: {
|
|
1357
|
-
url: string;
|
|
1358
|
-
host: string;
|
|
1359
|
-
};
|
|
1360
|
-
brand?: {
|
|
1361
|
-
logo?: {
|
|
1362
|
-
image?: {
|
|
1363
|
-
url: string;
|
|
1364
|
-
};
|
|
1365
|
-
};
|
|
1366
|
-
colors?: {
|
|
1367
|
-
primary?: string;
|
|
1368
|
-
secondary?: string;
|
|
1369
|
-
};
|
|
1370
|
-
};
|
|
1371
|
-
metafields?: Record<string, any>;
|
|
1372
|
-
}
|
|
1353
|
+
type SiteInfo = NormalizedShop;
|
|
1373
1354
|
interface UseSiteOptions extends SWRConfiguration<SiteInfo | undefined> {
|
|
1374
1355
|
metafieldIdentifiers?: Array<{
|
|
1375
1356
|
namespace: string;
|
|
1376
1357
|
key: string;
|
|
1377
1358
|
}>;
|
|
1378
1359
|
}
|
|
1379
|
-
declare function useSite(options?: UseSiteOptions): swr.SWRResponse<
|
|
1360
|
+
declare function useSite(options?: UseSiteOptions): swr.SWRResponse<NormalizedShop | undefined, any, SWRConfiguration<NormalizedShop | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedShop | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedShop | undefined>)> | undefined>;
|
|
1380
1361
|
|
|
1381
1362
|
interface ShippingMethodsContext {
|
|
1382
1363
|
freeShippingMethods: PlusMemberShippingMethodConfig[];
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as swr_mutation from 'swr/mutation';
|
|
2
2
|
import { SWRMutationConfiguration } from 'swr/mutation';
|
|
3
3
|
import * as _anker_in_shopify_sdk from '@anker-in/shopify-sdk';
|
|
4
|
-
import { CartLineInput, BuyerIdentityInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { CartLineInput, BuyerIdentityInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedShop, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
5
|
import { h as UseAddToCartOptions, g as AddToCartInput, A as AddToCartLineItem, G as GtmParams, C as BuyNowTrackConfig, e as UseScriptAutoFreeGiftResult, m as PlusMemberShippingMethodConfig, n as PlusMemberSettingsMetafields, D as DeliveryPlusType, o as SelectedPlusMemberVariant } from '../types-C0UyuPrG.js';
|
|
6
6
|
export { p as DeliveryCustomData, P as PLUS_MEMBER_TYPE, j as PlusMemberMode, l as PlusMemberShippingMethodMetafields, S as ScriptAutoFreeGiftConfig, k as ShippingMethodMode, U as UseAutoRemoveFreeGiftsOptions, a as UseAutoRemoveFreeGiftsResult, d as isAnyGift, c as isBuyGetGift, i as isFunctionGift, b as isScriptGift, u as useAutoRemoveFreeGifts, f as useScriptAutoFreeGift } from '../types-C0UyuPrG.js';
|
|
7
7
|
import * as swr from 'swr';
|
|
@@ -1350,33 +1350,14 @@ interface UseSearchOptions extends SWRConfiguration<SearchResult | undefined> {
|
|
|
1350
1350
|
}
|
|
1351
1351
|
declare function useSearch(options?: UseSearchOptions): swr.SWRResponse<SearchResult | undefined, any, SWRConfiguration<SearchResult | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>)> | undefined>;
|
|
1352
1352
|
|
|
1353
|
-
|
|
1354
|
-
name: string;
|
|
1355
|
-
description?: string;
|
|
1356
|
-
primaryDomain: {
|
|
1357
|
-
url: string;
|
|
1358
|
-
host: string;
|
|
1359
|
-
};
|
|
1360
|
-
brand?: {
|
|
1361
|
-
logo?: {
|
|
1362
|
-
image?: {
|
|
1363
|
-
url: string;
|
|
1364
|
-
};
|
|
1365
|
-
};
|
|
1366
|
-
colors?: {
|
|
1367
|
-
primary?: string;
|
|
1368
|
-
secondary?: string;
|
|
1369
|
-
};
|
|
1370
|
-
};
|
|
1371
|
-
metafields?: Record<string, any>;
|
|
1372
|
-
}
|
|
1353
|
+
type SiteInfo = NormalizedShop;
|
|
1373
1354
|
interface UseSiteOptions extends SWRConfiguration<SiteInfo | undefined> {
|
|
1374
1355
|
metafieldIdentifiers?: Array<{
|
|
1375
1356
|
namespace: string;
|
|
1376
1357
|
key: string;
|
|
1377
1358
|
}>;
|
|
1378
1359
|
}
|
|
1379
|
-
declare function useSite(options?: UseSiteOptions): swr.SWRResponse<
|
|
1360
|
+
declare function useSite(options?: UseSiteOptions): swr.SWRResponse<NormalizedShop | undefined, any, SWRConfiguration<NormalizedShop | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedShop | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedShop | undefined>)> | undefined>;
|
|
1380
1361
|
|
|
1381
1362
|
interface ShippingMethodsContext {
|
|
1382
1363
|
freeShippingMethods: PlusMemberShippingMethodConfig[];
|
package/dist/hooks/index.js
CHANGED
|
@@ -3186,76 +3186,15 @@ function useSearch(options = {}) {
|
|
|
3186
3186
|
swrOptions
|
|
3187
3187
|
);
|
|
3188
3188
|
}
|
|
3189
|
-
async function getSiteInfo(client, locale, metafieldIdentifiers) {
|
|
3190
|
-
const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
|
|
3191
|
-
const query = (
|
|
3192
|
-
/* GraphQL */
|
|
3193
|
-
`
|
|
3194
|
-
query getSiteInfo(
|
|
3195
|
-
${hasMetafields ? "$shopMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
3196
|
-
) {
|
|
3197
|
-
shop {
|
|
3198
|
-
name
|
|
3199
|
-
description
|
|
3200
|
-
primaryDomain {
|
|
3201
|
-
url
|
|
3202
|
-
host
|
|
3203
|
-
}
|
|
3204
|
-
brand {
|
|
3205
|
-
logo {
|
|
3206
|
-
image {
|
|
3207
|
-
url
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
colors {
|
|
3211
|
-
primary {
|
|
3212
|
-
background
|
|
3213
|
-
}
|
|
3214
|
-
secondary {
|
|
3215
|
-
background
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
${hasMetafields ? "metafields(identifiers: $shopMetafieldIdentifiers) { key value }" : ""}
|
|
3220
|
-
}
|
|
3221
|
-
}
|
|
3222
|
-
`
|
|
3223
|
-
);
|
|
3224
|
-
const variables = {};
|
|
3225
|
-
if (hasMetafields) {
|
|
3226
|
-
variables.shopMetafieldIdentifiers = metafieldIdentifiers;
|
|
3227
|
-
}
|
|
3228
|
-
const data = await client.query(query, variables);
|
|
3229
|
-
if (!data || !data.shop) {
|
|
3230
|
-
return void 0;
|
|
3231
|
-
}
|
|
3232
|
-
const shop = data.shop;
|
|
3233
|
-
const metafields = shop.metafields?.reduce((acc, mf) => {
|
|
3234
|
-
if (mf && mf.key) {
|
|
3235
|
-
acc[mf.key] = mf.value;
|
|
3236
|
-
}
|
|
3237
|
-
return acc;
|
|
3238
|
-
}, {});
|
|
3239
|
-
return {
|
|
3240
|
-
name: shop.name,
|
|
3241
|
-
description: shop.description,
|
|
3242
|
-
primaryDomain: shop.primaryDomain,
|
|
3243
|
-
brand: shop.brand ? {
|
|
3244
|
-
logo: shop.brand.logo,
|
|
3245
|
-
colors: shop.brand.colors ? {
|
|
3246
|
-
primary: shop.brand.colors.primary?.background,
|
|
3247
|
-
secondary: shop.brand.colors.secondary?.background
|
|
3248
|
-
} : void 0
|
|
3249
|
-
} : void 0,
|
|
3250
|
-
metafields
|
|
3251
|
-
};
|
|
3252
|
-
}
|
|
3253
3189
|
function useSite(options = {}) {
|
|
3254
3190
|
const { client, locale } = useShopify();
|
|
3255
3191
|
const { metafieldIdentifiers, ...swrOptions } = options;
|
|
3256
3192
|
return useSWR__default.default(
|
|
3257
3193
|
["site", locale, metafieldIdentifiers],
|
|
3258
|
-
() =>
|
|
3194
|
+
() => shopifySdk.getShop(client, {
|
|
3195
|
+
locale,
|
|
3196
|
+
metafieldIdentifiers
|
|
3197
|
+
}),
|
|
3259
3198
|
swrOptions
|
|
3260
3199
|
);
|
|
3261
3200
|
}
|