@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.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define('@builder.io/sdk', ['exports'], factory) :
4
- (factory((global.BuilderIO = {})));
5
- }(this, (function (exports) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BuilderIO = {}));
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -28,6 +28,11 @@
28
28
  return t;
29
29
  };
30
30
  return __assign.apply(this, arguments);
31
+ };
32
+
33
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
34
+ var e = new Error(message);
35
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
36
  };
32
37
 
33
38
  (function () {
@@ -152,7 +157,7 @@
152
157
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
153
158
  }
154
159
 
155
- var version = "2.0.5-0";
160
+ var version = "2.0.6";
156
161
 
157
162
  var Subscription = /** @class */ (function () {
158
163
  function Subscription(listeners, listener) {
@@ -189,9 +194,18 @@
189
194
  // TODO: follow minimal basic spec: https://github.com/tc39/proposal-observable
190
195
  var BehaviorSubject = /** @class */ (function () {
191
196
  function BehaviorSubject(value) {
197
+ var _this = this;
192
198
  this.value = value;
193
199
  this.listeners = [];
194
200
  this.errorListeners = [];
201
+ this.then = function () {
202
+ var _a;
203
+ var args = [];
204
+ for (var _i = 0; _i < arguments.length; _i++) {
205
+ args[_i] = arguments[_i];
206
+ }
207
+ return (_a = _this.toPromise()).then.apply(_a, args);
208
+ };
195
209
  }
196
210
  BehaviorSubject.prototype.next = function (value) {
197
211
  this.value = value;
@@ -502,10 +516,6 @@
502
516
  }
503
517
 
504
518
  function assign(target) {
505
- var args = [];
506
- for (var _i = 1; _i < arguments.length; _i++) {
507
- args[_i - 1] = arguments[_i];
508
- }
509
519
  var to = Object(target);
510
520
  for (var index = 1; index < arguments.length; index++) {
511
521
  var nextSource = arguments[index];
@@ -946,7 +956,7 @@
946
956
  }
947
957
  // Replacement for `url.parse` using `URL` global object that works with relative paths.
948
958
  // Assumptions: this function operates in a NodeJS environment.
949
- function parse(url) {
959
+ function parse$1(url) {
950
960
  var out = emptyUrl();
951
961
  var u;
952
962
  var pathOnly = url === '' || url[0] === '/';
@@ -1124,12 +1134,12 @@
1124
1134
  return out;
1125
1135
  },
1126
1136
  };
1127
- var parse$1 = isReactNative
1137
+ var parse = isReactNative
1128
1138
  ? function () { return emptyUrl(); }
1129
1139
  : typeof window === 'object'
1130
1140
  ? urlParser.parse
1131
- : parse;
1132
- function setCookie(name$$1, value, expires) {
1141
+ : parse$1;
1142
+ function setCookie(name, value, expires) {
1133
1143
  try {
1134
1144
  var expiresString = '';
1135
1145
  // TODO: need to know if secure server side
@@ -1138,7 +1148,7 @@
1138
1148
  }
1139
1149
  var secure = isBrowser ? location.protocol === 'https:' : true;
1140
1150
  document.cookie =
1141
- name$$1 +
1151
+ name +
1142
1152
  '=' +
1143
1153
  (value || '') +
1144
1154
  expiresString +
@@ -1150,10 +1160,10 @@
1150
1160
  console.warn('Could not set cookie', err);
1151
1161
  }
1152
1162
  }
1153
- function getCookie(name$$1) {
1163
+ function getCookie(name) {
1154
1164
  try {
1155
1165
  return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
1156
- encodeURIComponent(name$$1).replace(/[\-\.\+\*]/g, '\\$&') +
1166
+ encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') +
1157
1167
  '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
1158
1168
  }
1159
1169
  catch (err) {
@@ -1383,11 +1393,11 @@
1383
1393
  throw new Error("Action not found: ".concat(action));
1384
1394
  }
1385
1395
  };
1386
- Builder.fields = function (name$$1, fields) {
1396
+ Builder.fields = function (name, fields) {
1387
1397
  var _a;
1388
1398
  (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
1389
1399
  type: 'builder.fields',
1390
- data: { name: name$$1, fields: fields },
1400
+ data: { name: name, fields: fields },
1391
1401
  }, '*');
1392
1402
  };
1393
1403
  /**
@@ -1880,7 +1890,7 @@
1880
1890
  var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1881
1891
  var builder = params.builder;
1882
1892
  if (builder) {
1883
- 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;
1893
+ 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;
1884
1894
  if (userAttributes) {
1885
1895
  this.setUserAttributes(userAttributes);
1886
1896
  }
@@ -1928,7 +1938,7 @@
1928
1938
  if (isBrowser) {
1929
1939
  addEventListener('message', function (event) {
1930
1940
  var _a, _b, _c, _d, _e;
1931
- var url = parse$1(event.origin);
1941
+ var url = parse(event.origin);
1932
1942
  var isRestricted = ['builder.register', 'builder.registerComponent'].indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === -1;
1933
1943
  var isTrusted = url.hostname && Builder.isTrustedHost(url.hostname);
1934
1944
  if (isRestricted && !isTrusted) {
@@ -2147,11 +2157,11 @@
2147
2157
  var parsedLocation = {};
2148
2158
  // in ssr mode
2149
2159
  if (this.request) {
2150
- parsedLocation = parse$1((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2160
+ parsedLocation = parse((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2151
2161
  }
2152
2162
  else if (typeof location === 'object') {
2153
2163
  // in the browser
2154
- parsedLocation = parse$1(location.href);
2164
+ parsedLocation = parse(location.href);
2155
2165
  }
2156
2166
  // IE11 bug with parsed path being empty string
2157
2167
  // causes issues with our user targeting
@@ -2395,7 +2405,7 @@
2395
2405
  }
2396
2406
  var pageQueryParams = typeof location !== 'undefined'
2397
2407
  ? QueryString.parseDeep(location.search.substr(1))
2398
- : undefined || {};
2408
+ : {};
2399
2409
  var userAttributes =
2400
2410
  // FIXME: HACK: only checks first in queue for user attributes overrides, should check all
2401
2411
  // TODO: merge user attributes provided here with defaults and current user attiributes (?)
@@ -2608,20 +2618,20 @@
2608
2618
  future.setDate(future.getDate() + 30);
2609
2619
  return this.setCookie("".concat(this.testCookiePrefix, ".").concat(contentId), variationId, future);
2610
2620
  };
2611
- Builder.prototype.getCookie = function (name$$1) {
2621
+ Builder.prototype.getCookie = function (name) {
2612
2622
  if (this.cookies) {
2613
- return this.cookies.get(name$$1);
2623
+ return this.cookies.get(name);
2614
2624
  }
2615
- return Builder.isBrowser && getCookie(name$$1);
2625
+ return Builder.isBrowser && getCookie(name);
2616
2626
  };
2617
- Builder.prototype.setCookie = function (name$$1, value, expires) {
2627
+ Builder.prototype.setCookie = function (name, value, expires) {
2618
2628
  if (this.cookies && !(Builder.isServer && Builder.isStatic)) {
2619
- return this.cookies.set(name$$1, value, {
2629
+ return this.cookies.set(name, value, {
2620
2630
  expires: expires,
2621
2631
  secure: this.getLocation().protocol === 'https:',
2622
2632
  });
2623
2633
  }
2624
- return Builder.isBrowser && setCookie(name$$1, value, expires);
2634
+ return Builder.isBrowser && setCookie(name, value, expires);
2625
2635
  };
2626
2636
  Builder.prototype.getContent = function (modelName, options) {
2627
2637
  if (options === void 0) { options = {}; }
@@ -2704,14 +2714,14 @@
2704
2714
  var builder = new Builder(null, undefined, undefined, true);
2705
2715
  Builder.singletonInstance = builder;
2706
2716
 
2717
+ exports.BehaviorSubject = BehaviorSubject;
2707
2718
  exports.Builder = Builder;
2708
2719
  exports.BuilderComponent = BuilderComponent;
2709
- exports.isBrowser = isBrowser;
2710
- exports.BehaviorSubject = BehaviorSubject;
2711
2720
  exports.Subscription = Subscription;
2712
2721
  exports.builder = builder;
2722
+ exports.isBrowser = isBrowser;
2713
2723
 
2714
2724
  Object.defineProperty(exports, '__esModule', { value: true });
2715
2725
 
2716
- })));
2726
+ }));
2717
2727
  //# sourceMappingURL=index.umd.js.map