@vielzeug/pulse 2.0.1 → 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.
- package/README.md +37 -42
- package/dist/_connection.cjs +2 -0
- package/dist/_connection.cjs.map +1 -0
- package/dist/_connection.d.ts +9 -0
- package/dist/_connection.d.ts.map +1 -0
- package/dist/_connection.js +107 -0
- package/dist/_connection.js.map +1 -0
- package/dist/channel.cjs +1 -1
- package/dist/channel.cjs.map +1 -1
- package/dist/channel.js +32 -35
- package/dist/channel.js.map +1 -1
- package/dist/heartbeat.cjs +1 -1
- package/dist/heartbeat.cjs.map +1 -1
- package/dist/heartbeat.d.ts.map +1 -1
- package/dist/heartbeat.js +1 -2
- package/dist/heartbeat.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/presence.cjs +1 -1
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +34 -35
- package/dist/presence.js.map +1 -1
- package/dist/pulse.cjs +1 -1
- package/dist/pulse.cjs.map +1 -1
- package/dist/pulse.d.ts +4 -13
- package/dist/pulse.d.ts.map +1 -1
- package/dist/pulse.iife.js +1 -1
- package/dist/pulse.iife.js.map +1 -1
- package/dist/pulse.js +1 -1
- package/dist/pulse.js.map +1 -1
- package/dist/types.d.ts +40 -69
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/_dev.cjs +0 -2
- package/dist/_dev.cjs.map +0 -1
- package/dist/_dev.d.ts +0 -2
- package/dist/_dev.d.ts.map +0 -1
- package/dist/_dev.js +0 -6
- package/dist/_dev.js.map +0 -1
- package/dist/reconnect.cjs +0 -2
- package/dist/reconnect.cjs.map +0 -1
- package/dist/reconnect.d.ts +0 -13
- package/dist/reconnect.d.ts.map +0 -1
- package/dist/reconnect.js +0 -32
- package/dist/reconnect.js.map +0 -1
package/dist/reconnect.d.ts.map
DELETED
|
@@ -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
|
package/dist/reconnect.js.map
DELETED
|
@@ -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"}
|