@builder.io/react 3.0.2-0 → 3.0.3

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 (138) 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 +1 -1
  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 +1 -1
  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 +108 -102
  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 +16 -11
  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 +12 -8
  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 -7
  136. package/rollup.config.ts +1 -0
  137. package/src/components/builder-component.component.tsx +1 -1
  138. package/src/functions/string-to-function.ts +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;
@@ -287,7 +293,7 @@ var BuilderComponent = /** @class */ (function (_super) {
287
293
  };
288
294
  _this.onContentLoaded = function (data, content) {
289
295
  var _a;
290
- if (_this.name === 'page' && Builder.isBrowser) {
296
+ if (_this.name === 'page' && sdk_1.Builder.isBrowser) {
291
297
  if (data) {
292
298
  var title = data.title, pageTitle = data.pageTitle, description = data.description, pageDescription = data.pageDescription;
293
299
  if (title || pageTitle) {
@@ -304,7 +310,7 @@ var BuilderComponent = /** @class */ (function (_super) {
304
310
  }
305
311
  }
306
312
  }
307
- if (Builder.isEditing) {
313
+ if (sdk_1.Builder.isEditing) {
308
314
  _this.notifyStateChange();
309
315
  }
310
316
  if (_this.props.contentLoaded) {
@@ -334,10 +340,10 @@ var BuilderComponent = /** @class */ (function (_super) {
334
340
  }
335
341
  }
336
342
  // TODO: also throttle on edits maybe
337
- if (data && data.jsCode && Builder.isBrowser && !_this.options.codegen) {
343
+ if (data && data.jsCode && sdk_1.Builder.isBrowser && !_this.options.codegen) {
338
344
  // Don't rerun js code when editing and not changed
339
345
  var skip = false;
340
- if (Builder.isEditing) {
346
+ if (sdk_1.Builder.isEditing) {
341
347
  if (_this.lastJsCode === data.jsCode) {
342
348
  skip = true;
343
349
  }
@@ -349,13 +355,13 @@ var BuilderComponent = /** @class */ (function (_super) {
349
355
  var state = _this.state.state;
350
356
  // TODO: real editing method
351
357
  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);
358
+ 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
359
  // TODO: allow exports = { } syntax?
354
360
  // TODO: do something with reuslt like view - methods, computed, actions, properties, template, etc etc
355
361
  }
356
362
  catch (err) {
357
- var error = toError(err);
358
- if (Builder.isBrowser) {
363
+ var error = (0, to_error_1.toError)(err);
364
+ if (sdk_1.Builder.isBrowser) {
359
365
  console.warn('Builder custom code error:', error.message, 'in', data.jsCode, error.stack);
360
366
  }
361
367
  else {
@@ -374,10 +380,10 @@ var BuilderComponent = /** @class */ (function (_super) {
374
380
  if (!skip) {
375
381
  var _loop_1 = function (key) {
376
382
  var url = data.httpRequests[key];
377
- if (url && (!_this.data[key] || Builder.isEditing)) {
378
- if (Builder.isBrowser) {
383
+ if (url && (!_this.data[key] || sdk_1.Builder.isEditing)) {
384
+ if (sdk_1.Builder.isBrowser) {
379
385
  var finalUrl_1 = _this.evalExpression(url);
380
- if (Builder.isEditing && _this.lastHttpRequests[key] === finalUrl_1) {
386
+ if (sdk_1.Builder.isEditing && _this.lastHttpRequests[key] === finalUrl_1) {
381
387
  return "continue";
382
388
  }
383
389
  _this.lastHttpRequests[key] = finalUrl_1;
@@ -416,20 +422,20 @@ var BuilderComponent = /** @class */ (function (_super) {
416
422
  if (_content && _content.content) {
417
423
  _content = _content.content;
418
424
  }
419
- _this.sizes = getSizesForBreakpoints(((_a = _content === null || _content === void 0 ? void 0 : _content.meta) === null || _a === void 0 ? void 0 : _a.breakpoints) || {});
425
+ _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
426
  // TODO: pass this all the way down - symbols, etc
421
427
  // this.asServer = Boolean(props.hydrate && Builder.isBrowser)
422
428
  _this.state = {
423
429
  // 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,
430
+ context: __assign(__assign({}, props.context), { apiKey: sdk_1.builder.apiKey || _this.props.apiKey }),
431
+ 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
432
  // TODO: will user attributes be ready here?
427
433
  device: _this.device }), _this.getHtmlData()), props.data)),
428
434
  updates: 0,
429
435
  key: 0,
430
436
  update: _this.updateState,
431
437
  };
432
- if (Builder.isBrowser) {
438
+ if (sdk_1.Builder.isBrowser) {
433
439
  var key = _this.props.apiKey;
434
440
  if (key && key !== _this.builder.apiKey) {
435
441
  _this.builder.apiKey = key;
@@ -437,7 +443,7 @@ var BuilderComponent = /** @class */ (function (_super) {
437
443
  if (_this.inlinedContent) {
438
444
  // Sometimes with graphql we get the content as `content.content`
439
445
  var content = _this.inlinedContent.content || _this.inlinedContent;
440
- _this.onContentLoaded(content === null || content === void 0 ? void 0 : content.data, getContentWithInfo(content));
446
+ _this.onContentLoaded(content === null || content === void 0 ? void 0 : content.data, (0, builder_content_component_1.getContentWithInfo)(content));
441
447
  }
442
448
  }
443
449
  return _this;
@@ -476,7 +482,7 @@ var BuilderComponent = /** @class */ (function (_super) {
476
482
  });
477
483
  Object.defineProperty(BuilderComponent.prototype, "builder", {
478
484
  get: function () {
479
- return this.props.builder || builder;
485
+ return this.props.builder || sdk_1.builder;
480
486
  },
481
487
  enumerable: false,
482
488
  configurable: true
@@ -484,7 +490,7 @@ var BuilderComponent = /** @class */ (function (_super) {
484
490
  BuilderComponent.prototype.getHtmlData = function () {
485
491
  var id = (this.inlinedContent && this.inlinedContent.id) || this.props.entry;
486
492
  var script = id &&
487
- Builder.isBrowser &&
493
+ sdk_1.Builder.isBrowser &&
488
494
  document.querySelector("script[data-builder-json=\"".concat(id, "\"],script[data-builder-state=\"").concat(id, "\"]"));
489
495
  if (script) {
490
496
  try {
@@ -516,7 +522,7 @@ var BuilderComponent = /** @class */ (function (_super) {
516
522
  // TODO: trigger state change on screen size change
517
523
  get: function () {
518
524
  // TODO: use context to pass this down on server
519
- return Builder.isBrowser
525
+ return sdk_1.Builder.isBrowser
520
526
  ? this.sizes.getSizeForWidth(window.innerWidth)
521
527
  : sizeMap[this.device] || 'large';
522
528
  },
@@ -571,13 +577,13 @@ var BuilderComponent = /** @class */ (function (_super) {
571
577
  if (el) {
572
578
  el.innerHTML = content;
573
579
  }
574
- else if (!Builder.isEditing) {
580
+ else if (!sdk_1.Builder.isEditing) {
575
581
  keepStyles_1 += match;
576
582
  }
577
583
  return match;
578
584
  });
579
585
  // NextTick? or longer timeout?
580
- Builder.nextTick(function () {
586
+ sdk_1.Builder.nextTick(function () {
581
587
  apiStyles_1.innerHTML = keepStyles_1;
582
588
  });
583
589
  }
@@ -599,16 +605,16 @@ var BuilderComponent = /** @class */ (function (_super) {
599
605
  div.appendChild(element);
600
606
  useEl = div;
601
607
  }
602
- if (Builder.isEditing || (Builder.isBrowser && location.search.includes('builder.preview='))) {
608
+ if (sdk_1.Builder.isEditing || (sdk_1.Builder.isBrowser && location.search.includes('builder.preview='))) {
603
609
  shouldHydrate = false;
604
610
  }
605
611
  if (shouldHydrate && element) {
606
612
  // TODO: maybe hydrate again. Maybe...
607
- var val_1 = ReactDOM.render(React.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
613
+ var val_1 = react_dom_1.default.render(react_1.default.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
608
614
  useEl.builderRootRef = val_1;
609
615
  return val_1;
610
616
  }
611
- var val = ReactDOM.render(React.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
617
+ var val = react_dom_1.default.render(react_1.default.createElement(BuilderComponent, __assign({}, props)), useEl, useEl.builderRootRef);
612
618
  useEl.builderRootRef = val;
613
619
  return val;
614
620
  };
@@ -623,17 +629,17 @@ var BuilderComponent = /** @class */ (function (_super) {
623
629
  state.isServer = false;
624
630
  });
625
631
  }
626
- if (Builder.isIframe) {
632
+ if (sdk_1.Builder.isIframe) {
627
633
  (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'builder.sdkInjected', data: { modelName: this.name } }, '*');
628
634
  }
629
- if (Builder.isBrowser) {
635
+ if (sdk_1.Builder.isBrowser) {
630
636
  // TODO: remove event on unload
631
637
  window.addEventListener('resize', this.resizeListener);
632
- if (Builder.isEditing) {
638
+ if (sdk_1.Builder.isEditing) {
633
639
  window.addEventListener('message', this.messageListener);
634
640
  }
635
- if (Builder.isEditing || Builder.isPreviewing) {
636
- Builder.nextTick(function () {
641
+ if (sdk_1.Builder.isEditing || sdk_1.Builder.isPreviewing) {
642
+ sdk_1.Builder.nextTick(function () {
637
643
  _this.firstLoad = false;
638
644
  _this.reload();
639
645
  });
@@ -649,14 +655,14 @@ var BuilderComponent = /** @class */ (function (_super) {
649
655
  };
650
656
  Object.defineProperty(BuilderComponent.prototype, "isPreviewing", {
651
657
  get: function () {
652
- return ((Builder.isServer || (Builder.isBrowser && Builder.isPreviewing && !this.firstLoad)) &&
653
- builder.previewingModel === this.name);
658
+ return ((sdk_1.Builder.isServer || (sdk_1.Builder.isBrowser && sdk_1.Builder.isPreviewing && !this.firstLoad)) &&
659
+ sdk_1.builder.previewingModel === this.name);
654
660
  },
655
661
  enumerable: false,
656
662
  configurable: true
657
663
  });
658
664
  BuilderComponent.prototype.notifyStateChange = function () {
659
- if (Builder.isServer) {
665
+ if (sdk_1.Builder.isServer) {
660
666
  return;
661
667
  }
662
668
  if (!(this && this.state)) {
@@ -667,7 +673,7 @@ var BuilderComponent = /** @class */ (function (_super) {
667
673
  if (this.props.onStateChange) {
668
674
  this.props.onStateChange(nextState);
669
675
  }
670
- if (Builder.isBrowser) {
676
+ if (sdk_1.Builder.isBrowser) {
671
677
  window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
672
678
  detail: {
673
679
  state: nextState,
@@ -682,7 +688,7 @@ var BuilderComponent = /** @class */ (function (_super) {
682
688
  };
683
689
  Object.defineProperty(BuilderComponent.prototype, "location", {
684
690
  get: function () {
685
- return this.props.location || (Builder.isBrowser ? location : {});
691
+ return this.props.location || (sdk_1.Builder.isBrowser ? location : {});
686
692
  },
687
693
  enumerable: false,
688
694
  configurable: true
@@ -713,7 +719,7 @@ var BuilderComponent = /** @class */ (function (_super) {
713
719
  };
714
720
  BuilderComponent.prototype.componentWillUnmount = function () {
715
721
  this.unsubscribe();
716
- if (Builder.isBrowser) {
722
+ if (sdk_1.Builder.isBrowser) {
717
723
  window.removeEventListener('resize', this.resizeListener);
718
724
  window.removeEventListener('message', this.messageListener);
719
725
  }
@@ -779,7 +785,7 @@ var BuilderComponent = /** @class */ (function (_super) {
779
785
  Object.assign(state, _this.externalState);
780
786
  });
781
787
  }
782
- if (Builder.isEditing) {
788
+ if (sdk_1.Builder.isEditing) {
783
789
  if (this.inlinedContent && prevProps.content !== this.inlinedContent) {
784
790
  this.onContentLoaded(this.inlinedContent.data, this.inlinedContent);
785
791
  }
@@ -830,36 +836,36 @@ var BuilderComponent = /** @class */ (function (_super) {
830
836
  var _this = this;
831
837
  var _a;
832
838
  var content = this.content;
833
- var dataString = Builder.isBrowser &&
839
+ var dataString = sdk_1.Builder.isBrowser &&
834
840
  this.externalState &&
835
841
  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) {
842
+ (0, hash_sum_1.default)(this.externalState);
843
+ var key = sdk_1.Builder.isEditing ? this.name : this.props.entry;
844
+ if (key && !sdk_1.Builder.isEditing && dataString && dataString.length < 300) {
839
845
  key += ':' + dataString;
840
846
  }
841
- var WrapComponent = this.props.dataOnly ? React.Fragment : 'div';
847
+ var WrapComponent = this.props.dataOnly ? react_1.default.Fragment : 'div';
842
848
  var contentId = (_a = this.useContent) === null || _a === void 0 ? void 0 : _a.id;
843
849
  return (
844
850
  // TODO: data attributes for model, id, etc?
845
- React.createElement(WrapComponent, { onClick: function (event) {
851
+ react_1.default.createElement(WrapComponent, { onClick: function (event) {
846
852
  // Prevent propagation from the root content component when editing to prevent issues
847
853
  // like client side routing triggering when links are clicked, unless this behavior is
848
854
  // disabled with the stopClickPropagationWhenEditing prop
849
- if (Builder.isEditing &&
855
+ if (sdk_1.Builder.isEditing &&
850
856
  !_this.props.isChild &&
851
857
  !_this.props.stopClickPropagationWhenEditing) {
852
858
  event.stopPropagation();
853
859
  }
854
860
  }, 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'
861
+ 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
862
  ? __assign(__assign({}, value), { ampMode: _this.props.ampMode }) : value },
857
- React.createElement(BuilderAsyncRequestsContext.Consumer, null, function (value) {
863
+ react_1.default.createElement(builder_async_requests_1.BuilderAsyncRequestsContext.Consumer, null, function (value) {
858
864
  var _a;
859
865
  _this._asyncRequests = value && value.requests;
860
866
  _this._errors = value && value.errors;
861
867
  _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) ||
868
+ 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
869
  ('content' in _this.props && !_this.isPreviewing
864
870
  ? 'null-content-prop'
865
871
  : 'no-content-prop'), builder: _this.builder, ref: function (ref) { return (_this.contentRef = ref); },
@@ -880,22 +886,22 @@ var BuilderComponent = /** @class */ (function (_super) {
880
886
  }
881
887
  _this.state.context.builderContent = fullData;
882
888
  }
883
- if (Builder.isBrowser) {
884
- Builder.nextTick(function () {
889
+ if (sdk_1.Builder.isBrowser) {
890
+ sdk_1.Builder.nextTick(function () {
885
891
  _this.checkStyles(data);
886
892
  });
887
893
  }
888
894
  var codegen = _this.options.codegen;
889
895
  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();
896
+ var builderComponentNames = Array.from(new Set(sdk_1.Builder.components.map(function (item) { return item.name; })));
897
+ var reversedcomponents_1 = sdk_1.Builder.components.slice().reverse();
892
898
  var builderComponents = builderComponentNames.map(function (name) {
893
899
  return reversedcomponents_1.find(function (item) { return item.class && item.name === name; });
894
900
  });
895
901
  var useBuilderState = function (initialState) {
896
- var _a = React.useState(0), setTick = _a[1];
897
- var state = React.useState(function () {
898
- return onChange(initialState, function () {
902
+ var _a = react_1.default.useState(0), setTick = _a[1];
903
+ var state = react_1.default.useState(function () {
904
+ return (0, on_change_1.default)(initialState, function () {
899
905
  setTick(function (tick) { return tick + 1; });
900
906
  });
901
907
  })[0];
@@ -912,29 +918,29 @@ var BuilderComponent = /** @class */ (function (_super) {
912
918
  'Builder',
913
919
  'builder',
914
920
  'React',
915
- 'useBuilderState'], mappedComponentNames, false), [data.blocksJs], false)))().apply(void 0, __spreadArray([jsx,
916
- css,
917
- Builder,
918
- builder,
919
- React,
921
+ 'useBuilderState'], mappedComponentNames, false), [data.blocksJs], false)))().apply(void 0, __spreadArray([core_1.jsx,
922
+ core_1.css,
923
+ sdk_1.Builder,
924
+ sdk_1.builder,
925
+ react_1.default,
920
926
  useBuilderState], finalizedComponents, false));
921
927
  }
922
928
  var blocks = (data === null || data === void 0 ? void 0 : data.blocks) || [];
923
929
  var hasPixel = blocks.find(function (block) { var _a; return (_a = block.id) === null || _a === void 0 ? void 0 : _a.startsWith('builder-pixel'); });
924
930
  if (data && !hasPixel && blocks.length > 0) {
925
- blocks.push(getBuilderPixel(builder.apiKey));
931
+ blocks.push((0, get_builder_pixel_1.getBuilderPixel)(sdk_1.builder.apiKey));
926
932
  }
927
933
  // TODO: loading option - maybe that is what the children is or component prop
928
934
  // 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
935
+ return data ? (react_1.default.createElement("div", __assign({ "data-builder-component": _this.name, "data-builder-content-id": fullData.id }, (_this.isPreviewing
930
936
  ? {
931
937
  'data-builder-variation-id': fullData.testVariationId || fullData.variationId || fullData.id,
932
938
  }
933
939
  : {})),
934
- !codegen && _this.getCss(data) && (React.createElement("style", { ref: function (ref) { return (_this.styleRef = ref); }, className: "builder-custom-styles", dangerouslySetInnerHTML: {
940
+ !codegen && _this.getCss(data) && (react_1.default.createElement("style", { ref: function (ref) { return (_this.styleRef = ref); }, className: "builder-custom-styles", dangerouslySetInnerHTML: {
935
941
  __html: _this.getCss(data),
936
942
  } })),
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" }));
943
+ 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
944
  }));
939
945
  }))); })));
940
946
  };
@@ -942,7 +948,7 @@ var BuilderComponent = /** @class */ (function (_super) {
942
948
  var _this = this;
943
949
  var data = this.data;
944
950
  return String(expression).replace(/{{([^}]+)}}/g, function (match, group) {
945
- return tryEval(group, data, _this._errors);
951
+ return (0, try_eval_1.tryEval)(group, data, _this._errors);
946
952
  });
947
953
  };
948
954
  BuilderComponent.prototype.handleRequest = function (propertyName, url) {
@@ -951,7 +957,7 @@ var BuilderComponent = /** @class */ (function (_super) {
951
957
  var _this = this;
952
958
  return __generator(this, function (_a) {
953
959
  // TODO: Builder.isEditing = just checks if iframe and parent page is this.builder.io or localhost:1234
954
- if (Builder.isIframe && fetchCache[url]) {
960
+ if (sdk_1.Builder.isIframe && fetchCache[url]) {
955
961
  this.updateState(function (ctx) {
956
962
  ctx[propertyName] = fetchCache[url];
957
963
  });
@@ -963,7 +969,7 @@ var BuilderComponent = /** @class */ (function (_super) {
963
969
  switch (_a.label) {
964
970
  case 0:
965
971
  requestStart = Date.now();
966
- if (!Builder.isBrowser) {
972
+ if (!sdk_1.Builder.isBrowser) {
967
973
  console.time('Fetch ' + url);
968
974
  }
969
975
  _a.label = 1;
@@ -978,7 +984,7 @@ var BuilderComponent = /** @class */ (function (_super) {
978
984
  return [3 /*break*/, 6];
979
985
  case 4:
980
986
  err_1 = _a.sent();
981
- error = toError(err_1);
987
+ error = (0, to_error_1.toError)(err_1);
982
988
  if (this._errors) {
983
989
  this._errors.push(error);
984
990
  }
@@ -987,7 +993,7 @@ var BuilderComponent = /** @class */ (function (_super) {
987
993
  }
988
994
  return [2 /*return*/];
989
995
  case 5:
990
- if (!Builder.isBrowser) {
996
+ if (!sdk_1.Builder.isBrowser) {
991
997
  console.timeEnd('Fetch ' + url);
992
998
  if (this._logs) {
993
999
  this._logs.push("Fetched ".concat(url, " in ").concat(Date.now() - requestStart, "ms"));
@@ -996,7 +1002,7 @@ var BuilderComponent = /** @class */ (function (_super) {
996
1002
  return [7 /*endfinally*/];
997
1003
  case 6:
998
1004
  if (json) {
999
- if (Builder.isIframe) {
1005
+ if (sdk_1.Builder.isIframe) {
1000
1006
  fetchCache[url] = json;
1001
1007
  }
1002
1008
  // TODO: debounce next tick all of these when there are a bunch
@@ -1009,7 +1015,7 @@ var BuilderComponent = /** @class */ (function (_super) {
1009
1015
  });
1010
1016
  }); };
1011
1017
  existing = this._asyncRequests &&
1012
- this._asyncRequests.find(function (req) { return isRequestInfo(req) && req.url === url; });
1018
+ this._asyncRequests.find(function (req) { return (0, builder_async_requests_1.isRequestInfo)(req) && req.url === url; });
1013
1019
  if (existing) {
1014
1020
  promise_1 = existing.promise;
1015
1021
  promise_1.then(function (json) {
@@ -1022,7 +1028,7 @@ var BuilderComponent = /** @class */ (function (_super) {
1022
1028
  return [2 /*return*/, promise_1];
1023
1029
  }
1024
1030
  promise = request();
1025
- Builder.nextTick(function () {
1031
+ sdk_1.Builder.nextTick(function () {
1026
1032
  if (_this._asyncRequests) {
1027
1033
  _this._asyncRequests.push(promise);
1028
1034
  }
@@ -1034,12 +1040,12 @@ var BuilderComponent = /** @class */ (function (_super) {
1034
1040
  BuilderComponent.prototype.unsubscribe = function () {
1035
1041
  if (this.subscriptions) {
1036
1042
  this.subscriptions.unsubscribe();
1037
- this.subscriptions = new Subscription();
1043
+ this.subscriptions = new sdk_1.Subscription();
1038
1044
  }
1039
1045
  };
1040
1046
  BuilderComponent.prototype.handleBuilderRequest = function (propertyName, optionsString) {
1041
1047
  var _this = this;
1042
- var options = tryEval(optionsString, this.data, this._errors);
1048
+ var options = (0, try_eval_1.tryEval)(optionsString, this.data, this._errors);
1043
1049
  // TODO: this will screw up for multiple bits of data
1044
1050
  if (this.subscriptions) {
1045
1051
  this.unsubscribe();
@@ -1058,15 +1064,15 @@ var BuilderComponent = /** @class */ (function (_super) {
1058
1064
  }
1059
1065
  };
1060
1066
  BuilderComponent.defaults = {
1061
- codegen: Boolean(Builder.isBrowser && location.href.includes('builder.codegen=true')),
1067
+ codegen: Boolean(sdk_1.Builder.isBrowser && location.href.includes('builder.codegen=true')),
1062
1068
  };
1063
1069
  __decorate([
1064
- debounceNextTick,
1070
+ debonce_next_tick_1.debounceNextTick,
1065
1071
  __metadata("design:type", Function),
1066
1072
  __metadata("design:paramtypes", []),
1067
1073
  __metadata("design:returntype", void 0)
1068
1074
  ], BuilderComponent.prototype, "notifyStateChange", null);
1069
1075
  return BuilderComponent;
1070
- }(React.Component));
1071
- export { BuilderComponent };
1076
+ }(react_1.default.Component));
1077
+ exports.BuilderComponent = BuilderComponent;
1072
1078
  //# sourceMappingURL=builder-component.component.js.map