@vtex/faststore 0.0.7 → 0.0.10
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/CHANGELOG.md +102 -0
- package/dist/actions.json +194 -1
- package/dist/catalog.json +3449 -1612
- package/dist/cli/index.d.ts +512 -63
- package/dist/cli/index.js +2098 -686
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/server-runtime.js +44 -24
- package/dist/cli/server-runtime.js.map +1 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.js +5 -1
- package/dist/components.d.ts +42 -10
- package/dist/components.js +47 -15
- package/dist/content-types.json +823 -0
- package/dist/core/dist/define-component.d.ts +12 -2
- package/dist/docs/account-access-gate.md +4 -4
- package/dist/docs/account-address-book.md +519 -0
- package/dist/docs/account-entry-point.md +5 -5
- package/dist/docs/account-menu.md +7 -7
- package/dist/docs/account-saved-cards.md +301 -0
- package/dist/docs/alert-dialog.md +2 -2
- package/dist/docs/billing-address.md +17 -9
- package/dist/docs/binding-switcher.md +154 -0
- package/dist/docs/card-entry.md +38 -7
- package/dist/docs/card-summary.md +175 -0
- package/dist/docs/cardholder-document.md +16 -14
- package/dist/docs/cart-destination.md +238 -0
- package/dist/docs/cart-item.md +22 -4
- package/dist/docs/cart-totalizer.md +1 -1
- package/dist/docs/cart.md +126 -19
- package/dist/docs/client-profile-fieldset.md +7 -5
- package/dist/docs/copy-text.md +84 -0
- package/dist/docs/document-field.md +8 -8
- package/dist/docs/footer-link-group.md +2 -2
- package/dist/docs/footer-social.md +1 -1
- package/dist/docs/free-shipping-progress.md +13 -9
- package/dist/docs/header-root.md +1 -1
- package/dist/docs/incentives.md +4 -4
- package/dist/docs/logo.md +6 -6
- package/dist/docs/my-account-profile.md +4 -4
- package/dist/docs/navigation-link-list.md +2 -2
- package/dist/docs/navigation-link.md +3 -3
- package/dist/docs/order-cancel.md +52 -0
- package/dist/docs/order-delivery-address.md +63 -0
- package/dist/docs/order-delivery-group.md +83 -0
- package/dist/docs/order-details-back.md +41 -0
- package/dist/docs/order-details-header.md +48 -0
- package/dist/docs/order-list-row.md +46 -0
- package/dist/docs/order-list-search.md +101 -0
- package/dist/docs/order-list-views.md +97 -0
- package/dist/docs/order-list.md +94 -0
- package/dist/docs/order-payment.md +94 -0
- package/dist/docs/order-placed-date.md +49 -0
- package/dist/docs/order-placed-payment-summary.md +13 -15
- package/dist/docs/order-placed.md +225 -0
- package/dist/docs/order-progress.md +88 -0
- package/dist/docs/order-status-badge.md +91 -0
- package/dist/docs/order-summary.md +53 -0
- package/dist/docs/payment-method-badges.md +16 -5
- package/dist/docs/payment-methods.md +1 -1
- package/dist/docs/place-order.md +13 -9
- package/dist/docs/product-information.md +2 -2
- package/dist/docs/product-shelf.md +7 -0
- package/dist/docs/saved-cards.md +2 -2
- package/dist/docs/select.md +22 -10
- package/dist/docs/session.md +1 -1
- package/dist/docs/shipping-address.md +1 -1
- package/dist/docs/sign-in-redirect.md +7 -7
- package/dist/docs/toast.md +35 -13
- package/dist/index.d.ts +7 -2
- package/dist/index.js +2 -1
- package/dist/internal/client.d.ts +9 -1
- package/dist/internal/client.js +10 -2
- package/dist/internal/server.d.ts +8 -2
- package/dist/internal/server.js +8 -2
- package/dist/matter/account-access-gate/account-access-gate.d.ts +2 -1
- package/dist/matter/account-access-gate/account-access-gate.js +19 -16
- package/dist/matter/account-access-gate/account-access-gate.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-delete.d.ts +60 -0
- package/dist/matter/account-address-book/account-address-book-delete.js +184 -0
- package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +19 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.js +50 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +42 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.js +146 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +25 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.js +72 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book.d.ts +120 -0
- package/dist/matter/account-address-book/account-address-book.js +469 -0
- package/dist/matter/account-address-book/account-address-book.js.map +1 -0
- package/dist/matter/account-address-book/account-address-country-switch.js +59 -0
- package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -0
- package/dist/matter/account-address-book/account-address-country.d.ts +36 -0
- package/dist/matter/account-address-book/account-address-country.js +151 -0
- package/dist/matter/account-address-book/account-address-country.js.map +1 -0
- package/dist/matter/account-address-book/account-address-first-line.js +11 -0
- package/dist/matter/account-address-book/account-address-first-line.js.map +1 -0
- package/dist/matter/account-address-book/account-address-form-context.d.ts +55 -0
- package/dist/matter/account-address-book/account-address-form-context.js +14 -0
- package/dist/matter/account-address-book/account-address-form-context.js.map +1 -0
- package/dist/matter/account-address-book/account-address-form.d.ts +85 -0
- package/dist/matter/account-address-book/account-address-form.js +946 -0
- package/dist/matter/account-address-book/account-address-form.js.map +1 -0
- package/dist/matter/account-address-book/account-address-postal-autofill.js +189 -0
- package/dist/matter/account-address-book/account-address-postal-autofill.js.map +1 -0
- package/dist/matter/account-address-book/account-address-record.d.ts +26 -0
- package/dist/matter/account-address-book/account-address-record.js +138 -0
- package/dist/matter/account-address-book/account-address-record.js.map +1 -0
- package/dist/matter/account-entry-point/account-entry-point.js +11 -11
- package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
- package/dist/matter/account-menu/account-menu.d.ts +7 -3
- package/dist/matter/account-menu/account-menu.js +69 -28
- package/dist/matter/account-menu/account-menu.js.map +1 -1
- package/dist/matter/account-saved-cards/account-saved-cards.d.ts +383 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js +956 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -0
- package/dist/matter/billing-address/billing-address.d.ts +30 -17
- package/dist/matter/billing-address/billing-address.js +128 -33
- package/dist/matter/billing-address/billing-address.js.map +1 -1
- package/dist/matter/breadcrumb/breadcrumb.js +2 -2
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/matter/card-entry/card-capture.js +4 -3
- package/dist/matter/card-entry/card-capture.js.map +1 -1
- package/dist/matter/card-entry/card-entry.d.ts +5 -3
- package/dist/matter/card-entry/card-entry.js +77 -27
- package/dist/matter/card-entry/card-entry.js.map +1 -1
- package/dist/matter/cardholder-document/cardholder-document.d.ts +10 -9
- package/dist/matter/cardholder-document/cardholder-document.js +36 -16
- package/dist/matter/cardholder-document/cardholder-document.js.map +1 -1
- package/dist/matter/cart/cart-namespace.d.ts +5 -1
- package/dist/matter/cart/cart-namespace.js +5 -1
- package/dist/matter/cart/cart-namespace.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +41 -6
- package/dist/matter/cart/cart.js +267 -54
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-destination/cart-destination.d.ts +222 -0
- package/dist/matter/cart-destination/cart-destination.js +613 -0
- package/dist/matter/cart-destination/cart-destination.js.map +1 -0
- package/dist/matter/cart-item/cart-item.d.ts +4 -2
- package/dist/matter/cart-item/cart-item.js +76 -17
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/cart-totalizer/cart-totalizer.js +3 -2
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences-fieldset.js +1 -1
- package/dist/matter/client-profile-form/client-profile-fieldset.js +8 -5
- package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +6 -3
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +76 -33
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
- package/dist/matter/identity-edit/identity-edit.js +3 -3
- package/dist/matter/identity-edit/identity-edit.js.map +1 -1
- package/dist/matter/identity-summary/identity-summary.js +2 -2
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/my-account-profile/my-account-profile.d.ts +3 -3
- package/dist/matter/my-account-profile/my-account-profile.js +4 -4
- package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
- package/dist/matter/order-cancel/order-cancel.d.ts +110 -0
- package/dist/matter/order-cancel/order-cancel.js +344 -0
- package/dist/matter/order-cancel/order-cancel.js.map +1 -0
- package/dist/matter/order-delivery-address/order-delivery-address.d.ts +73 -0
- package/dist/matter/order-delivery-address/order-delivery-address.js +172 -0
- package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -0
- package/dist/matter/order-delivery-group/order-delivery-group.d.ts +128 -0
- package/dist/matter/order-delivery-group/order-delivery-group.js +408 -0
- package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -0
- package/dist/matter/order-details-header/order-details-header.d.ts +104 -0
- package/dist/matter/order-details-header/order-details-header.js +190 -0
- package/dist/matter/order-details-header/order-details-header.js.map +1 -0
- package/dist/matter/order-list/customer-orders-filter.d.ts +12 -0
- package/dist/matter/order-list/customer-orders-filter.js +30 -0
- package/dist/matter/order-list/customer-orders-filter.js.map +1 -0
- package/dist/matter/order-list/order-list.d.ts +121 -0
- package/dist/matter/order-list/order-list.js +395 -0
- package/dist/matter/order-list/order-list.js.map +1 -0
- package/dist/matter/order-list-row/order-list-row.d.ts +44 -0
- package/dist/matter/order-list-row/order-list-row.js +127 -0
- package/dist/matter/order-list-row/order-list-row.js.map +1 -0
- package/dist/matter/order-list-search/order-list-search.d.ts +72 -0
- package/dist/matter/order-list-search/order-list-search.js +296 -0
- package/dist/matter/order-list-search/order-list-search.js.map +1 -0
- package/dist/matter/order-list-views/order-list-views.d.ts +65 -0
- package/dist/matter/order-list-views/order-list-views.js +154 -0
- package/dist/matter/order-list-views/order-list-views.js.map +1 -0
- package/dist/matter/order-payment/order-payment.d.ts +83 -0
- package/dist/matter/order-payment/order-payment.js +258 -0
- package/dist/matter/order-payment/order-payment.js.map +1 -0
- package/dist/matter/order-placed/order-placed-deliveries.d.ts +145 -0
- package/dist/matter/order-placed/order-placed-deliveries.js +380 -0
- package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -0
- package/dist/matter/order-placed/order-placed.d.ts +122 -0
- package/dist/matter/order-placed/order-placed.js +452 -0
- package/dist/matter/order-placed/order-placed.js.map +1 -0
- package/dist/matter/order-placed-date/order-placed-date.d.ts +45 -0
- package/dist/matter/order-placed-date/order-placed-date.js +92 -0
- package/dist/matter/order-placed-date/order-placed-date.js.map +1 -0
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +5 -8
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +29 -81
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
- package/dist/matter/order-progress/order-progress.d.ts +85 -0
- package/dist/matter/order-progress/order-progress.js +203 -0
- package/dist/matter/order-progress/order-progress.js.map +1 -0
- package/dist/matter/order-summary/order-summary.d.ts +81 -0
- package/dist/matter/order-summary/order-summary.js +192 -0
- package/dist/matter/order-summary/order-summary.js.map +1 -0
- package/dist/matter/payment/cardholder-document-rule.d.ts +35 -0
- package/dist/matter/payment/cardholder-document-rule.js +35 -0
- package/dist/matter/payment/cardholder-document-rule.js.map +1 -0
- package/dist/matter/payment/payment-card-capture.js +38 -23
- package/dist/matter/payment/payment-card-capture.js.map +1 -1
- package/dist/matter/payment/payment-controller.js +11 -0
- package/dist/matter/payment/payment-controller.js.map +1 -1
- package/dist/matter/payment/payment-method-badges.js +4 -2
- package/dist/matter/payment/payment-method-badges.js.map +1 -1
- package/dist/matter/payment/payment.js +11 -0
- package/dist/matter/payment/payment.js.map +1 -1
- package/dist/matter/payment/use-payment-method-selection.d.ts +39 -0
- package/dist/matter/payment/use-payment-method-selection.js +30 -2
- package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
- package/dist/matter/payment/use-payment-submit-gate.d.ts +16 -2
- package/dist/matter/payment/use-payment-submit-gate.js +42 -14
- package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
- package/dist/matter/place-order/place-order.d.ts +12 -7
- package/dist/matter/place-order/place-order.js +126 -103
- package/dist/matter/place-order/place-order.js.map +1 -1
- package/dist/matter/pricing/pricing.js +5 -5
- package/dist/matter/pricing/pricing.js.map +1 -1
- package/dist/matter/product-shelf/product-shelf.d.ts +7 -0
- package/dist/matter/product-shelf/product-shelf.js +115 -1
- package/dist/matter/product-shelf/product-shelf.js.map +1 -1
- package/dist/matter/region/region.js +1 -1
- package/dist/matter/saved-cards/saved-cards.js +26 -15
- package/dist/matter/saved-cards/saved-cards.js.map +1 -1
- package/dist/matter/session/session.js +2 -2
- package/dist/matter/session/session.js.map +1 -1
- package/dist/matter/shipping-address/country-descriptors.d.ts +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +23 -1
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
- package/dist/matter/shipping-address/shipping-address.js +62 -14
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +2 -2
- package/dist/matter/shipping-simulator/shipping-simulator.js +6 -2
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
- package/dist/matter/sign-in-redirect/sign-in-redirect.js +48 -10
- package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -1
- package/dist/matter/variant-selector/variant-selector.js +2 -2
- package/dist/matter/variant-selector/variant-selector.js.map +1 -1
- package/dist/particles/address-summary/address-summary.js +2 -2
- package/dist/particles/address-summary/address-summary.js.map +1 -1
- package/dist/particles/alert-dialog/alert-dialog.d.ts +5 -1
- package/dist/particles/alert-dialog/alert-dialog.js +5 -2
- package/dist/particles/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/particles/binding-switcher/binding-switcher.d.ts +38 -0
- package/dist/particles/binding-switcher/binding-switcher.js +183 -0
- package/dist/particles/binding-switcher/binding-switcher.js.map +1 -0
- package/dist/particles/card-summary/card-network.d.ts +17 -0
- package/dist/particles/card-summary/card-network.js +25 -0
- package/dist/particles/card-summary/card-network.js.map +1 -0
- package/dist/particles/card-summary/card-summary.d.ts +83 -0
- package/dist/particles/card-summary/card-summary.js +188 -0
- package/dist/particles/card-summary/card-summary.js.map +1 -0
- package/dist/particles/copy-text/copy-text.d.ts +28 -0
- package/dist/particles/copy-text/copy-text.js +140 -0
- package/dist/particles/copy-text/copy-text.js.map +1 -0
- package/dist/particles/document-field/document-field.d.ts +34 -5
- package/dist/particles/document-field/document-field.js +115 -19
- package/dist/particles/document-field/document-field.js.map +1 -1
- package/dist/particles/field/field.js +1 -1
- package/dist/particles/field/field.js.map +1 -1
- package/dist/particles/footer-link-group/footer-link-group.d.ts +6 -2
- package/dist/particles/footer-link-group/footer-link-group.js +18 -7
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
- package/dist/particles/footer-social/footer-social.d.ts +1 -1
- package/dist/particles/footer-social/footer-social.js +1 -1
- package/dist/particles/footer-social/footer-social.js.map +1 -1
- package/dist/particles/incentives/incentives.d.ts +7 -3
- package/dist/particles/incentives/incentives.js +8 -3
- package/dist/particles/incentives/incentives.js.map +1 -1
- package/dist/particles/logo/logo.d.ts +3 -2
- package/dist/particles/logo/logo.js +20 -8
- package/dist/particles/logo/logo.js.map +1 -1
- package/dist/particles/navigation-link/navigation-link.d.ts +2 -3
- package/dist/particles/navigation-link/navigation-link.js +4 -4
- package/dist/particles/navigation-link/navigation-link.js.map +1 -1
- package/dist/particles/navigation-link-list/navigation-link-list.d.ts +6 -2
- package/dist/particles/navigation-link-list/navigation-link-list.js +18 -7
- package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -1
- package/dist/particles/order-details-back/order-details-back.d.ts +28 -0
- package/dist/particles/order-details-back/order-details-back.js +52 -0
- package/dist/particles/order-details-back/order-details-back.js.map +1 -0
- package/dist/particles/order-status-badge/order-status-badge.d.ts +19 -0
- package/dist/particles/order-status-badge/order-status-badge.js +50 -0
- package/dist/particles/order-status-badge/order-status-badge.js.map +1 -0
- package/dist/particles/payment-methods/payment-methods.d.ts +1 -1
- package/dist/particles/payment-methods/payment-methods.js +1 -1
- package/dist/particles/payment-methods/payment-methods.js.map +1 -1
- package/dist/particles/phone-field/phone-field.js +2 -2
- package/dist/particles/phone-field/phone-field.js.map +1 -1
- package/dist/particles/select/select.js +6 -6
- package/dist/particles/select/select.js.map +1 -1
- package/dist/particles/toast/toast.d.ts +21 -7
- package/dist/particles/toast/toast.js +76 -8
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +1376 -126
- package/dist/sdk/actions/address-action-provider.d.ts +16 -0
- package/dist/sdk/actions/address-action-provider.js +20 -0
- package/dist/sdk/actions/address-action-provider.js.map +1 -0
- package/dist/sdk/actions/analytics-action-provider.js +1 -1
- package/dist/sdk/actions/index.d.ts +5 -1
- package/dist/sdk/actions/index.js +5 -1
- package/dist/sdk/actions/locale-action-provider.d.ts +16 -0
- package/dist/sdk/actions/locale-action-provider.js +20 -0
- package/dist/sdk/actions/locale-action-provider.js.map +1 -0
- package/dist/sdk/actions/order-action-provider.d.ts +12 -0
- package/dist/sdk/actions/order-action-provider.js +16 -0
- package/dist/sdk/actions/order-action-provider.js.map +1 -0
- package/dist/sdk/actions/saved-card-action-provider.d.ts +12 -0
- package/dist/sdk/actions/saved-card-action-provider.js +16 -0
- package/dist/sdk/actions/saved-card-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +10 -2
- package/dist/sdk/address/address-fields.js +38 -0
- package/dist/sdk/address/address-fields.js.map +1 -0
- package/dist/sdk/address/checkout-readiness.js +17 -0
- package/dist/sdk/address/checkout-readiness.js.map +1 -0
- package/dist/sdk/address/constants.js +60 -0
- package/dist/sdk/address/constants.js.map +1 -0
- package/dist/sdk/address/country-display.js +19 -0
- package/dist/sdk/address/country-display.js.map +1 -0
- package/dist/sdk/address/country-rules.js +30 -0
- package/dist/sdk/address/country-rules.js.map +1 -0
- package/dist/sdk/address/format-address.js +18 -0
- package/dist/sdk/address/format-address.js.map +1 -0
- package/dist/sdk/address/iso-countries.js +262 -0
- package/dist/sdk/address/iso-countries.js.map +1 -0
- package/dist/sdk/address/layouts.js +56 -0
- package/dist/sdk/address/layouts.js.map +1 -0
- package/dist/sdk/address/messages.js +97 -0
- package/dist/sdk/address/messages.js.map +1 -0
- package/dist/sdk/address/operations.d.ts +54 -0
- package/dist/sdk/address/operations.js +83 -0
- package/dist/sdk/address/operations.js.map +1 -0
- package/dist/sdk/address/postal-code-lookup-operations.js +23 -0
- package/dist/sdk/address/postal-code-lookup-operations.js.map +1 -0
- package/dist/sdk/address/postal-code.js +11 -0
- package/dist/sdk/address/postal-code.js.map +1 -0
- package/dist/sdk/address/schema.js +14 -0
- package/dist/sdk/address/schema.js.map +1 -0
- package/dist/sdk/address/server-fields.js +25 -0
- package/dist/sdk/address/server-fields.js.map +1 -0
- package/dist/sdk/address/switch-country.js +57 -0
- package/dist/sdk/address/switch-country.js.map +1 -0
- package/dist/sdk/address/types.d.ts +26 -0
- package/dist/sdk/address/use-address-actions.d.ts +29 -0
- package/dist/sdk/address/use-address-actions.js +247 -0
- package/dist/sdk/address/use-address-actions.js.map +1 -0
- package/dist/sdk/address/use-address-by-postal-code.js +57 -0
- package/dist/sdk/address/use-address-by-postal-code.js.map +1 -0
- package/dist/sdk/address/validate-address.js +62 -0
- package/dist/sdk/address/validate-address.js.map +1 -0
- package/dist/sdk/cache/storefront-cache.js +30 -4
- package/dist/sdk/cache/storefront-cache.js.map +1 -1
- package/dist/sdk/cart/operations.d.ts +2 -1
- package/dist/sdk/cart/operations.js +55 -1
- package/dist/sdk/cart/operations.js.map +1 -1
- package/dist/sdk/cart/optimistic.d.ts +30 -7
- package/dist/sdk/cart/optimistic.js +78 -41
- package/dist/sdk/cart/optimistic.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.d.ts +7 -0
- package/dist/sdk/cart/use-cart-actions.js +61 -15
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-sync-sales-channel.js +70 -0
- package/dist/sdk/cart/use-cart-sync-sales-channel.js.map +1 -0
- package/dist/sdk/client/fetch-page-data.d.ts +11 -0
- package/dist/sdk/client/fetch-page-data.js +12 -1
- package/dist/sdk/client/fetch-page-data.js.map +1 -1
- package/dist/sdk/content/create-content-runtime.js +1 -8
- package/dist/sdk/content/create-content-runtime.js.map +1 -1
- package/dist/sdk/data/failed-fields.js +23 -0
- package/dist/sdk/data/failed-fields.js.map +1 -0
- package/dist/sdk/data/index.js +2 -2
- package/dist/sdk/data/page-reactive-data-root.d.ts +45 -7
- package/dist/sdk/data/page-reactive-data-root.js +88 -12
- package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
- package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
- package/dist/sdk/generated/fragment-types.js +2 -0
- package/dist/sdk/generated/fragment-types.js.map +1 -1
- package/dist/sdk/generated/gql.js +17 -11
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +185 -46
- package/dist/sdk/generated/graphql.js +2587 -155
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/messages/en-US.js +157 -1
- package/dist/sdk/i18n/messages/en-US.json +157 -1
- package/dist/sdk/i18n/messages/en-US.json.d.ts +156 -0
- package/dist/sdk/i18n/messages/es-ES.js +157 -1
- package/dist/sdk/i18n/messages/es-ES.json +157 -1
- package/dist/sdk/i18n/messages/pt-BR.js +157 -1
- package/dist/sdk/i18n/messages/pt-BR.json +157 -1
- package/dist/sdk/i18n/provider.js +1 -1
- package/dist/sdk/i18n/provider.js.map +1 -1
- package/dist/sdk/locale/binding-switch-provider.d.ts +13 -0
- package/dist/sdk/locale/binding-switch-provider.js +20 -0
- package/dist/sdk/locale/binding-switch-provider.js.map +1 -0
- package/dist/sdk/locale/use-locale-actions.d.ts +16 -0
- package/dist/sdk/locale/use-locale-actions.js +70 -0
- package/dist/sdk/locale/use-locale-actions.js.map +1 -0
- package/dist/sdk/navigation/binding-switch.d.ts +39 -0
- package/dist/sdk/navigation/binding-switch.js +129 -0
- package/dist/sdk/navigation/binding-switch.js.map +1 -0
- package/dist/sdk/navigation/current-page.js +30 -0
- package/dist/sdk/navigation/current-page.js.map +1 -0
- package/dist/sdk/navigation/decode-route-params.d.ts +11 -0
- package/dist/sdk/navigation/decode-route-params.js +32 -0
- package/dist/sdk/navigation/decode-route-params.js.map +1 -0
- package/dist/sdk/navigation/not-found-log.d.ts +28 -0
- package/dist/sdk/navigation/not-found-log.js +133 -0
- package/dist/sdk/navigation/not-found-log.js.map +1 -0
- package/dist/sdk/navigation/path.js +25 -0
- package/dist/sdk/navigation/path.js.map +1 -0
- package/dist/sdk/navigation/redirect.d.ts +11 -0
- package/dist/sdk/navigation/redirect.js +22 -0
- package/dist/sdk/navigation/redirect.js.map +1 -0
- package/dist/sdk/navigation/report.js +70 -0
- package/dist/sdk/navigation/report.js.map +1 -0
- package/dist/sdk/navigation/resolve-storefront-href.d.ts +12 -0
- package/dist/sdk/navigation/resolve-storefront-href.js +214 -0
- package/dist/sdk/navigation/resolve-storefront-href.js.map +1 -0
- package/dist/sdk/navigation/route-identity-provider.d.ts +11 -0
- package/dist/sdk/navigation/route-identity-provider.js +20 -0
- package/dist/sdk/navigation/route-identity-provider.js.map +1 -0
- package/dist/sdk/navigation/route-map-provider.d.ts +19 -0
- package/dist/sdk/navigation/route-map-provider.js +29 -0
- package/dist/sdk/navigation/route-map-provider.js.map +1 -0
- package/dist/sdk/navigation/storefront-link.d.ts +16 -0
- package/dist/sdk/navigation/storefront-link.js +66 -0
- package/dist/sdk/navigation/storefront-link.js.map +1 -0
- package/dist/sdk/navigation/types.d.ts +45 -0
- package/dist/sdk/navigation/use-storefront-navigation.d.ts +26 -0
- package/dist/sdk/navigation/use-storefront-navigation.js +73 -0
- package/dist/sdk/navigation/use-storefront-navigation.js.map +1 -0
- package/dist/sdk/navigation/use-storefront-route.d.ts +26 -0
- package/dist/sdk/navigation/use-storefront-route.js +87 -0
- package/dist/sdk/navigation/use-storefront-route.js.map +1 -0
- package/dist/sdk/navigation/use-storefront-search-params.d.ts +11 -0
- package/dist/sdk/navigation/use-storefront-search-params.js +16 -0
- package/dist/sdk/navigation/use-storefront-search-params.js.map +1 -0
- package/dist/sdk/orders/completion-badge.d.ts +8 -0
- package/dist/sdk/orders/completion-badge.js +47 -0
- package/dist/sdk/orders/completion-badge.js.map +1 -0
- package/dist/sdk/orders/order-operations.d.ts +19 -0
- package/dist/sdk/orders/order-operations.js +21 -0
- package/dist/sdk/orders/order-operations.js.map +1 -0
- package/dist/sdk/orders/use-order-actions.d.ts +23 -0
- package/dist/sdk/orders/use-order-actions.js +62 -0
- package/dist/sdk/orders/use-order-actions.js.map +1 -0
- package/dist/sdk/payment/gateway-origin.js +26 -13
- package/dist/sdk/payment/gateway-origin.js.map +1 -1
- package/dist/sdk/payment/gateway.d.ts +14 -2
- package/dist/sdk/payment/gateway.js +32 -14
- package/dist/sdk/payment/gateway.js.map +1 -1
- package/dist/sdk/payment/operations.js +11 -0
- package/dist/sdk/payment/operations.js.map +1 -1
- package/dist/sdk/payment/submission-registry.d.ts +2 -1
- package/dist/sdk/payment/submission-registry.js +12 -8
- package/dist/sdk/payment/submission-registry.js.map +1 -1
- package/dist/sdk/payment/use-payment-actions.d.ts +5 -3
- package/dist/sdk/payment/use-payment-actions.js +5 -2
- package/dist/sdk/payment/use-payment-actions.js.map +1 -1
- package/dist/sdk/payment/use-place-order.d.ts +6 -3
- package/dist/sdk/payment/use-place-order.js +333 -143
- package/dist/sdk/payment/use-place-order.js.map +1 -1
- package/dist/sdk/saved-cards/operations.d.ts +16 -0
- package/dist/sdk/saved-cards/operations.js +41 -0
- package/dist/sdk/saved-cards/operations.js.map +1 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.d.ts +26 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js +86 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js.map +1 -0
- package/dist/sdk/seo/page-alternates.d.ts +57 -0
- package/dist/sdk/seo/page-alternates.js +127 -0
- package/dist/sdk/seo/page-alternates.js.map +1 -0
- package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
- package/dist/sdk/shipping/shipping-operations.js +13 -0
- package/dist/sdk/shipping/shipping-operations.js.map +1 -1
- package/dist/sdk/state/cart.d.ts +9 -2
- package/dist/sdk/state/cart.js +9 -2
- package/dist/sdk/state/cart.js.map +1 -1
- package/dist/utils/own-value.js +19 -0
- package/dist/utils/own-value.js.map +1 -0
- package/dist/utils/safe-href.d.ts +4 -4
- package/dist/utils/safe-href.js +31 -22
- package/dist/utils/safe-href.js.map +1 -1
- package/package.json +5 -1
- package/skills/storefront-asset/SKILL.md +111 -0
- package/skills/storefront-asset/references/api-side.md +153 -0
- package/skills/storefront-asset/references/findings.md +40 -0
- package/skills/storefront-asset/references/ui-side.md +94 -0
- package/src/styles/tailwind.css +28 -2
|
@@ -1,12 +1,166 @@
|
|
|
1
1
|
{
|
|
2
2
|
"fs/a11y.close": "Fechar",
|
|
3
|
+
"fs/address-book.empty": "Você ainda não tem endereços salvos.",
|
|
4
|
+
"fs/address-book.error": "Não foi possível carregar seus endereços.",
|
|
5
|
+
"fs/address-book.loading": "Carregando seus endereços…",
|
|
6
|
+
"fs/address-book.profile-notice": "Seus endereços salvos não serão oferecidos no checkout até que seu perfil tenha um telefone.",
|
|
7
|
+
"fs/address-book.profile-notice.link": "Complete seu perfil",
|
|
8
|
+
"fs/address-book.retry": "Tentar novamente",
|
|
9
|
+
"fs/address-book.undeliverable": "No momento, não entregamos neste país.",
|
|
10
|
+
"fs/address-delete.cancel": "Cancelar",
|
|
11
|
+
"fs/address-delete.confirm": "Excluir",
|
|
12
|
+
"fs/address-delete.deleted": "Endereço excluído.",
|
|
13
|
+
"fs/address-delete.description": "Esta ação não pode ser desfeita.",
|
|
14
|
+
"fs/address-delete.error.failed": "Não foi possível excluir este endereço. Tente novamente.",
|
|
15
|
+
"fs/address-delete.error.unauthorized": "Sua sessão expirou. Entre novamente para excluir este endereço.",
|
|
16
|
+
"fs/address-delete.title": "Excluir este endereço?",
|
|
17
|
+
"fs/address-delete.trigger": "Excluir",
|
|
18
|
+
"fs/address-form.add": "Adicionar endereço",
|
|
19
|
+
"fs/address-form.added": "Endereço adicionado.",
|
|
20
|
+
"fs/address-form.cancel": "Cancelar",
|
|
21
|
+
"fs/address-form.country": "País",
|
|
22
|
+
"fs/address-form.country-notice": "{count, plural, one {Este campo não passa para um endereço em {country}: {fields}. Ele volta se você trocar de novo para {previous}.} other {Estes campos não passam para um endereço em {country}: {fields}. Eles voltam se você trocar de novo para {previous}.}}",
|
|
23
|
+
"fs/address-form.edit": "Editar",
|
|
24
|
+
"fs/address-form.error.country-switch-failed": "Não foi possível trocar o país. Tente de novo.",
|
|
25
|
+
"fs/address-form.error.not-found": "Este endereço não existe mais.",
|
|
26
|
+
"fs/address-form.error.rules-failed": "Não foi possível carregar este formulário. Feche-o e tente novamente.",
|
|
27
|
+
"fs/address-form.error.save-failed": "Não foi possível salvar este endereço. Tente novamente.",
|
|
28
|
+
"fs/address-form.error.unauthorized": "Sua sessão expirou. Entre novamente para salvar este endereço.",
|
|
29
|
+
"fs/address-form.error.unrendered-field": "Este endereço precisa de informações que este formulário não consegue mostrar, então ele não foi salvo.",
|
|
30
|
+
"fs/address-form.error.unsupported-country": "A loja não entrega neste país.",
|
|
31
|
+
"fs/address-form.saved": "Endereço salvo.",
|
|
32
|
+
"fs/address-form.status.failed": "Endereço não salvo.",
|
|
33
|
+
"fs/address-form.status.fields": "Endereço não salvo. {count, plural, one {# campo precisa de atenção.} other {# campos precisam de atenção.}}",
|
|
34
|
+
"fs/address-form.status.filled": "{count, plural, one {# campo preenchido a partir do CEP.} other {# campos preenchidos a partir do CEP.}}",
|
|
35
|
+
"fs/address-form.submit": "Salvar",
|
|
36
|
+
"fs/address-form.title.add": "Adicionar endereço",
|
|
37
|
+
"fs/address-form.title.edit": "Editar endereço",
|
|
38
|
+
"fs/address-record.error": "Não foi possível carregar este endereço.",
|
|
39
|
+
"fs/address.error.cep": "Informe um CEP válido (exemplo: {example}).",
|
|
40
|
+
"fs/address.error.invalid": "Confira este campo.",
|
|
41
|
+
"fs/address.error.postal-code": "Informe um código postal válido (exemplo: {example}).",
|
|
42
|
+
"fs/address.error.required": "Campo obrigatório.",
|
|
43
|
+
"fs/address.error.too-long": "Use no máximo {maxLength, number} caracteres.",
|
|
44
|
+
"fs/address.field.cep": "CEP",
|
|
45
|
+
"fs/address.field.city": "Cidade",
|
|
46
|
+
"fs/address.field.commune": "Comuna",
|
|
47
|
+
"fs/address.field.complement": "Complemento (opcional)",
|
|
48
|
+
"fs/address.field.county": "Condado",
|
|
49
|
+
"fs/address.field.department": "Departamento",
|
|
50
|
+
"fs/address.field.district": "Distrito",
|
|
51
|
+
"fs/address.field.municipality": "Município",
|
|
52
|
+
"fs/address.field.name": "Nome do endereço (opcional)",
|
|
53
|
+
"fs/address.field.neighborhood": "Bairro",
|
|
54
|
+
"fs/address.field.number": "Número",
|
|
55
|
+
"fs/address.field.postal-code": "Código postal",
|
|
56
|
+
"fs/address.field.postcode": "Código postal",
|
|
57
|
+
"fs/address.field.province": "Província",
|
|
58
|
+
"fs/address.field.recipient-name": "Nome do destinatário",
|
|
59
|
+
"fs/address.field.reference": "Referência (opcional)",
|
|
60
|
+
"fs/address.field.region": "Região",
|
|
61
|
+
"fs/address.field.state": "Estado",
|
|
62
|
+
"fs/address.field.street": "Endereço",
|
|
63
|
+
"fs/address.field.town": "Cidade",
|
|
64
|
+
"fs/address.placeholder.postal-code": "Exemplo: {example}",
|
|
65
|
+
"fs/address.placeholder.street": "Endereço",
|
|
66
|
+
"fs/card.ending-in": "final {lastDigits}",
|
|
3
67
|
"fs/form.clear": "Limpar",
|
|
4
68
|
"fs/form.reset": "Redefinir",
|
|
5
69
|
"fs/form.submit": "Continuar",
|
|
70
|
+
"fs/order-cancel.confirm": "Cancelar pedido",
|
|
71
|
+
"fs/order-cancel.description": "Esta ação não pode ser desfeita.",
|
|
72
|
+
"fs/order-cancel.dismiss": "Manter pedido",
|
|
73
|
+
"fs/order-cancel.dismiss-message": "Dispensar",
|
|
74
|
+
"fs/order-cancel.failure": "Não foi possível cancelar o pedido. Tente novamente.",
|
|
75
|
+
"fs/order-cancel.other": "Outro",
|
|
76
|
+
"fs/order-cancel.other-field": "Motivo",
|
|
77
|
+
"fs/order-cancel.reason.better-price": "Encontrei um preço melhor",
|
|
78
|
+
"fs/order-cancel.reason.bought-by-mistake": "Comprei por engano",
|
|
79
|
+
"fs/order-cancel.reason.changed-mind": "Mudei de ideia",
|
|
80
|
+
"fs/order-cancel.reason.slow-delivery": "A entrega está demorando",
|
|
81
|
+
"fs/order-cancel.success": "Seu pedido foi cancelado.",
|
|
82
|
+
"fs/order-cancel.title": "Cancelar este pedido?",
|
|
83
|
+
"fs/order-cancel.trigger": "Cancelar pedido",
|
|
84
|
+
"fs/order-delivery-address.delivery": "Endereço de entrega",
|
|
85
|
+
"fs/order-delivery-address.store": "Endereço da loja",
|
|
86
|
+
"fs/order-delivery-group.channel.delivery": "Entrega",
|
|
87
|
+
"fs/order-delivery-group.channel.pickup-in-point": "Retirada",
|
|
88
|
+
"fs/order-delivery-group.estimate": "Previsão de entrega",
|
|
89
|
+
"fs/order-delivery-group.items": "{count, plural, one {# item} other {# itens}}",
|
|
90
|
+
"fs/order-delivery-group.label": "Entregas",
|
|
91
|
+
"fs/order-delivery-group.list-price": "Preço de lista",
|
|
92
|
+
"fs/order-delivery-group.quantity": "Quantidade",
|
|
93
|
+
"fs/order-delivery-group.subtotal": "Subtotal",
|
|
94
|
+
"fs/order-delivery-group.tax": "Imposto",
|
|
95
|
+
"fs/order-delivery-group.total": "Total",
|
|
96
|
+
"fs/order-delivery-group.unit-price": "Preço unitário",
|
|
97
|
+
"fs/order-list.column.estimate": "Previsão",
|
|
98
|
+
"fs/order-list.column.id": "Pedido",
|
|
99
|
+
"fs/order-list.column.items": "Itens",
|
|
100
|
+
"fs/order-list.column.placed": "Data",
|
|
101
|
+
"fs/order-list.column.status": "Status",
|
|
102
|
+
"fs/order-list.column.total": "Total",
|
|
103
|
+
"fs/order-payment.bank-invoice.number": "Número do boleto",
|
|
104
|
+
"fs/order-payment.bank-invoice.print": "Imprimir boleto",
|
|
105
|
+
"fs/order-payment.empty": "Nenhum pagamento registrado",
|
|
106
|
+
"fs/order-payment.heading": "Pagamento",
|
|
107
|
+
"fs/order-payment.installments": "{count}x {amount}",
|
|
108
|
+
"fs/order-payment.method.placeholder": "Forma de pagamento indisponível",
|
|
109
|
+
"fs/order-payment.redemption-code": "Código do vale-presente",
|
|
110
|
+
"fs/order-status.cancellation-requested": "Cancelamento solicitado",
|
|
111
|
+
"fs/order-status.cancelled": "Cancelado",
|
|
112
|
+
"fs/order-status.collected": "Retirado",
|
|
113
|
+
"fs/order-status.delivered": "Entregue",
|
|
114
|
+
"fs/order-status.in-progress": "Em andamento",
|
|
115
|
+
"fs/order-status.placeholder": "Status indisponível",
|
|
116
|
+
"fs/order-status.ready-for-pickup": "Pronto para retirada",
|
|
117
|
+
"fs/order-status.shipped": "Enviado",
|
|
118
|
+
"fs/order.back-to-orders": "Voltar aos pedidos",
|
|
119
|
+
"fs/order.copy.action": "Copiar",
|
|
120
|
+
"fs/order.copy.copied": "Copiado",
|
|
121
|
+
"fs/order.copy.dismiss": "Dispensar",
|
|
122
|
+
"fs/order.copy.failure": "Não foi possível copiar",
|
|
123
|
+
"fs/order.number.copy-name": "Copiar número do pedido",
|
|
124
|
+
"fs/order.number.prefix": "Pedido nº",
|
|
125
|
+
"fs/order.placed-at": "Pedido realizado",
|
|
126
|
+
"fs/order.progress.label": "Progresso do pedido",
|
|
127
|
+
"fs/order.stage-state.current": "Em andamento",
|
|
128
|
+
"fs/order.stage-state.done": "Concluído",
|
|
129
|
+
"fs/order.stage-state.pending": "Não iniciado",
|
|
130
|
+
"fs/order.stage.payment": "Pagamento",
|
|
131
|
+
"fs/order.stage.placed": "Pedido realizado",
|
|
132
|
+
"fs/order.stage.processing": "Preparação",
|
|
133
|
+
"fs/order.stage.shipping": "Envio",
|
|
134
|
+
"fs/order.totals.change": "Troco",
|
|
135
|
+
"fs/order.totals.discounts": "Descontos",
|
|
136
|
+
"fs/order.totals.grand-total": "Total",
|
|
137
|
+
"fs/order.totals.heading": "Resumo",
|
|
138
|
+
"fs/order.totals.interest": "Juros",
|
|
139
|
+
"fs/order.totals.items": "Itens",
|
|
140
|
+
"fs/order.totals.shipping": "Frete",
|
|
141
|
+
"fs/order.totals.tax": "Impostos",
|
|
6
142
|
"fs/region.error.invalid-postal-code": "Informe um CEP válido.",
|
|
7
143
|
"fs/region.error.network": "Não foi possível definir sua região. Tente novamente.",
|
|
8
144
|
"fs/region.error.unserved-postal-code": "Ainda não entregamos neste CEP.",
|
|
9
145
|
"fs/route.not-found": "Página não encontrada",
|
|
146
|
+
"fs/saved-cards.empty": "Você ainda não tem cartões salvos.",
|
|
147
|
+
"fs/saved-cards.expired": "Venceu em",
|
|
148
|
+
"fs/saved-cards.expired-no-date": "Vencido",
|
|
149
|
+
"fs/saved-cards.expires": "Vence em",
|
|
150
|
+
"fs/saved-cards.heading": "Cartões salvos",
|
|
151
|
+
"fs/saved-cards.load-failed": "Não foi possível carregar seus cartões salvos. Tente novamente mais tarde.",
|
|
152
|
+
"fs/saved-cards.loading": "Carregando seus cartões salvos…",
|
|
153
|
+
"fs/saved-cards.remove.cancel": "Cancelar",
|
|
154
|
+
"fs/saved-cards.remove.confirm": "Remover cartão",
|
|
155
|
+
"fs/saved-cards.remove.description": "Ele não será mais oferecido no pagamento. Essa ação não pode ser desfeita.",
|
|
156
|
+
"fs/saved-cards.remove.failed": "Não foi possível remover o cartão. Tente novamente.",
|
|
157
|
+
"fs/saved-cards.remove.pending": "Removendo…",
|
|
158
|
+
"fs/saved-cards.remove.success": "O cartão foi removido.",
|
|
159
|
+
"fs/saved-cards.remove.title": "Remover este cartão?",
|
|
160
|
+
"fs/saved-cards.remove.trigger": "Remover",
|
|
161
|
+
"fs/saved-cards.session-expired": "Sua sessão expirou.",
|
|
162
|
+
"fs/saved-cards.sign-in": "Entrar novamente",
|
|
163
|
+
"fs/saved-cards.unusable": "Este cartão não pode ser usado",
|
|
10
164
|
"fs/shipping.calculating": "Calculando…",
|
|
11
165
|
"fs/shipping.calculation-failed": "Não foi possível calcular o frete. Tente novamente.",
|
|
12
166
|
"fs/shipping.estimate.in-business-days": "em {days, plural, one {# dia útil} other {# dias úteis}}",
|
|
@@ -18,5 +172,7 @@
|
|
|
18
172
|
"fs/shipping.free-price": "Grátis",
|
|
19
173
|
"fs/shipping.no-options": "Nenhuma opção de entrega disponível para este endereço.",
|
|
20
174
|
"fs/shipping.postal-code.aria-label": "CEP",
|
|
21
|
-
"fs/shipping.postal-code.placeholder": "Digite seu CEP"
|
|
175
|
+
"fs/shipping.postal-code.placeholder": "Digite seu CEP",
|
|
176
|
+
"fs/toast.dismiss": "Fechar",
|
|
177
|
+
"fs/toast.region": "Notificações"
|
|
22
178
|
}
|
|
@@ -7,7 +7,7 @@ import { IntlProvider } from "react-intl";
|
|
|
7
7
|
* Mounted by `StorefrontProvider`, never by a store.
|
|
8
8
|
*
|
|
9
9
|
* The record arrives already resolved: the server merged the locale's catalog over the fallback
|
|
10
|
-
* chain
|
|
10
|
+
* chain the store's foundation declares, so SSR and hydration read the same bytes and only one locale reaches
|
|
11
11
|
* the browser.
|
|
12
12
|
*
|
|
13
13
|
* The tag is normalized for the same reason `getIntl` normalizes it: when no catalog ships for the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":[],"sources":["../../../src/sdk/i18n/provider.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { IntlProvider } from 'react-intl';\nimport { asIntlMessages, DEFAULT_LOCALE, type Messages, normalizeLocale, onIntlError } from './locales.js';\n\nexport type MessageProviderProps = Readonly<{\n locale: string;\n messages: Messages;\n children: ReactNode;\n}>;\n\n/**\n * Mounted by `StorefrontProvider`, never by a store.\n *\n * The record arrives already resolved: the server merged the locale's catalog over the fallback\n * chain
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../../../src/sdk/i18n/provider.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { IntlProvider } from 'react-intl';\nimport { asIntlMessages, DEFAULT_LOCALE, type Messages, normalizeLocale, onIntlError } from './locales.js';\n\nexport type MessageProviderProps = Readonly<{\n locale: string;\n messages: Messages;\n children: ReactNode;\n}>;\n\n/**\n * Mounted by `StorefrontProvider`, never by a store.\n *\n * The record arrives already resolved: the server merged the locale's catalog over the fallback\n * chain the store's foundation declares, so SSR and hydration read the same bytes and only one locale reaches\n * the browser.\n *\n * The tag is normalized for the same reason `getIntl` normalizes it: when no catalog ships for the\n * declared locale the strings rendered are the source catalog's, and plural categories have to be\n * selected under the language those strings are written in. Without it a Server Component and a\n * Client Component could pluralize the same English string under different rules.\n */\nexport function MessageProvider({ locale, messages, children }: MessageProviderProps) {\n return (\n <IntlProvider\n locale={normalizeLocale(locale) ?? DEFAULT_LOCALE}\n defaultLocale={DEFAULT_LOCALE}\n messages={asIntlMessages(messages)}\n onError={onIntlError}\n >\n {children}\n </IntlProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,SAAgB,gBAAgB,EAAE,QAAQ,UAAU,YAAkC;CACpF,OACE,oBAAC,cAAD;EACE,QAAQ,gBAAgB,MAAM,KAAA;EAC9B,eAAe;EACf,UAAU,eAAe,QAAQ;EACjC,SAAS;EAER;CACW,CAAA;AAElB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BindingSwitchRequest, BindingSwitchResult } from "../navigation/binding-switch.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/sdk/locale/binding-switch-provider.d.ts
|
|
4
|
+
export type SwitchBinding = (request: BindingSwitchRequest) => Promise<BindingSwitchResult>;
|
|
5
|
+
export type BindingSwitchProviderProps = Readonly<{
|
|
6
|
+
/** The app's `switchBinding` server action. The package cannot import the generated binding table. */
|
|
7
|
+
switchBinding: SwitchBinding;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
/** Hands the generated app's `switchBinding` server action to `locale.set`. */
|
|
11
|
+
export declare function BindingSwitchProvider({ switchBinding, children }: BindingSwitchProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=binding-switch-provider.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/sdk/locale/binding-switch-provider.tsx
|
|
5
|
+
const Context = createContext(null);
|
|
6
|
+
/** Hands the generated app's `switchBinding` server action to `locale.set`. */
|
|
7
|
+
function BindingSwitchProvider({ switchBinding, children }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
9
|
+
value: switchBinding,
|
|
10
|
+
children
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/** The provided server action, or `null` outside a `BindingSwitchProvider`. */
|
|
14
|
+
function useSwitchBinding() {
|
|
15
|
+
return useContext(Context);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { BindingSwitchProvider, useSwitchBinding };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=binding-switch-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-switch-provider.js","names":[],"sources":["../../../src/sdk/locale/binding-switch-provider.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, type ReactNode, useContext } from 'react';\nimport type { BindingSwitchRequest, BindingSwitchResult } from '../navigation/binding-switch.js';\n\nexport type SwitchBinding = (request: BindingSwitchRequest) => Promise<BindingSwitchResult>;\n\nexport type BindingSwitchProviderProps = Readonly<{\n /** The app's `switchBinding` server action. The package cannot import the generated binding table. */\n switchBinding: SwitchBinding;\n children: ReactNode;\n}>;\n\nconst Context = createContext<SwitchBinding | null>(null);\n\n/** Hands the generated app's `switchBinding` server action to `locale.set`. */\nexport function BindingSwitchProvider({ switchBinding, children }: BindingSwitchProviderProps) {\n return <Context.Provider value={switchBinding}>{children}</Context.Provider>;\n}\n\n/** The provided server action, or `null` outside a `BindingSwitchProvider`. */\nexport function useSwitchBinding(): SwitchBinding | null {\n return useContext(Context);\n}\n"],"mappings":";;;;AAaA,MAAM,UAAU,cAAoC,IAAI;;AAGxD,SAAgB,sBAAsB,EAAE,eAAe,YAAwC;CAC7F,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAgB;CAA2B,CAAA;AAC7E;;AAGA,SAAgB,mBAAyC;CACvD,OAAO,WAAW,OAAO;AAC3B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../../core/dist/index.js";
|
|
2
|
+
//#region src/sdk/locale/use-locale-actions.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The `locale` action namespace. `set` switches the whole binding (locale, currency, sales channel):
|
|
5
|
+
* the app's server action decides the equivalent URL, or the no-equivalent fallback, and the browser
|
|
6
|
+
* goes there with a document navigation. `set` always resolves, never navigates on an error, and
|
|
7
|
+
* resolves `true` only when it started the navigation.
|
|
8
|
+
*/
|
|
9
|
+
export type LocaleActions = Readonly<{
|
|
10
|
+
/** Switches to the binding `bindingId` names. `true` once the navigation starts; `false` after logging. */
|
|
11
|
+
set: (payload: {
|
|
12
|
+
bindingId: string;
|
|
13
|
+
}) => Promise<boolean>;
|
|
14
|
+
}>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//# sourceMappingURL=use-locale-actions.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineActions } from "../../core/dist/actions/registry.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { useStorefrontContext } from "../context/storefront-context.js";
|
|
5
|
+
import { useStorefrontRoute } from "../navigation/use-storefront-route.js";
|
|
6
|
+
import { loggableErrorName } from "../../utils/loggable-error-name.js";
|
|
7
|
+
import { useSwitchBinding } from "./binding-switch-provider.js";
|
|
8
|
+
import { useCallback, useMemo } from "react";
|
|
9
|
+
//#region src/sdk/locale/use-locale-actions.ts
|
|
10
|
+
/**
|
|
11
|
+
* The `locale` namespace hook. Reads the route at call time: `search` and `hash` come from
|
|
12
|
+
* `location`, because `useStorefrontRoute().search` is `null` during hydration. The page name is
|
|
13
|
+
* not sent: a layout has none, and the server derives the page from the path and params.
|
|
14
|
+
*/
|
|
15
|
+
function useLocaleActions() {
|
|
16
|
+
const switchBinding = useSwitchBinding();
|
|
17
|
+
const { params, path } = useStorefrontRoute();
|
|
18
|
+
const { bindingId: currentBindingId } = useStorefrontContext();
|
|
19
|
+
const set = useCallback(async ({ bindingId }) => {
|
|
20
|
+
if (!switchBinding) {
|
|
21
|
+
console.error("[locale.set] no BindingSwitchProvider");
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const { url } = await switchBinding({
|
|
26
|
+
bindingId,
|
|
27
|
+
currentBindingId,
|
|
28
|
+
params,
|
|
29
|
+
path,
|
|
30
|
+
search: globalThis.location.search,
|
|
31
|
+
hash: globalThis.location.hash
|
|
32
|
+
});
|
|
33
|
+
if (url === null) {
|
|
34
|
+
console.error("[locale.set] no URL for the binding");
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
globalThis.location.assign(url);
|
|
38
|
+
return true;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error("[locale.set] switchBinding failed", loggableErrorName(error));
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}, [
|
|
44
|
+
switchBinding,
|
|
45
|
+
currentBindingId,
|
|
46
|
+
params,
|
|
47
|
+
path
|
|
48
|
+
]);
|
|
49
|
+
return useMemo(() => ({ set }), [set]);
|
|
50
|
+
}
|
|
51
|
+
defineActions({
|
|
52
|
+
namespace: "locale",
|
|
53
|
+
description: "Switches the whole binding (locale, currency, sales channel) by a document navigation to the equivalent URL, or to the destination home with a notice.",
|
|
54
|
+
provider: {
|
|
55
|
+
name: "LocaleActionProvider",
|
|
56
|
+
importPath: "@vtex/faststore/internal/client"
|
|
57
|
+
},
|
|
58
|
+
methods: { set: {
|
|
59
|
+
description: "Switch to another binding: navigates to the equivalent URL of the current page, or to the destination home with fs_notice=no-equivalent.",
|
|
60
|
+
payload: [{
|
|
61
|
+
name: "bindingId",
|
|
62
|
+
type: "string"
|
|
63
|
+
}]
|
|
64
|
+
} },
|
|
65
|
+
use: useLocaleActions
|
|
66
|
+
});
|
|
67
|
+
//#endregion
|
|
68
|
+
export { useLocaleActions };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=use-locale-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-locale-actions.js","names":[],"sources":["../../../src/sdk/locale/use-locale-actions.ts"],"sourcesContent":["'use client';\n\nimport { defineActions } from '@vtex/fs-core';\nimport { useCallback, useMemo } from 'react';\nimport { loggableErrorName } from '../../utils/loggable-error-name.js';\nimport { useStorefrontContext } from '../context/storefront-context.js';\nimport { useStorefrontRoute } from '../navigation/use-storefront-route.js';\nimport { useSwitchBinding } from './binding-switch-provider.js';\n\n/**\n * The `locale` action namespace. `set` switches the whole binding (locale, currency, sales channel):\n * the app's server action decides the equivalent URL, or the no-equivalent fallback, and the browser\n * goes there with a document navigation. `set` always resolves, never navigates on an error, and\n * resolves `true` only when it started the navigation.\n */\nexport type LocaleActions = Readonly<{\n /** Switches to the binding `bindingId` names. `true` once the navigation starts; `false` after logging. */\n set: (payload: { bindingId: string }) => Promise<boolean>;\n}>;\n\n/**\n * The `locale` namespace hook. Reads the route at call time: `search` and `hash` come from\n * `location`, because `useStorefrontRoute().search` is `null` during hydration. The page name is\n * not sent: a layout has none, and the server derives the page from the path and params.\n */\nexport function useLocaleActions(): LocaleActions {\n const switchBinding = useSwitchBinding();\n const { params, path } = useStorefrontRoute();\n const { bindingId: currentBindingId } = useStorefrontContext();\n\n const set = useCallback<LocaleActions['set']>(\n async ({ bindingId }) => {\n if (!switchBinding) {\n console.error('[locale.set] no BindingSwitchProvider');\n return false;\n }\n try {\n const { url } = await switchBinding({\n bindingId,\n currentBindingId,\n params,\n path,\n search: globalThis.location.search,\n hash: globalThis.location.hash,\n });\n if (url === null) {\n console.error('[locale.set] no URL for the binding');\n return false;\n }\n globalThis.location.assign(url);\n return true;\n } catch (error) {\n console.error('[locale.set] switchBinding failed', loggableErrorName(error));\n return false;\n }\n },\n [switchBinding, currentBindingId, params, path],\n );\n\n return useMemo(() => ({ set }), [set]);\n}\n\n/**\n * Declares the `locale` action namespace. The native catalog builder reads this call to emit\n * `actions.json`; at runtime `LocaleActionProvider` calls `useLocaleActions` directly.\n */\nexport const localeActions = defineActions({\n namespace: 'locale',\n description:\n 'Switches the whole binding (locale, currency, sales channel) by a document navigation to the equivalent URL, or to the destination home with a notice.',\n provider: { name: 'LocaleActionProvider', importPath: '@vtex/faststore/internal/client' },\n methods: {\n set: {\n description:\n 'Switch to another binding: navigates to the equivalent URL of the current page, or to the destination home with fs_notice=no-equivalent.',\n payload: [{ name: 'bindingId', type: 'string' }],\n },\n },\n use: useLocaleActions,\n});\n"],"mappings":";;;;;;;;;;;;;;AAyBA,SAAgB,mBAAkC;CAChD,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,EAAE,QAAQ,SAAS,mBAAmB;CAC5C,MAAM,EAAE,WAAW,qBAAqB,qBAAqB;CAE7D,MAAM,MAAM,YACV,OAAO,EAAE,gBAAgB;EACvB,IAAI,CAAC,eAAe;GAClB,QAAQ,MAAM,uCAAuC;GACrD,OAAO;EACT;EACA,IAAI;GACF,MAAM,EAAE,QAAQ,MAAM,cAAc;IAClC;IACA;IACA;IACA;IACA,QAAQ,WAAW,SAAS;IAC5B,MAAM,WAAW,SAAS;GAC5B,CAAC;GACD,IAAI,QAAQ,MAAM;IAChB,QAAQ,MAAM,qCAAqC;IACnD,OAAO;GACT;GACA,WAAW,SAAS,OAAO,GAAG;GAC9B,OAAO;EACT,SAAS,OAAO;GACd,QAAQ,MAAM,qCAAqC,kBAAkB,KAAK,CAAC;GAC3E,OAAO;EACT;CACF,GACA;EAAC;EAAe;EAAkB;EAAQ;CAAI,CAChD;CAEA,OAAO,eAAe,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC;AACvC;AAM6B,cAAc;CACzC,WAAW;CACX,aACE;CACF,UAAU;EAAE,MAAM;EAAwB,YAAY;CAAkC;CACxF,SAAS,EACP,KAAK;EACH,aACE;EACF,SAAS,CAAC;GAAE,MAAM;GAAa,MAAM;EAAS,CAAC;CACjD,EACF;CACA,KAAK;AACP,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RouteMap } from "./types.js";
|
|
2
|
+
import { AlternateBinding } from "../seo/page-alternates.js";
|
|
3
|
+
import { ApolloClient } from "@apollo/client";
|
|
4
|
+
//#region src/sdk/navigation/binding-switch.d.ts
|
|
5
|
+
export type BindingSwitchRequest = {
|
|
6
|
+
/** Destination binding id. */
|
|
7
|
+
bindingId: string;
|
|
8
|
+
/** The binding the shopper is on. */
|
|
9
|
+
currentBindingId: string;
|
|
10
|
+
params: Record<string, string | string[]>;
|
|
11
|
+
/** Decoded logical path of the current page. */
|
|
12
|
+
path: string;
|
|
13
|
+
/** `location.search`: `''` or `'?…'`. */
|
|
14
|
+
search: string;
|
|
15
|
+
/** `location.hash`: `''` or `'#…'`. */
|
|
16
|
+
hash: string;
|
|
17
|
+
};
|
|
18
|
+
export type BindingSwitchResult = {
|
|
19
|
+
url: string | null;
|
|
20
|
+
};
|
|
21
|
+
export type ResolveBindingSwitchOptions = {
|
|
22
|
+
request: BindingSwitchRequest;
|
|
23
|
+
knownBindingId: (candidate: string | null | undefined) => string | null;
|
|
24
|
+
bindings: readonly AlternateBinding[];
|
|
25
|
+
routeMap: RouteMap;
|
|
26
|
+
buildUrl: (bindingId: string, logicalPath: string) => string;
|
|
27
|
+
clientFor: (bindingId: string) => ApolloClient;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The equivalent URL of the current page in the destination binding, or the destination's home with
|
|
31
|
+
* `fs_notice=no-equivalent` when none exists or the lookup fails. The page is the one route-map
|
|
32
|
+
* entry whose href in the current binding equals the logical path; none or several take the
|
|
33
|
+
* fallback. Every URL is built by `buildUrl` from an id `knownBindingId` accepted; an undeclared
|
|
34
|
+
* destination resolves `{ url: null }`. The request comes off the wire, so each field is read as
|
|
35
|
+
* unchecked. Never throws for an expected outcome, writes no cookie, and reads no request header.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveBindingSwitch({ request, knownBindingId, bindings, routeMap, buildUrl, clientFor }: ResolveBindingSwitchOptions): Promise<BindingSwitchResult>;
|
|
38
|
+
//#endregion
|
|
39
|
+
//# sourceMappingURL=binding-switch.d.ts.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { resolveStorefrontHref } from "./resolve-storefront-href.js";
|
|
2
|
+
import { CATALOG_ROUTE_ALTERNATES_QUERY, catalogClusterPaths, encodePath } from "../seo/page-alternates.js";
|
|
3
|
+
import { decodeRouteParams } from "./decode-route-params.js";
|
|
4
|
+
//#region src/sdk/navigation/binding-switch.ts
|
|
5
|
+
/** Bounds the `catalogRoute` lookup: a slow API takes the no-equivalent fallback instead of stalling the switch. */
|
|
6
|
+
const BINDING_SWITCH_LOOKUP_TIMEOUT_MS = 3e3;
|
|
7
|
+
const CATALOG_STANDARDS = /* @__PURE__ */ new Set([
|
|
8
|
+
"product",
|
|
9
|
+
"category",
|
|
10
|
+
"brand",
|
|
11
|
+
"collection"
|
|
12
|
+
]);
|
|
13
|
+
const NO_EQUIVALENT_QUERY = "?fs_notice=no-equivalent";
|
|
14
|
+
/**
|
|
15
|
+
* The equivalent URL of the current page in the destination binding, or the destination's home with
|
|
16
|
+
* `fs_notice=no-equivalent` when none exists or the lookup fails. The page is the one route-map
|
|
17
|
+
* entry whose href in the current binding equals the logical path; none or several take the
|
|
18
|
+
* fallback. Every URL is built by `buildUrl` from an id `knownBindingId` accepted; an undeclared
|
|
19
|
+
* destination resolves `{ url: null }`. The request comes off the wire, so each field is read as
|
|
20
|
+
* unchecked. Never throws for an expected outcome, writes no cookie, and reads no request header.
|
|
21
|
+
*/
|
|
22
|
+
async function resolveBindingSwitch({ request, knownBindingId, bindings, routeMap, buildUrl, clientFor }) {
|
|
23
|
+
const destination = knownBindingId(stringOr(request.bindingId, null));
|
|
24
|
+
if (destination === null) {
|
|
25
|
+
console.error("[locale.set] unknown binding");
|
|
26
|
+
return { url: null };
|
|
27
|
+
}
|
|
28
|
+
const fallback = { url: `${buildUrl(destination, "/")}${NO_EQUIVALENT_QUERY}` };
|
|
29
|
+
const path = stringOr(request.path, "");
|
|
30
|
+
const params = decodeRouteParams(paramsOf(request.params));
|
|
31
|
+
const page = pageMatchingPath(routeMap, stringOr(request.currentBindingId, ""), path, params);
|
|
32
|
+
const entry = page === void 0 ? void 0 : ownEntry(routeMap, page);
|
|
33
|
+
if (page === void 0 || entry === void 0) return fallback;
|
|
34
|
+
if (entry.bindings !== void 0 && !entry.bindings.includes(destination)) return fallback;
|
|
35
|
+
const tail = `${searchOf(request.search)}${hashOf(request.hash)}`;
|
|
36
|
+
if (entry.standard !== void 0 && CATALOG_STANDARDS.has(entry.standard)) {
|
|
37
|
+
const current = knownBindingId(stringOr(request.currentBindingId, null));
|
|
38
|
+
if (current === null || path === "" || path === "/") return fallback;
|
|
39
|
+
const paths = await catalogClusterPaths(bindings, async () => {
|
|
40
|
+
const { data, error } = await clientFor(current).query({
|
|
41
|
+
query: CATALOG_ROUTE_ALTERNATES_QUERY,
|
|
42
|
+
variables: { path },
|
|
43
|
+
errorPolicy: "all",
|
|
44
|
+
fetchPolicy: "no-cache",
|
|
45
|
+
context: { fetchOptions: { signal: AbortSignal.timeout(BINDING_SWITCH_LOOKUP_TIMEOUT_MS) } }
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
data,
|
|
49
|
+
error
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const variantPath = paths && Object.hasOwn(paths, destination) ? paths[destination] : void 0;
|
|
53
|
+
if (variantPath === void 0) return fallback;
|
|
54
|
+
return { url: `${buildUrl(destination, encodePath(variantPath))}${tail}` };
|
|
55
|
+
}
|
|
56
|
+
const { href } = resolveStorefrontHref({
|
|
57
|
+
bindingId: destination,
|
|
58
|
+
basePath: "/"
|
|
59
|
+
}, routeMap, {
|
|
60
|
+
page,
|
|
61
|
+
params
|
|
62
|
+
});
|
|
63
|
+
if (href === null) return fallback;
|
|
64
|
+
return { url: `${buildUrl(destination, href)}${tail}` };
|
|
65
|
+
}
|
|
66
|
+
function stringOr(value, empty) {
|
|
67
|
+
return typeof value === "string" ? value : empty;
|
|
68
|
+
}
|
|
69
|
+
function paramsOf(value) {
|
|
70
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The single page whose href in the current binding is this logical path. A miss and a tie are both
|
|
74
|
+
* no page: the switch falls back instead of guessing. An entry that cannot be resolved (a missing
|
|
75
|
+
* param, a binding it does not serve) is skipped.
|
|
76
|
+
*/
|
|
77
|
+
function pageMatchingPath(routeMap, bindingId, path, params) {
|
|
78
|
+
const matches = [];
|
|
79
|
+
for (const name of Object.keys(routeMap)) {
|
|
80
|
+
const { href } = resolveStorefrontHref({
|
|
81
|
+
bindingId,
|
|
82
|
+
basePath: "/"
|
|
83
|
+
}, routeMap, {
|
|
84
|
+
page: name,
|
|
85
|
+
params
|
|
86
|
+
});
|
|
87
|
+
if (href === null || !sameDecodedPath(href, path)) continue;
|
|
88
|
+
matches.push(name);
|
|
89
|
+
}
|
|
90
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* `resolveStorefrontHref` percent-encodes params, so the href is decoded once. The request path is
|
|
94
|
+
* compared as it arrived first, so a decoded slug like `100%-off` or `%41` is not decoded again; an
|
|
95
|
+
* encoded path still matches through its decoded form.
|
|
96
|
+
*/
|
|
97
|
+
function sameDecodedPath(href, path) {
|
|
98
|
+
const decodedHref = decodeOrNull(href);
|
|
99
|
+
if (decodedHref === null) return false;
|
|
100
|
+
return decodedHref === path || decodedHref === decodeOrNull(path);
|
|
101
|
+
}
|
|
102
|
+
function decodeOrNull(text) {
|
|
103
|
+
try {
|
|
104
|
+
return decodeURIComponent(text);
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function ownEntry(routeMap, page) {
|
|
110
|
+
return Object.hasOwn(routeMap, page) ? routeMap[page] : void 0;
|
|
111
|
+
}
|
|
112
|
+
/** Kept verbatim when it is only a query: a leading `?`, no `#`, and no control character. */
|
|
113
|
+
function searchOf(search) {
|
|
114
|
+
const text = stringOr(search, "");
|
|
115
|
+
if (text.length < 2 || !text.startsWith("?")) return "";
|
|
116
|
+
for (const char of text) {
|
|
117
|
+
const code = char.codePointAt(0) ?? 0;
|
|
118
|
+
if (char === "#" || code < 32 || code === 127) return "";
|
|
119
|
+
}
|
|
120
|
+
return text;
|
|
121
|
+
}
|
|
122
|
+
function hashOf(hash) {
|
|
123
|
+
const text = stringOr(hash, "");
|
|
124
|
+
return text.startsWith("#") && text.length > 1 ? text : "";
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { resolveBindingSwitch };
|
|
128
|
+
|
|
129
|
+
//# sourceMappingURL=binding-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-switch.js","names":[],"sources":["../../../src/sdk/navigation/binding-switch.ts"],"sourcesContent":["import type { ApolloClient } from '@apollo/client';\nimport {\n type AlternateBinding,\n CATALOG_ROUTE_ALTERNATES_QUERY,\n catalogClusterPaths,\n encodePath,\n} from '../seo/page-alternates.js';\nimport { decodeRouteParams } from './decode-route-params.js';\nimport { resolveStorefrontHref } from './resolve-storefront-href.js';\nimport type { RouteMap, RouteMapEntry, StandardName } from './types.js';\n\n/** Bounds the `catalogRoute` lookup: a slow API takes the no-equivalent fallback instead of stalling the switch. */\nconst BINDING_SWITCH_LOOKUP_TIMEOUT_MS = 3_000;\n\nconst CATALOG_STANDARDS: ReadonlySet<StandardName> = new Set(['product', 'category', 'brand', 'collection']);\n\nconst NO_EQUIVALENT_QUERY = '?fs_notice=no-equivalent';\n\nexport type BindingSwitchRequest = {\n /** Destination binding id. */\n bindingId: string;\n /** The binding the shopper is on. */\n currentBindingId: string;\n params: Record<string, string | string[]>;\n /** Decoded logical path of the current page. */\n path: string;\n /** `location.search`: `''` or `'?…'`. */\n search: string;\n /** `location.hash`: `''` or `'#…'`. */\n hash: string;\n};\n\nexport type BindingSwitchResult = { url: string | null };\n\nexport type ResolveBindingSwitchOptions = {\n request: BindingSwitchRequest;\n knownBindingId: (candidate: string | null | undefined) => string | null;\n bindings: readonly AlternateBinding[];\n routeMap: RouteMap;\n buildUrl: (bindingId: string, logicalPath: string) => string;\n clientFor: (bindingId: string) => ApolloClient;\n};\n\n/**\n * The equivalent URL of the current page in the destination binding, or the destination's home with\n * `fs_notice=no-equivalent` when none exists or the lookup fails. The page is the one route-map\n * entry whose href in the current binding equals the logical path; none or several take the\n * fallback. Every URL is built by `buildUrl` from an id `knownBindingId` accepted; an undeclared\n * destination resolves `{ url: null }`. The request comes off the wire, so each field is read as\n * unchecked. Never throws for an expected outcome, writes no cookie, and reads no request header.\n */\nexport async function resolveBindingSwitch({\n request,\n knownBindingId,\n bindings,\n routeMap,\n buildUrl,\n clientFor,\n}: ResolveBindingSwitchOptions): Promise<BindingSwitchResult> {\n const destination = knownBindingId(stringOr(request.bindingId, null));\n if (destination === null) {\n console.error('[locale.set] unknown binding');\n return { url: null };\n }\n\n const fallback = { url: `${buildUrl(destination, '/')}${NO_EQUIVALENT_QUERY}` };\n const path = stringOr(request.path, '');\n // `useParams()` hands the segments over percent-encoded; the route map fills patterns with decoded values.\n const params = decodeRouteParams(paramsOf(request.params));\n const page = pageMatchingPath(routeMap, stringOr(request.currentBindingId, ''), path, params);\n const entry = page === undefined ? undefined : ownEntry(routeMap, page);\n if (page === undefined || entry === undefined) return fallback;\n if (entry.bindings !== undefined && !entry.bindings.includes(destination)) return fallback;\n\n const tail = `${searchOf(request.search)}${hashOf(request.hash)}`;\n\n if (entry.standard !== undefined && CATALOG_STANDARDS.has(entry.standard)) {\n const current = knownBindingId(stringOr(request.currentBindingId, null));\n if (current === null || path === '' || path === '/') return fallback;\n\n const paths = await catalogClusterPaths(bindings, async () => {\n const { data, error } = await clientFor(current).query({\n query: CATALOG_ROUTE_ALTERNATES_QUERY,\n variables: { path },\n errorPolicy: 'all',\n fetchPolicy: 'no-cache',\n context: { fetchOptions: { signal: AbortSignal.timeout(BINDING_SWITCH_LOOKUP_TIMEOUT_MS) } },\n });\n return { data, error };\n });\n const variantPath = paths && Object.hasOwn(paths, destination) ? paths[destination] : undefined;\n if (variantPath === undefined) return fallback;\n return { url: `${buildUrl(destination, encodePath(variantPath))}${tail}` };\n }\n\n const { href } = resolveStorefrontHref({ bindingId: destination, basePath: '/' }, routeMap, { page, params });\n if (href === null) return fallback;\n return { url: `${buildUrl(destination, href)}${tail}` };\n}\n\nfunction stringOr<T extends string | null>(value: unknown, empty: T): string | T {\n return typeof value === 'string' ? value : empty;\n}\n\nfunction paramsOf(value: unknown): BindingSwitchRequest['params'] {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as BindingSwitchRequest['params'])\n : {};\n}\n\n/**\n * The single page whose href in the current binding is this logical path. A miss and a tie are both\n * no page: the switch falls back instead of guessing. An entry that cannot be resolved (a missing\n * param, a binding it does not serve) is skipped.\n */\nfunction pageMatchingPath(\n routeMap: RouteMap,\n bindingId: string,\n path: string,\n params: BindingSwitchRequest['params'],\n): string | undefined {\n const matches: string[] = [];\n for (const name of Object.keys(routeMap)) {\n const { href } = resolveStorefrontHref({ bindingId, basePath: '/' }, routeMap, { page: name, params });\n if (href === null || !sameDecodedPath(href, path)) continue;\n matches.push(name);\n }\n return matches.length === 1 ? matches[0] : undefined;\n}\n\n/**\n * `resolveStorefrontHref` percent-encodes params, so the href is decoded once. The request path is\n * compared as it arrived first, so a decoded slug like `100%-off` or `%41` is not decoded again; an\n * encoded path still matches through its decoded form.\n */\nfunction sameDecodedPath(href: string, path: string): boolean {\n const decodedHref = decodeOrNull(href);\n if (decodedHref === null) return false;\n return decodedHref === path || decodedHref === decodeOrNull(path);\n}\n\nfunction decodeOrNull(text: string): string | null {\n try {\n return decodeURIComponent(text);\n } catch {\n return null;\n }\n}\n\nfunction ownEntry(routeMap: RouteMap, page: string): RouteMapEntry | undefined {\n return Object.hasOwn(routeMap, page) ? routeMap[page] : undefined;\n}\n\n/** Kept verbatim when it is only a query: a leading `?`, no `#`, and no control character. */\nfunction searchOf(search: unknown): string {\n const text = stringOr(search, '');\n if (text.length < 2 || !text.startsWith('?')) return '';\n for (const char of text) {\n const code = char.codePointAt(0) ?? 0;\n if (char === '#' || code < 0x20 || code === 0x7f) return '';\n }\n return text;\n}\n\nfunction hashOf(hash: unknown): string {\n const text = stringOr(hash, '');\n return text.startsWith('#') && text.length > 1 ? text : '';\n}\n"],"mappings":";;;;;AAYA,MAAM,mCAAmC;AAEzC,MAAM,oCAA+C,IAAI,IAAI;CAAC;CAAW;CAAY;CAAS;AAAY,CAAC;AAE3G,MAAM,sBAAsB;;;;;;;;;AAmC5B,eAAsB,qBAAqB,EACzC,SACA,gBACA,UACA,UACA,UACA,aAC4D;CAC5D,MAAM,cAAc,eAAe,SAAS,QAAQ,WAAW,IAAI,CAAC;CACpE,IAAI,gBAAgB,MAAM;EACxB,QAAQ,MAAM,8BAA8B;EAC5C,OAAO,EAAE,KAAK,KAAK;CACrB;CAEA,MAAM,WAAW,EAAE,KAAK,GAAG,SAAS,aAAa,GAAG,IAAI,sBAAsB;CAC9E,MAAM,OAAO,SAAS,QAAQ,MAAM,EAAE;CAEtC,MAAM,SAAS,kBAAkB,SAAS,QAAQ,MAAM,CAAC;CACzD,MAAM,OAAO,iBAAiB,UAAU,SAAS,QAAQ,kBAAkB,EAAE,GAAG,MAAM,MAAM;CAC5F,MAAM,QAAQ,SAAS,KAAA,IAAY,KAAA,IAAY,SAAS,UAAU,IAAI;CACtE,IAAI,SAAS,KAAA,KAAa,UAAU,KAAA,GAAW,OAAO;CACtD,IAAI,MAAM,aAAa,KAAA,KAAa,CAAC,MAAM,SAAS,SAAS,WAAW,GAAG,OAAO;CAElF,MAAM,OAAO,GAAG,SAAS,QAAQ,MAAM,IAAI,OAAO,QAAQ,IAAI;CAE9D,IAAI,MAAM,aAAa,KAAA,KAAa,kBAAkB,IAAI,MAAM,QAAQ,GAAG;EACzE,MAAM,UAAU,eAAe,SAAS,QAAQ,kBAAkB,IAAI,CAAC;EACvE,IAAI,YAAY,QAAQ,SAAS,MAAM,SAAS,KAAK,OAAO;EAE5D,MAAM,QAAQ,MAAM,oBAAoB,UAAU,YAAY;GAC5D,MAAM,EAAE,MAAM,UAAU,MAAM,UAAU,OAAO,CAAC,CAAC,MAAM;IACrD,OAAO;IACP,WAAW,EAAE,KAAK;IAClB,aAAa;IACb,aAAa;IACb,SAAS,EAAE,cAAc,EAAE,QAAQ,YAAY,QAAQ,gCAAgC,EAAE,EAAE;GAC7F,CAAC;GACD,OAAO;IAAE;IAAM;GAAM;EACvB,CAAC;EACD,MAAM,cAAc,SAAS,OAAO,OAAO,OAAO,WAAW,IAAI,MAAM,eAAe,KAAA;EACtF,IAAI,gBAAgB,KAAA,GAAW,OAAO;EACtC,OAAO,EAAE,KAAK,GAAG,SAAS,aAAa,WAAW,WAAW,CAAC,IAAI,OAAO;CAC3E;CAEA,MAAM,EAAE,SAAS,sBAAsB;EAAE,WAAW;EAAa,UAAU;CAAI,GAAG,UAAU;EAAE;EAAM;CAAO,CAAC;CAC5G,IAAI,SAAS,MAAM,OAAO;CAC1B,OAAO,EAAE,KAAK,GAAG,SAAS,aAAa,IAAI,IAAI,OAAO;AACxD;AAEA,SAAS,SAAkC,OAAgB,OAAsB;CAC/E,OAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AAEA,SAAS,SAAS,OAAgD;CAChE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD,CAAC;AACP;;;;;;AAOA,SAAS,iBACP,UACA,WACA,MACA,QACoB;CACpB,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,OAAO,KAAK,QAAQ,GAAG;EACxC,MAAM,EAAE,SAAS,sBAAsB;GAAE;GAAW,UAAU;EAAI,GAAG,UAAU;GAAE,MAAM;GAAM;EAAO,CAAC;EACrG,IAAI,SAAS,QAAQ,CAAC,gBAAgB,MAAM,IAAI,GAAG;EACnD,QAAQ,KAAK,IAAI;CACnB;CACA,OAAO,QAAQ,WAAW,IAAI,QAAQ,KAAK,KAAA;AAC7C;;;;;;AAOA,SAAS,gBAAgB,MAAc,MAAuB;CAC5D,MAAM,cAAc,aAAa,IAAI;CACrC,IAAI,gBAAgB,MAAM,OAAO;CACjC,OAAO,gBAAgB,QAAQ,gBAAgB,aAAa,IAAI;AAClE;AAEA,SAAS,aAAa,MAA6B;CACjD,IAAI;EACF,OAAO,mBAAmB,IAAI;CAChC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,SAAS,UAAoB,MAAyC;CAC7E,OAAO,OAAO,OAAO,UAAU,IAAI,IAAI,SAAS,QAAQ,KAAA;AAC1D;;AAGA,SAAS,SAAS,QAAyB;CACzC,MAAM,OAAO,SAAS,QAAQ,EAAE;CAChC,IAAI,KAAK,SAAS,KAAK,CAAC,KAAK,WAAW,GAAG,GAAG,OAAO;CACrD,KAAK,MAAM,QAAQ,MAAM;EACvB,MAAM,OAAO,KAAK,YAAY,CAAC,KAAK;EACpC,IAAI,SAAS,OAAO,OAAO,MAAQ,SAAS,KAAM,OAAO;CAC3D;CACA,OAAO;AACT;AAEA,SAAS,OAAO,MAAuB;CACrC,MAAM,OAAO,SAAS,MAAM,EAAE;CAC9B,OAAO,KAAK,WAAW,GAAG,KAAK,KAAK,SAAS,IAAI,OAAO;AAC1D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/sdk/navigation/current-page.ts
|
|
2
|
+
/**
|
|
3
|
+
* The current page with `query` as its whole query: a page reference inside a Route Marker, and the
|
|
4
|
+
* Logical Path plus the query outside one, where a layout has no page.
|
|
5
|
+
*/
|
|
6
|
+
function currentPageWith(route, query) {
|
|
7
|
+
const text = query.toString();
|
|
8
|
+
if (route.page === null) return text.length === 0 ? route.path : `${route.path}?${text}`;
|
|
9
|
+
const target = {
|
|
10
|
+
page: route.page.name,
|
|
11
|
+
params: route.params
|
|
12
|
+
};
|
|
13
|
+
return text.length === 0 ? target : {
|
|
14
|
+
...target,
|
|
15
|
+
query: queryRecord(query)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** The query as a record, keeping every value of a repeated key in order. */
|
|
19
|
+
function queryRecord(query) {
|
|
20
|
+
const record = {};
|
|
21
|
+
for (const key of new Set(query.keys())) {
|
|
22
|
+
const values = query.getAll(key);
|
|
23
|
+
record[key] = values.length === 1 ? values[0] ?? "" : values;
|
|
24
|
+
}
|
|
25
|
+
return record;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { currentPageWith };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=current-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-page.js","names":[],"sources":["../../../src/sdk/navigation/current-page.ts"],"sourcesContent":["import type { PageRef } from './types.js';\nimport type { StorefrontRoute } from './use-storefront-route.js';\n\nexport type CurrentRoute = Pick<StorefrontRoute, 'page' | 'params' | 'path'>;\n\n/**\n * The current page with `query` as its whole query: a page reference inside a Route Marker, and the\n * Logical Path plus the query outside one, where a layout has no page.\n */\nexport function currentPageWith(route: CurrentRoute, query: URLSearchParams): PageRef | string {\n const text = query.toString();\n if (route.page === null) return text.length === 0 ? route.path : `${route.path}?${text}`;\n const target: PageRef = { page: route.page.name, params: route.params };\n return text.length === 0 ? target : { ...target, query: queryRecord(query) };\n}\n\n/** The query as a record, keeping every value of a repeated key in order. */\nfunction queryRecord(query: URLSearchParams): Record<string, string | string[]> {\n const record: Record<string, string | string[]> = {};\n for (const key of new Set(query.keys())) {\n const values = query.getAll(key);\n record[key] = values.length === 1 ? (values[0] ?? '') : values;\n }\n return record;\n}\n"],"mappings":";;;;;AASA,SAAgB,gBAAgB,OAAqB,OAA0C;CAC7F,MAAM,OAAO,MAAM,SAAS;CAC5B,IAAI,MAAM,SAAS,MAAM,OAAO,KAAK,WAAW,IAAI,MAAM,OAAO,GAAG,MAAM,KAAK,GAAG;CAClF,MAAM,SAAkB;EAAE,MAAM,MAAM,KAAK;EAAM,QAAQ,MAAM;CAAO;CACtE,OAAO,KAAK,WAAW,IAAI,SAAS;EAAE,GAAG;EAAQ,OAAO,YAAY,KAAK;CAAE;AAC7E;;AAGA,SAAS,YAAY,OAA2D;CAC9E,MAAM,SAA4C,CAAC;CACnD,KAAK,MAAM,OAAO,IAAI,IAAI,MAAM,KAAK,CAAC,GAAG;EACvC,MAAM,SAAS,MAAM,OAAO,GAAG;EAC/B,OAAO,OAAO,OAAO,WAAW,IAAK,OAAO,MAAM,KAAM;CAC1D;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/sdk/navigation/decode-route-params.d.ts
|
|
2
|
+
type RouteParamValue = string | string[] | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* The route params a generated page receives, decoded: Next hands over a dynamic segment
|
|
5
|
+
* percent-encoded, so an id ending in `=` arrives as `%3D`. A value with a malformed sequence is kept
|
|
6
|
+
* as received, so a request can never turn into an exception. A list (catch-all) is decoded segment
|
|
7
|
+
* by segment, and the keys are unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function decodeRouteParams<T extends Record<string, RouteParamValue>>(params: T): T;
|
|
10
|
+
//#endregion
|
|
11
|
+
//# sourceMappingURL=decode-route-params.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/sdk/navigation/decode-route-params.ts
|
|
2
|
+
function decodeSegment(segment) {
|
|
3
|
+
try {
|
|
4
|
+
return decodeURIComponent(segment);
|
|
5
|
+
} catch {
|
|
6
|
+
return segment;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function decodeValue(value) {
|
|
10
|
+
if (value === void 0) return void 0;
|
|
11
|
+
return Array.isArray(value) ? value.map(decodeSegment) : decodeSegment(value);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The route params a generated page receives, decoded: Next hands over a dynamic segment
|
|
15
|
+
* percent-encoded, so an id ending in `=` arrives as `%3D`. A value with a malformed sequence is kept
|
|
16
|
+
* as received, so a request can never turn into an exception. A list (catch-all) is decoded segment
|
|
17
|
+
* by segment, and the keys are unchanged.
|
|
18
|
+
*/
|
|
19
|
+
function decodeRouteParams(params) {
|
|
20
|
+
const decoded = {};
|
|
21
|
+
for (const [key, value] of Object.entries(params)) Object.defineProperty(decoded, key, {
|
|
22
|
+
value: decodeValue(value),
|
|
23
|
+
enumerable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
return decoded;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { decodeRouteParams };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=decode-route-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-route-params.js","names":[],"sources":["../../../src/sdk/navigation/decode-route-params.ts"],"sourcesContent":["type RouteParamValue = string | string[] | undefined;\n\nfunction decodeSegment(segment: string): string {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n}\n\nfunction decodeValue(value: RouteParamValue): RouteParamValue {\n if (value === undefined) return undefined;\n return Array.isArray(value) ? value.map(decodeSegment) : decodeSegment(value);\n}\n\n/**\n * The route params a generated page receives, decoded: Next hands over a dynamic segment\n * percent-encoded, so an id ending in `=` arrives as `%3D`. A value with a malformed sequence is kept\n * as received, so a request can never turn into an exception. A list (catch-all) is decoded segment\n * by segment, and the keys are unchanged.\n */\nexport function decodeRouteParams<T extends Record<string, RouteParamValue>>(params: T): T {\n const decoded: Record<string, RouteParamValue> = {};\n for (const [key, value] of Object.entries(params)) {\n // defineProperty, not assignment: a param named `__proto__` must stay an own key.\n Object.defineProperty(decoded, key, {\n value: decodeValue(value),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return decoded as T;\n}\n"],"mappings":";AAEA,SAAS,cAAc,SAAyB;CAC9C,IAAI;EACF,OAAO,mBAAmB,OAAO;CACnC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,YAAY,OAAyC;CAC5D,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,IAAI,aAAa,IAAI,cAAc,KAAK;AAC9E;;;;;;;AAQA,SAAgB,kBAA6D,QAAc;CACzF,MAAM,UAA2C,CAAC;CAClD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAE9C,OAAO,eAAe,SAAS,KAAK;EAClC,OAAO,YAAY,KAAK;EACxB,YAAY;EACZ,UAAU;EACV,cAAc;CAChB,CAAC;CAEH,OAAO;AACT"}
|