@phreshos/client 0.1.8 → 0.1.10

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/README.md CHANGED
@@ -128,10 +128,11 @@ The same rule applies to Client-visible traffic destinations.
128
128
 
129
129
  Client-visible Program handles can operate only within their own Program.
130
130
  They deliberately omit `install()` and `fork()`, and their storage areas never
131
- expose host filesystem paths. `current.window` is authoritative and
132
- subscribable. `current.localWindow` is the physical representation belonging to
133
- this iframe on this desktop. Its reads and updates are local, have no events,
134
- and cannot target another Client handle.
131
+ expose host filesystem paths. Every Client-side Window handle exposes the same
132
+ authoritative, subscribable Window capability and its `window.local` physical
133
+ representation on this desktop. Local reads and updates have no events and do
134
+ not change Server state. `current.window` is only convenient access to the
135
+ executing Client's canonical Window; it has no additional authority.
135
136
  When both dimensions must change, `setGeometry({ position, size })` commits
136
137
  them through one authoritative request and produces one `geometry` event.
137
138
  Calling `move()` and `resize()` sequentially or through `Promise.all()` remains
@@ -140,12 +141,12 @@ two independent operations and can expose an intermediate state remotely.
140
141
  An `under` or `over` representation may request one local host-rendered Surface:
141
142
 
142
143
  ```ts
143
- await current.localWindow.surface.set({
144
+ await current.window.local.surface.set({
144
145
  opacity: 0.65,
145
146
  radius: "large"
146
147
  }, { duration: 240, easing: "ease-out", wait: true })
147
148
 
148
- await current.localWindow.surface.remove()
149
+ await current.window.local.surface.remove()
149
150
  ```
150
151
 
151
152
  The desktop holds local state only for the lifetime of that iframe
package/dist/current.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { LocalWindow } from "@phreshos/core";
2
1
  import { type Channel } from "./channel.js";
3
2
  import { Client, Server, type Process, type Program, type Window } from "./domain.js";
4
3
  /** The current Process's canonical Server handle. */
@@ -9,8 +8,6 @@ export interface Current<Events extends object = {}> extends Channel<Events>, Pi
9
8
  readonly server: CurrentServer;
10
9
  /** Presentation capability of this current Client. */
11
10
  readonly window: Window;
12
- /** Physical Window representation belonging only to this Client iframe. */
13
- readonly localWindow: LocalWindow;
14
11
  /** The same permission capability exposed by the current Program. */
15
12
  readonly permissions: Program["permissions"];
16
13
  /** Returns the Process represented by this Client. */
package/dist/current.js CHANGED
@@ -84,7 +84,6 @@ currentClient = new CurrentClientHandle(owner);
84
84
  class ClientCurrent {
85
85
  server = currentServer;
86
86
  window = currentClient.window;
87
- localWindow = new LocalWindowHandle();
88
87
  permissions = currentProgramPermissions;
89
88
  constructor() {
90
89
  bindChannel(this, channel);
@@ -105,30 +104,6 @@ class ClientCurrent {
105
104
  async stop() { await wire.request(["stop-current"]); }
106
105
  service() { return endpointService(null, "client"); }
107
106
  }
108
- class LocalWindowHandle {
109
- surface = new LocalWindowSurfaceHandle();
110
- async state() {
111
- const answer = await wire.request(["localWindow"]);
112
- return answer[0];
113
- }
114
- async title() { return (await this.state()).title; }
115
- async position() { return (await this.state()).position; }
116
- async size() { return (await this.state()).size; }
117
- async minimized() { return (await this.state()).minimized; }
118
- async front() { return (await this.state()).front; }
119
- async layer() { return (await this.state()).layer; }
120
- async location() { return (await this.state()).location; }
121
- async move(position, transaction) { await wire.request(["localWindowMove", position, transaction]); }
122
- async resize(size, transaction) { await wire.request(["localWindowResize", size, transaction]); }
123
- async setGeometry(geometry, transaction) { await wire.request(["localWindowGeometry", geometry, transaction]); }
124
- async minimize(minimized = true) { await wire.request(["localWindowMinimize", minimized]); }
125
- async changeTitle(title) { await wire.request(["localWindowTitle", title]); }
126
- async raise() { await wire.request(["localWindowRaise"]); }
127
- }
128
- class LocalWindowSurfaceHandle {
129
- async set(settings = {}, transaction) { await wire.request(["localWindowSurfaceSet", settings, transaction]); }
130
- async remove() { await wire.request(["localWindowSurfaceRemove"]); }
131
- }
132
107
  function bindChannel(target, source) {
133
108
  Object.assign(target, {
134
109
  publish: source.publish.bind(source),
package/dist/domain.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Client as CoreClient, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, Server as CoreServer, type AnswerCapture as CoreAnswerCapture, type AnswerMessage as CoreAnswerMessage, type AnswerObserver as CoreAnswerObserver, type AskCapture as CoreAskCapture, type AskMessage as CoreAskMessage, type AskObserver as CoreAskObserver, type Cleanup, type ClientTraffic as CoreClientTraffic, type ClientDeclaration, type EndpointTraffic as CoreEndpointTraffic, type EndpointDeclaration, type Exit, type Launch, type Permissions, type ServerTraffic as CoreServerTraffic, type TrafficMessage as CoreTrafficMessage, type TrafficCapture as CoreTrafficCapture, type TrafficEvents as CoreTrafficEvents, type Window as CoreWindow, type WindowState } from "@phreshos/core";
1
+ import { Client as CoreClient, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, Server as CoreServer, type AnswerCapture as CoreAnswerCapture, type AnswerMessage as CoreAnswerMessage, type AnswerObserver as CoreAnswerObserver, type AskCapture as CoreAskCapture, type AskMessage as CoreAskMessage, type AskObserver as CoreAskObserver, type Cleanup, type ClientTraffic as CoreClientTraffic, type ClientDeclaration, type EndpointTraffic as CoreEndpointTraffic, type EndpointDeclaration, type Exit, type Launch, type LocalWindow, type Permissions, type ServerTraffic as CoreServerTraffic, type TrafficMessage as CoreTrafficMessage, type TrafficCapture as CoreTrafficCapture, type TrafficEvents as CoreTrafficEvents, type Window as CoreWindow, type WindowState } from "@phreshos/core";
2
2
  import Events from "./events.js";
3
3
  export interface HandleAddress {
4
4
  identity: string;
@@ -102,8 +102,11 @@ export type Client<Events extends object = {}> = Omit<CoreClient<Events>, "proce
102
102
  /** Returns the Process that owns this Client. */
103
103
  process(): Promise<Process>;
104
104
  };
105
- /** Authoritative Client-owned Window capability visible inside a Client boundary. */
106
- export type Window = CoreWindow;
105
+ /** Authoritative Window state plus its representation on this desktop. */
106
+ export type Window = CoreWindow & {
107
+ /** Physical representation of this Window on the current desktop. */
108
+ readonly local: LocalWindow;
109
+ };
107
110
  export declare class TrafficHandle extends Events {
108
111
  protected readonly target: HandleAddress | null;
109
112
  protected readonly kind: "server" | "client";
package/dist/domain.js CHANGED
@@ -206,9 +206,11 @@ class ClientHandle extends ClientBase {
206
206
  }
207
207
  class WindowHandle extends Events {
208
208
  target;
209
+ local;
209
210
  constructor(target) {
210
211
  super(...deferredScoped("host-end", target, (_event, values) => values[0]));
211
212
  this.target = target;
213
+ this.local = new LocalWindowHandle(target);
212
214
  }
213
215
  async state() {
214
216
  const answer = await wire.request(["window", await this.target()]);
@@ -228,6 +230,41 @@ class WindowHandle extends Events {
228
230
  async changeTitle(title) { await wire.request(["changeTitle", await this.target(), title]); }
229
231
  async raise() { await wire.request(["raise", await this.target()]); }
230
232
  }
233
+ class LocalWindowHandle {
234
+ target;
235
+ surface;
236
+ constructor(target) {
237
+ this.target = target;
238
+ this.surface = new LocalWindowSurfaceHandle(target);
239
+ }
240
+ async state() {
241
+ const answer = await wire.request(["windowLocal", await this.target()]);
242
+ return answer[0];
243
+ }
244
+ async title() { return (await this.state()).title; }
245
+ async position() { return (await this.state()).position; }
246
+ async size() { return (await this.state()).size; }
247
+ async minimized() { return (await this.state()).minimized; }
248
+ async front() { return (await this.state()).front; }
249
+ async layer() { return (await this.state()).layer; }
250
+ async location() { return (await this.state()).location; }
251
+ async move(position, transaction) { await wire.request(["windowLocalMove", await this.target(), position, transaction]); }
252
+ async resize(size, transaction) { await wire.request(["windowLocalResize", await this.target(), size, transaction]); }
253
+ async setGeometry(geometry, transaction) { await wire.request(["windowLocalGeometry", await this.target(), geometry, transaction]); }
254
+ async minimize(minimized = true) { await wire.request(["windowLocalMinimize", await this.target(), minimized]); }
255
+ async changeTitle(title) { await wire.request(["windowLocalTitle", await this.target(), title]); }
256
+ async raise() { await wire.request(["windowLocalRaise", await this.target()]); }
257
+ }
258
+ class LocalWindowSurfaceHandle {
259
+ target;
260
+ constructor(target) {
261
+ this.target = target;
262
+ }
263
+ async set(settings = {}, transaction) {
264
+ await wire.request(["windowLocalSurfaceSet", await this.target(), settings, transaction]);
265
+ }
266
+ async remove() { await wire.request(["windowLocalSurfaceRemove", await this.target()]); }
267
+ }
231
268
  function deferredScoped(route, target, convert) {
232
269
  return [
233
270
  (event, listener, impossible) => {
package/dist/theme.d.ts CHANGED
@@ -9,5 +9,6 @@ export default class ClientTheme extends Events {
9
9
  spacing: number;
10
10
  radius: number;
11
11
  glass: import("@phreshos/core").ThemeGlass;
12
+ surface: import("@phreshos/core").ThemeSurface;
12
13
  }>>;
13
14
  }
package/dist/theme.js CHANGED
@@ -23,7 +23,11 @@ function isObject(value) {
23
23
  if (typeof value !== "object" || value === null || Array.isArray(value))
24
24
  return false;
25
25
  const theme = value;
26
+ const surface = theme.surface;
26
27
  return typeof theme.background === "string" && typeof theme.foreground === "string" && typeof theme.accent === "string"
27
28
  && typeof theme.spacing === "number" && typeof theme.radius === "number"
28
- && typeof theme.glass === "object" && theme.glass !== null;
29
+ && typeof theme.glass === "object" && theme.glass !== null
30
+ && typeof surface === "object" && surface !== null && typeof surface.color === "string"
31
+ && typeof surface.grain === "number" && typeof surface.animation === "number"
32
+ && typeof surface.backdrop === "number" && typeof surface.opacity === "number";
29
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/client",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
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
  "prepack": "node --run build"
47
47
  },
48
48
  "peerDependencies": {
49
- "@phreshos/core": "^0.1.6"
49
+ "@phreshos/core": "^0.1.7"
50
50
  },
51
51
  "dependencies": {
52
52
  "@msgpack/msgpack": "^3.1.3"
53
53
  },
54
54
  "devDependencies": {
55
- "@phreshos/core": "^0.1.6",
55
+ "@phreshos/core": "^0.1.7",
56
56
  "typescript": "^6.0.3"
57
57
  }
58
58
  }