@builder.io/sdk-react-native 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-native",
3
3
  "description": "Builder.io SDK for React Native",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "main": "src/index.js",
6
6
  "files": [
7
7
  "src"
@@ -40,6 +40,7 @@ import {
40
40
  registerInsertMenu,
41
41
  setupBrowserForEditing
42
42
  } from "../../scripts/init-editing.js";
43
+ import { checkIsDefined } from "../../helpers/nullable.js";
43
44
  function RenderContent(props) {
44
45
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
45
46
  const elementRef = useRef(null);
@@ -61,7 +62,7 @@ function RenderContent(props) {
61
62
  const [update, setUpdate] = useState(() => 0);
62
63
  const [useBreakpoints, setUseBreakpoints] = useState(() => null);
63
64
  function canTrackToUse() {
64
- return props.canTrack || true;
65
+ return checkIsDefined(props.canTrack) ? props.canTrack : true;
65
66
  }
66
67
  const [overrideState, setOverrideState] = useState(() => ({}));
67
68
  function contentState() {
@@ -12,6 +12,7 @@ const getLocalStorageItem = ({
12
12
  return void 0;
13
13
  } catch (err) {
14
14
  console.debug("[LocalStorage] GET error: ", err);
15
+ return void 0;
15
16
  }
16
17
  };
17
18
  const setLocalStorageItem = ({
@@ -22,7 +22,9 @@ import { getCookie, setCookie } from "./cookie.js";
22
22
  import { checkIsDefined } from "./nullable.js";
23
23
  import { uuid } from "./uuid.js";
24
24
  const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
25
- const getSessionId = (_0) => __async(void 0, [_0], function* ({ canTrack }) {
25
+ const getSessionId = (_0) => __async(void 0, [_0], function* ({
26
+ canTrack
27
+ }) {
26
28
  if (!canTrack) {
27
29
  return void 0;
28
30
  }
@@ -35,6 +37,7 @@ const getSessionId = (_0) => __async(void 0, [_0], function* ({ canTrack }) {
35
37
  } else {
36
38
  const newSessionId = createSessionId();
37
39
  setSessionId({ id: newSessionId, canTrack });
40
+ return newSessionId;
38
41
  }
39
42
  });
40
43
  const createSessionId = () => uuid();
@@ -1,4 +1,7 @@
1
1
  const getTopLevelDomain = (host) => {
2
+ if (host === "localhost" || host === "127.0.0.1") {
3
+ return host;
4
+ }
2
5
  const parts = host.split(".");
3
6
  if (parts.length > 2) {
4
7
  return parts.slice(1).join(".");
@@ -12,4 +12,10 @@ describe("getTopLevelDomain", () => {
12
12
  const output = getTopLevelDomain("www.example.co.uk");
13
13
  expect(output).toBe("example.co.uk");
14
14
  });
15
+ test("handles localhost", () => {
16
+ const output = getTopLevelDomain("localhost");
17
+ expect(output).toBe("localhost");
18
+ const output2 = getTopLevelDomain("127.0.0.1");
19
+ expect(output2).toBe("127.0.0.1");
20
+ });
15
21
  });
@@ -15,6 +15,7 @@ const getVisitorId = ({ canTrack }) => {
15
15
  } else {
16
16
  const newVisitorId = createVisitorId();
17
17
  setVisitorId({ id: newVisitorId, canTrack });
18
+ return newVisitorId;
18
19
  }
19
20
  };
20
21
  const createVisitorId = () => uuid();