@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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RouteMap } from "./types.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/sdk/navigation/route-map-provider.d.ts
|
|
4
|
+
/** The generated resolver's `toLogicalPath`: the path under a binding's base path. */
|
|
5
|
+
export type ToLogicalPath = (entry: {
|
|
6
|
+
basePath: string;
|
|
7
|
+
}, pathname: string) => string;
|
|
8
|
+
export type RouteMapProviderProps = Readonly<{
|
|
9
|
+
routeMap: RouteMap;
|
|
10
|
+
toLogicalPath: ToLogicalPath;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Publishes the generated route map and `toLogicalPath` to the Client tree. `toLogicalPath` is a prop
|
|
15
|
+
* because the SDK cannot import the generated resolver and must not reimplement the prefix rule.
|
|
16
|
+
*/
|
|
17
|
+
export declare function RouteMapProvider({ routeMap, toLogicalPath, children }: RouteMapProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=route-map-provider.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/sdk/navigation/route-map-provider.tsx
|
|
5
|
+
const Context = createContext(null);
|
|
6
|
+
/**
|
|
7
|
+
* Publishes the generated route map and `toLogicalPath` to the Client tree. `toLogicalPath` is a prop
|
|
8
|
+
* because the SDK cannot import the generated resolver and must not reimplement the prefix rule.
|
|
9
|
+
*/
|
|
10
|
+
function RouteMapProvider({ routeMap, toLogicalPath, children }) {
|
|
11
|
+
const value = useMemo(() => ({
|
|
12
|
+
routeMap,
|
|
13
|
+
toLogicalPath
|
|
14
|
+
}), [routeMap, toLogicalPath]);
|
|
15
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
16
|
+
value,
|
|
17
|
+
children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** The route map and `toLogicalPath`. Throws outside a `RouteMapProvider`. */
|
|
21
|
+
function useRouteMap() {
|
|
22
|
+
const value = useContext(Context);
|
|
23
|
+
if (!value) throw new Error("useRouteMap: no route map in this tree. Render under a `RouteMapProvider` that receives `routeMap` and `toLogicalPath` — the generated `src/app/providers.tsx` mounts it.");
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { RouteMapProvider, useRouteMap };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=route-map-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-map-provider.js","names":[],"sources":["../../../src/sdk/navigation/route-map-provider.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, type ReactNode, useContext, useMemo } from 'react';\nimport type { RouteMap } from './types.js';\n\n/** The generated resolver's `toLogicalPath`: the path under a binding's base path. */\nexport type ToLogicalPath = (entry: { basePath: string }, pathname: string) => string;\n\nexport type RouteMapProviderProps = Readonly<{\n routeMap: RouteMap;\n toLogicalPath: ToLogicalPath;\n children: ReactNode;\n}>;\n\ntype RouteMapValue = { routeMap: RouteMap; toLogicalPath: ToLogicalPath };\n\nconst Context = createContext<RouteMapValue | null>(null);\n\n/**\n * Publishes the generated route map and `toLogicalPath` to the Client tree. `toLogicalPath` is a prop\n * because the SDK cannot import the generated resolver and must not reimplement the prefix rule.\n */\nexport function RouteMapProvider({ routeMap, toLogicalPath, children }: RouteMapProviderProps) {\n const value = useMemo(() => ({ routeMap, toLogicalPath }), [routeMap, toLogicalPath]);\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\n/** The route map and `toLogicalPath`. Throws outside a `RouteMapProvider`. */\nexport function useRouteMap(): RouteMapValue {\n const value = useContext(Context);\n if (!value) {\n throw new Error(\n 'useRouteMap: no route map in this tree. Render under a `RouteMapProvider` that receives ' +\n '`routeMap` and `toLogicalPath` — the generated `src/app/providers.tsx` mounts it.',\n );\n }\n return value;\n}\n"],"mappings":";;;;AAgBA,MAAM,UAAU,cAAoC,IAAI;;;;;AAMxD,SAAgB,iBAAiB,EAAE,UAAU,eAAe,YAAmC;CAC7F,MAAM,QAAQ,eAAe;EAAE;EAAU;CAAc,IAAI,CAAC,UAAU,aAAa,CAAC;CACpF,OAAO,oBAAC,QAAQ,UAAT;EAAyB;EAAQ;CAA2B,CAAA;AACrE;;AAGA,SAAgB,cAA6B;CAC3C,MAAM,QAAQ,WAAW,OAAO;CAChC,IAAI,CAAC,OACH,MAAM,IAAI,MACR,2KAEF;CAEF,OAAO;AACT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PageRef } from "./types.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
//#region src/sdk/navigation/storefront-link.d.ts
|
|
5
|
+
export type StorefrontLinkProps = Omit<ComponentProps<typeof Link>, 'href'> & {
|
|
6
|
+
/** A page reference or a logical path, resolved for the current binding. */
|
|
7
|
+
href: PageRef | string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* `next/link` resolved through the binding. A target that does not resolve renders a `<span>` that
|
|
11
|
+
* keeps the class, `aria-*` and `data-fs-*` props, so the composing component's hooks still style it.
|
|
12
|
+
* An absolute URL renders a plain anchor, because it may cross bindings.
|
|
13
|
+
*/
|
|
14
|
+
export declare function StorefrontLink({ href, children, ...props }: StorefrontLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
//# sourceMappingURL=storefront-link.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isClientHref, useStorefrontNavigation } from "./use-storefront-navigation.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
//#region src/sdk/navigation/storefront-link.tsx
|
|
6
|
+
/** Props `next/link` reads and a plain anchor must not receive. */
|
|
7
|
+
const LINK_ONLY_PROPS = [
|
|
8
|
+
"replace",
|
|
9
|
+
"scroll",
|
|
10
|
+
"prefetch",
|
|
11
|
+
"onNavigate",
|
|
12
|
+
"shallow",
|
|
13
|
+
"passHref",
|
|
14
|
+
"legacyBehavior",
|
|
15
|
+
"locale",
|
|
16
|
+
"as",
|
|
17
|
+
"transitionTypes"
|
|
18
|
+
];
|
|
19
|
+
const LINK_ONLY_PROP_NAMES = new Set(LINK_ONLY_PROPS);
|
|
20
|
+
/** What a `<span>` standing in for an unresolved link must not receive: the anchor's own attributes. */
|
|
21
|
+
const NOT_ON_SPAN_PROP_NAMES = /* @__PURE__ */ new Set([
|
|
22
|
+
...LINK_ONLY_PROPS,
|
|
23
|
+
"ref",
|
|
24
|
+
"target",
|
|
25
|
+
"rel",
|
|
26
|
+
"download",
|
|
27
|
+
"hrefLang",
|
|
28
|
+
"ping",
|
|
29
|
+
"referrerPolicy",
|
|
30
|
+
"type",
|
|
31
|
+
"media"
|
|
32
|
+
]);
|
|
33
|
+
function withoutProps(props, names) {
|
|
34
|
+
return Object.fromEntries(Object.entries(props).filter(([key]) => !names.has(key)));
|
|
35
|
+
}
|
|
36
|
+
function withoutLinkOnlyProps(props) {
|
|
37
|
+
return withoutProps(props, LINK_ONLY_PROP_NAMES);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `next/link` resolved through the binding. A target that does not resolve renders a `<span>` that
|
|
41
|
+
* keeps the class, `aria-*` and `data-fs-*` props, so the composing component's hooks still style it.
|
|
42
|
+
* An absolute URL renders a plain anchor, because it may cross bindings.
|
|
43
|
+
*/
|
|
44
|
+
function StorefrontLink({ href, children, ...props }) {
|
|
45
|
+
const { hrefFor } = useStorefrontNavigation();
|
|
46
|
+
const resolved = hrefFor(href);
|
|
47
|
+
if (resolved === null) return /* @__PURE__ */ jsx("span", {
|
|
48
|
+
...withoutProps(props, NOT_ON_SPAN_PROP_NAMES),
|
|
49
|
+
"data-fs-link-unresolved": "",
|
|
50
|
+
children
|
|
51
|
+
});
|
|
52
|
+
if (isClientHref(resolved)) return /* @__PURE__ */ jsx(Link, {
|
|
53
|
+
...props,
|
|
54
|
+
href: resolved,
|
|
55
|
+
children
|
|
56
|
+
});
|
|
57
|
+
return /* @__PURE__ */ jsx("a", {
|
|
58
|
+
...withoutLinkOnlyProps(props),
|
|
59
|
+
href: resolved,
|
|
60
|
+
children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { StorefrontLink };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=storefront-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storefront-link.js","names":[],"sources":["../../../src/sdk/navigation/storefront-link.tsx"],"sourcesContent":["'use client';\n\nimport Link from 'next/link';\nimport type { ComponentProps } from 'react';\nimport type { PageRef } from './types.js';\nimport { isClientHref, useStorefrontNavigation } from './use-storefront-navigation.js';\n\nexport type StorefrontLinkProps = Omit<ComponentProps<typeof Link>, 'href'> & {\n /** A page reference or a logical path, resolved for the current binding. */\n href: PageRef | string;\n};\n\ntype LinkOnlyProp = (typeof LINK_ONLY_PROPS)[number];\n\n/** Props `next/link` reads and a plain anchor must not receive. */\nconst LINK_ONLY_PROPS = [\n 'replace',\n 'scroll',\n 'prefetch',\n 'onNavigate',\n 'shallow',\n 'passHref',\n 'legacyBehavior',\n 'locale',\n 'as',\n 'transitionTypes',\n] as const;\n\nconst LINK_ONLY_PROP_NAMES: ReadonlySet<string> = new Set(LINK_ONLY_PROPS);\n\n/** What a `<span>` standing in for an unresolved link must not receive: the anchor's own attributes. */\nconst NOT_ON_SPAN_PROP_NAMES: ReadonlySet<string> = new Set([\n ...LINK_ONLY_PROPS,\n 'ref',\n 'target',\n 'rel',\n 'download',\n 'hrefLang',\n 'ping',\n 'referrerPolicy',\n 'type',\n 'media',\n]);\n\nfunction withoutProps<T extends object>(props: T, names: ReadonlySet<string>): Partial<T> {\n return Object.fromEntries(Object.entries(props).filter(([key]) => !names.has(key))) as Partial<T>;\n}\n\nfunction withoutLinkOnlyProps<T extends object>(props: T): Omit<T, LinkOnlyProp> {\n return withoutProps(props, LINK_ONLY_PROP_NAMES) as Omit<T, LinkOnlyProp>;\n}\n\n/**\n * `next/link` resolved through the binding. A target that does not resolve renders a `<span>` that\n * keeps the class, `aria-*` and `data-fs-*` props, so the composing component's hooks still style it.\n * An absolute URL renders a plain anchor, because it may cross bindings.\n */\nexport function StorefrontLink({ href, children, ...props }: StorefrontLinkProps) {\n const { hrefFor } = useStorefrontNavigation();\n const resolved = hrefFor(href);\n\n if (resolved === null) {\n return (\n <span {...(withoutProps(props, NOT_ON_SPAN_PROP_NAMES) as ComponentProps<'span'>)} data-fs-link-unresolved=\"\">\n {children}\n </span>\n );\n }\n\n if (isClientHref(resolved)) {\n return (\n <Link {...props} href={resolved}>\n {children}\n </Link>\n );\n }\n\n return (\n <a {...withoutLinkOnlyProps(props)} href={resolved}>\n {children}\n </a>\n );\n}\n"],"mappings":";;;;;;AAeA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,uBAA4C,IAAI,IAAI,eAAe;;AAGzE,MAAM,yCAA8C,IAAI,IAAI;CAC1D,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,aAA+B,OAAU,OAAwC;CACxF,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AACpF;AAEA,SAAS,qBAAuC,OAAiC;CAC/E,OAAO,aAAa,OAAO,oBAAoB;AACjD;;;;;;AAOA,SAAgB,eAAe,EAAE,MAAM,UAAU,GAAG,SAA8B;CAChF,MAAM,EAAE,YAAY,wBAAwB;CAC5C,MAAM,WAAW,QAAQ,IAAI;CAE7B,IAAI,aAAa,MACf,OACE,oBAAC,QAAD;EAAM,GAAK,aAAa,OAAO,sBAAsB;EAA8B,2BAAwB;EACxG;CACG,CAAA;CAIV,IAAI,aAAa,QAAQ,GACvB,OACE,oBAAC,MAAD;EAAM,GAAI;EAAO,MAAM;EACpB;CACG,CAAA;CAIV,OACE,oBAAC,KAAD;EAAG,GAAI,qBAAqB,KAAK;EAAG,MAAM;EACvC;CACA,CAAA;AAEP"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/sdk/navigation/types.d.ts
|
|
2
|
+
/** The standard page names, copied from the compiler's `StandardName`. FastStore does not depend on sukima. */
|
|
3
|
+
export type StandardName = 'home' | 'search' | 'cart' | 'checkout' | 'order-placed' | 'sign-in' | 'product' | 'category' | 'brand' | 'collection' | 'account' | 'profile' | 'orders' | 'order' | 'address' | 'payments' | 'security' | 'subscriptions' | 'subscription';
|
|
4
|
+
/**
|
|
5
|
+
* A page named either by the store's page name or by a standard name. `params`, `query`, and `hash`
|
|
6
|
+
* apply to either form. A query key with a list appears once per value.
|
|
7
|
+
*/
|
|
8
|
+
export type PageRef = ({
|
|
9
|
+
page: string;
|
|
10
|
+
} | {
|
|
11
|
+
standard: StandardName;
|
|
12
|
+
}) & {
|
|
13
|
+
params?: Record<string, string | string[]>;
|
|
14
|
+
query?: Record<string, string | string[]>;
|
|
15
|
+
hash?: string;
|
|
16
|
+
};
|
|
17
|
+
export type RouteKind = 'singleton' | 'dynamic';
|
|
18
|
+
/**
|
|
19
|
+
* One page in the route map. `pattern` keeps the bracket text (`/[slug]/p`, `/docs/[...slug]`,
|
|
20
|
+
* `/blog/[[...slug]]`). `params` lists the bare names. No base path.
|
|
21
|
+
*/
|
|
22
|
+
export type RouteMapEntry = {
|
|
23
|
+
pattern: string;
|
|
24
|
+
kind: RouteKind;
|
|
25
|
+
standard?: StandardName;
|
|
26
|
+
params?: string[];
|
|
27
|
+
aliases?: Record<string, string>;
|
|
28
|
+
bindings?: string[];
|
|
29
|
+
};
|
|
30
|
+
/** Keyed by page name. */
|
|
31
|
+
export type RouteMap = Record<string, RouteMapEntry>;
|
|
32
|
+
export type RouteIdentity = {
|
|
33
|
+
name: string;
|
|
34
|
+
kind: RouteKind;
|
|
35
|
+
standard?: StandardName;
|
|
36
|
+
};
|
|
37
|
+
export type ResolveHrefReason = 'unknown-page' | 'unknown-standard' | 'ambiguous-standard' | 'outside-bindings' | 'missing-param' | 'invalid-ref' | 'blank' | 'malformed' | 'protocol-relative' | 'forbidden-scheme';
|
|
38
|
+
export type ResolveHrefResult = {
|
|
39
|
+
href: string;
|
|
40
|
+
} | {
|
|
41
|
+
href: null;
|
|
42
|
+
reason: ResolveHrefReason;
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PageRef } from "./types.js";
|
|
2
|
+
//#region src/sdk/navigation/use-storefront-navigation.d.ts
|
|
3
|
+
export type NavigateOptions = {
|
|
4
|
+
scroll?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type StorefrontNavigation = {
|
|
7
|
+
/** The href for the current binding, or `null` when the target does not resolve. */
|
|
8
|
+
hrefFor: (target: PageRef | string) => string | null;
|
|
9
|
+
/** Navigates to the target. Does nothing when it does not resolve. */
|
|
10
|
+
push: (target: PageRef | string, options?: NavigateOptions) => void;
|
|
11
|
+
/** Navigates to the target, replacing the history entry. Does nothing when it does not resolve. */
|
|
12
|
+
replace: (target: PageRef | string, options?: NavigateOptions) => void;
|
|
13
|
+
/** Prefetches a page of this store. Does nothing for an anchor, an absolute URL, or `null`. */
|
|
14
|
+
prefetch: (target: PageRef | string) => void;
|
|
15
|
+
back: () => void;
|
|
16
|
+
forward: () => void;
|
|
17
|
+
refresh: () => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The router of `next/navigation`, resolved through the binding. Depends only on the binding
|
|
21
|
+
* context and the route map, so a component that only links does not re-render on navigation.
|
|
22
|
+
* A link that does not resolve is reported once per component, not once per render.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useStorefrontNavigation(): StorefrontNavigation;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=use-storefront-navigation.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveStorefrontHref } from "./resolve-storefront-href.js";
|
|
3
|
+
import { useStorefrontContext } from "../context/storefront-context.js";
|
|
4
|
+
import { reportUnresolved, warnSuspiciousPath } from "./report.js";
|
|
5
|
+
import { useRouteMap } from "./route-map-provider.js";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { useRouter } from "next/navigation";
|
|
8
|
+
//#region src/sdk/navigation/use-storefront-navigation.ts
|
|
9
|
+
/** Whether Next's router handles the href, as opposed to a document navigation. */
|
|
10
|
+
function isClientHref(href) {
|
|
11
|
+
return href.startsWith("/") || href.startsWith("#");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The router of `next/navigation`, resolved through the binding. Depends only on the binding
|
|
15
|
+
* context and the route map, so a component that only links does not re-render on navigation.
|
|
16
|
+
* A link that does not resolve is reported once per component, not once per render.
|
|
17
|
+
*/
|
|
18
|
+
function useStorefrontNavigation() {
|
|
19
|
+
const router = useRouter();
|
|
20
|
+
const { bindingId, basePath } = useStorefrontContext();
|
|
21
|
+
const { routeMap } = useRouteMap();
|
|
22
|
+
return useMemo(() => {
|
|
23
|
+
const reported = /* @__PURE__ */ new Set();
|
|
24
|
+
function hrefFor(target) {
|
|
25
|
+
if (typeof target === "string") warnSuspiciousPath({ basePath }, routeMap, target);
|
|
26
|
+
const result = resolveStorefrontHref({
|
|
27
|
+
bindingId,
|
|
28
|
+
basePath
|
|
29
|
+
}, routeMap, target);
|
|
30
|
+
if (result.href === null) {
|
|
31
|
+
const key = `${result.reason}\n${JSON.stringify(target)}`;
|
|
32
|
+
if (!reported.has(key)) {
|
|
33
|
+
reported.add(key);
|
|
34
|
+
reportUnresolved(result.reason, target);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return result.href;
|
|
39
|
+
}
|
|
40
|
+
function navigate(method, target, options) {
|
|
41
|
+
const href = hrefFor(target);
|
|
42
|
+
if (href === null) return;
|
|
43
|
+
if (!isClientHref(href)) {
|
|
44
|
+
if (method === "push") globalThis.location.assign(href);
|
|
45
|
+
else globalThis.location.replace(href);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (options?.scroll === void 0) router[method](href);
|
|
49
|
+
else router[method](href, { scroll: options.scroll });
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
hrefFor,
|
|
53
|
+
push: (target, options) => navigate("push", target, options),
|
|
54
|
+
replace: (target, options) => navigate("replace", target, options),
|
|
55
|
+
prefetch: (target) => {
|
|
56
|
+
const href = hrefFor(target);
|
|
57
|
+
if (href?.startsWith("/")) router.prefetch(href);
|
|
58
|
+
},
|
|
59
|
+
back: () => router.back(),
|
|
60
|
+
forward: () => router.forward(),
|
|
61
|
+
refresh: () => router.refresh()
|
|
62
|
+
};
|
|
63
|
+
}, [
|
|
64
|
+
router,
|
|
65
|
+
bindingId,
|
|
66
|
+
basePath,
|
|
67
|
+
routeMap
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { isClientHref, useStorefrontNavigation };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=use-storefront-navigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-storefront-navigation.js","names":[],"sources":["../../../src/sdk/navigation/use-storefront-navigation.ts"],"sourcesContent":["'use client';\n\nimport { useRouter } from 'next/navigation';\nimport { useMemo } from 'react';\nimport { useStorefrontContext } from '../context/storefront-context.js';\nimport { reportUnresolved, warnSuspiciousPath } from './report.js';\nimport { resolveStorefrontHref } from './resolve-storefront-href.js';\nimport { useRouteMap } from './route-map-provider.js';\nimport type { PageRef } from './types.js';\n\nexport type NavigateOptions = { scroll?: boolean };\n\nexport type StorefrontNavigation = {\n /** The href for the current binding, or `null` when the target does not resolve. */\n hrefFor: (target: PageRef | string) => string | null;\n /** Navigates to the target. Does nothing when it does not resolve. */\n push: (target: PageRef | string, options?: NavigateOptions) => void;\n /** Navigates to the target, replacing the history entry. Does nothing when it does not resolve. */\n replace: (target: PageRef | string, options?: NavigateOptions) => void;\n /** Prefetches a page of this store. Does nothing for an anchor, an absolute URL, or `null`. */\n prefetch: (target: PageRef | string) => void;\n back: () => void;\n forward: () => void;\n refresh: () => void;\n};\n\n/** Whether Next's router handles the href, as opposed to a document navigation. */\nexport function isClientHref(href: string): boolean {\n return href.startsWith('/') || href.startsWith('#');\n}\n\n/**\n * The router of `next/navigation`, resolved through the binding. Depends only on the binding\n * context and the route map, so a component that only links does not re-render on navigation.\n * A link that does not resolve is reported once per component, not once per render.\n */\nexport function useStorefrontNavigation(): StorefrontNavigation {\n const router = useRouter();\n const { bindingId, basePath } = useStorefrontContext();\n const { routeMap } = useRouteMap();\n\n return useMemo(() => {\n const reported = new Set<string>();\n\n function hrefFor(target: PageRef | string): string | null {\n if (typeof target === 'string') warnSuspiciousPath({ basePath }, routeMap, target);\n const result = resolveStorefrontHref({ bindingId, basePath }, routeMap, target);\n if (result.href === null) {\n const key = `${result.reason}\\n${JSON.stringify(target)}`;\n if (!reported.has(key)) {\n reported.add(key);\n reportUnresolved(result.reason, target);\n }\n return null;\n }\n return result.href;\n }\n\n function navigate(method: 'push' | 'replace', target: PageRef | string, options?: NavigateOptions): void {\n const href = hrefFor(target);\n if (href === null) return;\n if (!isClientHref(href)) {\n if (method === 'push') globalThis.location.assign(href);\n else globalThis.location.replace(href);\n return;\n }\n if (options?.scroll === undefined) router[method](href);\n else router[method](href, { scroll: options.scroll });\n }\n\n return {\n hrefFor,\n push: (target, options) => navigate('push', target, options),\n replace: (target, options) => navigate('replace', target, options),\n prefetch: (target) => {\n const href = hrefFor(target);\n if (href?.startsWith('/')) router.prefetch(href);\n },\n back: () => router.back(),\n forward: () => router.forward(),\n refresh: () => router.refresh(),\n };\n }, [router, bindingId, basePath, routeMap]);\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,aAAa,MAAuB;CAClD,OAAO,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG;AACpD;;;;;;AAOA,SAAgB,0BAAgD;CAC9D,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,WAAW,aAAa,qBAAqB;CACrD,MAAM,EAAE,aAAa,YAAY;CAEjC,OAAO,cAAc;EACnB,MAAM,2BAAW,IAAI,IAAY;EAEjC,SAAS,QAAQ,QAAyC;GACxD,IAAI,OAAO,WAAW,UAAU,mBAAmB,EAAE,SAAS,GAAG,UAAU,MAAM;GACjF,MAAM,SAAS,sBAAsB;IAAE;IAAW;GAAS,GAAG,UAAU,MAAM;GAC9E,IAAI,OAAO,SAAS,MAAM;IACxB,MAAM,MAAM,GAAG,OAAO,OAAO,IAAI,KAAK,UAAU,MAAM;IACtD,IAAI,CAAC,SAAS,IAAI,GAAG,GAAG;KACtB,SAAS,IAAI,GAAG;KAChB,iBAAiB,OAAO,QAAQ,MAAM;IACxC;IACA,OAAO;GACT;GACA,OAAO,OAAO;EAChB;EAEA,SAAS,SAAS,QAA4B,QAA0B,SAAiC;GACvG,MAAM,OAAO,QAAQ,MAAM;GAC3B,IAAI,SAAS,MAAM;GACnB,IAAI,CAAC,aAAa,IAAI,GAAG;IACvB,IAAI,WAAW,QAAQ,WAAW,SAAS,OAAO,IAAI;SACjD,WAAW,SAAS,QAAQ,IAAI;IACrC;GACF;GACA,IAAI,SAAS,WAAW,KAAA,GAAW,OAAO,OAAO,CAAC,IAAI;QACjD,OAAO,OAAO,CAAC,MAAM,EAAE,QAAQ,QAAQ,OAAO,CAAC;EACtD;EAEA,OAAO;GACL;GACA,OAAO,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;GAC3D,UAAU,QAAQ,YAAY,SAAS,WAAW,QAAQ,OAAO;GACjE,WAAW,WAAW;IACpB,MAAM,OAAO,QAAQ,MAAM;IAC3B,IAAI,MAAM,WAAW,GAAG,GAAG,OAAO,SAAS,IAAI;GACjD;GACA,YAAY,OAAO,KAAK;GACxB,eAAe,OAAO,QAAQ;GAC9B,eAAe,OAAO,QAAQ;EAChC;CACF,GAAG;EAAC;EAAQ;EAAW;EAAU;CAAQ,CAAC;AAC5C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RouteIdentity } from "./types.js";
|
|
2
|
+
//#region src/sdk/navigation/use-storefront-route.d.ts
|
|
3
|
+
export type StorefrontRoute = {
|
|
4
|
+
/** Which page is rendering, from the route marker and the route map. `null` outside a marker. */
|
|
5
|
+
page: RouteIdentity | null;
|
|
6
|
+
/** The route params, without the internal binding segment. */
|
|
7
|
+
params: Record<string, string | string[]>;
|
|
8
|
+
/** The logical path: the page's path inside the binding. */
|
|
9
|
+
path: string;
|
|
10
|
+
/** The public path: what the browser shows, binding base path included. */
|
|
11
|
+
publicPath: string;
|
|
12
|
+
/** `location.search` (`''` or `'?…'`), and `null` on the server and during hydration. */
|
|
13
|
+
search: string | null;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The current route: the page, its params, and its logical and public paths. Changes on every
|
|
17
|
+
* navigation, so a component that only links uses `useStorefrontNavigation` instead.
|
|
18
|
+
*
|
|
19
|
+
* `search` is read from `location.search` and refreshes on `popstate` or on a render the pathname or
|
|
20
|
+
* params cause. A soft navigation that changes only the query (`router.push('?q=x')`) fires no
|
|
21
|
+
* `popstate`, so `search` keeps its previous value until the next such render. A component whose
|
|
22
|
+
* state lives in the query reads `useStorefrontSearchParams()` instead.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useStorefrontRoute(): StorefrontRoute;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=use-storefront-route.d.ts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useStorefrontContext } from "../context/storefront-context.js";
|
|
3
|
+
import { useRouteMap } from "./route-map-provider.js";
|
|
4
|
+
import { useRouteIdentityName } from "./route-identity-provider.js";
|
|
5
|
+
import { useMemo, useSyncExternalStore } from "react";
|
|
6
|
+
import { useParams, usePathname } from "next/navigation";
|
|
7
|
+
//#region src/sdk/navigation/use-storefront-route.ts
|
|
8
|
+
/** The internal route segment the generated root layout names the binding with. */
|
|
9
|
+
const BINDING_PARAM = "binding";
|
|
10
|
+
function subscribeToPopState(onChange) {
|
|
11
|
+
globalThis.addEventListener("popstate", onChange);
|
|
12
|
+
return () => globalThis.removeEventListener("popstate", onChange);
|
|
13
|
+
}
|
|
14
|
+
function readSearch() {
|
|
15
|
+
return globalThis.location.search;
|
|
16
|
+
}
|
|
17
|
+
function readServerSearch() {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/** Next's params without the binding segment. An empty optional catch-all is `undefined` and is left out. */
|
|
21
|
+
function routeParams(raw) {
|
|
22
|
+
const params = {};
|
|
23
|
+
for (const [key, value] of Object.entries(raw)) if (key !== BINDING_PARAM && value !== void 0) params[key] = value;
|
|
24
|
+
return params;
|
|
25
|
+
}
|
|
26
|
+
const reportedMissingPages = /* @__PURE__ */ new Set();
|
|
27
|
+
/**
|
|
28
|
+
* The page the marker names, or `null` when the route map does not hold it. The generator emits both,
|
|
29
|
+
* so they disagree only for a moment of Fast Refresh or through a generator bug; either way the page
|
|
30
|
+
* reads as a layout does instead of failing to render. Logged once per name.
|
|
31
|
+
*/
|
|
32
|
+
function pageIdentity(routeMap, name) {
|
|
33
|
+
if (name === null) return null;
|
|
34
|
+
const entry = Object.hasOwn(routeMap, name) ? routeMap[name] : void 0;
|
|
35
|
+
if (entry === void 0) {
|
|
36
|
+
if (!reportedMissingPages.has(name)) {
|
|
37
|
+
reportedMissingPages.add(name);
|
|
38
|
+
console.error(`useStorefrontRoute: the route marker names page ${JSON.stringify(name)}, which the route map does not hold. The generator emits both, so they must agree; reading the page as null.`);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return entry.standard === void 0 ? {
|
|
43
|
+
name,
|
|
44
|
+
kind: entry.kind
|
|
45
|
+
} : {
|
|
46
|
+
name,
|
|
47
|
+
kind: entry.kind,
|
|
48
|
+
standard: entry.standard
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The current route: the page, its params, and its logical and public paths. Changes on every
|
|
53
|
+
* navigation, so a component that only links uses `useStorefrontNavigation` instead.
|
|
54
|
+
*
|
|
55
|
+
* `search` is read from `location.search` and refreshes on `popstate` or on a render the pathname or
|
|
56
|
+
* params cause. A soft navigation that changes only the query (`router.push('?q=x')`) fires no
|
|
57
|
+
* `popstate`, so `search` keeps its previous value until the next such render. A component whose
|
|
58
|
+
* state lives in the query reads `useStorefrontSearchParams()` instead.
|
|
59
|
+
*/
|
|
60
|
+
function useStorefrontRoute() {
|
|
61
|
+
const publicPath = usePathname();
|
|
62
|
+
const rawParams = useParams();
|
|
63
|
+
const { basePath } = useStorefrontContext();
|
|
64
|
+
const { routeMap, toLogicalPath } = useRouteMap();
|
|
65
|
+
const name = useRouteIdentityName();
|
|
66
|
+
const search = useSyncExternalStore(subscribeToPopState, readSearch, readServerSearch);
|
|
67
|
+
const params = useMemo(() => routeParams(rawParams ?? {}), [rawParams]);
|
|
68
|
+
const page = useMemo(() => pageIdentity(routeMap, name), [routeMap, name]);
|
|
69
|
+
const path = toLogicalPath({ basePath }, publicPath);
|
|
70
|
+
return useMemo(() => ({
|
|
71
|
+
page,
|
|
72
|
+
params,
|
|
73
|
+
path,
|
|
74
|
+
publicPath,
|
|
75
|
+
search
|
|
76
|
+
}), [
|
|
77
|
+
page,
|
|
78
|
+
params,
|
|
79
|
+
path,
|
|
80
|
+
publicPath,
|
|
81
|
+
search
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { useStorefrontRoute };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=use-storefront-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-storefront-route.js","names":[],"sources":["../../../src/sdk/navigation/use-storefront-route.ts"],"sourcesContent":["'use client';\n\nimport { useParams, usePathname } from 'next/navigation';\nimport { useMemo, useSyncExternalStore } from 'react';\nimport { useStorefrontContext } from '../context/storefront-context.js';\nimport { useRouteIdentityName } from './route-identity-provider.js';\nimport { useRouteMap } from './route-map-provider.js';\nimport type { RouteIdentity, RouteMap } from './types.js';\n\n/** The internal route segment the generated root layout names the binding with. */\nconst BINDING_PARAM = 'binding';\n\nexport type StorefrontRoute = {\n /** Which page is rendering, from the route marker and the route map. `null` outside a marker. */\n page: RouteIdentity | null;\n /** The route params, without the internal binding segment. */\n params: Record<string, string | string[]>;\n /** The logical path: the page's path inside the binding. */\n path: string;\n /** The public path: what the browser shows, binding base path included. */\n publicPath: string;\n /** `location.search` (`''` or `'?…'`), and `null` on the server and during hydration. */\n search: string | null;\n};\n\nfunction subscribeToPopState(onChange: () => void): () => void {\n globalThis.addEventListener('popstate', onChange);\n return () => globalThis.removeEventListener('popstate', onChange);\n}\n\nfunction readSearch(): string {\n return globalThis.location.search;\n}\n\nfunction readServerSearch(): null {\n return null;\n}\n\n/** Next's params without the binding segment. An empty optional catch-all is `undefined` and is left out. */\nfunction routeParams(raw: Record<string, string | string[] | undefined>): Record<string, string | string[]> {\n const params: Record<string, string | string[]> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (key !== BINDING_PARAM && value !== undefined) params[key] = value;\n }\n return params;\n}\n\nconst reportedMissingPages = new Set<string>();\n\n/**\n * The page the marker names, or `null` when the route map does not hold it. The generator emits both,\n * so they disagree only for a moment of Fast Refresh or through a generator bug; either way the page\n * reads as a layout does instead of failing to render. Logged once per name.\n */\nfunction pageIdentity(routeMap: RouteMap, name: string | null): RouteIdentity | null {\n if (name === null) return null;\n const entry = Object.hasOwn(routeMap, name) ? routeMap[name] : undefined;\n if (entry === undefined) {\n if (!reportedMissingPages.has(name)) {\n reportedMissingPages.add(name);\n console.error(\n `useStorefrontRoute: the route marker names page ${JSON.stringify(name)}, which the route map ` +\n 'does not hold. The generator emits both, so they must agree; reading the page as null.',\n );\n }\n return null;\n }\n return entry.standard === undefined\n ? { name, kind: entry.kind }\n : { name, kind: entry.kind, standard: entry.standard };\n}\n\n/**\n * The current route: the page, its params, and its logical and public paths. Changes on every\n * navigation, so a component that only links uses `useStorefrontNavigation` instead.\n *\n * `search` is read from `location.search` and refreshes on `popstate` or on a render the pathname or\n * params cause. A soft navigation that changes only the query (`router.push('?q=x')`) fires no\n * `popstate`, so `search` keeps its previous value until the next such render. A component whose\n * state lives in the query reads `useStorefrontSearchParams()` instead.\n */\nexport function useStorefrontRoute(): StorefrontRoute {\n const publicPath = usePathname();\n const rawParams = useParams();\n const { basePath } = useStorefrontContext();\n const { routeMap, toLogicalPath } = useRouteMap();\n const name = useRouteIdentityName();\n const search = useSyncExternalStore(subscribeToPopState, readSearch, readServerSearch);\n\n const params = useMemo(() => routeParams(rawParams ?? {}), [rawParams]);\n const page = useMemo(() => pageIdentity(routeMap, name), [routeMap, name]);\n const path = toLogicalPath({ basePath }, publicPath);\n\n return useMemo(() => ({ page, params, path, publicPath, search }), [page, params, path, publicPath, search]);\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,gBAAgB;AAetB,SAAS,oBAAoB,UAAkC;CAC7D,WAAW,iBAAiB,YAAY,QAAQ;CAChD,aAAa,WAAW,oBAAoB,YAAY,QAAQ;AAClE;AAEA,SAAS,aAAqB;CAC5B,OAAO,WAAW,SAAS;AAC7B;AAEA,SAAS,mBAAyB;CAChC,OAAO;AACT;;AAGA,SAAS,YAAY,KAAuF;CAC1G,MAAM,SAA4C,CAAC;CACnD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAC3C,IAAI,QAAQ,iBAAiB,UAAU,KAAA,GAAW,OAAO,OAAO;CAElE,OAAO;AACT;AAEA,MAAM,uCAAuB,IAAI,IAAY;;;;;;AAO7C,SAAS,aAAa,UAAoB,MAA2C;CACnF,IAAI,SAAS,MAAM,OAAO;CAC1B,MAAM,QAAQ,OAAO,OAAO,UAAU,IAAI,IAAI,SAAS,QAAQ,KAAA;CAC/D,IAAI,UAAU,KAAA,GAAW;EACvB,IAAI,CAAC,qBAAqB,IAAI,IAAI,GAAG;GACnC,qBAAqB,IAAI,IAAI;GAC7B,QAAQ,MACN,mDAAmD,KAAK,UAAU,IAAI,EAAE,6GAE1E;EACF;EACA,OAAO;CACT;CACA,OAAO,MAAM,aAAa,KAAA,IACtB;EAAE;EAAM,MAAM,MAAM;CAAK,IACzB;EAAE;EAAM,MAAM,MAAM;EAAM,UAAU,MAAM;CAAS;AACzD;;;;;;;;;;AAWA,SAAgB,qBAAsC;CACpD,MAAM,aAAa,YAAY;CAC/B,MAAM,YAAY,UAAU;CAC5B,MAAM,EAAE,aAAa,qBAAqB;CAC1C,MAAM,EAAE,UAAU,kBAAkB,YAAY;CAChD,MAAM,OAAO,qBAAqB;CAClC,MAAM,SAAS,qBAAqB,qBAAqB,YAAY,gBAAgB;CAErF,MAAM,SAAS,cAAc,YAAY,aAAa,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;CACtE,MAAM,OAAO,cAAc,aAAa,UAAU,IAAI,GAAG,CAAC,UAAU,IAAI,CAAC;CACzE,MAAM,OAAO,cAAc,EAAE,SAAS,GAAG,UAAU;CAEnD,OAAO,eAAe;EAAE;EAAM;EAAQ;EAAM;EAAY;CAAO,IAAI;EAAC;EAAM;EAAQ;EAAM;EAAY;CAAM,CAAC;AAC7G"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReadonlyURLSearchParams } from "next/navigation";
|
|
2
|
+
//#region src/sdk/navigation/use-storefront-search-params.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The live query of the current URL. It follows a query-only soft navigation, which
|
|
5
|
+
* `useStorefrontRoute().search` does not, so a component whose state lives in the query (a filter, a
|
|
6
|
+
* search field, a page cursor) reads it here. On a prerendered page it needs a `<Suspense>` boundary,
|
|
7
|
+
* as Next's `useSearchParams` does.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useStorefrontSearchParams(): ReadonlyURLSearchParams;
|
|
10
|
+
//#endregion
|
|
11
|
+
//# sourceMappingURL=use-storefront-search-params.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSearchParams } from "next/navigation";
|
|
3
|
+
//#region src/sdk/navigation/use-storefront-search-params.ts
|
|
4
|
+
/**
|
|
5
|
+
* The live query of the current URL. It follows a query-only soft navigation, which
|
|
6
|
+
* `useStorefrontRoute().search` does not, so a component whose state lives in the query (a filter, a
|
|
7
|
+
* search field, a page cursor) reads it here. On a prerendered page it needs a `<Suspense>` boundary,
|
|
8
|
+
* as Next's `useSearchParams` does.
|
|
9
|
+
*/
|
|
10
|
+
function useStorefrontSearchParams() {
|
|
11
|
+
return useSearchParams();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useStorefrontSearchParams };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=use-storefront-search-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-storefront-search-params.js","names":[],"sources":["../../../src/sdk/navigation/use-storefront-search-params.ts"],"sourcesContent":["'use client';\n\nimport { type ReadonlyURLSearchParams, useSearchParams } from 'next/navigation';\n\n/**\n * The live query of the current URL. It follows a query-only soft navigation, which\n * `useStorefrontRoute().search` does not, so a component whose state lives in the query (a filter, a\n * search field, a page cursor) reads it here. On a prerendered page it needs a `<Suspense>` boundary,\n * as Next's `useSearchParams` does.\n */\nexport function useStorefrontSearchParams(): ReadonlyURLSearchParams {\n return useSearchParams();\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,4BAAqD;CACnE,OAAO,gBAAgB;AACzB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/sdk/orders/completion-badge.ts
|
|
2
|
+
function viewTone(view) {
|
|
3
|
+
switch (view) {
|
|
4
|
+
case "ONGOING": return {
|
|
5
|
+
state: "ongoing",
|
|
6
|
+
tone: "progress"
|
|
7
|
+
};
|
|
8
|
+
case "COMPLETED": return {
|
|
9
|
+
state: "completed",
|
|
10
|
+
tone: "success"
|
|
11
|
+
};
|
|
12
|
+
case "CANCELLED": return {
|
|
13
|
+
state: "cancelled",
|
|
14
|
+
tone: "danger"
|
|
15
|
+
};
|
|
16
|
+
default: return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function badgeLabel(label) {
|
|
20
|
+
switch (label) {
|
|
21
|
+
case "CANCELLED": return "cancelled";
|
|
22
|
+
case "CANCELLATION_REQUESTED": return "cancellation-requested";
|
|
23
|
+
case "IN_PROGRESS": return "in-progress";
|
|
24
|
+
case "DELIVERED": return "delivered";
|
|
25
|
+
case "SHIPPED": return "shipped";
|
|
26
|
+
case "READY_FOR_PICKUP": return "ready-for-pickup";
|
|
27
|
+
case "COLLECTED": return "collected";
|
|
28
|
+
default: return "";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Maps the API's `CustomerOrderCompletion` enums to `OrderStatusBadge` props. An unknown view
|
|
33
|
+
* yields `null`, so the caller omits the badge; an unknown label yields `''`, so the badge
|
|
34
|
+
* renders its catalogue placeholder.
|
|
35
|
+
*/
|
|
36
|
+
function completionBadgeModel(completion) {
|
|
37
|
+
const tone = viewTone(completion.view);
|
|
38
|
+
if (!tone) return null;
|
|
39
|
+
return {
|
|
40
|
+
...tone,
|
|
41
|
+
label: badgeLabel(completion.label)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { completionBadgeModel };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=completion-badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion-badge.js","names":[],"sources":["../../../src/sdk/orders/completion-badge.ts"],"sourcesContent":["import type { OrderStatusState, OrderStatusTone } from '../../particles/order-status-badge/order-status-badge.js';\n\nexport type OrderCompletionData = { view: string; label: string };\n\nexport type CompletionBadgeModel = {\n state: OrderStatusState;\n tone: OrderStatusTone;\n label: string;\n};\n\nfunction viewTone(view: string): { state: OrderStatusState; tone: OrderStatusTone } | null {\n switch (view) {\n case 'ONGOING':\n return { state: 'ongoing', tone: 'progress' };\n case 'COMPLETED':\n return { state: 'completed', tone: 'success' };\n case 'CANCELLED':\n return { state: 'cancelled', tone: 'danger' };\n default:\n return null;\n }\n}\n\nfunction badgeLabel(label: string): string {\n switch (label) {\n case 'CANCELLED':\n return 'cancelled';\n case 'CANCELLATION_REQUESTED':\n return 'cancellation-requested';\n case 'IN_PROGRESS':\n return 'in-progress';\n case 'DELIVERED':\n return 'delivered';\n case 'SHIPPED':\n return 'shipped';\n case 'READY_FOR_PICKUP':\n return 'ready-for-pickup';\n case 'COLLECTED':\n return 'collected';\n default:\n return '';\n }\n}\n\n/**\n * Maps the API's `CustomerOrderCompletion` enums to `OrderStatusBadge` props. An unknown view\n * yields `null`, so the caller omits the badge; an unknown label yields `''`, so the badge\n * renders its catalogue placeholder.\n */\nexport function completionBadgeModel(completion: OrderCompletionData): CompletionBadgeModel | null {\n const tone = viewTone(completion.view);\n if (!tone) {\n return null;\n }\n return { ...tone, label: badgeLabel(completion.label) };\n}\n"],"mappings":";AAUA,SAAS,SAAS,MAAyE;CACzF,QAAQ,MAAR;EACE,KAAK,WACH,OAAO;GAAE,OAAO;GAAW,MAAM;EAAW;EAC9C,KAAK,aACH,OAAO;GAAE,OAAO;GAAa,MAAM;EAAU;EAC/C,KAAK,aACH,OAAO;GAAE,OAAO;GAAa,MAAM;EAAS;EAC9C,SACE,OAAO;CACX;AACF;AAEA,SAAS,WAAW,OAAuB;CACzC,QAAQ,OAAR;EACE,KAAK,aACH,OAAO;EACT,KAAK,0BACH,OAAO;EACT,KAAK,eACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,oBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;;;;;AAOA,SAAgB,qBAAqB,YAA8D;CACjG,MAAM,OAAO,SAAS,WAAW,IAAI;CACrC,IAAI,CAAC,MACH,OAAO;CAET,OAAO;EAAE,GAAG;EAAM,OAAO,WAAW,WAAW,KAAK;CAAE;AACxD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TypedDocumentNode } from "@apollo/client";
|
|
2
|
+
//#region src/sdk/orders/order-operations.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The order-cancel write document.
|
|
5
|
+
*
|
|
6
|
+
* Authored with the hand `gql` tag, like `sdk/region/region-operations.ts`. The document selects
|
|
7
|
+
* the order identity so Apollo can merge the entity, and the typed errors the caller shows.
|
|
8
|
+
* A null `customerOrder` with empty `userErrors` is a successful write whose re-read failed.
|
|
9
|
+
*/
|
|
10
|
+
export type OrderCancelUserError = Readonly<{
|
|
11
|
+
code?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type OrderCancelOrder = Readonly<{
|
|
15
|
+
__typename: 'CustomerOrder';
|
|
16
|
+
id: string;
|
|
17
|
+
}>;
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=order-operations.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { gql } from "../graphql-tag.js";
|
|
2
|
+
//#region src/sdk/orders/order-operations.ts
|
|
3
|
+
const CUSTOMER_ORDER_CANCEL = gql`
|
|
4
|
+
mutation CustomerOrderCancel($id: ID!, $input: CustomerOrderCancelInput!) {
|
|
5
|
+
customerOrderCancel(id: $id, input: $input) {
|
|
6
|
+
__typename
|
|
7
|
+
customerOrder {
|
|
8
|
+
__typename
|
|
9
|
+
id
|
|
10
|
+
}
|
|
11
|
+
userErrors {
|
|
12
|
+
code
|
|
13
|
+
message
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { CUSTOMER_ORDER_CANCEL };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=order-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-operations.js","names":[],"sources":["../../../src/sdk/orders/order-operations.ts"],"sourcesContent":["import type { TypedDocumentNode } from '@apollo/client';\nimport { gql } from '../graphql-tag.js';\n\n/**\n * The order-cancel write document.\n *\n * Authored with the hand `gql` tag, like `sdk/region/region-operations.ts`. The document selects\n * the order identity so Apollo can merge the entity, and the typed errors the caller shows.\n * A null `customerOrder` with empty `userErrors` is a successful write whose re-read failed.\n */\n\nexport type OrderCancelUserError = Readonly<{ code?: string; message: string }>;\n\nexport type OrderCancelOrder = Readonly<{ __typename: 'CustomerOrder'; id: string }>;\n\nexport type OrderCancelPayload = Readonly<{\n __typename: 'CustomerOrderCancelPayload';\n customerOrder: OrderCancelOrder | null;\n userErrors: readonly OrderCancelUserError[];\n}>;\n\ntype CustomerOrderCancelData = Readonly<{ customerOrderCancel: OrderCancelPayload }>;\n\nexport type CustomerOrderCancelVariables = Readonly<{\n id: string;\n input: Readonly<{ reason?: string }>;\n}>;\n\nexport const CUSTOMER_ORDER_CANCEL: TypedDocumentNode<CustomerOrderCancelData, CustomerOrderCancelVariables> = gql`\n mutation CustomerOrderCancel($id: ID!, $input: CustomerOrderCancelInput!) {\n customerOrderCancel(id: $id, input: $input) {\n __typename\n customerOrder {\n __typename\n id\n }\n userErrors {\n code\n message\n }\n }\n }\n`;\n"],"mappings":";;AA4BA,MAAa,wBAAkG,GAAG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "../../core/dist/index.js";
|
|
2
|
+
import { OrderCancelOrder, OrderCancelUserError } from "./order-operations.js";
|
|
3
|
+
//#region src/sdk/orders/use-order-actions.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The `order` action namespace. `cancel` awaits `customerOrderCancel` and returns the payload.
|
|
6
|
+
* It does not throw: a typed refusal stays in `userErrors`, and a transport failure becomes one
|
|
7
|
+
* `NETWORK_ERROR`. A null order with empty `userErrors` means the write was accepted and the
|
|
8
|
+
* re-read failed. The order id and the reason are never logged.
|
|
9
|
+
*/
|
|
10
|
+
export type OrderCancelInput = Readonly<{
|
|
11
|
+
id: string;
|
|
12
|
+
reason?: string | null;
|
|
13
|
+
}>;
|
|
14
|
+
export type OrderCancelResult = Readonly<{
|
|
15
|
+
customerOrder: OrderCancelOrder | null;
|
|
16
|
+
userErrors: readonly OrderCancelUserError[];
|
|
17
|
+
}>;
|
|
18
|
+
export type OrderActions = Readonly<{
|
|
19
|
+
cancel: (input: OrderCancelInput) => Promise<OrderCancelResult>;
|
|
20
|
+
}>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export type { OrderCancelOrder, OrderCancelUserError };
|
|
23
|
+
//# sourceMappingURL=use-order-actions.d.ts.map
|