@vtex/faststore 0.0.1
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 +18 -0
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/actions.json +334 -0
- package/dist/catalog.json +6615 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.js +8 -0
- package/dist/components.d.ts +87 -0
- package/dist/components.js +87 -0
- package/dist/content-types.json +684 -0
- package/dist/core/dist/actions/mock-action.d.ts +24 -0
- package/dist/core/dist/actions/mock-action.js +28 -0
- package/dist/core/dist/actions/mock-action.js.map +1 -0
- package/dist/core/dist/actions/registry.d.ts +24 -0
- package/dist/core/dist/actions/registry.js +28 -0
- package/dist/core/dist/actions/registry.js.map +1 -0
- package/dist/core/dist/define-component.d.ts +100 -0
- package/dist/core/dist/define-component.js +8 -0
- package/dist/core/dist/define-component.js.map +1 -0
- package/dist/core/dist/define-content-type.d.ts +95 -0
- package/dist/core/dist/define-content-type.js +283 -0
- package/dist/core/dist/define-content-type.js.map +1 -0
- package/dist/core/dist/index.d.ts +7 -0
- package/dist/core/dist/index.js +5 -0
- package/dist/core/dist/schema/generated/schema.d.ts +28 -0
- package/dist/core/dist/types.d.ts +1 -0
- package/dist/docs/access-code-field.md +100 -0
- package/dist/docs/access-code-sign-in.md +174 -0
- package/dist/docs/account-entry-point.md +155 -0
- package/dist/docs/address-summary.md +50 -0
- package/dist/docs/buy-button.md +162 -0
- package/dist/docs/carousel.md +105 -0
- package/dist/docs/cart-item.md +162 -0
- package/dist/docs/cart-totalizer.md +197 -0
- package/dist/docs/cart.md +495 -0
- package/dist/docs/client-preferences.md +184 -0
- package/dist/docs/client-profile-form.md +192 -0
- package/dist/docs/client-profile.md +117 -0
- package/dist/docs/container.md +97 -0
- package/dist/docs/document-field.md +97 -0
- package/dist/docs/email-field.md +93 -0
- package/dist/docs/email-identification.md +102 -0
- package/dist/docs/footer-copyright.md +112 -0
- package/dist/docs/footer-link-group.md +162 -0
- package/dist/docs/footer-root.md +145 -0
- package/dist/docs/footer-social.md +151 -0
- package/dist/docs/free-shipping-progress.md +87 -0
- package/dist/docs/gallery.md +84 -0
- package/dist/docs/header-root.md +150 -0
- package/dist/docs/identity-edit.md +88 -0
- package/dist/docs/identity-summary.md +106 -0
- package/dist/docs/incentives.md +151 -0
- package/dist/docs/logo.md +135 -0
- package/dist/docs/meter.md +67 -0
- package/dist/docs/navigation-link-list.md +171 -0
- package/dist/docs/navigation-link.md +163 -0
- package/dist/docs/navigation-menu.md +264 -0
- package/dist/docs/payment-methods.md +139 -0
- package/dist/docs/phone-field.md +106 -0
- package/dist/docs/postal-code-field.md +126 -0
- package/dist/docs/pricing.md +499 -0
- package/dist/docs/product-gallery.md +409 -0
- package/dist/docs/product-information.md +295 -0
- package/dist/docs/product-list.md +170 -0
- package/dist/docs/product-quantity.md +88 -0
- package/dist/docs/product-shelf.md +141 -0
- package/dist/docs/promotion.md +109 -0
- package/dist/docs/region.md +225 -0
- package/dist/docs/session.md +123 -0
- package/dist/docs/shipping-address.md +390 -0
- package/dist/docs/shipping-simulator.md +147 -0
- package/dist/docs/sign-in-form.md +117 -0
- package/dist/docs/tabs.md +176 -0
- package/dist/docs/toast.md +124 -0
- package/dist/docs/variant-selector.md +450 -0
- package/dist/graphql/define-subgraph.d.ts +12 -0
- package/dist/graphql/define-subgraph.js +15 -0
- package/dist/graphql/define-subgraph.js.map +1 -0
- package/dist/graphql/gql.d.ts +10 -0
- package/dist/graphql/gql.js +16 -0
- package/dist/graphql/gql.js.map +1 -0
- package/dist/graphql/types.d.ts +88 -0
- package/dist/graphql.d.ts +4 -0
- package/dist/graphql.js +3 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +5 -0
- package/dist/internal/client.d.ts +24 -0
- package/dist/internal/client.js +23 -0
- package/dist/internal/content.d.ts +2 -0
- package/dist/internal/content.js +2 -0
- package/dist/internal/server.d.ts +7 -0
- package/dist/internal/server.js +6 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +111 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.js +387 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -0
- package/dist/matter/account-entry-point/account-entry-point.d.ts +64 -0
- package/dist/matter/account-entry-point/account-entry-point.js +151 -0
- package/dist/matter/account-entry-point/account-entry-point.js.map +1 -0
- package/dist/matter/breadcrumb/breadcrumb.d.ts +40 -0
- package/dist/matter/breadcrumb/breadcrumb.js +155 -0
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/matter/buy-button/buy-button.d.ts +95 -0
- package/dist/matter/buy-button/buy-button.js +259 -0
- package/dist/matter/buy-button/buy-button.js.map +1 -0
- package/dist/matter/cart/cart-namespace.d.ts +48 -0
- package/dist/matter/cart/cart-namespace.js +50 -0
- package/dist/matter/cart/cart-namespace.js.map +1 -0
- package/dist/matter/cart/cart.d.ts +312 -0
- package/dist/matter/cart/cart.js +1034 -0
- package/dist/matter/cart/cart.js.map +1 -0
- package/dist/matter/cart-item/cart-item.d.ts +103 -0
- package/dist/matter/cart-item/cart-item.js +672 -0
- package/dist/matter/cart-item/cart-item.js.map +1 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.d.ts +49 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.js +165 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.d.ts +28 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.js +73 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.d.ts +33 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.js +70 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.d.ts +24 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +54 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -0
- package/dist/matter/cart-item-variations/cart-item-variations.d.ts +27 -0
- package/dist/matter/cart-item-variations/cart-item-variations.js +69 -0
- package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -0
- package/dist/matter/cart-totalizer/cart-totalizer.d.ts +78 -0
- package/dist/matter/cart-totalizer/cart-totalizer.js +220 -0
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -0
- package/dist/matter/client-preferences/client-preferences.d.ts +50 -0
- package/dist/matter/client-preferences/client-preferences.js +206 -0
- package/dist/matter/client-preferences/client-preferences.js.map +1 -0
- package/dist/matter/client-profile/client-profile.d.ts +59 -0
- package/dist/matter/client-profile/client-profile.js +185 -0
- package/dist/matter/client-profile/client-profile.js.map +1 -0
- package/dist/matter/client-profile-form/client-profile-form.d.ts +126 -0
- package/dist/matter/client-profile-form/client-profile-form.js +660 -0
- package/dist/matter/client-profile-form/client-profile-form.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options-accordion.d.ts +30 -0
- package/dist/matter/delivery-options/delivery-options-accordion.js +189 -0
- package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options-controller.d.ts +49 -0
- package/dist/matter/delivery-options/delivery-options-controller.js +203 -0
- package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options.d.ts +31 -0
- package/dist/matter/delivery-options/delivery-options.js +103 -0
- package/dist/matter/delivery-options/delivery-options.js.map +1 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +9 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js +76 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -0
- package/dist/matter/email-identification/email-identification.d.ts +37 -0
- package/dist/matter/email-identification/email-identification.js +111 -0
- package/dist/matter/email-identification/email-identification.js.map +1 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +44 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +170 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -0
- package/dist/matter/identity-edit/identity-edit.d.ts +52 -0
- package/dist/matter/identity-edit/identity-edit.js +148 -0
- package/dist/matter/identity-edit/identity-edit.js.map +1 -0
- package/dist/matter/identity-summary/identity-summary.d.ts +128 -0
- package/dist/matter/identity-summary/identity-summary.js +344 -0
- package/dist/matter/identity-summary/identity-summary.js.map +1 -0
- package/dist/matter/pricing/pricing.d.ts +162 -0
- package/dist/matter/pricing/pricing.js +793 -0
- package/dist/matter/pricing/pricing.js.map +1 -0
- package/dist/matter/product-gallery/product-gallery.d.ts +23 -0
- package/dist/matter/product-gallery/product-gallery.js +188 -0
- package/dist/matter/product-gallery/product-gallery.js.map +1 -0
- package/dist/matter/product-information/product-information.d.ts +61 -0
- package/dist/matter/product-information/product-information.js +355 -0
- package/dist/matter/product-information/product-information.js.map +1 -0
- package/dist/matter/product-list/product-list.d.ts +86 -0
- package/dist/matter/product-list/product-list.js +342 -0
- package/dist/matter/product-list/product-list.js.map +1 -0
- package/dist/matter/product-quantity/product-quantity.d.ts +50 -0
- package/dist/matter/product-quantity/product-quantity.js +111 -0
- package/dist/matter/product-quantity/product-quantity.js.map +1 -0
- package/dist/matter/product-shelf/product-shelf.d.ts +125 -0
- package/dist/matter/product-shelf/product-shelf.js +376 -0
- package/dist/matter/product-shelf/product-shelf.js.map +1 -0
- package/dist/matter/region/region.d.ts +211 -0
- package/dist/matter/region/region.js +579 -0
- package/dist/matter/region/region.js.map +1 -0
- package/dist/matter/session/session.d.ts +58 -0
- package/dist/matter/session/session.js +112 -0
- package/dist/matter/session/session.js.map +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +101 -0
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -0
- package/dist/matter/shipping-address/shipping-address.d.ts +284 -0
- package/dist/matter/shipping-address/shipping-address.js +1036 -0
- package/dist/matter/shipping-address/shipping-address.js.map +1 -0
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +143 -0
- package/dist/matter/shipping-simulator/shipping-simulator.js +644 -0
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -0
- package/dist/matter/sign-in-form/sign-in-form.d.ts +79 -0
- package/dist/matter/sign-in-form/sign-in-form.js +226 -0
- package/dist/matter/sign-in-form/sign-in-form.js.map +1 -0
- package/dist/matter/variant-selector/variant-selector.d.ts +183 -0
- package/dist/matter/variant-selector/variant-selector.js +840 -0
- package/dist/matter/variant-selector/variant-selector.js.map +1 -0
- package/dist/message-locales.json +7 -0
- package/dist/particles/access-code-field/access-code-field.d.ts +33 -0
- package/dist/particles/access-code-field/access-code-field.js +95 -0
- package/dist/particles/access-code-field/access-code-field.js.map +1 -0
- package/dist/particles/accordion/accordion.d.ts +45 -0
- package/dist/particles/accordion/accordion.js +156 -0
- package/dist/particles/accordion/accordion.js.map +1 -0
- package/dist/particles/address-summary/address-summary.d.ts +50 -0
- package/dist/particles/address-summary/address-summary.js +129 -0
- package/dist/particles/address-summary/address-summary.js.map +1 -0
- package/dist/particles/badge/badge.d.ts +10 -0
- package/dist/particles/badge/badge.js +27 -0
- package/dist/particles/badge/badge.js.map +1 -0
- package/dist/particles/button/button.d.ts +18 -0
- package/dist/particles/button/button.js +37 -0
- package/dist/particles/button/button.js.map +1 -0
- package/dist/particles/carousel/carousel.d.ts +60 -0
- package/dist/particles/carousel/carousel.js +335 -0
- package/dist/particles/carousel/carousel.js.map +1 -0
- package/dist/particles/checkbox/checkbox.d.ts +40 -0
- package/dist/particles/checkbox/checkbox.js +82 -0
- package/dist/particles/checkbox/checkbox.js.map +1 -0
- package/dist/particles/container/container.d.ts +20 -0
- package/dist/particles/container/container.js +36 -0
- package/dist/particles/container/container.js.map +1 -0
- package/dist/particles/dialog/dialog.d.ts +54 -0
- package/dist/particles/dialog/dialog.js +192 -0
- package/dist/particles/dialog/dialog.js.map +1 -0
- package/dist/particles/document-field/document-field.d.ts +61 -0
- package/dist/particles/document-field/document-field.js +146 -0
- package/dist/particles/document-field/document-field.js.map +1 -0
- package/dist/particles/drawer/drawer.d.ts +52 -0
- package/dist/particles/drawer/drawer.js +183 -0
- package/dist/particles/drawer/drawer.js.map +1 -0
- package/dist/particles/email-field/email-field.d.ts +37 -0
- package/dist/particles/email-field/email-field.js +106 -0
- package/dist/particles/email-field/email-field.js.map +1 -0
- package/dist/particles/field/field.d.ts +50 -0
- package/dist/particles/field/field.js +133 -0
- package/dist/particles/field/field.js.map +1 -0
- package/dist/particles/fieldset/fieldset.d.ts +16 -0
- package/dist/particles/fieldset/fieldset.js +52 -0
- package/dist/particles/fieldset/fieldset.js.map +1 -0
- package/dist/particles/footer-copyright/footer-copyright.d.ts +32 -0
- package/dist/particles/footer-copyright/footer-copyright.js +50 -0
- package/dist/particles/footer-copyright/footer-copyright.js.map +1 -0
- package/dist/particles/footer-link-group/footer-link-group.d.ts +66 -0
- package/dist/particles/footer-link-group/footer-link-group.js +154 -0
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -0
- package/dist/particles/footer-root/footer-root.d.ts +21 -0
- package/dist/particles/footer-root/footer-root.js +38 -0
- package/dist/particles/footer-root/footer-root.js.map +1 -0
- package/dist/particles/footer-social/footer-social.d.ts +79 -0
- package/dist/particles/footer-social/footer-social.js +176 -0
- package/dist/particles/footer-social/footer-social.js.map +1 -0
- package/dist/particles/gallery/gallery.d.ts +181 -0
- package/dist/particles/gallery/gallery.js +920 -0
- package/dist/particles/gallery/gallery.js.map +1 -0
- package/dist/particles/header-root/header-root.d.ts +21 -0
- package/dist/particles/header-root/header-root.js +38 -0
- package/dist/particles/header-root/header-root.js.map +1 -0
- package/dist/particles/icon/icon.d.ts +22 -0
- package/dist/particles/icon/icon.js +48 -0
- package/dist/particles/icon/icon.js.map +1 -0
- package/dist/particles/image/image.d.ts +13 -0
- package/dist/particles/image/image.js +59 -0
- package/dist/particles/image/image.js.map +1 -0
- package/dist/particles/incentives/incentives.d.ts +85 -0
- package/dist/particles/incentives/incentives.js +200 -0
- package/dist/particles/incentives/incentives.js.map +1 -0
- package/dist/particles/input/input.d.ts +9 -0
- package/dist/particles/input/input.js +28 -0
- package/dist/particles/input/input.js.map +1 -0
- package/dist/particles/logo/logo.d.ts +55 -0
- package/dist/particles/logo/logo.js +96 -0
- package/dist/particles/logo/logo.js.map +1 -0
- package/dist/particles/menu/menu.d.ts +103 -0
- package/dist/particles/menu/menu.js +409 -0
- package/dist/particles/menu/menu.js.map +1 -0
- package/dist/particles/menubar/menubar.d.ts +18 -0
- package/dist/particles/menubar/menubar.js +42 -0
- package/dist/particles/menubar/menubar.js.map +1 -0
- package/dist/particles/meter/meter.d.ts +36 -0
- package/dist/particles/meter/meter.js +132 -0
- package/dist/particles/meter/meter.js.map +1 -0
- package/dist/particles/navigation-link/navigation-link.d.ts +43 -0
- package/dist/particles/navigation-link/navigation-link.js +82 -0
- package/dist/particles/navigation-link/navigation-link.js.map +1 -0
- package/dist/particles/navigation-link-list/navigation-link-list.d.ts +59 -0
- package/dist/particles/navigation-link-list/navigation-link-list.js +103 -0
- package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -0
- package/dist/particles/navigation-menu/navigation-menu.d.ts +78 -0
- package/dist/particles/navigation-menu/navigation-menu.js +295 -0
- package/dist/particles/navigation-menu/navigation-menu.js.map +1 -0
- package/dist/particles/number-field/number-field.d.ts +46 -0
- package/dist/particles/number-field/number-field.js +169 -0
- package/dist/particles/number-field/number-field.js.map +1 -0
- package/dist/particles/password-field/password-field.d.ts +31 -0
- package/dist/particles/password-field/password-field.js +109 -0
- package/dist/particles/password-field/password-field.js.map +1 -0
- package/dist/particles/payment-methods/payment-methods.d.ts +72 -0
- package/dist/particles/payment-methods/payment-methods.js +151 -0
- package/dist/particles/payment-methods/payment-methods.js.map +1 -0
- package/dist/particles/phone-field/phone-field.d.ts +67 -0
- package/dist/particles/phone-field/phone-field.js +250 -0
- package/dist/particles/phone-field/phone-field.js.map +1 -0
- package/dist/particles/popover/popover.d.ts +68 -0
- package/dist/particles/popover/popover.js +284 -0
- package/dist/particles/popover/popover.js.map +1 -0
- package/dist/particles/postal-code-field/postal-code-field.d.ts +75 -0
- package/dist/particles/postal-code-field/postal-code-field.js +169 -0
- package/dist/particles/postal-code-field/postal-code-field.js.map +1 -0
- package/dist/particles/promotion/promotion.d.ts +46 -0
- package/dist/particles/promotion/promotion.js +78 -0
- package/dist/particles/promotion/promotion.js.map +1 -0
- package/dist/particles/quantity-selector/quantity-selector.d.ts +30 -0
- package/dist/particles/quantity-selector/quantity-selector.js +116 -0
- package/dist/particles/quantity-selector/quantity-selector.js.map +1 -0
- package/dist/particles/radio/radio.d.ts +36 -0
- package/dist/particles/radio/radio.js +76 -0
- package/dist/particles/radio/radio.js.map +1 -0
- package/dist/particles/scroll-area/scroll-area.d.ts +36 -0
- package/dist/particles/scroll-area/scroll-area.js +145 -0
- package/dist/particles/scroll-area/scroll-area.js.map +1 -0
- package/dist/particles/select/select.d.ts +125 -0
- package/dist/particles/select/select.js +478 -0
- package/dist/particles/select/select.js.map +1 -0
- package/dist/particles/separator/separator.d.ts +12 -0
- package/dist/particles/separator/separator.js +33 -0
- package/dist/particles/separator/separator.js.map +1 -0
- package/dist/particles/shared/input-mask.d.ts +5 -0
- package/dist/particles/shared/input-mask.js +58 -0
- package/dist/particles/shared/input-mask.js.map +1 -0
- package/dist/particles/spinner/spinner.d.ts +13 -0
- package/dist/particles/spinner/spinner.js +31 -0
- package/dist/particles/spinner/spinner.js.map +1 -0
- package/dist/particles/switch/switch.d.ts +27 -0
- package/dist/particles/switch/switch.js +59 -0
- package/dist/particles/switch/switch.js.map +1 -0
- package/dist/particles/tabs/tabs.d.ts +45 -0
- package/dist/particles/tabs/tabs.js +164 -0
- package/dist/particles/tabs/tabs.js.map +1 -0
- package/dist/particles/text/text.d.ts +24 -0
- package/dist/particles/text/text.js +40 -0
- package/dist/particles/text/text.js.map +1 -0
- package/dist/particles/toast/toast.d.ts +83 -0
- package/dist/particles/toast/toast.js +194 -0
- package/dist/particles/toast/toast.js.map +1 -0
- package/dist/particles/toggle/toggle.d.ts +26 -0
- package/dist/particles/toggle/toggle.js +61 -0
- package/dist/particles/toggle/toggle.js.map +1 -0
- package/dist/particles/tooltip/tooltip.d.ts +61 -0
- package/dist/particles/tooltip/tooltip.js +240 -0
- package/dist/particles/tooltip/tooltip.js.map +1 -0
- package/dist/schema.graphql +2953 -0
- package/dist/sdk/actions/cart-action-provider.d.ts +19 -0
- package/dist/sdk/actions/cart-action-provider.js +23 -0
- package/dist/sdk/actions/cart-action-provider.js.map +1 -0
- package/dist/sdk/actions/identity-action-provider.d.ts +15 -0
- package/dist/sdk/actions/identity-action-provider.js +19 -0
- package/dist/sdk/actions/identity-action-provider.js.map +1 -0
- package/dist/sdk/actions/index.d.ts +7 -0
- package/dist/sdk/actions/index.js +6 -0
- package/dist/sdk/actions/inject-actions.d.ts +14 -0
- package/dist/sdk/actions/inject-actions.js +36 -0
- package/dist/sdk/actions/inject-actions.js.map +1 -0
- package/dist/sdk/actions/region-action-provider.d.ts +15 -0
- package/dist/sdk/actions/region-action-provider.js +19 -0
- package/dist/sdk/actions/region-action-provider.js.map +1 -0
- package/dist/sdk/actions/session-action-provider.d.ts +15 -0
- package/dist/sdk/actions/session-action-provider.js +19 -0
- package/dist/sdk/actions/session-action-provider.js.map +1 -0
- package/dist/sdk/actions/shipping-action-provider.d.ts +15 -0
- package/dist/sdk/actions/shipping-action-provider.js +19 -0
- package/dist/sdk/actions/shipping-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +21 -0
- package/dist/sdk/cache/storefront-cache.js +35 -0
- package/dist/sdk/cache/storefront-cache.js.map +1 -0
- package/dist/sdk/cart/operations.d.ts +31 -0
- package/dist/sdk/cart/operations.js +215 -0
- package/dist/sdk/cart/operations.js.map +1 -0
- package/dist/sdk/cart/optimistic.d.ts +24 -0
- package/dist/sdk/cart/optimistic.js +164 -0
- package/dist/sdk/cart/optimistic.js.map +1 -0
- package/dist/sdk/cart/use-cart-actions.d.ts +56 -0
- package/dist/sdk/cart/use-cart-actions.js +348 -0
- package/dist/sdk/cart/use-cart-actions.js.map +1 -0
- package/dist/sdk/cart/use-cart-validate-on-open.js +50 -0
- package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -0
- package/dist/sdk/cart/write-gate.js +54 -0
- package/dist/sdk/cart/write-gate.js.map +1 -0
- package/dist/sdk/client/assert-api-url.js +20 -0
- package/dist/sdk/client/assert-api-url.js.map +1 -0
- package/dist/sdk/client/create-client.d.ts +23 -0
- package/dist/sdk/client/create-client.js +46 -0
- package/dist/sdk/client/create-client.js.map +1 -0
- package/dist/sdk/client/fetch-page-data.d.ts +39 -0
- package/dist/sdk/client/fetch-page-data.js +33 -0
- package/dist/sdk/client/fetch-page-data.js.map +1 -0
- package/dist/sdk/client/register-preload-query.d.ts +24 -0
- package/dist/sdk/client/register-preload-query.js +33 -0
- package/dist/sdk/client/register-preload-query.js.map +1 -0
- package/dist/sdk/content/create-content-runtime.d.ts +68 -0
- package/dist/sdk/content/create-content-runtime.js +503 -0
- package/dist/sdk/content/create-content-runtime.js.map +1 -0
- package/dist/sdk/context/headers.d.ts +15 -0
- package/dist/sdk/context/headers.js +21 -0
- package/dist/sdk/context/headers.js.map +1 -0
- package/dist/sdk/context/storefront-context.d.ts +11 -0
- package/dist/sdk/context/storefront-context.js +29 -0
- package/dist/sdk/context/storefront-context.js.map +1 -0
- package/dist/sdk/data/data-override-context.d.ts +12 -0
- package/dist/sdk/data/data-override-context.js +19 -0
- package/dist/sdk/data/data-override-context.js.map +1 -0
- package/dist/sdk/data/entity-subscriber.js +28 -0
- package/dist/sdk/data/entity-subscriber.js.map +1 -0
- package/dist/sdk/data/hot-data-provider.d.ts +19 -0
- package/dist/sdk/data/hot-data-provider.js +33 -0
- package/dist/sdk/data/hot-data-provider.js.map +1 -0
- package/dist/sdk/data/index.d.ts +8 -0
- package/dist/sdk/data/index.js +8 -0
- package/dist/sdk/data/list-item-ref-context.d.ts +20 -0
- package/dist/sdk/data/list-item-ref-context.js +11 -0
- package/dist/sdk/data/list-item-ref-context.js.map +1 -0
- package/dist/sdk/data/multiple-reactive-data-provider.d.ts +32 -0
- package/dist/sdk/data/multiple-reactive-data-provider.js +20 -0
- package/dist/sdk/data/multiple-reactive-data-provider.js.map +1 -0
- package/dist/sdk/data/page-reactive-data-root.d.ts +53 -0
- package/dist/sdk/data/page-reactive-data-root.js +153 -0
- package/dist/sdk/data/page-reactive-data-root.js.map +1 -0
- package/dist/sdk/data/reactive-data-provider.d.ts +25 -0
- package/dist/sdk/data/reactive-data-provider.js +24 -0
- package/dist/sdk/data/reactive-data-provider.js.map +1 -0
- package/dist/sdk/data/reactive-list-item-data-provider.d.ts +26 -0
- package/dist/sdk/data/reactive-list-item-data-provider.js +42 -0
- package/dist/sdk/data/reactive-list-item-data-provider.js.map +1 -0
- package/dist/sdk/data/use-reactive-entity.js +40 -0
- package/dist/sdk/data/use-reactive-entity.js.map +1 -0
- package/dist/sdk/format/client.d.ts +12 -0
- package/dist/sdk/format/client.js +20 -0
- package/dist/sdk/format/client.js.map +1 -0
- package/dist/sdk/format/formatters.d.ts +32 -0
- package/dist/sdk/format/formatters.js +45 -0
- package/dist/sdk/format/formatters.js.map +1 -0
- package/dist/sdk/generated/fragment-types.js +23 -0
- package/dist/sdk/generated/fragment-types.js.map +1 -0
- package/dist/sdk/generated/gql.js +51 -0
- package/dist/sdk/generated/gql.js.map +1 -0
- package/dist/sdk/generated/graphql.d.ts +622 -0
- package/dist/sdk/generated/graphql.js +11917 -0
- package/dist/sdk/generated/graphql.js.map +1 -0
- package/dist/sdk/graphql-tag.d.ts +10 -0
- package/dist/sdk/graphql-tag.js +21 -0
- package/dist/sdk/graphql-tag.js.map +1 -0
- package/dist/sdk/i18n/client.d.ts +4 -0
- package/dist/sdk/i18n/client.js +4 -0
- package/dist/sdk/i18n/locales.d.ts +8 -0
- package/dist/sdk/i18n/locales.js +57 -0
- package/dist/sdk/i18n/locales.js.map +1 -0
- package/dist/sdk/i18n/messages/en-US.js +24 -0
- package/dist/sdk/i18n/messages/en-US.js.map +1 -0
- package/dist/sdk/i18n/messages/en-US.json +19 -0
- package/dist/sdk/i18n/messages/en-US.json.d.ts +23 -0
- package/dist/sdk/i18n/messages/es-ES.js +24 -0
- package/dist/sdk/i18n/messages/es-ES.js.map +1 -0
- package/dist/sdk/i18n/messages/es-ES.json +19 -0
- package/dist/sdk/i18n/messages/pt-BR.js +24 -0
- package/dist/sdk/i18n/messages/pt-BR.js.map +1 -0
- package/dist/sdk/i18n/messages/pt-BR.json +19 -0
- package/dist/sdk/i18n/provider.d.ts +1 -0
- package/dist/sdk/i18n/provider.js +30 -0
- package/dist/sdk/i18n/provider.js.map +1 -0
- package/dist/sdk/i18n/server.d.ts +28 -0
- package/dist/sdk/i18n/server.js +59 -0
- package/dist/sdk/i18n/server.js.map +1 -0
- package/dist/sdk/identity/operations.d.ts +34 -0
- package/dist/sdk/identity/operations.js +78 -0
- package/dist/sdk/identity/operations.js.map +1 -0
- package/dist/sdk/identity/use-identity-actions.d.ts +62 -0
- package/dist/sdk/identity/use-identity-actions.js +180 -0
- package/dist/sdk/identity/use-identity-actions.js.map +1 -0
- package/dist/sdk/provider/index.d.ts +2 -0
- package/dist/sdk/provider/index.js +2 -0
- package/dist/sdk/provider/storefront-provider.d.ts +32 -0
- package/dist/sdk/provider/storefront-provider.js +111 -0
- package/dist/sdk/provider/storefront-provider.js.map +1 -0
- package/dist/sdk/region/operations.d.ts +6 -0
- package/dist/sdk/region/region-operations.d.ts +30 -0
- package/dist/sdk/region/region-operations.js +23 -0
- package/dist/sdk/region/region-operations.js.map +1 -0
- package/dist/sdk/region/use-region-actions.d.ts +23 -0
- package/dist/sdk/region/use-region-actions.js +66 -0
- package/dist/sdk/region/use-region-actions.js.map +1 -0
- package/dist/sdk/seller.js +11 -0
- package/dist/sdk/seller.js.map +1 -0
- package/dist/sdk/session/auth-operations.d.ts +47 -0
- package/dist/sdk/session/auth-operations.js +79 -0
- package/dist/sdk/session/auth-operations.js.map +1 -0
- package/dist/sdk/session/operations.d.ts +6 -0
- package/dist/sdk/session/use-session-actions.d.ts +27 -0
- package/dist/sdk/session/use-session-actions.js +126 -0
- package/dist/sdk/session/use-session-actions.js.map +1 -0
- package/dist/sdk/shipping/cart-operations.d.ts +3 -0
- package/dist/sdk/shipping/cart-operations.js +33 -0
- package/dist/sdk/shipping/cart-operations.js.map +1 -0
- package/dist/sdk/shipping/operations.d.ts +3 -0
- package/dist/sdk/shipping/operations.js +33 -0
- package/dist/sdk/shipping/operations.js.map +1 -0
- package/dist/sdk/shipping/option-select-operations.d.ts +24 -0
- package/dist/sdk/shipping/option-select-operations.js +45 -0
- package/dist/sdk/shipping/option-select-operations.js.map +1 -0
- package/dist/sdk/shipping/request-timeout.js +41 -0
- package/dist/sdk/shipping/request-timeout.js.map +1 -0
- package/dist/sdk/shipping/shipping-operations.d.ts +38 -0
- package/dist/sdk/shipping/shipping-operations.js +77 -0
- package/dist/sdk/shipping/shipping-operations.js.map +1 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.d.ts +7 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.js +72 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -0
- package/dist/sdk/shipping/use-shipping-actions.d.ts +27 -0
- package/dist/sdk/shipping/use-shipping-actions.js +113 -0
- package/dist/sdk/shipping/use-shipping-actions.js.map +1 -0
- package/dist/sdk/shipping/use-shipping-simulation.d.ts +7 -0
- package/dist/sdk/shipping/use-shipping-simulation.js +72 -0
- package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -0
- package/dist/sdk/state/cart.d.ts +42 -0
- package/dist/sdk/state/cart.js +64 -0
- package/dist/sdk/state/cart.js.map +1 -0
- package/dist/sdk/state/index.js +3 -0
- package/dist/sdk/state/variant-selector.d.ts +17 -0
- package/dist/sdk/state/variant-selector.js +14 -0
- package/dist/sdk/state/variant-selector.js.map +1 -0
- package/dist/utils/safe-href.js +63 -0
- package/dist/utils/safe-href.js.map +1 -0
- package/package.json +84 -0
- package/src/styles/tailwind.css +32 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/sdk/context/storefront-context.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Private, so the only read is `useStorefrontContext` — which can tell an unprovided tree from a
|
|
7
|
+
* provided one instead of silently handing out a default locale.
|
|
8
|
+
*/
|
|
9
|
+
const Context = createContext(null);
|
|
10
|
+
/** Publishes the context the generated app handed `StorefrontProvider` to the Client tree. */
|
|
11
|
+
function StorefrontContextProvider({ context, children }) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
13
|
+
value: context,
|
|
14
|
+
children
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The active storefront context: locale, currency, sales channel, country, timezone, and text
|
|
19
|
+
* direction. Throws outside a `StorefrontProvider` that received a `context`.
|
|
20
|
+
*/
|
|
21
|
+
function useStorefrontContext() {
|
|
22
|
+
const context = useContext(Context);
|
|
23
|
+
if (!context) throw new Error("useStorefrontContext: no storefront context in this tree. Render under a `StorefrontProvider` that receives a `context` prop — the generated app passes the `storefrontContext` constant from `src/utils/storefront-context.ts`.");
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { StorefrontContextProvider, useStorefrontContext };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=storefront-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storefront-context.js","names":[],"sources":["../../../src/sdk/context/storefront-context.tsx"],"sourcesContent":["'use client';\n\nimport type { StorefrontContext } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext } from 'react';\n\nexport type StorefrontContextProviderProps = Readonly<{\n /** `null` when the app declared no context, which makes every read throw rather than default. */\n context: StorefrontContext | null;\n children: ReactNode;\n}>;\n\n/**\n * Private, so the only read is `useStorefrontContext` — which can tell an unprovided tree from a\n * provided one instead of silently handing out a default locale.\n */\nconst Context = createContext<StorefrontContext | null>(null);\n\n/** Publishes the context the generated app handed `StorefrontProvider` to the Client tree. */\nexport function StorefrontContextProvider({ context, children }: StorefrontContextProviderProps) {\n return <Context.Provider value={context}>{children}</Context.Provider>;\n}\n\n/**\n * The active storefront context: locale, currency, sales channel, country, timezone, and text\n * direction. Throws outside a `StorefrontProvider` that received a `context`.\n */\nexport function useStorefrontContext(): StorefrontContext {\n const context = useContext(Context);\n if (!context) {\n throw new Error(\n 'useStorefrontContext: no storefront context in this tree. Render under a ' +\n '`StorefrontProvider` that receives a `context` prop — the generated app passes the ' +\n '`storefrontContext` constant from `src/utils/storefront-context.ts`.',\n );\n }\n return context;\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,UAAU,cAAwC,IAAI;;AAG5D,SAAgB,0BAA0B,EAAE,SAAS,YAA4C;CAC/F,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAU;CAA2B,CAAA;AACvE;;;;;AAMA,SAAgB,uBAA0C;CACxD,MAAM,UAAU,WAAW,OAAO;CAClC,IAAI,CAAC,SACH,MAAM,IAAI,MACR,kOAGF;CAEF,OAAO;AACT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/sdk/data/data-override-context.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Context used by HotDataProvider, ReactiveDataProvider, and ReactiveListItemDataProvider to inject
|
|
4
|
+
* resolved `$data` into descendant data-root components without cloneElement — which breaks in
|
|
5
|
+
* React 19 RSC because children cross the flight boundary as lazy elements that isValidElement /
|
|
6
|
+
* cloneElement cannot handle. This is also why a `reactive-list-item` element is emitted with no
|
|
7
|
+
* `$data` prop: the per-line slice arrives here through the iteration context, never as a prop.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DataOverrideContext: import("react").Context<unknown>;
|
|
10
|
+
export declare function useDataOverride<T>($data: T): T;
|
|
11
|
+
//#endregion
|
|
12
|
+
//# sourceMappingURL=data-override-context.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
//#region src/sdk/data/data-override-context.ts
|
|
4
|
+
/**
|
|
5
|
+
* Context used by HotDataProvider, ReactiveDataProvider, and ReactiveListItemDataProvider to inject
|
|
6
|
+
* resolved `$data` into descendant data-root components without cloneElement — which breaks in
|
|
7
|
+
* React 19 RSC because children cross the flight boundary as lazy elements that isValidElement /
|
|
8
|
+
* cloneElement cannot handle. This is also why a `reactive-list-item` element is emitted with no
|
|
9
|
+
* `$data` prop: the per-line slice arrives here through the iteration context, never as a prop.
|
|
10
|
+
*/
|
|
11
|
+
const DataOverrideContext = createContext(void 0);
|
|
12
|
+
function useDataOverride($data) {
|
|
13
|
+
const override = useContext(DataOverrideContext);
|
|
14
|
+
return override === void 0 ? $data : override;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { DataOverrideContext, useDataOverride };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=data-override-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-override-context.js","names":[],"sources":["../../../src/sdk/data/data-override-context.ts"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\n\n/**\n * Context used by HotDataProvider, ReactiveDataProvider, and ReactiveListItemDataProvider to inject\n * resolved `$data` into descendant data-root components without cloneElement — which breaks in\n * React 19 RSC because children cross the flight boundary as lazy elements that isValidElement /\n * cloneElement cannot handle. This is also why a `reactive-list-item` element is emitted with no\n * `$data` prop: the per-line slice arrives here through the iteration context, never as a prop.\n */\nexport const DataOverrideContext = createContext<unknown>(undefined);\n\nexport function useDataOverride<T>($data: T): T {\n const override = useContext(DataOverrideContext);\n return (override === undefined ? $data : override) as T;\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAa,sBAAsB,cAAuB,KAAA,CAAS;AAEnE,SAAgB,gBAAmB,OAAa;CAC9C,MAAM,WAAW,WAAW,mBAAmB;CAC/C,OAAQ,aAAa,KAAA,IAAY,QAAQ;AAC3C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DataOverrideContext } from "./data-override-context.js";
|
|
3
|
+
import { useReactiveEntity } from "./use-reactive-entity.js";
|
|
4
|
+
import { useContext } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/sdk/data/entity-subscriber.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Per-entity subscriber used internally by `MultipleReactiveDataProvider` to compose several
|
|
9
|
+
* entities' cache slices into one keyed `$data` object for a single component. Resolves its own
|
|
10
|
+
* slice exactly like `ReactiveDataProvider` (see `useReactiveEntity`), then merges it under
|
|
11
|
+
* `rootField` into the outer `DataOverrideContext` value.
|
|
12
|
+
*/
|
|
13
|
+
function EntitySubscriber({ entityFragment, fragmentName, rootField, fallbackData, reset, children }) {
|
|
14
|
+
const outer = useContext(DataOverrideContext);
|
|
15
|
+
const resolved = useReactiveEntity(entityFragment, fragmentName, rootField, fallbackData);
|
|
16
|
+
const value = reset ? { [rootField]: resolved } : {
|
|
17
|
+
...outer && typeof outer === "object" ? outer : {},
|
|
18
|
+
[rootField]: resolved
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsx(DataOverrideContext, {
|
|
21
|
+
value,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { EntitySubscriber };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=entity-subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-subscriber.js","names":[],"sources":["../../../src/sdk/data/entity-subscriber.tsx"],"sourcesContent":["'use client';\n\nimport type { DocumentNode } from '@apollo/client';\nimport type { ReactNode } from 'react';\nimport { useContext } from 'react';\nimport { DataOverrideContext } from './data-override-context.js';\nimport { useReactiveEntity } from './use-reactive-entity.js';\n\nexport type EntitySubscriberProps = Readonly<{\n /** Derived `fragment <X>_<EntityType> on <EntityType>` document emitted by the compiler. */\n entityFragment: DocumentNode;\n /** Name of the derived fragment, passed to `useFragment`. */\n fragmentName: string;\n /** Top-level field of the page query (e.g. 'cart') used to extract the entity ref, and the key\n * under which the resolved slice is merged into the composed `$data` object. */\n rootField: string;\n /** Server-rendered fragment payload; used until the cache resolves a complete entity slice. */\n fallbackData: unknown;\n /**\n * When `true`, RESETS the context to `{ [rootField]: resolved }`, discarding any outer\n * `DataOverrideContext` value — this is the outermost subscriber of a component's nested stack,\n * and prevents a parent component's `$data` from leaking into this component's descendants. When\n * `false`, merges this subscriber's slice into the SAME-stack outer value instead.\n */\n reset: boolean;\n children: ReactNode;\n}>;\n\n/**\n * Per-entity subscriber used internally by `MultipleReactiveDataProvider` to compose several\n * entities' cache slices into one keyed `$data` object for a single component. Resolves its own\n * slice exactly like `ReactiveDataProvider` (see `useReactiveEntity`), then merges it under\n * `rootField` into the outer `DataOverrideContext` value.\n */\nexport function EntitySubscriber({\n entityFragment,\n fragmentName,\n rootField,\n fallbackData,\n reset,\n children,\n}: EntitySubscriberProps): ReactNode {\n const outer = useContext(DataOverrideContext);\n const resolved = useReactiveEntity(entityFragment, fragmentName, rootField, fallbackData);\n\n const value = reset\n ? { [rootField]: resolved }\n : { ...(outer && typeof outer === 'object' ? outer : {}), [rootField]: resolved };\n\n return <DataOverrideContext value={value}>{children}</DataOverrideContext>;\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgB,iBAAiB,EAC/B,gBACA,cACA,WACA,cACA,OACA,YACmC;CACnC,MAAM,QAAQ,WAAW,mBAAmB;CAC5C,MAAM,WAAW,kBAAkB,gBAAgB,cAAc,WAAW,YAAY;CAExF,MAAM,QAAQ,QACV,GAAG,YAAY,SAAS,IACxB;EAAE,GAAI,SAAS,OAAO,UAAU,WAAW,QAAQ,CAAC;GAAK,YAAY;CAAS;CAElF,OAAO,oBAAC,qBAAD;EAA4B;EAAQ;CAA8B,CAAA;AAC3E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { OperationVariables, TypedDocumentNode } from "@apollo/client";
|
|
3
|
+
//#region src/sdk/data/hot-data-provider.d.ts
|
|
4
|
+
export type HotDataProviderProps<TData, TVariables extends OperationVariables> = Readonly<{
|
|
5
|
+
query: TypedDocumentNode<TData, TVariables>;
|
|
6
|
+
variables: TVariables;
|
|
7
|
+
/** Top-level field of the fragment to forward as `$data`. */
|
|
8
|
+
field: string;
|
|
9
|
+
/**
|
|
10
|
+
* Server-rendered value from the composed PAGE_QUERY result. It paints the first frame — `useQuery`
|
|
11
|
+
* issues no request during SSR and the client cache is empty at hydration — and stays on screen on
|
|
12
|
+
* error or a null payload.
|
|
13
|
+
*/
|
|
14
|
+
fallbackData: unknown;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function HotDataProvider<TData, TVariables extends OperationVariables>({ query, variables, field, fallbackData, children }: HotDataProviderProps<TData, TVariables>): ReactNode;
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=hot-data-provider.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DataOverrideContext } from "./data-override-context.js";
|
|
3
|
+
import { useQuery } from "@apollo/client/react";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/sdk/data/hot-data-provider.tsx
|
|
7
|
+
function HotDataProvider({ query, variables, field, fallbackData, children }) {
|
|
8
|
+
const { data, error } = useQuery(query, {
|
|
9
|
+
variables,
|
|
10
|
+
errorPolicy: "all",
|
|
11
|
+
fetchPolicy: "cache-and-network"
|
|
12
|
+
});
|
|
13
|
+
const errorLoggedRef = useRef(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (error && !errorLoggedRef.current) {
|
|
16
|
+
errorLoggedRef.current = true;
|
|
17
|
+
console.error("[HotDataProvider] lazy fetch failed; falling back to composed page data.", error);
|
|
18
|
+
}
|
|
19
|
+
}, [error]);
|
|
20
|
+
let resolved = fallbackData;
|
|
21
|
+
if (!error && data != null) {
|
|
22
|
+
const fieldValue = data[field];
|
|
23
|
+
if (fieldValue != null) resolved = fieldValue;
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsx(DataOverrideContext, {
|
|
26
|
+
value: resolved,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { HotDataProvider };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=hot-data-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hot-data-provider.js","names":[],"sources":["../../../src/sdk/data/hot-data-provider.tsx"],"sourcesContent":["'use client';\n\nimport type { OperationVariables, TypedDocumentNode } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef } from 'react';\nimport { DataOverrideContext } from './data-override-context.js';\n\nexport type HotDataProviderProps<TData, TVariables extends OperationVariables> = Readonly<{\n query: TypedDocumentNode<TData, TVariables>;\n variables: TVariables;\n /** Top-level field of the fragment to forward as `$data`. */\n field: string;\n /**\n * Server-rendered value from the composed PAGE_QUERY result. It paints the first frame — `useQuery`\n * issues no request during SSR and the client cache is empty at hydration — and stays on screen on\n * error or a null payload.\n */\n fallbackData: unknown;\n children: ReactNode;\n}>;\n\nexport function HotDataProvider<TData, TVariables extends OperationVariables>({\n query,\n variables,\n field,\n fallbackData,\n children,\n}: HotDataProviderProps<TData, TVariables>): ReactNode {\n // Non-suspending, so the element never becomes a boundary and the route stays one contiguous\n // response. `cache-and-network` rather than `cache-first`: on a repeat client-side navigation the\n // cache is warm and the whole point of a hot field is that it refreshes anyway.\n const { data, error } = useQuery(query, {\n variables,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n\n const errorLoggedRef = useRef(false);\n useEffect(() => {\n if (error && !errorLoggedRef.current) {\n errorLoggedRef.current = true;\n console.error('[HotDataProvider] lazy fetch failed; falling back to composed page data.', error);\n }\n }, [error]);\n\n let resolved: unknown = fallbackData;\n if (!error && data != null) {\n const fieldValue = (data as Record<string, unknown>)[field];\n if (fieldValue != null) {\n resolved = fieldValue;\n }\n }\n\n return <DataOverrideContext value={resolved}>{children}</DataOverrideContext>;\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,gBAA8D,EAC5E,OACA,WACA,OACA,cACA,YACqD;CAIrD,MAAM,EAAE,MAAM,UAAU,SAAS,OAAO;EACtC;EACA,aAAa;EACb,aAAa;CACf,CAAC;CAED,MAAM,iBAAiB,OAAO,KAAK;CACnC,gBAAgB;EACd,IAAI,SAAS,CAAC,eAAe,SAAS;GACpC,eAAe,UAAU;GACzB,QAAQ,MAAM,4EAA4E,KAAK;EACjG;CACF,GAAG,CAAC,KAAK,CAAC;CAEV,IAAI,WAAoB;CACxB,IAAI,CAAC,SAAS,QAAQ,MAAM;EAC1B,MAAM,aAAc,KAAiC;EACrD,IAAI,cAAc,MAChB,WAAW;CAEf;CAEA,OAAO,oBAAC,qBAAD;EAAqB,OAAO;EAAW;CAA8B,CAAA;AAC9E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataOverrideContext, useDataOverride } from "./data-override-context.js";
|
|
2
|
+
import { HotDataProvider, HotDataProviderProps } from "./hot-data-provider.js";
|
|
3
|
+
import { ListItemRef, ListItemRefContext, useListItemRef } from "./list-item-ref-context.js";
|
|
4
|
+
import { MultipleReactiveDataProvider, MultipleReactiveDataProviderEntity, MultipleReactiveDataProviderProps } from "./multiple-reactive-data-provider.js";
|
|
5
|
+
import { ClientVariablesMap, PageReactiveDataRoot, PageReactiveDataRootProps, ReactiveRootContext, ReactiveRootContextValue } from "./page-reactive-data-root.js";
|
|
6
|
+
import { ReactiveDataProvider, ReactiveDataProviderProps } from "./reactive-data-provider.js";
|
|
7
|
+
import { ReactiveListItemDataProvider, ReactiveListItemDataProviderProps } from "./reactive-list-item-data-provider.js";
|
|
8
|
+
export { type ClientVariablesMap, DataOverrideContext, HotDataProvider, type HotDataProviderProps, type ListItemRef, ListItemRefContext, MultipleReactiveDataProvider, type MultipleReactiveDataProviderEntity, type MultipleReactiveDataProviderProps, PageReactiveDataRoot, type PageReactiveDataRootProps, ReactiveDataProvider, type ReactiveDataProviderProps, ReactiveListItemDataProvider, type ReactiveListItemDataProviderProps, ReactiveRootContext, type ReactiveRootContextValue, useDataOverride, useListItemRef };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataOverrideContext, useDataOverride } from "./data-override-context.js";
|
|
2
|
+
import { HotDataProvider } from "./hot-data-provider.js";
|
|
3
|
+
import { ListItemRefContext, useListItemRef } from "./list-item-ref-context.js";
|
|
4
|
+
import { PageReactiveDataRoot, ReactiveRootContext } from "./page-reactive-data-root.js";
|
|
5
|
+
import { MultipleReactiveDataProvider } from "./multiple-reactive-data-provider.js";
|
|
6
|
+
import { ReactiveDataProvider } from "./reactive-data-provider.js";
|
|
7
|
+
import { ReactiveListItemDataProvider } from "./reactive-list-item-data-provider.js";
|
|
8
|
+
export { DataOverrideContext, HotDataProvider, ListItemRefContext, MultipleReactiveDataProvider, PageReactiveDataRoot, ReactiveDataProvider, ReactiveListItemDataProvider, ReactiveRootContext, useDataOverride, useListItemRef };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/sdk/data/list-item-ref-context.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Per-iterated-line entity ref published by an iterator (e.g. `CartList`) so a
|
|
4
|
+
* `<ReactiveListItemDataProvider>` rendered inside the iteration can subscribe to that one line's
|
|
5
|
+
* normalized cache entity. It carries the addressing tuple (`__typename` + `id`) and the
|
|
6
|
+
* server-rendered slice used as fallback until the cache slice is complete.
|
|
7
|
+
*
|
|
8
|
+
* This is the generic, SDK-owned seam the per-item provider reads: the iterator depends on the SDK
|
|
9
|
+
* (not the reverse), so a cart-specific context never has to be imported into `sdk/data`.
|
|
10
|
+
*/
|
|
11
|
+
export type ListItemRef = {
|
|
12
|
+
__typename: string;
|
|
13
|
+
id: string | number;
|
|
14
|
+
/** Server-rendered slice for this line; the provider falls back to it until the cache is complete. */
|
|
15
|
+
fallbackData: unknown;
|
|
16
|
+
};
|
|
17
|
+
export declare const ListItemRefContext: import("react").Context<ListItemRef | undefined>;
|
|
18
|
+
export declare function useListItemRef(): ListItemRef | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
//# sourceMappingURL=list-item-ref-context.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
//#region src/sdk/data/list-item-ref-context.tsx
|
|
4
|
+
const ListItemRefContext = createContext(void 0);
|
|
5
|
+
function useListItemRef() {
|
|
6
|
+
return useContext(ListItemRefContext);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ListItemRefContext, useListItemRef };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=list-item-ref-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-item-ref-context.js","names":[],"sources":["../../../src/sdk/data/list-item-ref-context.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\n\n/**\n * Per-iterated-line entity ref published by an iterator (e.g. `CartList`) so a\n * `<ReactiveListItemDataProvider>` rendered inside the iteration can subscribe to that one line's\n * normalized cache entity. It carries the addressing tuple (`__typename` + `id`) and the\n * server-rendered slice used as fallback until the cache slice is complete.\n *\n * This is the generic, SDK-owned seam the per-item provider reads: the iterator depends on the SDK\n * (not the reverse), so a cart-specific context never has to be imported into `sdk/data`.\n */\nexport type ListItemRef = {\n __typename: string;\n id: string | number;\n /** Server-rendered slice for this line; the provider falls back to it until the cache is complete. */\n fallbackData: unknown;\n};\n\nexport const ListItemRefContext = createContext<ListItemRef | undefined>(undefined);\n\nexport function useListItemRef(): ListItemRef | undefined {\n return useContext(ListItemRefContext);\n}\n"],"mappings":";;;AAoBA,MAAa,qBAAqB,cAAuC,KAAA,CAAS;AAElF,SAAgB,iBAA0C;CACxD,OAAO,WAAW,kBAAkB;AACtC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { DocumentNode } from "@apollo/client";
|
|
3
|
+
//#region src/sdk/data/multiple-reactive-data-provider.d.ts
|
|
4
|
+
export type MultipleReactiveDataProviderEntity = Readonly<{
|
|
5
|
+
/** Derived `fragment <X>_<EntityType> on <EntityType>` document emitted by the compiler. */
|
|
6
|
+
entityFragment: DocumentNode;
|
|
7
|
+
/** Name of the derived fragment, passed to `useFragment`. */
|
|
8
|
+
fragmentName: string;
|
|
9
|
+
/** Top-level field of the page query (e.g. 'cart') used to extract the entity ref, and the key
|
|
10
|
+
* under which the resolved slice is merged into the composed `$data` object. */
|
|
11
|
+
rootField: string;
|
|
12
|
+
/** Server-rendered fragment payload; used until the cache resolves a complete entity slice. */
|
|
13
|
+
fallbackData: unknown;
|
|
14
|
+
}>;
|
|
15
|
+
export type MultipleReactiveDataProviderProps = Readonly<{
|
|
16
|
+
/**
|
|
17
|
+
* Entities consumed by a single component, each contributing a keyed slice to the composed
|
|
18
|
+
* `$data` object. `entities[0]` is treated as the outermost subscriber — it resets the
|
|
19
|
+
* `DataOverrideContext` so an ancestor component's `$data` never leaks in — and each subsequent
|
|
20
|
+
* entity nests inside it, merging its slice under its own `rootField`.
|
|
21
|
+
*/
|
|
22
|
+
entities: readonly MultipleReactiveDataProviderEntity[];
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Composes multiple entity subscriptions into a single keyed `$data` object for one component
|
|
27
|
+
* (AD-4 / AD-D2 multi-entity case), by nesting an `EntitySubscriber` per entity via `reduceRight`.
|
|
28
|
+
* Calls no hooks itself — all cache reads happen in the nested `EntitySubscriber`s.
|
|
29
|
+
*/
|
|
30
|
+
export declare function MultipleReactiveDataProvider({ entities, children }: MultipleReactiveDataProviderProps): ReactNode;
|
|
31
|
+
//#endregion
|
|
32
|
+
//# sourceMappingURL=multiple-reactive-data-provider.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EntitySubscriber } from "./entity-subscriber.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/sdk/data/multiple-reactive-data-provider.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Composes multiple entity subscriptions into a single keyed `$data` object for one component
|
|
7
|
+
* (AD-4 / AD-D2 multi-entity case), by nesting an `EntitySubscriber` per entity via `reduceRight`.
|
|
8
|
+
* Calls no hooks itself — all cache reads happen in the nested `EntitySubscriber`s.
|
|
9
|
+
*/
|
|
10
|
+
function MultipleReactiveDataProvider({ entities, children }) {
|
|
11
|
+
return entities.reduceRight((inner, entity, index) => /* @__PURE__ */ jsx(EntitySubscriber, {
|
|
12
|
+
...entity,
|
|
13
|
+
reset: index === 0,
|
|
14
|
+
children: inner
|
|
15
|
+
}, entity.rootField), children);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { MultipleReactiveDataProvider };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=multiple-reactive-data-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiple-reactive-data-provider.js","names":[],"sources":["../../../src/sdk/data/multiple-reactive-data-provider.tsx"],"sourcesContent":["'use client';\n\nimport type { DocumentNode } from '@apollo/client';\nimport type { ReactNode } from 'react';\nimport { EntitySubscriber } from './entity-subscriber.js';\n\nexport type MultipleReactiveDataProviderEntity = Readonly<{\n /** Derived `fragment <X>_<EntityType> on <EntityType>` document emitted by the compiler. */\n entityFragment: DocumentNode;\n /** Name of the derived fragment, passed to `useFragment`. */\n fragmentName: string;\n /** Top-level field of the page query (e.g. 'cart') used to extract the entity ref, and the key\n * under which the resolved slice is merged into the composed `$data` object. */\n rootField: string;\n /** Server-rendered fragment payload; used until the cache resolves a complete entity slice. */\n fallbackData: unknown;\n}>;\n\nexport type MultipleReactiveDataProviderProps = Readonly<{\n /**\n * Entities consumed by a single component, each contributing a keyed slice to the composed\n * `$data` object. `entities[0]` is treated as the outermost subscriber — it resets the\n * `DataOverrideContext` so an ancestor component's `$data` never leaks in — and each subsequent\n * entity nests inside it, merging its slice under its own `rootField`.\n */\n entities: readonly MultipleReactiveDataProviderEntity[];\n children: ReactNode;\n}>;\n\n/**\n * Composes multiple entity subscriptions into a single keyed `$data` object for one component\n * (AD-4 / AD-D2 multi-entity case), by nesting an `EntitySubscriber` per entity via `reduceRight`.\n * Calls no hooks itself — all cache reads happen in the nested `EntitySubscriber`s.\n */\nexport function MultipleReactiveDataProvider({ entities, children }: MultipleReactiveDataProviderProps): ReactNode {\n return entities.reduceRight<ReactNode>(\n (inner, entity, index) => (\n <EntitySubscriber key={entity.rootField} {...entity} reset={index === 0}>\n {inner}\n </EntitySubscriber>\n ),\n children,\n );\n}\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,6BAA6B,EAAE,UAAU,YAA0D;CACjH,OAAO,SAAS,aACb,OAAO,QAAQ,UACd,oBAAC,kBAAD;EAAyC,GAAI;EAAQ,OAAO,UAAU;EACnE,UAAA;CACe,GAFK,OAAO,SAEZ,GAEpB,QACF;AACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ErrorLike, OperationVariables, ReactiveVar, TypedDocumentNode } from "@apollo/client";
|
|
3
|
+
//#region src/sdk/data/page-reactive-data-root.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Compile-time-stable map keyed by the operation's variable names. Each value is either an Apollo
|
|
6
|
+
* reactive variable (`makeVar`) or the string name of one registered in REACTIVE_VAR_REGISTRY —
|
|
7
|
+
* Server Components must pass strings because functions cannot cross the RSC boundary. Vars that
|
|
8
|
+
* have not yet resolved should hold `null`; the runtime treats both `null` and `undefined` as
|
|
9
|
+
* "not yet ready" and keeps `useQuery` skipped.
|
|
10
|
+
*/
|
|
11
|
+
export type ClientVariablesMap<TVars> = Partial<{ [K in keyof TVars]: ReactiveVar<TVars[K] | null> | string; }>;
|
|
12
|
+
export type PageReactiveDataRootProps<TData, TVars extends OperationVariables> = Readonly<{
|
|
13
|
+
/** The composed PAGE_QUERY operation document. */
|
|
14
|
+
query: TypedDocumentNode<TData, TVars>;
|
|
15
|
+
/** Variables the server used when calling fetchPageData. Only used to seed the client cache. */
|
|
16
|
+
serverVariables?: TVars;
|
|
17
|
+
/** Server-rendered PAGE_QUERY result. When present and shape-matched, seeded into the cache once. */
|
|
18
|
+
initialData?: TData | null;
|
|
19
|
+
/** Reactive vars whose current values are merged into operation variables at render time. */
|
|
20
|
+
clientVariables?: ClientVariablesMap<TVars>;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}>;
|
|
23
|
+
export type ReactiveRootContextValue<TData = unknown> = Readonly<{
|
|
24
|
+
/** Current root query data exposed to descendant `ReactiveDataProvider`s. */
|
|
25
|
+
rootQueryData: TData | undefined;
|
|
26
|
+
/** Whether the underlying useQuery is currently in flight. */
|
|
27
|
+
loading: boolean;
|
|
28
|
+
/** False when at least one required variable has not been provided yet. */
|
|
29
|
+
hasAllRequiredVariables: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Error from the underlying useQuery. With non-null root fields (e.g. `cart: Cart!`), a failed
|
|
32
|
+
* fetch nulls the whole operation's `data` — descendants need this to tell "fetch failed" apart
|
|
33
|
+
* from "entity is legitimately absent" (specs/cart-context-client-migrate.md US-5).
|
|
34
|
+
*/
|
|
35
|
+
error: ErrorLike | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const ReactiveRootContext: import("react").Context<Readonly<{
|
|
38
|
+
/** Current root query data exposed to descendant `ReactiveDataProvider`s. */
|
|
39
|
+
rootQueryData: unknown;
|
|
40
|
+
/** Whether the underlying useQuery is currently in flight. */
|
|
41
|
+
loading: boolean;
|
|
42
|
+
/** False when at least one required variable has not been provided yet. */
|
|
43
|
+
hasAllRequiredVariables: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Error from the underlying useQuery. With non-null root fields (e.g. `cart: Cart!`), a failed
|
|
46
|
+
* fetch nulls the whole operation's `data` — descendants need this to tell "fetch failed" apart
|
|
47
|
+
* from "entity is legitimately absent" (specs/cart-context-client-migrate.md US-5).
|
|
48
|
+
*/
|
|
49
|
+
error: ErrorLike | undefined;
|
|
50
|
+
}>>;
|
|
51
|
+
export declare function PageReactiveDataRoot<TData = unknown, TVars extends OperationVariables = OperationVariables>(props: PageReactiveDataRootProps<TData, TVars>): ReactNode;
|
|
52
|
+
//#endregion
|
|
53
|
+
//# sourceMappingURL=page-reactive-data-root.d.ts.map
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useApolloClient, useQuery } from "@apollo/client/react";
|
|
3
|
+
import { createContext, useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Kind } from "graphql";
|
|
6
|
+
//#region src/sdk/data/page-reactive-data-root.tsx
|
|
7
|
+
const REACTIVE_VAR_REGISTRY = {};
|
|
8
|
+
function resolveReactiveVar(value) {
|
|
9
|
+
if (typeof value === "function") return value;
|
|
10
|
+
const resolved = REACTIVE_VAR_REGISTRY[value];
|
|
11
|
+
if (!resolved) throw new Error(`PageReactiveDataRoot: clientVariables entry "${value}" is not registered. Add it to REACTIVE_VAR_REGISTRY in page-reactive-data-root.tsx.`);
|
|
12
|
+
return resolved;
|
|
13
|
+
}
|
|
14
|
+
const ReactiveRootContext = createContext({
|
|
15
|
+
rootQueryData: void 0,
|
|
16
|
+
loading: false,
|
|
17
|
+
hasAllRequiredVariables: false,
|
|
18
|
+
error: void 0
|
|
19
|
+
});
|
|
20
|
+
function getOperationDefinition(query) {
|
|
21
|
+
for (const definition of query.definitions) if (definition.kind === Kind.OPERATION_DEFINITION) return definition;
|
|
22
|
+
}
|
|
23
|
+
function getRequiredVariableNames(query) {
|
|
24
|
+
const op = getOperationDefinition(query);
|
|
25
|
+
if (!op?.variableDefinitions) return [];
|
|
26
|
+
const required = [];
|
|
27
|
+
for (const def of op.variableDefinitions) if (def.type.kind === Kind.NON_NULL_TYPE && def.defaultValue === void 0) required.push(def.variable.name.value);
|
|
28
|
+
return required;
|
|
29
|
+
}
|
|
30
|
+
function getTopLevelFieldNames(query) {
|
|
31
|
+
const op = getOperationDefinition(query);
|
|
32
|
+
const names = /* @__PURE__ */ new Set();
|
|
33
|
+
if (!op) return names;
|
|
34
|
+
for (const sel of op.selectionSet.selections) if (sel.kind === Kind.FIELD) names.add((sel.alias ?? sel.name).value);
|
|
35
|
+
return names;
|
|
36
|
+
}
|
|
37
|
+
function shapeMatches(query, data) {
|
|
38
|
+
if (data == null || typeof data !== "object") return false;
|
|
39
|
+
const expected = getTopLevelFieldNames(query);
|
|
40
|
+
if (expected.size === 0) return false;
|
|
41
|
+
const actual = data;
|
|
42
|
+
for (const key of expected) if (key in actual) return true;
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reads the current values of every reactive var in `clientVariables` into a plain object via a
|
|
47
|
+
* single `useSyncExternalStore` call (no hooks-in-loop). Apollo's `ReactiveVar.onNextChange` fires
|
|
48
|
+
* once per registration, so the subscriber re-attaches after each notification to stay listening.
|
|
49
|
+
*/
|
|
50
|
+
function useClientVariableValues(clientVariables) {
|
|
51
|
+
const varsRef = useRef(clientVariables);
|
|
52
|
+
varsRef.current = clientVariables;
|
|
53
|
+
const subscribe = useCallback((notify) => {
|
|
54
|
+
const cv = varsRef.current;
|
|
55
|
+
if (!cv) return () => {};
|
|
56
|
+
const activeUnsubs = [];
|
|
57
|
+
let cancelled = false;
|
|
58
|
+
const attach = (rv) => {
|
|
59
|
+
if (cancelled) return;
|
|
60
|
+
const unsub = rv.onNextChange(() => {
|
|
61
|
+
notify();
|
|
62
|
+
attach(rv);
|
|
63
|
+
});
|
|
64
|
+
activeUnsubs.push(unsub);
|
|
65
|
+
};
|
|
66
|
+
for (const rv of Object.values(cv)) {
|
|
67
|
+
if (rv === void 0 || rv === null) continue;
|
|
68
|
+
const resolved = resolveReactiveVar(rv);
|
|
69
|
+
if (resolved) attach(resolved);
|
|
70
|
+
}
|
|
71
|
+
return () => {
|
|
72
|
+
cancelled = true;
|
|
73
|
+
for (const u of activeUnsubs) u();
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
const lastSnapshotRef = useRef(null);
|
|
77
|
+
const getSnapshot = () => {
|
|
78
|
+
const cv = varsRef.current;
|
|
79
|
+
const snap = {};
|
|
80
|
+
if (cv) for (const [key, reactiveVar] of Object.entries(cv)) {
|
|
81
|
+
if (reactiveVar === void 0 || reactiveVar === null) continue;
|
|
82
|
+
const resolved = resolveReactiveVar(reactiveVar);
|
|
83
|
+
if (!resolved) continue;
|
|
84
|
+
const value = resolved();
|
|
85
|
+
if (value !== null && value !== void 0) snap[key] = value;
|
|
86
|
+
}
|
|
87
|
+
const json = JSON.stringify(snap);
|
|
88
|
+
if (lastSnapshotRef.current && lastSnapshotRef.current.json === json) return lastSnapshotRef.current.json;
|
|
89
|
+
lastSnapshotRef.current = {
|
|
90
|
+
json,
|
|
91
|
+
value: snap
|
|
92
|
+
};
|
|
93
|
+
return json;
|
|
94
|
+
};
|
|
95
|
+
useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
96
|
+
return lastSnapshotRef.current?.value ?? {};
|
|
97
|
+
}
|
|
98
|
+
function PageReactiveDataRoot(props) {
|
|
99
|
+
const { query, serverVariables, initialData, clientVariables, children } = props;
|
|
100
|
+
const client = useApolloClient();
|
|
101
|
+
const seededRef = useRef(false);
|
|
102
|
+
const clientValues = useClientVariableValues(clientVariables);
|
|
103
|
+
const mergedVariables = {
|
|
104
|
+
...serverVariables ?? {},
|
|
105
|
+
...clientValues
|
|
106
|
+
};
|
|
107
|
+
const requiredNames = getRequiredVariableNames(query);
|
|
108
|
+
const mergedRecord = mergedVariables;
|
|
109
|
+
const hasAllRequiredVariables = requiredNames.every((name) => {
|
|
110
|
+
const v = mergedRecord[name];
|
|
111
|
+
return v !== null && v !== void 0;
|
|
112
|
+
});
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (seededRef.current) return;
|
|
115
|
+
if (!serverVariables || initialData == null) return;
|
|
116
|
+
if (!shapeMatches(query, initialData)) return;
|
|
117
|
+
client.cache.writeQuery({
|
|
118
|
+
query,
|
|
119
|
+
variables: serverVariables,
|
|
120
|
+
data: initialData
|
|
121
|
+
});
|
|
122
|
+
seededRef.current = true;
|
|
123
|
+
}, [
|
|
124
|
+
client,
|
|
125
|
+
query,
|
|
126
|
+
serverVariables,
|
|
127
|
+
initialData
|
|
128
|
+
]);
|
|
129
|
+
const { data, loading, error } = useQuery(query, {
|
|
130
|
+
variables: mergedVariables,
|
|
131
|
+
fetchPolicy: "cache-first",
|
|
132
|
+
skip: !hasAllRequiredVariables
|
|
133
|
+
});
|
|
134
|
+
const contextValue = useMemo(() => ({
|
|
135
|
+
rootQueryData: data ?? void 0,
|
|
136
|
+
loading,
|
|
137
|
+
hasAllRequiredVariables,
|
|
138
|
+
error
|
|
139
|
+
}), [
|
|
140
|
+
data,
|
|
141
|
+
loading,
|
|
142
|
+
hasAllRequiredVariables,
|
|
143
|
+
error
|
|
144
|
+
]);
|
|
145
|
+
return /* @__PURE__ */ jsx(ReactiveRootContext.Provider, {
|
|
146
|
+
value: contextValue,
|
|
147
|
+
children
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { PageReactiveDataRoot, ReactiveRootContext };
|
|
152
|
+
|
|
153
|
+
//# sourceMappingURL=page-reactive-data-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-reactive-data-root.js","names":[],"sources":["../../../src/sdk/data/page-reactive-data-root.tsx"],"sourcesContent":["'use client';\n\nimport type { ErrorLike, OperationVariables, ReactiveVar, TypedDocumentNode } from '@apollo/client';\nimport { useApolloClient, useQuery } from '@apollo/client/react';\nimport { type DocumentNode, Kind, type OperationDefinitionNode } from 'graphql';\nimport { createContext, type ReactNode, useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\n\n// Reactive vars resolvable by name from a Server Component. Functions cannot cross the\n// Server→Client boundary in RSC, so the compiler emits string keys and this component resolves\n// them at runtime. New reactive vars must be registered here to be addressable from generated\n// pages. Currently empty: cart context travels on the transport, so no cart entry is needed\n// (specs/cart-context-client-migrate.md).\nconst REACTIVE_VAR_REGISTRY: Record<string, ReactiveVar<unknown>> = {};\n\n/**\n * Compile-time-stable map keyed by the operation's variable names. Each value is either an Apollo\n * reactive variable (`makeVar`) or the string name of one registered in REACTIVE_VAR_REGISTRY —\n * Server Components must pass strings because functions cannot cross the RSC boundary. Vars that\n * have not yet resolved should hold `null`; the runtime treats both `null` and `undefined` as\n * \"not yet ready\" and keeps `useQuery` skipped.\n */\nexport type ClientVariablesMap<TVars> = Partial<{\n [K in keyof TVars]: ReactiveVar<TVars[K] | null> | string;\n}>;\n\nfunction resolveReactiveVar(value: ReactiveVar<unknown> | string): ReactiveVar<unknown> | undefined {\n if (typeof value === 'function') return value;\n const resolved = REACTIVE_VAR_REGISTRY[value];\n if (!resolved) {\n throw new Error(\n `PageReactiveDataRoot: clientVariables entry \"${value}\" is not registered. Add it to REACTIVE_VAR_REGISTRY in page-reactive-data-root.tsx.`,\n );\n }\n return resolved;\n}\n\nexport type PageReactiveDataRootProps<TData, TVars extends OperationVariables> = Readonly<{\n /** The composed PAGE_QUERY operation document. */\n query: TypedDocumentNode<TData, TVars>;\n /** Variables the server used when calling fetchPageData. Only used to seed the client cache. */\n serverVariables?: TVars;\n /** Server-rendered PAGE_QUERY result. When present and shape-matched, seeded into the cache once. */\n initialData?: TData | null;\n /** Reactive vars whose current values are merged into operation variables at render time. */\n clientVariables?: ClientVariablesMap<TVars>;\n children: ReactNode;\n}>;\n\nexport type ReactiveRootContextValue<TData = unknown> = Readonly<{\n /** Current root query data exposed to descendant `ReactiveDataProvider`s. */\n rootQueryData: TData | undefined;\n /** Whether the underlying useQuery is currently in flight. */\n loading: boolean;\n /** False when at least one required variable has not been provided yet. */\n hasAllRequiredVariables: boolean;\n /**\n * Error from the underlying useQuery. With non-null root fields (e.g. `cart: Cart!`), a failed\n * fetch nulls the whole operation's `data` — descendants need this to tell \"fetch failed\" apart\n * from \"entity is legitimately absent\" (specs/cart-context-client-migrate.md US-5).\n */\n error: ErrorLike | undefined;\n}>;\n\nexport const ReactiveRootContext = createContext<ReactiveRootContextValue>({\n rootQueryData: undefined,\n loading: false,\n hasAllRequiredVariables: false,\n error: undefined,\n});\n\nfunction getOperationDefinition(query: DocumentNode): OperationDefinitionNode | undefined {\n for (const definition of query.definitions) {\n if (definition.kind === Kind.OPERATION_DEFINITION) return definition;\n }\n return undefined;\n}\n\nfunction getRequiredVariableNames(query: DocumentNode): string[] {\n const op = getOperationDefinition(query);\n if (!op?.variableDefinitions) return [];\n const required: string[] = [];\n for (const def of op.variableDefinitions) {\n if (def.type.kind === Kind.NON_NULL_TYPE && def.defaultValue === undefined) {\n required.push(def.variable.name.value);\n }\n }\n return required;\n}\n\nfunction getTopLevelFieldNames(query: DocumentNode): Set<string> {\n const op = getOperationDefinition(query);\n const names = new Set<string>();\n if (!op) return names;\n for (const sel of op.selectionSet.selections) {\n if (sel.kind === Kind.FIELD) {\n names.add((sel.alias ?? sel.name).value);\n }\n }\n return names;\n}\n\nfunction shapeMatches(query: DocumentNode, data: unknown): boolean {\n if (data == null || typeof data !== 'object') return false;\n const expected = getTopLevelFieldNames(query);\n if (expected.size === 0) return false;\n const actual = data as Record<string, unknown>;\n // Require AT LEAST ONE top-level field name to be present in `data`. The operation's full\n // top-level shape may include fields the server did not return; partial seeds still help. A total\n // miss (no overlap at all) signals a shape mismatch and we skip the seed.\n for (const key of expected) {\n if (key in actual) return true;\n }\n return false;\n}\n\n/**\n * Reads the current values of every reactive var in `clientVariables` into a plain object via a\n * single `useSyncExternalStore` call (no hooks-in-loop). Apollo's `ReactiveVar.onNextChange` fires\n * once per registration, so the subscriber re-attaches after each notification to stay listening.\n */\nfunction useClientVariableValues<TVars>(clientVariables: ClientVariablesMap<TVars> | undefined): Partial<TVars> {\n // Keep the latest map identity reachable from inside subscribe()/getSnapshot() without forcing\n // useSyncExternalStore to tear down the underlying subscription.\n const varsRef = useRef(clientVariables);\n // react-doctor-disable-next-line no-ref-current-in-render -- keeps the latest map reachable from the stable subscribe()/getSnapshot() callbacks below\n varsRef.current = clientVariables;\n\n const subscribe = useCallback((notify: () => void): (() => void) => {\n const cv = varsRef.current;\n if (!cv) return () => {};\n\n const activeUnsubs: Array<() => void> = [];\n let cancelled = false;\n\n const attach = (rv: ReactiveVar<unknown>): void => {\n if (cancelled) return;\n const unsub = rv.onNextChange(() => {\n notify();\n // onNextChange fires only once — re-attach to keep listening for subsequent changes.\n attach(rv);\n });\n activeUnsubs.push(unsub);\n };\n\n for (const rv of Object.values(cv)) {\n if (rv === undefined || rv === null) continue;\n const resolved = resolveReactiveVar(rv as ReactiveVar<unknown> | string);\n if (resolved) attach(resolved);\n }\n\n return () => {\n cancelled = true;\n for (const u of activeUnsubs) u();\n };\n }, []);\n\n const lastSnapshotRef = useRef<{ json: string; value: Record<string, unknown> } | null>(null);\n\n const getSnapshot = (): string => {\n const cv = varsRef.current;\n const snap: Record<string, unknown> = {};\n if (cv) {\n for (const [key, reactiveVar] of Object.entries(cv)) {\n if (reactiveVar === undefined || reactiveVar === null) continue;\n const resolved = resolveReactiveVar(reactiveVar as ReactiveVar<unknown> | string);\n if (!resolved) continue;\n const value = resolved();\n if (value !== null && value !== undefined) snap[key] = value;\n }\n }\n const json = JSON.stringify(snap);\n // useSyncExternalStore expects a stable snapshot reference until the value changes (Object.is\n // identity check) — return the cached `json` whenever the contents are unchanged.\n if (lastSnapshotRef.current && lastSnapshotRef.current.json === json) {\n return lastSnapshotRef.current.json;\n }\n lastSnapshotRef.current = { json, value: snap };\n return json;\n };\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n return (lastSnapshotRef.current?.value ?? {}) as Partial<TVars>;\n}\n\nexport function PageReactiveDataRoot<TData = unknown, TVars extends OperationVariables = OperationVariables>(\n props: PageReactiveDataRootProps<TData, TVars>,\n): ReactNode {\n const { query, serverVariables, initialData, clientVariables, children } = props;\n const client = useApolloClient();\n const seededRef = useRef(false);\n\n const clientValues = useClientVariableValues<TVars>(clientVariables);\n const mergedVariables = { ...(serverVariables ?? ({} as TVars)), ...clientValues } as TVars;\n\n const requiredNames = getRequiredVariableNames(query);\n const mergedRecord = mergedVariables as Record<string, unknown>;\n const hasAllRequiredVariables = requiredNames.every((name) => {\n const v = mergedRecord[name];\n return v !== null && v !== undefined;\n });\n\n // Ref- and shape-guarded one-time cache seed from server props. We use `useEffect` (not\n // `useLayoutEffect`) to avoid the SSR-pass warning emitted by React 19 — the resulting \"first\n // render shows fallbackData, second render shows cache slice\" behaviour is acceptable because\n // initialData is the same value `ReactiveDataProvider` falls back to anyway.\n useEffect(() => {\n if (seededRef.current) return;\n if (!serverVariables || initialData == null) return;\n if (!shapeMatches(query, initialData)) return;\n client.cache.writeQuery({ query, variables: serverVariables, data: initialData });\n seededRef.current = true;\n }, [client, query, serverVariables, initialData]);\n\n const { data, loading, error } = useQuery(query, {\n variables: mergedVariables,\n fetchPolicy: 'cache-first',\n skip: !hasAllRequiredVariables,\n });\n\n const contextValue: ReactiveRootContextValue<TData> = useMemo(\n () => ({\n rootQueryData: (data ?? undefined) as TData | undefined,\n loading,\n hasAllRequiredVariables,\n error,\n }),\n [data, loading, hasAllRequiredVariables, error],\n );\n\n return (\n <ReactiveRootContext.Provider value={contextValue as ReactiveRootContextValue}>\n {children}\n </ReactiveRootContext.Provider>\n );\n}\n"],"mappings":";;;;;;AAYA,MAAM,wBAA8D,CAAC;AAarE,SAAS,mBAAmB,OAAwE;CAClG,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,MAAM,WAAW,sBAAsB;CACvC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,gDAAgD,MAAM,qFACxD;CAEF,OAAO;AACT;AA6BA,MAAa,sBAAsB,cAAwC;CACzE,eAAe,KAAA;CACf,SAAS;CACT,yBAAyB;CACzB,OAAO,KAAA;AACT,CAAC;AAED,SAAS,uBAAuB,OAA0D;CACxF,KAAK,MAAM,cAAc,MAAM,aAC7B,IAAI,WAAW,SAAS,KAAK,sBAAsB,OAAO;AAG9D;AAEA,SAAS,yBAAyB,OAA+B;CAC/D,MAAM,KAAK,uBAAuB,KAAK;CACvC,IAAI,CAAC,IAAI,qBAAqB,OAAO,CAAC;CACtC,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,OAAO,GAAG,qBACnB,IAAI,IAAI,KAAK,SAAS,KAAK,iBAAiB,IAAI,iBAAiB,KAAA,GAC/D,SAAS,KAAK,IAAI,SAAS,KAAK,KAAK;CAGzC,OAAO;AACT;AAEA,SAAS,sBAAsB,OAAkC;CAC/D,MAAM,KAAK,uBAAuB,KAAK;CACvC,MAAM,wBAAQ,IAAI,IAAY;CAC9B,IAAI,CAAC,IAAI,OAAO;CAChB,KAAK,MAAM,OAAO,GAAG,aAAa,YAChC,IAAI,IAAI,SAAS,KAAK,OACpB,MAAM,KAAK,IAAI,SAAS,IAAI,KAAA,CAAM,KAAK;CAG3C,OAAO;AACT;AAEA,SAAS,aAAa,OAAqB,MAAwB;CACjE,IAAI,QAAQ,QAAQ,OAAO,SAAS,UAAU,OAAO;CACrD,MAAM,WAAW,sBAAsB,KAAK;CAC5C,IAAI,SAAS,SAAS,GAAG,OAAO;CAChC,MAAM,SAAS;CAIf,KAAK,MAAM,OAAO,UAChB,IAAI,OAAO,QAAQ,OAAO;CAE5B,OAAO;AACT;;;;;;AAOA,SAAS,wBAA+B,iBAAwE;CAG9G,MAAM,UAAU,OAAO,eAAe;CAEtC,QAAQ,UAAU;CAElB,MAAM,YAAY,aAAa,WAAqC;EAClE,MAAM,KAAK,QAAQ;EACnB,IAAI,CAAC,IAAI,aAAa,CAAC;EAEvB,MAAM,eAAkC,CAAC;EACzC,IAAI,YAAY;EAEhB,MAAM,UAAU,OAAmC;GACjD,IAAI,WAAW;GACf,MAAM,QAAQ,GAAG,mBAAmB;IAClC,OAAO;IAEP,OAAO,EAAE;GACX,CAAC;GACD,aAAa,KAAK,KAAK;EACzB;EAEA,KAAK,MAAM,MAAM,OAAO,OAAO,EAAE,GAAG;GAClC,IAAI,OAAO,KAAA,KAAa,OAAO,MAAM;GACrC,MAAM,WAAW,mBAAmB,EAAmC;GACvE,IAAI,UAAU,OAAO,QAAQ;EAC/B;EAEA,aAAa;GACX,YAAY;GACZ,KAAK,MAAM,KAAK,cAAc,EAAE;EAClC;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,kBAAkB,OAAgE,IAAI;CAE5F,MAAM,oBAA4B;EAChC,MAAM,KAAK,QAAQ;EACnB,MAAM,OAAgC,CAAC;EACvC,IAAI,IACF,KAAK,MAAM,CAAC,KAAK,gBAAgB,OAAO,QAAQ,EAAE,GAAG;GACnD,IAAI,gBAAgB,KAAA,KAAa,gBAAgB,MAAM;GACvD,MAAM,WAAW,mBAAmB,WAA4C;GAChF,IAAI,CAAC,UAAU;GACf,MAAM,QAAQ,SAAS;GACvB,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,KAAK,OAAO;EACzD;EAEF,MAAM,OAAO,KAAK,UAAU,IAAI;EAGhC,IAAI,gBAAgB,WAAW,gBAAgB,QAAQ,SAAS,MAC9D,OAAO,gBAAgB,QAAQ;EAEjC,gBAAgB,UAAU;GAAE;GAAM,OAAO;EAAK;EAC9C,OAAO;CACT;CAEA,qBAAqB,WAAW,aAAa,WAAW;CAExD,OAAQ,gBAAgB,SAAS,SAAS,CAAC;AAC7C;AAEA,SAAgB,qBACd,OACW;CACX,MAAM,EAAE,OAAO,iBAAiB,aAAa,iBAAiB,aAAa;CAC3E,MAAM,SAAS,gBAAgB;CAC/B,MAAM,YAAY,OAAO,KAAK;CAE9B,MAAM,eAAe,wBAA+B,eAAe;CACnE,MAAM,kBAAkB;EAAE,GAAI,mBAAoB,CAAC;EAAc,GAAG;CAAa;CAEjF,MAAM,gBAAgB,yBAAyB,KAAK;CACpD,MAAM,eAAe;CACrB,MAAM,0BAA0B,cAAc,OAAO,SAAS;EAC5D,MAAM,IAAI,aAAa;EACvB,OAAO,MAAM,QAAQ,MAAM,KAAA;CAC7B,CAAC;CAMD,gBAAgB;EACd,IAAI,UAAU,SAAS;EACvB,IAAI,CAAC,mBAAmB,eAAe,MAAM;EAC7C,IAAI,CAAC,aAAa,OAAO,WAAW,GAAG;EACvC,OAAO,MAAM,WAAW;GAAE;GAAO,WAAW;GAAiB,MAAM;EAAY,CAAC;EAChF,UAAU,UAAU;CACtB,GAAG;EAAC;EAAQ;EAAO;EAAiB;CAAW,CAAC;CAEhD,MAAM,EAAE,MAAM,SAAS,UAAU,SAAS,OAAO;EAC/C,WAAW;EACX,aAAa;EACb,MAAM,CAAC;CACT,CAAC;CAED,MAAM,eAAgD,eAC7C;EACL,eAAgB,QAAQ,KAAA;EACxB;EACA;EACA;CACF,IACA;EAAC;EAAM;EAAS;EAAyB;CAAK,CAChD;CAEA,OACE,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAClC;CAC2B,CAAA;AAElC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { DocumentNode } from "@apollo/client";
|
|
3
|
+
//#region src/sdk/data/reactive-data-provider.d.ts
|
|
4
|
+
export type ReactiveDataProviderProps = Readonly<{
|
|
5
|
+
/** Derived `fragment <X>_<EntityType> on <EntityType>` document emitted by the compiler. */
|
|
6
|
+
entityFragment: DocumentNode;
|
|
7
|
+
/** Name of the derived fragment, passed to `useFragment`. */
|
|
8
|
+
fragmentName: string;
|
|
9
|
+
/** Top-level field of the page query (e.g. 'cart') used to extract the entity ref. */
|
|
10
|
+
rootField: string;
|
|
11
|
+
/** Server-rendered fragment payload; used until the cache resolves a complete entity slice. */
|
|
12
|
+
fallbackData: unknown;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Per-particle reactive subscriber (AD-4 / AD-D2).
|
|
17
|
+
*
|
|
18
|
+
* Resolves its entity slice via `useReactiveEntity` (the shared single-entity resolve; see that
|
|
19
|
+
* hook's doc for the cache-read details) and writes it, unmodified, into `DataOverrideContext`.
|
|
20
|
+
*
|
|
21
|
+
* See specs/reactive-data-flow.md (AD-4, AD-D2) and rfc-data-layer.md §"Reactive fetch".
|
|
22
|
+
*/
|
|
23
|
+
export declare function ReactiveDataProvider({ entityFragment, fragmentName, rootField, fallbackData, children }: ReactiveDataProviderProps): ReactNode;
|
|
24
|
+
//#endregion
|
|
25
|
+
//# sourceMappingURL=reactive-data-provider.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DataOverrideContext } from "./data-override-context.js";
|
|
3
|
+
import { useReactiveEntity } from "./use-reactive-entity.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/sdk/data/reactive-data-provider.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Per-particle reactive subscriber (AD-4 / AD-D2).
|
|
8
|
+
*
|
|
9
|
+
* Resolves its entity slice via `useReactiveEntity` (the shared single-entity resolve; see that
|
|
10
|
+
* hook's doc for the cache-read details) and writes it, unmodified, into `DataOverrideContext`.
|
|
11
|
+
*
|
|
12
|
+
* See specs/reactive-data-flow.md (AD-4, AD-D2) and rfc-data-layer.md §"Reactive fetch".
|
|
13
|
+
*/
|
|
14
|
+
function ReactiveDataProvider({ entityFragment, fragmentName, rootField, fallbackData, children }) {
|
|
15
|
+
const resolved = useReactiveEntity(entityFragment, fragmentName, rootField, fallbackData);
|
|
16
|
+
return /* @__PURE__ */ jsx(DataOverrideContext, {
|
|
17
|
+
value: resolved,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ReactiveDataProvider };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=reactive-data-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-data-provider.js","names":[],"sources":["../../../src/sdk/data/reactive-data-provider.tsx"],"sourcesContent":["'use client';\n\nimport type { DocumentNode } from '@apollo/client';\nimport type { ReactNode } from 'react';\nimport { DataOverrideContext } from './data-override-context.js';\nimport { useReactiveEntity } from './use-reactive-entity.js';\n\nexport type ReactiveDataProviderProps = Readonly<{\n /** Derived `fragment <X>_<EntityType> on <EntityType>` document emitted by the compiler. */\n entityFragment: DocumentNode;\n /** Name of the derived fragment, passed to `useFragment`. */\n fragmentName: string;\n /** Top-level field of the page query (e.g. 'cart') used to extract the entity ref. */\n rootField: string;\n /** Server-rendered fragment payload; used until the cache resolves a complete entity slice. */\n fallbackData: unknown;\n children: ReactNode;\n}>;\n\n/**\n * Per-particle reactive subscriber (AD-4 / AD-D2).\n *\n * Resolves its entity slice via `useReactiveEntity` (the shared single-entity resolve; see that\n * hook's doc for the cache-read details) and writes it, unmodified, into `DataOverrideContext`.\n *\n * See specs/reactive-data-flow.md (AD-4, AD-D2) and rfc-data-layer.md §\"Reactive fetch\".\n */\nexport function ReactiveDataProvider({\n entityFragment,\n fragmentName,\n rootField,\n fallbackData,\n children,\n}: ReactiveDataProviderProps): ReactNode {\n const resolved = useReactiveEntity(entityFragment, fragmentName, rootField, fallbackData);\n\n return <DataOverrideContext value={resolved}>{children}</DataOverrideContext>;\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,qBAAqB,EACnC,gBACA,cACA,WACA,cACA,YACuC;CACvC,MAAM,WAAW,kBAAkB,gBAAgB,cAAc,WAAW,YAAY;CAExF,OAAO,oBAAC,qBAAD;EAAqB,OAAO;EAAW;CAA8B,CAAA;AAC9E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { DocumentNode } from "@apollo/client";
|
|
3
|
+
//#region src/sdk/data/reactive-list-item-data-provider.d.ts
|
|
4
|
+
export type ReactiveListItemDataProviderProps = Readonly<{
|
|
5
|
+
/** Derived `fragment <X>_<ListElementEntity> on <ListElementEntity>` document emitted by the compiler. */
|
|
6
|
+
entityFragment: DocumentNode;
|
|
7
|
+
/** Name of the derived fragment, passed to `useFragment`. */
|
|
8
|
+
fragmentName: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Per-iterated-line reactive subscriber.
|
|
13
|
+
*
|
|
14
|
+
* The list-item sibling of `ReactiveDataProvider`: instead of deriving the entity ref from a
|
|
15
|
+
* top-level page-query field, it reads the current line's ref from `ListItemRefContext` (published
|
|
16
|
+
* per line by the iterator, e.g. `CartList`) and subscribes to that one normalized entity
|
|
17
|
+
* (`CartItem:<id>`) via `useFragment`. The hook never triggers a network request — it is purely a
|
|
18
|
+
* cache reader. When the ref is unresolved or the cache slice is incomplete, it falls back to the
|
|
19
|
+
* line's server-rendered slice (`fallbackData`) so descendants always see a value. The resolved
|
|
20
|
+
* slice is published through the same `DataOverrideContext` seam reactive components read today.
|
|
21
|
+
*
|
|
22
|
+
* See specs/fspg-816-minicart-compiler-per-item-composition.md.
|
|
23
|
+
*/
|
|
24
|
+
export declare function ReactiveListItemDataProvider({ entityFragment, fragmentName, children }: ReactiveListItemDataProviderProps): ReactNode;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=reactive-list-item-data-provider.d.ts.map
|