@remkoj/optimizely-cms-react 2.0.4 → 3.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.
- package/README.md +36 -2
- package/dist/components/client.d.ts +42 -0
- package/dist/components/client.js +52 -0
- package/dist/components/client.js.map +1 -0
- package/dist/components/cms-content/client.d.ts +11 -0
- package/dist/components/cms-content/client.js +72 -0
- package/dist/components/cms-content/client.js.map +1 -0
- package/dist/components/cms-content/get-content-type.d.ts +13 -0
- package/dist/components/cms-content/get-content-type.js +70 -0
- package/dist/components/cms-content/get-content-type.js.map +1 -0
- package/dist/components/cms-content/get-content.d.ts +4 -0
- package/dist/components/cms-content/get-content.js +91 -0
- package/dist/components/cms-content/get-content.js.map +1 -0
- package/dist/components/cms-content/resolve-component.d.ts +18 -0
- package/dist/components/cms-content/resolve-component.js +53 -0
- package/dist/components/cms-content/resolve-component.js.map +1 -0
- package/dist/components/cms-content/resolve-content-type.d.ts +15 -0
- package/dist/components/cms-content/resolve-content-type.js +29 -0
- package/dist/components/cms-content/resolve-content-type.js.map +1 -0
- package/dist/components/cms-content/rsc.d.ts +11 -0
- package/dist/components/cms-content/rsc.js +50 -0
- package/dist/components/cms-content/rsc.js.map +1 -0
- package/dist/components/cms-content/types.d.ts +54 -0
- package/dist/components/cms-content/types.js +2 -0
- package/dist/components/cms-content/types.js.map +1 -0
- package/dist/components/cms-content/utils.d.ts +3 -0
- package/dist/components/cms-content/utils.js +6 -0
- package/dist/components/cms-content/utils.js.map +1 -0
- package/dist/components/cms-content-area/index.d.ts +17 -0
- package/dist/{server/components/cms-content-area.js → components/cms-content-area/index.js} +27 -36
- package/dist/components/cms-content-area/index.js.map +1 -0
- package/dist/{server/components → components/cms-content-area}/types.d.ts +7 -94
- package/dist/components/cms-content-area/types.js.map +1 -0
- package/dist/{server/components/cms-editable.d.ts → components/cms-editable/index.d.ts} +5 -3
- package/dist/components/cms-editable/index.js +15 -0
- package/dist/components/cms-editable/index.js.map +1 -0
- package/dist/components/{cms-styles.js → cms-styles/index.js} +1 -1
- package/dist/components/cms-styles/index.js.map +1 -0
- package/dist/components/rich-text/components.d.ts +14 -0
- package/dist/components/rich-text/components.js +63 -0
- package/dist/components/rich-text/components.js.map +1 -0
- package/dist/components/rich-text/index.d.ts +4 -0
- package/dist/components/rich-text/index.js +47 -0
- package/dist/components/rich-text/index.js.map +1 -0
- package/dist/components/{rich-text.d.ts → rich-text/types.d.ts} +13 -18
- package/dist/components/rich-text/types.js +2 -0
- package/dist/components/rich-text/types.js.map +1 -0
- package/dist/components/rich-text/utils.d.ts +5 -0
- package/dist/components/rich-text/utils.js +24 -0
- package/dist/components/rich-text/utils.js.map +1 -0
- package/dist/components/rsc.d.ts +47 -0
- package/dist/components/rsc.js +55 -0
- package/dist/components/rsc.js.map +1 -0
- package/dist/{server → components}/type-utils.js.map +1 -1
- package/dist/{server/components → components}/visual-builder/functions.d.ts +7 -2
- package/dist/{server/components → components}/visual-builder/functions.js +8 -3
- package/dist/components/visual-builder/functions.js.map +1 -0
- package/dist/{server/components/visual-builder/Composition.d.ts → components/visual-builder/index.d.ts} +4 -3
- package/dist/{server/components/visual-builder/Composition.js → components/visual-builder/index.js} +9 -18
- package/dist/components/visual-builder/index.js.map +1 -0
- package/dist/{server/components → components}/visual-builder/types.d.ts +6 -1
- package/dist/components/visual-builder/types.js.map +1 -0
- package/dist/components.d.ts +27 -0
- package/dist/components.js +20 -0
- package/dist/components.js.map +1 -0
- package/dist/context/client.d.ts +70 -0
- package/dist/context/client.js +78 -0
- package/dist/context/client.js.map +1 -0
- package/dist/context/rsc.d.ts +33 -0
- package/dist/context/rsc.js +75 -0
- package/dist/context/rsc.js.map +1 -0
- package/dist/context/types.d.ts +15 -0
- package/dist/context/types.js +2 -0
- package/dist/{server/components → context}/types.js.map +1 -1
- package/dist/{server/components → data}/queries.js +121 -121
- package/dist/data/queries.js.map +1 -0
- package/dist/{factory.d.ts → factory/default.d.ts} +0 -18
- package/dist/{factory.js → factory/default.js} +1 -33
- package/dist/factory/default.js.map +1 -0
- package/dist/factory/index.d.ts +12 -0
- package/dist/factory/index.js +16 -0
- package/dist/factory/index.js.map +1 -0
- package/dist/factory/types.d.ts +51 -0
- package/dist/factory/types.js +2 -0
- package/dist/factory/types.js.map +1 -0
- package/dist/factory/undef.d.ts +9 -0
- package/dist/factory/undef.js +19 -0
- package/dist/factory/undef.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/{server/is-debug.d.ts → rsc-utilities.d.ts} +0 -1
- package/dist/{server/is-debug.js → rsc-utilities.js} +1 -2
- package/dist/{server/is-debug.js.map → rsc-utilities.js.map} +1 -1
- package/dist/rsc.d.ts +11 -0
- package/dist/rsc.js +14 -0
- package/dist/rsc.js.map +1 -0
- package/dist/types.d.ts +10 -56
- package/package.json +12 -24
- package/dist/browser/context.d.ts +0 -6
- package/dist/browser/context.js +0 -15
- package/dist/browser/context.js.map +0 -1
- package/dist/browser/index.d.ts +0 -1
- package/dist/browser/index.js +0 -2
- package/dist/browser/index.js.map +0 -1
- package/dist/components/cms-styles.js.map +0 -1
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -3
- package/dist/components/index.js.map +0 -1
- package/dist/components/rich-text.js +0 -138
- package/dist/components/rich-text.js.map +0 -1
- package/dist/factory.js.map +0 -1
- package/dist/server/components/cms-content-area.d.ts +0 -13
- package/dist/server/components/cms-content-area.js.map +0 -1
- package/dist/server/components/cms-content.d.ts +0 -11
- package/dist/server/components/cms-content.js +0 -125
- package/dist/server/components/cms-content.js.map +0 -1
- package/dist/server/components/cms-editable.js +0 -18
- package/dist/server/components/cms-editable.js.map +0 -1
- package/dist/server/components/get-content-type.d.ts +0 -12
- package/dist/server/components/get-content-type.js +0 -51
- package/dist/server/components/get-content-type.js.map +0 -1
- package/dist/server/components/index.d.ts +0 -4
- package/dist/server/components/index.js +0 -5
- package/dist/server/components/index.js.map +0 -1
- package/dist/server/components/queries.js.map +0 -1
- package/dist/server/components/visual-builder/Composition.js.map +0 -1
- package/dist/server/components/visual-builder/functions.js.map +0 -1
- package/dist/server/components/visual-builder/index.d.ts +0 -4
- package/dist/server/components/visual-builder/index.js +0 -4
- package/dist/server/components/visual-builder/index.js.map +0 -1
- package/dist/server/components/visual-builder/types.js.map +0 -1
- package/dist/server/context.d.ts +0 -22
- package/dist/server/context.js +0 -81
- package/dist/server/context.js.map +0 -1
- package/dist/server/factory.d.ts +0 -10
- package/dist/server/factory.js +0 -18
- package/dist/server/factory.js.map +0 -1
- package/dist/server/index.d.ts +0 -6
- package/dist/server/index.js +0 -6
- package/dist/server/index.js.map +0 -1
- /package/dist/{server/components → components/cms-content-area}/types.js +0 -0
- /package/dist/components/{cms-styles.d.ts → cms-styles/index.d.ts} +0 -0
- /package/dist/{server → components}/type-utils.d.ts +0 -0
- /package/dist/{server → components}/type-utils.js +0 -0
- /package/dist/{server/components → components}/visual-builder/types.js +0 -0
- /package/dist/{server/components → data}/queries.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/rich-text/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,MAAM,CAAC,MAA+B;IAElD,OAAO,CACH,OAAO,MAAM,IAAI,QAAQ;QACzB,MAAM,IAAI,IAAI;QACd,CAAC,OAAQ,MAAmB,CAAC,IAAI,CAAC,IAAI,QAAQ;QAC7C,MAAmB,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CACxC,CAAA;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAA+B;IAEvD,OAAO,CACH,OAAO,MAAM,IAAI,QAAQ;QACzB,MAAM,IAAI,IAAI;QACd,CAAC,OAAQ,MAAoB,CAAC,IAAI,CAAC,IAAI,QAAQ;QAC9C,MAAoB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CACxC,CAAA;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAmC;IAEhE,IAAI,CAAC,KAAK;QACN,OAAO,SAAS,CAAA;IACpB,MAAM,UAAU,GAAG,OAAO,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAA8B,CAAC,CAAC,CAAC,KAAK,CAAA;IACpG,IAAI,UAAU,EAAE,IAAI,IAAI,UAAU,IAAI,UAAU,EAAE,IAAI,IAAI,QAAQ;QAC9D,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;IAC3E,OAAO,UAAU,CAAA;AACrB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB,UAAU;IAElD,OAAO,GAAG,KAAK,KAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAE,EAAE,CAAA;AAC9D,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type ReactNode, type ComponentType } from 'react';
|
|
3
|
+
import { type PropsWithContext } from '../context/types.js';
|
|
4
|
+
import { type CmsContentAreaComponent } from './cms-content-area/index.js';
|
|
5
|
+
import { type CmsEditableComponent } from './cms-editable/index.js';
|
|
6
|
+
import { type CmsContentComponent } from './cms-content/rsc.js';
|
|
7
|
+
import { type OptimizelyCompositionComponent } from './visual-builder/index.js';
|
|
8
|
+
import { type RichTextComponent } from './rich-text/index.js';
|
|
9
|
+
export * from "./cms-styles/index.js";
|
|
10
|
+
export { isNode, isElementNode, isElementNodeOfType, isStructureNode } from "./visual-builder/functions.js";
|
|
11
|
+
export { DefaultComponents as RichTextComponentDictionary } from './rich-text/components.js';
|
|
12
|
+
/**
|
|
13
|
+
* Fallback while RSC hasn't been moved from Canary to Main
|
|
14
|
+
*/
|
|
15
|
+
type ReactServerComponentType<P = any> = ComponentType<P> | ((props: P) => Promise<ReactNode>);
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper function to turn context dependant components into easy to use
|
|
18
|
+
* server components
|
|
19
|
+
*
|
|
20
|
+
* @param component The component where the `ctx` parameter must be fulfilled
|
|
21
|
+
* @returns The component, without CTX parameter
|
|
22
|
+
*/
|
|
23
|
+
export declare function serverContextAware<P = any>(component: ReactServerComponentType<PropsWithContext<P>>): ComponentType<P>;
|
|
24
|
+
/**
|
|
25
|
+
* Client side Optimizely CMS Editable
|
|
26
|
+
*/
|
|
27
|
+
export declare const CmsEditable: CmsEditableComponent;
|
|
28
|
+
/**
|
|
29
|
+
* Client side Optimizely CMS Content, leveraging the CMS Context to load the
|
|
30
|
+
* content type and content data when needed
|
|
31
|
+
*/
|
|
32
|
+
export declare const CmsContent: CmsContentComponent;
|
|
33
|
+
/**
|
|
34
|
+
* Client side Optimizely CMS Content Area, leveraging the CMS Context to infer
|
|
35
|
+
* the connection to Optimizely Graph and component dictionary.
|
|
36
|
+
*/
|
|
37
|
+
export declare const CmsContentArea: CmsContentAreaComponent;
|
|
38
|
+
/**
|
|
39
|
+
* Client side Optimizely Composition (e.g. Visual Builder), leveraging the CMS
|
|
40
|
+
* Context to infer the connection to Optimizely Graph and component
|
|
41
|
+
* dictionary.
|
|
42
|
+
*/
|
|
43
|
+
export declare const OptimizelyComposition: OptimizelyCompositionComponent;
|
|
44
|
+
/**
|
|
45
|
+
* Client side renderer for Rich Text
|
|
46
|
+
*/
|
|
47
|
+
export declare const RichText: RichTextComponent;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "server-only";
|
|
3
|
+
import { getServerContext } from '../context/rsc.js';
|
|
4
|
+
import { cmsContentAware } from './cms-content/utils.js';
|
|
5
|
+
import { CmsContentArea as BaseContentArea } from './cms-content-area/index.js'; // Both RSC & Client capable
|
|
6
|
+
import { CmsEditable as BaseEditable } from './cms-editable/index.js'; // Both RSC & Client capable
|
|
7
|
+
import { CmsContent as BaseCmsContent } from './cms-content/rsc.js'; // Different components for RSC & Client
|
|
8
|
+
import { OptimizelyComposition as BaseOptimizelyComposition } from './visual-builder/index.js'; // Both RSC & Client capable
|
|
9
|
+
import { RichText as BaseRichText } from './rich-text/index.js';
|
|
10
|
+
// Pass through Style functions types
|
|
11
|
+
export * from "./cms-styles/index.js";
|
|
12
|
+
export { isNode, isElementNode, isElementNodeOfType, isStructureNode } from "./visual-builder/functions.js";
|
|
13
|
+
// Export dictionary
|
|
14
|
+
export { DefaultComponents as RichTextComponentDictionary } from './rich-text/components.js';
|
|
15
|
+
/**
|
|
16
|
+
* Wrapper function to turn context dependant components into easy to use
|
|
17
|
+
* server components
|
|
18
|
+
*
|
|
19
|
+
* @param component The component where the `ctx` parameter must be fulfilled
|
|
20
|
+
* @returns The component, without CTX parameter
|
|
21
|
+
*/
|
|
22
|
+
export function serverContextAware(component) {
|
|
23
|
+
const BaseComponent = component;
|
|
24
|
+
const ServerContextInjector = (props) => {
|
|
25
|
+
const ctx = getServerContext();
|
|
26
|
+
return _jsx(BaseComponent, { ctx: ctx, ...props });
|
|
27
|
+
};
|
|
28
|
+
ServerContextInjector.displayName = "Server Context Injector";
|
|
29
|
+
return ServerContextInjector;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Client side Optimizely CMS Editable
|
|
33
|
+
*/
|
|
34
|
+
export const CmsEditable = serverContextAware(BaseEditable);
|
|
35
|
+
/**
|
|
36
|
+
* Client side Optimizely CMS Content, leveraging the CMS Context to load the
|
|
37
|
+
* content type and content data when needed
|
|
38
|
+
*/
|
|
39
|
+
export const CmsContent = serverContextAware(BaseCmsContent);
|
|
40
|
+
/**
|
|
41
|
+
* Client side Optimizely CMS Content Area, leveraging the CMS Context to infer
|
|
42
|
+
* the connection to Optimizely Graph and component dictionary.
|
|
43
|
+
*/
|
|
44
|
+
export const CmsContentArea = cmsContentAware(serverContextAware(BaseContentArea), CmsContent);
|
|
45
|
+
/**
|
|
46
|
+
* Client side Optimizely Composition (e.g. Visual Builder), leveraging the CMS
|
|
47
|
+
* Context to infer the connection to Optimizely Graph and component
|
|
48
|
+
* dictionary.
|
|
49
|
+
*/
|
|
50
|
+
export const OptimizelyComposition = cmsContentAware(serverContextAware(BaseOptimizelyComposition), CmsContent);
|
|
51
|
+
/**
|
|
52
|
+
* Client side renderer for Rich Text
|
|
53
|
+
*/
|
|
54
|
+
export const RichText = BaseRichText;
|
|
55
|
+
//# sourceMappingURL=rsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/components/rsc.tsx"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,cAAc,IAAI,eAAe,EAAgC,MAAM,6BAA6B,CAAA,CAAC,4BAA4B;AAC1I,OAAO,EAAE,WAAW,IAAI,YAAY,EAA6B,MAAM,yBAAyB,CAAA,CAAC,4BAA4B;AAC7H,OAAO,EAAE,UAAU,IAAI,cAAc,EAA0D,MAAM,sBAAsB,CAAA,CAAC,wCAAwC;AACpK,OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAuC,MAAM,2BAA2B,CAAA,CAAC,4BAA4B;AAChK,OAAO,EAAE,QAAQ,IAAI,YAAY,EAA0B,MAAM,sBAAsB,CAAA;AAEvF,qCAAqC;AACrC,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE3G,oBAAoB;AACpB,OAAO,EAAE,iBAAiB,IAAI,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAO5F;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAU,SAAwD;IAEhG,MAAM,aAAa,GAAG,SAA+C,CAAA;IACrE,MAAM,qBAAqB,GAAsB,CAAC,KAAQ,EAAE,EAAE;QAC1D,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAA;QAC9B,OAAO,KAAC,aAAa,IAAC,GAAG,EAAE,GAAG,KAAO,KAAK,GAAK,CAAA;IACnD,CAAC,CAAA;IACD,qBAAqB,CAAC,WAAW,GAAG,yBAAyB,CAAA;IAC7D,OAAO,qBAAqB,CAAA;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC,YAAY,CAAyB,CAAA;AAGnF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC,cAAoD,CAAwB,CAAA;AAEzH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,UAAU,CAA4B,CAAA;AAEzH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,EAAE,UAAU,CAAmC,CAAA;AAEjJ;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAiC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../../src/components/type-utils.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type { ContentType } from '../../../types.js';
|
|
2
1
|
import type { CompositionNode, LeafPropsFactory, CompositionElementNode, NodePropsFactory, CompositionStructureNode } from './types.js';
|
|
3
2
|
export declare function isElementNode(node: CompositionNode<Record<string, any>>): node is CompositionElementNode<Record<string, any>>;
|
|
4
3
|
export declare function isElementNodeOfType<ET extends Record<string, any>>(node: CompositionNode<Record<string, any>>, test: (data: Record<string, any>) => data is ET): node is CompositionElementNode<ET>;
|
|
5
4
|
export declare function isStructureNode(node: CompositionNode<Record<string, any>>): node is CompositionStructureNode;
|
|
5
|
+
/**
|
|
6
|
+
* Test if the provided value is a Visual Builder node
|
|
7
|
+
*
|
|
8
|
+
* @param toTest The value to test
|
|
9
|
+
* @returns `true` when the value is a Visual Builder node, `false`
|
|
10
|
+
* otherwise
|
|
11
|
+
*/
|
|
6
12
|
export declare function isNode(toTest: any): toTest is CompositionNode;
|
|
7
|
-
export declare function isContentType(toTest: any): toTest is ContentType;
|
|
8
13
|
export declare const defaultPropsFactory: LeafPropsFactory;
|
|
9
14
|
export declare const defaultNodePropsFactory: NodePropsFactory;
|
|
10
15
|
export declare function ucFirst(input: string | undefined | null): string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isContentType } from '../../utilities.js';
|
|
1
2
|
import { isContentLink, isInlineContentLink } from '@remkoj/optimizely-graph-client';
|
|
2
3
|
export function isElementNode(node) {
|
|
3
4
|
return node.layoutType == "element";
|
|
@@ -10,6 +11,13 @@ export function isElementNodeOfType(node, test) {
|
|
|
10
11
|
export function isStructureNode(node) {
|
|
11
12
|
return !isElementNode(node);
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Test if the provided value is a Visual Builder node
|
|
16
|
+
*
|
|
17
|
+
* @param toTest The value to test
|
|
18
|
+
* @returns `true` when the value is a Visual Builder node, `false`
|
|
19
|
+
* otherwise
|
|
20
|
+
*/
|
|
13
21
|
export function isNode(toTest) {
|
|
14
22
|
if (typeof (toTest) != 'object' || toTest == null)
|
|
15
23
|
return false;
|
|
@@ -18,9 +26,6 @@ export function isNode(toTest) {
|
|
|
18
26
|
const hasValidType = typeof toTest.layoutType == 'string' && nodeTypes.includes(toTest.layoutType);
|
|
19
27
|
return hasValidName && hasValidType;
|
|
20
28
|
}
|
|
21
|
-
export function isContentType(toTest) {
|
|
22
|
-
return Array.isArray(toTest) && toTest.every(x => typeof (x) == 'string' && x.length > 0);
|
|
23
|
-
}
|
|
24
29
|
export const defaultPropsFactory = (node) => {
|
|
25
30
|
const contentType = node.element?._metadata?.types;
|
|
26
31
|
if (!isContentType(contentType))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/components/visual-builder/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAyB,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAG3G,MAAM,UAAU,aAAa,CAAC,IAAyC;IAEnE,OAAO,IAAI,CAAC,UAAU,IAAI,SAAS,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAgC,IAAyC,EAAE,IAA8C;IAExJ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QACpB,OAAO,KAAK,CAAA;IAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAyC;IAErE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,MAAW;IAE9B,IAAI,OAAM,CAAC,MAAM,CAAC,IAAI,QAAQ,IAAI,MAAM,IAAI,IAAI;QAC5C,OAAO,KAAK,CAAA;IAEhB,MAAM,SAAS,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;IACvE,MAAM,YAAY,GAAG,CAAC,OAAQ,MAA0B,CAAC,IAAI,IAAI,QAAQ,IAAI,CAAE,MAA0B,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAK,MAA0B,CAAC,IAAI,IAAI,IAAI,CAAA;IAC7K,MAAM,YAAY,GAAG,OAAQ,MAA0B,CAAC,UAAU,IAAI,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAE,MAA0B,CAAC,UAAU,CAAC,CAAA;IAE5I,OAAO,YAAY,IAAI,YAAY,CAAA;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
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { BaseOptimizelyCompositionProps } from './types.js';
|
|
3
|
+
export type * from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Render the composition as made available through Optimizely Graph for Visual Builder
|
|
5
6
|
*
|
|
6
7
|
* @param param0
|
|
7
8
|
* @returns The
|
|
8
9
|
*/
|
|
9
|
-
export declare function OptimizelyComposition({ node, leafPropsFactory, nodePropsFactory }:
|
|
10
|
+
export declare function OptimizelyComposition({ node, leafPropsFactory, nodePropsFactory, ctx, cmsContent: CmsContent }: BaseOptimizelyCompositionProps): ReactNode;
|
|
10
11
|
export default OptimizelyComposition;
|
package/dist/{server/components/visual-builder/Composition.js → components/visual-builder/index.js}
RENAMED
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import 'server-only';
|
|
3
2
|
import { isElementNode, defaultNodePropsFactory, defaultPropsFactory } from './functions.js';
|
|
4
|
-
import { CmsContent } from '../cms-content.js';
|
|
5
|
-
import getServerContext from '../../context.js';
|
|
6
3
|
/**
|
|
7
4
|
* Render the composition as made available through Optimizely Graph for Visual Builder
|
|
8
5
|
*
|
|
9
6
|
* @param param0
|
|
10
7
|
* @returns The
|
|
11
8
|
*/
|
|
12
|
-
export
|
|
13
|
-
const { factory, isDebug } =
|
|
9
|
+
export function OptimizelyComposition({ node, leafPropsFactory = defaultPropsFactory, nodePropsFactory = defaultNodePropsFactory, ctx, cmsContent: CmsContent }) {
|
|
10
|
+
const { factory, isDebug } = ctx;
|
|
11
|
+
// Render the element
|
|
14
12
|
if (isElementNode(node)) {
|
|
15
13
|
if (isDebug)
|
|
16
14
|
console.log(`⚪ [VisualBuilder] Rendering element node ${JSON.stringify(node)}`);
|
|
17
15
|
const [contentLink, contentType, fragmentData, layoutProps] = leafPropsFactory(node);
|
|
18
|
-
//@ts-expect-error CmsContent is an Asynchronous server component, which isn't supported by the generic React Typings
|
|
19
16
|
return _jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, layoutProps: layoutProps });
|
|
20
17
|
}
|
|
18
|
+
// Debug
|
|
21
19
|
if (isDebug)
|
|
22
20
|
console.log(`⚪ [VisualBuilder] Rendering structure node ${JSON.stringify(node)}`);
|
|
21
|
+
// Ensure we've got a factory
|
|
23
22
|
if (!factory)
|
|
24
23
|
throw new Error("🟡 [VisualBuilder] [OptimizelyComposition] The factory must be defined within the serverContext");
|
|
25
24
|
const [contentLink, contentTypes, fragmentData, layoutProps] = nodePropsFactory(node);
|
|
26
|
-
const firstExistingType = contentTypes.map(ct =>
|
|
27
|
-
const reversed = [...ct].reverse();
|
|
28
|
-
const hasType = factory.has(reversed);
|
|
29
|
-
if (!hasType && isDebug)
|
|
30
|
-
console.log(`🟡 [VisualBuilder] [OptimizelyComposition] Content type ${reversed.join('/')} not found within factory`);
|
|
31
|
-
return hasType;
|
|
32
|
-
}).indexOf(true);
|
|
25
|
+
const firstExistingType = contentTypes.map(ct => factory.has([...ct].reverse())).indexOf(true);
|
|
33
26
|
const contentType = contentTypes[firstExistingType];
|
|
34
27
|
if (!contentType)
|
|
35
|
-
throw new Error(
|
|
36
|
-
//@ts-expect-error CmsContent is an Asynchronous server component, which isn't supported by the generic React Typings
|
|
28
|
+
throw new Error(`🟡 [VisualBuilder] [OptimizelyComposition] The factory must have a definition for one of these types: ${contentTypes.map(x => x.join('/')).join(', ')}`);
|
|
37
29
|
return _jsx(CmsContent, { contentType: contentType, contentLink: contentLink, fragmentData: fragmentData, layoutProps: layoutProps, noDataLoad: true, children: (node.nodes ?? []).map((child) => {
|
|
38
30
|
const childKey = child.key ? child.key : `vb::${JSON.stringify(child)}`;
|
|
39
|
-
|
|
40
|
-
return _jsx(OptimizelyComposition, { node: child, leafPropsFactory: leafPropsFactory, nodePropsFactory: nodePropsFactory }, childKey);
|
|
31
|
+
return _jsx(OptimizelyComposition, { node: child, leafPropsFactory: leafPropsFactory, nodePropsFactory: nodePropsFactory, ctx: ctx, cmsContent: CmsContent }, childKey);
|
|
41
32
|
}) });
|
|
42
33
|
}
|
|
43
34
|
export default OptimizelyComposition;
|
|
44
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/visual-builder/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAI5F;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EAAE,IAAI,EAAE,gBAAgB,GAAG,mBAAmB,EAAE,gBAAgB,GAAG,uBAAuB,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAkC;IAE3L,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;IAEhC,qBAAqB;IACrB,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,IAAI,OAAO;YACP,OAAO,CAAC,GAAG,CAAC,4CAA6C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE,EAAE,CAAC,CAAA;QACrF,MAAM,CAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,CAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;QACtF,OAAO,KAAC,UAAU,IAAC,WAAW,EAAG,WAAW,EAAG,WAAW,EAAG,WAAW,EAAG,YAAY,EAAG,YAAY,EAAG,WAAW,EAAG,WAAW,GAAK,CAAA;IAC3I,CAAC;IAED,QAAQ;IACR,IAAI,OAAO;QACP,OAAO,CAAC,GAAG,CAAC,8CAA+C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE,EAAE,CAAC,CAAA;IAEvF,6BAA6B;IAC7B,IAAI,CAAC,OAAO;QACR,MAAM,IAAI,KAAK,CAAC,iGAAiG,CAAC,CAAA;IAEtH,MAAM,CAAE,WAAW,EAAE,YAAY,EA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ContentType } from "../../../types.js";
|
|
3
2
|
import { type InlineContentLinkWithLocale, type ContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
|
|
3
|
+
import { type ContentType } from "../../types.js";
|
|
4
|
+
import { type PropsWithContext } from "../../context/types.js";
|
|
5
|
+
import { type PropsWithCmsContent } from "../cms-content/types.js";
|
|
4
6
|
export declare enum StructureNodeTypes {
|
|
5
7
|
Experience = "experience",
|
|
6
8
|
Section = "section",
|
|
@@ -50,3 +52,6 @@ export type OptimizelyCompositionProps = JSX.IntrinsicAttributes & {
|
|
|
50
52
|
*/
|
|
51
53
|
nodePropsFactory?: NodePropsFactory;
|
|
52
54
|
};
|
|
55
|
+
export type BaseOptimizelyCompositionProps = PropsWithCmsContent<PropsWithContext<OptimizelyCompositionProps>>;
|
|
56
|
+
export type OptimizelyCompositionComponent = ComponentType<OptimizelyCompositionProps>;
|
|
57
|
+
export type OptimizelyCompositionBaseComponent = ComponentType<BaseOptimizelyCompositionProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/visual-builder/types.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC1B,+CAAyB,CAAA;IACzB,yCAAmB,CAAA;IACnB,iCAAW,CAAA;IACX,uCAAiB,CAAA;AACrB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
6
|
+
*/
|
|
7
|
+
export { RichText } from "./components/rich-text/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
10
|
+
*/
|
|
11
|
+
export { DefaultComponents, DefaultTextNode, createHtmlComponent } from "./components/rich-text/components.js";
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
14
|
+
*/
|
|
15
|
+
export * as Utils from "./components/rich-text/utils.js";
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
18
|
+
*/
|
|
19
|
+
export type * from "./components/rich-text/types.js";
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
22
|
+
*/
|
|
23
|
+
export type { BaseStyleDefinition, ElementStyleDefinition, LayoutProps, LayoutPropsSetting, LayoutPropsSettingChoices, LayoutPropsSettingKeys, LayoutPropsSettingValues, NodeStyleDefinition, StyleDefinition, StyleSetting } from "./components/cms-styles/index.js";
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
26
|
+
*/
|
|
27
|
+
export { extractSettings, readSetting } from "./components/cms-styles/index.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
6
|
+
*/
|
|
7
|
+
export { RichText } from "./components/rich-text/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
10
|
+
*/
|
|
11
|
+
export { DefaultComponents, DefaultTextNode, createHtmlComponent } from "./components/rich-text/components.js";
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
14
|
+
*/
|
|
15
|
+
export * as Utils from "./components/rich-text/utils.js";
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated The `@remkoj/optimizely-cms-react/components` export has been deprecated
|
|
18
|
+
*/
|
|
19
|
+
export { extractSettings, readSetting } from "./components/cms-styles/index.js";
|
|
20
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC1D;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AAC9G;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,iCAAiC,CAAA;AASxD;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type FunctionComponent, type PropsWithChildren, type Dispatch, type SetStateAction } from "react";
|
|
2
|
+
import { type OptimizelyGraphConfig, type IOptiGraphClient } from "@remkoj/optimizely-graph-client";
|
|
3
|
+
import { type GenericContext } from "./types.js";
|
|
4
|
+
import { type ComponentTypeDictionary, type ComponentFactory } from "../factory/index.js";
|
|
5
|
+
export declare const enum OptimizelyCmsMode {
|
|
6
|
+
default = "default",
|
|
7
|
+
edit = "edit",
|
|
8
|
+
preview = "preview"
|
|
9
|
+
}
|
|
10
|
+
export interface ClientContext extends GenericContext {
|
|
11
|
+
setLocale: Dispatch<SetStateAction<string | undefined>>;
|
|
12
|
+
setMode: Dispatch<SetStateAction<OptimizelyCmsMode>>;
|
|
13
|
+
}
|
|
14
|
+
export type OptimizelyCmsProps = {
|
|
15
|
+
/**
|
|
16
|
+
* The Optimizely Graph Client to use, provide either an instance of the
|
|
17
|
+
* client, or the configuration used to create the instance. In case you
|
|
18
|
+
* provide no parameters, the Client will try to infer the configuration
|
|
19
|
+
* from the environment variables.
|
|
20
|
+
*/
|
|
21
|
+
client?: null | OptimizelyGraphConfig | IOptiGraphClient;
|
|
22
|
+
/**
|
|
23
|
+
* The authentication token to use for the Optimizely Graph Client. This
|
|
24
|
+
* token will be applied to the client after it has been resolved from the
|
|
25
|
+
* `client` property. If not provided the current authentication data of
|
|
26
|
+
* the client will not be affected.
|
|
27
|
+
*/
|
|
28
|
+
clientToken?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Marker to indicate if the debug mode should be activated. If not provided
|
|
31
|
+
* it will be read from the Optimizely Graph Client, inferred by the `client`
|
|
32
|
+
* property.
|
|
33
|
+
*/
|
|
34
|
+
isDebug?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Marker to indicate if the development mode should be activated. If not
|
|
37
|
+
* provided, it will be read from the `process.env.NODE_ENV` variable. If
|
|
38
|
+
* this variable is not set it assumes it to be "production".
|
|
39
|
+
*/
|
|
40
|
+
isDevelopment?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The default mode to initialize the context with, after initialization the
|
|
43
|
+
* current mode will be state managed using `useState`.
|
|
44
|
+
*/
|
|
45
|
+
initialMode?: OptimizelyCmsMode;
|
|
46
|
+
} & ({
|
|
47
|
+
/**
|
|
48
|
+
* The component factory to be used to resolve content within the scope
|
|
49
|
+
* of this provider.
|
|
50
|
+
*/
|
|
51
|
+
factory: ComponentFactory;
|
|
52
|
+
/**
|
|
53
|
+
* The defaults components to apply when there's no factory provided. If a
|
|
54
|
+
* factory is provided, these components will not be added to the factory.
|
|
55
|
+
*/
|
|
56
|
+
initialComponents?: never;
|
|
57
|
+
} | {
|
|
58
|
+
/**
|
|
59
|
+
* The component factory to be used to resolve content within the scope
|
|
60
|
+
* of this provider.
|
|
61
|
+
*/
|
|
62
|
+
factory?: never;
|
|
63
|
+
/**
|
|
64
|
+
* The defaults components to apply when there's no factory provided. If a
|
|
65
|
+
* factory is provided, these components will not be added to the factory.
|
|
66
|
+
*/
|
|
67
|
+
initialComponents: ComponentTypeDictionary;
|
|
68
|
+
});
|
|
69
|
+
export declare const OptimizelyCms: FunctionComponent<PropsWithChildren<OptimizelyCmsProps>>;
|
|
70
|
+
export declare const useOptimizelyCms: () => ClientContext;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useMemo } from "react";
|
|
4
|
+
import { isOptiGraphClient, isOptiGraphConfig, createClient } from "@remkoj/optimizely-graph-client";
|
|
5
|
+
import { getFactory } from "../factory/index.js";
|
|
6
|
+
import { UndefinedComponentFactory } from "../factory/undef.js";
|
|
7
|
+
export var OptimizelyCmsMode;
|
|
8
|
+
(function (OptimizelyCmsMode) {
|
|
9
|
+
OptimizelyCmsMode["default"] = "default";
|
|
10
|
+
OptimizelyCmsMode["edit"] = "edit";
|
|
11
|
+
OptimizelyCmsMode["preview"] = "preview";
|
|
12
|
+
})(OptimizelyCmsMode || (OptimizelyCmsMode = {}));
|
|
13
|
+
const _clientContext = createContext({
|
|
14
|
+
factory: new UndefinedComponentFactory(),
|
|
15
|
+
inEditMode: false,
|
|
16
|
+
inPreviewMode: false,
|
|
17
|
+
isDebug: false,
|
|
18
|
+
isDebugOrDevelopment: false,
|
|
19
|
+
isDevelopment: false,
|
|
20
|
+
setLocale: () => { throw new Error("Not implemented"); },
|
|
21
|
+
setMode: () => { throw new Error("Not implemented"); }
|
|
22
|
+
});
|
|
23
|
+
_clientContext.displayName = "Optimizely CMS Provider";
|
|
24
|
+
export const OptimizelyCms = ({ factory, client, clientToken, children, isDebug, isDevelopment, initialMode = OptimizelyCmsMode.default, initialComponents = [] }) => {
|
|
25
|
+
const CtxProvider = _clientContext.Provider;
|
|
26
|
+
//#region React State
|
|
27
|
+
const [locale, setLocale] = useState();
|
|
28
|
+
const [mode, setMode] = useState(initialMode);
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region Memoized Optimizely Graph Client
|
|
31
|
+
const graphClient = useMemo(() => {
|
|
32
|
+
const gc = isOptiGraphClient(client) ? client : createClient(isOptiGraphConfig(client) ? client : undefined);
|
|
33
|
+
if (clientToken)
|
|
34
|
+
gc.updateAuthentication(clientToken);
|
|
35
|
+
return gc;
|
|
36
|
+
}, [client, clientToken]);
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region Memoized Debug and Development flags
|
|
39
|
+
const isDev = useMemo(() => isDevelopment == undefined ? getNodeEnv() == 'development' : isDevelopment, [isDevelopment]);
|
|
40
|
+
const isDbg = useMemo(() => isDebug == undefined ? graphClient.debug : isDebug, [isDebug, graphClient]);
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region Memoized Component Factory
|
|
43
|
+
const ctxFactory = useMemo(() => {
|
|
44
|
+
if (factory)
|
|
45
|
+
return factory;
|
|
46
|
+
const newFactory = getFactory();
|
|
47
|
+
newFactory.registerAll(initialComponents);
|
|
48
|
+
return newFactory;
|
|
49
|
+
}, [factory]);
|
|
50
|
+
//#endregion
|
|
51
|
+
const ctxValue = {
|
|
52
|
+
client: graphClient,
|
|
53
|
+
factory: ctxFactory,
|
|
54
|
+
isDebug: isDbg,
|
|
55
|
+
isDevelopment: isDev,
|
|
56
|
+
isDebugOrDevelopment: isDbg || isDev,
|
|
57
|
+
inEditMode: mode == OptimizelyCmsMode.edit,
|
|
58
|
+
inPreviewMode: mode == OptimizelyCmsMode.preview,
|
|
59
|
+
locale,
|
|
60
|
+
setLocale,
|
|
61
|
+
setMode
|
|
62
|
+
};
|
|
63
|
+
return _jsx(CtxProvider, { value: ctxValue, children: children });
|
|
64
|
+
};
|
|
65
|
+
export const useOptimizelyCms = () => {
|
|
66
|
+
return useContext(_clientContext);
|
|
67
|
+
};
|
|
68
|
+
function getNodeEnv() {
|
|
69
|
+
let env;
|
|
70
|
+
try {
|
|
71
|
+
env = process.env.NODE_ENV;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Ignored on purpose
|
|
75
|
+
}
|
|
76
|
+
return env || 'production';
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @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AC,CAAC,CAAA;IACb,YAAY;IAEZ,MAAM,QAAQ,GAAmB;QAC7B,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,KAAK;QACpB,oBAAoB,EAAE,KAAK,IAAI,KAAK;QACpC,UAAU,EAAE,IAAI,IAAI,iBAAiB,CAAC,IAAI;QAC1C,aAAa,EAAE,IAAI,IAAI,iBAAiB,CAAC,OAAO;QAChD,MAAM;QACN,SAAS;QACT,OAAO;KACV,CAAA;IAED,OAAO,KAAC,WAAW,IAAC,KAAK,EAAG,QAAQ,YAAK,QAAQ,GAAgB,CAAA;AACrE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACjC,OAAO,UAAU,CAAC,cAAc,CAAC,CAAA;AACrC,CAAC,CAAA;AAED,SAAS,UAAU;IAEf,IAAI,GAAwB,CAAA;IAC5B,IAAI,CAAC;QACD,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACL,qBAAqB;IACzB,CAAC;IACD,OAAO,GAAG,IAAI,YAAY,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
import { type IOptiGraphClient, type ContentLink } from '@remkoj/optimizely-graph-client';
|
|
3
|
+
import { type GenericContext } from './types.js';
|
|
4
|
+
import { type ComponentFactory } from '../factory/index.js';
|
|
5
|
+
export * from "./types.js";
|
|
6
|
+
type ServerContextArgs = {
|
|
7
|
+
factory?: ComponentFactory;
|
|
8
|
+
client?: IOptiGraphClient;
|
|
9
|
+
locale?: string;
|
|
10
|
+
};
|
|
11
|
+
declare class ServerContext implements GenericContext {
|
|
12
|
+
private _mode;
|
|
13
|
+
private _locale;
|
|
14
|
+
private _client;
|
|
15
|
+
private _factory;
|
|
16
|
+
private _editable;
|
|
17
|
+
get client(): IOptiGraphClient | undefined;
|
|
18
|
+
get factory(): ComponentFactory;
|
|
19
|
+
get locale(): string | undefined;
|
|
20
|
+
get inEditMode(): boolean;
|
|
21
|
+
get inPreviewMode(): boolean;
|
|
22
|
+
get isDevelopment(): boolean;
|
|
23
|
+
get isDebug(): boolean;
|
|
24
|
+
get isDebugOrDevelopment(): boolean;
|
|
25
|
+
get editableContent(): ContentLink | undefined;
|
|
26
|
+
constructor({ factory, client, locale }: ServerContextArgs);
|
|
27
|
+
setMode(mode: 'edit' | 'preview' | 'public'): ServerContext;
|
|
28
|
+
setLocale(locale: string): ServerContext;
|
|
29
|
+
setOptimizelyGraphClient(client: IOptiGraphClient | ((currentClient: IOptiGraphClient | undefined) => IOptiGraphClient | undefined)): void;
|
|
30
|
+
setComponentFactory(factory: ComponentFactory | ((currentClient: ComponentFactory | undefined) => ComponentFactory)): void;
|
|
31
|
+
setEditableContentId(link: ContentLink): void;
|
|
32
|
+
}
|
|
33
|
+
export declare const getServerContext: () => ServerContext;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
import { createClient, isOptiGraphClient } from '@remkoj/optimizely-graph-client';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { DefaultComponentFactory } from '../factory/index.js';
|
|
5
|
+
import { isDebug, isDevelopment } from '../rsc-utilities.js';
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
const cachePlaceholder = (factory) => {
|
|
8
|
+
if (isDebug())
|
|
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 {
|
|
15
|
+
get client() {
|
|
16
|
+
return this._client;
|
|
17
|
+
}
|
|
18
|
+
get factory() {
|
|
19
|
+
return this._factory;
|
|
20
|
+
}
|
|
21
|
+
get locale() {
|
|
22
|
+
return this._locale;
|
|
23
|
+
}
|
|
24
|
+
get inEditMode() {
|
|
25
|
+
return this._mode == 'edit';
|
|
26
|
+
}
|
|
27
|
+
get inPreviewMode() {
|
|
28
|
+
return this._mode == 'preview';
|
|
29
|
+
}
|
|
30
|
+
get isDevelopment() {
|
|
31
|
+
return isDevelopment();
|
|
32
|
+
}
|
|
33
|
+
get isDebug() {
|
|
34
|
+
return isDebug();
|
|
35
|
+
}
|
|
36
|
+
get isDebugOrDevelopment() {
|
|
37
|
+
return this.isDebug || this.isDevelopment;
|
|
38
|
+
}
|
|
39
|
+
get editableContent() {
|
|
40
|
+
return this._editable;
|
|
41
|
+
}
|
|
42
|
+
constructor({ factory, client, locale }) {
|
|
43
|
+
this._mode = 'public';
|
|
44
|
+
this._factory = factory || new DefaultComponentFactory();
|
|
45
|
+
this._client = client || createClient();
|
|
46
|
+
this._locale = locale;
|
|
47
|
+
}
|
|
48
|
+
setMode(mode) {
|
|
49
|
+
this._mode = mode;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
setLocale(locale) {
|
|
53
|
+
this._locale = locale;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
setOptimizelyGraphClient(client) {
|
|
57
|
+
this._client = typeof (client) == 'function' ? client(this._client) : isOptiGraphClient(client) ? client : undefined;
|
|
58
|
+
}
|
|
59
|
+
setComponentFactory(factory) {
|
|
60
|
+
const newFactory = typeof (factory) == 'function' ? factory(this._factory) : factory;
|
|
61
|
+
if (!newFactory)
|
|
62
|
+
throw new Error("Unsetting the context factory is not allowed!");
|
|
63
|
+
this._factory = newFactory;
|
|
64
|
+
}
|
|
65
|
+
setEditableContentId(link) {
|
|
66
|
+
this._editable = link;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export const getServerContext = cache(() => {
|
|
70
|
+
const ctx = new ServerContext({});
|
|
71
|
+
if (ctx.isDebug)
|
|
72
|
+
console.log('🦺 [ServerContext] Created new context');
|
|
73
|
+
return ctx;
|
|
74
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M,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,GAAG,EAAE;IACvC,MAAM,GAAG,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAA;IACjC,IAAI,GAAG,CAAC,OAAO;QACX,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAA;IACzD,OAAO,GAAG,CAAA;AACd,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type IOptiGraphClient } from "@remkoj/optimizely-graph-client";
|
|
2
|
+
import { type ComponentFactory } from "../factory/types.js";
|
|
3
|
+
export interface GenericContext {
|
|
4
|
+
readonly client?: IOptiGraphClient;
|
|
5
|
+
readonly factory: ComponentFactory;
|
|
6
|
+
readonly locale?: string;
|
|
7
|
+
readonly inEditMode: boolean;
|
|
8
|
+
readonly inPreviewMode: boolean;
|
|
9
|
+
readonly isDevelopment: boolean;
|
|
10
|
+
readonly isDebug: boolean;
|
|
11
|
+
readonly isDebugOrDevelopment: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type PropsWithContext<P = any> = P & {
|
|
14
|
+
ctx: GenericContext;
|
|
15
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":""}
|