@remkoj/optimizely-cms-react 2.0.0-pre5 → 2.0.1-pre1
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/dist/components/cms-styles.js +3 -2
- package/dist/components/cms-styles.js.map +1 -1
- package/dist/components/rich-text.d.ts +5 -2
- package/dist/components/rich-text.js +59 -8
- package/dist/components/rich-text.js.map +1 -1
- package/dist/factory.d.ts +10 -2
- package/dist/factory.js +26 -3
- package/dist/factory.js.map +1 -1
- package/dist/server/components/cms-content-area.d.ts +0 -1
- package/dist/server/components/cms-content.d.ts +1 -2
- package/dist/server/components/cms-content.js +22 -20
- package/dist/server/components/cms-content.js.map +1 -1
- package/dist/server/components/queries.js +12 -12
- package/dist/server/components/types.d.ts +5 -0
- package/dist/server/components/visual-builder/Composition.d.ts +6 -1
- package/dist/server/components/visual-builder/Composition.js +24 -68
- package/dist/server/components/visual-builder/Composition.js.map +1 -1
- package/dist/server/components/visual-builder/functions.d.ts +6 -1
- package/dist/server/components/visual-builder/functions.js +56 -1
- package/dist/server/components/visual-builder/functions.js.map +1 -1
- package/dist/server/components/visual-builder/types.d.ts +15 -5
- package/dist/server/components/visual-builder/types.js +2 -2
- package/dist/server/components/visual-builder/types.js.map +1 -1
- package/dist/server/type-utils.d.ts +0 -1
- package/dist/types.d.ts +34 -3
- package/dist/utilities.d.ts +22 -1
- package/dist/utilities.js +33 -3
- package/dist/utilities.js.map +1 -1
- package/package.json +9 -7
|
@@ -14,8 +14,9 @@ export function extractSettings(from) {
|
|
|
14
14
|
if (!from)
|
|
15
15
|
return {};
|
|
16
16
|
const extracted = {};
|
|
17
|
-
from?.settings?.
|
|
18
|
-
|
|
17
|
+
from?.settings?.forEach((itm) => {
|
|
18
|
+
if (itm.value)
|
|
19
|
+
extracted[itm.key] = itm.value;
|
|
19
20
|
});
|
|
20
21
|
return extracted;
|
|
21
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-styles.js","sourceRoot":"","sources":["../../src/components/cms-styles.tsx"],"names":[],"mappings":"AA0CA;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAIzB,IAAmB,EAAE,WAAc,EAAE,YAAiB;IAGpD,MAAM,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAA;IACtE,OAAO,CAAC,EAAE,IAAI,YAAY,CAAO,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAA6B,IAAmB;IAG3E,IAAI,CAAC,IAAI;QACL,OAAO,EAAQ,CAAA;IACnB,MAAM,SAAS,GAAiB,EAAE,CAAA;IAClC,IAAI,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"cms-styles.js","sourceRoot":"","sources":["../../src/components/cms-styles.tsx"],"names":[],"mappings":"AA0CA;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAIzB,IAAmB,EAAE,WAAc,EAAE,YAAiB;IAGpD,MAAM,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAA;IACtE,OAAO,CAAC,EAAE,IAAI,YAAY,CAAO,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAA6B,IAAmB;IAG3E,IAAI,CAAC,IAAI;QACL,OAAO,EAAQ,CAAA;IACnB,MAAM,SAAS,GAAiB,EAAE,CAAA;IAClC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC5B,IAAI,GAAG,CAAC,KAAK;YACT,SAAS,CAAC,GAAG,CAAC,GAAe,CAAC,GAAG,GAAG,CAAC,KAAqB,CAAA;IAClE,CAAC,CAAC,CAAA;IACF,OAAO,SAAe,CAAA;AAC1B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type FunctionComponent } from "react";
|
|
1
|
+
import type { ComponentFactory, ComponentType, ComponentTypeDictionary } from "../types.js";
|
|
2
|
+
import { type FunctionComponent, type PropsWithChildren } from "react";
|
|
3
3
|
export type RichTextProps = {
|
|
4
4
|
/**
|
|
5
5
|
* The component factory used for this rich text content
|
|
@@ -64,6 +64,9 @@ export declare const Utils: {
|
|
|
64
64
|
getRandomId(scope?: string): string;
|
|
65
65
|
};
|
|
66
66
|
export declare const RichText: FunctionComponent<RichTextProps>;
|
|
67
|
+
export declare function createHtmlComponent<E extends keyof JSX.IntrinsicElements>(element: E, ignoreChildren?: boolean, defaultProps?: JSX.IntrinsicElements[E] & Record<string, string>): ({ children, node, ...props }: PropsWithChildren<JSX.IntrinsicElements[E] & {
|
|
68
|
+
node: TypedNode;
|
|
69
|
+
}>) => import("react/jsx-runtime").JSX.Element;
|
|
67
70
|
/**
|
|
68
71
|
* A default component dictionary that allows to serialize the structured HTML
|
|
69
72
|
* into React, using the component library shared across the react SDK.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DefaultComponentFactory } from "../factory.js";
|
|
3
|
+
import { decodeHTML } from 'entities';
|
|
2
4
|
//#endregion
|
|
3
5
|
//#region Utils & Supports
|
|
4
6
|
export const Utils = {
|
|
@@ -6,7 +8,7 @@ export const Utils = {
|
|
|
6
8
|
return (typeof toTest == 'object' &&
|
|
7
9
|
toTest != null &&
|
|
8
10
|
(typeof toTest.text) == 'string' &&
|
|
9
|
-
toTest.text.length
|
|
11
|
+
toTest.text.length >= 0);
|
|
10
12
|
},
|
|
11
13
|
isTypedNode(toTest) {
|
|
12
14
|
return (typeof toTest == 'object' &&
|
|
@@ -30,11 +32,12 @@ export const Utils = {
|
|
|
30
32
|
export const RichText = ({ factory, text, className = 'rich-text', as: Wrapper = "div", ...props }) => {
|
|
31
33
|
const debug = process.env.NODE_ENV != 'production';
|
|
32
34
|
const id = Utils.getRandomId("rich-text");
|
|
35
|
+
const richTextFactory = factory ?? new DefaultComponentFactory(DefaultComponents);
|
|
33
36
|
try {
|
|
34
37
|
const data = Utils.processNodeInput(text);
|
|
35
38
|
return _jsx(Wrapper, { className: className, ...props, children: (data?.children || []).map((child, idx) => {
|
|
36
39
|
const elementId = id + '::' + idx;
|
|
37
|
-
return _jsx(RichTextElement, { factory:
|
|
40
|
+
return _jsx(RichTextElement, { factory: richTextFactory, node: child, idPrefix: elementId + '::' }, elementId);
|
|
38
41
|
}) });
|
|
39
42
|
}
|
|
40
43
|
catch {
|
|
@@ -47,6 +50,8 @@ export const RichText = ({ factory, text, className = 'rich-text', as: Wrapper =
|
|
|
47
50
|
const RichTextElement = ({ factory, node, idPrefix }) => {
|
|
48
51
|
const debug = process.env.NODE_ENV != 'production';
|
|
49
52
|
if (Utils.isText(node)) {
|
|
53
|
+
if (node.text.length == 0)
|
|
54
|
+
return null;
|
|
50
55
|
const TextComponent = factory?.resolve(`RichText/text`) ?? DefaultTextNode;
|
|
51
56
|
return _jsx(TextComponent, { node: node });
|
|
52
57
|
}
|
|
@@ -61,27 +66,73 @@ const RichTextElement = ({ factory, node, idPrefix }) => {
|
|
|
61
66
|
});
|
|
62
67
|
if (!factory?.has(`RichText/${node.type}`)) {
|
|
63
68
|
console.warn('🟠 [Rich Text] No renderer for node type, falling back to "div":', `RichText/${node.type}`);
|
|
64
|
-
|
|
69
|
+
const DivComponent = createHtmlComponent("div", false, { "data-type": node.type });
|
|
70
|
+
return _jsx(DivComponent, { node: node, children: childData });
|
|
65
71
|
}
|
|
66
72
|
const Component = factory?.resolve(`RichText/${node.type}`) ?? 'div';
|
|
67
73
|
return _jsx(Component, { node: node, children: childData });
|
|
68
74
|
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region HTML Components
|
|
77
|
+
export function createHtmlComponent(element, ignoreChildren = false, defaultProps) {
|
|
78
|
+
const HtmlElement = element;
|
|
79
|
+
const reservedProps = ['url', 'class', 'children', 'type'];
|
|
80
|
+
const component = ({ children, node, ...props }) => {
|
|
81
|
+
const nodeProps = {};
|
|
82
|
+
const renderProps = Object.getOwnPropertyNames(node);
|
|
83
|
+
renderProps.filter(x => !reservedProps.includes(x)).forEach(x => nodeProps[x] = node[x]);
|
|
84
|
+
if (renderProps.includes('class'))
|
|
85
|
+
nodeProps['className'] = node['class'];
|
|
86
|
+
if (renderProps.includes('url')) {
|
|
87
|
+
switch (node.type) {
|
|
88
|
+
case 'link':
|
|
89
|
+
nodeProps['href'] = node['url'];
|
|
90
|
+
break;
|
|
91
|
+
case 'image':
|
|
92
|
+
nodeProps['src'] = node['url'];
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
nodeProps['data-url'] = node['url'];
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return ignoreChildren ? _jsx(HtmlElement, { ...defaultProps, ...nodeProps, ...props }) : _jsx(HtmlElement, { ...defaultProps, ...nodeProps, ...props, children: children });
|
|
100
|
+
};
|
|
101
|
+
return component;
|
|
102
|
+
}
|
|
69
103
|
const DefaultTextNode = ({ node }) => {
|
|
70
104
|
if (node.bold)
|
|
71
|
-
return _jsx("strong", { children: node.text });
|
|
105
|
+
return _jsx("strong", { children: decodeHTML(node.text) });
|
|
106
|
+
if (node.italic)
|
|
107
|
+
return _jsx("em", { children: decodeHTML(node.text) });
|
|
72
108
|
const unsupportedProps = Object.getOwnPropertyNames(node).filter(x => x != 'text');
|
|
73
109
|
if (unsupportedProps.length > 0 && process.env.NODE_ENV != 'production')
|
|
74
110
|
console.warn('🟠 [Rich Text] Text node with unsupported additional properties:', unsupportedProps.join(', '));
|
|
75
|
-
return node.text
|
|
111
|
+
return decodeHTML(node.text);
|
|
76
112
|
};
|
|
77
|
-
//#endregion
|
|
78
113
|
/**
|
|
79
114
|
* A default component dictionary that allows to serialize the structured HTML
|
|
80
115
|
* into React, using the component library shared across the react SDK.
|
|
81
116
|
*/
|
|
82
117
|
export const DefaultComponents = [
|
|
83
|
-
{ type: 'RichText/
|
|
84
|
-
{ type: 'RichText/
|
|
118
|
+
{ type: 'RichText/richText', component: createHtmlComponent("div", false, { className: "cms:rich-text" }) },
|
|
119
|
+
{ type: 'RichText/paragraph', component: createHtmlComponent("p") },
|
|
120
|
+
{ type: 'RichText/span', component: createHtmlComponent("span") },
|
|
121
|
+
{ type: 'RichText/div', component: createHtmlComponent("div") },
|
|
122
|
+
{ type: 'RichText/heading-one', component: createHtmlComponent("h1") },
|
|
123
|
+
{ type: 'RichText/heading-two', component: createHtmlComponent("h2") },
|
|
124
|
+
{ type: 'RichText/heading-three', component: createHtmlComponent("h3") },
|
|
125
|
+
{ type: 'RichText/heading-four', component: createHtmlComponent("h4") },
|
|
126
|
+
{ type: 'RichText/heading-five', component: createHtmlComponent("h5") },
|
|
127
|
+
{ type: 'RichText/heading-six', component: createHtmlComponent("h6") },
|
|
128
|
+
{ type: 'RichText/link', component: createHtmlComponent("a") },
|
|
129
|
+
{ type: 'RichText/image', component: createHtmlComponent("img", true) },
|
|
130
|
+
{ type: 'RichText/text', component: DefaultTextNode },
|
|
131
|
+
{ type: 'RichText/br', component: createHtmlComponent("br", true) },
|
|
132
|
+
{ type: 'RichText/bulleted-list', component: createHtmlComponent("ul") },
|
|
133
|
+
{ type: 'RichText/numbered-list', component: createHtmlComponent("ol") },
|
|
134
|
+
{ type: 'RichText/list-item', component: createHtmlComponent("li") }
|
|
85
135
|
];
|
|
136
|
+
//#endregion
|
|
86
137
|
export default RichText;
|
|
87
138
|
//# sourceMappingURL=rich-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text.js","sourceRoot":"","sources":["../../src/components/rich-text.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"rich-text.js","sourceRoot":"","sources":["../../src/components/rich-text.tsx"],"names":[],"mappings":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AAI,CAAC,EAAC;CACtE,CAAA;AACD,YAAY;AAEZ,eAAe,QAAQ,CAAA"}
|
package/dist/factory.d.ts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import type { ComponentFactory, ComponentType, ComponentTypeHandle, ComponentTypeDictionary } from './types.js';
|
|
2
2
|
export declare const EmptyComponentHandle = "$$fragment$$";
|
|
3
3
|
/**
|
|
4
|
-
* The default implementation of the ComponentFactory
|
|
4
|
+
* The default implementation of the ComponentFactory interface, which works both
|
|
5
|
+
* client and server side.
|
|
5
6
|
*/
|
|
6
7
|
export declare class DefaultComponentFactory implements ComponentFactory {
|
|
7
8
|
private registry;
|
|
8
9
|
private dbg;
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of the DefaultComponentFactory
|
|
12
|
+
*
|
|
13
|
+
* @param initialComponents If provided, this dictionary will be registered
|
|
14
|
+
* with the factory.
|
|
15
|
+
*/
|
|
16
|
+
constructor(initialComponents?: ComponentTypeDictionary);
|
|
10
17
|
register(type: ComponentTypeHandle, component: ComponentType): void;
|
|
11
18
|
registerAll(components: ComponentTypeDictionary): void;
|
|
12
19
|
has(type: ComponentTypeHandle): boolean;
|
|
13
20
|
resolve(type: ComponentTypeHandle): undefined | ComponentType;
|
|
21
|
+
extract(): ComponentTypeDictionary;
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
24
|
* Retrieve the currently staticly cached ComponentFactory instance, if there's no
|
package/dist/factory.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
const MERGE_SYMBOL = '/';
|
|
2
2
|
export const EmptyComponentHandle = '$$fragment$$';
|
|
3
3
|
/**
|
|
4
|
-
* The default implementation of the ComponentFactory
|
|
4
|
+
* The default implementation of the ComponentFactory interface, which works both
|
|
5
|
+
* client and server side.
|
|
5
6
|
*/
|
|
6
7
|
export class DefaultComponentFactory {
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of the DefaultComponentFactory
|
|
10
|
+
*
|
|
11
|
+
* @param initialComponents If provided, this dictionary will be registered
|
|
12
|
+
* with the factory.
|
|
13
|
+
*/
|
|
14
|
+
constructor(initialComponents) {
|
|
8
15
|
this.registry = {};
|
|
9
16
|
this.dbg = process.env.OPTIMIZELY_DEBUG == '1';
|
|
17
|
+
if (initialComponents)
|
|
18
|
+
this.registerAll(initialComponents);
|
|
10
19
|
}
|
|
11
20
|
register(type, component) {
|
|
12
21
|
type = processComponentTypeHandle(type);
|
|
@@ -31,12 +40,26 @@ export class DefaultComponentFactory {
|
|
|
31
40
|
return this.registry[type];
|
|
32
41
|
return undefined;
|
|
33
42
|
}
|
|
43
|
+
extract() {
|
|
44
|
+
const extracted = [];
|
|
45
|
+
Object.getOwnPropertyNames(this.registry).map(typeKey => {
|
|
46
|
+
extracted.push({
|
|
47
|
+
type: typeKey,
|
|
48
|
+
component: this.registry[typeKey]
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return extracted;
|
|
52
|
+
}
|
|
34
53
|
}
|
|
35
54
|
function processComponentTypeHandle(handle) {
|
|
36
55
|
if (typeof (handle) == 'string')
|
|
37
56
|
return handle == "" ? EmptyComponentHandle : handle;
|
|
38
57
|
if (Array.isArray(handle) && handle.every(s => typeof (s) == 'string'))
|
|
39
|
-
return handle
|
|
58
|
+
return handle
|
|
59
|
+
.map(s => s.startsWith("_") ? s.substring(1) : s) // Remove all leading underscores
|
|
60
|
+
.filter(s => s.toLowerCase() != 'content') // Remove the "Content" base type
|
|
61
|
+
.map(s => s == "" ? EmptyComponentHandle : s) // Fall back to a fragment
|
|
62
|
+
.join(MERGE_SYMBOL); // Types are processed as a string
|
|
40
63
|
throw new Error(`Invalid component type handle: ${typeof (handle)}`);
|
|
41
64
|
}
|
|
42
65
|
const _static = {};
|
package/dist/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AACA,MAAM,Y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AAE,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,CAAU,iCAAiC;aACpF,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAO,0BAA0B;aAC7E,IAAI,CAAC,YAAY,CAAC,CAAA,CAAiC,kCAAkC;IAC9F,MAAM,IAAI,KAAK,CAAC,kCAAmC,OAAM,CAAC,MAAM,CAAE,EAAE,CAAC,CAAA;AACzE,CAAC;AAED,MAAM,OAAO,GAAqC,EAAE,CAAA;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAA4B,GAAG,EAAE;IACpD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAA;IAC/C,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACnB,IAAI,GAAG;YAAE,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAA;QAC3E,OAAO,CAAC,OAAO,GAAG,IAAI,uBAAuB,EAAE,CAAA;IACnD,CAAC;SAAM,CAAC;QACJ,IAAI,GAAG;YAAE,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAA;IACnF,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAA;AAC1B,CAAC,CAAA;AACD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAA4C,CAAC,UAA4B,EAAE,EAAE;IAChG,OAAO,CAAC,OAAO,GAAG,UAAU,CAAA;AAChC,CAAC,CAAA;AACD,eAAe,UAAU,EAAE,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import 'server-only';
|
|
3
2
|
import type { CmsContentProps } from './types.js';
|
|
4
3
|
export type { CmsContentProps } from './types.js';
|
|
@@ -8,5 +7,5 @@ export type { CmsContentProps } from './types.js';
|
|
|
8
7
|
* @param param0
|
|
9
8
|
* @returns
|
|
10
9
|
*/
|
|
11
|
-
export declare const CmsContent: <LocalesType = string>({ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps }: CmsContentProps<LocalesType>) => Promise<JSX.Element>;
|
|
10
|
+
export declare const CmsContent: <LocalesType = string>({ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps, noDataLoad }: CmsContentProps<LocalesType>) => Promise<JSX.Element>;
|
|
12
11
|
export default CmsContent;
|
|
@@ -12,7 +12,8 @@ import * as Queries from './queries.js';
|
|
|
12
12
|
* @param param0
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
export const CmsContent = async ({ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps }) => {
|
|
15
|
+
export const CmsContent = async ({ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps, noDataLoad }) => {
|
|
16
|
+
let myContentType = contentType ? [...contentType] : undefined;
|
|
16
17
|
const context = getServerContext();
|
|
17
18
|
const contentLink = normalizeContentLink(rawContentLink);
|
|
18
19
|
if (!contentLink) {
|
|
@@ -37,34 +38,30 @@ export const CmsContent = async ({ contentType, contentTypePrefix, contentLink:
|
|
|
37
38
|
console.warn(`🟠 [CmsContent] Edit mode active without an authenticated client, this will cause problems`);
|
|
38
39
|
// DEBUG Tracing
|
|
39
40
|
if (context.isDebug)
|
|
40
|
-
console.log("⚪ [CmsContent] Rendering CMS Content for:", JSON.stringify(
|
|
41
|
+
console.log("⚪ [CmsContent] Rendering CMS Content for:", JSON.stringify(myContentType), contentLinkToString(contentLink), context.inEditMode ? "edit-mode" : "published");
|
|
41
42
|
// Ensure we have a content type to work with
|
|
42
|
-
if (!
|
|
43
|
+
if (!myContentType) {
|
|
43
44
|
if (isInline) {
|
|
44
45
|
console.error(`🔴 [CmsContent] No content type provided for content ${contentLinkToString(contentLink)}, content types cannot be resolved for inline content`);
|
|
45
46
|
throw new Error("Unable to render Inline CMS Content without Content Type information");
|
|
46
47
|
}
|
|
47
48
|
if (context.isDebugOrDevelopment)
|
|
48
|
-
console.warn(`🟠 [CmsContent] No content type provided for content ${contentLinkToString(contentLink)}, this causes an additional GraphQL query to resolve the
|
|
49
|
-
|
|
49
|
+
console.warn(`🟠 [CmsContent] No content type provided for content ${contentLinkToString(contentLink)}, this causes an additional GraphQL query to resolve the myContentType`);
|
|
50
|
+
myContentType = await getContentType(contentLink, client);
|
|
50
51
|
}
|
|
51
52
|
// Optimizely Graph stores the type in Most Significant first order, we need least significant first, also we're stripping out the common "Content" item from it
|
|
52
|
-
if (Array.isArray(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (context.isDebug)
|
|
57
|
-
console.info(`⚪ [CmsContent] Component type [${contentType.join('/')}] doesn't have the configured prefix, adding ${contentTypePrefix} as prefix`);
|
|
58
|
-
contentType.unshift(contentTypePrefix);
|
|
59
|
-
}
|
|
53
|
+
if (Array.isArray(myContentType))
|
|
54
|
+
myContentType = contentTypePrefix ?
|
|
55
|
+
Utils.normalizeAndPrefixContentType(myContentType.reverse(), contentTypePrefix) :
|
|
56
|
+
Utils.normalizeContentType(myContentType.reverse(), true);
|
|
60
57
|
// Resolve component
|
|
61
|
-
const Component = factory.resolve(
|
|
58
|
+
const Component = factory.resolve(myContentType ?? "");
|
|
62
59
|
if (!Component) {
|
|
63
60
|
if (context.isDebugOrDevelopment) {
|
|
64
|
-
console.warn(`🟠 [CmsContent] Component of type "${
|
|
61
|
+
console.warn(`🟠 [CmsContent] Component of type "${myContentType?.join('/') ?? ""}" not resolved by factory`);
|
|
65
62
|
}
|
|
66
63
|
if (context.isDebug || context.inEditMode || outputEditorWarning) {
|
|
67
|
-
const errorMsg = _jsxs("div", { className: 'opti-error', children: ["Component of type \"",
|
|
64
|
+
const errorMsg = _jsxs("div", { className: 'opti-error', children: ["Component of type \"", myContentType?.join('/') ?? "", "\" not resolved by factory"] });
|
|
68
65
|
return children ? _jsxs(_Fragment, { children: [errorMsg, children] }) : errorMsg;
|
|
69
66
|
}
|
|
70
67
|
return _jsx(_Fragment, { children: children ? children : undefined });
|
|
@@ -77,14 +74,19 @@ export const CmsContent = async ({ contentType, contentTypePrefix, contentLink:
|
|
|
77
74
|
if (context.isDebug)
|
|
78
75
|
console.log("⚪ [CmsContent] Rendering CMS Component using fragment information", fragmentProps);
|
|
79
76
|
if (Utils.validatesFragment(Component) && !Component.validateFragment(fragmentData)) {
|
|
80
|
-
console.error("🔴 [CmsContent] Invalid fragment data received for ", Component.displayName ??
|
|
77
|
+
console.error("🔴 [CmsContent] Invalid fragment data received for ", Component.displayName ?? myContentType?.join("/") ?? "[Undetermined component]");
|
|
81
78
|
return _jsx(_Fragment, {});
|
|
82
79
|
}
|
|
83
80
|
return _jsx(Component, { contentLink: contentLink, data: fragmentData || {}, inEditMode: context.inEditMode, layoutProps: layoutProps, children: children });
|
|
84
81
|
}
|
|
85
82
|
if (isInline) {
|
|
86
83
|
console.error(`🔴 [CmsContent] No data for content ${contentLinkToString(contentLink)}, data cannot be resolved for inline content`);
|
|
87
|
-
throw new Error(`Unable to render Inline CMS Content without data. (Content Type: ${Component?.displayName ??
|
|
84
|
+
throw new Error(`Unable to render Inline CMS Content without data. (Content Type: ${Component?.displayName ?? myContentType?.join('/') ?? "Unknown"}; Content Link: ${contentLinkToString(contentLink)}; Data keys: ${Object.getOwnPropertyNames(fragmentData ?? {}).join(", ")})`);
|
|
85
|
+
}
|
|
86
|
+
if (noDataLoad) {
|
|
87
|
+
if (context.isDebug)
|
|
88
|
+
console.log(`⚪ [CmsContent] Component of type "${myContentType?.join('/') ?? Component.displayName ?? '?'}" was prohibited to load data`);
|
|
89
|
+
return _jsx(Component, { contentLink: contentLink, data: fragmentData || {}, inEditMode: context.inEditMode, layoutProps: layoutProps, children: children });
|
|
88
90
|
}
|
|
89
91
|
// Render using included query
|
|
90
92
|
if (Utils.isCmsComponentWithDataQuery(Component)) {
|
|
@@ -102,7 +104,7 @@ export const CmsContent = async ({ contentType, contentTypePrefix, contentLink:
|
|
|
102
104
|
const [name, fragment] = Component.getDataFragment();
|
|
103
105
|
if (context.isDebug)
|
|
104
106
|
console.log(`⚪ [CmsContent] Component data fetching using fragment: ${name}`);
|
|
105
|
-
const fragmentQuery = `query getContentFragmentById($key: String!, $version: String, $locale: [Locales!]) {contentById:
|
|
107
|
+
const fragmentQuery = `query getContentFragmentById($key: String!, $version: String, $locale: [Locales!]) {contentById: _Content(where: {_metadata: {key: { eq: $key }, version: { eq: $version }}} locale: $locale) { total, items { _type: __typename, _metadata { key, version, locale } ...${name} }}} ${print(fragment)}`;
|
|
106
108
|
const fragmentVariables = Utils.contentLinkToRequestVariables(contentLink);
|
|
107
109
|
if (context.isDebug)
|
|
108
110
|
console.log(`⚪ [CmsContent] Component data fetching using variables: ${JSON.stringify(fragmentVariables)}`);
|
|
@@ -116,7 +118,7 @@ export const CmsContent = async ({ contentType, contentTypePrefix, contentLink:
|
|
|
116
118
|
}
|
|
117
119
|
// Assume there's no server side prepared data needed for the component
|
|
118
120
|
if (context.isDebug)
|
|
119
|
-
console.log(`⚪ [CmsContent] Component of type "${
|
|
121
|
+
console.log(`⚪ [CmsContent] Component of type "${myContentType?.join('/') ?? Component.displayName ?? '?'}" did not request pre-loading of data`);
|
|
120
122
|
return _jsx(Component, { contentLink: contentLink, data: fragmentData || {}, inEditMode: context.inEditMode, layoutProps: layoutProps, children: children });
|
|
121
123
|
};
|
|
122
124
|
export default CmsContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-content.js","sourceRoot":"","sources":["../../../src/server/components/cms-content.tsx"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"cms-content.js","sourceRoot":"","sources":["../../../src/server/components/cms-content.tsx"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAA;AAKpB,OAAO,cAAc,MAAM,uBAAuB,CAAA;AAClD,OAAO,gBAAgB,MAAM,eAAe,C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S,CAAC,iBAAiB,CAAE,EAAE,CAAC,CAAA;QAClI,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,OAAO,CAA6B,aAAa,EAAE,iBAAiB,CAAC,CAAA;QAC3G,MAAM,UAAU,GAAG,gBAAgB,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,CAAA;QAC1D,IAAI,UAAU,GAAG,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,gEAAiE,IAAK,cAAe,UAAW,yCAA0C,IAAI,CAAC,SAAS,CAAE,iBAAiB,CAAE,EAAE,CAAC,CAAA;QACpM,IAAI,UAAU,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,4BAA6B,UAAW,uDAAuD,CAAC,CAAA;QACpJ,OAAO,KAAC,SAAS,IAAC,WAAW,EAAG,WAA0B,EAAG,IAAI,EAAG,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAG,UAAU,EAAG,OAAO,CAAC,UAAU,EAAG,WAAW,EAAG,WAAW,YAAK,QAAQ,GAAa,CAAA;IACrM,CAAC;IAED,uEAAuE;IACvE,IAAI,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,GAAG,CAAC,qCAAsC,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,WAAW,IAAI,GAAG,uCAAuC,CAAC,CAAA;IACtJ,OAAO,KAAC,SAAS,IAAC,WAAW,EAAG,WAA0B,EAAG,IAAI,EAAG,YAAY,IAAI,EAAE,EAAG,UAAU,EAAG,OAAO,CAAC,UAAU,EAAG,WAAW,EAAG,WAAW,YAAK,QAAQ,GAAa,CAAA;AAClL,CAAC,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -2,19 +2,19 @@ import { gql } from 'graphql-request';
|
|
|
2
2
|
export const CmsContentFragments = {
|
|
3
3
|
IContentDataProps: ["_metadata", "_type", "__typename"],
|
|
4
4
|
ContentLink: gql `fragment ContentLink on ContentModelReference {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
id: Id,
|
|
6
|
+
workId: WorkId,
|
|
7
|
+
guidValue: GuidValue
|
|
8
8
|
}`,
|
|
9
9
|
ContentLinkSearch: gql `fragment ContentLinkSearch on ContentModelReferenceSearch {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
id: Id,
|
|
11
|
+
workId: WorkId,
|
|
12
|
+
guidValue: GuidValue
|
|
13
13
|
}`,
|
|
14
14
|
IContentData: gql `fragment IContentData on IContent {
|
|
15
15
|
contentType: ContentType
|
|
16
16
|
id: ContentLink {
|
|
17
|
-
|
|
17
|
+
...ContentLink
|
|
18
18
|
}
|
|
19
19
|
locale: Language {
|
|
20
20
|
name: Name
|
|
@@ -25,7 +25,7 @@ export const CmsContentFragments = {
|
|
|
25
25
|
item: ContentLink {
|
|
26
26
|
...ContentLinkSearch
|
|
27
27
|
data: Expanded {
|
|
28
|
-
|
|
28
|
+
...BlockData
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
displayOption:DisplayOption
|
|
@@ -34,7 +34,7 @@ export const CmsContentFragments = {
|
|
|
34
34
|
item: ContentLink {
|
|
35
35
|
...ContentLinkSearch
|
|
36
36
|
data: Expanded {
|
|
37
|
-
|
|
37
|
+
...IContentData
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
displayOption:DisplayOption
|
|
@@ -43,7 +43,7 @@ export const CmsContentFragments = {
|
|
|
43
43
|
item: ContentLink {
|
|
44
44
|
...ContentLink
|
|
45
45
|
data: Expanded {
|
|
46
|
-
|
|
46
|
+
...IContentData
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
displayOption:DisplayOption
|
|
@@ -102,7 +102,7 @@ export const ContentAreaFragments = {
|
|
|
102
102
|
}`
|
|
103
103
|
};
|
|
104
104
|
export const getContentById = gql `query getContentById($id: Int, $workId: Int, $guidValue: String, $locale: [Locales!], $isCommonDraft: Boolean) {
|
|
105
|
-
|
|
105
|
+
content:_Content(
|
|
106
106
|
where: {
|
|
107
107
|
ContentLink: {
|
|
108
108
|
Id: { eq: $id },
|
|
@@ -123,7 +123,7 @@ export const getContentById = gql `query getContentById($id: Int, $workId: Int,
|
|
|
123
123
|
}`;
|
|
124
124
|
export const getContentByPath = gql `query getContentByPath($path: String!, $locale: [Locales], $siteId: String)
|
|
125
125
|
{
|
|
126
|
-
|
|
126
|
+
content: _Content(
|
|
127
127
|
where: {
|
|
128
128
|
RelativePath: {
|
|
129
129
|
eq: $path
|
|
@@ -63,6 +63,11 @@ export type CmsContentProps<LocalesType = string> = PropsWithChildren<{
|
|
|
63
63
|
* Any layout properties inferred from the context
|
|
64
64
|
*/
|
|
65
65
|
layoutProps?: Record<string, any>;
|
|
66
|
+
/**
|
|
67
|
+
* When set to true, this will prevent the CmsContent component to try loading content from
|
|
68
|
+
* the store
|
|
69
|
+
*/
|
|
70
|
+
noDataLoad?: boolean;
|
|
66
71
|
}>;
|
|
67
72
|
export type ContentAreaItemDefinition = {
|
|
68
73
|
__typename?: string | null;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import 'server-only';
|
|
3
2
|
import type { OptimizelyCompositionProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Render the composition as made available through Optimizely Graph for Visual Builder
|
|
5
|
+
*
|
|
6
|
+
* @param param0
|
|
7
|
+
* @returns The
|
|
8
|
+
*/
|
|
4
9
|
export declare function OptimizelyComposition({ node, leafPropsFactory, nodePropsFactory }: OptimizelyCompositionProps): Promise<JSX.Element>;
|
|
5
10
|
export default OptimizelyComposition;
|
|
@@ -1,88 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import 'server-only';
|
|
2
|
-
import { isElementNode } from './functions.js';
|
|
3
|
+
import { isElementNode, defaultNodePropsFactory, defaultPropsFactory } from './functions.js';
|
|
3
4
|
import { CmsContent } from '../cms-content.js';
|
|
4
|
-
import { isContentLink, isInlineContentLink } from '@remkoj/optimizely-graph-client';
|
|
5
5
|
import getServerContext from '../../context.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throw new Error("Invalid content type: " + JSON.stringify(contentType));
|
|
13
|
-
const contentLink = {
|
|
14
|
-
key: node.element?._metadata?.key || node.key || undefined,
|
|
15
|
-
version: node.element?._metadata?.version,
|
|
16
|
-
locale: node.element?._metadata?.locale
|
|
17
|
-
};
|
|
18
|
-
if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
|
|
19
|
-
throw new Error("Invalid content link: " + JSON.stringify(contentLink));
|
|
20
|
-
const layoutData = {
|
|
21
|
-
type: node.type,
|
|
22
|
-
layoutType: node.layoutType,
|
|
23
|
-
template: node.template,
|
|
24
|
-
settings: node.settings
|
|
25
|
-
};
|
|
26
|
-
return [contentLink, contentType, node.element, layoutData];
|
|
27
|
-
};
|
|
28
|
-
function ucFirst(input) {
|
|
29
|
-
return input[0].toUpperCase() + input.substring(1);
|
|
30
|
-
}
|
|
31
|
-
const defaultNodePropsFactory = (node) => {
|
|
32
|
-
const componentTypes = [
|
|
33
|
-
[node.template, node.type ? ucFirst(node.type) : null, ucFirst(node.layoutType), "Component", "Content"].filter(x => x),
|
|
34
|
-
(node.template && node.type) ? [node.type ? ucFirst(node.type) : null, ucFirst(node.layoutType), "Component", "Content"].filter(x => x) : null,
|
|
35
|
-
["Node", "Component", "Content"]
|
|
36
|
-
].filter(x => x);
|
|
37
|
-
const contentLink = { key: node.key ?? '' };
|
|
38
|
-
const componentData = {};
|
|
39
|
-
const layoutData = {
|
|
40
|
-
type: node.type,
|
|
41
|
-
layoutType: node.layoutType,
|
|
42
|
-
template: node.template,
|
|
43
|
-
settings: node.settings
|
|
44
|
-
};
|
|
45
|
-
if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
|
|
46
|
-
throw new Error("Invalid content link: " + JSON.stringify(contentLink));
|
|
47
|
-
return [contentLink, componentTypes, componentData, layoutData];
|
|
48
|
-
};
|
|
6
|
+
/**
|
|
7
|
+
* Render the composition as made available through Optimizely Graph for Visual Builder
|
|
8
|
+
*
|
|
9
|
+
* @param param0
|
|
10
|
+
* @returns The
|
|
11
|
+
*/
|
|
49
12
|
export async function OptimizelyComposition({ node, leafPropsFactory = defaultPropsFactory, nodePropsFactory = defaultNodePropsFactory }) {
|
|
13
|
+
const { factory, isDebug } = getServerContext();
|
|
50
14
|
if (isElementNode(node)) {
|
|
15
|
+
if (isDebug)
|
|
16
|
+
console.log(`⚪ [VisualBuilder] Rendering element node ${JSON.stringify(node)}`);
|
|
51
17
|
const [contentLink, contentType, fragmentData, layoutProps] = leafPropsFactory(node);
|
|
52
|
-
|
|
18
|
+
//@ts-expect-error CmsContent is an Asynchronous server component, which isn't supported by the generic React Typings
|
|
19
|
+
return _jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, layoutProps: layoutProps });
|
|
53
20
|
}
|
|
54
|
-
|
|
21
|
+
if (isDebug)
|
|
22
|
+
console.log(`⚪ [VisualBuilder] Rendering structure node ${JSON.stringify(node)}`);
|
|
55
23
|
if (!factory)
|
|
56
|
-
throw new Error("OptimizelyComposition
|
|
57
|
-
const children = await Promise.all((node.nodes ?? []).map((child) => {
|
|
58
|
-
const childKey = child.key ? child.key : `vb::${JSON.stringify(child)}`;
|
|
59
|
-
if (isDebug)
|
|
60
|
-
console.log(`⚪ [VisualBuilder] Generated child key: ${childKey}`);
|
|
61
|
-
return OptimizelyComposition({
|
|
62
|
-
key: childKey,
|
|
63
|
-
node: child,
|
|
64
|
-
leafPropsFactory,
|
|
65
|
-
nodePropsFactory
|
|
66
|
-
});
|
|
67
|
-
}));
|
|
24
|
+
throw new Error("🟡 [VisualBuilder] [OptimizelyComposition] The factory must be defined within the serverContext");
|
|
68
25
|
const [contentLink, contentTypes, fragmentData, layoutProps] = nodePropsFactory(node);
|
|
69
26
|
const firstExistingType = contentTypes.map(ct => {
|
|
70
27
|
const reversed = [...ct].reverse();
|
|
71
28
|
const hasType = factory.has(reversed);
|
|
72
29
|
if (!hasType && isDebug)
|
|
73
|
-
console.log(`🟡 [VisualBuilder] Content type ${reversed.join('/')} not found within factory`);
|
|
30
|
+
console.log(`🟡 [VisualBuilder] [OptimizelyComposition] Content type ${reversed.join('/')} not found within factory`);
|
|
74
31
|
return hasType;
|
|
75
32
|
}).indexOf(true);
|
|
76
33
|
const contentType = contentTypes[firstExistingType];
|
|
77
34
|
if (!contentType)
|
|
78
|
-
throw new Error("OptimizelyComposition
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
35
|
+
throw new Error("🟡 [VisualBuilder] [OptimizelyComposition] The factory must have a definition for Component/Node");
|
|
36
|
+
//@ts-expect-error CmsContent is an Asynchronous server component, which isn't supported by the generic React Typings
|
|
37
|
+
return _jsx(CmsContent, { contentType: contentType, contentLink: contentLink, fragmentData: fragmentData, layoutProps: layoutProps, noDataLoad: true, children: (node.nodes ?? []).map((child) => {
|
|
38
|
+
const childKey = child.key ? child.key : `vb::${JSON.stringify(child)}`;
|
|
39
|
+
//@ts-expect-error OptimizelyComposition is an Asynchronous server component, which isn't supported by the generic React Typings
|
|
40
|
+
return _jsx(OptimizelyComposition, { node: child, leafPropsFactory: leafPropsFactory, nodePropsFactory: nodePropsFactory }, childKey);
|
|
41
|
+
}) });
|
|
86
42
|
}
|
|
87
43
|
export default OptimizelyComposition;
|
|
88
44
|
//# sourceMappingURL=Composition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composition.js","sourceRoot":"","sources":["../../../../src/server/components/visual-builder/Composition.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"Composition.js","sourceRoot":"","sources":["../../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C,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAA;QAClC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,CAAC,OAAO,IAAI,OAAO;YACnB,OAAO,CAAC,GAAG,CAAC,2DAA4D,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAE,2BAA2B,CAAC,CAAA;QAC3H,OAAO,OAAO,CAAA;IAClB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAChB,MAAM,WAAW,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAA;IACnD,IAAI,CAAC,WAAW;QACZ,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAA;IAEvH,qHAAqH;IACrH,OAAO,KAAC,UAAU,IAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,kBAClI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAQ,IAAI,CAAC,SAAS,CAAE,KAAK,CAAE,EAAE,CAAA;YAC1E,gIAAgI;YAChI,OAAO,KAAC,qBAAqB,IAAkB,IAAI,EAAG,KAAK,EAAG,gBAAgB,EAAG,gBAAgB,EAAG,gBAAgB,EAAG,gBAAgB,IAAnG,QAAQ,CAAgG,CAAA;QAChJ,CAAC,CAAC,GACO,CAAA;AACjB,CAAC;AAED,eAAe,qBAAqB,CAAA"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ContentType } from '../../../types.js';
|
|
2
|
+
import type { CompositionNode, LeafPropsFactory, CompositionElementNode, NodePropsFactory, CompositionStructureNode } from './types.js';
|
|
2
3
|
export declare function isElementNode(node: CompositionNode<Record<string, any>>): node is CompositionElementNode<Record<string, any>>;
|
|
3
4
|
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>;
|
|
4
5
|
export declare function isStructureNode(node: CompositionNode<Record<string, any>>): node is CompositionStructureNode;
|
|
5
6
|
export declare function isNode(toTest: any): toTest is CompositionNode;
|
|
7
|
+
export declare function isContentType(toTest: any): toTest is ContentType;
|
|
8
|
+
export declare const defaultPropsFactory: LeafPropsFactory;
|
|
9
|
+
export declare const defaultNodePropsFactory: NodePropsFactory;
|
|
10
|
+
export declare function ucFirst(input: string | undefined | null): string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isContentLink, isInlineContentLink } from '@remkoj/optimizely-graph-client';
|
|
1
2
|
export function isElementNode(node) {
|
|
2
3
|
return node.layoutType == "element";
|
|
3
4
|
}
|
|
@@ -12,9 +13,63 @@ export function isStructureNode(node) {
|
|
|
12
13
|
export function isNode(toTest) {
|
|
13
14
|
if (typeof (toTest) != 'object' || toTest == null)
|
|
14
15
|
return false;
|
|
15
|
-
const nodeTypes = ["experience", "
|
|
16
|
+
const nodeTypes = ["experience", "section", "row", "column", "element"];
|
|
16
17
|
const hasValidName = (typeof toTest.name == 'string' && (toTest.name?.length ?? 0) > 0) || toTest.name == null;
|
|
17
18
|
const hasValidType = typeof toTest.layoutType == 'string' && nodeTypes.includes(toTest.layoutType);
|
|
18
19
|
return hasValidName && hasValidType;
|
|
19
20
|
}
|
|
21
|
+
export function isContentType(toTest) {
|
|
22
|
+
return Array.isArray(toTest) && toTest.every(x => typeof (x) == 'string' && x.length > 0);
|
|
23
|
+
}
|
|
24
|
+
export const defaultPropsFactory = (node) => {
|
|
25
|
+
const contentType = node.element?._metadata?.types;
|
|
26
|
+
if (!isContentType(contentType))
|
|
27
|
+
throw new Error("Invalid content type: " + JSON.stringify(contentType));
|
|
28
|
+
const contentLink = {
|
|
29
|
+
key: node.element?._metadata?.key || node.key || undefined,
|
|
30
|
+
version: node.element?._metadata?.version,
|
|
31
|
+
locale: node.element?._metadata?.locale
|
|
32
|
+
};
|
|
33
|
+
if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
|
|
34
|
+
throw new Error("Invalid content link: " + JSON.stringify(contentLink));
|
|
35
|
+
const layoutData = {
|
|
36
|
+
type: node.type,
|
|
37
|
+
layoutType: node.layoutType,
|
|
38
|
+
template: node.template,
|
|
39
|
+
settings: node.settings
|
|
40
|
+
};
|
|
41
|
+
return [contentLink, contentType, node.element, layoutData];
|
|
42
|
+
};
|
|
43
|
+
export const defaultNodePropsFactory = (node) => {
|
|
44
|
+
const componentTypes = [
|
|
45
|
+
// New style logic
|
|
46
|
+
node.template && [node.template, ucFirst(node.type), ucFirst(node.layoutType), "Content"].filter(x => x),
|
|
47
|
+
[ucFirst(node.type), ucFirst(node.layoutType), "Content"].filter(x => x),
|
|
48
|
+
node.template && [node.template, ucFirst(node.layoutType), "Content"].filter(x => x),
|
|
49
|
+
node.template && [node.template, "Styles", ucFirst(node.layoutType), "Content"].filter(x => x),
|
|
50
|
+
node.template && [node.template, ucFirst(node.layoutType), "Nodes", "Content"].filter(x => x),
|
|
51
|
+
// Old style logic
|
|
52
|
+
[node.template, ucFirst(node.type), ucFirst(node.layoutType), "Component", "Content"].filter(x => x),
|
|
53
|
+
(node.template && node.type) ? [node.type ? ucFirst(node.type) : null, ucFirst(node.layoutType), "Component", "Content"].filter(x => x) : null,
|
|
54
|
+
// Fallback
|
|
55
|
+
["Node", "Content"],
|
|
56
|
+
["Node", "Component", "Content"]
|
|
57
|
+
].filter(x => x);
|
|
58
|
+
const contentLink = { key: node.key ?? '' };
|
|
59
|
+
const componentData = {};
|
|
60
|
+
const layoutData = {
|
|
61
|
+
type: node.type,
|
|
62
|
+
layoutType: node.layoutType,
|
|
63
|
+
template: node.template,
|
|
64
|
+
settings: node.settings
|
|
65
|
+
};
|
|
66
|
+
if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
|
|
67
|
+
throw new Error("🔴 [VisualBuilder] Invalid content link: " + JSON.stringify(contentLink) + " - Node: " + JSON.stringify(node));
|
|
68
|
+
return [contentLink, componentTypes, componentData, layoutData];
|
|
69
|
+
};
|
|
70
|
+
export function ucFirst(input) {
|
|
71
|
+
if (typeof (input) == 'string' && input.length > 0)
|
|
72
|
+
return input[0].toUpperCase() + input.substring(1);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
20
75
|
//# sourceMappingURL=functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../src/server/components/visual-builder/functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../src/server/components/visual-builder/functions.ts"],"names":[],"mappings":"AACA,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,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,QA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,CAAC,WAAW,CAAC,IAAI,mBAAmB,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,2CAA2C,GAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAE,WAAW,GAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAE/H,OAAO,CAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,CAAE,CAAA;AACrE,CAAC,CAAA;AAED,MAAM,UAAU,OAAO,CAAC,KAAgC;IAEpD,IAAI,OAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAC7C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACtD,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -2,8 +2,8 @@ import { type ComponentType, type PropsWithChildren } from "react";
|
|
|
2
2
|
import { type ContentType } from "../../../types.js";
|
|
3
3
|
import { type InlineContentLinkWithLocale, type ContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
|
|
4
4
|
export declare enum StructureNodeTypes {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Experience = "experience",
|
|
6
|
+
Section = "section",
|
|
7
7
|
Row = "row",
|
|
8
8
|
Column = "column"
|
|
9
9
|
}
|
|
@@ -18,7 +18,7 @@ export type CompositionNodeBase = {
|
|
|
18
18
|
} | null> | null;
|
|
19
19
|
};
|
|
20
20
|
export type CompositionStructureNode = CompositionNodeBase & {
|
|
21
|
-
layoutType: "
|
|
21
|
+
layoutType: "experience" | "section" | "row" | "column";
|
|
22
22
|
nodes?: Array<CompositionNode>;
|
|
23
23
|
};
|
|
24
24
|
export type CompositionElementNode<E extends Record<string, any> = Record<string, any>> = CompositionNodeBase & {
|
|
@@ -34,9 +34,19 @@ export type CompositionComponentType<NT extends CompositionNode> = ComponentType
|
|
|
34
34
|
}>>;
|
|
35
35
|
export type LeafPropsFactory = <ET extends Record<string, any>, LT = string>(node: CompositionElementNode<ET>) => [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, ContentType, ET] | [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, ContentType, ET, Record<string, any>];
|
|
36
36
|
export type NodePropsFactory = <ET extends Record<string, any>, LT = string>(node: CompositionStructureNode) => [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, Array<ContentType>, ET] | [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, Array<ContentType>, ET, Record<string, any>];
|
|
37
|
-
export type OptimizelyCompositionProps = {
|
|
37
|
+
export type OptimizelyCompositionProps = JSX.IntrinsicAttributes & {
|
|
38
|
+
/**
|
|
39
|
+
* The Visual Builder node to start rendering from
|
|
40
|
+
*/
|
|
38
41
|
node: CompositionNode<Record<string, any>>;
|
|
42
|
+
/**
|
|
43
|
+
* Allows overriding of the factory that transforms the data received from
|
|
44
|
+
* Optimizely Graph into properties for an element.
|
|
45
|
+
*/
|
|
39
46
|
leafPropsFactory?: LeafPropsFactory;
|
|
47
|
+
/**
|
|
48
|
+
* Allows overriding of the factory that transforms the data received from
|
|
49
|
+
* Optimizely Graph into properties for a structure node.
|
|
50
|
+
*/
|
|
40
51
|
nodePropsFactory?: NodePropsFactory;
|
|
41
|
-
key?: string;
|
|
42
52
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var StructureNodeTypes;
|
|
2
2
|
(function (StructureNodeTypes) {
|
|
3
|
-
StructureNodeTypes["
|
|
4
|
-
StructureNodeTypes["
|
|
3
|
+
StructureNodeTypes["Experience"] = "experience";
|
|
4
|
+
StructureNodeTypes["Section"] = "section";
|
|
5
5
|
StructureNodeTypes["Row"] = "row";
|
|
6
6
|
StructureNodeTypes["Column"] = "column";
|
|
7
7
|
})(StructureNodeTypes || (StructureNodeTypes = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/server/components/visual-builder/types.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC1B,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/server/components/visual-builder/types.ts"],"names":[],"mappings":"AAIA,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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { PropsWithChildren, ComponentType as ReactComponentType, ExoticComp
|
|
|
2
2
|
import type { DocumentNode } from "graphql";
|
|
3
3
|
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
4
4
|
import type { IOptiGraphClient } from "@remkoj/optimizely-graph-client";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ContentLinkWithLocale, InlineContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
|
|
6
6
|
export type ContentType = string[];
|
|
7
7
|
export type { ContentLink, ContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
|
|
8
8
|
export type CmsComponentProps<T, L extends Record<string, any> = Record<string, any>> = PropsWithChildren<{
|
|
@@ -23,8 +23,7 @@ export type CmsComponentProps<T, L extends Record<string, any> = Record<string,
|
|
|
23
23
|
*/
|
|
24
24
|
layoutProps?: L;
|
|
25
25
|
}>;
|
|
26
|
-
export type ContentQueryProps<LocaleType = string> =
|
|
27
|
-
locale?: Array<LocaleType> | LocaleType | null;
|
|
26
|
+
export type ContentQueryProps<LocaleType = string> = ContentLinkWithLocale<LocaleType> & {
|
|
28
27
|
path?: string | null;
|
|
29
28
|
domain?: string | null;
|
|
30
29
|
};
|
|
@@ -73,11 +72,43 @@ export type ComponentTypeDictionary = {
|
|
|
73
72
|
type: ComponentTypeHandle;
|
|
74
73
|
component: ComponentType;
|
|
75
74
|
}[];
|
|
75
|
+
/**
|
|
76
|
+
* Component Factory
|
|
77
|
+
*/
|
|
76
78
|
export interface ComponentFactory {
|
|
79
|
+
/**
|
|
80
|
+
* Check if the component type has been registered within the factory
|
|
81
|
+
*
|
|
82
|
+
* @param type The component type to check for
|
|
83
|
+
* @returns Whether or not the type exists within the factory
|
|
84
|
+
*/
|
|
77
85
|
has(type: ComponentTypeHandle): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Register an individual component
|
|
88
|
+
* @param type The component type to register
|
|
89
|
+
* @param componentType The component to bind to the type
|
|
90
|
+
*/
|
|
78
91
|
register(type: ComponentTypeHandle, componentType: ComponentType): void;
|
|
92
|
+
/**
|
|
93
|
+
* Register all components provided through the dictionary
|
|
94
|
+
*
|
|
95
|
+
* @param components The components to register
|
|
96
|
+
*/
|
|
79
97
|
registerAll(components: ComponentTypeDictionary): void;
|
|
98
|
+
/**
|
|
99
|
+
* Resolve a component type
|
|
100
|
+
*
|
|
101
|
+
* @param type The type to search the component for
|
|
102
|
+
* @returns The component that was resolved for the provided type
|
|
103
|
+
*/
|
|
80
104
|
resolve(type: ComponentTypeHandle): ComponentType | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Retrieve the registered components as a dictionary that can be used to
|
|
107
|
+
* be imported in a new instance.
|
|
108
|
+
*
|
|
109
|
+
* @returns The dictionary
|
|
110
|
+
*/
|
|
111
|
+
extract(): ComponentTypeDictionary;
|
|
81
112
|
}
|
|
82
113
|
export interface GenericContext {
|
|
83
114
|
readonly client?: IOptiGraphClient;
|
package/dist/utilities.d.ts
CHANGED
|
@@ -4,7 +4,28 @@ import type { DocumentNode } from 'graphql';
|
|
|
4
4
|
export declare function isNonEmptyString(toTest: any): toTest is string;
|
|
5
5
|
export declare function isNotNullOrUndefined<T>(toTest?: T | null): toTest is T;
|
|
6
6
|
export declare function isContentType(toTest: any): toTest is Types.ContentType;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes the content type by:
|
|
9
|
+
* - Converting strings to ContentType
|
|
10
|
+
* - Stripping the leading underscore, if any
|
|
11
|
+
*
|
|
12
|
+
* @param toNormalize The Content Type value to process
|
|
13
|
+
* @param stripContent When set to true, the global base type "Content" will be removed as well
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeContentType(toNormalize: (string | null)[] | string | null | undefined, stripContent?: boolean): Types.ContentType | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes and prefixes the content type by:
|
|
19
|
+
* - Converting strings to ContentType
|
|
20
|
+
* - Stripping the leading underscore, if any
|
|
21
|
+
* - Removing the global base type "Content"
|
|
22
|
+
* - Ensuring that in the remaining type the least specific type is equal to the provided prefix
|
|
23
|
+
*
|
|
24
|
+
* @param contentType
|
|
25
|
+
* @param prefix
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeAndPrefixContentType(contentType: Array<string | null> | string | null | undefined, prefix: string): Types.ContentType;
|
|
8
29
|
export declare function isCmsComponentWithDataQuery<T = DocumentNode>(toTest?: Types.BaseCmsComponent<T>): toTest is Types.CmsComponentWithQuery<T>;
|
|
9
30
|
export declare function isCmsComponentWithFragment<T = DocumentNode>(toTest?: Types.BaseCmsComponent<T>): toTest is Types.CmsComponentWithFragment<T>;
|
|
10
31
|
export declare function validatesFragment<T extends ComponentType<any>>(toTest?: T): toTest is T & Pick<Required<Types.WithGqlFragment<T, any>>, "validateFragment">;
|
package/dist/utilities.js
CHANGED
|
@@ -10,12 +10,42 @@ export function isContentType(toTest) {
|
|
|
10
10
|
return false;
|
|
11
11
|
return toTest.every(isNonEmptyString);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes the content type by:
|
|
15
|
+
* - Converting strings to ContentType
|
|
16
|
+
* - Stripping the leading underscore, if any
|
|
17
|
+
*
|
|
18
|
+
* @param toNormalize The Content Type value to process
|
|
19
|
+
* @param stripContent When set to true, the global base type "Content" will be removed as well
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export function normalizeContentType(toNormalize, stripContent = false) {
|
|
23
|
+
if (!toNormalize)
|
|
15
24
|
return undefined;
|
|
16
|
-
|
|
25
|
+
let filtered = (typeof (toNormalize) == 'string' ? toNormalize.split('/') : toNormalize).filter(isNonEmptyString).map(x => x.startsWith('_') ? x.substring(1) : x);
|
|
26
|
+
if (stripContent)
|
|
27
|
+
filtered = filtered.filter(x => x.toLowerCase() != 'content');
|
|
17
28
|
return filtered.length > 0 ? filtered : undefined;
|
|
18
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Normalizes and prefixes the content type by:
|
|
32
|
+
* - Converting strings to ContentType
|
|
33
|
+
* - Stripping the leading underscore, if any
|
|
34
|
+
* - Removing the global base type "Content"
|
|
35
|
+
* - Ensuring that in the remaining type the least specific type is equal to the provided prefix
|
|
36
|
+
*
|
|
37
|
+
* @param contentType
|
|
38
|
+
* @param prefix
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export function normalizeAndPrefixContentType(contentType, prefix) {
|
|
42
|
+
if (!contentType)
|
|
43
|
+
return [prefix];
|
|
44
|
+
const processedContentType = (typeof (contentType) == 'string' ? contentType.split('/') : contentType).filter(isNonEmptyString).map(x => x.startsWith('_') ? x.substring(1) : x).filter(x => x.toLowerCase() != 'content');
|
|
45
|
+
if (processedContentType[0] != prefix)
|
|
46
|
+
processedContentType.unshift(prefix);
|
|
47
|
+
return processedContentType;
|
|
48
|
+
}
|
|
19
49
|
export function isCmsComponentWithDataQuery(toTest) {
|
|
20
50
|
const toTestType = typeof (toTest);
|
|
21
51
|
if ((toTestType == 'function' || toTestType == 'object') && toTest != null) {
|
package/dist/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAGA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1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remkoj/optimizely-cms-react",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1-pre1",
|
|
5
5
|
"packageManager": "yarn@4.1.1",
|
|
6
6
|
"repository": "https://github.com/remkoj/optimizely-dxp-clients.git",
|
|
7
7
|
"author": "Remko Jantzen <693172+remkoj@users.noreply.github.com>",
|
|
@@ -40,25 +40,27 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@remkoj/optimizely-graph-client": "2.0.
|
|
43
|
+
"@remkoj/optimizely-graph-client": "2.0.1-pre1",
|
|
44
44
|
"@types/crypto-js": "^4.2.2",
|
|
45
|
-
"@types/node": "^20.14.
|
|
45
|
+
"@types/node": "^20.14.9",
|
|
46
46
|
"@types/react": "^18.3.3",
|
|
47
47
|
"@types/react-dom": "18.3.0",
|
|
48
|
-
"
|
|
48
|
+
"entities": "^4.5.0",
|
|
49
|
+
"graphql": "^16.9.0",
|
|
49
50
|
"graphql-request": "^6.1.0",
|
|
50
51
|
"prop-types": "^15.8.1",
|
|
51
52
|
"react": "^18.3.1",
|
|
52
53
|
"react-dom": "^18.3.1",
|
|
53
54
|
"scheduler": "^0.23.2",
|
|
54
|
-
"typescript": "^5.
|
|
55
|
+
"typescript": "^5.5.2"
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
58
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
58
59
|
"crypto-js": "^4.2.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
|
-
"@remkoj/optimizely-graph-client": "2.0.
|
|
62
|
+
"@remkoj/optimizely-graph-client": "2.0.1-pre1",
|
|
63
|
+
"entities": "*",
|
|
62
64
|
"graphql": "^16.8.1",
|
|
63
65
|
"graphql-request": "^6.1.0",
|
|
64
66
|
"react": "*",
|
|
@@ -70,5 +72,5 @@
|
|
|
70
72
|
"watch": "tsc --watch",
|
|
71
73
|
"recompile": "tsc --build --clean && tsc --build --force"
|
|
72
74
|
},
|
|
73
|
-
"stableVersion": "
|
|
75
|
+
"stableVersion": "2.0.1"
|
|
74
76
|
}
|