@memobit/libs 3.12.0 → 3.12.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.
@@ -1,5 +1,5 @@
1
- import { logger as p } from "@memobit/core";
2
- var c = {
1
+ import { logger as c } from "@memobit/core";
2
+ var u = {
3
3
  Continue: 100,
4
4
  SwitchingProtocols: 101,
5
5
  Ok: 200,
@@ -39,21 +39,21 @@ var c = {
39
39
  Put: "PUT",
40
40
  Patch: "PATCH",
41
41
  Delete: "DELETE"
42
- }, A = (e) => e >= 200 && e < 300, R = (e) => e >= 400 && e < 500, U = (e) => e >= 500 && e < 600, y = "csrf_token", S = "X-CSRF-Token", T = () => {
43
- const e = document.cookie.match(new RegExp(`(?:^|;\\s*)${y}=([^;]+)`));
42
+ }, U = (e) => e >= 200 && e < 300, N = (e) => e >= 400 && e < 500, b = (e) => e >= 500 && e < 600, S = "csrf_token", y = "X-CSRF-Token", T = () => {
43
+ const e = document.cookie.match(new RegExp(`(?:^|;\\s*)${S}=([^;]+)`));
44
44
  return e ? decodeURIComponent(e[1]) : null;
45
45
  }, m = (e, t = !0) => {
46
46
  const n = t ? { "Content-Type": "application/json" } : {};
47
47
  if (e !== s.Get) {
48
- const u = T();
49
- u && (n[S] = u);
48
+ const d = T();
49
+ d && (n[y] = d);
50
50
  }
51
51
  return n;
52
- }, v = class extends Error {
52
+ }, w = class extends Error {
53
53
  constructor(e, t) {
54
54
  super(e), this.name = "ApiError", this.status = t;
55
55
  }
56
- }, P = async (e) => {
56
+ }, g = async (e) => {
57
57
  try {
58
58
  const t = await e.json();
59
59
  if (t && typeof t == "object") {
@@ -63,68 +63,77 @@ var c = {
63
63
  } catch {
64
64
  }
65
65
  return `Request failed (${e.status}${e.statusText ? ` ${e.statusText}` : ""})`;
66
- }, w = (e) => e instanceof DOMException && e.name === "AbortError", b = (e, t, n) => {
67
- t instanceof v || w(t) || p.error(e, t, n);
68
- }, g = /* @__PURE__ */ new Set([
69
- c.BadGateway,
70
- c.ServiceUnavailable,
71
- c.GatewayTimeout
72
- ]), G = ({ baseUrl: e, loginPath: t = "/login" }) => {
66
+ }, v = (e) => e instanceof DOMException && e.name === "AbortError", A = /^(Failed to fetch|NetworkError when attempting to fetch resource\.?|Load failed)$/, P = (e) => e instanceof TypeError && A.test(e.message), G = (e, t, n) => {
67
+ if (!(t instanceof w || v(t))) {
68
+ if (P(t)) {
69
+ c.warn(e, {
70
+ ...n,
71
+ error: String(t)
72
+ });
73
+ return;
74
+ }
75
+ c.error(e, t, n);
76
+ }
77
+ }, C = /* @__PURE__ */ new Set([
78
+ u.BadGateway,
79
+ u.ServiceUnavailable,
80
+ u.GatewayTimeout
81
+ ]), F = ({ baseUrl: e, loginPath: t = "/login" }) => {
73
82
  let n = !1;
74
- const u = (r) => `${e.replace(/\/$/, "")}/${r.replace(/^\//, "")}`, d = async (r, o, l, E = !0) => {
83
+ const d = (r) => `${e.replace(/\/$/, "")}/${r.replace(/^\//, "")}`, l = async (r, a, f, E = !0) => {
75
84
  const h = {
76
- method: o,
85
+ method: a,
77
86
  path: r.split("?")[0]
78
87
  };
79
- let a;
88
+ let o;
80
89
  try {
81
- a = await fetch(u(r), {
82
- method: o,
83
- headers: m(o, E),
90
+ o = await fetch(d(r), {
91
+ method: a,
92
+ headers: m(a, E),
84
93
  credentials: "include",
85
- body: l
94
+ body: f
86
95
  });
87
96
  } catch (i) {
88
- throw w(i) ? i : (p.warn("API request could not reach the server", h), new v("Could not reach the server", 0));
97
+ throw v(i) ? i : (c.warn("API request could not reach the server", h), new w("Could not reach the server", 0));
89
98
  }
90
- if (a.status === c.Unauthorized && !window.location.pathname.startsWith(t))
99
+ if (o.status === u.Unauthorized && !window.location.pathname.startsWith(t))
91
100
  return n || (n = !0, window.location.href = `${t}?session_expired=true`), new Promise(() => {
92
101
  });
93
- if (!a.ok)
94
- throw g.has(a.status) && p.warn("API gateway failure", {
102
+ if (!o.ok)
103
+ throw C.has(o.status) && c.warn("API gateway failure", {
95
104
  ...h,
96
- status: a.status
97
- }), new v(await P(a), a.status);
98
- if (a.status !== c.NoContent)
105
+ status: o.status
106
+ }), new w(await g(o), o.status);
107
+ if (o.status !== u.NoContent)
99
108
  try {
100
- return await a.json();
109
+ return await o.json();
101
110
  } catch (i) {
102
- throw p.error("API response was not valid JSON", i, {
111
+ throw c.error("API response was not valid JSON", i, {
103
112
  ...h,
104
- status: a.status
113
+ status: o.status
105
114
  }), i;
106
115
  }
107
- }, f = (r, o, l) => d(r, o, l === void 0 ? void 0 : JSON.stringify(l));
116
+ }, p = (r, a, f) => l(r, a, f === void 0 ? void 0 : JSON.stringify(f));
108
117
  return {
109
- get: (r) => d(r, s.Get),
110
- post: (r, o) => f(r, s.Post, o),
111
- put: (r, o) => f(r, s.Put, o),
112
- patch: (r, o) => f(r, s.Patch, o),
113
- delete: (r) => d(r, s.Delete),
114
- upload: (r, o) => d(r, s.Post, o, !1)
118
+ get: (r) => l(r, s.Get),
119
+ post: (r, a) => p(r, s.Post, a),
120
+ put: (r, a) => p(r, s.Put, a),
121
+ patch: (r, a) => p(r, s.Patch, a),
122
+ delete: (r) => l(r, s.Delete),
123
+ upload: (r, a) => l(r, s.Post, a, !1)
115
124
  };
116
125
  };
117
126
  export {
118
- v as ApiError,
119
- S as CSRF_HEADER,
127
+ w as ApiError,
128
+ y as CSRF_HEADER,
120
129
  s as HttpMethod,
121
- c as HttpStatus,
130
+ u as HttpStatus,
122
131
  m as buildRequestHeaders,
123
- G as createApiClient,
132
+ F as createApiClient,
124
133
  T as getCsrfToken,
125
- R as isClientErrorStatus,
126
- U as isServerErrorStatus,
127
- A as isSuccessStatus,
128
- b as logUnexpectedError,
129
- P as readErrorMessage
134
+ N as isClientErrorStatus,
135
+ b as isServerErrorStatus,
136
+ U as isSuccessStatus,
137
+ G as logUnexpectedError,
138
+ g as readErrorMessage
130
139
  };
@@ -23,7 +23,7 @@ var r = (i) => {
23
23
  const o = {
24
24
  ...i,
25
25
  lib: d,
26
- libBuildNumber: 515,
26
+ libBuildNumber: 517,
27
27
  libCommit: n,
28
28
  libBuildDate: t
29
29
  };
package/dist/index.d.ts CHANGED
@@ -2394,8 +2394,9 @@ export declare interface LoginResponse {
2394
2394
 
2395
2395
  /**
2396
2396
  * For the catch around an API call: reports `error` unless it is an `ApiError` (the client and
2397
- * the backend already report those that matter) or an aborted request. What is left is a bug in
2398
- * the code around the call, e.g. mapping the response.
2397
+ * the backend already report those that matter) or an aborted request. A bare fetch() that could
2398
+ * not reach the server is a warning. What is left is a bug in the code around the call, e.g.
2399
+ * mapping the response.
2399
2400
  */
2400
2401
  export declare const logUnexpectedError: (message: string, error: unknown, context?: ErrorReportContext) => void;
2401
2402
 
package/dist/version.js CHANGED
@@ -1,7 +1,7 @@
1
- var I = "3.12.0", B = 515, L = "3e853ab", _ = "2026-10-16T19:55:36.011Z", a = "515";
1
+ var I = "3.12.1", B = 517, L = "020f557", _ = "2026-10-17T06:11:23.897Z", r = "517";
2
2
  export {
3
3
  _ as LIB_BUILD_DATE,
4
- a as LIB_BUILD_ID,
4
+ r as LIB_BUILD_ID,
5
5
  B as LIB_BUILD_NUMBER,
6
6
  L as LIB_COMMIT,
7
7
  I as LIB_VERSION
package/dist/version.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "3.12.0",
3
- "buildNumber": 515,
4
- "commit": "3e853ab",
5
- "buildDate": "2026-10-16T19:55:36.011Z"
2
+ "version": "3.12.1",
3
+ "buildNumber": 517,
4
+ "commit": "020f557",
5
+ "buildDate": "2026-10-17T06:11:23.897Z"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memobit/libs",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "description": "React component library powering the Memobit apps — 100+ components, helpers and hooks. Icons ship as @memobit/icons and themes as @memobit/themes. TypeScript-first, ESM-only, React 19.",
5
5
  "keywords": [
6
6
  "react",