@phreshos/client 0.1.31 → 0.1.32

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/context.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Context as CoreContext, ContextCapture as CoreContextCapture, ContextEvents as CoreContextEvents, ContextMessage as CoreContextMessage } from "@phreshos/core";
2
2
  import { Server, type Endpoint, type Process, type Program, type Window } from "./domain.js";
3
3
  /** The executing Process's canonical Server handle. */
4
- export type ContextServer<Events extends object = {}, Fallback = never> = Server<Events, Fallback>;
4
+ export type ContextServer<Events extends object = {}, Fallback = unknown> = Server<Events, Fallback>;
5
5
  /** One value addressed to the current Client, with a client-visible sender. */
6
6
  export type ContextMessage<Payload = unknown> = CoreContextMessage<Payload, Endpoint | null>;
7
7
  /** Applies the client-visible sender envelope to known Context events. */
package/dist/context.js CHANGED
@@ -23,7 +23,7 @@ class ContextServerHandle extends ServerBase {
23
23
  async start(launch = {}) { await wire.request(["start-endpoint", undefined, "server", launch]); }
24
24
  async stop() { await wire.request(["stop-endpoint", undefined, "server"]); }
25
25
  async isService() { return (await wire.request(["is-service", "server"]))[0]; }
26
- async waitReady(timeout) { await wire.request(["wait-ready"], timeout); }
26
+ async waitReady(timeout) { await wire.request(["wait-ready", undefined, "server"], timeout); }
27
27
  async ask(event, payload = undefined) {
28
28
  return this.askWithin(undefined, event, payload);
29
29
  }
@@ -32,7 +32,7 @@ class ContextServerHandle extends ServerBase {
32
32
  }
33
33
  async askWithin(timeout, event, payload) {
34
34
  const deadline = new Deadline(timeout);
35
- await wire.requestWithin(["wait-ready", null, true], deadline);
35
+ await wire.requestWithin(["wait-ready", undefined, "server", true], deadline);
36
36
  return await wire.askServerWithin(event, payload, deadline);
37
37
  }
38
38
  }
@@ -77,6 +77,7 @@ class ContextClientHandle extends ClientBase {
77
77
  async start(launch = {}) { await wire.request(["start-endpoint", undefined, "client", launch]); }
78
78
  async stop() { await wire.request(["stop-endpoint", undefined, "client"]); }
79
79
  async isService() { return (await wire.request(["is-service", "client"]))[0]; }
80
+ async waitReady(timeout) { await wire.request(["wait-ready", undefined, "client"], timeout); }
80
81
  }
81
82
  contextClient = new ContextClientHandle(owner);
82
83
  class ClientContext extends Events {
package/dist/domain.d.ts CHANGED
@@ -84,7 +84,7 @@ export type TrafficMessage<Payload = unknown> = CoreTrafficMessage<Payload, Endp
84
84
  /** Applies client-visible destination metadata to known traffic events. */
85
85
  export type TrafficEvents<Events extends object> = CoreTrafficEvents<Events, Endpoint | null>;
86
86
  /** Every ordinary event observable in client-visible Endpoint traffic. */
87
- export type TrafficCapture<Events extends object = {}, Fallback = never> = CoreTrafficCapture<Events, Endpoint | null, Fallback>;
87
+ export type TrafficCapture<Events extends object = {}, Fallback = unknown> = CoreTrafficCapture<Events, Endpoint | null, Fallback>;
88
88
  /** Question with a Server destination hidden when it crosses the Client boundary. */
89
89
  export type AskMessage<Payload = unknown> = CoreAskMessage<Payload, Server | null>;
90
90
  /** One question observable in client-visible Endpoint traffic. */
@@ -98,27 +98,27 @@ export type AnswerCapture<Result = unknown> = CoreAnswerCapture<Result, Endpoint
98
98
  /** Callback that observes answers sent by a client-visible Server. */
99
99
  export type AnswerSubscriber<Result = unknown> = CoreAnswerSubscriber<Result, Endpoint | null>;
100
100
  /** Directed communication originating from one client-visible Endpoint. */
101
- export type EndpointTraffic<Events extends object = {}, Fallback = never> = CoreEndpointTraffic<Events, Endpoint | null, Server | null, Fallback>;
101
+ export type EndpointTraffic<Events extends object = {}, Fallback = unknown> = CoreEndpointTraffic<Events, Endpoint | null, Server | null, Fallback>;
102
102
  /** Directed communication originating from one client-visible Server. */
103
- export type ServerTraffic<Events extends object = {}, Fallback = never> = CoreServerTraffic<Events, Endpoint | null, Server | null, Fallback>;
103
+ export type ServerTraffic<Events extends object = {}, Fallback = unknown> = CoreServerTraffic<Events, Endpoint | null, Server | null, Fallback>;
104
104
  /** Directed communication originating from one client-visible Client. */
105
- export type ClientTraffic<Events extends object = {}, Fallback = never> = CoreClientTraffic<Events, Endpoint | null, Server | null, Fallback>;
105
+ export type ClientTraffic<Events extends object = {}, Fallback = unknown> = CoreClientTraffic<Events, Endpoint | null, Server | null, Fallback>;
106
106
  /** Common Endpoint handle visible inside a structurally isolated Client. */
107
- export type Endpoint<Events extends object = {}, Fallback = never> = Omit<CoreEndpoint<Events, Fallback>, "process" | "traffic"> & {
107
+ export type Endpoint<Events extends object = {}, Fallback = unknown> = Omit<CoreEndpoint<Events, Fallback>, "process" | "traffic"> & {
108
108
  /** Directed communication originating from this Endpoint. */
109
109
  readonly traffic: EndpointTraffic<Events, Fallback>;
110
110
  /** Returns the Process that owns this Endpoint. */
111
111
  process(): Promise<Process>;
112
112
  };
113
113
  /** Server handle visible inside a structurally isolated Client. */
114
- export type Server<Events extends object = {}, Fallback = never> = Omit<CoreServer<Events, Fallback>, "process" | "traffic"> & Endpoint<Events, Fallback> & {
114
+ export type Server<Events extends object = {}, Fallback = unknown> = Omit<CoreServer<Events, Fallback>, "process" | "traffic"> & Endpoint<Events, Fallback> & {
115
115
  /** Directed communication originating from this Server. */
116
116
  readonly traffic: ServerTraffic<Events, Fallback>;
117
117
  /** Returns the Process that owns this Server. */
118
118
  process(): Promise<Process>;
119
119
  };
120
120
  /** Client handle visible inside a structurally isolated Client. */
121
- export type Client<Events extends object = {}, Fallback = never> = Omit<CoreClient<Events, Fallback>, "process" | "traffic" | "window"> & Endpoint<Events, Fallback> & {
121
+ export type Client<Events extends object = {}, Fallback = unknown> = Omit<CoreClient<Events, Fallback>, "process" | "traffic" | "window"> & Endpoint<Events, Fallback> & {
122
122
  /** Directed communication originating from this Client. */
123
123
  readonly traffic: ClientTraffic<Events, Fallback>;
124
124
  /** Presentation capability permanently owned by this Client handle. */
@@ -140,7 +140,7 @@ export declare class TrafficHandle extends Events {
140
140
  event: string;
141
141
  questionId: string;
142
142
  message: Readonly<{
143
- to: Server<{}, never> | null;
143
+ to: Server<{}, unknown> | null;
144
144
  payload: unknown;
145
145
  }>;
146
146
  }>>;
@@ -152,7 +152,7 @@ export declare class ServerTrafficHandle extends TrafficHandle {
152
152
  event: string;
153
153
  questionId: string;
154
154
  message: Readonly<{
155
- to: Endpoint<{}, never> | null;
155
+ to: Endpoint<{}, unknown> | null;
156
156
  outcome: Outcome<unknown>;
157
157
  }>;
158
158
  }>>;
@@ -173,7 +173,7 @@ export declare function process(record: ProcessRecord, endpoints?: {
173
173
  client?: Client;
174
174
  }): Process;
175
175
  export declare function endpoint(reference: EndpointReference | undefined): Endpoint;
176
- export declare function claimEndpoint(reference: string, kind: "server" | "client", endpoint: Endpoint): Endpoint<{}, never>;
176
+ export declare function claimEndpoint(reference: string, kind: "server" | "client", endpoint: Endpoint): Endpoint<{}, unknown>;
177
177
  export declare function window(target: WindowTarget): Window;
178
178
  /** Resolves only endpoint identities intentionally visible to this Client. */
179
179
  export declare function visibleEndpoint(reference: EndpointReference | null | undefined): Endpoint | null;
package/dist/domain.js CHANGED
@@ -222,7 +222,7 @@ class ServerHandle extends ServerBase {
222
222
  async start(launch = {}) { await wire.request(["start-endpoint", this.owner.address, "server", launch]); }
223
223
  async stop() { await wire.request(["stop-endpoint", this.owner.address, "server"]); }
224
224
  async isService() { return (await wire.request(["is-service", "server", this.owner.address]))[0]; }
225
- async waitReady(timeout) { await wire.request(["wait-ready", this.owner.address], timeout); }
225
+ async waitReady(timeout) { await wire.request(["wait-ready", this.owner.address, "server"], timeout); }
226
226
  async ask(event, payload = undefined) {
227
227
  return this.askWithin(undefined, event, payload);
228
228
  }
@@ -231,7 +231,7 @@ class ServerHandle extends ServerBase {
231
231
  }
232
232
  async askWithin(timeout, event, payload) {
233
233
  const deadline = new Deadline(timeout);
234
- await wire.requestWithin(["wait-ready", this.owner.address, true], deadline);
234
+ await wire.requestWithin(["wait-ready", this.owner.address, "server", true], deadline);
235
235
  const source = await wire.identity();
236
236
  const address = `client:${source.process}:${crypto.randomUUID()}`;
237
237
  const questionId = crypto.randomUUID();
@@ -267,6 +267,7 @@ class ClientHandle extends ClientBase {
267
267
  async start(launch = {}) { await wire.request(["start-endpoint", this.owner.address, "client", launch]); }
268
268
  async stop() { await wire.request(["stop-endpoint", this.owner.address, "client"]); }
269
269
  async isService() { return (await wire.request(["is-service", "client", this.owner.address]))[0]; }
270
+ async waitReady(timeout) { await wire.request(["wait-ready", this.owner.address, "client"], timeout); }
270
271
  }
271
272
  class WindowHandle extends Events {
272
273
  target;
package/dist/service.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { type ClientService, type ServerService, type Service, type ServiceKey } from "@phreshos/core";
2
- export declare function prepareService<EventsMap extends object = {}, Fallback = never>(key: ServiceKey & {
2
+ export declare function prepareService<EventsMap extends object = {}, Fallback = unknown>(key: ServiceKey & {
3
3
  endpoint: "server";
4
4
  }): ServerService<EventsMap, Fallback>;
5
- export declare function prepareService<EventsMap extends object = {}, Fallback = never>(key: ServiceKey & {
5
+ export declare function prepareService<EventsMap extends object = {}, Fallback = unknown>(key: ServiceKey & {
6
6
  endpoint: "client";
7
7
  }): ClientService<EventsMap, Fallback>;
8
8
  export declare function prepareService(key: ServiceKey): Service;
package/dist/service.js CHANGED
@@ -20,6 +20,9 @@ class ServiceHandle {
20
20
  const answer = await wire.request(["service-exists", this.key]);
21
21
  return answer[0];
22
22
  }
23
+ async waitReady(timeout) {
24
+ await wire.request(["service-wait-ready", this.key, timeout], timeout);
25
+ }
23
26
  }
24
27
  class ServerHandler extends ServerServiceBase {
25
28
  key;
@@ -34,9 +37,7 @@ class ServerHandler extends ServerServiceBase {
34
37
  }
35
38
  publish(event, payload = undefined) { this.service.publish(event, payload); }
36
39
  exists() { return this.service.exists(); }
37
- async waitReady(timeout) {
38
- await wire.request(["service-wait-ready", this.key, timeout], timeout);
39
- }
40
+ waitReady(timeout) { return this.service.waitReady(timeout); }
40
41
  async ask(event, payload = undefined) {
41
42
  return await this.askWithin(new Deadline(), event, payload);
42
43
  }
@@ -68,6 +69,7 @@ class ClientHandler extends ClientServiceBase {
68
69
  }
69
70
  publish(event, payload = undefined) { this.service.publish(event, payload); }
70
71
  exists() { return this.service.exists(); }
72
+ waitReady(timeout) { return this.service.waitReady(timeout); }
71
73
  }
72
74
  export function prepareService(key) {
73
75
  if (!isServiceKey(key))
package/dist/system.d.ts CHANGED
@@ -4,7 +4,7 @@ type ServiceEndpoint = ServiceKey["endpoint"];
4
4
  type ServiceAddress<Endpoint extends ServiceEndpoint> = Omit<ServiceKey, "endpoint"> & Readonly<{
5
5
  endpoint: Endpoint;
6
6
  }>;
7
- type ServiceHandle<Endpoint extends ServiceEndpoint, Events extends object, Fallback = never> = Endpoint extends "server" ? ServerService<Events, Fallback> : ClientService<Events, Fallback>;
7
+ type ServiceHandle<Endpoint extends ServiceEndpoint, Events extends object, Fallback = unknown> = Endpoint extends "server" ? ServerService<Events, Fallback> : ClientService<Events, Fallback>;
8
8
  /** Desktop capabilities structurally available to a Client endpoint. */
9
9
  export interface System {
10
10
  /** Complete unresolved Appearance read from the System authority. */
@@ -18,9 +18,9 @@ export interface System {
18
18
  /** Returns a precisely typed stable handle for either service endpoint. */
19
19
  service<Endpoint extends ServiceEndpoint>(key: ServiceAddress<Endpoint>): ServiceHandle<Endpoint, {}>;
20
20
  /** Returns a typed stable handle for one exact Server service identity. */
21
- service<ServiceEvents extends object, Fallback = never>(key: ServiceAddress<"server">): ServerService<ServiceEvents, Fallback>;
21
+ service<ServiceEvents extends object, Fallback = unknown>(key: ServiceAddress<"server">): ServerService<ServiceEvents, Fallback>;
22
22
  /** Returns a typed stable handle for one exact Client service identity. */
23
- service<ServiceEvents extends object, Fallback = never>(key: ServiceAddress<"client">): ClientService<ServiceEvents, Fallback>;
23
+ service<ServiceEvents extends object, Fallback = unknown>(key: ServiceAddress<"client">): ClientService<ServiceEvents, Fallback>;
24
24
  }
25
25
  /** Desktop capabilities available to this Client. */
26
26
  export declare const system: System;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/client",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "description": "The SDK used by a Program's client endpoint.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -39,7 +39,7 @@
39
39
  "packageManager": "bun@1.3.14",
40
40
  "scripts": {
41
41
  "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
42
- "check": "tsc --noEmit",
42
+ "check": "tsc --noEmit && tsc -p tsconfig.test.json",
43
43
  "build": "node --run clean && tsc --noEmit false --outDir dist --rootDir source",
44
44
  "verify:completions": "node scripts/verify-completions.mjs",
45
45
  "verify:package": "node scripts/verify-package.mjs",
@@ -47,13 +47,13 @@
47
47
  "prepack": "node --run build"
48
48
  },
49
49
  "peerDependencies": {
50
- "@phreshos/core": "^0.1.35"
50
+ "@phreshos/core": "^0.1.36"
51
51
  },
52
52
  "dependencies": {
53
53
  "@msgpack/msgpack": "^3.1.3"
54
54
  },
55
55
  "devDependencies": {
56
- "@phreshos/core": "^0.1.35",
56
+ "@phreshos/core": "^0.1.36",
57
57
  "typescript": "^6.0.3"
58
58
  }
59
59
  }