@shopify/hydrogen 2026.4.5 → 2026.10.0-preview.2
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/README.md +73 -13
- package/bin/hydrogen.mjs +7 -0
- package/dist/cli/index.mjs +647 -0
- package/dist/client/client.d.mts +34 -0
- package/dist/client/client.mjs +206 -0
- package/dist/client/client.mjs.map +1 -0
- package/dist/client/errors.d.mts +48 -0
- package/dist/client/errors.mjs +52 -0
- package/dist/client/errors.mjs.map +1 -0
- package/dist/client/index.d.mts +4 -0
- package/dist/client/types.d.mts +147 -0
- package/dist/core/analytics/cart-tracker.d.mts +8 -0
- package/dist/core/analytics/cart-tracker.mjs +144 -0
- package/dist/core/analytics/cart-tracker.mjs.map +1 -0
- package/dist/core/analytics/events.d.mts +15 -0
- package/dist/core/analytics/events.mjs +15 -0
- package/dist/core/analytics/events.mjs.map +1 -0
- package/dist/core/analytics/index.d.mts +3 -0
- package/dist/core/analytics/types.d.mts +143 -0
- package/dist/core/analytics/utils/flatten-connection.d.mts +19 -0
- package/dist/core/analytics/utils/flatten-connection.mjs +25 -0
- package/dist/core/analytics/utils/flatten-connection.mjs.map +1 -0
- package/dist/core/cache/cache-status.mjs +17 -0
- package/dist/core/cache/cache-status.mjs.map +1 -0
- package/dist/core/cache/fetch-with-cache.d.mts +43 -0
- package/dist/core/cache/fetch-with-cache.mjs +188 -0
- package/dist/core/cache/fetch-with-cache.mjs.map +1 -0
- package/dist/core/cache/key.d.mts +6 -0
- package/dist/core/cache/key.mjs +27 -0
- package/dist/core/cache/key.mjs.map +1 -0
- package/dist/core/cache/run-with-cache.d.mts +36 -0
- package/dist/core/cache/run-with-cache.mjs +114 -0
- package/dist/core/cache/run-with-cache.mjs.map +1 -0
- package/dist/core/cache/store.d.mts +19 -0
- package/dist/core/cache/store.mjs +62 -0
- package/dist/core/cache/store.mjs.map +1 -0
- package/dist/core/cache/strategies.d.mts +39 -0
- package/dist/core/cache/strategies.mjs +70 -0
- package/dist/core/cache/strategies.mjs.map +1 -0
- package/dist/core/cart/actions.d.mts +50 -0
- package/dist/core/cart/actions.mjs +240 -0
- package/dist/core/cart/actions.mjs.map +1 -0
- package/dist/core/cart/attach-quantity-input.d.mts +5 -0
- package/dist/core/cart/attach-quantity-input.mjs +17 -0
- package/dist/core/cart/attach-quantity-input.mjs.map +1 -0
- package/dist/core/cart/buyer-identity-sync.d.mts +23 -0
- package/dist/core/cart/buyer-identity-sync.mjs +9 -0
- package/dist/core/cart/buyer-identity-sync.mjs.map +1 -0
- package/dist/core/cart/cart.d.mts +37 -0
- package/dist/core/cart/cart.mjs +1707 -0
- package/dist/core/cart/cart.mjs.map +1 -0
- package/dist/core/cart/cookie.d.mts +5 -0
- package/dist/core/cart/cookie.mjs +28 -0
- package/dist/core/cart/cookie.mjs.map +1 -0
- package/dist/core/cart/form.d.mts +130 -0
- package/dist/core/cart/form.mjs +75 -0
- package/dist/core/cart/form.mjs.map +1 -0
- package/dist/core/cart/get-cart.d.mts +25 -0
- package/dist/core/cart/get-cart.mjs +32 -0
- package/dist/core/cart/get-cart.mjs.map +1 -0
- package/dist/core/cart/index.d.mts +10 -0
- package/dist/core/cart/quantity.d.mts +10 -0
- package/dist/core/cart/quantity.mjs +14 -0
- package/dist/core/cart/quantity.mjs.map +1 -0
- package/dist/core/cart/queries.d.mts +4296 -0
- package/dist/core/cart/queries.mjs +70 -0
- package/dist/core/cart/queries.mjs.map +1 -0
- package/dist/core/cart/server-handlers.d.mts +82 -0
- package/dist/core/cart/server-handlers.mjs +322 -0
- package/dist/core/cart/server-handlers.mjs.map +1 -0
- package/dist/core/cart/state.d.mts +137 -0
- package/dist/core/cart/state.mjs +76 -0
- package/dist/core/cart/state.mjs.map +1 -0
- package/dist/core/cart/sync-quantity-inputs.mjs +16 -0
- package/dist/core/cart/sync-quantity-inputs.mjs.map +1 -0
- package/dist/core/collection/collection.d.mts +134 -0
- package/dist/core/collection/collection.mjs +170 -0
- package/dist/core/collection/collection.mjs.map +1 -0
- package/dist/core/collection/index.d.mts +6 -0
- package/dist/core/collection/reconciler.d.mts +32 -0
- package/dist/core/collection/reconciler.mjs +89 -0
- package/dist/core/collection/reconciler.mjs.map +1 -0
- package/dist/core/collection/state.d.mts +66 -0
- package/dist/core/collection/state.mjs +20 -0
- package/dist/core/collection/state.mjs.map +1 -0
- package/dist/core/collection/url.d.mts +71 -0
- package/dist/core/collection/url.mjs +376 -0
- package/dist/core/collection/url.mjs.map +1 -0
- package/dist/core/constants.d.mts +5 -0
- package/dist/core/constants.mjs +8 -0
- package/dist/core/constants.mjs.map +1 -0
- package/dist/core/headers.mjs +43 -0
- package/dist/core/headers.mjs.map +1 -0
- package/dist/core/index.d.mts +56 -0
- package/dist/core/index.mjs +45 -0
- package/dist/core/logging/logging.d.mts +21 -0
- package/dist/core/logging/logging.mjs +99 -0
- package/dist/core/logging/logging.mjs.map +1 -0
- package/dist/core/logging/types.d.mts +40 -0
- package/dist/core/logging/types.mjs +18 -0
- package/dist/core/logging/types.mjs.map +1 -0
- package/dist/core/money/cache.mjs +25 -0
- package/dist/core/money/cache.mjs.map +1 -0
- package/dist/core/money/format.d.mts +15 -0
- package/dist/core/money/format.mjs +243 -0
- package/dist/core/money/format.mjs.map +1 -0
- package/dist/core/money/types.d.mts +47 -0
- package/dist/core/observable.mjs +46 -0
- package/dist/core/observable.mjs.map +1 -0
- package/dist/core/predictive-search/constants.d.mts +5 -0
- package/dist/core/predictive-search/constants.mjs +6 -0
- package/dist/core/predictive-search/constants.mjs.map +1 -0
- package/dist/core/predictive-search/form.d.mts +31 -0
- package/dist/core/predictive-search/form.mjs +31 -0
- package/dist/core/predictive-search/form.mjs.map +1 -0
- package/dist/core/predictive-search/index.d.mts +6 -0
- package/dist/core/predictive-search/queries.d.mts +118 -0
- package/dist/core/predictive-search/queries.mjs +81 -0
- package/dist/core/predictive-search/queries.mjs.map +1 -0
- package/dist/core/predictive-search/search.d.mts +32 -0
- package/dist/core/predictive-search/search.mjs +74 -0
- package/dist/core/predictive-search/search.mjs.map +1 -0
- package/dist/core/predictive-search/server-handlers.d.mts +36 -0
- package/dist/core/predictive-search/server-handlers.mjs +113 -0
- package/dist/core/predictive-search/server-handlers.mjs.map +1 -0
- package/dist/core/predictive-search/store.d.mts +44 -0
- package/dist/core/predictive-search/store.mjs +224 -0
- package/dist/core/predictive-search/store.mjs.map +1 -0
- package/dist/core/predictive-search/url.d.mts +41 -0
- package/dist/core/predictive-search/url.mjs +71 -0
- package/dist/core/predictive-search/url.mjs.map +1 -0
- package/dist/core/product/accept-variant-id.mjs +98 -0
- package/dist/core/product/accept-variant-id.mjs.map +1 -0
- package/dist/core/product/form.d.mts +63 -0
- package/dist/core/product/form.mjs +44 -0
- package/dist/core/product/form.mjs.map +1 -0
- package/dist/core/product/index.d.mts +5 -0
- package/dist/core/product/options.d.mts +43 -0
- package/dist/core/product/options.mjs +296 -0
- package/dist/core/product/options.mjs.map +1 -0
- package/dist/core/product/product-form.d.mts +72 -0
- package/dist/core/product/product-form.mjs +158 -0
- package/dist/core/product/product-form.mjs.map +1 -0
- package/dist/core/product/state.d.mts +68 -0
- package/dist/core/product/url.d.mts +47 -0
- package/dist/core/product/url.mjs +69 -0
- package/dist/core/product/url.mjs.map +1 -0
- package/dist/core/request-context.d.mts +75 -0
- package/dist/core/request-context.mjs +141 -0
- package/dist/core/request-context.mjs.map +1 -0
- package/dist/core/request-routing/handle-shopify-redirects.d.mts +17 -0
- package/dist/core/request-routing/handle-shopify-redirects.mjs +31 -0
- package/dist/core/request-routing/handle-shopify-redirects.mjs.map +1 -0
- package/dist/core/request-routing/handle-shopify-routes.d.mts +14 -0
- package/dist/core/request-routing/handle-shopify-routes.mjs +42 -0
- package/dist/core/request-routing/handle-shopify-routes.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/admin-redirect.mjs +12 -0
- package/dist/core/request-routing/interceptors/admin-redirect.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/ajax-api.mjs +16 -0
- package/dist/core/request-routing/interceptors/ajax-api.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/api-proxy.mjs +20 -0
- package/dist/core/request-routing/interceptors/api-proxy.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/checkout.mjs +58 -0
- package/dist/core/request-routing/interceptors/checkout.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/mcp-proxy.mjs +23 -0
- package/dist/core/request-routing/interceptors/mcp-proxy.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/proxy.mjs +73 -0
- package/dist/core/request-routing/interceptors/proxy.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/query-param-redirect.mjs +22 -0
- package/dist/core/request-routing/interceptors/query-param-redirect.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/sfapi-proxy.mjs +27 -0
- package/dist/core/request-routing/interceptors/sfapi-proxy.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/standard-routes.mjs +19 -0
- package/dist/core/request-routing/interceptors/standard-routes.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/url-redirects.mjs +27 -0
- package/dist/core/request-routing/interceptors/url-redirects.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/well-known.mjs +22 -0
- package/dist/core/request-routing/interceptors/well-known.mjs.map +1 -0
- package/dist/core/request-routing/registered-routes.d.mts +7 -0
- package/dist/core/request-routing/registered-routes.mjs +72 -0
- package/dist/core/request-routing/registered-routes.mjs.map +1 -0
- package/dist/core/request-routing/route-types.d.mts +56 -0
- package/dist/core/request-routing/safe-apply-response-headers.mjs +16 -0
- package/dist/core/request-routing/safe-apply-response-headers.mjs.map +1 -0
- package/dist/core/shop-pay/shop-pay.d.mts +102 -0
- package/dist/core/shop-pay/shop-pay.mjs +289 -0
- package/dist/core/shop-pay/shop-pay.mjs.map +1 -0
- package/dist/core/shopify-scripts/analytics.mjs +26 -0
- package/dist/core/shopify-scripts/analytics.mjs.map +1 -0
- package/dist/core/shopify-scripts/consent.mjs +17 -0
- package/dist/core/shopify-scripts/consent.mjs.map +1 -0
- package/dist/core/shopify-scripts/constants.mjs +19 -0
- package/dist/core/shopify-scripts/constants.mjs.map +1 -0
- package/dist/core/shopify-scripts/deprecated-cookies.mjs +97 -0
- package/dist/core/shopify-scripts/deprecated-cookies.mjs.map +1 -0
- package/dist/core/shopify-scripts/global.d.mts +1 -0
- package/dist/core/shopify-scripts/global.mjs +86 -0
- package/dist/core/shopify-scripts/global.mjs.map +1 -0
- package/dist/core/shopify-scripts/index.d.mts +27 -0
- package/dist/core/shopify-scripts/index.mjs +135 -0
- package/dist/core/shopify-scripts/index.mjs.map +1 -0
- package/dist/core/shopify-scripts/initialize.d.mts +18 -0
- package/dist/core/shopify-scripts/initialize.mjs +27 -0
- package/dist/core/shopify-scripts/initialize.mjs.map +1 -0
- package/dist/core/shopify-scripts/page-view.mjs +49 -0
- package/dist/core/shopify-scripts/page-view.mjs.map +1 -0
- package/dist/core/shopify-scripts/perfkit.mjs +33 -0
- package/dist/core/shopify-scripts/perfkit.mjs.map +1 -0
- package/dist/core/shopify-scripts/render.d.mts +1 -0
- package/dist/core/shopify-scripts/render.mjs +23 -0
- package/dist/core/shopify-scripts/render.mjs.map +1 -0
- package/dist/core/shopify-scripts/types.d.mts +76 -0
- package/dist/core/shopify-scripts/utils/cookie-domain.mjs +43 -0
- package/dist/core/shopify-scripts/utils/cookie-domain.mjs.map +1 -0
- package/dist/core/shopify-scripts/utils/inline-script.mjs +8 -0
- package/dist/core/shopify-scripts/utils/inline-script.mjs.map +1 -0
- package/dist/core/shopify-scripts/utils/navigation.mjs +46 -0
- package/dist/core/shopify-scripts/utils/navigation.mjs.map +1 -0
- package/dist/core/shopify-scripts/utils/tracking-values.mjs +65 -0
- package/dist/core/shopify-scripts/utils/tracking-values.mjs.map +1 -0
- package/dist/core/shopify-scripts/utils/uuid.mjs +17 -0
- package/dist/core/shopify-scripts/utils/uuid.mjs.map +1 -0
- package/dist/core/shopify-scripts/webmcp.mjs +22 -0
- package/dist/core/shopify-scripts/webmcp.mjs.map +1 -0
- package/dist/core/standard-routes/build.d.mts +34 -0
- package/dist/core/standard-routes/build.mjs +54 -0
- package/dist/core/standard-routes/build.mjs.map +1 -0
- package/dist/core/standard-routes/defaults.mjs +31 -0
- package/dist/core/standard-routes/defaults.mjs.map +1 -0
- package/dist/core/standard-routes/match.mjs +108 -0
- package/dist/core/standard-routes/match.mjs.map +1 -0
- package/dist/core/standard-routes/path.mjs +58 -0
- package/dist/core/standard-routes/path.mjs.map +1 -0
- package/dist/core/standard-routes/redirects.mjs +51 -0
- package/dist/core/standard-routes/redirects.mjs.map +1 -0
- package/dist/core/standard-routes/types.d.mts +95 -0
- package/dist/core/url.mjs +42 -0
- package/dist/core/url.mjs.map +1 -0
- package/dist/core/utils/load-script.mjs +34 -0
- package/dist/core/utils/load-script.mjs.map +1 -0
- package/dist/core/utils/parse-gid.mjs +33 -0
- package/dist/core/utils/parse-gid.mjs.map +1 -0
- package/dist/core/utils/record.mjs +8 -0
- package/dist/core/utils/record.mjs.map +1 -0
- package/dist/customer-account/client.d.mts +50 -0
- package/dist/customer-account/client.mjs +239 -0
- package/dist/customer-account/client.mjs.map +1 -0
- package/dist/customer-account/errors.d.mts +28 -0
- package/dist/customer-account/errors.mjs +39 -0
- package/dist/customer-account/errors.mjs.map +1 -0
- package/dist/customer-account/graphql.d.mts +29 -0
- package/dist/customer-account/graphql.mjs +39 -0
- package/dist/customer-account/graphql.mjs.map +1 -0
- package/dist/customer-account/index.d.mts +7 -0
- package/dist/customer-account/index.mjs +7 -0
- package/dist/customer-account/session.d.mts +117 -0
- package/dist/customer-account/session.mjs +733 -0
- package/dist/customer-account/session.mjs.map +1 -0
- package/dist/customer-account/type-resolver.d.mts +11 -0
- package/dist/customer-account-api-types.d.ts +3269 -3270
- package/dist/customer-account.schema.json +50753 -1
- package/dist/development/_virtual/_@oxc-project_runtime@0.127.0/helpers/taggedTemplateLiteral.mjs +7 -0
- package/dist/development/client/client.d.mts +34 -0
- package/dist/development/client/client.mjs +206 -0
- package/dist/development/client/client.mjs.map +1 -0
- package/dist/development/client/errors.d.mts +48 -0
- package/dist/development/client/errors.mjs +57 -0
- package/dist/development/client/errors.mjs.map +1 -0
- package/dist/development/client/index.d.mts +4 -0
- package/dist/development/client/types.d.mts +147 -0
- package/dist/development/core/analytics/cart-tracker.d.mts +8 -0
- package/dist/development/core/analytics/cart-tracker.mjs +144 -0
- package/dist/development/core/analytics/cart-tracker.mjs.map +1 -0
- package/dist/development/core/analytics/events.d.mts +15 -0
- package/dist/development/core/analytics/events.mjs +15 -0
- package/dist/development/core/analytics/events.mjs.map +1 -0
- package/dist/development/core/analytics/index.d.mts +3 -0
- package/dist/development/core/analytics/types.d.mts +143 -0
- package/dist/development/core/analytics/utils/flatten-connection.d.mts +19 -0
- package/dist/development/core/analytics/utils/flatten-connection.mjs +25 -0
- package/dist/development/core/analytics/utils/flatten-connection.mjs.map +1 -0
- package/dist/development/core/cache/cache-status.mjs +17 -0
- package/dist/development/core/cache/cache-status.mjs.map +1 -0
- package/dist/development/core/cache/fetch-with-cache.d.mts +43 -0
- package/dist/development/core/cache/fetch-with-cache.mjs +188 -0
- package/dist/development/core/cache/fetch-with-cache.mjs.map +1 -0
- package/dist/development/core/cache/key.d.mts +6 -0
- package/dist/development/core/cache/key.mjs +27 -0
- package/dist/development/core/cache/key.mjs.map +1 -0
- package/dist/development/core/cache/run-with-cache.d.mts +36 -0
- package/dist/development/core/cache/run-with-cache.mjs +114 -0
- package/dist/development/core/cache/run-with-cache.mjs.map +1 -0
- package/dist/development/core/cache/store.d.mts +19 -0
- package/dist/development/core/cache/store.mjs +62 -0
- package/dist/development/core/cache/store.mjs.map +1 -0
- package/dist/development/core/cache/strategies.d.mts +39 -0
- package/dist/development/core/cache/strategies.mjs +70 -0
- package/dist/development/core/cache/strategies.mjs.map +1 -0
- package/dist/development/core/cart/actions.d.mts +50 -0
- package/dist/development/core/cart/actions.mjs +240 -0
- package/dist/development/core/cart/actions.mjs.map +1 -0
- package/dist/development/core/cart/attach-quantity-input.d.mts +5 -0
- package/dist/development/core/cart/attach-quantity-input.mjs +17 -0
- package/dist/development/core/cart/attach-quantity-input.mjs.map +1 -0
- package/dist/development/core/cart/buyer-identity-sync.d.mts +19 -0
- package/dist/development/core/cart/buyer-identity-sync.mjs +6 -0
- package/dist/development/core/cart/buyer-identity-sync.mjs.map +1 -0
- package/dist/development/core/cart/cart.d.mts +37 -0
- package/dist/development/core/cart/cart.mjs +1707 -0
- package/dist/development/core/cart/cart.mjs.map +1 -0
- package/dist/development/core/cart/cookie.d.mts +5 -0
- package/dist/development/core/cart/cookie.mjs +28 -0
- package/dist/development/core/cart/cookie.mjs.map +1 -0
- package/dist/development/core/cart/form.d.mts +130 -0
- package/dist/development/core/cart/form.mjs +75 -0
- package/dist/development/core/cart/form.mjs.map +1 -0
- package/dist/development/core/cart/get-cart.d.mts +25 -0
- package/dist/development/core/cart/get-cart.mjs +32 -0
- package/dist/development/core/cart/get-cart.mjs.map +1 -0
- package/dist/development/core/cart/index.d.mts +10 -0
- package/dist/development/core/cart/quantity.d.mts +10 -0
- package/dist/development/core/cart/quantity.mjs +14 -0
- package/dist/development/core/cart/quantity.mjs.map +1 -0
- package/dist/development/core/cart/queries.d.mts +4296 -0
- package/dist/development/core/cart/queries.mjs +70 -0
- package/dist/development/core/cart/queries.mjs.map +1 -0
- package/dist/development/core/cart/server-handlers.d.mts +82 -0
- package/dist/development/core/cart/server-handlers.mjs +322 -0
- package/dist/development/core/cart/server-handlers.mjs.map +1 -0
- package/dist/development/core/cart/state.d.mts +137 -0
- package/dist/development/core/cart/state.mjs +76 -0
- package/dist/development/core/cart/state.mjs.map +1 -0
- package/dist/development/core/cart/sync-quantity-inputs.mjs +16 -0
- package/dist/development/core/cart/sync-quantity-inputs.mjs.map +1 -0
- package/dist/development/core/collection/collection.d.mts +134 -0
- package/dist/development/core/collection/collection.mjs +170 -0
- package/dist/development/core/collection/collection.mjs.map +1 -0
- package/dist/development/core/collection/index.d.mts +6 -0
- package/dist/development/core/collection/reconciler.d.mts +32 -0
- package/dist/development/core/collection/reconciler.mjs +89 -0
- package/dist/development/core/collection/reconciler.mjs.map +1 -0
- package/dist/development/core/collection/state.d.mts +66 -0
- package/dist/development/core/collection/state.mjs +20 -0
- package/dist/development/core/collection/state.mjs.map +1 -0
- package/dist/development/core/collection/url.d.mts +71 -0
- package/dist/development/core/collection/url.mjs +376 -0
- package/dist/development/core/collection/url.mjs.map +1 -0
- package/dist/development/core/constants.mjs +7 -0
- package/dist/development/core/constants.mjs.map +1 -0
- package/dist/development/core/development.d.mts +56 -0
- package/dist/development/core/development.mjs +45 -0
- package/dist/development/core/headers.mjs +43 -0
- package/dist/development/core/headers.mjs.map +1 -0
- package/dist/development/core/index.d.mts +54 -0
- package/dist/development/core/logging/logging.d.mts +21 -0
- package/dist/development/core/logging/logging.mjs +99 -0
- package/dist/development/core/logging/logging.mjs.map +1 -0
- package/dist/development/core/logging/types.d.mts +40 -0
- package/dist/development/core/logging/types.mjs +18 -0
- package/dist/development/core/logging/types.mjs.map +1 -0
- package/dist/development/core/money/cache.mjs +25 -0
- package/dist/development/core/money/cache.mjs.map +1 -0
- package/dist/development/core/money/format.d.mts +15 -0
- package/dist/development/core/money/format.mjs +243 -0
- package/dist/development/core/money/format.mjs.map +1 -0
- package/dist/development/core/money/types.d.mts +47 -0
- package/dist/development/core/observable.mjs +46 -0
- package/dist/development/core/observable.mjs.map +1 -0
- package/dist/development/core/predictive-search/constants.d.mts +5 -0
- package/dist/development/core/predictive-search/constants.mjs +6 -0
- package/dist/development/core/predictive-search/constants.mjs.map +1 -0
- package/dist/development/core/predictive-search/form.d.mts +31 -0
- package/dist/development/core/predictive-search/form.mjs +31 -0
- package/dist/development/core/predictive-search/form.mjs.map +1 -0
- package/dist/development/core/predictive-search/index.d.mts +6 -0
- package/dist/development/core/predictive-search/queries.d.mts +118 -0
- package/dist/development/core/predictive-search/queries.mjs +81 -0
- package/dist/development/core/predictive-search/queries.mjs.map +1 -0
- package/dist/development/core/predictive-search/search.d.mts +32 -0
- package/dist/development/core/predictive-search/search.mjs +74 -0
- package/dist/development/core/predictive-search/search.mjs.map +1 -0
- package/dist/development/core/predictive-search/server-handlers.d.mts +36 -0
- package/dist/development/core/predictive-search/server-handlers.mjs +113 -0
- package/dist/development/core/predictive-search/server-handlers.mjs.map +1 -0
- package/dist/development/core/predictive-search/store.d.mts +44 -0
- package/dist/development/core/predictive-search/store.mjs +224 -0
- package/dist/development/core/predictive-search/store.mjs.map +1 -0
- package/dist/development/core/predictive-search/url.d.mts +41 -0
- package/dist/development/core/predictive-search/url.mjs +71 -0
- package/dist/development/core/predictive-search/url.mjs.map +1 -0
- package/dist/development/core/product/accept-variant-id.mjs +98 -0
- package/dist/development/core/product/accept-variant-id.mjs.map +1 -0
- package/dist/development/core/product/form.d.mts +63 -0
- package/dist/development/core/product/form.mjs +44 -0
- package/dist/development/core/product/form.mjs.map +1 -0
- package/dist/development/core/product/index.d.mts +5 -0
- package/dist/development/core/product/options.d.mts +43 -0
- package/dist/development/core/product/options.mjs +296 -0
- package/dist/development/core/product/options.mjs.map +1 -0
- package/dist/development/core/product/product-form.d.mts +72 -0
- package/dist/development/core/product/product-form.mjs +158 -0
- package/dist/development/core/product/product-form.mjs.map +1 -0
- package/dist/development/core/product/state.d.mts +68 -0
- package/dist/development/core/product/url.d.mts +47 -0
- package/dist/development/core/product/url.mjs +69 -0
- package/dist/development/core/product/url.mjs.map +1 -0
- package/dist/development/core/request-context.d.mts +75 -0
- package/dist/development/core/request-context.mjs +141 -0
- package/dist/development/core/request-context.mjs.map +1 -0
- package/dist/development/core/request-routing/handle-shopify-redirects.d.mts +17 -0
- package/dist/development/core/request-routing/handle-shopify-redirects.mjs +31 -0
- package/dist/development/core/request-routing/handle-shopify-redirects.mjs.map +1 -0
- package/dist/development/core/request-routing/handle-shopify-routes.d.mts +1 -0
- package/dist/development/core/request-routing/handle-shopify-routes.development.d.mts +11 -0
- package/dist/development/core/request-routing/handle-shopify-routes.development.mjs +16 -0
- package/dist/development/core/request-routing/handle-shopify-routes.development.mjs.map +1 -0
- package/dist/development/core/request-routing/handle-shopify-routes.mjs +42 -0
- package/dist/development/core/request-routing/handle-shopify-routes.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/admin-redirect.mjs +12 -0
- package/dist/development/core/request-routing/interceptors/admin-redirect.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/ajax-api.mjs +16 -0
- package/dist/development/core/request-routing/interceptors/ajax-api.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/api-proxy.mjs +20 -0
- package/dist/development/core/request-routing/interceptors/api-proxy.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/checkout.mjs +58 -0
- package/dist/development/core/request-routing/interceptors/checkout.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/graphiql.mjs +46 -0
- package/dist/development/core/request-routing/interceptors/graphiql.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/mcp-proxy.mjs +23 -0
- package/dist/development/core/request-routing/interceptors/mcp-proxy.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/proxy.mjs +73 -0
- package/dist/development/core/request-routing/interceptors/proxy.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/query-param-redirect.mjs +22 -0
- package/dist/development/core/request-routing/interceptors/query-param-redirect.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/sfapi-proxy.mjs +27 -0
- package/dist/development/core/request-routing/interceptors/sfapi-proxy.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/standard-routes.mjs +19 -0
- package/dist/development/core/request-routing/interceptors/standard-routes.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/url-redirects.mjs +27 -0
- package/dist/development/core/request-routing/interceptors/url-redirects.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/well-known.mjs +22 -0
- package/dist/development/core/request-routing/interceptors/well-known.mjs.map +1 -0
- package/dist/development/core/request-routing/registered-routes.d.mts +7 -0
- package/dist/development/core/request-routing/registered-routes.mjs +72 -0
- package/dist/development/core/request-routing/registered-routes.mjs.map +1 -0
- package/dist/development/core/request-routing/route-types.d.mts +56 -0
- package/dist/development/core/request-routing/safe-apply-response-headers.mjs +16 -0
- package/dist/development/core/request-routing/safe-apply-response-headers.mjs.map +1 -0
- package/dist/development/core/shop-pay/shop-pay.d.mts +102 -0
- package/dist/development/core/shop-pay/shop-pay.mjs +289 -0
- package/dist/development/core/shop-pay/shop-pay.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/analytics.mjs +26 -0
- package/dist/development/core/shopify-scripts/analytics.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/consent.mjs +17 -0
- package/dist/development/core/shopify-scripts/consent.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/constants.mjs +19 -0
- package/dist/development/core/shopify-scripts/constants.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/deprecated-cookies.mjs +97 -0
- package/dist/development/core/shopify-scripts/deprecated-cookies.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/global.d.mts +1 -0
- package/dist/development/core/shopify-scripts/global.mjs +86 -0
- package/dist/development/core/shopify-scripts/global.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/index.d.mts +27 -0
- package/dist/development/core/shopify-scripts/index.mjs +145 -0
- package/dist/development/core/shopify-scripts/index.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/initialize.d.mts +18 -0
- package/dist/development/core/shopify-scripts/initialize.mjs +27 -0
- package/dist/development/core/shopify-scripts/initialize.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/page-view.mjs +49 -0
- package/dist/development/core/shopify-scripts/page-view.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/perfkit.mjs +33 -0
- package/dist/development/core/shopify-scripts/perfkit.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/render.d.mts +1 -0
- package/dist/development/core/shopify-scripts/render.mjs +23 -0
- package/dist/development/core/shopify-scripts/render.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/types.d.mts +76 -0
- package/dist/development/core/shopify-scripts/utils/cookie-domain.mjs +43 -0
- package/dist/development/core/shopify-scripts/utils/cookie-domain.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/utils/inline-script.mjs +8 -0
- package/dist/development/core/shopify-scripts/utils/inline-script.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/utils/navigation.mjs +46 -0
- package/dist/development/core/shopify-scripts/utils/navigation.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/utils/tracking-values.mjs +65 -0
- package/dist/development/core/shopify-scripts/utils/tracking-values.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/utils/uuid.mjs +17 -0
- package/dist/development/core/shopify-scripts/utils/uuid.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/webmcp.mjs +22 -0
- package/dist/development/core/shopify-scripts/webmcp.mjs.map +1 -0
- package/dist/development/core/standard-routes/build.d.mts +34 -0
- package/dist/development/core/standard-routes/build.mjs +54 -0
- package/dist/development/core/standard-routes/build.mjs.map +1 -0
- package/dist/development/core/standard-routes/defaults.mjs +31 -0
- package/dist/development/core/standard-routes/defaults.mjs.map +1 -0
- package/dist/development/core/standard-routes/match.mjs +108 -0
- package/dist/development/core/standard-routes/match.mjs.map +1 -0
- package/dist/development/core/standard-routes/path.mjs +58 -0
- package/dist/development/core/standard-routes/path.mjs.map +1 -0
- package/dist/development/core/standard-routes/redirects.mjs +51 -0
- package/dist/development/core/standard-routes/redirects.mjs.map +1 -0
- package/dist/development/core/standard-routes/types.d.mts +95 -0
- package/dist/development/core/types.d.mts +11 -0
- package/dist/development/core/url.mjs +42 -0
- package/dist/development/core/url.mjs.map +1 -0
- package/dist/development/core/utils/load-script.mjs +34 -0
- package/dist/development/core/utils/load-script.mjs.map +1 -0
- package/dist/development/core/utils/parse-gid.mjs +33 -0
- package/dist/development/core/utils/parse-gid.mjs.map +1 -0
- package/dist/development/customer-account/session.d.mts +46 -0
- package/dist/development/customer-account/session.mjs +21 -0
- package/dist/development/customer-account/session.mjs.map +1 -0
- package/dist/development/globals.d.mts +64 -0
- package/dist/development/graphql/generated/customer-account-api-types.d.mts +13 -0
- package/dist/development/graphql/generated/graphql-env.d.mts +19280 -0
- package/dist/development/graphql/generated/storefront-api-types.d.mts +47 -0
- package/dist/development/graphql/graphql.d.mts +40 -0
- package/dist/development/graphql/graphql.mjs +16 -0
- package/dist/development/graphql/graphql.mjs.map +1 -0
- package/dist/development/graphql/index.d.mts +2 -0
- package/dist/development/graphql/scalars.d.mts +15 -0
- package/dist/development/graphql/type-resolver.d.mts +229 -0
- package/dist/development/react/cart.d.mts +44 -0
- package/dist/development/react/cart.mjs +155 -0
- package/dist/development/react/cart.mjs.map +1 -0
- package/dist/development/react/collection.d.mts +91 -0
- package/dist/development/react/collection.mjs +129 -0
- package/dist/development/react/collection.mjs.map +1 -0
- package/dist/development/react/index.d.mts +13 -0
- package/dist/development/react/index.mjs +10 -0
- package/dist/development/react/predictive-search.d.mts +49 -0
- package/dist/development/react/predictive-search.mjs +133 -0
- package/dist/development/react/predictive-search.mjs.map +1 -0
- package/dist/development/react/product.d.mts +72 -0
- package/dist/development/react/product.mjs +127 -0
- package/dist/development/react/product.mjs.map +1 -0
- package/dist/development/react/shop-pay.d.mts +9 -0
- package/dist/development/react/shop-pay.mjs +16 -0
- package/dist/development/react/shop-pay.mjs.map +1 -0
- package/dist/development/react/shopify-scripts.d.mts +20 -0
- package/dist/development/react/shopify-scripts.mjs +39 -0
- package/dist/development/react/shopify-scripts.mjs.map +1 -0
- package/dist/development/vendor/standard-actions.d.mts +134 -0
- package/dist/development/vendor/standard-events.d.mts +1107 -0
- package/dist/development/vue/cart.d.mts +46 -0
- package/dist/development/vue/cart.mjs +122 -0
- package/dist/development/vue/cart.mjs.map +1 -0
- package/dist/development/vue/collection.d.mts +46 -0
- package/dist/development/vue/collection.mjs +108 -0
- package/dist/development/vue/collection.mjs.map +1 -0
- package/dist/development/vue/index.d.mts +11 -0
- package/dist/development/vue/index.mjs +8 -0
- package/dist/development/vue/predictive-search.d.mts +124 -0
- package/dist/development/vue/predictive-search.mjs +171 -0
- package/dist/development/vue/predictive-search.mjs.map +1 -0
- package/dist/development/vue/product.d.mts +57 -0
- package/dist/development/vue/product.mjs +167 -0
- package/dist/development/vue/product.mjs.map +1 -0
- package/dist/development/vue/shop-pay.d.mts +25 -0
- package/dist/development/vue/shop-pay.mjs +35 -0
- package/dist/development/vue/shop-pay.mjs.map +1 -0
- package/dist/development/vue/shopify-scripts.d.mts +127 -0
- package/dist/development/vue/shopify-scripts.mjs +79 -0
- package/dist/development/vue/shopify-scripts.mjs.map +1 -0
- package/dist/globals.d.mts +64 -0
- package/dist/graphql/generated/customer-account-api-types.d.mts +13 -0
- package/dist/graphql/generated/customer-account-graphql-env.d.mts +22170 -0
- package/dist/graphql/generated/graphql-env.d.mts +19280 -0
- package/dist/graphql/generated/storefront-api-types.d.mts +47 -0
- package/dist/graphql/graphql.d.mts +40 -0
- package/dist/graphql/graphql.mjs +16 -0
- package/dist/graphql/graphql.mjs.map +1 -0
- package/dist/graphql/index.d.mts +2 -0
- package/dist/graphql/scalars.d.mts +26 -0
- package/dist/graphql/type-resolver.d.mts +229 -0
- package/dist/react/cart.d.mts +44 -0
- package/dist/react/cart.mjs +155 -0
- package/dist/react/cart.mjs.map +1 -0
- package/dist/react/collection.d.mts +91 -0
- package/dist/react/collection.mjs +129 -0
- package/dist/react/collection.mjs.map +1 -0
- package/dist/react/index.d.mts +13 -0
- package/dist/react/index.mjs +10 -0
- package/dist/react/predictive-search.d.mts +49 -0
- package/dist/react/predictive-search.mjs +133 -0
- package/dist/react/predictive-search.mjs.map +1 -0
- package/dist/react/product.d.mts +72 -0
- package/dist/react/product.mjs +127 -0
- package/dist/react/product.mjs.map +1 -0
- package/dist/react/shop-pay.d.mts +9 -0
- package/dist/react/shop-pay.mjs +16 -0
- package/dist/react/shop-pay.mjs.map +1 -0
- package/dist/react/shopify-scripts.d.mts +20 -0
- package/dist/react/shopify-scripts.mjs +39 -0
- package/dist/react/shopify-scripts.mjs.map +1 -0
- package/dist/storefront-api-types.d.ts +2351 -2390
- package/dist/storefront.schema.json +41534 -1
- package/dist/ts-plugin/index.cjs +68 -0
- package/dist/ts-plugin/index.cjs.map +1 -0
- package/dist/ts-plugin/index.d.cts +4 -0
- package/dist/vendor/standard-actions.d.mts +134 -0
- package/dist/vendor/standard-events.d.mts +1107 -0
- package/dist/vite/certificate-prompt.mjs +24 -0
- package/dist/vite/certificate-prompt.mjs.map +1 -0
- package/dist/vite/index.d.mts +2 -0
- package/dist/vite/index.mjs +3 -0
- package/dist/vite/local-https.d.mts +47 -0
- package/dist/vite/local-https.mjs +276 -0
- package/dist/vite/local-https.mjs.map +1 -0
- package/dist/vite/mkcert.mjs +141 -0
- package/dist/vite/mkcert.mjs.map +1 -0
- package/dist/vue/cart.d.mts +46 -0
- package/dist/vue/cart.mjs +122 -0
- package/dist/vue/cart.mjs.map +1 -0
- package/dist/vue/collection.d.mts +46 -0
- package/dist/vue/collection.mjs +108 -0
- package/dist/vue/collection.mjs.map +1 -0
- package/dist/vue/index.d.mts +11 -0
- package/dist/vue/index.mjs +8 -0
- package/dist/vue/predictive-search.d.mts +124 -0
- package/dist/vue/predictive-search.mjs +171 -0
- package/dist/vue/predictive-search.mjs.map +1 -0
- package/dist/vue/product.d.mts +57 -0
- package/dist/vue/product.mjs +167 -0
- package/dist/vue/product.mjs.map +1 -0
- package/dist/vue/shop-pay.d.mts +25 -0
- package/dist/vue/shop-pay.mjs +35 -0
- package/dist/vue/shop-pay.mjs.map +1 -0
- package/dist/vue/shopify-scripts.d.mts +127 -0
- package/dist/vue/shopify-scripts.mjs +79 -0
- package/dist/vue/shopify-scripts.mjs.map +1 -0
- package/package.json +116 -86
- package/skills/hydrogen-analytics/SKILL.md +80 -0
- package/skills/hydrogen-analytics/references/react.md +160 -0
- package/skills/hydrogen-analytics/references/vue.md +80 -0
- package/skills/hydrogen-cart-drawer/SKILL.md +248 -0
- package/skills/hydrogen-cart-drawer/references/accessibility.md +109 -0
- package/skills/hydrogen-cart-drawer/references/css.md +67 -0
- package/skills/hydrogen-cart-ui/SKILL.md +224 -0
- package/skills/hydrogen-cart-ui/references/nextjs.md +89 -0
- package/skills/hydrogen-cart-ui/references/react.md +285 -0
- package/skills/hydrogen-cart-ui/references/vue.md +228 -0
- package/skills/hydrogen-collection-browser/SKILL.md +83 -0
- package/skills/hydrogen-collection-browser/references/nextjs.md +118 -0
- package/skills/hydrogen-collection-browser/references/nuxt.md +108 -0
- package/skills/hydrogen-collection-browser/references/react.md +301 -0
- package/skills/hydrogen-customer-account/SKILL.md +107 -0
- package/skills/hydrogen-image/SKILL.md +65 -0
- package/skills/hydrogen-local-https/SKILL.md +142 -0
- package/skills/hydrogen-markets/SKILL.md +221 -0
- package/skills/hydrogen-markets/references/nextjs.md +157 -0
- package/skills/hydrogen-money/SKILL.md +67 -0
- package/skills/hydrogen-oxygen/SKILL.md +245 -0
- package/skills/hydrogen-oxygen/references/react-router.md +230 -0
- package/skills/hydrogen-predictive-search/SKILL.md +130 -0
- package/skills/hydrogen-predictive-search/references/react.md +32 -0
- package/skills/hydrogen-predictive-search/references/vue.md +40 -0
- package/skills/hydrogen-request-handlers/SKILL.md +107 -0
- package/skills/hydrogen-request-handlers/references/frameworks.md +179 -0
- package/skills/hydrogen-request-handlers/references/nextjs.md +137 -0
- package/skills/hydrogen-request-handlers/references/nuxt.md +215 -0
- package/skills/hydrogen-routing/SKILL.md +171 -0
- package/skills/hydrogen-setup/SKILL.md +50 -0
- package/skills/hydrogen-setup/references/analytics.md +624 -0
- package/skills/hydrogen-setup/steps/1-inspect-app.md +62 -0
- package/skills/hydrogen-setup/steps/10-analytics.md +10 -0
- package/skills/hydrogen-setup/steps/11-verify.md +31 -0
- package/skills/hydrogen-setup/steps/2-scaffold.md +86 -0
- package/skills/hydrogen-setup/steps/3-build-home-page.md +37 -0
- package/skills/hydrogen-setup/steps/4-collection-and-search.md +14 -0
- package/skills/hydrogen-setup/steps/5-cart.md +10 -0
- package/skills/hydrogen-setup/steps/6-product-detail-page.md +416 -0
- package/skills/hydrogen-setup/steps/7-shopify-runtime-scripts.md +69 -0
- package/skills/hydrogen-setup/steps/8-cart-drawer-and-navbar.md +35 -0
- package/skills/hydrogen-setup/steps/9-account-page.md +54 -0
- package/skills/hydrogen-shop-pay/SKILL.md +79 -0
- package/skills/hydrogen-shop-pay/references/core.md +66 -0
- package/skills/hydrogen-shop-pay/references/react.md +50 -0
- package/skills/hydrogen-shop-pay/references/vue.md +39 -0
- package/skills/hydrogen-smoke-test/SKILL.md +205 -0
- package/skills/hydrogen-storefront-client/SKILL.md +322 -0
- package/skills/hydrogen-storefront-client/references/astro.md +125 -0
- package/skills/hydrogen-storefront-client/references/caching.md +25 -0
- package/skills/hydrogen-storefront-client/references/nextjs.md +121 -0
- package/skills/hydrogen-storefront-client/references/nuxt.md +121 -0
- package/skills/hydrogen-storefront-client/references/query-validation.md +95 -0
- package/skills/hydrogen-storefront-client/references/react-router.md +81 -0
- package/skills/hydrogen-storefront-client/references/solidstart.md +131 -0
- package/skills/hydrogen-storefront-client/references/sveltekit.md +169 -0
- package/skills/hydrogen-variant-form/SKILL.md +267 -0
- package/skills/hydrogen-variant-form/references/nextjs.md +207 -0
- package/skills/hydrogen-variant-form/references/nuxt.md +95 -0
- package/skills/hydrogen-variant-form/references/react.md +71 -0
- package/dist/dev/get-virtual-routes-H72465VB.js +0 -74
- package/dist/dev/hydrogen-routes.d.ts +0 -5
- package/dist/dev/hydrogen-routes.js +0 -25
- package/dist/development/get-virtual-routes-ACFZHU42.js +0 -71
- package/dist/development/get-virtual-routes-ACFZHU42.js.map +0 -1
- package/dist/development/index.cjs +0 -6978
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -6631
- package/dist/development/index.js.map +0 -1
- package/dist/development/log-seo-tags-IG37ONQ2.js +0 -74
- package/dist/development/log-seo-tags-IG37ONQ2.js.map +0 -1
- package/dist/development/react-router-preset.d.ts +0 -45
- package/dist/development/react-router-preset.js +0 -49
- package/dist/development/react-router-preset.js.map +0 -1
- package/dist/index.cjs +0 -1
- package/dist/oxygen/index.d.ts +0 -197
- package/dist/oxygen/index.js +0 -107
- package/dist/production/get-virtual-routes-ZZEGQQDV.js +0 -3
- package/dist/production/get-virtual-routes-ZZEGQQDV.js.map +0 -1
- package/dist/production/index.cjs +0 -1019
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.d.cts +0 -3260
- package/dist/production/index.d.ts +0 -3260
- package/dist/production/index.js +0 -1019
- package/dist/production/index.js.map +0 -1
- package/dist/production/log-seo-tags-TY72EQWZ.js +0 -2
- package/dist/production/log-seo-tags-TY72EQWZ.js.map +0 -1
- package/dist/production/react-router-preset.d.ts +0 -45
- package/dist/production/react-router-preset.js +0 -11
- package/dist/react-router.d.ts +0 -75
- package/dist/vite/chunk-4O5OI3OO.js +0 -127
- package/dist/vite/chunk-FAQ7TVHC.js +0 -9
- package/dist/vite/chunk-QXBQVDMY.js +0 -68
- package/dist/vite/compat-date.d.ts +0 -3
- package/dist/vite/compat-date.js +0 -6
- package/dist/vite/get-virtual-routes.d.ts +0 -21
- package/dist/vite/get-virtual-routes.js +0 -74
- package/dist/vite/hydrogen-middleware.d.ts +0 -9
- package/dist/vite/hydrogen-middleware.js +0 -7
- package/dist/vite/plugin.d.ts +0 -22
- package/dist/vite/plugin.js +0 -171
- package/dist/vite/request-events.d.ts +0 -144
- package/dist/vite/request-events.js +0 -10
- package/dist/vite/types.d.ts +0 -5
- package/dist/vite/types.js +0 -0
- package/dist/vite/virtual-routes/assets/debug-network.css +0 -609
- package/dist/vite/virtual-routes/assets/favicon-dark.svg +0 -20
- package/dist/vite/virtual-routes/assets/favicon.svg +0 -28
- package/dist/vite/virtual-routes/assets/inter-variable-font.woff2 +0 -0
- package/dist/vite/virtual-routes/assets/jetbrainsmono-variable-font.woff2 +0 -0
- package/dist/vite/virtual-routes/assets/styles.css +0 -249
- package/dist/vite/virtual-routes/components/FlameChartWrapper.jsx +0 -123
- package/dist/vite/virtual-routes/components/HydrogenLogoBaseBW.jsx +0 -32
- package/dist/vite/virtual-routes/components/HydrogenLogoBaseColor.jsx +0 -47
- package/dist/vite/virtual-routes/components/IconBanner.jsx +0 -292
- package/dist/vite/virtual-routes/components/IconClose.jsx +0 -38
- package/dist/vite/virtual-routes/components/IconDiscard.jsx +0 -44
- package/dist/vite/virtual-routes/components/IconError.jsx +0 -61
- package/dist/vite/virtual-routes/components/IconGithub.jsx +0 -23
- package/dist/vite/virtual-routes/components/IconTwitter.jsx +0 -21
- package/dist/vite/virtual-routes/components/Layout.jsx +0 -7
- package/dist/vite/virtual-routes/components/RequestDetails.jsx +0 -171
- package/dist/vite/virtual-routes/components/RequestTable.jsx +0 -91
- package/dist/vite/virtual-routes/components/RequestWaterfall.jsx +0 -151
- package/dist/vite/virtual-routes/layout.jsx +0 -33
- package/dist/vite/virtual-routes/lib/useDebugNetworkServer.jsx +0 -178
- package/dist/vite/virtual-routes/routes/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.jsx +0 -37
- package/dist/vite/virtual-routes/routes/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.tsx +0 -79
- package/dist/vite/virtual-routes/routes/graphiql.jsx +0 -5
- package/dist/vite/virtual-routes/routes/index.jsx +0 -265
- package/dist/vite/virtual-routes/routes/subrequest-profiler.jsx +0 -243
- package/dist/vite/virtual-routes/virtual-root-with-layout.jsx +0 -63
- package/dist/vite/virtual-routes/virtual-root.jsx +0 -67
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-with-cache.mjs","names":[],"sources":["../../../src/core/cache/fetch-with-cache.ts"],"sourcesContent":["import { HYDROGEN_CACHE_STATUS_PRODUCT } from \"./cache-status\";\nimport { type CacheKey } from \"./key\";\nimport {\n type CreateRunWithCacheOptions,\n type RunWithCache,\n type RunWithCacheResult,\n StaleFallbackDisabledError,\n createRunWithCache,\n} from \"./run-with-cache\";\nimport { type SerializableCacheValue } from \"./store\";\nimport { NO_STORE, type CachingStrategy } from \"./strategies\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\ntype FetchInput = Parameters<typeof fetch>[0];\ntype FetchInit = Parameters<typeof fetch>[1];\n\ntype SerializableResponse = SerializableCacheValue & {\n body: string;\n cacheable: boolean;\n headers: [string, string][];\n status: number;\n statusText: string;\n};\n\nexport type FetchCacheResponseContext = {\n ok: boolean;\n status: number;\n statusText: string;\n headers: Headers;\n url: string;\n text(): Promise<string>;\n json?: () => Promise<unknown>;\n};\n\nexport type FetchCacheOptions = {\n key: CacheKey;\n strategy: CachingStrategy;\n annotateCacheStatus?: boolean;\n /**\n * Runs only for OK responses with text-serializable bodies. Non-OK responses\n * and binary/streaming responses are never cached.\n */\n shouldCacheResponse?: (context: FetchCacheResponseContext) => MaybePromise<boolean>;\n};\n\ntype FetchWithCache = {\n (input: FetchInput, init?: FetchInit): Promise<Response>;\n (input: FetchInput, init: FetchInit | undefined, options: FetchCacheOptions): Promise<Response>;\n};\n\ntype CreateFetchWithCacheOptions = (\n | CreateRunWithCacheOptions\n | {\n runWithCache: RunWithCache;\n }\n) & {\n fetch?: typeof fetch;\n};\n\nconst excludedCachedResponseHeaders = new Set([\"set-cookie\", \"server-timing\"]);\nconst staleIfErrorStatuses = new Set([500, 502, 503, 504]);\n\nclass UnserializableResponseError extends StaleFallbackDisabledError {\n constructor() {\n super(\"Response body is not serializable for cache.\");\n }\n}\n\nclass StaleFallbackEligibleResponseError extends Error {\n constructor() {\n super(\"Origin returned an unserializable response eligible for stale-if-error fallback.\");\n }\n}\n\nclass ServerResponseError extends Error {\n readonly response: SerializableResponse;\n\n constructor(response: SerializableResponse) {\n super(\"Origin returned a response eligible for stale-if-error fallback.\");\n this.response = response;\n }\n}\n\nexport function createFetchWithCache({\n fetch: customFetch,\n ...options\n}: CreateFetchWithCacheOptions): FetchWithCache {\n const resolvedFetch = customFetch ?? globalThis.fetch;\n const runWithCache =\n \"runWithCache\" in options ? options.runWithCache : createRunWithCache(options);\n\n return async function fetchWithCache(\n input: FetchInput,\n init?: FetchInit,\n cacheOptions?: FetchCacheOptions,\n ): Promise<Response> {\n if (!cacheOptions) return resolvedFetch(input, init);\n\n if (cacheOptions.strategy.mode === NO_STORE) {\n return annotateResponse(\n await resolvedFetch(input, init),\n getCacheStatusHeader(\"fwd=bypass\"),\n cacheOptions,\n );\n }\n\n let passthroughResponse: Response | undefined;\n let result: RunWithCacheResult<SerializableResponse>;\n\n try {\n result = await runWithCache<SerializableResponse>(\n {\n key: cacheOptions.key,\n strategy: cacheOptions.strategy,\n },\n async () => {\n const response = await resolvedFetch(input, init);\n\n if (!response.ok) {\n if (isStaleIfErrorStatus(response.status)) {\n if (!canSerializeBodyAsText(response)) {\n passthroughResponse = response;\n throw new StaleFallbackEligibleResponseError();\n }\n\n throw new ServerResponseError(\n await serializeResponse(response, {\n cacheable: false,\n fallbackOnError: true,\n }),\n );\n }\n\n return {\n data: await serializeResponse(response, {\n cacheable: false,\n fallbackOnError: true,\n }),\n shouldCache: false,\n };\n }\n\n if (!canSerializeBodyAsText(response)) {\n passthroughResponse = response;\n\n // Signal bypass so the original streaming response can be returned\n // to this caller without attempting to serialize it for storage.\n throw new UnserializableResponseError();\n }\n\n const bodyReader = createBodyReader(response);\n const shouldCache = await shouldCacheResponse(response, bodyReader, cacheOptions);\n\n if (!shouldCache) {\n return {\n data: await serializeResponse(response, {\n bodyReader,\n cacheable: false,\n fallbackOnError: true,\n }),\n shouldCache: false,\n };\n }\n\n const data = await serializeResponse(response, {\n bodyReader,\n cacheable: true,\n fallbackOnError: true,\n });\n\n return {\n data,\n shouldCache: data.cacheable,\n };\n },\n );\n } catch (error) {\n if (error instanceof ServerResponseError) {\n return annotateResponse(\n fromSerializableResponse(error.response),\n getCacheStatusHeader(\"fwd=bypass\"),\n cacheOptions,\n );\n }\n\n if (error instanceof UnserializableResponseError) {\n return annotateResponse(\n // The raw Response body is not cache-serializable, so return the\n // original response. Refetch defensively if the response was not kept.\n passthroughResponse ?? (await resolvedFetch(input, init)),\n getCacheStatusHeader(\"fwd=bypass\"),\n cacheOptions,\n );\n }\n\n if (error instanceof StaleFallbackEligibleResponseError) {\n return annotateResponse(\n // Return the original unserializable response. This error type can\n // also trigger stale-if-error fallback when a stale entry exists.\n passthroughResponse ?? (await resolvedFetch(input, init)),\n getCacheStatusHeader(\"fwd=bypass\"),\n cacheOptions,\n );\n }\n\n throw error;\n }\n\n return annotateResponse(\n fromSerializableResponse(result.data),\n result.cacheStatus === \"hit\"\n ? getCacheStatusHeader(\"hit\")\n : getNonHitCacheStatusHeader(result.data.cacheable, result.cacheStatus),\n cacheOptions,\n );\n };\n}\n\nfunction shouldCacheResponse(\n response: Response,\n bodyReader: BodyReader,\n options: FetchCacheOptions,\n): MaybePromise<boolean> {\n const context: FetchCacheResponseContext = {\n ok: response.ok,\n status: response.status,\n statusText: response.statusText,\n headers: new Headers(response.headers),\n url: response.url,\n text: bodyReader.text,\n };\n\n if (isJsonResponse(response)) {\n context.json = bodyReader.json;\n }\n\n return options.shouldCacheResponse?.(context) ?? true;\n}\n\ntype BodyReader = {\n text(): Promise<string>;\n json(): Promise<unknown>;\n};\n\ntype SerializeResponseOptions = {\n bodyReader?: BodyReader;\n cacheable: boolean;\n fallbackOnError?: boolean;\n};\n\nfunction createBodyReader(response: Response): BodyReader {\n let bodyText: Promise<string> | undefined;\n let bodyJson: Promise<unknown> | undefined;\n\n const text = () => {\n bodyText ??= response.text();\n return bodyText;\n };\n\n return {\n text,\n json() {\n bodyJson ??= text().then((value) => JSON.parse(value));\n return bodyJson;\n },\n };\n}\n\nasync function serializeResponse(\n response: Response,\n { bodyReader, cacheable, fallbackOnError = false }: SerializeResponseOptions,\n): Promise<SerializableResponse> {\n if (!canSerializeBodyAsText(response)) return emptySerializableResponse(response);\n\n try {\n return {\n body: await (bodyReader ?? createBodyReader(response)).text(),\n cacheable,\n headers: getSerializableHeaders(response.headers, cacheable),\n status: response.status,\n statusText: response.statusText,\n };\n } catch (error) {\n if (!fallbackOnError) throw error;\n return emptySerializableResponse(response);\n }\n}\n\nfunction fromSerializableResponse(response: SerializableResponse): Response {\n return new Response(response.body, {\n headers: response.headers,\n status: response.status,\n statusText: response.statusText,\n });\n}\n\nfunction emptySerializableResponse(response: Response): SerializableResponse {\n return {\n body: \"\",\n cacheable: false,\n headers: [],\n status: response.status,\n statusText: response.statusText,\n };\n}\n\nfunction getSerializableHeaders(headers: Headers, cacheable: boolean): [string, string][] {\n if (!cacheable) return [...headers];\n\n // Cacheable serialized responses can be returned to future requests, so\n // per-request headers must not be copied.\n return [...headers].filter(([key]) => !excludedCachedResponseHeaders.has(key.toLowerCase()));\n}\n\nfunction annotateResponse(\n response: Response,\n cacheStatus: string,\n options: FetchCacheOptions,\n): Response {\n if (options.annotateCacheStatus === false) return response;\n\n const headers = new Headers(response.headers);\n headers.append(\"Cache-Status\", cacheStatus);\n\n return new Response(response.body, {\n headers,\n status: response.status,\n statusText: response.statusText,\n });\n}\n\nfunction getNonHitCacheStatusHeader(shouldCache: boolean, cacheStatus: \"miss\" | \"bypass\"): string {\n if (cacheStatus === \"bypass\") return getCacheStatusHeader(\"fwd=bypass\");\n return shouldCache\n ? getCacheStatusHeader(\"fwd=uri-miss; stored\")\n : getCacheStatusHeader(\"fwd=bypass\");\n}\n\nfunction getCacheStatusHeader(value: string): string {\n return `${HYDROGEN_CACHE_STATUS_PRODUCT}; ${value}`;\n}\n\nfunction isJsonResponse(response: Response): boolean {\n return response.headers.get(\"content-type\")?.toLowerCase().includes(\"json\") ?? false;\n}\n\nfunction isStaleIfErrorStatus(status: number): boolean {\n return staleIfErrorStatuses.has(status);\n}\n\nfunction canSerializeBodyAsText(response: Response): boolean {\n if (response.body == null) return true;\n\n const contentType = response.headers.get(\"content-type\");\n return contentType != null && /\\b(json|text|xml|html|graphql|javascript)\\b/i.test(contentType);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/core/cache/key.ts
|
|
2
|
+
const textEncoder = new TextEncoder();
|
|
3
|
+
async function hashCacheKey(key) {
|
|
4
|
+
const serialized = typeof key === "string" ? `string:${key}` : `array:${serializeArrayKey(key)}`;
|
|
5
|
+
return `h2:${hexEncode(await crypto.subtle.digest("SHA-256", textEncoder.encode(serialized)))}`;
|
|
6
|
+
}
|
|
7
|
+
function serializeArrayKey(value) {
|
|
8
|
+
const values = [];
|
|
9
|
+
for (let index = 0; index < value.length; index++) {
|
|
10
|
+
if (!(index in value)) throw new TypeError("Cache key arrays cannot contain empty slots.");
|
|
11
|
+
values.push(serializeCacheKeyPrimitive(value[index]));
|
|
12
|
+
}
|
|
13
|
+
return `[${values.join(",")}]`;
|
|
14
|
+
}
|
|
15
|
+
function serializeCacheKeyPrimitive(value) {
|
|
16
|
+
if (value === null) return "null";
|
|
17
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
18
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
19
|
+
throw new TypeError(`Cache key arrays must contain only primitive values. Received: ${typeof value}`);
|
|
20
|
+
}
|
|
21
|
+
function hexEncode(bytes) {
|
|
22
|
+
return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { hashCacheKey };
|
|
27
|
+
//# sourceMappingURL=key.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.mjs","names":[],"sources":["../../../src/core/cache/key.ts"],"sourcesContent":["export type CacheKeyPrimitive = string | number | boolean | null;\n\nexport type CacheKey = string | readonly CacheKeyPrimitive[];\n\nconst textEncoder = new TextEncoder();\n\nexport async function hashCacheKey(key: CacheKey): Promise<string> {\n const serialized = typeof key === \"string\" ? `string:${key}` : `array:${serializeArrayKey(key)}`;\n const bytes = await crypto.subtle.digest(\"SHA-256\", textEncoder.encode(serialized));\n\n return `h2:${hexEncode(bytes)}`;\n}\n\nfunction serializeArrayKey(value: readonly unknown[]): string {\n const values: string[] = [];\n for (let index = 0; index < value.length; index++) {\n if (!(index in value)) {\n throw new TypeError(\"Cache key arrays cannot contain empty slots.\");\n }\n\n values.push(serializeCacheKeyPrimitive(value[index]));\n }\n\n return `[${values.join(\",\")}]`;\n}\n\nfunction serializeCacheKeyPrimitive(value: unknown): string {\n if (value === null) return \"null\";\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n\n throw new TypeError(\n `Cache key arrays must contain only primitive values. Received: ${typeof value}`,\n );\n}\n\nfunction hexEncode(bytes: ArrayBuffer): string {\n return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n"],"mappings":";AAIA,MAAM,cAAc,IAAI,aAAa;AAErC,eAAsB,aAAa,KAAgC;CACjE,MAAM,aAAa,OAAO,QAAQ,WAAW,UAAU,QAAQ,SAAS,kBAAkB,IAAI;AAG9F,QAAO,MAAM,UAAU,MAFH,OAAO,OAAO,OAAO,WAAW,YAAY,OAAO,WAAW,CAAC,CAEtD;;AAG/B,SAAS,kBAAkB,OAAmC;CAC5D,MAAM,SAAmB,EAAE;AAC3B,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;AACjD,MAAI,EAAE,SAAS,OACb,OAAM,IAAI,UAAU,+CAA+C;AAGrE,SAAO,KAAK,2BAA2B,MAAM,OAAO,CAAC;;AAGvD,QAAO,IAAI,OAAO,KAAK,IAAI,CAAC;;AAG9B,SAAS,2BAA2B,OAAwB;AAC1D,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,OAAO,UAAU,SAAU,QAAO,KAAK,UAAU,MAAM;AAC3D,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAChD,QAAO,OAAO,MAAM;AAGtB,OAAM,IAAI,UACR,kEAAkE,OAAO,QAC1E;;AAGH,SAAS,UAAU,OAA4B;AAC7C,QAAO,CAAC,GAAG,IAAI,WAAW,MAAM,CAAC,CAAC,KAAK,SAAS,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CacheKey } from "./key.mjs";
|
|
2
|
+
import { CachingStrategy } from "./strategies.mjs";
|
|
3
|
+
import { KeyValueCacheLike, SerializableCacheValue, WebCacheLike } from "./store.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/core/cache/run-with-cache.d.ts
|
|
6
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
7
|
+
type WaitUntil = (promise: Promise<unknown>) => void;
|
|
8
|
+
type CacheInstance = WebCacheLike | KeyValueCacheLike;
|
|
9
|
+
type CreateRunWithCacheOptions = {
|
|
10
|
+
cache: CacheInstance;
|
|
11
|
+
waitUntil?: WaitUntil;
|
|
12
|
+
};
|
|
13
|
+
type RunWithCacheOptions = {
|
|
14
|
+
key: CacheKey;
|
|
15
|
+
strategy: CachingStrategy;
|
|
16
|
+
};
|
|
17
|
+
type CacheDecision<T extends SerializableCacheValue> = {
|
|
18
|
+
/**
|
|
19
|
+
* Must be a JSON-serializable object. The cache store may persist this value
|
|
20
|
+
* through `JSON.stringify`; nested serializability is the caller's contract.
|
|
21
|
+
*/
|
|
22
|
+
data: T;
|
|
23
|
+
shouldCache: boolean;
|
|
24
|
+
};
|
|
25
|
+
type RunWithCacheResult<T extends SerializableCacheValue> = {
|
|
26
|
+
data: T;
|
|
27
|
+
cacheStatus: "hit" | "miss" | "bypass";
|
|
28
|
+
};
|
|
29
|
+
type RunWithCache = <T extends SerializableCacheValue>(options: RunWithCacheOptions, run: () => MaybePromise<CacheDecision<T>>) => Promise<RunWithCacheResult<T>>;
|
|
30
|
+
declare function createRunWithCache({
|
|
31
|
+
cache,
|
|
32
|
+
waitUntil
|
|
33
|
+
}: CreateRunWithCacheOptions): RunWithCache;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { CacheInstance, CreateRunWithCacheOptions, RunWithCache, WaitUntil, createRunWithCache };
|
|
36
|
+
//# sourceMappingURL=run-with-cache.d.mts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { hashCacheKey } from "./key.mjs";
|
|
2
|
+
import { NO_STORE, getCacheRetentionTtl } from "./strategies.mjs";
|
|
3
|
+
import { createNormalizedCacheStore } from "./store.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/core/cache/run-with-cache.ts
|
|
6
|
+
/**
|
|
7
|
+
* Internal control-flow error for adapters that need to escape the cache
|
|
8
|
+
* pipeline without being interpreted as an origin failure. `staleIfError`
|
|
9
|
+
* catches refresh failures, but it should not hide intentional bypasses.
|
|
10
|
+
*/
|
|
11
|
+
var StaleFallbackDisabledError = class extends Error {};
|
|
12
|
+
function createRunWithCache({ cache, waitUntil }) {
|
|
13
|
+
const store = createNormalizedCacheStore(cache);
|
|
14
|
+
return async function runWithCache(options, run) {
|
|
15
|
+
if (options.strategy.mode === "no-store") return {
|
|
16
|
+
data: (await runAndValidate(run)).data,
|
|
17
|
+
cacheStatus: "bypass"
|
|
18
|
+
};
|
|
19
|
+
const cacheKey = await hashCacheKey(options.key);
|
|
20
|
+
let cached;
|
|
21
|
+
try {
|
|
22
|
+
cached = await store.get(cacheKey);
|
|
23
|
+
} catch {}
|
|
24
|
+
if (cached) {
|
|
25
|
+
const state = getCacheState(cached, options.strategy);
|
|
26
|
+
if (state === "fresh") return {
|
|
27
|
+
data: cached.value,
|
|
28
|
+
cacheStatus: "hit"
|
|
29
|
+
};
|
|
30
|
+
if (state === "stale") {
|
|
31
|
+
revalidateInBackground(cacheKey, options, run);
|
|
32
|
+
return {
|
|
33
|
+
data: cached.value,
|
|
34
|
+
cacheStatus: "hit"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (state === "stale-if-error") return refreshWithStaleFallback(cacheKey, cached.value, options, run);
|
|
38
|
+
}
|
|
39
|
+
return runAndMaybeStore(cacheKey, options, run).result;
|
|
40
|
+
};
|
|
41
|
+
function revalidateInBackground(cacheKey, options, run) {
|
|
42
|
+
schedule(runAndMaybeStore(cacheKey, options, run, { scheduleCacheWrite: false }).complete);
|
|
43
|
+
}
|
|
44
|
+
async function refreshWithStaleFallback(cacheKey, staleValue, options, run) {
|
|
45
|
+
try {
|
|
46
|
+
return await runAndMaybeStore(cacheKey, options, run).result;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (!shouldFallbackToStale(error)) throw error;
|
|
49
|
+
return {
|
|
50
|
+
data: staleValue,
|
|
51
|
+
cacheStatus: "hit"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function runAndMaybeStore(key, options, run, { scheduleCacheWrite = true } = {}) {
|
|
56
|
+
let storePromise = Promise.resolve();
|
|
57
|
+
const result = Promise.resolve().then(async () => {
|
|
58
|
+
const decision = await runAndValidate(run);
|
|
59
|
+
if (!shouldStore(options.strategy, decision)) return {
|
|
60
|
+
data: decision.data,
|
|
61
|
+
cacheStatus: "miss"
|
|
62
|
+
};
|
|
63
|
+
storePromise = storeDecision(key, options, decision).catch(() => {});
|
|
64
|
+
if (waitUntil && scheduleCacheWrite) schedule(storePromise);
|
|
65
|
+
else if (!waitUntil) await storePromise;
|
|
66
|
+
return {
|
|
67
|
+
data: decision.data,
|
|
68
|
+
cacheStatus: "miss"
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
result,
|
|
73
|
+
complete: result.then(() => storePromise, () => void 0).then(() => void 0)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function storeDecision(key, options, decision) {
|
|
77
|
+
await store.set(key, {
|
|
78
|
+
version: 1,
|
|
79
|
+
value: decision.data,
|
|
80
|
+
storedAt: Date.now(),
|
|
81
|
+
strategy: options.strategy
|
|
82
|
+
}, { strategy: options.strategy });
|
|
83
|
+
}
|
|
84
|
+
function schedule(promise) {
|
|
85
|
+
try {
|
|
86
|
+
waitUntil?.(promise);
|
|
87
|
+
} catch {}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function shouldStore(strategy, decision) {
|
|
91
|
+
return decision.shouldCache && getCacheRetentionTtl(strategy) > 0;
|
|
92
|
+
}
|
|
93
|
+
function shouldFallbackToStale(error) {
|
|
94
|
+
return !(error instanceof StaleFallbackDisabledError);
|
|
95
|
+
}
|
|
96
|
+
async function runAndValidate(run) {
|
|
97
|
+
const decision = await run();
|
|
98
|
+
if (typeof decision !== "object" || decision == null || !("data" in decision) || !("shouldCache" in decision) || typeof decision.shouldCache !== "boolean") throw new TypeError("runWithCache callback must return {data, shouldCache}.");
|
|
99
|
+
return decision;
|
|
100
|
+
}
|
|
101
|
+
function getCacheState(envelope, strategy) {
|
|
102
|
+
const age = Math.max(0, (Date.now() - envelope.storedAt) / 1e3);
|
|
103
|
+
const maxAge = strategy.maxAge ?? 0;
|
|
104
|
+
const staleWhileRevalidate = strategy.staleWhileRevalidate ?? 0;
|
|
105
|
+
const staleIfError = strategy.staleIfError ?? 0;
|
|
106
|
+
if (age <= maxAge) return "fresh";
|
|
107
|
+
if (age <= maxAge + staleWhileRevalidate) return "stale";
|
|
108
|
+
if (age <= maxAge + staleWhileRevalidate + staleIfError) return "stale-if-error";
|
|
109
|
+
return "expired";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
export { StaleFallbackDisabledError, createRunWithCache };
|
|
114
|
+
//# sourceMappingURL=run-with-cache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-with-cache.mjs","names":[],"sources":["../../../src/core/cache/run-with-cache.ts"],"sourcesContent":["import { hashCacheKey, type CacheKey } from \"./key\";\nimport {\n type CacheEnvelope,\n type KeyValueCacheLike,\n type SerializableCacheValue,\n type WebCacheLike,\n createNormalizedCacheStore,\n} from \"./store\";\nimport { NO_STORE, type CachingStrategy, getCacheRetentionTtl } from \"./strategies\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\nexport type WaitUntil = (promise: Promise<unknown>) => void;\n\nexport type CacheInstance = WebCacheLike | KeyValueCacheLike;\n\nexport type CreateRunWithCacheOptions = {\n cache: CacheInstance;\n waitUntil?: WaitUntil;\n};\n\nexport type RunWithCacheOptions = {\n key: CacheKey;\n strategy: CachingStrategy;\n};\n\nexport type CacheDecision<T extends SerializableCacheValue> = {\n /**\n * Must be a JSON-serializable object. The cache store may persist this value\n * through `JSON.stringify`; nested serializability is the caller's contract.\n */\n data: T;\n shouldCache: boolean;\n};\n\nexport type RunWithCacheResult<T extends SerializableCacheValue> = {\n data: T;\n cacheStatus: \"hit\" | \"miss\" | \"bypass\";\n};\n\nexport type RunWithCache = <T extends SerializableCacheValue>(\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n) => Promise<RunWithCacheResult<T>>;\n\ntype CacheState = \"fresh\" | \"stale\" | \"stale-if-error\" | \"expired\";\n\n/**\n * `result` resolves as soon as user data is available; `complete` also waits for\n * any cache write so background revalidation can be scheduled as one operation.\n */\ntype CacheOperation<T extends SerializableCacheValue = SerializableCacheValue> = {\n result: Promise<RunWithCacheResult<T>>;\n complete: Promise<void>;\n};\n\ntype RunAndMaybeStoreOptions = {\n scheduleCacheWrite?: boolean;\n};\n\n/**\n * Internal control-flow error for adapters that need to escape the cache\n * pipeline without being interpreted as an origin failure. `staleIfError`\n * catches refresh failures, but it should not hide intentional bypasses.\n */\nexport class StaleFallbackDisabledError extends Error {}\n\nexport function createRunWithCache({ cache, waitUntil }: CreateRunWithCacheOptions): RunWithCache {\n const store = createNormalizedCacheStore(cache);\n\n return async function runWithCache<T extends SerializableCacheValue>(\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n ): Promise<RunWithCacheResult<T>> {\n if (options.strategy.mode === NO_STORE) {\n return { data: (await runAndValidate(run)).data, cacheStatus: \"bypass\" };\n }\n\n const cacheKey = await hashCacheKey(options.key);\n\n let cached: CacheEnvelope<T> | undefined;\n\n try {\n cached = await store.get<T>(cacheKey);\n } catch {}\n\n if (cached) {\n const state = getCacheState(cached, options.strategy);\n\n if (state === \"fresh\") return { data: cached.value, cacheStatus: \"hit\" };\n\n if (state === \"stale\") {\n revalidateInBackground(cacheKey, options, run);\n return { data: cached.value, cacheStatus: \"hit\" };\n }\n\n if (state === \"stale-if-error\") {\n return refreshWithStaleFallback(cacheKey, cached.value, options, run);\n }\n }\n\n return runAndMaybeStore(cacheKey, options, run).result;\n };\n\n function revalidateInBackground<T extends SerializableCacheValue>(\n cacheKey: string,\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n ) {\n const entry = runAndMaybeStore(cacheKey, options, run, { scheduleCacheWrite: false });\n schedule(entry.complete);\n }\n\n async function refreshWithStaleFallback<T extends SerializableCacheValue>(\n cacheKey: string,\n staleValue: T,\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n ): Promise<RunWithCacheResult<T>> {\n try {\n return await runAndMaybeStore(cacheKey, options, run).result;\n } catch (error) {\n if (!shouldFallbackToStale(error)) throw error;\n\n return { data: staleValue, cacheStatus: \"hit\" };\n }\n }\n\n function runAndMaybeStore<T extends SerializableCacheValue>(\n key: string,\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n { scheduleCacheWrite = true }: RunAndMaybeStoreOptions = {},\n ): CacheOperation<T> {\n // Assigned inside `result` once the callback has produced cacheable data.\n // `complete` reads the same variable later, so it follows the actual write\n // without making the foreground result wait when waitUntil is available.\n let storePromise: Promise<void> = Promise.resolve();\n\n const result = Promise.resolve().then(async (): Promise<RunWithCacheResult<T>> => {\n const decision = await runAndValidate(run);\n if (!shouldStore(options.strategy, decision)) {\n return { data: decision.data, cacheStatus: \"miss\" };\n }\n\n storePromise = storeDecision(key, options, decision).catch(() => {});\n\n if (waitUntil && scheduleCacheWrite) {\n schedule(storePromise);\n } else if (!waitUntil) {\n await storePromise;\n }\n\n return { data: decision.data, cacheStatus: \"miss\" };\n });\n\n return {\n result,\n complete: result\n .then(\n () => storePromise,\n () => undefined,\n )\n .then(() => undefined),\n };\n }\n\n async function storeDecision<T extends SerializableCacheValue>(\n key: string,\n options: RunWithCacheOptions,\n decision: CacheDecision<T>,\n ) {\n await store.set(\n key,\n {\n version: 1,\n value: decision.data,\n storedAt: Date.now(),\n strategy: options.strategy,\n },\n {\n strategy: options.strategy,\n },\n );\n }\n\n function schedule(promise: Promise<unknown>) {\n try {\n waitUntil?.(promise);\n } catch {}\n }\n}\n\nfunction shouldStore<T extends SerializableCacheValue>(\n strategy: CachingStrategy,\n decision: CacheDecision<T>,\n): boolean {\n return decision.shouldCache && getCacheRetentionTtl(strategy) > 0;\n}\n\nfunction shouldFallbackToStale(error: unknown): boolean {\n return !(error instanceof StaleFallbackDisabledError);\n}\n\nasync function runAndValidate<T extends SerializableCacheValue>(\n run: () => MaybePromise<CacheDecision<T>>,\n): Promise<CacheDecision<T>> {\n const decision = await run();\n\n if (\n typeof decision !== \"object\" ||\n decision == null ||\n !(\"data\" in decision) ||\n !(\"shouldCache\" in decision) ||\n typeof decision.shouldCache !== \"boolean\"\n ) {\n throw new TypeError(\"runWithCache callback must return {data, shouldCache}.\");\n }\n\n return decision;\n}\n\nfunction getCacheState<T extends SerializableCacheValue>(\n envelope: CacheEnvelope<T>,\n strategy: CachingStrategy,\n): CacheState {\n const age = Math.max(0, (Date.now() - envelope.storedAt) / 1000);\n const maxAge = strategy.maxAge ?? 0;\n const staleWhileRevalidate = strategy.staleWhileRevalidate ?? 0;\n const staleIfError = strategy.staleIfError ?? 0;\n\n if (age <= maxAge) return \"fresh\";\n if (age <= maxAge + staleWhileRevalidate) return \"stale\";\n if (age <= maxAge + staleWhileRevalidate + staleIfError) {\n return \"stale-if-error\";\n }\n\n return \"expired\";\n}\n"],"mappings":";;;;;;;;;;AAiEA,IAAa,6BAAb,cAAgD,MAAM;AAEtD,SAAgB,mBAAmB,EAAE,OAAO,aAAsD;CAChG,MAAM,QAAQ,2BAA2B,MAAM;AAE/C,QAAO,eAAe,aACpB,SACA,KACgC;AAChC,MAAI,QAAQ,SAAS,oBACnB,QAAO;GAAE,OAAO,MAAM,eAAe,IAAI,EAAE;GAAM,aAAa;GAAU;EAG1E,MAAM,WAAW,MAAM,aAAa,QAAQ,IAAI;EAEhD,IAAI;AAEJ,MAAI;AACF,YAAS,MAAM,MAAM,IAAO,SAAS;UAC/B;AAER,MAAI,QAAQ;GACV,MAAM,QAAQ,cAAc,QAAQ,QAAQ,SAAS;AAErD,OAAI,UAAU,QAAS,QAAO;IAAE,MAAM,OAAO;IAAO,aAAa;IAAO;AAExE,OAAI,UAAU,SAAS;AACrB,2BAAuB,UAAU,SAAS,IAAI;AAC9C,WAAO;KAAE,MAAM,OAAO;KAAO,aAAa;KAAO;;AAGnD,OAAI,UAAU,iBACZ,QAAO,yBAAyB,UAAU,OAAO,OAAO,SAAS,IAAI;;AAIzE,SAAO,iBAAiB,UAAU,SAAS,IAAI,CAAC;;CAGlD,SAAS,uBACP,UACA,SACA,KACA;AAEA,WADc,iBAAiB,UAAU,SAAS,KAAK,EAAE,oBAAoB,OAAO,CACtE,CAAC,SAAS;;CAG1B,eAAe,yBACb,UACA,YACA,SACA,KACgC;AAChC,MAAI;AACF,UAAO,MAAM,iBAAiB,UAAU,SAAS,IAAI,CAAC;WAC/C,OAAO;AACd,OAAI,CAAC,sBAAsB,MAAM,CAAE,OAAM;AAEzC,UAAO;IAAE,MAAM;IAAY,aAAa;IAAO;;;CAInD,SAAS,iBACP,KACA,SACA,KACA,EAAE,qBAAqB,SAAkC,EAAE,EACxC;EAInB,IAAI,eAA8B,QAAQ,SAAS;EAEnD,MAAM,SAAS,QAAQ,SAAS,CAAC,KAAK,YAA4C;GAChF,MAAM,WAAW,MAAM,eAAe,IAAI;AAC1C,OAAI,CAAC,YAAY,QAAQ,UAAU,SAAS,CAC1C,QAAO;IAAE,MAAM,SAAS;IAAM,aAAa;IAAQ;AAGrD,kBAAe,cAAc,KAAK,SAAS,SAAS,CAAC,YAAY,GAAG;AAEpE,OAAI,aAAa,mBACf,UAAS,aAAa;YACb,CAAC,UACV,OAAM;AAGR,UAAO;IAAE,MAAM,SAAS;IAAM,aAAa;IAAQ;IACnD;AAEF,SAAO;GACL;GACA,UAAU,OACP,WACO,oBACA,OACP,CACA,WAAW,OAAU;GACzB;;CAGH,eAAe,cACb,KACA,SACA,UACA;AACA,QAAM,MAAM,IACV,KACA;GACE,SAAS;GACT,OAAO,SAAS;GAChB,UAAU,KAAK,KAAK;GACpB,UAAU,QAAQ;GACnB,EACD,EACE,UAAU,QAAQ,UACnB,CACF;;CAGH,SAAS,SAAS,SAA2B;AAC3C,MAAI;AACF,eAAY,QAAQ;UACd;;;AAIZ,SAAS,YACP,UACA,UACS;AACT,QAAO,SAAS,eAAe,qBAAqB,SAAS,GAAG;;AAGlE,SAAS,sBAAsB,OAAyB;AACtD,QAAO,EAAE,iBAAiB;;AAG5B,eAAe,eACb,KAC2B;CAC3B,MAAM,WAAW,MAAM,KAAK;AAE5B,KACE,OAAO,aAAa,YACpB,YAAY,QACZ,EAAE,UAAU,aACZ,EAAE,iBAAiB,aACnB,OAAO,SAAS,gBAAgB,UAEhC,OAAM,IAAI,UAAU,yDAAyD;AAG/E,QAAO;;AAGT,SAAS,cACP,UACA,UACY;CACZ,MAAM,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,GAAG,SAAS,YAAY,IAAK;CAChE,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,uBAAuB,SAAS,wBAAwB;CAC9D,MAAM,eAAe,SAAS,gBAAgB;AAE9C,KAAI,OAAO,OAAQ,QAAO;AAC1B,KAAI,OAAO,SAAS,qBAAsB,QAAO;AACjD,KAAI,OAAO,SAAS,uBAAuB,aACzC,QAAO;AAGT,QAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/core/cache/store.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Cache values must be JSON-serializable because Web Cache stores serialize
|
|
4
|
+
* envelopes before persistence. Callers are responsible for returning data that
|
|
5
|
+
* can safely round-trip through `JSON.stringify`.
|
|
6
|
+
*/
|
|
7
|
+
type SerializableCacheValue = Record<string, unknown>;
|
|
8
|
+
type WebCacheLike = Pick<Cache, "match" | "put" | "delete">;
|
|
9
|
+
type KeyValueCacheSetOptions = {
|
|
10
|
+
ttl?: number;
|
|
11
|
+
};
|
|
12
|
+
type KeyValueCacheLike = {
|
|
13
|
+
get(key: string): unknown | Promise<unknown>;
|
|
14
|
+
set(key: string, value: unknown, options?: KeyValueCacheSetOptions): unknown | Promise<unknown>;
|
|
15
|
+
delete?(key: string): unknown | Promise<unknown>;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { KeyValueCacheLike, SerializableCacheValue, WebCacheLike };
|
|
19
|
+
//# sourceMappingURL=store.d.mts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getCacheRetentionTtl, getPlatformCacheControlHeader } from "./strategies.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/cache/store.ts
|
|
4
|
+
function createNormalizedCacheStore(cache) {
|
|
5
|
+
if (isWebCacheLike(cache)) return createWebCacheStore(cache);
|
|
6
|
+
if (isKeyValueCacheLike(cache)) return createKeyValueCacheStore(cache);
|
|
7
|
+
throw new TypeError("Expected a Web Cache API compatible store or a key/value cache store.");
|
|
8
|
+
}
|
|
9
|
+
function createWebCacheStore(cache) {
|
|
10
|
+
return {
|
|
11
|
+
async get(key) {
|
|
12
|
+
const response = await cache.match(createCacheRequest(key));
|
|
13
|
+
if (!response) return void 0;
|
|
14
|
+
const envelope = JSON.parse(await response.text());
|
|
15
|
+
return isCacheEnvelope(envelope) ? envelope : void 0;
|
|
16
|
+
},
|
|
17
|
+
async set(key, envelope, { strategy }) {
|
|
18
|
+
const response = new Response(JSON.stringify(envelope), { headers: {
|
|
19
|
+
"cache-control": getPlatformCacheControlHeader(strategy),
|
|
20
|
+
"content-type": "application/json"
|
|
21
|
+
} });
|
|
22
|
+
await cache.put(createCacheRequest(key), response);
|
|
23
|
+
},
|
|
24
|
+
async delete(key) {
|
|
25
|
+
await cache.delete(createCacheRequest(key));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function createKeyValueCacheStore(cache) {
|
|
30
|
+
return {
|
|
31
|
+
async get(key) {
|
|
32
|
+
const envelope = await cache.get(key);
|
|
33
|
+
return isCacheEnvelope(envelope) ? envelope : void 0;
|
|
34
|
+
},
|
|
35
|
+
async set(key, envelope, { strategy }) {
|
|
36
|
+
const ttl = Math.ceil(getCacheRetentionTtl(strategy));
|
|
37
|
+
await cache.set(key, envelope, { ttl });
|
|
38
|
+
},
|
|
39
|
+
async delete(key) {
|
|
40
|
+
await cache.delete?.(key);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function createCacheRequest(key) {
|
|
45
|
+
return new Request(`https://hydrogen.cache/${key}`);
|
|
46
|
+
}
|
|
47
|
+
function isWebCacheLike(cache) {
|
|
48
|
+
return typeof cache === "object" && cache != null && "match" in cache && "put" in cache && typeof cache.match === "function" && typeof cache.put === "function";
|
|
49
|
+
}
|
|
50
|
+
function isKeyValueCacheLike(cache) {
|
|
51
|
+
return typeof cache === "object" && cache != null && "get" in cache && "set" in cache && typeof cache.get === "function" && typeof cache.set === "function";
|
|
52
|
+
}
|
|
53
|
+
function isCacheEnvelope(value) {
|
|
54
|
+
return typeof value === "object" && value != null && "version" in value && value.version === 1 && "storedAt" in value && typeof value.storedAt === "number" && "strategy" in value && Boolean(value.strategy) && "value" in value && isSerializableCacheValue(value.value);
|
|
55
|
+
}
|
|
56
|
+
function isSerializableCacheValue(value) {
|
|
57
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { createNormalizedCacheStore };
|
|
62
|
+
//# sourceMappingURL=store.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.mjs","names":[],"sources":["../../../src/core/cache/store.ts"],"sourcesContent":["import {\n type CachingStrategy,\n getPlatformCacheControlHeader,\n getCacheRetentionTtl,\n} from \"./strategies\";\n\n/**\n * Cache values must be JSON-serializable because Web Cache stores serialize\n * envelopes before persistence. Callers are responsible for returning data that\n * can safely round-trip through `JSON.stringify`.\n */\nexport type SerializableCacheValue = Record<string, unknown>;\n\nexport type CacheEnvelope<T extends SerializableCacheValue = SerializableCacheValue> = {\n version: 1;\n value: T;\n storedAt: number;\n strategy: CachingStrategy;\n};\n\nexport type WebCacheLike = Pick<Cache, \"match\" | \"put\" | \"delete\">;\n\nexport type KeyValueCacheSetOptions = {\n ttl?: number;\n};\n\nexport type KeyValueCacheLike = {\n get(key: string): unknown | Promise<unknown>;\n set(key: string, value: unknown, options?: KeyValueCacheSetOptions): unknown | Promise<unknown>;\n delete?(key: string): unknown | Promise<unknown>;\n};\n\ntype NormalizedCacheStore = {\n get<T extends SerializableCacheValue>(key: string): Promise<CacheEnvelope<T> | undefined>;\n set<T extends SerializableCacheValue>(\n key: string,\n envelope: CacheEnvelope<T>,\n options: NormalizedCacheSetOptions,\n ): Promise<void>;\n delete?(key: string): Promise<void>;\n};\n\ntype NormalizedCacheSetOptions = {\n strategy: CachingStrategy;\n};\n\nexport function createNormalizedCacheStore(\n cache: WebCacheLike | KeyValueCacheLike,\n): NormalizedCacheStore {\n if (isWebCacheLike(cache)) return createWebCacheStore(cache);\n if (isKeyValueCacheLike(cache)) return createKeyValueCacheStore(cache);\n\n throw new TypeError(\"Expected a Web Cache API compatible store or a key/value cache store.\");\n}\n\nfunction createWebCacheStore(cache: WebCacheLike): NormalizedCacheStore {\n return {\n async get<T extends SerializableCacheValue>(key: string) {\n const response = await cache.match(createCacheRequest(key));\n if (!response) return undefined;\n\n const envelope: unknown = JSON.parse(await response.text());\n return isCacheEnvelope<T>(envelope) ? envelope : undefined;\n },\n\n async set<T extends SerializableCacheValue>(\n key: string,\n envelope: CacheEnvelope<T>,\n { strategy }: NormalizedCacheSetOptions,\n ) {\n const response = new Response(JSON.stringify(envelope), {\n headers: {\n \"cache-control\": getPlatformCacheControlHeader(strategy),\n \"content-type\": \"application/json\",\n },\n });\n\n await cache.put(createCacheRequest(key), response);\n },\n\n async delete(key) {\n await cache.delete(createCacheRequest(key));\n },\n };\n}\n\nfunction createKeyValueCacheStore(cache: KeyValueCacheLike): NormalizedCacheStore {\n return {\n async get<T extends SerializableCacheValue>(key: string) {\n const envelope = await cache.get(key);\n return isCacheEnvelope<T>(envelope) ? envelope : undefined;\n },\n\n async set<T extends SerializableCacheValue>(\n key: string,\n envelope: CacheEnvelope<T>,\n { strategy }: NormalizedCacheSetOptions,\n ) {\n const ttl = Math.ceil(getCacheRetentionTtl(strategy));\n\n await cache.set(key, envelope, { ttl });\n },\n\n async delete(key) {\n await cache.delete?.(key);\n },\n };\n}\n\nfunction createCacheRequest(key: string) {\n return new Request(`https://hydrogen.cache/${key}`);\n}\n\nfunction isWebCacheLike(cache: unknown): cache is WebCacheLike {\n return (\n typeof cache === \"object\" &&\n cache != null &&\n \"match\" in cache &&\n \"put\" in cache &&\n typeof cache.match === \"function\" &&\n typeof cache.put === \"function\"\n );\n}\n\nfunction isKeyValueCacheLike(cache: unknown): cache is KeyValueCacheLike {\n return (\n typeof cache === \"object\" &&\n cache != null &&\n \"get\" in cache &&\n \"set\" in cache &&\n typeof cache.get === \"function\" &&\n typeof cache.set === \"function\"\n );\n}\n\nfunction isCacheEnvelope<T extends SerializableCacheValue>(\n value: unknown,\n): value is CacheEnvelope<T> {\n return (\n typeof value === \"object\" &&\n value != null &&\n \"version\" in value &&\n value.version === 1 &&\n \"storedAt\" in value &&\n typeof value.storedAt === \"number\" &&\n // Freshness uses the call-site strategy, but stored envelopes should still\n // look like the current shape so older or malformed entries do not become hits.\n \"strategy\" in value &&\n Boolean(value.strategy) &&\n \"value\" in value &&\n isSerializableCacheValue(value.value)\n );\n}\n\nfunction isSerializableCacheValue(value: unknown): value is SerializableCacheValue {\n return typeof value === \"object\" && value != null && !Array.isArray(value);\n}\n"],"mappings":";;;AA8CA,SAAgB,2BACd,OACsB;AACtB,KAAI,eAAe,MAAM,CAAE,QAAO,oBAAoB,MAAM;AAC5D,KAAI,oBAAoB,MAAM,CAAE,QAAO,yBAAyB,MAAM;AAEtE,OAAM,IAAI,UAAU,wEAAwE;;AAG9F,SAAS,oBAAoB,OAA2C;AACtE,QAAO;EACL,MAAM,IAAsC,KAAa;GACvD,MAAM,WAAW,MAAM,MAAM,MAAM,mBAAmB,IAAI,CAAC;AAC3D,OAAI,CAAC,SAAU,QAAO;GAEtB,MAAM,WAAoB,KAAK,MAAM,MAAM,SAAS,MAAM,CAAC;AAC3D,UAAO,gBAAmB,SAAS,GAAG,WAAW;;EAGnD,MAAM,IACJ,KACA,UACA,EAAE,YACF;GACA,MAAM,WAAW,IAAI,SAAS,KAAK,UAAU,SAAS,EAAE,EACtD,SAAS;IACP,iBAAiB,8BAA8B,SAAS;IACxD,gBAAgB;IACjB,EACF,CAAC;AAEF,SAAM,MAAM,IAAI,mBAAmB,IAAI,EAAE,SAAS;;EAGpD,MAAM,OAAO,KAAK;AAChB,SAAM,MAAM,OAAO,mBAAmB,IAAI,CAAC;;EAE9C;;AAGH,SAAS,yBAAyB,OAAgD;AAChF,QAAO;EACL,MAAM,IAAsC,KAAa;GACvD,MAAM,WAAW,MAAM,MAAM,IAAI,IAAI;AACrC,UAAO,gBAAmB,SAAS,GAAG,WAAW;;EAGnD,MAAM,IACJ,KACA,UACA,EAAE,YACF;GACA,MAAM,MAAM,KAAK,KAAK,qBAAqB,SAAS,CAAC;AAErD,SAAM,MAAM,IAAI,KAAK,UAAU,EAAE,KAAK,CAAC;;EAGzC,MAAM,OAAO,KAAK;AAChB,SAAM,MAAM,SAAS,IAAI;;EAE5B;;AAGH,SAAS,mBAAmB,KAAa;AACvC,QAAO,IAAI,QAAQ,0BAA0B,MAAM;;AAGrD,SAAS,eAAe,OAAuC;AAC7D,QACE,OAAO,UAAU,YACjB,SAAS,QACT,WAAW,SACX,SAAS,SACT,OAAO,MAAM,UAAU,cACvB,OAAO,MAAM,QAAQ;;AAIzB,SAAS,oBAAoB,OAA4C;AACvE,QACE,OAAO,UAAU,YACjB,SAAS,QACT,SAAS,SACT,SAAS,SACT,OAAO,MAAM,QAAQ,cACrB,OAAO,MAAM,QAAQ;;AAIzB,SAAS,gBACP,OAC2B;AAC3B,QACE,OAAO,UAAU,YACjB,SAAS,QACT,aAAa,SACb,MAAM,YAAY,KAClB,cAAc,SACd,OAAO,MAAM,aAAa,YAG1B,cAAc,SACd,QAAQ,MAAM,SAAS,IACvB,WAAW,SACX,yBAAyB,MAAM,MAAM;;AAIzC,SAAS,yBAAyB,OAAiD;AACjF,QAAO,OAAO,UAAU,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,MAAM"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/core/cache/strategies.d.ts
|
|
2
|
+
declare const NO_STORE = "no-store";
|
|
3
|
+
declare const PUBLIC = "public";
|
|
4
|
+
declare const PRIVATE = "private";
|
|
5
|
+
type CacheMode = typeof PUBLIC | typeof PRIVATE | typeof NO_STORE;
|
|
6
|
+
type ExpirableCacheMode = typeof PUBLIC | typeof PRIVATE;
|
|
7
|
+
type CacheDuration = number | {
|
|
8
|
+
seconds?: number;
|
|
9
|
+
minutes?: number;
|
|
10
|
+
hours?: number;
|
|
11
|
+
days?: number;
|
|
12
|
+
};
|
|
13
|
+
interface CachingStrategy {
|
|
14
|
+
mode?: CacheMode;
|
|
15
|
+
maxAge?: number;
|
|
16
|
+
staleWhileRevalidate?: number;
|
|
17
|
+
staleIfError?: number;
|
|
18
|
+
}
|
|
19
|
+
type CacheOptions = {
|
|
20
|
+
mode?: ExpirableCacheMode;
|
|
21
|
+
maxAge?: CacheDuration;
|
|
22
|
+
staleWhileRevalidate?: CacheDuration;
|
|
23
|
+
staleIfError?: CacheDuration;
|
|
24
|
+
};
|
|
25
|
+
type NoStoreStrategy = CachingStrategy & {
|
|
26
|
+
mode: typeof NO_STORE;
|
|
27
|
+
};
|
|
28
|
+
declare const Cache: typeof createCache & {
|
|
29
|
+
none: typeof cacheNone;
|
|
30
|
+
short: typeof cacheShort;
|
|
31
|
+
long: typeof cacheLong;
|
|
32
|
+
};
|
|
33
|
+
declare function createCache(options: CacheOptions): CachingStrategy;
|
|
34
|
+
declare function cacheNone(): NoStoreStrategy;
|
|
35
|
+
declare function cacheShort(overrideOptions?: CacheOptions): CachingStrategy;
|
|
36
|
+
declare function cacheLong(overrideOptions?: CacheOptions): CachingStrategy;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Cache, CacheOptions, CachingStrategy };
|
|
39
|
+
//# sourceMappingURL=strategies.d.mts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/core/cache/strategies.ts
|
|
2
|
+
const NO_STORE = "no-store";
|
|
3
|
+
const PUBLIC = "public";
|
|
4
|
+
const PRIVATE = "private";
|
|
5
|
+
const Cache = Object.assign(createCache, {
|
|
6
|
+
none: cacheNone,
|
|
7
|
+
short: cacheShort,
|
|
8
|
+
long: cacheLong
|
|
9
|
+
});
|
|
10
|
+
function getCacheRetentionTtl(strategy) {
|
|
11
|
+
if (strategy.mode === "no-store") return 0;
|
|
12
|
+
return Math.max(0, (strategy.maxAge ?? 0) + (strategy.staleWhileRevalidate ?? 0) + (strategy.staleIfError ?? 0));
|
|
13
|
+
}
|
|
14
|
+
function getPlatformCacheControlHeader(strategy) {
|
|
15
|
+
const ttl = getCacheRetentionTtl(strategy);
|
|
16
|
+
if (ttl <= 0) return NO_STORE;
|
|
17
|
+
return `${strategy.mode ?? PUBLIC}, max-age=${Math.ceil(ttl)}`;
|
|
18
|
+
}
|
|
19
|
+
function createCache(options) {
|
|
20
|
+
return normalizeCacheOptions(options);
|
|
21
|
+
}
|
|
22
|
+
function cacheNone() {
|
|
23
|
+
return { mode: NO_STORE };
|
|
24
|
+
}
|
|
25
|
+
function cacheShort(overrideOptions) {
|
|
26
|
+
return normalizeCacheOptions({
|
|
27
|
+
mode: PUBLIC,
|
|
28
|
+
maxAge: 1,
|
|
29
|
+
staleWhileRevalidate: 9
|
|
30
|
+
}, overrideOptions);
|
|
31
|
+
}
|
|
32
|
+
function cacheLong(overrideOptions) {
|
|
33
|
+
return normalizeCacheOptions({
|
|
34
|
+
mode: PUBLIC,
|
|
35
|
+
maxAge: 3600,
|
|
36
|
+
staleWhileRevalidate: 82800
|
|
37
|
+
}, overrideOptions);
|
|
38
|
+
}
|
|
39
|
+
function normalizeCacheOptions(defaultsOrOptions, overrideOptions) {
|
|
40
|
+
const options = {
|
|
41
|
+
...defaultsOrOptions,
|
|
42
|
+
...overrideOptions
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
...normalizeMode(options),
|
|
46
|
+
...normalizeDurationOption("maxAge", options.maxAge),
|
|
47
|
+
...normalizeDurationOption("staleWhileRevalidate", options.staleWhileRevalidate),
|
|
48
|
+
...normalizeDurationOption("staleIfError", options.staleIfError)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function normalizeMode(options) {
|
|
52
|
+
if (options.mode && options.mode !== PUBLIC && options.mode !== PRIVATE) throw new Error("'mode' must be either 'public' or 'private'");
|
|
53
|
+
return { mode: options.mode ?? PUBLIC };
|
|
54
|
+
}
|
|
55
|
+
function normalizeDurationOption(name, duration) {
|
|
56
|
+
if (duration == null) return {};
|
|
57
|
+
return { [name]: normalizeDuration(duration) };
|
|
58
|
+
}
|
|
59
|
+
function normalizeDuration(duration) {
|
|
60
|
+
if (typeof duration === "number") return validateDuration(duration);
|
|
61
|
+
return validateDuration((duration.seconds ?? 0) + (duration.minutes ?? 0) * 60 + (duration.hours ?? 0) * 3600 + (duration.days ?? 0) * 86400);
|
|
62
|
+
}
|
|
63
|
+
function validateDuration(duration) {
|
|
64
|
+
if (!Number.isFinite(duration) || duration < 0) throw new Error("Cache durations must be finite, non-negative numbers.");
|
|
65
|
+
return Math.ceil(duration);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
export { Cache, NO_STORE, getCacheRetentionTtl, getPlatformCacheControlHeader };
|
|
70
|
+
//# sourceMappingURL=strategies.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategies.mjs","names":[],"sources":["../../../src/core/cache/strategies.ts"],"sourcesContent":["export const NO_STORE = \"no-store\";\n\nconst PUBLIC = \"public\";\nconst PRIVATE = \"private\";\n\nexport type CacheMode = typeof PUBLIC | typeof PRIVATE | typeof NO_STORE;\nexport type ExpirableCacheMode = typeof PUBLIC | typeof PRIVATE;\n\nexport type CacheDuration =\n | number\n | {\n seconds?: number;\n minutes?: number;\n hours?: number;\n days?: number;\n };\n\nexport interface CachingStrategy {\n mode?: CacheMode;\n maxAge?: number;\n staleWhileRevalidate?: number;\n staleIfError?: number;\n}\n\nexport type CacheOptions = {\n mode?: ExpirableCacheMode;\n maxAge?: CacheDuration;\n staleWhileRevalidate?: CacheDuration;\n staleIfError?: CacheDuration;\n};\n\ntype NoStoreStrategy = CachingStrategy & {\n mode: typeof NO_STORE;\n};\n\nexport const Cache = Object.assign(createCache, {\n none: cacheNone,\n short: cacheShort,\n long: cacheLong,\n});\n\nexport function getCacheRetentionTtl(strategy: CachingStrategy): number {\n if (strategy.mode === NO_STORE) return 0;\n\n return Math.max(\n 0,\n (strategy.maxAge ?? 0) + (strategy.staleWhileRevalidate ?? 0) + (strategy.staleIfError ?? 0),\n );\n}\n\nexport function getPlatformCacheControlHeader(strategy: CachingStrategy): string {\n const ttl = getCacheRetentionTtl(strategy);\n if (ttl <= 0) return NO_STORE;\n\n return `${strategy.mode ?? PUBLIC}, max-age=${Math.ceil(ttl)}`;\n}\n\nfunction createCache(options: CacheOptions): CachingStrategy {\n return normalizeCacheOptions(options);\n}\n\nfunction cacheNone(): NoStoreStrategy {\n return { mode: NO_STORE };\n}\n\nfunction cacheShort(overrideOptions?: CacheOptions): CachingStrategy {\n return normalizeCacheOptions(\n {\n mode: PUBLIC,\n maxAge: 1,\n staleWhileRevalidate: 9,\n },\n overrideOptions,\n );\n}\n\nfunction cacheLong(overrideOptions?: CacheOptions): CachingStrategy {\n return normalizeCacheOptions(\n {\n mode: PUBLIC,\n maxAge: 3600,\n staleWhileRevalidate: 82800,\n },\n overrideOptions,\n );\n}\n\nfunction normalizeCacheOptions(\n defaults: CacheOptions,\n overrideOptions?: CacheOptions,\n): CachingStrategy;\nfunction normalizeCacheOptions(options: CacheOptions): CachingStrategy;\nfunction normalizeCacheOptions(\n defaultsOrOptions: CacheOptions,\n overrideOptions?: CacheOptions,\n): CachingStrategy {\n const options = {\n ...defaultsOrOptions,\n ...overrideOptions,\n };\n\n return {\n ...normalizeMode(options),\n ...normalizeDurationOption(\"maxAge\", options.maxAge),\n ...normalizeDurationOption(\"staleWhileRevalidate\", options.staleWhileRevalidate),\n ...normalizeDurationOption(\"staleIfError\", options.staleIfError),\n };\n}\n\nfunction normalizeMode(options: CacheOptions): Pick<CachingStrategy, \"mode\"> {\n if (options.mode && options.mode !== PUBLIC && options.mode !== PRIVATE) {\n throw new Error(\"'mode' must be either 'public' or 'private'\");\n }\n\n return { mode: options.mode ?? PUBLIC };\n}\n\nfunction normalizeDurationOption(\n name: \"maxAge\" | \"staleWhileRevalidate\" | \"staleIfError\",\n duration: CacheDuration | undefined,\n): Pick<CachingStrategy, typeof name> {\n if (duration == null) return {};\n\n return { [name]: normalizeDuration(duration) };\n}\n\nfunction normalizeDuration(duration: CacheDuration): number {\n if (typeof duration === \"number\") return validateDuration(duration);\n\n return validateDuration(\n (duration.seconds ?? 0) +\n (duration.minutes ?? 0) * 60 +\n (duration.hours ?? 0) * 3600 +\n (duration.days ?? 0) * 86400,\n );\n}\n\nfunction validateDuration(duration: number): number {\n if (!Number.isFinite(duration) || duration < 0) {\n throw new Error(\"Cache durations must be finite, non-negative numbers.\");\n }\n\n return Math.ceil(duration);\n}\n"],"mappings":";AAAA,MAAa,WAAW;AAExB,MAAM,SAAS;AACf,MAAM,UAAU;AAgChB,MAAa,QAAQ,OAAO,OAAO,aAAa;CAC9C,MAAM;CACN,OAAO;CACP,MAAM;CACP,CAAC;AAEF,SAAgB,qBAAqB,UAAmC;AACtE,KAAI,SAAS,oBAAmB,QAAO;AAEvC,QAAO,KAAK,IACV,IACC,SAAS,UAAU,MAAM,SAAS,wBAAwB,MAAM,SAAS,gBAAgB,GAC3F;;AAGH,SAAgB,8BAA8B,UAAmC;CAC/E,MAAM,MAAM,qBAAqB,SAAS;AAC1C,KAAI,OAAO,EAAG,QAAO;AAErB,QAAO,GAAG,SAAS,QAAQ,OAAO,YAAY,KAAK,KAAK,IAAI;;AAG9D,SAAS,YAAY,SAAwC;AAC3D,QAAO,sBAAsB,QAAQ;;AAGvC,SAAS,YAA6B;AACpC,QAAO,EAAE,MAAM,UAAU;;AAG3B,SAAS,WAAW,iBAAiD;AACnE,QAAO,sBACL;EACE,MAAM;EACN,QAAQ;EACR,sBAAsB;EACvB,EACD,gBACD;;AAGH,SAAS,UAAU,iBAAiD;AAClE,QAAO,sBACL;EACE,MAAM;EACN,QAAQ;EACR,sBAAsB;EACvB,EACD,gBACD;;AAQH,SAAS,sBACP,mBACA,iBACiB;CACjB,MAAM,UAAU;EACd,GAAG;EACH,GAAG;EACJ;AAED,QAAO;EACL,GAAG,cAAc,QAAQ;EACzB,GAAG,wBAAwB,UAAU,QAAQ,OAAO;EACpD,GAAG,wBAAwB,wBAAwB,QAAQ,qBAAqB;EAChF,GAAG,wBAAwB,gBAAgB,QAAQ,aAAa;EACjE;;AAGH,SAAS,cAAc,SAAsD;AAC3E,KAAI,QAAQ,QAAQ,QAAQ,SAAS,UAAU,QAAQ,SAAS,QAC9D,OAAM,IAAI,MAAM,8CAA8C;AAGhE,QAAO,EAAE,MAAM,QAAQ,QAAQ,QAAQ;;AAGzC,SAAS,wBACP,MACA,UACoC;AACpC,KAAI,YAAY,KAAM,QAAO,EAAE;AAE/B,QAAO,GAAG,OAAO,kBAAkB,SAAS,EAAE;;AAGhD,SAAS,kBAAkB,UAAiC;AAC1D,KAAI,OAAO,aAAa,SAAU,QAAO,iBAAiB,SAAS;AAEnE,QAAO,kBACJ,SAAS,WAAW,MAClB,SAAS,WAAW,KAAK,MACzB,SAAS,SAAS,KAAK,QACvB,SAAS,QAAQ,KAAK,MAC1B;;AAGH,SAAS,iBAAiB,UAA0B;AAClD,KAAI,CAAC,OAAO,SAAS,SAAS,IAAI,WAAW,EAC3C,OAAM,IAAI,MAAM,wDAAwD;AAG1E,QAAO,KAAK,KAAK,SAAS"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/core/cart/actions.d.ts
|
|
2
|
+
type CartAttributeInput = {
|
|
3
|
+
key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
type CartLineAddInput = {
|
|
7
|
+
merchandiseId: string;
|
|
8
|
+
quantity: number;
|
|
9
|
+
attributes?: CartAttributeInput[];
|
|
10
|
+
sellingPlanId?: string;
|
|
11
|
+
};
|
|
12
|
+
type CartLineUpdateInput = {
|
|
13
|
+
id: string;
|
|
14
|
+
quantity: number;
|
|
15
|
+
attributes?: CartAttributeInput[];
|
|
16
|
+
sellingPlanId?: string;
|
|
17
|
+
};
|
|
18
|
+
type CartAction = {
|
|
19
|
+
intent: "add";
|
|
20
|
+
lines: CartLineAddInput[];
|
|
21
|
+
} | {
|
|
22
|
+
intent: "update";
|
|
23
|
+
lines: CartLineUpdateInput[];
|
|
24
|
+
} | {
|
|
25
|
+
intent: "remove";
|
|
26
|
+
lineIds: string[];
|
|
27
|
+
} | {
|
|
28
|
+
intent: "discount-update";
|
|
29
|
+
discountCodes: string[];
|
|
30
|
+
} | {
|
|
31
|
+
intent: "discount-apply";
|
|
32
|
+
code: string;
|
|
33
|
+
} | {
|
|
34
|
+
intent: "discount-remove";
|
|
35
|
+
code: string;
|
|
36
|
+
} | {
|
|
37
|
+
intent: "attributes-update";
|
|
38
|
+
attributes: CartAttributeInput[];
|
|
39
|
+
} | {
|
|
40
|
+
intent: "note-update";
|
|
41
|
+
note: string;
|
|
42
|
+
};
|
|
43
|
+
type ParsedCartRequest = {
|
|
44
|
+
action: CartAction;
|
|
45
|
+
cartId: string | null;
|
|
46
|
+
};
|
|
47
|
+
declare function parseCartRequest(request: Request): Promise<ParsedCartRequest>;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { CartAction, CartAttributeInput, CartLineAddInput, CartLineUpdateInput, parseCartRequest };
|
|
50
|
+
//# sourceMappingURL=actions.d.mts.map
|