@builder.io/sdk 2.2.8 → 3.0.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.
package/dist/index.cjs.js CHANGED
@@ -126,7 +126,7 @@ function assertAllowedPropertyName(name) {
126
126
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
127
127
  }
128
128
 
129
- var version = "2.2.8";
129
+ var version = "3.0.0";
130
130
 
131
131
  var Subscription = /** @class */ (function () {
132
132
  function Subscription(listeners, listener) {
@@ -1756,15 +1756,20 @@ var Builder = /** @class */ (function () {
1756
1756
  };
1757
1757
  Builder.prototype.setTestsFromUrl = function () {
1758
1758
  var search = this.getLocation().search;
1759
- var params = QueryString.parseDeep(this.modifySearch(search || '').substr(1));
1760
- var tests = params.builder && params.builder.tests;
1761
- if (tests && typeof tests === 'object') {
1762
- for (var key in tests) {
1763
- if (tests.hasOwnProperty(key)) {
1764
- this.setTestCookie(key, tests[key]);
1759
+ try {
1760
+ var params = QueryString.parseDeep(this.modifySearch(search || '').substr(1));
1761
+ var tests = params.builder && params.builder.tests;
1762
+ if (tests && typeof tests === 'object') {
1763
+ for (var key in tests) {
1764
+ if (tests.hasOwnProperty(key)) {
1765
+ this.setTestCookie(key, tests[key]);
1766
+ }
1765
1767
  }
1766
1768
  }
1767
1769
  }
1770
+ catch (e) {
1771
+ console.debug('Error parsing tests from URL', e);
1772
+ }
1768
1773
  };
1769
1774
  Builder.prototype.resetOverrides = function () {
1770
1775
  // Ugly - pass down instances per request instead using react context
@@ -1782,41 +1787,46 @@ var Builder = /** @class */ (function () {
1782
1787
  };
1783
1788
  Builder.prototype.getOverridesFromQueryString = function () {
1784
1789
  var location = this.getLocation();
1785
- var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1786
- var builder = params.builder;
1787
- if (builder) {
1788
- var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env; builder.host; var api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, options = builder.options, overrideParams = builder.params;
1789
- if (userAttributes) {
1790
- this.setUserAttributes(userAttributes);
1791
- }
1792
- if (options) {
1793
- // picking only locale, includeRefs, and enrich for now
1794
- this.queryOptions = tslib.__assign(tslib.__assign(tslib.__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs })), (options.enrich && { enrich: options.enrich }));
1795
- }
1796
- if (overrides) {
1797
- this.overrides = overrides;
1798
- }
1799
- if (validEnvList.indexOf(env || api) > -1) {
1800
- this.env = env || api;
1801
- }
1802
- if (Builder.isEditing) {
1803
- var editingModel = frameEditing || editing || preview;
1804
- if (editingModel && editingModel !== 'true') {
1805
- this.editingModel = editingModel;
1790
+ try {
1791
+ var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1792
+ var builder = params.builder;
1793
+ if (builder) {
1794
+ var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env, host = builder.host, api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, options = builder.options, overrideParams = builder.params;
1795
+ if (userAttributes) {
1796
+ this.setUserAttributes(userAttributes);
1797
+ }
1798
+ if (options) {
1799
+ // picking only locale, includeRefs, and enrich for now
1800
+ this.queryOptions = tslib.__assign(tslib.__assign(tslib.__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs })), (options.enrich && { enrich: options.enrich }));
1801
+ }
1802
+ if (overrides) {
1803
+ this.overrides = overrides;
1804
+ }
1805
+ if (validEnvList.indexOf(env || api) > -1) {
1806
+ this.env = env || api;
1807
+ }
1808
+ if (Builder.isEditing) {
1809
+ var editingModel = frameEditing || editing || preview;
1810
+ if (editingModel && editingModel !== 'true') {
1811
+ this.editingModel = editingModel;
1812
+ }
1813
+ }
1814
+ if (cachebust) {
1815
+ this.cachebust = true;
1816
+ }
1817
+ if (noCache) {
1818
+ this.noCache = true;
1819
+ }
1820
+ if (preview) {
1821
+ this.preview = true;
1822
+ }
1823
+ if (params) {
1824
+ this.overrideParams = overrideParams;
1806
1825
  }
1807
1826
  }
1808
- if (cachebust) {
1809
- this.cachebust = true;
1810
- }
1811
- if (noCache) {
1812
- this.noCache = true;
1813
- }
1814
- if (preview) {
1815
- this.preview = true;
1816
- }
1817
- if (params) {
1818
- this.overrideParams = overrideParams;
1819
- }
1827
+ }
1828
+ catch (e) {
1829
+ console.debug('Error parsing overrides from URL', e);
1820
1830
  }
1821
1831
  };
1822
1832
  Builder.prototype.messageFrameLoaded = function () {
@@ -2237,7 +2247,7 @@ var Builder = /** @class */ (function () {
2237
2247
  // even though we only use `fetch()` now, we prefer to keep the old behavior and use the `fetch` that comes from
2238
2248
  // the core SDK for consistency
2239
2249
  Builder.prototype.requestUrl = function (url, options) {
2240
- return getFetch()(url, tslib.__assign({ next: tslib.__assign({ revalidate: 1 }, options === null || options === void 0 ? void 0 : options.next) }, options)).then(function (res) { return res.json(); });
2250
+ return getFetch()(url, options).then(function (res) { return res.json(); });
2241
2251
  };
2242
2252
  Object.defineProperty(Builder.prototype, "host", {
2243
2253
  get: function () {
@@ -2333,7 +2343,7 @@ var Builder = /** @class */ (function () {
2333
2343
  }
2334
2344
  // TODO: merge in the attribute from query string ones
2335
2345
  // TODO: make this an option per component/request
2336
- queryParams.userAttributes = userAttributes;
2346
+ queryParams.userAttributes = JSON.stringify(userAttributes);
2337
2347
  if (!usePastQueue && !useQueue) {
2338
2348
  this.priorContentQueue = queue;
2339
2349
  this.getContentQueue = null;
@@ -2411,7 +2421,7 @@ var Builder = /** @class */ (function () {
2411
2421
  }
2412
2422
  var queryStr = QueryString.stringifyDeep(queryParams);
2413
2423
  var format = queryParams.format;
2414
- var requestOptions = { headers: {}, next: { revalidate: 1 } };
2424
+ var requestOptions = { headers: {} };
2415
2425
  if (this.authToken) {
2416
2426
  requestOptions.headers = tslib.__assign(tslib.__assign({}, requestOptions.headers), { Authorization: "Bearer ".concat(this.authToken) });
2417
2427
  }