@phreshos/client 0.1.49 → 0.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/domain.js +38 -35
  2. package/package.json +3 -3
package/dist/domain.js CHANGED
@@ -321,8 +321,6 @@ class WindowHandle extends Events {
321
321
  }
322
322
  async title() { return (await this.state()).title; }
323
323
  async header() { return (await this.state()).header; }
324
- async surface() { return (await this.state()).surface; }
325
- async transaction() { return (await this.state()).transaction; }
326
324
  async position() { return (await this.state()).position; }
327
325
  async size() { return (await this.state()).size; }
328
326
  async minimized() { return (await this.state()).minimized; }
@@ -336,24 +334,12 @@ class WindowHandle extends Events {
336
334
  async maximize(maximized = true) { await wire.request(["maximize", await this.target(), maximized]); }
337
335
  async setTitle(title) { await wire.request(["setTitle", await this.target(), title]); }
338
336
  async setHeader(header) { await wire.request(["setHeader", await this.target(), header]); }
339
- async setSurface(surface) { await wire.request(["setSurface", await this.target(), surface]); }
340
- async setTransaction(transaction) { await wire.request(["setTransaction", await this.target(), transaction]); }
341
337
  async raise() { await wire.request(["raise", await this.target()]); }
342
338
  }
343
- class WindowPresentationHandle extends Events {
339
+ class WindowPresentationHandle {
344
340
  target;
345
341
  selected;
346
342
  constructor(target, selected) {
347
- super((event, listener, impossible) => {
348
- if (!windowEvent(event)) {
349
- impossible?.(new Error(`A Window presentation has no "${event}" event`));
350
- return () => undefined;
351
- }
352
- return wire.on("presentation", event, listener, null, impossible);
353
- }, (listener, impossible) => wire.onAll("presentation", (event, ...values) => {
354
- if (typeof event === "string")
355
- listener(event, values[0]);
356
- }, null, impossible));
357
343
  this.target = target;
358
344
  this.selected = selected;
359
345
  }
@@ -363,32 +349,49 @@ class WindowPresentationHandle extends Events {
363
349
  transactionAndWait(transaction) {
364
350
  return new WindowPresentationHandle(this.target, { transaction, wait: true });
365
351
  }
366
- async title() { return await this.read("title"); }
367
- async header() { return await this.read("header"); }
368
- async surface() { return await this.read("surface"); }
369
- async position() { return await this.read("position"); }
370
- async size() { return await this.read("size"); }
371
- async minimized() { return await this.read("minimized"); }
372
- async maximized() { return await this.read("maximized"); }
373
- async front() { return await this.read("front"); }
374
- async layer() { return await this.read("layer"); }
352
+ async layer() {
353
+ const answer = await wire.request(["windowPresentationLayer", await this.target()]);
354
+ return answer[0];
355
+ }
356
+ beginMoveGesture(start) {
357
+ return new WindowMoveGestureHandle(this.target(), start);
358
+ }
375
359
  async move(position) { await this.change("windowPresentationMove", position); }
376
360
  async resize(size) { await this.change("windowPresentationResize", size); }
377
361
  async setGeometry(geometry) { await this.change("windowPresentationGeometry", geometry); }
378
- async minimize(minimized = true) { await this.change("windowPresentationMinimize", minimized); }
379
- async maximize(maximized = true) { await this.change("windowPresentationMaximize", maximized); }
380
- async setTitle(title) { await this.change("windowPresentationTitle", title); }
381
- async setHeader(header) { await this.change("windowPresentationHeader", header); }
382
362
  async setSurface(surface) { await this.change("windowPresentationSurface", surface); }
383
- async follow() { await this.change("windowPresentationFollow"); }
384
- async unfollow() { await this.change("windowPresentationUnfollow"); }
385
363
  async raise() { await this.change("windowPresentationRaise"); }
386
364
  async change(operation, value) {
387
- await wire.request([operation, await this.target(), value, this.selected?.transaction, this.selected?.wait === true]);
365
+ await wire.request([operation, await this.target(), value, this.selected ?? null]);
388
366
  }
389
- async read(property) {
390
- const answer = await wire.request(["windowPresentationRead", await this.target(), property]);
391
- return answer[0];
367
+ }
368
+ class WindowMoveGestureHandle {
369
+ gesture = crypto.randomUUID();
370
+ address;
371
+ ready;
372
+ finished;
373
+ ended = false;
374
+ constructor(target, start) {
375
+ this.address = target;
376
+ this.ready = target.then(async (address) => {
377
+ await wire.request(["windowPresentationMoveGestureBegin", address, this.gesture, start]);
378
+ });
379
+ this.finished = this.ready.then(async () => {
380
+ await wire.request(["windowPresentationMoveGestureWait", await this.address, this.gesture]);
381
+ });
382
+ // A gesture may be abandoned by document teardown before its owner can end
383
+ // it. The boundary still owns cleanup; this only prevents an unhandled rejection.
384
+ void this.finished.catch(() => undefined);
385
+ void this.finished.then(() => { this.ended = true; }, () => { this.ended = true; });
386
+ }
387
+ cancel() {
388
+ if (this.ended)
389
+ return;
390
+ this.ended = true;
391
+ void this.ready.then(async () => {
392
+ const address = await this.address;
393
+ wire.send("end-host", "windowPresentationMoveGestureCancel", address, this.gesture);
394
+ }, () => undefined);
392
395
  }
393
396
  }
394
397
  function deferredScoped(route, target, convert) {
@@ -414,7 +417,7 @@ function deferredScoped(route, target, convert) {
414
417
  ];
415
418
  }
416
419
  function windowEvent(event) {
417
- return event === "move" || event === "resize" || event === "minimize" || event === "maximize" || event === "changeTitle" || event === "changeHeader" || event === "changeSurface" || event === "changeTransaction" || event === "front";
420
+ return event === "move" || event === "resize" || event === "minimize" || event === "maximize" || event === "changeTitle" || event === "changeHeader" || event === "front";
418
421
  }
419
422
  function deferred(target, register, impossible) {
420
423
  let active = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/client",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "description": "The SDK used by a Program's client endpoint.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -46,13 +46,13 @@
46
46
  "test": "vitest run --project default"
47
47
  },
48
48
  "peerDependencies": {
49
- "@phreshos/core": "^0.1.58"
49
+ "@phreshos/core": "^0.1.59"
50
50
  },
51
51
  "dependencies": {
52
52
  "@the-link/messagepack": "^0.1.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@phreshos/core": "^0.1.58",
55
+ "@phreshos/core": "^0.1.59",
56
56
  "typescript": "^6.0.3",
57
57
  "vitest": "^4.1.10"
58
58
  }