@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.js CHANGED
@@ -5,7 +5,7 @@ import { BaseError } from 'make-error';
5
5
  import { map, filter } from 'rxjs/operators';
6
6
  import polyfilledEventSource from '@sanity/eventsource';
7
7
  var name = "@sanity/client";
8
- var version = "5.0.0-esm.3";
8
+ var version = "5.0.0-esm.4";
9
9
  const middleware = [debug({
10
10
  verbose: true,
11
11
  namespace: "sanity:client"
@@ -1283,7 +1283,8 @@ var __privateSet = (obj, member, value, setter) => {
1283
1283
  };
1284
1284
  var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1285
1285
  const _ObservableSanityClient = class {
1286
- constructor(httpRequest, config) {
1286
+ constructor(httpRequest) {
1287
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1287
1288
  __privateAdd(this, _clientConfig, void 0);
1288
1289
  __privateAdd(this, _httpRequest, void 0);
1289
1290
  this.config(config);
@@ -1354,11 +1355,11 @@ let ObservableSanityClient = _ObservableSanityClient;
1354
1355
  _clientConfig = new WeakMap();
1355
1356
  _httpRequest = new WeakMap();
1356
1357
  const _SanityClient = class {
1357
- constructor(httpRequest, config) {
1358
+ constructor(httpRequest) {
1359
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1358
1360
  __privateAdd(this, _clientConfig2, void 0);
1359
1361
  __privateAdd(this, _httpRequest2, void 0);
1360
1362
  this.listen = _listen;
1361
- this.observable = new ObservableSanityClient(httpRequest, config);
1362
1363
  this.config(config);
1363
1364
  __privateSet(this, _httpRequest2, httpRequest);
1364
1365
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
@@ -1366,6 +1367,7 @@ const _SanityClient = class {
1366
1367
  this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
1367
1368
  this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
1368
1369
  this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
1370
+ this.observable = new ObservableSanityClient(httpRequest, config);
1369
1371
  }
1370
1372
  clone() {
1371
1373
  return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
@@ -1379,7 +1381,9 @@ const _SanityClient = class {
1379
1381
  if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
1380
1382
  throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
1381
1383
  }
1382
- this.observable.config(newConfig);
1384
+ if (this.observable) {
1385
+ this.observable.config(newConfig);
1386
+ }
1383
1387
  __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
1384
1388
  return this;
1385
1389
  }
@@ -1432,8 +1436,6 @@ _clientConfig2 = new WeakMap();
1432
1436
  _httpRequest2 = new WeakMap();
1433
1437
  const httpRequest = defineHttpRequest(middleware);
1434
1438
  const requester = httpRequest.defaultRequester;
1435
- function createClient(config) {
1436
- return new SanityClient(httpRequest, config);
1437
- }
1439
+ const createClient = config => new SanityClient(httpRequest, config);
1438
1440
  export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, requester };
1439
1441
  //# sourceMappingURL=index.js.map