@band-ai/band-sdk-core 0.6.0 → 0.7.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/band_sdk_core.js +170 -0
- package/band_sdk_core_bg.wasm +0 -0
- package/index.d.ts +34 -0
- package/package.json +1 -1
package/band_sdk_core.js
CHANGED
|
@@ -348,6 +348,170 @@ class RetryTracker {
|
|
|
348
348
|
if (Symbol.dispose) RetryTracker.prototype[Symbol.dispose] = RetryTracker.prototype.free;
|
|
349
349
|
exports.RetryTracker = RetryTracker;
|
|
350
350
|
|
|
351
|
+
/**
|
|
352
|
+
* One reconnect's reconciliation against an authoritative room snapshot.
|
|
353
|
+
* `removed` and `admitting` are already applied by the time this is
|
|
354
|
+
* returned.
|
|
355
|
+
*/
|
|
356
|
+
class RoomReconciliation {
|
|
357
|
+
static __wrap(ptr) {
|
|
358
|
+
const obj = Object.create(RoomReconciliation.prototype);
|
|
359
|
+
obj.__wbg_ptr = ptr;
|
|
360
|
+
RoomReconciliationFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
361
|
+
return obj;
|
|
362
|
+
}
|
|
363
|
+
__destroy_into_raw() {
|
|
364
|
+
const ptr = this.__wbg_ptr;
|
|
365
|
+
this.__wbg_ptr = 0;
|
|
366
|
+
RoomReconciliationFinalization.unregister(this);
|
|
367
|
+
return ptr;
|
|
368
|
+
}
|
|
369
|
+
free() {
|
|
370
|
+
const ptr = this.__destroy_into_raw();
|
|
371
|
+
wasm.__wbg_roomreconciliation_free(ptr, 0);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* @returns {Array<any>}
|
|
375
|
+
*/
|
|
376
|
+
get admitting() {
|
|
377
|
+
const ret = wasm.roomreconciliation_admitting(this.__wbg_ptr);
|
|
378
|
+
return ret;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* @returns {string[]}
|
|
382
|
+
*/
|
|
383
|
+
get removed() {
|
|
384
|
+
const ret = wasm.roomreconciliation_removed(this.__wbg_ptr);
|
|
385
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
386
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
387
|
+
return v1;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @returns {string[]}
|
|
391
|
+
*/
|
|
392
|
+
get resync() {
|
|
393
|
+
const ret = wasm.roomreconciliation_resync(this.__wbg_ptr);
|
|
394
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
395
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
396
|
+
return v1;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (Symbol.dispose) RoomReconciliation.prototype[Symbol.dispose] = RoomReconciliation.prototype.free;
|
|
400
|
+
exports.RoomReconciliation = RoomReconciliation;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Room admission and membership decisions for one agent session, separate
|
|
404
|
+
* from `SubscriptionTracker`'s two-topic transport join.
|
|
405
|
+
*/
|
|
406
|
+
class RoomRoster {
|
|
407
|
+
__destroy_into_raw() {
|
|
408
|
+
const ptr = this.__wbg_ptr;
|
|
409
|
+
this.__wbg_ptr = 0;
|
|
410
|
+
RoomRosterFinalization.unregister(this);
|
|
411
|
+
return ptr;
|
|
412
|
+
}
|
|
413
|
+
free() {
|
|
414
|
+
const ptr = this.__destroy_into_raw();
|
|
415
|
+
wasm.__wbg_roomroster_free(ptr, 0);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* @param {any} room_id
|
|
419
|
+
* @param {boolean} passesFilter
|
|
420
|
+
* @returns {bigint | undefined}
|
|
421
|
+
*/
|
|
422
|
+
beginRoomAdmission(room_id, passesFilter) {
|
|
423
|
+
const ret = wasm.roomroster_beginRoomAdmission(this.__wbg_ptr, room_id, passesFilter);
|
|
424
|
+
if (ret[3]) {
|
|
425
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
426
|
+
}
|
|
427
|
+
return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* @returns {string[]}
|
|
431
|
+
*/
|
|
432
|
+
clear() {
|
|
433
|
+
const ret = wasm.roomroster_clear(this.__wbg_ptr);
|
|
434
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
435
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
436
|
+
return v1;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* @param {any} room_id
|
|
440
|
+
* @param {bigint} ticket
|
|
441
|
+
* @returns {boolean}
|
|
442
|
+
*/
|
|
443
|
+
isRoomAdmissionCurrent(room_id, ticket) {
|
|
444
|
+
const ret = wasm.roomroster_isRoomAdmissionCurrent(this.__wbg_ptr, room_id, ticket);
|
|
445
|
+
if (ret[2]) {
|
|
446
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
447
|
+
}
|
|
448
|
+
return ret[0] !== 0;
|
|
449
|
+
}
|
|
450
|
+
constructor() {
|
|
451
|
+
const ret = wasm.roomroster_new();
|
|
452
|
+
this.__wbg_ptr = ret;
|
|
453
|
+
RoomRosterFinalization.register(this, this.__wbg_ptr, this);
|
|
454
|
+
return this;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @param {any} current_room_ids
|
|
458
|
+
* @returns {RoomReconciliation}
|
|
459
|
+
*/
|
|
460
|
+
reconcile(current_room_ids) {
|
|
461
|
+
const ret = wasm.roomroster_reconcile(this.__wbg_ptr, current_room_ids);
|
|
462
|
+
if (ret[2]) {
|
|
463
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
464
|
+
}
|
|
465
|
+
return RoomReconciliation.__wrap(ret[0]);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* @param {any} room_id
|
|
469
|
+
* @param {bigint} ticket
|
|
470
|
+
* @param {boolean} succeeded
|
|
471
|
+
* @returns {boolean}
|
|
472
|
+
*/
|
|
473
|
+
recordRoomAdmission(room_id, ticket, succeeded) {
|
|
474
|
+
const ret = wasm.roomroster_recordRoomAdmission(this.__wbg_ptr, room_id, ticket, succeeded);
|
|
475
|
+
if (ret[2]) {
|
|
476
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
477
|
+
}
|
|
478
|
+
return ret[0] !== 0;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* @param {any} room_id
|
|
482
|
+
* @returns {boolean}
|
|
483
|
+
*/
|
|
484
|
+
recordRoomRemoved(room_id) {
|
|
485
|
+
const ret = wasm.roomroster_recordRoomRemoved(this.__wbg_ptr, room_id);
|
|
486
|
+
if (ret[2]) {
|
|
487
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
488
|
+
}
|
|
489
|
+
return ret[0] !== 0;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* @param {any} room_id
|
|
493
|
+
* @returns {string}
|
|
494
|
+
*/
|
|
495
|
+
roomMembership(room_id) {
|
|
496
|
+
const ret = wasm.roomroster_roomMembership(this.__wbg_ptr, room_id);
|
|
497
|
+
if (ret[3]) {
|
|
498
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
499
|
+
}
|
|
500
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* @returns {string[]}
|
|
504
|
+
*/
|
|
505
|
+
trackedRoomIds() {
|
|
506
|
+
const ret = wasm.roomroster_trackedRoomIds(this.__wbg_ptr);
|
|
507
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
508
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
509
|
+
return v1;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (Symbol.dispose) RoomRoster.prototype[Symbol.dispose] = RoomRoster.prototype.free;
|
|
513
|
+
exports.RoomRoster = RoomRoster;
|
|
514
|
+
|
|
351
515
|
/**
|
|
352
516
|
* One WebSocket session's state machine. Behavior contract:
|
|
353
517
|
* `docs/runtime-state-policy.md`'s `## Session` section.
|
|
@@ -1181,6 +1345,12 @@ const ParticipantRosterFinalization = (typeof FinalizationRegistry === 'undefine
|
|
|
1181
1345
|
const RetryTrackerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1182
1346
|
? { register: () => {}, unregister: () => {} }
|
|
1183
1347
|
: new FinalizationRegistry(ptr => wasm.__wbg_retrytracker_free(ptr, 1));
|
|
1348
|
+
const RoomReconciliationFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1349
|
+
? { register: () => {}, unregister: () => {} }
|
|
1350
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_roomreconciliation_free(ptr, 1));
|
|
1351
|
+
const RoomRosterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1352
|
+
? { register: () => {}, unregister: () => {} }
|
|
1353
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_roomroster_free(ptr, 1));
|
|
1184
1354
|
const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1185
1355
|
? { register: () => {}, unregister: () => {} }
|
|
1186
1356
|
: new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr, 1));
|
package/band_sdk_core_bg.wasm
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -173,6 +173,8 @@ export type SessionState = "connecting" | "up" | "reconnecting" | "dead";
|
|
|
173
173
|
|
|
174
174
|
export type DeadReason = "classified" | "rapid_disconnect";
|
|
175
175
|
|
|
176
|
+
export type RoomMembership = "unadmitted" | "admitting" | "admitted";
|
|
177
|
+
|
|
176
178
|
/**
|
|
177
179
|
* Classify a WebSocket close code. Returns `[terminal, delayRange]`.
|
|
178
180
|
* Throws a plain `Error` if `closeCode` is not an integer in `0..=65535`
|
|
@@ -297,3 +299,35 @@ export class SubscriptionTracker {
|
|
|
297
299
|
acknowledgeAgentTopicReconciled(topic: string): boolean;
|
|
298
300
|
joinedAgentTopics(): string[];
|
|
299
301
|
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* One reconnect's reconciliation against an authoritative room snapshot.
|
|
305
|
+
* `removed` and `admitting` are already applied by the time this is
|
|
306
|
+
* returned.
|
|
307
|
+
*/
|
|
308
|
+
export class RoomReconciliation {
|
|
309
|
+
private constructor();
|
|
310
|
+
readonly removed: string[];
|
|
311
|
+
readonly admitting: Array<[string, bigint]>;
|
|
312
|
+
readonly resync: string[];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Room admission and membership decisions for one agent session, separate
|
|
317
|
+
* from {@link SubscriptionTracker}'s two-topic transport join.
|
|
318
|
+
*
|
|
319
|
+
* Every `roomId` argument below throws a plain `Error` if it is not a
|
|
320
|
+
* string. `reconcile` throws a plain `Error` if `currentRoomIds` is not an
|
|
321
|
+
* array of strings.
|
|
322
|
+
*/
|
|
323
|
+
export class RoomRoster {
|
|
324
|
+
constructor();
|
|
325
|
+
roomMembership(roomId: string): RoomMembership;
|
|
326
|
+
beginRoomAdmission(roomId: string, passesFilter: boolean): bigint | undefined;
|
|
327
|
+
recordRoomAdmission(roomId: string, ticket: bigint, succeeded: boolean): boolean;
|
|
328
|
+
isRoomAdmissionCurrent(roomId: string, ticket: bigint): boolean;
|
|
329
|
+
recordRoomRemoved(roomId: string): boolean;
|
|
330
|
+
trackedRoomIds(): string[];
|
|
331
|
+
reconcile(currentRoomIds: string[]): RoomReconciliation;
|
|
332
|
+
clear(): string[];
|
|
333
|
+
}
|