@lakutata/dbus 2.3.1 → 3.0.0-beta.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.
Files changed (81) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +253 -25
  3. package/dist/cjs/adapters/DBusEntrypoint.d.ts +89 -0
  4. package/dist/cjs/adapters/DBusEntrypoint.js +280 -0
  5. package/dist/cjs/channel/DBusChannel.d.ts +36 -0
  6. package/dist/cjs/channel/DBusChannel.js +70 -0
  7. package/dist/cjs/components/DBusClientComponent.d.ts +494 -0
  8. package/dist/cjs/components/DBusClientComponent.js +272 -0
  9. package/dist/cjs/components/DBusObjectManager.d.ts +164 -0
  10. package/dist/cjs/components/DBusObjectManager.js +200 -0
  11. package/dist/cjs/context/DBusContext.d.ts +52 -0
  12. package/dist/cjs/context/DBusContext.js +68 -0
  13. package/dist/cjs/decorators/DBusInterface.d.ts +74 -0
  14. package/dist/cjs/decorators/DBusInterface.js +63 -0
  15. package/dist/cjs/decorators/DBusMethod.d.ts +115 -0
  16. package/dist/cjs/decorators/DBusMethod.js +20 -0
  17. package/dist/cjs/exports/DBus.d.ts +11 -0
  18. package/dist/cjs/exports/DBus.js +42 -0
  19. package/dist/cjs/lib/DBusClientOptions.d.ts +30 -0
  20. package/dist/cjs/lib/Declarations.d.ts +187 -0
  21. package/dist/cjs/lib/Declarations.js +113 -0
  22. package/dist/cjs/lib/Names.d.ts +35 -0
  23. package/dist/cjs/lib/Names.js +80 -0
  24. package/dist/cjs/lib/Signature.d.ts +14 -0
  25. package/dist/cjs/lib/Signature.js +53 -0
  26. package/dist/cjs/package.json +1 -0
  27. package/dist/cjs/types/DBusContextParams.d.ts +22 -0
  28. package/dist/cjs/types/DBusContextParams.js +2 -0
  29. package/dist/esm/adapters/DBusEntrypoint.js +274 -0
  30. package/dist/esm/channel/DBusChannel.js +67 -0
  31. package/dist/esm/components/DBusClientComponent.js +267 -0
  32. package/dist/esm/components/DBusObjectManager.js +197 -0
  33. package/dist/esm/context/DBusContext.js +64 -0
  34. package/dist/esm/decorators/DBusInterface.js +60 -0
  35. package/dist/esm/decorators/DBusMethod.js +17 -0
  36. package/dist/esm/exports/DBus.js +12 -0
  37. package/dist/esm/lib/DBusClientOptions.js +1 -0
  38. package/dist/esm/lib/Declarations.js +107 -0
  39. package/dist/esm/lib/Names.js +73 -0
  40. package/dist/esm/lib/Signature.js +49 -0
  41. package/dist/esm/types/DBusContextParams.js +1 -0
  42. package/dist/types/adapters/DBusEntrypoint.d.ts +89 -0
  43. package/dist/types/channel/DBusChannel.d.ts +36 -0
  44. package/dist/types/components/DBusClientComponent.d.ts +494 -0
  45. package/dist/types/components/DBusObjectManager.d.ts +164 -0
  46. package/dist/types/context/DBusContext.d.ts +52 -0
  47. package/dist/types/decorators/DBusInterface.d.ts +74 -0
  48. package/dist/types/decorators/DBusMethod.d.ts +115 -0
  49. package/dist/types/exports/DBus.d.ts +11 -0
  50. package/dist/types/lib/DBusClientOptions.d.ts +30 -0
  51. package/dist/types/lib/Declarations.d.ts +187 -0
  52. package/dist/types/lib/Names.d.ts +35 -0
  53. package/dist/types/lib/Signature.d.ts +14 -0
  54. package/dist/types/types/DBusContextParams.d.ts +22 -0
  55. package/package.json +38 -39
  56. package/CHANGELOG.md +0 -153
  57. package/dist/CommonExports.d.ts +0 -2
  58. package/dist/CommonExports.d.ts.map +0 -1
  59. package/dist/CommonExports.js +0 -44
  60. package/dist/ComponentExports.d.ts +0 -2
  61. package/dist/ComponentExports.d.ts.map +0 -1
  62. package/dist/ComponentExports.js +0 -5
  63. package/dist/ProviderExports.d.ts +0 -2
  64. package/dist/ProviderExports.d.ts.map +0 -1
  65. package/dist/ProviderExports.js +0 -5
  66. package/dist/components/DBusClientComponent.d.ts +0 -75
  67. package/dist/components/DBusClientComponent.d.ts.map +0 -1
  68. package/dist/components/DBusClientComponent.js +0 -125
  69. package/dist/interfaces/DBusClientOptions.d.ts +0 -7
  70. package/dist/interfaces/DBusClientOptions.d.ts.map +0 -1
  71. package/dist/providers/DBusClientProvider.d.ts +0 -75
  72. package/dist/providers/DBusClientProvider.d.ts.map +0 -1
  73. package/dist/providers/DBusClientProvider.js +0 -125
  74. package/dist/tests/DBusTest.spec.d.ts +0 -2
  75. package/dist/tests/DBusTest.spec.d.ts.map +0 -1
  76. package/dist/tests/DBusTest.spec.js +0 -26
  77. package/dist/tests/Test.d.ts +0 -9
  78. package/dist/tests/Test.d.ts.map +0 -1
  79. package/dist/tests/Test.js +0 -80
  80. package/tsconfig.json +0 -7
  81. /package/dist/{interfaces → cjs/lib}/DBusClientOptions.js +0 -0
@@ -0,0 +1,494 @@
1
+ import { BusNameBasicInfo, DBus, DBusInterface, DBusMessage, DBusObject, DBusService, DBusSignalEmitter, type DecodeOpts, InvokeOpts } from 'dbus-sdk';
2
+ import { Component, type ComponentOptionsBuilder } from '@lakutata/core';
3
+ import type { DBusClientOptions } from '../lib/DBusClientOptions.js';
4
+ /**
5
+ * Build the declaration of a {@link DBusClientComponent} for the `components` of an application or a module, from its
6
+ * typed options.
7
+ * @param options The bus address and the connection options.
8
+ * @returns The declaration: the options with `class: DBusClientComponent`.
9
+ * @example
10
+ * ```typescript
11
+ * import {Application} from 'lakutata'
12
+ * import {buildDBusClientOptions, DBusClientComponent} from '@lakutata/dbus'
13
+ *
14
+ * Application
15
+ * .run(() => ({
16
+ * id: 'client.app',
17
+ * name: 'Client',
18
+ * components: {
19
+ * dbus: buildDBusClientOptions({busAddress: 'unix:path=/var/run/dbus/system_bus_socket', timeout: 5000})
20
+ * }
21
+ * }))
22
+ * .onLaunched(async (app: Application): Promise<void> => {
23
+ * const dbus: DBusClientComponent = await app.getObject('dbus')
24
+ * console.log(await dbus.listNames())
25
+ * })
26
+ * ```
27
+ */
28
+ export declare const buildDBusClientOptions: ComponentOptionsBuilder<DBusClientOptions>;
29
+ /**
30
+ * A D-Bus client: a connection to a bus, to call the services on it, read their objects, properties and introspection,
31
+ * and listen to their signals. Declare it in the `components` of an application with {@link buildDBusClientOptions}
32
+ * (or `{class: DBusClientComponent, busAddress: …}`) and get it with `getObject()` or `@Inject`; it is a singleton
33
+ * component. It connects when it is created, so a bus that cannot be reached fails its creation; it disconnects when it
34
+ * is destroyed (the application stopping). It is a thin layer over the `DBus` connection of `dbus-sdk`, whose classes
35
+ * (`DBusService`, `DBusObject`, `DBusRemoteInterface`…) its methods return.
36
+ *
37
+ * Its `on`, `once`, `off` and `removeListener` listen to the connection's events (`'nameOwnerChanged'`,
38
+ * `'connectionClose'`…), not to events of the component.
39
+ * @example
40
+ * ```typescript
41
+ * import {Application} from 'lakutata'
42
+ * import {DBusClientComponent, type DBusRemoteInterface} from '@lakutata/dbus'
43
+ *
44
+ * Application
45
+ * .run(() => ({
46
+ * id: 'client.app',
47
+ * name: 'Client',
48
+ * components: {
49
+ * dbus: {class: DBusClientComponent, busAddress: 'unix:path=/var/run/dbus/system_bus_socket'}
50
+ * }
51
+ * }))
52
+ * .onLaunched(async (app: Application): Promise<void> => {
53
+ * const dbus: DBusClientComponent = await app.getObject('dbus')
54
+ * //A method call: the output arguments, as an array
55
+ * const [owner] = await dbus.invoke({
56
+ * service: 'org.freedesktop.DBus',
57
+ * objectPath: '/org/freedesktop/DBus',
58
+ * interface: 'org.freedesktop.DBus',
59
+ * method: 'GetNameOwner',
60
+ * signature: 's',
61
+ * args: ['org.freedesktop.DBus']
62
+ * })
63
+ * console.log(owner)
64
+ * //An interface, from the introspection of its object: its methods, properties and signals
65
+ * const device: DBusRemoteInterface = await dbus.interface('com.example.DeviceService', '/com/example/Devices/A1', 'com.example.Device')
66
+ * console.log(await device.method.Status({sn: 'A1'}))
67
+ * console.log(await device.property.State.get())
68
+ * device.signal.on('Changed', (data: unknown): void => console.log(data))
69
+ * dbus.on('nameOwnerChanged', (name: string, oldOwner: string, newOwner: string): void => console.log(name, oldOwner, newOwner))
70
+ * })
71
+ * ```
72
+ */
73
+ export declare class DBusClientComponent extends Component {
74
+ /**
75
+ * The address of the bus: `'unix:path=/var/run/dbus/system_bus_socket'` (the system bus),
76
+ * `'unix:path=/run/user/1000/bus'`, `'tcp:host=127.0.0.1,port=5555'`; the value of `DBUS_SESSION_BUS_ADDRESS` for
77
+ * the session bus. Required.
78
+ */
79
+ protected readonly busAddress: string;
80
+ /**
81
+ * How long the connection to the bus may take, in milliseconds (a positive integer); the creation of the component
82
+ * fails after it.
83
+ * @default 20000 (dbus-sdk's default)
84
+ */
85
+ protected readonly timeout: number;
86
+ /**
87
+ * How long a call may wait for its reply, in milliseconds (a positive integer); a call's own `timeout` overrides it.
88
+ * @default dbus-sdk's default
89
+ */
90
+ protected readonly callTimeout: number;
91
+ /**
92
+ * How the replies and the signals are decoded (`DecodeOpts` of `dbus-sdk`): `types` (`'none'`, `'variants'`,
93
+ * `'all'`: where the values keep their D-Bus types as typed values), `dictionaries` (`'object'` or `'map'`),
94
+ * `int64` (`'number'` or `'bigint'`). A call's own `decode` overrides it.
95
+ * @default {int64: 'number'} (the 64-bit integers as numbers when they are safe integers, else bigints)
96
+ */
97
+ protected readonly decode: DecodeOpts;
98
+ /**
99
+ * The `dbus-sdk` connection to the bus, open from the component's creation to its destruction; the subclasses use
100
+ * it for what the component's methods do not cover.
101
+ */
102
+ protected dbus: DBus;
103
+ /**
104
+ * The unique name the bus gave this connection (`':1.42'`).
105
+ */
106
+ get uniqueName(): string;
107
+ /**
108
+ * Connect to the bus, when the component is created.
109
+ * @throws {Error} When the bus cannot be reached, or the authentication fails.
110
+ */
111
+ protected init(): Promise<void>;
112
+ /**
113
+ * Disconnect from the bus, when the component is destroyed.
114
+ */
115
+ protected destroy(): Promise<void>;
116
+ /**
117
+ * Call a method without waiting for its reply (the call is flagged as expecting none): its errors are not reported.
118
+ * @param opts The service, the object path, the interface and the method to call, with the signature and the
119
+ * arguments of the call, and `noReply: true`.
120
+ * @throws {Error} An `InvalidValueError` or a `SignatureError` of `dbus-sdk` when the arguments do not fit the
121
+ * signature.
122
+ */
123
+ invoke(opts: InvokeOpts & {
124
+ noReply: true;
125
+ }): void;
126
+ /**
127
+ * Call a method and wait for its reply.
128
+ * @param opts The service, the object path, the interface and the method to call, with the signature (`'sa{sv}'`)
129
+ * and the arguments of the call; its `timeout` and `decode` override the component's.
130
+ * @returns The output arguments of the method, in order (an empty array for a method returning nothing).
131
+ * @throws {Error} When the method replies with a D-Bus error (its name and message), the call times out, the
132
+ * arguments do not fit the signature, or the connection closes.
133
+ */
134
+ invoke(opts: InvokeOpts & {
135
+ noReply?: false;
136
+ }): Promise<any[]>;
137
+ /**
138
+ * Listen to the connection's `'serviceOnline'` event, emitted when a bus name gets an owner (a service comes online):
139
+ * the listener is called every time it is emitted.
140
+ * @param eventName The event, `'serviceOnline'`.
141
+ * @param listener The listener; its arguments: the bus name.
142
+ * @returns The component, for chaining.
143
+ */
144
+ on(eventName: 'serviceOnline', listener: (name: string) => void): this;
145
+ /**
146
+ * Listen to the connection's `'serviceOffline'` event, emitted when a service name loses its owner (the service goes
147
+ * offline): the listener is called every time it is emitted.
148
+ * @param eventName The event, `'serviceOffline'`.
149
+ * @param listener The listener; its arguments: the bus name.
150
+ * @returns The component, for chaining.
151
+ */
152
+ on(eventName: 'serviceOffline', listener: (name: string) => void): this;
153
+ /**
154
+ * Listen to the connection's `'serviceReplaced'` event, emitted when the owner of a service name changes from one
155
+ * connection to another: the listener is called every time it is emitted.
156
+ * @param eventName The event, `'serviceReplaced'`.
157
+ * @param listener The listener; its arguments: the bus name.
158
+ * @returns The component, for chaining.
159
+ */
160
+ on(eventName: 'serviceReplaced', listener: (name: string) => void): this;
161
+ /**
162
+ * Listen to the connection's `'methodCall'` event, emitted when a method call addressed to this connection is
163
+ * received: the listener is called every time it is emitted.
164
+ * @param eventName The event, `'methodCall'`.
165
+ * @param listener The listener; its arguments: the message of the call.
166
+ * @returns The component, for chaining.
167
+ */
168
+ on(eventName: 'methodCall', listener: (message: DBusMessage) => void): this;
169
+ /**
170
+ * Listen to the connection's `'nameOwnerChanged'` event, emitted when the bus announces that the owner of a name
171
+ * changed (an empty owner means none): the listener is called every time it is emitted.
172
+ * @param eventName The event, `'nameOwnerChanged'`.
173
+ * @param listener The listener; its arguments: the name, its previous owner and its new owner (unique names).
174
+ * @returns The component, for chaining.
175
+ */
176
+ on(eventName: 'nameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this;
177
+ /**
178
+ * Listen to the connection's `'nameLost'` event, emitted when this connection loses a name it owned: the listener is
179
+ * called every time it is emitted.
180
+ * @param eventName The event, `'nameLost'`.
181
+ * @param listener The listener; its arguments: the name lost.
182
+ * @returns The component, for chaining.
183
+ */
184
+ on(eventName: 'nameLost', listener: (name: string) => void): this;
185
+ /**
186
+ * Listen to the connection's `'nameAcquired'` event, emitted when this connection acquires a name (its unique name
187
+ * at least, when it connects): the listener is called every time it is emitted.
188
+ * @param eventName The event, `'nameAcquired'`.
189
+ * @param listener The listener; its arguments: the name acquired.
190
+ * @returns The component, for chaining.
191
+ */
192
+ on(eventName: 'nameAcquired', listener: (name: string) => void): this;
193
+ /**
194
+ * Listen to the connection's `'connectionClose'` event, emitted when the connection to the bus closes: the listener
195
+ * is called every time it is emitted.
196
+ * @param eventName The event, `'connectionClose'`.
197
+ * @param listener The listener, called with no argument.
198
+ * @returns The component, for chaining.
199
+ */
200
+ on(eventName: 'connectionClose', listener: () => void): this;
201
+ /**
202
+ * Listen to the connection's `'connectionError'` event, emitted when an error occurs on the connection to the bus:
203
+ * the listener is called every time it is emitted.
204
+ * @param eventName The event, `'connectionError'`.
205
+ * @param listener The listener; its arguments: the error.
206
+ * @returns The component, for chaining.
207
+ */
208
+ on(eventName: 'connectionError', listener: (error: Error) => void): this;
209
+ /**
210
+ * Listen once to the connection's `'serviceOnline'` event, emitted when a service name gets an owner (the service comes
211
+ * online): the listener is called the next time it is emitted.
212
+ * @param eventName The event, `'serviceOnline'`.
213
+ * @param listener The listener; its arguments: the bus name.
214
+ * @returns The component, for chaining.
215
+ */
216
+ once(eventName: 'serviceOnline', listener: (name: string) => void): this;
217
+ /**
218
+ * Listen once to the connection's `'serviceOffline'` event, emitted when a service name loses its owner (the service goes
219
+ * offline): the listener is called the next time it is emitted.
220
+ * @param eventName The event, `'serviceOffline'`.
221
+ * @param listener The listener; its arguments: the bus name.
222
+ * @returns The component, for chaining.
223
+ */
224
+ once(eventName: 'serviceOffline', listener: (name: string) => void): this;
225
+ /**
226
+ * Listen once to the connection's `'serviceReplaced'` event, emitted when the owner of a service name changes from one
227
+ * connection to another: the listener is called the next time it is emitted.
228
+ * @param eventName The event, `'serviceReplaced'`.
229
+ * @param listener The listener; its arguments: the bus name.
230
+ * @returns The component, for chaining.
231
+ */
232
+ once(eventName: 'serviceReplaced', listener: (name: string) => void): this;
233
+ /**
234
+ * Listen once to the connection's `'methodCall'` event, emitted when a method call addressed to this connection is
235
+ * received: the listener is called the next time it is emitted.
236
+ * @param eventName The event, `'methodCall'`.
237
+ * @param listener The listener; its arguments: the message of the call.
238
+ * @returns The component, for chaining.
239
+ */
240
+ once(eventName: 'methodCall', listener: (message: DBusMessage) => void): this;
241
+ /**
242
+ * Listen once to the connection's `'nameOwnerChanged'` event, emitted when the bus announces that the owner of a
243
+ * name changed (an empty owner means none): the listener is called the next time it is emitted.
244
+ * @param eventName The event, `'nameOwnerChanged'`.
245
+ * @param listener The listener; its arguments: the name, its previous owner and its new owner (unique names).
246
+ * @returns The component, for chaining.
247
+ */
248
+ once(eventName: 'nameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this;
249
+ /**
250
+ * Listen once to the connection's `'nameLost'` event, emitted when this connection loses a name it owned: the
251
+ * listener is called the next time it is emitted.
252
+ * @param eventName The event, `'nameLost'`.
253
+ * @param listener The listener; its arguments: the name lost.
254
+ * @returns The component, for chaining.
255
+ */
256
+ once(eventName: 'nameLost', listener: (name: string) => void): this;
257
+ /**
258
+ * Listen once to the connection's `'nameAcquired'` event, emitted when this connection acquires a name (its unique
259
+ * name at least, when it connects): the listener is called the next time it is emitted.
260
+ * @param eventName The event, `'nameAcquired'`.
261
+ * @param listener The listener; its arguments: the name acquired.
262
+ * @returns The component, for chaining.
263
+ */
264
+ once(eventName: 'nameAcquired', listener: (name: string) => void): this;
265
+ /**
266
+ * Listen once to the connection's `'connectionClose'` event, emitted when the connection to the bus closes: the
267
+ * listener is called the next time it is emitted.
268
+ * @param eventName The event, `'connectionClose'`.
269
+ * @param listener The listener, called with no argument.
270
+ * @returns The component, for chaining.
271
+ */
272
+ once(eventName: 'connectionClose', listener: () => void): this;
273
+ /**
274
+ * Listen once to the connection's `'connectionError'` event, emitted when an error occurs on the connection to the
275
+ * bus: the listener is called the next time it is emitted.
276
+ * @param eventName The event, `'connectionError'`.
277
+ * @param listener The listener; its arguments: the error.
278
+ * @returns The component, for chaining.
279
+ */
280
+ once(eventName: 'connectionError', listener: (error: Error) => void): this;
281
+ /**
282
+ * Stop listening to the connection's `'serviceOnline'` event: remove a listener added with `on` or `once`.
283
+ * @param eventName The event, `'serviceOnline'`.
284
+ * @param listener The listener to remove, as it was added.
285
+ * @returns The component, for chaining.
286
+ */
287
+ off(eventName: 'serviceOnline', listener: (name: string) => void): this;
288
+ /**
289
+ * Stop listening to the connection's `'serviceOffline'` event: remove a listener added with `on` or `once`.
290
+ * @param eventName The event, `'serviceOffline'`.
291
+ * @param listener The listener to remove, as it was added.
292
+ * @returns The component, for chaining.
293
+ */
294
+ off(eventName: 'serviceOffline', listener: (name: string) => void): this;
295
+ /**
296
+ * Stop listening to the connection's `'serviceReplaced'` event: remove a listener added with `on` or `once`.
297
+ * @param eventName The event, `'serviceReplaced'`.
298
+ * @param listener The listener to remove, as it was added.
299
+ * @returns The component, for chaining.
300
+ */
301
+ off(eventName: 'serviceReplaced', listener: (name: string) => void): this;
302
+ /**
303
+ * Stop listening to the connection's `'methodCall'` event: remove a listener added with `on` or `once`.
304
+ * @param eventName The event, `'methodCall'`.
305
+ * @param listener The listener to remove, as it was added.
306
+ * @returns The component, for chaining.
307
+ */
308
+ off(eventName: 'methodCall', listener: (message: DBusMessage) => void): this;
309
+ /**
310
+ * Stop listening to the connection's `'nameOwnerChanged'` event: remove a listener added with `on` or `once`.
311
+ * @param eventName The event, `'nameOwnerChanged'`.
312
+ * @param listener The listener to remove, as it was added.
313
+ * @returns The component, for chaining.
314
+ */
315
+ off(eventName: 'nameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this;
316
+ /**
317
+ * Stop listening to the connection's `'nameLost'` event: remove a listener added with `on` or `once`.
318
+ * @param eventName The event, `'nameLost'`.
319
+ * @param listener The listener to remove, as it was added.
320
+ * @returns The component, for chaining.
321
+ */
322
+ off(eventName: 'nameLost', listener: (name: string) => void): this;
323
+ /**
324
+ * Stop listening to the connection's `'nameAcquired'` event: remove a listener added with `on` or `once`.
325
+ * @param eventName The event, `'nameAcquired'`.
326
+ * @param listener The listener to remove, as it was added.
327
+ * @returns The component, for chaining.
328
+ */
329
+ off(eventName: 'nameAcquired', listener: (name: string) => void): this;
330
+ /**
331
+ * Stop listening to the connection's `'connectionClose'` event: remove a listener added with `on` or `once`.
332
+ * @param eventName The event, `'connectionClose'`.
333
+ * @param listener The listener to remove, as it was added.
334
+ * @returns The component, for chaining.
335
+ */
336
+ off(eventName: 'connectionClose', listener: () => void): this;
337
+ /**
338
+ * Stop listening to the connection's `'connectionError'` event: remove a listener added with `on` or `once`.
339
+ * @param eventName The event, `'connectionError'`.
340
+ * @param listener The listener to remove, as it was added.
341
+ * @returns The component, for chaining.
342
+ */
343
+ off(eventName: 'connectionError', listener: (error: Error) => void): this;
344
+ /**
345
+ * Stop listening to the connection's `'serviceOnline'` event: remove a listener added with `on` or `once`.
346
+ * @param eventName The event, `'serviceOnline'`.
347
+ * @param listener The listener to remove, as it was added.
348
+ * @returns The component, for chaining (same as `off`).
349
+ */
350
+ removeListener(eventName: 'serviceOnline', listener: (name: string) => void): this;
351
+ /**
352
+ * Stop listening to the connection's `'serviceOffline'` event: remove a listener added with `on` or `once`.
353
+ * @param eventName The event, `'serviceOffline'`.
354
+ * @param listener The listener to remove, as it was added.
355
+ * @returns The component, for chaining (same as `off`).
356
+ */
357
+ removeListener(eventName: 'serviceOffline', listener: (name: string) => void): this;
358
+ /**
359
+ * Stop listening to the connection's `'serviceReplaced'` event: remove a listener added with `on` or `once`.
360
+ * @param eventName The event, `'serviceReplaced'`.
361
+ * @param listener The listener to remove, as it was added.
362
+ * @returns The component, for chaining (same as `off`).
363
+ */
364
+ removeListener(eventName: 'serviceReplaced', listener: (name: string) => void): this;
365
+ /**
366
+ * Stop listening to the connection's `'methodCall'` event: remove a listener added with `on` or `once`.
367
+ * @param eventName The event, `'methodCall'`.
368
+ * @param listener The listener to remove, as it was added.
369
+ * @returns The component, for chaining (same as `off`).
370
+ */
371
+ removeListener(eventName: 'methodCall', listener: (message: DBusMessage) => void): this;
372
+ /**
373
+ * Stop listening to the connection's `'nameOwnerChanged'` event: remove a listener added with `on` or `once`.
374
+ * @param eventName The event, `'nameOwnerChanged'`.
375
+ * @param listener The listener to remove, as it was added.
376
+ * @returns The component, for chaining (same as `off`).
377
+ */
378
+ removeListener(eventName: 'nameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this;
379
+ /**
380
+ * Stop listening to the connection's `'nameLost'` event: remove a listener added with `on` or `once`.
381
+ * @param eventName The event, `'nameLost'`.
382
+ * @param listener The listener to remove, as it was added.
383
+ * @returns The component, for chaining (same as `off`).
384
+ */
385
+ removeListener(eventName: 'nameLost', listener: (name: string) => void): this;
386
+ /**
387
+ * Stop listening to the connection's `'nameAcquired'` event: remove a listener added with `on` or `once`.
388
+ * @param eventName The event, `'nameAcquired'`.
389
+ * @param listener The listener to remove, as it was added.
390
+ * @returns The component, for chaining (same as `off`).
391
+ */
392
+ removeListener(eventName: 'nameAcquired', listener: (name: string) => void): this;
393
+ /**
394
+ * Stop listening to the connection's `'connectionClose'` event: remove a listener added with `on` or `once`.
395
+ * @param eventName The event, `'connectionClose'`.
396
+ * @param listener The listener to remove, as it was added.
397
+ * @returns The component, for chaining (same as `off`).
398
+ */
399
+ removeListener(eventName: 'connectionClose', listener: () => void): this;
400
+ /**
401
+ * Stop listening to the connection's `'connectionError'` event: remove a listener added with `on` or `once`.
402
+ * @param eventName The event, `'connectionError'`.
403
+ * @param listener The listener to remove, as it was added.
404
+ * @returns The component, for chaining (same as `off`).
405
+ */
406
+ removeListener(eventName: 'connectionError', listener: (error: Error) => void): this;
407
+ /**
408
+ * Ask the bus to route the messages matching a rule to this connection, without waiting for the bus's answer (the
409
+ * signal emitters of {@link interface} and {@link interfaceSignal} add their own rules).
410
+ * @param rule The match rule (`"type='signal',interface='com.example.Device'"`).
411
+ */
412
+ addMatch(rule: string): void;
413
+ /**
414
+ * Remove a match rule added with {@link addMatch}, without waiting for the bus's answer.
415
+ * @param rule The match rule, as it was added.
416
+ */
417
+ removeMatch(rule: string): void;
418
+ /**
419
+ * Get the connection owning a name.
420
+ * @param name The bus name (`'com.example.DeviceService'`).
421
+ * @returns The unique name of its owner (`':1.42'`), or `undefined` when nobody owns it or the query fails.
422
+ */
423
+ getNameOwner(name: string): Promise<string | undefined>;
424
+ /**
425
+ * List the names the bus can start a service for (D-Bus activation), running or not.
426
+ * @returns The names.
427
+ */
428
+ listActivatableNames(): Promise<string[]>;
429
+ /**
430
+ * List the names owned on the bus now: the well-known names and the unique names of the connections.
431
+ * @returns The names.
432
+ */
433
+ listNames(): Promise<string[]>;
434
+ /**
435
+ * Tell whether a name is owned on the bus now.
436
+ * @param name The bus name.
437
+ * @returns `true` when a connection owns it.
438
+ */
439
+ nameHasOwner(name: string): Promise<boolean>;
440
+ /**
441
+ * List the names of the bus, owned or activatable, with their owner, whether they are active or activatable, and the
442
+ * process id of their owner.
443
+ * @returns The names and their details.
444
+ */
445
+ listBusNames(): Promise<BusNameBasicInfo[]>;
446
+ /**
447
+ * List the services of the bus: its well-known names (the unique names `:1.42` left out), with their details.
448
+ * @returns The services and their details.
449
+ */
450
+ listServices(): Promise<BusNameBasicInfo[]>;
451
+ /**
452
+ * Get the services of the bus which are running, to browse their objects (the activatable services which are not
453
+ * running are left out, not started: get one with {@link service} to start it).
454
+ * @returns The services.
455
+ */
456
+ services(): Promise<DBusService[]>;
457
+ /**
458
+ * Get a service, starting it when it is activatable and not running.
459
+ * @param service The service's well-known name (`'org.freedesktop.NetworkManager'`).
460
+ * @returns The service.
461
+ * @throws {Error} A `ServiceNotFoundError` of `dbus-sdk` when the name is neither owned nor activatable.
462
+ */
463
+ service(service: string): Promise<DBusService>;
464
+ /**
465
+ * Get an object of a service, to read its introspection and its interfaces.
466
+ * @param service The service's well-known name.
467
+ * @param objectPath The object path (`'/org/freedesktop/NetworkManager'`).
468
+ * @returns The object.
469
+ * @throws {Error} A `ServiceNotFoundError` of `dbus-sdk` when the service is neither running nor activatable.
470
+ */
471
+ object(service: string, objectPath: string): Promise<DBusObject>;
472
+ /**
473
+ * Get an interface of an object, built from the object's introspection: its methods (`method.Name(...args)`, or
474
+ * `noReplyMethod`), its properties (`property.Name.get()`, `.set(value)`) and its signals (`signal.on('Name', …)`).
475
+ * @param service The service's well-known name.
476
+ * @param objectPath The object path.
477
+ * @param iface The interface name (`'org.freedesktop.NetworkManager'`).
478
+ * @returns The interface.
479
+ * @throws {Error} When the service is not found, or the object does not implement the interface
480
+ * (`InterfaceNotFoundError` of `dbus-sdk`).
481
+ */
482
+ interface(service: string, objectPath: string, iface: string): Promise<DBusInterface>;
483
+ /**
484
+ * Get the signals of an interface of an object: an event emitter emitting each signal under its name, with its
485
+ * arguments.
486
+ * @param service The service's well-known name.
487
+ * @param objectPath The object path.
488
+ * @param iface The interface name.
489
+ * @returns The emitter of the interface's signals.
490
+ * @throws {Error} When the service is not found, or the object does not implement the interface
491
+ * (`InterfaceNotFoundError` of `dbus-sdk`).
492
+ */
493
+ interfaceSignal(service: string, objectPath: string, iface: string): Promise<DBusSignalEmitter>;
494
+ }