iii-browser-sdk 0.25.0-rc.6 → 0.25.1-alpha.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 +174 -49
- package/dist/helpers.cjs +1 -5
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +1 -5
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.mts +1 -5
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +1 -5
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +1737 -1028
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +33 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1736 -1028
- package/dist/index.mjs.map +1 -1
- package/dist/stream.d.cts +2 -26
- package/dist/stream.d.cts.map +1 -1
- package/dist/stream.d.mts +2 -26
- package/dist/stream.d.mts.map +1 -1
- package/dist/{types-BGYN2Z4E.d.cts → types-Bf5tgTLe.d.cts} +617 -623
- package/dist/types-Bf5tgTLe.d.cts.map +1 -0
- package/dist/{types-Crw4auK5.d.mts → types-Bw5KRoof.d.mts} +617 -623
- package/dist/types-Bw5KRoof.d.mts.map +1 -0
- package/dist/{utils-BUI0XQTZ.cjs → utils-Cy-Lu8WQ.cjs} +22 -5
- package/dist/utils-Cy-Lu8WQ.cjs.map +1 -0
- package/dist/{utils-Bz5eP_hN.mjs → utils-CyT9CwWA.mjs} +22 -5
- package/dist/utils-CyT9CwWA.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/types-BGYN2Z4E.d.cts.map +0 -1
- package/dist/types-Crw4auK5.d.mts.map +0 -1
- package/dist/utils-BUI0XQTZ.cjs.map +0 -1
- package/dist/utils-Bz5eP_hN.mjs.map +0 -1
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 `
|
|
14
|
-
- **Same API** — `registerFunction`, `
|
|
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.
|
|
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
|
|
52
|
-
| ------------------------ |
|
|
53
|
-
| Initialize | `registerWorker(url, options?)`
|
|
54
|
-
| Register function | `iii.registerFunction(id, handler, options?)`
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
| Observe | `iii.observe({ function_id, args?, filters? }, target, options?)`
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
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`, `onObservationMatch`, `onObservationDeliver` | 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
|
-
|
|
83
|
+
Call any function registered in the engine directly from the browser:
|
|
77
84
|
|
|
78
85
|
```typescript
|
|
79
|
-
const users = await iii.
|
|
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
|
|
86
|
-
argument and readable by observer filters as `metadata
|
|
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.
|
|
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.
|
|
109
|
-
the `Observed` envelope (`input`,
|
|
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,117 @@ await shipped.ready()
|
|
|
123
143
|
await shipped.dispose()
|
|
124
144
|
```
|
|
125
145
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
+
| `onObservationMatch(obs, call)` | every observer wants every call |
|
|
168
|
+
| `onObservationDeliver(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
|
+
`onObservationMatch` and `onObservationDeliver` 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
|
+
.onObservationMatch((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.onObservationMatch('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.onObservationDeliver('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 by calling through
|
|
232
|
+
that observer, which runs its target alone with the payload as given:
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
import { CallAction } from 'iii-browser-sdk'
|
|
236
|
+
|
|
237
|
+
iii.onObserverAdded('ui::on-click', (obs) => {
|
|
238
|
+
void obs
|
|
239
|
+
.accepted()
|
|
240
|
+
.then(() =>
|
|
241
|
+
iii.call({
|
|
242
|
+
observer: obs,
|
|
243
|
+
payload: lastClick(obs.args.selector as string),
|
|
244
|
+
action: CallAction.Void(),
|
|
245
|
+
}),
|
|
246
|
+
)
|
|
247
|
+
.catch(() => {
|
|
248
|
+
// a rejected observer gets nothing
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
A function that sets `args_format`, `private: true`, `observable: false`, an
|
|
254
|
+
`onObservationMatch` hook or an `onObservationDeliver` hook needs an engine that
|
|
255
|
+
advertises `observe.v2`; against an older engine it stays unregistered, and the
|
|
256
|
+
SDK logs `UNSUPPORTED` once for it.
|
|
129
257
|
|
|
130
258
|
### The current invocation across `await`
|
|
131
259
|
|
|
@@ -143,13 +271,18 @@ re-enter it with `withInvocation` for what comes after:
|
|
|
143
271
|
iii.registerFunction('ui::checkout', async (cart) => {
|
|
144
272
|
const inv = iii.currentInvocation() // before the first await
|
|
145
273
|
const quote = await fetchQuote(cart)
|
|
146
|
-
return iii.withInvocation(inv, () => iii.
|
|
274
|
+
return iii.withInvocation(inv, () => iii.call({ function_id: 'orders::create', payload: quote }))
|
|
147
275
|
})
|
|
148
276
|
```
|
|
149
277
|
|
|
150
278
|
`withInvocation(inv, fn)` runs `fn` in that invocation and returns what `fn`
|
|
151
|
-
returns;
|
|
152
|
-
When `fn` is async, the invocation counts as running until its
|
|
279
|
+
returns; the calls made inside it, through observers included, belong to the
|
|
280
|
+
invocation too. When `fn` is async, the invocation counts as running until its
|
|
281
|
+
promise settles.
|
|
282
|
+
|
|
283
|
+
A deliver hook runs in its function's invocation the same way: in scope up to
|
|
284
|
+
its first `await`. A call through an observer is routed by the observer alone,
|
|
285
|
+
so it reaches the observer's target from anywhere, after an `await` included.
|
|
153
286
|
|
|
154
287
|
Calls made after an `await` without `withInvocation` are not treated as new
|
|
155
288
|
chains. They carry the `observe_depth` of the deepest invocation running on the
|
|
@@ -158,28 +291,20 @@ stops an observer cycle whose target awaits before it calls back. The cost of
|
|
|
158
291
|
guessing: with several invocations running at once the depth is over-counted,
|
|
159
292
|
and a legitimate chain may be stopped early. Such calls carry a `caller` and
|
|
160
293
|
`traceparent` only when that is unambiguous (exactly one invocation is running,
|
|
161
|
-
and it is an observe activation
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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).
|
|
294
|
+
and it is an observe activation or its function's deliver hook is running);
|
|
295
|
+
otherwise they carry neither. An invocation that never settles stops counting
|
|
296
|
+
as running after 10 minutes (a local call: at its timeout). Local calls to this
|
|
297
|
+
worker's own functions are nested the same way: a recursion that awaits before
|
|
298
|
+
each call still goes through the engine past 64 levels, while calls started
|
|
299
|
+
together (a loop, `Promise.all`) count as one level. A known limitation: local
|
|
300
|
+
calls started in separate ticks while earlier ones are still running look
|
|
301
|
+
nested too, so a long-running, wide fan-out may send some of its calls through
|
|
302
|
+
the engine (same results, more frames). While the socket is closed that never
|
|
303
|
+
happens, since the engine could not take the call anyway: a function this
|
|
304
|
+
worker hosts then runs here up to 256 local calls deep, and past that the call
|
|
305
|
+
fails at once with the code `LOCAL_DEPTH_EXCEEDED`, so a runaway recursion
|
|
306
|
+
neither overflows the stack nor freezes the page. Use `withInvocation` to say
|
|
307
|
+
exactly which invocation a call belongs to.
|
|
183
308
|
|
|
184
309
|
### Receiving Live Invocations
|
|
185
310
|
|
package/dist/helpers.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils = require('./utils-
|
|
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) {
|
package/dist/helpers.cjs.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { N as StreamChannelRef, a as ISdk, r as Channel, v as ChannelDirection, y as ChannelItem } from "./types-Bf5tgTLe.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;
|
package/dist/helpers.d.cts.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/helpers.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { N as StreamChannelRef, a as ISdk, r as Channel, v as ChannelDirection, y as ChannelItem } from "./types-Bw5KRoof.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;
|
package/dist/helpers.d.mts.map
CHANGED
|
@@ -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
|
|
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-
|
|
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) {
|
package/dist/helpers.mjs.map
CHANGED
|
@@ -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
|
|
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"}
|