import { inject } from "vue"; import type { ApiClient } from "#shopware"; import ContextError from "../helpers/ContextError"; export type ShopwareContext = { devStorefrontUrl: string | null; /** * Shopware API client */ apiClient: ApiClient; }; /** * @public * @category Context & Language */ export function useShopwareContext(): ShopwareContext { const shopwareContext = inject("shopware", null); const apiClient = inject("apiClient"); if (!shopwareContext || !apiClient) { console.error("[Error][Shopware] API Client is not provided."); throw new ContextError("Shopware or apiClient"); } return { apiClient, devStorefrontUrl: shopwareContext.devStorefrontUrl, }; }