@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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class } from './src/builder.class';
2
- export { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class };
3
- export { BehaviorSubject, Subscription } from './src/classes/observable.class';
4
- export { BuilderElement } from './src/types/element';
5
- export { BuilderContent, BuilderContentVariation } from './src/types/content';
6
- export { ApiVersion } from './src/types/api-version';
7
- export { builder } from './src/constants/builder';
1
+ import { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class } from './src/builder.class';
2
+ export { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class };
3
+ export { BehaviorSubject, Subscription } from './src/classes/observable.class';
4
+ export { BuilderElement } from './src/types/element';
5
+ export { BuilderContent, BuilderContentVariation } from './src/types/content';
6
+ export { ApiVersion } from './src/types/api-version';
7
+ export { builder } from './src/constants/builder';
package/dist/index.esm.js CHANGED
@@ -16,21 +16,16 @@ import hash from 'hash-sum';
16
16
 
17
17
  var isSafari = typeof window !== 'undefined' &&
18
18
  /^((?!chrome|android).)*safari/i.test(window.navigator.userAgent);
19
+ var isClient = typeof window !== 'undefined';
19
20
  // TODO: queue all of these in a debounceNextTick
20
21
  function nextTick(fn) {
21
- // React native
22
- if (typeof setImmediate === 'function' && typeof window === 'undefined') {
23
- return setImmediate(fn);
24
- }
25
- // TODO: should this be setImmediate instead? Forgot if that is micro or macro task
26
- // TODO: detect specifically if is server
27
22
  // if (typeof process !== 'undefined' && process.nextTick) {
28
23
  // console.log('process.nextTick?');
29
24
  // process.nextTick(fn);
30
25
  // return;
31
26
  // }
32
27
  // FIXME: fix the real safari issue of this randomly not working
33
- if (isSafari || typeof MutationObserver === 'undefined') {
28
+ if (!isClient || isSafari || typeof MutationObserver === 'undefined') {
34
29
  setTimeout(fn);
35
30
  return;
36
31
  }
@@ -123,7 +118,7 @@ function assertAllowedPropertyName(name) {
123
118
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
124
119
  }
125
120
 
126
- var version = "2.0.5";
121
+ var version = "2.0.7";
127
122
 
128
123
  var Subscription = /** @class */ (function () {
129
124
  function Subscription(listeners, listener) {
@@ -482,10 +477,6 @@ function getFetch() {
482
477
  }
483
478
 
484
479
  function assign(target) {
485
- var args = [];
486
- for (var _i = 1; _i < arguments.length; _i++) {
487
- args[_i - 1] = arguments[_i];
488
- }
489
480
  var to = Object(target);
490
481
  for (var index = 1; index < arguments.length; index++) {
491
482
  var nextSource = arguments[index];
@@ -926,7 +917,7 @@ function emptyUrl() {
926
917
  }
927
918
  // Replacement for `url.parse` using `URL` global object that works with relative paths.
928
919
  // Assumptions: this function operates in a NodeJS environment.
929
- function parse(url) {
920
+ function parse$1(url) {
930
921
  var out = emptyUrl();
931
922
  var u;
932
923
  var pathOnly = url === '' || url[0] === '/';
@@ -1036,12 +1027,12 @@ var urlParser = {
1036
1027
  return out;
1037
1028
  },
1038
1029
  };
1039
- var parse$1 = isReactNative
1030
+ var parse = isReactNative
1040
1031
  ? function () { return emptyUrl(); }
1041
1032
  : typeof window === 'object'
1042
1033
  ? urlParser.parse
1043
- : parse;
1044
- function setCookie(name$$1, value, expires) {
1034
+ : parse$1;
1035
+ function setCookie(name, value, expires) {
1045
1036
  try {
1046
1037
  var expiresString = '';
1047
1038
  // TODO: need to know if secure server side
@@ -1050,7 +1041,7 @@ function setCookie(name$$1, value, expires) {
1050
1041
  }
1051
1042
  var secure = isBrowser ? location.protocol === 'https:' : true;
1052
1043
  document.cookie =
1053
- name$$1 +
1044
+ name +
1054
1045
  '=' +
1055
1046
  (value || '') +
1056
1047
  expiresString +
@@ -1062,10 +1053,10 @@ function setCookie(name$$1, value, expires) {
1062
1053
  console.warn('Could not set cookie', err);
1063
1054
  }
1064
1055
  }
1065
- function getCookie(name$$1) {
1056
+ function getCookie(name) {
1066
1057
  try {
1067
1058
  return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
1068
- encodeURIComponent(name$$1).replace(/[\-\.\+\*]/g, '\\$&') +
1059
+ encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') +
1069
1060
  '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
1070
1061
  }
1071
1062
  catch (err) {
@@ -1295,11 +1286,11 @@ var Builder = /** @class */ (function () {
1295
1286
  throw new Error("Action not found: ".concat(action));
1296
1287
  }
1297
1288
  };
1298
- Builder.fields = function (name$$1, fields) {
1289
+ Builder.fields = function (name, fields) {
1299
1290
  var _a;
1300
1291
  (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
1301
1292
  type: 'builder.fields',
1302
- data: { name: name$$1, fields: fields },
1293
+ data: { name: name, fields: fields },
1303
1294
  }, '*');
1304
1295
  };
1305
1296
  /**
@@ -1792,7 +1783,7 @@ var Builder = /** @class */ (function () {
1792
1783
  var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1793
1784
  var builder = params.builder;
1794
1785
  if (builder) {
1795
- 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;
1786
+ 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;
1796
1787
  if (userAttributes) {
1797
1788
  this.setUserAttributes(userAttributes);
1798
1789
  }
@@ -1840,7 +1831,7 @@ var Builder = /** @class */ (function () {
1840
1831
  if (isBrowser) {
1841
1832
  addEventListener('message', function (event) {
1842
1833
  var _a, _b, _c, _d, _e;
1843
- var url = parse$1(event.origin);
1834
+ var url = parse(event.origin);
1844
1835
  var isRestricted = ['builder.register', 'builder.registerComponent'].indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === -1;
1845
1836
  var isTrusted = url.hostname && Builder.isTrustedHost(url.hostname);
1846
1837
  if (isRestricted && !isTrusted) {
@@ -2059,11 +2050,11 @@ var Builder = /** @class */ (function () {
2059
2050
  var parsedLocation = {};
2060
2051
  // in ssr mode
2061
2052
  if (this.request) {
2062
- parsedLocation = parse$1((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2053
+ parsedLocation = parse((_a = this.request.url) !== null && _a !== void 0 ? _a : '');
2063
2054
  }
2064
2055
  else if (typeof location === 'object') {
2065
2056
  // in the browser
2066
- parsedLocation = parse$1(location.href);
2057
+ parsedLocation = parse(location.href);
2067
2058
  }
2068
2059
  // IE11 bug with parsed path being empty string
2069
2060
  // causes issues with our user targeting
@@ -2307,7 +2298,7 @@ var Builder = /** @class */ (function () {
2307
2298
  }
2308
2299
  var pageQueryParams = typeof location !== 'undefined'
2309
2300
  ? QueryString.parseDeep(location.search.substr(1))
2310
- : undefined || {};
2301
+ : {};
2311
2302
  var userAttributes =
2312
2303
  // FIXME: HACK: only checks first in queue for user attributes overrides, should check all
2313
2304
  // TODO: merge user attributes provided here with defaults and current user attiributes (?)
@@ -2520,20 +2511,20 @@ var Builder = /** @class */ (function () {
2520
2511
  future.setDate(future.getDate() + 30);
2521
2512
  return this.setCookie("".concat(this.testCookiePrefix, ".").concat(contentId), variationId, future);
2522
2513
  };
2523
- Builder.prototype.getCookie = function (name$$1) {
2514
+ Builder.prototype.getCookie = function (name) {
2524
2515
  if (this.cookies) {
2525
- return this.cookies.get(name$$1);
2516
+ return this.cookies.get(name);
2526
2517
  }
2527
- return Builder.isBrowser && getCookie(name$$1);
2518
+ return Builder.isBrowser && getCookie(name);
2528
2519
  };
2529
- Builder.prototype.setCookie = function (name$$1, value, expires) {
2520
+ Builder.prototype.setCookie = function (name, value, expires) {
2530
2521
  if (this.cookies && !(Builder.isServer && Builder.isStatic)) {
2531
- return this.cookies.set(name$$1, value, {
2522
+ return this.cookies.set(name, value, {
2532
2523
  expires: expires,
2533
2524
  secure: this.getLocation().protocol === 'https:',
2534
2525
  });
2535
2526
  }
2536
- return Builder.isBrowser && setCookie(name$$1, value, expires);
2527
+ return Builder.isBrowser && setCookie(name, value, expires);
2537
2528
  };
2538
2529
  Builder.prototype.getContent = function (modelName, options) {
2539
2530
  if (options === void 0) { options = {}; }
@@ -2616,5 +2607,5 @@ var Builder = /** @class */ (function () {
2616
2607
  var builder = new Builder(null, undefined, undefined, true);
2617
2608
  Builder.singletonInstance = builder;
2618
2609
 
2619
- export { Builder, BuilderComponent, isBrowser, BehaviorSubject, Subscription, builder };
2610
+ export { BehaviorSubject, Builder, BuilderComponent, Subscription, builder, isBrowser };
2620
2611
  //# sourceMappingURL=index.esm.js.map