@builder.io/sdk 4.0.2 → 4.0.3

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.umd.js CHANGED
@@ -1052,7 +1052,7 @@
1052
1052
 
1053
1053
  var DEFAULT_API_VERSION = 'v3';
1054
1054
 
1055
- var SDK_VERSION = '4.0.2';
1055
+ var SDK_VERSION = '4.0.3';
1056
1056
 
1057
1057
  function datePlusMinutes(minutes) {
1058
1058
  if (minutes === void 0) { minutes = 30; }
@@ -1452,7 +1452,9 @@
1452
1452
  // 1. `function name(args) => {code}`
1453
1453
  // 2. `name(args) => {code}`
1454
1454
  // 3. `(args) => {}`
1455
- var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
1455
+ // 4. `args => {}`
1456
+ var isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
1457
+ var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
1456
1458
  return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
1457
1459
  };
1458
1460
  return JSON.parse(JSON.stringify(info, function (key, value) {
@@ -2218,8 +2220,14 @@
2218
2220
  assign(this.trackingUserAttributes, attributes);
2219
2221
  };
2220
2222
  Builder.prototype.get = function (modelName, options) {
2223
+ var _a;
2221
2224
  if (options === void 0) { options = {}; }
2222
2225
  var instance = this;
2226
+ var finalLocale = options.locale || ((_a = options.userAttributes) === null || _a === void 0 ? void 0 : _a.locale) || this.getUserAttributes().locale;
2227
+ var finalOptions = __assign(__assign({}, options), (finalLocale && {
2228
+ locale: String(finalLocale),
2229
+ userAttributes: __assign({ locale: String(finalLocale) }, options.userAttributes),
2230
+ }));
2223
2231
  if (!Builder.isBrowser) {
2224
2232
  instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
2225
2233
  instance.setUserAttributes(this.getUserAttributes());
@@ -2237,7 +2245,7 @@
2237
2245
  this.apiVersion = options.apiVersion;
2238
2246
  }
2239
2247
  }
2240
- return instance.queueGetContent(modelName, options).map(
2248
+ return instance.queueGetContent(modelName, finalOptions).map(
2241
2249
  /* map( */ function (matches) {
2242
2250
  var match = matches && matches[0];
2243
2251
  if (Builder.isStatic) {
@@ -2445,9 +2453,9 @@
2445
2453
  if (queue[0].sort) {
2446
2454
  queryParams.sort = queue[0].sort;
2447
2455
  }
2448
- var pageQueryParams = typeof location !== 'undefined'
2456
+ var pageQueryParams = (typeof location !== 'undefined'
2449
2457
  ? QueryString.parseDeep(location.search.substr(1))
2450
- : {}; // TODO: WHAT about SSR (this.request) ?
2458
+ : undefined) || {}; // TODO: WHAT about SSR (this.request) ?
2451
2459
  var userAttributes =
2452
2460
  // FIXME: HACK: only checks first in queue for user attributes overrides, should check all
2453
2461
  // TODO: merge user attributes provided here with defaults and current user attiributes (?)