@caprid/relay 0.0.0 → 0.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/LICENSE +202 -0
- package/README.md +160 -1
- package/dist/connect-session.d.ts +125 -0
- package/dist/connect-session.d.ts.map +1 -0
- package/dist/connect-session.js +300 -0
- package/dist/connect-session.js.map +1 -0
- package/dist/connect.d.ts +143 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +129 -0
- package/dist/connect.js.map +1 -0
- package/dist/delivery-timeouts.d.ts +37 -0
- package/dist/delivery-timeouts.d.ts.map +1 -0
- package/dist/delivery-timeouts.js +48 -0
- package/dist/delivery-timeouts.js.map +1 -0
- package/dist/document-service.d.ts +58 -0
- package/dist/document-service.d.ts.map +1 -0
- package/dist/document-service.js +166 -0
- package/dist/document-service.js.map +1 -0
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +99 -0
- package/dist/errors.js.map +1 -0
- package/dist/frame-reader.d.ts +81 -0
- package/dist/frame-reader.d.ts.map +1 -0
- package/dist/frame-reader.js +110 -0
- package/dist/frame-reader.js.map +1 -0
- package/dist/frame-writer.d.ts +109 -0
- package/dist/frame-writer.d.ts.map +1 -0
- package/dist/frame-writer.js +409 -0
- package/dist/frame-writer.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/media-track-properties.d.ts +59 -0
- package/dist/media-track-properties.d.ts.map +1 -0
- package/dist/media-track-properties.js +120 -0
- package/dist/media-track-properties.js.map +1 -0
- package/dist/media.d.ts +28 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +28 -0
- package/dist/media.js.map +1 -0
- package/dist/namespace-events.d.ts +44 -0
- package/dist/namespace-events.d.ts.map +1 -0
- package/dist/namespace-events.js +107 -0
- package/dist/namespace-events.js.map +1 -0
- package/dist/node.d.ts +75 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +114 -0
- package/dist/node.js.map +1 -0
- package/dist/payload.d.ts +8 -0
- package/dist/payload.d.ts.map +1 -0
- package/dist/payload.js +23 -0
- package/dist/payload.js.map +1 -0
- package/dist/publish.d.ts +209 -0
- package/dist/publish.d.ts.map +1 -0
- package/dist/publish.js +123 -0
- package/dist/publish.js.map +1 -0
- package/dist/room-endpoint.d.ts +21 -0
- package/dist/room-endpoint.d.ts.map +1 -0
- package/dist/room-endpoint.js +47 -0
- package/dist/room-endpoint.js.map +1 -0
- package/dist/send-order.d.ts +14 -0
- package/dist/send-order.d.ts.map +1 -0
- package/dist/send-order.js +11 -0
- package/dist/send-order.js.map +1 -0
- package/dist/settling-groups.d.ts +35 -0
- package/dist/settling-groups.d.ts.map +1 -0
- package/dist/settling-groups.js +73 -0
- package/dist/settling-groups.js.map +1 -0
- package/dist/subscription-events.d.ts +51 -0
- package/dist/subscription-events.d.ts.map +1 -0
- package/dist/subscription-events.js +125 -0
- package/dist/subscription-events.js.map +1 -0
- package/dist/subscription.d.ts +207 -0
- package/dist/subscription.d.ts.map +1 -0
- package/dist/subscription.js +283 -0
- package/dist/subscription.js.map +1 -0
- package/dist/supervised-publisher.d.ts +92 -0
- package/dist/supervised-publisher.d.ts.map +1 -0
- package/dist/supervised-publisher.js +839 -0
- package/dist/supervised-publisher.js.map +1 -0
- package/dist/supervised-subscriber.d.ts +201 -0
- package/dist/supervised-subscriber.d.ts.map +1 -0
- package/dist/supervised-subscriber.js +1420 -0
- package/dist/supervised-subscriber.js.map +1 -0
- package/dist/supervision.d.ts +78 -0
- package/dist/supervision.d.ts.map +1 -0
- package/dist/supervision.js +149 -0
- package/dist/supervision.js.map +1 -0
- package/dist/switchable.d.ts +164 -0
- package/dist/switchable.d.ts.map +1 -0
- package/dist/switchable.js +327 -0
- package/dist/switchable.js.map +1 -0
- package/dist/validation.d.ts +64 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +137 -0
- package/dist/validation.js.map +1 -0
- package/dist/write-slot.d.ts +87 -0
- package/dist/write-slot.d.ts.map +1 -0
- package/dist/write-slot.js +519 -0
- package/dist/write-slot.js.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-slot.d.ts","sourceRoot":"","sources":["../src/write-slot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,KAAK,gBAAgB,EAItB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAErE,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3E,+FAA+F;IAC/F,cAAc,EAAE,cAAc,CAAC;IAC/B,+FAA+F;IAC/F,kBAAkB,IAAI,OAAO,GAAG,SAAS,CAAC;IAC1C,2EAA2E;IAC3E,UAAU,IAAI,IAAI,CAAC;IACnB,gFAAgF;IAChF,QAAQ,IAAI,IAAI,CAAC;IACjB,gEAAgE;IAChE,cAAc,EAAE,MAAM,CAAC;IACvB,iHAAiH;IACjH,aAAa,EAAE,gBAAgB,CAAC;IAChC,wGAAwG;IACxG,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC1D;AAED,MAAM,WAAW,SAAS;IACxB,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,yGAAyG;IACzG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC3C,6FAA6F;IAC7F,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACnC;AAqCD,yCAAyC;AACzC,eAAO,MAAM,GAAG,cAA0B,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,MAAgC,CAAC;AAEtE,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,wBAAgB,eAAe,CAAC,IAAI,EAAE,qBAAqB,GAAG,SAAS,CAuetE"}
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The write slot: a track's single place for a pending operation (see CONTEXT.md).
|
|
3
|
+
*
|
|
4
|
+
* One slot per registered track. It owns the relay's demand binding for the track, the one active
|
|
5
|
+
* operation (a single write or an open group) and its phases, the write deadline, cancellation, and
|
|
6
|
+
* the demand observers behind `hasDemand` and `demandChanges()`. Its public face is the
|
|
7
|
+
* {@link RelayTrackWriter} the application holds; the publisher connection drives it through two
|
|
8
|
+
* inbound calls, `bind()` when the relay's binding changes and `disconnect()` when the connection
|
|
9
|
+
* ends.
|
|
10
|
+
*
|
|
11
|
+
* An operation completes once the transport has taken its group's FIN, not once the relay has
|
|
12
|
+
* acknowledged it: the slot hands the FIN over, frees itself, and passes the group on to the
|
|
13
|
+
* connection as a settling group (see CONTEXT.md). Only the group's own delivery timeout resets a
|
|
14
|
+
* settling group, and nothing reports how it ends.
|
|
15
|
+
*
|
|
16
|
+
* The slot enforces the group's delivery timeouts (draft-ietf-moq-transport-22 §5.2, see
|
|
17
|
+
* delivery-timeouts.ts), fixed per group: the subscriber's side just before the group's stream opens
|
|
18
|
+
* (until then only the publisher's applies), the publisher's side from the first object or the track. The object timeout
|
|
19
|
+
* runs from the application's call until the transport takes the object, so waiting for demand, for
|
|
20
|
+
* settling room and for the stream all count, and it fails the operation with `DELIVERY_TIMEOUT`. The
|
|
21
|
+
* subgroup timeout runs from the FIN's hand-over and resets the settling group with code
|
|
22
|
+
* DELIVERY_TIMEOUT if the relay has not acknowledged it by then; it outlives the subscription and the
|
|
23
|
+
* track, and only the connection's end stops it.
|
|
24
|
+
*
|
|
25
|
+
* Everything the slot borrows enters through {@link WriteSlotDependencies}: how to open a subgroup
|
|
26
|
+
* stream, the connection's settling-group limit, whether the namespace is solicited, whether the
|
|
27
|
+
* connection is still open, how to end the track in the core, and both sides' delivery timeouts.
|
|
28
|
+
* Tests drive a slot with an in-memory subgroup writer and fake timers; the "Write phases and
|
|
29
|
+
* interruptions" table in spec/behavior.md is the list they cover.
|
|
30
|
+
*/
|
|
31
|
+
import { streamResetReason } from '@caprid/moq-core';
|
|
32
|
+
import { effectiveTimeouts, NO_DELIVERY_TIMEOUTS, publisherTimeouts, } from './delivery-timeouts.js';
|
|
33
|
+
import { isStreamStop, RelayError, transportError } from './errors.js';
|
|
34
|
+
import { encodeJSON, encodeText } from './payload.js';
|
|
35
|
+
import { objectPropertyPairs, payloadBytes } from './validation.js';
|
|
36
|
+
/**
|
|
37
|
+
* Stream reset codes a publisher sends (draft-ietf-moq-transport-22 §12.5, registry §16.11.4).
|
|
38
|
+
* The core defines the same values but does not export them.
|
|
39
|
+
*/
|
|
40
|
+
export const RESET_CODE = {
|
|
41
|
+
INTERNAL_ERROR: 0x0,
|
|
42
|
+
CANCELLED: 0x1,
|
|
43
|
+
DELIVERY_TIMEOUT: 0x2,
|
|
44
|
+
SESSION_CLOSED: 0x3,
|
|
45
|
+
GOING_AWAY: 0x4,
|
|
46
|
+
};
|
|
47
|
+
/** The reason a stream reset hands the transport (TA-17): see `streamResetReason`. */
|
|
48
|
+
function resetReason(code, cause) {
|
|
49
|
+
const message = cause instanceof Error ? cause.message : 'Publish operation reset';
|
|
50
|
+
return streamResetReason(code, message, { cause });
|
|
51
|
+
}
|
|
52
|
+
/** The code for a reset caused by the connection ending. */
|
|
53
|
+
function connectionResetCode(error) {
|
|
54
|
+
return error instanceof RelayError && error.code === 'GOAWAY' ? RESET_CODE.GOING_AWAY : RESET_CODE.SESSION_CLOSED;
|
|
55
|
+
}
|
|
56
|
+
/** A monotonic clock for object ages. */
|
|
57
|
+
export const now = () => performance.now();
|
|
58
|
+
/**
|
|
59
|
+
* An internal option on `write()` and `openGroup()`: when, on {@link now}, the application made the call. A wrapper that
|
|
60
|
+
* checks the arguments before handing them on (the supervised publisher) passes it, so its own work counts toward the
|
|
61
|
+
* object's delivery timeout (§5.2: the clock starts when the application provides the object).
|
|
62
|
+
*/
|
|
63
|
+
export const CALL_STARTED_AT = Symbol('callStartedAt');
|
|
64
|
+
export function createWriteSlot(deps) {
|
|
65
|
+
const { openSubgroup, settlingGroups, namespaceSolicited, assertOpen, endTrack, writeTimeoutMs, trackTimeouts, subscriberTimeouts, } = deps;
|
|
66
|
+
let alias;
|
|
67
|
+
let ended = false;
|
|
68
|
+
let nextGroupId = 0;
|
|
69
|
+
let active;
|
|
70
|
+
const watchers = new Set();
|
|
71
|
+
// Subgroup timers of this track's settling groups. They outlive the subscription and the track;
|
|
72
|
+
// only the connection's end clears them.
|
|
73
|
+
const subgroupTimers = new Set();
|
|
74
|
+
const notify = (value) => {
|
|
75
|
+
for (const watcher of watchers)
|
|
76
|
+
watcher(value);
|
|
77
|
+
};
|
|
78
|
+
const end = () => {
|
|
79
|
+
if (ended)
|
|
80
|
+
return;
|
|
81
|
+
ended = true;
|
|
82
|
+
endTrack();
|
|
83
|
+
notify(undefined);
|
|
84
|
+
watchers.clear();
|
|
85
|
+
};
|
|
86
|
+
const close = (error = new RelayError('CLOSED', 'Published track is closed', active?.phase ?? 'waiting-for-demand'), code = RESET_CODE.CANCELLED) => {
|
|
87
|
+
if (ended)
|
|
88
|
+
return;
|
|
89
|
+
active?.cancel(error, code);
|
|
90
|
+
end();
|
|
91
|
+
};
|
|
92
|
+
const assertWritable = () => {
|
|
93
|
+
assertOpen();
|
|
94
|
+
// Refused before an operation starts: nothing of this write was sent (spec/behavior.md).
|
|
95
|
+
if (ended)
|
|
96
|
+
throw new RelayError('CLOSED', 'Published track is closed', 'waiting-for-demand');
|
|
97
|
+
if (active)
|
|
98
|
+
throw new RelayError('WRITE_PENDING', 'A write or group is already pending; await it before writing another object', 'writing');
|
|
99
|
+
};
|
|
100
|
+
const begin = (kind, signal) => {
|
|
101
|
+
let wake;
|
|
102
|
+
let reject;
|
|
103
|
+
const demand = new Promise((resolve) => {
|
|
104
|
+
wake = resolve;
|
|
105
|
+
});
|
|
106
|
+
const interrupted = new Promise((_, rejectPromise) => {
|
|
107
|
+
reject = rejectPromise;
|
|
108
|
+
});
|
|
109
|
+
// An open group can be aborted between calls, when nobody is awaiting this promise.
|
|
110
|
+
void interrupted.catch(() => { });
|
|
111
|
+
const abort = () => {
|
|
112
|
+
const reason = signal?.reason;
|
|
113
|
+
operation.cancel(reason === undefined ? new RelayError('CLOSED', 'Publish operation aborted', operation.phase) : reason, RESET_CODE.CANCELLED);
|
|
114
|
+
};
|
|
115
|
+
const operation = {
|
|
116
|
+
kind,
|
|
117
|
+
phase: 'waiting-for-demand',
|
|
118
|
+
publisher: trackTimeouts,
|
|
119
|
+
subscriber: NO_DELIVERY_TIMEOUTS,
|
|
120
|
+
timeouts: effectiveTimeouts(trackTimeouts, NO_DELIVERY_TIMEOUTS),
|
|
121
|
+
objectStartedAt: undefined,
|
|
122
|
+
objectTimer: undefined,
|
|
123
|
+
alias: undefined,
|
|
124
|
+
writer: undefined,
|
|
125
|
+
cancelled: false,
|
|
126
|
+
failure: undefined,
|
|
127
|
+
code: RESET_CODE.INTERNAL_ERROR,
|
|
128
|
+
demand,
|
|
129
|
+
interrupted,
|
|
130
|
+
wake,
|
|
131
|
+
cleanup() {
|
|
132
|
+
signal?.removeEventListener('abort', abort);
|
|
133
|
+
untimeObject(operation);
|
|
134
|
+
},
|
|
135
|
+
cancel(error, code) {
|
|
136
|
+
if (operation.cancelled)
|
|
137
|
+
return;
|
|
138
|
+
operation.cancelled = true;
|
|
139
|
+
operation.failure = error;
|
|
140
|
+
operation.code = code;
|
|
141
|
+
operation.writer?.abort(resetReason(code, error));
|
|
142
|
+
if (active === operation)
|
|
143
|
+
active = undefined;
|
|
144
|
+
operation.cleanup();
|
|
145
|
+
wake();
|
|
146
|
+
reject(error);
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
active = operation;
|
|
150
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
151
|
+
if (signal?.aborted)
|
|
152
|
+
abort();
|
|
153
|
+
return operation;
|
|
154
|
+
};
|
|
155
|
+
const check = (operation) => {
|
|
156
|
+
if (operation.cancelled)
|
|
157
|
+
throw operation.failure;
|
|
158
|
+
assertOpen();
|
|
159
|
+
};
|
|
160
|
+
// The object timeout expired before the transport took the object (§5.2): fail the operation in its
|
|
161
|
+
// current phase and reset its stream, if one is open, with DELIVERY_TIMEOUT. A group is not reopened.
|
|
162
|
+
const expireObject = (operation) => {
|
|
163
|
+
operation.cancel(new RelayError('DELIVERY_TIMEOUT', 'Object exceeded its delivery timeout before reaching the transport', operation.phase), RESET_CODE.DELIVERY_TIMEOUT);
|
|
164
|
+
};
|
|
165
|
+
// (Re)arm the object timer for the object now in flight, against the operation's current timeouts.
|
|
166
|
+
const timeObject = (operation) => {
|
|
167
|
+
clearTimeout(operation.objectTimer);
|
|
168
|
+
operation.objectTimer = undefined;
|
|
169
|
+
const { objectMs } = operation.timeouts;
|
|
170
|
+
if (operation.objectStartedAt === undefined || objectMs === 0 || operation.cancelled)
|
|
171
|
+
return;
|
|
172
|
+
const remaining = operation.objectStartedAt + objectMs - now();
|
|
173
|
+
if (remaining < 0)
|
|
174
|
+
expireObject(operation);
|
|
175
|
+
else
|
|
176
|
+
operation.objectTimer = setTimeout(() => expireObject(operation), remaining);
|
|
177
|
+
};
|
|
178
|
+
const startObject = (operation, startedAt) => {
|
|
179
|
+
operation.objectStartedAt = startedAt;
|
|
180
|
+
timeObject(operation);
|
|
181
|
+
};
|
|
182
|
+
const untimeObject = (operation) => {
|
|
183
|
+
clearTimeout(operation.objectTimer);
|
|
184
|
+
operation.objectTimer = undefined;
|
|
185
|
+
operation.objectStartedAt = undefined;
|
|
186
|
+
};
|
|
187
|
+
// The check §5.2 requires just before an object goes to the transport, in case its timer is late:
|
|
188
|
+
// before the stream write starts, and again once the stream's header write has settled.
|
|
189
|
+
const checkObjectAge = (operation) => {
|
|
190
|
+
const { objectMs } = operation.timeouts;
|
|
191
|
+
if (operation.objectStartedAt !== undefined && objectMs > 0 && now() - operation.objectStartedAt > objectMs)
|
|
192
|
+
expireObject(operation);
|
|
193
|
+
check(operation);
|
|
194
|
+
};
|
|
195
|
+
// Fix the group's effective timeouts from the publisher's values and the subscription's.
|
|
196
|
+
const fixTimeouts = (operation, publisher) => {
|
|
197
|
+
operation.publisher = publisher;
|
|
198
|
+
operation.timeouts = effectiveTimeouts(publisher, operation.subscriber);
|
|
199
|
+
timeObject(operation);
|
|
200
|
+
};
|
|
201
|
+
const run = async (operation, send) => {
|
|
202
|
+
const timer = setTimeout(() => {
|
|
203
|
+
const uncovered = operation.phase === 'waiting-for-demand' && namespaceSolicited() === false;
|
|
204
|
+
operation.cancel(new RelayError(uncovered ? 'NAMESPACE_NOT_SOLICITED' : 'WRITE_TIMEOUT', uncovered
|
|
205
|
+
? 'Publisher namespace is not covered by the relay namespace solicitations; check the token and namespace'
|
|
206
|
+
: 'Publish write timed out waiting for relay demand or transport', operation.phase), RESET_CODE.DELIVERY_TIMEOUT);
|
|
207
|
+
}, writeTimeoutMs);
|
|
208
|
+
try {
|
|
209
|
+
check(operation);
|
|
210
|
+
const result = await Promise.race([send(), operation.interrupted]);
|
|
211
|
+
check(operation);
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
let failure;
|
|
216
|
+
let code = RESET_CODE.INTERNAL_ERROR;
|
|
217
|
+
try {
|
|
218
|
+
// Closure can precede the callback that cancels this track. Preserve its reason
|
|
219
|
+
// even when the send continuation runs before that callback.
|
|
220
|
+
check(operation);
|
|
221
|
+
if (operation.writer && isStreamStop(error)) {
|
|
222
|
+
// The relay stopped this operation's own stream: the group is no longer of interest
|
|
223
|
+
// (§11.3.2), whether or not its subscription is ending too. The binding alone decides
|
|
224
|
+
// whether the next write waits for demand; a later binding change finds no operation.
|
|
225
|
+
failure = new RelayError('SUBSCRIPTION_CHANGED', 'Relay stopped the stream during a write or group; objects may be incomplete', operation.phase, { cause: error });
|
|
226
|
+
code = RESET_CODE.CANCELLED;
|
|
227
|
+
}
|
|
228
|
+
else
|
|
229
|
+
failure = transportError(error, operation.phase);
|
|
230
|
+
}
|
|
231
|
+
catch (interrupted) {
|
|
232
|
+
failure = interrupted;
|
|
233
|
+
code = connectionResetCode(interrupted);
|
|
234
|
+
}
|
|
235
|
+
operation.cancel(failure, code);
|
|
236
|
+
throw failure;
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
clearTimeout(timer);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const openStream = async (operation) => {
|
|
243
|
+
if (alias === undefined) {
|
|
244
|
+
await operation.demand;
|
|
245
|
+
check(operation);
|
|
246
|
+
if (alias === undefined)
|
|
247
|
+
throw new RelayError('SUBSCRIPTION_CHANGED', 'Relay subscription ended before the write started', operation.phase);
|
|
248
|
+
}
|
|
249
|
+
check(operation);
|
|
250
|
+
operation.alias = alias;
|
|
251
|
+
const groupId = nextGroupId++;
|
|
252
|
+
operation.phase = 'opening-stream';
|
|
253
|
+
// At the settling-group limit this waits under the write deadline, which reports it as a
|
|
254
|
+
// WRITE_TIMEOUT in this phase rather than letting the transport refuse the stream.
|
|
255
|
+
if (!settlingGroups.hasRoom()) {
|
|
256
|
+
await settlingGroups.waitForRoom(operation.interrupted);
|
|
257
|
+
check(operation);
|
|
258
|
+
}
|
|
259
|
+
// The subscription's delivery timeouts are fixed just before the stream opens: a later
|
|
260
|
+
// REQUEST_UPDATE applies to later groups. Until now only the publisher's applied; an object
|
|
261
|
+
// already older than the effective timeout fails here, before any stream exists.
|
|
262
|
+
operation.subscriber = subscriberTimeouts(operation.alias);
|
|
263
|
+
fixTimeouts(operation, operation.publisher);
|
|
264
|
+
check(operation);
|
|
265
|
+
const subgroup = await openSubgroup(operation.alias, groupId);
|
|
266
|
+
if (operation.cancelled) {
|
|
267
|
+
// The stream opened after the failure: reset it without sending payload bytes (§11.3.2).
|
|
268
|
+
subgroup.abort(resetReason(operation.code, operation.failure));
|
|
269
|
+
check(operation);
|
|
270
|
+
}
|
|
271
|
+
operation.writer = subgroup;
|
|
272
|
+
return subgroup;
|
|
273
|
+
};
|
|
274
|
+
const release = (operation) => {
|
|
275
|
+
if (active === operation)
|
|
276
|
+
active = undefined;
|
|
277
|
+
operation.cleanup();
|
|
278
|
+
};
|
|
279
|
+
// The operation is complete: its FIN was handed over, so the group settles on the connection's
|
|
280
|
+
// account and the slot is free. Its subgroup timeout starts now (§5.2): if the relay has not
|
|
281
|
+
// acknowledged the FIN when it expires, the stream is reset with DELIVERY_TIMEOUT, the failed FIN
|
|
282
|
+
// takes the group out of the settling set, and nobody hears of it.
|
|
283
|
+
const completeOperation = (operation, subgroup) => {
|
|
284
|
+
const settled = subgroup.fin();
|
|
285
|
+
settlingGroups.add(settled);
|
|
286
|
+
const { subgroupMs } = operation.timeouts;
|
|
287
|
+
if (subgroupMs > 0) {
|
|
288
|
+
const timer = setTimeout(() => {
|
|
289
|
+
subgroupTimers.delete(timer);
|
|
290
|
+
subgroup.abort(resetReason(RESET_CODE.DELIVERY_TIMEOUT, new RelayError('DELIVERY_TIMEOUT', 'Group exceeded its subgroup delivery timeout before the relay acknowledged it', 'closing')));
|
|
291
|
+
}, subgroupMs);
|
|
292
|
+
subgroupTimers.add(timer);
|
|
293
|
+
const stop = () => {
|
|
294
|
+
clearTimeout(timer);
|
|
295
|
+
subgroupTimers.delete(timer);
|
|
296
|
+
};
|
|
297
|
+
void settled.then(stop, stop);
|
|
298
|
+
}
|
|
299
|
+
release(operation);
|
|
300
|
+
};
|
|
301
|
+
const writer = {
|
|
302
|
+
get hasDemand() {
|
|
303
|
+
return alias !== undefined && !ended;
|
|
304
|
+
},
|
|
305
|
+
get closed() {
|
|
306
|
+
return ended;
|
|
307
|
+
},
|
|
308
|
+
demandChanges() {
|
|
309
|
+
const queue = ended ? [] : [alias !== undefined];
|
|
310
|
+
const waiting = [];
|
|
311
|
+
let done = ended;
|
|
312
|
+
const push = (value) => {
|
|
313
|
+
if (done)
|
|
314
|
+
return;
|
|
315
|
+
if (value === undefined) {
|
|
316
|
+
done = true;
|
|
317
|
+
for (const resolve of waiting.splice(0))
|
|
318
|
+
resolve({ done: true, value: undefined });
|
|
319
|
+
watchers.delete(push);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
const resolve = waiting.shift();
|
|
323
|
+
if (resolve)
|
|
324
|
+
resolve({ done: false, value });
|
|
325
|
+
else
|
|
326
|
+
queue.push(value);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
if (!done)
|
|
330
|
+
watchers.add(push);
|
|
331
|
+
const iterator = {
|
|
332
|
+
[Symbol.asyncIterator]() {
|
|
333
|
+
return iterator;
|
|
334
|
+
},
|
|
335
|
+
next() {
|
|
336
|
+
const value = queue.shift();
|
|
337
|
+
if (value !== undefined)
|
|
338
|
+
return Promise.resolve({ done: false, value });
|
|
339
|
+
if (done)
|
|
340
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
341
|
+
return new Promise((resolve) => {
|
|
342
|
+
waiting.push(resolve);
|
|
343
|
+
});
|
|
344
|
+
},
|
|
345
|
+
return() {
|
|
346
|
+
queue.length = 0;
|
|
347
|
+
push(undefined);
|
|
348
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
return iterator;
|
|
352
|
+
},
|
|
353
|
+
close: () => close(),
|
|
354
|
+
async writeText(text, writeOptions) {
|
|
355
|
+
await writer.write(encodeText(text), writeOptions);
|
|
356
|
+
},
|
|
357
|
+
async writeJSON(value, writeOptions) {
|
|
358
|
+
await writer.write(encodeJSON(value), writeOptions);
|
|
359
|
+
},
|
|
360
|
+
async write(payload, writeOptions = {}) {
|
|
361
|
+
// The object's age counts from here (§5.2), or from a wrapper's call.
|
|
362
|
+
const startedAt = writeOptions[CALL_STARTED_AT] ?? now();
|
|
363
|
+
// Arguments before slot state: a bad payload is a programming error whatever the slot holds.
|
|
364
|
+
const bytes = payloadBytes(payload);
|
|
365
|
+
const properties = objectPropertyPairs(writeOptions.properties);
|
|
366
|
+
assertWritable();
|
|
367
|
+
const operation = begin('write', writeOptions.signal);
|
|
368
|
+
// The object is the group's first, so its properties can set the publisher's timeouts.
|
|
369
|
+
operation.publisher = publisherTimeouts(properties, trackTimeouts);
|
|
370
|
+
operation.timeouts = effectiveTimeouts(operation.publisher, NO_DELIVERY_TIMEOUTS);
|
|
371
|
+
startObject(operation, startedAt);
|
|
372
|
+
try {
|
|
373
|
+
const subgroup = await run(operation, async () => {
|
|
374
|
+
const opened = await openStream(operation);
|
|
375
|
+
operation.phase = 'writing';
|
|
376
|
+
checkObjectAge(operation);
|
|
377
|
+
await opened.writeObject({ objectId: 0, properties, payload: bytes }, { beforeWrite: () => checkObjectAge(operation) });
|
|
378
|
+
untimeObject(operation);
|
|
379
|
+
check(operation);
|
|
380
|
+
operation.phase = 'closing';
|
|
381
|
+
await opened.handOverFin();
|
|
382
|
+
return opened;
|
|
383
|
+
});
|
|
384
|
+
completeOperation(operation, subgroup);
|
|
385
|
+
}
|
|
386
|
+
finally {
|
|
387
|
+
release(operation);
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
async openGroup(groupOptions = {}) {
|
|
391
|
+
// With a first object, its age counts from here (§5.2), so the waits for demand, settling room
|
|
392
|
+
// and the stream all count. Without one there is no object to time: only the write deadline applies.
|
|
393
|
+
const startedAt = groupOptions[CALL_STARTED_AT] ?? now();
|
|
394
|
+
const first = groupOptions.payload === undefined
|
|
395
|
+
? undefined
|
|
396
|
+
: { bytes: payloadBytes(groupOptions.payload), properties: objectPropertyPairs(groupOptions.properties) };
|
|
397
|
+
if (!first && groupOptions.properties !== undefined)
|
|
398
|
+
throw new TypeError('Group properties belong to a first object: pass a payload with them');
|
|
399
|
+
assertWritable();
|
|
400
|
+
const operation = begin('group', groupOptions.signal);
|
|
401
|
+
if (first) {
|
|
402
|
+
// Object 0's properties can set the group's publisher timeouts, before the stream opens.
|
|
403
|
+
operation.publisher = publisherTimeouts(first.properties, trackTimeouts);
|
|
404
|
+
operation.timeouts = effectiveTimeouts(operation.publisher, NO_DELIVERY_TIMEOUTS);
|
|
405
|
+
startObject(operation, startedAt);
|
|
406
|
+
}
|
|
407
|
+
// A failure here cancels the operation, which resets any stream it opened: no writer is returned.
|
|
408
|
+
const subgroup = await run(operation, async () => {
|
|
409
|
+
const opened = await openStream(operation);
|
|
410
|
+
if (!first)
|
|
411
|
+
return opened;
|
|
412
|
+
operation.phase = 'writing';
|
|
413
|
+
checkObjectAge(operation);
|
|
414
|
+
await opened.writeObject({ objectId: 0, properties: first.properties, payload: first.bytes }, { beforeWrite: () => checkObjectAge(operation) });
|
|
415
|
+
untimeObject(operation);
|
|
416
|
+
check(operation);
|
|
417
|
+
return opened;
|
|
418
|
+
});
|
|
419
|
+
let objectCount = first ? 1 : 0;
|
|
420
|
+
let pending = false;
|
|
421
|
+
let complete = false;
|
|
422
|
+
const assertGroup = () => {
|
|
423
|
+
check(operation);
|
|
424
|
+
// The FIN already went out, so nothing of the refused call is sent.
|
|
425
|
+
if (complete)
|
|
426
|
+
throw new RelayError('CLOSED', 'Group is closed', 'waiting-for-demand');
|
|
427
|
+
if (pending)
|
|
428
|
+
throw new RelayError('WRITE_PENDING', 'A group write or close is already pending', 'writing');
|
|
429
|
+
};
|
|
430
|
+
const groupWriter = {
|
|
431
|
+
groupId: subgroup.groupId,
|
|
432
|
+
get objectCount() {
|
|
433
|
+
return objectCount;
|
|
434
|
+
},
|
|
435
|
+
get closed() {
|
|
436
|
+
return complete || operation.cancelled;
|
|
437
|
+
},
|
|
438
|
+
async writeText(text, writeOptions) {
|
|
439
|
+
await groupWriter.write(encodeText(text), writeOptions);
|
|
440
|
+
},
|
|
441
|
+
async writeJSON(value, writeOptions) {
|
|
442
|
+
await groupWriter.write(encodeJSON(value), writeOptions);
|
|
443
|
+
},
|
|
444
|
+
async write(payload, writeOptions = {}) {
|
|
445
|
+
const startedAt = now();
|
|
446
|
+
const bytes = payloadBytes(payload);
|
|
447
|
+
const properties = objectPropertyPairs(writeOptions.properties);
|
|
448
|
+
const status = writeOptions.status ?? 'normal';
|
|
449
|
+
if (typeof status !== 'string')
|
|
450
|
+
throw new TypeError('Object status must be a string');
|
|
451
|
+
if (!['normal', 'end-of-group', 'end-of-track'].includes(status))
|
|
452
|
+
throw new RangeError('Unknown object status');
|
|
453
|
+
assertGroup();
|
|
454
|
+
pending = true;
|
|
455
|
+
try {
|
|
456
|
+
operation.phase = 'writing';
|
|
457
|
+
// The first object's properties can override the track's timeouts for this group; a later
|
|
458
|
+
// object's are ignored (§5.2).
|
|
459
|
+
if (objectCount === 0)
|
|
460
|
+
fixTimeouts(operation, publisherTimeouts(properties, trackTimeouts));
|
|
461
|
+
startObject(operation, startedAt);
|
|
462
|
+
await run(operation, () => {
|
|
463
|
+
checkObjectAge(operation);
|
|
464
|
+
return subgroup.writeObject({ objectId: objectCount, properties, payload: bytes, status }, { beforeWrite: () => checkObjectAge(operation) });
|
|
465
|
+
});
|
|
466
|
+
objectCount++;
|
|
467
|
+
}
|
|
468
|
+
finally {
|
|
469
|
+
untimeObject(operation);
|
|
470
|
+
pending = false;
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
async close() {
|
|
474
|
+
if (complete)
|
|
475
|
+
return;
|
|
476
|
+
assertGroup();
|
|
477
|
+
pending = true;
|
|
478
|
+
try {
|
|
479
|
+
operation.phase = 'closing';
|
|
480
|
+
await run(operation, () => subgroup.handOverFin());
|
|
481
|
+
complete = true;
|
|
482
|
+
completeOperation(operation, subgroup);
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
pending = false;
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
abort(reason = new RelayError('CLOSED', 'Group was aborted', operation.phase)) {
|
|
489
|
+
// After a clean close the FIN already ended the stream; a later reset is ignorable (§11.3.2).
|
|
490
|
+
if (!complete)
|
|
491
|
+
operation.cancel(reason, RESET_CODE.CANCELLED);
|
|
492
|
+
},
|
|
493
|
+
};
|
|
494
|
+
return groupWriter;
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
return {
|
|
498
|
+
writer,
|
|
499
|
+
bind(nextAlias) {
|
|
500
|
+
if (active?.alias !== undefined && active.alias !== nextAlias) {
|
|
501
|
+
active.cancel(new RelayError('SUBSCRIPTION_CHANGED', 'Relay subscription changed during a write or group; objects may be incomplete', active.phase), RESET_CODE.CANCELLED);
|
|
502
|
+
}
|
|
503
|
+
const changed = alias !== nextAlias;
|
|
504
|
+
alias = nextAlias;
|
|
505
|
+
if (alias !== undefined)
|
|
506
|
+
active?.wake();
|
|
507
|
+
if (changed && !ended)
|
|
508
|
+
notify(alias !== undefined);
|
|
509
|
+
},
|
|
510
|
+
disconnect(error) {
|
|
511
|
+
close(error, connectionResetCode(error));
|
|
512
|
+
// The connection's end resets every stream anyway: the subgroup timers have nothing left to do.
|
|
513
|
+
for (const timer of subgroupTimers)
|
|
514
|
+
clearTimeout(timer);
|
|
515
|
+
subgroupTimers.clear();
|
|
516
|
+
},
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
//# sourceMappingURL=write-slot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-slot.js","sourceRoot":"","sources":["../src/write-slot.ts"],"names":[],"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C,CAAC;gBAChE,CAAC;aACF,CAAC;YACF,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC;IAEF,OAAO;QACL,MAAM;QACN,IAAI,CAAC,SAAS;YACZ,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC9D,MAAM,CAAC,MAAM,CACX,IAAI,UAAU,CACZ,sBAAsB,EACtB,+EAA+E,EAC/E,MAAM,CAAC,KAAK,CACb,EACD,UAAU,CAAC,SAAS,CACrB,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,GAAG,KAAK,KAAK,SAAS,CAAC;YACpC,KAAK,GAAG,SAAS,CAAC;YAClB,IAAI,KAAK,KAAK,SAAS;gBAAE,MAAM,EAAE,IAAI,EAAE,CAAC;YACxC,IAAI,OAAO,IAAI,CAAC,KAAK;gBAAE,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QACrD,CAAC;QACD,UAAU,CAAC,KAAK;YACd,KAAK,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;YACzC,gGAAgG;YAChG,KAAK,MAAM,KAAK,IAAI,cAAc;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YACxD,cAAc,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caprid/relay",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "JavaScript SDK for Relay",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"repository": {
|
|
7
|
-
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/caprids/relay-sdks.git",
|
|
9
|
+
"directory": "ts"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./node": {
|
|
23
|
+
"types": "./dist/node.d.ts",
|
|
24
|
+
"import": "./dist/node.js"
|
|
25
|
+
},
|
|
26
|
+
"./media": {
|
|
27
|
+
"types": "./dist/media.d.ts",
|
|
28
|
+
"import": "./dist/media.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@caprid/moq-core": "0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@caprid/relay-quic": "0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"@caprid/relay-quic": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@biomejs/biome": "2.5.13",
|
|
44
|
+
"@moq/qmux": "0.3.3",
|
|
45
|
+
"@types/node": "24.12.2",
|
|
46
|
+
"@types/ws": "8.18.2",
|
|
47
|
+
"mediabunny": "1.58.1",
|
|
48
|
+
"playwright": "1.63.0",
|
|
49
|
+
"typedoc": "0.28.20",
|
|
50
|
+
"typescript": "6.0.2",
|
|
51
|
+
"vitest": "4.1.10",
|
|
52
|
+
"ws": "8.22.0",
|
|
53
|
+
"@caprid/moq-media": "0.1.0",
|
|
54
|
+
"@caprid/moq-mediabunny": "0.1.0",
|
|
55
|
+
"@caprid/relay-quic": "0.1.0",
|
|
56
|
+
"@caprid/relay-websocket": "0.1.0"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=24"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "pnpm --filter @caprid/moq-core build && pnpm --filter @caprid/moq-media build && pnpm --filter @caprid/moq-mediabunny build && pnpm --filter @caprid/relay-quic build && pnpm --filter @caprid/relay-websocket build && tsc -p tsconfig.build.json",
|
|
66
|
+
"test": "pnpm --filter @caprid/moq-core build && pnpm --filter @caprid/moq-media build && pnpm --filter @caprid/moq-mediabunny build && pnpm --filter @caprid/relay-quic build && pnpm --filter @caprid/relay-websocket build && vitest run",
|
|
67
|
+
"typecheck": "pnpm --filter @caprid/moq-core build && pnpm --filter @caprid/moq-media build && pnpm --filter @caprid/moq-mediabunny build && pnpm --filter @caprid/relay-quic build && pnpm --filter @caprid/relay-websocket build && tsc --noEmit -p tsconfig.json",
|
|
68
|
+
"lint": "biome check --error-on-warnings .",
|
|
69
|
+
"fix": "biome check --write .",
|
|
70
|
+
"format": "biome format --write .",
|
|
71
|
+
"check": "pnpm lint && pnpm build && pnpm typecheck && pnpm test && pnpm check:boundaries && pnpm check:docs",
|
|
72
|
+
"check:boundaries": "node scripts/check-boundaries.mjs",
|
|
73
|
+
"check:docs": "typedoc --options typedoc.workspace.json --emit none",
|
|
74
|
+
"docs": "pnpm build && typedoc --options typedoc.workspace.json",
|
|
75
|
+
"test:relay": "pnpm build && pnpm --filter @caprid/relay-quic build:native && node scripts/test-relay.mjs",
|
|
76
|
+
"test:av-sync": "pnpm build && node scripts/test-av-sync.mjs",
|
|
77
|
+
"test:audio-player": "pnpm build && node scripts/test-audio-player.mjs",
|
|
78
|
+
"test:conformance": "pnpm build && node scripts/test-conformance.mjs",
|
|
79
|
+
"example:voice-bot": "pnpm build && node examples/voice-bot/serve.mjs",
|
|
80
|
+
"example:mux-global": "pnpm build && pnpm --filter @caprid/relay-quic build:native && node examples/mux-global/run.mjs",
|
|
81
|
+
"test:conformance:node": "pnpm build && pnpm --filter @caprid/relay-quic build:native && vitest run --config conformance/vitest.relay-quic.config.js",
|
|
82
|
+
"test:conformance:websocket": "pnpm build && vitest run --config conformance/vitest.websocket.config.js",
|
|
83
|
+
"test:conformance:websocket:browsers": "pnpm build && node scripts/test-conformance-websocket.mjs"
|
|
84
|
+
}
|
|
85
|
+
}
|