@builder.io/sdk-solid 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/package.json +17 -5
- package/solid-index.jsx +5 -0
- package/src/blocks/BaseText.jsx +9 -0
- package/src/blocks/button/button.jsx +9 -6
- package/src/blocks/columns/columns.jsx +54 -52
- package/src/blocks/columns/component-info.js +26 -1
- package/src/blocks/custom-code/custom-code.jsx +35 -38
- package/src/blocks/embed/component-info.js +21 -1
- package/src/blocks/embed/embed.jsx +37 -42
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/form.jsx +175 -176
- package/src/blocks/image/component-info.js +48 -1
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.jsx +44 -13
- package/src/blocks/img/img.jsx +1 -1
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.jsx +40 -13
- package/src/blocks/text/text.jsx +1 -1
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/video.jsx +21 -2
- package/src/components/render-block/block-styles.jsx +41 -31
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.jsx +205 -90
- package/src/components/render-block/render-component-with-context.jsx +36 -0
- package/src/components/render-block/render-component.jsx +28 -0
- package/src/components/render-block/render-repeated-block.jsx +36 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.jsx +42 -33
- package/src/components/render-content/components/render-styles.jsx +39 -42
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.jsx +200 -129
- package/src/components/render-inlined-styles.jsx +21 -5
- package/src/constants/builder-registered-components.js +54 -0
- package/src/constants/device-sizes.js +3 -21
- package/src/context/builder.context.js +3 -1
- package/src/context/types.js +0 -0
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +14 -0
- package/src/functions/evaluate.js +1 -1
- package/src/functions/extract-text-styles.js +22 -0
- package/src/functions/fast-clone.js +4 -0
- package/src/functions/get-block-actions-handler.js +12 -0
- package/src/functions/get-block-actions.js +2 -7
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +27 -19
- package/src/functions/get-builder-search-params/index.js +17 -2
- package/src/functions/get-content/ab-testing.js +99 -0
- package/src/functions/get-content/fn.test.js +1 -1
- package/src/functions/get-content/index.js +20 -62
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +2 -2
- package/src/functions/get-processed-block.js +24 -11
- package/src/functions/get-processed-block.test.js +2 -1
- package/src/functions/mark-mutable.js +10 -0
- package/src/functions/register-component.js +45 -26
- package/src/functions/sanitize-styles.js +4 -0
- package/src/functions/track.js +108 -13
- package/src/helpers/ab-tests.js +16 -0
- package/src/helpers/cookie.js +79 -0
- package/src/helpers/css.js +28 -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 +49 -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 +11 -9
- package/src/scripts/init-editing.js +4 -5
- package/src/types/can-track.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/element.js +0 -0
- package/src/blocks/button/button.lite.tsx +0 -20
- package/src/blocks/button/index.js +0 -7
- package/src/blocks/columns/columns.lite.tsx +0 -102
- package/src/blocks/columns/index.js +0 -7
- package/src/blocks/custom-code/custom-code.lite.tsx +0 -67
- package/src/blocks/custom-code/index.js +0 -7
- package/src/blocks/embed/embed.lite.tsx +0 -59
- package/src/blocks/embed/index.js +0 -7
- package/src/blocks/form/form.lite.tsx +0 -293
- package/src/blocks/form/index.js +0 -7
- package/src/blocks/fragment/fragment.lite.tsx +0 -5
- package/src/blocks/fragment/index.js +0 -7
- package/src/blocks/image/image.lite.tsx +0 -83
- package/src/blocks/image/index.js +0 -7
- package/src/blocks/img/img.lite.tsx +0 -18
- package/src/blocks/img/index.js +0 -7
- package/src/blocks/input/index.js +0 -7
- package/src/blocks/input/input.lite.tsx +0 -20
- package/src/blocks/raw-text/index.js +0 -7
- package/src/blocks/raw-text/raw-text.lite.tsx +0 -10
- package/src/blocks/section/index.js +0 -7
- package/src/blocks/section/section.lite.tsx +0 -18
- package/src/blocks/select/index.js +0 -7
- package/src/blocks/select/select.lite.tsx +0 -28
- package/src/blocks/submit-button/index.js +0 -7
- package/src/blocks/submit-button/submit-button.lite.tsx +0 -9
- package/src/blocks/symbol/index.js +0 -7
- package/src/blocks/symbol/symbol.lite.tsx +0 -39
- package/src/blocks/text/index.js +0 -7
- package/src/blocks/text/text.lite.tsx +0 -5
- package/src/blocks/textarea/index.js +0 -7
- package/src/blocks/textarea/textarea.lite.tsx +0 -13
- package/src/blocks/video/index.js +0 -7
- package/src/blocks/video/video.lite.tsx +0 -26
- package/src/components/error-boundary.jsx +0 -5
- package/src/components/error-boundary.lite.tsx +0 -5
- package/src/components/render-block/block-styles.lite.tsx +0 -38
- package/src/components/render-block/render-block.lite.tsx +0 -119
- package/src/components/render-blocks.lite.tsx +0 -75
- package/src/components/render-content/components/render-styles.lite.tsx +0 -76
- package/src/components/render-content/render-content.lite.tsx +0 -232
- package/src/components/render-inlined-styles.lite.tsx +0 -5
- package/src/functions/macro-eval.js +0 -5
- package/src/functions/previewing-model-name.js +0 -11
|
@@ -17,37 +17,56 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
import { fastClone } from "./fast-clone.js";
|
|
33
|
+
const components = [];
|
|
22
34
|
function registerComponent(component, info) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (isBrowser()) {
|
|
26
|
-
const sendInfo = prepareComponentInfoToSend(info);
|
|
27
|
-
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
28
|
-
type: "builder.registerComponent",
|
|
29
|
-
data: sendInfo
|
|
30
|
-
}, "*");
|
|
31
|
-
}
|
|
35
|
+
components.push(__spreadValues({ component }, info));
|
|
36
|
+
console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
|
|
32
37
|
return component;
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
const createRegisterComponentMessage = (_a) => {
|
|
40
|
+
var _b = _a, {
|
|
41
|
+
component: _
|
|
42
|
+
} = _b, info = __objRest(_b, [
|
|
43
|
+
"component"
|
|
44
|
+
]);
|
|
45
|
+
return {
|
|
46
|
+
type: "builder.registerComponent",
|
|
47
|
+
data: prepareComponentInfoToSend(info)
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
51
|
+
const serializeFn = (fnValue) => {
|
|
52
|
+
const fnStr = fnValue.toString().trim();
|
|
53
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
54
|
+
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
55
|
+
};
|
|
56
|
+
const prepareComponentInfoToSend = (_c) => {
|
|
57
|
+
var _d = _c, {
|
|
58
|
+
inputs
|
|
59
|
+
} = _d, info = __objRest(_d, [
|
|
60
|
+
"inputs"
|
|
61
|
+
]);
|
|
62
|
+
return __spreadProps(__spreadValues({}, fastClone(info)), {
|
|
63
|
+
inputs: inputs == null ? void 0 : inputs.map((input) => Object.entries(input).reduce((acc, [key, value]) => __spreadProps(__spreadValues({}, acc), {
|
|
64
|
+
[key]: serializeValue(value)
|
|
65
|
+
}), {}))
|
|
48
66
|
});
|
|
49
|
-
}
|
|
67
|
+
};
|
|
50
68
|
export {
|
|
51
69
|
components,
|
|
70
|
+
createRegisterComponentMessage,
|
|
52
71
|
registerComponent
|
|
53
72
|
};
|
package/src/functions/track.js
CHANGED
|
@@ -1,20 +1,115 @@
|
|
|
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
|
+
};
|
|
1
52
|
import { TARGET } from "../constants/target.js";
|
|
53
|
+
import { getSessionId } from "../helpers/sessionId.js";
|
|
54
|
+
import { getVisitorId } from "../helpers/visitorId.js";
|
|
2
55
|
import { isBrowser } from "./is-browser.js";
|
|
3
56
|
import { isEditing } from "./is-editing.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return;
|
|
57
|
+
const getTrackingEventData = (_0) => __async(void 0, [_0], function* ({
|
|
58
|
+
canTrack
|
|
59
|
+
}) {
|
|
60
|
+
if (!canTrack) {
|
|
61
|
+
return { visitorId: void 0, sessionId: void 0 };
|
|
10
62
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
63
|
+
const sessionId = yield getSessionId({ canTrack });
|
|
64
|
+
const visitorId = getVisitorId({ canTrack });
|
|
65
|
+
return {
|
|
66
|
+
sessionId,
|
|
67
|
+
visitorId
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
const createEvent = (_a) => __async(void 0, null, function* () {
|
|
71
|
+
var _b = _a, {
|
|
72
|
+
type: eventType,
|
|
73
|
+
canTrack,
|
|
74
|
+
orgId,
|
|
75
|
+
contentId
|
|
76
|
+
} = _b, properties = __objRest(_b, [
|
|
77
|
+
"type",
|
|
78
|
+
"canTrack",
|
|
79
|
+
"orgId",
|
|
80
|
+
"contentId"
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
type: eventType,
|
|
84
|
+
data: __spreadProps(__spreadValues(__spreadValues({}, properties), yield getTrackingEventData({ canTrack })), {
|
|
85
|
+
ownerId: orgId,
|
|
86
|
+
contentId
|
|
87
|
+
})
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
function track(eventProps) {
|
|
91
|
+
return __async(this, null, function* () {
|
|
92
|
+
if (!eventProps.canTrack) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (isEditing()) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
return fetch(`https://builder.io/api/v1/track`, {
|
|
102
|
+
method: "POST",
|
|
103
|
+
body: JSON.stringify({
|
|
104
|
+
events: [yield createEvent(eventProps)]
|
|
105
|
+
}),
|
|
106
|
+
headers: {
|
|
107
|
+
"content-type": "application/json"
|
|
108
|
+
},
|
|
109
|
+
mode: "cors"
|
|
110
|
+
}).catch((err) => {
|
|
111
|
+
console.error("Failed to track: ", err);
|
|
112
|
+
});
|
|
18
113
|
});
|
|
19
114
|
}
|
|
20
115
|
export {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getCookie, setCookie } from "./cookie.js";
|
|
2
|
+
const BUILDER_STORE_PREFIX = "builderio.variations";
|
|
3
|
+
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
4
|
+
const getContentVariationCookie = ({
|
|
5
|
+
contentId,
|
|
6
|
+
canTrack
|
|
7
|
+
}) => getCookie({ name: getContentTestKey(contentId), canTrack });
|
|
8
|
+
const setContentVariationCookie = ({
|
|
9
|
+
contentId,
|
|
10
|
+
canTrack,
|
|
11
|
+
value
|
|
12
|
+
}) => setCookie({ name: getContentTestKey(contentId), value, canTrack });
|
|
13
|
+
export {
|
|
14
|
+
getContentVariationCookie,
|
|
15
|
+
setContentVariationCookie
|
|
16
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
22
|
+
import { getTopLevelDomain } from "./url.js";
|
|
23
|
+
const getCookie = (_0) => __async(void 0, [_0], function* ({
|
|
24
|
+
name,
|
|
25
|
+
canTrack
|
|
26
|
+
}) {
|
|
27
|
+
var _a;
|
|
28
|
+
try {
|
|
29
|
+
if (!canTrack) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.debug("[COOKIE] GET error: ", err);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).join("; ");
|
|
38
|
+
const SECURE_CONFIG = [
|
|
39
|
+
["secure", ""],
|
|
40
|
+
["SameSite", "None"]
|
|
41
|
+
];
|
|
42
|
+
const createCookieString = ({
|
|
43
|
+
name,
|
|
44
|
+
value,
|
|
45
|
+
expires
|
|
46
|
+
}) => {
|
|
47
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
48
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
49
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
50
|
+
const cookieValue = [
|
|
51
|
+
[name, value],
|
|
52
|
+
...expiresObj,
|
|
53
|
+
["path", "/"],
|
|
54
|
+
["domain", getTopLevelDomain(window.location.hostname)],
|
|
55
|
+
...secureObj
|
|
56
|
+
];
|
|
57
|
+
const cookie = stringifyCookie(cookieValue);
|
|
58
|
+
return cookie;
|
|
59
|
+
};
|
|
60
|
+
const setCookie = (_0) => __async(void 0, [_0], function* ({
|
|
61
|
+
name,
|
|
62
|
+
value,
|
|
63
|
+
expires,
|
|
64
|
+
canTrack
|
|
65
|
+
}) {
|
|
66
|
+
try {
|
|
67
|
+
if (!canTrack) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
const cookie = createCookieString({ name, value, expires });
|
|
71
|
+
document.cookie = cookie;
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.warn("[COOKIE] SET error: ", err);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export {
|
|
77
|
+
getCookie,
|
|
78
|
+
setCookie
|
|
79
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
const createCssClass = ({
|
|
11
|
+
mediaQuery,
|
|
12
|
+
className,
|
|
13
|
+
styles
|
|
14
|
+
}) => {
|
|
15
|
+
const cssClass = `.${className} {
|
|
16
|
+
${convertStyleMaptoCSS(styles)}
|
|
17
|
+
}`;
|
|
18
|
+
if (mediaQuery) {
|
|
19
|
+
return `${mediaQuery} {
|
|
20
|
+
${cssClass}
|
|
21
|
+
}`;
|
|
22
|
+
} else {
|
|
23
|
+
return cssClass;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
createCssClass
|
|
28
|
+
};
|
|
@@ -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,49 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { getCookie, setCookie } from "./cookie.js";
|
|
22
|
+
import { checkIsDefined } from "./nullable.js";
|
|
23
|
+
import { uuid } from "./uuid.js";
|
|
24
|
+
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
25
|
+
const getSessionId = (_0) => __async(void 0, [_0], function* ({ canTrack }) {
|
|
26
|
+
if (!canTrack) {
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
const sessionId = yield getCookie({
|
|
30
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
31
|
+
canTrack
|
|
32
|
+
});
|
|
33
|
+
if (checkIsDefined(sessionId)) {
|
|
34
|
+
return sessionId;
|
|
35
|
+
} else {
|
|
36
|
+
const newSessionId = createSessionId();
|
|
37
|
+
setSessionId({ id: newSessionId, canTrack });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const createSessionId = () => uuid();
|
|
41
|
+
const setSessionId = ({
|
|
42
|
+
id,
|
|
43
|
+
canTrack
|
|
44
|
+
}) => setCookie({ name: SESSION_LOCAL_STORAGE_KEY, value: id, canTrack });
|
|
45
|
+
export {
|
|
46
|
+
createSessionId,
|
|
47
|
+
getSessionId,
|
|
48
|
+
setSessionId
|
|
49
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { default as default2 } from "../blocks/columns/
|
|
2
|
-
import { default as default3 } from "../blocks/image/
|
|
3
|
-
import { default as default4 } from "../blocks/text/
|
|
4
|
-
import { default as default5 } from "../blocks/video/
|
|
5
|
-
import { default as default6 } from "../blocks/symbol/
|
|
6
|
-
import { default as default7 } from "../blocks/button/
|
|
7
|
-
import { default as default8 } from "../blocks/section/
|
|
8
|
-
import { default as default9 } from "../blocks/fragment/
|
|
9
|
-
import { default as default10 } from "../components/render-content/render-content
|
|
1
|
+
import { default as default2 } from "../blocks/columns/columns.jsx";
|
|
2
|
+
import { default as default3 } from "../blocks/image/image.jsx";
|
|
3
|
+
import { default as default4 } from "../blocks/text/text.jsx";
|
|
4
|
+
import { default as default5 } from "../blocks/video/video.jsx";
|
|
5
|
+
import { default as default6 } from "../blocks/symbol/symbol.jsx";
|
|
6
|
+
import { default as default7 } from "../blocks/button/button.jsx";
|
|
7
|
+
import { default as default8 } from "../blocks/section/section.jsx";
|
|
8
|
+
import { default as default9 } from "../blocks/fragment/fragment.jsx";
|
|
9
|
+
import { default as default10 } from "../components/render-content/render-content.jsx";
|
|
10
|
+
import { default as default11 } from "../components/render-blocks.jsx";
|
|
10
11
|
export {
|
|
11
12
|
default7 as Button,
|
|
12
13
|
default2 as Columns,
|
|
13
14
|
default9 as Fragment,
|
|
14
15
|
default3 as Image,
|
|
16
|
+
default11 as RenderBlocks,
|
|
15
17
|
default10 as RenderContent,
|
|
16
18
|
default8 as Section,
|
|
17
19
|
default6 as Symbol,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TARGET } from "../constants/target.js";
|
|
2
2
|
import { isBrowser } from "../functions/is-browser.js";
|
|
3
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
4
3
|
import { register } from "../functions/register.js";
|
|
5
4
|
const registerInsertMenu = () => {
|
|
6
5
|
register("insertMenu", {
|
|
@@ -74,7 +73,7 @@ const setupBrowserForEditing = () => {
|
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
75
|
};
|
|
77
|
-
|
|
78
|
-
registerInsertMenu
|
|
79
|
-
setupBrowserForEditing
|
|
80
|
-
}
|
|
76
|
+
export {
|
|
77
|
+
registerInsertMenu,
|
|
78
|
+
setupBrowserForEditing
|
|
79
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Show } from "solid-js";
|
|
2
|
-
|
|
3
|
-
function Button(props) {
|
|
4
|
-
return (
|
|
5
|
-
<>
|
|
6
|
-
<Show when={props.link}>
|
|
7
|
-
<a
|
|
8
|
-
{...props.attributes}
|
|
9
|
-
role="button"
|
|
10
|
-
href={props.link}
|
|
11
|
-
target={props.openLinkInNewTab ? "_blank" : undefined}
|
|
12
|
-
>
|
|
13
|
-
{props.text}
|
|
14
|
-
</a>
|
|
15
|
-
</Show>
|
|
16
|
-
</>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default Button;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
-
import component from "./button..js";
|
|
3
|
-
import { componentInfo } from "./component-info.js";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|