@phreshos/core 0.1.1 → 0.1.3

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
@@ -220,6 +220,13 @@ from its Client; its stable capability addresses the Client's current, live
220
220
  presentation state and rejects reads or mutations while that Client is
221
221
  absent.
222
222
 
223
+ `LaunchClient.title` supplies a dynamic initial title when starting a declared
224
+ Client. The system resolves it with the remaining launch shape before the
225
+ Client is announced, so the first rendered Window already has its final title.
226
+ Omission uses the Program declaration; `window.changeTitle()` remains the live
227
+ operation after startup. Window operations are never queued while the Client
228
+ is absent.
229
+
223
230
  Core also defines the independent, environment-neutral `FileWallpaper` and
224
231
  `DesktopWallpaper` contracts. The desktop variant additionally accepts a
225
232
  Program and the deliberately narrow `WallpaperLaunch`, containing only `name`,
@@ -231,10 +238,9 @@ persistence, upload, Process creation, or rendering implementation.
231
238
 
232
239
  `client.window.surface` addresses the optional host-rendered material belonging
233
240
  to one Window. Its source of truth is authoritative, server-owned Window state,
234
- not iframe state. `snapshot()` explicitly reads the current target, while the
235
- ordinary `change` subscription receives only replacements published after that
236
- subscription exists. A `null` target means no Surface exists in the render
237
- tree.
241
+ not iframe state. Program endpoints may explicitly replace or remove that
242
+ target, but cannot read or subscribe to it. A `null` target means no Surface
243
+ exists in the render tree.
238
244
 
239
245
  Only Windows currently occupying the `under` or `over` layer may call `set()`
240
246
  or `remove()`; `window` and `wallpaper` layers reject those operations. Calling
package/dist/askable.d.ts CHANGED
@@ -12,12 +12,11 @@ export interface Askable<Events extends object = {}, Fallback = unknown> extends
12
12
  /**
13
13
  * Sends one question payload to this target and waits for its answer.
14
14
  *
15
- * The SDK uses a ten-second deadline by default. It sends the question only
16
- * after the current Server incarnation becomes ready. The operation rejects
17
- * immediately when that Server is absent, and also rejects if the incarnation
18
- * stops before readiness or before answering. One SDK deadline covers both
19
- * readiness and the answer. The boundary cannot infer whether an answerer
20
- * exists, so a ready unanswered question waits for that deadline.
15
+ * The SDK uses a ten-second deadline by default. Any target-specific
16
+ * readiness wait shares that same deadline with the answer. The operation
17
+ * rejects when the target is known to be unavailable, or stops before
18
+ * answering. A boundary cannot infer whether an answerer exists, so a
19
+ * delivered but unanswered question waits for the deadline.
21
20
  */
22
21
  ask<Answer = unknown>(event: string): Promise<Answer>;
23
22
  ask<Answer = unknown, Payload = unknown>(event: string, payload: Payload): Promise<Answer>;
package/dist/channel.d.ts CHANGED
@@ -17,5 +17,9 @@ type ChannelFallback<Events extends object, From> = keyof Events extends never ?
17
17
  export type ChannelCapture<Events extends object = {}, From = Endpoint> = Captures<ChannelEvents<Events, From>, ChannelFallback<Events, From>>;
18
18
  /** Addressed input and destinationless output for the executing Endpoint. */
19
19
  export interface Channel<Events extends object = {}, From = Endpoint> extends Subscribable<ChannelEvents<Events, From>, ChannelFallback<Events, From>>, Publishable {
20
+ /** Exposes this executing Channel under one public service name. */
21
+ enableService(name: string): Promise<void>;
22
+ /** Stops exposing this executing Channel as a service. */
23
+ disableService(): Promise<void>;
20
24
  }
21
25
  export {};
package/dist/client.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Endpoint, type EndpointTraffic } from "./endpoint.js";
2
2
  import type { LaunchClient } from "./launch.js";
3
3
  import type { Server } from "./server.js";
4
4
  import type { Window } from "./window.js";
5
+ import type { ClientServiceHandler } from "./service.js";
5
6
  /** Directed communication originating from one Client. */
6
7
  export interface ClientTraffic<Events extends object = {}, To = Endpoint, AskTo = Server> extends EndpointTraffic<Events, To, AskTo> {
7
8
  }
@@ -16,4 +17,6 @@ export interface Client<Events extends object = {}> {
16
17
  readonly window: Window;
17
18
  /** Starts a fresh Client and Window using optional Process-local overrides. */
18
19
  start(overrides?: LaunchClient): Promise<void>;
20
+ /** Returns this Client's current complete service handle, or `null`. */
21
+ service<ServiceEvents extends object = {}>(): Promise<ClientServiceHandler<ServiceEvents> | null>;
19
22
  }
@@ -1,6 +1,7 @@
1
1
  import type { Process } from "./process.js";
2
2
  import type { Publishable } from "./publishable.js";
3
3
  import type { Server } from "./server.js";
4
+ import type { ServiceHandler } from "./service.js";
4
5
  import type { Captures, Cleanup, Subscribable } from "./subscribable.js";
5
6
  /** One application value observed in traffic originating from an Endpoint. */
6
7
  export type TrafficMessage<Payload = unknown, To = Endpoint> = Readonly<{
@@ -67,5 +68,7 @@ export interface Endpoint<Events extends object = {}> extends Publishable, Subsc
67
68
  * fails. Stopping never exits the Process implicitly.
68
69
  */
69
70
  stop(): Promise<void>;
71
+ /** Returns this Endpoint's current complete service handle, or `null`. */
72
+ service(): Promise<ServiceHandler | null>;
70
73
  }
71
74
  export {};
package/dist/launch.d.ts CHANGED
@@ -19,6 +19,8 @@ export type Layer = "window" | "under" | "over";
19
19
  export declare const layers: readonly Layer[];
20
20
  /** Per-Process overrides used when starting a Client and its Window. */
21
21
  export type LaunchClient = Readonly<{
22
+ /** Initial Window title for this Client incarnation. */
23
+ title?: string;
22
24
  /** Initial Window size for this Process. */
23
25
  size?: Size;
24
26
  /** Initial Window position for this Process. */
package/dist/main.d.ts CHANGED
@@ -2,6 +2,7 @@ export { type Message, type Cleanup, type Capture, type Captures, type EventMess
2
2
  export { type Publishable } from "./publishable.js";
3
3
  export { type Timeoutable } from "./timeout.js";
4
4
  export { type Askable, type TimedAskable } from "./askable.js";
5
+ export { ClientServiceHandler, ServerServiceHandler, ServiceHandler, isServiceKey, type ClientServiceChannel, type ServerServiceChannel, type ServiceChannel, type ServiceKey, type ServiceLifecycleEvents } from "./service.js";
5
6
  export { isPermissionName, permissionNames, type PermissionDecision, type PermissionDecisions, type PermissionName, type Permissions, type ProgramPermissions, type TimedPermissions } from "./permissions.js";
6
7
  export { type Outcome } from "./outcome.js";
7
8
  export { type ServedFile } from "./served-file.js";
@@ -18,6 +19,6 @@ export { Server, type AnswerCapture, type AnswerMessage, type AnswerObserver, ty
18
19
  export { Client, type ClientTraffic } from "./client.js";
19
20
  export { Process, type Exit, type ProcessEvents } from "./process.js";
20
21
  export { Program, type ClientDeclaration, type EndpointDeclaration, type ProgramEvents, type ProgramIconSize, type ProgramProcessExit } from "./program.js";
21
- export { type Window, type WindowEvents, type WindowLayer, type WindowState, type WindowSurface, type WindowSurfaceEasing, type WindowSurfaceEvents, type WindowSurfaceSettings, type WindowSurfaceTransaction } from "./window.js";
22
+ export { type Window, type WindowEvents, type WindowLayer, type WindowState, type WindowSurface, type WindowSurfaceEasing, type WindowSurfaceSettings, type WindowSurfaceTransaction } from "./window.js";
22
23
  export { layers, type Launch, type LaunchClient, type Layer, type Position, type Size } from "./launch.js";
23
24
  export { defineConfig, type ClientConfig, type ClientDevelopment, type Config, type ServerConfig, type ServerDevelopment } from "./config.js";
package/dist/main.js CHANGED
@@ -2,6 +2,7 @@ export {} from "./subscribable.js";
2
2
  export {} from "./publishable.js";
3
3
  export {} from "./timeout.js";
4
4
  export {} from "./askable.js";
5
+ export { ClientServiceHandler, ServerServiceHandler, ServiceHandler, isServiceKey } from "./service.js";
5
6
  export { isPermissionName, permissionNames } from "./permissions.js";
6
7
  export {} from "./outcome.js";
7
8
  export {} from "./served-file.js";
package/dist/server.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { Askable } from "./askable.js";
2
2
  import { Endpoint, type EndpointTraffic } from "./endpoint.js";
3
3
  import type { Outcome } from "./outcome.js";
4
4
  import type { Cleanup } from "./subscribable.js";
5
+ import type { ServerServiceHandler } from "./service.js";
5
6
  /** One answer sent by this Server to the Endpoint that asked. */
6
7
  export type AnswerMessage<Result = unknown, To = Endpoint> = Readonly<{
7
8
  /** Destination Endpoint, or `null` when its identity is outside this boundary. */
@@ -39,4 +40,6 @@ export interface Server<Events extends object = {}> extends Askable {
39
40
  * The SDK uses its ten-second deadline unless one is supplied.
40
41
  */
41
42
  waitReady(timeout?: number): Promise<void>;
43
+ /** Returns this Server's current complete service handle, or `null`. */
44
+ service<ServiceEvents extends object = {}>(): Promise<ServerServiceHandler<ServiceEvents> | null>;
42
45
  }
@@ -0,0 +1,61 @@
1
+ import type { Askable } from "./askable.js";
2
+ import type { Subscribable } from "./subscribable.js";
3
+ /** Stable public coordinates of one explicitly named Endpoint service. */
4
+ export type ServiceKey = Readonly<{
5
+ /** Stable identity of the Program that owns the providing Endpoint. */
6
+ program: string;
7
+ /** Endpoint kind deliberately exposed by the service author. */
8
+ endpoint: "server" | "client";
9
+ /** Program-authored service identity. */
10
+ name: string;
11
+ }>;
12
+ /** Lifecycle transitions of one exact service identity. */
13
+ export type ServiceLifecycleEvents = {
14
+ /** A live Endpoint began providing this service. */
15
+ enable: undefined;
16
+ /** The providing Endpoint stopped exposing this service. */
17
+ disable: undefined;
18
+ };
19
+ /** Application events emitted by one service. */
20
+ export interface ServiceChannel<Events extends object = {}> extends Subscribable<Events, keyof Events extends never ? unknown : never> {
21
+ }
22
+ /** Communication surface of a service provided by a Server Endpoint. */
23
+ export interface ServerServiceChannel<Events extends object = {}> extends ServiceChannel<Events>, Askable {
24
+ }
25
+ /** Communication surface of a service provided by a Client Endpoint. */
26
+ export interface ClientServiceChannel<Events extends object = {}> extends ServiceChannel<Events> {
27
+ }
28
+ /** Stable lifecycle handle for one exact public service identity. */
29
+ export declare class ServiceHandler<Channel extends object = ServiceChannel> {
30
+ protected constructor();
31
+ }
32
+ export interface ServiceHandler<Channel extends object = ServiceChannel> extends Subscribable<ServiceLifecycleEvents, never> {
33
+ /** Program namespace of this service. */
34
+ readonly program: string;
35
+ /** Endpoint kind represented by this service. */
36
+ readonly endpoint: "server" | "client";
37
+ /** Program-authored service identity. */
38
+ readonly name: string;
39
+ /** Application communication, separate from service lifecycle. */
40
+ readonly channel: Channel;
41
+ /** Explicitly reads whether no live Endpoint currently provides the service. */
42
+ disabled(): Promise<boolean>;
43
+ }
44
+ /** Stable handle for one Server-provided service. */
45
+ export declare class ServerServiceHandler<Events extends object = {}> extends ServiceHandler<ServerServiceChannel<Events>> {
46
+ protected constructor();
47
+ }
48
+ export interface ServerServiceHandler<Events extends object = {}> {
49
+ readonly endpoint: "server";
50
+ readonly channel: ServerServiceChannel<Events>;
51
+ }
52
+ /** Stable handle for one Client-provided service. */
53
+ export declare class ClientServiceHandler<Events extends object = {}> extends ServiceHandler<ClientServiceChannel<Events>> {
54
+ protected constructor();
55
+ }
56
+ export interface ClientServiceHandler<Events extends object = {}> {
57
+ readonly endpoint: "client";
58
+ readonly channel: ClientServiceChannel<Events>;
59
+ }
60
+ /** Returns whether a boundary value is a complete service key. */
61
+ export declare function isServiceKey(value: unknown): value is ServiceKey;
@@ -0,0 +1,27 @@
1
+ /** Stable lifecycle handle for one exact public service identity. */
2
+ export class ServiceHandler {
3
+ constructor() { }
4
+ }
5
+ /** Stable handle for one Server-provided service. */
6
+ export class ServerServiceHandler extends ServiceHandler {
7
+ constructor() {
8
+ super();
9
+ }
10
+ }
11
+ /** Stable handle for one Client-provided service. */
12
+ export class ClientServiceHandler extends ServiceHandler {
13
+ constructor() {
14
+ super();
15
+ }
16
+ }
17
+ /** Returns whether a boundary value is a complete service key. */
18
+ export function isServiceKey(value) {
19
+ if (typeof value !== "object" || value === null)
20
+ return false;
21
+ const candidate = value;
22
+ return typeof candidate.program === "string"
23
+ && candidate.program.length > 0
24
+ && (candidate.endpoint === "server" || candidate.endpoint === "client")
25
+ && typeof candidate.name === "string"
26
+ && candidate.name.length > 0;
27
+ }
package/dist/window.d.ts CHANGED
@@ -21,15 +21,8 @@ export type WindowSurfaceSettings = Readonly<{
21
21
  /** Optional motion from the currently rendered values to this target. */
22
22
  transaction?: WindowSurfaceTransaction;
23
23
  }>;
24
- /** Live changes emitted by one Window Surface capability. */
25
- export type WindowSurfaceEvents = {
26
- /** The authoritative target changed, including immediate removal as null. */
27
- change: WindowSurfaceSettings | null;
28
- };
29
24
  /** Optional host-rendered material owned by one authoritative Window. */
30
- export interface WindowSurface extends Subscribable<WindowSurfaceEvents, never> {
31
- /** Explicitly reads the authoritative target, or null when no Surface exists. */
32
- snapshot(): Promise<WindowSurfaceSettings | null>;
25
+ export interface WindowSurface {
33
26
  /** Creates or replaces the authoritative target. Omission creates the default Surface. */
34
27
  set(settings?: WindowSurfaceSettings): Promise<void>;
35
28
  /** Immediately removes the authoritative Surface. */
@@ -64,8 +57,6 @@ export type WindowState = Readonly<{
64
57
  layer: WindowLayer;
65
58
  /** Current page beneath the declared Client location. */
66
59
  location: string;
67
- /** Current authoritative host Surface target, or null when absent. */
68
- surface: WindowSurfaceSettings | null;
69
60
  }>;
70
61
  /** Presentation capability owned by one Client handle. */
71
62
  export interface Window extends Subscribable<WindowEvents, never> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Environment-neutral contracts and domain objects for PhreshOS Programs.",
5
5
  "type": "module",
6
6
  "sideEffects": false,