Skip to content

Type guards

function assertEmitTransport(transport: Transport): asserts transport is EmitTransport

Defined in: utils/type-guards.ts:205

Transport

asserts transport is EmitTransport


function assertReceiveTransport(transport: Transport): asserts transport is ReceiveTransport

Defined in: utils/type-guards.ts:219

Transport

asserts transport is ReceiveTransport


function instanceOfAny(value: unknown, ctors: readonly (AnyConstructor | undefined)[]): boolean

Defined in: utils/type-guards.ts:93

True if value is an instance of any of the given constructors. Tolerates undefined entries (constructors missing on this platform).

unknown

readonly (AnyConstructor | undefined)[]

boolean


function isCustomEmitTransport(value: unknown): value is CustomEmitTransport

Defined in: utils/type-guards.ts:232

unknown

value is CustomEmitTransport


function isCustomReceiveTransport(value: unknown): value is CustomReceiveTransport

Defined in: utils/type-guards.ts:238

unknown

value is CustomReceiveTransport


function isCustomTransport(value: unknown): value is CustomTransport

Defined in: utils/type-guards.ts:244

unknown

value is CustomTransport


function isDedicatedWorker(value: unknown): value is DedicatedWorkerGlobalScopeLike

Defined in: utils/type-guards.ts:76

unknown

value is DedicatedWorkerGlobalScopeLike


function isEmitJsonOnlyTransport(value: unknown): value is EmitJsonPlatformTransport

Defined in: utils/type-guards.ts:177

unknown

value is EmitJsonPlatformTransport


function isEmitTransport(value: unknown): value is EmitTransport

Defined in: utils/type-guards.ts:195

unknown

value is EmitTransport


function isJsonOnlyTransport(
value: unknown,
): value is WebSocket | WebExtPort | WebExtRuntime | WebExtEvent<(args: any[]) => any>

Defined in: utils/type-guards.ts:190

unknown

value is WebSocket | WebExtPort | WebExtRuntime | WebExtEvent<(args: any[]) => any>


function isOsraMessage(value: unknown): value is Message

Defined in: utils/type-guards.ts:83

unknown

value is Message


function isReceiveJsonOnlyTransport(value: unknown): value is ReceiveJsonPlatformTransport

Defined in: utils/type-guards.ts:182

unknown

value is ReceiveJsonPlatformTransport


function isReceiveTransport(value: unknown): value is ReceiveTransport

Defined in: utils/type-guards.ts:209

unknown

value is ReceiveTransport


function isServiceWorker(value: unknown): value is ServiceWorker

Defined in: utils/type-guards.ts:70

unknown

value is ServiceWorker


function isServiceWorkerContainer(value: unknown): value is ServiceWorkerContainer

Defined in: utils/type-guards.ts:69

unknown

value is ServiceWorkerContainer


function isSharedArrayBuffer(value: unknown): boolean

Defined in: utils/type-guards.ts:102

unknown

boolean


function isSharedWorker(value: unknown): value is SharedWorker

Defined in: utils/type-guards.ts:80

unknown

value is SharedWorker


function isTransferable(value: unknown): value is Transferable

Defined in: utils/type-guards.ts:106

unknown

value is Transferable


function isTransport(value: unknown): value is Transport

Defined in: utils/type-guards.ts:248

unknown

value is Transport


function isTypedArray(value: unknown): value is TypedArray

Defined in: utils/type-guards.ts:66

unknown

value is TypedArray


function isWebExtensionOnConnect(value: unknown): value is WebExtEvent<(args: any[]) => any>

Defined in: utils/type-guards.ts:151

unknown

value is WebExtEvent<(args: any[]) => any>


function isWebExtensionOnMessage(value: unknown): value is WebExtEvent<(args: any[]) => any>

Defined in: utils/type-guards.ts:157

unknown

value is WebExtEvent<(args: any[]) => any>


function isWebExtensionPort(value: unknown, connectPort?: boolean): value is WebExtPort

Defined in: utils/type-guards.ts:133

unknown

boolean = false

value is WebExtPort


function isWebExtensionRuntime(value: unknown): value is WebExtRuntime

Defined in: utils/type-guards.ts:127

unknown

value is WebExtRuntime


function isWebSocket(value: unknown): value is WebSocket

Defined in: utils/type-guards.ts:68

unknown

value is WebSocket


function isWindow(value: unknown): value is Window

Defined in: utils/type-guards.ts:160

unknown

value is Window


function isWorker(value: unknown): value is Worker

Defined in: utils/type-guards.ts:71

unknown

value is Worker


function typedArrayToType(
value: TypedArray,
):
| 'Int8Array'
| 'Uint8Array'
| 'Uint8ClampedArray'
| 'Int16Array'
| 'Uint16Array'
| 'Int32Array'
| 'Uint32Array'
| 'Float16Array'
| 'Float32Array'
| 'Float64Array'
| 'BigInt64Array'
| 'BigUint64Array'

Defined in: utils/type-guards.ts:50

TypedArray

| "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float16Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array"


function typedArrayTypeToTypedArrayConstructor(
value:
| 'Int8Array'
| 'Uint8Array'
| 'Uint8ClampedArray'
| 'Int16Array'
| 'Uint16Array'
| 'Int32Array'
| 'Uint32Array'
| 'Float16Array'
| 'Float32Array'
| 'Float64Array'
| 'BigInt64Array'
| 'BigUint64Array',
): TypedArrayConstructor

Defined in: utils/type-guards.ts:60

| "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float16Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array"

TypedArrayConstructor

type DedicatedWorkerGlobalScopeLike = typeof globalThis & {
name: string
postMessage: (message: unknown, transfer?: Transferable[]) => void
}

Defined in: utils/type-guards.ts:72

name: string
(message: unknown, transfer?: Transferable[]) => void

type IsJsonOnlyTransport<T> = T extends JsonPlatformTransport ? true : false

Defined in: utils/type-guards.ts:189

T extends Transport


type TypedArray = InstanceType<TypedArrayConstructor>

Defined in: utils/type-guards.ts:46


type TypedArrayConstructor = NonNullable<(typeof typedArrayConstructorsByName)[TypedArrayType]>

Defined in: utils/type-guards.ts:45


type TypedArrayType = keyof typeof typedArrayConstructorsByName

Defined in: utils/type-guards.ts:44


type WebExtEvent<TListener> = {
addListener: void
hasListener: boolean
removeListener: void
}

Defined in: utils/webext-types.ts:21

The three members osra uses on an extension event (runtime.onMessage, port.onDisconnect, …).

TListener extends (…args: any[]) => any = (…args: any[]) => any

addListener(listener: TListener, ...rest: any[]): void;

Defined in: utils/webext-types.ts:22

TListener

any[]

void

hasListener(listener: TListener): boolean;

Defined in: utils/webext-types.ts:24

TListener

boolean

removeListener(listener: TListener): void;

Defined in: utils/webext-types.ts:23

TListener

void


type WebExtGlobal = {
runtime?: WebExtRuntime
}

Defined in: utils/webext-types.ts:69

The browser / chrome global, as much of it as osra looks at.

optional runtime?: WebExtRuntime;

Defined in: utils/webext-types.ts:70


type WebExtOnConnect = WebExtRuntime['onConnect']

Defined in: utils/webext-types.ts:65


type WebExtOnMessage = WebExtRuntime['onMessage']

Defined in: utils/webext-types.ts:66


type WebExtPort = {
name: string
onDisconnect: WebExtEvent
onMessage: WebExtEvent
sender?: WebExtSender
disconnect: void
postMessage: void
}

Defined in: utils/webext-types.ts:47

disconnect(): void;

Defined in: utils/webext-types.ts:50

void

postMessage(message: any): void;

Defined in: utils/webext-types.ts:51

any

void

name: string

Defined in: utils/webext-types.ts:48

onDisconnect: WebExtEvent

Defined in: utils/webext-types.ts:53

onMessage: WebExtEvent

Defined in: utils/webext-types.ts:52

optional sender?: WebExtSender;

Defined in: utils/webext-types.ts:49


type WebExtRuntime = {
id?: string
onConnect: WebExtEvent
onConnectExternal?: WebExtEvent
onMessage: WebExtEvent
connect: WebExtPort
sendMessage: any
}

Defined in: utils/webext-types.ts:56

connect(...args: any[]): WebExtPort;

Defined in: utils/webext-types.ts:58

any[]

WebExtPort

sendMessage(...args: any[]): any;

Defined in: utils/webext-types.ts:59

any[]

any

optional id?: string;

Defined in: utils/webext-types.ts:57

onConnect: WebExtEvent

Defined in: utils/webext-types.ts:61

optional onConnectExternal?: WebExtEvent;

Defined in: utils/webext-types.ts:62

onMessage: WebExtEvent

Defined in: utils/webext-types.ts:60


type WebExtSender = {
documentId?: string
frameId?: number
id?: string
origin?: string
tab?: {
active?: boolean
id?: number
index?: number
title?: string
url?: string
windowId?: number
}
tlsChannelId?: string
url?: string
}

Defined in: utils/webext-types.ts:30

Who a message came from, as the browser reported it. osra never builds one, it only hands the browser’s own object through to your code, so the fields are all optional and the engine may carry more than these.

optional documentId?: string;

Defined in: utils/webext-types.ts:35

optional frameId?: number;

Defined in: utils/webext-types.ts:34

optional id?: string;

Defined in: utils/webext-types.ts:31

optional origin?: string;

Defined in: utils/webext-types.ts:33

optional tab?: {
active?: boolean;
id?: number;
index?: number;
title?: string;
url?: string;
windowId?: number;
};

Defined in: utils/webext-types.ts:37

optional active?: boolean;
optional id?: number;
optional index?: number;
optional title?: string;
optional url?: string;
optional windowId?: number;
optional tlsChannelId?: string;

Defined in: utils/webext-types.ts:36

optional url?: string;

Defined in: utils/webext-types.ts:32