File: bindings.d.ts

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (315 lines) | stat: -rw-r--r-- 11,083 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Minimal definitions for the Mojo core bindings, just enough to make the TS
// compiler to not throw errors, and minimal definitions of types that are
// indirectly exposed by generated bindings. These should be fleshed out, or
// even better auto-generated from bindings_uncompiled.js eventually. The
// latter currently does not produce definitions that work.
// More information about them can be found in the *.idl files that generate
// many of these functions and types.
// @see //third_party/blink/renderer/core/mojo/mojo.idl

/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/naming-convention */

declare global {
  enum MojoResult {
    RESULT_OK = 0,
    RESULT_CANCELLED = 1,
    RESULT_UNKNOWN = 2,
    RESULT_INVALID_ARGUMENT = 3,
    RESULT_DEADLINE_EXCEEDED = 4,
    RESULT_NOT_FOUND = 5,
    RESULT_ALREADY_EXISTS = 6,
    RESULT_PERMISSION_DENIED = 7,
    RESULT_RESOURCE_EXHAUSTED = 8,
    RESULT_FAILED_PRECONDITION = 9,
    RESULT_ABORTED = 10,
    RESULT_OUT_OF_RANGE = 11,
    RESULT_UNIMPLEMENTED = 12,
    RESULT_INTERNAL = 13,
    RESULT_UNAVAILABLE = 14,
    RESULT_DATA_LOSS = 15,
    RESULT_BUSY = 16,
    RESULT_SHOULD_WAIT = 17,
  }

  namespace Mojo {
    // The following constants already belong to the `MojoResult` enum, but code
    // already references these constants as Mojo.MOJO_RESULT_NAME. To preserve
    // that functionality, redefine these as constants in the Mojo namespace
    // here. This allows us to keep the `Mojo` a namespace (the alternative is a
    // undefined const variable typed to &MojoResult with additional APIs, but
    // this causes issues with clients using the bindings as externs only as
    // calling the APIs results in 'Mojo is undefined' errors).
    const RESULT_OK = MojoResult.RESULT_OK;
    const RESULT_CANCELLED = MojoResult.RESULT_CANCELLED;
    const RESULT_UNKNOWN = MojoResult.RESULT_UNKNOWN;
    const RESULT_INVALID_ARGUMENT = MojoResult.RESULT_INVALID_ARGUMENT;
    const RESULT_DEADLINE_EXCEEDED = MojoResult.RESULT_DEADLINE_EXCEEDED;
    const RESULT_NOT_FOUND = MojoResult.RESULT_NOT_FOUND;
    const RESULT_ALREADY_EXISTS = MojoResult.RESULT_ALREADY_EXISTS;
    const RESULT_PERMISSION_DENIED = MojoResult.RESULT_PERMISSION_DENIED;
    const RESULT_RESOURCE_EXHAUSTED = MojoResult.RESULT_RESOURCE_EXHAUSTED;
    const RESULT_FAILED_PRECONDITION = MojoResult.RESULT_FAILED_PRECONDITION;
    const RESULT_ABORTED = MojoResult.RESULT_ABORTED;
    const RESULT_OUT_OF_RANGE = MojoResult.RESULT_OUT_OF_RANGE;
    const RESULT_UNIMPLEMENTED = MojoResult.RESULT_UNIMPLEMENTED;
    const RESULT_INTERNAL = MojoResult.RESULT_INTERNAL;
    const RESULT_UNAVAILABLE = MojoResult.RESULT_UNAVAILABLE;
    const RESULT_DATA_LOSS = MojoResult.RESULT_DATA_LOSS;
    const RESULT_BUSY = MojoResult.RESULT_BUSY;
    const RESULT_SHOULD_WAIT = MojoResult.RESULT_SHOULD_WAIT;
  }

  interface MojoHandleSignals {
    readable?: boolean;
    writable?: boolean;
    peerClosed?: boolean;
  }

  type MojoWatchCallback = (result: MojoResult) => void;

  interface MojoWatcher {
    cancel(): MojoResult;
  }

  interface MojoReadMessageFlags {
    mayDiscard: boolean;
  }

  interface MojoReadMessageResult {
    result: MojoResult;
    buffer: ArrayBuffer;
    handles: MojoHandle[];
  }

  interface MojoMapBufferResult {
    buffer: ArrayBuffer;
    result: MojoResult;
  }

  interface MojoHandle {
    close(): void;
    watch(signals: MojoHandleSignals, callback: MojoWatchCallback): MojoWatcher;
    writeMessage(buffer: BufferSource, handles: MojoHandle[]): MojoResult;
    readMessage(flags?: MojoReadMessageFlags): MojoReadMessageResult;
    mapBuffer(start: number, end: number): MojoMapBufferResult;
  }

  interface MojoCreateMessagePipeResult {
    result: MojoResult;
    handle0: MojoHandle;
    handle1: MojoHandle;
  }

  interface MojoCreateSharedBufferResult {
    handle: MojoHandle;
    result: MojoResult;
  }

  namespace Mojo {
    function createMessagePipe(): MojoCreateMessagePipeResult;
    function createSharedBuffer(numBytes: number): MojoCreateSharedBufferResult;
    function bindInterface(
        interfaceName: string, requestHandle: MojoHandle, scope?: string): void;
  }

  interface MojoInterfaceRequestEvent {
    handle: MojoHandle;
  }

  class MojoInterfaceInterceptor {
    constructor(interfaceName: string);
    start(): void;
    stop(): void;
    oninterfacerequest(e: MojoInterfaceRequestEvent): void;
  }
}

export namespace mojo {
  namespace internal {
    namespace interfaceSupport {
      interface Endpoint {}

      function getEndpointForReceiver(handle: MojoHandle|Endpoint): Endpoint;
      function acceptBufferForTesting(endpoint: Endpoint, buffer: ArrayBuffer):
          void;

      function bind(handle: Endpoint, name: string, scope: string): void;

      interface ConnectionErrorEventRouter {
        addListener(listener: Function): number;
        removeListener(id: number): boolean;
        dispatchErrorEvent(): void;
      }

      interface PendingReceiver {
        readonly handle: Endpoint;
      }

      type RequestType = new(handle: Endpoint) => PendingReceiver;

      class InterfaceRemoteBase<T> {
        constructor(requestType: RequestType, handle: Endpoint|undefined);
        get endpoint(): Endpoint;
        bindNewPipeAndPassReceiver(): PendingReceiver;
        bindHandle(handle: MojoHandle|Endpoint): void;
        associateAndPassReceiver(): PendingReceiver;
        unbind(): void;
        close(): void;
        getConnectionErrorEventRouter(): ConnectionErrorEventRouter;
        sendMessage(
            ordinal: number, paramStruct: mojo.internal.MojomType,
            maybeResponseStruct: mojo.internal.MojomType|null, args: any[],
            useResultResponse: boolean): Promise<any>;
      }

      class InterfaceRemoteBaseWrapper<T> {
        constructor(remote: InterfaceRemoteBase<T>);
        bindNewPipeAndPassReceiver(): T;
        associateAndPassReceiver(): T;
        isBound(): boolean;
        close(): void;
        flushForTesting(): Promise<void>;
      }

      class CallbackRouter {
        getNextId(): number;
        removeListener(id: number): boolean;
      }

      class InterfaceCallbackReceiver {
        constructor(router: CallbackRouter);
        addListener(listener: Function): number;
        createReceiverHandler(expectsResponse: boolean): Function;
      }

      type RemoteType<T> = new(handle: MojoHandle|Endpoint) => T;

      class InterfaceReceiverHelperInternal<T> {
        constructor(remoteType: RemoteType<T>);
        registerHandler(
            ordinal: number, paramStruct: mojo.internal.MojomType,
            responseStruct: mojo.internal.MojomType|null, handler: Function,
            useResultResponse: boolean): void;
        getConnectionErrorEventRouter(): ConnectionErrorEventRouter;
      }

      class InterfaceReceiverHelper<T> {
        constructor(helper: InterfaceReceiverHelperInternal<T>);
        bindHandle(handle: MojoHandle|Endpoint): void;
        bindNewPipeAndPassRemote(): T;
        associateAndPassRemote(): T;
        close(): void;
        flush(): Promise<void>;
      }
    }

    class Decoder {}

    interface MojomType {}
    class Bool implements MojomType {}
    class Int8 implements MojomType {}
    class Uint8 implements MojomType {}
    class Int16 implements MojomType {}
    class Uint16 implements MojomType {}
    class Int32 implements MojomType {}
    class Uint32 implements MojomType {}
    class Int64 implements MojomType {}
    class Uint64 implements MojomType {}
    class Float implements MojomType {}
    class Double implements MojomType {}
    class Handle implements MojomType {}
    class String implements MojomType {}

    function Array(elementType: MojomType, elementNullable: boolean): MojomType;
    function Map(
        keyType: MojomType, valueType: MojomType,
        valueNullable: boolean): MojomType;
    function Enum(): MojomType;

    interface NullableValueKindProperties {
      isPrimary: boolean;
      linkedValueFieldName?: string;
      originalFieldName: string;
    }

    interface StructFieldSpec<StructType, FieldType> {
      name: string;
      packedOffset: number;
      packedBitOffset: number;
      type: MojomType;
      // defaultValue needs to be nullable because we need to have some sort
      // of placeholder here. This field should never be used if the following
      // "nullable" field is set to false.
      defaultValue: FieldType|null;
      nullable: boolean;
      minVersion: number;
      nullableValueKindProperties?: NullableValueKindProperties;
      fieldGetter?: (value: StructType) => FieldType;
    }

    function createStructDeserializer(structMojomType: mojo.internal.MojomType):
        (dataView: DataView) => {
          [key: string]: any,
        };


    function StructField<StructType, FieldType>(
        name: string, packedOffset: number, packedBitOffset: number,
        type: MojomType, defaultValue: FieldType|null, nullable: boolean,
        minVersion?: number,
        nullableValueKindProperites?: NullableValueKindProperties,
        fieldGetter?: (value: StructType) => FieldType |
            null): StructFieldSpec<StructType, FieldType>;

    function Struct<StructType>(
        objectToBlessAsType: object, name: string,
        fields: Array<StructFieldSpec<StructType, any>>,
        versionData: number[][]): void;

    class TypemapAdapter<MappedType, MojoType> {
      constructor(
          toMappedTypeFn: (mojoType: MojoType) => MappedType,
      );
    }

    class MojoDataView<StructType> {
      constructor(
          decoder: mojo.internal.Decoder, version: number,
          fieldSpecs: Array<mojo.internal.StructFieldSpec<StructType, any>>);
    }

    function TypemappedStruct<MappedType, MojoType>(
        objectToBlessAsType: object, name: string,
        dataViewType: MojoDataView<MappedType>,
        adapter: TypemapAdapter<MappedType, MojoType>,
        fields: Array<StructFieldSpec<MappedType, any>>,
        versionData: number[][]): void;

    interface UnionFieldSpec {
      name?: string;
      ordinal: number;
      nullable?: boolean;
      type: MojomType;
    }

    function Union(
        objectToBlessAsUnion: object, name: string,
        fields: {[key: string]: any}): void;

    function InterfaceProxy(type: {name: string}): MojomType;
    function InterfaceRequest(type: {name: string}): MojomType;
    function AssociatedInterfaceProxy(type: {name: string}): MojomType;
    function AssociatedInterfaceRequest(type: {name: string}): MojomType;
    function decodeStructField(
        decoder: Decoder, fieldSpec: StructFieldSpec<any, any>,
        version: number): any;
    function decodeStructNullableValueField(
        decoder: Decoder, flagFieldSpec: StructFieldSpec<any, any>,
        fieldSpecs: Array<StructFieldSpec<any, any>>, version: number): any;
  }
}