@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.esm.js CHANGED
@@ -950,7 +950,7 @@ function toError(err) {
950
950
 
951
951
  var DEFAULT_API_VERSION = 'v3';
952
952
 
953
- var SDK_VERSION = '4.0.2';
953
+ var SDK_VERSION = '4.0.3';
954
954
 
955
955
  function datePlusMinutes(minutes) {
956
956
  if (minutes === void 0) { minutes = 30; }
@@ -1350,7 +1350,9 @@ var Builder = /** @class */ (function () {
1350
1350
  // 1. `function name(args) => {code}`
1351
1351
  // 2. `name(args) => {code}`
1352
1352
  // 3. `(args) => {}`
1353
- var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
1353
+ // 4. `args => {}`
1354
+ var isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
1355
+ var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
1354
1356
  return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
1355
1357
  };
1356
1358
  return JSON.parse(JSON.stringify(info, function (key, value) {
@@ -2116,8 +2118,14 @@ var Builder = /** @class */ (function () {
2116
2118
  assign(this.trackingUserAttributes, attributes);
2117
2119
  };
2118
2120
  Builder.prototype.get = function (modelName, options) {
2121
+ var _a;
2119
2122
  if (options === void 0) { options = {}; }
2120
2123
  var instance = this;
2124
+ var finalLocale = options.locale || ((_a = options.userAttributes) === null || _a === void 0 ? void 0 : _a.locale) || this.getUserAttributes().locale;
2125
+ var finalOptions = __assign(__assign({}, options), (finalLocale && {
2126
+ locale: String(finalLocale),
2127
+ userAttributes: __assign({ locale: String(finalLocale) }, options.userAttributes),
2128
+ }));
2121
2129
  if (!Builder.isBrowser) {
2122
2130
  instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
2123
2131
  instance.setUserAttributes(this.getUserAttributes());
@@ -2135,7 +2143,7 @@ var Builder = /** @class */ (function () {
2135
2143
  this.apiVersion = options.apiVersion;
2136
2144
  }
2137
2145
  }
2138
- return instance.queueGetContent(modelName, options).map(
2146
+ return instance.queueGetContent(modelName, finalOptions).map(
2139
2147
  /* map( */ function (matches) {
2140
2148
  var match = matches && matches[0];
2141
2149
  if (Builder.isStatic) {
@@ -2343,9 +2351,9 @@ var Builder = /** @class */ (function () {
2343
2351
  if (queue[0].sort) {
2344
2352
  queryParams.sort = queue[0].sort;
2345
2353
  }
2346
- var pageQueryParams = typeof location !== 'undefined'
2354
+ var pageQueryParams = (typeof location !== 'undefined'
2347
2355
  ? QueryString.parseDeep(location.search.substr(1))
2348
- : {}; // TODO: WHAT about SSR (this.request) ?
2356
+ : undefined) || {}; // TODO: WHAT about SSR (this.request) ?
2349
2357
  var userAttributes =
2350
2358
  // FIXME: HACK: only checks first in queue for user attributes overrides, should check all
2351
2359
  // TODO: merge user attributes provided here with defaults and current user attiributes (?)