@phreshos/client 0.1.3 → 0.1.4

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/channel.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Channel as CoreChannel, ChannelCapture as CoreChannelCapture, ChannelEvents as CoreChannelEvents, ChannelMessage as CoreChannelMessage } from "@phreshos/core";
1
+ import type { Channel as CoreChannel, ChannelCapture as CoreChannelCapture, ChannelEvents as CoreChannelEvents, ChannelMessage as CoreChannelMessage, ServiceDefinition } from "@phreshos/core";
2
2
  import { type Endpoint } from "./domain.js";
3
3
  /** One value addressed to the current Client, with a client-visible sender. */
4
4
  export type ChannelMessage<Payload = unknown> = CoreChannelMessage<Payload, Endpoint | null>;
@@ -7,6 +7,6 @@ export type ChannelEvents<Events extends object> = CoreChannelEvents<Events, End
7
7
  /** Every event observable through the current Client's Channel. */
8
8
  export type ChannelCapture<Events extends object = {}> = CoreChannelCapture<Events, Endpoint | null>;
9
9
  /** Events explicitly accepted by the current Client. */
10
- export interface Channel<Events extends object = {}> extends CoreChannel<Events, Endpoint | null> {
10
+ export interface Channel<Events extends object = {}> extends CoreChannel<Events, Endpoint | null, ServiceDefinition> {
11
11
  }
12
12
  export declare const channel: Channel;
package/dist/channel.js CHANGED
@@ -12,7 +12,7 @@ class ClientChannel 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
  }
18
18
  function message(value) {
package/dist/current.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { Channel as CoreChannel } from "@phreshos/core";
2
- import { Client, Server, type Endpoint, type Process, type Program, type Window } from "./domain.js";
1
+ import { type Channel } from "./channel.js";
2
+ import { Client, Server, type Process, type Program, type Window } from "./domain.js";
3
3
  /** The current Process's canonical Server handle. */
4
4
  export type CurrentServer<Events extends object = {}> = Server<Events>;
5
5
  /** Current Client context: its inbound Channel, owner hierarchy, and paired Server. */
6
- export interface Current<Events extends object = {}> extends CoreChannel<Events, Endpoint | null>, Pick<Client, "service"> {
6
+ export interface Current<Events extends object = {}> extends Channel<Events>, Pick<Client, "service"> {
7
7
  /** The same Server handle exposed by the current Process. */
8
8
  readonly server: CurrentServer;
9
9
  /** Presentation capability of this current Client. */
package/dist/domain.js CHANGED
@@ -54,10 +54,6 @@ class ProgramHandle extends ProgramBase {
54
54
  const answer = await wire.request(["create-process", undefined, launch]);
55
55
  return process(answer[0]);
56
56
  }
57
- async apiDocs() {
58
- const answer = await wire.request(["api-docs"]);
59
- return answer[0];
60
- }
61
57
  async icon(size = "medium") {
62
58
  const answer = await wire.request(["icon", size]);
63
59
  return new Blob([Uint8Array.from(answer[0])], { type: "image/png" });
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 ServerServiceHandler, type ServiceDefinition, 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: ServiceDefinition): 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
@@ -62,6 +62,10 @@ class ServerHandler extends ServerServiceBase {
62
62
  const answer = await wire.request(["service-disabled", this.key]);
63
63
  return answer[0];
64
64
  }
65
+ async docs() {
66
+ const answer = await wire.request(["service-docs", this.key]);
67
+ return answer[0];
68
+ }
65
69
  }
66
70
  class ClientHandler extends ClientServiceBase {
67
71
  key;
@@ -93,8 +97,8 @@ export function service(key) {
93
97
  : new ClientHandler(normalized);
94
98
  });
95
99
  }
96
- export async function enableCurrentService(name) {
97
- await wire.request(["enable-service", name]);
100
+ export async function enableCurrentService(definition) {
101
+ await wire.request(["enable-service", definition]);
98
102
  }
99
103
  export async function disableCurrentService() {
100
104
  await wire.request(["disable-service"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/client",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The SDK used by a Program's client 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.4"
50
50
  },
51
51
  "devDependencies": {
52
- "@phreshos/core": "^0.1.3",
52
+ "@phreshos/core": "^0.1.4",
53
53
  "typescript": "^6.0.3"
54
54
  }
55
55
  }