@builder.io/sdk-react-native 1.0.31-0 → 1.0.31
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/lib/browser/commonjs/blocks/symbol/symbol.js +1 -0
- package/lib/browser/commonjs/blocks/symbol/symbol.js.map +1 -1
- package/lib/browser/commonjs/components/content/content.js +1 -0
- package/lib/browser/commonjs/components/content/content.js.map +1 -1
- package/lib/browser/commonjs/constants/sdk-version.js +1 -1
- package/lib/browser/module/blocks/symbol/symbol.js +1 -0
- package/lib/browser/module/blocks/symbol/symbol.js.map +1 -1
- package/lib/browser/module/components/content/content.js +1 -0
- package/lib/browser/module/components/content/content.js.map +1 -1
- package/lib/browser/module/constants/sdk-version.js +1 -1
- package/lib/browser/typescript/blocks/symbol/symbol.d.ts.map +1 -1
- package/lib/browser/typescript/components/content/content.d.ts.map +1 -1
- package/lib/browser/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/browser/typescript/context/types.d.ts +1 -0
- package/lib/browser/typescript/context/types.d.ts.map +1 -1
- package/lib/edge/commonjs/blocks/symbol/symbol.js +1 -0
- package/lib/edge/commonjs/blocks/symbol/symbol.js.map +1 -1
- package/lib/edge/commonjs/components/content/content.js +1 -0
- package/lib/edge/commonjs/components/content/content.js.map +1 -1
- package/lib/edge/commonjs/constants/sdk-version.js +1 -1
- package/lib/edge/module/blocks/symbol/symbol.js +1 -0
- package/lib/edge/module/blocks/symbol/symbol.js.map +1 -1
- package/lib/edge/module/components/content/content.js +1 -0
- package/lib/edge/module/components/content/content.js.map +1 -1
- package/lib/edge/module/constants/sdk-version.js +1 -1
- package/lib/edge/typescript/blocks/symbol/symbol.d.ts.map +1 -1
- package/lib/edge/typescript/components/content/content.d.ts.map +1 -1
- package/lib/edge/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/edge/typescript/context/types.d.ts +1 -0
- package/lib/edge/typescript/context/types.d.ts.map +1 -1
- package/lib/node/commonjs/blocks/symbol/symbol.js +1 -0
- package/lib/node/commonjs/blocks/symbol/symbol.js.map +1 -1
- package/lib/node/commonjs/components/content/content.js +1 -0
- package/lib/node/commonjs/components/content/content.js.map +1 -1
- package/lib/node/commonjs/constants/sdk-version.js +1 -1
- package/lib/node/module/blocks/symbol/symbol.js +1 -0
- package/lib/node/module/blocks/symbol/symbol.js.map +1 -1
- package/lib/node/module/components/content/content.js +1 -0
- package/lib/node/module/components/content/content.js.map +1 -1
- package/lib/node/module/constants/sdk-version.js +1 -1
- package/lib/node/typescript/blocks/symbol/symbol.d.ts.map +1 -1
- package/lib/node/typescript/components/content/content.d.ts.map +1 -1
- package/lib/node/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/node/typescript/context/types.d.ts +1 -0
- package/lib/node/typescript/context/types.d.ts.map +1 -1
- package/package.json +5 -9
- package/lib/node/index.cjs +0 -6910
- package/lib/node/index.mjs +0 -7477
- package/src/blocks/BaseText.tsx +0 -17
- package/src/blocks/accordion/accordion.tsx +0 -181
- package/src/blocks/accordion/accordion.types.ts +0 -12
- package/src/blocks/accordion/component-info.ts +0 -124
- package/src/blocks/accordion/helpers.ts +0 -3
- package/src/blocks/accordion/index.ts +0 -1
- package/src/blocks/button/button.tsx +0 -56
- package/src/blocks/button/button.types.ts +0 -7
- package/src/blocks/button/component-info.ts +0 -35
- package/src/blocks/button/index.ts +0 -1
- package/src/blocks/columns/columns.tsx +0 -199
- package/src/blocks/columns/columns.types.ts +0 -14
- package/src/blocks/columns/component-info.ts +0 -219
- package/src/blocks/columns/helpers.ts +0 -3
- package/src/blocks/columns/index.ts +0 -1
- package/src/blocks/custom-code/component-info.ts +0 -24
- package/src/blocks/custom-code/custom-code.tsx +0 -71
- package/src/blocks/custom-code/index.ts +0 -1
- package/src/blocks/embed/component-info.ts +0 -38
- package/src/blocks/embed/embed.tsx +0 -62
- package/src/blocks/embed/helpers.ts +0 -2
- package/src/blocks/embed/index.ts +0 -1
- package/src/blocks/form/form/component-info.ts +0 -233
- package/src/blocks/form/form/form.tsx +0 -324
- package/src/blocks/form/form/index.ts +0 -1
- package/src/blocks/form/input/component-info.ts +0 -47
- package/src/blocks/form/input/index.ts +0 -1
- package/src/blocks/form/input/input.tsx +0 -49
- package/src/blocks/form/select/component-info.ts +0 -44
- package/src/blocks/form/select/index.ts +0 -1
- package/src/blocks/form/select/select.tsx +0 -54
- package/src/blocks/form/submit-button/component-info.ts +0 -27
- package/src/blocks/form/submit-button/index.ts +0 -1
- package/src/blocks/form/submit-button/submit-button.tsx +0 -34
- package/src/blocks/fragment/component-info.ts +0 -8
- package/src/blocks/fragment/fragment.tsx +0 -18
- package/src/blocks/fragment/fragment.types.ts +0 -5
- package/src/blocks/fragment/index.ts +0 -1
- package/src/blocks/helpers.ts +0 -43
- package/src/blocks/image/component-info.ts +0 -124
- package/src/blocks/image/image.helpers.ts +0 -47
- package/src/blocks/image/image.tsx +0 -65
- package/src/blocks/image/image.types.ts +0 -19
- package/src/blocks/image/index.ts +0 -1
- package/src/blocks/img/component-info.ts +0 -16
- package/src/blocks/img/img.tsx +0 -55
- package/src/blocks/img/index.ts +0 -1
- package/src/blocks/raw-text/component-info.ts +0 -11
- package/src/blocks/raw-text/index.ts +0 -1
- package/src/blocks/raw-text/raw-text.tsx +0 -1
- package/src/blocks/section/component-info.ts +0 -41
- package/src/blocks/section/index.ts +0 -1
- package/src/blocks/section/section.tsx +0 -39
- package/src/blocks/section/section.types.ts +0 -6
- package/src/blocks/slot/component-info.ts +0 -15
- package/src/blocks/slot/index.ts +0 -1
- package/src/blocks/slot/slot.tsx +0 -42
- package/src/blocks/symbol/component-info.ts +0 -35
- package/src/blocks/symbol/index.ts +0 -1
- package/src/blocks/symbol/symbol.helpers.ts +0 -47
- package/src/blocks/symbol/symbol.tsx +0 -99
- package/src/blocks/symbol/symbol.types.ts +0 -17
- package/src/blocks/tabs/component-info.ts +0 -139
- package/src/blocks/tabs/index.ts +0 -1
- package/src/blocks/tabs/tabs.tsx +0 -79
- package/src/blocks/tabs/tabs.types.ts +0 -13
- package/src/blocks/text/component-info.ts +0 -20
- package/src/blocks/text/index.ts +0 -1
- package/src/blocks/text/text.tsx +0 -105
- package/src/blocks/text/text.types.ts +0 -4
- package/src/blocks/textarea/component-info.ts +0 -38
- package/src/blocks/textarea/index.ts +0 -1
- package/src/blocks/textarea/textarea.tsx +0 -41
- package/src/blocks/video/component-info.ts +0 -83
- package/src/blocks/video/index.ts +0 -1
- package/src/blocks/video/video.tsx +0 -70
- package/src/blocks/video/video.types.ts +0 -21
- package/src/components/block/animator.ts +0 -220
- package/src/components/block/block.helpers.ts +0 -106
- package/src/components/block/block.tsx +0 -235
- package/src/components/block/components/block-styles.tsx +0 -136
- package/src/components/block/components/block-wrapper.tsx +0 -53
- package/src/components/block/components/component-ref/component-ref.helpers.ts +0 -55
- package/src/components/block/components/component-ref/component-ref.tsx +0 -66
- package/src/components/block/components/interactive-element.tsx +0 -53
- package/src/components/block/components/repeated-block.tsx +0 -37
- package/src/components/block/types.ts +0 -6
- package/src/components/blocks/blocks-wrapper.tsx +0 -93
- package/src/components/blocks/blocks.tsx +0 -57
- package/src/components/blocks/blocks.types.ts +0 -7
- package/src/components/blocks/index.ts +0 -1
- package/src/components/content/components/enable-editor.tsx +0 -471
- package/src/components/content/components/styles.helpers.ts +0 -101
- package/src/components/content/components/styles.tsx +0 -42
- package/src/components/content/content.helpers.ts +0 -40
- package/src/components/content/content.tsx +0 -150
- package/src/components/content/content.types.ts +0 -13
- package/src/components/content/contentProps.types.ts +0 -17
- package/src/components/content/index.ts +0 -1
- package/src/components/content/wrap-component-ref.ts +0 -6
- package/src/components/content-variants/content-variants.tsx +0 -146
- package/src/components/content-variants/content-variants.types.ts +0 -84
- package/src/components/content-variants/helpers.ts +0 -72
- package/src/components/content-variants/index.ts +0 -1
- package/src/components/content-variants/inlined-fns.ts +0 -22
- package/src/components/dynamic-div.tsx +0 -30
- package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +0 -7
- package/src/components/dynamic-renderer/dynamic-renderer.tsx +0 -47
- package/src/components/error-boundary.tsx +0 -38
- package/src/components/inlined-script.tsx +0 -10
- package/src/components/inlined-styles.tsx +0 -10
- package/src/constants/builder-registered-components.ts +0 -59
- package/src/constants/device-sizes.ts +0 -59
- package/src/constants/extra-components.ts +0 -1
- package/src/constants/sdk-version.ts +0 -1
- package/src/constants/target.ts +0 -3
- package/src/context/builder.context.ts +0 -15
- package/src/context/components.context.ts +0 -3
- package/src/context/index.ts +0 -1
- package/src/context/types.ts +0 -37
- package/src/functions/apply-patch-with-mutation.ts +0 -61
- package/src/functions/camel-to-kebab-case.ts +0 -1
- package/src/functions/deopt.ts +0 -6
- package/src/functions/evaluate/browser-runtime/browser.ts +0 -61
- package/src/functions/evaluate/browser-runtime/index.ts +0 -1
- package/src/functions/evaluate/choose-eval.ts +0 -23
- package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +0 -2891
- package/src/functions/evaluate/edge-runtime/edge-runtime.ts +0 -96
- package/src/functions/evaluate/edge-runtime/index.ts +0 -1
- package/src/functions/evaluate/evaluate.ts +0 -76
- package/src/functions/evaluate/helpers.ts +0 -56
- package/src/functions/evaluate/index.ts +0 -1
- package/src/functions/evaluate/node-runtime/index.ts +0 -1
- package/src/functions/evaluate/node-runtime/init.ts +0 -33
- package/src/functions/evaluate/node-runtime/node-runtime.ts +0 -176
- package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +0 -24
- package/src/functions/evaluate/placeholder-runtime.ts +0 -4
- package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +0 -16
- package/src/functions/event-handler-name.ts +0 -4
- package/src/functions/extract-text-styles.ts +0 -24
- package/src/functions/fast-clone.ts +0 -4
- package/src/functions/fetch-builder-props.ts +0 -75
- package/src/functions/get-block-actions-handler.ts +0 -17
- package/src/functions/get-block-actions.ts +0 -35
- package/src/functions/get-block-component-options.ts +0 -11
- package/src/functions/get-block-properties.ts +0 -62
- package/src/functions/get-builder-search-params/index.ts +0 -33
- package/src/functions/get-class-prop-name.ts +0 -15
- package/src/functions/get-content/generate-content-url.ts +0 -88
- package/src/functions/get-content/index.ts +0 -99
- package/src/functions/get-content/types.ts +0 -157
- package/src/functions/get-env.ts +0 -5
- package/src/functions/get-fetch.ts +0 -11
- package/src/functions/get-global-this.ts +0 -16
- package/src/functions/get-processed-block.ts +0 -70
- package/src/functions/get-style.ts +0 -38
- package/src/functions/get.ts +0 -4
- package/src/functions/is-browser.ts +0 -3
- package/src/functions/is-edge-runtime.ts +0 -9
- package/src/functions/is-editing.ts +0 -8
- package/src/functions/is-from-trusted-host.ts +0 -8
- package/src/functions/is-iframe.ts +0 -4
- package/src/functions/is-node-runtime.ts +0 -8
- package/src/functions/is-previewing.ts +0 -16
- package/src/functions/on-change.ts +0 -29
- package/src/functions/register-component.ts +0 -30
- package/src/functions/register.ts +0 -44
- package/src/functions/set-editor-settings.ts +0 -15
- package/src/functions/set.ts +0 -14
- package/src/functions/track/helpers.ts +0 -51
- package/src/functions/track/index.ts +0 -131
- package/src/functions/track/interaction.ts +0 -63
- package/src/functions/transform-block-properties.ts +0 -33
- package/src/functions/transform-block.ts +0 -30
- package/src/functions/transform-style-property.ts +0 -296
- package/src/helpers/ab-tests.ts +0 -166
- package/src/helpers/canTrack.ts +0 -2
- package/src/helpers/cookie.ts +0 -97
- package/src/helpers/css.ts +0 -33
- package/src/helpers/flatten.ts +0 -41
- package/src/helpers/localStorage.ts +0 -36
- package/src/helpers/logger.ts +0 -7
- package/src/helpers/nullable.ts +0 -2
- package/src/helpers/omit.ts +0 -7
- package/src/helpers/preview-lru-cache/get.ts +0 -4
- package/src/helpers/preview-lru-cache/helpers.ts +0 -1
- package/src/helpers/preview-lru-cache/init.ts +0 -7
- package/src/helpers/preview-lru-cache/set.ts +0 -12
- package/src/helpers/preview-lru-cache/types.ts +0 -1
- package/src/helpers/search/search.ts +0 -18
- package/src/helpers/sessionId.ts +0 -37
- package/src/helpers/subscribe-to-editor.ts +0 -95
- package/src/helpers/time.ts +0 -2
- package/src/helpers/url.ts +0 -15
- package/src/helpers/uuid.ts +0 -17
- package/src/helpers/visitorId.ts +0 -37
- package/src/index-helpers/blocks-exports.ts +0 -16
- package/src/index-helpers/top-of-file.ts +0 -2
- package/src/index.ts +0 -15
- package/src/scripts/init-editing.ts +0 -119
- package/src/server-index.ts +0 -43
- package/src/types/api-version.ts +0 -2
- package/src/types/builder-block.ts +0 -89
- package/src/types/builder-content.ts +0 -47
- package/src/types/builder-props.ts +0 -12
- package/src/types/can-track.ts +0 -3
- package/src/types/components.ts +0 -119
- package/src/types/deep-partial.ts +0 -1
- package/src/types/element.ts +0 -57
- package/src/types/enforced-partials.ts +0 -19
- package/src/types/input.ts +0 -123
- package/src/types/targets.ts +0 -1
- package/src/types/typescript.ts +0 -9
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type QueryObject = Record<string, string | string[]>;
|
|
2
|
-
export const convertSearchParamsToQueryObject = (searchParams: URLSearchParams): QueryObject => {
|
|
3
|
-
const options: Record<string, string> = {};
|
|
4
|
-
searchParams.forEach((value, key) => {
|
|
5
|
-
options[key] = value;
|
|
6
|
-
});
|
|
7
|
-
return options;
|
|
8
|
-
};
|
|
9
|
-
export const normalizeSearchParams = (searchParams: QueryObject | URLSearchParams): QueryObject => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
10
|
-
export type Search = URLSearchParams | string | QueryObject;
|
|
11
|
-
export const getSearchString = (search: Search): string => {
|
|
12
|
-
if (typeof search === 'string') {
|
|
13
|
-
return search;
|
|
14
|
-
} else if (search instanceof URLSearchParams) {
|
|
15
|
-
return search.toString();
|
|
16
|
-
}
|
|
17
|
-
return new URLSearchParams((search as any)).toString();
|
|
18
|
-
}
|
package/src/helpers/sessionId.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { CanTrack } from '../types/can-track';
|
|
2
|
-
import { getCookie, setCookie } from './cookie';
|
|
3
|
-
import { checkIsDefined } from './nullable';
|
|
4
|
-
import { uuid } from './uuid';
|
|
5
|
-
const SESSION_LOCAL_STORAGE_KEY = 'builderSessionId';
|
|
6
|
-
export const getSessionId = async ({
|
|
7
|
-
canTrack
|
|
8
|
-
}: CanTrack): Promise<string | undefined> => {
|
|
9
|
-
if (!canTrack) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
const sessionId = await getCookie({
|
|
13
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
14
|
-
canTrack
|
|
15
|
-
});
|
|
16
|
-
if (checkIsDefined(sessionId)) {
|
|
17
|
-
return sessionId;
|
|
18
|
-
} else {
|
|
19
|
-
const newSessionId = createSessionId();
|
|
20
|
-
setSessionId({
|
|
21
|
-
id: newSessionId,
|
|
22
|
-
canTrack
|
|
23
|
-
});
|
|
24
|
-
return newSessionId;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export const createSessionId = () => uuid();
|
|
28
|
-
export const setSessionId = ({
|
|
29
|
-
id,
|
|
30
|
-
canTrack
|
|
31
|
-
}: {
|
|
32
|
-
id: string;
|
|
33
|
-
} & CanTrack) => setCookie({
|
|
34
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
35
|
-
value: id,
|
|
36
|
-
canTrack
|
|
37
|
-
})
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { ContentProps } from '../components/content/content.types';
|
|
2
|
-
import { isBrowser } from '../functions/is-browser';
|
|
3
|
-
import { isFromTrustedHost } from '../functions/is-from-trusted-host';
|
|
4
|
-
import { setupBrowserForEditing } from '../scripts/init-editing';
|
|
5
|
-
import type { BuilderAnimation } from '../types/builder-block';
|
|
6
|
-
import type { BuilderContent } from '../types/builder-content';
|
|
7
|
-
import { logger } from './logger';
|
|
8
|
-
type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
|
|
9
|
-
callbacks: {
|
|
10
|
-
contentUpdate: (updatedContent: BuilderContent) => void;
|
|
11
|
-
animation: (updatedContent: BuilderAnimation) => void;
|
|
12
|
-
configureSdk: (updatedContent: any) => void;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export const createEditorListener = ({
|
|
16
|
-
model,
|
|
17
|
-
trustedHosts,
|
|
18
|
-
callbacks
|
|
19
|
-
}: ContentListener) => {
|
|
20
|
-
return (event: MessageEvent<any>): void => {
|
|
21
|
-
if (!isFromTrustedHost(trustedHosts, event)) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const {
|
|
25
|
-
data
|
|
26
|
-
} = event;
|
|
27
|
-
if (data) {
|
|
28
|
-
switch (data.type) {
|
|
29
|
-
case 'builder.configureSdk':
|
|
30
|
-
{
|
|
31
|
-
callbacks.configureSdk(data.data);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
case 'builder.triggerAnimation':
|
|
35
|
-
{
|
|
36
|
-
callbacks.animation(data.data);
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
case 'builder.contentUpdate':
|
|
40
|
-
{
|
|
41
|
-
const messageContent = data.data;
|
|
42
|
-
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
43
|
-
const contentData = messageContent.data;
|
|
44
|
-
if (key === model) {
|
|
45
|
-
callbacks.contentUpdate(contentData);
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
type SubscribeToEditor = (
|
|
54
|
-
/**
|
|
55
|
-
* The Builder `model` to subscribe to
|
|
56
|
-
*/
|
|
57
|
-
model: string,
|
|
58
|
-
/**
|
|
59
|
-
* The callback function to call when the content is updated.
|
|
60
|
-
*/
|
|
61
|
-
callback: (updatedContent: BuilderContent) => void,
|
|
62
|
-
/**
|
|
63
|
-
* Extra options for the listener.
|
|
64
|
-
*/
|
|
65
|
-
options?: {
|
|
66
|
-
/**
|
|
67
|
-
* List of hosts to allow editing content from.
|
|
68
|
-
*/
|
|
69
|
-
trustedHosts?: string[] | undefined;
|
|
70
|
-
}) => () => void;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Subscribes to the Builder editor and listens to `content` updates of a certain `model`.
|
|
74
|
-
* Sends the updated `content` to the `callback` function.
|
|
75
|
-
*/
|
|
76
|
-
export const subscribeToEditor: SubscribeToEditor = (model, callback, options) => {
|
|
77
|
-
if (!isBrowser) {
|
|
78
|
-
logger.warn('`subscribeToEditor` only works in the browser. It currently seems to be running on the server.');
|
|
79
|
-
return () => {};
|
|
80
|
-
}
|
|
81
|
-
setupBrowserForEditing();
|
|
82
|
-
const listener = createEditorListener({
|
|
83
|
-
callbacks: {
|
|
84
|
-
contentUpdate: callback,
|
|
85
|
-
animation: () => {},
|
|
86
|
-
configureSdk: () => {}
|
|
87
|
-
},
|
|
88
|
-
model,
|
|
89
|
-
trustedHosts: options?.trustedHosts
|
|
90
|
-
});
|
|
91
|
-
window.addEventListener('message', listener);
|
|
92
|
-
return () => {
|
|
93
|
-
window.removeEventListener('message', listener);
|
|
94
|
-
};
|
|
95
|
-
}
|
package/src/helpers/time.ts
DELETED
package/src/helpers/url.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Only gets one level up from hostname
|
|
3
|
-
* wwww.example.com -> example.com
|
|
4
|
-
* www.example.co.uk -> example.co.uk
|
|
5
|
-
*/
|
|
6
|
-
export const getTopLevelDomain = (host: string) => {
|
|
7
|
-
if (host === 'localhost' || host === '127.0.0.1') {
|
|
8
|
-
return host;
|
|
9
|
-
}
|
|
10
|
-
const parts = host.split('.');
|
|
11
|
-
if (parts.length > 2) {
|
|
12
|
-
return parts.slice(1).join('.');
|
|
13
|
-
}
|
|
14
|
-
return host;
|
|
15
|
-
}
|
package/src/helpers/uuid.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @credit https://stackoverflow.com/a/2117523
|
|
3
|
-
*/
|
|
4
|
-
export function uuidv4() {
|
|
5
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
6
|
-
const r = Math.random() * 16 | 0,
|
|
7
|
-
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
8
|
-
return v.toString(16);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Slightly cleaner and smaller UUIDs
|
|
14
|
-
*/
|
|
15
|
-
export function uuid() {
|
|
16
|
-
return uuidv4().replace(/-/g, '');
|
|
17
|
-
}
|
package/src/helpers/visitorId.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { CanTrack } from '../types/can-track';
|
|
2
|
-
import { getLocalStorageItem, setLocalStorageItem } from './localStorage';
|
|
3
|
-
import { checkIsDefined } from './nullable';
|
|
4
|
-
import { uuid } from './uuid';
|
|
5
|
-
const VISITOR_LOCAL_STORAGE_KEY = 'builderVisitorId';
|
|
6
|
-
export const getVisitorId = ({
|
|
7
|
-
canTrack
|
|
8
|
-
}: CanTrack): string | undefined => {
|
|
9
|
-
if (!canTrack) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
const visitorId = getLocalStorageItem({
|
|
13
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
14
|
-
canTrack
|
|
15
|
-
});
|
|
16
|
-
if (checkIsDefined(visitorId)) {
|
|
17
|
-
return visitorId;
|
|
18
|
-
} else {
|
|
19
|
-
const newVisitorId = createVisitorId();
|
|
20
|
-
setVisitorId({
|
|
21
|
-
id: newVisitorId,
|
|
22
|
-
canTrack
|
|
23
|
-
});
|
|
24
|
-
return newVisitorId;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export const createVisitorId = () => uuid();
|
|
28
|
-
export const setVisitorId = ({
|
|
29
|
-
id,
|
|
30
|
-
canTrack
|
|
31
|
-
}: {
|
|
32
|
-
id: string;
|
|
33
|
-
} & CanTrack) => setLocalStorageItem({
|
|
34
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
35
|
-
value: id,
|
|
36
|
-
canTrack
|
|
37
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { default as Button } from '../blocks/button/index';
|
|
2
|
-
export { default as Columns } from '../blocks/columns/index';
|
|
3
|
-
export { default as Fragment } from '../blocks/fragment/index';
|
|
4
|
-
export { default as Image } from '../blocks/image/index';
|
|
5
|
-
export { default as Section } from '../blocks/section/index';
|
|
6
|
-
export { default as Symbol } from '../blocks/symbol/index';
|
|
7
|
-
export { default as Text } from '../blocks/text/index';
|
|
8
|
-
// TO-DO: This file breaks due to this issue:
|
|
9
|
-
// https://github.com/expo/web-examples/issues/73
|
|
10
|
-
// For now, we do not import it elsewhere to avoid crashing Expo servers on web when importing the SDK.
|
|
11
|
-
// export { default as Video } from '../blocks/video/video';
|
|
12
|
-
|
|
13
|
-
import { default as Blocks } from '../components/blocks/index';
|
|
14
|
-
import { default as Content } from '../components/content-variants/index';
|
|
15
|
-
|
|
16
|
-
export { Blocks, Content };
|
package/src/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// ignore prettier formatting for this file because the order of exports is meaningful
|
|
2
|
-
// prettier-ignore
|
|
3
|
-
export * from './index-helpers/top-of-file';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* In the React SDK, this file is marked with `use client`.
|
|
7
|
-
*/
|
|
8
|
-
// prettier-ignore
|
|
9
|
-
export * from './index-helpers/blocks-exports';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* In the React SDK, this file is not marked with `use client`, to allow
|
|
13
|
-
* NextJS App Directory to use the SDK helper functions without issues.
|
|
14
|
-
*/
|
|
15
|
-
export * from './server-index'
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { SDK_VERSION } from '../constants/sdk-version';
|
|
2
|
-
import { TARGET } from '../constants/target';
|
|
3
|
-
import { isBrowser } from '../functions/is-browser';
|
|
4
|
-
import { isFromTrustedHost } from '../functions/is-from-trusted-host';
|
|
5
|
-
import { register } from '../functions/register';
|
|
6
|
-
export const registerInsertMenu = () => {
|
|
7
|
-
register('insertMenu', {
|
|
8
|
-
name: '_default',
|
|
9
|
-
default: true,
|
|
10
|
-
items: [{
|
|
11
|
-
name: 'Box'
|
|
12
|
-
}, {
|
|
13
|
-
name: 'Text'
|
|
14
|
-
}, {
|
|
15
|
-
name: 'Image'
|
|
16
|
-
}, {
|
|
17
|
-
name: 'Columns'
|
|
18
|
-
}, ...(TARGET === 'reactNative' ? [] : [{
|
|
19
|
-
name: 'Core:Section'
|
|
20
|
-
}, {
|
|
21
|
-
name: 'Core:Button'
|
|
22
|
-
}, {
|
|
23
|
-
name: 'Embed'
|
|
24
|
-
}, {
|
|
25
|
-
name: 'Custom Code'
|
|
26
|
-
}])]
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
let isSetupForEditing = false;
|
|
30
|
-
export const setupBrowserForEditing = (options: {
|
|
31
|
-
enrich?: boolean;
|
|
32
|
-
includeRefs?: boolean;
|
|
33
|
-
locale?: string;
|
|
34
|
-
trustedHosts?: string[];
|
|
35
|
-
} = {}) => {
|
|
36
|
-
if (isSetupForEditing) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
isSetupForEditing = true;
|
|
40
|
-
if (isBrowser()) {
|
|
41
|
-
window.parent?.postMessage({
|
|
42
|
-
type: 'builder.sdkInfo',
|
|
43
|
-
data: {
|
|
44
|
-
target: TARGET,
|
|
45
|
-
version: SDK_VERSION,
|
|
46
|
-
supportsPatchUpdates: false,
|
|
47
|
-
// Supports builder-model="..." attribute which is needed to
|
|
48
|
-
// scope our '+ add block' button styling
|
|
49
|
-
supportsAddBlockScoping: true,
|
|
50
|
-
supportsCustomBreakpoints: true
|
|
51
|
-
}
|
|
52
|
-
}, '*');
|
|
53
|
-
window.parent?.postMessage({
|
|
54
|
-
type: 'builder.updateContent',
|
|
55
|
-
data: {
|
|
56
|
-
options
|
|
57
|
-
}
|
|
58
|
-
}, '*');
|
|
59
|
-
window.addEventListener('message', (event: MessageEvent) => {
|
|
60
|
-
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const {
|
|
64
|
-
data
|
|
65
|
-
} = event;
|
|
66
|
-
if (!data?.type) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
switch (data.type) {
|
|
70
|
-
case 'builder.evaluate':
|
|
71
|
-
{
|
|
72
|
-
const text = data.data.text;
|
|
73
|
-
const args = data.data.arguments || [];
|
|
74
|
-
const id = data.data.id;
|
|
75
|
-
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
76
|
-
const fn = new Function(text);
|
|
77
|
-
let result: any;
|
|
78
|
-
let error: Error | null = null;
|
|
79
|
-
try {
|
|
80
|
-
// eslint-disable-next-line prefer-spread
|
|
81
|
-
result = fn.apply(null, args);
|
|
82
|
-
} catch (err) {
|
|
83
|
-
error = (err as Error);
|
|
84
|
-
}
|
|
85
|
-
if (error) {
|
|
86
|
-
window.parent?.postMessage({
|
|
87
|
-
type: 'builder.evaluateError',
|
|
88
|
-
data: {
|
|
89
|
-
id,
|
|
90
|
-
error: error.message
|
|
91
|
-
}
|
|
92
|
-
}, '*');
|
|
93
|
-
} else {
|
|
94
|
-
if (result && typeof result.then === 'function') {
|
|
95
|
-
(result as Promise<any>).then(finalResult => {
|
|
96
|
-
window.parent?.postMessage({
|
|
97
|
-
type: 'builder.evaluateResult',
|
|
98
|
-
data: {
|
|
99
|
-
id,
|
|
100
|
-
result: finalResult
|
|
101
|
-
}
|
|
102
|
-
}, '*');
|
|
103
|
-
}).catch(console.error);
|
|
104
|
-
} else {
|
|
105
|
-
window.parent?.postMessage({
|
|
106
|
-
type: 'builder.evaluateResult',
|
|
107
|
-
data: {
|
|
108
|
-
result,
|
|
109
|
-
id
|
|
110
|
-
}
|
|
111
|
-
}, '*');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
package/src/server-index.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export * from './index-helpers/top-of-file';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Component Prop types
|
|
5
|
-
*/
|
|
6
|
-
export type { ButtonProps } from './blocks/button/button.types';
|
|
7
|
-
export type { ColumnProps } from './blocks/columns/columns.types';
|
|
8
|
-
export type { FragmentProps } from './blocks/fragment/fragment.types';
|
|
9
|
-
export type { ImageProps } from './blocks/image/image.types';
|
|
10
|
-
export type { SectionProps } from './blocks/section/section.types';
|
|
11
|
-
export type { SymbolProps } from './blocks/symbol/symbol.types';
|
|
12
|
-
export type { TextProps } from './blocks/text/text.types';
|
|
13
|
-
export type { VideoProps } from './blocks/video/video.types';
|
|
14
|
-
export type { BlocksProps } from './components/blocks/blocks.types';
|
|
15
|
-
export type { ContentVariantsPrps as ContentProps } from './components/content-variants/content-variants.types';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* General Builder types
|
|
19
|
-
*/
|
|
20
|
-
export type { RegisteredComponent } from './context/types';
|
|
21
|
-
export type { BuilderBlock } from './types/builder-block';
|
|
22
|
-
export type { BuilderContent } from './types/builder-content';
|
|
23
|
-
export type { ComponentInfo } from './types/components';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Helper functions
|
|
27
|
-
*/
|
|
28
|
-
export { isEditing } from './functions/is-editing';
|
|
29
|
-
export { isPreviewing } from './functions/is-previewing';
|
|
30
|
-
export { createRegisterComponentMessage } from './functions/register-component';
|
|
31
|
-
export { register } from './functions/register';
|
|
32
|
-
export type { InsertMenuConfig, InsertMenuItem } from './functions/register';
|
|
33
|
-
export { setEditorSettings } from './functions/set-editor-settings';
|
|
34
|
-
export type { Settings } from './functions/set-editor-settings';
|
|
35
|
-
export { getBuilderSearchParams } from './functions/get-builder-search-params/index';
|
|
36
|
-
export { track } from './functions/track/index';
|
|
37
|
-
export { subscribeToEditor } from './helpers/subscribe-to-editor';
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Content fetching
|
|
41
|
-
*/
|
|
42
|
-
export { fetchBuilderProps } from './functions/fetch-builder-props';
|
|
43
|
-
export { _processContentResult, fetchEntries, fetchOneEntry } from './functions/get-content/index'
|
package/src/types/api-version.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
type JSONValue = string | number | boolean | JSONObject | JSONArray;
|
|
2
|
-
interface JSONObject {
|
|
3
|
-
[x: string]: JSONValue;
|
|
4
|
-
}
|
|
5
|
-
interface JSONArray extends Array<JSONValue> {}
|
|
6
|
-
export interface AnimationStep {
|
|
7
|
-
// First one is always start state
|
|
8
|
-
// isStartState?: boolean;
|
|
9
|
-
styles: {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
};
|
|
12
|
-
delay?: number;
|
|
13
|
-
}
|
|
14
|
-
export interface BuilderAnimation {
|
|
15
|
-
elementId: string;
|
|
16
|
-
trigger: string;
|
|
17
|
-
steps: AnimationStep[];
|
|
18
|
-
duration: number;
|
|
19
|
-
delay?: number;
|
|
20
|
-
easing?: string;
|
|
21
|
-
// TODO: deprecate - only here because of an API bug
|
|
22
|
-
id?: string;
|
|
23
|
-
// only apply in scrollInView
|
|
24
|
-
repeat?: boolean;
|
|
25
|
-
// only apply in scrollInView, number from -1 to 1
|
|
26
|
-
thresholdPercent?: number;
|
|
27
|
-
}
|
|
28
|
-
/** @todo typedoc this */
|
|
29
|
-
export interface BuilderBlock {
|
|
30
|
-
'@type': '@builder.io/sdk:Element';
|
|
31
|
-
'@version'?: number;
|
|
32
|
-
id?: string;
|
|
33
|
-
tagName?: string;
|
|
34
|
-
layerName?: string;
|
|
35
|
-
groupLocked?: boolean;
|
|
36
|
-
layerLocked?: boolean;
|
|
37
|
-
/** @todo make alias for properties.class */
|
|
38
|
-
class?: string;
|
|
39
|
-
children?: BuilderBlock[];
|
|
40
|
-
responsiveStyles?: {
|
|
41
|
-
large?: Partial<CSSStyleDeclaration>;
|
|
42
|
-
medium?: Partial<CSSStyleDeclaration>;
|
|
43
|
-
small?: Partial<CSSStyleDeclaration>;
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
xsmall?: Partial<CSSStyleDeclaration>;
|
|
46
|
-
};
|
|
47
|
-
component?: {
|
|
48
|
-
name: string;
|
|
49
|
-
options?: any;
|
|
50
|
-
tag?: string;
|
|
51
|
-
};
|
|
52
|
-
bindings?: {
|
|
53
|
-
[key: string]: string;
|
|
54
|
-
};
|
|
55
|
-
meta?: {
|
|
56
|
-
[key: string]: JSONValue;
|
|
57
|
-
};
|
|
58
|
-
actions?: {
|
|
59
|
-
[key: string]: string;
|
|
60
|
-
};
|
|
61
|
-
properties?: {
|
|
62
|
-
[key: string]: string;
|
|
63
|
-
};
|
|
64
|
-
code?: {
|
|
65
|
-
bindings?: {
|
|
66
|
-
[key: string]: string;
|
|
67
|
-
};
|
|
68
|
-
actions?: {
|
|
69
|
-
[key: string]: string;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
repeat?: {
|
|
73
|
-
collection: string;
|
|
74
|
-
itemName?: string;
|
|
75
|
-
} | null;
|
|
76
|
-
animations?: BuilderAnimation[];
|
|
77
|
-
style?: Partial<CSSStyleDeclaration>;
|
|
78
|
-
href?: string;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* generated by the "Hide If" binding
|
|
82
|
-
*/
|
|
83
|
-
hide?: boolean;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* generated by the "Show If" binding
|
|
87
|
-
*/
|
|
88
|
-
show?: boolean;
|
|
89
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { BuilderBlock } from './builder-block';
|
|
2
|
-
import type { Input } from './input';
|
|
3
|
-
import type { Nullable } from './typescript';
|
|
4
|
-
export interface Breakpoints {
|
|
5
|
-
small: number;
|
|
6
|
-
medium: number;
|
|
7
|
-
}
|
|
8
|
-
export interface BuilderContentVariation {
|
|
9
|
-
data?: {
|
|
10
|
-
title?: string;
|
|
11
|
-
blocks?: BuilderBlock[];
|
|
12
|
-
inputs?: Input[];
|
|
13
|
-
state?: {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
};
|
|
16
|
-
jsCode?: string;
|
|
17
|
-
tsCode?: string;
|
|
18
|
-
httpRequests?: {
|
|
19
|
-
[key: string]: string;
|
|
20
|
-
};
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
};
|
|
23
|
-
name?: string;
|
|
24
|
-
testRatio?: number;
|
|
25
|
-
id?: string;
|
|
26
|
-
meta?: {
|
|
27
|
-
breakpoints?: Nullable<Breakpoints>;
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// TODO: separate full and partial versions
|
|
33
|
-
export interface BuilderContent extends BuilderContentVariation {
|
|
34
|
-
// TODO: query
|
|
35
|
-
'@version'?: number;
|
|
36
|
-
published?: 'published' | 'draft' | 'archived';
|
|
37
|
-
modelId?: string;
|
|
38
|
-
priority?: number;
|
|
39
|
-
lastUpdated?: number;
|
|
40
|
-
startDate?: number;
|
|
41
|
-
endDate?: number;
|
|
42
|
-
variations?: {
|
|
43
|
-
[id: string]: BuilderContentVariation;
|
|
44
|
-
};
|
|
45
|
-
testVariationId?: string;
|
|
46
|
-
testVariationName?: string;
|
|
47
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { BuilderContextInterface, RegisteredComponents } from '../context/types';
|
|
2
|
-
import type { BuilderBlock } from './builder-block';
|
|
3
|
-
export type BuilderDataProps = {
|
|
4
|
-
builderBlock: BuilderBlock;
|
|
5
|
-
builderContext: BuilderContextInterface;
|
|
6
|
-
};
|
|
7
|
-
export type BuilderComponentsProp = {
|
|
8
|
-
builderComponents: RegisteredComponents;
|
|
9
|
-
};
|
|
10
|
-
export type BuilderLinkComponentProp = {
|
|
11
|
-
builderLinkComponent?: any;
|
|
12
|
-
}
|
package/src/types/can-track.ts
DELETED