@builder.io/sdk-react-nextjs 0.4.6-0 → 0.5.1
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 +32 -44
- package/dist/blocks/button/button.d.ts +1 -2
- package/dist/blocks/button/button.js +2 -2
- package/dist/blocks/columns/columns.js +6 -6
- package/dist/blocks/embed/component-info.js +2 -1
- package/dist/blocks/image/component-info.js +2 -1
- package/dist/blocks/image/image.js +8 -7
- package/dist/blocks/img/img.d.ts +1 -2
- package/dist/blocks/section/section.d.ts +1 -2
- package/dist/blocks/symbol/symbol.d.ts +2 -4
- package/dist/blocks/symbol/symbol.helpers.js +2 -1
- package/dist/blocks/symbol/symbol.js +3 -3
- package/dist/blocks/video/video.js +4 -1
- package/dist/components/block/block.helpers.js +5 -3
- package/dist/components/block/block.js +4 -4
- package/dist/components/block/components/block-styles.js +1 -1
- package/dist/components/block/components/block-wrapper.d.ts +1 -2
- package/dist/components/block/components/component-ref/component-ref.helpers.d.ts +1 -1
- package/dist/components/block/components/component-ref/component-ref.helpers.js +2 -1
- package/dist/components/block/components/component-ref/component-ref.js +3 -3
- package/dist/components/block/components/repeated-block.js +1 -1
- package/dist/components/blocks/blocks.d.ts +3 -3
- package/dist/components/blocks/blocks.js +3 -3
- package/dist/components/content/components/enable-editor.js +1 -1
- package/dist/components/content/components/styles.helpers.js +4 -2
- package/dist/components/content/components/styles.js +1 -1
- package/dist/components/content/content.helpers.js +10 -5
- package/dist/components/content/content.js +6 -4
- package/dist/components/content-variants/content-variants.js +3 -3
- package/dist/components/content-variants/helpers.js +2 -1
- package/dist/constants/builder-registered-components.js +11 -11
- package/dist/constants/sdk-version.d.ts +1 -1
- package/dist/constants/sdk-version.js +1 -1
- package/dist/context/components.context.d.ts +3 -0
- package/dist/context/components.context.js +2 -0
- package/dist/functions/evaluate/evaluate.d.ts +10 -0
- package/dist/functions/evaluate/evaluate.js +70 -0
- package/dist/functions/evaluate/index.d.ts +1 -0
- package/dist/functions/evaluate/index.js +1 -0
- package/dist/functions/evaluate/interpreter.d.ts +2 -0
- package/dist/functions/evaluate/interpreter.js +3853 -0
- package/dist/functions/evaluate/non-node-runtime.d.ts +2 -0
- package/dist/functions/evaluate/non-node-runtime.js +84 -0
- package/dist/functions/evaluate/types.d.ts +10 -0
- package/dist/functions/evaluate/types.js +1 -0
- package/dist/functions/extract-text-styles.js +2 -1
- package/dist/functions/get-block-actions-handler.js +1 -1
- package/dist/functions/get-block-component-options.js +4 -2
- package/dist/functions/get-block-properties.js +2 -1
- package/dist/functions/get-content/generate-content-url.js +2 -1
- package/dist/functions/get-content/index.d.ts +1 -5
- package/dist/functions/get-content/index.js +4 -3
- package/dist/functions/get-processed-block.js +7 -4
- package/dist/functions/get-react-native-block-styles.js +1 -0
- package/dist/functions/is-non-node-server.d.ts +4 -0
- package/dist/functions/is-non-node-server.js +8 -0
- package/dist/functions/register-component.js +8 -4
- package/dist/functions/sanitize-react-native-block-styles.js +6 -3
- package/dist/functions/track/helpers.js +2 -1
- package/dist/functions/track/index.js +4 -2
- package/dist/functions/transform-block.js +1 -0
- package/dist/helpers/ab-tests.js +12 -6
- package/dist/helpers/cookie.js +2 -1
- package/dist/helpers/flatten.js +4 -2
- package/dist/helpers/preview-lru-cache/init.d.ts +5 -0
- package/dist/helpers/preview-lru-cache/types.js +5 -0
- package/dist/index-helpers/blocks-exports.d.ts +10 -10
- package/dist/index-helpers/blocks-exports.js +10 -10
- package/dist/scripts/init-editing.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { logger } from '../../helpers/logger';
|
|
2
|
+
import { set } from '../set';
|
|
3
|
+
import Interpreter from './interpreter.js';
|
|
4
|
+
const processCode = (code) => {
|
|
5
|
+
return code.split('\n').map(line => {
|
|
6
|
+
const trimmed = line.trim();
|
|
7
|
+
// this async wrapper doesn't work in JS-interpreter, so we drop it.
|
|
8
|
+
if (line.includes('__awaiter'))
|
|
9
|
+
return undefined;
|
|
10
|
+
// we find all state setter expressions and append a call to setRootState afterwards
|
|
11
|
+
const isStateSetter = trimmed.startsWith('state.');
|
|
12
|
+
if (!isStateSetter)
|
|
13
|
+
return line;
|
|
14
|
+
const [lhs, rhs] = trimmed.split('=');
|
|
15
|
+
const setStr = lhs.replace('state.', '').trim();
|
|
16
|
+
const setExpr = `setRootState('${setStr}', ${rhs.trim()})`;
|
|
17
|
+
return `
|
|
18
|
+
${line}
|
|
19
|
+
${setExpr}
|
|
20
|
+
`;
|
|
21
|
+
}).filter(Boolean).join('\n');
|
|
22
|
+
};
|
|
23
|
+
const getJSONValName = (val) => val + 'JSON';
|
|
24
|
+
export const runInNonNode = ({ builder, context, event, rootState, localState, rootSetState, useCode }) => {
|
|
25
|
+
const state = {
|
|
26
|
+
...rootState,
|
|
27
|
+
...localState
|
|
28
|
+
};
|
|
29
|
+
const properties = {
|
|
30
|
+
state,
|
|
31
|
+
Builder: builder,
|
|
32
|
+
builder,
|
|
33
|
+
context,
|
|
34
|
+
event
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Deserialize all properties from JSON strings to JS objects
|
|
38
|
+
*/
|
|
39
|
+
const prependedCode = Object.keys(properties).map(key => `var ${key} = JSON.parse(${getJSONValName(key)});`).join('\n');
|
|
40
|
+
const cleanedCode = processCode(useCode);
|
|
41
|
+
if (cleanedCode === '') {
|
|
42
|
+
logger.warn('Skipping evaluation of empty code block.');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const transformed = `
|
|
46
|
+
function theFunction() {
|
|
47
|
+
${prependedCode}
|
|
48
|
+
|
|
49
|
+
${cleanedCode}
|
|
50
|
+
}
|
|
51
|
+
theFunction();
|
|
52
|
+
`;
|
|
53
|
+
const setRootState = (prop, value) => {
|
|
54
|
+
const newState = set(state, prop, value);
|
|
55
|
+
rootSetState?.(newState);
|
|
56
|
+
};
|
|
57
|
+
const initFunc = function (interpreter, globalObject) {
|
|
58
|
+
/**
|
|
59
|
+
* serialize all function args to JSON strings
|
|
60
|
+
*/
|
|
61
|
+
Object.keys(properties).forEach(key => {
|
|
62
|
+
const val = properties[key] || {};
|
|
63
|
+
const jsonVal = JSON.stringify(val);
|
|
64
|
+
interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Add a JavaScript function "setRootState" to the interpreter's global object, that will be called whenever a
|
|
68
|
+
* state property is set. This function will update the state object.
|
|
69
|
+
*/
|
|
70
|
+
interpreter.setProperty(globalObject, 'setRootState', interpreter.createNativeFunction(setRootState));
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
const myInterpreter = new Interpreter(transformed, initFunc);
|
|
74
|
+
myInterpreter.run();
|
|
75
|
+
const output = myInterpreter.pseudoToNative(myInterpreter.value);
|
|
76
|
+
return output;
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
logger.warn('Custom code error in non-node runtime. SDK can only execute ES5 JavaScript.', {
|
|
80
|
+
e
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BuilderContextInterface } from '../../context/types';
|
|
2
|
+
export type ExecutorArgs = Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'> & {
|
|
3
|
+
useCode: string;
|
|
4
|
+
builder: {
|
|
5
|
+
isEditing: boolean | undefined;
|
|
6
|
+
isBrowser: boolean | undefined;
|
|
7
|
+
isServer: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
event: Event | undefined;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,7 +11,8 @@ const isTextStyle = (key) => {
|
|
|
11
11
|
* Extract styles that apply to text from a style object.
|
|
12
12
|
*/
|
|
13
13
|
export const extractTextStyles = (styles) => {
|
|
14
|
-
const textStyles = {};
|
|
14
|
+
const textStyles = {};
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
16
|
Object.entries(styles).forEach(([key, value]) => {
|
|
16
17
|
if (isTextStyle(key)) {
|
|
17
18
|
textStyles[key] = value;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export function getBlockComponentOptions(block) {
|
|
2
|
-
return {
|
|
2
|
+
return {
|
|
3
|
+
...block.component?.options,
|
|
3
4
|
...block.options,
|
|
4
5
|
/**
|
|
5
6
|
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
6
7
|
*/
|
|
7
|
-
builderBlock: block
|
|
8
|
+
builderBlock: block
|
|
9
|
+
};
|
|
8
10
|
}
|
|
@@ -35,7 +35,8 @@ const extractRelevantRootBlockProperties = (block) => {
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
export function getBlockProperties({ block, context }) {
|
|
38
|
-
const properties = {
|
|
38
|
+
const properties = {
|
|
39
|
+
...extractRelevantRootBlockProperties(block),
|
|
39
40
|
...block.properties,
|
|
40
41
|
'builder-id': block.id,
|
|
41
42
|
style: block.style ? getStyleAttribute(block.style) : undefined,
|
|
@@ -10,7 +10,8 @@ export const generateContentUrl = (options) => {
|
|
|
10
10
|
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
|
|
11
11
|
}
|
|
12
12
|
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}${enrich ? `&enrich=${enrich}` : ''}`);
|
|
13
|
-
const queryOptions = {
|
|
13
|
+
const queryOptions = {
|
|
14
|
+
...getBuilderSearchParamsFromWindow(),
|
|
14
15
|
...normalizeSearchParams(options.options || {})
|
|
15
16
|
};
|
|
16
17
|
const flattened = flatten(queryOptions);
|
|
@@ -4,13 +4,9 @@ export declare function getContent(options: GetContentOptions): Promise<BuilderC
|
|
|
4
4
|
type ContentResults = {
|
|
5
5
|
results: BuilderContent[];
|
|
6
6
|
};
|
|
7
|
-
type ContentResponse = ContentResults | {
|
|
8
|
-
status: number;
|
|
9
|
-
message: string;
|
|
10
|
-
};
|
|
11
7
|
/**
|
|
12
8
|
* Exported only for testing purposes. Should not be used directly.
|
|
13
9
|
*/
|
|
14
10
|
export declare const processContentResult: (options: GetContentOptions, content: ContentResults, url?: URL) => Promise<ContentResults>;
|
|
15
|
-
export declare function getAllContent(options: GetContentOptions): Promise<
|
|
11
|
+
export declare function getAllContent(options: GetContentOptions): Promise<ContentResults>;
|
|
16
12
|
export {};
|
|
@@ -8,10 +8,11 @@ import { isBrowser } from '../is-browser.js';
|
|
|
8
8
|
import { generateContentUrl } from './generate-content-url.js';
|
|
9
9
|
const checkContentHasResults = (content) => 'results' in content;
|
|
10
10
|
export async function getContent(options) {
|
|
11
|
-
const allContent = await getAllContent({
|
|
11
|
+
const allContent = await getAllContent({
|
|
12
|
+
...options,
|
|
12
13
|
limit: 1
|
|
13
14
|
});
|
|
14
|
-
if (allContent
|
|
15
|
+
if (allContent) {
|
|
15
16
|
return allContent.results[0] || null;
|
|
16
17
|
}
|
|
17
18
|
return null;
|
|
@@ -71,7 +72,7 @@ export async function getAllContent(options) {
|
|
|
71
72
|
content,
|
|
72
73
|
options
|
|
73
74
|
});
|
|
74
|
-
return
|
|
75
|
+
return null;
|
|
75
76
|
}
|
|
76
77
|
return processContentResult(options, content);
|
|
77
78
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { evaluate } from './evaluate
|
|
1
|
+
import { evaluate } from './evaluate';
|
|
2
2
|
import { fastClone } from './fast-clone.js';
|
|
3
3
|
import { set } from './set.js';
|
|
4
4
|
import { transformBlock } from './transform-block.js';
|
|
@@ -7,10 +7,13 @@ const evaluateBindings = ({ block, context, localState, rootState, rootSetState
|
|
|
7
7
|
return block;
|
|
8
8
|
}
|
|
9
9
|
const copy = fastClone(block);
|
|
10
|
-
const copied = {
|
|
11
|
-
|
|
10
|
+
const copied = {
|
|
11
|
+
...copy,
|
|
12
|
+
properties: {
|
|
13
|
+
...copy.properties
|
|
12
14
|
},
|
|
13
|
-
actions: {
|
|
15
|
+
actions: {
|
|
16
|
+
...copy.actions
|
|
14
17
|
}
|
|
15
18
|
};
|
|
16
19
|
for (const binding in block.bindings) {
|
|
@@ -5,6 +5,7 @@ export function getReactNativeBlockStyles({ block, context, blockStyles }) {
|
|
|
5
5
|
return {};
|
|
6
6
|
}
|
|
7
7
|
const styles = {
|
|
8
|
+
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
8
9
|
...context.inheritedStyles,
|
|
9
10
|
...(responsiveStyles.large || {}),
|
|
10
11
|
...(responsiveStyles.medium || {}),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isBrowser } from './is-browser';
|
|
2
|
+
/**
|
|
3
|
+
* Identifies non-node server runtimes (edge, workers, serverless, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export function isNonNodeServer() {
|
|
6
|
+
const hasNode = () => typeof process !== 'undefined' && process?.versions?.node;
|
|
7
|
+
return !isBrowser() && !hasNode();
|
|
8
|
+
}
|
|
@@ -17,9 +17,11 @@ export function registerComponent(component, info) {
|
|
|
17
17
|
export const createRegisterComponentMessage = (info) => ({
|
|
18
18
|
type: 'builder.registerComponent',
|
|
19
19
|
data: info
|
|
20
|
-
});
|
|
20
|
+
});
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
21
22
|
const serializeFn = (fnValue) => {
|
|
22
|
-
const fnStr = fnValue.toString().trim();
|
|
23
|
+
const fnStr = fnValue.toString().trim();
|
|
24
|
+
// we need to account for a few different fn syntaxes:
|
|
23
25
|
// 1. `function name(args) => {code}`
|
|
24
26
|
// 2. `name(args) => {code}`
|
|
25
27
|
// 3. `(args) => {}`
|
|
@@ -27,8 +29,10 @@ const serializeFn = (fnValue) => {
|
|
|
27
29
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
28
30
|
};
|
|
29
31
|
const serializeValue = (value) => typeof value === 'function' ? serializeFn(value) : fastClone(value);
|
|
30
|
-
export const serializeComponentInfo = ({ inputs, ...info }) => ({
|
|
31
|
-
|
|
32
|
+
export const serializeComponentInfo = ({ inputs, ...info }) => ({
|
|
33
|
+
...fastClone(info),
|
|
34
|
+
inputs: inputs?.map(input => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
35
|
+
...acc,
|
|
32
36
|
[key]: serializeValue(value)
|
|
33
37
|
}), {}))
|
|
34
38
|
});
|
|
@@ -36,7 +36,8 @@ export const sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
36
36
|
const newValue = parseFloat(propertyValue);
|
|
37
37
|
const normalizedValue = normalizeNumber(newValue);
|
|
38
38
|
if (normalizedValue) {
|
|
39
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...acc,
|
|
40
41
|
[key]: normalizedValue
|
|
41
42
|
};
|
|
42
43
|
}
|
|
@@ -46,12 +47,14 @@ export const sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
46
47
|
}
|
|
47
48
|
else if (propertyValue === '0') {
|
|
48
49
|
// 0 edge case needs to be handled
|
|
49
|
-
return {
|
|
50
|
+
return {
|
|
51
|
+
...acc,
|
|
50
52
|
[key]: 0
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
|
-
return {
|
|
56
|
+
return {
|
|
57
|
+
...acc,
|
|
55
58
|
[key]: propertyValue
|
|
56
59
|
};
|
|
57
60
|
}, {});
|
|
@@ -5,7 +5,8 @@ const getLocation = () => {
|
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
7
|
else if (isBrowser()) {
|
|
8
|
-
const parsedLocation = new URL(location.href);
|
|
8
|
+
const parsedLocation = new URL(location.href);
|
|
9
|
+
// IE11 bug with parsed path being empty string
|
|
9
10
|
// causes issues with our user targeting
|
|
10
11
|
if (parsedLocation.pathname === '') {
|
|
11
12
|
parsedLocation.pathname = '/';
|
|
@@ -25,7 +25,8 @@ const getTrackingEventData = async ({ canTrack }) => {
|
|
|
25
25
|
};
|
|
26
26
|
const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...properties }) => ({
|
|
27
27
|
type: eventType,
|
|
28
|
-
data: {
|
|
28
|
+
data: {
|
|
29
|
+
...properties,
|
|
29
30
|
metadata: {
|
|
30
31
|
url: location.href,
|
|
31
32
|
...metadata
|
|
@@ -64,6 +65,7 @@ export async function _track(eventProps) {
|
|
|
64
65
|
console.error('Failed to track: ', err);
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
|
-
export const track = (args) => _track({
|
|
68
|
+
export const track = (args) => _track({
|
|
69
|
+
...args,
|
|
68
70
|
canTrack: true
|
|
69
71
|
});
|
package/dist/helpers/ab-tests.js
CHANGED
|
@@ -23,7 +23,8 @@ const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) &&
|
|
|
23
23
|
*/
|
|
24
24
|
const getRandomVariationId = ({ id, variations }) => {
|
|
25
25
|
let n = 0;
|
|
26
|
-
const random = Math.random();
|
|
26
|
+
const random = Math.random();
|
|
27
|
+
// loop over variations test ratios, incrementing a counter,
|
|
27
28
|
// until we find the variation that this user should be assigned to
|
|
28
29
|
for (const id in variations) {
|
|
29
30
|
const testRatio = variations[id]?.testRatio;
|
|
@@ -31,13 +32,15 @@ const getRandomVariationId = ({ id, variations }) => {
|
|
|
31
32
|
if (random < n) {
|
|
32
33
|
return id;
|
|
33
34
|
}
|
|
34
|
-
}
|
|
35
|
+
}
|
|
36
|
+
// the variations array does not include the default variation.
|
|
35
37
|
// if we arrive here, then it means that the random number fits in the default variation bucket.
|
|
36
38
|
return id;
|
|
37
39
|
};
|
|
38
40
|
const getAndSetVariantId = (args) => {
|
|
39
41
|
// if variation not found in storage, assign a random variation to this user
|
|
40
|
-
const randomVariationId = getRandomVariationId(args);
|
|
42
|
+
const randomVariationId = getRandomVariationId(args);
|
|
43
|
+
// store variation in cookies/storage
|
|
41
44
|
setContentVariationCookie({
|
|
42
45
|
contentId: args.id,
|
|
43
46
|
value: randomVariationId
|
|
@@ -48,7 +51,8 @@ const getAndSetVariantId = (args) => {
|
|
|
48
51
|
};
|
|
49
52
|
const getTestFields = ({ item, testGroupId }) => {
|
|
50
53
|
const variationValue = item.variations[testGroupId];
|
|
51
|
-
if (testGroupId === item.id ||
|
|
54
|
+
if (testGroupId === item.id ||
|
|
55
|
+
// handle edge-case where `testGroupId` points to non-existing variation
|
|
52
56
|
!variationValue) {
|
|
53
57
|
return {
|
|
54
58
|
testVariationId: item.id,
|
|
@@ -88,7 +92,8 @@ export const handleABTestingSync = ({ item, canTrack }) => {
|
|
|
88
92
|
item,
|
|
89
93
|
testGroupId
|
|
90
94
|
});
|
|
91
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
...item,
|
|
92
97
|
...variationValue
|
|
93
98
|
};
|
|
94
99
|
};
|
|
@@ -110,7 +115,8 @@ export const handleABTesting = async ({ item, canTrack }) => {
|
|
|
110
115
|
item,
|
|
111
116
|
testGroupId
|
|
112
117
|
});
|
|
113
|
-
return {
|
|
118
|
+
return {
|
|
119
|
+
...item,
|
|
114
120
|
...variationValue
|
|
115
121
|
};
|
|
116
122
|
};
|
package/dist/helpers/cookie.js
CHANGED
|
@@ -27,7 +27,8 @@ const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}
|
|
|
27
27
|
const SECURE_CONFIG = [['secure', ''], ['SameSite', 'None']];
|
|
28
28
|
const createCookieString = ({ name, value, expires }) => {
|
|
29
29
|
const secure = isBrowser() ? location.protocol === 'https:' : true;
|
|
30
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
30
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
31
|
+
// TODO: need to know if secure server side
|
|
31
32
|
const expiresObj = expires ? [['expires', expires.toUTCString()]] : [[]];
|
|
32
33
|
const cookieValue = [[name, value], ...expiresObj, ['path', '/'], ['domain', getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
33
34
|
const cookie = stringifyCookie(cookieValue);
|
package/dist/helpers/flatten.js
CHANGED
|
@@ -8,9 +8,11 @@ export function flatten(object, path = null, separator = '.') {
|
|
|
8
8
|
const value = object[key];
|
|
9
9
|
const newPath = [path, key].filter(Boolean).join(separator);
|
|
10
10
|
const isObject = [typeof value === 'object', value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
|
|
11
|
-
return isObject ? {
|
|
11
|
+
return isObject ? {
|
|
12
|
+
...acc,
|
|
12
13
|
...flatten(value, newPath, separator)
|
|
13
|
-
} : {
|
|
14
|
+
} : {
|
|
15
|
+
...acc,
|
|
14
16
|
[newPath]: value
|
|
15
17
|
};
|
|
16
18
|
}, {});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { default as Button } from '../blocks/button/button
|
|
2
|
-
export { default as Columns } from '../blocks/columns/columns
|
|
3
|
-
export { default as Fragment } from '../blocks/fragment/fragment
|
|
4
|
-
export { default as Image } from '../blocks/image/image
|
|
5
|
-
export { default as RenderBlocks } from '../components/blocks/blocks
|
|
6
|
-
export { default as Section } from '../blocks/section/section
|
|
7
|
-
export { default as Symbol } from '../blocks/symbol/symbol
|
|
8
|
-
export { default as Text } from '../blocks/text/text
|
|
9
|
-
export { default as Video } from '../blocks/video/video
|
|
10
|
-
export { default as RenderContent } from '../components/content-variants/content-variants
|
|
1
|
+
export { default as Button } from '../blocks/button/button';
|
|
2
|
+
export { default as Columns } from '../blocks/columns/columns';
|
|
3
|
+
export { default as Fragment } from '../blocks/fragment/fragment';
|
|
4
|
+
export { default as Image } from '../blocks/image/image';
|
|
5
|
+
export { default as RenderBlocks } from '../components/blocks/blocks';
|
|
6
|
+
export { default as Section } from '../blocks/section/section';
|
|
7
|
+
export { default as Symbol } from '../blocks/symbol/symbol';
|
|
8
|
+
export { default as Text } from '../blocks/text/text';
|
|
9
|
+
export { default as Video } from '../blocks/video/video';
|
|
10
|
+
export { default as RenderContent } from '../components/content-variants/content-variants';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { default as Button } from '../blocks/button/button
|
|
2
|
-
export { default as Columns } from '../blocks/columns/columns
|
|
3
|
-
export { default as Fragment } from '../blocks/fragment/fragment
|
|
4
|
-
export { default as Image } from '../blocks/image/image
|
|
5
|
-
export { default as RenderBlocks } from '../components/blocks/blocks
|
|
6
|
-
export { default as Section } from '../blocks/section/section
|
|
7
|
-
export { default as Symbol } from '../blocks/symbol/symbol
|
|
8
|
-
export { default as Text } from '../blocks/text/text
|
|
9
|
-
export { default as Video } from '../blocks/video/video
|
|
10
|
-
export { default as RenderContent } from '../components/content-variants/content-variants
|
|
1
|
+
export { default as Button } from '../blocks/button/button';
|
|
2
|
+
export { default as Columns } from '../blocks/columns/columns';
|
|
3
|
+
export { default as Fragment } from '../blocks/fragment/fragment';
|
|
4
|
+
export { default as Image } from '../blocks/image/image';
|
|
5
|
+
export { default as RenderBlocks } from '../components/blocks/blocks';
|
|
6
|
+
export { default as Section } from '../blocks/section/section';
|
|
7
|
+
export { default as Symbol } from '../blocks/symbol/symbol';
|
|
8
|
+
export { default as Text } from '../blocks/text/text';
|
|
9
|
+
export { default as Video } from '../blocks/video/video';
|
|
10
|
+
export { default as RenderContent } from '../components/content-variants/content-variants';
|
|
@@ -59,7 +59,8 @@ export const setupBrowserForEditing = (options = {}) => {
|
|
|
59
59
|
{
|
|
60
60
|
const text = data.data.text;
|
|
61
61
|
const args = data.data.arguments || [];
|
|
62
|
-
const id = data.data.id;
|
|
62
|
+
const id = data.data.id;
|
|
63
|
+
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
63
64
|
const fn = new Function(text);
|
|
64
65
|
let result;
|
|
65
66
|
let error = null;
|