@builder.io/sdk 2.0.6 → 2.0.8

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 (40) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/index.browser.js +2721 -1
  3. package/dist/index.browser.js.map +1 -1
  4. package/dist/index.cjs.js +31 -38
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.d.ts +7 -7
  7. package/dist/index.esm.js +24 -33
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.umd.js +33 -37
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/package.json +13 -9
  12. package/dist/src/builder.class.d.ts +861 -862
  13. package/dist/src/builder.class.js.map +1 -1
  14. package/dist/src/classes/animator.class.d.ts +26 -26
  15. package/dist/src/classes/cookies.class.d.ts +15 -15
  16. package/dist/src/classes/observable.class.d.ts +27 -27
  17. package/dist/src/classes/promise.class.d.ts +17 -17
  18. package/dist/src/classes/query-string.class.d.ts +9 -9
  19. package/dist/src/classes/query-string.class.test.d.ts +1 -1
  20. package/dist/src/constants/builder.d.ts +2 -2
  21. package/dist/src/functions/assign.function.d.ts +1 -1
  22. package/dist/src/functions/fetch.function.d.ts +28 -28
  23. package/dist/src/functions/finder.function.d.ts +10 -10
  24. package/dist/src/functions/get-top-level-domain.d.ts +6 -6
  25. package/dist/src/functions/next-tick.function.d.ts +1 -1
  26. package/dist/src/functions/next-tick.function.js +1 -7
  27. package/dist/src/functions/next-tick.function.js.map +1 -1
  28. package/dist/src/functions/omit.function.d.ts +1 -1
  29. package/dist/src/functions/server-only-require.function.d.ts +3 -3
  30. package/dist/src/functions/throttle.function.d.ts +1 -1
  31. package/dist/src/functions/to-error.d.ts +13 -13
  32. package/dist/src/functions/uuid.d.ts +8 -8
  33. package/dist/src/types/api-version.d.ts +2 -2
  34. package/dist/src/types/content.d.ts +31 -31
  35. package/dist/src/types/element.d.ts +60 -60
  36. package/dist/src/url.d.ts +9 -9
  37. package/dist/src/url.test.d.ts +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +13 -9
  40. 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 () {
@@ -45,21 +50,16 @@
45
50
 
46
51
  var isSafari = typeof window !== 'undefined' &&
47
52
  /^((?!chrome|android).)*safari/i.test(window.navigator.userAgent);
53
+ var isClient = typeof window !== 'undefined';
48
54
  // TODO: queue all of these in a debounceNextTick
49
55
  function nextTick(fn) {
50
- // React native
51
- if (typeof setImmediate === 'function' && typeof window === 'undefined') {
52
- return setImmediate(fn);
53
- }
54
- // TODO: should this be setImmediate instead? Forgot if that is micro or macro task
55
- // TODO: detect specifically if is server
56
56
  // if (typeof process !== 'undefined' && process.nextTick) {
57
57
  // console.log('process.nextTick?');
58
58
  // process.nextTick(fn);
59
59
  // return;
60
60
  // }
61
61
  // FIXME: fix the real safari issue of this randomly not working
62
- if (isSafari || typeof MutationObserver === 'undefined') {
62
+ if (!isClient || isSafari || typeof MutationObserver === 'undefined') {
63
63
  setTimeout(fn);
64
64
  return;
65
65
  }
@@ -152,7 +152,7 @@
152
152
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
153
153
  }
154
154
 
155
- var version = "2.0.5";
155
+ var version = "2.0.7";
156
156
 
157
157
  var Subscription = /** @class */ (function () {
158
158
  function Subscription(listeners, listener) {
@@ -511,10 +511,6 @@
511
511
  }
512
512
 
513
513
  function assign(target) {
514
- var args = [];
515
- for (var _i = 1; _i < arguments.length; _i++) {
516
- args[_i - 1] = arguments[_i];
517
- }
518
514
  var to = Object(target);
519
515
  for (var index = 1; index < arguments.length; index++) {
520
516
  var nextSource = arguments[index];
@@ -955,7 +951,7 @@
955
951
  }
956
952
  // Replacement for `url.parse` using `URL` global object that works with relative paths.
957
953
  // Assumptions: this function operates in a NodeJS environment.
958
- function parse(url) {
954
+ function parse$1(url) {
959
955
  var out = emptyUrl();
960
956
  var u;
961
957
  var pathOnly = url === '' || url[0] === '/';
@@ -1133,12 +1129,12 @@
1133
1129
  return out;
1134
1130
  },
1135
1131
  };
1136
- var parse$1 = isReactNative
1132
+ var parse = isReactNative
1137
1133
  ? function () { return emptyUrl(); }
1138
1134
  : typeof window === 'object'
1139
1135
  ? urlParser.parse
1140
- : parse;
1141
- function setCookie(name$$1, value, expires) {
1136
+ : parse$1;
1137
+ function setCookie(name, value, expires) {
1142
1138
  try {
1143
1139
  var expiresString = '';
1144
1140
  // TODO: need to know if secure server side
@@ -1147,7 +1143,7 @@
1147
1143
  }
1148
1144
  var secure = isBrowser ? location.protocol === 'https:' : true;
1149
1145
  document.cookie =
1150
- name$$1 +
1146
+ name +
1151
1147
  '=' +
1152
1148
  (value || '') +
1153
1149
  expiresString +
@@ -1159,10 +1155,10 @@
1159
1155
  console.warn('Could not set cookie', err);
1160
1156
  }
1161
1157
  }
1162
- function getCookie(name$$1) {
1158
+ function getCookie(name) {
1163
1159
  try {
1164
1160
  return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
1165
- encodeURIComponent(name$$1).replace(/[\-\.\+\*]/g, '\\$&') +
1161
+ encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') +
1166
1162
  '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
1167
1163
  }
1168
1164
  catch (err) {
@@ -1392,11 +1388,11 @@
1392
1388
  throw new Error("Action not found: ".concat(action));
1393
1389
  }
1394
1390
  };
1395
- Builder.fields = function (name$$1, fields) {
1391
+ Builder.fields = function (name, fields) {
1396
1392
  var _a;
1397
1393
  (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
1398
1394
  type: 'builder.fields',
1399
- data: { name: name$$1, fields: fields },
1395
+ data: { name: name, fields: fields },
1400
1396
  }, '*');
1401
1397
  };
1402
1398
  /**
@@ -1889,7 +1885,7 @@
1889
1885
  var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1890
1886
  var builder = params.builder;
1891
1887
  if (builder) {
1892
- 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;
1888
+ 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;
1893
1889
  if (userAttributes) {
1894
1890
  this.setUserAttributes(userAttributes);
1895
1891
  }
@@ -1937,7 +1933,7 @@
1937
1933
  if (isBrowser) {
1938
1934
  addEventListener('message', function (event) {
1939
1935
  var _a, _b, _c, _d, _e;
1940
- var url = parse$1(event.origin);
1936
+ var url = parse(event.origin);
1941
1937
  var isRestricted = ['builder.register', 'builder.registerComponent'].indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === -1;
1942
1938
  var isTrusted = url.hostname && Builder.isTrustedHost(url.hostname);
1943
1939
  if (isRestricted && !isTrusted) {
@@ -2156,11 +2152,11 @@
2156
2152
  var parsedLocation = {};
2157
2153
  // in ssr mode
2158
2154
  if (this.request) {
2159
- parsedLocation = parse$1((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2155
+ parsedLocation = parse((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2160
2156
  }
2161
2157
  else if (typeof location === 'object') {
2162
2158
  // in the browser
2163
- parsedLocation = parse$1(location.href);
2159
+ parsedLocation = parse(location.href);
2164
2160
  }
2165
2161
  // IE11 bug with parsed path being empty string
2166
2162
  // causes issues with our user targeting
@@ -2404,7 +2400,7 @@
2404
2400
  }
2405
2401
  var pageQueryParams = typeof location !== 'undefined'
2406
2402
  ? QueryString.parseDeep(location.search.substr(1))
2407
- : undefined || {};
2403
+ : {};
2408
2404
  var userAttributes =
2409
2405
  // FIXME: HACK: only checks first in queue for user attributes overrides, should check all
2410
2406
  // TODO: merge user attributes provided here with defaults and current user attiributes (?)
@@ -2617,20 +2613,20 @@
2617
2613
  future.setDate(future.getDate() + 30);
2618
2614
  return this.setCookie("".concat(this.testCookiePrefix, ".").concat(contentId), variationId, future);
2619
2615
  };
2620
- Builder.prototype.getCookie = function (name$$1) {
2616
+ Builder.prototype.getCookie = function (name) {
2621
2617
  if (this.cookies) {
2622
- return this.cookies.get(name$$1);
2618
+ return this.cookies.get(name);
2623
2619
  }
2624
- return Builder.isBrowser && getCookie(name$$1);
2620
+ return Builder.isBrowser && getCookie(name);
2625
2621
  };
2626
- Builder.prototype.setCookie = function (name$$1, value, expires) {
2622
+ Builder.prototype.setCookie = function (name, value, expires) {
2627
2623
  if (this.cookies && !(Builder.isServer && Builder.isStatic)) {
2628
- return this.cookies.set(name$$1, value, {
2624
+ return this.cookies.set(name, value, {
2629
2625
  expires: expires,
2630
2626
  secure: this.getLocation().protocol === 'https:',
2631
2627
  });
2632
2628
  }
2633
- return Builder.isBrowser && setCookie(name$$1, value, expires);
2629
+ return Builder.isBrowser && setCookie(name, value, expires);
2634
2630
  };
2635
2631
  Builder.prototype.getContent = function (modelName, options) {
2636
2632
  if (options === void 0) { options = {}; }
@@ -2713,14 +2709,14 @@
2713
2709
  var builder = new Builder(null, undefined, undefined, true);
2714
2710
  Builder.singletonInstance = builder;
2715
2711
 
2712
+ exports.BehaviorSubject = BehaviorSubject;
2716
2713
  exports.Builder = Builder;
2717
2714
  exports.BuilderComponent = BuilderComponent;
2718
- exports.isBrowser = isBrowser;
2719
- exports.BehaviorSubject = BehaviorSubject;
2720
2715
  exports.Subscription = Subscription;
2721
2716
  exports.builder = builder;
2717
+ exports.isBrowser = isBrowser;
2722
2718
 
2723
2719
  Object.defineProperty(exports, '__esModule', { value: true });
2724
2720
 
2725
- })));
2721
+ }));
2726
2722
  //# sourceMappingURL=index.umd.js.map