@coveo/headless-react 2.5.7-pre.5db15b515b → 2.5.7-pre.5fc0927ed4

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.
Files changed (37) hide show
  1. package/dist/__tests__/component-test-utils.d.ts +6 -0
  2. package/dist/__tests__/component-test-utils.js +16 -0
  3. package/dist/__tests__/component-test-utils.js.map +1 -0
  4. package/dist/__tests__/mock-navigator-context-provider.d.ts +2 -0
  5. package/dist/__tests__/mock-navigator-context-provider.js +7 -0
  6. package/dist/__tests__/mock-navigator-context-provider.js.map +1 -0
  7. package/dist/__tests__/mock-products.d.ts +2 -0
  8. package/dist/__tests__/mock-products.js +31 -0
  9. package/dist/__tests__/mock-products.js.map +1 -0
  10. package/dist/__tests__/mock-ssr-controller-definitions.d.ts +16 -0
  11. package/dist/__tests__/mock-ssr-controller-definitions.js +19 -0
  12. package/dist/__tests__/mock-ssr-controller-definitions.js.map +1 -0
  13. package/dist/__tests__/mock-ssr-engine.d.ts +2 -0
  14. package/dist/__tests__/mock-ssr-engine.js +7 -0
  15. package/dist/__tests__/mock-ssr-engine.js.map +1 -0
  16. package/dist/__tests__/setup.d.ts +1 -0
  17. package/dist/__tests__/setup.js +9 -0
  18. package/dist/__tests__/setup.js.map +1 -0
  19. package/dist/__tests__/test-utils.d.ts +10 -0
  20. package/dist/__tests__/test-utils.js +19 -0
  21. package/dist/__tests__/test-utils.js.map +1 -0
  22. package/dist/ssr-commerce-next/index.d.ts +5 -5
  23. package/dist/ssr-commerce-next/index.js +3 -3
  24. package/dist/ssr-commerce-next/index.js.map +1 -1
  25. package/package.json +2 -2
  26. package/dist/ssr-commerce-next/commerce-engine.d.ts +0 -23
  27. package/dist/ssr-commerce-next/commerce-engine.js +0 -47
  28. package/dist/ssr-commerce-next/commerce-engine.js.map +0 -1
  29. package/dist/ssr-commerce-next/common.d.ts +0 -25
  30. package/dist/ssr-commerce-next/common.js +0 -80
  31. package/dist/ssr-commerce-next/common.js.map +0 -1
  32. package/dist/ssr-commerce-next/providers.d.ts +0 -20
  33. package/dist/ssr-commerce-next/providers.js +0 -31
  34. package/dist/ssr-commerce-next/providers.js.map +0 -1
  35. package/dist/ssr-commerce-next/types.d.ts +0 -25
  36. package/dist/ssr-commerce-next/types.js +0 -2
  37. package/dist/ssr-commerce-next/types.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import type { Product } from '@coveo/headless/ssr-commerce';
2
+ export declare const createProductListComponent: (productCount?: number) => {
3
+ ProductListComponent: () => import("react/jsx-runtime").JSX.Element;
4
+ mockProducts: Product[];
5
+ };
6
+ export declare const createTestComponent: (testId: string, content?: string) => () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { generateMockProducts } from './mock-products.js';
3
+ export const createProductListComponent = (productCount = 5) => {
4
+ const mockProducts = generateMockProducts(productCount);
5
+ function ProductListComponent() {
6
+ return (_jsx("ul", { "data-testid": "product-list", children: mockProducts.map((product) => (_jsx("li", { "data-testid": "product-item", children: product.ec_name }, product.ec_product_id))) }));
7
+ }
8
+ return { ProductListComponent, mockProducts };
9
+ };
10
+ export const createTestComponent = (testId, content = 'Test Content') => {
11
+ function TestComponent() {
12
+ return _jsx("div", { "data-testid": testId, children: content });
13
+ }
14
+ return TestComponent;
15
+ };
16
+ //# sourceMappingURL=component-test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-test-utils.js","sourceRoot":"","sources":["../../src/__tests__/component-test-utils.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAExD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,YAAY,GAAG,CAAC,EAAE,EAAE;IAC7D,MAAM,YAAY,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAExD,SAAS,oBAAoB;QAC3B,OAAO,CACL,4BAAgB,cAAc,YAC3B,YAAY,CAAC,GAAG,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,CACtC,4BAA4C,cAAc,YACvD,OAAO,CAAC,OAAO,IADT,OAAO,CAAC,aAAa,CAEzB,CACN,CAAC,GACC,CACN,CAAC;IACJ,CAAC;IAED,OAAO,EAAC,oBAAoB,EAAE,YAAY,EAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAAc,EACd,OAAO,GAAG,cAAc,EACxB,EAAE;IACF,SAAS,aAAa;QACpB,OAAO,6BAAkB,MAAM,YAAG,OAAO,GAAO,CAAC;IACnD,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { NavigatorContextProvider } from '@coveo/headless/ssr-commerce';
2
+ export declare const createMockCommerceNavigatorContextProvider: () => NavigatorContextProvider;
@@ -0,0 +1,7 @@
1
+ export const createMockCommerceNavigatorContextProvider = () => () => ({
2
+ clientId: 'test-commerce-client',
3
+ location: 'https://commerce.test.com',
4
+ referrer: 'https://search.test.com',
5
+ userAgent: 'Test Commerce Agent',
6
+ });
7
+ //# sourceMappingURL=mock-navigator-context-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-navigator-context-provider.js","sourceRoot":"","sources":["../../src/__tests__/mock-navigator-context-provider.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0CAA0C,GACrD,GAA6B,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC,QAAQ,EAAE,sBAAsB;IAChC,QAAQ,EAAE,2BAA2B;IACrC,QAAQ,EAAE,yBAAyB;IACnC,SAAS,EAAE,qBAAqB;CACjC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { Product } from '@coveo/headless/ssr-commerce';
2
+ export declare const generateMockProducts: (count: number) => Product[];
@@ -0,0 +1,31 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ const createMockProduct = (overrides = {}) => ({
3
+ additionalFields: {},
4
+ children: [],
5
+ clickUri: '',
6
+ ec_brand: 'Test Brand',
7
+ ec_category: ['Test Category'],
8
+ ec_color: 'Test Color',
9
+ ec_description: 'Test Description',
10
+ ec_gender: 'Test Gender',
11
+ ec_images: [],
12
+ ec_in_stock: true,
13
+ ec_item_group_id: 'test-group',
14
+ ec_listing: 'test-listing',
15
+ ec_name: 'Test Product',
16
+ ec_price: 99.99,
17
+ ec_product_id: randomUUID(),
18
+ ec_promo_price: 79.99,
19
+ ec_rating: 4.5,
20
+ ec_shortdesc: 'Test short description',
21
+ ec_thumbnails: [],
22
+ permanentid: randomUUID(),
23
+ position: 1,
24
+ totalNumberOfChildren: 0,
25
+ ...overrides,
26
+ });
27
+ export const generateMockProducts = (count) => Array.from({ length: count }, (_, index) => createMockProduct({
28
+ ec_name: `Product ${index + 1}`,
29
+ position: index + 1,
30
+ }));
31
+ //# sourceMappingURL=mock-products.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-products.js","sourceRoot":"","sources":["../../src/__tests__/mock-products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAGvC,MAAM,iBAAiB,GAAG,CAAC,YAA8B,EAAE,EAAW,EAAE,CAAC,CAAC;IACxE,gBAAgB,EAAE,EAAE;IACpB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,CAAC,eAAe,CAAC;IAC9B,QAAQ,EAAE,YAAY;IACtB,cAAc,EAAE,kBAAkB;IAClC,SAAS,EAAE,aAAa;IACxB,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,YAAY;IAC9B,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,KAAK;IACf,aAAa,EAAE,UAAU,EAAE;IAC3B,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,GAAG;IACd,YAAY,EAAE,wBAAwB;IACtC,aAAa,EAAE,EAAE;IACjB,WAAW,EAAE,UAAU,EAAE;IACzB,QAAQ,EAAE,CAAC;IACX,qBAAqB,EAAE,CAAC;IACxB,GAAG,SAAS;CACb,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAa,EAAE,CAC/D,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CACvC,iBAAiB,CAAC;IAChB,OAAO,EAAE,WAAW,KAAK,GAAG,CAAC,EAAE;IAC/B,QAAQ,EAAE,KAAK,GAAG,CAAC;CACpB,CAAC,CACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Controller } from '@coveo/headless';
2
+ type SolutionTypeAvailabilities = {
3
+ listing?: boolean;
4
+ search?: boolean;
5
+ standalone?: boolean;
6
+ recommendation?: boolean;
7
+ };
8
+ export declare function buildMockController(): Controller;
9
+ export declare function defineMockCommerceController(options?: SolutionTypeAvailabilities): {
10
+ build: import("vitest").Mock<(_engine: any) => Controller>;
11
+ listing: boolean;
12
+ search: boolean;
13
+ standalone: boolean;
14
+ recommendation: boolean;
15
+ };
16
+ export {};
@@ -0,0 +1,19 @@
1
+ import { vi } from 'vitest';
2
+ export function buildMockController() {
3
+ return {
4
+ subscribe: vi.fn(() => vi.fn()),
5
+ state: {},
6
+ };
7
+ }
8
+ export function defineMockCommerceController(options) {
9
+ return {
10
+ build: vi.fn((_engine) => {
11
+ return buildMockController();
12
+ }),
13
+ listing: options?.listing ?? true,
14
+ search: options?.search ?? true,
15
+ standalone: options?.standalone ?? true,
16
+ recommendation: options?.recommendation ?? true,
17
+ };
18
+ }
19
+ //# sourceMappingURL=mock-ssr-controller-definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-ssr-controller-definitions.js","sourceRoot":"","sources":["../../src/__tests__/mock-ssr-controller-definitions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,QAAQ,CAAC;AAS1B,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,KAAK,EAAE,EAAE;KACI,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAAoC;IAEpC,OAAO;QACL,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;YACvB,OAAO,mBAAmB,EAAE,CAAC;QAC/B,CAAC,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI;QACjC,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,IAAI;QAC/B,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,IAAI;QACvC,cAAc,EAAE,OAAO,EAAE,cAAc,IAAI,IAAI;KAChD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { CommerceEngine } from '@coveo/headless/ssr-commerce';
2
+ export declare const createMockCommerceEngine: () => CommerceEngine;
@@ -0,0 +1,7 @@
1
+ import { vi } from 'vitest';
2
+ export const createMockCommerceEngine = () => ({
3
+ state: {},
4
+ subscribe: vi.fn(() => vi.fn()), // Returns unsubscribe function
5
+ dispatch: vi.fn(),
6
+ });
7
+ //# sourceMappingURL=mock-ssr-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-ssr-engine.js","sourceRoot":"","sources":["../../src/__tests__/mock-ssr-engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,QAAQ,CAAC;AAE1B,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAC3C,CAAC;IACC,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,+BAA+B;IAChE,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;CAClB,CAA8B,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { cleanup } from '@testing-library/react';
2
+ import { afterEach, beforeEach, vi } from 'vitest';
3
+ beforeEach(() => {
4
+ vi.clearAllMocks();
5
+ });
6
+ afterEach(() => {
7
+ cleanup();
8
+ });
9
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAC;AAEjD,UAAU,CAAC,GAAG,EAAE;IACd,EAAE,CAAC,aAAa,EAAE,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,GAAG,EAAE;IACb,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type RenderResult } from '@testing-library/react';
2
+ import type { ReactElement } from 'react';
3
+ interface ProviderWrapperOptions {
4
+ controllers?: unknown;
5
+ engine?: unknown;
6
+ provider?: React.ComponentType<any>;
7
+ }
8
+ export declare function renderWithProvider(ui: ReactElement, options?: ProviderWrapperOptions): RenderResult;
9
+ export declare const waitForAsyncUpdates: () => Promise<void>;
10
+ export {};
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { render } from '@testing-library/react';
3
+ export function renderWithProvider(ui, options) {
4
+ return render(ui, {
5
+ wrapper: createProviderWrapper(options),
6
+ });
7
+ }
8
+ export const waitForAsyncUpdates = async () => {
9
+ // Wait for React to flush all pending updates
10
+ await new Promise((resolve) => setTimeout(resolve, 0));
11
+ // Wait for microtasks
12
+ await new Promise((resolve) => queueMicrotask(resolve));
13
+ };
14
+ function createProviderWrapper(options) {
15
+ return function ProviderWrapper({ children }) {
16
+ return options?.provider ? (_jsx(options.provider, { controllers: options?.controllers, engine: options?.engine, children: children })) : (_jsxs(_Fragment, { children: [" ", children, " "] }));
17
+ };
18
+ }
19
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../src/__tests__/test-utils.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAoB,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAUjE,MAAM,UAAU,kBAAkB,CAChC,EAAgB,EAChB,OAAgC;IAEhC,OAAO,MAAM,CAAC,EAAE,EAAE;QAChB,OAAO,EAAE,qBAAqB,CAAC,OAAO,CAAC;KACxC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE;IAC5C,8CAA8C;IAC9C,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IACvD,sBAAsB;IACtB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,SAAS,qBAAqB,CAAC,OAAgC;IAC7D,OAAO,SAAS,eAAe,CAAC,EAAC,QAAQ,EAAoB;QAC3D,OAAO,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CACzB,KAAC,OAAO,CAAC,QAAQ,IACf,WAAW,EAAE,OAAO,EAAE,WAAW,EACjC,MAAM,EAAE,OAAO,EAAE,MAAM,YAEtB,QAAQ,GACQ,CACpB,CAAC,CAAC,CAAC,CACF,mCAAI,QAAQ,SAAK,CAClB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
- export * from '@coveo/headless/ssr-commerce-next';
1
+ export * from '@coveo/headless/ssr-commerce';
2
2
  export { MissingEngineProviderError } from '../errors.js';
3
- export type { ReactCommerceEngineDefinition } from '../ssr-commerce-next/commerce-engine.js';
4
- export { defineCommerceEngine } from '../ssr-commerce-next/commerce-engine.js';
5
- export { buildProviderWithDefinition } from '../ssr-commerce-next/providers.js';
6
- export { ReactEngineDefinition } from '../ssr-commerce-next/types.js';
3
+ export type { ReactCommerceEngineDefinition } from '../ssr-commerce/commerce-engine.js';
4
+ export { defineCommerceEngine } from '../ssr-commerce/commerce-engine.js';
5
+ export { buildProviderWithDefinition } from '../ssr-commerce/providers.js';
6
+ export { ReactEngineDefinition } from '../ssr-commerce/types.js';
@@ -1,5 +1,5 @@
1
- export * from '@coveo/headless/ssr-commerce-next';
1
+ export * from '@coveo/headless/ssr-commerce';
2
2
  export { MissingEngineProviderError } from '../errors.js';
3
- export { defineCommerceEngine } from '../ssr-commerce-next/commerce-engine.js';
4
- export { buildProviderWithDefinition } from '../ssr-commerce-next/providers.js';
3
+ export { defineCommerceEngine } from '../ssr-commerce/commerce-engine.js';
4
+ export { buildProviderWithDefinition } from '../ssr-commerce/providers.js';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ssr-commerce-next/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAC,0BAA0B,EAAC,MAAM,cAAc,CAAC;AAExD,OAAO,EAAC,oBAAoB,EAAC,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAC,2BAA2B,EAAC,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ssr-commerce-next/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAC,0BAA0B,EAAC,MAAM,cAAc,CAAC;AAExD,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAC,2BAA2B,EAAC,MAAM,8BAA8B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveo/headless-react",
3
- "version": "2.5.7-pre.5db15b515b",
3
+ "version": "2.5.7-pre.5fc0927ed4",
4
4
  "description": "React utilities for SSR (Server Side Rendering) with headless",
5
5
  "homepage": "https://docs.coveo.com/en/headless/latest/",
6
6
  "repository": {
@@ -41,7 +41,7 @@
41
41
  "serve:typedoc": "live-server ./docs"
42
42
  },
43
43
  "dependencies": {
44
- "@coveo/headless": "3.29.2-pre.5db15b515b"
44
+ "@coveo/headless": "3.29.2-pre.5fc0927ed4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@testing-library/react": "16.3.0",
@@ -1,23 +0,0 @@
1
- import { type AugmentedControllerDefinition, type CommerceEngine, type CommerceEngineDefinitionOptions, type Controller, type ControllerDefinitionsMap, SolutionType } from '@coveo/headless/ssr-commerce-next';
2
- import type { InferControllerHooksMapFromDefinition, ReactEngineDefinition } from './types.js';
3
- /**
4
- * A React engine definition that includes context providers for static and hydrated states.
5
- *
6
- * @group Engine
7
- * */
8
- export type ReactCommerceEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = ReactEngineDefinition<TControllers, TSolutionType>;
9
- /**
10
- * Returns engine and controller hooks, and context providers.
11
- *
12
- * See [Define the commerce engine and controllers](https://docs.coveo.com/en/obif0156#define-the-commerce-engine-and-controllers).
13
- *
14
- * @group Engine
15
- */
16
- export declare function defineCommerceEngine<TControllers extends ControllerDefinitionsMap<Controller>>(options: CommerceEngineDefinitionOptions<TControllers>): {
17
- useEngine: () => CommerceEngine | undefined;
18
- controllers: InferControllerHooksMapFromDefinition<AugmentedControllerDefinition<TControllers>>;
19
- listingEngineDefinition: ReactCommerceEngineDefinition<TControllers, SolutionType.listing>;
20
- searchEngineDefinition: ReactCommerceEngineDefinition<TControllers, SolutionType.search>;
21
- standaloneEngineDefinition: ReactCommerceEngineDefinition<TControllers, SolutionType.standalone>;
22
- recommendationEngineDefinition: ReactCommerceEngineDefinition<TControllers, SolutionType.recommendation>;
23
- };
@@ -1,47 +0,0 @@
1
- import { defineCommerceEngine as defineBaseCommerceEngine, defineCart, defineContext, defineParameterManager, SolutionType, } from '@coveo/headless/ssr-commerce-next';
2
- // Workaround to prevent Next.js erroring about importing CSR only hooks
3
- import React from 'react';
4
- import { singleton } from '../utils.js';
5
- import { buildControllerHooks, buildEngineHook, buildStateProvider, } from './common.js';
6
- // Wrapper to workaround the limitation that `createContext()` cannot be called directly during SSR in next.js
7
- function createSingletonContext() {
8
- return singleton(() => React.createContext(null));
9
- }
10
- /**
11
- * Returns engine and controller hooks, and context providers.
12
- *
13
- * See [Define the commerce engine and controllers](https://docs.coveo.com/en/obif0156#define-the-commerce-engine-and-controllers).
14
- *
15
- * @group Engine
16
- */
17
- export function defineCommerceEngine(options) {
18
- const singletonContext = createSingletonContext();
19
- const { listingEngineDefinition, searchEngineDefinition, standaloneEngineDefinition, recommendationEngineDefinition, } = defineBaseCommerceEngine({ ...options });
20
- const augmentedControllerDefinition = {
21
- ...options.controllers,
22
- parameterManager: defineParameterManager(),
23
- context: defineContext(),
24
- cart: defineCart(),
25
- };
26
- return {
27
- useEngine: buildEngineHook(singletonContext),
28
- controllers: buildControllerHooks(singletonContext, augmentedControllerDefinition),
29
- listingEngineDefinition: {
30
- ...listingEngineDefinition,
31
- StateProvider: buildStateProvider(singletonContext, SolutionType.listing),
32
- },
33
- searchEngineDefinition: {
34
- ...searchEngineDefinition,
35
- StateProvider: buildStateProvider(singletonContext, SolutionType.search),
36
- },
37
- standaloneEngineDefinition: {
38
- ...standaloneEngineDefinition,
39
- StateProvider: buildStateProvider(singletonContext, SolutionType.standalone),
40
- },
41
- recommendationEngineDefinition: {
42
- ...recommendationEngineDefinition,
43
- StateProvider: buildStateProvider(singletonContext, SolutionType.recommendation),
44
- },
45
- };
46
- }
47
- //# sourceMappingURL=commerce-engine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commerce-engine.js","sourceRoot":"","sources":["../../src/ssr-commerce-next/commerce-engine.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,oBAAoB,IAAI,wBAAwB,EAChD,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,YAAY,GACb,MAAM,mCAAmC,CAAC;AAC3C,wEAAwE;AACxE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAuB,SAAS,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAgBrB,8GAA8G;AAC9G,SAAS,sBAAsB;IAI7B,OAAO,SAAS,CAAC,GAAG,EAAE,CACpB,KAAK,CAAC,aAAa,CAAmD,IAAI,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAGlC,OAAsD;IAuBtD,MAAM,gBAAgB,GAAG,sBAAsB,EAAgB,CAAC;IAUhE,MAAM,EACJ,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,GAC/B,GAAG,wBAAwB,CAAC,EAAC,GAAG,OAAO,EAAC,CAAC,CAAC;IAE3C,MAAM,6BAA6B,GAAG;QACpC,GAAG,OAAO,CAAC,WAAW;QACtB,gBAAgB,EAAE,sBAAsB,EAAE;QAC1C,OAAO,EAAE,aAAa,EAAE;QACxB,IAAI,EAAE,UAAU,EAAE;KAC4B,CAAC;IAEjD,OAAO;QACL,SAAS,EAAE,eAAe,CAAC,gBAAgB,CAAC;QAC5C,WAAW,EAAE,oBAAoB,CAC/B,gBAAgB,EAChB,6BAA6B,CAC9B;QACD,uBAAuB,EAAE;YACvB,GAAG,uBAAuB;YAC1B,aAAa,EAAE,kBAAkB,CAC/B,gBAAkC,EAClC,YAAY,CAAC,OAAO,CACrB;SACF;QACD,sBAAsB,EAAE;YACtB,GAAG,sBAAsB;YACzB,aAAa,EAAE,kBAAkB,CAC/B,gBAAiC,EACjC,YAAY,CAAC,MAAM,CACpB;SACF;QACD,0BAA0B,EAAE;YAC1B,GAAG,0BAA0B;YAC7B,aAAa,EAAE,kBAAkB,CAC/B,gBAAqC,EACrC,YAAY,CAAC,UAAU,CACxB;SACF;QACD,8BAA8B,EAAE;YAC9B,GAAG,8BAA8B;YACjC,aAAa,EAAE,kBAAkB,CAC/B,gBAAyC,EACzC,YAAY,CAAC,cAAc,CAC5B;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,25 +0,0 @@
1
- import { type Controller, type ControllerDefinitionsMap, type InferControllerStaticStateMapFromDefinitionsWithSolutionType, type InferControllersMapFromDefinition, SolutionType, type CommerceEngine as SSRCommerceEngine } from '@coveo/headless/ssr-commerce-next';
2
- import { type Context, type PropsWithChildren } from 'react';
3
- import { type SingletonGetter } from '../utils.js';
4
- import type { ContextState, InferControllerHooksMapFromDefinition } from './types.js';
5
- export declare function buildControllerHooks<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>(singletonContext: SingletonGetter<Context<ContextState<TControllers, TSolutionType> | null>>, controllersMap?: TControllers): InferControllerHooksMapFromDefinition<TControllers>;
6
- export declare function buildEngineHook<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>(singletonContext: SingletonGetter<Context<ContextState<TControllers, TSolutionType> | null>>): () => SSRCommerceEngine | undefined;
7
- /**
8
- * @deprecated use `buildStateProvider` instead.
9
- * It is isomorphic and can be used for both static and hydrated state.
10
- */
11
- export declare function buildStaticStateProvider<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>(singletonContext: SingletonGetter<Context<ContextState<TControllers, TSolutionType> | null>>, solutionType: TSolutionType): ({ controllers, children, }: PropsWithChildren<{
12
- controllers: InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers, TSolutionType>;
13
- }>) => import("react/jsx-runtime").JSX.Element;
14
- /**
15
- * @deprecated use `buildStateProvider` instead.
16
- * It is isomorphic and can be used for both static and hydrated state.
17
- */
18
- export declare function buildHydratedStateProvider<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>(singletonContext: SingletonGetter<Context<ContextState<TControllers, TSolutionType> | null>>, solutionType: TSolutionType): ({ engine, controllers, children, }: PropsWithChildren<{
19
- engine: SSRCommerceEngine;
20
- controllers: InferControllersMapFromDefinition<TControllers, TSolutionType>;
21
- }>) => import("react/jsx-runtime").JSX.Element;
22
- export declare function buildStateProvider<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>(singletonContext: SingletonGetter<Context<ContextState<TControllers, TSolutionType> | null>>, solutionType: TSolutionType): ({ engine, controllers, children, }: PropsWithChildren<{
23
- engine?: SSRCommerceEngine;
24
- controllers: InferControllersMapFromDefinition<TControllers, TSolutionType> | InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers, TSolutionType>;
25
- }>) => import("react/jsx-runtime").JSX.Element;
@@ -1,80 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { SolutionType, } from '@coveo/headless/ssr-commerce-next';
3
- import { useCallback, useContext, useMemo, } from 'react';
4
- import { useSyncMemoizedStore } from '../client-utils.js';
5
- import { MissingEngineProviderError, UndefinedControllerError, } from '../errors.js';
6
- import { capitalize, mapObject } from '../utils.js';
7
- function isHydratedStateContext(ctx) {
8
- return 'engine' in ctx && !!ctx.engine;
9
- }
10
- function buildControllerHook(singletonContext, key, controllerDefinition) {
11
- return () => {
12
- const ctx = useContext(singletonContext.get());
13
- if (ctx === null) {
14
- throw new MissingEngineProviderError();
15
- }
16
- const allSolutionTypes = Object.values(SolutionType);
17
- const supportedSolutionTypes = allSolutionTypes.filter((solutionType) => controllerDefinition[solutionType] === true);
18
- if (ctx.controllers[key] === undefined) {
19
- throw new UndefinedControllerError(key.toString(), supportedSolutionTypes);
20
- }
21
- const subscribe = useCallback((listener) => isHydratedStateContext(ctx)
22
- ? ctx.controllers[key].subscribe(listener)
23
- : () => { }, [ctx, key]);
24
- const getStaticState = useCallback(() => ctx.controllers[key].state, [ctx, key]);
25
- const state = useSyncMemoizedStore(subscribe, getStaticState);
26
- const methods = useMemo(() => {
27
- if (!isHydratedStateContext(ctx)) {
28
- return undefined;
29
- }
30
- const controller = ctx.controllers[key];
31
- const { state: _, subscribe: __, ...remainder } = controller;
32
- return mapObject(remainder, (member) => typeof member === 'function' ? member.bind(controller) : member);
33
- }, [ctx, key]);
34
- return { state, methods };
35
- };
36
- }
37
- export function buildControllerHooks(singletonContext, controllersMap) {
38
- return (controllersMap
39
- ? Object.fromEntries(Object.entries(controllersMap).map(([key, controllerDefinition]) => [
40
- `use${capitalize(key)}`,
41
- buildControllerHook(singletonContext, key, controllerDefinition),
42
- ]))
43
- : {});
44
- }
45
- export function buildEngineHook(singletonContext) {
46
- return () => {
47
- const ctx = useContext(singletonContext.get());
48
- if (ctx === null) {
49
- throw new MissingEngineProviderError();
50
- }
51
- return isHydratedStateContext(ctx) ? ctx.engine : undefined;
52
- };
53
- }
54
- /**
55
- * @deprecated use `buildStateProvider` instead.
56
- * It is isomorphic and can be used for both static and hydrated state.
57
- */
58
- export function buildStaticStateProvider(singletonContext, solutionType) {
59
- return ({ controllers, children, }) => {
60
- const { Provider } = singletonContext.get();
61
- return _jsx(Provider, { value: { controllers, solutionType }, children: children });
62
- };
63
- }
64
- /**
65
- * @deprecated use `buildStateProvider` instead.
66
- * It is isomorphic and can be used for both static and hydrated state.
67
- */
68
- export function buildHydratedStateProvider(singletonContext, solutionType) {
69
- return ({ engine, controllers, children, }) => {
70
- const { Provider } = singletonContext.get();
71
- return (_jsx(Provider, { value: { engine, controllers, solutionType }, children: children }));
72
- };
73
- }
74
- export function buildStateProvider(singletonContext, solutionType) {
75
- return ({ engine, controllers, children, }) => {
76
- const { Provider } = singletonContext.get();
77
- return (_jsx(Provider, { value: { engine, controllers, solutionType }, children: children }));
78
- };
79
- }
80
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1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AkB,CAIhC,gBAEC,EACD,YAA2B;IAE3B,OAAO,CAAC,EACN,MAAM,EACN,WAAW,EACX,QAAQ,GASR,EAAE,EAAE;QACJ,MAAM,EAAC,QAAQ,EAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC;QAC1C,OAAO,CACL,KAAC,QAAQ,IAAC,KAAK,EAAE,EAAC,MAAM,EAAE,WAAW,EAAE,YAAY,EAAC,YACjD,QAAQ,GACA,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { BuildConfig, Controller, ControllerDefinitionsMap, EngineStaticState, FilteredBakedInControllers, InferControllerStaticStateMapFromDefinitionsWithSolutionType, NavigatorContext, SolutionType } from '@coveo/headless/ssr-commerce-next';
2
- import { type PropsWithChildren } from 'react';
3
- import type { ReactCommerceEngineDefinition } from './commerce-engine.js';
4
- type UnknownAction = {
5
- type: string;
6
- };
7
- /**
8
- * Providers take care of displaying your page with the static
9
- * state, and then hydrating the state and displaying the page
10
- * with the hydrated state. They are required for your controller hooks to function.
11
- *
12
- * See [Create providers](https://docs.coveo.com/en/obif0156/#create-providers).
13
- *
14
- * @group Providers
15
- */
16
- export declare function buildProviderWithDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>(definition: ReactCommerceEngineDefinition<TControllers, TSolutionType>): ({ staticState, navigatorContext, children, }: PropsWithChildren<{
17
- staticState: EngineStaticState<UnknownAction, InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers, TSolutionType> & FilteredBakedInControllers<TSolutionType>> & BuildConfig<TSolutionType>;
18
- navigatorContext: NavigatorContext;
19
- }>) => import("react/jsx-runtime").JSX.Element;
20
- export {};
@@ -1,31 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useEffect, useState } from 'react';
4
- /**
5
- * Providers take care of displaying your page with the static
6
- * state, and then hydrating the state and displaying the page
7
- * with the hydrated state. They are required for your controller hooks to function.
8
- *
9
- * See [Create providers](https://docs.coveo.com/en/obif0156/#create-providers).
10
- *
11
- * @group Providers
12
- */
13
- export function buildProviderWithDefinition(definition) {
14
- return function WrappedProvider({ staticState, navigatorContext, children, }) {
15
- const [hydratedState, setHydratedState] = useState(undefined);
16
- definition.setNavigatorContextProvider(() => navigatorContext);
17
- useEffect(() => {
18
- definition
19
- // @ts-expect-error: TODO: KIT-4754: get rid of the OptionTuple type
20
- .hydrateStaticState(staticState)
21
- .then(({ engine, controllers }) => {
22
- setHydratedState({
23
- engine,
24
- controllers: controllers,
25
- });
26
- });
27
- }, [staticState, definition]);
28
- return (_jsx(definition.StateProvider, { engine: hydratedState?.engine, controllers: hydratedState?.controllers || staticState.controllers, children: children }));
29
- };
30
- }
31
- //# sourceMappingURL=providers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/ssr-commerce-next/providers.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAcb,OAAO,EAAyB,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAKlE;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CAGzC,UAAsE;IACtE,OAAO,SAAS,eAAe,CAAC,EAC9B,WAAW,EACX,gBAAgB,EAChB,QAAQ,GAaR;QACA,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAEhD,SAAS,CAAC,CAAC;QACb,UAAU,CAAC,2BAA2B,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAE/D,SAAS,CAAC,GAAG,EAAE;YACb,UAAU;gBACR,oEAAoE;iBACnE,kBAAkB,CAAC,WAAW,CAAC;iBAC/B,IAAI,CAAC,CAAC,EAAC,MAAM,EAAE,WAAW,EAAC,EAAE,EAAE;gBAC9B,gBAAgB,CAAC;oBACf,MAAM;oBACN,WAAW,EAAE,WAGZ;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;QAE9B,OAAO,CACL,KAAC,UAAU,CAAC,aAAa,IACvB,MAAM,EAAE,aAAa,EAAE,MAAM,EAC7B,WAAW,EAAE,aAAa,EAAE,WAAW,IAAI,WAAW,CAAC,WAAW,YAEjE,QAAQ,GACgB,CAC5B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { CommerceEngineDefinition, Controller, ControllerDefinitionsMap, InferControllerFromDefinition, InferControllerStaticStateMapFromDefinitionsWithSolutionType, InferControllersMapFromDefinition, SolutionType, CommerceEngine as SSRCommerceEngine } from '@coveo/headless/ssr-commerce-next';
2
- import type { FunctionComponent, PropsWithChildren } from 'react';
3
- export type ContextHydratedState<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
4
- engine: SSRCommerceEngine;
5
- controllers: InferControllersMapFromDefinition<TControllers, TSolutionType>;
6
- solutionType: TSolutionType;
7
- };
8
- export type ContextState<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
9
- engine?: SSRCommerceEngine;
10
- controllers: InferControllersMapFromDefinition<TControllers, TSolutionType> | InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers, TSolutionType>;
11
- solutionType: TSolutionType;
12
- };
13
- export type ControllerHook<TController extends Controller> = () => {
14
- state: TController['state'];
15
- methods?: Omit<TController, 'state' | 'subscribe'>;
16
- };
17
- export type InferControllerHooksMapFromDefinition<TControllers extends ControllerDefinitionsMap<Controller>> = {
18
- [K in keyof TControllers as `use${Capitalize<K extends string ? K : never>}`]: ControllerHook<InferControllerFromDefinition<TControllers[K]>>;
19
- };
20
- export type ReactEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = CommerceEngineDefinition<TControllers, TSolutionType> & {
21
- StateProvider: FunctionComponent<PropsWithChildren<{
22
- engine?: SSRCommerceEngine;
23
- controllers: InferControllersMapFromDefinition<TControllers, TSolutionType> | InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers, TSolutionType>;
24
- }>>;
25
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ssr-commerce-next/types.ts"],"names":[],"mappings":""}