chore(deps): upgrade all dependencies, toolchains and images (#2825)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-17 21:08:56 +02:00
1 parent 56e04e7b53
commit 3b552e00ef
510 files changed
+23614 -37473

No files matched your search

@@ -0,0 +1,50 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
export function abortSignalAny(signals: Array<AbortSignal>): AbortSignal {
if (signals.length === 0) {
const controller = new AbortController();
return controller.signal;
}
if (signals.length === 1) {
return signals[0];
}
for (const signal of signals) {
if (signal.aborted) {
return signal;
}
}
const controller = new AbortController();
const unlisteners: Array<() => void> = Array(signals.length);
const cleanup = () => {
for (const unsubscribe of unlisteners) {
unsubscribe();
}
};
signals.forEach((signal, index) => {
const handler = () => {
controller.abort(signal.reason);
cleanup();
};
signal.addEventListener('abort', handler);
unlisteners[index] = () => signal.removeEventListener('abort', handler);
});
return controller.signal;
}
export function abortSignalTimeout(ms: number): AbortSignal {
const controller = new AbortController();
setTimeout(() => {
controller.abort(new DOMException(`signal timed out after ${ms} ms`, 'TimeoutError'));
}, ms);
return controller.signal;
}
@@ -1,25 +1,32 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import type {NonSharedUint8Array} from '../type-polyfills/non-shared-typed-arrays.ts';
export interface DataPacketItem {
data: Uint8Array;
data: NonSharedUint8Array;
sequence: number;
sent: boolean;
}
export class DataPacketBuffer {
private buffer: Array<DataPacketItem> = [];
private _totalSize = 0;
private _sentSize = 0;
push(item: DataPacketItem) {
this.buffer.push(item);
this._totalSize += item.data.byteLength;
if (item.sent) {
this._sentSize += item.data.byteLength;
}
}
pop(): DataPacketItem | undefined {
const item = this.buffer.shift();
if (item) {
this._totalSize -= item.data.byteLength;
if (item.sent) {
this._sentSize -= item.data.byteLength;
}
}
return item;
}
@@ -28,6 +35,24 @@ export class DataPacketBuffer {
return this.buffer.slice();
}
getUnsent(): Array<DataPacketItem> {
return this.buffer.filter((item) => !item.sent);
}
markSent(item: DataPacketItem) {
if (!item.sent) {
item.sent = true;
this._sentSize += item.data.byteLength;
}
}
markAllUnsent() {
for (const item of this.buffer) {
item.sent = false;
}
this._sentSize = 0;
}
popToSequence(sequence: number) {
while (this.buffer.length > 0) {
const first = this.buffer[0];
@@ -42,7 +67,10 @@ export class DataPacketBuffer {
alignBufferedAmount(bufferedAmount: number) {
while (this.buffer.length > 0) {
const first = this.buffer[0];
if (this._totalSize - first.data.byteLength <= bufferedAmount) {
if (!first.sent) {
break;
}
if (this._sentSize - first.data.byteLength <= bufferedAmount) {
break;
}
this.pop();
@@ -0,0 +1,89 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import {Future} from '../room/utils.ts';
import type {Throws} from './throws.ts';
export class DeferrableMapAbortError extends DOMException {
reason: unknown;
constructor(message: string, reason?: unknown) {
super(message, 'AbortError');
this.reason = reason;
}
}
export class DeferrableMap<K, V> extends Map<K, V> {
private pending: Map<K, Array<Future<V, DeferrableMapAbortError>>> = new Map();
override set(key: K, value: V): this {
super.set(key, value);
const futures = this.pending?.get(key);
if (futures) {
for (const future of futures) {
if (!future.isResolved) {
future.resolve?.(value);
}
}
this.pending.delete(key);
}
return this;
}
override get [Symbol.toStringTag](): string {
return 'DeferrableMap';
}
getDeferred(key: K): Promise<V>;
getDeferred(key: K, signal: AbortSignal): Promise<Throws<V, DeferrableMapAbortError>>;
async getDeferred(key: K, signal?: AbortSignal) {
const existing = this.get(key);
if (typeof existing !== 'undefined') {
return existing;
}
if (signal?.aborted) {
throw new DeferrableMapAbortError('The operation was aborted.', signal.reason);
}
const future = new Future<V, DeferrableMapAbortError>(undefined, () => {
const futures = this.pending.get(key);
if (!futures) {
return;
}
const idx = futures.indexOf(future);
if (idx !== -1) {
futures.splice(idx, 1);
}
if (futures.length === 0) {
this.pending.delete(key);
}
});
const existingFutures = this.pending.get(key);
if (existingFutures) {
existingFutures.push(future);
} else {
this.pending.set(key, [future]);
}
if (signal) {
const onAbort = () => {
if (!future.isResolved) {
future.reject?.(new DeferrableMapAbortError('The operation was aborted.', signal.reason));
}
};
signal.addEventListener('abort', onAbort, {once: true});
future.promise.finally(() => {
signal.removeEventListener('abort', onAbort);
});
}
return future.promise;
}
}
@@ -0,0 +1,59 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
export interface InspectableMachine {
readonly id: string;
readonly initialState: string;
readonly states: Record<string, Record<string, unknown>>;
readonly context?: unknown;
currentState(): string;
canHandle(input: string): boolean;
on(eventName: string, callback: (data: any) => void): {off(): void};
}
export interface MachineAnnouncement {
label: string;
seq: number;
at: number;
machine: InspectableMachine;
}
const HISTORY_LIMIT = 16;
let enabled = false;
let announced: Array<MachineAnnouncement> = [];
let subscribers: Array<(announcement: MachineAnnouncement) => void> = [];
export function enableMachineInspector() {
enabled = true;
}
export function isMachineInspectorEnabled() {
return enabled;
}
export function announceMachine(label: string, machine: InspectableMachine) {
if (!enabled) {
return;
}
const announcement: MachineAnnouncement = {
label,
seq: announced.length,
at: Date.now(),
machine,
};
announced = [...announced.slice(-(HISTORY_LIMIT - 1)), announcement];
for (const subscriber of subscribers) {
subscriber(announcement);
}
}
export function onMachineAnnounced(callback: (announcement: MachineAnnouncement) => void) {
subscribers = [...subscribers, callback];
for (const announcement of announced) {
callback(announcement);
}
return () => {
subscribers = subscribers.filter((subscriber) => subscriber !== callback);
};
}
@@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
const SerializerSymbol = Symbol.for('lk.serializer');
export type Serializer<Input, Output> = {
symbol: typeof SerializerSymbol;
parse: (raw: string) => Input;
serialize: (val: Output) => string;
};
export function isSerializer(v: unknown): v is Serializer<any, any> {
return typeof v === 'object' && v !== null && 'symbol' in v && v.symbol === SerializerSymbol;
}
export type SerializerInput<S> = S extends Serializer<infer Input, any> ? Input : any;
export type SerializerOutput<S> = S extends Serializer<any, infer Output> ? Output : any;
function base<Input = any, Output = any>(params: Omit<Serializer<Input, Output>, 'symbol'>): Serializer<Input, Output> {
return {...params, symbol: SerializerSymbol};
}
function json<Input = any, Output = any>(): Serializer<Input, Output> {
return base({
parse: (rawString: string) => JSON.parse(rawString) as Input,
serialize: (val: unknown) => JSON.stringify(val),
});
}
function raw() {
return base({
parse: (rawString: string) => rawString,
serialize: (val: string) => val,
});
}
function custom<Input = any, Output = any>(
params: Omit<Serializer<Input, Output>, 'symbol'>,
): Serializer<Input, Output> {
return base(params);
}
export const serializers = {json, raw, custom};
@@ -3,13 +3,16 @@
// SPDX-License-Identifier: Apache-2.0
type Primitives = null | undefined | string | number | bigint | boolean | symbol;
export type Throws<T, E extends Error> = (T & {readonly __throws?: E}) | Extract<T, Primitives>;
export type Throws<T, E extends Error> =
| (T & {__throws?(error: E): void})
| Extract<T, Primitives>
| (T extends void ? T : never);
export type ExtractErrors<T> = T extends Throws<unknown, infer E extends Error> ? E : never;
export type ExtractErrors<T> = T extends Throws<any, infer E> ? E : never;
export type ExtractSuccess<T> = T extends Throws<infer S, Error> ? S : T;
export type ExtractSuccess<T> = T extends Throws<infer S, any> ? S : T;
export type CombineErrors<T extends Array<unknown>> = T extends [infer First, ...infer Rest]
export type CombineErrors<T extends Array<any>> = T extends [infer First, ...infer Rest]
? ExtractErrors<First> | CombineErrors<Rest>
: never;