@phreshos/server 0.1.12 → 0.1.13
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 +20 -0
- package/dist/domain.d.ts +5 -0
- package/dist/host.d.ts +2 -1
- package/dist/main.d.ts +2 -1
- package/dist/main.js +2 -1
- package/dist/service.d.ts +27 -1
- package/dist/service.js +30 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,6 +154,26 @@ and their Endpoint declarations. `program.server?.hasService()` identifies a
|
|
|
154
154
|
declared Service capability, while `await program.server?.docs()` reads its
|
|
155
155
|
installed policy and API documentation before the Endpoint starts.
|
|
156
156
|
|
|
157
|
+
Server-side Service handles can create their dedicated providing Process and
|
|
158
|
+
wait for readiness without reproducing Program-specific launch rules:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
await serverService.createAndWaitReady()
|
|
162
|
+
await clientService.createAndWaitReady({ minimize: true })
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Both readiness operations accept an optional timeout directly and expose an
|
|
166
|
+
immutable timed view. A direct argument on the timed view takes precedence:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
await service.waitReady(10_000)
|
|
170
|
+
await service.timeout(5_000).waitReady()
|
|
171
|
+
await service.timeout(5_000).waitReady(10_000)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The System owns the single deadline across Process creation, Endpoint startup,
|
|
175
|
+
and Service readiness. The creation capability exists only in the Server SDK.
|
|
176
|
+
|
|
157
177
|
`program.icon()` requests a guaranteed PNG `Blob` in `small`, `medium`, or
|
|
158
178
|
`large` form without exposing the Program's source path or the system's private
|
|
159
179
|
asset-hosting address. Omitting the size selects `medium`.
|
package/dist/domain.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Client as CoreClient, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, Server as CoreServer, type AnswerCapture, type AskCapture, type Cleanup, type ClientDeclaration, type Exit, type Launch, type Position, type ProgramPermission, type ProgramProcess as CoreProgramProcess, type ProgramArea as CoreProgramArea, type Size, type TrafficMessage, type Window as CoreWindow, type WindowState } from "@phreshos/core";
|
|
2
2
|
import Events from "./events.js";
|
|
3
3
|
import { type ProgramStartup } from "./startup.js";
|
|
4
|
+
import { type ClientServiceHandler, type ServerServiceHandler } from "./service.js";
|
|
4
5
|
export interface HandleAddress {
|
|
5
6
|
identity: string;
|
|
6
7
|
reference: string;
|
|
@@ -104,6 +105,8 @@ export interface Endpoint<Events extends object = {}> extends CoreEndpoint<Event
|
|
|
104
105
|
export interface Server<Events extends object = {}> extends CoreServer<Events> {
|
|
105
106
|
/** Returns the Process that owns this Server. */
|
|
106
107
|
process(): Promise<Process>;
|
|
108
|
+
/** Returns the Service currently exposed by this Server Endpoint. */
|
|
109
|
+
service<ServiceEvents extends object = {}>(): Promise<ServerServiceHandler<ServiceEvents> | null>;
|
|
107
110
|
}
|
|
108
111
|
/** Server-visible Client handle. */
|
|
109
112
|
export interface Client<Events extends object = {}> extends CoreClient<Events> {
|
|
@@ -111,6 +114,8 @@ export interface Client<Events extends object = {}> extends CoreClient<Events> {
|
|
|
111
114
|
readonly window: Window;
|
|
112
115
|
/** Returns the Process that owns this Client. */
|
|
113
116
|
process(): Promise<Process>;
|
|
117
|
+
/** Returns the Service currently exposed by this Client Endpoint. */
|
|
118
|
+
service<ServiceEvents extends object = {}>(): Promise<ClientServiceHandler<ServiceEvents> | null>;
|
|
114
119
|
}
|
|
115
120
|
/** Server-visible Client-owned Window capability. */
|
|
116
121
|
export type Window = CoreWindow;
|
package/dist/host.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { DesktopWallpaper, Exit, FileWallpaper, Layer, Position, ServedFile,
|
|
1
|
+
import type { DesktopWallpaper, Exit, FileWallpaper, Layer, Position, ServedFile, ServiceKey, Size, Subscribable, ThemeProperties, WritableTheme } from "@phreshos/core";
|
|
2
|
+
import type { ClientServiceHandler, ServerServiceHandler } from "./service.js";
|
|
2
3
|
import { type Client, type Process, type Program, type Server } from "./domain.js";
|
|
3
4
|
/** Resolved production description for a Program's Server. */
|
|
4
5
|
export type ServerDescription = Readonly<{
|
package/dist/main.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { host, type Host, type HostProcess, type HostProgram, type ClientDescrip
|
|
|
2
2
|
export { current, type Current, type CurrentClient } from "./current.js";
|
|
3
3
|
export { type Answerer, type Channel } from "./channel.js";
|
|
4
4
|
export { type ProgramStartup } from "./startup.js";
|
|
5
|
-
export { ClientServiceHandler, ServerServiceHandler,
|
|
5
|
+
export { ClientServiceHandler, ServerServiceHandler, type TimedClientServiceHandler, type TimedServerServiceHandler } from "./service.js";
|
|
6
|
+
export { ServiceHandler, type ClientServiceChannel, type ServerServiceChannel, type ServiceChannel, type ServiceKey, type ServiceLifecycleEvents } from "@phreshos/core";
|
|
6
7
|
export { Client, Endpoint, Process, Program, Server, type Window, type ProgramArea, type ProgramProcess } from "./domain.js";
|
|
7
8
|
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, ProgramPermission, ProgramProcessEvents, 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/main.js
CHANGED
|
@@ -2,5 +2,6 @@ export { host } from "./host.js";
|
|
|
2
2
|
export { current } from "./current.js";
|
|
3
3
|
export {} from "./channel.js";
|
|
4
4
|
export {} from "./startup.js";
|
|
5
|
-
export { ClientServiceHandler, ServerServiceHandler
|
|
5
|
+
export { ClientServiceHandler, ServerServiceHandler } from "./service.js";
|
|
6
|
+
export { ServiceHandler } from "@phreshos/core";
|
|
6
7
|
export { Client, Endpoint, Process, Program, Server } from "./domain.js";
|
package/dist/service.d.ts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClientServiceHandler as CoreClientServiceHandler, ServerServiceHandler as CoreServerServiceHandler, type LaunchClient, type ServiceHandler, type ServiceKey, type Timeoutable } from "@phreshos/core";
|
|
2
2
|
import type { HandleAddress } from "./domain.js";
|
|
3
|
+
/** Timed view of a Server Endpoint Service available through the Server SDK. */
|
|
4
|
+
export interface TimedServerServiceHandler {
|
|
5
|
+
waitReady(timeout?: number): Promise<void>;
|
|
6
|
+
createAndWaitReady(timeout?: number): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** Timed view of a Client Endpoint Service available through the Server SDK. */
|
|
9
|
+
export interface TimedClientServiceHandler {
|
|
10
|
+
waitReady(timeout?: number): Promise<void>;
|
|
11
|
+
createAndWaitReady(client?: LaunchClient, timeout?: number): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** Server-SDK handle for a Service provided by a Server Endpoint. */
|
|
14
|
+
export declare class ServerServiceHandler<Events extends object = {}> extends CoreServerServiceHandler<Events> {
|
|
15
|
+
protected constructor();
|
|
16
|
+
}
|
|
17
|
+
export interface ServerServiceHandler<Events extends object = {}> extends Timeoutable<TimedServerServiceHandler> {
|
|
18
|
+
createAndWaitReady(timeout?: number): Promise<void>;
|
|
19
|
+
timeout(milliseconds: number): TimedServerServiceHandler;
|
|
20
|
+
}
|
|
21
|
+
/** Server-SDK handle for a Service provided by a Client Endpoint. */
|
|
22
|
+
export declare class ClientServiceHandler<Events extends object = {}> extends CoreClientServiceHandler<Events> {
|
|
23
|
+
protected constructor();
|
|
24
|
+
}
|
|
25
|
+
export interface ClientServiceHandler<Events extends object = {}> extends Timeoutable<TimedClientServiceHandler> {
|
|
26
|
+
createAndWaitReady(client?: LaunchClient, timeout?: number): Promise<void>;
|
|
27
|
+
timeout(milliseconds: number): TimedClientServiceHandler;
|
|
28
|
+
}
|
|
3
29
|
export declare function prepareService<EventsMap extends object = {}>(key: ServiceKey & {
|
|
4
30
|
endpoint: "server";
|
|
5
31
|
}): ServerServiceHandler<EventsMap>;
|
package/dist/service.js
CHANGED
|
@@ -5,8 +5,14 @@ import Events from "./events.js";
|
|
|
5
5
|
import HandleRegistry from "./handle-registry.js";
|
|
6
6
|
import wire from "./wire.js";
|
|
7
7
|
const handles = new HandleRegistry();
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/** Server-SDK handle for a Service provided by a Server Endpoint. */
|
|
9
|
+
export class ServerServiceHandler extends CoreServerServiceHandler {
|
|
10
|
+
constructor() { super(); }
|
|
11
|
+
}
|
|
12
|
+
/** Server-SDK handle for a Service provided by a Client Endpoint. */
|
|
13
|
+
export class ClientServiceHandler extends CoreClientServiceHandler {
|
|
14
|
+
constructor() { super(); }
|
|
15
|
+
}
|
|
10
16
|
class ServerChannelHandle extends Events {
|
|
11
17
|
key;
|
|
12
18
|
constructor(key) {
|
|
@@ -45,7 +51,7 @@ class ClientChannelHandle extends Events {
|
|
|
45
51
|
super(...serviceEvents(key, "channel"));
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
|
-
class ServerHandler extends
|
|
54
|
+
class ServerHandler extends ServerServiceHandler {
|
|
49
55
|
key;
|
|
50
56
|
name;
|
|
51
57
|
channel;
|
|
@@ -63,8 +69,17 @@ class ServerHandler extends ServerServiceBase {
|
|
|
63
69
|
async waitReady(timeout) {
|
|
64
70
|
await wire.request(["service-wait-ready", this.key, timeout], timeout);
|
|
65
71
|
}
|
|
72
|
+
async createAndWaitReady(timeout) {
|
|
73
|
+
await wire.request(["service-create-and-wait-ready", this.key, undefined, timeout], timeout);
|
|
74
|
+
}
|
|
75
|
+
timeout(milliseconds) {
|
|
76
|
+
return Object.freeze({
|
|
77
|
+
waitReady: (timeout) => this.waitReady(timeout ?? milliseconds),
|
|
78
|
+
createAndWaitReady: (timeout) => this.createAndWaitReady(timeout ?? milliseconds)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
66
81
|
}
|
|
67
|
-
class ClientHandler extends
|
|
82
|
+
class ClientHandler extends ClientServiceHandler {
|
|
68
83
|
key;
|
|
69
84
|
name;
|
|
70
85
|
channel;
|
|
@@ -82,6 +97,17 @@ class ClientHandler extends ClientServiceBase {
|
|
|
82
97
|
async waitReady(timeout) {
|
|
83
98
|
await wire.request(["service-wait-ready", this.key, timeout], timeout);
|
|
84
99
|
}
|
|
100
|
+
async createAndWaitReady(client, timeout) {
|
|
101
|
+
await wire.request(["service-create-and-wait-ready", this.key, client, timeout], timeout);
|
|
102
|
+
}
|
|
103
|
+
timeout(milliseconds) {
|
|
104
|
+
return Object.freeze({
|
|
105
|
+
waitReady: (timeout) => this.waitReady(timeout ?? milliseconds),
|
|
106
|
+
createAndWaitReady: (client, timeout) => {
|
|
107
|
+
return this.createAndWaitReady(client, timeout ?? milliseconds);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
85
111
|
}
|
|
86
112
|
export function prepareService(key) {
|
|
87
113
|
if (!isServiceKey(key))
|