@builder.io/sdk-react 0.0.1-3 → 0.0.1-6

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",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.0.1-3",
4
+ "version": "0.0.1-6",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "exports": {
@@ -57,10 +57,10 @@ function Columns(props) {
57
57
  };
58
58
  }
59
59
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
60
- className: "builder-columns div-01f6ab8c",
60
+ className: "builder-columns div-6588dcca",
61
61
  style: columnsCssVars()
62
62
  }, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement("div", {
63
- className: "builder-column div-01f6ab8c-2",
63
+ className: "builder-column div-6588dcca-2",
64
64
  style: __spreadValues({
65
65
  width: getColumnCssWidth(index),
66
66
  marginLeft: `${index === 0 ? 0 : getGutterSize()}px`
@@ -70,15 +70,15 @@ function Columns(props) {
70
70
  blocks: column.blocks,
71
71
  path: `component.options.columns.${index}.blocks`,
72
72
  parent: props.builderBlock.id
73
- })))), /* @__PURE__ */ React.createElement("style", null, `.div-01f6ab8c {
73
+ })))), /* @__PURE__ */ React.createElement("style", null, `.div-6588dcca {
74
74
  display: flex;
75
75
  align-items: stretch;
76
- line-height: normal; }@media (max-width: 991px) { .div-01f6ab8c {
77
- flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-01f6ab8c {
78
- flex-direction: var(--flex-dir); } }.div-01f6ab8c-2 {
79
- flex-grow: 1; }@media (max-width: 991px) { .div-01f6ab8c-2 {
76
+ line-height: normal; }@media (max-width: 991px) { .div-6588dcca {
77
+ flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-6588dcca {
78
+ flex-direction: var(--flex-dir); } }.div-6588dcca-2 {
79
+ flex-grow: 1; }@media (max-width: 991px) { .div-6588dcca-2 {
80
80
  width: var(--column-width-tablet) !important;
81
- margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-01f6ab8c-2 {
81
+ margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-6588dcca-2 {
82
82
  width: var(--column-width) !important;
83
83
  margin-left: var(--column-margin-left) !important; } }`));
84
84
  }
@@ -1,4 +1,4 @@
1
- import { markSerializable } from "../util";
1
+ import { markSerializable } from "../util.js";
2
2
  const componentInfo = {
3
3
  name: "Columns",
4
4
  builtIn: true,
@@ -1,4 +1,4 @@
1
- import { markSerializable } from "../util";
1
+ import { markSerializable } from "../util.js";
2
2
  const componentInfo = {
3
3
  name: "Embed",
4
4
  static: true,
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { useState, useRef, useEffect } from "react";
3
- import { isJsScript } from "./helpers";
3
+ import { isJsScript } from "./helpers.js";
4
4
  function Embed(props) {
5
5
  const elem = useRef(null);
6
6
  const [scriptsInserted, setScriptsInserted] = useState(() => []);
@@ -1,4 +1,4 @@
1
- import { markSerializable } from "../util";
1
+ import { markSerializable } from "../util.js";
2
2
  const componentInfo = {
3
3
  name: "Image",
4
4
  static: true,
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { getSrcSet } from "./image.helpers";
2
+ import { getSrcSet } from "./image.helpers.js";
3
3
  function Image(props) {
4
4
  var _a, _b, _c, _d;
5
5
  function srcSetToUse() {
@@ -28,7 +28,7 @@ function Image(props) {
28
28
  }
29
29
  }
30
30
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
31
- className: "div-4c804184"
31
+ className: "div-95472e7c"
32
32
  }, /* @__PURE__ */ React.createElement("picture", null, webpSrcSet() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("source", {
33
33
  type: "image/webp",
34
34
  srcset: webpSrcSet()
@@ -40,31 +40,31 @@ function Image(props) {
40
40
  objectPosition: props.backgroundSize || "center",
41
41
  objectFit: props.backgroundSize || "cover"
42
42
  },
43
- className: "builder-image" + (props.className ? " " + props.className : "") + " img-4c804184",
43
+ className: "builder-image" + (props.className ? " " + props.className : "") + " img-95472e7c",
44
44
  src: props.image,
45
45
  srcset: srcSetToUse(),
46
46
  sizes: props.sizes
47
47
  }), /* @__PURE__ */ React.createElement("source", {
48
48
  srcset: srcSetToUse()
49
49
  })), props.aspectRatio && !(props.fitContent && ((_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.length)) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
50
- className: "builder-image-sizer div-4c804184-2",
50
+ className: "builder-image-sizer div-95472e7c-2",
51
51
  style: {
52
52
  paddingTop: props.aspectRatio * 100 + "%"
53
53
  }
54
54
  })) : null, ((_d = (_c = props.builderBlock) == null ? void 0 : _c.children) == null ? void 0 : _d.length) && props.fitContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, props.children) : null, !props.fitContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
55
- className: "div-4c804184-3"
56
- }, props.children)) : null), /* @__PURE__ */ React.createElement("style", null, `.div-4c804184 {
57
- position: relative; }.img-4c804184 {
55
+ className: "div-95472e7c-3"
56
+ }, props.children)) : null), /* @__PURE__ */ React.createElement("style", null, `.div-95472e7c {
57
+ position: relative; }.img-95472e7c {
58
58
  opacity: 1;
59
59
  transition: opacity 0.2s ease-in-out;
60
60
  position: absolute;
61
61
  height: 100%;
62
62
  width: 100%;
63
63
  top: 0px;
64
- left: 0px; }.div-4c804184-2 {
64
+ left: 0px; }.div-95472e7c-2 {
65
65
  width: 100%;
66
66
  pointer-events: none;
67
- font-size: 0; }.div-4c804184-3 {
67
+ font-size: 0; }.div-95472e7c-3 {
68
68
  display: flex;
69
69
  flex-direction: column;
70
70
  align-items: stretch;
@@ -20,7 +20,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import * as React from "react";
21
21
  import { useState, useContext, useEffect } from "react";
22
22
  import RenderContent from "../../components/render-content/render-content.js";
23
- import BuilderContext from "../../context/builder.context";
23
+ import BuilderContext from "../../context/builder.context.js";
24
24
  import { getContent } from "../../functions/get-content/index.js";
25
25
  function Symbol(props) {
26
26
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import BuilderContext from "../../context/builder.context";
2
+ import BuilderContext from "../../context/builder.context.js";
3
3
  import RenderBlock from "./render-block.js";
4
4
  function RenderRepeatedBlock(props) {
5
5
  return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { useContext } from "react";
3
- import BuilderContext from "../context/builder.context";
3
+ import BuilderContext from "../context/builder.context.js";
4
4
  import { isEditing } from "../functions/is-editing.js";
5
5
  import BlockStyles from "./render-block/block-styles.js";
6
6
  import RenderBlock from "./render-block/render-block.js";
@@ -41,7 +41,7 @@ import * as React from "react";
41
41
  import { useState, useRef, useEffect } from "react";
42
42
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
43
43
  import { TARGET } from "../../constants/target.js";
44
- import BuilderContext from "../../context/builder.context";
44
+ import BuilderContext from "../../context/builder.context.js";
45
45
  import { evaluate } from "../../functions/evaluate.js";
46
46
  import { getContent } from "../../functions/get-content/index.js";
47
47
  import { getFetch } from "../../functions/get-fetch.js";
@@ -15,25 +15,25 @@ var __spreadValues = (a, b) => {
15
15
  return a;
16
16
  };
17
17
  import { default as Button } from "../blocks/button/button.js";
18
- import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
18
+ import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info.js";
19
19
  import { default as Columns } from "../blocks/columns/columns.js";
20
- import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info";
21
- import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info";
20
+ import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info.js";
21
+ import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info.js";
22
22
  import { default as Fragment } from "../blocks/fragment/fragment.js";
23
- import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
23
+ import { componentInfo as imageComponentInfo } from "../blocks/image/component-info.js";
24
24
  import { default as Image } from "../blocks/image/image.js";
25
- import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
25
+ import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info.js";
26
26
  import { default as Section } from "../blocks/section/section.js";
27
- import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
27
+ import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info.js";
28
28
  import { default as Symbol } from "../blocks/symbol/symbol.js";
29
- import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
29
+ import { componentInfo as textComponentInfo } from "../blocks/text/component-info.js";
30
30
  import { default as Text } from "../blocks/text/text.js";
31
- import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
31
+ import { componentInfo as videoComponentInfo } from "../blocks/video/component-info.js";
32
32
  import { default as Video } from "../blocks/video/video.js";
33
- import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info";
33
+ import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info.js";
34
34
  import { default as embed } from "../blocks/embed/embed.js";
35
35
  import { default as Img } from "../blocks/img/img.js";
36
- import { componentInfo as imgComponentInfo } from "../blocks/img/component-info";
36
+ import { componentInfo as imgComponentInfo } from "../blocks/img/component-info.js";
37
37
  const getDefaultRegisteredComponents = () => [
38
38
  __spreadValues({ component: Columns }, columnsComponentInfo),
39
39
  __spreadValues({ component: Image }, imageComponentInfo),
@@ -29,6 +29,26 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
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
+ };
32
52
  import { TARGET } from "../constants/target.js";
33
53
  import { getSessionId } from "../helpers/sessionId.js";
34
54
  import { getVisitorId } from "../helpers/visitorId.js";
@@ -66,24 +86,28 @@ const createEvent = (_a) => {
66
86
  };
67
87
  };
68
88
  function track(eventProps) {
69
- if (!eventProps.canTrack) {
70
- return;
71
- }
72
- if (isEditing()) {
73
- return;
74
- }
75
- if (!(isBrowser() || TARGET === "reactNative")) {
76
- return;
77
- }
78
- return fetch(`https://builder.io/api/v1/track`, {
79
- method: "POST",
80
- body: JSON.stringify({
81
- events: [createEvent(eventProps)]
82
- }),
83
- headers: {
84
- "content-type": "application/json"
85
- },
86
- mode: "cors"
89
+ return __async(this, null, function* () {
90
+ if (!eventProps.canTrack) {
91
+ return;
92
+ }
93
+ if (isEditing()) {
94
+ return;
95
+ }
96
+ if (!(isBrowser() || TARGET === "reactNative")) {
97
+ return;
98
+ }
99
+ return fetch(`https://builder.io/api/v1/track`, {
100
+ method: "POST",
101
+ body: JSON.stringify({
102
+ events: [createEvent(eventProps)]
103
+ }),
104
+ headers: {
105
+ "content-type": "application/json"
106
+ },
107
+ mode: "cors"
108
+ }).catch((err) => {
109
+ console.error("Failed to track: ", err);
110
+ });
87
111
  });
88
112
  }
89
113
  export {
@@ -1,4 +1,4 @@
1
- import { camelToKebabCase } from "../functions/camel-to-kebab-case";
1
+ import { camelToKebabCase } from "../functions/camel-to-kebab-case.js";
2
2
  const convertStyleMaptoCSS = (style) => {
3
3
  const cssProps = Object.entries(style).map(([key, value]) => {
4
4
  if (typeof value === "string") {
@@ -1,6 +1,6 @@
1
- import { getCookie, setCookie } from "./cookie";
2
- import { checkIsDefined } from "./nullable";
3
- import { uuid } from "./uuid";
1
+ import { getCookie, setCookie } from "./cookie.js";
2
+ import { checkIsDefined } from "./nullable.js";
3
+ import { uuid } from "./uuid.js";
4
4
  const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
5
5
  const getSessionId = ({ canTrack }) => {
6
6
  if (!canTrack) {
@@ -1,6 +1,6 @@
1
- import { getLocalStorageItem, setLocalStorageItem } from "./localStorage";
2
- import { checkIsDefined } from "./nullable";
3
- import { uuid } from "./uuid";
1
+ import { getLocalStorageItem, setLocalStorageItem } from "./localStorage.js";
2
+ import { checkIsDefined } from "./nullable.js";
3
+ import { uuid } from "./uuid.js";
4
4
  const VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
5
5
  const getVisitorId = ({ canTrack }) => {
6
6
  if (!canTrack) {