@vielzeug/pulse 2.0.0 → 2.1.0

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 (46) hide show
  1. package/README.md +37 -42
  2. package/dist/_connection.cjs +2 -0
  3. package/dist/_connection.cjs.map +1 -0
  4. package/dist/_connection.d.ts +9 -0
  5. package/dist/_connection.d.ts.map +1 -0
  6. package/dist/_connection.js +107 -0
  7. package/dist/_connection.js.map +1 -0
  8. package/dist/channel.cjs +1 -1
  9. package/dist/channel.cjs.map +1 -1
  10. package/dist/channel.js +32 -35
  11. package/dist/channel.js.map +1 -1
  12. package/dist/heartbeat.cjs +1 -1
  13. package/dist/heartbeat.cjs.map +1 -1
  14. package/dist/heartbeat.d.ts.map +1 -1
  15. package/dist/heartbeat.js +1 -2
  16. package/dist/heartbeat.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/presence.cjs +1 -1
  20. package/dist/presence.cjs.map +1 -1
  21. package/dist/presence.d.ts.map +1 -1
  22. package/dist/presence.js +34 -35
  23. package/dist/presence.js.map +1 -1
  24. package/dist/pulse.cjs +1 -1
  25. package/dist/pulse.cjs.map +1 -1
  26. package/dist/pulse.d.ts +4 -13
  27. package/dist/pulse.d.ts.map +1 -1
  28. package/dist/pulse.iife.js +1 -1
  29. package/dist/pulse.iife.js.map +1 -1
  30. package/dist/pulse.js +1 -1
  31. package/dist/pulse.js.map +1 -1
  32. package/dist/types.d.ts +40 -69
  33. package/dist/types.d.ts.map +1 -1
  34. package/package.json +3 -4
  35. package/dist/_dev.cjs +0 -2
  36. package/dist/_dev.cjs.map +0 -1
  37. package/dist/_dev.d.ts +0 -2
  38. package/dist/_dev.d.ts.map +0 -1
  39. package/dist/_dev.js +0 -6
  40. package/dist/_dev.js.map +0 -1
  41. package/dist/reconnect.cjs +0 -2
  42. package/dist/reconnect.cjs.map +0 -1
  43. package/dist/reconnect.d.ts +0 -13
  44. package/dist/reconnect.d.ts.map +0 -1
  45. package/dist/reconnect.js +0 -32
  46. package/dist/reconnect.js.map +0 -1
@@ -1,13 +0,0 @@
1
- export type ReconnectHandle = {
2
- /**
3
- * Attempt a reconnect. Waits for the computed delay then calls `connect`.
4
- * Returns outcome details including success and, when available, the failure reason.
5
- */
6
- attempt(connect: () => Promise<void>, signal: AbortSignal, onReconnect?: (attempt: number) => void): Promise<{
7
- error?: unknown;
8
- ok: boolean;
9
- }>;
10
- /** Cancel any pending reconnect attempt and reset the counter. */
11
- reset(): void;
12
- };
13
- //# sourceMappingURL=reconnect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconnect.d.ts","sourceRoot":"","sources":["../src/reconnect.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,OAAO,CACL,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC5B,MAAM,EAAE,WAAW,EACnB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7C,kEAAkE;IAClE,KAAK,IAAI,IAAI,CAAC;CACf,CAAC"}
package/dist/reconnect.js DELETED
@@ -1,32 +0,0 @@
1
- import { defaultReconnectDelay as e, sleep as t } from "./_utils.js";
2
- //#region src/reconnect.ts
3
- var n = 5;
4
- function r(r) {
5
- if (!r) return {
6
- attempt: async () => ({ ok: !1 }),
7
- reset() {}
8
- };
9
- let i = r === !0 ? {} : r, a = i.maxAttempts ?? n, o = typeof i.delay == "function" ? i.delay : typeof i.delay == "number" ? () => i.delay : e, s = 0;
10
- return {
11
- async attempt(e, n, r) {
12
- if (s >= a) return { ok: !1 };
13
- let i = o(s);
14
- if (s++, r?.(s), await t(i, n), n.aborted) return { ok: !1 };
15
- try {
16
- return await e(), s = 0, { ok: !0 };
17
- } catch (e) {
18
- return {
19
- error: e,
20
- ok: !1
21
- };
22
- }
23
- },
24
- reset() {
25
- s = 0;
26
- }
27
- };
28
- }
29
- //#endregion
30
- export { r as createReconnect };
31
-
32
- //# sourceMappingURL=reconnect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconnect.js","names":[],"sources":["../src/reconnect.ts"],"sourcesContent":["import type { ReconnectOptions } from './types';\n\nimport { defaultReconnectDelay, sleep } from './_utils';\n\nconst DEFAULT_MAX_ATTEMPTS = 5;\n\nexport type ReconnectHandle = {\n /**\n * Attempt a reconnect. Waits for the computed delay then calls `connect`.\n * Returns outcome details including success and, when available, the failure reason.\n */\n attempt(\n connect: () => Promise<void>,\n signal: AbortSignal,\n onReconnect?: (attempt: number) => void,\n ): Promise<{ error?: unknown; ok: boolean }>;\n /** Cancel any pending reconnect attempt and reset the counter. */\n reset(): void;\n};\n\n/**\n * Create a stateful reconnect manager.\n * @internal\n */\nexport function createReconnect(opts: boolean | ReconnectOptions | undefined): ReconnectHandle {\n if (!opts) {\n return {\n attempt: async () => ({ ok: false }),\n reset() {},\n };\n }\n\n const options: ReconnectOptions = opts === true ? {} : opts;\n const maxAttempts = options.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;\n const delayFn: (attempt: number) => number =\n typeof options.delay === 'function'\n ? options.delay\n : typeof options.delay === 'number'\n ? () => options.delay as number\n : defaultReconnectDelay;\n\n let attempts = 0;\n\n return {\n async attempt(\n connect: () => Promise<void>,\n signal: AbortSignal,\n onReconnect?: (attempt: number) => void,\n ): Promise<{ error?: unknown; ok: boolean }> {\n if (attempts >= maxAttempts) return { ok: false };\n\n const delay = delayFn(attempts);\n\n attempts++;\n onReconnect?.(attempts);\n\n await sleep(delay, signal);\n\n if (signal.aborted) return { ok: false };\n\n try {\n await connect();\n\n attempts = 0;\n\n return { ok: true };\n } catch (error) {\n return { error, ok: false };\n }\n },\n\n reset() {\n attempts = 0;\n },\n };\n}\n"],"mappings":";;AAIA,IAAM,IAAuB;AAoB7B,SAAgB,EAAgB,GAA+D;CAC7F,IAAI,CAAC,GACH,OAAO;EACL,SAAS,aAAa,EAAE,IAAI,GAAM;EAClC,QAAQ,CAAC;CACX;CAGF,IAAM,IAA4B,MAAS,KAAO,CAAC,IAAI,GACjD,IAAc,EAAQ,eAAe,GACrC,IACJ,OAAO,EAAQ,SAAU,aACrB,EAAQ,QACR,OAAO,EAAQ,SAAU,iBACjB,EAAQ,QACd,GAEJ,IAAW;CAEf,OAAO;EACL,MAAM,QACJ,GACA,GACA,GAC2C;GAC3C,IAAI,KAAY,GAAa,OAAO,EAAE,IAAI,GAAM;GAEhD,IAAM,IAAQ,EAAQ,CAAQ;GAO9B,IALA,KACA,IAAc,CAAQ,GAEtB,MAAM,EAAM,GAAO,CAAM,GAErB,EAAO,SAAS,OAAO,EAAE,IAAI,GAAM;GAEvC,IAAI;IAKF,OAJA,MAAM,EAAQ,GAEd,IAAW,GAEJ,EAAE,IAAI,GAAK;GACpB,SAAS,GAAO;IACd,OAAO;KAAE;KAAO,IAAI;IAAM;GAC5B;EACF;EAEA,QAAQ;GACN,IAAW;EACb;CACF;AACF"}