@fayz-ai/storefront 0.48.0 → 0.50.0
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/{chunk-SWLXBTHY.js → chunk-PU7DSP2T.js} +41 -11
- package/dist/chunk-PU7DSP2T.js.map +1 -0
- package/dist/data/auth.d.ts +8 -0
- package/dist/data/auth.d.ts.map +1 -1
- package/dist/document/store-policy.d.ts +7 -1
- package/dist/document/store-policy.d.ts.map +1 -1
- package/dist/hooks/use-known-customer.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/render.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-SWLXBTHY.js.map +0 -1
|
@@ -77,10 +77,8 @@ function initCustomerAuth(adapter) {
|
|
|
77
77
|
_accessToken = existing?.session.accessToken ?? null;
|
|
78
78
|
if (!existing) return;
|
|
79
79
|
_hadAuthUser = true;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
void linkCustomer(existing.user);
|
|
83
|
-
}
|
|
80
|
+
void linkCustomer(existing.user).catch(() => {
|
|
81
|
+
});
|
|
84
82
|
}).catch(() => {
|
|
85
83
|
});
|
|
86
84
|
adapter.onAuthStateChange((user) => {
|
|
@@ -93,9 +91,26 @@ function initCustomerAuth(adapter) {
|
|
|
93
91
|
return;
|
|
94
92
|
}
|
|
95
93
|
_hadAuthUser = true;
|
|
96
|
-
|
|
94
|
+
const linked = useSessionStore.getState();
|
|
95
|
+
const needsLink = !linked.customerId || (linked.email ?? "").toLowerCase() !== (user.email ?? "").toLowerCase();
|
|
96
|
+
void syncAccessToken(adapter).then(() => {
|
|
97
|
+
if (needsLink && user.email) return linkCustomer(user).then(() => void 0);
|
|
98
|
+
}).catch(() => {
|
|
99
|
+
});
|
|
97
100
|
});
|
|
98
101
|
}
|
|
102
|
+
function hasCustomerAuth() {
|
|
103
|
+
return _hadAuthUser;
|
|
104
|
+
}
|
|
105
|
+
async function relinkCustomer() {
|
|
106
|
+
if (!_hadAuthUser) return null;
|
|
107
|
+
const existing = await getCustomerAuthAdapter().getSession().catch(() => null);
|
|
108
|
+
if (!existing?.user.email) return null;
|
|
109
|
+
const customer = await resolveShopCustomer(existing.user.email.trim().toLowerCase(), existing.user.fullName ?? "");
|
|
110
|
+
const store = useSessionStore.getState();
|
|
111
|
+
store.setSession({ customerId: customer.id, email: existing.user.email.trim().toLowerCase(), name: store.name });
|
|
112
|
+
return { customerId: customer.id, phone: customer.phone ?? null, document: customer.document ?? null };
|
|
113
|
+
}
|
|
99
114
|
function getCustomerAuthAdapter() {
|
|
100
115
|
if (!_adapter) _adapter = createMockAuthAdapter();
|
|
101
116
|
return _adapter;
|
|
@@ -6774,6 +6789,10 @@ function applyStoreSettings(config, settings) {
|
|
|
6774
6789
|
}
|
|
6775
6790
|
return next;
|
|
6776
6791
|
}
|
|
6792
|
+
function applyShippingSettings(config, shipping) {
|
|
6793
|
+
if (!shipping) return config;
|
|
6794
|
+
return { ...config, shipping: { flatRate: shipping.flatRate, freeAbove: shipping.freeAbove ?? void 0 } };
|
|
6795
|
+
}
|
|
6777
6796
|
function applyBuyer(config, buyer) {
|
|
6778
6797
|
if (!buyer) return config;
|
|
6779
6798
|
const language = normalizeLanguage(buyer.language) ?? config.language;
|
|
@@ -6788,6 +6807,7 @@ function StorefrontConfigHost({
|
|
|
6788
6807
|
children
|
|
6789
6808
|
}) {
|
|
6790
6809
|
const [policy, setPolicy] = React38.useState(null);
|
|
6810
|
+
const [shipping, setShipping] = React38.useState(null);
|
|
6791
6811
|
React38.useEffect(() => {
|
|
6792
6812
|
let cancelled = false;
|
|
6793
6813
|
let provider;
|
|
@@ -6796,6 +6816,12 @@ function StorefrontConfigHost({
|
|
|
6796
6816
|
} catch {
|
|
6797
6817
|
return;
|
|
6798
6818
|
}
|
|
6819
|
+
if (typeof provider.getShippingSettings === "function") {
|
|
6820
|
+
void provider.getShippingSettings().then((saved) => {
|
|
6821
|
+
if (!cancelled) setShipping(saved);
|
|
6822
|
+
}).catch(() => {
|
|
6823
|
+
});
|
|
6824
|
+
}
|
|
6799
6825
|
if (typeof provider.getPublicStoreSettings !== "function") return;
|
|
6800
6826
|
void provider.getPublicStoreSettings().then((settings) => {
|
|
6801
6827
|
if (cancelled) return;
|
|
@@ -6814,8 +6840,8 @@ function StorefrontConfigHost({
|
|
|
6814
6840
|
};
|
|
6815
6841
|
}, [config]);
|
|
6816
6842
|
const resolved = React38.useMemo(
|
|
6817
|
-
() => applyBuyer(applyStoreSettings(config, policy), buyer),
|
|
6818
|
-
[config, policy, buyer?.language, buyer?.country]
|
|
6843
|
+
() => applyBuyer(applyShippingSettings(applyStoreSettings(config, policy), shipping), buyer),
|
|
6844
|
+
[config, policy, shipping, buyer?.language, buyer?.country]
|
|
6819
6845
|
);
|
|
6820
6846
|
return /* @__PURE__ */ jsx(StorefrontConfigProvider, { value: resolved, children: /* @__PURE__ */ jsx(MarketScope, { children }) });
|
|
6821
6847
|
}
|
|
@@ -9344,9 +9370,13 @@ function useKnownCustomer() {
|
|
|
9344
9370
|
}
|
|
9345
9371
|
let cancelled = false;
|
|
9346
9372
|
const shop = getShopProvider();
|
|
9347
|
-
Promise.resolve(shop.getCustomer?.(customerId)).then((customer) => {
|
|
9373
|
+
Promise.resolve(shop.getCustomer?.(customerId)).then(async (customer) => {
|
|
9374
|
+
if (customer || !hasCustomerAuth()) return customer ? { phone: customer.phone ?? null, document: customer.document ?? null } : null;
|
|
9375
|
+
const relinked = await relinkCustomer();
|
|
9376
|
+
return relinked ? { phone: relinked.phone, document: relinked.document } : null;
|
|
9377
|
+
}).then((found) => {
|
|
9348
9378
|
if (cancelled) return;
|
|
9349
|
-
setContact(
|
|
9379
|
+
setContact(found);
|
|
9350
9380
|
}).catch(() => {
|
|
9351
9381
|
if (!cancelled) setContact(null);
|
|
9352
9382
|
}).finally(() => {
|
|
@@ -14103,5 +14133,5 @@ ${formatErrors(report.errors)}`;
|
|
|
14103
14133
|
}
|
|
14104
14134
|
|
|
14105
14135
|
export { AddressForm, AddressSheet, AddressStrip, BEFORE_PLACE_ORDER_VALVE, BLOCK_STRUCTURAL_KEYS, BUYER_COUNTRY_COOKIE, BenefitsRow, BlockDataError, CART_LINE_ANNOTATION_POINT, CATALOG_BODY_BLOCK, CHECKOUT_FIELD_POINT, CartDrawer, CatalogPage, CategoryShowcase, CheckoutPage, ClosedStoreDialog, CollectionCta, CollectionHero, ContentPage, CountdownBand, CountrySelect, DeliverToPicker, EmailConfirmationRequiredError, EntityListBlock, FaqSection, FiltersPanel, FormBlock, HeroSection, ImageTiles, ItemSheet, Link, MESSAGES, ManifestoBlock, MediaCarousel, MenuItemRow, MenuPage, MenuToolbar, MotifStrip, MyPurchasesPage, NewsletterBand, ORDER_METADATA_POINT, OrderConfirmationPage, OrderTrackingTimeline, PAGE_DATA_SCRIPT_ID, PLACEHOLDER_ASPECTS, PRODUCT_BODY_BLOCK, PRODUCT_CARD_BADGE_POINT, PageDataScope, PaymentTerms, Price, ProductCard, ProductDetailPage, ProductEnquiryForm, ProductGallery, ProductGrid, ProductOptionSelector, ProductRail, ProductReviews, ProductSlider, ProductSpecs, ProductSpotlight, PromoBanner, QuantityInput, Reveal, STOREFRONT_COMPONENT_KEYS, STOREFRONT_PAGE_KINDS, STOREFRONT_SLOTS, STORE_BACKEND_PROVIDERS, STORE_COMMERCE_MODES, STORE_DOCUMENT_KIND, STORE_PAYMENT_METHOD_KINDS, STORE_PAYMENT_MODES, STORE_ROUTE_CHROMES, STORE_ROUTE_KINDS, STORE_SECTIONS, STORE_SECTION_NAMES, ScheduleSheet, SealsBand, SearchOverlay, ServiceHoursModal, Slot, SmoothImage, StepsSection, StoreCover, StorefrontConfigHost, StorefrontConfigProvider, StorefrontFooter, StorefrontHeader, StorefrontPage, StorefrontRouterProvider, StorefrontShell, StorefrontThemeStyle, StoryQuote, THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX, TID, Testimonials, TierCards, applyStoreSettings, bannerPlaceholder, blockInstanceId, buildEnquiryFromForm, checkPageBlocks, collectDataNeeds, collectOrderMetadata, contentPagePath, createStorefront, createStorefrontApp, currentStaticRenderPass, defaultPageBlocks, entityListBlockMeta, establishCustomerSession, exportStore, formatMoney, formatProductOptionSelection, getCartLineAnnotations, getCheckoutFieldContributions, getCustomerAuthAdapter, getProductCardBadges, getProductOptionGroups, hydrateStoreDocument, hydratedEntriesFor, initStorefrontRuntime, isJsonValue, isKnownPath, isNestedBlockRef, isPublicPath, isRecord, listSlots, marketForCountry, marketUnitPrice, matchContentPage, matchPath, matchesFacets, mergeCollectionFacet, mergePageTheme, navigateTo, nextMilestone, normalizeLanguage, normalizeProductOptionSelection, orderGalleryImages, overrideComponent, overrideProps, pageSeo, pageThemeSelector, pickProductCardImage, placeStorefrontOrder, prefersReducedMotion, primaryImageUrl, productCardComponentContract, productJsonLd, productOptionSelectionKey, productPlaceholder, productSeo, readHydratedPageData, registerStorefrontBlocks, registerStorefrontEntities, registerStorefrontExtensionPoints, registerStorefrontLoaders, resetPageDiagnostics, resetProductOptionsDeprecationWarnings, resetStorefrontExtensionPoints, resolveAuthAdapter, resolveConfig, resolveDataParams, resolveOverride, resolvePageData, resolvePageDataNeed, resolvePaymentTerms, resolveStorefrontProvider, resolveStorefrontRoute, resolveVariantForSelection, roundCents, routePathParams, runBeforePlaceOrderValve, sectionToJsonSchema, sectionsToBlocks, selectCount, selectDiscountTotal, selectIsOpen, selectRequiresShipping, selectShipping, selectShowsHours, selectSubtotal, selectTotal, selectionPrice, serializePageData, shellRouterAdapter, signInByEmail, signOutCustomer, signUpCustomer, slugifyStoreName, storefrontComponentContracts, storefrontPaths, themeToCss, toBlockNodes, toFacetMap, translate, useBlockData, useBuyerCountry, useBuyerStore, useCartStore, useCatalogStore, useCategories, useDeliveryStore, useDiscountValidator, useEnquiry, useHashPath, useInView, useLoader, useMarketProduct, useMarketStore, useMyOrders, useNavigate, usePopOnChange, useProduct, useProducts, useRoutePath, useRouterAdapter, useScrollToTopOnNavigate, useScrolled, useServiceStore, useSessionStore, useSlotContext, useStorefrontActions, useStorefrontConfig, useStorefrontConfigOptional, useStorefrontHead, useStorefrontPage, useStorefrontPageOptional, useT, usedSlots, validateStore, withFacet, withMarketPrice, withStaticRenderPass };
|
|
14106
|
-
//# sourceMappingURL=chunk-
|
|
14107
|
-
//# sourceMappingURL=chunk-
|
|
14136
|
+
//# sourceMappingURL=chunk-PU7DSP2T.js.map
|
|
14137
|
+
//# sourceMappingURL=chunk-PU7DSP2T.js.map
|