@builder.io/sdk 1.1.33 → 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.cjs.js CHANGED
@@ -129,7 +129,7 @@ function assertAllowedPropertyName(name) {
129
129
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
130
130
  }
131
131
 
132
- var version = "1.1.32";
132
+ var version = "1.1.34-0";
133
133
 
134
134
  var Subscription = /** @class */ (function () {
135
135
  function Subscription(listeners, listener) {
@@ -456,17 +456,27 @@ function tinyFetch(url, options) {
456
456
  }
457
457
  });
458
458
  }
459
- var fetch;
460
- // If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it.
461
- if (globalThis.fetch) {
462
- fetch = globalThis.fetch;
463
- }
464
- // If fetch is not defined, in a Node.js environment, use node-fetch.
465
- if (typeof window === 'undefined') {
466
- fetch !== null && fetch !== void 0 ? fetch : (fetch = serverOnlyRequire$1('node-fetch'));
467
- }
468
- // Otherwise, use tiny-fetch.
469
- fetch !== null && fetch !== void 0 ? fetch : (fetch = tinyFetch);
459
+ function getFetch() {
460
+ // If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it.
461
+ var _fetch = fetch;
462
+ if (globalThis.fetch) {
463
+ _fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = globalThis.fetch);
464
+ }
465
+ else if (typeof window === 'undefined') {
466
+ // If fetch is not defined, in a Node.js environment, use node-fetch.
467
+ try {
468
+ // node-fetch@^3 is ESM only, and will throw error on require.
469
+ _fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = serverOnlyRequire$1('node-fetch'));
470
+ }
471
+ catch (e) {
472
+ // If node-fetch is not installed, use tiny-fetch.
473
+ console.warn('node-fetch is not installed. consider polyfilling fetch or installing node-fetch.');
474
+ console.warn(e);
475
+ }
476
+ }
477
+ // Otherwise, use tiny-fetch.
478
+ return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch;
479
+ }
470
480
 
471
481
  function assign(target) {
472
482
  var args = [];
@@ -1423,7 +1433,7 @@ var Builder = /** @class */ (function () {
1423
1433
  Object.assign(event_1.data.metadata.user, fullUserAttributes, event_1.data.metadata.user);
1424
1434
  }
1425
1435
  var host = this.host;
1426
- fetch("".concat(host, "/api/v1/track"), {
1436
+ getFetch()("".concat(host, "/api/v1/track"), {
1427
1437
  method: 'POST',
1428
1438
  body: JSON.stringify({ events: events }),
1429
1439
  headers: {
@@ -2194,7 +2204,7 @@ var Builder = /** @class */ (function () {
2194
2204
  // even though we only use `fetch()` now, we prefer to keep the old behavior and use the `fetch` that comes from
2195
2205
  // the core SDK for consistency
2196
2206
  Builder.prototype.requestUrl = function (url, options) {
2197
- return fetch(url, options).then(function (res) { return res.json(); });
2207
+ return getFetch()(url, options).then(function (res) { return res.json(); });
2198
2208
  };
2199
2209
  Object.defineProperty(Builder.prototype, "host", {
2200
2210
  get: function () {
@@ -2360,7 +2370,7 @@ var Builder = /** @class */ (function () {
2360
2370
  var fn = format === 'solid' || format === 'react' ? 'codegen' : 'query';
2361
2371
  var url = "".concat(host, "/api/v1/").concat(fn, "/").concat(this.apiKey, "/").concat(keyNames) +
2362
2372
  (queryParams && hasParams ? "?".concat(queryStr) : '');
2363
- var promise = fetch(url, requestOptions)
2373
+ var promise = getFetch()(url, requestOptions)
2364
2374
  .then(function (res) { return res.json(); })
2365
2375
  .then(function (result) {
2366
2376
  for (var _i = 0, queue_3 = queue; _i < queue_3.length; _i++) {