@sanity/client 4.0.0-alpha.esm.6 → 4.0.0

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.
Files changed (68) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +23 -16
  3. package/dist/{browser/sanityClient.js → sanityClient.browser.mjs} +305 -1513
  4. package/dist/sanityClient.browser.mjs.map +7 -0
  5. package/index.js +7 -0
  6. package/lib/assets/assetsClient.js +100 -141
  7. package/lib/auth/authClient.js +20 -35
  8. package/lib/config.js +21 -43
  9. package/lib/data/dataMethods.js +32 -55
  10. package/lib/data/encodeQueryString.js +9 -15
  11. package/lib/data/listen.js +24 -53
  12. package/lib/data/patch.js +114 -167
  13. package/lib/data/transaction.js +95 -139
  14. package/lib/datasets/datasetsClient.js +31 -56
  15. package/lib/generateHelpUrl.js +11 -0
  16. package/lib/http/browserMiddleware.js +4 -3
  17. package/lib/http/errors.js +9 -15
  18. package/lib/http/nodeMiddleware.js +6 -10
  19. package/lib/http/queryString.js +4 -7
  20. package/lib/http/request.js +14 -28
  21. package/lib/http/requestOptions.js +7 -10
  22. package/lib/projects/projectsClient.js +19 -34
  23. package/lib/sanityClient.js +98 -153
  24. package/lib/users/usersClient.js +14 -27
  25. package/lib/util/defaults.js +6 -8
  26. package/lib/util/getSelection.js +3 -5
  27. package/lib/util/observable.js +0 -3
  28. package/lib/util/once.js +4 -6
  29. package/lib/util/pick.js +4 -6
  30. package/lib/validators.js +0 -26
  31. package/lib/warnings.js +9 -13
  32. package/package.json +49 -38
  33. package/sanityClient.d.ts +256 -99
  34. package/umd/sanityClient.js +165 -103
  35. package/umd/sanityClient.min.js +1 -1
  36. package/dist/node/sanityClient.js +0 -969
  37. package/src/assets/assetsClient.js +0 -132
  38. package/src/auth/authClient.js +0 -13
  39. package/src/config.js +0 -93
  40. package/src/data/dataMethods.js +0 -182
  41. package/src/data/encodeQueryString.js +0 -18
  42. package/src/data/listen.js +0 -159
  43. package/src/data/patch.js +0 -119
  44. package/src/data/transaction.js +0 -103
  45. package/src/datasets/datasetsClient.js +0 -28
  46. package/src/http/browserMiddleware.js +0 -1
  47. package/src/http/errors.js +0 -53
  48. package/src/http/nodeMiddleware.js +0 -11
  49. package/src/http/queryString.js +0 -10
  50. package/src/http/request.js +0 -50
  51. package/src/http/requestOptions.js +0 -29
  52. package/src/projects/projectsClient.js +0 -13
  53. package/src/sanityClient.js +0 -124
  54. package/src/users/usersClient.js +0 -9
  55. package/src/util/defaults.js +0 -9
  56. package/src/util/getSelection.js +0 -17
  57. package/src/util/observable.js +0 -6
  58. package/src/util/once.js +0 -12
  59. package/src/util/pick.js +0 -9
  60. package/src/validators.js +0 -76
  61. package/src/warnings.js +0 -25
  62. package/test/client.test.js +0 -2561
  63. package/test/encodeQueryString.test.js +0 -38
  64. package/test/fixtures/horsehead-nebula.jpg +0 -0
  65. package/test/fixtures/pdf-sample.pdf +0 -0
  66. package/test/helpers/sseServer.js +0 -27
  67. package/test/listen.test.js +0 -207
  68. package/test/warnings.test.disabled.js +0 -84
@@ -15,7 +15,10 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
20
+ mod
21
+ ));
19
22
 
20
23
  // node_modules/rxjs/internal/util/isFunction.js
21
24
  var require_isFunction = __commonJS({
@@ -900,29 +903,29 @@ var require_map = __commonJS({
900
903
  // node_modules/event-source-polyfill/src/eventsource.js
901
904
  var require_eventsource = __commonJS({
902
905
  "node_modules/event-source-polyfill/src/eventsource.js"(exports, module) {
903
- (function(global2) {
906
+ (function(global) {
904
907
  "use strict";
905
- var setTimeout2 = global2.setTimeout;
906
- var clearTimeout2 = global2.clearTimeout;
907
- var XMLHttpRequest2 = global2.XMLHttpRequest;
908
- var XDomainRequest2 = global2.XDomainRequest;
909
- var ActiveXObject = global2.ActiveXObject;
910
- var NativeEventSource = global2.EventSource;
911
- var document = global2.document;
912
- var Promise2 = global2.Promise;
913
- var fetch2 = global2.fetch;
914
- var Response = global2.Response;
915
- var TextDecoder = global2.TextDecoder;
916
- var TextEncoder = global2.TextEncoder;
917
- var AbortController2 = global2.AbortController;
908
+ var setTimeout2 = global.setTimeout;
909
+ var clearTimeout2 = global.clearTimeout;
910
+ var XMLHttpRequest = global.XMLHttpRequest;
911
+ var XDomainRequest = global.XDomainRequest;
912
+ var ActiveXObject = global.ActiveXObject;
913
+ var NativeEventSource = global.EventSource;
914
+ var document = global.document;
915
+ var Promise2 = global.Promise;
916
+ var fetch = global.fetch;
917
+ var Response = global.Response;
918
+ var TextDecoder = global.TextDecoder;
919
+ var TextEncoder = global.TextEncoder;
920
+ var AbortController = global.AbortController;
918
921
  if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) {
919
922
  document.readyState = "loading";
920
923
  window.addEventListener("load", function(event) {
921
924
  document.readyState = "complete";
922
925
  }, false);
923
926
  }
924
- if (XMLHttpRequest2 == null && ActiveXObject != null) {
925
- XMLHttpRequest2 = function() {
927
+ if (XMLHttpRequest == null && ActiveXObject != null) {
928
+ XMLHttpRequest = function() {
926
929
  return new ActiveXObject("Microsoft.XMLHTTP");
927
930
  };
928
931
  }
@@ -939,9 +942,9 @@ var require_eventsource = __commonJS({
939
942
  return new Date().getTime();
940
943
  };
941
944
  }
942
- if (AbortController2 == void 0) {
943
- var originalFetch2 = fetch2;
944
- fetch2 = function(url, options) {
945
+ if (AbortController == void 0) {
946
+ var originalFetch2 = fetch;
947
+ fetch = function(url, options) {
945
948
  var signal = options.signal;
946
949
  return originalFetch2(url, { headers: options.headers, credentials: options.credentials, cache: options.cache }).then(function(response) {
947
950
  var reader = response.body.getReader();
@@ -961,7 +964,7 @@ var require_eventsource = __commonJS({
961
964
  };
962
965
  });
963
966
  };
964
- AbortController2 = function() {
967
+ AbortController = function() {
965
968
  this.signal = {
966
969
  _reader: null,
967
970
  _aborted: false
@@ -1229,7 +1232,7 @@ var require_eventsource = __commonJS({
1229
1232
  onReadyStateChange(event);
1230
1233
  };
1231
1234
  }
1232
- if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest2.prototype)) {
1235
+ if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
1233
1236
  url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
1234
1237
  }
1235
1238
  xhr.open(method, url, true);
@@ -1255,7 +1258,7 @@ var require_eventsource = __commonJS({
1255
1258
  return this._xhr.getAllResponseHeaders != void 0 ? this._xhr.getAllResponseHeaders() || "" : "";
1256
1259
  };
1257
1260
  XHRWrapper.prototype.send = function() {
1258
- if ((!("ontimeout" in XMLHttpRequest2.prototype) || !("sendAsBinary" in XMLHttpRequest2.prototype) && !("mozAnon" in XMLHttpRequest2.prototype)) && document != void 0 && document.readyState != void 0 && document.readyState !== "complete") {
1261
+ if ((!("ontimeout" in XMLHttpRequest.prototype) || !("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype)) && document != void 0 && document.readyState != void 0 && document.readyState !== "complete") {
1259
1262
  var that = this;
1260
1263
  that._sendTimeout = setTimeout2(function() {
1261
1264
  that._sendTimeout = 0;
@@ -1293,8 +1296,8 @@ var require_eventsource = __commonJS({
1293
1296
  HeadersPolyfill.prototype.get = function(name) {
1294
1297
  return this._map[toLowerCase(name)];
1295
1298
  };
1296
- if (XMLHttpRequest2 != null && XMLHttpRequest2.HEADERS_RECEIVED == null) {
1297
- XMLHttpRequest2.HEADERS_RECEIVED = 2;
1299
+ if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) {
1300
+ XMLHttpRequest.HEADERS_RECEIVED = 2;
1298
1301
  }
1299
1302
  function XHRTransport() {
1300
1303
  }
@@ -1318,7 +1321,7 @@ var require_eventsource = __commonJS({
1318
1321
  onFinishCallback(null);
1319
1322
  };
1320
1323
  xhr.onreadystatechange = function() {
1321
- if (xhr.readyState === XMLHttpRequest2.HEADERS_RECEIVED) {
1324
+ if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
1322
1325
  var status = xhr.status;
1323
1326
  var statusText = xhr.statusText;
1324
1327
  var contentType = xhr.getResponseHeader("Content-Type");
@@ -1345,10 +1348,10 @@ var require_eventsource = __commonJS({
1345
1348
  }
1346
1349
  FetchTransport.prototype.open = function(xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
1347
1350
  var reader = null;
1348
- var controller = new AbortController2();
1351
+ var controller = new AbortController();
1349
1352
  var signal = controller.signal;
1350
1353
  var textDecoder = new TextDecoder();
1351
- fetch2(url, {
1354
+ fetch(url, {
1352
1355
  headers,
1353
1356
  credentials: withCredentials ? "include" : "same-origin",
1354
1357
  signal,
@@ -1520,9 +1523,9 @@ var require_eventsource = __commonJS({
1520
1523
  start(this, url, options);
1521
1524
  }
1522
1525
  function getBestXHRTransport() {
1523
- return XMLHttpRequest2 != void 0 && "withCredentials" in XMLHttpRequest2.prototype || XDomainRequest2 == void 0 ? new XMLHttpRequest2() : new XDomainRequest2();
1526
+ return XMLHttpRequest != void 0 && "withCredentials" in XMLHttpRequest.prototype || XDomainRequest == void 0 ? new XMLHttpRequest() : new XDomainRequest();
1524
1527
  }
1525
- var isFetchSupported = fetch2 != void 0 && Response != void 0 && "body" in Response.prototype;
1528
+ var isFetchSupported = fetch != void 0 && Response != void 0 && "body" in Response.prototype;
1526
1529
  function start(es, url, options) {
1527
1530
  url = String(url);
1528
1531
  var withCredentials = Boolean(options.withCredentials);
@@ -1787,7 +1790,7 @@ var require_eventsource = __commonJS({
1787
1790
  EventSourcePolyfill.CLOSED = CLOSED;
1788
1791
  EventSourcePolyfill.prototype.withCredentials = void 0;
1789
1792
  var R = NativeEventSource;
1790
- if (XMLHttpRequest2 != void 0 && (NativeEventSource == void 0 || !("withCredentials" in NativeEventSource.prototype))) {
1793
+ if (XMLHttpRequest != void 0 && (NativeEventSource == void 0 || !("withCredentials" in NativeEventSource.prototype))) {
1791
1794
  R = EventSourcePolyfill;
1792
1795
  }
1793
1796
  (function(factory) {
@@ -1798,7 +1801,7 @@ var require_eventsource = __commonJS({
1798
1801
  } else if (typeof define === "function" && define.amd) {
1799
1802
  define(["exports"], factory);
1800
1803
  } else {
1801
- factory(global2);
1804
+ factory(global);
1802
1805
  }
1803
1806
  })(function(exports2) {
1804
1807
  exports2.EventSourcePolyfill = EventSourcePolyfill;
@@ -1817,1257 +1820,6 @@ var require_browser = __commonJS({
1817
1820
  }
1818
1821
  });
1819
1822
 
1820
- // node_modules/nano-pubsub/index.js
1821
- var require_nano_pubsub = __commonJS({
1822
- "node_modules/nano-pubsub/index.js"(exports, module) {
1823
- module.exports = function Pubsub() {
1824
- var subscribers = [];
1825
- return {
1826
- subscribe,
1827
- publish
1828
- };
1829
- function subscribe(subscriber) {
1830
- subscribers.push(subscriber);
1831
- return function unsubscribe() {
1832
- var idx = subscribers.indexOf(subscriber);
1833
- if (idx > -1) {
1834
- subscribers.splice(idx, 1);
1835
- }
1836
- };
1837
- }
1838
- function publish() {
1839
- for (var i = 0; i < subscribers.length; i++) {
1840
- subscribers[i].apply(null, arguments);
1841
- }
1842
- }
1843
- };
1844
- }
1845
- });
1846
-
1847
- // node_modules/get-it/lib/util/middlewareReducer.js
1848
- var require_middlewareReducer = __commonJS({
1849
- "node_modules/get-it/lib/util/middlewareReducer.js"(exports, module) {
1850
- "use strict";
1851
- module.exports = function(middleware3) {
1852
- var applyMiddleware = function applyMiddleware2(hook, defaultValue) {
1853
- var bailEarly = hook === "onError";
1854
- var value = defaultValue;
1855
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1856
- args[_key - 2] = arguments[_key];
1857
- }
1858
- for (var i = 0; i < middleware3[hook].length; i++) {
1859
- var handler = middleware3[hook][i];
1860
- value = handler.apply(void 0, [value].concat(args));
1861
- if (bailEarly && !value) {
1862
- break;
1863
- }
1864
- }
1865
- return value;
1866
- };
1867
- return applyMiddleware;
1868
- };
1869
- }
1870
- });
1871
-
1872
- // node_modules/object-assign/index.js
1873
- var require_object_assign = __commonJS({
1874
- "node_modules/object-assign/index.js"(exports, module) {
1875
- "use strict";
1876
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1877
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1878
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
1879
- function toObject(val) {
1880
- if (val === null || val === void 0) {
1881
- throw new TypeError("Object.assign cannot be called with null or undefined");
1882
- }
1883
- return Object(val);
1884
- }
1885
- function shouldUseNative() {
1886
- try {
1887
- if (!Object.assign) {
1888
- return false;
1889
- }
1890
- var test1 = new String("abc");
1891
- test1[5] = "de";
1892
- if (Object.getOwnPropertyNames(test1)[0] === "5") {
1893
- return false;
1894
- }
1895
- var test2 = {};
1896
- for (var i = 0; i < 10; i++) {
1897
- test2["_" + String.fromCharCode(i)] = i;
1898
- }
1899
- var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
1900
- return test2[n];
1901
- });
1902
- if (order2.join("") !== "0123456789") {
1903
- return false;
1904
- }
1905
- var test3 = {};
1906
- "abcdefghijklmnopqrst".split("").forEach(function(letter) {
1907
- test3[letter] = letter;
1908
- });
1909
- if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
1910
- return false;
1911
- }
1912
- return true;
1913
- } catch (err) {
1914
- return false;
1915
- }
1916
- }
1917
- module.exports = shouldUseNative() ? Object.assign : function(target, source) {
1918
- var from;
1919
- var to = toObject(target);
1920
- var symbols;
1921
- for (var s = 1; s < arguments.length; s++) {
1922
- from = Object(arguments[s]);
1923
- for (var key in from) {
1924
- if (hasOwnProperty.call(from, key)) {
1925
- to[key] = from[key];
1926
- }
1927
- }
1928
- if (getOwnPropertySymbols) {
1929
- symbols = getOwnPropertySymbols(from);
1930
- for (var i = 0; i < symbols.length; i++) {
1931
- if (propIsEnumerable.call(from, symbols[i])) {
1932
- to[symbols[i]] = from[symbols[i]];
1933
- }
1934
- }
1935
- }
1936
- }
1937
- return to;
1938
- };
1939
- }
1940
- });
1941
-
1942
- // node_modules/requires-port/index.js
1943
- var require_requires_port = __commonJS({
1944
- "node_modules/requires-port/index.js"(exports, module) {
1945
- "use strict";
1946
- module.exports = function required(port, protocol) {
1947
- protocol = protocol.split(":")[0];
1948
- port = +port;
1949
- if (!port)
1950
- return false;
1951
- switch (protocol) {
1952
- case "http":
1953
- case "ws":
1954
- return port !== 80;
1955
- case "https":
1956
- case "wss":
1957
- return port !== 443;
1958
- case "ftp":
1959
- return port !== 21;
1960
- case "gopher":
1961
- return port !== 70;
1962
- case "file":
1963
- return false;
1964
- }
1965
- return port !== 0;
1966
- };
1967
- }
1968
- });
1969
-
1970
- // node_modules/querystringify/index.js
1971
- var require_querystringify = __commonJS({
1972
- "node_modules/querystringify/index.js"(exports) {
1973
- "use strict";
1974
- var has = Object.prototype.hasOwnProperty;
1975
- var undef;
1976
- function decode(input) {
1977
- try {
1978
- return decodeURIComponent(input.replace(/\+/g, " "));
1979
- } catch (e) {
1980
- return null;
1981
- }
1982
- }
1983
- function encode(input) {
1984
- try {
1985
- return encodeURIComponent(input);
1986
- } catch (e) {
1987
- return null;
1988
- }
1989
- }
1990
- function querystring(query) {
1991
- var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
1992
- while (part = parser.exec(query)) {
1993
- var key = decode(part[1]), value = decode(part[2]);
1994
- if (key === null || value === null || key in result)
1995
- continue;
1996
- result[key] = value;
1997
- }
1998
- return result;
1999
- }
2000
- function querystringify(obj, prefix) {
2001
- prefix = prefix || "";
2002
- var pairs = [], value, key;
2003
- if (typeof prefix !== "string")
2004
- prefix = "?";
2005
- for (key in obj) {
2006
- if (has.call(obj, key)) {
2007
- value = obj[key];
2008
- if (!value && (value === null || value === undef || isNaN(value))) {
2009
- value = "";
2010
- }
2011
- key = encode(key);
2012
- value = encode(value);
2013
- if (key === null || value === null)
2014
- continue;
2015
- pairs.push(key + "=" + value);
2016
- }
2017
- }
2018
- return pairs.length ? prefix + pairs.join("&") : "";
2019
- }
2020
- exports.stringify = querystringify;
2021
- exports.parse = querystring;
2022
- }
2023
- });
2024
-
2025
- // node_modules/url-parse/index.js
2026
- var require_url_parse = __commonJS({
2027
- "node_modules/url-parse/index.js"(exports, module) {
2028
- "use strict";
2029
- var required = require_requires_port();
2030
- var qs = require_querystringify();
2031
- var controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
2032
- var CRHTLF = /[\n\r\t]/g;
2033
- var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
2034
- var port = /:\d+$/;
2035
- var protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i;
2036
- var windowsDriveLetter = /^[a-zA-Z]:/;
2037
- function trimLeft(str) {
2038
- return (str ? str : "").toString().replace(controlOrWhitespace, "");
2039
- }
2040
- var rules = [
2041
- ["#", "hash"],
2042
- ["?", "query"],
2043
- function sanitize(address, url) {
2044
- return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
2045
- },
2046
- ["/", "pathname"],
2047
- ["@", "auth", 1],
2048
- [NaN, "host", void 0, 1, 1],
2049
- [/:(\d*)$/, "port", void 0, 1],
2050
- [NaN, "hostname", void 0, 1, 1]
2051
- ];
2052
- var ignore = { hash: 1, query: 1 };
2053
- function lolcation(loc) {
2054
- var globalVar;
2055
- if (typeof window !== "undefined")
2056
- globalVar = window;
2057
- else if (typeof global !== "undefined")
2058
- globalVar = global;
2059
- else if (typeof self !== "undefined")
2060
- globalVar = self;
2061
- else
2062
- globalVar = {};
2063
- var location = globalVar.location || {};
2064
- loc = loc || location;
2065
- var finaldestination = {}, type = typeof loc, key;
2066
- if (loc.protocol === "blob:") {
2067
- finaldestination = new Url(unescape(loc.pathname), {});
2068
- } else if (type === "string") {
2069
- finaldestination = new Url(loc, {});
2070
- for (key in ignore)
2071
- delete finaldestination[key];
2072
- } else if (type === "object") {
2073
- for (key in loc) {
2074
- if (key in ignore)
2075
- continue;
2076
- finaldestination[key] = loc[key];
2077
- }
2078
- if (finaldestination.slashes === void 0) {
2079
- finaldestination.slashes = slashes.test(loc.href);
2080
- }
2081
- }
2082
- return finaldestination;
2083
- }
2084
- function isSpecial(scheme) {
2085
- return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
2086
- }
2087
- function extractProtocol(address, location) {
2088
- address = trimLeft(address);
2089
- address = address.replace(CRHTLF, "");
2090
- location = location || {};
2091
- var match = protocolre.exec(address);
2092
- var protocol = match[1] ? match[1].toLowerCase() : "";
2093
- var forwardSlashes = !!match[2];
2094
- var otherSlashes = !!match[3];
2095
- var slashesCount = 0;
2096
- var rest;
2097
- if (forwardSlashes) {
2098
- if (otherSlashes) {
2099
- rest = match[2] + match[3] + match[4];
2100
- slashesCount = match[2].length + match[3].length;
2101
- } else {
2102
- rest = match[2] + match[4];
2103
- slashesCount = match[2].length;
2104
- }
2105
- } else {
2106
- if (otherSlashes) {
2107
- rest = match[3] + match[4];
2108
- slashesCount = match[3].length;
2109
- } else {
2110
- rest = match[4];
2111
- }
2112
- }
2113
- if (protocol === "file:") {
2114
- if (slashesCount >= 2) {
2115
- rest = rest.slice(2);
2116
- }
2117
- } else if (isSpecial(protocol)) {
2118
- rest = match[4];
2119
- } else if (protocol) {
2120
- if (forwardSlashes) {
2121
- rest = rest.slice(2);
2122
- }
2123
- } else if (slashesCount >= 2 && isSpecial(location.protocol)) {
2124
- rest = match[4];
2125
- }
2126
- return {
2127
- protocol,
2128
- slashes: forwardSlashes || isSpecial(protocol),
2129
- slashesCount,
2130
- rest
2131
- };
2132
- }
2133
- function resolve(relative, base) {
2134
- if (relative === "")
2135
- return base;
2136
- var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
2137
- while (i--) {
2138
- if (path[i] === ".") {
2139
- path.splice(i, 1);
2140
- } else if (path[i] === "..") {
2141
- path.splice(i, 1);
2142
- up++;
2143
- } else if (up) {
2144
- if (i === 0)
2145
- unshift = true;
2146
- path.splice(i, 1);
2147
- up--;
2148
- }
2149
- }
2150
- if (unshift)
2151
- path.unshift("");
2152
- if (last === "." || last === "..")
2153
- path.push("");
2154
- return path.join("/");
2155
- }
2156
- function Url(address, location, parser) {
2157
- address = trimLeft(address);
2158
- address = address.replace(CRHTLF, "");
2159
- if (!(this instanceof Url)) {
2160
- return new Url(address, location, parser);
2161
- }
2162
- var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
2163
- if (type !== "object" && type !== "string") {
2164
- parser = location;
2165
- location = null;
2166
- }
2167
- if (parser && typeof parser !== "function")
2168
- parser = qs.parse;
2169
- location = lolcation(location);
2170
- extracted = extractProtocol(address || "", location);
2171
- relative = !extracted.protocol && !extracted.slashes;
2172
- url.slashes = extracted.slashes || relative && location.slashes;
2173
- url.protocol = extracted.protocol || location.protocol || "";
2174
- address = extracted.rest;
2175
- if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
2176
- instructions[3] = [/(.*)/, "pathname"];
2177
- }
2178
- for (; i < instructions.length; i++) {
2179
- instruction = instructions[i];
2180
- if (typeof instruction === "function") {
2181
- address = instruction(address, url);
2182
- continue;
2183
- }
2184
- parse = instruction[0];
2185
- key = instruction[1];
2186
- if (parse !== parse) {
2187
- url[key] = address;
2188
- } else if (typeof parse === "string") {
2189
- index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
2190
- if (~index) {
2191
- if (typeof instruction[2] === "number") {
2192
- url[key] = address.slice(0, index);
2193
- address = address.slice(index + instruction[2]);
2194
- } else {
2195
- url[key] = address.slice(index);
2196
- address = address.slice(0, index);
2197
- }
2198
- }
2199
- } else if (index = parse.exec(address)) {
2200
- url[key] = index[1];
2201
- address = address.slice(0, index.index);
2202
- }
2203
- url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
2204
- if (instruction[4])
2205
- url[key] = url[key].toLowerCase();
2206
- }
2207
- if (parser)
2208
- url.query = parser(url.query);
2209
- if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
2210
- url.pathname = resolve(url.pathname, location.pathname);
2211
- }
2212
- if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
2213
- url.pathname = "/" + url.pathname;
2214
- }
2215
- if (!required(url.port, url.protocol)) {
2216
- url.host = url.hostname;
2217
- url.port = "";
2218
- }
2219
- url.username = url.password = "";
2220
- if (url.auth) {
2221
- index = url.auth.indexOf(":");
2222
- if (~index) {
2223
- url.username = url.auth.slice(0, index);
2224
- url.username = encodeURIComponent(decodeURIComponent(url.username));
2225
- url.password = url.auth.slice(index + 1);
2226
- url.password = encodeURIComponent(decodeURIComponent(url.password));
2227
- } else {
2228
- url.username = encodeURIComponent(decodeURIComponent(url.auth));
2229
- }
2230
- url.auth = url.password ? url.username + ":" + url.password : url.username;
2231
- }
2232
- url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
2233
- url.href = url.toString();
2234
- }
2235
- function set(part, value, fn) {
2236
- var url = this;
2237
- switch (part) {
2238
- case "query":
2239
- if (typeof value === "string" && value.length) {
2240
- value = (fn || qs.parse)(value);
2241
- }
2242
- url[part] = value;
2243
- break;
2244
- case "port":
2245
- url[part] = value;
2246
- if (!required(value, url.protocol)) {
2247
- url.host = url.hostname;
2248
- url[part] = "";
2249
- } else if (value) {
2250
- url.host = url.hostname + ":" + value;
2251
- }
2252
- break;
2253
- case "hostname":
2254
- url[part] = value;
2255
- if (url.port)
2256
- value += ":" + url.port;
2257
- url.host = value;
2258
- break;
2259
- case "host":
2260
- url[part] = value;
2261
- if (port.test(value)) {
2262
- value = value.split(":");
2263
- url.port = value.pop();
2264
- url.hostname = value.join(":");
2265
- } else {
2266
- url.hostname = value;
2267
- url.port = "";
2268
- }
2269
- break;
2270
- case "protocol":
2271
- url.protocol = value.toLowerCase();
2272
- url.slashes = !fn;
2273
- break;
2274
- case "pathname":
2275
- case "hash":
2276
- if (value) {
2277
- var char = part === "pathname" ? "/" : "#";
2278
- url[part] = value.charAt(0) !== char ? char + value : value;
2279
- } else {
2280
- url[part] = value;
2281
- }
2282
- break;
2283
- case "username":
2284
- case "password":
2285
- url[part] = encodeURIComponent(value);
2286
- break;
2287
- case "auth":
2288
- var index = value.indexOf(":");
2289
- if (~index) {
2290
- url.username = value.slice(0, index);
2291
- url.username = encodeURIComponent(decodeURIComponent(url.username));
2292
- url.password = value.slice(index + 1);
2293
- url.password = encodeURIComponent(decodeURIComponent(url.password));
2294
- } else {
2295
- url.username = encodeURIComponent(decodeURIComponent(value));
2296
- }
2297
- }
2298
- for (var i = 0; i < rules.length; i++) {
2299
- var ins = rules[i];
2300
- if (ins[4])
2301
- url[ins[1]] = url[ins[1]].toLowerCase();
2302
- }
2303
- url.auth = url.password ? url.username + ":" + url.password : url.username;
2304
- url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
2305
- url.href = url.toString();
2306
- return url;
2307
- }
2308
- function toString(stringify) {
2309
- if (!stringify || typeof stringify !== "function")
2310
- stringify = qs.stringify;
2311
- var query, url = this, host = url.host, protocol = url.protocol;
2312
- if (protocol && protocol.charAt(protocol.length - 1) !== ":")
2313
- protocol += ":";
2314
- var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
2315
- if (url.username) {
2316
- result += url.username;
2317
- if (url.password)
2318
- result += ":" + url.password;
2319
- result += "@";
2320
- } else if (url.password) {
2321
- result += ":" + url.password;
2322
- result += "@";
2323
- } else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
2324
- result += "@";
2325
- }
2326
- if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) {
2327
- host += ":";
2328
- }
2329
- result += host + url.pathname;
2330
- query = typeof url.query === "object" ? stringify(url.query) : url.query;
2331
- if (query)
2332
- result += query.charAt(0) !== "?" ? "?" + query : query;
2333
- if (url.hash)
2334
- result += url.hash;
2335
- return result;
2336
- }
2337
- Url.prototype = { set, toString };
2338
- Url.extractProtocol = extractProtocol;
2339
- Url.location = lolcation;
2340
- Url.trimLeft = trimLeft;
2341
- Url.qs = qs;
2342
- module.exports = Url;
2343
- }
2344
- });
2345
-
2346
- // node_modules/get-it/lib/middleware/defaultOptionsProcessor.js
2347
- var require_defaultOptionsProcessor = __commonJS({
2348
- "node_modules/get-it/lib/middleware/defaultOptionsProcessor.js"(exports, module) {
2349
- "use strict";
2350
- var objectAssign = require_object_assign();
2351
- var urlParse = require_url_parse();
2352
- var isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
2353
- var has = Object.prototype.hasOwnProperty;
2354
- var defaultOptions2 = {
2355
- timeout: isReactNative ? 6e4 : 12e4
2356
- };
2357
- module.exports = function(opts) {
2358
- var options = typeof opts === "string" ? objectAssign({
2359
- url: opts
2360
- }, defaultOptions2) : objectAssign({}, defaultOptions2, opts);
2361
- var url = urlParse(options.url, {}, true);
2362
- options.timeout = normalizeTimeout(options.timeout);
2363
- if (options.query) {
2364
- url.query = objectAssign({}, url.query, removeUndefined(options.query));
2365
- }
2366
- options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
2367
- options.url = url.toString(stringifyQueryString);
2368
- return options;
2369
- };
2370
- function stringifyQueryString(obj) {
2371
- var pairs = [];
2372
- for (var key in obj) {
2373
- if (has.call(obj, key)) {
2374
- push(key, obj[key]);
2375
- }
2376
- }
2377
- return pairs.length ? pairs.join("&") : "";
2378
- function push(key2, val) {
2379
- if (Array.isArray(val)) {
2380
- val.forEach(function(item) {
2381
- return push(key2, item);
2382
- });
2383
- } else {
2384
- pairs.push([key2, val].map(encodeURIComponent).join("="));
2385
- }
2386
- }
2387
- }
2388
- function normalizeTimeout(time) {
2389
- if (time === false || time === 0) {
2390
- return false;
2391
- }
2392
- if (time.connect || time.socket) {
2393
- return time;
2394
- }
2395
- var delay = Number(time);
2396
- if (isNaN(delay)) {
2397
- return normalizeTimeout(defaultOptions2.timeout);
2398
- }
2399
- return {
2400
- connect: delay,
2401
- socket: delay
2402
- };
2403
- }
2404
- function removeUndefined(obj) {
2405
- var target = {};
2406
- for (var key in obj) {
2407
- if (obj[key] !== void 0) {
2408
- target[key] = obj[key];
2409
- }
2410
- }
2411
- return target;
2412
- }
2413
- }
2414
- });
2415
-
2416
- // node_modules/get-it/lib/middleware/defaultOptionsValidator.js
2417
- var require_defaultOptionsValidator = __commonJS({
2418
- "node_modules/get-it/lib/middleware/defaultOptionsValidator.js"(exports, module) {
2419
- "use strict";
2420
- var validUrl = /^https?:\/\//i;
2421
- module.exports = function(options) {
2422
- if (!validUrl.test(options.url)) {
2423
- throw new Error('"'.concat(options.url, '" is not a valid URL'));
2424
- }
2425
- };
2426
- }
2427
- });
2428
-
2429
- // node_modules/same-origin/url-parser.js
2430
- var require_url_parser = __commonJS({
2431
- "node_modules/same-origin/url-parser.js"(exports, module) {
2432
- "use strict";
2433
- var regex = /^(?:(?:(?:([^:\/#\?]+:)?(?:(?:\/\/)((?:((?:[^:@\/#\?]+)(?:\:(?:[^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((?:\/?(?:[^\/\?#]+\/+)*)(?:[^\?#]*)))?(\?[^#]+)?)(#.*)?/;
2434
- module.exports = {
2435
- regex,
2436
- parse: function(url) {
2437
- var match = regex.exec(url);
2438
- if (!match) {
2439
- return {};
2440
- }
2441
- return {
2442
- protocol: (match[1] || "").toLowerCase() || void 0,
2443
- hostname: (match[5] || "").toLowerCase() || void 0,
2444
- port: match[6] || void 0
2445
- };
2446
- }
2447
- };
2448
- }
2449
- });
2450
-
2451
- // node_modules/same-origin/index.js
2452
- var require_same_origin = __commonJS({
2453
- "node_modules/same-origin/index.js"(exports, module) {
2454
- "use strict";
2455
- var url = require_url_parser();
2456
- module.exports = function(uri1, uri2, ieMode) {
2457
- if (uri1 === uri2) {
2458
- return true;
2459
- }
2460
- var url1 = url.parse(uri1, false, true);
2461
- var url2 = url.parse(uri2, false, true);
2462
- var url1Port = url1.port | 0 || (url1.protocol === "https" ? 443 : 80);
2463
- var url2Port = url2.port | 0 || (url2.protocol === "https" ? 443 : 80);
2464
- var match = {
2465
- proto: url1.protocol === url2.protocol,
2466
- hostname: url1.hostname === url2.hostname,
2467
- port: url1Port === url2Port
2468
- };
2469
- return match.proto && match.hostname && (match.port || ieMode);
2470
- };
2471
- }
2472
- });
2473
-
2474
- // node_modules/parse-headers/parse-headers.js
2475
- var require_parse_headers = __commonJS({
2476
- "node_modules/parse-headers/parse-headers.js"(exports, module) {
2477
- var trim = function(string) {
2478
- return string.replace(/^\s+|\s+$/g, "");
2479
- };
2480
- var isArray = function(arg) {
2481
- return Object.prototype.toString.call(arg) === "[object Array]";
2482
- };
2483
- module.exports = function(headers) {
2484
- if (!headers)
2485
- return {};
2486
- var result = {};
2487
- var headersArr = trim(headers).split("\n");
2488
- for (var i = 0; i < headersArr.length; i++) {
2489
- var row = headersArr[i];
2490
- var index = row.indexOf(":"), key = trim(row.slice(0, index)).toLowerCase(), value = trim(row.slice(index + 1));
2491
- if (typeof result[key] === "undefined") {
2492
- result[key] = value;
2493
- } else if (isArray(result[key])) {
2494
- result[key].push(value);
2495
- } else {
2496
- result[key] = [result[key], value];
2497
- }
2498
- }
2499
- return result;
2500
- };
2501
- }
2502
- });
2503
-
2504
- // node_modules/get-it/lib/request/browser/fetchXhr.js
2505
- var require_fetchXhr = __commonJS({
2506
- "node_modules/get-it/lib/request/browser/fetchXhr.js"(exports, module) {
2507
- "use strict";
2508
- function FetchXhr() {
2509
- this.readyState = 0;
2510
- }
2511
- FetchXhr.prototype.open = function(method, url) {
2512
- this._method = method;
2513
- this._url = url;
2514
- this._resHeaders = "";
2515
- this.readyState = 1;
2516
- this.onreadystatechange();
2517
- };
2518
- FetchXhr.prototype.abort = function() {
2519
- if (this._controller) {
2520
- this._controller.abort();
2521
- }
2522
- };
2523
- FetchXhr.prototype.getAllResponseHeaders = function() {
2524
- return this._resHeaders;
2525
- };
2526
- FetchXhr.prototype.setRequestHeader = function(key, value) {
2527
- this._headers = this._headers || {};
2528
- this._headers[key] = value;
2529
- };
2530
- FetchXhr.prototype.send = function(body) {
2531
- var _this = this;
2532
- var ctrl = this._controller = typeof AbortController === "function" && new AbortController();
2533
- var textBody = this.responseType !== "arraybuffer";
2534
- var options = {
2535
- method: this._method,
2536
- headers: this._headers,
2537
- signal: ctrl && ctrl.signal,
2538
- body
2539
- };
2540
- if (typeof window !== "undefined") {
2541
- options.credentials = this.withCredentials ? "include" : "omit";
2542
- }
2543
- fetch(this._url, options).then(function(res) {
2544
- res.headers.forEach(function(value, key) {
2545
- _this._resHeaders += "".concat(key, ": ").concat(value, "\r\n");
2546
- });
2547
- _this.status = res.status;
2548
- _this.statusText = res.statusText;
2549
- _this.readyState = 3;
2550
- return textBody ? res.text() : res.arrayBuffer();
2551
- }).then(function(resBody) {
2552
- if (textBody) {
2553
- _this.responseText = resBody;
2554
- } else {
2555
- _this.response = resBody;
2556
- }
2557
- _this.readyState = 4;
2558
- _this.onreadystatechange();
2559
- }).catch(function(err) {
2560
- if (err.name === "AbortError") {
2561
- _this.onabort();
2562
- return;
2563
- }
2564
- _this.onerror(err);
2565
- });
2566
- };
2567
- module.exports = FetchXhr;
2568
- }
2569
- });
2570
-
2571
- // node_modules/get-it/lib/request/browser-request.js
2572
- var require_browser_request = __commonJS({
2573
- "node_modules/get-it/lib/request/browser-request.js"(exports, module) {
2574
- "use strict";
2575
- var sameOrigin = require_same_origin();
2576
- var parseHeaders = require_parse_headers();
2577
- var FetchXhr = require_fetchXhr();
2578
- var noop = function noop2() {
2579
- };
2580
- var win = typeof window === "undefined" ? void 0 : window;
2581
- var adapter = win ? "xhr" : "fetch";
2582
- var XmlHttpRequest = typeof XMLHttpRequest === "function" ? XMLHttpRequest : noop;
2583
- var hasXhr2 = "withCredentials" in new XmlHttpRequest();
2584
- var XDR = typeof XDomainRequest === "undefined" ? void 0 : XDomainRequest;
2585
- var CrossDomainRequest = hasXhr2 ? XmlHttpRequest : XDR;
2586
- if (!win) {
2587
- XmlHttpRequest = FetchXhr;
2588
- CrossDomainRequest = FetchXhr;
2589
- }
2590
- module.exports = function(context, callback) {
2591
- var opts = context.options;
2592
- var options = context.applyMiddleware("finalizeOptions", opts);
2593
- var timers = {};
2594
- var cors = win && win.location && !sameOrigin(win.location.href, options.url);
2595
- var injectedResponse = context.applyMiddleware("interceptRequest", void 0, {
2596
- adapter,
2597
- context
2598
- });
2599
- if (injectedResponse) {
2600
- var cbTimer = setTimeout(callback, 0, null, injectedResponse);
2601
- var cancel = function cancel2() {
2602
- return clearTimeout(cbTimer);
2603
- };
2604
- return {
2605
- abort: cancel
2606
- };
2607
- }
2608
- var xhr = cors ? new CrossDomainRequest() : new XmlHttpRequest();
2609
- var isXdr = win && win.XDomainRequest && xhr instanceof win.XDomainRequest;
2610
- var headers = options.headers;
2611
- var delays = options.timeout;
2612
- var aborted = false;
2613
- var loaded = false;
2614
- var timedOut = false;
2615
- xhr.onerror = onError;
2616
- xhr.ontimeout = onError;
2617
- xhr.onabort = function() {
2618
- stopTimers(true);
2619
- aborted = true;
2620
- };
2621
- xhr.onprogress = function() {
2622
- };
2623
- var loadEvent = isXdr ? "onload" : "onreadystatechange";
2624
- xhr[loadEvent] = function() {
2625
- resetTimers();
2626
- if (aborted || xhr.readyState !== 4 && !isXdr) {
2627
- return;
2628
- }
2629
- if (xhr.status === 0) {
2630
- return;
2631
- }
2632
- onLoad();
2633
- };
2634
- xhr.open(options.method, options.url, true);
2635
- xhr.withCredentials = !!options.withCredentials;
2636
- if (headers && xhr.setRequestHeader) {
2637
- for (var key in headers) {
2638
- if (headers.hasOwnProperty(key)) {
2639
- xhr.setRequestHeader(key, headers[key]);
2640
- }
2641
- }
2642
- } else if (headers && isXdr) {
2643
- throw new Error("Headers cannot be set on an XDomainRequest object");
2644
- }
2645
- if (options.rawBody) {
2646
- xhr.responseType = "arraybuffer";
2647
- }
2648
- context.applyMiddleware("onRequest", {
2649
- options,
2650
- adapter,
2651
- request: xhr,
2652
- context
2653
- });
2654
- xhr.send(options.body || null);
2655
- if (delays) {
2656
- timers.connect = setTimeout(function() {
2657
- return timeoutRequest("ETIMEDOUT");
2658
- }, delays.connect);
2659
- }
2660
- return {
2661
- abort
2662
- };
2663
- function abort() {
2664
- aborted = true;
2665
- if (xhr) {
2666
- xhr.abort();
2667
- }
2668
- }
2669
- function timeoutRequest(code) {
2670
- timedOut = true;
2671
- xhr.abort();
2672
- var error = new Error(code === "ESOCKETTIMEDOUT" ? "Socket timed out on request to ".concat(options.url) : "Connection timed out on request to ".concat(options.url));
2673
- error.code = code;
2674
- context.channels.error.publish(error);
2675
- }
2676
- function resetTimers() {
2677
- if (!delays) {
2678
- return;
2679
- }
2680
- stopTimers();
2681
- timers.socket = setTimeout(function() {
2682
- return timeoutRequest("ESOCKETTIMEDOUT");
2683
- }, delays.socket);
2684
- }
2685
- function stopTimers(force) {
2686
- if (force || aborted || xhr.readyState >= 2 && timers.connect) {
2687
- clearTimeout(timers.connect);
2688
- }
2689
- if (timers.socket) {
2690
- clearTimeout(timers.socket);
2691
- }
2692
- }
2693
- function onError(error) {
2694
- if (loaded) {
2695
- return;
2696
- }
2697
- stopTimers(true);
2698
- loaded = true;
2699
- xhr = null;
2700
- var err = error || new Error("Network error while attempting to reach ".concat(options.url));
2701
- err.isNetworkError = true;
2702
- err.request = options;
2703
- callback(err);
2704
- }
2705
- function reduceResponse() {
2706
- var statusCode = xhr.status;
2707
- var statusMessage = xhr.statusText;
2708
- if (isXdr && statusCode === void 0) {
2709
- statusCode = 200;
2710
- } else if (statusCode > 12e3 && statusCode < 12156) {
2711
- return onError();
2712
- } else {
2713
- statusCode = xhr.status === 1223 ? 204 : xhr.status;
2714
- statusMessage = xhr.status === 1223 ? "No Content" : statusMessage;
2715
- }
2716
- return {
2717
- body: xhr.response || xhr.responseText,
2718
- url: options.url,
2719
- method: options.method,
2720
- headers: isXdr ? {} : parseHeaders(xhr.getAllResponseHeaders()),
2721
- statusCode,
2722
- statusMessage
2723
- };
2724
- }
2725
- function onLoad() {
2726
- if (aborted || loaded || timedOut) {
2727
- return;
2728
- }
2729
- if (xhr.status === 0) {
2730
- onError(new Error("Unknown XHR error"));
2731
- return;
2732
- }
2733
- stopTimers();
2734
- loaded = true;
2735
- callback(null, reduceResponse());
2736
- }
2737
- };
2738
- }
2739
- });
2740
-
2741
- // node_modules/get-it/lib/request/index.js
2742
- var require_request = __commonJS({
2743
- "node_modules/get-it/lib/request/index.js"(exports, module) {
2744
- "use strict";
2745
- module.exports = require_browser_request();
2746
- }
2747
- });
2748
-
2749
- // node_modules/get-it/lib/index.js
2750
- var require_lib = __commonJS({
2751
- "node_modules/get-it/lib/index.js"(exports, module) {
2752
- "use strict";
2753
- var pubsub = require_nano_pubsub();
2754
- var middlewareReducer = require_middlewareReducer();
2755
- var processOptions = require_defaultOptionsProcessor();
2756
- var validateOptions = require_defaultOptionsValidator();
2757
- var httpRequester = require_request();
2758
- var channelNames = ["request", "response", "progress", "error", "abort"];
2759
- var middlehooks = ["processOptions", "validateOptions", "interceptRequest", "finalizeOptions", "onRequest", "onResponse", "onError", "onReturn", "onHeaders"];
2760
- module.exports = function createRequester() {
2761
- var initMiddleware = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
2762
- var httpRequest2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : httpRequester;
2763
- var loadedMiddleware = [];
2764
- var middleware3 = middlehooks.reduce(function(ware, name) {
2765
- ware[name] = ware[name] || [];
2766
- return ware;
2767
- }, {
2768
- processOptions: [processOptions],
2769
- validateOptions: [validateOptions]
2770
- });
2771
- function request2(opts) {
2772
- var channels = channelNames.reduce(function(target, name) {
2773
- target[name] = pubsub();
2774
- return target;
2775
- }, {});
2776
- var applyMiddleware = middlewareReducer(middleware3);
2777
- var options = applyMiddleware("processOptions", opts);
2778
- applyMiddleware("validateOptions", options);
2779
- var context = {
2780
- options,
2781
- channels,
2782
- applyMiddleware
2783
- };
2784
- var ongoingRequest = null;
2785
- var unsubscribe = channels.request.subscribe(function(ctx) {
2786
- ongoingRequest = httpRequest2(ctx, function(err, res) {
2787
- return onResponse(err, res, ctx);
2788
- });
2789
- });
2790
- channels.abort.subscribe(function() {
2791
- unsubscribe();
2792
- if (ongoingRequest) {
2793
- ongoingRequest.abort();
2794
- }
2795
- });
2796
- var returnValue = applyMiddleware("onReturn", channels, context);
2797
- if (returnValue === channels) {
2798
- channels.request.publish(context);
2799
- }
2800
- return returnValue;
2801
- function onResponse(reqErr, res, ctx) {
2802
- var error = reqErr;
2803
- var response = res;
2804
- if (!error) {
2805
- try {
2806
- response = applyMiddleware("onResponse", res, ctx);
2807
- } catch (err) {
2808
- response = null;
2809
- error = err;
2810
- }
2811
- }
2812
- error = error && applyMiddleware("onError", error, ctx);
2813
- if (error) {
2814
- channels.error.publish(error);
2815
- } else if (response) {
2816
- channels.response.publish(response);
2817
- }
2818
- }
2819
- }
2820
- request2.use = function use(newMiddleware) {
2821
- if (!newMiddleware) {
2822
- throw new Error("Tried to add middleware that resolved to falsey value");
2823
- }
2824
- if (typeof newMiddleware === "function") {
2825
- throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");
2826
- }
2827
- if (newMiddleware.onReturn && middleware3.onReturn.length > 0) {
2828
- throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");
2829
- }
2830
- middlehooks.forEach(function(key) {
2831
- if (newMiddleware[key]) {
2832
- middleware3[key].push(newMiddleware[key]);
2833
- }
2834
- });
2835
- loadedMiddleware.push(newMiddleware);
2836
- return request2;
2837
- };
2838
- request2.clone = function clone() {
2839
- return createRequester(loadedMiddleware);
2840
- };
2841
- initMiddleware.forEach(request2.use);
2842
- return request2;
2843
- };
2844
- }
2845
- });
2846
-
2847
- // node_modules/get-it/index.js
2848
- var require_get_it = __commonJS({
2849
- "node_modules/get-it/index.js"(exports, module) {
2850
- module.exports = require_lib();
2851
- }
2852
- });
2853
-
2854
- // node_modules/get-it/lib/util/global.js
2855
- var require_global = __commonJS({
2856
- "node_modules/get-it/lib/util/global.js"(exports, module) {
2857
- "use strict";
2858
- if (typeof globalThis !== "undefined") {
2859
- module.exports = globalThis;
2860
- } else if (typeof window !== "undefined") {
2861
- module.exports = window;
2862
- } else if (typeof global !== "undefined") {
2863
- module.exports = global;
2864
- } else if (typeof self !== "undefined") {
2865
- module.exports = self;
2866
- } else {
2867
- module.exports = {};
2868
- }
2869
- }
2870
- });
2871
-
2872
- // node_modules/get-it/lib/middleware/observable.js
2873
- var require_observable2 = __commonJS({
2874
- "node_modules/get-it/lib/middleware/observable.js"(exports, module) {
2875
- "use strict";
2876
- var global2 = require_global();
2877
- var objectAssign = require_object_assign();
2878
- module.exports = function() {
2879
- var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2880
- var Observable2 = opts.implementation || global2.Observable;
2881
- if (!Observable2) {
2882
- throw new Error("`Observable` is not available in global scope, and no implementation was passed");
2883
- }
2884
- return {
2885
- onReturn: function onReturn(channels, context) {
2886
- return new Observable2(function(observer) {
2887
- channels.error.subscribe(function(err) {
2888
- return observer.error(err);
2889
- });
2890
- channels.progress.subscribe(function(event) {
2891
- return observer.next(objectAssign({
2892
- type: "progress"
2893
- }, event));
2894
- });
2895
- channels.response.subscribe(function(response) {
2896
- observer.next(objectAssign({
2897
- type: "response"
2898
- }, response));
2899
- observer.complete();
2900
- });
2901
- channels.request.publish(context);
2902
- return function() {
2903
- return channels.abort.publish();
2904
- };
2905
- });
2906
- }
2907
- };
2908
- };
2909
- }
2910
- });
2911
-
2912
- // node_modules/isobject/index.js
2913
- var require_isobject = __commonJS({
2914
- "node_modules/isobject/index.js"(exports, module) {
2915
- "use strict";
2916
- module.exports = function isObject(val) {
2917
- return val != null && typeof val === "object" && Array.isArray(val) === false;
2918
- };
2919
- }
2920
- });
2921
-
2922
- // node_modules/is-plain-object/index.js
2923
- var require_is_plain_object = __commonJS({
2924
- "node_modules/is-plain-object/index.js"(exports, module) {
2925
- "use strict";
2926
- var isObject = require_isobject();
2927
- function isObjectObject(o) {
2928
- return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
2929
- }
2930
- module.exports = function isPlainObject(o) {
2931
- var ctor, prot;
2932
- if (isObjectObject(o) === false)
2933
- return false;
2934
- ctor = o.constructor;
2935
- if (typeof ctor !== "function")
2936
- return false;
2937
- prot = ctor.prototype;
2938
- if (isObjectObject(prot) === false)
2939
- return false;
2940
- if (prot.hasOwnProperty("isPrototypeOf") === false) {
2941
- return false;
2942
- }
2943
- return true;
2944
- };
2945
- }
2946
- });
2947
-
2948
- // node_modules/get-it/lib/middleware/jsonRequest.js
2949
- var require_jsonRequest = __commonJS({
2950
- "node_modules/get-it/lib/middleware/jsonRequest.js"(exports, module) {
2951
- "use strict";
2952
- function _typeof(obj) {
2953
- "@babel/helpers - typeof";
2954
- return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
2955
- return typeof obj2;
2956
- } : function(obj2) {
2957
- return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
2958
- }, _typeof(obj);
2959
- }
2960
- var objectAssign = require_object_assign();
2961
- var isPlainObject = require_is_plain_object();
2962
- var serializeTypes = ["boolean", "string", "number"];
2963
- var isBuffer = function isBuffer2(obj) {
2964
- return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
2965
- };
2966
- module.exports = function() {
2967
- return {
2968
- processOptions: function processOptions(options) {
2969
- var body = options.body;
2970
- if (!body) {
2971
- return options;
2972
- }
2973
- var isStream = typeof body.pipe === "function";
2974
- var shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(_typeof(body)) !== -1 || Array.isArray(body) || isPlainObject(body));
2975
- if (!shouldSerialize) {
2976
- return options;
2977
- }
2978
- return objectAssign({}, options, {
2979
- body: JSON.stringify(options.body),
2980
- headers: objectAssign({}, options.headers, {
2981
- "Content-Type": "application/json"
2982
- })
2983
- });
2984
- }
2985
- };
2986
- };
2987
- }
2988
- });
2989
-
2990
- // node_modules/get-it/lib/middleware/jsonResponse.js
2991
- var require_jsonResponse = __commonJS({
2992
- "node_modules/get-it/lib/middleware/jsonResponse.js"(exports, module) {
2993
- "use strict";
2994
- var objectAssign = require_object_assign();
2995
- module.exports = function(opts) {
2996
- return {
2997
- onResponse: function onResponse(response) {
2998
- var contentType = response.headers["content-type"] || "";
2999
- var shouldDecode = opts && opts.force || contentType.indexOf("application/json") !== -1;
3000
- if (!response.body || !contentType || !shouldDecode) {
3001
- return response;
3002
- }
3003
- return objectAssign({}, response, {
3004
- body: tryParse(response.body)
3005
- });
3006
- },
3007
- processOptions: function processOptions(options) {
3008
- return objectAssign({}, options, {
3009
- headers: objectAssign({
3010
- Accept: "application/json"
3011
- }, options.headers)
3012
- });
3013
- }
3014
- };
3015
- };
3016
- function tryParse(body) {
3017
- try {
3018
- return JSON.parse(body);
3019
- } catch (err) {
3020
- err.message = "Failed to parsed response body as JSON: ".concat(err.message);
3021
- throw err;
3022
- }
3023
- }
3024
- }
3025
- });
3026
-
3027
- // node_modules/get-it/lib/middleware/progress/browser-progress.js
3028
- var require_browser_progress = __commonJS({
3029
- "node_modules/get-it/lib/middleware/progress/browser-progress.js"(exports, module) {
3030
- "use strict";
3031
- module.exports = function() {
3032
- return {
3033
- onRequest: function onRequest(evt) {
3034
- if (evt.adapter !== "xhr") {
3035
- return;
3036
- }
3037
- var xhr = evt.request;
3038
- var context = evt.context;
3039
- if ("upload" in xhr && "onprogress" in xhr.upload) {
3040
- xhr.upload.onprogress = handleProgress("upload");
3041
- }
3042
- if ("onprogress" in xhr) {
3043
- xhr.onprogress = handleProgress("download");
3044
- }
3045
- function handleProgress(stage) {
3046
- return function(event) {
3047
- var percent = event.lengthComputable ? event.loaded / event.total * 100 : -1;
3048
- context.channels.progress.publish({
3049
- stage,
3050
- percent,
3051
- total: event.total,
3052
- loaded: event.loaded,
3053
- lengthComputable: event.lengthComputable
3054
- });
3055
- };
3056
- }
3057
- }
3058
- };
3059
- };
3060
- }
3061
- });
3062
-
3063
- // node_modules/get-it/lib/middleware/progress/index.js
3064
- var require_progress = __commonJS({
3065
- "node_modules/get-it/lib/middleware/progress/index.js"(exports, module) {
3066
- "use strict";
3067
- module.exports = require_browser_progress();
3068
- }
3069
- });
3070
-
3071
1823
  // node_modules/make-error/index.js
3072
1824
  var require_make_error = __commonJS({
3073
1825
  "node_modules/make-error/index.js"(exports, module) {
@@ -3213,7 +1965,9 @@ var VALID_ASSET_TYPES = ["image", "file"];
3213
1965
  var VALID_INSERT_LOCATIONS = ["before", "after", "replace"];
3214
1966
  var dataset = (name) => {
3215
1967
  if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
3216
- throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters");
1968
+ throw new Error(
1969
+ "Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
1970
+ );
3217
1971
  }
3218
1972
  };
3219
1973
  var projectId = (id) => {
@@ -3263,58 +2017,60 @@ var hasDataset = (config) => {
3263
2017
  };
3264
2018
  var requestTag = (tag) => {
3265
2019
  if (typeof tag !== "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
3266
- throw new Error(`Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.`);
2020
+ throw new Error(
2021
+ `Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.`
2022
+ );
3267
2023
  }
3268
2024
  return tag;
3269
2025
  };
3270
2026
 
3271
2027
  // src/data/patch.js
3272
- var Patch = class {
3273
- constructor(selection, operations = {}, client = null) {
3274
- this.selection = selection;
3275
- this.operations = Object.assign({}, operations);
3276
- this.client = client;
3277
- }
2028
+ function Patch(selection, operations = {}, client = null) {
2029
+ this.selection = selection;
2030
+ this.operations = Object.assign({}, operations);
2031
+ this.client = client;
2032
+ }
2033
+ Object.assign(Patch.prototype, {
3278
2034
  clone() {
3279
2035
  return new Patch(this.selection, Object.assign({}, this.operations), this.client);
3280
- }
2036
+ },
3281
2037
  set(props) {
3282
- return this._assign("set", props);
3283
- }
2038
+ return this.assign("set", props);
2039
+ },
3284
2040
  diffMatchPatch(props) {
3285
2041
  validateObject("diffMatchPatch", props);
3286
- return this._assign("diffMatchPatch", props);
3287
- }
2042
+ return this.assign("diffMatchPatch", props);
2043
+ },
3288
2044
  unset(attrs) {
3289
2045
  if (!Array.isArray(attrs)) {
3290
2046
  throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
3291
2047
  }
3292
2048
  this.operations = Object.assign({}, this.operations, { unset: attrs });
3293
2049
  return this;
3294
- }
2050
+ },
3295
2051
  setIfMissing(props) {
3296
- return this._assign("setIfMissing", props);
3297
- }
2052
+ return this.assign("setIfMissing", props);
2053
+ },
3298
2054
  replace(props) {
3299
2055
  validateObject("replace", props);
3300
2056
  return this._set("set", { $: props });
3301
- }
2057
+ },
3302
2058
  inc(props) {
3303
- return this._assign("inc", props);
3304
- }
2059
+ return this.assign("inc", props);
2060
+ },
3305
2061
  dec(props) {
3306
- return this._assign("dec", props);
3307
- }
2062
+ return this.assign("dec", props);
2063
+ },
3308
2064
  insert(at, selector, items) {
3309
2065
  validateInsert(at, selector, items);
3310
- return this._assign("insert", { [at]: selector, items });
3311
- }
2066
+ return this.assign("insert", { [at]: selector, items });
2067
+ },
3312
2068
  append(selector, items) {
3313
2069
  return this.insert("after", `${selector}[-1]`, items);
3314
- }
2070
+ },
3315
2071
  prepend(selector, items) {
3316
2072
  return this.insert("before", `${selector}[0]`, items);
3317
- }
2073
+ },
3318
2074
  splice(selector, start, deleteCount, items) {
3319
2075
  const delAll = typeof deleteCount === "undefined" || deleteCount === -1;
3320
2076
  const startIndex = start < 0 ? start - 1 : start;
@@ -3322,123 +2078,135 @@ var Patch = class {
3322
2078
  const delRange = startIndex < 0 && delCount >= 0 ? "" : delCount;
3323
2079
  const rangeSelector = `${selector}[${startIndex}:${delRange}]`;
3324
2080
  return this.insert("replace", rangeSelector, items || []);
3325
- }
2081
+ },
3326
2082
  ifRevisionId(rev) {
3327
2083
  this.operations.ifRevisionID = rev;
3328
2084
  return this;
3329
- }
2085
+ },
3330
2086
  serialize() {
3331
2087
  return Object.assign(getSelection(this.selection), this.operations);
3332
- }
2088
+ },
3333
2089
  toJSON() {
3334
2090
  return this.serialize();
3335
- }
2091
+ },
3336
2092
  commit(options = {}) {
3337
2093
  if (!this.client) {
3338
- throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
2094
+ throw new Error(
2095
+ "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
2096
+ );
3339
2097
  }
3340
2098
  const returnFirst = typeof this.selection === "string";
3341
2099
  const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
3342
2100
  return this.client.mutate({ patch: this.serialize() }, opts);
3343
- }
2101
+ },
3344
2102
  reset() {
3345
2103
  this.operations = {};
3346
2104
  return this;
3347
- }
2105
+ },
3348
2106
  _set(op, props) {
3349
- return this._assign(op, props, false);
3350
- }
3351
- _assign(op, props, merge = true) {
2107
+ return this.assign(op, props, false);
2108
+ },
2109
+ assign(op, props, merge = true) {
3352
2110
  validateObject(op, props);
3353
2111
  this.operations = Object.assign({}, this.operations, {
3354
2112
  [op]: Object.assign({}, merge && this.operations[op] || {}, props)
3355
2113
  });
3356
2114
  return this;
3357
2115
  }
3358
- };
2116
+ });
2117
+ var patch_default = Patch;
3359
2118
 
3360
2119
  // src/data/transaction.js
3361
2120
  var defaultMutateOptions = { returnDocuments: false };
3362
- var Transaction = class {
3363
- constructor(operations = [], client, transactionId) {
3364
- this.trxId = transactionId;
3365
- this.operations = operations;
3366
- this.client = client;
3367
- }
2121
+ function Transaction(operations = [], client, transactionId) {
2122
+ this.trxId = transactionId;
2123
+ this.operations = operations;
2124
+ this.client = client;
2125
+ }
2126
+ Object.assign(Transaction.prototype, {
3368
2127
  clone() {
3369
2128
  return new Transaction(this.operations.slice(0), this.client, this.trxId);
3370
- }
2129
+ },
3371
2130
  create(doc) {
3372
2131
  validateObject("create", doc);
3373
2132
  return this._add({ create: doc });
3374
- }
2133
+ },
3375
2134
  createIfNotExists(doc) {
3376
2135
  const op = "createIfNotExists";
3377
2136
  validateObject(op, doc);
3378
2137
  requireDocumentId(op, doc);
3379
2138
  return this._add({ [op]: doc });
3380
- }
2139
+ },
3381
2140
  createOrReplace(doc) {
3382
2141
  const op = "createOrReplace";
3383
2142
  validateObject(op, doc);
3384
2143
  requireDocumentId(op, doc);
3385
2144
  return this._add({ [op]: doc });
3386
- }
2145
+ },
3387
2146
  delete(documentId) {
3388
2147
  validateDocumentId("delete", documentId);
3389
2148
  return this._add({ delete: { id: documentId } });
3390
- }
2149
+ },
3391
2150
  patch(documentId, patchOps) {
3392
2151
  const isBuilder = typeof patchOps === "function";
3393
- const isPatch = documentId instanceof Patch;
2152
+ const isPatch = documentId instanceof patch_default;
3394
2153
  if (isPatch) {
3395
2154
  return this._add({ patch: documentId.serialize() });
3396
2155
  }
3397
2156
  if (isBuilder) {
3398
- const patch = patchOps(new Patch(documentId, {}, this.client));
3399
- if (!(patch instanceof Patch)) {
2157
+ const patch = patchOps(new patch_default(documentId, {}, this.client));
2158
+ if (!(patch instanceof patch_default)) {
3400
2159
  throw new Error("function passed to `patch()` must return the patch");
3401
2160
  }
3402
2161
  return this._add({ patch: patch.serialize() });
3403
2162
  }
3404
2163
  return this._add({ patch: Object.assign({ id: documentId }, patchOps) });
3405
- }
2164
+ },
3406
2165
  transactionId(id) {
3407
2166
  if (!id) {
3408
2167
  return this.trxId;
3409
2168
  }
3410
2169
  this.trxId = id;
3411
2170
  return this;
3412
- }
2171
+ },
3413
2172
  serialize() {
3414
2173
  return this.operations.slice();
3415
- }
2174
+ },
3416
2175
  toJSON() {
3417
2176
  return this.serialize();
3418
- }
2177
+ },
3419
2178
  commit(options) {
3420
2179
  if (!this.client) {
3421
- throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
3422
- }
3423
- return this.client.mutate(this.serialize(), Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {}));
3424
- }
2180
+ throw new Error(
2181
+ "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
2182
+ );
2183
+ }
2184
+ return this.client.mutate(
2185
+ this.serialize(),
2186
+ Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
2187
+ );
2188
+ },
3425
2189
  reset() {
3426
2190
  this.operations = [];
3427
2191
  return this;
3428
- }
2192
+ },
3429
2193
  _add(mut) {
3430
2194
  this.operations.push(mut);
3431
2195
  return this;
3432
2196
  }
3433
- };
2197
+ });
2198
+ var transaction_default = Transaction;
3434
2199
 
3435
2200
  // src/data/encodeQueryString.js
3436
2201
  var enc = encodeURIComponent;
3437
- var encodeQueryString = ({ query, params = {}, options = {} }) => {
2202
+ var encodeQueryString_default = ({ query, params = {}, options = {} }) => {
3438
2203
  const { tag, ...opts } = options;
3439
2204
  const q = `query=${enc(query)}`;
3440
2205
  const base = tag ? `?tag=${enc(tag)}&${q}` : `?${q}`;
3441
- const qString = Object.keys(params).reduce((qs, param) => `${qs}&${enc(`$${param}`)}=${enc(JSON.stringify(params[param]))}`, base);
2206
+ const qString = Object.keys(params).reduce(
2207
+ (qs, param) => `${qs}&${enc(`$${param}`)}=${enc(JSON.stringify(params[param]))}`,
2208
+ base
2209
+ );
3442
2210
  return Object.keys(opts).reduce((qs, option) => {
3443
2211
  return options[option] ? `${qs}&${enc(option)}=${enc(options[option])}` : qs;
3444
2212
  }, qString);
@@ -3448,7 +2216,7 @@ var encodeQueryString = ({ query, params = {}, options = {} }) => {
3448
2216
  var import_eventsource = __toESM(require_browser());
3449
2217
 
3450
2218
  // src/util/pick.js
3451
- var pick = (obj, props) => props.reduce((selection, prop) => {
2219
+ var pick_default = (obj, props) => props.reduce((selection, prop) => {
3452
2220
  if (typeof obj[prop] === "undefined") {
3453
2221
  return selection;
3454
2222
  }
@@ -3457,8 +2225,8 @@ var pick = (obj, props) => props.reduce((selection, prop) => {
3457
2225
  }, {});
3458
2226
 
3459
2227
  // src/util/defaults.js
3460
- var defaults = (obj, defaults2) => Object.keys(defaults2).concat(Object.keys(obj)).reduce((target, prop) => {
3461
- target[prop] = typeof obj[prop] === "undefined" ? defaults2[prop] : obj[prop];
2228
+ var defaults_default = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => {
2229
+ target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
3462
2230
  return target;
3463
2231
  }, {});
3464
2232
 
@@ -3478,9 +2246,9 @@ var defaultOptions = {
3478
2246
  function listen(query, params, opts = {}) {
3479
2247
  const { url, token, withCredentials, requestTagPrefix } = this.clientConfig;
3480
2248
  const tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag;
3481
- const options = { ...defaults(opts, defaultOptions), tag };
3482
- const listenOpts = pick(options, possibleOptions);
3483
- const qs = encodeQueryString({ query, params, options: listenOpts, tag });
2249
+ const options = { ...defaults_default(opts, defaultOptions), tag };
2250
+ const listenOpts = pick_default(options, possibleOptions);
2251
+ const qs = encodeQueryString_default({ query, params, options: listenOpts, tag });
3484
2252
  const uri = `${url}${this.getDataUrl("listen", qs)}`;
3485
2253
  if (uri.length > MAX_URL_LENGTH) {
3486
2254
  return new import_Observable.Observable((observer) => observer.error(new Error("Query too large for listener")));
@@ -3604,7 +2372,7 @@ var indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
3604
2372
  }, /* @__PURE__ */ Object.create(null));
3605
2373
  var toPromise = (observable2) => observable2.toPromise();
3606
2374
  var getQuerySizeLimit = 11264;
3607
- var dataMethods = {
2375
+ var dataMethods_default = {
3608
2376
  listen,
3609
2377
  getDataUrl(operation, path) {
3610
2378
  const config = this.clientConfig;
@@ -3620,15 +2388,21 @@ var dataMethods = {
3620
2388
  },
3621
2389
  getDocument(id, opts = {}) {
3622
2390
  const options = { uri: this.getDataUrl("doc", id), json: true, tag: opts.tag };
3623
- const observable2 = this._requestObservable(options).pipe((0, import_filter.filter)(isResponse), (0, import_map.map)((event) => event.body.documents && event.body.documents[0]));
2391
+ const observable2 = this._requestObservable(options).pipe(
2392
+ (0, import_filter.filter)(isResponse),
2393
+ (0, import_map.map)((event) => event.body.documents && event.body.documents[0])
2394
+ );
3624
2395
  return this.isPromiseAPI() ? toPromise(observable2) : observable2;
3625
2396
  },
3626
2397
  getDocuments(ids, opts = {}) {
3627
2398
  const options = { uri: this.getDataUrl("doc", ids.join(",")), json: true, tag: opts.tag };
3628
- const observable2 = this._requestObservable(options).pipe((0, import_filter.filter)(isResponse), (0, import_map.map)((event) => {
3629
- const indexed = indexBy(event.body.documents || [], (doc) => doc._id);
3630
- return ids.map((id) => indexed[id] || null);
3631
- }));
2399
+ const observable2 = this._requestObservable(options).pipe(
2400
+ (0, import_filter.filter)(isResponse),
2401
+ (0, import_map.map)((event) => {
2402
+ const indexed = indexBy(event.body.documents || [], (doc) => doc._id);
2403
+ return ids.map((id) => indexed[id] || null);
2404
+ })
2405
+ );
3632
2406
  return this.isPromiseAPI() ? toPromise(observable2) : observable2;
3633
2407
  },
3634
2408
  create(doc, options) {
@@ -3643,19 +2417,19 @@ var dataMethods = {
3643
2417
  return this._create(doc, "createOrReplace", options);
3644
2418
  },
3645
2419
  patch(selector, operations) {
3646
- return new Patch(selector, operations, this);
2420
+ return new patch_default(selector, operations, this);
3647
2421
  },
3648
2422
  delete(selection, options) {
3649
2423
  return this.dataRequest("mutate", { mutations: [{ delete: getSelection(selection) }] }, options);
3650
2424
  },
3651
2425
  mutate(mutations, options) {
3652
- const mut = mutations instanceof Patch || mutations instanceof Transaction ? mutations.serialize() : mutations;
2426
+ const mut = mutations instanceof patch_default || mutations instanceof transaction_default ? mutations.serialize() : mutations;
3653
2427
  const muts = Array.isArray(mut) ? mut : [mut];
3654
2428
  const transactionId = options && options.transactionId;
3655
2429
  return this.dataRequest("mutate", { mutations: muts, transactionId }, options);
3656
2430
  },
3657
2431
  transaction(operations) {
3658
- return new Transaction(operations, this);
2432
+ return new transaction_default(operations, this);
3659
2433
  },
3660
2434
  dataRequest(endpoint, body, options = {}) {
3661
2435
  const request2 = this._dataRequest(endpoint, body, options);
@@ -3664,7 +2438,7 @@ var dataMethods = {
3664
2438
  _dataRequest(endpoint, body, options = {}) {
3665
2439
  const isMutation = endpoint === "mutate";
3666
2440
  const isQuery = endpoint === "query";
3667
- const strQuery = !isMutation && encodeQueryString(body);
2441
+ const strQuery = !isMutation && encodeQueryString_default(body);
3668
2442
  const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
3669
2443
  const stringQuery = useGet ? strQuery : "";
3670
2444
  const returnFirst = options.returnFirst;
@@ -3682,22 +2456,26 @@ var dataMethods = {
3682
2456
  tag,
3683
2457
  canUseCdn: isQuery
3684
2458
  };
3685
- return this._requestObservable(reqOptions).pipe((0, import_filter.filter)(isResponse), (0, import_map.map)(getBody), (0, import_map.map)((res) => {
3686
- if (!isMutation) {
3687
- return res;
3688
- }
3689
- const results = res.results || [];
3690
- if (options.returnDocuments) {
3691
- return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
3692
- }
3693
- const key = returnFirst ? "documentId" : "documentIds";
3694
- const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
3695
- return {
3696
- transactionId: res.transactionId,
3697
- results,
3698
- [key]: ids
3699
- };
3700
- }));
2459
+ return this._requestObservable(reqOptions).pipe(
2460
+ (0, import_filter.filter)(isResponse),
2461
+ (0, import_map.map)(getBody),
2462
+ (0, import_map.map)((res) => {
2463
+ if (!isMutation) {
2464
+ return res;
2465
+ }
2466
+ const results = res.results || [];
2467
+ if (options.returnDocuments) {
2468
+ return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
2469
+ }
2470
+ const key = returnFirst ? "documentId" : "documentIds";
2471
+ const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
2472
+ return {
2473
+ transactionId: res.transactionId,
2474
+ results,
2475
+ [key]: ids
2476
+ };
2477
+ })
2478
+ );
3701
2479
  },
3702
2480
  _create(doc, op, options = {}) {
3703
2481
  const mutation = { [op]: doc };
@@ -3707,43 +2485,45 @@ var dataMethods = {
3707
2485
  };
3708
2486
 
3709
2487
  // src/datasets/datasetsClient.js
3710
- var DatasetsClient = class {
3711
- constructor(client) {
3712
- this.request = client.request.bind(client);
3713
- }
2488
+ function DatasetsClient(client) {
2489
+ this.request = client.request.bind(client);
2490
+ }
2491
+ Object.assign(DatasetsClient.prototype, {
3714
2492
  create(name, options) {
3715
2493
  return this._modify("PUT", name, options);
3716
- }
2494
+ },
3717
2495
  edit(name, options) {
3718
2496
  return this._modify("PATCH", name, options);
3719
- }
2497
+ },
3720
2498
  delete(name) {
3721
2499
  return this._modify("DELETE", name);
3722
- }
2500
+ },
3723
2501
  list() {
3724
2502
  return this.request({ uri: "/datasets" });
3725
- }
2503
+ },
3726
2504
  _modify(method, name, body) {
3727
2505
  dataset(name);
3728
2506
  return this.request({ method, uri: `/datasets/${name}`, body });
3729
2507
  }
3730
- };
2508
+ });
2509
+ var datasetsClient_default = DatasetsClient;
3731
2510
 
3732
2511
  // src/projects/projectsClient.js
3733
- var ProjectsClient = class {
3734
- constructor(client) {
3735
- this.client = client;
3736
- }
2512
+ function ProjectsClient(client) {
2513
+ this.client = client;
2514
+ }
2515
+ Object.assign(ProjectsClient.prototype, {
3737
2516
  list() {
3738
2517
  return this.client.request({ uri: "/projects" });
3739
- }
2518
+ },
3740
2519
  getById(id) {
3741
2520
  return this.client.request({ uri: `/projects/${id}` });
3742
2521
  }
3743
- };
2522
+ });
2523
+ var projectsClient_default = ProjectsClient;
3744
2524
 
3745
2525
  // src/http/queryString.js
3746
- var queryString = (params) => {
2526
+ var queryString_default = (params) => {
3747
2527
  const qs = [];
3748
2528
  for (const key in params) {
3749
2529
  if (params.hasOwnProperty(key)) {
@@ -3754,10 +2534,22 @@ var queryString = (params) => {
3754
2534
  };
3755
2535
 
3756
2536
  // src/assets/assetsClient.js
3757
- var AssetsClient = class {
3758
- constructor(client) {
3759
- this.client = client;
2537
+ function AssetsClient(client) {
2538
+ this.client = client;
2539
+ }
2540
+ function optionsFromFile(opts, file) {
2541
+ if (typeof window === "undefined" || !(file instanceof window.File)) {
2542
+ return opts;
3760
2543
  }
2544
+ return Object.assign(
2545
+ {
2546
+ filename: opts.preserveFilename === false ? void 0 : file.name,
2547
+ contentType: file.type
2548
+ },
2549
+ opts
2550
+ );
2551
+ }
2552
+ Object.assign(AssetsClient.prototype, {
3761
2553
  upload(assetType, body, opts = {}) {
3762
2554
  validateAssetType(assetType);
3763
2555
  let meta = opts.extract || void 0;
@@ -3790,8 +2582,11 @@ var AssetsClient = class {
3790
2582
  query,
3791
2583
  body
3792
2584
  });
3793
- return this.client.isPromiseAPI() ? observable2.pipe((0, import_filter.filter)((event) => event.type === "response"), (0, import_map.map)((event) => event.body.document)).toPromise() : observable2;
3794
- }
2585
+ return this.client.isPromiseAPI() ? observable2.pipe(
2586
+ (0, import_filter.filter)((event) => event.type === "response"),
2587
+ (0, import_map.map)((event) => event.body.document)
2588
+ ).toPromise() : observable2;
2589
+ },
3795
2590
  delete(type, id) {
3796
2591
  console.warn("client.assets.delete() is deprecated, please use client.delete(<document-id>)");
3797
2592
  let docId = id || "";
@@ -3802,61 +2597,56 @@ var AssetsClient = class {
3802
2597
  }
3803
2598
  hasDataset(this.client.clientConfig);
3804
2599
  return this.client.delete(docId);
3805
- }
2600
+ },
3806
2601
  getImageUrl(ref, query) {
3807
2602
  const id = ref._ref || ref;
3808
2603
  if (typeof id !== "string") {
3809
- throw new Error("getImageUrl() needs either an object with a _ref, or a string with an asset document ID");
2604
+ throw new Error(
2605
+ "getImageUrl() needs either an object with a _ref, or a string with an asset document ID"
2606
+ );
3810
2607
  }
3811
2608
  if (!/^image-[A-Za-z0-9_]+-\d+x\d+-[a-z]{1,5}$/.test(id)) {
3812
- throw new Error(`Unsupported asset ID "${id}". URL generation only works for auto-generated IDs.`);
2609
+ throw new Error(
2610
+ `Unsupported asset ID "${id}". URL generation only works for auto-generated IDs.`
2611
+ );
3813
2612
  }
3814
2613
  const [, assetId, size, format] = id.split("-");
3815
2614
  hasDataset(this.client.clientConfig);
3816
2615
  const { projectId: projectId2, dataset: dataset2 } = this.client.clientConfig;
3817
- const qs = query ? queryString(query) : "";
2616
+ const qs = query ? queryString_default(query) : "";
3818
2617
  return `https://cdn.sanity.io/images/${projectId2}/${dataset2}/${assetId}-${size}.${format}${qs}`;
3819
2618
  }
3820
- };
3821
- function optionsFromFile(opts, file) {
3822
- if (typeof window === "undefined" || !(file instanceof window.File)) {
3823
- return opts;
3824
- }
3825
- return Object.assign({
3826
- filename: opts.preserveFilename === false ? void 0 : file.name,
3827
- contentType: file.type
3828
- }, opts);
3829
- }
2619
+ });
2620
+ var assetsClient_default = AssetsClient;
3830
2621
 
3831
2622
  // src/users/usersClient.js
3832
- var UsersClient = class {
3833
- constructor(client) {
3834
- this.client = client;
3835
- }
2623
+ function UsersClient(client) {
2624
+ this.client = client;
2625
+ }
2626
+ Object.assign(UsersClient.prototype, {
3836
2627
  getById(id) {
3837
2628
  return this.client.request({ uri: `/users/${id}` });
3838
2629
  }
3839
- };
2630
+ });
2631
+ var usersClient_default = UsersClient;
3840
2632
 
3841
2633
  // src/auth/authClient.js
3842
- var AuthClient = class {
3843
- constructor(client) {
3844
- this.client = client;
3845
- }
2634
+ function AuthClient(client) {
2635
+ this.client = client;
2636
+ }
2637
+ Object.assign(AuthClient.prototype, {
3846
2638
  getLoginProviders() {
3847
2639
  return this.client.request({ uri: "/auth/providers" });
3848
- }
2640
+ },
3849
2641
  logout() {
3850
2642
  return this.client.request({ uri: "/auth/logout", method: "POST" });
3851
2643
  }
3852
- };
2644
+ });
2645
+ var authClient_default = AuthClient;
3853
2646
 
3854
2647
  // src/http/request.js
3855
- var import_get_it = __toESM(require_get_it());
3856
- var import_observable4 = __toESM(require_observable2());
3857
- var import_jsonRequest = __toESM(require_jsonRequest());
3858
- var import_jsonResponse = __toESM(require_jsonResponse());
3859
- var import_progress = __toESM(require_progress());
2648
+ import getIt from "get-it";
2649
+ import { observable, jsonRequest, jsonResponse, progress } from "get-it/middleware";
3860
2650
 
3861
2651
  // src/http/errors.js
3862
2652
  var import_make_error = __toESM(require_make_error());
@@ -3902,7 +2692,7 @@ function stringifyBody(body, res) {
3902
2692
  (0, import_make_error.default)(ServerError);
3903
2693
 
3904
2694
  // src/http/browserMiddleware.js
3905
- var middleware = [];
2695
+ var browserMiddleware_default = [];
3906
2696
 
3907
2697
  // src/http/request.js
3908
2698
  var httpError = {
@@ -3923,25 +2713,27 @@ var printWarnings = {
3923
2713
  return res;
3924
2714
  }
3925
2715
  };
3926
- var middleware2 = middleware.concat([
2716
+ var envSpecific = browserMiddleware_default;
2717
+ var middleware = envSpecific.concat([
3927
2718
  printWarnings,
3928
- (0, import_jsonRequest.default)(),
3929
- (0, import_jsonResponse.default)(),
3930
- (0, import_progress.default)(),
2719
+ jsonRequest(),
2720
+ jsonResponse(),
2721
+ progress(),
3931
2722
  httpError,
3932
- (0, import_observable4.default)({ implementation: import_Observable.Observable })
2723
+ observable({ implementation: import_Observable.Observable })
3933
2724
  ]);
3934
- var request = (0, import_get_it.default)(middleware2);
2725
+ var request = getIt(middleware);
3935
2726
  function httpRequest(options, requester = request) {
3936
2727
  return requester(Object.assign({ maxRedirects: 0 }, options));
3937
2728
  }
3938
2729
  httpRequest.defaultRequester = request;
3939
2730
  httpRequest.ClientError = ClientError;
3940
2731
  httpRequest.ServerError = ServerError;
2732
+ var request_default = httpRequest;
3941
2733
 
3942
2734
  // src/http/requestOptions.js
3943
2735
  var projectHeader = "X-Sanity-Project-ID";
3944
- var requestOptions = (config, overrides = {}) => {
2736
+ var requestOptions_default = (config, overrides = {}) => {
3945
2737
  const headers = {};
3946
2738
  const token = overrides.token || config.token;
3947
2739
  if (token) {
@@ -3950,7 +2742,9 @@ var requestOptions = (config, overrides = {}) => {
3950
2742
  if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {
3951
2743
  headers[projectHeader] = config.projectId;
3952
2744
  }
3953
- const withCredentials = Boolean(typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials);
2745
+ const withCredentials = Boolean(
2746
+ typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
2747
+ );
3954
2748
  const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
3955
2749
  return Object.assign({}, overrides, {
3956
2750
  headers: Object.assign({}, headers, overrides.headers || {}),
@@ -3961,14 +2755,14 @@ var requestOptions = (config, overrides = {}) => {
3961
2755
  });
3962
2756
  };
3963
2757
 
3964
- // node_modules/@sanity/generate-help-url/dist/generate-help-url.esm.js
2758
+ // src/generateHelpUrl.js
3965
2759
  var BASE_URL = "https://docs.sanity.io/help/";
3966
2760
  function generateHelpUrl(slug) {
3967
2761
  return BASE_URL + slug;
3968
2762
  }
3969
2763
 
3970
2764
  // src/util/once.js
3971
- var once = (fn) => {
2765
+ var once_default = (fn) => {
3972
2766
  let didCall = false;
3973
2767
  let returnValue;
3974
2768
  return (...args) => {
@@ -3982,7 +2776,7 @@ var once = (fn) => {
3982
2776
  };
3983
2777
 
3984
2778
  // src/warnings.js
3985
- var createWarningPrinter = (message) => once((...args) => console.warn(message.join(" "), ...args));
2779
+ var createWarningPrinter = (message) => once_default((...args) => console.warn(message.join(" "), ...args));
3986
2780
  var printCdnWarning = createWarningPrinter([
3987
2781
  "You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and",
3988
2782
  `cheaper. Think about it! For more info, see ${generateHelpUrl("js-client-cdn-configuration")}.`,
@@ -3991,7 +2785,9 @@ var printCdnWarning = createWarningPrinter([
3991
2785
  ]);
3992
2786
  var printBrowserTokenWarning = createWarningPrinter([
3993
2787
  "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
3994
- `See ${generateHelpUrl("js-client-browser-token")} for more information and how to hide this warning.`
2788
+ `See ${generateHelpUrl(
2789
+ "js-client-browser-token"
2790
+ )} for more information and how to hide this warning.`
3995
2791
  ]);
3996
2792
  var printNoApiVersionSpecifiedWarning = createWarningPrinter([
3997
2793
  "Using the Sanity client without specifying an API version is deprecated.",
@@ -4008,6 +2804,16 @@ var defaultConfig = {
4008
2804
  };
4009
2805
  var LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
4010
2806
  var isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
2807
+ var validateApiVersion = function validateApiVersion2(apiVersion) {
2808
+ if (apiVersion === "1" || apiVersion === "X") {
2809
+ return;
2810
+ }
2811
+ const apiDate = new Date(apiVersion);
2812
+ const apiVersionValid = /^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0;
2813
+ if (!apiVersionValid) {
2814
+ throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
2815
+ }
2816
+ };
4011
2817
  var initConfig = (config, prevConfig) => {
4012
2818
  const specifiedConfig = Object.assign({}, prevConfig, config);
4013
2819
  if (!specifiedConfig.apiVersion) {
@@ -4055,56 +2861,55 @@ var initConfig = (config, prevConfig) => {
4055
2861
  }
4056
2862
  return newConfig;
4057
2863
  };
4058
- function validateApiVersion(apiVersion) {
4059
- if (apiVersion === "1" || apiVersion === "X") {
4060
- return;
4061
- }
4062
- const apiDate = new Date(apiVersion);
4063
- const apiVersionValid = /^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0;
4064
- if (!apiVersionValid) {
4065
- throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
4066
- }
4067
- }
4068
2864
 
4069
2865
  // src/sanityClient.js
4070
2866
  var toPromise2 = (observable2) => observable2.toPromise();
4071
- var SanityClient = class {
4072
- constructor(config = defaultConfig) {
4073
- this.config(config);
4074
- this.assets = new AssetsClient(this);
4075
- this.datasets = new DatasetsClient(this);
4076
- this.projects = new ProjectsClient(this);
4077
- this.users = new UsersClient(this);
4078
- this.auth = new AuthClient(this);
4079
- if (this.clientConfig.isPromiseAPI) {
4080
- const observableConfig = Object.assign({}, this.clientConfig, { isPromiseAPI: false });
4081
- this.observable = new SanityClient(observableConfig);
4082
- }
2867
+ function SanityClient(config = defaultConfig) {
2868
+ if (!(this instanceof SanityClient)) {
2869
+ return new SanityClient(config);
2870
+ }
2871
+ this.config(config);
2872
+ this.assets = new assetsClient_default(this);
2873
+ this.datasets = new datasetsClient_default(this);
2874
+ this.projects = new projectsClient_default(this);
2875
+ this.users = new usersClient_default(this);
2876
+ this.auth = new authClient_default(this);
2877
+ if (this.clientConfig.isPromiseAPI) {
2878
+ const observableConfig = Object.assign({}, this.clientConfig, { isPromiseAPI: false });
2879
+ this.observable = new SanityClient(observableConfig);
4083
2880
  }
2881
+ }
2882
+ Object.assign(SanityClient.prototype, dataMethods_default);
2883
+ Object.assign(SanityClient.prototype, {
4084
2884
  clone() {
4085
2885
  return new SanityClient(this.config());
4086
- }
2886
+ },
4087
2887
  config(newConfig) {
4088
2888
  if (typeof newConfig === "undefined") {
4089
2889
  return Object.assign({}, this.clientConfig);
4090
2890
  }
2891
+ if (this.clientConfig && this.clientConfig.allowReconfigure === false) {
2892
+ throw new Error(
2893
+ "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
2894
+ );
2895
+ }
4091
2896
  if (this.observable) {
4092
2897
  const observableConfig = Object.assign({}, newConfig, { isPromiseAPI: false });
4093
2898
  this.observable.config(observableConfig);
4094
2899
  }
4095
2900
  this.clientConfig = initConfig(newConfig, this.clientConfig || {});
4096
2901
  return this;
4097
- }
2902
+ },
4098
2903
  withConfig(newConfig) {
4099
- return this.clone().config(newConfig);
4100
- }
2904
+ return new SanityClient({ ...this.config(), ...newConfig });
2905
+ },
4101
2906
  getUrl(uri, useCdn = false) {
4102
2907
  const base = useCdn ? this.clientConfig.cdnUrl : this.clientConfig.url;
4103
2908
  return `${base}/${uri.replace(/^\//, "")}`;
4104
- }
2909
+ },
4105
2910
  isPromiseAPI() {
4106
2911
  return this.clientConfig.isPromiseAPI;
4107
- }
2912
+ },
4108
2913
  _requestObservable(options) {
4109
2914
  const uri = options.url || options.uri;
4110
2915
  const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
@@ -4113,53 +2918,40 @@ var SanityClient = class {
4113
2918
  if (tag) {
4114
2919
  options.query = { tag: requestTag(tag), ...options.query };
4115
2920
  }
4116
- const reqOptions = requestOptions(this.clientConfig, Object.assign({}, options, {
4117
- url: this.getUrl(uri, useCdn)
4118
- }));
4119
- return new import_Observable.Observable((subscriber) => httpRequest(reqOptions, this.clientConfig.requester).subscribe(subscriber));
4120
- }
2921
+ const reqOptions = requestOptions_default(
2922
+ this.clientConfig,
2923
+ Object.assign({}, options, {
2924
+ url: this.getUrl(uri, useCdn)
2925
+ })
2926
+ );
2927
+ return new import_Observable.Observable(
2928
+ (subscriber) => request_default(reqOptions, this.clientConfig.requester).subscribe(subscriber)
2929
+ );
2930
+ },
4121
2931
  request(options) {
4122
- const observable2 = this._requestObservable(options).pipe((0, import_filter.filter)((event) => event.type === "response"), (0, import_map.map)((event) => event.body));
2932
+ const observable2 = this._requestObservable(options).pipe(
2933
+ (0, import_filter.filter)((event) => event.type === "response"),
2934
+ (0, import_map.map)((event) => event.body)
2935
+ );
4123
2936
  return this.isPromiseAPI() ? toPromise2(observable2) : observable2;
4124
2937
  }
4125
- };
4126
- Object.assign(SanityClient.prototype, dataMethods);
4127
- SanityClient.Patch = Patch;
4128
- SanityClient.Transaction = Transaction;
4129
- SanityClient.ClientError = httpRequest.ClientError;
4130
- SanityClient.ServerError = httpRequest.ServerError;
4131
- SanityClient.requester = httpRequest.defaultRequester;
4132
- function createClient(config) {
4133
- return new SanityClient(config);
4134
- }
4135
- createClient.Patch = Patch;
4136
- createClient.Transaction = Transaction;
4137
- createClient.ClientError = httpRequest.ClientError;
4138
- createClient.ServerError = httpRequest.ServerError;
4139
- createClient.requester = httpRequest.defaultRequester;
2938
+ });
2939
+ SanityClient.Patch = patch_default;
2940
+ SanityClient.Transaction = transaction_default;
2941
+ SanityClient.ClientError = request_default.ClientError;
2942
+ SanityClient.ServerError = request_default.ServerError;
2943
+ SanityClient.requester = request_default.defaultRequester;
2944
+ var sanityClient_default = SanityClient;
4140
2945
  export {
4141
- SanityClient,
4142
- createClient
2946
+ sanityClient_default as default
4143
2947
  };
4144
- /*
4145
- object-assign
4146
- (c) Sindre Sorhus
4147
- @license MIT
2948
+ /*! Bundled license information:
2949
+
2950
+ event-source-polyfill/src/eventsource.js:
2951
+ (** @license
2952
+ * eventsource.js
2953
+ * Available under MIT License (MIT)
2954
+ * https://github.com/Yaffle/EventSource/
2955
+ *)
4148
2956
  */
4149
- /*!
4150
- * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
4151
- *
4152
- * Copyright (c) 2014-2017, Jon Schlinkert.
4153
- * Released under the MIT License.
4154
- */
4155
- /*!
4156
- * isobject <https://github.com/jonschlinkert/isobject>
4157
- *
4158
- * Copyright (c) 2014-2017, Jon Schlinkert.
4159
- * Released under the MIT License.
4160
- */
4161
- /** @license
4162
- * eventsource.js
4163
- * Available under MIT License (MIT)
4164
- * https://github.com/Yaffle/EventSource/
4165
- */
2957
+ //# sourceMappingURL=sanityClient.browser.mjs.map