@bridgething/client 0.12.1 → 0.14.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.
@@ -314,6 +314,87 @@ export class AudioSurface {
314
314
  await this._client.send(msg);
315
315
  }
316
316
  }
317
+ export class BlobSurface {
318
+ _client;
319
+ constructor(_client) {
320
+ this._client = _client;
321
+ }
322
+ /** Subscribe to `Blob::List` from the daemon. */
323
+ onList(handler) {
324
+ return this._client.on(event => {
325
+ if (event.type !== 'message')
326
+ return;
327
+ const data = event.message.data;
328
+ if (data.type !== 'blob')
329
+ return;
330
+ const inner = data.data;
331
+ if (inner.event !== 'list')
332
+ return;
333
+ handler(inner.data);
334
+ });
335
+ }
336
+ /** Subscribe to `Blob::Changed` from the daemon. */
337
+ onChanged(handler) {
338
+ return this._client.on(event => {
339
+ if (event.type !== 'message')
340
+ return;
341
+ const data = event.message.data;
342
+ if (data.type !== 'blob')
343
+ return;
344
+ const inner = data.data;
345
+ if (inner.event !== 'changed')
346
+ return;
347
+ handler(inner.data);
348
+ });
349
+ }
350
+ /** Exhaustive subscribe over all inbound `Blob` variants. */
351
+ subscribe(handlers) {
352
+ return this._subscribe(handlers, false);
353
+ }
354
+ /** Same as `subscribe` but every handler is optional. */
355
+ subscribePartial(handlers) {
356
+ return this._subscribe(handlers, true);
357
+ }
358
+ _subscribe(handlers, partial) {
359
+ return this._client.on(event => {
360
+ if (event.type !== 'message')
361
+ return;
362
+ const data = event.message.data;
363
+ if (data.type !== 'blob')
364
+ return;
365
+ const inner = data.data;
366
+ switch (inner.event) {
367
+ case 'list': {
368
+ handlers.list?.(inner.data);
369
+ return;
370
+ }
371
+ case 'changed': {
372
+ handlers.changed?.(inner.data);
373
+ return;
374
+ }
375
+ default: {
376
+ if (!partial)
377
+ this._client.logger.warn('Blob: no handler for inner', inner);
378
+ return;
379
+ }
380
+ }
381
+ });
382
+ }
383
+ /** Typed request to the daemon: webapp sends, daemon responds. */
384
+ async list(options) {
385
+ const wireData = { type: 'blob', data: { event: 'list' } };
386
+ const response = await this._client.request(wireData, options?.timeoutMs);
387
+ const d = response.data;
388
+ if (d.type === 'blob') {
389
+ const inner = d.data;
390
+ if (inner.event === 'list')
391
+ return { ok: true, response: inner.data };
392
+ }
393
+ if (d.type === 'error')
394
+ return { ok: false, kind: 'protocol', error: d.data };
395
+ return { ok: false, kind: 'protocol', error: { type: 'unsupported' } };
396
+ }
397
+ }
317
398
  export class BluetoothSurface {
318
399
  _client;
319
400
  constructor(_client) {
@@ -479,15 +560,6 @@ export class BluetoothSurface {
479
560
  };
480
561
  await this._client.send(msg);
481
562
  }
482
- /** Send `Bluetooth::Forget` to the daemon. */
483
- async forget(payload) {
484
- const msg = {
485
- id: newUuid(),
486
- meta: { kind: 'command' },
487
- data: { type: 'bluetooth', data: { event: 'forget', data: payload } },
488
- };
489
- await this._client.send(msg);
490
- }
491
563
  /** Send `Bluetooth::SetAlias` to the daemon. */
492
564
  async setAlias(payload) {
493
565
  const msg = {
@@ -511,6 +583,20 @@ export class BluetoothSurface {
511
583
  return { ok: false, kind: 'protocol', error: d.data };
512
584
  return { ok: false, kind: 'protocol', error: { type: 'unsupported' } };
513
585
  }
586
+ /** Typed request to the daemon: webapp sends, daemon responds. */
587
+ async forget(req, options) {
588
+ const wireData = { type: 'bluetooth', data: { event: 'forget', data: req } };
589
+ const response = await this._client.request(wireData, options?.timeoutMs);
590
+ const d = response.data;
591
+ if (d.type === 'bluetooth') {
592
+ const inner = d.data;
593
+ if (inner.event === 'pairedDevices')
594
+ return { ok: true, response: inner.data };
595
+ }
596
+ if (d.type === 'error')
597
+ return { ok: false, kind: 'protocol', error: d.data };
598
+ return { ok: false, kind: 'protocol', error: { type: 'unsupported' } };
599
+ }
514
600
  }
515
601
  export class CapabilitiesSurface {
516
602
  _client;
@@ -1281,6 +1367,20 @@ export class LibrarySurface {
1281
1367
  handler(inner.data);
1282
1368
  });
1283
1369
  }
1370
+ /** Subscribe to `Library::BrowseChanged` from the daemon. */
1371
+ onBrowseChanged(handler) {
1372
+ return this._client.on(event => {
1373
+ if (event.type !== 'message')
1374
+ return;
1375
+ const data = event.message.data;
1376
+ if (data.type !== 'library')
1377
+ return;
1378
+ const inner = data.data;
1379
+ if (inner.event !== 'browseChanged')
1380
+ return;
1381
+ handler(inner.data);
1382
+ });
1383
+ }
1284
1384
  /** Subscribe to `Library::ErrorEvent` from the daemon. */
1285
1385
  onErrorEvent(handler) {
1286
1386
  return this._client.on(event => {
@@ -1344,6 +1444,10 @@ export class LibrarySurface {
1344
1444
  handlers.favoriteChanged?.(inner.data);
1345
1445
  return;
1346
1446
  }
1447
+ case 'browseChanged': {
1448
+ handlers.browseChanged?.(inner.data);
1449
+ return;
1450
+ }
1347
1451
  case 'errorEvent': {
1348
1452
  handlers.errorEvent?.(inner.data);
1349
1453
  return;
@@ -2694,6 +2798,90 @@ export class SystemSurface {
2694
2798
  handler(inner.data);
2695
2799
  });
2696
2800
  }
2801
+ /** Subscribe to `System::LauncherGestureReply` from the daemon. */
2802
+ onLauncherGestureReply(handler) {
2803
+ return this._client.on(event => {
2804
+ if (event.type !== 'message')
2805
+ return;
2806
+ const data = event.message.data;
2807
+ if (data.type !== 'system')
2808
+ return;
2809
+ const inner = data.data;
2810
+ if (inner.event !== 'launcherGestureReply')
2811
+ return;
2812
+ handler(inner.data);
2813
+ });
2814
+ }
2815
+ /** Subscribe to `System::LauncherGestureChanged` from the daemon. */
2816
+ onLauncherGestureChanged(handler) {
2817
+ return this._client.on(event => {
2818
+ if (event.type !== 'message')
2819
+ return;
2820
+ const data = event.message.data;
2821
+ if (data.type !== 'system')
2822
+ return;
2823
+ const inner = data.data;
2824
+ if (inner.event !== 'launcherGestureChanged')
2825
+ return;
2826
+ handler(inner.data);
2827
+ });
2828
+ }
2829
+ /** Subscribe to `System::CompanionLaunchReply` from the daemon. */
2830
+ onCompanionLaunchReply(handler) {
2831
+ return this._client.on(event => {
2832
+ if (event.type !== 'message')
2833
+ return;
2834
+ const data = event.message.data;
2835
+ if (data.type !== 'system')
2836
+ return;
2837
+ const inner = data.data;
2838
+ if (inner.event !== 'companionLaunchReply')
2839
+ return;
2840
+ handler(inner.data);
2841
+ });
2842
+ }
2843
+ /** Subscribe to `System::CompanionLaunchChanged` from the daemon. */
2844
+ onCompanionLaunchChanged(handler) {
2845
+ return this._client.on(event => {
2846
+ if (event.type !== 'message')
2847
+ return;
2848
+ const data = event.message.data;
2849
+ if (data.type !== 'system')
2850
+ return;
2851
+ const inner = data.data;
2852
+ if (inner.event !== 'companionLaunchChanged')
2853
+ return;
2854
+ handler(inner.data);
2855
+ });
2856
+ }
2857
+ /** Subscribe to `System::FactoryResetStarted` from the daemon. */
2858
+ onFactoryResetStarted(handler) {
2859
+ return this._client.on(event => {
2860
+ if (event.type !== 'message')
2861
+ return;
2862
+ const data = event.message.data;
2863
+ if (data.type !== 'system')
2864
+ return;
2865
+ const inner = data.data;
2866
+ if (inner.event !== 'factoryResetStarted')
2867
+ return;
2868
+ handler(inner.data);
2869
+ });
2870
+ }
2871
+ /** Subscribe to `System::FactoryResetRefused` from the daemon. */
2872
+ onFactoryResetRefused(handler) {
2873
+ return this._client.on(event => {
2874
+ if (event.type !== 'message')
2875
+ return;
2876
+ const data = event.message.data;
2877
+ if (data.type !== 'system')
2878
+ return;
2879
+ const inner = data.data;
2880
+ if (inner.event !== 'factoryResetRefused')
2881
+ return;
2882
+ handler(inner.data);
2883
+ });
2884
+ }
2697
2885
  /** Exhaustive subscribe over all inbound `System` variants. */
2698
2886
  subscribe(handlers) {
2699
2887
  return this._subscribe(handlers, false);
@@ -2751,6 +2939,30 @@ export class SystemSurface {
2751
2939
  handlers.deviceNicknameChanged?.(inner.data);
2752
2940
  return;
2753
2941
  }
2942
+ case 'launcherGestureReply': {
2943
+ handlers.launcherGestureReply?.(inner.data);
2944
+ return;
2945
+ }
2946
+ case 'launcherGestureChanged': {
2947
+ handlers.launcherGestureChanged?.(inner.data);
2948
+ return;
2949
+ }
2950
+ case 'companionLaunchReply': {
2951
+ handlers.companionLaunchReply?.(inner.data);
2952
+ return;
2953
+ }
2954
+ case 'companionLaunchChanged': {
2955
+ handlers.companionLaunchChanged?.(inner.data);
2956
+ return;
2957
+ }
2958
+ case 'factoryResetStarted': {
2959
+ handlers.factoryResetStarted?.(inner.data);
2960
+ return;
2961
+ }
2962
+ case 'factoryResetRefused': {
2963
+ handlers.factoryResetRefused?.(inner.data);
2964
+ return;
2965
+ }
2754
2966
  default: {
2755
2967
  if (!partial)
2756
2968
  this._client.logger.warn('System: no handler for inner', inner);
@@ -2786,12 +2998,21 @@ export class SystemSurface {
2786
2998
  };
2787
2999
  await this._client.send(msg);
2788
3000
  }
2789
- /** Send `System::FactoryReset` to the daemon. */
2790
- async factoryReset() {
3001
+ /** Send `System::LauncherGestureSet` to the daemon. */
3002
+ async launcherGestureSet(payload) {
3003
+ const msg = {
3004
+ id: newUuid(),
3005
+ meta: { kind: 'command' },
3006
+ data: { type: 'system', data: { event: 'launcherGestureSet', data: payload } },
3007
+ };
3008
+ await this._client.send(msg);
3009
+ }
3010
+ /** Send `System::CompanionLaunchSet` to the daemon. */
3011
+ async companionLaunchSet(payload) {
2791
3012
  const msg = {
2792
3013
  id: newUuid(),
2793
3014
  meta: { kind: 'command' },
2794
- data: { type: 'system', data: { event: 'factoryReset' } },
3015
+ data: { type: 'system', data: { event: 'companionLaunchSet', data: payload } },
2795
3016
  };
2796
3017
  await this._client.send(msg);
2797
3018
  }
@@ -2865,6 +3086,50 @@ export class SystemSurface {
2865
3086
  return { ok: false, kind: 'protocol', error: d.data };
2866
3087
  return { ok: false, kind: 'protocol', error: { type: 'unsupported' } };
2867
3088
  }
3089
+ /** Typed request to the daemon: webapp sends, daemon responds. */
3090
+ async factoryReset(options) {
3091
+ const wireData = { type: 'system', data: { event: 'factoryReset' } };
3092
+ const response = await this._client.request(wireData, options?.timeoutMs);
3093
+ const d = response.data;
3094
+ if (d.type === 'system') {
3095
+ const inner = d.data;
3096
+ if (inner.event === 'factoryResetStarted')
3097
+ return { ok: true, response: inner.data };
3098
+ if (inner.event === 'factoryResetRefused')
3099
+ return { ok: false, kind: 'domain', error: inner.data };
3100
+ }
3101
+ if (d.type === 'error')
3102
+ return { ok: false, kind: 'protocol', error: d.data };
3103
+ return { ok: false, kind: 'protocol', error: { type: 'unsupported' } };
3104
+ }
3105
+ /** Typed request to the daemon: webapp sends, daemon responds. */
3106
+ async launcherGestureGet(options) {
3107
+ const wireData = { type: 'system', data: { event: 'launcherGestureGet' } };
3108
+ const response = await this._client.request(wireData, options?.timeoutMs);
3109
+ const d = response.data;
3110
+ if (d.type === 'system') {
3111
+ const inner = d.data;
3112
+ if (inner.event === 'launcherGestureReply')
3113
+ return { ok: true, response: inner.data };
3114
+ }
3115
+ if (d.type === 'error')
3116
+ return { ok: false, kind: 'protocol', error: d.data };
3117
+ return { ok: false, kind: 'protocol', error: { type: 'unsupported' } };
3118
+ }
3119
+ /** Typed request to the daemon: webapp sends, daemon responds. */
3120
+ async companionLaunchGet(options) {
3121
+ const wireData = { type: 'system', data: { event: 'companionLaunchGet' } };
3122
+ const response = await this._client.request(wireData, options?.timeoutMs);
3123
+ const d = response.data;
3124
+ if (d.type === 'system') {
3125
+ const inner = d.data;
3126
+ if (inner.event === 'companionLaunchReply')
3127
+ return { ok: true, response: inner.data };
3128
+ }
3129
+ if (d.type === 'error')
3130
+ return { ok: false, kind: 'protocol', error: d.data };
3131
+ return { ok: false, kind: 'protocol', error: { type: 'unsupported' } };
3132
+ }
2868
3133
  }
2869
3134
  export class TimeSurface {
2870
3135
  _client;
@@ -3552,6 +3817,14 @@ export function applyDispatch() {
3552
3817
  return (bucket.audio ??= new AudioSurface(this));
3553
3818
  },
3554
3819
  });
3820
+ Object.defineProperty(BridgethingClient.prototype, 'blob', {
3821
+ configurable: true,
3822
+ enumerable: true,
3823
+ get() {
3824
+ const bucket = bucketFor(this);
3825
+ return (bucket.blob ??= new BlobSurface(this));
3826
+ },
3827
+ });
3555
3828
  Object.defineProperty(BridgethingClient.prototype, 'bluetooth', {
3556
3829
  configurable: true,
3557
3830
  enumerable: true,
@@ -3781,6 +4054,30 @@ function outerSubscribe(c, handlers, partial) {
3781
4054
  }
3782
4055
  }
3783
4056
  }
4057
+ case 'blob': {
4058
+ const innerHandlers = handlers.blob;
4059
+ if (!innerHandlers) {
4060
+ if (!partial)
4061
+ c.logger.warn('subscribe: no handler for blob');
4062
+ return;
4063
+ }
4064
+ const inner = data.data;
4065
+ switch (inner.event) {
4066
+ case 'list': {
4067
+ innerHandlers.list?.(inner.data);
4068
+ return;
4069
+ }
4070
+ case 'changed': {
4071
+ innerHandlers.changed?.(inner.data);
4072
+ return;
4073
+ }
4074
+ default: {
4075
+ if (!partial)
4076
+ c.logger.warn('Blob: no handler for inner', inner);
4077
+ return;
4078
+ }
4079
+ }
4080
+ }
3784
4081
  case 'bluetooth': {
3785
4082
  const innerHandlers = handlers.bluetooth;
3786
4083
  if (!innerHandlers) {
@@ -4014,6 +4311,10 @@ function outerSubscribe(c, handlers, partial) {
4014
4311
  innerHandlers.favoriteChanged?.(inner.data);
4015
4312
  return;
4016
4313
  }
4314
+ case 'browseChanged': {
4315
+ innerHandlers.browseChanged?.(inner.data);
4316
+ return;
4317
+ }
4017
4318
  case 'errorEvent': {
4018
4319
  innerHandlers.errorEvent?.(inner.data);
4019
4320
  return;
@@ -4272,6 +4573,30 @@ function outerSubscribe(c, handlers, partial) {
4272
4573
  innerHandlers.deviceNicknameChanged?.(inner.data);
4273
4574
  return;
4274
4575
  }
4576
+ case 'launcherGestureReply': {
4577
+ innerHandlers.launcherGestureReply?.(inner.data);
4578
+ return;
4579
+ }
4580
+ case 'launcherGestureChanged': {
4581
+ innerHandlers.launcherGestureChanged?.(inner.data);
4582
+ return;
4583
+ }
4584
+ case 'companionLaunchReply': {
4585
+ innerHandlers.companionLaunchReply?.(inner.data);
4586
+ return;
4587
+ }
4588
+ case 'companionLaunchChanged': {
4589
+ innerHandlers.companionLaunchChanged?.(inner.data);
4590
+ return;
4591
+ }
4592
+ case 'factoryResetStarted': {
4593
+ innerHandlers.factoryResetStarted?.(inner.data);
4594
+ return;
4595
+ }
4596
+ case 'factoryResetRefused': {
4597
+ innerHandlers.factoryResetRefused?.(inner.data);
4598
+ return;
4599
+ }
4275
4600
  default: {
4276
4601
  if (!partial)
4277
4602
  c.logger.warn('System: no handler for inner', inner);