@builder.io/react 3.0.2-0 → 3.0.3-0

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 (139) hide show
  1. package/dist/builder-react-lite.cjs.js +1 -1
  2. package/dist/builder-react-lite.cjs.js.map +1 -1
  3. package/dist/builder-react-lite.esm.js +1 -1
  4. package/dist/builder-react-lite.esm.js.map +1 -1
  5. package/dist/builder-react.browser.js +2 -2
  6. package/dist/builder-react.browser.js.map +1 -1
  7. package/dist/builder-react.cjs.js +1 -1
  8. package/dist/builder-react.cjs.js.map +1 -1
  9. package/dist/builder-react.es5.js +2 -0
  10. package/dist/builder-react.es5.js.map +1 -0
  11. package/dist/builder-react.unpkg.js +2 -2
  12. package/dist/builder-react.unpkg.js.map +1 -1
  13. package/dist/lib/package.json +4 -4
  14. package/dist/lib/rollup.config.js +29 -23
  15. package/dist/lib/rollup.config.js.map +1 -1
  16. package/dist/lib/src/blocks/Button.js +13 -7
  17. package/dist/lib/src/blocks/Button.js.map +1 -1
  18. package/dist/lib/src/blocks/Columns.js +21 -15
  19. package/dist/lib/src/blocks/Columns.js.map +1 -1
  20. package/dist/lib/src/blocks/CustomCode.js +19 -13
  21. package/dist/lib/src/blocks/CustomCode.js.map +1 -1
  22. package/dist/lib/src/blocks/Embed.js +13 -7
  23. package/dist/lib/src/blocks/Embed.js.map +1 -1
  24. package/dist/lib/src/blocks/Fragment.js +12 -6
  25. package/dist/lib/src/blocks/Fragment.js.map +1 -1
  26. package/dist/lib/src/blocks/Image.js +39 -30
  27. package/dist/lib/src/blocks/Image.js.map +1 -1
  28. package/dist/lib/src/blocks/Mutation.js +17 -10
  29. package/dist/lib/src/blocks/Mutation.js.map +1 -1
  30. package/dist/lib/src/blocks/Router.js +24 -18
  31. package/dist/lib/src/blocks/Router.js.map +1 -1
  32. package/dist/lib/src/blocks/Section.js +15 -9
  33. package/dist/lib/src/blocks/Section.js.map +1 -1
  34. package/dist/lib/src/blocks/Slot.js +14 -10
  35. package/dist/lib/src/blocks/Slot.js.map +1 -1
  36. package/dist/lib/src/blocks/StateProvider.js +14 -8
  37. package/dist/lib/src/blocks/StateProvider.js.map +1 -1
  38. package/dist/lib/src/blocks/Symbol.js +27 -21
  39. package/dist/lib/src/blocks/Symbol.js.map +1 -1
  40. package/dist/lib/src/blocks/Text.js +20 -14
  41. package/dist/lib/src/blocks/Text.js.map +1 -1
  42. package/dist/lib/src/blocks/Video.js +21 -15
  43. package/dist/lib/src/blocks/Video.js.map +1 -1
  44. package/dist/lib/src/blocks/forms/Button.js +11 -5
  45. package/dist/lib/src/blocks/forms/Button.js.map +1 -1
  46. package/dist/lib/src/blocks/forms/Form.js +28 -22
  47. package/dist/lib/src/blocks/forms/Form.js.map +1 -1
  48. package/dist/lib/src/blocks/forms/Input.js +12 -6
  49. package/dist/lib/src/blocks/forms/Input.js.map +1 -1
  50. package/dist/lib/src/blocks/forms/Label.js +14 -8
  51. package/dist/lib/src/blocks/forms/Label.js.map +1 -1
  52. package/dist/lib/src/blocks/forms/Select.js +13 -7
  53. package/dist/lib/src/blocks/forms/Select.js.map +1 -1
  54. package/dist/lib/src/blocks/forms/TextArea.js +11 -5
  55. package/dist/lib/src/blocks/forms/TextArea.js.map +1 -1
  56. package/dist/lib/src/blocks/raw/Img.js +11 -5
  57. package/dist/lib/src/blocks/raw/Img.js.map +1 -1
  58. package/dist/lib/src/blocks/raw/RawText.js +31 -4
  59. package/dist/lib/src/blocks/raw/RawText.js.map +1 -1
  60. package/dist/lib/src/builder-react-lite.js +30 -17
  61. package/dist/lib/src/builder-react-lite.js.map +1 -1
  62. package/dist/lib/src/builder-react.js +98 -44
  63. package/dist/lib/src/builder-react.js.map +1 -1
  64. package/dist/lib/src/components/Link.js +11 -4
  65. package/dist/lib/src/components/Link.js.map +1 -1
  66. package/dist/lib/src/components/builder-block.component.js +52 -46
  67. package/dist/lib/src/components/builder-block.component.js.map +1 -1
  68. package/dist/lib/src/components/builder-blocks.component.js +22 -16
  69. package/dist/lib/src/components/builder-blocks.component.js.map +1 -1
  70. package/dist/lib/src/components/builder-component.component.js +109 -104
  71. package/dist/lib/src/components/builder-component.component.js.map +1 -1
  72. package/dist/lib/src/components/builder-content.component.js +38 -31
  73. package/dist/lib/src/components/builder-content.component.js.map +1 -1
  74. package/dist/lib/src/components/insert-spacer.component.js +17 -11
  75. package/dist/lib/src/components/insert-spacer.component.js.map +1 -1
  76. package/dist/lib/src/components/no-wrap.js +5 -1
  77. package/dist/lib/src/components/no-wrap.js.map +1 -1
  78. package/dist/lib/src/components/variants-provider.component.js +36 -9
  79. package/dist/lib/src/components/variants-provider.component.js.map +1 -1
  80. package/dist/lib/src/constants/device-sizes.constant.js +9 -5
  81. package/dist/lib/src/constants/device-sizes.constant.js.map +1 -1
  82. package/dist/lib/src/decorators/builder-block.decorator.js +7 -3
  83. package/dist/lib/src/decorators/builder-block.decorator.js.map +1 -1
  84. package/dist/lib/src/functions/apply-patch-with-mutation.js +5 -1
  85. package/dist/lib/src/functions/apply-patch-with-mutation.js.map +1 -1
  86. package/dist/lib/src/functions/apply-patch-with-mutation.test.js +6 -4
  87. package/dist/lib/src/functions/apply-patch-with-mutation.test.js.map +1 -1
  88. package/dist/lib/src/functions/block-to-html-string.js +10 -5
  89. package/dist/lib/src/functions/block-to-html-string.js.map +1 -1
  90. package/dist/lib/src/functions/debonce-next-tick.js +7 -3
  91. package/dist/lib/src/functions/debonce-next-tick.js.map +1 -1
  92. package/dist/lib/src/functions/get-builder-pixel.js +5 -1
  93. package/dist/lib/src/functions/get-builder-pixel.js.map +1 -1
  94. package/dist/lib/src/functions/get.js +5 -1
  95. package/dist/lib/src/functions/get.js.map +1 -1
  96. package/dist/lib/src/functions/no-wrap.js +11 -4
  97. package/dist/lib/src/functions/no-wrap.js.map +1 -1
  98. package/dist/lib/src/functions/safe-dynamic-require.js +8 -8
  99. package/dist/lib/src/functions/safe-dynamic-require.js.map +1 -1
  100. package/dist/lib/src/functions/set.js +5 -1
  101. package/dist/lib/src/functions/set.js.map +1 -1
  102. package/dist/lib/src/functions/string-to-function.js +17 -13
  103. package/dist/lib/src/functions/string-to-function.js.map +1 -1
  104. package/dist/lib/src/functions/throttle.js +5 -1
  105. package/dist/lib/src/functions/throttle.js.map +1 -1
  106. package/dist/lib/src/functions/try-eval.js +13 -10
  107. package/dist/lib/src/functions/try-eval.js.map +1 -1
  108. package/dist/lib/src/functions/update-metadata.js +9 -5
  109. package/dist/lib/src/functions/update-metadata.js.map +1 -1
  110. package/dist/lib/src/functions/utils.js +5 -1
  111. package/dist/lib/src/functions/utils.js.map +1 -1
  112. package/dist/lib/src/functions/with-builder.js +7 -3
  113. package/dist/lib/src/functions/with-builder.js.map +1 -1
  114. package/dist/lib/src/functions/with-children.js +13 -6
  115. package/dist/lib/src/functions/with-children.js.map +1 -1
  116. package/dist/lib/src/hooks/useIsPreviewing.js +10 -6
  117. package/dist/lib/src/hooks/useIsPreviewing.js.map +1 -1
  118. package/dist/lib/src/scripts/init-editing.js +4 -2
  119. package/dist/lib/src/scripts/init-editing.js.map +1 -1
  120. package/dist/lib/src/store/builder-async-requests.js +12 -4
  121. package/dist/lib/src/store/builder-async-requests.js.map +1 -1
  122. package/dist/lib/src/store/builder-meta.js +8 -2
  123. package/dist/lib/src/store/builder-meta.js.map +1 -1
  124. package/dist/lib/src/store/builder-store.js +8 -2
  125. package/dist/lib/src/store/builder-store.js.map +1 -1
  126. package/dist/lib/src/to-error.js +5 -1
  127. package/dist/lib/src/to-error.js.map +1 -1
  128. package/dist/lib/test/basic.test.js +74 -49
  129. package/dist/lib/test/basic.test.js.map +1 -1
  130. package/dist/lib/test/functions/render-block.js +8 -3
  131. package/dist/lib/test/functions/render-block.js.map +1 -1
  132. package/dist/lib/test/image.test.js +39 -14
  133. package/dist/lib/test/image.test.js.map +1 -1
  134. package/dist/types/src/components/builder-content.component.d.ts +67 -1
  135. package/package.json +6 -6
  136. package/rollup.config.ts +1 -0
  137. package/src/components/builder-component.component.tsx +2 -2
  138. package/src/functions/string-to-function.ts +2 -2
  139. package/src/functions/try-eval.tsx +1 -1
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  'use client';
2
3
  var __extends = (this && this.__extends) || (function () {
3
4
  var extendStatics = function (d, b) {
@@ -79,24 +80,29 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
79
80
  }
80
81
  return to.concat(ar || Array.prototype.slice.call(from));
81
82
  };
82
- import React from 'react';
83
- import ReactDOM from 'react-dom';
84
- import { jsx, css } from '@emotion/core';
85
- import { BuilderContent, getContentWithInfo } from './builder-content.component';
86
- import { BuilderBlocks } from './builder-blocks.component';
87
- import { Builder, builder, Subscription, BehaviorSubject, } from '@builder.io/sdk';
88
- import { BuilderStoreContext } from '../store/builder-store';
89
- import hash from 'hash-sum';
90
- import onChange from '../../lib/on-change';
91
- export { onChange };
92
- import { getSizesForBreakpoints } from '../constants/device-sizes.constant';
93
- import { BuilderAsyncRequestsContext, isRequestInfo, } from '../store/builder-async-requests';
94
- import { debounceNextTick } from '../functions/debonce-next-tick';
95
- import { throttle } from '../functions/throttle';
96
- import { BuilderMetaContext } from '../store/builder-meta';
97
- import { tryEval } from '../functions/try-eval';
98
- import { toError } from '../to-error';
99
- import { getBuilderPixel } from '../functions/get-builder-pixel';
83
+ var __importDefault = (this && this.__importDefault) || function (mod) {
84
+ return (mod && mod.__esModule) ? mod : { "default": mod };
85
+ };
86
+ Object.defineProperty(exports, "__esModule", { value: true });
87
+ exports.BuilderComponent = exports.onChange = void 0;
88
+ var react_1 = __importDefault(require("react"));
89
+ var react_dom_1 = __importDefault(require("react-dom"));
90
+ var core_1 = require("@emotion/core");
91
+ var builder_content_component_1 = require("./builder-content.component");
92
+ var builder_blocks_component_1 = require("./builder-blocks.component");
93
+ var sdk_1 = require("@builder.io/sdk");
94
+ var builder_store_1 = require("../store/builder-store");
95
+ var hash_sum_1 = __importDefault(require("hash-sum"));
96
+ var on_change_1 = __importDefault(require("../../lib/on-change"));
97
+ exports.onChange = on_change_1.default;
98
+ var device_sizes_constant_1 = require("../constants/device-sizes.constant");
99
+ var builder_async_requests_1 = require("../store/builder-async-requests");
100
+ var debonce_next_tick_1 = require("../functions/debonce-next-tick");
101
+ var throttle_1 = require("../functions/throttle");
102
+ var builder_meta_1 = require("../store/builder-meta");
103
+ var try_eval_1 = require("../functions/try-eval");
104
+ var to_error_1 = require("../to-error");
105
+ var get_builder_pixel_1 = require("../functions/get-builder-pixel");
100
106
  function pick(obj) {
101
107
  var keys = [];
102
108
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -128,10 +134,10 @@ var wrapComponent = function (info) {
128
134
  var baseProps = omit.apply(void 0, __spreadArray(__spreadArray([props], inputNames, false), ['attributes'], false));
129
135
  var inputProps = props; // pick(props, ...inputNames);
130
136
  if (info.noWrap) {
131
- return React.createElement(info.class, __assign({ attributes: baseProps }, inputProps));
137
+ return react_1.default.createElement(info.class, __assign({ attributes: baseProps }, inputProps));
132
138
  }
133
- return (React.createElement(Tag, __assign({}, baseProps),
134
- React.createElement(info.class, __assign({}, inputProps))));
139
+ return (react_1.default.createElement(Tag, __assign({}, baseProps),
140
+ react_1.default.createElement(info.class, __assign({}, inputProps))));
135
141
  };
136
142
  };
137
143
  var size = function (thing) { return Object.keys(thing).length; };
@@ -192,13 +198,13 @@ var BuilderComponent = /** @class */ (function (_super) {
192
198
  var _this = this;
193
199
  var _a;
194
200
  _this = _super.call(this, props) || this;
195
- _this.subscriptions = new Subscription();
201
+ _this.subscriptions = new sdk_1.Subscription();
196
202
  // TODO: don't trigger initial one?
197
- _this.onStateChange = new BehaviorSubject(null);
198
- _this.asServer = Builder.isServer;
203
+ _this.onStateChange = new sdk_1.BehaviorSubject(null);
204
+ _this.asServer = sdk_1.Builder.isServer;
199
205
  _this.contentRef = null;
200
206
  _this.styleRef = null;
201
- _this.rootState = Builder.isServer ? {} : onChange({}, function () { return _this.updateState(); });
207
+ _this.rootState = sdk_1.Builder.isServer ? {} : (0, on_change_1.default)({}, function () { return _this.updateState(); });
202
208
  _this.lastJsCode = '';
203
209
  _this.lastHttpRequests = {};
204
210
  _this.httpSubscriptionPerKey = {};
@@ -213,7 +219,7 @@ var BuilderComponent = /** @class */ (function (_super) {
213
219
  if (!data.contentId || data.contentId !== ((_a = _this.useContent) === null || _a === void 0 ? void 0 : _a.id)) {
214
220
  return;
215
221
  }
216
- _this.sizes = getSizesForBreakpoints(data.breakpoints || {});
222
+ _this.sizes = (0, device_sizes_constant_1.getSizesForBreakpoints)(data.breakpoints || {});
217
223
  _this.setState({
218
224
  state: Object.assign(_this.rootState, {
219
225
  deviceSize: _this.deviceSizeState,
@@ -266,7 +272,7 @@ var BuilderComponent = /** @class */ (function (_super) {
266
272
  _this.setState(__assign(__assign({}, _this.state), { updates: ((_this.state && _this.state.updates) || 0) + 1, state: Object.assign(_this.rootState, __assign(__assign({}, _this.state.state), { deviceSize: deviceSize })) }));
267
273
  }
268
274
  };
269
- _this.resizeListener = Builder.isEditing ? throttle(_this.resizeFn, 200) : debounce(_this.resizeFn, 400);
275
+ _this.resizeListener = sdk_1.Builder.isEditing ? (0, throttle_1.throttle)(_this.resizeFn, 200) : debounce(_this.resizeFn, 400);
270
276
  _this.mounted = false;
271
277
  _this.updateState = function (fn) {
272
278
  var state = _this.rootState;
@@ -286,8 +292,7 @@ var BuilderComponent = /** @class */ (function (_super) {
286
292
  _this.notifyStateChange();
287
293
  };
288
294
  _this.onContentLoaded = function (data, content) {
289
- var _a;
290
- if (_this.name === 'page' && Builder.isBrowser) {
295
+ if (_this.name === 'page' && sdk_1.Builder.isBrowser) {
291
296
  if (data) {
292
297
  var title = data.title, pageTitle = data.pageTitle, description = data.description, pageDescription = data.pageDescription;
293
298
  if (title || pageTitle) {
@@ -304,7 +309,7 @@ var BuilderComponent = /** @class */ (function (_super) {
304
309
  }
305
310
  }
306
311
  }
307
- if (Builder.isEditing) {
312
+ if (sdk_1.Builder.isEditing) {
308
313
  _this.notifyStateChange();
309
314
  }
310
315
  if (_this.props.contentLoaded) {
@@ -334,10 +339,10 @@ var BuilderComponent = /** @class */ (function (_super) {
334
339
  }
335
340
  }
336
341
  // TODO: also throttle on edits maybe
337
- if (data && data.jsCode && Builder.isBrowser && !_this.options.codegen) {
342
+ if (data && data.jsCode && sdk_1.Builder.isBrowser && !_this.options.codegen) {
338
343
  // Don't rerun js code when editing and not changed
339
344
  var skip = false;
340
- if (Builder.isEditing) {
345
+ if (sdk_1.Builder.isEditing) {
341
346
  if (_this.lastJsCode === data.jsCode) {
342
347
  skip = true;
343
348
  }
@@ -349,17 +354,17 @@ var BuilderComponent = /** @class */ (function (_super) {
349
354
  var state = _this.state.state;
350
355
  // TODO: real editing method
351
356
  try {
352
- var result = new Function('data', 'ref', 'state', 'update', 'element', 'Builder', 'builder', 'context', data.jsCode)(data, _this, state, _this.state.update, _this.ref, Builder, builder, _this.state.context);
357
+ var result = new Function('data', 'ref', 'state', 'update', 'element', 'Builder', 'builder', 'context', data.jsCode)(data, _this, state, _this.state.update, _this.ref, sdk_1.Builder, sdk_1.builder, _this.state.context);
353
358
  // TODO: allow exports = { } syntax?
354
359
  // TODO: do something with reuslt like view - methods, computed, actions, properties, template, etc etc
355
360
  }
356
361
  catch (err) {
357
- var error = toError(err);
358
- if (Builder.isBrowser) {
362
+ var error = (0, to_error_1.toError)(err);
363
+ if (sdk_1.Builder.isBrowser) {
359
364
  console.warn('Builder custom code error:', error.message, 'in', data.jsCode, error.stack);
360
365
  }
361
366
  else {
362
- if ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.DEBUG) {
367
+ if (process && process.env && process.env.DEBUG) {
363
368
  console.debug('Builder custom code error:', error.message, 'in', data.jsCode, error.stack);
364
369
  }
365
370
  // Add to req.options.errors to return to client
@@ -374,10 +379,10 @@ var BuilderComponent = /** @class */ (function (_super) {
374
379
  if (!skip) {
375
380
  var _loop_1 = function (key) {
376
381
  var url = data.httpRequests[key];
377
- if (url && (!_this.data[key] || Builder.isEditing)) {
378
- if (Builder.isBrowser) {
382
+ if (url && (!_this.data[key] || sdk_1.Builder.isEditing)) {
383
+ if (sdk_1.Builder.isBrowser) {
379
384
  var finalUrl_1 = _this.evalExpression(url);
380
- if (Builder.isEditing && _this.lastHttpRequests[key] === finalUrl_1) {
385
+ if (sdk_1.Builder.isEditing && _this.lastHttpRequests[key] === finalUrl_1) {
381
386
  return "continue";
382
387
  }
383
388
  _this.lastHttpRequests[key] = finalUrl_1;
@@ -416,20 +421,20 @@ var BuilderComponent = /** @class */ (function (_super) {
416
421
  if (_content && _content.content) {
417
422
  _content = _content.content;
418
423
  }
419
- _this.sizes = getSizesForBreakpoints(((_a = _content === null || _content === void 0 ? void 0 : _content.meta) === null || _a === void 0 ? void 0 : _a.breakpoints) || {});
424
+ _this.sizes = (0, device_sizes_constant_1.getSizesForBreakpoints)(((_a = _content === null || _content === void 0 ? void 0 : _content.meta) === null || _a === void 0 ? void 0 : _a.breakpoints) || {});
420
425
  // TODO: pass this all the way down - symbols, etc
421
426
  // this.asServer = Boolean(props.hydrate && Builder.isBrowser)
422
427
  _this.state = {
423
428
  // TODO: should change if this prop changes
424
- context: __assign(__assign({}, props.context), { apiKey: builder.apiKey || _this.props.apiKey }),
425
- state: Object.assign(_this.rootState, __assign(__assign(__assign(__assign({}, (_this.inlinedContent && _this.inlinedContent.data && _this.inlinedContent.data.state)), { isBrowser: Builder.isBrowser, isServer: !Builder.isBrowser, _hydrate: props.hydrate, location: _this.locationState, deviceSize: _this.deviceSizeState,
429
+ context: __assign(__assign({}, props.context), { apiKey: sdk_1.builder.apiKey || _this.props.apiKey }),
430
+ state: Object.assign(_this.rootState, __assign(__assign(__assign(__assign({}, (_this.inlinedContent && _this.inlinedContent.data && _this.inlinedContent.data.state)), { isBrowser: sdk_1.Builder.isBrowser, isServer: !sdk_1.Builder.isBrowser, _hydrate: props.hydrate, location: _this.locationState, deviceSize: _this.deviceSizeState,
426
431
  // TODO: will user attributes be ready here?
427
432
  device: _this.device }), _this.getHtmlData()), props.data)),
428
433
  updates: 0,
429
434
  key: 0,
430
435
  update: _this.updateState,
431
436
  };
432
- if (Builder.isBrowser) {
437
+ if (sdk_1.Builder.isBrowser) {
433
438
  var key = _this.props.apiKey;
434
439
  if (key && key !== _this.builder.apiKey) {
435
440
  _this.builder.apiKey = key;
@@ -437,7 +442,7 @@ var BuilderComponent = /** @class */ (function (_super) {
437
442
  if (_this.inlinedContent) {
438
443
  // Sometimes with graphql we get the content as `content.content`
439
444
  var content = _this.inlinedContent.content || _this.inlinedContent;
440
- _this.onContentLoaded(content === null || content === void 0 ? void 0 : content.data, getContentWithInfo(content));
445
+ _this.onContentLoaded(content === null || content === void 0 ? void 0 : content.data, (0, builder_content_component_1.getContentWithInfo)(content));
441
446
  }
442
447
  }
443
448
  return _this;
@@ -476,7 +481,7 @@ var BuilderComponent = /** @class */ (function (_super) {
476
481
  });
477
482
  Object.defineProperty(BuilderComponent.prototype, "builder", {
478
483
  get: function () {
479
- return this.props.builder || builder;
484
+ return this.props.builder || sdk_1.builder;
480
485
  },
481
486
  enumerable: false,
482
487
  configurable: true
@@ -484,7 +489,7 @@ var BuilderComponent = /** @class */ (function (_super) {
484
489
  BuilderComponent.prototype.getHtmlData = function () {
485
490
  var id = (this.inlinedContent && this.inlinedContent.id) || this.props.entry;
486
491
  var script = id &&
487
- Builder.isBrowser &&
492
+ sdk_1.Builder.isBrowser &&
488
493
  document.querySelector("script[data-builder-json=\"".concat(id, "\"],script[data-builder-state=\"").concat(id, "\"]"));
489
494
  if (script) {
490
495
  try {
@@ -516,7 +521,7 @@ var BuilderComponent = /** @class */ (function (_super) {
516
521
  // TODO: trigger state change on screen size change
517
522
  get: function () {
518
523
  // TODO: use context to pass this down on server
519
- return Builder.isBrowser
524
+ return sdk_1.Builder.isBrowser
520
525
  ? this.sizes.getSizeForWidth(window.innerWidth)
521
526
  : sizeMap[this.device] || 'large';
522
527
  },
@@ -571,13 +576,13 @@ var BuilderComponent = /** @class */ (function (_super) {
571
576
  if (el) {
572
577
  el.innerHTML = content;
573
578
  }
574
- else if (!Builder.isEditing) {
579
+ else if (!sdk_1.Builder.isEditing) {
575
580
  keepStyles_1 += match;
576
581
  }
577
582
  return match;
578
583
  });
579
584
  // NextTick? or longer timeout?
580
- Builder.nextTick(function () {
585
+ sdk_1.Builder.nextTick(function () {
581
586
  apiStyles_1.innerHTML = keepStyles_1;
582
587
  });
583
588
  }
@@ -599,16 +604,16 @@ var BuilderComponent = /** @class */ (function (_super) {
599
604
  div.appendChild(element);
600
605
  useEl = div;
601
606
  }
602
- if (Builder.isEditing || (Builder.isBrowser && location.search.includes('builder.preview='))) {
607
+ if (sdk_1.Builder.isEditing || (sdk_1.Builder.isBrowser && location.search.includes('builder.preview='))) {
603
608
  shouldHydrate = false;
604
609
  }
605
610
  if (shouldHydrate && element) {
606
611
  // TODO: maybe hydrate again. Maybe...
607
- var val_1 = ReactDOM.render(React.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
612
+ var val_1 = react_dom_1.default.render(react_1.default.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
608
613
  useEl.builderRootRef = val_1;
609
614
  return val_1;
610
615
  }
611
- var val = ReactDOM.render(React.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
616
+ var val = react_dom_1.default.render(react_1.default.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
612
617
  useEl.builderRootRef = val;
613
618
  return val;
614
619
  };
@@ -623,17 +628,17 @@ var BuilderComponent = /** @class */ (function (_super) {
623
628
  state.isServer = false;
624
629
  });
625
630
  }
626
- if (Builder.isIframe) {
631
+ if (sdk_1.Builder.isIframe) {
627
632
  (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'builder.sdkInjected', data: { modelName: this.name } }, '*');
628
633
  }
629
- if (Builder.isBrowser) {
634
+ if (sdk_1.Builder.isBrowser) {
630
635
  // TODO: remove event on unload
631
636
  window.addEventListener('resize', this.resizeListener);
632
- if (Builder.isEditing) {
637
+ if (sdk_1.Builder.isEditing) {
633
638
  window.addEventListener('message', this.messageListener);
634
639
  }
635
- if (Builder.isEditing || Builder.isPreviewing) {
636
- Builder.nextTick(function () {
640
+ if (sdk_1.Builder.isEditing || sdk_1.Builder.isPreviewing) {
641
+ sdk_1.Builder.nextTick(function () {
637
642
  _this.firstLoad = false;
638
643
  _this.reload();
639
644
  });
@@ -649,14 +654,14 @@ var BuilderComponent = /** @class */ (function (_super) {
649
654
  };
650
655
  Object.defineProperty(BuilderComponent.prototype, "isPreviewing", {
651
656
  get: function () {
652
- return ((Builder.isServer || (Builder.isBrowser && Builder.isPreviewing && !this.firstLoad)) &&
653
- builder.previewingModel === this.name);
657
+ return ((sdk_1.Builder.isServer || (sdk_1.Builder.isBrowser && sdk_1.Builder.isPreviewing && !this.firstLoad)) &&
658
+ sdk_1.builder.previewingModel === this.name);
654
659
  },
655
660
  enumerable: false,
656
661
  configurable: true
657
662
  });
658
663
  BuilderComponent.prototype.notifyStateChange = function () {
659
- if (Builder.isServer) {
664
+ if (sdk_1.Builder.isServer) {
660
665
  return;
661
666
  }
662
667
  if (!(this && this.state)) {
@@ -667,7 +672,7 @@ var BuilderComponent = /** @class */ (function (_super) {
667
672
  if (this.props.onStateChange) {
668
673
  this.props.onStateChange(nextState);
669
674
  }
670
- if (Builder.isBrowser) {
675
+ if (sdk_1.Builder.isBrowser) {
671
676
  window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
672
677
  detail: {
673
678
  state: nextState,
@@ -682,7 +687,7 @@ var BuilderComponent = /** @class */ (function (_super) {
682
687
  };
683
688
  Object.defineProperty(BuilderComponent.prototype, "location", {
684
689
  get: function () {
685
- return this.props.location || (Builder.isBrowser ? location : {});
690
+ return this.props.location || (sdk_1.Builder.isBrowser ? location : {});
686
691
  },
687
692
  enumerable: false,
688
693
  configurable: true
@@ -713,7 +718,7 @@ var BuilderComponent = /** @class */ (function (_super) {
713
718
  };
714
719
  BuilderComponent.prototype.componentWillUnmount = function () {
715
720
  this.unsubscribe();
716
- if (Builder.isBrowser) {
721
+ if (sdk_1.Builder.isBrowser) {
717
722
  window.removeEventListener('resize', this.resizeListener);
718
723
  window.removeEventListener('message', this.messageListener);
719
724
  }
@@ -779,7 +784,7 @@ var BuilderComponent = /** @class */ (function (_super) {
779
784
  Object.assign(state, _this.externalState);
780
785
  });
781
786
  }
782
- if (Builder.isEditing) {
787
+ if (sdk_1.Builder.isEditing) {
783
788
  if (this.inlinedContent && prevProps.content !== this.inlinedContent) {
784
789
  this.onContentLoaded(this.inlinedContent.data, this.inlinedContent);
785
790
  }
@@ -830,36 +835,36 @@ var BuilderComponent = /** @class */ (function (_super) {
830
835
  var _this = this;
831
836
  var _a;
832
837
  var content = this.content;
833
- var dataString = Builder.isBrowser &&
838
+ var dataString = sdk_1.Builder.isBrowser &&
834
839
  this.externalState &&
835
840
  size(this.externalState) &&
836
- hash(this.externalState);
837
- var key = Builder.isEditing ? this.name : this.props.entry;
838
- if (key && !Builder.isEditing && dataString && dataString.length < 300) {
841
+ (0, hash_sum_1.default)(this.externalState);
842
+ var key = sdk_1.Builder.isEditing ? this.name : this.props.entry;
843
+ if (key && !sdk_1.Builder.isEditing && dataString && dataString.length < 300) {
839
844
  key += ':' + dataString;
840
845
  }
841
- var WrapComponent = this.props.dataOnly ? React.Fragment : 'div';
846
+ var WrapComponent = this.props.dataOnly ? react_1.default.Fragment : 'div';
842
847
  var contentId = (_a = this.useContent) === null || _a === void 0 ? void 0 : _a.id;
843
848
  return (
844
849
  // TODO: data attributes for model, id, etc?
845
- React.createElement(WrapComponent, { onClick: function (event) {
850
+ react_1.default.createElement(WrapComponent, { onClick: function (event) {
846
851
  // Prevent propagation from the root content component when editing to prevent issues
847
852
  // like client side routing triggering when links are clicked, unless this behavior is
848
853
  // disabled with the stopClickPropagationWhenEditing prop
849
- if (Builder.isEditing &&
854
+ if (sdk_1.Builder.isEditing &&
850
855
  !_this.props.isChild &&
851
856
  !_this.props.stopClickPropagationWhenEditing) {
852
857
  event.stopPropagation();
853
858
  }
854
859
  }, className: "builder-component ".concat(contentId ? "builder-component-".concat(contentId) : ''), "data-name": this.name, "data-source": "Rendered by Builder.io", key: this.state.key, ref: function (ref) { return (_this.ref = ref); } },
855
- React.createElement(BuilderMetaContext.Consumer, null, function (value) { return (React.createElement(BuilderMetaContext.Provider, { value: typeof _this.props.ampMode === 'boolean'
860
+ react_1.default.createElement(builder_meta_1.BuilderMetaContext.Consumer, null, function (value) { return (react_1.default.createElement(builder_meta_1.BuilderMetaContext.Provider, { value: typeof _this.props.ampMode === 'boolean'
856
861
  ? __assign(__assign({}, value), { ampMode: _this.props.ampMode }) : value },
857
- React.createElement(BuilderAsyncRequestsContext.Consumer, null, function (value) {
862
+ react_1.default.createElement(builder_async_requests_1.BuilderAsyncRequestsContext.Consumer, null, function (value) {
858
863
  var _a;
859
864
  _this._asyncRequests = value && value.requests;
860
865
  _this._errors = value && value.errors;
861
866
  _this._logs = value && value.logs;
862
- return (React.createElement(BuilderContent, { isStatic: _this.props.isStatic || Builder.isStatic, key: ((_a = _this.inlinedContent) === null || _a === void 0 ? void 0 : _a.id) ||
867
+ return (react_1.default.createElement(builder_content_component_1.BuilderContent, { isStatic: _this.props.isStatic || sdk_1.Builder.isStatic, key: ((_a = _this.inlinedContent) === null || _a === void 0 ? void 0 : _a.id) ||
863
868
  ('content' in _this.props && !_this.isPreviewing
864
869
  ? 'null-content-prop'
865
870
  : 'no-content-prop'), builder: _this.builder, ref: function (ref) { return (_this.contentRef = ref); },
@@ -880,22 +885,22 @@ var BuilderComponent = /** @class */ (function (_super) {
880
885
  }
881
886
  _this.state.context.builderContent = fullData;
882
887
  }
883
- if (Builder.isBrowser) {
884
- Builder.nextTick(function () {
888
+ if (sdk_1.Builder.isBrowser) {
889
+ sdk_1.Builder.nextTick(function () {
885
890
  _this.checkStyles(data);
886
891
  });
887
892
  }
888
893
  var codegen = _this.options.codegen;
889
894
  if (codegen && !_this.Component && (data === null || data === void 0 ? void 0 : data.blocksJs)) {
890
- var builderComponentNames = Array.from(new Set(Builder.components.map(function (item) { return item.name; })));
891
- var reversedcomponents_1 = Builder.components.slice().reverse();
895
+ var builderComponentNames = Array.from(new Set(sdk_1.Builder.components.map(function (item) { return item.name; })));
896
+ var reversedcomponents_1 = sdk_1.Builder.components.slice().reverse();
892
897
  var builderComponents = builderComponentNames.map(function (name) {
893
898
  return reversedcomponents_1.find(function (item) { return item.class && item.name === name; });
894
899
  });
895
900
  var useBuilderState = function (initialState) {
896
- var _a = React.useState(0), setTick = _a[1];
897
- var state = React.useState(function () {
898
- return onChange(initialState, function () {
901
+ var _a = react_1.default.useState(0), setTick = _a[1];
902
+ var state = react_1.default.useState(function () {
903
+ return (0, on_change_1.default)(initialState, function () {
899
904
  setTick(function (tick) { return tick + 1; });
900
905
  });
901
906
  })[0];
@@ -912,29 +917,29 @@ var BuilderComponent = /** @class */ (function (_super) {
912
917
  'Builder',
913
918
  'builder',
914
919
  'React',
915
- 'useBuilderState'], mappedComponentNames, false), [data.blocksJs], false)))().apply(void 0, __spreadArray([jsx,
916
- css,
917
- Builder,
918
- builder,
919
- React,
920
+ 'useBuilderState'], mappedComponentNames, false), [data.blocksJs], false)))().apply(void 0, __spreadArray([core_1.jsx,
921
+ core_1.css,
922
+ sdk_1.Builder,
923
+ sdk_1.builder,
924
+ react_1.default,
920
925
  useBuilderState], finalizedComponents, false));
921
926
  }
922
927
  var blocks = (data === null || data === void 0 ? void 0 : data.blocks) || [];
923
928
  var hasPixel = blocks.find(function (block) { var _a; return (_a = block.id) === null || _a === void 0 ? void 0 : _a.startsWith('builder-pixel'); });
924
929
  if (data && !hasPixel && blocks.length > 0) {
925
- blocks.push(getBuilderPixel(builder.apiKey));
930
+ blocks.push((0, get_builder_pixel_1.getBuilderPixel)(sdk_1.builder.apiKey));
926
931
  }
927
932
  // TODO: loading option - maybe that is what the children is or component prop
928
933
  // TODO: get rid of all these wrapper divs
929
- return data ? (React.createElement("div", __assign({ "data-builder-component": _this.name, "data-builder-content-id": fullData.id }, (_this.isPreviewing
934
+ return data ? (react_1.default.createElement("div", __assign({ "data-builder-component": _this.name, "data-builder-content-id": fullData.id }, (_this.isPreviewing
930
935
  ? {
931
936
  'data-builder-variation-id': fullData.testVariationId || fullData.variationId || fullData.id,
932
937
  }
933
938
  : {})),
934
- !codegen && _this.getCss(data) && (React.createElement("style", { ref: function (ref) { return (_this.styleRef = ref); }, className: "builder-custom-styles", dangerouslySetInnerHTML: {
939
+ !codegen && _this.getCss(data) && (react_1.default.createElement("style", { ref: function (ref) { return (_this.styleRef = ref); }, className: "builder-custom-styles", dangerouslySetInnerHTML: {
935
940
  __html: _this.getCss(data),
936
941
  } })),
937
- React.createElement(BuilderStoreContext.Provider, { value: __assign(__assign({}, _this.state), { rootState: _this.rootState, state: _this.data, content: fullData, renderLink: _this.props.renderLink }) }, codegen && _this.Component ? (React.createElement(_this.Component, { data: _this.data, context: _this.state.context })) : (React.createElement(BuilderBlocks, { key: String(!!((_a = data === null || data === void 0 ? void 0 : data.blocks) === null || _a === void 0 ? void 0 : _a.length)), emailMode: _this.props.emailMode, fieldName: "blocks", blocks: blocks }))))) : loading ? (React.createElement("div", { "data-builder-component": _this.name, className: "builder-loading" }, _this.props.children)) : (React.createElement("div", { "data-builder-component": _this.name, className: "builder-no-content" }));
942
+ react_1.default.createElement(builder_store_1.BuilderStoreContext.Provider, { value: __assign(__assign({}, _this.state), { rootState: _this.rootState, state: _this.data, content: fullData, renderLink: _this.props.renderLink }) }, codegen && _this.Component ? (react_1.default.createElement(_this.Component, { data: _this.data, context: _this.state.context })) : (react_1.default.createElement(builder_blocks_component_1.BuilderBlocks, { key: String(!!((_a = data === null || data === void 0 ? void 0 : data.blocks) === null || _a === void 0 ? void 0 : _a.length)), emailMode: _this.props.emailMode, fieldName: "blocks", blocks: blocks }))))) : loading ? (react_1.default.createElement("div", { "data-builder-component": _this.name, className: "builder-loading" }, _this.props.children)) : (react_1.default.createElement("div", { "data-builder-component": _this.name, className: "builder-no-content" }));
938
943
  }));
939
944
  }))); })));
940
945
  };
@@ -942,7 +947,7 @@ var BuilderComponent = /** @class */ (function (_super) {
942
947
  var _this = this;
943
948
  var data = this.data;
944
949
  return String(expression).replace(/{{([^}]+)}}/g, function (match, group) {
945
- return tryEval(group, data, _this._errors);
950
+ return (0, try_eval_1.tryEval)(group, data, _this._errors);
946
951
  });
947
952
  };
948
953
  BuilderComponent.prototype.handleRequest = function (propertyName, url) {
@@ -951,7 +956,7 @@ var BuilderComponent = /** @class */ (function (_super) {
951
956
  var _this = this;
952
957
  return __generator(this, function (_a) {
953
958
  // TODO: Builder.isEditing = just checks if iframe and parent page is this.builder.io or localhost:1234
954
- if (Builder.isIframe && fetchCache[url]) {
959
+ if (sdk_1.Builder.isIframe && fetchCache[url]) {
955
960
  this.updateState(function (ctx) {
956
961
  ctx[propertyName] = fetchCache[url];
957
962
  });
@@ -963,7 +968,7 @@ var BuilderComponent = /** @class */ (function (_super) {
963
968
  switch (_a.label) {
964
969
  case 0:
965
970
  requestStart = Date.now();
966
- if (!Builder.isBrowser) {
971
+ if (!sdk_1.Builder.isBrowser) {
967
972
  console.time('Fetch ' + url);
968
973
  }
969
974
  _a.label = 1;
@@ -978,7 +983,7 @@ var BuilderComponent = /** @class */ (function (_super) {
978
983
  return [3 /*break*/, 6];
979
984
  case 4:
980
985
  err_1 = _a.sent();
981
- error = toError(err_1);
986
+ error = (0, to_error_1.toError)(err_1);
982
987
  if (this._errors) {
983
988
  this._errors.push(error);
984
989
  }
@@ -987,7 +992,7 @@ var BuilderComponent = /** @class */ (function (_super) {
987
992
  }
988
993
  return [2 /*return*/];
989
994
  case 5:
990
- if (!Builder.isBrowser) {
995
+ if (!sdk_1.Builder.isBrowser) {
991
996
  console.timeEnd('Fetch ' + url);
992
997
  if (this._logs) {
993
998
  this._logs.push("Fetched ".concat(url, " in ").concat(Date.now() - requestStart, "ms"));
@@ -996,7 +1001,7 @@ var BuilderComponent = /** @class */ (function (_super) {
996
1001
  return [7 /*endfinally*/];
997
1002
  case 6:
998
1003
  if (json) {
999
- if (Builder.isIframe) {
1004
+ if (sdk_1.Builder.isIframe) {
1000
1005
  fetchCache[url] = json;
1001
1006
  }
1002
1007
  // TODO: debounce next tick all of these when there are a bunch
@@ -1009,7 +1014,7 @@ var BuilderComponent = /** @class */ (function (_super) {
1009
1014
  });
1010
1015
  }); };
1011
1016
  existing = this._asyncRequests &&
1012
- this._asyncRequests.find(function (req) { return isRequestInfo(req) && req.url === url; });
1017
+ this._asyncRequests.find(function (req) { return (0, builder_async_requests_1.isRequestInfo)(req) && req.url === url; });
1013
1018
  if (existing) {
1014
1019
  promise_1 = existing.promise;
1015
1020
  promise_1.then(function (json) {
@@ -1022,7 +1027,7 @@ var BuilderComponent = /** @class */ (function (_super) {
1022
1027
  return [2 /*return*/, promise_1];
1023
1028
  }
1024
1029
  promise = request();
1025
- Builder.nextTick(function () {
1030
+ sdk_1.Builder.nextTick(function () {
1026
1031
  if (_this._asyncRequests) {
1027
1032
  _this._asyncRequests.push(promise);
1028
1033
  }
@@ -1034,12 +1039,12 @@ var BuilderComponent = /** @class */ (function (_super) {
1034
1039
  BuilderComponent.prototype.unsubscribe = function () {
1035
1040
  if (this.subscriptions) {
1036
1041
  this.subscriptions.unsubscribe();
1037
- this.subscriptions = new Subscription();
1042
+ this.subscriptions = new sdk_1.Subscription();
1038
1043
  }
1039
1044
  };
1040
1045
  BuilderComponent.prototype.handleBuilderRequest = function (propertyName, optionsString) {
1041
1046
  var _this = this;
1042
- var options = tryEval(optionsString, this.data, this._errors);
1047
+ var options = (0, try_eval_1.tryEval)(optionsString, this.data, this._errors);
1043
1048
  // TODO: this will screw up for multiple bits of data
1044
1049
  if (this.subscriptions) {
1045
1050
  this.unsubscribe();
@@ -1058,15 +1063,15 @@ var BuilderComponent = /** @class */ (function (_super) {
1058
1063
  }
1059
1064
  };
1060
1065
  BuilderComponent.defaults = {
1061
- codegen: Boolean(Builder.isBrowser && location.href.includes('builder.codegen=true')),
1066
+ codegen: Boolean(sdk_1.Builder.isBrowser && location.href.includes('builder.codegen=true')),
1062
1067
  };
1063
1068
  __decorate([
1064
- debounceNextTick,
1069
+ debonce_next_tick_1.debounceNextTick,
1065
1070
  __metadata("design:type", Function),
1066
1071
  __metadata("design:paramtypes", []),
1067
1072
  __metadata("design:returntype", void 0)
1068
1073
  ], BuilderComponent.prototype, "notifyStateChange", null);
1069
1074
  return BuilderComponent;
1070
- }(React.Component));
1071
- export { BuilderComponent };
1075
+ }(react_1.default.Component));
1076
+ exports.BuilderComponent = BuilderComponent;
1072
1077
  //# sourceMappingURL=builder-component.component.js.map