iii-browser-sdk 0.25.0-rc.6 → 0.26.0-rc.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.
package/README.md CHANGED
@@ -10,8 +10,8 @@ Browser SDK for the [iii engine](https://github.com/iii-hq/iii) — WebSocket-ba
10
10
  The browser SDK turns your frontend into an iii Worker enabling:
11
11
 
12
12
  - **Persistent connection** — one WebSocket replaces many HTTP round-trips.
13
- - **Bi-directional communication** — the engine can invoke functions registered in the browser. Backend workers push data to the frontend with `trigger()`, enabling real-time patterns without polling.
14
- - **Same API** — `registerFunction`, `trigger`, `observe` — all the primitives you use server-side work identically in the browser.
13
+ - **Bi-directional communication** — the engine can invoke functions registered in the browser. Backend workers push data to the frontend with `call()` or by observing it, enabling real-time patterns without polling.
14
+ - **Same API** — `registerFunction`, `call`, `observe` and the observer hooks — all the primitives you use server-side work identically in the browser.
15
15
  - **Zero Node.js dependencies** — runs in any browser environment with native `WebSocket`.
16
16
 
17
17
  ## Install
@@ -40,7 +40,7 @@ iii.registerFunction('ui::show-notification', async (data: { title: string; body
40
40
  return { displayed: true }
41
41
  })
42
42
 
43
- const users = await iii.trigger({
43
+ const users = await iii.call({
44
44
  function_id: 'api::get::users',
45
45
  payload: {},
46
46
  })
@@ -48,17 +48,22 @@ const users = await iii.trigger({
48
48
 
49
49
  ## API
50
50
 
51
- | Operation | Signature | Description |
52
- | ------------------------ | --------------------------------------------------------------------------------- | -------------------------------------------------------------- |
53
- | Initialize | `registerWorker(url, options?)` | Connect to the engine via browser WebSocket. Returns `ISdk` |
54
- | Register function | `iii.registerFunction(id, handler, options?)` | Register a function the engine (or backend) can invoke |
55
- | Invoke (await) | `await iii.trigger({ function_id, payload })` | Invoke a function and wait for the result |
56
- | Invoke (fire-and-forget) | `iii.trigger({ function_id, payload, action: TriggerAction.Void() })` | Invoke without waiting |
57
- | Invoke (enqueue) | `iii.trigger({ function_id, payload, action: TriggerAction.Enqueue({ queue }) })` | Route invocation through a named queue |
58
- | Observe | `iii.observe({ function_id, args?, filters? }, target, options?)` | Invoke `target` on every matching invocation of a function |
59
- | Current invocation | `iii.currentInvocation()` / `iii.withInvocation(inv, fn)` | The invocation the running handler serves (caller, activation) |
60
- | Create channel | `createChannel(iii)` (from `iii-browser-sdk/helpers`) | Create a streaming channel pair (writer + reader) |
61
- | Shutdown | `iii.shutdown()` | Gracefully disconnect from the engine |
51
+ | Operation | Signature | Description |
52
+ | ------------------------ | ------------------------------------------------------------------------------ | -------------------------------------------------------------- |
53
+ | Initialize | `registerWorker(url, options?)` | Connect to the engine via browser WebSocket. Returns `ISdk` |
54
+ | Register function | `iii.registerFunction(id, handler, options?)` | Register a function that can be called by id and observed |
55
+ | Call (await) | `await iii.call({ function_id, payload })` | Call a function and wait for the result |
56
+ | Call (fire-and-forget) | `iii.call({ function_id, payload, action: CallAction.Void() })` | Call without waiting |
57
+ | Call (enqueue) | `iii.call({ function_id, payload, action: CallAction.Enqueue({ queue }) })` | Route the call through a named queue |
58
+ | Observe | `iii.observe('fn::id' \| { function_id, args?, filters? }, target, options?)` | Call `target` on every matching call of a function |
59
+ | Observer hooks | `onObserverAdded`, `onObserverRemoved`, `onObserverMatch`, `onObserverDeliver` | Change what observing a function this page hosts means |
60
+ | Call through an observer | `await iii.call({ observer, payload })` | Run an observer's target from a deliver hook |
61
+ | Current invocation | `iii.currentInvocation()` / `iii.withInvocation(inv, fn)` | The invocation the running handler serves (caller, activation) |
62
+ | Create channel | `createChannel(iii)` (from `iii-browser-sdk/helpers`) | Create a streaming channel pair (writer + reader) |
63
+ | Shutdown | `iii.shutdown()` | Gracefully disconnect from the engine |
64
+
65
+ `iii.trigger`, `TriggerAction` and `TriggerRequest` are deprecated aliases of
66
+ `iii.call`, `CallAction` and `CallRequest`: the same function, object and type.
62
67
 
63
68
  ### Registering Functions
64
69
 
@@ -71,26 +76,29 @@ iii.registerFunction('ui::show-notification', async (data: { title: string; body
71
76
  })
72
77
  ```
73
78
 
79
+ The handler's return value is what the function's observers observe.
80
+
74
81
  ### Calling Backend Functions
75
82
 
76
- Invoke any function registered in the engine directly from the browser:
83
+ Call any function registered in the engine directly from the browser:
77
84
 
78
85
  ```typescript
79
- const users = await iii.trigger({
86
+ const users = await iii.call({
80
87
  function_id: 'api::get::users',
81
88
  payload: {},
82
89
  })
83
90
  ```
84
91
 
85
- A call can carry `metadata` (any JSON, handed to the handler as its second
86
- argument and readable by observer filters as `metadata.*`), and a W3C
92
+ A call can carry `metadata` (any JSON value, handed to the handler as its
93
+ second argument and readable by observer filters as `metadata.*`; `null` is the
94
+ same as none, and a call through an observer takes none), and a W3C
87
95
  `traceparent` / `baggage` to continue a trace. The browser SDK has no
88
96
  OpenTelemetry: it never makes up a trace context. Inside a handler, calls
89
97
  forward the `traceparent` the handler was invoked with; a top-level call sends
90
98
  the one you pass, or none.
91
99
 
92
100
  ```typescript
93
- await iii.trigger({
101
+ await iii.call({
94
102
  function_id: 'orders::create',
95
103
  payload: cart,
96
104
  metadata: { page: 'checkout' },
@@ -105,15 +113,27 @@ with `localDispatch: false`.
105
113
 
106
114
  ### Observing Functions
107
115
 
108
- Every function is observable. The target is a registered function; it receives
109
- the `Observed` envelope (`input`, `output` or `error`, `caller`, ...).
116
+ Every function is observable. When `orders::ship` runs, its observers run. The
117
+ target is a registered function; it receives the `Observed` envelope (`input`,
118
+ `output` or `error`, `caller`, ...).
110
119
 
111
120
  ```typescript
121
+ import type { Observed } from 'iii-browser-sdk'
122
+
123
+ iii.registerFunction('ui::refresh-orders', async () => {
124
+ await ordersTable.reload()
125
+ return null
126
+ })
127
+
112
128
  iii.registerFunction('ui::order-shipped', async ({ input }: Observed<{ order_id: string }>) => {
113
129
  showToast(`Order ${input?.order_id} shipped`)
114
130
  return null
115
131
  })
116
132
 
133
+ // every successful call
134
+ iii.observe('orders::ship', 'ui::refresh-orders')
135
+
136
+ // only this customer's orders
117
137
  const shipped = iii.observe(
118
138
  { function_id: 'orders::ship', filters: { 'input.customer_id': { $eq: customerId } }, capture: ['input'] },
119
139
  'ui::order-shipped',
@@ -123,9 +143,129 @@ await shipped.ready()
123
143
  await shipped.dispose()
124
144
  ```
125
145
 
126
- A function can also hand its own events to the observers they belong to (owner
127
- delivery, `registerFunction(id, handler, { observe: { delivery: 'owner', onObserverAdded, onObserverRemoved } })`)
128
- and check `FunctionRef.isObserved()` before building an event nobody receives.
146
+ Filters are evaluated where the call is. The engine evaluates them for every
147
+ call it routes, holding the call's input, caller and metadata and the
148
+ answer's output or error. The SDK evaluates them for the calls a page makes
149
+ to its own functions in-process, which the engine never sees, and matches
150
+ each call through an index of the filters' `$eq` and `$in` conditions: with
151
+ 1,000 observers that each filter on their own `input.tenant`, a call
152
+ evaluates one filter.
153
+
154
+ The engine's own events are functions too: observe `EngineSources.FUNCTIONS_CHANGED`
155
+ (`engine::on-functions-changed`), `EngineSources.WORKERS_CHANGED` and the others
156
+ the same way.
157
+
158
+ ### Hosting Observable Functions
159
+
160
+ The worker that hosts a function decides what observing it means with four
161
+ hooks, each overriding a default:
162
+
163
+ | Hook | Default |
164
+ | ------------------------------------ | ------------------------------------------------------------------------------------- |
165
+ | `onObserverAdded(obs)` | accept the observer |
166
+ | `onObserverRemoved(obs)` | stop delivering to it and forget it |
167
+ | `onObserverMatch(obs, call)` | every observer wants every call |
168
+ | `onObserverDeliver(call, observers)` | run every matching observer whose filters match the call; return the handler's value |
169
+
170
+ `onObserverAdded` and `onObserverRemoved` can be set for every function the
171
+ page hosts, or for one function by id or on its `FunctionRef`.
172
+ `onObserverMatch` and `onObserverDeliver` are set per function. Each method
173
+ returns its receiver, and `null` removes a hook.
174
+
175
+ An event source returns the event it is called with. `args_format` describes
176
+ the `args` its observers pass, and `private: true` lets only this page call it
177
+ (its input and result then pass by reference, never copied):
178
+
179
+ ```typescript
180
+ import { ObserveRejection } from 'iii-browser-sdk'
181
+
182
+ iii
183
+ .registerFunction('ui::on-click', (click: { selector: string; x: number; y: number }) => click, {
184
+ args_format: { type: 'object', required: ['selector'], properties: { selector: { type: 'string' } } },
185
+ private: true,
186
+ })
187
+ .onObserverAdded((obs) => {
188
+ const selector = obs.args.selector as string
189
+ if (!document.querySelector(selector)) throw new ObserveRejection('NO_SUCH_ELEMENT', `nothing matches ${selector}`)
190
+ clicks.retain(selector, (event) =>
191
+ iii.call({ function_id: 'ui::on-click', payload: { selector, x: event.clientX, y: event.clientY } }),
192
+ )
193
+ })
194
+ .onObserverRemoved((obs) => clicks.release(obs.args.selector as string))
195
+ // each click reaches the observers of its selector
196
+ .onObserverMatch((obs, call) => obs.args.selector === call.input.selector)
197
+
198
+ // a backend worker observes it
199
+ // iii.observe({ function_id: 'ui::on-click', args: { selector: '#buy' } }, 'analytics::track-click')
200
+ ```
201
+
202
+ With many observers, match by keys instead: the SDK keeps an index, one
203
+ lookup per key whatever the number of observers.
204
+
205
+ ```typescript
206
+ iii.onObserverMatch('ui::on-click', {
207
+ observer: (obs) => obs.args.selector as string, // what this observer listens for
208
+ call: (call) => call.input.selector, // what this call is
209
+ })
210
+ ```
211
+
212
+ `iii.isObserved('ui::on-click', { input })` (or `isObserved({ input })` on the
213
+ `FunctionRef`) says whether a call would reach anyone, so a source can skip
214
+ building an event nobody receives.
215
+
216
+ A deliver hook delivers each call itself: it receives the call and the
217
+ observers that matched it, and what it returns is what the function's caller
218
+ gets back. It applies the observers' filters with `obs.matches(call)` and
219
+ runs their targets with a call through the observer:
220
+
221
+ ```typescript
222
+ iii.onObserverDeliver('ui::on-command', async (call) => {
223
+ const handler = commands.match(call.input)
224
+ if (!handler) return { handled: false }
225
+ if (!handler.obs.matches(call)) return { handled: false }
226
+ return iii.call({ observer: handler.obs, payload: call.input })
227
+ })
228
+ ```
229
+
230
+ `obs.accepted()` resolves once the SDK acked the observer; a call made then
231
+ reaches it. A source sends a new observer its initial state as a call of the
232
+ function with `metadata: { for_observer: obs.id }`, which the match hook gives
233
+ to that observer alone, so the target receives it in the shape of every call:
234
+
235
+ ```typescript
236
+ import { CallAction } from 'iii-browser-sdk'
237
+
238
+ iii.onObserverAdded('ui::on-click', (obs) => {
239
+ void obs
240
+ .accepted()
241
+ .then(() =>
242
+ iii.call({
243
+ function_id: 'ui::on-click',
244
+ payload: lastClick(obs.args.selector as string),
245
+ metadata: { for_observer: obs.id },
246
+ action: CallAction.Void(),
247
+ }),
248
+ )
249
+ .catch(() => {
250
+ // a rejected observer gets nothing
251
+ })
252
+ })
253
+ iii.onObserverMatch('ui::on-click', (obs, call) =>
254
+ call.metadata?.for_observer ? call.metadata.for_observer === obs.id : obs.args.selector === call.input.selector,
255
+ )
256
+ ```
257
+
258
+ With keys, file each observer under `for_observer:<id>` as well, and give such
259
+ a call that one key.
260
+
261
+ With `standby: true`, a second page that registers a function another
262
+ connection already hosts waits and takes it over (with its observers) when that
263
+ one leaves.
264
+
265
+ A function that sets `args_format`, `private: true`, `observable: false`, an
266
+ `onObserverMatch` hook or an `onObserverDeliver` hook needs an engine that
267
+ advertises `observe.v2`; against an older engine it stays unregistered, and the
268
+ SDK logs `UNSUPPORTED` once for it.
129
269
 
130
270
  ### The current invocation across `await`
131
271
 
@@ -143,13 +283,18 @@ re-enter it with `withInvocation` for what comes after:
143
283
  iii.registerFunction('ui::checkout', async (cart) => {
144
284
  const inv = iii.currentInvocation() // before the first await
145
285
  const quote = await fetchQuote(cart)
146
- return iii.withInvocation(inv, () => iii.trigger({ function_id: 'orders::create', payload: quote }))
286
+ return iii.withInvocation(inv, () => iii.call({ function_id: 'orders::create', payload: quote }))
147
287
  })
148
288
  ```
149
289
 
150
290
  `withInvocation(inv, fn)` runs `fn` in that invocation and returns what `fn`
151
- returns; `obs.emit` and `obs.call` made inside it belong to the invocation too.
152
- When `fn` is async, the invocation counts as running until its promise settles.
291
+ returns; the calls made inside it, through observers included, belong to the
292
+ invocation too. When `fn` is async, the invocation counts as running until its
293
+ promise settles.
294
+
295
+ A deliver hook runs in its function's invocation the same way: in scope up to
296
+ its first `await`. A call through an observer is routed by the observer alone,
297
+ so it reaches the observer's target from anywhere, after an `await` included.
153
298
 
154
299
  Calls made after an `await` without `withInvocation` are not treated as new
155
300
  chains. They carry the `observe_depth` of the deepest invocation running on the
@@ -158,28 +303,20 @@ stops an observer cycle whose target awaits before it calls back. The cost of
158
303
  guessing: with several invocations running at once the depth is over-counted,
159
304
  and a legitimate chain may be stopped early. Such calls carry a `caller` and
160
305
  `traceparent` only when that is unambiguous (exactly one invocation is running,
161
- and it is an observe activation); otherwise they carry neither. They never
162
- borrow an invocation's metadata, so `obs.emit` / `obs.call` filters on
163
- `metadata.*` only see it inside a real scope. An invocation that never settles
164
- stops counting as running after 10 minutes (a local call: at its timeout).
165
- Local calls to this worker's own functions are nested the same way: a recursion
166
- that awaits before each call still goes through the engine past 64 levels,
167
- while calls started together (a loop, `Promise.all`) count as one level. A
168
- known limitation: local calls started in separate ticks while earlier ones are
169
- still running look nested too, so a long-running, wide fan-out may send some of
170
- its calls through the engine (same results, more frames). While the socket is
171
- closed that never happens, since the engine could not take the call anyway: a
172
- function this worker hosts then runs here up to 256 local calls deep, and past
173
- that the call fails at once with the code `LOCAL_DEPTH_EXCEEDED`, so a runaway
174
- recursion neither overflows the stack nor freezes the page. Use
175
- `withInvocation` to say exactly which invocation a call belongs to.
176
-
177
- ### Trigger APIs (deprecated)
178
-
179
- `registerTrigger` and `registerTriggerType` keep working in 0.25 but are
180
- deprecated: they log a warning once per page. Use `iii.observe(source,
181
- target)` and `registerFunction(id, handler, { observe })` instead. See the
182
- [migration guide](https://iii.dev/docs/upgrading/from-0-24-x).
306
+ and it is an observe activation or its function's deliver hook is running);
307
+ otherwise they carry neither. An invocation that never settles stops counting
308
+ as running after 10 minutes (a local call: at its timeout). Local calls to this
309
+ worker's own functions are nested the same way: a recursion that awaits before
310
+ each call still goes through the engine past 64 levels, while calls started
311
+ together (a loop, `Promise.all`) count as one level. A known limitation: local
312
+ calls started in separate ticks while earlier ones are still running look
313
+ nested too, so a long-running, wide fan-out may send some of its calls through
314
+ the engine (same results, more frames). While the socket is closed that never
315
+ happens, since the engine could not take the call anyway: a function this
316
+ worker hosts then runs here up to 256 local calls deep, and past that the call
317
+ fails at once with the code `LOCAL_DEPTH_EXCEEDED`, so a runaway recursion
318
+ neither overflows the stack nor freezes the page. Use `withInvocation` to say
319
+ exactly which invocation a call belongs to.
183
320
 
184
321
  ### Receiving Live Invocations
185
322
 
package/dist/helpers.cjs CHANGED
@@ -1,11 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_utils = require('./utils-BUI0XQTZ.cjs');
2
+ const require_utils = require('./utils-Cy-Lu8WQ.cjs');
3
3
 
4
4
  //#region src/helpers.ts
5
5
  /**
6
6
  * Create a streaming channel pair for worker-to-worker data transfer.
7
- *
8
- * Free-function form of the previous `ISdk.createChannel` instance method.
9
7
  */
10
8
  function createChannel(iii, bufferSize) {
11
9
  return iii.__helpers_create_channel(bufferSize);
@@ -14,8 +12,6 @@ function createChannel(iii, bufferSize) {
14
12
  * Register a custom stream implementation by wiring its 5 callable methods
15
13
  * to `stream::get/set/delete/list/list_groups`.
16
14
  *
17
- * Free-function form of the previous `ISdk.createStream` instance method.
18
- *
19
15
  * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams
20
16
  */
21
17
  function createStream(iii, streamName, stream) {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Helper free functions that operate on an {@link ISdk} instance.\n *\n * These were previously instance methods on the SDK. They take the iii\n * instance as the first argument so the public API surface of `ISdk` stays\n * focused on the core lifecycle and registration methods.\n */\nimport type { Channel, ISdk } from './types'\nimport type { IStream } from './stream'\n\nexport { ChannelDirection, ChannelItem } from './channels'\nexport { extractChannelRefs, isChannelRef } from './utils'\n\ntype IIIWithHelperShims = ISdk & {\n __helpers_create_channel(bufferSize?: number): Promise<Channel>\n __helpers_create_stream<T>(name: string, stream: IStream<T>): void\n}\n\n/**\n * Create a streaming channel pair for worker-to-worker data transfer.\n *\n * Free-function form of the previous `ISdk.createChannel` instance method.\n */\nexport function createChannel(iii: ISdk, bufferSize?: number): Promise<Channel> {\n return (iii as IIIWithHelperShims).__helpers_create_channel(bufferSize)\n}\n\n/**\n * Register a custom stream implementation by wiring its 5 callable methods\n * to `stream::get/set/delete/list/list_groups`.\n *\n * Free-function form of the previous `ISdk.createStream` instance method.\n *\n * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams\n */\nexport function createStream<TData>(iii: ISdk, streamName: string, stream: IStream<TData>): void {\n ;(iii as IIIWithHelperShims).__helpers_create_stream(streamName, stream)\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,cAAc,KAAW,YAAuC;AAC9E,QAAQ,IAA2B,yBAAyB,WAAW;;;;;;;;;;AAWzE,SAAgB,aAAoB,KAAW,YAAoB,QAA8B;AAC9F,CAAC,IAA2B,wBAAwB,YAAY,OAAO"}
1
+ {"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Helper free functions that operate on an {@link ISdk} instance: each one\n * takes the client as its first argument, so `ISdk` itself keeps to the\n * connection lifecycle, functions, calls and observers.\n */\nimport type { Channel, ISdk } from './types'\nimport type { IStream } from './stream'\n\nexport { ChannelDirection, ChannelItem } from './channels'\nexport { extractChannelRefs, isChannelRef } from './utils'\n\ntype IIIWithHelperShims = ISdk & {\n __helpers_create_channel(bufferSize?: number): Promise<Channel>\n __helpers_create_stream<T>(name: string, stream: IStream<T>): void\n}\n\n/**\n * Create a streaming channel pair for worker-to-worker data transfer.\n */\nexport function createChannel(iii: ISdk, bufferSize?: number): Promise<Channel> {\n return (iii as IIIWithHelperShims).__helpers_create_channel(bufferSize)\n}\n\n/**\n * Register a custom stream implementation by wiring its 5 callable methods\n * to `stream::get/set/delete/list/list_groups`.\n *\n * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams\n */\nexport function createStream<TData>(iii: ISdk, streamName: string, stream: IStream<TData>): void {\n ;(iii as IIIWithHelperShims).__helpers_create_stream(streamName, stream)\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,cAAc,KAAW,YAAuC;AAC9E,QAAQ,IAA2B,yBAAyB,WAAW;;;;;;;;AASzE,SAAgB,aAAoB,KAAW,YAAoB,QAA8B;AAC9F,CAAC,IAA2B,wBAAwB,YAAY,OAAO"}
@@ -1,4 +1,4 @@
1
- import { B as ChannelItem, a as ISdk, ot as StreamChannelRef, r as Channel, z as ChannelDirection } from "./types-BGYN2Z4E.cjs";
1
+ import { N as StreamChannelRef, a as ISdk, r as Channel, v as ChannelDirection, y as ChannelItem } from "./types-KMHoWM6-.cjs";
2
2
  import { IStream } from "./stream.cjs";
3
3
 
4
4
  //#region src/utils.d.ts
@@ -22,16 +22,12 @@ declare const extractChannelRefs: (data: unknown) => Array<[string, StreamChanne
22
22
  //#region src/helpers.d.ts
23
23
  /**
24
24
  * Create a streaming channel pair for worker-to-worker data transfer.
25
- *
26
- * Free-function form of the previous `ISdk.createChannel` instance method.
27
25
  */
28
26
  declare function createChannel(iii: ISdk, bufferSize?: number): Promise<Channel>;
29
27
  /**
30
28
  * Register a custom stream implementation by wiring its 5 callable methods
31
29
  * to `stream::get/set/delete/list/list_groups`.
32
30
  *
33
- * Free-function form of the previous `ISdk.createStream` instance method.
34
- *
35
31
  * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams
36
32
  */
37
33
  declare function createStream<TData>(iii: ISdk, streamName: string, stream: IStream<TData>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.cts","names":[],"sources":["../src/utils.ts","../src/helpers.ts"],"mappings":";;;;;;;;;;cAmCa,YAAA,GAAgB,KAAA,cAAiB,KAAA,IAAS,gBAAA;AAkBvD;;;;;;;;AAAA,cAAa,kBAAA,GAAsB,IAAA,cAAgB,KAAA,UAAe,gBAAA;;;;;AAAlE;;;iBC9BgB,aAAA,CAAc,GAAA,EAAK,IAAA,EAAM,UAAA,YAAsB,OAAA,CAAQ,OAAA;;;;;;;;;iBAYvD,YAAA,OAAA,CAAoB,GAAA,EAAK,IAAA,EAAM,UAAA,UAAoB,MAAA,EAAQ,OAAA,CAAQ,KAAA"}
1
+ {"version":3,"file":"helpers.d.cts","names":[],"sources":["../src/utils.ts","../src/helpers.ts"],"mappings":";;;;;;;;;;cAmCa,YAAA,GAAgB,KAAA,cAAiB,KAAA,IAAS,gBAAA;AAkBvD;;;;;;;;AAAA,cAAa,kBAAA,GAAsB,IAAA,cAAgB,KAAA,UAAe,gBAAA;;;;;;iBClClD,aAAA,CAAc,GAAA,EAAK,IAAA,EAAM,UAAA,YAAsB,OAAA,CAAQ,OAAA;ADkCvE;;;;;;AAAA,iBCxBgB,YAAA,OAAA,CAAoB,GAAA,EAAK,IAAA,EAAM,UAAA,UAAoB,MAAA,EAAQ,OAAA,CAAQ,KAAA"}
@@ -1,4 +1,4 @@
1
- import { B as ChannelItem, a as ISdk, ot as StreamChannelRef, r as Channel, z as ChannelDirection } from "./types-Crw4auK5.mjs";
1
+ import { N as StreamChannelRef, a as ISdk, r as Channel, v as ChannelDirection, y as ChannelItem } from "./types-DqyCQ8JS.mjs";
2
2
  import { IStream } from "./stream.mjs";
3
3
 
4
4
  //#region src/utils.d.ts
@@ -22,16 +22,12 @@ declare const extractChannelRefs: (data: unknown) => Array<[string, StreamChanne
22
22
  //#region src/helpers.d.ts
23
23
  /**
24
24
  * Create a streaming channel pair for worker-to-worker data transfer.
25
- *
26
- * Free-function form of the previous `ISdk.createChannel` instance method.
27
25
  */
28
26
  declare function createChannel(iii: ISdk, bufferSize?: number): Promise<Channel>;
29
27
  /**
30
28
  * Register a custom stream implementation by wiring its 5 callable methods
31
29
  * to `stream::get/set/delete/list/list_groups`.
32
30
  *
33
- * Free-function form of the previous `ISdk.createStream` instance method.
34
- *
35
31
  * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams
36
32
  */
37
33
  declare function createStream<TData>(iii: ISdk, streamName: string, stream: IStream<TData>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.mts","names":[],"sources":["../src/utils.ts","../src/helpers.ts"],"mappings":";;;;;;;;;;cAmCa,YAAA,GAAgB,KAAA,cAAiB,KAAA,IAAS,gBAAA;AAkBvD;;;;;;;;AAAA,cAAa,kBAAA,GAAsB,IAAA,cAAgB,KAAA,UAAe,gBAAA;;;;;AAAlE;;;iBC9BgB,aAAA,CAAc,GAAA,EAAK,IAAA,EAAM,UAAA,YAAsB,OAAA,CAAQ,OAAA;;;;;;;;;iBAYvD,YAAA,OAAA,CAAoB,GAAA,EAAK,IAAA,EAAM,UAAA,UAAoB,MAAA,EAAQ,OAAA,CAAQ,KAAA"}
1
+ {"version":3,"file":"helpers.d.mts","names":[],"sources":["../src/utils.ts","../src/helpers.ts"],"mappings":";;;;;;;;;;cAmCa,YAAA,GAAgB,KAAA,cAAiB,KAAA,IAAS,gBAAA;AAkBvD;;;;;;;;AAAA,cAAa,kBAAA,GAAsB,IAAA,cAAgB,KAAA,UAAe,gBAAA;;;;;;iBClClD,aAAA,CAAc,GAAA,EAAK,IAAA,EAAM,UAAA,YAAsB,OAAA,CAAQ,OAAA;ADkCvE;;;;;;AAAA,iBCxBgB,YAAA,OAAA,CAAoB,GAAA,EAAK,IAAA,EAAM,UAAA,UAAoB,MAAA,EAAQ,OAAA,CAAQ,KAAA"}
package/dist/helpers.mjs CHANGED
@@ -1,10 +1,8 @@
1
- import { n as isChannelRef, o as ChannelDirection, s as ChannelItem, t as extractChannelRefs } from "./utils-Bz5eP_hN.mjs";
1
+ import { n as isChannelRef, o as ChannelDirection, s as ChannelItem, t as extractChannelRefs } from "./utils-CyT9CwWA.mjs";
2
2
 
3
3
  //#region src/helpers.ts
4
4
  /**
5
5
  * Create a streaming channel pair for worker-to-worker data transfer.
6
- *
7
- * Free-function form of the previous `ISdk.createChannel` instance method.
8
6
  */
9
7
  function createChannel(iii, bufferSize) {
10
8
  return iii.__helpers_create_channel(bufferSize);
@@ -13,8 +11,6 @@ function createChannel(iii, bufferSize) {
13
11
  * Register a custom stream implementation by wiring its 5 callable methods
14
12
  * to `stream::get/set/delete/list/list_groups`.
15
13
  *
16
- * Free-function form of the previous `ISdk.createStream` instance method.
17
- *
18
14
  * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams
19
15
  */
20
16
  function createStream(iii, streamName, stream) {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Helper free functions that operate on an {@link ISdk} instance.\n *\n * These were previously instance methods on the SDK. They take the iii\n * instance as the first argument so the public API surface of `ISdk` stays\n * focused on the core lifecycle and registration methods.\n */\nimport type { Channel, ISdk } from './types'\nimport type { IStream } from './stream'\n\nexport { ChannelDirection, ChannelItem } from './channels'\nexport { extractChannelRefs, isChannelRef } from './utils'\n\ntype IIIWithHelperShims = ISdk & {\n __helpers_create_channel(bufferSize?: number): Promise<Channel>\n __helpers_create_stream<T>(name: string, stream: IStream<T>): void\n}\n\n/**\n * Create a streaming channel pair for worker-to-worker data transfer.\n *\n * Free-function form of the previous `ISdk.createChannel` instance method.\n */\nexport function createChannel(iii: ISdk, bufferSize?: number): Promise<Channel> {\n return (iii as IIIWithHelperShims).__helpers_create_channel(bufferSize)\n}\n\n/**\n * Register a custom stream implementation by wiring its 5 callable methods\n * to `stream::get/set/delete/list/list_groups`.\n *\n * Free-function form of the previous `ISdk.createStream` instance method.\n *\n * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams\n */\nexport function createStream<TData>(iii: ISdk, streamName: string, stream: IStream<TData>): void {\n ;(iii as IIIWithHelperShims).__helpers_create_stream(streamName, stream)\n}\n"],"mappings":";;;;;;;;AAuBA,SAAgB,cAAc,KAAW,YAAuC;AAC9E,QAAQ,IAA2B,yBAAyB,WAAW;;;;;;;;;;AAWzE,SAAgB,aAAoB,KAAW,YAAoB,QAA8B;AAC9F,CAAC,IAA2B,wBAAwB,YAAY,OAAO"}
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Helper free functions that operate on an {@link ISdk} instance: each one\n * takes the client as its first argument, so `ISdk` itself keeps to the\n * connection lifecycle, functions, calls and observers.\n */\nimport type { Channel, ISdk } from './types'\nimport type { IStream } from './stream'\n\nexport { ChannelDirection, ChannelItem } from './channels'\nexport { extractChannelRefs, isChannelRef } from './utils'\n\ntype IIIWithHelperShims = ISdk & {\n __helpers_create_channel(bufferSize?: number): Promise<Channel>\n __helpers_create_stream<T>(name: string, stream: IStream<T>): void\n}\n\n/**\n * Create a streaming channel pair for worker-to-worker data transfer.\n */\nexport function createChannel(iii: ISdk, bufferSize?: number): Promise<Channel> {\n return (iii as IIIWithHelperShims).__helpers_create_channel(bufferSize)\n}\n\n/**\n * Register a custom stream implementation by wiring its 5 callable methods\n * to `stream::get/set/delete/list/list_groups`.\n *\n * @deprecated createStream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams\n */\nexport function createStream<TData>(iii: ISdk, streamName: string, stream: IStream<TData>): void {\n ;(iii as IIIWithHelperShims).__helpers_create_stream(streamName, stream)\n}\n"],"mappings":";;;;;;AAmBA,SAAgB,cAAc,KAAW,YAAuC;AAC9E,QAAQ,IAA2B,yBAAyB,WAAW;;;;;;;;AASzE,SAAgB,aAAoB,KAAW,YAAoB,QAA8B;AAC9F,CAAC,IAA2B,wBAAwB,YAAY,OAAO"}