@reactuses/core 5.0.23-beta.1 → 5.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3844,7 +3844,7 @@ function _object_without_properties_loose(source, excluded) {
3844
3844
  const useFetchEventSource = (url, options = {})=>{
3845
3845
  const [data, setData] = React.useState(null);
3846
3846
  const [error, setError] = React.useState(null);
3847
- const [status, setStatus] = React.useState("DISCONNECTED");
3847
+ const [status, setStatus] = React.useState('DISCONNECTED');
3848
3848
  const [event, setEvent] = React.useState(null);
3849
3849
  const [lastEventId, setLastEventId] = React.useState(null);
3850
3850
  const retries = React.useRef(0);
@@ -3856,13 +3856,13 @@ const useFetchEventSource = (url, options = {})=>{
3856
3856
  explicitlyClosed.current = true;
3857
3857
  (_abortController_current = abortController.current) == null ? void 0 : _abortController_current.abort();
3858
3858
  abortController.current = null;
3859
- setStatus("DISCONNECTED");
3859
+ setStatus('DISCONNECTED');
3860
3860
  options.onClose == null ? void 0 : options.onClose.call(options);
3861
3861
  }
3862
3862
  });
3863
3863
  const open = useEvent(/*#__PURE__*/ _async_to_generator(function*() {
3864
3864
  close();
3865
- setStatus("CONNECTING");
3865
+ setStatus('CONNECTING');
3866
3866
  explicitlyClosed.current = false;
3867
3867
  retries.current = 0;
3868
3868
  // 创建新的 AbortController
@@ -3881,20 +3881,20 @@ const useFetchEventSource = (url, options = {})=>{
3881
3881
  ]);
3882
3882
  // 构建请求配置
3883
3883
  const finalOptions = _extends({
3884
- method: options.method || "GET",
3884
+ method: options.method || 'GET',
3885
3885
  headers: _extends({
3886
- Accept: "text/event-stream",
3887
- "Cache-Control": "no-cache",
3888
- Connection: "keep-alive"
3886
+ 'Accept': 'text/event-stream',
3887
+ 'Cache-Control': 'no-cache',
3888
+ 'Connection': 'keep-alive'
3889
3889
  }, options.headers),
3890
3890
  signal: abortController.current.signal,
3891
- credentials: withCredentials ? "include" : "same-origin"
3891
+ credentials: withCredentials ? 'include' : 'same-origin'
3892
3892
  }, fetchOptions);
3893
3893
  // 只在 POST 请求时添加 body
3894
- if (options.method === "POST" && body) {
3894
+ if (options.method === 'POST' && body) {
3895
3895
  finalOptions.body = body;
3896
3896
  finalOptions.headers = _extends({}, finalOptions.headers, {
3897
- "Content-Type": "application/json"
3897
+ 'Content-Type': 'application/json'
3898
3898
  });
3899
3899
  }
3900
3900
  yield fetchEventSource.fetchEventSource(url.toString(), _extends({}, finalOptions, {
@@ -3902,7 +3902,7 @@ const useFetchEventSource = (url, options = {})=>{
3902
3902
  onopen (response) {
3903
3903
  return _async_to_generator(function*() {
3904
3904
  if (response.ok) {
3905
- setStatus("CONNECTED");
3905
+ setStatus('CONNECTED');
3906
3906
  setError(null);
3907
3907
  options.onOpen == null ? void 0 : options.onOpen.call(options);
3908
3908
  } else {
@@ -3923,12 +3923,12 @@ const useFetchEventSource = (url, options = {})=>{
3923
3923
  },
3924
3924
  onerror (err) {
3925
3925
  setError(err);
3926
- setStatus("DISCONNECTED");
3926
+ setStatus('DISCONNECTED');
3927
3927
  const retryDelay = options.onError == null ? void 0 : options.onError.call(options, err);
3928
3928
  if (options.autoReconnect && !explicitlyClosed.current) {
3929
3929
  const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3930
3930
  retries.current += 1;
3931
- if (typeof maxRetries === "number" && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === "function" && maxRetries()) {
3931
+ if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3932
3932
  return retryDelay != null ? retryDelay : delay;
3933
3933
  } else {
3934
3934
  onFailed == null ? void 0 : onFailed();
@@ -3939,7 +3939,7 @@ const useFetchEventSource = (url, options = {})=>{
3939
3939
  },
3940
3940
  onclose () {
3941
3941
  if (!explicitlyClosed.current) {
3942
- setStatus("DISCONNECTED");
3942
+ setStatus('DISCONNECTED');
3943
3943
  options.onClose == null ? void 0 : options.onClose.call(options);
3944
3944
  }
3945
3945
  }
@@ -3947,9 +3947,9 @@ const useFetchEventSource = (url, options = {})=>{
3947
3947
  } catch (err) {
3948
3948
  // 只处理非主动关闭导致的错误
3949
3949
  if (!explicitlyClosed.current) {
3950
- console.error("EventSource Error:", err);
3950
+ console.error('EventSource Error:', err);
3951
3951
  setError(err);
3952
- setStatus("DISCONNECTED");
3952
+ setStatus('DISCONNECTED');
3953
3953
  }
3954
3954
  }
3955
3955
  }));
package/dist/index.mjs CHANGED
@@ -3836,7 +3836,7 @@ function _object_without_properties_loose(source, excluded) {
3836
3836
  const useFetchEventSource = (url, options = {})=>{
3837
3837
  const [data, setData] = useState(null);
3838
3838
  const [error, setError] = useState(null);
3839
- const [status, setStatus] = useState("DISCONNECTED");
3839
+ const [status, setStatus] = useState('DISCONNECTED');
3840
3840
  const [event, setEvent] = useState(null);
3841
3841
  const [lastEventId, setLastEventId] = useState(null);
3842
3842
  const retries = useRef(0);
@@ -3848,13 +3848,13 @@ const useFetchEventSource = (url, options = {})=>{
3848
3848
  explicitlyClosed.current = true;
3849
3849
  (_abortController_current = abortController.current) == null ? void 0 : _abortController_current.abort();
3850
3850
  abortController.current = null;
3851
- setStatus("DISCONNECTED");
3851
+ setStatus('DISCONNECTED');
3852
3852
  options.onClose == null ? void 0 : options.onClose.call(options);
3853
3853
  }
3854
3854
  });
3855
3855
  const open = useEvent(/*#__PURE__*/ _async_to_generator(function*() {
3856
3856
  close();
3857
- setStatus("CONNECTING");
3857
+ setStatus('CONNECTING');
3858
3858
  explicitlyClosed.current = false;
3859
3859
  retries.current = 0;
3860
3860
  // 创建新的 AbortController
@@ -3873,20 +3873,20 @@ const useFetchEventSource = (url, options = {})=>{
3873
3873
  ]);
3874
3874
  // 构建请求配置
3875
3875
  const finalOptions = _extends({
3876
- method: options.method || "GET",
3876
+ method: options.method || 'GET',
3877
3877
  headers: _extends({
3878
- Accept: "text/event-stream",
3879
- "Cache-Control": "no-cache",
3880
- Connection: "keep-alive"
3878
+ 'Accept': 'text/event-stream',
3879
+ 'Cache-Control': 'no-cache',
3880
+ 'Connection': 'keep-alive'
3881
3881
  }, options.headers),
3882
3882
  signal: abortController.current.signal,
3883
- credentials: withCredentials ? "include" : "same-origin"
3883
+ credentials: withCredentials ? 'include' : 'same-origin'
3884
3884
  }, fetchOptions);
3885
3885
  // 只在 POST 请求时添加 body
3886
- if (options.method === "POST" && body) {
3886
+ if (options.method === 'POST' && body) {
3887
3887
  finalOptions.body = body;
3888
3888
  finalOptions.headers = _extends({}, finalOptions.headers, {
3889
- "Content-Type": "application/json"
3889
+ 'Content-Type': 'application/json'
3890
3890
  });
3891
3891
  }
3892
3892
  yield fetchEventSource(url.toString(), _extends({}, finalOptions, {
@@ -3894,7 +3894,7 @@ const useFetchEventSource = (url, options = {})=>{
3894
3894
  onopen (response) {
3895
3895
  return _async_to_generator(function*() {
3896
3896
  if (response.ok) {
3897
- setStatus("CONNECTED");
3897
+ setStatus('CONNECTED');
3898
3898
  setError(null);
3899
3899
  options.onOpen == null ? void 0 : options.onOpen.call(options);
3900
3900
  } else {
@@ -3915,12 +3915,12 @@ const useFetchEventSource = (url, options = {})=>{
3915
3915
  },
3916
3916
  onerror (err) {
3917
3917
  setError(err);
3918
- setStatus("DISCONNECTED");
3918
+ setStatus('DISCONNECTED');
3919
3919
  const retryDelay = options.onError == null ? void 0 : options.onError.call(options, err);
3920
3920
  if (options.autoReconnect && !explicitlyClosed.current) {
3921
3921
  const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3922
3922
  retries.current += 1;
3923
- if (typeof maxRetries === "number" && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === "function" && maxRetries()) {
3923
+ if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3924
3924
  return retryDelay != null ? retryDelay : delay;
3925
3925
  } else {
3926
3926
  onFailed == null ? void 0 : onFailed();
@@ -3931,7 +3931,7 @@ const useFetchEventSource = (url, options = {})=>{
3931
3931
  },
3932
3932
  onclose () {
3933
3933
  if (!explicitlyClosed.current) {
3934
- setStatus("DISCONNECTED");
3934
+ setStatus('DISCONNECTED');
3935
3935
  options.onClose == null ? void 0 : options.onClose.call(options);
3936
3936
  }
3937
3937
  }
@@ -3939,9 +3939,9 @@ const useFetchEventSource = (url, options = {})=>{
3939
3939
  } catch (err) {
3940
3940
  // 只处理非主动关闭导致的错误
3941
3941
  if (!explicitlyClosed.current) {
3942
- console.error("EventSource Error:", err);
3942
+ console.error('EventSource Error:', err);
3943
3943
  setError(err);
3944
- setStatus("DISCONNECTED");
3944
+ setStatus('DISCONNECTED');
3945
3945
  }
3946
3946
  }
3947
3947
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactuses/core",
3
- "version": "5.0.23-beta.1",
3
+ "version": "5.0.23",
4
4
  "license": "Unlicense",
5
5
  "homepage": "https://www.reactuse.com/",
6
6
  "repository": {