@builder.io/sdk 1.1.34-0 → 1.1.34-1

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
@@ -123,7 +123,7 @@ function assertAllowedPropertyName(name) {
123
123
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
124
124
  }
125
125
 
126
- var version = "1.1.33";
126
+ var version = "1.1.34-0";
127
127
 
128
128
  var Subscription = /** @class */ (function () {
129
129
  function Subscription(listeners, listener) {
@@ -450,17 +450,27 @@ function tinyFetch(url, options) {
450
450
  }
451
451
  });
452
452
  }
453
- var fetch;
454
- // If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it.
455
- if (globalThis.fetch) {
456
- fetch = globalThis.fetch;
457
- }
458
- // If fetch is not defined, in a Node.js environment, use node-fetch.
459
- if (typeof window === 'undefined') {
460
- fetch !== null && fetch !== void 0 ? fetch : (fetch = serverOnlyRequire$1('node-fetch'));
461
- }
462
- // Otherwise, use tiny-fetch.
463
- fetch !== null && fetch !== void 0 ? fetch : (fetch = tinyFetch);
453
+ function getFetch() {
454
+ // If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it.
455
+ var _fetch = fetch;
456
+ if (globalThis.fetch) {
457
+ _fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = globalThis.fetch);
458
+ }
459
+ else if (typeof window === 'undefined') {
460
+ // If fetch is not defined, in a Node.js environment, use node-fetch.
461
+ try {
462
+ // node-fetch@^3 is ESM only, and will throw error on require.
463
+ _fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = serverOnlyRequire$1('node-fetch'));
464
+ }
465
+ catch (e) {
466
+ // If node-fetch is not installed, use tiny-fetch.
467
+ console.warn('node-fetch is not installed. consider polyfilling fetch or installing node-fetch.');
468
+ console.warn(e);
469
+ }
470
+ }
471
+ // Otherwise, use tiny-fetch.
472
+ return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch;
473
+ }
464
474
 
465
475
  function assign(target) {
466
476
  var args = [];
@@ -1417,7 +1427,7 @@ var Builder = /** @class */ (function () {
1417
1427
  Object.assign(event_1.data.metadata.user, fullUserAttributes, event_1.data.metadata.user);
1418
1428
  }
1419
1429
  var host = this.host;
1420
- fetch("".concat(host, "/api/v1/track"), {
1430
+ getFetch()("".concat(host, "/api/v1/track"), {
1421
1431
  method: 'POST',
1422
1432
  body: JSON.stringify({ events: events }),
1423
1433
  headers: {
@@ -2188,7 +2198,7 @@ var Builder = /** @class */ (function () {
2188
2198
  // even though we only use `fetch()` now, we prefer to keep the old behavior and use the `fetch` that comes from
2189
2199
  // the core SDK for consistency
2190
2200
  Builder.prototype.requestUrl = function (url, options) {
2191
- return fetch(url, options).then(function (res) { return res.json(); });
2201
+ return getFetch()(url, options).then(function (res) { return res.json(); });
2192
2202
  };
2193
2203
  Object.defineProperty(Builder.prototype, "host", {
2194
2204
  get: function () {
@@ -2354,7 +2364,7 @@ var Builder = /** @class */ (function () {
2354
2364
  var fn = format === 'solid' || format === 'react' ? 'codegen' : 'query';
2355
2365
  var url = "".concat(host, "/api/v1/").concat(fn, "/").concat(this.apiKey, "/").concat(keyNames) +
2356
2366
  (queryParams && hasParams ? "?".concat(queryStr) : '');
2357
- var promise = fetch(url, requestOptions)
2367
+ var promise = getFetch()(url, requestOptions)
2358
2368
  .then(function (res) { return res.json(); })
2359
2369
  .then(function (result) {
2360
2370
  for (var _i = 0, queue_3 = queue; _i < queue_3.length; _i++) {