@dutchiesdk/ecommerce-extensions-sdk 0.17.0 → 0.18.0

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 CHANGED
@@ -26,11 +26,7 @@ yarn add @dutchie/ecommerce-extensions-sdk
26
26
 
27
27
  ```tsx
28
28
  import React from "react";
29
- import {
30
- useDataBridge,
31
- RemoteBoundaryComponent,
32
- DataBridgeVersion,
33
- } from "@dutchie/ecommerce-extensions-sdk";
29
+ import { useDataBridge, RemoteBoundaryComponent, DataBridgeVersion } from "@dutchie/ecommerce-extensions-sdk";
34
30
 
35
31
  const MyExtension: RemoteBoundaryComponent = () => {
36
32
  const { dataLoaders, actions, location, user, cart } = useDataBridge();
@@ -78,10 +74,7 @@ const MyComponent = () => {
78
74
  A utility hook for handling async data loading with loading states.
79
75
 
80
76
  ```tsx
81
- import {
82
- useAsyncLoader,
83
- useDataBridge,
84
- } from "@dutchie/ecommerce-extensions-sdk";
77
+ import { useAsyncLoader, useDataBridge } from "@dutchie/ecommerce-extensions-sdk";
85
78
 
86
79
  const ProductList = () => {
87
80
  const { dataLoaders } = useDataBridge();
@@ -125,11 +118,7 @@ All extension components that integrate with the Dutchie platform should satisfy
125
118
  **Example:**
126
119
 
127
120
  ```tsx
128
- import {
129
- RemoteBoundaryComponent,
130
- useDataBridge,
131
- DataBridgeVersion,
132
- } from "@dutchie/ecommerce-extensions-sdk";
121
+ import { RemoteBoundaryComponent, useDataBridge, DataBridgeVersion } from "@dutchie/ecommerce-extensions-sdk";
133
122
 
134
123
  const MyCustomHeader: RemoteBoundaryComponent = () => {
135
124
  const { location, user, actions } = useDataBridge();
@@ -137,11 +126,7 @@ const MyCustomHeader: RemoteBoundaryComponent = () => {
137
126
  return (
138
127
  <header>
139
128
  <h1>{location?.name}</h1>
140
- {user ? (
141
- <span>Welcome, {user.firstName}!</span>
142
- ) : (
143
- <button onClick={actions.goToLogin}>Login</button>
144
- )}
129
+ {user ? <span>Welcome, {user.firstName}!</span> : <button onClick={actions.goToLogin}>Login</button>}
145
130
  </header>
146
131
  );
147
132
  };
@@ -216,9 +201,7 @@ The `getStoreFrontMetaFields` function is the **recommended approach** for gener
216
201
  ### Function Signature
217
202
 
218
203
  ```typescript
219
- export type StoreFrontMetaFieldsFunction = (
220
- data: CommerceComponentsDataInterface
221
- ) => MetaFields | Promise<MetaFields>;
204
+ export type StoreFrontMetaFieldsFunction = (data: CommerceComponentsDataInterface) => MetaFields | Promise<MetaFields>;
222
205
  ```
223
206
 
224
207
  The function receives the full data bridge interface and can return meta fields synchronously or asynchronously.
@@ -246,14 +229,9 @@ type MetaFields = {
246
229
  Create a file in your theme (e.g., `get-meta-fields.ts`):
247
230
 
248
231
  ```typescript
249
- import {
250
- CommerceComponentsDataInterface,
251
- MetaFields,
252
- } from "@dutchiesdk/ecommerce-extensions-sdk";
253
-
254
- export const getStoreFrontMetaFields = async (
255
- data: CommerceComponentsDataInterface
256
- ): Promise<MetaFields> => {
232
+ import { CommerceComponentsDataInterface, MetaFields } from "@dutchiesdk/ecommerce-extensions-sdk";
233
+
234
+ export const getStoreFrontMetaFields = async (data: CommerceComponentsDataInterface): Promise<MetaFields> => {
257
235
  const { location, dataLoaders } = data;
258
236
  const page = typeof window !== "undefined" ? window.location.pathname : "";
259
237
 
@@ -306,6 +284,24 @@ export default {
306
284
  } satisfies RemoteModuleRegistry;
307
285
  ```
308
286
 
287
+ You may also register components for only specific menu contexts:
288
+
289
+ ```typescript
290
+ import { RemoteModuleRegistry } from "@dutchiesdk/ecommerce-extensions-sdk";
291
+
292
+ export default {
293
+ StoreFrontHeader: {
294
+ // use one component for storefront and a different one for kiosk
295
+ 'store-front': createLazyRemoteBoundaryComponent(() => import("./store-header")),
296
+ kiosk: createLazyRemoteBoundaryComponent(() => import("./kiosk-header")),
297
+ },
298
+ StoreFrontFooter: {
299
+ // only override storefront but not kiosk, kiosk will have default dutchie footer
300
+ 'store-front': createLazyRemoteBoundaryComponent(() => import("./footer")),
301
+ },
302
+ } satisfies RemoteModuleRegistry;
303
+ ```
304
+
309
305
  ### Available Data
310
306
 
311
307
  The function receives the full `CommerceComponentsDataInterface`:
@@ -417,7 +413,7 @@ const MyComponent = () => {
417
413
  const { data, isLoading } = useAsyncLoader(dataLoaders.products);
418
414
 
419
415
  if (isLoading) return <LoadingSpinner />;
420
- if (!data) return <EmptyProducts message='No products found' />;
416
+ if (!data) return <EmptyProducts message="No products found" />;
421
417
 
422
418
  return <ProductList products={data} />;
423
419
  };
@@ -432,11 +428,7 @@ Any uncaught errors will be caught by a Dutchie error boundary, and the fallback
432
428
  Leverage the provided types for better development experience:
433
429
 
434
430
  ```tsx
435
- import {
436
- Product,
437
- Category,
438
- useDataBridge,
439
- } from "@dutchie/ecommerce-extensions-sdk";
431
+ import { Product, Category, useDataBridge } from "@dutchie/ecommerce-extensions-sdk";
440
432
 
441
433
  interface ProductFilterProps {
442
434
  products: Product[];
@@ -444,11 +436,7 @@ interface ProductFilterProps {
444
436
  onFilterChange: (categoryId: string) => void;
445
437
  }
446
438
 
447
- const ProductFilter: React.FC<ProductFilterProps> = ({
448
- products,
449
- categories,
450
- onFilterChange,
451
- }) => {
439
+ const ProductFilter: React.FC<ProductFilterProps> = ({ products, categories, onFilterChange }) => {
452
440
  // Implementation
453
441
  };
454
442
  ```
@@ -463,7 +451,7 @@ const UserProfile = () => {
463
451
 
464
452
  if (!user) {
465
453
  return (
466
- <div className='login-prompt'>
454
+ <div className="login-prompt">
467
455
  <p>Please log in to view your profile</p>
468
456
  <button onClick={actions.goToLogin}>Login</button>
469
457
  </div>
@@ -471,7 +459,7 @@ const UserProfile = () => {
471
459
  }
472
460
 
473
461
  return (
474
- <div className='user-profile'>
462
+ <div className="user-profile">
475
463
  <h2>Welcome, {user.firstName}!</h2>
476
464
  {/* Profile content */}
477
465
  </div>
@@ -526,3 +514,11 @@ For technical support and questions about the Dutchie Ecommerce Extensions SDK:
526
514
  - 📧 Contact your Dutchie agency partner representative
527
515
  - 📚 Refer to the Dutchie Pro platform documentation
528
516
  - 🐛 Report issues through the official Dutchie support channels
517
+
518
+ ## Updates
519
+
520
+ Stay up to date with this SDK by checking here for changes, and updating to the latest version with:
521
+
522
+ ```bash
523
+ npm install @dutchiesdk/ecommerce-extensions-sdk@latest
524
+ ```
@@ -30,7 +30,7 @@ __webpack_require__.d(__webpack_exports__, {
30
30
  useDataBridge: ()=>useDataBridge
31
31
  });
32
32
  const external_react_namespaceObject = require("react");
33
- const DataBridgeVersion = '0.17.0';
33
+ const DataBridgeVersion = '0.18.0';
34
34
  const DataBridgeContext = (0, external_react_namespaceObject.createContext)(void 0);
35
35
  const useDataBridge = ()=>{
36
36
  const context = (0, external_react_namespaceObject.useContext)(DataBridgeContext);
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext, useEffect, useState } from "react";
2
- const DataBridgeVersion = '0.17.0';
2
+ const DataBridgeVersion = '0.18.0';
3
3
  const DataBridgeContext = createContext(void 0);
4
4
  const useDataBridge = ()=>{
5
5
  const context = useContext(DataBridgeContext);
@@ -1,9 +1,14 @@
1
1
  import type React from 'react';
2
+ import type { MenuContext } from './data';
2
3
  import type { Events } from './events';
3
4
  import type { CommerceComponentsDataInterface } from './interface';
4
5
  export type RemoteBoundaryComponent<P = {}> = React.FC<P> & {
5
6
  DataBridgeVersion: string;
6
7
  };
8
+ export type MenuSpecificRemoteComponent = {
9
+ [key in MenuContext]?: RemoteBoundaryComponent;
10
+ };
11
+ export type ModuleRegistryEntry = MenuSpecificRemoteComponent | RemoteBoundaryComponent;
7
12
  export type RoutablePageRegistryEntry = {
8
13
  component: RemoteBoundaryComponent;
9
14
  path: string;
@@ -40,14 +45,12 @@ export type MetaFields = {
40
45
  export type StoreFrontMetaFieldsFunction = (data: CommerceComponentsDataInterface) => MetaFields | Promise<MetaFields>;
41
46
  export type RemoteModuleRegistry = {
42
47
  RouteablePages?: RoutablePageRegistryEntry[];
43
- StoreFrontHeader?: RemoteBoundaryComponent;
44
- StoreFrontMeta?: RemoteBoundaryComponent;
45
- StoreFrontNavigation?: RemoteBoundaryComponent;
46
- StoreFrontFooter?: RemoteBoundaryComponent;
47
- StoreFrontCarouselInterstitials?: RemoteBoundaryComponent[];
48
- StoreFrontHero?: RemoteBoundaryComponent;
49
- ProductDetailsMeta?: RemoteBoundaryComponent;
50
- ProductDetailsPrimary?: RemoteBoundaryComponent;
48
+ StoreFrontHeader?: ModuleRegistryEntry;
49
+ StoreFrontNavigation?: ModuleRegistryEntry;
50
+ StoreFrontFooter?: ModuleRegistryEntry;
51
+ StoreFrontCarouselInterstitials?: ModuleRegistryEntry[];
52
+ StoreFrontHero?: ModuleRegistryEntry;
53
+ ProductDetailsPrimary?: ModuleRegistryEntry;
51
54
  /**
52
55
  * Function that provides meta fields for the current page.
53
56
  * Replaces the StoreFrontMeta component approach.
@@ -57,4 +60,12 @@ export type RemoteModuleRegistry = {
57
60
  */
58
61
  getStoreFrontMetaFields?: StoreFrontMetaFieldsFunction;
59
62
  events?: Events;
63
+ /**
64
+ * @deprecated Use getStoreFrontMetaFields instead
65
+ */
66
+ StoreFrontMeta?: RemoteBoundaryComponent;
67
+ /**
68
+ * @deprecated Use getStoreFrontMetaFields instead
69
+ */
70
+ ProductDetailsMeta?: RemoteBoundaryComponent;
60
71
  };
@@ -1,9 +1,14 @@
1
1
  import type React from 'react';
2
+ import type { MenuContext } from './data';
2
3
  import type { Events } from './events';
3
4
  import type { CommerceComponentsDataInterface } from './interface';
4
5
  export type RemoteBoundaryComponent<P = {}> = React.FC<P> & {
5
6
  DataBridgeVersion: string;
6
7
  };
8
+ export type MenuSpecificRemoteComponent = {
9
+ [key in MenuContext]?: RemoteBoundaryComponent;
10
+ };
11
+ export type ModuleRegistryEntry = MenuSpecificRemoteComponent | RemoteBoundaryComponent;
7
12
  export type RoutablePageRegistryEntry = {
8
13
  component: RemoteBoundaryComponent;
9
14
  path: string;
@@ -40,14 +45,12 @@ export type MetaFields = {
40
45
  export type StoreFrontMetaFieldsFunction = (data: CommerceComponentsDataInterface) => MetaFields | Promise<MetaFields>;
41
46
  export type RemoteModuleRegistry = {
42
47
  RouteablePages?: RoutablePageRegistryEntry[];
43
- StoreFrontHeader?: RemoteBoundaryComponent;
44
- StoreFrontMeta?: RemoteBoundaryComponent;
45
- StoreFrontNavigation?: RemoteBoundaryComponent;
46
- StoreFrontFooter?: RemoteBoundaryComponent;
47
- StoreFrontCarouselInterstitials?: RemoteBoundaryComponent[];
48
- StoreFrontHero?: RemoteBoundaryComponent;
49
- ProductDetailsMeta?: RemoteBoundaryComponent;
50
- ProductDetailsPrimary?: RemoteBoundaryComponent;
48
+ StoreFrontHeader?: ModuleRegistryEntry;
49
+ StoreFrontNavigation?: ModuleRegistryEntry;
50
+ StoreFrontFooter?: ModuleRegistryEntry;
51
+ StoreFrontCarouselInterstitials?: ModuleRegistryEntry[];
52
+ StoreFrontHero?: ModuleRegistryEntry;
53
+ ProductDetailsPrimary?: ModuleRegistryEntry;
51
54
  /**
52
55
  * Function that provides meta fields for the current page.
53
56
  * Replaces the StoreFrontMeta component approach.
@@ -57,4 +60,12 @@ export type RemoteModuleRegistry = {
57
60
  */
58
61
  getStoreFrontMetaFields?: StoreFrontMetaFieldsFunction;
59
62
  events?: Events;
63
+ /**
64
+ * @deprecated Use getStoreFrontMetaFields instead
65
+ */
66
+ StoreFrontMeta?: RemoteBoundaryComponent;
67
+ /**
68
+ * @deprecated Use getStoreFrontMetaFields instead
69
+ */
70
+ ProductDetailsMeta?: RemoteBoundaryComponent;
60
71
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.17.0",
7
+ "version": "0.18.0",
8
8
  "license": "MIT",
9
9
  "type": "module",
10
10
  "module": "./dist/esm/index.js",