@builder.io/sdk-react-native 0.0.1-7 → 0.0.1-70
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/CHANGELOG.md +42 -0
- package/README.md +19 -0
- package/package.json +6 -4
- package/src/blocks/button/button.js +34 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/columns/columns.js +61 -0
- package/src/blocks/columns/component-info.js +242 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.js} +16 -33
- package/src/blocks/embed/component-info.js +44 -0
- package/src/blocks/embed/embed.js +43 -0
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.js +224 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.js +8 -0
- package/src/blocks/image/component-info.js +151 -0
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.js +40 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.js +36 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/input.js +36 -0
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/raw-text.js +10 -0
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/section.js +31 -0
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/select.js +36 -0
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/submit-button.js +29 -0
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.js +69 -0
- package/src/blocks/{text.js → text/component-info.js} +4 -11
- package/src/blocks/text/text.js +64 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/textarea.js +32 -0
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/video.js +32 -0
- package/src/components/render-block/block-styles.js +37 -0
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.js +171 -0
- package/src/components/render-block/render-component.js +35 -0
- package/src/components/render-block/render-repeated-block.js +30 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.js +29 -13
- package/src/components/render-content/components/render-styles.js +58 -0
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.js +277 -0
- package/src/components/render-inlined-styles.js +18 -0
- package/src/constants/builder-registered-components.js +42 -0
- package/src/constants/device-sizes.js +3 -22
- package/src/constants/target.js +4 -0
- package/src/context/builder.context.js +7 -1
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/evaluate.js +17 -9
- package/src/functions/event-handler-name.js +7 -0
- package/src/functions/get-block-actions.js +14 -14
- package/src/functions/get-block-component-options.js +22 -2
- package/src/functions/get-block-properties.js +2 -4
- package/src/functions/get-block-styles.js +9 -28
- package/src/functions/get-block-tag.js +1 -2
- package/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/src/functions/get-builder-search-params/index.js +33 -0
- package/src/functions/get-content/ab-testing.js +38 -0
- package/src/functions/get-content/fn.test.js +31 -0
- package/src/functions/get-content/index.js +96 -0
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +34 -0
- package/src/functions/get-global-this.js +18 -0
- package/src/functions/get-processed-block.js +22 -10
- package/src/functions/get-processed-block.test.js +14 -9
- package/src/functions/if-target.js +11 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -2
- package/src/functions/is-iframe.js +1 -2
- package/src/functions/is-previewing.js +14 -0
- package/src/functions/is-react-native.js +1 -2
- package/src/functions/on-change.js +0 -1
- package/src/functions/on-change.test.js +1 -3
- package/src/functions/register-component.js +46 -27
- package/src/functions/register.js +29 -0
- package/src/functions/sanitize-styles.js +32 -0
- package/src/functions/set-editor-settings.js +15 -0
- package/src/functions/set.js +0 -1
- package/src/functions/set.test.js +1 -3
- package/src/functions/track.js +109 -13
- package/src/functions/transform-block.js +37 -0
- package/src/helpers/cookie.js +59 -0
- package/src/helpers/css.js +12 -0
- package/src/helpers/flatten.js +34 -0
- package/src/helpers/localStorage.js +34 -0
- package/src/helpers/nullable.js +4 -0
- package/src/helpers/sessionId.js +26 -0
- package/src/helpers/time.js +5 -0
- package/src/helpers/url.js +10 -0
- package/src/helpers/url.test.js +15 -0
- package/src/helpers/uuid.js +13 -0
- package/src/helpers/visitorId.js +33 -0
- package/src/index-helpers/blocks-exports.js +18 -0
- package/src/index-helpers/top-of-file.js +1 -0
- package/src/index.js +10 -24
- package/src/scripts/init-editing.js +73 -51
- package/src/types/builder-block.js +0 -1
- package/src/types/builder-content.js +0 -1
- package/src/types/can-track.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/deep-partial.js +0 -0
- package/src/types/element.js +0 -0
- package/src/types/targets.js +0 -0
- package/src/types/typescript.js +0 -0
- package/index.js +0 -11
- package/src/blocks/button.js +0 -37
- package/src/blocks/button.lite.tsx +0 -29
- package/src/blocks/columns.js +0 -42
- package/src/blocks/columns.lite.tsx +0 -41
- package/src/blocks/custom-code.js +0 -56
- package/src/blocks/embed.js +0 -56
- package/src/blocks/embed.lite.tsx +0 -65
- package/src/blocks/form.js +0 -229
- package/src/blocks/form.lite.tsx +0 -257
- package/src/blocks/image.js +0 -123
- package/src/blocks/image.lite.tsx +0 -35
- package/src/blocks/img.js +0 -41
- package/src/blocks/img.lite.tsx +0 -19
- package/src/blocks/input.js +0 -41
- package/src/blocks/input.lite.tsx +0 -23
- package/src/blocks/raw-text.js +0 -17
- package/src/blocks/raw-text.lite.tsx +0 -12
- package/src/blocks/section.js +0 -36
- package/src/blocks/section.lite.tsx +0 -20
- package/src/blocks/select.js +0 -40
- package/src/blocks/select.lite.tsx +0 -24
- package/src/blocks/submit-button.js +0 -34
- package/src/blocks/submit-button.lite.tsx +0 -11
- package/src/blocks/symbol.js +0 -20
- package/src/blocks/symbol.lite.tsx +0 -20
- package/src/blocks/text.lite.tsx +0 -12
- package/src/blocks/textarea.js +0 -37
- package/src/blocks/textarea.lite.tsx +0 -15
- package/src/blocks/video.js +0 -49
- package/src/blocks/video.lite.tsx +0 -28
- package/src/components/render-block.js +0 -84
- package/src/components/render-block.lite.tsx +0 -92
- package/src/components/render-blocks.lite.tsx +0 -56
- package/src/components/render-content.js +0 -66
- package/src/components/render-content.lite.tsx +0 -95
- package/src/functions/get-content.js +0 -103
- package/src/functions/get-target.js +0 -7
- package/src/functions/macro-eval.js +0 -6
- package/src/package.json +0 -18
package/src/functions/track.js
CHANGED
|
@@ -1,17 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
import { TARGET } from "../constants/target.js";
|
|
53
|
+
import { getSessionId } from "../helpers/sessionId.js";
|
|
54
|
+
import { getVisitorId } from "../helpers/visitorId.js";
|
|
55
|
+
import { isBrowser } from "./is-browser.js";
|
|
56
|
+
import { isEditing } from "./is-editing.js";
|
|
57
|
+
const getTrackingEventData = ({ canTrack }) => {
|
|
58
|
+
if (!canTrack) {
|
|
59
|
+
return { visitorId: void 0, sessionId: void 0 };
|
|
7
60
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
61
|
+
const sessionId = getSessionId({ canTrack });
|
|
62
|
+
const visitorId = getVisitorId({ canTrack });
|
|
63
|
+
return {
|
|
64
|
+
sessionId,
|
|
65
|
+
visitorId
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const createEvent = (_a) => {
|
|
69
|
+
var _b = _a, {
|
|
70
|
+
type: eventType,
|
|
71
|
+
canTrack,
|
|
72
|
+
orgId,
|
|
73
|
+
contentId
|
|
74
|
+
} = _b, properties = __objRest(_b, [
|
|
75
|
+
"type",
|
|
76
|
+
"canTrack",
|
|
77
|
+
"orgId",
|
|
78
|
+
"contentId"
|
|
79
|
+
]);
|
|
80
|
+
return {
|
|
81
|
+
type: eventType,
|
|
82
|
+
data: __spreadProps(__spreadValues(__spreadValues({}, properties), getTrackingEventData({ canTrack })), {
|
|
83
|
+
ownerId: orgId,
|
|
84
|
+
contentId
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
function track(eventProps) {
|
|
89
|
+
return __async(this, null, function* () {
|
|
90
|
+
if (!eventProps.canTrack) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (isEditing()) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
return fetch(`https://builder.io/api/v1/track`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
body: JSON.stringify({
|
|
102
|
+
events: [createEvent(eventProps)]
|
|
103
|
+
}),
|
|
104
|
+
headers: {
|
|
105
|
+
"content-type": "application/json"
|
|
106
|
+
},
|
|
107
|
+
mode: "cors"
|
|
108
|
+
}).catch((err) => {
|
|
109
|
+
console.error("Failed to track: ", err);
|
|
110
|
+
});
|
|
15
111
|
});
|
|
16
112
|
}
|
|
17
113
|
export {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
function transformBlock(block) {
|
|
21
|
+
if (block.id.startsWith("builder-pixel-") && !block.component) {
|
|
22
|
+
return __spreadProps(__spreadValues({}, block), {
|
|
23
|
+
component: {
|
|
24
|
+
name: "Image",
|
|
25
|
+
options: {
|
|
26
|
+
image: block.properties.src,
|
|
27
|
+
width: 1,
|
|
28
|
+
height: 1
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return block;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
transformBlock
|
|
37
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
2
|
+
import { getTopLevelDomain } from "./url.js";
|
|
3
|
+
const getCookie = ({
|
|
4
|
+
name,
|
|
5
|
+
canTrack
|
|
6
|
+
}) => {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
if (!canTrack) {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.debug("[COOKIE] GET error: ", err);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).join("; ");
|
|
18
|
+
const SECURE_CONFIG = [
|
|
19
|
+
["secure", ""],
|
|
20
|
+
["SameSite", "None"]
|
|
21
|
+
];
|
|
22
|
+
const createCookieString = ({
|
|
23
|
+
name,
|
|
24
|
+
value,
|
|
25
|
+
expires
|
|
26
|
+
}) => {
|
|
27
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
28
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
29
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
30
|
+
const cookieValue = [
|
|
31
|
+
[name, value],
|
|
32
|
+
...expiresObj,
|
|
33
|
+
["path", "/"],
|
|
34
|
+
["domain", getTopLevelDomain(window.location.hostname)],
|
|
35
|
+
...secureObj
|
|
36
|
+
];
|
|
37
|
+
const cookie = stringifyCookie(cookieValue);
|
|
38
|
+
return cookie;
|
|
39
|
+
};
|
|
40
|
+
const setCookie = ({
|
|
41
|
+
name,
|
|
42
|
+
value,
|
|
43
|
+
expires,
|
|
44
|
+
canTrack
|
|
45
|
+
}) => {
|
|
46
|
+
try {
|
|
47
|
+
if (!canTrack) {
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
const cookie = createCookieString({ name, value, expires });
|
|
51
|
+
document.cookie = cookie;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.warn("[COOKIE] SET error: ", err);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
getCookie,
|
|
58
|
+
setCookie
|
|
59
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { camelToKebabCase } from "../functions/camel-to-kebab-case.js";
|
|
2
|
+
const convertStyleMaptoCSS = (style) => {
|
|
3
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
4
|
+
if (typeof value === "string") {
|
|
5
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
return cssProps.join("\n");
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
convertStyleMaptoCSS
|
|
12
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
function flatten(object, path = null, separator = ".") {
|
|
21
|
+
return Object.keys(object).reduce((acc, key) => {
|
|
22
|
+
const value = object[key];
|
|
23
|
+
const newPath = [path, key].filter(Boolean).join(separator);
|
|
24
|
+
const isObject = [
|
|
25
|
+
typeof value === "object",
|
|
26
|
+
value !== null,
|
|
27
|
+
!(Array.isArray(value) && value.length === 0)
|
|
28
|
+
].every(Boolean);
|
|
29
|
+
return isObject ? __spreadValues(__spreadValues({}, acc), flatten(value, newPath, separator)) : __spreadProps(__spreadValues({}, acc), { [newPath]: value });
|
|
30
|
+
}, {});
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
flatten
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
2
|
+
const getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3
|
+
const getLocalStorageItem = ({
|
|
4
|
+
key,
|
|
5
|
+
canTrack
|
|
6
|
+
}) => {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
if (canTrack) {
|
|
10
|
+
return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
|
|
11
|
+
}
|
|
12
|
+
return void 0;
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.debug("[LocalStorage] GET error: ", err);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const setLocalStorageItem = ({
|
|
18
|
+
key,
|
|
19
|
+
canTrack,
|
|
20
|
+
value
|
|
21
|
+
}) => {
|
|
22
|
+
var _a;
|
|
23
|
+
try {
|
|
24
|
+
if (canTrack) {
|
|
25
|
+
(_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.debug("[LocalStorage] SET error: ", err);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
getLocalStorageItem,
|
|
33
|
+
setLocalStorageItem
|
|
34
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getCookie, setCookie } from "./cookie.js";
|
|
2
|
+
import { checkIsDefined } from "./nullable.js";
|
|
3
|
+
import { uuid } from "./uuid.js";
|
|
4
|
+
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
5
|
+
const getSessionId = ({ canTrack }) => {
|
|
6
|
+
if (!canTrack) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const sessionId = getCookie({ name: SESSION_LOCAL_STORAGE_KEY, canTrack });
|
|
10
|
+
if (checkIsDefined(sessionId)) {
|
|
11
|
+
return sessionId;
|
|
12
|
+
} else {
|
|
13
|
+
const newSessionId = createSessionId();
|
|
14
|
+
setSessionId({ id: newSessionId, canTrack });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const createSessionId = () => uuid();
|
|
18
|
+
const setSessionId = ({
|
|
19
|
+
id,
|
|
20
|
+
canTrack
|
|
21
|
+
}) => setCookie({ name: SESSION_LOCAL_STORAGE_KEY, value: id, canTrack });
|
|
22
|
+
export {
|
|
23
|
+
createSessionId,
|
|
24
|
+
getSessionId,
|
|
25
|
+
setSessionId
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getTopLevelDomain } from "./url.js";
|
|
2
|
+
describe("getTopLevelDomain", () => {
|
|
3
|
+
test("handles root domain", () => {
|
|
4
|
+
const output = getTopLevelDomain("example.com");
|
|
5
|
+
expect(output).toBe("example.com");
|
|
6
|
+
});
|
|
7
|
+
test("handles subdomain", () => {
|
|
8
|
+
const output = getTopLevelDomain("wwww.example.com");
|
|
9
|
+
expect(output).toBe("example.com");
|
|
10
|
+
});
|
|
11
|
+
test("handles subdomain with long suffix", () => {
|
|
12
|
+
const output = getTopLevelDomain("www.example.co.uk");
|
|
13
|
+
expect(output).toBe("example.co.uk");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function uuidv4() {
|
|
2
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
3
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
4
|
+
return v.toString(16);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
function uuid() {
|
|
8
|
+
return uuidv4().replace(/-/g, "");
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
uuid,
|
|
12
|
+
uuidv4
|
|
13
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getLocalStorageItem, setLocalStorageItem } from "./localStorage.js";
|
|
2
|
+
import { checkIsDefined } from "./nullable.js";
|
|
3
|
+
import { uuid } from "./uuid.js";
|
|
4
|
+
const VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
5
|
+
const getVisitorId = ({ canTrack }) => {
|
|
6
|
+
if (!canTrack) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const visitorId = getLocalStorageItem({
|
|
10
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
11
|
+
canTrack
|
|
12
|
+
});
|
|
13
|
+
if (checkIsDefined(visitorId)) {
|
|
14
|
+
return visitorId;
|
|
15
|
+
} else {
|
|
16
|
+
const newVisitorId = createVisitorId();
|
|
17
|
+
setVisitorId({ id: newVisitorId, canTrack });
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const createVisitorId = () => uuid();
|
|
21
|
+
const setVisitorId = ({
|
|
22
|
+
id,
|
|
23
|
+
canTrack
|
|
24
|
+
}) => setLocalStorageItem({
|
|
25
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
26
|
+
value: id,
|
|
27
|
+
canTrack
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
createVisitorId,
|
|
31
|
+
getVisitorId,
|
|
32
|
+
setVisitorId
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as default2 } from "../blocks/columns/columns.js";
|
|
2
|
+
import { default as default3 } from "../blocks/image/image.js";
|
|
3
|
+
import { default as default4 } from "../blocks/text/text.js";
|
|
4
|
+
import { default as default5 } from "../blocks/symbol/symbol.js";
|
|
5
|
+
import { default as default6 } from "../blocks/button/button.js";
|
|
6
|
+
import { default as default7 } from "../blocks/section/section.js";
|
|
7
|
+
import { default as default8 } from "../blocks/fragment/fragment.js";
|
|
8
|
+
import { default as default9 } from "../components/render-content/render-content.js";
|
|
9
|
+
export {
|
|
10
|
+
default6 as Button,
|
|
11
|
+
default2 as Columns,
|
|
12
|
+
default8 as Fragment,
|
|
13
|
+
default3 as Image,
|
|
14
|
+
default9 as RenderContent,
|
|
15
|
+
default7 as Section,
|
|
16
|
+
default5 as Symbol,
|
|
17
|
+
default4 as Text
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "react-native-url-polyfill/auto";
|
package/src/index.js
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { default as default7 } from "./blocks/button";
|
|
12
|
-
import { default as default8 } from "./blocks/section";
|
|
13
|
-
import { default as default9 } from "./components/render-content";
|
|
14
|
-
export * from "./functions/register-component";
|
|
15
|
-
export {
|
|
16
|
-
default7 as Button,
|
|
17
|
-
default2 as Columns,
|
|
18
|
-
default3 as Image,
|
|
19
|
-
default9 as RenderContent,
|
|
20
|
-
default8 as Section,
|
|
21
|
-
default6 as Symbol,
|
|
22
|
-
default4 as Text,
|
|
23
|
-
default5 as Video
|
|
24
|
-
};
|
|
1
|
+
import "./index-helpers/top-of-file.js";
|
|
2
|
+
import "./scripts/init-editing.js";
|
|
3
|
+
export * from "./index-helpers/blocks-exports.js";
|
|
4
|
+
export * from "./functions/is-editing.js";
|
|
5
|
+
export * from "./functions/is-previewing.js";
|
|
6
|
+
export * from "./functions/register-component.js";
|
|
7
|
+
export * from "./functions/register.js";
|
|
8
|
+
export * from "./functions/set-editor-settings.js";
|
|
9
|
+
export * from "./functions/get-content/index.js";
|
|
10
|
+
export * from "./functions/get-builder-search-params/index.js";
|
|
@@ -1,57 +1,79 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import { TARGET } from "../constants/target.js";
|
|
2
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
3
|
+
import { register } from "../functions/register.js";
|
|
4
|
+
const registerInsertMenu = () => {
|
|
5
|
+
register("insertMenu", {
|
|
6
|
+
name: "_default",
|
|
7
|
+
default: true,
|
|
8
|
+
items: [
|
|
9
|
+
{ name: "Box" },
|
|
10
|
+
{ name: "Text" },
|
|
11
|
+
{ name: "Image" },
|
|
12
|
+
{ name: "Columns" },
|
|
13
|
+
...TARGET === "reactNative" ? [] : [
|
|
14
|
+
{ name: "Core:Section" },
|
|
15
|
+
{ name: "Core:Button" },
|
|
16
|
+
{ name: "Embed" },
|
|
17
|
+
{ name: "Custom Code" }
|
|
18
|
+
]
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const setupBrowserForEditing = () => {
|
|
23
|
+
var _a;
|
|
24
|
+
if (isBrowser()) {
|
|
25
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
26
|
+
type: "builder.sdkInfo",
|
|
27
|
+
data: {
|
|
28
|
+
target: TARGET,
|
|
29
|
+
supportsPatchUpdates: false
|
|
30
|
+
}
|
|
31
|
+
}, "*");
|
|
32
|
+
window.addEventListener("message", ({ data }) => {
|
|
33
|
+
var _a2, _b;
|
|
34
|
+
if (data) {
|
|
35
|
+
switch (data.type) {
|
|
36
|
+
case "builder.evaluate": {
|
|
37
|
+
const text = data.data.text;
|
|
38
|
+
const args = data.data.arguments || [];
|
|
39
|
+
const id = data.data.id;
|
|
40
|
+
const fn = new Function(text);
|
|
41
|
+
let result;
|
|
42
|
+
let error = null;
|
|
43
|
+
try {
|
|
44
|
+
result = fn.apply(null, args);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
error = err;
|
|
47
|
+
}
|
|
48
|
+
if (error) {
|
|
49
|
+
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
50
|
+
type: "builder.evaluateError",
|
|
51
|
+
data: { id, error: error.message }
|
|
52
|
+
}, "*");
|
|
53
|
+
} else {
|
|
54
|
+
if (result && typeof result.then === "function") {
|
|
55
|
+
result.then((finalResult) => {
|
|
56
|
+
var _a3;
|
|
57
|
+
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
58
|
+
type: "builder.evaluateResult",
|
|
59
|
+
data: { id, result: finalResult }
|
|
60
|
+
}, "*");
|
|
61
|
+
}).catch(console.error);
|
|
62
|
+
} else {
|
|
63
|
+
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
41
64
|
type: "builder.evaluateResult",
|
|
42
|
-
data: {
|
|
65
|
+
data: { result, id }
|
|
43
66
|
}, "*");
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
47
|
-
type: "builder.evaluateResult",
|
|
48
|
-
data: { result, id }
|
|
49
|
-
}, "*");
|
|
67
|
+
}
|
|
50
68
|
}
|
|
69
|
+
break;
|
|
51
70
|
}
|
|
52
|
-
break;
|
|
53
71
|
}
|
|
54
72
|
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
registerInsertMenu,
|
|
78
|
+
setupBrowserForEditing
|
|
79
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isEditing } from './src/functions/is-editing';
|
|
2
|
-
|
|
3
|
-
if (isEditing()) {
|
|
4
|
-
import('./src/scripts/init-editing');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
// TODO: lazy option
|
|
8
|
-
export { default as Columns } from './src/blocks/columns';
|
|
9
|
-
export { default as Image } from './src/blocks/image';
|
|
10
|
-
export { default as Text } from './src/blocks/text';
|
|
11
|
-
export { default as RenderContent } from './src/components/render-content';
|