@builder.io/sdk 2.0.5 → 2.0.7

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 (39) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/index.browser.js +2726 -1
  3. package/dist/index.browser.js.map +1 -1
  4. package/dist/index.cjs.js +38 -31
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.d.ts +7 -7
  7. package/dist/index.esm.js +31 -26
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.umd.js +40 -30
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/package.json +14 -11
  12. package/dist/src/builder.class.d.ts +862 -862
  13. package/dist/src/classes/animator.class.d.ts +26 -26
  14. package/dist/src/classes/cookies.class.d.ts +15 -15
  15. package/dist/src/classes/observable.class.d.ts +27 -26
  16. package/dist/src/classes/observable.class.js +9 -0
  17. package/dist/src/classes/observable.class.js.map +1 -1
  18. package/dist/src/classes/promise.class.d.ts +17 -17
  19. package/dist/src/classes/query-string.class.d.ts +9 -9
  20. package/dist/src/classes/query-string.class.test.d.ts +1 -1
  21. package/dist/src/constants/builder.d.ts +2 -2
  22. package/dist/src/functions/assign.function.d.ts +1 -1
  23. package/dist/src/functions/fetch.function.d.ts +28 -28
  24. package/dist/src/functions/finder.function.d.ts +10 -10
  25. package/dist/src/functions/get-top-level-domain.d.ts +6 -6
  26. package/dist/src/functions/next-tick.function.d.ts +2 -1
  27. package/dist/src/functions/omit.function.d.ts +1 -1
  28. package/dist/src/functions/server-only-require.function.d.ts +3 -3
  29. package/dist/src/functions/throttle.function.d.ts +1 -1
  30. package/dist/src/functions/to-error.d.ts +13 -13
  31. package/dist/src/functions/uuid.d.ts +8 -8
  32. package/dist/src/types/api-version.d.ts +2 -2
  33. package/dist/src/types/content.d.ts +31 -31
  34. package/dist/src/types/element.d.ts +60 -60
  35. package/dist/src/url.d.ts +9 -9
  36. package/dist/src/url.test.d.ts +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +13 -9
  39. package/project.json +4 -0
package/dist/index.cjs.js CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  var tslib = require('tslib');
8
- var hash = _interopDefault(require('hash-sum'));
6
+ var hash = require('hash-sum');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
9
11
 
10
12
  (function () {
11
13
  if (typeof window === 'undefined' || typeof window.CustomEvent === 'function') return false;
@@ -129,7 +131,7 @@ function assertAllowedPropertyName(name) {
129
131
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
130
132
  }
131
133
 
132
- var version = "2.0.5-0";
134
+ var version = "2.0.6";
133
135
 
134
136
  var Subscription = /** @class */ (function () {
135
137
  function Subscription(listeners, listener) {
@@ -166,9 +168,18 @@ var Subscription = /** @class */ (function () {
166
168
  // TODO: follow minimal basic spec: https://github.com/tc39/proposal-observable
167
169
  var BehaviorSubject = /** @class */ (function () {
168
170
  function BehaviorSubject(value) {
171
+ var _this = this;
169
172
  this.value = value;
170
173
  this.listeners = [];
171
174
  this.errorListeners = [];
175
+ this.then = function () {
176
+ var _a;
177
+ var args = [];
178
+ for (var _i = 0; _i < arguments.length; _i++) {
179
+ args[_i] = arguments[_i];
180
+ }
181
+ return (_a = _this.toPromise()).then.apply(_a, args);
182
+ };
172
183
  }
173
184
  BehaviorSubject.prototype.next = function (value) {
174
185
  this.value = value;
@@ -479,10 +490,6 @@ function getFetch() {
479
490
  }
480
491
 
481
492
  function assign(target) {
482
- var args = [];
483
- for (var _i = 1; _i < arguments.length; _i++) {
484
- args[_i - 1] = arguments[_i];
485
- }
486
493
  var to = Object(target);
487
494
  for (var index = 1; index < arguments.length; index++) {
488
495
  var nextSource = arguments[index];
@@ -923,7 +930,7 @@ function emptyUrl() {
923
930
  }
924
931
  // Replacement for `url.parse` using `URL` global object that works with relative paths.
925
932
  // Assumptions: this function operates in a NodeJS environment.
926
- function parse(url) {
933
+ function parse$1(url) {
927
934
  var out = emptyUrl();
928
935
  var u;
929
936
  var pathOnly = url === '' || url[0] === '/';
@@ -1033,12 +1040,12 @@ var urlParser = {
1033
1040
  return out;
1034
1041
  },
1035
1042
  };
1036
- var parse$1 = isReactNative
1043
+ var parse = isReactNative
1037
1044
  ? function () { return emptyUrl(); }
1038
1045
  : typeof window === 'object'
1039
1046
  ? urlParser.parse
1040
- : parse;
1041
- function setCookie(name$$1, value, expires) {
1047
+ : parse$1;
1048
+ function setCookie(name, value, expires) {
1042
1049
  try {
1043
1050
  var expiresString = '';
1044
1051
  // TODO: need to know if secure server side
@@ -1047,7 +1054,7 @@ function setCookie(name$$1, value, expires) {
1047
1054
  }
1048
1055
  var secure = isBrowser ? location.protocol === 'https:' : true;
1049
1056
  document.cookie =
1050
- name$$1 +
1057
+ name +
1051
1058
  '=' +
1052
1059
  (value || '') +
1053
1060
  expiresString +
@@ -1059,10 +1066,10 @@ function setCookie(name$$1, value, expires) {
1059
1066
  console.warn('Could not set cookie', err);
1060
1067
  }
1061
1068
  }
1062
- function getCookie(name$$1) {
1069
+ function getCookie(name) {
1063
1070
  try {
1064
1071
  return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
1065
- encodeURIComponent(name$$1).replace(/[\-\.\+\*]/g, '\\$&') +
1072
+ encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') +
1066
1073
  '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
1067
1074
  }
1068
1075
  catch (err) {
@@ -1292,11 +1299,11 @@ var Builder = /** @class */ (function () {
1292
1299
  throw new Error("Action not found: ".concat(action));
1293
1300
  }
1294
1301
  };
1295
- Builder.fields = function (name$$1, fields) {
1302
+ Builder.fields = function (name, fields) {
1296
1303
  var _a;
1297
1304
  (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
1298
1305
  type: 'builder.fields',
1299
- data: { name: name$$1, fields: fields },
1306
+ data: { name: name, fields: fields },
1300
1307
  }, '*');
1301
1308
  };
1302
1309
  /**
@@ -1789,7 +1796,7 @@ var Builder = /** @class */ (function () {
1789
1796
  var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1790
1797
  var builder = params.builder;
1791
1798
  if (builder) {
1792
- 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;
1799
+ 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;
1793
1800
  if (userAttributes) {
1794
1801
  this.setUserAttributes(userAttributes);
1795
1802
  }
@@ -1837,7 +1844,7 @@ var Builder = /** @class */ (function () {
1837
1844
  if (isBrowser) {
1838
1845
  addEventListener('message', function (event) {
1839
1846
  var _a, _b, _c, _d, _e;
1840
- var url = parse$1(event.origin);
1847
+ var url = parse(event.origin);
1841
1848
  var isRestricted = ['builder.register', 'builder.registerComponent'].indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === -1;
1842
1849
  var isTrusted = url.hostname && Builder.isTrustedHost(url.hostname);
1843
1850
  if (isRestricted && !isTrusted) {
@@ -2056,11 +2063,11 @@ var Builder = /** @class */ (function () {
2056
2063
  var parsedLocation = {};
2057
2064
  // in ssr mode
2058
2065
  if (this.request) {
2059
- parsedLocation = parse$1((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2066
+ parsedLocation = parse((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2060
2067
  }
2061
2068
  else if (typeof location === 'object') {
2062
2069
  // in the browser
2063
- parsedLocation = parse$1(location.href);
2070
+ parsedLocation = parse(location.href);
2064
2071
  }
2065
2072
  // IE11 bug with parsed path being empty string
2066
2073
  // causes issues with our user targeting
@@ -2304,7 +2311,7 @@ var Builder = /** @class */ (function () {
2304
2311
  }
2305
2312
  var pageQueryParams = typeof location !== 'undefined'
2306
2313
  ? QueryString.parseDeep(location.search.substr(1))
2307
- : undefined || {};
2314
+ : {};
2308
2315
  var userAttributes =
2309
2316
  // FIXME: HACK: only checks first in queue for user attributes overrides, should check all
2310
2317
  // TODO: merge user attributes provided here with defaults and current user attiributes (?)
@@ -2517,20 +2524,20 @@ var Builder = /** @class */ (function () {
2517
2524
  future.setDate(future.getDate() + 30);
2518
2525
  return this.setCookie("".concat(this.testCookiePrefix, ".").concat(contentId), variationId, future);
2519
2526
  };
2520
- Builder.prototype.getCookie = function (name$$1) {
2527
+ Builder.prototype.getCookie = function (name) {
2521
2528
  if (this.cookies) {
2522
- return this.cookies.get(name$$1);
2529
+ return this.cookies.get(name);
2523
2530
  }
2524
- return Builder.isBrowser && getCookie(name$$1);
2531
+ return Builder.isBrowser && getCookie(name);
2525
2532
  };
2526
- Builder.prototype.setCookie = function (name$$1, value, expires) {
2533
+ Builder.prototype.setCookie = function (name, value, expires) {
2527
2534
  if (this.cookies && !(Builder.isServer && Builder.isStatic)) {
2528
- return this.cookies.set(name$$1, value, {
2535
+ return this.cookies.set(name, value, {
2529
2536
  expires: expires,
2530
2537
  secure: this.getLocation().protocol === 'https:',
2531
2538
  });
2532
2539
  }
2533
- return Builder.isBrowser && setCookie(name$$1, value, expires);
2540
+ return Builder.isBrowser && setCookie(name, value, expires);
2534
2541
  };
2535
2542
  Builder.prototype.getContent = function (modelName, options) {
2536
2543
  if (options === void 0) { options = {}; }
@@ -2561,7 +2568,7 @@ var Builder = /** @class */ (function () {
2561
2568
  // Make the key include all options, so we don't reuse cache for the same content fetched
2562
2569
  // with different options
2563
2570
  Builder.isBrowser
2564
- ? "".concat(modelName, ":").concat(hash(omit(options, 'initialContent', 'req', 'res')))
2571
+ ? "".concat(modelName, ":").concat(hash__default["default"](omit(options, 'initialContent', 'req', 'res')))
2565
2572
  : undefined }))
2566
2573
  .promise();
2567
2574
  };
@@ -2613,10 +2620,10 @@ var Builder = /** @class */ (function () {
2613
2620
  var builder = new Builder(null, undefined, undefined, true);
2614
2621
  Builder.singletonInstance = builder;
2615
2622
 
2623
+ exports.BehaviorSubject = BehaviorSubject;
2616
2624
  exports.Builder = Builder;
2617
2625
  exports.BuilderComponent = BuilderComponent;
2618
- exports.isBrowser = isBrowser;
2619
- exports.BehaviorSubject = BehaviorSubject;
2620
2626
  exports.Subscription = Subscription;
2621
2627
  exports.builder = builder;
2628
+ exports.isBrowser = isBrowser;
2622
2629
  //# sourceMappingURL=index.cjs.js.map