@sanity/client 5.0.0-esm.3 → 5.0.0-esm.4

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 CHANGED
@@ -16,7 +16,7 @@ function _interopDefaultCompat(e) {
16
16
  }
17
17
  var polyfilledEventSource__default = /*#__PURE__*/_interopDefaultCompat(polyfilledEventSource);
18
18
  var name = "@sanity/client";
19
- var version = "5.0.0-esm.3";
19
+ var version = "5.0.0-esm.4";
20
20
  const middleware = [middleware$1.debug({
21
21
  verbose: true,
22
22
  namespace: "sanity:client"
@@ -1294,7 +1294,8 @@ var __privateSet = (obj, member, value, setter) => {
1294
1294
  };
1295
1295
  var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1296
1296
  const _ObservableSanityClient = class {
1297
- constructor(httpRequest, config) {
1297
+ constructor(httpRequest) {
1298
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1298
1299
  __privateAdd(this, _clientConfig, void 0);
1299
1300
  __privateAdd(this, _httpRequest, void 0);
1300
1301
  this.config(config);
@@ -1365,11 +1366,11 @@ let ObservableSanityClient = _ObservableSanityClient;
1365
1366
  _clientConfig = new WeakMap();
1366
1367
  _httpRequest = new WeakMap();
1367
1368
  const _SanityClient = class {
1368
- constructor(httpRequest, config) {
1369
+ constructor(httpRequest) {
1370
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1369
1371
  __privateAdd(this, _clientConfig2, void 0);
1370
1372
  __privateAdd(this, _httpRequest2, void 0);
1371
1373
  this.listen = _listen;
1372
- this.observable = new ObservableSanityClient(httpRequest, config);
1373
1374
  this.config(config);
1374
1375
  __privateSet(this, _httpRequest2, httpRequest);
1375
1376
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
@@ -1377,6 +1378,7 @@ const _SanityClient = class {
1377
1378
  this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
1378
1379
  this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
1379
1380
  this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
1381
+ this.observable = new ObservableSanityClient(httpRequest, config);
1380
1382
  }
1381
1383
  clone() {
1382
1384
  return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
@@ -1390,7 +1392,9 @@ const _SanityClient = class {
1390
1392
  if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
1391
1393
  throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
1392
1394
  }
1393
- this.observable.config(newConfig);
1395
+ if (this.observable) {
1396
+ this.observable.config(newConfig);
1397
+ }
1394
1398
  __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
1395
1399
  return this;
1396
1400
  }
@@ -1443,9 +1447,7 @@ _clientConfig2 = new WeakMap();
1443
1447
  _httpRequest2 = new WeakMap();
1444
1448
  const httpRequest = defineHttpRequest(middleware);
1445
1449
  const requester = httpRequest.defaultRequester;
1446
- function createClient(config) {
1447
- return new SanityClient(httpRequest, config);
1448
- }
1450
+ const createClient = config => new SanityClient(httpRequest, config);
1449
1451
  exports.BasePatch = BasePatch;
1450
1452
  exports.BaseTransaction = BaseTransaction;
1451
1453
  exports.ClientError = ClientError;