@jellybrick/mpris-service 2.1.5 → 2.2.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/dist/index.cjs ADDED
@@ -0,0 +1,2244 @@
1
+ let node_events = require("node:events");
2
+ let _jellybrick_dbus_next = require("@jellybrick/dbus-next");
3
+ let fast_equals = require("fast-equals");
4
+ //#region src/constants.ts
5
+ const PLAYBACK_STATUS_PLAYING = "Playing";
6
+ const PLAYBACK_STATUS_PAUSED = "Paused";
7
+ const PLAYBACK_STATUS_STOPPED = "Stopped";
8
+ const LOOP_STATUS_NONE = "None";
9
+ const LOOP_STATUS_TRACK = "Track";
10
+ const LOOP_STATUS_PLAYLIST = "Playlist";
11
+ const playbackStatuses = [
12
+ PLAYBACK_STATUS_PLAYING,
13
+ PLAYBACK_STATUS_PAUSED,
14
+ PLAYBACK_STATUS_STOPPED
15
+ ];
16
+ const loopStatuses = [
17
+ LOOP_STATUS_NONE,
18
+ LOOP_STATUS_PLAYLIST,
19
+ LOOP_STATUS_TRACK
20
+ ];
21
+ const isLoopStatusValid = (value) => {
22
+ return typeof value === "string" && loopStatuses.includes(value);
23
+ };
24
+ const isPlaybackStatusValid = (value) => {
25
+ return typeof value === "string" && playbackStatuses.includes(value);
26
+ };
27
+ //#endregion
28
+ //#region src/logging.ts
29
+ const loggingEnabled = process.env.MPRIS_SERVICE_DEBUG !== void 0 && process.env.MPRIS_SERVICE_DEBUG !== "0";
30
+ const warn = (message) => {
31
+ if (loggingEnabled) console.warn(message);
32
+ };
33
+ //#endregion
34
+ //#region src/interfaces/types.ts
35
+ const guessMetadataSignature = (key, value) => {
36
+ if (key === "mpris:trackid") return "o";
37
+ else if (key === "mpris:length") return "x";
38
+ else if (typeof value === "string") return "s";
39
+ else if (typeof value === "boolean") return "b";
40
+ else if (typeof value === "number") return "d";
41
+ else if (Array.isArray(value) && value.every((v) => typeof v === "string")) return "as";
42
+ else {
43
+ warn(`could not determine metadata type for ${key}: ${String(value)}`);
44
+ return null;
45
+ }
46
+ };
47
+ const metadataToPlain = (metadataVariant) => {
48
+ const metadataPlain = {};
49
+ for (const k of Object.keys(metadataVariant)) {
50
+ const value = metadataVariant[k];
51
+ if (value === void 0 || value === null) {
52
+ warn(`ignoring a null metadata value for key ${k}`);
53
+ continue;
54
+ }
55
+ if (value instanceof _jellybrick_dbus_next.Variant) metadataPlain[k] = value.value;
56
+ else metadataPlain[k] = value;
57
+ }
58
+ return metadataPlain;
59
+ };
60
+ const metadataToDbus = (metadataPlain) => {
61
+ const metadataVariant = {};
62
+ const plain = metadataPlain;
63
+ for (const k of Object.keys(plain)) {
64
+ const value = plain[k];
65
+ const signature = guessMetadataSignature(k, value);
66
+ if (signature) metadataVariant[k] = new _jellybrick_dbus_next.Variant(signature, value);
67
+ }
68
+ return metadataVariant;
69
+ };
70
+ const emptyPlaylist = [
71
+ "/",
72
+ "",
73
+ ""
74
+ ];
75
+ const playlistToDbus = (playlist) => {
76
+ if (!playlist) return emptyPlaylist;
77
+ const { Id, Name, Icon } = playlist;
78
+ return [
79
+ Id,
80
+ Name,
81
+ Icon
82
+ ];
83
+ };
84
+ const playlistToPlain = (wire) => {
85
+ const [Id, Name, Icon] = wire;
86
+ return {
87
+ Id,
88
+ Name,
89
+ Icon
90
+ };
91
+ };
92
+ //#endregion
93
+ //#region src/interfaces/mpris-interface.ts
94
+ function _define_property$5(obj, key, value) {
95
+ if (key in obj) Object.defineProperty(obj, key, {
96
+ value,
97
+ enumerable: true,
98
+ configurable: true,
99
+ writable: true
100
+ });
101
+ else obj[key] = value;
102
+ return obj;
103
+ }
104
+ const { Interface } = _jellybrick_dbus_next.interface;
105
+ const settableEvent = {
106
+ Fullscreen: "fullscreen",
107
+ Rate: "rate",
108
+ Shuffle: "shuffle",
109
+ Volume: "volume",
110
+ LoopStatus: "loopStatus"
111
+ };
112
+ var MprisInterface = class extends Interface {
113
+ _setPropertyInternal(property, valueDbus) {
114
+ this.player.emit(settableEvent[property], valueDbus);
115
+ }
116
+ setProperty(property, valuePlain) {
117
+ let valueDbus = valuePlain;
118
+ if (property === "Metadata") valueDbus = metadataToDbus(valuePlain);
119
+ else if (property === "ActivePlaylist") if (valuePlain) valueDbus = [true, playlistToDbus(valuePlain)];
120
+ else valueDbus = [false, emptyPlaylist];
121
+ else if (property === "Tracks") valueDbus = valuePlain.filter((t) => t["mpris:trackid"]).map((t) => t["mpris:trackid"]);
122
+ if (!(0, fast_equals.deepEqual)(Reflect.get(this, `_${property}`), valueDbus)) {
123
+ Reflect.set(this, `_${property}`, valueDbus);
124
+ if (property === "LoopStatus" && !isLoopStatusValid(valuePlain)) warn(`setting player loop status to an invalid value: ${String(valuePlain)}`);
125
+ else if (property === "PlaybackStatus" && !isPlaybackStatusValid(valuePlain)) warn(`setting player playback status to an invalid value: ${String(valuePlain)}`);
126
+ else Interface.emitPropertiesChanged(this, { [property]: valueDbus }, []);
127
+ }
128
+ }
129
+ constructor(name, player) {
130
+ super(name), _define_property$5(this, "player", void 0);
131
+ this.player = player;
132
+ }
133
+ };
134
+ //#endregion
135
+ //#region src/interfaces/root.ts
136
+ function _define_property$4(obj, key, value) {
137
+ if (key in obj) Object.defineProperty(obj, key, {
138
+ value,
139
+ enumerable: true,
140
+ configurable: true,
141
+ writable: true
142
+ });
143
+ else obj[key] = value;
144
+ return obj;
145
+ }
146
+ function applyDecs2203RFactory$3() {
147
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
148
+ return function addInitializer(initializer) {
149
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
150
+ assertCallable(initializer, "An initializer");
151
+ initializers.push(initializer);
152
+ };
153
+ }
154
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
155
+ var kindStr;
156
+ switch (kind) {
157
+ case 1:
158
+ kindStr = "accessor";
159
+ break;
160
+ case 2:
161
+ kindStr = "method";
162
+ break;
163
+ case 3:
164
+ kindStr = "getter";
165
+ break;
166
+ case 4:
167
+ kindStr = "setter";
168
+ break;
169
+ default: kindStr = "field";
170
+ }
171
+ var ctx = {
172
+ kind: kindStr,
173
+ name: isPrivate ? "#" + name : name,
174
+ static: isStatic,
175
+ private: isPrivate,
176
+ metadata
177
+ };
178
+ var decoratorFinishedRef = { v: false };
179
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
180
+ var get, set;
181
+ if (kind === 0) if (isPrivate) {
182
+ get = desc.get;
183
+ set = desc.set;
184
+ } else {
185
+ get = function() {
186
+ return this[name];
187
+ };
188
+ set = function(v) {
189
+ this[name] = v;
190
+ };
191
+ }
192
+ else if (kind === 2) get = function() {
193
+ return desc.value;
194
+ };
195
+ else {
196
+ if (kind === 1 || kind === 3) get = function() {
197
+ return desc.get.call(this);
198
+ };
199
+ if (kind === 1 || kind === 4) set = function(v) {
200
+ desc.set.call(this, v);
201
+ };
202
+ }
203
+ if (get) {
204
+ var originalGet = get;
205
+ get = function(target) {
206
+ if (arguments.length === 0) target = this;
207
+ return originalGet.call(target);
208
+ };
209
+ }
210
+ if (set) {
211
+ var originalSet = set;
212
+ set = function(target, value) {
213
+ if (arguments.length === 1) {
214
+ value = target;
215
+ target = this;
216
+ }
217
+ return originalSet.call(target, value);
218
+ };
219
+ }
220
+ if (isPrivate) ctx.access = get && set ? {
221
+ get,
222
+ set
223
+ } : get ? { get } : { set };
224
+ else {
225
+ var has = function(target) {
226
+ return name in target;
227
+ };
228
+ ctx.access = get && set ? {
229
+ has,
230
+ get,
231
+ set
232
+ } : get ? {
233
+ has,
234
+ get
235
+ } : {
236
+ has,
237
+ set
238
+ };
239
+ }
240
+ var newValue = dec(value, ctx);
241
+ decoratorFinishedRef.v = true;
242
+ return newValue;
243
+ }
244
+ function assertNotFinished(decoratorFinishedRef, fnName) {
245
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
246
+ }
247
+ function assertCallable(fn, hint) {
248
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
249
+ }
250
+ function assertValidReturnValue(kind, value) {
251
+ var type = typeof value;
252
+ if (kind === 1) {
253
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
254
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
255
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
256
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
257
+ } else if (type !== "function") {
258
+ var hint;
259
+ if (kind === 0) hint = "field";
260
+ else if (kind === 10) hint = "class";
261
+ else hint = "method";
262
+ throw new TypeError(hint + " decorators must return a function or void 0");
263
+ }
264
+ }
265
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
266
+ var decs = decInfo[0];
267
+ var desc, init, value;
268
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
269
+ get: decInfo[3],
270
+ set: decInfo[4]
271
+ };
272
+ else if (kind === 3) desc = { get: decInfo[3] };
273
+ else if (kind === 4) desc = { set: decInfo[3] };
274
+ else desc = { value: decInfo[3] };
275
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
276
+ if (kind === 1) value = {
277
+ get: desc.get,
278
+ set: desc.set
279
+ };
280
+ else if (kind === 2) value = desc.value;
281
+ else if (kind === 3) value = desc.get;
282
+ else if (kind === 4) value = desc.set;
283
+ var newValue, get, set;
284
+ if (typeof decs === "function") {
285
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
286
+ if (newValue !== void 0) {
287
+ assertValidReturnValue(kind, newValue);
288
+ if (kind === 0) init = newValue;
289
+ else if (kind === 1) {
290
+ init = newValue.init;
291
+ get = newValue.get || value.get;
292
+ set = newValue.set || value.set;
293
+ value = {
294
+ get,
295
+ set
296
+ };
297
+ } else value = newValue;
298
+ }
299
+ } else for (var i = decs.length - 1; i >= 0; i--) {
300
+ var dec = decs[i];
301
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
302
+ if (newValue !== void 0) {
303
+ assertValidReturnValue(kind, newValue);
304
+ var newInit;
305
+ if (kind === 0) newInit = newValue;
306
+ else if (kind === 1) {
307
+ newInit = newValue.init;
308
+ get = newValue.get || value.get;
309
+ set = newValue.set || value.set;
310
+ value = {
311
+ get,
312
+ set
313
+ };
314
+ } else value = newValue;
315
+ if (newInit !== void 0) if (init === void 0) init = newInit;
316
+ else if (typeof init === "function") init = [init, newInit];
317
+ else init.push(newInit);
318
+ }
319
+ }
320
+ if (kind === 0 || kind === 1) {
321
+ if (init === void 0) init = function(instance, init) {
322
+ return init;
323
+ };
324
+ else if (typeof init !== "function") {
325
+ var ownInitializers = init;
326
+ init = function(instance, init) {
327
+ var value = init;
328
+ for (var i = 0; i < ownInitializers.length; i++) value = ownInitializers[i].call(instance, value);
329
+ return value;
330
+ };
331
+ } else {
332
+ var originalInitializer = init;
333
+ init = function(instance, init) {
334
+ return originalInitializer.call(instance, init);
335
+ };
336
+ }
337
+ ret.push(init);
338
+ }
339
+ if (kind !== 0) {
340
+ if (kind === 1) {
341
+ desc.get = value.get;
342
+ desc.set = value.set;
343
+ } else if (kind === 2) desc.value = value;
344
+ else if (kind === 3) desc.get = value;
345
+ else if (kind === 4) desc.set = value;
346
+ if (isPrivate) if (kind === 1) {
347
+ ret.push(function(instance, args) {
348
+ return value.get.call(instance, args);
349
+ });
350
+ ret.push(function(instance, args) {
351
+ return value.set.call(instance, args);
352
+ });
353
+ } else if (kind === 2) ret.push(value);
354
+ else ret.push(function(instance, args) {
355
+ return value.call(instance, args);
356
+ });
357
+ else Object.defineProperty(base, name, desc);
358
+ }
359
+ }
360
+ function applyMemberDecs(Class, decInfos, metadata) {
361
+ var ret = [];
362
+ var protoInitializers;
363
+ var staticInitializers;
364
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
365
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
366
+ for (var i = 0; i < decInfos.length; i++) {
367
+ var decInfo = decInfos[i];
368
+ if (!Array.isArray(decInfo)) continue;
369
+ var kind = decInfo[1];
370
+ var name = decInfo[2];
371
+ var isPrivate = decInfo.length > 3;
372
+ var isStatic = kind >= 5;
373
+ var base;
374
+ var initializers;
375
+ if (isStatic) {
376
+ base = Class;
377
+ kind = kind - 5;
378
+ staticInitializers = staticInitializers || [];
379
+ initializers = staticInitializers;
380
+ } else {
381
+ base = Class.prototype;
382
+ protoInitializers = protoInitializers || [];
383
+ initializers = protoInitializers;
384
+ }
385
+ if (kind !== 0 && !isPrivate) {
386
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
387
+ var existingKind = existingNonFields.get(name) || 0;
388
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
389
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
390
+ else existingNonFields.set(name, true);
391
+ }
392
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
393
+ }
394
+ pushInitializers(ret, protoInitializers);
395
+ pushInitializers(ret, staticInitializers);
396
+ return ret;
397
+ }
398
+ function pushInitializers(ret, initializers) {
399
+ if (initializers) ret.push(function(instance) {
400
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
401
+ return instance;
402
+ });
403
+ }
404
+ function applyClassDecs(targetClass, classDecs, metadata) {
405
+ if (classDecs.length > 0) {
406
+ var initializers = [];
407
+ var newClass = targetClass;
408
+ var name = targetClass.name;
409
+ for (var i = classDecs.length - 1; i >= 0; i--) {
410
+ var decoratorFinishedRef = { v: false };
411
+ var nextNewClass = classDecs[i](newClass, {
412
+ kind: "class",
413
+ name,
414
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
415
+ metadata
416
+ });
417
+ decoratorFinishedRef.v = true;
418
+ if (nextNewClass !== void 0) {
419
+ assertValidReturnValue(10, nextNewClass);
420
+ newClass = nextNewClass;
421
+ }
422
+ }
423
+ return [defineMetadata(newClass, metadata), function() {
424
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(newClass);
425
+ }];
426
+ }
427
+ }
428
+ function defineMetadata(Class, metadata) {
429
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
430
+ configurable: true,
431
+ enumerable: true,
432
+ value: metadata
433
+ });
434
+ }
435
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
436
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
437
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
438
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
439
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
440
+ return {
441
+ e,
442
+ get c() {
443
+ return applyClassDecs(targetClass, classDecs, metadata);
444
+ }
445
+ };
446
+ };
447
+ }
448
+ function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
449
+ return (_apply_decs_2203_r$3 = applyDecs2203RFactory$3())(targetClass, memberDecs, classDecs, parentClass);
450
+ }
451
+ var _dec$3, _dec1$3, _dec2$3, _dec3$3, _dec4$3, _dec5$3, _dec6$2, _dec7$2, _dec8$2, _dec9$2, _dec10$1, _initProto$3;
452
+ const { property: property$3, method: method$3 } = _jellybrick_dbus_next.interface;
453
+ const ACCESS_READ$2 = _jellybrick_dbus_next.interface.ACCESS_READ;
454
+ _dec$3 = property$3({
455
+ signature: "b",
456
+ access: ACCESS_READ$2
457
+ }), _dec1$3 = property$3({ signature: "b" }), _dec2$3 = property$3({
458
+ signature: "b",
459
+ access: ACCESS_READ$2
460
+ }), _dec3$3 = property$3({
461
+ signature: "b",
462
+ access: ACCESS_READ$2
463
+ }), _dec4$3 = property$3({
464
+ signature: "b",
465
+ access: ACCESS_READ$2
466
+ }), _dec5$3 = property$3({
467
+ signature: "s",
468
+ access: ACCESS_READ$2
469
+ }), _dec6$2 = property$3({
470
+ signature: "s",
471
+ access: ACCESS_READ$2
472
+ }), _dec7$2 = property$3({
473
+ signature: "as",
474
+ access: ACCESS_READ$2
475
+ }), _dec8$2 = property$3({
476
+ signature: "as",
477
+ access: ACCESS_READ$2
478
+ }), _dec9$2 = method$3({}), _dec10$1 = method$3({});
479
+ var RootInterface = class extends MprisInterface {
480
+ get CanQuit() {
481
+ return this._CanQuit;
482
+ }
483
+ get Fullscreen() {
484
+ return this._Fullscreen;
485
+ }
486
+ set Fullscreen(value) {
487
+ this._setPropertyInternal("Fullscreen", value);
488
+ }
489
+ get CanSetFullscreen() {
490
+ return this._CanSetFullscreen;
491
+ }
492
+ get CanRaise() {
493
+ return this._CanRaise;
494
+ }
495
+ get HasTrackList() {
496
+ return this._HasTrackList;
497
+ }
498
+ get Identity() {
499
+ return this._Identity;
500
+ }
501
+ get DesktopEntry() {
502
+ return this._DesktopEntry;
503
+ }
504
+ get SupportedUriSchemes() {
505
+ return this._SupportedUriSchemes;
506
+ }
507
+ get SupportedMimeTypes() {
508
+ return this._SupportedMimeTypes;
509
+ }
510
+ Raise() {
511
+ this.player.emit("raise");
512
+ }
513
+ Quit() {
514
+ this.player.emit("quit");
515
+ }
516
+ constructor(player, opts = {}) {
517
+ super("org.mpris.MediaPlayer2", player), _define_property$4(this, "_CanQuit", (_initProto$3(this), true)), _define_property$4(this, "_Fullscreen", false), _define_property$4(this, "_CanSetFullscreen", false), _define_property$4(this, "_CanRaise", true), _define_property$4(this, "_HasTrackList", false), _define_property$4(this, "_Identity", ""), _define_property$4(this, "_DesktopEntry", ""), _define_property$4(this, "_SupportedUriSchemes", []), _define_property$4(this, "_SupportedMimeTypes", []);
518
+ if (opts.identity !== void 0) this._Identity = opts.identity;
519
+ if (opts.supportedUriSchemes !== void 0) this._SupportedUriSchemes = opts.supportedUriSchemes;
520
+ if (opts.supportedMimeTypes !== void 0) this._SupportedMimeTypes = opts.supportedMimeTypes;
521
+ if (opts.desktopEntry !== void 0) this._DesktopEntry = opts.desktopEntry;
522
+ }
523
+ };
524
+ ({e: [_initProto$3]} = _apply_decs_2203_r$3(RootInterface, [
525
+ [
526
+ _dec$3,
527
+ 3,
528
+ "CanQuit"
529
+ ],
530
+ [
531
+ _dec1$3,
532
+ 3,
533
+ "Fullscreen"
534
+ ],
535
+ [
536
+ _dec2$3,
537
+ 3,
538
+ "CanSetFullscreen"
539
+ ],
540
+ [
541
+ _dec3$3,
542
+ 3,
543
+ "CanRaise"
544
+ ],
545
+ [
546
+ _dec4$3,
547
+ 3,
548
+ "HasTrackList"
549
+ ],
550
+ [
551
+ _dec5$3,
552
+ 3,
553
+ "Identity"
554
+ ],
555
+ [
556
+ _dec6$2,
557
+ 3,
558
+ "DesktopEntry"
559
+ ],
560
+ [
561
+ _dec7$2,
562
+ 3,
563
+ "SupportedUriSchemes"
564
+ ],
565
+ [
566
+ _dec8$2,
567
+ 3,
568
+ "SupportedMimeTypes"
569
+ ],
570
+ [
571
+ _dec9$2,
572
+ 2,
573
+ "Raise"
574
+ ],
575
+ [
576
+ _dec10$1,
577
+ 2,
578
+ "Quit"
579
+ ]
580
+ ], []));
581
+ //#endregion
582
+ //#region src/interfaces/player.ts
583
+ function _define_property$3(obj, key, value) {
584
+ if (key in obj) Object.defineProperty(obj, key, {
585
+ value,
586
+ enumerable: true,
587
+ configurable: true,
588
+ writable: true
589
+ });
590
+ else obj[key] = value;
591
+ return obj;
592
+ }
593
+ function applyDecs2203RFactory$2() {
594
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
595
+ return function addInitializer(initializer) {
596
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
597
+ assertCallable(initializer, "An initializer");
598
+ initializers.push(initializer);
599
+ };
600
+ }
601
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
602
+ var kindStr;
603
+ switch (kind) {
604
+ case 1:
605
+ kindStr = "accessor";
606
+ break;
607
+ case 2:
608
+ kindStr = "method";
609
+ break;
610
+ case 3:
611
+ kindStr = "getter";
612
+ break;
613
+ case 4:
614
+ kindStr = "setter";
615
+ break;
616
+ default: kindStr = "field";
617
+ }
618
+ var ctx = {
619
+ kind: kindStr,
620
+ name: isPrivate ? "#" + name : name,
621
+ static: isStatic,
622
+ private: isPrivate,
623
+ metadata
624
+ };
625
+ var decoratorFinishedRef = { v: false };
626
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
627
+ var get, set;
628
+ if (kind === 0) if (isPrivate) {
629
+ get = desc.get;
630
+ set = desc.set;
631
+ } else {
632
+ get = function() {
633
+ return this[name];
634
+ };
635
+ set = function(v) {
636
+ this[name] = v;
637
+ };
638
+ }
639
+ else if (kind === 2) get = function() {
640
+ return desc.value;
641
+ };
642
+ else {
643
+ if (kind === 1 || kind === 3) get = function() {
644
+ return desc.get.call(this);
645
+ };
646
+ if (kind === 1 || kind === 4) set = function(v) {
647
+ desc.set.call(this, v);
648
+ };
649
+ }
650
+ if (get) {
651
+ var originalGet = get;
652
+ get = function(target) {
653
+ if (arguments.length === 0) target = this;
654
+ return originalGet.call(target);
655
+ };
656
+ }
657
+ if (set) {
658
+ var originalSet = set;
659
+ set = function(target, value) {
660
+ if (arguments.length === 1) {
661
+ value = target;
662
+ target = this;
663
+ }
664
+ return originalSet.call(target, value);
665
+ };
666
+ }
667
+ if (isPrivate) ctx.access = get && set ? {
668
+ get,
669
+ set
670
+ } : get ? { get } : { set };
671
+ else {
672
+ var has = function(target) {
673
+ return name in target;
674
+ };
675
+ ctx.access = get && set ? {
676
+ has,
677
+ get,
678
+ set
679
+ } : get ? {
680
+ has,
681
+ get
682
+ } : {
683
+ has,
684
+ set
685
+ };
686
+ }
687
+ var newValue = dec(value, ctx);
688
+ decoratorFinishedRef.v = true;
689
+ return newValue;
690
+ }
691
+ function assertNotFinished(decoratorFinishedRef, fnName) {
692
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
693
+ }
694
+ function assertCallable(fn, hint) {
695
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
696
+ }
697
+ function assertValidReturnValue(kind, value) {
698
+ var type = typeof value;
699
+ if (kind === 1) {
700
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
701
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
702
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
703
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
704
+ } else if (type !== "function") {
705
+ var hint;
706
+ if (kind === 0) hint = "field";
707
+ else if (kind === 10) hint = "class";
708
+ else hint = "method";
709
+ throw new TypeError(hint + " decorators must return a function or void 0");
710
+ }
711
+ }
712
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
713
+ var decs = decInfo[0];
714
+ var desc, init, value;
715
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
716
+ get: decInfo[3],
717
+ set: decInfo[4]
718
+ };
719
+ else if (kind === 3) desc = { get: decInfo[3] };
720
+ else if (kind === 4) desc = { set: decInfo[3] };
721
+ else desc = { value: decInfo[3] };
722
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
723
+ if (kind === 1) value = {
724
+ get: desc.get,
725
+ set: desc.set
726
+ };
727
+ else if (kind === 2) value = desc.value;
728
+ else if (kind === 3) value = desc.get;
729
+ else if (kind === 4) value = desc.set;
730
+ var newValue, get, set;
731
+ if (typeof decs === "function") {
732
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
733
+ if (newValue !== void 0) {
734
+ assertValidReturnValue(kind, newValue);
735
+ if (kind === 0) init = newValue;
736
+ else if (kind === 1) {
737
+ init = newValue.init;
738
+ get = newValue.get || value.get;
739
+ set = newValue.set || value.set;
740
+ value = {
741
+ get,
742
+ set
743
+ };
744
+ } else value = newValue;
745
+ }
746
+ } else for (var i = decs.length - 1; i >= 0; i--) {
747
+ var dec = decs[i];
748
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
749
+ if (newValue !== void 0) {
750
+ assertValidReturnValue(kind, newValue);
751
+ var newInit;
752
+ if (kind === 0) newInit = newValue;
753
+ else if (kind === 1) {
754
+ newInit = newValue.init;
755
+ get = newValue.get || value.get;
756
+ set = newValue.set || value.set;
757
+ value = {
758
+ get,
759
+ set
760
+ };
761
+ } else value = newValue;
762
+ if (newInit !== void 0) if (init === void 0) init = newInit;
763
+ else if (typeof init === "function") init = [init, newInit];
764
+ else init.push(newInit);
765
+ }
766
+ }
767
+ if (kind === 0 || kind === 1) {
768
+ if (init === void 0) init = function(instance, init) {
769
+ return init;
770
+ };
771
+ else if (typeof init !== "function") {
772
+ var ownInitializers = init;
773
+ init = function(instance, init) {
774
+ var value = init;
775
+ for (var i = 0; i < ownInitializers.length; i++) value = ownInitializers[i].call(instance, value);
776
+ return value;
777
+ };
778
+ } else {
779
+ var originalInitializer = init;
780
+ init = function(instance, init) {
781
+ return originalInitializer.call(instance, init);
782
+ };
783
+ }
784
+ ret.push(init);
785
+ }
786
+ if (kind !== 0) {
787
+ if (kind === 1) {
788
+ desc.get = value.get;
789
+ desc.set = value.set;
790
+ } else if (kind === 2) desc.value = value;
791
+ else if (kind === 3) desc.get = value;
792
+ else if (kind === 4) desc.set = value;
793
+ if (isPrivate) if (kind === 1) {
794
+ ret.push(function(instance, args) {
795
+ return value.get.call(instance, args);
796
+ });
797
+ ret.push(function(instance, args) {
798
+ return value.set.call(instance, args);
799
+ });
800
+ } else if (kind === 2) ret.push(value);
801
+ else ret.push(function(instance, args) {
802
+ return value.call(instance, args);
803
+ });
804
+ else Object.defineProperty(base, name, desc);
805
+ }
806
+ }
807
+ function applyMemberDecs(Class, decInfos, metadata) {
808
+ var ret = [];
809
+ var protoInitializers;
810
+ var staticInitializers;
811
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
812
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
813
+ for (var i = 0; i < decInfos.length; i++) {
814
+ var decInfo = decInfos[i];
815
+ if (!Array.isArray(decInfo)) continue;
816
+ var kind = decInfo[1];
817
+ var name = decInfo[2];
818
+ var isPrivate = decInfo.length > 3;
819
+ var isStatic = kind >= 5;
820
+ var base;
821
+ var initializers;
822
+ if (isStatic) {
823
+ base = Class;
824
+ kind = kind - 5;
825
+ staticInitializers = staticInitializers || [];
826
+ initializers = staticInitializers;
827
+ } else {
828
+ base = Class.prototype;
829
+ protoInitializers = protoInitializers || [];
830
+ initializers = protoInitializers;
831
+ }
832
+ if (kind !== 0 && !isPrivate) {
833
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
834
+ var existingKind = existingNonFields.get(name) || 0;
835
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
836
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
837
+ else existingNonFields.set(name, true);
838
+ }
839
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
840
+ }
841
+ pushInitializers(ret, protoInitializers);
842
+ pushInitializers(ret, staticInitializers);
843
+ return ret;
844
+ }
845
+ function pushInitializers(ret, initializers) {
846
+ if (initializers) ret.push(function(instance) {
847
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
848
+ return instance;
849
+ });
850
+ }
851
+ function applyClassDecs(targetClass, classDecs, metadata) {
852
+ if (classDecs.length > 0) {
853
+ var initializers = [];
854
+ var newClass = targetClass;
855
+ var name = targetClass.name;
856
+ for (var i = classDecs.length - 1; i >= 0; i--) {
857
+ var decoratorFinishedRef = { v: false };
858
+ var nextNewClass = classDecs[i](newClass, {
859
+ kind: "class",
860
+ name,
861
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
862
+ metadata
863
+ });
864
+ decoratorFinishedRef.v = true;
865
+ if (nextNewClass !== void 0) {
866
+ assertValidReturnValue(10, nextNewClass);
867
+ newClass = nextNewClass;
868
+ }
869
+ }
870
+ return [defineMetadata(newClass, metadata), function() {
871
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(newClass);
872
+ }];
873
+ }
874
+ }
875
+ function defineMetadata(Class, metadata) {
876
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
877
+ configurable: true,
878
+ enumerable: true,
879
+ value: metadata
880
+ });
881
+ }
882
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
883
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
884
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
885
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
886
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
887
+ return {
888
+ e,
889
+ get c() {
890
+ return applyClassDecs(targetClass, classDecs, metadata);
891
+ }
892
+ };
893
+ };
894
+ }
895
+ function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
896
+ return (_apply_decs_2203_r$2 = applyDecs2203RFactory$2())(targetClass, memberDecs, classDecs, parentClass);
897
+ }
898
+ var _dec$2, _dec1$2, _dec2$2, _dec3$2, _dec4$2, _dec5$2, _dec6$1, _dec7$1, _dec8$1, _dec9$1, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _initProto$2;
899
+ const { property: property$2, method: method$2, signal: signal$2 } = _jellybrick_dbus_next.interface;
900
+ _dec$2 = property$2({
901
+ signature: "b",
902
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
903
+ }), _dec1$2 = property$2({
904
+ signature: "b",
905
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
906
+ }), _dec2$2 = property$2({
907
+ signature: "b",
908
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
909
+ }), _dec3$2 = property$2({
910
+ signature: "b",
911
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
912
+ }), _dec4$2 = property$2({
913
+ signature: "b",
914
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
915
+ }), _dec5$2 = property$2({
916
+ signature: "b",
917
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
918
+ }), _dec6$1 = property$2({
919
+ signature: "a{sv}",
920
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
921
+ }), _dec7$1 = property$2({
922
+ signature: "d",
923
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
924
+ }), _dec8$1 = property$2({
925
+ signature: "d",
926
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
927
+ }), _dec9$1 = property$2({ signature: "d" }), _dec10 = property$2({ signature: "b" }), _dec11 = property$2({ signature: "d" }), _dec12 = property$2({
928
+ signature: "x",
929
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
930
+ }), _dec13 = property$2({ signature: "s" }), _dec14 = property$2({
931
+ signature: "s",
932
+ access: _jellybrick_dbus_next.interface.ACCESS_READ
933
+ }), _dec15 = method$2({}), _dec16 = method$2({}), _dec17 = method$2({}), _dec18 = method$2({}), _dec19 = method$2({}), _dec20 = method$2({}), _dec21 = method$2({ inSignature: "x" }), _dec22 = method$2({ inSignature: "ox" }), _dec23 = method$2({ inSignature: "s" }), _dec24 = signal$2({ signature: "x" });
934
+ var PlayerInterface = class extends MprisInterface {
935
+ get CanControl() {
936
+ return this._CanControl;
937
+ }
938
+ get CanPause() {
939
+ return this._CanPause;
940
+ }
941
+ get CanPlay() {
942
+ return this._CanPlay;
943
+ }
944
+ get CanSeek() {
945
+ return this._CanSeek;
946
+ }
947
+ get CanGoNext() {
948
+ return this._CanGoNext;
949
+ }
950
+ get CanGoPrevious() {
951
+ return this._CanGoPrevious;
952
+ }
953
+ get Metadata() {
954
+ return this._Metadata;
955
+ }
956
+ get MaximumRate() {
957
+ return this._MaximumRate;
958
+ }
959
+ get MinimumRate() {
960
+ return this._MinimumRate;
961
+ }
962
+ get Rate() {
963
+ return this._Rate;
964
+ }
965
+ set Rate(value) {
966
+ this._setPropertyInternal("Rate", value);
967
+ }
968
+ get Shuffle() {
969
+ return this._Shuffle;
970
+ }
971
+ set Shuffle(value) {
972
+ this._setPropertyInternal("Shuffle", value);
973
+ }
974
+ get Volume() {
975
+ return this._Volume;
976
+ }
977
+ set Volume(value) {
978
+ this._setPropertyInternal("Volume", value);
979
+ }
980
+ get Position() {
981
+ const playerPosition = this.player.getPosition();
982
+ const position = Math.floor(playerPosition || 0);
983
+ if (isNaN(position)) throw new _jellybrick_dbus_next.DBusError("github.mpris_service.InvalidPositionError", `The player has set an invalid position: ${playerPosition}`);
984
+ return position;
985
+ }
986
+ get LoopStatus() {
987
+ if (!isLoopStatusValid(this._LoopStatus)) throw new _jellybrick_dbus_next.DBusError("github.mpris_service.InvalidLoopStatusError", `The player has set an invalid loop status: ${this._LoopStatus}`);
988
+ return this._LoopStatus;
989
+ }
990
+ set LoopStatus(value) {
991
+ if (!isLoopStatusValid(value)) throw new _jellybrick_dbus_next.DBusError("github.mpris_service.InvalidLoopStatusError", `Tried to set loop status to an invalid value: ${value}`);
992
+ this._setPropertyInternal("LoopStatus", value);
993
+ }
994
+ get PlaybackStatus() {
995
+ if (!isPlaybackStatusValid(this._PlaybackStatus)) throw new _jellybrick_dbus_next.DBusError("github.mpris_service.InvalidPlaybackStatusError", `The player has set an invalid playback status: ${this._PlaybackStatus}`);
996
+ return this._PlaybackStatus;
997
+ }
998
+ Next() {
999
+ this.player.emit("next");
1000
+ }
1001
+ Previous() {
1002
+ this.player.emit("previous");
1003
+ }
1004
+ Pause() {
1005
+ this.player.emit("pause");
1006
+ }
1007
+ PlayPause() {
1008
+ this.player.emit("playpause");
1009
+ }
1010
+ Stop() {
1011
+ this.player.emit("stop");
1012
+ }
1013
+ Play() {
1014
+ this.player.emit("play");
1015
+ }
1016
+ Seek(offset) {
1017
+ this.player.emit("seek", Number(offset));
1018
+ }
1019
+ SetPosition(trackId, position) {
1020
+ this.player.emit("position", {
1021
+ trackId,
1022
+ position: Number(position)
1023
+ });
1024
+ }
1025
+ OpenUri(uri) {
1026
+ this.player.emit("open", { uri });
1027
+ }
1028
+ Seeked(position) {
1029
+ return position;
1030
+ }
1031
+ constructor(player) {
1032
+ super("org.mpris.MediaPlayer2.Player", player), _define_property$3(this, "_CanControl", (_initProto$2(this), true)), _define_property$3(this, "_CanPause", true), _define_property$3(this, "_CanPlay", true), _define_property$3(this, "_CanSeek", true), _define_property$3(this, "_CanGoNext", true), _define_property$3(this, "_CanGoPrevious", true), _define_property$3(this, "_Metadata", {}), _define_property$3(this, "_MaximumRate", 1), _define_property$3(this, "_MinimumRate", 1), _define_property$3(this, "_Rate", 1), _define_property$3(this, "_Shuffle", false), _define_property$3(this, "_Volume", 0), _define_property$3(this, "_LoopStatus", LOOP_STATUS_NONE), _define_property$3(this, "_PlaybackStatus", PLAYBACK_STATUS_STOPPED);
1033
+ }
1034
+ };
1035
+ ({e: [_initProto$2]} = _apply_decs_2203_r$2(PlayerInterface, [
1036
+ [
1037
+ _dec$2,
1038
+ 3,
1039
+ "CanControl"
1040
+ ],
1041
+ [
1042
+ _dec1$2,
1043
+ 3,
1044
+ "CanPause"
1045
+ ],
1046
+ [
1047
+ _dec2$2,
1048
+ 3,
1049
+ "CanPlay"
1050
+ ],
1051
+ [
1052
+ _dec3$2,
1053
+ 3,
1054
+ "CanSeek"
1055
+ ],
1056
+ [
1057
+ _dec4$2,
1058
+ 3,
1059
+ "CanGoNext"
1060
+ ],
1061
+ [
1062
+ _dec5$2,
1063
+ 3,
1064
+ "CanGoPrevious"
1065
+ ],
1066
+ [
1067
+ _dec6$1,
1068
+ 3,
1069
+ "Metadata"
1070
+ ],
1071
+ [
1072
+ _dec7$1,
1073
+ 3,
1074
+ "MaximumRate"
1075
+ ],
1076
+ [
1077
+ _dec8$1,
1078
+ 3,
1079
+ "MinimumRate"
1080
+ ],
1081
+ [
1082
+ _dec9$1,
1083
+ 3,
1084
+ "Rate"
1085
+ ],
1086
+ [
1087
+ _dec10,
1088
+ 3,
1089
+ "Shuffle"
1090
+ ],
1091
+ [
1092
+ _dec11,
1093
+ 3,
1094
+ "Volume"
1095
+ ],
1096
+ [
1097
+ _dec12,
1098
+ 3,
1099
+ "Position"
1100
+ ],
1101
+ [
1102
+ _dec13,
1103
+ 3,
1104
+ "LoopStatus"
1105
+ ],
1106
+ [
1107
+ _dec14,
1108
+ 3,
1109
+ "PlaybackStatus"
1110
+ ],
1111
+ [
1112
+ _dec15,
1113
+ 2,
1114
+ "Next"
1115
+ ],
1116
+ [
1117
+ _dec16,
1118
+ 2,
1119
+ "Previous"
1120
+ ],
1121
+ [
1122
+ _dec17,
1123
+ 2,
1124
+ "Pause"
1125
+ ],
1126
+ [
1127
+ _dec18,
1128
+ 2,
1129
+ "PlayPause"
1130
+ ],
1131
+ [
1132
+ _dec19,
1133
+ 2,
1134
+ "Stop"
1135
+ ],
1136
+ [
1137
+ _dec20,
1138
+ 2,
1139
+ "Play"
1140
+ ],
1141
+ [
1142
+ _dec21,
1143
+ 2,
1144
+ "Seek"
1145
+ ],
1146
+ [
1147
+ _dec22,
1148
+ 2,
1149
+ "SetPosition"
1150
+ ],
1151
+ [
1152
+ _dec23,
1153
+ 2,
1154
+ "OpenUri"
1155
+ ],
1156
+ [
1157
+ _dec24,
1158
+ 2,
1159
+ "Seeked"
1160
+ ]
1161
+ ], []));
1162
+ //#endregion
1163
+ //#region src/interfaces/playlists.ts
1164
+ function _define_property$2(obj, key, value) {
1165
+ if (key in obj) Object.defineProperty(obj, key, {
1166
+ value,
1167
+ enumerable: true,
1168
+ configurable: true,
1169
+ writable: true
1170
+ });
1171
+ else obj[key] = value;
1172
+ return obj;
1173
+ }
1174
+ function applyDecs2203RFactory$1() {
1175
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1176
+ return function addInitializer(initializer) {
1177
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
1178
+ assertCallable(initializer, "An initializer");
1179
+ initializers.push(initializer);
1180
+ };
1181
+ }
1182
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1183
+ var kindStr;
1184
+ switch (kind) {
1185
+ case 1:
1186
+ kindStr = "accessor";
1187
+ break;
1188
+ case 2:
1189
+ kindStr = "method";
1190
+ break;
1191
+ case 3:
1192
+ kindStr = "getter";
1193
+ break;
1194
+ case 4:
1195
+ kindStr = "setter";
1196
+ break;
1197
+ default: kindStr = "field";
1198
+ }
1199
+ var ctx = {
1200
+ kind: kindStr,
1201
+ name: isPrivate ? "#" + name : name,
1202
+ static: isStatic,
1203
+ private: isPrivate,
1204
+ metadata
1205
+ };
1206
+ var decoratorFinishedRef = { v: false };
1207
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1208
+ var get, set;
1209
+ if (kind === 0) if (isPrivate) {
1210
+ get = desc.get;
1211
+ set = desc.set;
1212
+ } else {
1213
+ get = function() {
1214
+ return this[name];
1215
+ };
1216
+ set = function(v) {
1217
+ this[name] = v;
1218
+ };
1219
+ }
1220
+ else if (kind === 2) get = function() {
1221
+ return desc.value;
1222
+ };
1223
+ else {
1224
+ if (kind === 1 || kind === 3) get = function() {
1225
+ return desc.get.call(this);
1226
+ };
1227
+ if (kind === 1 || kind === 4) set = function(v) {
1228
+ desc.set.call(this, v);
1229
+ };
1230
+ }
1231
+ if (get) {
1232
+ var originalGet = get;
1233
+ get = function(target) {
1234
+ if (arguments.length === 0) target = this;
1235
+ return originalGet.call(target);
1236
+ };
1237
+ }
1238
+ if (set) {
1239
+ var originalSet = set;
1240
+ set = function(target, value) {
1241
+ if (arguments.length === 1) {
1242
+ value = target;
1243
+ target = this;
1244
+ }
1245
+ return originalSet.call(target, value);
1246
+ };
1247
+ }
1248
+ if (isPrivate) ctx.access = get && set ? {
1249
+ get,
1250
+ set
1251
+ } : get ? { get } : { set };
1252
+ else {
1253
+ var has = function(target) {
1254
+ return name in target;
1255
+ };
1256
+ ctx.access = get && set ? {
1257
+ has,
1258
+ get,
1259
+ set
1260
+ } : get ? {
1261
+ has,
1262
+ get
1263
+ } : {
1264
+ has,
1265
+ set
1266
+ };
1267
+ }
1268
+ var newValue = dec(value, ctx);
1269
+ decoratorFinishedRef.v = true;
1270
+ return newValue;
1271
+ }
1272
+ function assertNotFinished(decoratorFinishedRef, fnName) {
1273
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
1274
+ }
1275
+ function assertCallable(fn, hint) {
1276
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
1277
+ }
1278
+ function assertValidReturnValue(kind, value) {
1279
+ var type = typeof value;
1280
+ if (kind === 1) {
1281
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1282
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
1283
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
1284
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
1285
+ } else if (type !== "function") {
1286
+ var hint;
1287
+ if (kind === 0) hint = "field";
1288
+ else if (kind === 10) hint = "class";
1289
+ else hint = "method";
1290
+ throw new TypeError(hint + " decorators must return a function or void 0");
1291
+ }
1292
+ }
1293
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1294
+ var decs = decInfo[0];
1295
+ var desc, init, value;
1296
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
1297
+ get: decInfo[3],
1298
+ set: decInfo[4]
1299
+ };
1300
+ else if (kind === 3) desc = { get: decInfo[3] };
1301
+ else if (kind === 4) desc = { set: decInfo[3] };
1302
+ else desc = { value: decInfo[3] };
1303
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
1304
+ if (kind === 1) value = {
1305
+ get: desc.get,
1306
+ set: desc.set
1307
+ };
1308
+ else if (kind === 2) value = desc.value;
1309
+ else if (kind === 3) value = desc.get;
1310
+ else if (kind === 4) value = desc.set;
1311
+ var newValue, get, set;
1312
+ if (typeof decs === "function") {
1313
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1314
+ if (newValue !== void 0) {
1315
+ assertValidReturnValue(kind, newValue);
1316
+ if (kind === 0) init = newValue;
1317
+ else if (kind === 1) {
1318
+ init = newValue.init;
1319
+ get = newValue.get || value.get;
1320
+ set = newValue.set || value.set;
1321
+ value = {
1322
+ get,
1323
+ set
1324
+ };
1325
+ } else value = newValue;
1326
+ }
1327
+ } else for (var i = decs.length - 1; i >= 0; i--) {
1328
+ var dec = decs[i];
1329
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1330
+ if (newValue !== void 0) {
1331
+ assertValidReturnValue(kind, newValue);
1332
+ var newInit;
1333
+ if (kind === 0) newInit = newValue;
1334
+ else if (kind === 1) {
1335
+ newInit = newValue.init;
1336
+ get = newValue.get || value.get;
1337
+ set = newValue.set || value.set;
1338
+ value = {
1339
+ get,
1340
+ set
1341
+ };
1342
+ } else value = newValue;
1343
+ if (newInit !== void 0) if (init === void 0) init = newInit;
1344
+ else if (typeof init === "function") init = [init, newInit];
1345
+ else init.push(newInit);
1346
+ }
1347
+ }
1348
+ if (kind === 0 || kind === 1) {
1349
+ if (init === void 0) init = function(instance, init) {
1350
+ return init;
1351
+ };
1352
+ else if (typeof init !== "function") {
1353
+ var ownInitializers = init;
1354
+ init = function(instance, init) {
1355
+ var value = init;
1356
+ for (var i = 0; i < ownInitializers.length; i++) value = ownInitializers[i].call(instance, value);
1357
+ return value;
1358
+ };
1359
+ } else {
1360
+ var originalInitializer = init;
1361
+ init = function(instance, init) {
1362
+ return originalInitializer.call(instance, init);
1363
+ };
1364
+ }
1365
+ ret.push(init);
1366
+ }
1367
+ if (kind !== 0) {
1368
+ if (kind === 1) {
1369
+ desc.get = value.get;
1370
+ desc.set = value.set;
1371
+ } else if (kind === 2) desc.value = value;
1372
+ else if (kind === 3) desc.get = value;
1373
+ else if (kind === 4) desc.set = value;
1374
+ if (isPrivate) if (kind === 1) {
1375
+ ret.push(function(instance, args) {
1376
+ return value.get.call(instance, args);
1377
+ });
1378
+ ret.push(function(instance, args) {
1379
+ return value.set.call(instance, args);
1380
+ });
1381
+ } else if (kind === 2) ret.push(value);
1382
+ else ret.push(function(instance, args) {
1383
+ return value.call(instance, args);
1384
+ });
1385
+ else Object.defineProperty(base, name, desc);
1386
+ }
1387
+ }
1388
+ function applyMemberDecs(Class, decInfos, metadata) {
1389
+ var ret = [];
1390
+ var protoInitializers;
1391
+ var staticInitializers;
1392
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
1393
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
1394
+ for (var i = 0; i < decInfos.length; i++) {
1395
+ var decInfo = decInfos[i];
1396
+ if (!Array.isArray(decInfo)) continue;
1397
+ var kind = decInfo[1];
1398
+ var name = decInfo[2];
1399
+ var isPrivate = decInfo.length > 3;
1400
+ var isStatic = kind >= 5;
1401
+ var base;
1402
+ var initializers;
1403
+ if (isStatic) {
1404
+ base = Class;
1405
+ kind = kind - 5;
1406
+ staticInitializers = staticInitializers || [];
1407
+ initializers = staticInitializers;
1408
+ } else {
1409
+ base = Class.prototype;
1410
+ protoInitializers = protoInitializers || [];
1411
+ initializers = protoInitializers;
1412
+ }
1413
+ if (kind !== 0 && !isPrivate) {
1414
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1415
+ var existingKind = existingNonFields.get(name) || 0;
1416
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
1417
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
1418
+ else existingNonFields.set(name, true);
1419
+ }
1420
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1421
+ }
1422
+ pushInitializers(ret, protoInitializers);
1423
+ pushInitializers(ret, staticInitializers);
1424
+ return ret;
1425
+ }
1426
+ function pushInitializers(ret, initializers) {
1427
+ if (initializers) ret.push(function(instance) {
1428
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1429
+ return instance;
1430
+ });
1431
+ }
1432
+ function applyClassDecs(targetClass, classDecs, metadata) {
1433
+ if (classDecs.length > 0) {
1434
+ var initializers = [];
1435
+ var newClass = targetClass;
1436
+ var name = targetClass.name;
1437
+ for (var i = classDecs.length - 1; i >= 0; i--) {
1438
+ var decoratorFinishedRef = { v: false };
1439
+ var nextNewClass = classDecs[i](newClass, {
1440
+ kind: "class",
1441
+ name,
1442
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1443
+ metadata
1444
+ });
1445
+ decoratorFinishedRef.v = true;
1446
+ if (nextNewClass !== void 0) {
1447
+ assertValidReturnValue(10, nextNewClass);
1448
+ newClass = nextNewClass;
1449
+ }
1450
+ }
1451
+ return [defineMetadata(newClass, metadata), function() {
1452
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(newClass);
1453
+ }];
1454
+ }
1455
+ }
1456
+ function defineMetadata(Class, metadata) {
1457
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1458
+ configurable: true,
1459
+ enumerable: true,
1460
+ value: metadata
1461
+ });
1462
+ }
1463
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1464
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1465
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1466
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
1467
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
1468
+ return {
1469
+ e,
1470
+ get c() {
1471
+ return applyClassDecs(targetClass, classDecs, metadata);
1472
+ }
1473
+ };
1474
+ };
1475
+ }
1476
+ function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
1477
+ return (_apply_decs_2203_r$1 = applyDecs2203RFactory$1())(targetClass, memberDecs, classDecs, parentClass);
1478
+ }
1479
+ var _dec$1, _dec1$1, _dec2$1, _dec3$1, _dec4$1, _dec5$1, _initProto$1;
1480
+ const { property: property$1, method: method$1, signal: signal$1 } = _jellybrick_dbus_next.interface;
1481
+ const ACCESS_READ$1 = _jellybrick_dbus_next.interface.ACCESS_READ;
1482
+ _dec$1 = property$1({
1483
+ signature: "u",
1484
+ access: ACCESS_READ$1
1485
+ }), _dec1$1 = property$1({
1486
+ signature: "as",
1487
+ access: ACCESS_READ$1
1488
+ }), _dec2$1 = property$1({
1489
+ signature: "(b(oss))",
1490
+ access: ACCESS_READ$1
1491
+ }), _dec3$1 = method$1({ inSignature: "o" }), _dec4$1 = method$1({
1492
+ inSignature: "uusb",
1493
+ outSignature: "a(oss)"
1494
+ }), _dec5$1 = signal$1({ signature: "(oss)" });
1495
+ var PlaylistsInterface = class extends MprisInterface {
1496
+ get PlaylistCount() {
1497
+ return this._PlaylistCount;
1498
+ }
1499
+ get Orderings() {
1500
+ return ["Alphabetical", "UserDefined"];
1501
+ }
1502
+ get ActivePlaylist() {
1503
+ return this._ActivePlaylist;
1504
+ }
1505
+ setActivePlaylistId(playlistId) {
1506
+ const i = this.player.getPlaylistIndex(playlistId);
1507
+ this.setProperty("ActivePlaylist", this.player.playlists[i] || null);
1508
+ }
1509
+ ActivatePlaylist(playlistId) {
1510
+ this.player.emit("activatePlaylist", playlistId);
1511
+ }
1512
+ GetPlaylists(index, maxCount, order, reverseOrder) {
1513
+ if (!this.player.playlists) return [];
1514
+ const result = this.player.playlists.sort((a, b) => {
1515
+ let ret = 1;
1516
+ switch (order) {
1517
+ case "Alphabetical":
1518
+ ret = a.Name > b.Name ? 1 : -1;
1519
+ break;
1520
+ case "UserDefined": break;
1521
+ }
1522
+ return ret;
1523
+ }).slice(index, maxCount + index).map((p) => playlistToDbus(p));
1524
+ if (reverseOrder) result.reverse();
1525
+ return result;
1526
+ }
1527
+ PlaylistChanged(playlist) {
1528
+ return playlistToDbus(playlist);
1529
+ }
1530
+ constructor(player) {
1531
+ super("org.mpris.MediaPlayer2.Playlists", player), _define_property$2(this, "_ActivePlaylist", (_initProto$1(this), [false, emptyPlaylist])), _define_property$2(this, "_PlaylistCount", 0);
1532
+ }
1533
+ };
1534
+ ({e: [_initProto$1]} = _apply_decs_2203_r$1(PlaylistsInterface, [
1535
+ [
1536
+ _dec$1,
1537
+ 3,
1538
+ "PlaylistCount"
1539
+ ],
1540
+ [
1541
+ _dec1$1,
1542
+ 3,
1543
+ "Orderings"
1544
+ ],
1545
+ [
1546
+ _dec2$1,
1547
+ 3,
1548
+ "ActivePlaylist"
1549
+ ],
1550
+ [
1551
+ _dec3$1,
1552
+ 2,
1553
+ "ActivatePlaylist"
1554
+ ],
1555
+ [
1556
+ _dec4$1,
1557
+ 2,
1558
+ "GetPlaylists"
1559
+ ],
1560
+ [
1561
+ _dec5$1,
1562
+ 2,
1563
+ "PlaylistChanged"
1564
+ ]
1565
+ ], []));
1566
+ //#endregion
1567
+ //#region src/interfaces/tracklist.ts
1568
+ function _define_property$1(obj, key, value) {
1569
+ if (key in obj) Object.defineProperty(obj, key, {
1570
+ value,
1571
+ enumerable: true,
1572
+ configurable: true,
1573
+ writable: true
1574
+ });
1575
+ else obj[key] = value;
1576
+ return obj;
1577
+ }
1578
+ function applyDecs2203RFactory() {
1579
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1580
+ return function addInitializer(initializer) {
1581
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
1582
+ assertCallable(initializer, "An initializer");
1583
+ initializers.push(initializer);
1584
+ };
1585
+ }
1586
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1587
+ var kindStr;
1588
+ switch (kind) {
1589
+ case 1:
1590
+ kindStr = "accessor";
1591
+ break;
1592
+ case 2:
1593
+ kindStr = "method";
1594
+ break;
1595
+ case 3:
1596
+ kindStr = "getter";
1597
+ break;
1598
+ case 4:
1599
+ kindStr = "setter";
1600
+ break;
1601
+ default: kindStr = "field";
1602
+ }
1603
+ var ctx = {
1604
+ kind: kindStr,
1605
+ name: isPrivate ? "#" + name : name,
1606
+ static: isStatic,
1607
+ private: isPrivate,
1608
+ metadata
1609
+ };
1610
+ var decoratorFinishedRef = { v: false };
1611
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1612
+ var get, set;
1613
+ if (kind === 0) if (isPrivate) {
1614
+ get = desc.get;
1615
+ set = desc.set;
1616
+ } else {
1617
+ get = function() {
1618
+ return this[name];
1619
+ };
1620
+ set = function(v) {
1621
+ this[name] = v;
1622
+ };
1623
+ }
1624
+ else if (kind === 2) get = function() {
1625
+ return desc.value;
1626
+ };
1627
+ else {
1628
+ if (kind === 1 || kind === 3) get = function() {
1629
+ return desc.get.call(this);
1630
+ };
1631
+ if (kind === 1 || kind === 4) set = function(v) {
1632
+ desc.set.call(this, v);
1633
+ };
1634
+ }
1635
+ if (get) {
1636
+ var originalGet = get;
1637
+ get = function(target) {
1638
+ if (arguments.length === 0) target = this;
1639
+ return originalGet.call(target);
1640
+ };
1641
+ }
1642
+ if (set) {
1643
+ var originalSet = set;
1644
+ set = function(target, value) {
1645
+ if (arguments.length === 1) {
1646
+ value = target;
1647
+ target = this;
1648
+ }
1649
+ return originalSet.call(target, value);
1650
+ };
1651
+ }
1652
+ if (isPrivate) ctx.access = get && set ? {
1653
+ get,
1654
+ set
1655
+ } : get ? { get } : { set };
1656
+ else {
1657
+ var has = function(target) {
1658
+ return name in target;
1659
+ };
1660
+ ctx.access = get && set ? {
1661
+ has,
1662
+ get,
1663
+ set
1664
+ } : get ? {
1665
+ has,
1666
+ get
1667
+ } : {
1668
+ has,
1669
+ set
1670
+ };
1671
+ }
1672
+ var newValue = dec(value, ctx);
1673
+ decoratorFinishedRef.v = true;
1674
+ return newValue;
1675
+ }
1676
+ function assertNotFinished(decoratorFinishedRef, fnName) {
1677
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
1678
+ }
1679
+ function assertCallable(fn, hint) {
1680
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
1681
+ }
1682
+ function assertValidReturnValue(kind, value) {
1683
+ var type = typeof value;
1684
+ if (kind === 1) {
1685
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1686
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
1687
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
1688
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
1689
+ } else if (type !== "function") {
1690
+ var hint;
1691
+ if (kind === 0) hint = "field";
1692
+ else if (kind === 10) hint = "class";
1693
+ else hint = "method";
1694
+ throw new TypeError(hint + " decorators must return a function or void 0");
1695
+ }
1696
+ }
1697
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1698
+ var decs = decInfo[0];
1699
+ var desc, init, value;
1700
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
1701
+ get: decInfo[3],
1702
+ set: decInfo[4]
1703
+ };
1704
+ else if (kind === 3) desc = { get: decInfo[3] };
1705
+ else if (kind === 4) desc = { set: decInfo[3] };
1706
+ else desc = { value: decInfo[3] };
1707
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
1708
+ if (kind === 1) value = {
1709
+ get: desc.get,
1710
+ set: desc.set
1711
+ };
1712
+ else if (kind === 2) value = desc.value;
1713
+ else if (kind === 3) value = desc.get;
1714
+ else if (kind === 4) value = desc.set;
1715
+ var newValue, get, set;
1716
+ if (typeof decs === "function") {
1717
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1718
+ if (newValue !== void 0) {
1719
+ assertValidReturnValue(kind, newValue);
1720
+ if (kind === 0) init = newValue;
1721
+ else if (kind === 1) {
1722
+ init = newValue.init;
1723
+ get = newValue.get || value.get;
1724
+ set = newValue.set || value.set;
1725
+ value = {
1726
+ get,
1727
+ set
1728
+ };
1729
+ } else value = newValue;
1730
+ }
1731
+ } else for (var i = decs.length - 1; i >= 0; i--) {
1732
+ var dec = decs[i];
1733
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1734
+ if (newValue !== void 0) {
1735
+ assertValidReturnValue(kind, newValue);
1736
+ var newInit;
1737
+ if (kind === 0) newInit = newValue;
1738
+ else if (kind === 1) {
1739
+ newInit = newValue.init;
1740
+ get = newValue.get || value.get;
1741
+ set = newValue.set || value.set;
1742
+ value = {
1743
+ get,
1744
+ set
1745
+ };
1746
+ } else value = newValue;
1747
+ if (newInit !== void 0) if (init === void 0) init = newInit;
1748
+ else if (typeof init === "function") init = [init, newInit];
1749
+ else init.push(newInit);
1750
+ }
1751
+ }
1752
+ if (kind === 0 || kind === 1) {
1753
+ if (init === void 0) init = function(instance, init) {
1754
+ return init;
1755
+ };
1756
+ else if (typeof init !== "function") {
1757
+ var ownInitializers = init;
1758
+ init = function(instance, init) {
1759
+ var value = init;
1760
+ for (var i = 0; i < ownInitializers.length; i++) value = ownInitializers[i].call(instance, value);
1761
+ return value;
1762
+ };
1763
+ } else {
1764
+ var originalInitializer = init;
1765
+ init = function(instance, init) {
1766
+ return originalInitializer.call(instance, init);
1767
+ };
1768
+ }
1769
+ ret.push(init);
1770
+ }
1771
+ if (kind !== 0) {
1772
+ if (kind === 1) {
1773
+ desc.get = value.get;
1774
+ desc.set = value.set;
1775
+ } else if (kind === 2) desc.value = value;
1776
+ else if (kind === 3) desc.get = value;
1777
+ else if (kind === 4) desc.set = value;
1778
+ if (isPrivate) if (kind === 1) {
1779
+ ret.push(function(instance, args) {
1780
+ return value.get.call(instance, args);
1781
+ });
1782
+ ret.push(function(instance, args) {
1783
+ return value.set.call(instance, args);
1784
+ });
1785
+ } else if (kind === 2) ret.push(value);
1786
+ else ret.push(function(instance, args) {
1787
+ return value.call(instance, args);
1788
+ });
1789
+ else Object.defineProperty(base, name, desc);
1790
+ }
1791
+ }
1792
+ function applyMemberDecs(Class, decInfos, metadata) {
1793
+ var ret = [];
1794
+ var protoInitializers;
1795
+ var staticInitializers;
1796
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
1797
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
1798
+ for (var i = 0; i < decInfos.length; i++) {
1799
+ var decInfo = decInfos[i];
1800
+ if (!Array.isArray(decInfo)) continue;
1801
+ var kind = decInfo[1];
1802
+ var name = decInfo[2];
1803
+ var isPrivate = decInfo.length > 3;
1804
+ var isStatic = kind >= 5;
1805
+ var base;
1806
+ var initializers;
1807
+ if (isStatic) {
1808
+ base = Class;
1809
+ kind = kind - 5;
1810
+ staticInitializers = staticInitializers || [];
1811
+ initializers = staticInitializers;
1812
+ } else {
1813
+ base = Class.prototype;
1814
+ protoInitializers = protoInitializers || [];
1815
+ initializers = protoInitializers;
1816
+ }
1817
+ if (kind !== 0 && !isPrivate) {
1818
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1819
+ var existingKind = existingNonFields.get(name) || 0;
1820
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
1821
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
1822
+ else existingNonFields.set(name, true);
1823
+ }
1824
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1825
+ }
1826
+ pushInitializers(ret, protoInitializers);
1827
+ pushInitializers(ret, staticInitializers);
1828
+ return ret;
1829
+ }
1830
+ function pushInitializers(ret, initializers) {
1831
+ if (initializers) ret.push(function(instance) {
1832
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1833
+ return instance;
1834
+ });
1835
+ }
1836
+ function applyClassDecs(targetClass, classDecs, metadata) {
1837
+ if (classDecs.length > 0) {
1838
+ var initializers = [];
1839
+ var newClass = targetClass;
1840
+ var name = targetClass.name;
1841
+ for (var i = classDecs.length - 1; i >= 0; i--) {
1842
+ var decoratorFinishedRef = { v: false };
1843
+ var nextNewClass = classDecs[i](newClass, {
1844
+ kind: "class",
1845
+ name,
1846
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1847
+ metadata
1848
+ });
1849
+ decoratorFinishedRef.v = true;
1850
+ if (nextNewClass !== void 0) {
1851
+ assertValidReturnValue(10, nextNewClass);
1852
+ newClass = nextNewClass;
1853
+ }
1854
+ }
1855
+ return [defineMetadata(newClass, metadata), function() {
1856
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(newClass);
1857
+ }];
1858
+ }
1859
+ }
1860
+ function defineMetadata(Class, metadata) {
1861
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1862
+ configurable: true,
1863
+ enumerable: true,
1864
+ value: metadata
1865
+ });
1866
+ }
1867
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1868
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1869
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1870
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
1871
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
1872
+ return {
1873
+ e,
1874
+ get c() {
1875
+ return applyClassDecs(targetClass, classDecs, metadata);
1876
+ }
1877
+ };
1878
+ };
1879
+ }
1880
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
1881
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
1882
+ }
1883
+ var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _initProto;
1884
+ const { property, method, signal } = _jellybrick_dbus_next.interface;
1885
+ const ACCESS_READ = _jellybrick_dbus_next.interface.ACCESS_READ;
1886
+ _dec = property({
1887
+ signature: "ao",
1888
+ access: ACCESS_READ
1889
+ }), _dec1 = property({
1890
+ signature: "b",
1891
+ access: ACCESS_READ
1892
+ }), _dec2 = method({
1893
+ inSignature: "ao",
1894
+ outSignature: "aa{sv}"
1895
+ }), _dec3 = method({ inSignature: "sob" }), _dec4 = method({ inSignature: "o" }), _dec5 = method({ inSignature: "o" }), _dec6 = signal({ signature: "aoo" }), _dec7 = signal({ signature: "a{sv}" }), _dec8 = signal({ signature: "o" }), _dec9 = signal({ signature: "oa{sv}" });
1896
+ var TracklistInterface = class extends MprisInterface {
1897
+ setTracks(tracksPlain) {
1898
+ this.setProperty("Tracks", tracksPlain);
1899
+ }
1900
+ get Tracks() {
1901
+ return this._Tracks;
1902
+ }
1903
+ get CanEditTracks() {
1904
+ return this._CanEditTracks;
1905
+ }
1906
+ GetTracksMetadata(trackIds) {
1907
+ return this.player.tracks.filter((t) => {
1908
+ return trackIds.some((id) => id === t["mpris:trackid"]);
1909
+ }).map((t) => metadataToDbus(t));
1910
+ }
1911
+ AddTrack(uri, afterTrack, setAsCurrent) {
1912
+ this.player.emit("addTrack", {
1913
+ uri,
1914
+ afterTrack,
1915
+ setAsCurrent
1916
+ });
1917
+ }
1918
+ RemoveTrack(trackId) {
1919
+ this.player.emit("removeTrack", trackId);
1920
+ }
1921
+ GoTo(trackId) {
1922
+ this.player.emit("goTo", trackId);
1923
+ }
1924
+ TrackListReplaced(replacedPlain) {
1925
+ this.setTracks(replacedPlain);
1926
+ return [this._Tracks, "/org/mpris/MediaPlayer2/TrackList/NoTrack"];
1927
+ }
1928
+ TrackAdded(metadata) {
1929
+ return metadataToDbus(metadata);
1930
+ }
1931
+ TrackRemoved(path) {
1932
+ return path;
1933
+ }
1934
+ TrackMetadataChanged(path, metadata) {
1935
+ return [path, metadataToDbus(metadata)];
1936
+ }
1937
+ constructor(player) {
1938
+ super("org.mpris.MediaPlayer2.TrackList", player), _define_property$1(this, "_Tracks", (_initProto(this), [])), _define_property$1(this, "_CanEditTracks", false);
1939
+ }
1940
+ };
1941
+ ({e: [_initProto]} = _apply_decs_2203_r(TracklistInterface, [
1942
+ [
1943
+ _dec,
1944
+ 3,
1945
+ "Tracks"
1946
+ ],
1947
+ [
1948
+ _dec1,
1949
+ 3,
1950
+ "CanEditTracks"
1951
+ ],
1952
+ [
1953
+ _dec2,
1954
+ 2,
1955
+ "GetTracksMetadata"
1956
+ ],
1957
+ [
1958
+ _dec3,
1959
+ 2,
1960
+ "AddTrack"
1961
+ ],
1962
+ [
1963
+ _dec4,
1964
+ 2,
1965
+ "RemoveTrack"
1966
+ ],
1967
+ [
1968
+ _dec5,
1969
+ 2,
1970
+ "GoTo"
1971
+ ],
1972
+ [
1973
+ _dec6,
1974
+ 2,
1975
+ "TrackListReplaced"
1976
+ ],
1977
+ [
1978
+ _dec7,
1979
+ 2,
1980
+ "TrackAdded"
1981
+ ],
1982
+ [
1983
+ _dec8,
1984
+ 2,
1985
+ "TrackRemoved"
1986
+ ],
1987
+ [
1988
+ _dec9,
1989
+ 2,
1990
+ "TrackMetadataChanged"
1991
+ ]
1992
+ ], []));
1993
+ //#endregion
1994
+ //#region src/player.ts
1995
+ function _check_private_redeclaration(obj, privateCollection) {
1996
+ if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
1997
+ }
1998
+ function _class_private_method_get(receiver, privateSet, fn) {
1999
+ if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
2000
+ return fn;
2001
+ }
2002
+ function _class_private_method_init(obj, privateSet) {
2003
+ _check_private_redeclaration(obj, privateSet);
2004
+ privateSet.add(obj);
2005
+ }
2006
+ function _define_property(obj, key, value) {
2007
+ if (key in obj) Object.defineProperty(obj, key, {
2008
+ value,
2009
+ enumerable: true,
2010
+ configurable: true,
2011
+ writable: true
2012
+ });
2013
+ else obj[key] = value;
2014
+ return obj;
2015
+ }
2016
+ const MPRIS_PATH = "/org/mpris/MediaPlayer2";
2017
+ const lcfirst = (str) => {
2018
+ return str.charAt(0).toLowerCase() + str.substring(1);
2019
+ };
2020
+ var _addRootInterface = /*#__PURE__*/ new WeakSet(), _addPlayerInterface = /*#__PURE__*/ new WeakSet(), _addTracklistInterface = /*#__PURE__*/ new WeakSet(), _addPlaylistsInterface = /*#__PURE__*/ new WeakSet(), _addEventedProperty = /*#__PURE__*/ new WeakSet(), _addEventedPropertiesList = /*#__PURE__*/ new WeakSet();
2021
+ var Player = class extends node_events.EventEmitter {
2022
+ async init(opts) {
2023
+ this.serviceName = `org.mpris.MediaPlayer2.${this.name}`;
2024
+ _jellybrick_dbus_next.validators.assertBusNameValid(this.serviceName);
2025
+ this._bus = (0, _jellybrick_dbus_next.sessionBus)();
2026
+ this._bus.on("error", (err) => {
2027
+ this.emit("error", err instanceof Error ? err : new Error(String(err)));
2028
+ });
2029
+ this.interfaces = {};
2030
+ _class_private_method_get(this, _addRootInterface, addRootInterface).call(this, opts);
2031
+ if (this.supportedInterfaces.indexOf("player") >= 0) _class_private_method_get(this, _addPlayerInterface, addPlayerInterface).call(this);
2032
+ if (this.supportedInterfaces.indexOf("trackList") >= 0) _class_private_method_get(this, _addTracklistInterface, addTracklistInterface).call(this);
2033
+ if (this.supportedInterfaces.indexOf("playlists") >= 0) _class_private_method_get(this, _addPlaylistsInterface, addPlaylistsInterface).call(this);
2034
+ for (const iface of Object.values(this.interfaces)) if (iface !== void 0) this._bus.export(MPRIS_PATH, iface);
2035
+ try {
2036
+ if (await this._bus.requestName(this.serviceName, _jellybrick_dbus_next.NameFlag.DO_NOT_QUEUE) === _jellybrick_dbus_next.RequestNameReply.EXISTS) {
2037
+ this.serviceName = `${this.serviceName}.instance${process.pid}`;
2038
+ await this._bus.requestName(this.serviceName);
2039
+ }
2040
+ } catch (err) {
2041
+ this.emit("error", err instanceof Error ? err : new Error(String(err)));
2042
+ }
2043
+ }
2044
+ /**
2045
+ * Get a valid object path with the `subpath` as the basename which is suitable
2046
+ * for use as an id.
2047
+ *
2048
+ * @name Player#objectPath
2049
+ * @function
2050
+ * @param {String} subpath - The basename of this path
2051
+ * @returns {String} - A valid object path that can be used as an id.
2052
+ */ objectPath(subpath) {
2053
+ let path = `/org/node/mediaplayer/${this.name}`;
2054
+ if (subpath) path += `/${subpath}`;
2055
+ return path;
2056
+ }
2057
+ /**
2058
+ * Gets the position of this player. This method is intended to be overridden
2059
+ * by the user to return the position of the player in microseconds.
2060
+ *
2061
+ * @name Player#getPosition
2062
+ * @function
2063
+ * @returns {Number} - The current position of the player in microseconds. (Integer)
2064
+ */ getPosition() {
2065
+ return 0;
2066
+ }
2067
+ /**
2068
+ * Emits the `Seeked` DBus signal to listening clients with the given position.
2069
+ *
2070
+ * @name Player#seeked
2071
+ * @function
2072
+ * @param {Number} position - The position in microseconds. (Integer)
2073
+ */ seeked(position) {
2074
+ var _this_interfaces_player;
2075
+ const seekTo = Math.floor(position || 0);
2076
+ if (isNaN(seekTo)) throw new Error(`seeked expected a number (got ${position})`);
2077
+ (_this_interfaces_player = this.interfaces.player) === null || _this_interfaces_player === void 0 || _this_interfaces_player.Seeked(seekTo);
2078
+ }
2079
+ getTrackIndex(trackId) {
2080
+ for (let i = 0; i < this.tracks.length; i++) {
2081
+ const track = this.tracks[i];
2082
+ if ((track === null || track === void 0 ? void 0 : track["mpris:trackid"]) === trackId) return i;
2083
+ }
2084
+ return -1;
2085
+ }
2086
+ getTrack(trackId) {
2087
+ return this.tracks[this.getTrackIndex(trackId)];
2088
+ }
2089
+ addTrack(track) {
2090
+ var _this_interfaces_tracklist, _this_interfaces_tracklist1;
2091
+ this.tracks.push(track);
2092
+ (_this_interfaces_tracklist = this.interfaces.tracklist) === null || _this_interfaces_tracklist === void 0 || _this_interfaces_tracklist.setTracks(this.tracks);
2093
+ let afterTrack = "/org/mpris/MediaPlayer2/TrackList/NoTrack";
2094
+ if (this.tracks.length > 2) {
2095
+ const previous = this.tracks[this.tracks.length - 2];
2096
+ if ((previous === null || previous === void 0 ? void 0 : previous["mpris:trackid"]) !== void 0) afterTrack = previous["mpris:trackid"];
2097
+ }
2098
+ (_this_interfaces_tracklist1 = this.interfaces.tracklist) === null || _this_interfaces_tracklist1 === void 0 || _this_interfaces_tracklist1.TrackAdded(afterTrack);
2099
+ }
2100
+ removeTrack(trackId) {
2101
+ var _this_interfaces_tracklist, _this_interfaces_tracklist1;
2102
+ const i = this.getTrackIndex(trackId);
2103
+ this.tracks.splice(i, 1);
2104
+ (_this_interfaces_tracklist = this.interfaces.tracklist) === null || _this_interfaces_tracklist === void 0 || _this_interfaces_tracklist.setTracks(this.tracks);
2105
+ (_this_interfaces_tracklist1 = this.interfaces.tracklist) === null || _this_interfaces_tracklist1 === void 0 || _this_interfaces_tracklist1.TrackRemoved(trackId);
2106
+ }
2107
+ /**
2108
+ * Get the index of a playlist entry in the `playlists` list property of the
2109
+ * player from the given id.
2110
+ *
2111
+ * @name Player#getPlaylistIndex
2112
+ * @function
2113
+ * @param {String} playlistId - The id for the playlist entry.
2114
+ */ getPlaylistIndex(playlistId) {
2115
+ for (let i = 0; i < this.playlists.length; i++) {
2116
+ const playlist = this.playlists[i];
2117
+ if ((playlist === null || playlist === void 0 ? void 0 : playlist.Id) === playlistId) return i;
2118
+ }
2119
+ return -1;
2120
+ }
2121
+ /**
2122
+ * Set the list of playlists advertised to listeners on the bus. Each playlist
2123
+ * must have string members `Id`, `Name`, and `Icon`.
2124
+ *
2125
+ * @name Player#setPlaylists
2126
+ * @function
2127
+ * @param {Array} playlists - A list of playlists.
2128
+ */ setPlaylists(playlists) {
2129
+ this.playlists = playlists;
2130
+ this.playlistCount = playlists.length;
2131
+ this.playlists.forEach((playlist) => {
2132
+ if (playlist) {
2133
+ var _this_interfaces_playlists;
2134
+ (_this_interfaces_playlists = this.interfaces.playlists) === null || _this_interfaces_playlists === void 0 || _this_interfaces_playlists.PlaylistChanged(playlist);
2135
+ }
2136
+ });
2137
+ }
2138
+ /**
2139
+ * Set the playlist identified by `playlistId` to be the currently active
2140
+ * playlist.
2141
+ *
2142
+ * @name Player#setActivePlaylist
2143
+ * @function
2144
+ * @param {String} playlistId - The id of the playlist to activate.
2145
+ */ setActivePlaylist(playlistId) {
2146
+ var _this_interfaces_playlists;
2147
+ (_this_interfaces_playlists = this.interfaces.playlists) === null || _this_interfaces_playlists === void 0 || _this_interfaces_playlists.setActivePlaylistId(playlistId);
2148
+ }
2149
+ constructor(options) {
2150
+ var _options_supportedInterfaces;
2151
+ super(), _class_private_method_init(this, _addRootInterface), _class_private_method_init(this, _addPlayerInterface), _class_private_method_init(this, _addTracklistInterface), _class_private_method_init(this, _addPlaylistsInterface), _class_private_method_init(this, _addEventedProperty), _class_private_method_init(this, _addEventedPropertiesList), _define_property(this, "name", void 0), _define_property(this, "supportedInterfaces", void 0), _define_property(this, "serviceName", void 0), _define_property(this, "_bus", void 0), _define_property(this, "interfaces", {}), _define_property(this, "_tracks", []);
2152
+ this.name = options.name;
2153
+ this.supportedInterfaces = (_options_supportedInterfaces = options.supportedInterfaces) !== null && _options_supportedInterfaces !== void 0 ? _options_supportedInterfaces : ["player"];
2154
+ this._tracks = [];
2155
+ this.init(options).catch((err) => {
2156
+ this.emit("error", err instanceof Error ? err : new Error(String(err)));
2157
+ });
2158
+ }
2159
+ };
2160
+ _define_property(Player, "PLAYBACK_STATUS_PLAYING", PLAYBACK_STATUS_PLAYING);
2161
+ _define_property(Player, "PLAYBACK_STATUS_PAUSED", PLAYBACK_STATUS_PAUSED);
2162
+ _define_property(Player, "PLAYBACK_STATUS_STOPPED", PLAYBACK_STATUS_STOPPED);
2163
+ _define_property(Player, "LOOP_STATUS_NONE", LOOP_STATUS_NONE);
2164
+ _define_property(Player, "LOOP_STATUS_TRACK", LOOP_STATUS_TRACK);
2165
+ _define_property(Player, "LOOP_STATUS_PLAYLIST", LOOP_STATUS_PLAYLIST);
2166
+ function addRootInterface(opts) {
2167
+ this.interfaces.root = new RootInterface(this, opts);
2168
+ _class_private_method_get(this, _addEventedPropertiesList, addEventedPropertiesList).call(this, this.interfaces.root, [
2169
+ "Identity",
2170
+ "Fullscreen",
2171
+ "SupportedUriSchemes",
2172
+ "SupportedMimeTypes",
2173
+ "CanQuit",
2174
+ "CanRaise",
2175
+ "CanSetFullscreen",
2176
+ "HasTrackList",
2177
+ "DesktopEntry"
2178
+ ]);
2179
+ }
2180
+ function addPlayerInterface() {
2181
+ this.interfaces.player = new PlayerInterface(this);
2182
+ _class_private_method_get(this, _addEventedPropertiesList, addEventedPropertiesList).call(this, this.interfaces.player, [
2183
+ "PlaybackStatus",
2184
+ "LoopStatus",
2185
+ "Rate",
2186
+ "Shuffle",
2187
+ "Metadata",
2188
+ "Volume",
2189
+ "CanControl",
2190
+ "CanPause",
2191
+ "CanPlay",
2192
+ "CanSeek",
2193
+ "CanGoNext",
2194
+ "CanGoPrevious",
2195
+ "MinimumRate",
2196
+ "MaximumRate"
2197
+ ]);
2198
+ }
2199
+ function addTracklistInterface() {
2200
+ this.interfaces.tracklist = new TracklistInterface(this);
2201
+ _class_private_method_get(this, _addEventedPropertiesList, addEventedPropertiesList).call(this, this.interfaces.tracklist, ["CanEditTracks"]);
2202
+ Object.defineProperty(this, "tracks", {
2203
+ get: () => {
2204
+ return this._tracks;
2205
+ },
2206
+ set: (value) => {
2207
+ var _this_interfaces_tracklist;
2208
+ this._tracks = value;
2209
+ (_this_interfaces_tracklist = this.interfaces.tracklist) === null || _this_interfaces_tracklist === void 0 || _this_interfaces_tracklist.TrackListReplaced(value);
2210
+ },
2211
+ enumerable: true,
2212
+ configurable: true
2213
+ });
2214
+ }
2215
+ function addPlaylistsInterface() {
2216
+ this.interfaces.playlists = new PlaylistsInterface(this);
2217
+ _class_private_method_get(this, _addEventedPropertiesList, addEventedPropertiesList).call(this, this.interfaces.playlists, ["PlaylistCount", "ActivePlaylist"]);
2218
+ }
2219
+ function addEventedProperty(iface, name) {
2220
+ const localName = lcfirst(name);
2221
+ Object.defineProperty(this, localName, {
2222
+ get: () => {
2223
+ const value = Reflect.get(iface, name);
2224
+ if (name === "ActivePlaylist") return playlistToPlain(value);
2225
+ else if (name === "Metadata") return metadataToPlain(value);
2226
+ return value;
2227
+ },
2228
+ set: (value) => {
2229
+ iface.setProperty(name, value);
2230
+ },
2231
+ enumerable: true,
2232
+ configurable: true
2233
+ });
2234
+ }
2235
+ function addEventedPropertiesList(iface, props) {
2236
+ for (const prop of props) _class_private_method_get(this, _addEventedProperty, addEventedProperty).call(this, iface, prop);
2237
+ }
2238
+ //#endregion
2239
+ //#region src/index.ts
2240
+ var src_default = Player;
2241
+ //#endregion
2242
+ module.exports = src_default;
2243
+
2244
+ //# sourceMappingURL=index.cjs.map