@uniformdev/canvas-next-rsc 19.69.0 → 19.73.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/dist/UniformComposition-38e22896.d.ts +61 -0
- package/dist/component.d.mts +76 -0
- package/dist/component.d.ts +76 -0
- package/dist/component.js +218 -0
- package/dist/component.mjs +182 -0
- package/dist/config.d.mts +6 -0
- package/dist/config.d.ts +6 -1
- package/dist/config.js +56 -29
- package/dist/config.mjs +41 -0
- package/dist/handler.d.mts +12 -0
- package/dist/handler.d.ts +12 -2
- package/dist/handler.js +703 -2
- package/dist/handler.mjs +682 -0
- package/dist/{client/manifestClient.d.ts → index.d.mts} +100 -18
- package/dist/index.d.ts +243 -23
- package/dist/index.esm.js +977 -0
- package/dist/index.js +1013 -29
- package/dist/index.mjs +977 -0
- package/package.json +23 -15
- package/dist/actions/updateContext.d.ts +0 -2
- package/dist/actions/updateContext.js +0 -17
- package/dist/client/canvasClient.d.ts +0 -5
- package/dist/client/canvasClient.js +0 -53
- package/dist/client/manifestClient.js +0 -33
- package/dist/client/projectMapClient.d.ts +0 -5
- package/dist/client/projectMapClient.js +0 -17
- package/dist/client/routeClient.d.ts +0 -5
- package/dist/client/routeClient.js +0 -68
- package/dist/components/DefaultNotImplementedComponent.d.ts +0 -2
- package/dist/components/DefaultNotImplementedComponent.js +0 -45
- package/dist/components/GoogleTagManagerAnalytics.d.ts +0 -3
- package/dist/components/GoogleTagManagerAnalytics.js +0 -44
- package/dist/components/UniformComponent.d.ts +0 -25
- package/dist/components/UniformComponent.js +0 -14
- package/dist/components/UniformComposition.d.ts +0 -40
- package/dist/components/UniformComposition.js +0 -35
- package/dist/components/UniformContext.d.ts +0 -8
- package/dist/components/UniformContext.js +0 -19
- package/dist/components/UniformRichText.d.ts +0 -38
- package/dist/components/UniformRichText.js +0 -15
- package/dist/components/UniformRichTextNode.d.ts +0 -10
- package/dist/components/UniformRichTextNode.js +0 -49
- package/dist/components/UniformScript.d.ts +0 -3
- package/dist/components/UniformScript.js +0 -49
- package/dist/components/UniformSlot.d.ts +0 -40
- package/dist/components/UniformSlot.js +0 -38
- package/dist/components/UniformText.d.ts +0 -6
- package/dist/components/UniformText.js +0 -5
- package/dist/components/__tests__/evaluateComposition.spec.d.ts +0 -1
- package/dist/components/__tests__/evaluateComposition.spec.js +0 -80
- package/dist/components/convertComponentToProps.d.ts +0 -14
- package/dist/components/convertComponentToProps.js +0 -22
- package/dist/components/evaluateComposition.d.ts +0 -22
- package/dist/components/evaluateComposition.js +0 -183
- package/dist/components/getEnrichmentTags.d.ts +0 -3
- package/dist/components/getEnrichmentTags.js +0 -13
- package/dist/components/getUniformContext.d.ts +0 -6
- package/dist/components/getUniformContext.js +0 -17
- package/dist/components/nodes/HeadingRichTextNode.d.ts +0 -2
- package/dist/components/nodes/HeadingRichTextNode.js +0 -6
- package/dist/components/nodes/LinebreakRichTextNode.d.ts +0 -2
- package/dist/components/nodes/LinebreakRichTextNode.js +0 -4
- package/dist/components/nodes/LinkRichTextNode.d.ts +0 -2
- package/dist/components/nodes/LinkRichTextNode.js +0 -6
- package/dist/components/nodes/ListItemRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ListItemRichTextNode.js +0 -5
- package/dist/components/nodes/ListRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ListRichTextNode.js +0 -6
- package/dist/components/nodes/ParagraphRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ParagraphRichTextNode.js +0 -6
- package/dist/components/nodes/TabRichTextNode.d.ts +0 -2
- package/dist/components/nodes/TabRichTextNode.js +0 -4
- package/dist/components/nodes/TextRichTextNode.d.ts +0 -2
- package/dist/components/nodes/TextRichTextNode.js +0 -9
- package/dist/components/renderComponent.d.ts +0 -15
- package/dist/components/renderComponent.js +0 -52
- package/dist/components/resolvePath.d.ts +0 -5
- package/dist/components/resolvePath.js +0 -34
- package/dist/components/retrieveRoute.d.ts +0 -141
- package/dist/components/retrieveRoute.js +0 -146
- package/dist/components/types.d.ts +0 -11
- package/dist/components/types.js +0 -1
- package/dist/config/helpers.d.ts +0 -17
- package/dist/config/helpers.js +0 -34
- package/dist/config/models.d.ts +0 -51
- package/dist/config/models.js +0 -1
- package/dist/cookie/index.d.ts +0 -12
- package/dist/cookie/index.js +0 -21
- package/dist/handler/createPreviewGETRouteHandler.d.ts +0 -1
- package/dist/handler/createPreviewGETRouteHandler.js +0 -43
- package/dist/handler/createPreviewPOSTRouteHandler.d.ts +0 -1
- package/dist/handler/createPreviewPOSTRouteHandler.js +0 -88
- package/dist/handler/createUniformRouteHandler.d.ts +0 -4
- package/dist/handler/createUniformRouteHandler.js +0 -10
- package/dist/handler/helpers.d.ts +0 -19
- package/dist/handler/helpers.js +0 -148
- package/dist/handler/messages/handleCompositionChanged.d.ts +0 -2
- package/dist/handler/messages/handleCompositionChanged.js +0 -9
- package/dist/handler/messages/handleCompositionDeleted.d.ts +0 -2
- package/dist/handler/messages/handleCompositionDeleted.js +0 -9
- package/dist/handler/messages/handleCompositionPublished.d.ts +0 -2
- package/dist/handler/messages/handleCompositionPublished.js +0 -9
- package/dist/handler/messages/handleManifestPublished.d.ts +0 -2
- package/dist/handler/messages/handleManifestPublished.js +0 -10
- package/dist/handler/messages/handleProjectMapNodeDelete.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeDelete.js +0 -21
- package/dist/handler/messages/handleProjectMapNodeInsert.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeInsert.js +0 -21
- package/dist/handler/messages/handleProjectMapNodeUpdate.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeUpdate.js +0 -22
- package/dist/handler/messages/handleRedirectDelete.d.ts +0 -2
- package/dist/handler/messages/handleRedirectDelete.js +0 -15
- package/dist/handler/messages/handleRedirectInsert.d.ts +0 -2
- package/dist/handler/messages/handleRedirectInsert.js +0 -15
- package/dist/handler/messages/handleRedirectUpdate.d.ts +0 -2
- package/dist/handler/messages/handleRedirectUpdate.js +0 -15
- package/dist/hooks/useForgetMe.d.ts +0 -4
- package/dist/hooks/useForgetMe.js +0 -10
- package/dist/hooks/useToggleConsent.d.ts +0 -7
- package/dist/hooks/useToggleConsent.js +0 -22
- package/dist/hooks/useUniformContext.d.ts +0 -1
- package/dist/hooks/useUniformContext.js +0 -3
- package/dist/models/index.d.ts +0 -30
- package/dist/models/index.js +0 -1
- package/dist/register/componentStore.d.ts +0 -1
- package/dist/register/componentStore.js +0 -2
- package/dist/register/componentStoreResolver.d.ts +0 -2
- package/dist/register/componentStoreResolver.js +0 -5
- package/dist/register/createComponentStore.d.ts +0 -12
- package/dist/register/createComponentStore.js +0 -13
- package/dist/register/createComponentStoreResolver.d.ts +0 -9
- package/dist/register/createComponentStoreResolver.js +0 -9
- package/dist/register/getTypeWithVariant.d.ts +0 -1
- package/dist/register/getTypeWithVariant.js +0 -1
- package/dist/register/registerUniformComponent.d.ts +0 -6
- package/dist/register/registerUniformComponent.js +0 -8
- package/dist/resolve/resolveChildren.d.ts +0 -10
- package/dist/resolve/resolveChildren.js +0 -20
- package/dist/score/index.d.ts +0 -3
- package/dist/score/index.js +0 -114
- package/dist/utils/__tests__/apply.spec.d.ts +0 -1
- package/dist/utils/__tests__/apply.spec.js +0 -358
- package/dist/utils/__tests__/diff.spec.d.ts +0 -1
- package/dist/utils/__tests__/diff.spec.js +0 -394
- package/dist/utils/apply.d.ts +0 -6
- package/dist/utils/apply.js +0 -124
- package/dist/utils/comp.d.ts +0 -16
- package/dist/utils/comp.js +0 -65
- package/dist/utils/diff.d.ts +0 -44
- package/dist/utils/diff.js +0 -144
- package/dist/utils/draft.d.ts +0 -12
- package/dist/utils/draft.js +0 -22
- package/dist/utils/tag.d.ts +0 -2
- package/dist/utils/tag.js +0 -7
- package/dist/utils/url.d.ts +0 -1
- package/dist/utils/url.js +0 -10
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RenderComponentResolver } from '@uniformdev/canvas-react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { CompositionContext, UniformComponentProps } from '../components/UniformComponent';
|
|
4
|
-
export declare function resolveChildren<TRenderProps = unknown>({ children, data, context, hasParentLayout, resolveRenderer, }: {
|
|
5
|
-
children: UniformComponentProps<TRenderProps>['children'];
|
|
6
|
-
data: Required<UniformComponentProps<TRenderProps>>['data'];
|
|
7
|
-
context: CompositionContext;
|
|
8
|
-
hasParentLayout: boolean;
|
|
9
|
-
resolveRenderer: RenderComponentResolver;
|
|
10
|
-
}): ReactNode;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createElement } from 'react';
|
|
3
|
-
import { convertComponentToProps } from '../components/convertComponentToProps';
|
|
4
|
-
import { UniformSlot } from '../components/UniformSlot';
|
|
5
|
-
export function resolveChildren({ children, data, context, hasParentLayout, resolveRenderer, }) {
|
|
6
|
-
// attempt to resolve the top level component if we're at the root and children were not provided
|
|
7
|
-
if (!children && !hasParentLayout) {
|
|
8
|
-
const topLevelComponent = resolveRenderer({ type: data.type });
|
|
9
|
-
if (topLevelComponent) {
|
|
10
|
-
children = createElement(topLevelComponent, convertComponentToProps({ component: data, context }));
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
children = Object.keys(data.slots || {}).map((slotName) => (_jsx(UniformSlot, { name: slotName, data: data, context: context }, slotName)));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const renderChildren = typeof children === 'function'
|
|
17
|
-
? children(convertComponentToProps({ component: data, context }))
|
|
18
|
-
: children;
|
|
19
|
-
return renderChildren;
|
|
20
|
-
}
|
package/dist/score/index.d.ts
DELETED
package/dist/score/index.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
const TYPE_SEP = '~';
|
|
2
|
-
const PAIR_SEP = '!';
|
|
3
|
-
const KV_SEP = '-';
|
|
4
|
-
// the cookie format is thus:
|
|
5
|
-
// <ab-test-data>~<session-scores>~<visitor-scores>
|
|
6
|
-
// where each type is subdivided into key-value pairs:
|
|
7
|
-
// <k>-<v>!<k>-<v>!...
|
|
8
|
-
// score data is further encoded into base64, so the scores themselves are compressed
|
|
9
|
-
// example:
|
|
10
|
-
// mytest-var1!mytest2-var2~ses1-x!ses2-1~vis1-fa~vis2-10
|
|
11
|
-
// means:
|
|
12
|
-
// mytest test: var1 variant
|
|
13
|
-
// mytest2 test: var2 variant
|
|
14
|
-
// ses1 session signal: bton(x) score
|
|
15
|
-
// ses2 session signal: bton(1) score
|
|
16
|
-
// vis1 visitor signal: bton(fa) score
|
|
17
|
-
// vis2 visitor signal: bton(10) score;
|
|
18
|
-
export function parseScoreCookie(cookieValue) {
|
|
19
|
-
if (!cookieValue)
|
|
20
|
-
return;
|
|
21
|
-
const types = cookieValue.split(TYPE_SEP);
|
|
22
|
-
if (types.length > 3)
|
|
23
|
-
return;
|
|
24
|
-
const [abTestData, sessionScores, visitorScores] = types;
|
|
25
|
-
return {
|
|
26
|
-
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
|
27
|
-
consent: true,
|
|
28
|
-
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
|
29
|
-
scores: decodeCookieType(parseCookieType(visitorScores)),
|
|
30
|
-
tests: parseCookieType(abTestData),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function parseCookieType(type) {
|
|
34
|
-
if (!type) {
|
|
35
|
-
return {};
|
|
36
|
-
}
|
|
37
|
-
const pairs = type.split(PAIR_SEP).map((pair) => pair.split(KV_SEP));
|
|
38
|
-
return pairs.reduce((acc, cur) => {
|
|
39
|
-
if (cur.length < 2)
|
|
40
|
-
return acc;
|
|
41
|
-
// join handles the case when there is a pair separator in the value,
|
|
42
|
-
// i.e. testname-testid-with-hyphens
|
|
43
|
-
acc[cur[0]] = cur.slice(1).join('-');
|
|
44
|
-
return acc;
|
|
45
|
-
}, {});
|
|
46
|
-
}
|
|
47
|
-
function decodeCookieType(type) {
|
|
48
|
-
return Object.entries(type).reduce((acc, [key, value]) => {
|
|
49
|
-
acc[key] = bton(value);
|
|
50
|
-
return acc;
|
|
51
|
-
}, {});
|
|
52
|
-
}
|
|
53
|
-
export function serializeCookie(data) {
|
|
54
|
-
return [
|
|
55
|
-
serializeCookieType(data.tests),
|
|
56
|
-
serializeCookieType(encodeCookieType(data.sessionScores)),
|
|
57
|
-
serializeCookieType(encodeCookieType(data.scores)),
|
|
58
|
-
].join(TYPE_SEP);
|
|
59
|
-
}
|
|
60
|
-
function encodeCookieType(type) {
|
|
61
|
-
return Object.entries(type).reduce((acc, [key, value]) => {
|
|
62
|
-
acc[key] = ntob(value);
|
|
63
|
-
return acc;
|
|
64
|
-
}, {});
|
|
65
|
-
}
|
|
66
|
-
function serializeCookieType(type) {
|
|
67
|
-
return Object.entries(type)
|
|
68
|
-
.map((kv) => kv.join(KV_SEP))
|
|
69
|
-
.join(PAIR_SEP);
|
|
70
|
-
}
|
|
71
|
-
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
72
|
-
// binary to string lookup table
|
|
73
|
-
const b2s = alphabet.split('');
|
|
74
|
-
// string to binary lookup table
|
|
75
|
-
// 123 == 'z'.charCodeAt(0) + 1
|
|
76
|
-
const s2b = new Array(123);
|
|
77
|
-
for (let i = 0; i < alphabet.length; i++) {
|
|
78
|
-
s2b[alphabet.charCodeAt(i)] = i;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Converts a number to a base64 string of its representation.
|
|
82
|
-
* Compresses the number if it is to be transferred in a string representation.
|
|
83
|
-
*/
|
|
84
|
-
const ntob = (number) => {
|
|
85
|
-
if (number < 0)
|
|
86
|
-
return `-${ntob(-number)}`;
|
|
87
|
-
let lo = number >>> 0;
|
|
88
|
-
let hi = (number / 4294967296) >>> 0;
|
|
89
|
-
let right = '';
|
|
90
|
-
while (hi > 0) {
|
|
91
|
-
right = b2s[0x3f & lo] + right;
|
|
92
|
-
lo >>>= 6;
|
|
93
|
-
lo |= (0x3f & hi) << 26;
|
|
94
|
-
hi >>>= 6;
|
|
95
|
-
}
|
|
96
|
-
let left = '';
|
|
97
|
-
do {
|
|
98
|
-
left = b2s[0x3f & lo] + left;
|
|
99
|
-
lo >>>= 6;
|
|
100
|
-
} while (lo > 0);
|
|
101
|
-
return left + right;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Converts a base64 string to an equivalent number _represented as a string in base64_.
|
|
105
|
-
* Decompresses a number from the compressed base64 string.
|
|
106
|
-
*/
|
|
107
|
-
const bton = (base64) => {
|
|
108
|
-
let number = 0;
|
|
109
|
-
const sign = base64.charAt(0) === '-' ? 1 : 0;
|
|
110
|
-
for (let i = sign; i < base64.length; i++) {
|
|
111
|
-
number = number * 64 + s2b[base64.charCodeAt(i)];
|
|
112
|
-
}
|
|
113
|
-
return sign ? -number : number;
|
|
114
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import { applyDiff } from '../apply';
|
|
2
|
-
import { ComponentDiffType } from '../diff';
|
|
3
|
-
describe('apply', () => {
|
|
4
|
-
it('should leave a composition alone if the diff is blank', () => {
|
|
5
|
-
const result = applyDiff({
|
|
6
|
-
composition: {
|
|
7
|
-
_id: 'root',
|
|
8
|
-
_name: 'root',
|
|
9
|
-
type: 'root',
|
|
10
|
-
},
|
|
11
|
-
diff: [],
|
|
12
|
-
});
|
|
13
|
-
expect(result).toEqual({
|
|
14
|
-
_id: 'root',
|
|
15
|
-
_name: 'root',
|
|
16
|
-
type: 'root',
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
it('should add a slot component if diff specifies one', () => {
|
|
20
|
-
const result = applyDiff({
|
|
21
|
-
composition: {
|
|
22
|
-
_id: 'root',
|
|
23
|
-
_name: 'root',
|
|
24
|
-
type: 'root',
|
|
25
|
-
slots: {
|
|
26
|
-
content: [],
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
diff: [
|
|
30
|
-
{
|
|
31
|
-
type: ComponentDiffType.ComponentAdded,
|
|
32
|
-
id: 'child',
|
|
33
|
-
parentId: 'root',
|
|
34
|
-
slot: 'content',
|
|
35
|
-
slotIndex: 0,
|
|
36
|
-
component: {
|
|
37
|
-
type: 'child',
|
|
38
|
-
_id: 'child',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
});
|
|
43
|
-
expect(result).toEqual({
|
|
44
|
-
_id: 'root',
|
|
45
|
-
_name: 'root',
|
|
46
|
-
type: 'root',
|
|
47
|
-
slots: {
|
|
48
|
-
content: [
|
|
49
|
-
{
|
|
50
|
-
_id: 'child',
|
|
51
|
-
type: 'child',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
it('should remove a slot component if diff specifies one', () => {
|
|
58
|
-
const result = applyDiff({
|
|
59
|
-
composition: {
|
|
60
|
-
_id: 'root',
|
|
61
|
-
_name: 'root',
|
|
62
|
-
type: 'root',
|
|
63
|
-
slots: {
|
|
64
|
-
content: [
|
|
65
|
-
{
|
|
66
|
-
type: 'child1',
|
|
67
|
-
_id: 'child',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: 'child',
|
|
71
|
-
_id: 'child2',
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
diff: [
|
|
77
|
-
{
|
|
78
|
-
type: ComponentDiffType.ComponentRemoved,
|
|
79
|
-
id: 'child',
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
});
|
|
83
|
-
expect(result).toEqual({
|
|
84
|
-
_id: 'root',
|
|
85
|
-
_name: 'root',
|
|
86
|
-
type: 'root',
|
|
87
|
-
slots: {
|
|
88
|
-
content: [
|
|
89
|
-
{
|
|
90
|
-
type: 'child',
|
|
91
|
-
_id: 'child2',
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
it('should move a slot component if diff specifies one', () => {
|
|
98
|
-
const result = applyDiff({
|
|
99
|
-
composition: {
|
|
100
|
-
_id: 'root',
|
|
101
|
-
_name: 'root',
|
|
102
|
-
type: 'root',
|
|
103
|
-
slots: {
|
|
104
|
-
content: [
|
|
105
|
-
{
|
|
106
|
-
type: 'child',
|
|
107
|
-
_id: 'child1',
|
|
108
|
-
slots: {
|
|
109
|
-
content: [],
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
type: 'child',
|
|
114
|
-
_id: 'child2',
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
diff: [
|
|
120
|
-
{
|
|
121
|
-
type: ComponentDiffType.ComponentMoved,
|
|
122
|
-
id: 'child2',
|
|
123
|
-
parentId: 'child1',
|
|
124
|
-
slot: 'content',
|
|
125
|
-
slotIndex: 0,
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
});
|
|
129
|
-
expect(result).toEqual({
|
|
130
|
-
_id: 'root',
|
|
131
|
-
_name: 'root',
|
|
132
|
-
type: 'root',
|
|
133
|
-
slots: {
|
|
134
|
-
content: [
|
|
135
|
-
{
|
|
136
|
-
type: 'child',
|
|
137
|
-
_id: 'child1',
|
|
138
|
-
slots: {
|
|
139
|
-
content: [
|
|
140
|
-
{
|
|
141
|
-
type: 'child',
|
|
142
|
-
_id: 'child2',
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
it('should move a slot component if diff specifies one, even if target does not define slot', () => {
|
|
152
|
-
const result = applyDiff({
|
|
153
|
-
composition: {
|
|
154
|
-
_id: 'root',
|
|
155
|
-
_name: 'root',
|
|
156
|
-
type: 'root',
|
|
157
|
-
slots: {
|
|
158
|
-
content: [
|
|
159
|
-
{
|
|
160
|
-
type: 'child',
|
|
161
|
-
_id: 'child1',
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
type: 'child',
|
|
165
|
-
_id: 'child2',
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
diff: [
|
|
171
|
-
{
|
|
172
|
-
type: ComponentDiffType.ComponentMoved,
|
|
173
|
-
id: 'child2',
|
|
174
|
-
parentId: 'child1',
|
|
175
|
-
slot: 'content',
|
|
176
|
-
slotIndex: 0,
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
});
|
|
180
|
-
expect(result).toEqual({
|
|
181
|
-
_id: 'root',
|
|
182
|
-
_name: 'root',
|
|
183
|
-
type: 'root',
|
|
184
|
-
slots: {
|
|
185
|
-
content: [
|
|
186
|
-
{
|
|
187
|
-
type: 'child',
|
|
188
|
-
_id: 'child1',
|
|
189
|
-
slots: {
|
|
190
|
-
content: [
|
|
191
|
-
{
|
|
192
|
-
type: 'child',
|
|
193
|
-
_id: 'child2',
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
it('should change a parameter if diff specifies one', () => {
|
|
203
|
-
const result = applyDiff({
|
|
204
|
-
composition: {
|
|
205
|
-
_id: 'root',
|
|
206
|
-
_name: 'root',
|
|
207
|
-
type: 'root',
|
|
208
|
-
parameters: {
|
|
209
|
-
title: {
|
|
210
|
-
type: 'text',
|
|
211
|
-
value: 'Hello',
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
diff: [
|
|
216
|
-
{
|
|
217
|
-
type: ComponentDiffType.ParameterChanged,
|
|
218
|
-
componentId: 'root',
|
|
219
|
-
parameterName: 'title',
|
|
220
|
-
value: 'Goodbye',
|
|
221
|
-
},
|
|
222
|
-
],
|
|
223
|
-
});
|
|
224
|
-
expect(result).toEqual({
|
|
225
|
-
_id: 'root',
|
|
226
|
-
_name: 'root',
|
|
227
|
-
type: 'root',
|
|
228
|
-
parameters: {
|
|
229
|
-
title: {
|
|
230
|
-
type: 'text',
|
|
231
|
-
value: 'Goodbye',
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
it('should delete a parameter if diff specifies one', () => {
|
|
237
|
-
const result = applyDiff({
|
|
238
|
-
composition: {
|
|
239
|
-
_id: 'root',
|
|
240
|
-
_name: 'root',
|
|
241
|
-
type: 'root',
|
|
242
|
-
parameters: {
|
|
243
|
-
title: {
|
|
244
|
-
type: 'text',
|
|
245
|
-
value: 'Hello',
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
diff: [
|
|
250
|
-
{
|
|
251
|
-
type: ComponentDiffType.ParameterRemoved,
|
|
252
|
-
componentId: 'root',
|
|
253
|
-
parameterName: 'title',
|
|
254
|
-
},
|
|
255
|
-
],
|
|
256
|
-
});
|
|
257
|
-
expect(result).toEqual({
|
|
258
|
-
_id: 'root',
|
|
259
|
-
_name: 'root',
|
|
260
|
-
type: 'root',
|
|
261
|
-
parameters: {},
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
it('should handle a component and move in a slot', () => {
|
|
265
|
-
const result = applyDiff({
|
|
266
|
-
composition: {
|
|
267
|
-
_id: 'root',
|
|
268
|
-
_name: 'root',
|
|
269
|
-
type: 'root',
|
|
270
|
-
slots: {
|
|
271
|
-
pageContent: [
|
|
272
|
-
{
|
|
273
|
-
type: 'hero',
|
|
274
|
-
_id: '1f352a25-7acb-4893-a11c-f06bd45f27ab',
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
type: 'hero',
|
|
278
|
-
_id: '93e9fa20-d86e-4543-9ca7-927ffeab6d54',
|
|
279
|
-
},
|
|
280
|
-
],
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
diff: [
|
|
284
|
-
{
|
|
285
|
-
type: ComponentDiffType.ComponentRemoved,
|
|
286
|
-
id: '1f352a25-7acb-4893-a11c-f06bd45f27ab',
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
type: ComponentDiffType.ComponentMoved,
|
|
290
|
-
id: '93e9fa20-d86e-4543-9ca7-927ffeab6d54',
|
|
291
|
-
slotIndex: 0,
|
|
292
|
-
parentId: undefined,
|
|
293
|
-
slot: undefined,
|
|
294
|
-
},
|
|
295
|
-
],
|
|
296
|
-
});
|
|
297
|
-
expect(result).toEqual({
|
|
298
|
-
_id: 'root',
|
|
299
|
-
_name: 'root',
|
|
300
|
-
type: 'root',
|
|
301
|
-
slots: {
|
|
302
|
-
pageContent: [
|
|
303
|
-
{
|
|
304
|
-
type: 'hero',
|
|
305
|
-
_id: '93e9fa20-d86e-4543-9ca7-927ffeab6d54',
|
|
306
|
-
},
|
|
307
|
-
],
|
|
308
|
-
},
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
it('should put components back into the correct position', () => {
|
|
312
|
-
const result = applyDiff({
|
|
313
|
-
composition: {
|
|
314
|
-
_id: 'root',
|
|
315
|
-
_name: 'root',
|
|
316
|
-
type: 'root',
|
|
317
|
-
slots: {
|
|
318
|
-
content: [
|
|
319
|
-
{
|
|
320
|
-
type: 'child',
|
|
321
|
-
_id: 'existing',
|
|
322
|
-
},
|
|
323
|
-
],
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
diff: [
|
|
327
|
-
{
|
|
328
|
-
type: ComponentDiffType.ComponentAdded,
|
|
329
|
-
id: 'child',
|
|
330
|
-
parentId: 'root',
|
|
331
|
-
slot: 'content',
|
|
332
|
-
slotIndex: 0,
|
|
333
|
-
component: {
|
|
334
|
-
type: 'child',
|
|
335
|
-
_id: 'child',
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
],
|
|
339
|
-
});
|
|
340
|
-
expect(result).toEqual({
|
|
341
|
-
_id: 'root',
|
|
342
|
-
_name: 'root',
|
|
343
|
-
type: 'root',
|
|
344
|
-
slots: {
|
|
345
|
-
content: [
|
|
346
|
-
{
|
|
347
|
-
_id: 'child',
|
|
348
|
-
type: 'child',
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
type: 'child',
|
|
352
|
-
_id: 'existing',
|
|
353
|
-
},
|
|
354
|
-
],
|
|
355
|
-
},
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|