@hanzo/commerce 7.0.15 → 7.0.16

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/context/index.tsx CHANGED
@@ -10,10 +10,9 @@ import React, {
10
10
  import { enableStaticRendering } from 'mobx-react-lite'
11
11
  enableStaticRendering(typeof window === "undefined")
12
12
 
13
- import type { ServiceOptions } from '..'
14
13
  import type CommerceService from '../types/commerce-service'
15
14
  import getInstance from '../service/get-instance'
16
- import type { Family, CategoryNode, SelectionUISpecifier } from '../types'
15
+ import type { CommerceConfig } from '../types'
17
16
 
18
17
  const CommerceContext = createContext<CommerceService | undefined>(undefined)
19
18
 
@@ -22,20 +21,14 @@ const useCommerce = (): CommerceService => {
22
21
  }
23
22
 
24
23
  const CommerceProvider: React.FC<PropsWithChildren & {
25
- families: Family[]
26
- rootNode: CategoryNode
27
- options?: ServiceOptions
28
- uiSpecs?: Record<string, SelectionUISpecifier>
24
+ config: CommerceConfig
29
25
  }> = ({
30
26
  children,
31
- families,
32
- rootNode,
33
- options,
34
- uiSpecs
27
+ config
35
28
  }) => {
36
29
 
37
30
  // TODO: Inject Promo fixture here from siteDef
38
- const service = getInstance(families, rootNode, options, uiSpecs)
31
+ const service = getInstance(config)
39
32
  const valueRef = useRef<CommerceService>(service)
40
33
 
41
34
  return (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "7.0.15",
3
+ "version": "7.0.16",
4
4
  "description": "e-commerce framework.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -1,6 +1,6 @@
1
1
  import { enableStaticRendering } from 'mobx-react-lite'
2
2
 
3
- import type { CommerceService, Family, CategoryNode, SelectionUISpecifier } from '../../../types'
3
+ import type { CommerceService, Family, CategoryNode, SelectionUISpecifier, CommerceConfig } from '../../../types'
4
4
  import StandaloneService, {type StandaloneServiceOptions} from './standalone-service'
5
5
  import { initSelectionUI } from '../../../util'
6
6
 
@@ -18,20 +18,20 @@ const _log = (s: string) => {
18
18
 
19
19
  let instance: StandaloneService | undefined = undefined
20
20
 
21
- export const getInstance = (
22
- families: Family[],
23
- rootNode: CategoryNode,
24
- options?: StandaloneServiceOptions,
25
- uiSpecs?: Record<string, SelectionUISpecifier>
26
- ): CommerceService => {
21
+ export const getInstance = ({
22
+ families,
23
+ rootNode,
24
+ options,
25
+ uiSpecifiers
26
+ }: CommerceConfig) : CommerceService => {
27
27
 
28
28
  if (!options) {
29
29
  throw new Error('cmmc getInstance(): Standalone Commerce Service requires config options!')
30
30
  }
31
31
 
32
32
  if (typeof window === "undefined") {
33
- if (uiSpecs) {
34
- initSelectionUI(uiSpecs)
33
+ if (uiSpecifiers) {
34
+ initSelectionUI(uiSpecifiers)
35
35
  }
36
36
  //_log("NEW INSTANCE FOR SERVER")
37
37
  return new StandaloneService(
@@ -43,8 +43,8 @@ export const getInstance = (
43
43
 
44
44
  // Client side, create the store only once in the client
45
45
  if (!instance) {
46
- if (uiSpecs) {
47
- initSelectionUI(uiSpecs)
46
+ if (uiSpecifiers) {
47
+ initSelectionUI(uiSpecifiers)
48
48
  }
49
49
  //_log("NEW INSTANCE FOR CLIENT")
50
50
  const snapShot = readSnapshot()
@@ -0,0 +1,13 @@
1
+ import type { ServiceOptions } from '..'
2
+ import type { CategoryNode } from './category-node'
3
+ import type { Family } from './family'
4
+ import type { SelectionUISpecifier } from './selection-ui-specifier'
5
+
6
+ interface CommerceConfig {
7
+ families: Family[]
8
+ rootNode: CategoryNode
9
+ options?: ServiceOptions
10
+ uiSpecifiers?: Record<string, SelectionUISpecifier>
11
+ }
12
+
13
+ export { type CommerceConfig as default }
package/types/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  export type { default as CommerceService } from './commerce-service'
3
+ export type { default as CommerceConfig } from './commerce-config'
3
4
  export type { default as MultiFamilySelectorProps } from './multi-family-selector-props'
4
5
  export type { default as Product } from './product'
5
6
  export type { default as Promo } from './promo'