@owlmeans/client-socket 0.1.18-rc.2 → 0.1.18-rc.21

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 CHANGED
@@ -1,29 +1,33 @@
1
1
  # @owlmeans/client-socket
2
2
 
3
- React hook and factory for WebSocket connections via OwlMeans module routing.
3
+ React hook and factory for WebSocket connections via OwlMeans entrypoint routing.
4
4
 
5
5
  ## Overview
6
6
 
7
- - `ws(module, request?)` — creates a `Connection` by resolving the module URL and opening a WebSocket
8
- - `useWs(module, request?)` — React hook wrapping `ws()` with lifecycle management
7
+ - `ws(entrypoint, request?)` — creates a `Connection` from the entrypoint's URL and opens a WebSocket
8
+ - `useWs(entrypoint, request?)` — React hook wrapping `ws()` with lifecycle management; it takes an
9
+ alias or an entrypoint
9
10
  - The returned `Connection` implements `@owlmeans/socket`'s `Connection` interface
10
11
 
11
12
  ## Installation
12
13
 
13
14
  ```bash
14
- bun add @owlmeans/client-socket
15
+ bun add @owlmeans/client-socket@^0.1.18-rc.13
15
16
  ```
16
17
 
17
18
  ## Usage
18
19
 
19
- Connect to a WebSocket module and observe events:
20
+ Connect to a WebSocket entrypoint and observe events:
20
21
 
21
22
  ```typescript
22
23
  import { useWs } from '@owlmeans/client-socket'
23
24
  import { MessageType } from '@owlmeans/socket'
25
+ import { useContext } from '@owlmeans/web-client'
26
+ import { appEntrypoints } from 'my-app-common'
24
27
 
25
28
  function ThinkingPanel({ storyId }: { storyId: string }) {
26
- const conn = useWs('story-thinking', { params: { id: storyId } })
29
+ const context = useContext()
30
+ const conn = useWs(context.entrypoint(appEntrypoints.api.storyThinking), { params: { id: storyId } })
27
31
 
28
32
  useEffect(() => {
29
33
  if (!conn) return
@@ -39,19 +43,19 @@ Direct connection (non-hook):
39
43
 
40
44
  ```typescript
41
45
  import { ws } from '@owlmeans/client-socket'
42
- import type { ClientModule } from '@owlmeans/client-module'
46
+ import { appEntrypoints } from 'my-app-common'
43
47
 
44
- const wsModule = context.module<ClientModule<string>>('story-thinking')
45
- const connection = await ws(wsModule, { params: { id: storyId } })
48
+ const wsEntrypoint = context.entrypoint(appEntrypoints.api.storyThinking)
49
+ const connection = await ws(wsEntrypoint, { params: { id: storyId } })
46
50
  ```
47
51
 
48
52
  ## API
49
53
 
50
- ### `ws(module, request?): Promise<Connection>`
54
+ ### `ws(entrypoint, request?): Promise<Connection>`
51
55
 
52
- Resolves the module URL, opens a WebSocket, and returns a `Connection` once the socket opens.
56
+ Builds the entrypoint's URL, opens a WebSocket, and returns a `Connection` once the socket opens.
53
57
 
54
- ### `useWs(module, request?): Connection | null`
58
+ ### `useWs(entrypoint, request?): Connection | null`
55
59
 
56
60
  React hook version of `ws()`. Returns `null` while connecting. Manages connection lifecycle (opens on mount, closes on unmount).
57
61
 
@@ -59,7 +63,7 @@ React hook version of `ws()`. Returns `null` while connecting. Manages connectio
59
63
 
60
64
  - [`@owlmeans/socket`](../socket) — `Connection` interface with `notify`, `observe`, `call` methods
61
65
  - [`@owlmeans/server-socket`](../server-socket) — server-side connection handler
62
- - [`@owlmeans/client-module`](../client-module) — `ClientModule` passed to `ws()`
66
+ - [`@owlmeans/client-entrypoint`](../client-entrypoint) — protocol bindings passed to `ws()`
63
67
 
64
68
  <!-- owlmeans:agent-guidance:start -->
65
69
  ## Agent guidance
@@ -69,7 +73,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
69
73
  your project's skill store (`.agents/skills/`):
70
74
 
71
75
  ```sh
72
- npx @owlmeans/agent-skills
76
+ npx @owlmeans/agent-skills@^0.1.18-rc.19
73
77
  ```
74
78
 
75
79
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/client-socket",
4
- "version": "0.1.18-rc.0",
5
- "generatedAt": "2026-08-16T22:20:50.502Z",
4
+ "version": "0.1.18-rc.21",
5
+ "generatedAt": "2026-09-12T13:51:53.529Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: client-socket
3
- description: How to use @owlmeans/client-socket — client-side WebSocket connection helpers for browsers and native clients. Auto-invoked when importing client socket primitives.
3
+ description: How to use @owlmeans/client-socket — opening a WebSocket Connection to a socket entrypoint from browsers and native clients, the useWs hook, the heartbeat and the system close frame. Auto-invoked when importing client socket primitives or wiring a browser subscription.
4
4
  user-invocable: false
5
5
  ---
6
6
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
@@ -8,23 +8,113 @@ user-invocable: false
8
8
  # @owlmeans/client-socket
9
9
 
10
10
  **Layer:** Client
11
- **Install:** `"@owlmeans/client-socket": "^0.1.18-rc.0"` in `dependencies`
11
+ **Install:** `"@owlmeans/client-socket": "^0.1.18-rc.21"` in `dependencies`
12
+
13
+ The browser carrier for `@owlmeans/socket`. It supplies the four members the connection model
14
+ leaves abstract — `send`, `close`, `prepare`, `authenticate` — and hands back a plain `Connection`,
15
+ so everything a screen does with the socket is the vocabulary of that package — `observe`,
16
+ `notify`, `call`, `listen`.
12
17
 
13
18
  ## Key Exports
14
19
 
15
20
  | Export | Description |
16
21
  |--------|-------------|
17
- | `Socket` types | Client socket connection shape |
18
- | Helpers | Connect, send, subscribe to channels |
22
+ | `ws(entrypoint, request?)` | Open a `Connection` to a socket entrypoint. Resolves once the socket is open, and only then |
23
+ | `useWs(entrypoint \| alias, request?)` | React hook — `Connection \| null` until it opens; re-opens on change and closes on unmount |
24
+ | `Config` / `Context` | The client config and context types this package expects |
25
+
26
+ ## How the address is built
27
+
28
+ A socket entrypoint is **addressed, not called**: `entrypointUrl` from
29
+ `@owlmeans/client-entrypoint/utils` turns the declaration plus the asking context into the `wss://`
30
+ URL — `:params` filled in, query appended, protocol and TLS taken from the entrypoint's address —
31
+ and the connection is opened on that. Nothing is hand-concatenated, so the same declaration the
32
+ server binds is the one the client dials.
33
+
34
+ Authentication rides on the query, because a WebSocket handshake carries no Authorization header a
35
+ browser can set: the token goes under `AUTH_QUERY`, and the server derives the connection's subject
36
+ from it.
37
+
38
+ **Take the authenticated hook, not this one.** `@owlmeans/client-auth` exports its own `useWs` that
39
+ wraps this one and fills `AUTH_QUERY` from `ctx.auth().token` when the request does not already
40
+ carry it. Import `useWs` from there for anything a guard protects, and from here only for an
41
+ entrypoint that is open to everyone.
42
+
43
+ The in-band auth sequence is a different thing from the query token, and only half of it is here.
44
+ `connection.auth(stage, payload)` sends the frame and resolves on the server's reply — that is the
45
+ client-initiated exchange, and it works. This carrier's own `authenticate` is a stub answering an
46
+ empty tuple, so an `Auth` frame the SERVER opens finds no stage to answer with and is dropped
47
+ without a reply: a browser can start an exchange, never answer one.
19
48
 
20
49
  ## Usage
21
50
 
22
51
  ```typescript
23
- import { connectSocket } from '@owlmeans/client-socket'
24
- const socket = await connectSocket(context, { url: 'wss://api/ws' })
25
- socket.subscribe('projects', msg => console.log(msg))
52
+ // A guarded entrypoint: this useWs fills AUTH_QUERY from the current session.
53
+ import { useWs } from '@owlmeans/client-auth'
54
+
55
+ // An open one: this useWs sends whatever query it is given, and nothing more.
56
+ // import { useWs } from '@owlmeans/client-socket'
57
+
58
+ const connection = useWs(app.api.project.stream, { params: { id } })
59
+
60
+ useEffect(() => {
61
+ if (connection == null) {
62
+ return
63
+ }
64
+ const stop = connection.observe<Update>('update', async msg => apply(msg.payload))
65
+
66
+ return () => stop()
67
+ }, [connection])
26
68
  ```
27
69
 
70
+ Both hooks take an alias or the entrypoint itself, and re-open when the alias, the `AUTH_QUERY`
71
+ value or the params change — the params are compared by content, so a fresh object literal each
72
+ render does not re-open. Both close the connection when the component unmounts, and both answer
73
+ `null` until the socket is open, so every effect that touches one guards on that.
74
+
75
+ ## Disconnects
76
+
77
+ The carrier sends a JSON `{ type: 'ping' }` every 30 seconds while the socket is open and clears
78
+ the heartbeat when it closes. A closing socket is reported to the connection's own `listen`
79
+ listeners as a system frame — `MessageType.System`, `event: 'close'`, payload `{ code }` — and
80
+ that is the only notice a handler gets, so a subscription opened on the connection is released
81
+ there:
82
+
83
+ ```typescript
84
+ connection.listen(async message => {
85
+ const msg = message as EventMessage<{ code: number }>
86
+ if (typeof message === 'object' && msg.type === MessageType.System && msg.event === 'close') {
87
+ await release()
88
+ }
89
+ })
90
+ ```
91
+
92
+ **Nothing here reconnects.** The carrier has no retry: it reports a close and stops there, and
93
+ `useWs` opens a new socket only when the alias, the `AUTH_QUERY` value or the params change. A
94
+ connection that drops stays dropped until something above it changes one of those or remounts the
95
+ component, so a screen that must survive a drop re-opens the socket itself and re-reads its data
96
+ from the server.
97
+
98
+ Outbound frames are stamped with `dt` and dropped rather than queued while the socket is not
99
+ `OPEN`, so a `notify` issued while the socket is down is lost rather than delivered late.
100
+
101
+ A handshake that never opens has no error path: `ws()` resolves only from the socket's open event,
102
+ so a refused upgrade, a rejected token or a dead network leaves its promise pending forever —
103
+ `useWs` stays `null` with nothing reported, and an awaited `ws()` call hangs. Treat a `null` that
104
+ never turns into a connection as a failed handshake, and give a screen that depends on one a
105
+ timeout of its own.
106
+
28
107
  ## Depends On
29
108
 
30
- - `@owlmeans/socket`, `@owlmeans/client-context`
109
+ - `@owlmeans/socket` — `createBasicConnection`, `MessageType`, the `Connection` contract
110
+ - `@owlmeans/client-entrypoint` — `entrypointUrl`, `provideRequest`
111
+ - `@owlmeans/client` — `useContext`, `useValue`; `@owlmeans/client-context` — the config type
112
+ - `@owlmeans/auth` — `AUTH_QUERY`
113
+ - `react` (peer)
114
+
115
+ ## Related
116
+
117
+ - `socket` — the message model every verb here belongs to
118
+ - `server-socket` — the far side: guard enforcement, and what it stamps on a frame
119
+ - `client-auth` — the `useWs` that carries the token; `client-job` — `useJobFeed`, a worked
120
+ subscription built on it
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAG3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAUlD,eAAO,MAAM,EAAE,WAAkB,gBAAgB,CAAC,MAAM,CAAC,YAAY,eAAe,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,KAAG,OAAO,CAAC,UAAU,CA0B5H,CAAA;AAED,eAAO,MAAM,KAAK,WAAY,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,KAAG,UAAU,GAAG,IAyBpH,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AASlD,eAAO,MAAM,EAAE,WAAkB,gBAAgB,CAAC,MAAM,CAAC,YAAY,eAAe,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,KAAG,OAAO,CAAC,UAAU,CAuB5H,CAAA;AAED,eAAO,MAAM,KAAK,WAAY,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,KAAG,UAAU,GAAG,IAyBpH,CAAA"}
package/build/helper.js CHANGED
@@ -1,19 +1,14 @@
1
1
  import { provideRequest } from '@owlmeans/client-entrypoint';
2
- import { EntrypointOutcome } from '@owlmeans/entrypoint';
3
- import { SocketInitializationError } from '@owlmeans/socket';
4
2
  import { makeConnection } from './utils/connection.js';
5
3
  import { assertContext } from '@owlmeans/context';
6
4
  import { useContext, useValue } from '@owlmeans/client';
7
5
  import { AUTH_QUERY } from '@owlmeans/auth';
8
- import { urlCall } from '@owlmeans/client-entrypoint/utils';
6
+ import { entrypointUrl } from '@owlmeans/client-entrypoint/utils';
9
7
  import { useEffect, useMemo } from 'react';
10
8
  export const ws = async (module, request) => {
11
9
  const ctx = assertContext(module.ctx, 'client-ws');
12
- request = request ?? provideRequest(module.getAlias(), module.getPath());
13
- const [url, state] = await urlCall({ ref: module })(request);
14
- if (state !== EntrypointOutcome.Ok) {
15
- throw new SocketInitializationError;
16
- }
10
+ request = request ?? provideRequest(module.alias, module.path());
11
+ const url = await entrypointUrl({ ref: module }, request);
17
12
  const socket = new WebSocket(url);
18
13
  return new Promise(resolve => {
19
14
  socket.onopen = () => {
@@ -34,11 +29,11 @@ export const useWs = (module, request) => {
34
29
  const ctx = useContext();
35
30
  const mod = useMemo(() => typeof module === 'string' ? ctx.entrypoint(module) : module, [module]);
36
31
  const connection = useValue(async () => {
37
- const _request = provideRequest(mod.getAlias(), mod.getPath());
32
+ const _request = provideRequest(mod.alias, mod.path());
38
33
  Object.assign(_request, request);
39
34
  return await ws(mod, _request);
40
35
  }, [
41
- mod.getAlias(),
36
+ mod.alias,
42
37
  request?.query?.[AUTH_QUERY],
43
38
  request?.params ? JSON.stringify(request.params) : undefined
44
39
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAg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CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEhB,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/client-socket",
3
- "version": "0.1.18-rc.2",
3
+ "version": "0.1.18-rc.21",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -30,14 +30,14 @@
30
30
  "typescript": "^7.0.2"
31
31
  },
32
32
  "dependencies": {
33
- "@owlmeans/auth": "^0.1.18-rc.2",
34
- "@owlmeans/basic-envelope": "^0.1.18-rc.2",
35
- "@owlmeans/client": "^0.1.18-rc.2",
36
- "@owlmeans/client-context": "^0.1.18-rc.2",
37
- "@owlmeans/client-entrypoint": "^0.1.18-rc.2",
38
- "@owlmeans/context": "^0.1.18-rc.2",
39
- "@owlmeans/entrypoint": "^0.1.18-rc.2",
40
- "@owlmeans/socket": "^0.1.18-rc.2"
33
+ "@owlmeans/auth": "^0.1.18-rc.16",
34
+ "@owlmeans/basic-envelope": "^0.1.18-rc.19",
35
+ "@owlmeans/client": "^0.1.18-rc.23",
36
+ "@owlmeans/client-context": "^0.1.18-rc.20",
37
+ "@owlmeans/client-entrypoint": "^0.1.18-rc.20",
38
+ "@owlmeans/context": "^0.1.18-rc.15",
39
+ "@owlmeans/entrypoint": "^0.1.18-rc.18",
40
+ "@owlmeans/socket": "^0.1.18-rc.16"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
package/src/helper.ts CHANGED
@@ -1,25 +1,20 @@
1
1
  import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
2
2
  import type { AbstractRequest } from '@owlmeans/entrypoint'
3
3
  import { provideRequest } from '@owlmeans/client-entrypoint'
4
- import { EntrypointOutcome } from '@owlmeans/entrypoint'
5
4
  import type { Connection } from '@owlmeans/socket'
6
- import { SocketInitializationError } from '@owlmeans/socket'
7
5
  import { makeConnection } from './utils/connection.js'
8
6
  import { assertContext } from '@owlmeans/context'
9
7
  import type { Config, Context } from './types.js'
10
8
  import { useContext, useValue } from '@owlmeans/client'
11
9
  import { AUTH_QUERY } from '@owlmeans/auth'
12
- import { urlCall } from '@owlmeans/client-entrypoint/utils'
10
+ import { entrypointUrl } from '@owlmeans/client-entrypoint/utils'
13
11
  import { useEffect, useMemo } from 'react'
14
12
 
15
13
  export const ws = async (module: ClientEntrypoint<string>, request?: AbstractRequest<{ token?: string }>): Promise<Connection> => {
16
14
  const ctx = assertContext<Config, Context>(module.ctx as Context, 'client-ws')
17
- request = request ?? provideRequest(module.getAlias(), module.getPath())
18
- const [url, state] = await urlCall({ ref: module })(request)
15
+ request = request ?? provideRequest(module.alias, module.path())
16
+ const url = await entrypointUrl({ ref: module }, request)
19
17
 
20
- if (state !== EntrypointOutcome.Ok) {
21
- throw new SocketInitializationError
22
- }
23
18
  const socket = new WebSocket(url)
24
19
 
25
20
  return new Promise(resolve => {
@@ -47,11 +42,11 @@ export const useWs = (module: string | ClientEntrypoint<any>, request?: Partial<
47
42
  [module]
48
43
  )
49
44
  const connection = useValue<Connection>(async () => {
50
- const _request = provideRequest(mod.getAlias(), mod.getPath())
45
+ const _request = provideRequest(mod.alias, mod.path())
51
46
  Object.assign(_request, request)
52
47
  return await ws(mod, _request)
53
48
  }, [
54
- mod.getAlias(),
49
+ mod.alias,
55
50
  request?.query?.[AUTH_QUERY],
56
51
  request?.params ? JSON.stringify(request.params) : undefined
57
52
  ])
package/build/.gitkeep DELETED
File without changes