@nsail/stack 0.1.964 → 0.1.975

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/load.js CHANGED
@@ -24,7 +24,11 @@ export function useLoad(message, request) {
24
24
  setLoad((current) => ({ state: "loading", data: current.data, problem: null }));
25
25
  mediator
26
26
  .send(message, latest.current, { signal: abort.signal })
27
- .then((data) => setLoad({ state: "loaded", data, problem: null }))
27
+ .then((data) => {
28
+ if (!abort.signal.aborted) {
29
+ setLoad({ state: "loaded", data, problem: null });
30
+ }
31
+ })
28
32
  .catch((error) => {
29
33
  if (!abort.signal.aborted) {
30
34
  setLoad((current) => ({ state: "failed", data: current.data, problem: problemOf(error) }));
package/dist/mediator.js CHANGED
@@ -36,14 +36,28 @@ export class Mediator {
36
36
  }
37
37
  throw new BusinessError(requestFailed(null, null));
38
38
  }
39
- const text = await response.text();
39
+ let text;
40
+ try {
41
+ text = await response.text();
42
+ }
43
+ catch (error) {
44
+ if (error instanceof DOMException && error.name === "AbortError") {
45
+ throw error;
46
+ }
47
+ throw new BusinessError(requestFailed(response.status, "DeserializationFailed"));
48
+ }
40
49
  if (!response.ok) {
41
50
  throw new BusinessError(this.problemOf(response.status, text));
42
51
  }
43
52
  if (text.length === 0) {
44
53
  return undefined;
45
54
  }
46
- return JSON.parse(text);
55
+ try {
56
+ return JSON.parse(text);
57
+ }
58
+ catch {
59
+ throw new BusinessError(requestFailed(response.status, "DeserializationFailed"));
60
+ }
47
61
  }
48
62
  url(message, request) {
49
63
  const values = request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsail/stack",
3
- "version": "0.1.964",
3
+ "version": "0.1.975",
4
4
  "description": "NSail's vendor-free client half: sends messages from the descriptors an Sdk generates, speaks the catalog, and holds the hooks a page reads with.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,6 +30,10 @@
30
30
  "typecheck": "tsc --noEmit"
31
31
  },
32
32
  "peerDependencies": {
33
- "react": ">=19"
33
+ "react": ">=19",
34
+ "react-dom": ">=19"
35
+ },
36
+ "devDependencies": {
37
+ "happy-dom": "^21.0.4"
34
38
  }
35
39
  }