@graffy/client 0.16.1 → 0.16.2-alpha.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.
Files changed (3) hide show
  1. package/index.cjs +7 -9
  2. package/index.mjs +6 -6
  3. package/package.json +3 -3
package/index.cjs CHANGED
@@ -8,8 +8,6 @@ var __publicField = (obj, key, value) => {
8
8
  const common = require("@graffy/common");
9
9
  const stream = require("@graffy/stream");
10
10
  const debug = require("debug");
11
- const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
12
- const debug__default = /* @__PURE__ */ _interopDefaultLegacy(debug);
13
11
  function getOptionsParam(options) {
14
12
  if (!options)
15
13
  return "";
@@ -101,10 +99,10 @@ const httpClient = (baseUrl, {
101
99
  push(common.unpack(JSON.parse(data)));
102
100
  };
103
101
  source.onerror = (e) => {
104
- end(Error("client.sse.transport: " + e));
102
+ end(Error(`client.sse.transport: ${e}`));
105
103
  };
106
104
  source.addEventListener("graffyerror", (e) => {
107
- end(Error("server." + e.data));
105
+ end(Error(`server.${e.data}`));
108
106
  });
109
107
  return () => {
110
108
  source.close();
@@ -124,12 +122,12 @@ const httpClient = (baseUrl, {
124
122
  if (res.status === 200)
125
123
  return common.unpack(JSON.parse(await res.text()));
126
124
  return res.text().then((message) => {
127
- throw Error("server." + message);
125
+ throw Error(`server.${message}`);
128
126
  });
129
127
  });
130
128
  });
131
129
  };
132
- const log = debug__default.default("graffy:client:socket");
130
+ const log = debug("graffy:client:socket");
133
131
  log.log = console.log.bind(console);
134
132
  const MIN_DELAY = 1e3;
135
133
  const MAX_DELAY = 3e5;
@@ -181,7 +179,7 @@ function Socket(url, { onUnhandled = void 0, onStatusChange = void 0 } = {}) {
181
179
  } else if (handlers[id]) {
182
180
  handlers[id].callback(...data);
183
181
  } else {
184
- onUnhandled && onUnhandled(id, ...data);
182
+ onUnhandled == null ? void 0 : onUnhandled(id, ...data);
185
183
  }
186
184
  }
187
185
  function closed(_event) {
@@ -280,7 +278,7 @@ const wsClient = (url, {
280
278
  [op, common.pack(payload), getOptions(op, options) || {}],
281
279
  (error, result) => {
282
280
  socket.stop(id);
283
- error ? reject(Error("server." + error)) : resolve(common.unpack(result));
281
+ error ? reject(Error(`server.${error}`)) : resolve(common.unpack(result));
284
282
  }
285
283
  );
286
284
  });
@@ -303,7 +301,7 @@ const wsClient = (url, {
303
301
  (error, result) => {
304
302
  if (error) {
305
303
  socket.stop(id);
306
- end(Error("server." + error));
304
+ end(Error(`server.${error}`));
307
305
  return;
308
306
  }
309
307
  push(common.unpack(result));
package/index.mjs CHANGED
@@ -98,10 +98,10 @@ const httpClient = (baseUrl, {
98
98
  push(unpack(JSON.parse(data)));
99
99
  };
100
100
  source.onerror = (e) => {
101
- end(Error("client.sse.transport: " + e));
101
+ end(Error(`client.sse.transport: ${e}`));
102
102
  };
103
103
  source.addEventListener("graffyerror", (e) => {
104
- end(Error("server." + e.data));
104
+ end(Error(`server.${e.data}`));
105
105
  });
106
106
  return () => {
107
107
  source.close();
@@ -121,7 +121,7 @@ const httpClient = (baseUrl, {
121
121
  if (res.status === 200)
122
122
  return unpack(JSON.parse(await res.text()));
123
123
  return res.text().then((message) => {
124
- throw Error("server." + message);
124
+ throw Error(`server.${message}`);
125
125
  });
126
126
  });
127
127
  });
@@ -178,7 +178,7 @@ function Socket(url, { onUnhandled = void 0, onStatusChange = void 0 } = {}) {
178
178
  } else if (handlers[id]) {
179
179
  handlers[id].callback(...data);
180
180
  } else {
181
- onUnhandled && onUnhandled(id, ...data);
181
+ onUnhandled == null ? void 0 : onUnhandled(id, ...data);
182
182
  }
183
183
  }
184
184
  function closed(_event) {
@@ -277,7 +277,7 @@ const wsClient = (url, {
277
277
  [op, pack(payload), getOptions(op, options) || {}],
278
278
  (error, result) => {
279
279
  socket.stop(id);
280
- error ? reject(Error("server." + error)) : resolve(unpack(result));
280
+ error ? reject(Error(`server.${error}`)) : resolve(unpack(result));
281
281
  }
282
282
  );
283
283
  });
@@ -300,7 +300,7 @@ const wsClient = (url, {
300
300
  (error, result) => {
301
301
  if (error) {
302
302
  socket.stop(id);
303
- end(Error("server." + error));
303
+ end(Error(`server.${error}`));
304
304
  return;
305
305
  }
306
306
  push(unpack(result));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graffy/client",
3
3
  "description": "Graffy client library for the browser, usin the `fetch()` or `WebSocket` APIs. This module is intended to be used with a Node.js server running Graffy Server.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.16.1",
5
+ "version": "0.16.2-alpha.1",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
- "@graffy/common": "0.16.1",
20
- "@graffy/stream": "0.16.1",
19
+ "@graffy/common": "0.16.2-alpha.1",
20
+ "@graffy/stream": "0.16.2-alpha.1",
21
21
  "debug": "^4.3.3"
22
22
  }
23
23
  }