@builder.io/sdk-react-native 0.0.1-66 → 0.0.1-69

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 (99) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/button/button.js +5 -2
  3. package/src/blocks/button/component-info.js +0 -1
  4. package/src/blocks/columns/columns.js +3 -1
  5. package/src/blocks/columns/component-info.js +3 -3
  6. package/src/blocks/custom-code/component-info.js +0 -1
  7. package/src/blocks/embed/component-info.js +3 -3
  8. package/src/blocks/embed/embed.js +1 -1
  9. package/src/blocks/embed/helpers.js +0 -1
  10. package/src/blocks/form/component-info.js +0 -1
  11. package/src/blocks/form/form.js +5 -2
  12. package/src/blocks/fragment/component-info.js +0 -1
  13. package/src/blocks/image/component-info.js +3 -3
  14. package/src/blocks/image/image.helpers.js +0 -1
  15. package/src/blocks/image/image.js +0 -1
  16. package/src/blocks/img/component-info.js +0 -1
  17. package/src/blocks/img/img.js +1 -1
  18. package/src/blocks/input/component-info.js +0 -1
  19. package/src/blocks/raw-text/component-info.js +0 -1
  20. package/src/blocks/section/component-info.js +0 -1
  21. package/src/blocks/select/component-info.js +0 -1
  22. package/src/blocks/submit-button/component-info.js +0 -1
  23. package/src/blocks/symbol/component-info.js +0 -1
  24. package/src/blocks/text/component-info.js +0 -1
  25. package/src/blocks/text/text.js +0 -1
  26. package/src/blocks/textarea/component-info.js +0 -1
  27. package/src/blocks/util.js +7 -0
  28. package/src/blocks/video/component-info.js +0 -1
  29. package/src/blocks/video/video.js +0 -1
  30. package/src/components/render-block/block-styles.js +5 -8
  31. package/src/components/render-block/render-block.helpers.js +0 -1
  32. package/src/components/render-block/render-block.js +22 -20
  33. package/src/components/render-block/render-component.js +4 -2
  34. package/src/components/render-block/render-repeated-block.js +2 -1
  35. package/src/components/render-block/types.js +0 -1
  36. package/src/components/render-blocks.js +7 -2
  37. package/src/components/render-content/index.js +0 -1
  38. package/src/components/render-content/render-content.js +28 -8
  39. package/src/constants/builder-registered-components.js +0 -1
  40. package/src/constants/device-sizes.js +0 -1
  41. package/src/constants/target.js +0 -1
  42. package/src/functions/camel-to-kebab-case.js +0 -1
  43. package/src/functions/convert-style-object.js +0 -1
  44. package/src/functions/evaluate.js +0 -1
  45. package/src/functions/event-handler-name.js +0 -1
  46. package/src/functions/get-block-actions.js +0 -1
  47. package/src/functions/get-block-component-options.js +0 -1
  48. package/src/functions/get-block-properties.js +0 -1
  49. package/src/functions/get-block-styles.js +0 -1
  50. package/src/functions/get-block-tag.js +0 -1
  51. package/src/functions/get-builder-search-params/fn.test.js +0 -1
  52. package/src/functions/get-builder-search-params/index.js +0 -1
  53. package/src/functions/get-content/ab-testing.js +0 -1
  54. package/src/functions/get-content/fn.test.js +0 -1
  55. package/src/functions/get-content/index.js +0 -1
  56. package/src/functions/get-content/types.js +0 -1
  57. package/src/functions/get-fetch.js +2 -3
  58. package/src/functions/get-global-this.js +0 -1
  59. package/src/functions/get-processed-block.js +10 -7
  60. package/src/functions/get-processed-block.test.js +1 -2
  61. package/src/functions/if-target.js +0 -1
  62. package/src/functions/is-browser.js +0 -1
  63. package/src/functions/is-editing.js +0 -1
  64. package/src/functions/is-iframe.js +0 -1
  65. package/src/functions/is-previewing.js +0 -1
  66. package/src/functions/is-react-native.js +0 -1
  67. package/src/functions/on-change.js +0 -1
  68. package/src/functions/on-change.test.js +0 -1
  69. package/src/functions/register-component.js +0 -1
  70. package/src/functions/register.js +0 -1
  71. package/src/functions/sanitize-styles.js +0 -1
  72. package/src/functions/set-editor-settings.js +0 -1
  73. package/src/functions/set.js +0 -1
  74. package/src/functions/set.test.js +0 -1
  75. package/src/functions/track.js +71 -3
  76. package/src/functions/transform-block.js +0 -1
  77. package/src/helpers/cookie.js +59 -0
  78. package/src/helpers/css.js +0 -1
  79. package/src/helpers/flatten.js +0 -1
  80. package/src/helpers/localStorage.js +34 -0
  81. package/src/helpers/nullable.js +4 -0
  82. package/src/helpers/sessionId.js +26 -0
  83. package/src/helpers/time.js +5 -0
  84. package/src/helpers/url.js +10 -0
  85. package/src/helpers/url.test.js +15 -0
  86. package/src/helpers/uuid.js +13 -0
  87. package/src/helpers/visitorId.js +33 -0
  88. package/src/index-helpers/blocks-exports.js +0 -1
  89. package/src/index-helpers/top-of-file.js +0 -1
  90. package/src/index.js +0 -1
  91. package/src/scripts/init-editing.js +4 -6
  92. package/src/types/builder-block.js +0 -1
  93. package/src/types/builder-content.js +0 -1
  94. package/src/types/can-track.js +0 -0
  95. package/src/types/components.js +0 -1
  96. package/src/types/deep-partial.js +0 -1
  97. package/src/types/element.js +0 -1
  98. package/src/types/targets.js +0 -1
  99. package/src/types/typescript.js +0 -1
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
3
  var __hasOwnProp = Object.prototype.hasOwnProperty;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { View } from "react-native";
3
2
  function getBlockTag(_block) {
4
3
  return View;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { convertSearchParamsToQueryObject, getBuilderSearchParams } from ".";
3
2
  const querystring = "someotherValue=jklsjfdal&abc=klfdjklgfds&builder.cachebust=true&builder.preview=page&builder.noCache=true&__builder_editing__=true&builder.overrides.page=037948e52eaf4743afed464f02c70da4&builder.overrides.037948e52eaf4743afed464f02c70da4=037948e52eaf4743afed464f02c70da4&builder.overrides.page%3A%2F=037948e52eaf4743afed464f02c70da4&preview_theme_id=128854393017";
4
3
  const url = new URL(`localhost:3000/about-us?${querystring}`);
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { isBrowser } from "../is-browser";
3
2
  const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
4
3
  const convertSearchParamsToQueryObject = (searchParams) => {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  const handleABTesting = (item, testGroups) => {
3
2
  if (item.variations && Object.keys(item.variations).length) {
4
3
  const testGroup = item.id ? testGroups[item.id] : void 0;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { generateContentUrl } from ".";
3
2
  const testKey = "YJIGb4i01jvw0SRdL5Bt";
4
3
  const testModel = "page";
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -1 +0,0 @@
1
- import * as React from 'react';
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __async = (__this, __arguments, generator) => {
3
2
  return new Promise((resolve, reject) => {
4
3
  var fulfilled = (value) => {
@@ -25,9 +24,9 @@ function getFetch() {
25
24
  const globalFetch = getGlobalThis().fetch;
26
25
  if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
27
26
  const nodeFetch = import("node-fetch").then((d) => d.default);
28
- return nodeFetch;
27
+ return nodeFetch.default || nodeFetch;
29
28
  }
30
- return globalFetch;
29
+ return globalFetch.default || globalFetch;
31
30
  });
32
31
  }
33
32
  export {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  function getGlobalThis() {
3
2
  if (typeof globalThis !== "undefined") {
4
3
  return globalThis;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -40,13 +39,17 @@ const evaluateBindings = ({
40
39
  }
41
40
  return copied;
42
41
  };
43
- function getProcessedBlock(options) {
44
- const { state, context } = options;
45
- const block = transformBlock(options.block);
46
- if (evaluateBindings) {
47
- return evaluateBindings({ block, state, context });
42
+ function getProcessedBlock({
43
+ block,
44
+ context,
45
+ shouldEvaluateBindings,
46
+ state
47
+ }) {
48
+ const transformedBlock = transformBlock(block);
49
+ if (shouldEvaluateBindings) {
50
+ return evaluateBindings({ block: transformedBlock, state, context });
48
51
  } else {
49
- return block;
52
+ return transformedBlock;
50
53
  }
51
54
  }
52
55
  export {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { getProcessedBlock } from "./get-processed-block.js";
3
2
  test("Can process bindings", () => {
4
3
  var _a, _b, _c, _d, _e, _f;
@@ -22,7 +21,7 @@ test("Can process bindings", () => {
22
21
  block,
23
22
  context: {},
24
23
  state: { test: "hello" },
25
- evaluateBindings: true
24
+ shouldEvaluateBindings: true
26
25
  });
27
26
  expect(processed).not.toEqual(block);
28
27
  expect((_a = processed.properties) == null ? void 0 : _a.foo).toEqual("baz");
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { TARGET } from "../constants/target.js";
3
2
  function ifTarget({
4
3
  targets,
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  function isBrowser() {
3
2
  return typeof window !== "undefined" && typeof document !== "undefined";
4
3
  }
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { isIframe } from "./is-iframe.js";
3
2
  function isEditing() {
4
3
  return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { isBrowser } from "./is-browser.js";
3
2
  function isIframe() {
4
3
  return isBrowser() && window.self !== window.top;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { isBrowser } from "./is-browser.js";
3
2
  import { isEditing } from "./is-editing.js";
4
3
  function isPreviewing() {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  function isReactNative() {
3
2
  return true;
4
3
  }
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  const onChangeProxySymbol = Symbol("onChangeProxySymbol");
3
2
  function onChange(obj, cb) {
4
3
  return new Proxy(obj, {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { onChange } from "./on-change.js";
3
2
  test("onChange can observe a shallow change", () => {
4
3
  let changeHappend = false;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { isBrowser } from "./is-browser.js";
3
2
  const registry = {};
4
3
  function register(type, info) {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  const propertiesThatMustBeNumber = new Set(["lineHeight"]);
3
2
  const displayValues = new Set(["flex", "none"]);
4
3
  const SHOW_WARNINGS = false;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { isBrowser } from "./is-browser.js";
3
2
  const settings = {};
4
3
  function setEditorSettings(newSettings) {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  const set = (obj, _path, value) => {
3
2
  if (Object(obj) !== obj) {
4
3
  return obj;
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { set } from "./set.js";
3
2
  test("can shallow set a property", () => {
4
3
  const obj = { foo: "bar" };
@@ -1,8 +1,74 @@
1
- import * as React from 'react';
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
+ };
2
32
  import { TARGET } from "../constants/target.js";
33
+ import { getSessionId } from "../helpers/sessionId.js";
34
+ import { getVisitorId } from "../helpers/visitorId.js";
3
35
  import { isBrowser } from "./is-browser.js";
4
36
  import { isEditing } from "./is-editing.js";
5
- function track(event, properties) {
37
+ const getTrackingEventData = ({ canTrack }) => {
38
+ if (!canTrack) {
39
+ return { visitorId: void 0, sessionId: void 0 };
40
+ }
41
+ const sessionId = getSessionId({ canTrack });
42
+ const visitorId = getVisitorId({ canTrack });
43
+ return {
44
+ sessionId,
45
+ visitorId
46
+ };
47
+ };
48
+ const createEvent = (_a) => {
49
+ var _b = _a, {
50
+ type: eventType,
51
+ canTrack,
52
+ orgId,
53
+ contentId
54
+ } = _b, properties = __objRest(_b, [
55
+ "type",
56
+ "canTrack",
57
+ "orgId",
58
+ "contentId"
59
+ ]);
60
+ return {
61
+ type: eventType,
62
+ data: __spreadProps(__spreadValues(__spreadValues({}, properties), getTrackingEventData({ canTrack })), {
63
+ ownerId: orgId,
64
+ contentId
65
+ })
66
+ };
67
+ };
68
+ function track(eventProps) {
69
+ if (!eventProps.canTrack) {
70
+ return;
71
+ }
6
72
  if (isEditing()) {
7
73
  return;
8
74
  }
@@ -11,7 +77,9 @@ function track(event, properties) {
11
77
  }
12
78
  return fetch(`https://builder.io/api/v1/track`, {
13
79
  method: "POST",
14
- body: JSON.stringify({ events: [{ type: event, data: properties }] }),
80
+ body: JSON.stringify({
81
+ events: [createEvent(eventProps)]
82
+ }),
15
83
  headers: {
16
84
  "content-type": "application/json"
17
85
  },
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -0,0 +1,59 @@
1
+ import { isBrowser } from "../functions/is-browser";
2
+ import { getTopLevelDomain } from "./url";
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
+ };
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { camelToKebabCase } from "../functions/camel-to-kebab-case";
3
2
  const convertStyleMaptoCSS = (style) => {
4
3
  const cssProps = Object.entries(style).map(([key, value]) => {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -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,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { default as default2 } from "../blocks/columns/columns.js";
3
2
  import { default as default3 } from "../blocks/image/image.js";
4
3
  import { default as default4 } from "../blocks/text/text.js";
@@ -1,2 +1 @@
1
- import * as React from 'react';
2
1
  import "react-native-url-polyfill/auto";
package/src/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import "./index-helpers/top-of-file.js";
3
2
  import "./scripts/init-editing.js";
4
3
  export * from "./index-helpers/blocks-exports.js";
@@ -1,7 +1,5 @@
1
- import * as React from 'react';
2
1
  import { TARGET } from "../constants/target.js";
3
2
  import { isBrowser } from "../functions/is-browser.js";
4
- import { isEditing } from "../functions/is-editing.js";
5
3
  import { register } from "../functions/register.js";
6
4
  const registerInsertMenu = () => {
7
5
  register("insertMenu", {
@@ -75,7 +73,7 @@ const setupBrowserForEditing = () => {
75
73
  });
76
74
  }
77
75
  };
78
- if (isEditing()) {
79
- registerInsertMenu();
80
- setupBrowserForEditing();
81
- }
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
@@ -1 +0,0 @@
1
- import * as React from 'react';
@@ -1 +0,0 @@
1
- import * as React from 'react';
@@ -1 +0,0 @@
1
- import * as React from 'react';
@@ -1 +0,0 @@
1
- import * as React from 'react';
@@ -1 +0,0 @@
1
- import * as React from 'react';