@builder.io/sdk-react-nextjs 0.5.8 → 0.6.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/lib/browser/USE_CLIENT_BUNDLE-29f9ac5c.js +23 -0
- package/lib/browser/USE_CLIENT_BUNDLE-dfa97c43.mjs +664 -0
- package/lib/browser/USE_SERVER_BUNDLE-25e181fa.js +1 -0
- package/lib/browser/USE_SERVER_BUNDLE-fcd44ecb.mjs +11 -0
- package/lib/browser/bundle-5cab6113.js +76 -0
- package/lib/browser/bundle-babbd573.mjs +2419 -0
- package/lib/browser/index.cjs +1 -0
- package/lib/browser/index.mjs +34 -0
- package/lib/edge/USE_CLIENT_BUNDLE-3cbb02d5.mjs +664 -0
- package/lib/edge/USE_CLIENT_BUNDLE-d0b99f60.js +23 -0
- package/lib/edge/USE_SERVER_BUNDLE-4eeb4634.mjs +11 -0
- package/lib/edge/USE_SERVER_BUNDLE-bbd89085.js +1 -0
- package/lib/edge/bundle-9ed99f98.mjs +4863 -0
- package/lib/edge/bundle-e4764e2a.js +96 -0
- package/lib/edge/index.cjs +1 -0
- package/lib/edge/index.mjs +34 -0
- package/lib/node/USE_CLIENT_BUNDLE-29f9ac5c.js +23 -0
- package/lib/node/USE_CLIENT_BUNDLE-dfa97c43.mjs +664 -0
- package/lib/node/USE_SERVER_BUNDLE-25e181fa.js +1 -0
- package/lib/node/USE_SERVER_BUNDLE-fcd44ecb.mjs +11 -0
- package/lib/node/bundle-5cab6113.js +76 -0
- package/lib/node/bundle-babbd573.mjs +2419 -0
- package/lib/node/index.cjs +1 -0
- package/lib/node/index.mjs +34 -0
- package/package.json +96 -13
- package/{dist → types}/components/content/content.types.d.ts +2 -2
- package/{dist → types}/components/content-variants/content-variants.d.ts +2 -2
- package/{dist → types}/components/content-variants/content-variants.types.d.ts +1 -1
- package/types/constants/sdk-version.d.ts +1 -0
- package/types/functions/deopt.d.ts +4 -0
- package/types/functions/evaluate/browser-runtime/browser.d.ts +4 -0
- package/types/functions/evaluate/browser-runtime/index.d.ts +1 -0
- package/types/functions/evaluate/evaluate.d.ts +6 -0
- package/types/functions/evaluate/helpers.d.ts +18 -0
- package/types/functions/evaluate/index.d.ts +1 -0
- package/{dist → types}/functions/fetch-builder-props.d.ts +4 -3
- package/{dist → types}/functions/get-content/index.d.ts +4 -5
- package/{dist → types}/index-helpers/blocks-exports.d.ts +2 -2
- package/types/index.d.ts +7 -0
- package/{dist/index.d.ts → types/server-index.d.ts} +0 -1
- package/dist/blocks/button/button.js +0 -12
- package/dist/blocks/button/component-info.js +0 -34
- package/dist/blocks/columns/columns.js +0 -119
- package/dist/blocks/columns/component-info.js +0 -219
- package/dist/blocks/custom-code/component-info.js +0 -23
- package/dist/blocks/custom-code/custom-code.js +0 -51
- package/dist/blocks/embed/component-info.js +0 -39
- package/dist/blocks/embed/embed.js +0 -42
- package/dist/blocks/embed/helpers.js +0 -2
- package/dist/blocks/fragment/component-info.js +0 -7
- package/dist/blocks/fragment/fragment.js +0 -6
- package/dist/blocks/helpers.js +0 -40
- package/dist/blocks/image/component-info.js +0 -122
- package/dist/blocks/image/image.helpers.js +0 -47
- package/dist/blocks/image/image.js +0 -82
- package/dist/blocks/img/component-info.js +0 -15
- package/dist/blocks/img/img.js +0 -10
- package/dist/blocks/section/component-info.js +0 -40
- package/dist/blocks/section/section.js +0 -17
- package/dist/blocks/symbol/component-info.js +0 -34
- package/dist/blocks/symbol/symbol.helpers.js +0 -31
- package/dist/blocks/symbol/symbol.js +0 -29
- package/dist/blocks/text/component-info.js +0 -19
- package/dist/blocks/text/text.js +0 -7
- package/dist/blocks/video/component-info.js +0 -82
- package/dist/blocks/video/video.js +0 -50
- package/dist/components/block/block.helpers.js +0 -69
- package/dist/components/block/block.js +0 -92
- package/dist/components/block/components/block-styles.js +0 -65
- package/dist/components/block/components/block-wrapper.js +0 -36
- package/dist/components/block/components/component-ref/component-ref.helpers.js +0 -22
- package/dist/components/block/components/component-ref/component-ref.js +0 -21
- package/dist/components/block/components/interactive-element.js +0 -20
- package/dist/components/block/components/repeated-block.js +0 -7
- package/dist/components/block/types.js +0 -1
- package/dist/components/blocks/blocks-wrapper.js +0 -38
- package/dist/components/blocks/blocks.js +0 -10
- package/dist/components/content/components/enable-editor.js +0 -250
- package/dist/components/content/components/styles.helpers.js +0 -58
- package/dist/components/content/components/styles.js +0 -30
- package/dist/components/content/content.helpers.js +0 -30
- package/dist/components/content/content.js +0 -74
- package/dist/components/content/content.types.js +0 -1
- package/dist/components/content/wrap-component-ref.js +0 -6
- package/dist/components/content-variants/content-variants.js +0 -45
- package/dist/components/content-variants/content-variants.types.js +0 -1
- package/dist/components/content-variants/helpers.js +0 -189
- package/dist/components/inlined-script.js +0 -5
- package/dist/components/inlined-styles.js +0 -5
- package/dist/constants/builder-registered-components.js +0 -60
- package/dist/constants/device-sizes.js +0 -45
- package/dist/constants/sdk-version.d.ts +0 -1
- package/dist/constants/sdk-version.js +0 -1
- package/dist/constants/target.js +0 -2
- package/dist/context/builder.context.js +0 -12
- package/dist/context/components.context.js +0 -2
- package/dist/context/types.js +0 -1
- package/dist/functions/camel-to-kebab-case.js +0 -1
- package/dist/functions/evaluate/acorn-interpreter.d.ts +0 -2
- package/dist/functions/evaluate/acorn-interpreter.js +0 -3111
- package/dist/functions/evaluate/evaluate.d.ts +0 -10
- package/dist/functions/evaluate/evaluate.js +0 -70
- package/dist/functions/evaluate/index.d.ts +0 -1
- package/dist/functions/evaluate/index.js +0 -1
- package/dist/functions/evaluate/non-node-runtime/index.d.ts +0 -1
- package/dist/functions/evaluate/non-node-runtime/index.js +0 -2
- package/dist/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +0 -2
- package/dist/functions/evaluate/non-node-runtime/non-node-runtime.js +0 -84
- package/dist/functions/evaluate/types.d.ts +0 -11
- package/dist/functions/evaluate/types.js +0 -1
- package/dist/functions/event-handler-name.js +0 -4
- package/dist/functions/extract-text-styles.js +0 -22
- package/dist/functions/fast-clone.js +0 -4
- package/dist/functions/fetch-builder-props.js +0 -25
- package/dist/functions/get-block-actions-handler.js +0 -10
- package/dist/functions/get-block-actions.js +0 -28
- package/dist/functions/get-block-component-options.js +0 -10
- package/dist/functions/get-block-properties.js +0 -72
- package/dist/functions/get-builder-search-params/index.js +0 -38
- package/dist/functions/get-content/generate-content-url.js +0 -33
- package/dist/functions/get-content/index.js +0 -100
- package/dist/functions/get-content/types.js +0 -1
- package/dist/functions/get-fetch.js +0 -11
- package/dist/functions/get-global-this.js +0 -15
- package/dist/functions/get-processed-block.js +0 -46
- package/dist/functions/get-react-native-block-styles.js +0 -17
- package/dist/functions/is-browser.js +0 -3
- package/dist/functions/is-editing.js +0 -5
- package/dist/functions/is-iframe.js +0 -4
- package/dist/functions/is-non-node-server.d.ts +0 -4
- package/dist/functions/is-non-node-server.js +0 -8
- package/dist/functions/is-previewing.js +0 -11
- package/dist/functions/register-component.js +0 -38
- package/dist/functions/register.js +0 -27
- package/dist/functions/sanitize-react-native-block-styles.js +0 -61
- package/dist/functions/set-editor-settings.js +0 -12
- package/dist/functions/set.js +0 -14
- package/dist/functions/track/helpers.js +0 -51
- package/dist/functions/track/index.js +0 -71
- package/dist/functions/track/interaction.js +0 -53
- package/dist/functions/transform-block-properties.js +0 -5
- package/dist/functions/transform-block.js +0 -4
- package/dist/helpers/ab-tests.js +0 -122
- package/dist/helpers/canTrack.js +0 -2
- package/dist/helpers/cookie.js +0 -55
- package/dist/helpers/css.js +0 -27
- package/dist/helpers/flatten.js +0 -19
- package/dist/helpers/localStorage.js +0 -24
- package/dist/helpers/logger.js +0 -7
- package/dist/helpers/nullable.js +0 -1
- package/dist/helpers/preview-lru-cache/get.js +0 -9
- package/dist/helpers/preview-lru-cache/helpers.js +0 -9
- package/dist/helpers/preview-lru-cache/init.js +0 -15
- package/dist/helpers/preview-lru-cache/set.js +0 -7
- package/dist/helpers/preview-lru-cache/types.js +0 -6
- package/dist/helpers/sessionId.js +0 -30
- package/dist/helpers/url.js +0 -15
- package/dist/helpers/uuid.js +0 -15
- package/dist/helpers/visitorId.js +0 -30
- package/dist/index-helpers/blocks-exports.js +0 -19
- package/dist/index-helpers/top-of-file.js +0 -4
- package/dist/index.js +0 -11
- package/dist/scripts/init-editing.js +0 -110
- package/dist/types/api-version.js +0 -1
- package/dist/types/builder-block.js +0 -1
- package/dist/types/builder-content.js +0 -1
- package/dist/types/builder-props.js +0 -1
- package/dist/types/can-track.js +0 -1
- package/dist/types/components.js +0 -1
- package/dist/types/deep-partial.js +0 -1
- package/dist/types/element.js +0 -1
- package/dist/types/enforced-partials.js +0 -1
- package/dist/types/input.js +0 -1
- package/dist/types/targets.js +0 -1
- package/dist/types/typescript.js +0 -1
- /package/{dist → types}/blocks/button/button.d.ts +0 -0
- /package/{dist → types}/blocks/button/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/columns/columns.d.ts +0 -0
- /package/{dist → types}/blocks/columns/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/custom-code/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/custom-code/custom-code.d.ts +0 -0
- /package/{dist → types}/blocks/embed/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/embed/embed.d.ts +0 -0
- /package/{dist → types}/blocks/embed/helpers.d.ts +0 -0
- /package/{dist → types}/blocks/fragment/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/fragment/fragment.d.ts +0 -0
- /package/{dist → types}/blocks/helpers.d.ts +0 -0
- /package/{dist → types}/blocks/image/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/image/image.d.ts +0 -0
- /package/{dist → types}/blocks/image/image.helpers.d.ts +0 -0
- /package/{dist → types}/blocks/img/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/img/img.d.ts +0 -0
- /package/{dist → types}/blocks/section/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/section/section.d.ts +0 -0
- /package/{dist → types}/blocks/symbol/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/symbol/symbol.d.ts +0 -0
- /package/{dist → types}/blocks/symbol/symbol.helpers.d.ts +0 -0
- /package/{dist → types}/blocks/text/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/text/text.d.ts +0 -0
- /package/{dist → types}/blocks/video/component-info.d.ts +0 -0
- /package/{dist → types}/blocks/video/video.d.ts +0 -0
- /package/{dist → types}/components/block/block.d.ts +0 -0
- /package/{dist → types}/components/block/block.helpers.d.ts +0 -0
- /package/{dist → types}/components/block/components/block-styles.d.ts +0 -0
- /package/{dist → types}/components/block/components/block-wrapper.d.ts +0 -0
- /package/{dist → types}/components/block/components/component-ref/component-ref.d.ts +0 -0
- /package/{dist → types}/components/block/components/component-ref/component-ref.helpers.d.ts +0 -0
- /package/{dist → types}/components/block/components/interactive-element.d.ts +0 -0
- /package/{dist → types}/components/block/components/repeated-block.d.ts +0 -0
- /package/{dist → types}/components/block/types.d.ts +0 -0
- /package/{dist → types}/components/blocks/blocks-wrapper.d.ts +0 -0
- /package/{dist → types}/components/blocks/blocks.d.ts +0 -0
- /package/{dist → types}/components/content/components/enable-editor.d.ts +0 -0
- /package/{dist → types}/components/content/components/styles.d.ts +0 -0
- /package/{dist → types}/components/content/components/styles.helpers.d.ts +0 -0
- /package/{dist → types}/components/content/content.d.ts +0 -0
- /package/{dist → types}/components/content/content.helpers.d.ts +0 -0
- /package/{dist → types}/components/content/wrap-component-ref.d.ts +0 -0
- /package/{dist → types}/components/content-variants/helpers.d.ts +0 -0
- /package/{dist → types}/components/inlined-script.d.ts +0 -0
- /package/{dist → types}/components/inlined-styles.d.ts +0 -0
- /package/{dist → types}/constants/builder-registered-components.d.ts +0 -0
- /package/{dist → types}/constants/device-sizes.d.ts +0 -0
- /package/{dist → types}/constants/target.d.ts +0 -0
- /package/{dist → types}/context/builder.context.d.ts +0 -0
- /package/{dist → types}/context/components.context.d.ts +0 -0
- /package/{dist → types}/context/types.d.ts +0 -0
- /package/{dist → types}/functions/camel-to-kebab-case.d.ts +0 -0
- /package/{dist → types}/functions/event-handler-name.d.ts +0 -0
- /package/{dist → types}/functions/extract-text-styles.d.ts +0 -0
- /package/{dist → types}/functions/fast-clone.d.ts +0 -0
- /package/{dist → types}/functions/get-block-actions-handler.d.ts +0 -0
- /package/{dist → types}/functions/get-block-actions.d.ts +0 -0
- /package/{dist → types}/functions/get-block-component-options.d.ts +0 -0
- /package/{dist → types}/functions/get-block-properties.d.ts +0 -0
- /package/{dist → types}/functions/get-builder-search-params/index.d.ts +0 -0
- /package/{dist → types}/functions/get-content/generate-content-url.d.ts +0 -0
- /package/{dist → types}/functions/get-content/types.d.ts +0 -0
- /package/{dist → types}/functions/get-fetch.d.ts +0 -0
- /package/{dist → types}/functions/get-global-this.d.ts +0 -0
- /package/{dist → types}/functions/get-processed-block.d.ts +0 -0
- /package/{dist → types}/functions/get-react-native-block-styles.d.ts +0 -0
- /package/{dist → types}/functions/is-browser.d.ts +0 -0
- /package/{dist → types}/functions/is-editing.d.ts +0 -0
- /package/{dist → types}/functions/is-iframe.d.ts +0 -0
- /package/{dist → types}/functions/is-previewing.d.ts +0 -0
- /package/{dist → types}/functions/register-component.d.ts +0 -0
- /package/{dist → types}/functions/register.d.ts +0 -0
- /package/{dist → types}/functions/sanitize-react-native-block-styles.d.ts +0 -0
- /package/{dist → types}/functions/set-editor-settings.d.ts +0 -0
- /package/{dist → types}/functions/set.d.ts +0 -0
- /package/{dist → types}/functions/track/helpers.d.ts +0 -0
- /package/{dist → types}/functions/track/index.d.ts +0 -0
- /package/{dist → types}/functions/track/interaction.d.ts +0 -0
- /package/{dist → types}/functions/transform-block-properties.d.ts +0 -0
- /package/{dist → types}/functions/transform-block.d.ts +0 -0
- /package/{dist → types}/helpers/ab-tests.d.ts +0 -0
- /package/{dist → types}/helpers/canTrack.d.ts +0 -0
- /package/{dist → types}/helpers/cookie.d.ts +0 -0
- /package/{dist → types}/helpers/css.d.ts +0 -0
- /package/{dist → types}/helpers/flatten.d.ts +0 -0
- /package/{dist → types}/helpers/localStorage.d.ts +0 -0
- /package/{dist → types}/helpers/logger.d.ts +0 -0
- /package/{dist → types}/helpers/nullable.d.ts +0 -0
- /package/{dist → types}/helpers/preview-lru-cache/get.d.ts +0 -0
- /package/{dist → types}/helpers/preview-lru-cache/helpers.d.ts +0 -0
- /package/{dist → types}/helpers/preview-lru-cache/init.d.ts +0 -0
- /package/{dist → types}/helpers/preview-lru-cache/set.d.ts +0 -0
- /package/{dist → types}/helpers/preview-lru-cache/types.d.ts +0 -0
- /package/{dist → types}/helpers/sessionId.d.ts +0 -0
- /package/{dist → types}/helpers/url.d.ts +0 -0
- /package/{dist → types}/helpers/uuid.d.ts +0 -0
- /package/{dist → types}/helpers/visitorId.d.ts +0 -0
- /package/{dist → types}/index-helpers/top-of-file.d.ts +0 -0
- /package/{dist → types}/scripts/init-editing.d.ts +0 -0
- /package/{dist → types}/types/api-version.d.ts +0 -0
- /package/{dist → types}/types/builder-block.d.ts +0 -0
- /package/{dist → types}/types/builder-content.d.ts +0 -0
- /package/{dist → types}/types/builder-props.d.ts +0 -0
- /package/{dist → types}/types/can-track.d.ts +0 -0
- /package/{dist → types}/types/components.d.ts +0 -0
- /package/{dist → types}/types/deep-partial.d.ts +0 -0
- /package/{dist → types}/types/element.d.ts +0 -0
- /package/{dist → types}/types/enforced-partials.d.ts +0 -0
- /package/{dist → types}/types/input.d.ts +0 -0
- /package/{dist → types}/types/targets.d.ts +0 -0
- /package/{dist → types}/types/typescript.d.ts +0 -0
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from './is-browser.js';
|
|
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
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from './is-browser.js';
|
|
2
|
-
import { isEditing } from './is-editing.js';
|
|
3
|
-
export function isPreviewing() {
|
|
4
|
-
if (!isBrowser()) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
if (isEditing()) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
return Boolean(location.search.indexOf('builder.preview=') !== -1);
|
|
11
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { fastClone } from './fast-clone.js';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
4
|
-
*/
|
|
5
|
-
export const components = [];
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
8
|
-
*/
|
|
9
|
-
export function registerComponent(component, info) {
|
|
10
|
-
components.push({
|
|
11
|
-
component,
|
|
12
|
-
...info
|
|
13
|
-
});
|
|
14
|
-
console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
|
|
15
|
-
return component;
|
|
16
|
-
}
|
|
17
|
-
export const createRegisterComponentMessage = (info) => ({
|
|
18
|
-
type: 'builder.registerComponent',
|
|
19
|
-
data: serializeComponentInfo(info)
|
|
20
|
-
});
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22
|
-
const serializeFn = (fnValue) => {
|
|
23
|
-
const fnStr = fnValue.toString().trim();
|
|
24
|
-
// we need to account for a few different fn syntaxes:
|
|
25
|
-
// 1. `function name(args) => {code}`
|
|
26
|
-
// 2. `name(args) => {code}`
|
|
27
|
-
// 3. `(args) => {}`
|
|
28
|
-
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
29
|
-
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
30
|
-
};
|
|
31
|
-
const serializeValue = (value) => typeof value === 'function' ? serializeFn(value) : fastClone(value);
|
|
32
|
-
export const serializeComponentInfo = ({ inputs, ...info }) => ({
|
|
33
|
-
...fastClone(info),
|
|
34
|
-
inputs: inputs?.map(input => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
35
|
-
...acc,
|
|
36
|
-
[key]: serializeValue(value)
|
|
37
|
-
}), {}))
|
|
38
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from './is-browser.js';
|
|
2
|
-
const registry = {};
|
|
3
|
-
export function register(type, info) {
|
|
4
|
-
let typeList = registry[type];
|
|
5
|
-
if (!typeList) {
|
|
6
|
-
typeList = registry[type] = [];
|
|
7
|
-
}
|
|
8
|
-
typeList.push(info);
|
|
9
|
-
if (isBrowser()) {
|
|
10
|
-
const message = {
|
|
11
|
-
type: 'builder.register',
|
|
12
|
-
data: {
|
|
13
|
-
type,
|
|
14
|
-
info
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
try {
|
|
18
|
-
parent.postMessage(message, '*');
|
|
19
|
-
if (parent !== window) {
|
|
20
|
-
window.postMessage(message, '*');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
console.debug('Could not postmessage', err);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const propertiesThatMustBeNumber = new Set(['lineHeight']);
|
|
2
|
-
const displayValues = new Set(['flex', 'none']);
|
|
3
|
-
const SHOW_WARNINGS = false;
|
|
4
|
-
const normalizeNumber = (value) => {
|
|
5
|
-
if (Number.isNaN(value)) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
else if (value < 0) {
|
|
9
|
-
// TODO: why are negative values not allowed?
|
|
10
|
-
return 0;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export const sanitizeReactNativeBlockStyles = (styles) => {
|
|
17
|
-
return Object.keys(styles).reduce((acc, key) => {
|
|
18
|
-
const propertyValue = styles[key];
|
|
19
|
-
if (key === 'display' && !displayValues.has(propertyValue)) {
|
|
20
|
-
if (SHOW_WARNINGS) {
|
|
21
|
-
console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
|
|
22
|
-
}
|
|
23
|
-
return acc;
|
|
24
|
-
}
|
|
25
|
-
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== 'number') {
|
|
26
|
-
if (SHOW_WARNINGS) {
|
|
27
|
-
console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
|
|
28
|
-
}
|
|
29
|
-
return acc;
|
|
30
|
-
}
|
|
31
|
-
if (typeof propertyValue === 'string') {
|
|
32
|
-
// `px` units need to be stripped and replaced with numbers
|
|
33
|
-
// https://regexr.com/6ualn
|
|
34
|
-
const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
|
|
35
|
-
if (isPixelUnit) {
|
|
36
|
-
const newValue = parseFloat(propertyValue);
|
|
37
|
-
const normalizedValue = normalizeNumber(newValue);
|
|
38
|
-
if (normalizedValue) {
|
|
39
|
-
return {
|
|
40
|
-
...acc,
|
|
41
|
-
[key]: normalizedValue
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
return acc;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else if (propertyValue === '0') {
|
|
49
|
-
// 0 edge case needs to be handled
|
|
50
|
-
return {
|
|
51
|
-
...acc,
|
|
52
|
-
[key]: 0
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
...acc,
|
|
58
|
-
[key]: propertyValue
|
|
59
|
-
};
|
|
60
|
-
}, {});
|
|
61
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from './is-browser.js';
|
|
2
|
-
const settings = {};
|
|
3
|
-
export function setEditorSettings(newSettings) {
|
|
4
|
-
if (isBrowser()) {
|
|
5
|
-
Object.assign(settings, newSettings);
|
|
6
|
-
const message = {
|
|
7
|
-
type: 'builder.settingsChange',
|
|
8
|
-
data: settings
|
|
9
|
-
};
|
|
10
|
-
parent.postMessage(message, '*');
|
|
11
|
-
}
|
|
12
|
-
}
|
package/dist/functions/set.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal implementation of lodash's _.set
|
|
3
|
-
* https://lodash.com/docs/4.17.15#set
|
|
4
|
-
*
|
|
5
|
-
* See ./set.test.ts for usage examples
|
|
6
|
-
*/
|
|
7
|
-
export const set = (obj, _path, value) => {
|
|
8
|
-
if (Object(obj) !== obj) {
|
|
9
|
-
return obj;
|
|
10
|
-
}
|
|
11
|
-
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
12
|
-
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
13
|
-
return obj;
|
|
14
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { TARGET } from '../../constants/target.js';
|
|
2
|
-
import { isBrowser } from '../is-browser.js';
|
|
3
|
-
const getLocation = () => {
|
|
4
|
-
if (TARGET === 'reactNative') {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
else if (isBrowser()) {
|
|
8
|
-
const parsedLocation = new URL(location.href);
|
|
9
|
-
// IE11 bug with parsed path being empty string
|
|
10
|
-
// causes issues with our user targeting
|
|
11
|
-
if (parsedLocation.pathname === '') {
|
|
12
|
-
parsedLocation.pathname = '/';
|
|
13
|
-
}
|
|
14
|
-
return parsedLocation;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
console.warn('Cannot get location for tracking in non-browser environment');
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const getUserAgent = () => typeof navigator === 'object' && navigator.userAgent || '';
|
|
22
|
-
export const getUserAttributes = () => {
|
|
23
|
-
const userAgent = getUserAgent();
|
|
24
|
-
const isMobile = {
|
|
25
|
-
Android() {
|
|
26
|
-
return userAgent.match(/Android/i);
|
|
27
|
-
},
|
|
28
|
-
BlackBerry() {
|
|
29
|
-
return userAgent.match(/BlackBerry/i);
|
|
30
|
-
},
|
|
31
|
-
iOS() {
|
|
32
|
-
return userAgent.match(/iPhone|iPod/i);
|
|
33
|
-
},
|
|
34
|
-
Opera() {
|
|
35
|
-
return userAgent.match(/Opera Mini/i);
|
|
36
|
-
},
|
|
37
|
-
Windows() {
|
|
38
|
-
return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
|
|
39
|
-
},
|
|
40
|
-
any() {
|
|
41
|
-
return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || TARGET === 'reactNative';
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
45
|
-
const url = getLocation();
|
|
46
|
-
return {
|
|
47
|
-
urlPath: url?.pathname,
|
|
48
|
-
host: url?.host || url?.hostname,
|
|
49
|
-
device: isTablet ? 'tablet' : isMobile.any() ? 'mobile' : 'desktop'
|
|
50
|
-
};
|
|
51
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { TARGET } from '../../constants/target.js';
|
|
2
|
-
import { logger } from '../../helpers/logger.js';
|
|
3
|
-
import { getSessionId } from '../../helpers/sessionId.js';
|
|
4
|
-
import { getVisitorId } from '../../helpers/visitorId.js';
|
|
5
|
-
import { isBrowser } from '../is-browser.js';
|
|
6
|
-
import { isEditing } from '../is-editing.js';
|
|
7
|
-
import { getUserAttributes } from './helpers.js';
|
|
8
|
-
const getTrackingEventData = async ({ canTrack }) => {
|
|
9
|
-
if (!canTrack) {
|
|
10
|
-
return {
|
|
11
|
-
visitorId: undefined,
|
|
12
|
-
sessionId: undefined
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const sessionId = await getSessionId({
|
|
16
|
-
canTrack
|
|
17
|
-
});
|
|
18
|
-
const visitorId = getVisitorId({
|
|
19
|
-
canTrack
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
sessionId,
|
|
23
|
-
visitorId
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...properties }) => ({
|
|
27
|
-
type: eventType,
|
|
28
|
-
data: {
|
|
29
|
-
...properties,
|
|
30
|
-
metadata: {
|
|
31
|
-
url: location.href,
|
|
32
|
-
...metadata
|
|
33
|
-
},
|
|
34
|
-
...(await getTrackingEventData({
|
|
35
|
-
canTrack
|
|
36
|
-
})),
|
|
37
|
-
userAttributes: getUserAttributes(),
|
|
38
|
-
ownerId: apiKey
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
export async function _track(eventProps) {
|
|
42
|
-
if (!eventProps.apiKey) {
|
|
43
|
-
logger.error('Missing API key for track call. Please provide your API key.');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (!eventProps.canTrack) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (isEditing()) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (!(isBrowser() || TARGET === 'reactNative')) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
56
|
-
method: 'POST',
|
|
57
|
-
body: JSON.stringify({
|
|
58
|
-
events: [await createEvent(eventProps)]
|
|
59
|
-
}),
|
|
60
|
-
headers: {
|
|
61
|
-
'content-type': 'application/json'
|
|
62
|
-
},
|
|
63
|
-
mode: 'cors'
|
|
64
|
-
}).catch(err => {
|
|
65
|
-
console.error('Failed to track: ', err);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
export const track = (args) => _track({
|
|
69
|
-
...args,
|
|
70
|
-
canTrack: true
|
|
71
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
function round(num) {
|
|
2
|
-
return Math.round(num * 1000) / 1000;
|
|
3
|
-
}
|
|
4
|
-
const findParentElement = (target, callback, checkElement = true) => {
|
|
5
|
-
if (!(target instanceof HTMLElement)) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
let parent = checkElement ? target : target.parentElement;
|
|
9
|
-
do {
|
|
10
|
-
if (!parent) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const matches = callback(parent);
|
|
14
|
-
if (matches) {
|
|
15
|
-
return parent;
|
|
16
|
-
}
|
|
17
|
-
} while (parent = parent.parentElement);
|
|
18
|
-
return null;
|
|
19
|
-
};
|
|
20
|
-
const findBuilderParent = (target) => findParentElement(target, el => {
|
|
21
|
-
const id = el.getAttribute('builder-id') || el.id;
|
|
22
|
-
return Boolean(id?.indexOf('builder-') === 0);
|
|
23
|
-
});
|
|
24
|
-
const computeOffset = ({ event, target }) => {
|
|
25
|
-
const targetRect = target.getBoundingClientRect();
|
|
26
|
-
const xOffset = event.clientX - targetRect.left;
|
|
27
|
-
const yOffset = event.clientY - targetRect.top;
|
|
28
|
-
const xRatio = round(xOffset / targetRect.width);
|
|
29
|
-
const yRatio = round(yOffset / targetRect.height);
|
|
30
|
-
return {
|
|
31
|
-
x: xRatio,
|
|
32
|
-
y: yRatio
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export const getInteractionPropertiesForEvent = (event) => {
|
|
36
|
-
const target = event.target;
|
|
37
|
-
const targetBuilderElement = target && findBuilderParent(target);
|
|
38
|
-
const builderId = targetBuilderElement?.getAttribute('builder-id') || targetBuilderElement?.id;
|
|
39
|
-
return {
|
|
40
|
-
targetBuilderElement: builderId || undefined,
|
|
41
|
-
metadata: {
|
|
42
|
-
targetOffset: target ? computeOffset({
|
|
43
|
-
event,
|
|
44
|
-
target
|
|
45
|
-
}) : undefined,
|
|
46
|
-
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
47
|
-
event,
|
|
48
|
-
target: targetBuilderElement
|
|
49
|
-
}) : undefined,
|
|
50
|
-
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : undefined
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
};
|
package/dist/helpers/ab-tests.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { getCookie, getCookieSync, setCookie } from './cookie.js';
|
|
2
|
-
import { checkIsDefined } from '../helpers/nullable.js';
|
|
3
|
-
import { logger } from './logger.js';
|
|
4
|
-
import { TARGET } from '../constants/target.js';
|
|
5
|
-
const BUILDER_STORE_PREFIX = 'builder.tests';
|
|
6
|
-
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
7
|
-
const getContentVariationCookie = ({ contentId }) => getCookie({
|
|
8
|
-
name: getContentTestKey(contentId),
|
|
9
|
-
canTrack: true
|
|
10
|
-
});
|
|
11
|
-
const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
|
|
12
|
-
name: getContentTestKey(contentId),
|
|
13
|
-
canTrack: true
|
|
14
|
-
});
|
|
15
|
-
const setContentVariationCookie = ({ contentId, value }) => setCookie({
|
|
16
|
-
name: getContentTestKey(contentId),
|
|
17
|
-
value,
|
|
18
|
-
canTrack: true
|
|
19
|
-
});
|
|
20
|
-
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
21
|
-
/**
|
|
22
|
-
* Randomly assign a variation to a user
|
|
23
|
-
*/
|
|
24
|
-
const getRandomVariationId = ({ id, variations }) => {
|
|
25
|
-
let n = 0;
|
|
26
|
-
const random = Math.random();
|
|
27
|
-
// loop over variations test ratios, incrementing a counter,
|
|
28
|
-
// until we find the variation that this user should be assigned to
|
|
29
|
-
for (const id in variations) {
|
|
30
|
-
const testRatio = variations[id]?.testRatio;
|
|
31
|
-
n += testRatio;
|
|
32
|
-
if (random < n) {
|
|
33
|
-
return id;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// the variations array does not include the default variation.
|
|
37
|
-
// if we arrive here, then it means that the random number fits in the default variation bucket.
|
|
38
|
-
return id;
|
|
39
|
-
};
|
|
40
|
-
const getAndSetVariantId = (args) => {
|
|
41
|
-
// if variation not found in storage, assign a random variation to this user
|
|
42
|
-
const randomVariationId = getRandomVariationId(args);
|
|
43
|
-
// store variation in cookies/storage
|
|
44
|
-
setContentVariationCookie({
|
|
45
|
-
contentId: args.id,
|
|
46
|
-
value: randomVariationId
|
|
47
|
-
}).catch(err => {
|
|
48
|
-
logger.error('could not store A/B test variation: ', err);
|
|
49
|
-
});
|
|
50
|
-
return randomVariationId;
|
|
51
|
-
};
|
|
52
|
-
const getTestFields = ({ item, testGroupId }) => {
|
|
53
|
-
const variationValue = item.variations[testGroupId];
|
|
54
|
-
if (testGroupId === item.id ||
|
|
55
|
-
// handle edge-case where `testGroupId` points to non-existing variation
|
|
56
|
-
!variationValue) {
|
|
57
|
-
return {
|
|
58
|
-
testVariationId: item.id,
|
|
59
|
-
testVariationName: 'Default'
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return {
|
|
64
|
-
data: variationValue.data,
|
|
65
|
-
testVariationId: variationValue.id,
|
|
66
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? 'Default' : '')
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
export const handleABTestingSync = ({ item, canTrack }) => {
|
|
71
|
-
/**
|
|
72
|
-
* We cannot SSR in React-Native.
|
|
73
|
-
*/
|
|
74
|
-
if (TARGET === 'reactNative')
|
|
75
|
-
return item;
|
|
76
|
-
if (!canTrack) {
|
|
77
|
-
return item;
|
|
78
|
-
}
|
|
79
|
-
if (!item) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
if (!checkIsBuilderContentWithVariations(item)) {
|
|
83
|
-
return item;
|
|
84
|
-
}
|
|
85
|
-
const testGroupId = getContentVariationCookieSync({
|
|
86
|
-
contentId: item.id
|
|
87
|
-
}) || getAndSetVariantId({
|
|
88
|
-
variations: item.variations,
|
|
89
|
-
id: item.id
|
|
90
|
-
});
|
|
91
|
-
const variationValue = getTestFields({
|
|
92
|
-
item,
|
|
93
|
-
testGroupId
|
|
94
|
-
});
|
|
95
|
-
return {
|
|
96
|
-
...item,
|
|
97
|
-
...variationValue
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export const handleABTesting = async ({ item, canTrack }) => {
|
|
101
|
-
if (!canTrack) {
|
|
102
|
-
return item;
|
|
103
|
-
}
|
|
104
|
-
if (!checkIsBuilderContentWithVariations(item)) {
|
|
105
|
-
return item;
|
|
106
|
-
}
|
|
107
|
-
const cookieValue = await getContentVariationCookie({
|
|
108
|
-
contentId: item.id
|
|
109
|
-
});
|
|
110
|
-
const testGroupId = cookieValue || getAndSetVariantId({
|
|
111
|
-
variations: item.variations,
|
|
112
|
-
id: item.id
|
|
113
|
-
});
|
|
114
|
-
const variationValue = getTestFields({
|
|
115
|
-
item,
|
|
116
|
-
testGroupId
|
|
117
|
-
});
|
|
118
|
-
return {
|
|
119
|
-
...item,
|
|
120
|
-
...variationValue
|
|
121
|
-
};
|
|
122
|
-
};
|
package/dist/helpers/canTrack.js
DELETED
package/dist/helpers/cookie.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from '../functions/is-browser.js';
|
|
2
|
-
import { logger } from './logger.js';
|
|
3
|
-
import { checkIsDefined } from './nullable.js';
|
|
4
|
-
import { getTopLevelDomain } from './url.js';
|
|
5
|
-
export const getCookieSync = ({ name, canTrack }) => {
|
|
6
|
-
try {
|
|
7
|
-
if (!canTrack) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Extracted from MDN docs
|
|
12
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#example_2_get_a_sample_cookie_named_test2
|
|
13
|
-
*/
|
|
14
|
-
return document.cookie.split('; ').find(row => row.startsWith(`${name}=`))?.split('=')[1];
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
logger.warn('[COOKIE] GET error: ', err?.message || err);
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
23
|
-
* The sync version is only safe to use in code blocks that `react-native` is guaranteed not to not run.
|
|
24
|
-
*/
|
|
25
|
-
export const getCookie = async (args) => getCookieSync(args);
|
|
26
|
-
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join('; ');
|
|
27
|
-
const SECURE_CONFIG = [['secure', ''], ['SameSite', 'None']];
|
|
28
|
-
const createCookieString = ({ name, value, expires }) => {
|
|
29
|
-
const secure = isBrowser() ? location.protocol === 'https:' : true;
|
|
30
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
31
|
-
// TODO: need to know if secure server side
|
|
32
|
-
const expiresObj = expires ? [['expires', expires.toUTCString()]] : [[]];
|
|
33
|
-
const cookieValue = [[name, value], ...expiresObj, ['path', '/'], ['domain', getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
34
|
-
const cookie = stringifyCookie(cookieValue);
|
|
35
|
-
return cookie;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
39
|
-
*/
|
|
40
|
-
export const setCookie = async ({ name, value, expires, canTrack }) => {
|
|
41
|
-
try {
|
|
42
|
-
if (!canTrack) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const cookie = createCookieString({
|
|
46
|
-
name,
|
|
47
|
-
value,
|
|
48
|
-
expires
|
|
49
|
-
});
|
|
50
|
-
document.cookie = cookie;
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
logger.warn('[COOKIE] SET error: ', err?.message || err);
|
|
54
|
-
}
|
|
55
|
-
};
|
package/dist/helpers/css.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { camelToKebabCase } from '../functions/camel-to-kebab-case.js';
|
|
2
|
-
import { checkIsDefined } from './nullable.js';
|
|
3
|
-
export const convertStyleMapToCSSArray = (style) => {
|
|
4
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
5
|
-
if (typeof value === 'string') {
|
|
6
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return cssProps.filter(checkIsDefined);
|
|
13
|
-
};
|
|
14
|
-
export const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join('\n');
|
|
15
|
-
export const createCssClass = ({ mediaQuery, className, styles }) => {
|
|
16
|
-
const cssClass = `.${className} {
|
|
17
|
-
${convertStyleMapToCSS(styles)}
|
|
18
|
-
}`;
|
|
19
|
-
if (mediaQuery) {
|
|
20
|
-
return `${mediaQuery} {
|
|
21
|
-
${cssClass}
|
|
22
|
-
}`;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return cssClass;
|
|
26
|
-
}
|
|
27
|
-
};
|
package/dist/helpers/flatten.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert deep object to a flat object with dots
|
|
3
|
-
*
|
|
4
|
-
* { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
|
|
5
|
-
*/
|
|
6
|
-
export function flatten(object, path = null, separator = '.') {
|
|
7
|
-
return Object.keys(object).reduce((acc, key) => {
|
|
8
|
-
const value = object[key];
|
|
9
|
-
const newPath = [path, key].filter(Boolean).join(separator);
|
|
10
|
-
const isObject = [typeof value === 'object', value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
|
|
11
|
-
return isObject ? {
|
|
12
|
-
...acc,
|
|
13
|
-
...flatten(value, newPath, separator)
|
|
14
|
-
} : {
|
|
15
|
-
...acc,
|
|
16
|
-
[newPath]: value
|
|
17
|
-
};
|
|
18
|
-
}, {});
|
|
19
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from '../functions/is-browser.js';
|
|
2
|
-
const getLocalStorage = () => isBrowser() && typeof localStorage !== 'undefined' ? localStorage : undefined;
|
|
3
|
-
export const getLocalStorageItem = ({ key, canTrack }) => {
|
|
4
|
-
try {
|
|
5
|
-
if (canTrack) {
|
|
6
|
-
return getLocalStorage()?.getItem(key);
|
|
7
|
-
}
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
catch (err) {
|
|
11
|
-
console.debug('[LocalStorage] GET error: ', err);
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
export const setLocalStorageItem = ({ key, canTrack, value }) => {
|
|
16
|
-
try {
|
|
17
|
-
if (canTrack) {
|
|
18
|
-
getLocalStorage()?.setItem(key, value);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
console.debug('[LocalStorage] SET error: ', err);
|
|
23
|
-
}
|
|
24
|
-
};
|
package/dist/helpers/logger.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const MSG_PREFIX = '[Builder.io]: ';
|
|
2
|
-
export const logger = {
|
|
3
|
-
log: (...message) => console.log(MSG_PREFIX, ...message),
|
|
4
|
-
error: (...message) => console.error(MSG_PREFIX, ...message),
|
|
5
|
-
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
6
|
-
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
7
|
-
};
|
package/dist/helpers/nullable.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { getIdFromSearchParams } from './helpers';
|
|
2
|
-
import { init } from './init';
|
|
3
|
-
export function getPreviewContent(searchParams) {
|
|
4
|
-
init();
|
|
5
|
-
const id = getIdFromSearchParams(searchParams);
|
|
6
|
-
return typeof id === 'string'
|
|
7
|
-
? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id)
|
|
8
|
-
: undefined;
|
|
9
|
-
}
|