@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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/button/button.jsx +6 -1
  3. package/src/blocks/columns/columns.jsx +44 -47
  4. package/src/blocks/columns/component-info.js +3 -2
  5. package/src/blocks/custom-code/custom-code.jsx +34 -37
  6. package/src/blocks/embed/component-info.js +3 -2
  7. package/src/blocks/embed/embed.jsx +28 -31
  8. package/src/blocks/form/form.jsx +172 -173
  9. package/src/blocks/image/component-info.js +3 -2
  10. package/src/blocks/image/image.jsx +26 -29
  11. package/src/blocks/img/img.jsx +1 -1
  12. package/src/blocks/symbol/symbol.jsx +10 -13
  13. package/src/blocks/util.js +7 -0
  14. package/src/blocks/video/video.jsx +19 -23
  15. package/src/components/render-block/block-styles.jsx +22 -27
  16. package/src/components/render-block/render-block.jsx +155 -159
  17. package/src/components/render-block/render-component.jsx +2 -2
  18. package/src/components/render-block/render-repeated-block.jsx +1 -1
  19. package/src/components/render-blocks.jsx +32 -33
  20. package/src/components/render-content/components/render-styles.jsx +38 -41
  21. package/src/components/render-content/render-content.jsx +170 -156
  22. package/src/components/render-inlined-styles.jsx +10 -13
  23. package/src/constants/builder-registered-components.js +3 -0
  24. package/src/functions/get-fetch.js +2 -2
  25. package/src/functions/get-processed-block.js +10 -6
  26. package/src/functions/get-processed-block.test.js +1 -1
  27. package/src/functions/track.js +71 -2
  28. package/src/helpers/cookie.js +59 -0
  29. package/src/helpers/localStorage.js +34 -0
  30. package/src/helpers/nullable.js +4 -0
  31. package/src/helpers/sessionId.js +26 -0
  32. package/src/helpers/time.js +5 -0
  33. package/src/helpers/url.js +10 -0
  34. package/src/helpers/url.test.js +15 -0
  35. package/src/helpers/uuid.js +13 -0
  36. package/src/helpers/visitorId.js +33 -0
  37. package/src/scripts/init-editing.js +4 -5
  38. 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,4 @@
1
+ const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
2
+ export {
3
+ checkIsDefined
4
+ };
@@ -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,5 @@
1
+ const MINUTE_TO_MILLESECONDS_MULTIPLIER = 6e4;
2
+ const getCurrentDatePlusMinutes = (minutes = 30) => new Date(Date.now() + minutes * MINUTE_TO_MILLESECONDS_MULTIPLIER);
3
+ export {
4
+ getCurrentDatePlusMinutes
5
+ };
@@ -0,0 +1,10 @@
1
+ const getTopLevelDomain = (host) => {
2
+ const parts = host.split(".");
3
+ if (parts.length > 2) {
4
+ return parts.slice(1).join(".");
5
+ }
6
+ return host;
7
+ };
8
+ export {
9
+ getTopLevelDomain
10
+ };
@@ -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
- if (isEditing()) {
78
- registerInsertMenu();
79
- setupBrowserForEditing();
80
- }
76
+ export {
77
+ registerInsertMenu,
78
+ setupBrowserForEditing
79
+ };
File without changes