@builder.io/sdk-solid 0.0.8-21 → 0.0.8-24
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/package.json +1 -1
- package/src/blocks/button/button.jsx +6 -1
- package/src/blocks/columns/columns.jsx +44 -47
- package/src/blocks/columns/component-info.js +3 -2
- package/src/blocks/custom-code/custom-code.jsx +34 -37
- package/src/blocks/embed/component-info.js +3 -2
- package/src/blocks/embed/embed.jsx +28 -31
- package/src/blocks/form/form.jsx +172 -173
- package/src/blocks/image/component-info.js +3 -2
- package/src/blocks/image/image.jsx +26 -29
- package/src/blocks/img/img.jsx +1 -1
- package/src/blocks/symbol/symbol.jsx +10 -13
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/video.jsx +19 -23
- package/src/components/render-block/block-styles.jsx +22 -27
- package/src/components/render-block/render-block.jsx +155 -159
- package/src/components/render-block/render-component.jsx +2 -2
- package/src/components/render-block/render-repeated-block.jsx +1 -1
- package/src/components/render-blocks.jsx +32 -33
- package/src/components/render-content/components/render-styles.jsx +38 -41
- package/src/components/render-content/render-content.jsx +170 -156
- package/src/components/render-inlined-styles.jsx +10 -13
- package/src/constants/builder-registered-components.js +3 -0
- package/src/functions/get-fetch.js +2 -2
- package/src/functions/get-processed-block.js +10 -6
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/functions/track.js +71 -2
- package/src/helpers/cookie.js +59 -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/scripts/init-editing.js +4 -5
- package/src/types/can-track.js +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isBrowser } from "../functions/is-browser";
|
|
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";
|
|
2
|
+
import { checkIsDefined } from "./nullable";
|
|
3
|
+
import { uuid } from "./uuid";
|
|
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";
|
|
2
|
+
import { checkIsDefined } from "./nullable";
|
|
3
|
+
import { uuid } from "./uuid";
|
|
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,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
|