@spoosh/react 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -4
- package/dist/index.mjs +10 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -783,9 +783,9 @@ function createUseSubscription(options) {
|
|
|
783
783
|
// src/useSSE/index.ts
|
|
784
784
|
var import_react6 = require("react");
|
|
785
785
|
var import_core6 = require("@spoosh/core");
|
|
786
|
-
var import_transport_sse = require("@spoosh/transport-sse");
|
|
787
786
|
function isSSETransport(transport) {
|
|
788
|
-
|
|
787
|
+
const t = transport;
|
|
788
|
+
return typeof t.createSubscriptionAdapter === "function" && typeof t.utils?.resolveParser === "function" && typeof t.utils?.resolveAccumulator === "function";
|
|
789
789
|
}
|
|
790
790
|
function createUseSSE(options) {
|
|
791
791
|
const { eventEmitter, transports, config } = options;
|
|
@@ -873,7 +873,10 @@ function createUseSSE(options) {
|
|
|
873
873
|
if (eventSet && !eventSet.has(data.event)) {
|
|
874
874
|
return;
|
|
875
875
|
}
|
|
876
|
-
const parser =
|
|
876
|
+
const parser = transport.utils.resolveParser(
|
|
877
|
+
parseRef.current,
|
|
878
|
+
data.event
|
|
879
|
+
);
|
|
877
880
|
let parsed;
|
|
878
881
|
try {
|
|
879
882
|
parsed = parser(data.data);
|
|
@@ -883,7 +886,10 @@ function createUseSSE(options) {
|
|
|
883
886
|
if (parsed === void 0) {
|
|
884
887
|
return;
|
|
885
888
|
}
|
|
886
|
-
const accumulator =
|
|
889
|
+
const accumulator = transport.utils.resolveAccumulator(
|
|
890
|
+
accumulateRef.current,
|
|
891
|
+
data.event
|
|
892
|
+
);
|
|
887
893
|
const parsedObj = parsed;
|
|
888
894
|
const messageIndex = typeof parsedObj?.index === "number" ? parsedObj.index : void 0;
|
|
889
895
|
if (messageIndex !== void 0) {
|
package/dist/index.mjs
CHANGED
|
@@ -805,9 +805,9 @@ function createUseSubscription(options) {
|
|
|
805
805
|
// src/useSSE/index.ts
|
|
806
806
|
import { useState as useState5, useRef as useRef6, useEffect as useEffect5, useCallback as useCallback5, useMemo } from "react";
|
|
807
807
|
import { createSelectorProxy as createSelectorProxy6 } from "@spoosh/core";
|
|
808
|
-
import { resolveParser, resolveAccumulator } from "@spoosh/transport-sse";
|
|
809
808
|
function isSSETransport(transport) {
|
|
810
|
-
|
|
809
|
+
const t = transport;
|
|
810
|
+
return typeof t.createSubscriptionAdapter === "function" && typeof t.utils?.resolveParser === "function" && typeof t.utils?.resolveAccumulator === "function";
|
|
811
811
|
}
|
|
812
812
|
function createUseSSE(options) {
|
|
813
813
|
const { eventEmitter, transports, config } = options;
|
|
@@ -895,7 +895,10 @@ function createUseSSE(options) {
|
|
|
895
895
|
if (eventSet && !eventSet.has(data.event)) {
|
|
896
896
|
return;
|
|
897
897
|
}
|
|
898
|
-
const parser = resolveParser(
|
|
898
|
+
const parser = transport.utils.resolveParser(
|
|
899
|
+
parseRef.current,
|
|
900
|
+
data.event
|
|
901
|
+
);
|
|
899
902
|
let parsed;
|
|
900
903
|
try {
|
|
901
904
|
parsed = parser(data.data);
|
|
@@ -905,7 +908,10 @@ function createUseSSE(options) {
|
|
|
905
908
|
if (parsed === void 0) {
|
|
906
909
|
return;
|
|
907
910
|
}
|
|
908
|
-
const accumulator = resolveAccumulator(
|
|
911
|
+
const accumulator = transport.utils.resolveAccumulator(
|
|
912
|
+
accumulateRef.current,
|
|
913
|
+
data.event
|
|
914
|
+
);
|
|
909
915
|
const parsedObj = parsed;
|
|
910
916
|
const messageIndex = typeof parsedObj?.index === "number" ? parsedObj.index : void 0;
|
|
911
917
|
if (messageIndex !== void 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/react",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React hooks for Spoosh API toolkit",
|
|
6
6
|
"keywords": [
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@testing-library/react": "^16.0.0",
|
|
48
48
|
"jsdom": "^26.0.0",
|
|
49
49
|
"@spoosh/core": "0.16.0",
|
|
50
|
-
"@spoosh/transport-sse": "0.1.
|
|
50
|
+
"@spoosh/transport-sse": "0.1.1",
|
|
51
51
|
"@spoosh/test-utils": "0.3.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|