@solidrt/flux-types 0.0.10 → 0.0.13

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.
@@ -0,0 +1,31 @@
1
+ // Timers, microtask scheduling, and the monotonic clock. flux's timers differ
2
+ // from the browser in two ways: the delay is required, and no extra callback
3
+ // arguments are forwarded.
4
+
5
+ /**
6
+ * Run `callback` after at least `ms` milliseconds. Returns a timer id for
7
+ * {@link clearTimeout}.
8
+ */
9
+ declare function setTimeout(callback: () => void, ms: number): number
10
+ /** Cancel a pending timeout. Throws on an unknown id. */
11
+ declare function clearTimeout(id: number): void
12
+ /**
13
+ * Run `callback` every `ms` milliseconds. Returns a timer id for
14
+ * {@link clearInterval}.
15
+ */
16
+ declare function setInterval(callback: () => void, ms: number): number
17
+ /** Cancel a running interval. Throws on an unknown id. */
18
+ declare function clearInterval(id: number): void
19
+ /**
20
+ * Queue `callback` to run as a microtask: after the current job finishes, before
21
+ * any timer fires.
22
+ */
23
+ declare function queueMicrotask(callback: () => void): void
24
+
25
+ declare let performance: {
26
+ /**
27
+ * Milliseconds since a monotonic origin (high-resolution, not wall-clock). Use
28
+ * for measuring durations, not for calendar time.
29
+ */
30
+ now(): number
31
+ }
@@ -0,0 +1,62 @@
1
+ // The web-standard WebSocket client. A deliberate subset: handler properties
2
+ // only (no addEventListener), plain-object events (not Event instances), ws://
3
+ // only (wss:// is not supported yet), and send accepts only string or Uint8Array.
4
+
5
+ /** The event passed to {@link WebSocket.onopen}. */
6
+ interface WebSocketOpenEvent {
7
+ type: "open"
8
+ }
9
+
10
+ /** The event passed to {@link WebSocket.onmessage}. */
11
+ interface WebSocketMessageEvent {
12
+ type: "message"
13
+ /** Text frames arrive as a string, binary frames as a Uint8Array. */
14
+ data: string | Uint8Array
15
+ }
16
+
17
+ /** The event passed to {@link WebSocket.onerror}. */
18
+ interface WebSocketErrorEvent {
19
+ type: "error"
20
+ message: string
21
+ }
22
+
23
+ /** The event passed to {@link WebSocket.onclose}. */
24
+ interface WebSocketCloseEvent {
25
+ type: "close"
26
+ code: number
27
+ reason: string
28
+ wasClean: boolean
29
+ }
30
+
31
+ interface WebSocket {
32
+ readonly url: string
33
+ /** Connection state: CONNECTING 0, OPEN 1, CLOSING 2, CLOSED 3. */
34
+ readonly readyState: number
35
+ onopen: ((event: WebSocketOpenEvent) => void) | null
36
+ onmessage: ((event: WebSocketMessageEvent) => void) | null
37
+ onerror: ((event: WebSocketErrorEvent) => void) | null
38
+ onclose: ((event: WebSocketCloseEvent) => void) | null
39
+ /**
40
+ * Queue a message: a string sends a text frame, a Uint8Array a binary frame.
41
+ * Throws while CONNECTING; dropped once the socket is closing or closed.
42
+ */
43
+ send(data: string | Uint8Array): void
44
+ /**
45
+ * Start the closing handshake. `code` must be 1000 or in 3000..4999; `reason`
46
+ * must be 123 bytes or fewer.
47
+ */
48
+ close(code?: number, reason?: string): void
49
+ readonly CONNECTING: 0
50
+ readonly OPEN: 1
51
+ readonly CLOSING: 2
52
+ readonly CLOSED: 3
53
+ }
54
+
55
+ declare let WebSocket: {
56
+ /** Open a connection. `url` must be ws:// (wss:// is not supported yet). */
57
+ new (url: string): WebSocket
58
+ readonly CONNECTING: 0
59
+ readonly OPEN: 1
60
+ readonly CLOSING: 2
61
+ readonly CLOSED: 3
62
+ }