@builder.io/sdk-react-native 0.0.1-49 → 0.0.1-51

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 (142) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/package.json +1 -1
  3. package/src/blocks/button/button.js +31 -0
  4. package/src/blocks/{button.lite.tsx → button/button.lite.tsx} +3 -3
  5. package/src/blocks/button/component-info.js +42 -0
  6. package/src/blocks/columns/columns.js +59 -0
  7. package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +22 -21
  8. package/src/blocks/columns/component-info.js +218 -0
  9. package/src/blocks/custom-code/component-info.js +32 -0
  10. package/src/blocks/custom-code/custom-code.js +50 -0
  11. package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +11 -11
  12. package/src/blocks/embed/component-info.js +25 -0
  13. package/src/blocks/embed/embed.js +50 -0
  14. package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +11 -11
  15. package/src/blocks/form/component-info.js +263 -0
  16. package/src/blocks/form/form.js +221 -0
  17. package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +51 -50
  18. package/src/blocks/fragment/component-info.js +12 -0
  19. package/src/blocks/fragment/fragment.js +8 -0
  20. package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +2 -2
  21. package/src/blocks/image/component-info.js +105 -0
  22. package/src/blocks/image/image.js +41 -0
  23. package/src/blocks/{image.lite.tsx → image/image.lite.tsx} +11 -11
  24. package/src/blocks/img/component-info.js +21 -0
  25. package/src/blocks/img/img.js +36 -0
  26. package/src/blocks/img/img.lite.tsx +18 -0
  27. package/src/blocks/input/component-info.js +75 -0
  28. package/src/blocks/input/input.js +36 -0
  29. package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -4
  30. package/src/blocks/raw-text/component-info.js +17 -0
  31. package/src/blocks/raw-text/raw-text.js +10 -0
  32. package/src/blocks/raw-text/raw-text.lite.tsx +6 -0
  33. package/src/blocks/section/component-info.js +50 -0
  34. package/src/blocks/section/section.js +31 -0
  35. package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -3
  36. package/src/blocks/select/component-info.js +60 -0
  37. package/src/blocks/select/select.js +36 -0
  38. package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +4 -4
  39. package/src/blocks/submit-button/component-info.js +29 -0
  40. package/src/blocks/submit-button/submit-button.js +29 -0
  41. package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +2 -2
  42. package/src/blocks/symbol/component-info.js +43 -0
  43. package/src/blocks/symbol/symbol.js +68 -0
  44. package/src/blocks/symbol/symbol.lite.tsx +60 -0
  45. package/src/blocks/text/component-info.js +25 -0
  46. package/src/blocks/text/text.js +65 -0
  47. package/src/blocks/text/text.lite.tsx +6 -0
  48. package/src/blocks/textarea/component-info.js +48 -0
  49. package/src/blocks/textarea/textarea.js +32 -0
  50. package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +2 -2
  51. package/src/blocks/video/component-info.js +107 -0
  52. package/src/blocks/video/video.js +33 -0
  53. package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +5 -5
  54. package/src/components/error-boundary.js +9 -11
  55. package/src/components/error-boundary.lite.tsx +2 -2
  56. package/src/components/render-block/block-styles.js +29 -0
  57. package/src/components/render-block/block-styles.lite.tsx +35 -0
  58. package/src/components/render-block/render-block.helpers.js +24 -0
  59. package/src/components/render-block/render-block.js +116 -0
  60. package/src/components/render-block/render-block.lite.tsx +139 -0
  61. package/src/components/render-blocks.js +35 -61
  62. package/src/components/render-blocks.lite.tsx +11 -11
  63. package/src/components/render-content/components/render-styles.js +58 -0
  64. package/src/components/render-content/components/render-styles.lite.tsx +70 -0
  65. package/src/components/render-content/index.js +5 -0
  66. package/src/components/render-content/render-content.js +254 -0
  67. package/src/components/render-content/render-content.lite.tsx +283 -0
  68. package/src/components/render-inlined-styles.js +18 -0
  69. package/src/components/render-inlined-styles.lite.tsx +31 -0
  70. package/src/constants/builder-registered-components.js +27 -0
  71. package/src/constants/device-sizes.js +11 -8
  72. package/src/constants/target.js +5 -0
  73. package/src/context/builder.context.js +11 -3
  74. package/src/functions/evaluate.js +20 -20
  75. package/src/functions/event-handler-name.js +3 -1
  76. package/src/functions/fast-clone.js +5 -0
  77. package/src/functions/get-block-actions.js +17 -16
  78. package/src/functions/get-block-component-options.js +9 -16
  79. package/src/functions/get-block-properties.js +14 -18
  80. package/src/functions/get-block-styles.js +17 -34
  81. package/src/functions/get-block-tag.js +4 -2
  82. package/src/functions/get-builder-search-params/fn.test.js +6 -10
  83. package/src/functions/get-builder-search-params/index.js +6 -3
  84. package/src/functions/get-content/fn.test.js +15 -17
  85. package/src/functions/get-content/index.js +25 -42
  86. package/src/functions/get-fetch.js +32 -8
  87. package/src/functions/get-global-this.js +7 -5
  88. package/src/functions/get-processed-block.js +13 -17
  89. package/src/functions/get-processed-block.test.js +16 -27
  90. package/src/functions/if-target.js +14 -3
  91. package/src/functions/is-browser.js +4 -2
  92. package/src/functions/is-editing.js +5 -5
  93. package/src/functions/is-iframe.js +4 -2
  94. package/src/functions/is-previewing.js +6 -4
  95. package/src/functions/is-react-native.js +3 -1
  96. package/src/functions/macro-eval.js +5 -2
  97. package/src/functions/on-change.js +7 -4
  98. package/src/functions/on-change.test.js +9 -10
  99. package/src/functions/previewing-model-name.js +5 -3
  100. package/src/functions/register-component.js +33 -44
  101. package/src/functions/register.js +10 -8
  102. package/src/functions/set-editor-settings.js +7 -5
  103. package/src/functions/set.js +5 -14
  104. package/src/functions/set.test.js +13 -14
  105. package/src/functions/track.js +13 -7
  106. package/src/functions/transform-block.js +13 -17
  107. package/src/index-helpers/blocks-exports.js +9 -9
  108. package/src/index-helpers/top-of-file.js +1 -1
  109. package/src/index.js +10 -12
  110. package/src/scripts/init-editing.js +74 -88
  111. package/src/types/components.js +1 -0
  112. package/src/types/element.js +1 -0
  113. package/src/types/targets.js +1 -0
  114. package/src/types/typescript.js +1 -0
  115. package/src/blocks/button.js +0 -86
  116. package/src/blocks/columns.js +0 -293
  117. package/src/blocks/custom-code.js +0 -83
  118. package/src/blocks/embed.js +0 -77
  119. package/src/blocks/form.js +0 -521
  120. package/src/blocks/fragment.js +0 -21
  121. package/src/blocks/image.js +0 -165
  122. package/src/blocks/img.js +0 -64
  123. package/src/blocks/img.lite.tsx +0 -18
  124. package/src/blocks/input.js +0 -113
  125. package/src/blocks/raw-text.js +0 -17
  126. package/src/blocks/raw-text.lite.tsx +0 -6
  127. package/src/blocks/section.js +0 -84
  128. package/src/blocks/select.js +0 -91
  129. package/src/blocks/submit-button.js +0 -60
  130. package/src/blocks/symbol.js +0 -20
  131. package/src/blocks/symbol.lite.tsx +0 -20
  132. package/src/blocks/text.js +0 -100
  133. package/src/blocks/text.lite.tsx +0 -6
  134. package/src/blocks/textarea.js +0 -73
  135. package/src/blocks/video.js +0 -100
  136. package/src/components/block-styles.js +0 -5
  137. package/src/components/block-styles.lite.tsx +0 -6
  138. package/src/components/render-block.js +0 -164
  139. package/src/components/render-block.lite.tsx +0 -132
  140. package/src/components/render-content.js +0 -220
  141. package/src/components/render-content.lite.tsx +0 -206
  142. package/src/functions/get-target.js +0 -5
@@ -3,55 +3,42 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
- var __defNormalProp = (obj, key, value) =>
7
- key in obj
8
- ? __defProp(obj, key, {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value,
13
- })
14
- : (obj[key] = value);
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
7
  var __spreadValues = (a, b) => {
16
8
  for (var prop in b || (b = {}))
17
- if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
18
11
  if (__getOwnPropSymbols)
19
12
  for (var prop of __getOwnPropSymbols(b)) {
20
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
21
15
  }
22
16
  return a;
23
17
  };
24
- const propertiesThatMustBeNumber = new Set(['lineHeight']);
25
- const displayValues = new Set(['flex', 'none']);
18
+ const propertiesThatMustBeNumber = new Set(["lineHeight"]);
19
+ const displayValues = new Set(["flex", "none"]);
26
20
  const SHOW_WARNINGS = false;
27
21
  function validateReactNativeStyles(styles) {
28
22
  for (const key in styles) {
29
23
  const propertyValue = styles[key];
30
- if (key === 'display' && !displayValues.has(propertyValue)) {
24
+ if (key === "display" && !displayValues.has(propertyValue)) {
31
25
  if (SHOW_WARNINGS) {
32
- console.warn(
33
- `Style value for key "display" must be "flex" or "none" but had ${propertyValue}`
34
- );
26
+ console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
35
27
  }
36
28
  delete styles[key];
37
29
  }
38
- if (typeof propertyValue === 'string' && propertyValue.match(/^\-?\d/)) {
30
+ if (typeof propertyValue === "string" && propertyValue.match(/^\-?\d/)) {
39
31
  const newValue = parseFloat(propertyValue);
40
32
  if (!isNaN(newValue)) {
41
33
  styles[key] = newValue;
42
34
  }
43
- if (typeof newValue === 'number' && newValue < 0) {
35
+ if (typeof newValue === "number" && newValue < 0) {
44
36
  styles[key] = 0;
45
37
  }
46
38
  }
47
- if (
48
- propertiesThatMustBeNumber.has(key) &&
49
- typeof styles[key] !== 'number'
50
- ) {
39
+ if (propertiesThatMustBeNumber.has(key) && typeof styles[key] !== "number") {
51
40
  if (SHOW_WARNINGS) {
52
- console.warn(
53
- `Style key ${key} must be a number, but had value \`${styles[key]}\``
54
- );
41
+ console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
55
42
  }
56
43
  delete styles[key];
57
44
  }
@@ -59,13 +46,7 @@ function validateReactNativeStyles(styles) {
59
46
  }
60
47
  function getBlockStyles(block) {
61
48
  var _a, _b, _c;
62
- const styles = __spreadValues(
63
- __spreadValues(
64
- {},
65
- (_a = block.responsiveStyles) == null ? void 0 : _a.large
66
- ),
67
- block.styles
68
- );
49
+ const styles = __spreadValues(__spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large), block.styles);
69
50
  if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
70
51
  Object.assign(styles, block.responsiveStyles.medium);
71
52
  }
@@ -75,4 +56,6 @@ function getBlockStyles(block) {
75
56
  validateReactNativeStyles(styles);
76
57
  return styles;
77
58
  }
78
- export { getBlockStyles };
59
+ export {
60
+ getBlockStyles
61
+ };
@@ -1,6 +1,8 @@
1
1
  import * as React from 'react';
2
- import { View } from 'react-native';
2
+ import { View } from "react-native";
3
3
  function getBlockTag(block) {
4
4
  return View;
5
5
  }
6
- export { getBlockTag };
6
+ export {
7
+ getBlockTag
8
+ };
@@ -1,18 +1,14 @@
1
1
  import * as React from 'react';
2
- import { describe, test, expect } from '@jest/globals';
3
- import { getBuilderSearchParams, convertSearchParamsToQueryObject } from '.';
4
- const querystring =
5
- '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';
2
+ import { convertSearchParamsToQueryObject, getBuilderSearchParams } from ".";
3
+ 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";
6
4
  const url = new URL(`localhost:3000/about-us?${querystring}`);
7
- describe('Get Builder SearchParams', () => {
8
- test('correctly converts URLSearchParams to object', () => {
5
+ describe("Get Builder SearchParams", () => {
6
+ test("correctly converts URLSearchParams to object", () => {
9
7
  const output = convertSearchParamsToQueryObject(url.searchParams);
10
8
  expect(output).toMatchSnapshot();
11
9
  });
12
- test('correctly extracts all builder params from a query object', () => {
13
- const output = getBuilderSearchParams(
14
- convertSearchParamsToQueryObject(url.searchParams)
15
- );
10
+ test("correctly extracts all builder params from a query object", () => {
11
+ const output = getBuilderSearchParams(convertSearchParamsToQueryObject(url.searchParams));
16
12
  expect(output).toMatchSnapshot();
17
13
  });
18
14
  });
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
2
+ const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
3
3
  const convertSearchParamsToQueryObject = (searchParams) => {
4
4
  const options = {};
5
5
  searchParams.forEach((value, key) => {
@@ -11,10 +11,13 @@ const getBuilderSearchParams = (options) => {
11
11
  const newOptions = {};
12
12
  Object.keys(options).forEach((key) => {
13
13
  if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
14
- const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '');
14
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "");
15
15
  newOptions[trimmedKey] = options[key];
16
16
  }
17
17
  });
18
18
  return newOptions;
19
19
  };
20
- export { convertSearchParamsToQueryObject, getBuilderSearchParams };
20
+ export {
21
+ convertSearchParamsToQueryObject,
22
+ getBuilderSearchParams
23
+ };
@@ -1,33 +1,31 @@
1
1
  import * as React from 'react';
2
- import { describe, test, expect } from '@jest/globals';
3
- import { generateContentUrl } from '.';
4
- const testKey = 'YJIGb4i01jvw0SRdL5Bt';
5
- const testModel = 'page';
6
- const testId = 'c1b81bab59704599b997574eb0736def';
2
+ import { generateContentUrl } from ".";
3
+ const testKey = "YJIGb4i01jvw0SRdL5Bt";
4
+ const testModel = "page";
5
+ const testId = "c1b81bab59704599b997574eb0736def";
7
6
  const options = {
8
- cachebust: 'true',
9
- noCache: 'true',
10
- 'overrides.037948e52eaf4743afed464f02c70da4':
11
- '037948e52eaf4743afed464f02c70da4',
12
- 'overrides.page': '037948e52eaf4743afed464f02c70da4',
13
- 'overrides.page:/': '037948e52eaf4743afed464f02c70da4',
14
- preview: 'page',
7
+ cachebust: "true",
8
+ noCache: "true",
9
+ "overrides.037948e52eaf4743afed464f02c70da4": "037948e52eaf4743afed464f02c70da4",
10
+ "overrides.page": "037948e52eaf4743afed464f02c70da4",
11
+ "overrides.page:/": "037948e52eaf4743afed464f02c70da4",
12
+ preview: "page"
15
13
  };
16
- describe('Generate Content URL', () => {
17
- test('generates the proper value for a simple query', () => {
14
+ describe("Generate Content URL", () => {
15
+ test("generates the proper value for a simple query", () => {
18
16
  const output = generateContentUrl({
19
17
  apiKey: testKey,
20
18
  model: testModel,
21
- query: { id: testId },
19
+ query: { id: testId }
22
20
  });
23
21
  expect(output).toMatchSnapshot();
24
22
  });
25
- test('Handles overrides correctly', () => {
23
+ test("Handles overrides correctly", () => {
26
24
  const output = generateContentUrl({
27
25
  apiKey: testKey,
28
26
  model: testModel,
29
27
  query: { id: testId },
30
- options,
28
+ options
31
29
  });
32
30
  expect(output).toMatchSnapshot();
33
31
  });
@@ -5,21 +5,15 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) =>
9
- key in obj
10
- ? __defProp(obj, key, {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value,
15
- })
16
- : (obj[key] = value);
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
9
  var __spreadValues = (a, b) => {
18
10
  for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
20
13
  if (__getOwnPropSymbols)
21
14
  for (var prop of __getOwnPropSymbols(b)) {
22
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
23
17
  }
24
18
  return a;
25
19
  };
@@ -40,39 +34,27 @@ var __async = (__this, __arguments, generator) => {
40
34
  reject(e);
41
35
  }
42
36
  };
43
- var step = (x) =>
44
- x.done
45
- ? resolve(x.value)
46
- : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
47
38
  step((generator = generator.apply(__this, __arguments)).next());
48
39
  });
49
40
  };
50
- import { getFetch } from '../get-fetch';
51
- const fetch = getFetch();
52
- function flatten(object, path = null, separator = '.') {
41
+ import { getFetch } from "../get-fetch.js";
42
+ const fetch$ = getFetch();
43
+ function flatten(object, path = null, separator = ".") {
53
44
  return Object.keys(object).reduce((acc, key) => {
54
45
  const value = object[key];
55
46
  const newPath = [path, key].filter(Boolean).join(separator);
56
47
  const isObject = [
57
- typeof value === 'object',
48
+ typeof value === "object",
58
49
  value !== null,
59
- !(Array.isArray(value) && value.length === 0),
50
+ !(Array.isArray(value) && value.length === 0)
60
51
  ].every(Boolean);
61
- return isObject
62
- ? __spreadValues(
63
- __spreadValues({}, acc),
64
- flatten(value, newPath, separator)
65
- )
66
- : __spreadProps(__spreadValues({}, acc), { [newPath]: value });
52
+ return isObject ? __spreadValues(__spreadValues({}, acc), flatten(value, newPath, separator)) : __spreadProps(__spreadValues({}, acc), { [newPath]: value });
67
53
  }, {});
68
54
  }
69
55
  function getContent(options) {
70
56
  return __async(this, null, function* () {
71
- return (
72
- (yield getAllContent(
73
- __spreadProps(__spreadValues({}, options), { limit: 1 })
74
- )).results[0] || null
75
- );
57
+ return (yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }))).results[0] || null;
76
58
  });
77
59
  }
78
60
  const generateContentUrl = (options) => {
@@ -82,11 +64,9 @@ const generateContentUrl = (options) => {
82
64
  query,
83
65
  noTraverse = false,
84
66
  model,
85
- apiKey,
67
+ apiKey
86
68
  } = options;
87
- const url = new URL(
88
- `https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}`
89
- );
69
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}`);
90
70
  if (options.options) {
91
71
  const flattened = flatten(options.options);
92
72
  for (const key in flattened) {
@@ -94,7 +74,7 @@ const generateContentUrl = (options) => {
94
74
  }
95
75
  }
96
76
  if (userAttributes) {
97
- url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
77
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
98
78
  }
99
79
  if (query) {
100
80
  const flattened = flatten({ query });
@@ -122,21 +102,19 @@ const handleABTesting = (content, testGroups) => {
122
102
  const testRatio = variation.testRatio;
123
103
  n += testRatio;
124
104
  if (random < n) {
125
- const variationName =
126
- variation.name ||
127
- (variation.id === item.id ? 'Default variation' : '');
105
+ const variationName = variation.name || (variation.id === item.id ? "Default variation" : "");
128
106
  set = true;
129
107
  Object.assign(item, {
130
108
  data: variation.data,
131
109
  testVariationId: variation.id,
132
- testVariationName: variationName,
110
+ testVariationName: variationName
133
111
  });
134
112
  }
135
113
  }
136
114
  if (!set) {
137
115
  Object.assign(item, {
138
116
  testVariationId: item.id,
139
- testVariationName: 'Default',
117
+ testVariationName: "Default"
140
118
  });
141
119
  }
142
120
  }
@@ -146,6 +124,7 @@ const handleABTesting = (content, testGroups) => {
146
124
  function getAllContent(options) {
147
125
  return __async(this, null, function* () {
148
126
  const url = generateContentUrl(options);
127
+ const fetch = yield fetch$;
149
128
  const content = yield fetch(url.href).then((res) => res.json());
150
129
  if (options.testGroups) {
151
130
  handleABTesting(content, options.testGroups);
@@ -153,4 +132,8 @@ function getAllContent(options) {
153
132
  return content;
154
133
  });
155
134
  }
156
- export { generateContentUrl, getAllContent, getContent };
135
+ export {
136
+ generateContentUrl,
137
+ getAllContent,
138
+ getContent
139
+ };
@@ -1,11 +1,35 @@
1
1
  import * as React from 'react';
2
- import { getGlobalThis } from './get-global-this';
2
+ var __async = (__this, __arguments, generator) => {
3
+ return new Promise((resolve, reject) => {
4
+ var fulfilled = (value) => {
5
+ try {
6
+ step(generator.next(value));
7
+ } catch (e) {
8
+ reject(e);
9
+ }
10
+ };
11
+ var rejected = (value) => {
12
+ try {
13
+ step(generator.throw(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ };
18
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
+ step((generator = generator.apply(__this, __arguments)).next());
20
+ });
21
+ };
22
+ import { getGlobalThis } from "./get-global-this.js";
3
23
  function getFetch() {
4
- let fetch = getGlobalThis().fetch;
5
- if (typeof fetch === 'undefined' && typeof global !== 'undefined') {
6
- const _require = eval('require');
7
- fetch = _require('node-fetch');
8
- }
9
- return fetch;
24
+ return __async(this, null, function* () {
25
+ const globalFetch = getGlobalThis().fetch;
26
+ if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
27
+ const nodeFetch = import("node-fetch").then((d) => d.default);
28
+ return nodeFetch;
29
+ }
30
+ return globalFetch;
31
+ });
10
32
  }
11
- export { getFetch };
33
+ export {
34
+ getFetch
35
+ };
@@ -1,17 +1,19 @@
1
1
  import * as React from 'react';
2
2
  function getGlobalThis() {
3
- if (typeof globalThis !== 'undefined') {
3
+ if (typeof globalThis !== "undefined") {
4
4
  return globalThis;
5
5
  }
6
- if (typeof window !== 'undefined') {
6
+ if (typeof window !== "undefined") {
7
7
  return window;
8
8
  }
9
- if (typeof global !== 'undefined') {
9
+ if (typeof global !== "undefined") {
10
10
  return global;
11
11
  }
12
- if (typeof self !== 'undefined') {
12
+ if (typeof self !== "undefined") {
13
13
  return self;
14
14
  }
15
15
  return null;
16
16
  }
17
- export { getGlobalThis };
17
+ export {
18
+ getGlobalThis
19
+ };
@@ -5,28 +5,22 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) =>
9
- key in obj
10
- ? __defProp(obj, key, {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value,
15
- })
16
- : (obj[key] = value);
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
9
  var __spreadValues = (a, b) => {
18
10
  for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
20
13
  if (__getOwnPropSymbols)
21
14
  for (var prop of __getOwnPropSymbols(b)) {
22
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
23
17
  }
24
18
  return a;
25
19
  };
26
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
- import { evaluate } from './evaluate';
28
- import { set } from './set';
29
- import { transformBlock } from './transform-block';
21
+ import { evaluate } from "./evaluate.js";
22
+ import { set } from "./set.js";
23
+ import { transformBlock } from "./transform-block.js";
30
24
  function getProcessedBlock(options) {
31
25
  const { state, context } = options;
32
26
  const block = transformBlock(options.block);
@@ -35,17 +29,19 @@ function getProcessedBlock(options) {
35
29
  }
36
30
  const copied = __spreadProps(__spreadValues({}, block), {
37
31
  properties: __spreadValues({}, block.properties),
38
- actions: __spreadValues({}, block.actions),
32
+ actions: __spreadValues({}, block.actions)
39
33
  });
40
34
  for (const binding in block.bindings) {
41
35
  const expression = block.bindings[binding];
42
36
  const value = evaluate({
43
37
  code: expression,
44
38
  state,
45
- context,
39
+ context
46
40
  });
47
41
  set(copied, binding, value);
48
42
  }
49
43
  return copied;
50
44
  }
51
- export { getProcessedBlock };
45
+ export {
46
+ getProcessedBlock
47
+ };
@@ -1,43 +1,32 @@
1
1
  import * as React from 'react';
2
- import { expect, test } from '@jest/globals';
3
- import { getProcessedBlock } from './get-processed-block';
4
- test('Can process bindings', () => {
2
+ import { getProcessedBlock } from "./get-processed-block.js";
3
+ test("Can process bindings", () => {
5
4
  var _a, _b, _c, _d, _e, _f;
6
5
  const block = {
7
- '@type': '@builder.io/sdk:Element',
6
+ "@type": "@builder.io/sdk:Element",
8
7
  properties: {
9
- foo: 'bar',
8
+ foo: "bar"
10
9
  },
11
10
  bindings: {
12
- 'properties.foo': '"baz"',
13
- 'responsiveStyles.large.zIndex': '1 + 1',
14
- 'properties.test': 'state.test',
15
- 'properties.block': `
11
+ "properties.foo": '"baz"',
12
+ "responsiveStyles.large.zIndex": "1 + 1",
13
+ "properties.test": "state.test",
14
+ "properties.block": `
16
15
  const foo = 'bar';
17
16
  return foo;
18
17
  `,
19
- 'properties.isEditing': 'builder.isEditing',
20
- },
18
+ "properties.isEditing": "builder.isEditing"
19
+ }
21
20
  };
22
21
  const processed = getProcessedBlock({
23
22
  block,
24
23
  context: {},
25
- state: { test: 'hello' },
24
+ state: { test: "hello" }
26
25
  });
27
26
  expect(processed).not.toEqual(block);
28
- expect((_a = processed.properties) == null ? void 0 : _a.foo).toEqual('baz');
29
- expect((_b = processed.properties) == null ? void 0 : _b.test).toEqual(
30
- 'hello'
31
- );
32
- expect((_c = processed.properties) == null ? void 0 : _c.block).toEqual(
33
- 'bar'
34
- );
35
- expect((_d = processed.properties) == null ? void 0 : _d.isEditing).toEqual(
36
- false
37
- );
38
- expect(
39
- (_f = (_e = processed.responsiveStyles) == null ? void 0 : _e.large) == null
40
- ? void 0
41
- : _f.zIndex
42
- ).toEqual(2);
27
+ expect((_a = processed.properties) == null ? void 0 : _a.foo).toEqual("baz");
28
+ expect((_b = processed.properties) == null ? void 0 : _b.test).toEqual("hello");
29
+ expect((_c = processed.properties) == null ? void 0 : _c.block).toEqual("bar");
30
+ expect((_d = processed.properties) == null ? void 0 : _d.isEditing).toEqual(false);
31
+ expect((_f = (_e = processed.responsiveStyles) == null ? void 0 : _e.large) == null ? void 0 : _f.zIndex).toEqual(2);
43
32
  });
@@ -1,5 +1,16 @@
1
1
  import * as React from 'react';
2
- function ifTarget(target, doThing, elseThing) {
3
- return doThing();
2
+ import { TARGET } from "../constants/target.js";
3
+ function ifTarget({
4
+ targets,
5
+ doThing,
6
+ elseThing
7
+ }) {
8
+ if (TARGET && targets.includes(TARGET)) {
9
+ return doThing();
10
+ } else {
11
+ return elseThing == null ? void 0 : elseThing();
12
+ }
4
13
  }
5
- export { ifTarget };
14
+ export {
15
+ ifTarget
16
+ };
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  function isBrowser() {
3
- return typeof window !== 'undefined' && typeof document !== 'undefined';
3
+ return typeof window !== "undefined" && typeof document !== "undefined";
4
4
  }
5
- export { isBrowser };
5
+ export {
6
+ isBrowser
7
+ };
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
- import { isIframe } from './is-iframe';
2
+ import { isIframe } from "./is-iframe.js";
3
3
  function isEditing() {
4
- return (
5
- isIframe() && window.location.search.indexOf('builder.frameEditing=') !== -1
6
- );
4
+ return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
7
5
  }
8
- export { isEditing };
6
+ export {
7
+ isEditing
8
+ };
@@ -1,6 +1,8 @@
1
1
  import * as React from 'react';
2
- import { isBrowser } from './is-browser';
2
+ import { isBrowser } from "./is-browser.js";
3
3
  function isIframe() {
4
4
  return isBrowser() && window.self !== window.top;
5
5
  }
6
- export { isIframe };
6
+ export {
7
+ isIframe
8
+ };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { isBrowser } from './is-browser';
3
- import { isEditing } from './is-editing';
2
+ import { isBrowser } from "./is-browser.js";
3
+ import { isEditing } from "./is-editing.js";
4
4
  function isPreviewing() {
5
5
  if (!isBrowser()) {
6
6
  return false;
@@ -8,6 +8,8 @@ function isPreviewing() {
8
8
  if (isEditing()) {
9
9
  return false;
10
10
  }
11
- return Boolean(location.search.indexOf('builder.preview=') !== -1);
11
+ return Boolean(location.search.indexOf("builder.preview=") !== -1);
12
12
  }
13
- export { isPreviewing };
13
+ export {
14
+ isPreviewing
15
+ };
@@ -2,4 +2,6 @@ import * as React from 'react';
2
2
  function isReactNative() {
3
3
  return true;
4
4
  }
5
- export { isReactNative };
5
+ export {
6
+ isReactNative
7
+ };
@@ -1,3 +1,6 @@
1
1
  import * as React from 'react';
2
- function macroEval(items, string) {}
3
- export { macroEval };
2
+ function macroEval(items, string) {
3
+ }
4
+ export {
5
+ macroEval
6
+ };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- const onChangeProxySymbol = Symbol('onChangeProxySymbol');
2
+ const onChangeProxySymbol = Symbol("onChangeProxySymbol");
3
3
  function onChange(obj, cb) {
4
4
  return new Proxy(obj, {
5
5
  get(target, key) {
@@ -7,7 +7,7 @@ function onChange(obj, cb) {
7
7
  return true;
8
8
  }
9
9
  const value = Reflect.get(target, key);
10
- if (value && typeof value === 'object') {
10
+ if (value && typeof value === "object") {
11
11
  if (value[onChangeProxySymbol]) {
12
12
  return value;
13
13
  }
@@ -19,7 +19,10 @@ function onChange(obj, cb) {
19
19
  const returnValue = Reflect.set(target, key, value);
20
20
  cb();
21
21
  return returnValue;
22
- },
22
+ }
23
23
  });
24
24
  }
25
- export { onChange, onChangeProxySymbol };
25
+ export {
26
+ onChange,
27
+ onChangeProxySymbol
28
+ };