@remkoj/optimizely-cms-react 4.3.1 → 5.0.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.
Files changed (56) hide show
  1. package/dist/components/cms-content/get-content.js +23 -21
  2. package/dist/components/cms-content/get-content.js.map +1 -1
  3. package/dist/components/cms-content/resolve-component.d.ts +4 -4
  4. package/dist/components/cms-content/resolve-component.js +14 -14
  5. package/dist/components/cms-content/resolve-component.js.map +1 -1
  6. package/dist/components/cms-content/rsc.d.ts +2 -2
  7. package/dist/components/cms-content/rsc.js +14 -7
  8. package/dist/components/cms-content/rsc.js.map +1 -1
  9. package/dist/components/cms-content/types.d.ts +11 -4
  10. package/dist/components/cms-content-area/index.d.ts +3 -10
  11. package/dist/components/cms-content-area/index.js +35 -51
  12. package/dist/components/cms-content-area/index.js.map +1 -1
  13. package/dist/components/cms-content-area/types.d.ts +49 -57
  14. package/dist/components/cms-editable/index.d.ts +48 -13
  15. package/dist/components/cms-editable/index.js +41 -5
  16. package/dist/components/cms-editable/index.js.map +1 -1
  17. package/dist/components/rich-text/components.d.ts +8 -7
  18. package/dist/components/rich-text/components.js +27 -22
  19. package/dist/components/rich-text/components.js.map +1 -1
  20. package/dist/components/rich-text/index.d.ts +4 -4
  21. package/dist/components/rich-text/index.js +19 -20
  22. package/dist/components/rich-text/index.js.map +1 -1
  23. package/dist/components/rich-text/types.d.ts +7 -15
  24. package/dist/components/rsc.d.ts +12 -12
  25. package/dist/components/rsc.js +17 -16
  26. package/dist/components/rsc.js.map +1 -1
  27. package/dist/components/type-utils.d.ts +13 -0
  28. package/dist/components/visual-builder/functions.js +1 -1
  29. package/dist/components/visual-builder/functions.js.map +1 -1
  30. package/dist/components/visual-builder/index.d.ts +1 -1
  31. package/dist/components/visual-builder/index.js +11 -9
  32. package/dist/components/visual-builder/index.js.map +1 -1
  33. package/dist/components/visual-builder/types.d.ts +3 -3
  34. package/dist/components/visual-builder/types.js.map +1 -1
  35. package/dist/components.d.ts +1 -1
  36. package/dist/context/client.d.ts +16 -4
  37. package/dist/context/client.js +38 -12
  38. package/dist/context/client.js.map +1 -1
  39. package/dist/context/rsc.d.ts +26 -9
  40. package/dist/context/rsc.js +84 -18
  41. package/dist/context/rsc.js.map +1 -1
  42. package/dist/context/shared.d.ts +3 -0
  43. package/dist/context/shared.js +7 -0
  44. package/dist/context/shared.js.map +1 -0
  45. package/dist/context/types.d.ts +24 -2
  46. package/dist/factory/default.js +16 -16
  47. package/dist/factory/default.js.map +1 -1
  48. package/dist/index.d.ts +4 -5
  49. package/dist/index.js +6 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/rsc.d.ts +2 -4
  52. package/dist/rsc.js +3 -1
  53. package/dist/rsc.js.map +1 -1
  54. package/dist/types.d.ts +5 -0
  55. package/dist/version.json +3 -0
  56. package/package.json +7 -7
@@ -1,17 +1,10 @@
1
1
  import 'server-only';
2
- import { createClient, isOptiGraphClient } from '@remkoj/optimizely-graph-client';
2
+ import { createClient, isOptiGraphClient, } from '@remkoj/optimizely-graph-client';
3
3
  import React from 'react';
4
- import { DefaultComponentFactory } from '../factory/index.js';
4
+ import { DefaultComponentFactory, } from '../factory/index.js';
5
5
  import { isDebug, isDevelopment } from '../rsc-utilities.js';
6
- export * from "./types.js";
7
- const cachePlaceholder = (factory) => {
8
- if (isDebug() || isDevelopment())
9
- console.warn("🚧 [React Context] Running client/server react code instead of server context, no cache() available.");
10
- return factory;
11
- };
12
- //@ts-expect-error React.cache is only available in the react-server context
13
- const cache = (React.cache || cachePlaceholder);
14
- class ServerContext {
6
+ export * from './types.js';
7
+ export class ServerContext {
15
8
  get client() {
16
9
  return this._client;
17
10
  }
@@ -39,11 +32,14 @@ class ServerContext {
39
32
  get editableContent() {
40
33
  return this._editable;
41
34
  }
42
- constructor({ factory, client, locale }) {
43
- this._mode = 'public';
44
- this._factory = factory || new DefaultComponentFactory();
35
+ constructor({ factory, client, locale, mode, editableContent, }) {
36
+ this._factory = Array.isArray(factory)
37
+ ? new DefaultComponentFactory(factory)
38
+ : factory || new DefaultComponentFactory();
45
39
  this._client = client || createClient();
46
40
  this._locale = locale;
41
+ this._mode = mode ?? 'public';
42
+ this._editable = editableContent;
47
43
  }
48
44
  setMode(mode) {
49
45
  if (this.isDebug)
@@ -60,14 +56,19 @@ class ServerContext {
60
56
  setOptimizelyGraphClient(client) {
61
57
  if (this.isDebug)
62
58
  console.log(`🦺 [ServerContext] Assigning new Optimizely Graph Client`);
63
- this._client = typeof (client) == 'function' ? client(this._client) : isOptiGraphClient(client) ? client : undefined;
59
+ this._client =
60
+ typeof client == 'function'
61
+ ? client(this._client)
62
+ : isOptiGraphClient(client)
63
+ ? client
64
+ : undefined;
64
65
  }
65
66
  setComponentFactory(factory) {
66
67
  if (this.isDebug)
67
68
  console.log(`🦺 [ServerContext] Assigning new Component Factory`);
68
- const newFactory = typeof (factory) == 'function' ? factory(this._factory) : factory;
69
+ const newFactory = typeof factory == 'function' ? factory(this._factory) : factory;
69
70
  if (!newFactory)
70
- throw new Error("Unsetting the context factory is not allowed!");
71
+ throw new Error('Unsetting the context factory is not allowed!');
71
72
  this._factory = newFactory;
72
73
  }
73
74
  setEditableContentId(link) {
@@ -75,7 +76,25 @@ class ServerContext {
75
76
  console.log(`🦺 [ServerContext] Assigning editable content id: ${JSON.stringify(link)}`);
76
77
  this._editable = link;
77
78
  }
79
+ toJSON(key) {
80
+ if (this.isDebugOrDevelopment) {
81
+ console.warn('🦺 [ServerContext] Converting Context to JSON, this is typically a side effect of the context being passed between Server & Client components');
82
+ if (this.isDebug) {
83
+ console.trace('The conversion happened here');
84
+ }
85
+ }
86
+ return {
87
+ inEditMode: this.inEditMode,
88
+ inPreviewMode: this.inPreviewMode,
89
+ isDebug: this.isDebug,
90
+ isDebugOrDevelopment: this.isDebugOrDevelopment,
91
+ isDevelopment: this.isDevelopment,
92
+ clientConfig: this.client?.toJSON(),
93
+ locale: this.locale,
94
+ };
95
+ }
78
96
  }
97
+ //#region Obsolete & Deprecated methods, as context must be handed down in React Server Context
79
98
  /**
80
99
  * Obtain an instance of the servercontext, this either uses `React.cache`,
81
100
  * when available in the current context. If `React.cache` is not available, the
@@ -83,11 +102,58 @@ class ServerContext {
83
102
  *
84
103
  * It the cache fallback will notify in development or debug mode when it is in
85
104
  * use.
105
+ *
106
+ * @deprecated Use the context handed down through the CmsContentArea and CmsContent
107
+ * components
86
108
  */
87
- export const getServerContext = cache(() => {
109
+ export const getServerContext = () => {
110
+ if (isDebug())
111
+ console.debug('🦺 [ServerContext] getServerContext has been deprecated, this provides an instance of the Server Context that is potentially shared between requests');
112
+ return internalGetServerContext();
113
+ };
114
+ /**
115
+ * Update the shared server context from the provided context. This is compatibility
116
+ * method to ensure that the value returned by `getServerContext` can be retrieved and
117
+ * updated.
118
+ *
119
+ * @deprecated Use the context handed down through the CmsContentArea and CmsContent
120
+ * components
121
+ * @param currentCtx The current context to apply to the server context
122
+ * @returns The updated shared server context
123
+ */
124
+ export function updateSharedServerContext(currentCtx) {
125
+ const serverCtx = internalGetServerContext();
126
+ // Update component factory
127
+ serverCtx.setComponentFactory(currentCtx.factory);
128
+ // Update Optimizely Graph Client
129
+ if (currentCtx.client)
130
+ serverCtx.setOptimizelyGraphClient(currentCtx.client);
131
+ // Update locale
132
+ if (currentCtx.locale)
133
+ serverCtx.setLocale(currentCtx.locale);
134
+ // Update mode
135
+ if (currentCtx.inEditMode)
136
+ serverCtx.setMode('edit');
137
+ else if (currentCtx.inPreviewMode)
138
+ serverCtx.setMode('preview');
139
+ else if (!currentCtx.inEditMode && !currentCtx.inPreviewMode)
140
+ serverCtx.setMode('public');
141
+ // Update editable content
142
+ serverCtx.setEditableContentId(currentCtx.editableContent);
143
+ return serverCtx;
144
+ }
145
+ const cachePlaceholder = (factory) => {
146
+ if (isDebug() || isDevelopment())
147
+ console.warn('🚧 [React Context] Running client/server react code instead of server context, no cache() available.');
148
+ return factory;
149
+ };
150
+ //@ts-ignore React.cache is only available in the react-server context
151
+ const cache = (React.cache || cachePlaceholder);
152
+ const internalGetServerContext = cache(() => {
88
153
  const ctx = new ServerContext({});
89
154
  if (ctx.isDebug)
90
155
  console.log('🦺 [ServerContext] Created new context');
91
156
  return ctx;
92
157
  });
158
+ //#endregion
93
159
  //# sourceMappingURL=rsc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/context/rsc.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAA2C,MAAM,iCAAiC,CAAA;AAC1H,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAyB,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE5D,cAAc,YAAY,CAAA;AAG1B,MAAM,gBAAgB,GAAsB,CAAkC,OAAU,EAAE,EAAE;IAExF,IAAI,OAAO,EAAE,IAAI,aAAa,EAAE;QAC5B,OAAO,CAAC,IAAI,CAAC,sGAAsG,CAAC,CAAA;IACxH,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA;AAED,4EAA4E;AAC5E,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,gBAAgB,CAAqB,CAAA;AAInE,MAAM,aAAa;IAQf,IAAI,MAAM;QAEN,OAAO,IAAI,CAAC,OAAO,CAAA;IACvB,CAAC;IACD,IAAI,OAAO;QAEP,OAAO,IAAI,CAAC,QAAQ,CAAA;IACxB,CAAC;IAED,IAAI,MAAM;QAEN,OAAO,IAAI,CAAC,OAAO,CAAA;IACvB,CAAC;IACD,IAAI,UAAU;QAEV,OAAO,IAAI,CAAC,KAAK,IAAI,MAAM,CAAA;IAC/B,CAAC;IACD,IAAI,aAAa;QAEb,OAAO,IAAI,CAAC,KAAK,IAAI,SAAS,CAAA;IAClC,CAAC;IACD,IAAI,aAAa;QAEb,OAAO,aAAa,EAAE,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,OAAO,CAAC,MAAM,CAAC,CAAA;SAC/C,IAAI,UAAU,CAAC,aAAa;QAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;SAC1D,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,aAAa;QAC1D,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAE7B,0BAA0B;IAC1B,SAAS,CAAC,oBAAoB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAA;IAC1D,OAAO,SAAS,CAAA;AAClB,CAAC;AAOD,MAAM,gBAAgB,GAAqB,CACzC,OAAU,EACV,EAAE;IACF,IAAI,OAAO,EAAE,IAAI,aAAa,EAAE;QAC9B,OAAO,CAAC,IAAI,CACV,sGAAsG,CACvG,CAAA;IACH,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,sEAAsE;AACtE,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,gBAAgB,CAAqB,CAAA;AAEnE,MAAM,wBAAwB,GAAG,KAAK,CAAC,GAAG,EAAE;IAC1C,MAAM,GAAG,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAA;IACjC,IAAI,GAAG,CAAC,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAA;IACtE,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC,CAAA;AACF,YAAY"}
@@ -0,0 +1,3 @@
1
+ import type { GenericContext, TransferrableContext, BaseContext } from "./types.js";
2
+ export declare function isTransferrableContext(ctxIn?: BaseContext | null): ctxIn is TransferrableContext;
3
+ export declare function isGenericContext(ctxIn?: BaseContext | null): ctxIn is GenericContext;
@@ -0,0 +1,7 @@
1
+ export function isTransferrableContext(ctxIn) {
2
+ return typeof (ctxIn) == 'object' && ctxIn != null && ctxIn.factory === undefined;
3
+ }
4
+ export function isGenericContext(ctxIn) {
5
+ return typeof (ctxIn) == 'object' && ctxIn != null && typeof ctxIn.factory == 'object' && ctxIn.factory != null;
6
+ }
7
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/context/shared.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,KAA0B;IAC/D,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,QAAQ,IAAI,KAAK,IAAI,IAAI,IAAK,KAAwB,CAAC,OAAO,KAAK,SAAS,CAAA;AACvG,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA0B;IACzD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,QAAQ,IAAI,KAAK,IAAI,IAAI,IAAI,OAAQ,KAAwB,CAAC,OAAO,IAAI,QAAQ,IAAK,KAAwB,CAAC,OAAO,IAAI,IAAI,CAAA;AACzJ,CAAC"}
@@ -1,5 +1,6 @@
1
- import { type IOptiGraphClient } from "@remkoj/optimizely-graph-client";
1
+ import { type IOptiGraphClient, type OptimizelyGraphConfig, type ContentLink } from "@remkoj/optimizely-graph-client";
2
2
  import { type ComponentFactory } from "../factory/types.js";
3
+ export type RenderMode = 'edit' | 'preview' | 'public';
3
4
  export interface GenericContext {
4
5
  readonly client?: IOptiGraphClient;
5
6
  readonly factory: ComponentFactory;
@@ -9,7 +10,28 @@ export interface GenericContext {
9
10
  readonly isDevelopment: boolean;
10
11
  readonly isDebug: boolean;
11
12
  readonly isDebugOrDevelopment: boolean;
13
+ readonly editableContent?: ContentLink | null;
12
14
  }
13
- export type PropsWithContext<P = any> = P & {
15
+ /**
16
+ * The context information that can cross the React Server/Client boundary
17
+ */
18
+ export interface TransferrableContext {
19
+ readonly clientConfig?: OptimizelyGraphConfig;
20
+ readonly locale?: string;
21
+ readonly inEditMode: boolean;
22
+ readonly inPreviewMode: boolean;
23
+ readonly isDevelopment: boolean;
24
+ readonly isDebug: boolean;
25
+ readonly isDebugOrDevelopment: boolean;
26
+ readonly editableContent?: ContentLink | null;
27
+ }
28
+ export type BaseContext = TransferrableContext | GenericContext;
29
+ export type PropsWithContext<P = {}> = P & {
14
30
  ctx: GenericContext;
15
31
  };
32
+ export type PropsWithOptionalContext<P = {}> = P & {
33
+ /**
34
+ * The context to be used when rendering this component
35
+ */
36
+ ctx?: GenericContext;
37
+ };
@@ -29,37 +29,37 @@ export class DefaultComponentFactory {
29
29
  register(type, component, useSuspense = false, loader) {
30
30
  const registryKey = processComponentTypeHandle(type);
31
31
  if (this.dbg)
32
- console.log(`➕ [DefaultComponentFactory] Adding ${registryKey}`);
32
+ console.log(`➕ [DefaultComponentFactory] Registering ${registryKey}`);
33
33
  this.registry.set(registryKey, { type, component, useSuspense, loader });
34
34
  }
35
35
  registerAll(components) {
36
- components.forEach(c => {
36
+ components.forEach((c) => {
37
37
  const registryKey = processComponentTypeHandle(c.type);
38
38
  if (this.dbg)
39
- console.log(`➕ [DefaultComponentFactory] Adding ${registryKey}`);
39
+ console.log(`➕ [DefaultComponentFactory] Registering ${registryKey}`);
40
40
  this.registry.set(registryKey, c);
41
41
  });
42
42
  }
43
43
  has(type) {
44
44
  const registryKey = processComponentTypeHandle(type);
45
- if (this.dbg)
46
- console.log(`🔎 [DefaultComponentFactory] Checking for ${registryKey}`);
45
+ //if (this.dbg) console.log(`🔎 [DefaultComponentFactory] Checking for ${ registryKey }`)
47
46
  return this.registry.has(registryKey);
48
47
  }
49
48
  resolve(type) {
50
49
  const registryKey = processComponentTypeHandle(type);
51
- if (this.dbg)
52
- console.log(`⚡ [DefaultComponentFactory] Resolving ${registryKey}`);
53
50
  const entry = this.registry.get(registryKey);
54
- if (!entry)
51
+ if (!entry) {
52
+ if (this.dbg)
53
+ console.warn(`⚡ [DefaultComponentFactory] Unable to resolve ${registryKey}`);
55
54
  return undefined; // The key is not registered in the factory
55
+ }
56
56
  if (entry.useSuspense != true)
57
57
  return entry.component; // There's no suspense, so we're using the component directly
58
58
  // We need to wrap the component in a Supense
59
59
  const EntryComponent = entry.component;
60
60
  const EntryLoader = entry.loader;
61
61
  function Suspended(props) {
62
- return _jsx(Suspense, { fallback: EntryLoader && _jsx(EntryLoader, { ...props }), children: _jsx(EntryComponent, { ...props }) });
62
+ return (_jsx(Suspense, { fallback: EntryLoader && _jsx(EntryLoader, { ...props }), children: _jsx(EntryComponent, { ...props }) }));
63
63
  }
64
64
  return Suspended;
65
65
  }
@@ -78,14 +78,14 @@ export class DefaultComponentFactory {
78
78
  }
79
79
  }
80
80
  function processComponentTypeHandle(handle) {
81
- if (typeof (handle) == 'string')
82
- return handle == "" ? EmptyComponentHandle : handle;
83
- if (Array.isArray(handle) && handle.every(s => typeof (s) == 'string'))
81
+ if (typeof handle == 'string')
82
+ return handle == '' ? EmptyComponentHandle : handle;
83
+ if (Array.isArray(handle) && handle.every((s) => typeof s == 'string'))
84
84
  return handle
85
- .map(s => s.startsWith("_") ? s.substring(1) : s) // Remove all leading underscores
86
- .filter(s => s.toLowerCase() != 'content') // Remove the "Content" base type
87
- .map(s => s == "" ? EmptyComponentHandle : s) // Fall back to a fragment
85
+ .map((s) => (s.startsWith('_') ? s.substring(1) : s)) // Remove all leading underscores
86
+ .filter((s) => s.toLowerCase() != 'content') // Remove the "Content" base type
87
+ .map((s) => (s == '' ? EmptyComponentHandle : s)) // Fall back to a fragment
88
88
  .join(MERGE_SYMBOL); // Types are processed as a string
89
- throw new Error(`Invalid component type handle: ${typeof (handle)}`);
89
+ throw new Error(`Invalid component type handle: ${typeof handle}`);
90
90
  }
91
91
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/factory/default.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAI,cAAc,CAAA;AAEnD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAIhC;;;;;OAKG;IACH,YAAmB,iBAA2C;QATtD,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
- */
4
- export declare const Version = "3.2.2";
5
- export * from './types.js';
1
+ export declare const Version: string;
6
2
  export * as Errors from './errors.js';
7
3
  export * as Utils from './utilities.js';
4
+ export * from './types.js';
5
+ export * from './factory/index.js';
6
+ export * from './context/types.js';
8
7
  export * from './context/client.js';
9
8
  export * from './factory/index.js';
10
9
  export * from './components/client.js';
package/dist/index.js CHANGED
@@ -1,11 +1,15 @@
1
1
  /**
2
2
  * The version of the current Optimizely DXP React SDK
3
3
  */
4
- export const Version = '3.2.2';
4
+ import buildInfo from "./version.json" with { type: "json" };
5
+ export const Version = buildInfo.version;
5
6
  // Export library
6
- export * from './types.js';
7
7
  export * as Errors from './errors.js';
8
8
  export * as Utils from './utilities.js';
9
+ export * from './types.js';
10
+ export * from './factory/index.js';
11
+ export * from './context/types.js';
12
+ // Export React Client Components
9
13
  export * from './context/client.js';
10
14
  export * from './factory/index.js';
11
15
  export * from './components/client.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAE9B,iBAAiB;AACjB,cAAc,YAAY,CAAA;AAC1B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AAEvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,SAAS,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;AAExC,iBAAiB;AACjB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAElC,iCAAiC;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA"}
package/dist/rsc.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- /**
2
- * The version of the current Optimizely DXP React SDK
3
- */
4
- export declare const Version = "3.2.2";
1
+ export declare const Version: string;
5
2
  export * as Errors from './errors.js';
6
3
  export * as Utils from './utilities.js';
7
4
  export * from './types.js';
8
5
  export * from './factory/index.js';
6
+ export * from './context/types.js';
9
7
  export * from './context/rsc.js';
10
8
  export * from './components/rsc.js';
11
9
  export * from './rsc-utilities.js';
package/dist/rsc.js CHANGED
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * The version of the current Optimizely DXP React SDK
3
3
  */
4
- export const Version = '3.2.2';
4
+ import buildInfo from "./version.json" with { type: "json" };
5
+ export const Version = buildInfo.version;
5
6
  // Export library
6
7
  export * as Errors from './errors.js';
7
8
  export * as Utils from './utilities.js';
8
9
  export * from './types.js';
9
10
  export * from './factory/index.js';
11
+ export * from './context/types.js';
10
12
  // Export React Server Components
11
13
  export * from './context/rsc.js';
12
14
  export * from './components/rsc.js';
package/dist/rsc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rsc.js","sourceRoot":"","sources":["../src/rsc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAE9B,iBAAiB;AACjB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAElC,iCAAiC;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"rsc.js","sourceRoot":"","sources":["../src/rsc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,SAAS,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;AAExC,iBAAiB;AACjB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAElC,iCAAiC;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
package/dist/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { PropsWithChildren, ComponentType as ReactComponentType } from "rea
2
2
  import type { DocumentNode } from "graphql";
3
3
  import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  import type { ContentLinkWithLocale, ContentLink, InlineContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
5
+ import type { GenericContext } from "./context/types.js";
5
6
  export type ContentType = string[];
6
7
  export type {
7
8
  /**
@@ -29,6 +30,10 @@ export type CmsComponentProps<T, L extends Record<string, any> = Record<string,
29
30
  * Contextual layout data, if any
30
31
  */
31
32
  layoutProps?: L;
33
+ /**
34
+ * The context in which this component will be rendered
35
+ */
36
+ ctx?: GenericContext;
32
37
  }>;
33
38
  export type ContentQueryProps<LocaleType = string> = ContentLink & {
34
39
  locale?: Array<LocaleType> | LocaleType | null;
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "4.3.2"
3
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@remkoj/optimizely-cms-react",
3
3
  "license": "Apache-2.0",
4
- "version": "4.3.1",
4
+ "version": "5.0.0",
5
5
  "repository": "https://github.com/remkoj/optimizely-dxp-clients.git",
6
6
  "author": "Remko Jantzen <693172+remkoj@users.noreply.github.com>",
7
7
  "homepage": "https://github.com/remkoj/optimizely-dxp-clients/tree/main/packages/optimizely-cms-react",
@@ -27,11 +27,11 @@
27
27
  }
28
28
  },
29
29
  "devDependencies": {
30
- "@remkoj/optimizely-graph-client": "4.3.1",
30
+ "@remkoj/optimizely-graph-client": "5.0.0",
31
31
  "@types/crypto-js": "^4.2.2",
32
- "@types/node": "^22.13.5",
33
- "@types/react": "^18.3.18",
34
- "@types/react-dom": "18.3.5",
32
+ "@types/node": "^22.14.1",
33
+ "@types/react": "^18.3.20",
34
+ "@types/react-dom": "18.3.6",
35
35
  "entities": "^6.0.0",
36
36
  "graphql": "^16.10.0",
37
37
  "graphql-request": "^6.1.0",
@@ -39,14 +39,14 @@
39
39
  "react": "^18.3.1",
40
40
  "react-dom": "^18.3.1",
41
41
  "scheduler": "^0.25.0",
42
- "typescript": "^5.7.3"
42
+ "typescript": "^5.8.3"
43
43
  },
44
44
  "dependencies": {
45
45
  "@graphql-typed-document-node/core": "^3.2.0",
46
46
  "crypto-js": "^4.2.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@remkoj/optimizely-graph-client": "^4",
49
+ "@remkoj/optimizely-graph-client": "^5.0.0",
50
50
  "entities": "^6",
51
51
  "graphql": "^16",
52
52
  "graphql-request": "^6",