@phreshos/server 0.1.3 → 0.1.5

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
@@ -76,13 +76,10 @@ retained handle. Server and Client handles remain stable for their Process
76
76
  lifetime. Each Client permanently owns one synchronous `window` capability,
77
77
  whose operations address that Client's current live presentation state.
78
78
 
79
- An `under` or `over` Client Window may own an authoritative host Surface through
80
- `client.window.surface`. It is command-only: `set()` or `remove()` changes the
81
- server-owned value, while Program endpoints cannot read or subscribe to it.
82
- Radius may be a
83
- nonnegative pixel number, `"full"`, or a semantic `ScaleLevel` resolved by the
84
- desktop against its current Theme. Ordinary `window` and system `wallpaper`
85
- layers reject Surface mutations.
79
+ Surface presentation is deliberately absent from the Server SDK. It belongs to
80
+ one live iframe representation and is requested through the Client's
81
+ `current.window.surface`; a Server may coordinate Program state, but it neither
82
+ owns nor controls the resulting desktop material.
86
83
 
87
84
  The package provides two contextual runtime entry points:
88
85
 
package/dist/channel.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { Channel as CoreChannel, ChannelMessage, Cleanup } from "@phreshos/core";
1
+ import type { Channel as CoreChannel, ChannelMessage, Cleanup, ServerServiceDefinition } from "@phreshos/core";
2
+ import { type Endpoint } from "./domain.js";
2
3
  /** Handles one question addressed to the current Server. */
3
4
  export type Answerer<Payload = unknown, Result = undefined> = (message: ChannelMessage<Payload>) => Result | Promise<Result>;
4
5
  /** Events and questions explicitly accepted by the current Server. */
5
- export interface Channel<Events extends object = {}> extends CoreChannel<Events> {
6
+ export interface Channel<Events extends object = {}> extends CoreChannel<Events, Endpoint, ServerServiceDefinition> {
6
7
  /** Registers one answerer; omitting its return produces `undefined`. */
7
8
  answer<Payload = unknown, Result = undefined>(event: string, answerer: Answerer<Payload, Result>): Cleanup;
8
9
  }
package/dist/channel.js CHANGED
@@ -12,7 +12,7 @@ class ServerChannel extends Events {
12
12
  publish(event, payload = undefined) {
13
13
  wire.send("end-host", "emit", event, payload);
14
14
  }
15
- async enableService(name) { await enableCurrentService(name); }
15
+ async enableService(definition) { await enableCurrentService(definition); }
16
16
  async disableService() { await disableCurrentService(); }
17
17
  answer(event, answerer) {
18
18
  return wire.answer("end-end", event, value => answerer(message(value)));
package/dist/current.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import type { Channel as CoreChannel } from "@phreshos/core";
2
- import { type Answerer } from "./channel.js";
1
+ import { type Answerer, type Channel } from "./channel.js";
3
2
  import { Client, type Process, type Program, type Server } from "./domain.js";
4
3
  /** The current Process's canonical Client handle. */
5
4
  export type CurrentClient<Events extends object = {}> = Client<Events>;
6
5
  /** Current Server context: its inbound Channel, owner hierarchy, and paired Client. */
7
- export interface Current<Events extends object = {}> extends CoreChannel<Events>, Pick<Server, "service"> {
6
+ export interface Current<Events extends object = {}> extends Channel<Events>, Pick<Server, "service"> {
8
7
  /** The same Client handle exposed by the current Process. */
9
8
  readonly client: CurrentClient;
10
9
  /** Registers one answerer; omitting its return produces `undefined`. */
package/dist/domain.js CHANGED
@@ -67,10 +67,6 @@ class ProgramHandle extends ProgramBase {
67
67
  const answer = await wire.request(["create-process", this.address, launch]);
68
68
  return process(answer[0]);
69
69
  }
70
- async apiDocs() {
71
- const answer = await wire.request(["api-docs", this.address]);
72
- return answer[0];
73
- }
74
70
  async icon(size = "medium") {
75
71
  const answer = await wire.request(["icon", this.address, size]);
76
72
  return new Blob([Uint8Array.from(answer[0])], { type: "image/png" });
@@ -253,11 +249,9 @@ class ClientHandle extends ClientBase {
253
249
  }
254
250
  class WindowHandle extends Events {
255
251
  target;
256
- surface;
257
252
  constructor(target) {
258
253
  super(...deferredScoped("host-end", target, (_event, values) => values[0]));
259
254
  this.target = target;
260
- this.surface = new WindowSurfaceHandle(target);
261
255
  }
262
256
  async state() {
263
257
  const answer = await wire.request(["window", await this.target()]);
@@ -272,18 +266,11 @@ class WindowHandle extends Events {
272
266
  async location() { return (await this.state()).location; }
273
267
  async move(position) { await wire.request(["move", await this.target(), position]); }
274
268
  async resize(size) { await wire.request(["resize", await this.target(), size]); }
269
+ async setGeometry(geometry) { await wire.request(["setGeometry", await this.target(), geometry]); }
275
270
  async minimize(minimized = true) { await wire.request(["minimize", await this.target(), minimized]); }
276
271
  async changeTitle(title) { await wire.request(["changeTitle", await this.target(), title]); }
277
272
  async raise() { await wire.request(["raise", await this.target()]); }
278
273
  }
279
- class WindowSurfaceHandle {
280
- target;
281
- constructor(target) {
282
- this.target = target;
283
- }
284
- async set(settings = {}) { await wire.request(["surfaceSet", await this.target(), settings]); }
285
- async remove() { await wire.request(["surfaceRemove", await this.target()]); }
286
- }
287
274
  function deferredScoped(route, target, convert) {
288
275
  return [
289
276
  (event, listener, impossible) => {
@@ -307,7 +294,7 @@ function deferredScoped(route, target, convert) {
307
294
  ];
308
295
  }
309
296
  function windowEvent(event) {
310
- return event === "move" || event === "resize" || event === "minimize" || event === "changeTitle" || event === "front";
297
+ return event === "move" || event === "resize" || event === "geometry" || event === "minimize" || event === "changeTitle" || event === "front";
311
298
  }
312
299
  function deferred(target, register, impossible) {
313
300
  let active = true;
package/dist/host.d.ts CHANGED
@@ -37,8 +37,6 @@ type Description = Readonly<{
37
37
  version?: string;
38
38
  /** Short human-readable Program description. */
39
39
  description?: string;
40
- /** Path to the Program-authored API entry document. */
41
- apiDocs?: string;
42
40
  /** Absolute validated PNG source used to derive the Program's hosted icon sizes. */
43
41
  icon?: string;
44
42
  /** Absolute directory used for the Program's persistent storage. */
package/dist/main.d.ts CHANGED
@@ -4,4 +4,4 @@ export { type Answerer, type Channel } from "./channel.js";
4
4
  export { type ProgramStartup } from "./startup.js";
5
5
  export { ClientServiceHandler, ServerServiceHandler, ServiceHandler, type ClientServiceChannel, type ServerServiceChannel, type ServiceChannel, type ServiceKey, type ServiceLifecycleEvents } from "@phreshos/core";
6
6
  export { Client, Endpoint, Process, Program, Server, type Window, type ProgramArea } from "./domain.js";
7
- export type { AnswerCapture, AnswerMessage, AnswerObserver, Askable, AskCapture, AskMessage, AskObserver, Capture, Captures, ChannelCapture, ChannelEvents, ChannelMessage, ClientTraffic, ClientDeclaration, Cleanup, DirectoryStat, EndpointDeclaration, EndpointTraffic, EntryStat, EventMessage, EventName, EventObserver, EventOptions, EventSubscriber, Exit, FileStat, Launch, LaunchClient, Layer, LogKind, LogRecord, LogSource, Message, OtherStat, Outcome, Position, ProgramEvents, ProgramPermissions, ProgramProcessExit, ProgramSql, ProgramStore, ProcessEvents, Publishable, ServedFile, ServerTraffic, Size, Subscribable, SubscribableEvents, SubscribableFallback, TimedAskable, TrafficCapture, TrafficEvents, TrafficMessage, Value, Theme, ThemeEvents, ThemeProperties, WallpaperLaunch, FileWallpaper, DesktopWallpaper, WritableTheme, WindowEvents, WindowLayer, WindowState, WindowSurface, WindowSurfaceEasing, WindowSurfaceSettings, WindowSurfaceTransaction } from "@phreshos/core";
7
+ export type { AnswerCapture, AnswerMessage, AnswerObserver, Askable, AskCapture, AskMessage, AskObserver, Capture, Captures, ChannelCapture, ChannelEvents, ChannelMessage, ClientTraffic, ClientDeclaration, Cleanup, DirectoryStat, EndpointDeclaration, EndpointTraffic, EntryStat, EventMessage, EventName, EventObserver, EventOptions, EventSubscriber, Exit, FileStat, Launch, LaunchClient, Layer, LogKind, LogRecord, LogSource, Message, OtherStat, Outcome, Position, ProgramEvents, ProgramPermissions, ProgramProcessExit, ProgramSql, ProgramStore, ProcessEvents, Publishable, ServedFile, ServerTraffic, Size, Subscribable, SubscribableEvents, SubscribableFallback, TimedAskable, TrafficCapture, TrafficEvents, TrafficMessage, Value, Theme, ThemeEvents, ThemeProperties, WallpaperLaunch, FileWallpaper, DesktopWallpaper, WritableTheme, WindowEvents, WindowGeometry, WindowLayer, WindowState } from "@phreshos/core";
package/dist/service.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type ClientServiceHandler, type ServerServiceHandler, type ServiceHandler, type ServiceKey } from "@phreshos/core";
1
+ import { type ClientServiceHandler, type ServerServiceDefinition, type ServerServiceHandler, type ServiceHandler, type ServiceKey } from "@phreshos/core";
2
2
  import type { HandleAddress } from "./domain.js";
3
3
  export declare function service<EventsMap extends object = {}>(key: ServiceKey & {
4
4
  endpoint: "server";
@@ -7,7 +7,7 @@ export declare function service<EventsMap extends object = {}>(key: ServiceKey &
7
7
  endpoint: "client";
8
8
  }): ClientServiceHandler<EventsMap>;
9
9
  export declare function service(key: ServiceKey): ServiceHandler;
10
- export declare function enableCurrentService(name: string): Promise<void>;
10
+ export declare function enableCurrentService(definition: ServerServiceDefinition): Promise<void>;
11
11
  export declare function disableCurrentService(): Promise<void>;
12
12
  export declare function endpointService<EventsMap extends object = {}>(target: HandleAddress | null, endpoint: "server"): Promise<ServerServiceHandler<EventsMap> | null>;
13
13
  export declare function endpointService<EventsMap extends object = {}>(target: HandleAddress | null, endpoint: "client"): Promise<ClientServiceHandler<EventsMap> | null>;
package/dist/service.js CHANGED
@@ -63,6 +63,10 @@ class ServerHandler extends ServerServiceBase {
63
63
  const answer = await wire.request(["service-disabled", this.key]);
64
64
  return answer[0];
65
65
  }
66
+ async docs() {
67
+ const answer = await wire.request(["service-docs", this.key]);
68
+ return answer[0];
69
+ }
66
70
  }
67
71
  class ClientHandler extends ClientServiceBase {
68
72
  key;
@@ -94,8 +98,8 @@ export function service(key) {
94
98
  : new ClientHandler(normalized);
95
99
  });
96
100
  }
97
- export async function enableCurrentService(name) {
98
- await wire.request(["enable-service", name]);
101
+ export async function enableCurrentService(definition) {
102
+ await wire.request(["enable-service", definition]);
99
103
  }
100
104
  export async function disableCurrentService() {
101
105
  await wire.request(["disable-service"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/server",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "The SDK used by a Program's server endpoint.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -46,10 +46,10 @@
46
46
  "prepack": "node --run build"
47
47
  },
48
48
  "peerDependencies": {
49
- "@phreshos/core": "^0.1.3"
49
+ "@phreshos/core": "^0.1.5"
50
50
  },
51
51
  "devDependencies": {
52
- "@phreshos/core": "^0.1.3",
52
+ "@phreshos/core": "^0.1.5",
53
53
  "@types/node": "^26.2.0",
54
54
  "typescript": "^6.0.3"
55
55
  }