@phreshos/node 0.1.2 → 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/dist/main.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { gatewayAddress } from "./address.js";
2
- export { Client, Endpoint, Process, Program, Server, System, type ProgramProcessRunEvent, type ProgramProcessRunOptions } from "./system.js";
2
+ export { Client, ClientService, Endpoint, Process, Program, Server, ServerService, System, type ProgramProcessRunEvent, type ProgramProcessRunOptions } from "./system.js";
3
+ export { Service, type ClientServiceChannel, type ServerServiceChannel, type ServiceChannel, type ServiceKey, type ServiceLifecycleEvents } from "@phreshos/core";
3
4
  export { resolveHome } from "./home.js";
4
5
  export { Project, type Manifest, type PackedProject, type ProjectMode, type ProjectOptions, type ProjectRunOptions } from "./project.js";
package/dist/main.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { gatewayAddress } from "./address.js";
2
- export { Client, Endpoint, Process, Program, Server, System } from "./system.js";
2
+ export { Client, ClientService, Endpoint, Process, Program, Server, ServerService, System } from "./system.js";
3
+ export { Service } from "@phreshos/core";
3
4
  export { resolveHome } from "./home.js";
4
5
  export { Project } from "./project.js";
package/dist/system.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Client as CoreClient, ClientServiceHandler as CoreClientServiceHandler, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, Server as CoreServer, ServerServiceHandler as CoreServerServiceHandler, type ClientDeclaration, type ClientServiceChannel, type EndpointDeclaration, type Launch, type LaunchClient, type Position, type ProgramDefinition, type ProgramCommandChunk, type ServerServiceChannel, type ServiceKey, type Size, type System as CoreSystem, type SystemClientEntity, type SystemEndpointEntity, type SystemProcessEntity, type SystemProcess, type SystemProgram, type SystemProgramEntity, type SystemProgramProcessEvents, type SystemServerEntity, type SystemUploads, type WritableAppearance, type Window, type WindowEvents, type WindowGeometry } from "@phreshos/core";
1
+ import { Client as CoreClient, ClientService as CoreClientService, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, Server as CoreServer, ServerService as CoreServerService, type ClientDeclaration, type EndpointDeclaration, type Launch, type LaunchClient, type Position, type ProgramDefinition, type ProgramCommandChunk, type ServiceKey, type Size, type System as CoreSystem, type SystemClientEntity, type SystemEndpointEntity, type SystemProcessEntity, type SystemProcess, type SystemProgram, type SystemProgramEntity, type SystemProgramProcessEvents, type SystemServerEntity, type SystemUploads, type WritableAppearance, type Window, type WindowEvents, type WindowGeometry } from "@phreshos/core";
2
2
  import Events from "./events.js";
3
3
  import { type TransportEvent } from "./transport.js";
4
4
  export type ProgramProcessRunOptions = Readonly<{
@@ -193,25 +193,13 @@ declare class SystemWindow extends Events<WindowEvents> implements Window {
193
193
  private snapshot;
194
194
  private change;
195
195
  }
196
- declare class ServerService<EventsMap extends object = {}> extends CoreServerServiceHandler<EventsMap> {
197
- readonly name: string;
198
- readonly channel: ServerServiceChannel<EventsMap>;
199
- private readonly base;
200
- constructor(system: System, key: ServiceKey & {
201
- endpoint: "server";
202
- });
203
- enabled(): Promise<boolean>;
204
- waitReady(timeout?: number): Promise<void>;
196
+ /** Node-SDK handle for a Service provided by a Server Endpoint. */
197
+ export declare class ServerService<EventsMap extends object = {}> extends CoreServerService<EventsMap> {
198
+ protected constructor();
205
199
  }
206
- declare class ClientService<EventsMap extends object = {}> extends CoreClientServiceHandler<EventsMap> {
207
- readonly name: string;
208
- readonly channel: ClientServiceChannel<EventsMap>;
209
- private readonly base;
210
- constructor(system: System, key: ServiceKey & {
211
- endpoint: "client";
212
- });
213
- enabled(): Promise<boolean>;
214
- waitReady(timeout?: number): Promise<void>;
200
+ /** Node-SDK handle for a Service provided by a Client Endpoint. */
201
+ export declare class ClientService<EventsMap extends object = {}> extends CoreClientService<EventsMap> {
202
+ protected constructor();
215
203
  }
216
204
  interface ProgramSnapshot {
217
205
  reference: string;
package/dist/system.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Client as CoreClient, ClientServiceHandler as CoreClientServiceHandler, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, Server as CoreServer, ServerServiceHandler as CoreServerServiceHandler } from "@phreshos/core";
1
+ import { Client as CoreClient, ClientService as CoreClientService, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, Server as CoreServer, ServerService as CoreServerService, isServiceKey } from "@phreshos/core";
2
2
  import { homedir } from "node:os";
3
3
  import { gatewayAddress } from "./address.js";
4
4
  import Events from "./events.js";
@@ -65,9 +65,13 @@ export class System {
65
65
  }
66
66
  service(key) {
67
67
  this.requireConnected();
68
- return key.endpoint === "server"
69
- ? new ServerService(this, key)
70
- : new ClientService(this, key);
68
+ if (!isServiceKey(key))
69
+ throw new Error("A complete service key is required");
70
+ const normalized = Object.freeze({ program: key.program, endpoint: key.endpoint, name: key.name });
71
+ const identity = JSON.stringify([normalized.program, normalized.endpoint, normalized.name]);
72
+ return this.handles.obtain(`service:${identity}`, () => normalized.endpoint === "server"
73
+ ? new ServerServiceHandle(this, normalized)
74
+ : new ClientServiceHandle(this, normalized));
71
75
  }
72
76
  programHandle(snapshot) {
73
77
  const handle = this.handles.obtain(`program:${snapshot.reference}`, () => new ProgramHandle(this, snapshot));
@@ -502,7 +506,11 @@ class ServiceBase extends Events {
502
506
  async enabled() { return await this.system.transport.api({ capability: "service", operation: "enabled", key: this.key }); }
503
507
  async waitReady(timeout) { await this.system.transport.api({ capability: "service", operation: "waitReady", key: this.key, timeout }); }
504
508
  }
505
- class ServerService extends CoreServerServiceHandler {
509
+ /** Node-SDK handle for a Service provided by a Server Endpoint. */
510
+ export class ServerService extends CoreServerService {
511
+ constructor() { super(); }
512
+ }
513
+ class ServerServiceHandle extends ServerService {
506
514
  name;
507
515
  channel;
508
516
  base;
@@ -516,7 +524,11 @@ class ServerService extends CoreServerServiceHandler {
516
524
  enabled() { return this.base.enabled(); }
517
525
  waitReady(timeout) { return this.base.waitReady(timeout); }
518
526
  }
519
- class ClientService extends CoreClientServiceHandler {
527
+ /** Node-SDK handle for a Service provided by a Client Endpoint. */
528
+ export class ClientService extends CoreClientService {
529
+ constructor() { super(); }
530
+ }
531
+ class ClientServiceHandle extends ClientService {
520
532
  name;
521
533
  channel;
522
534
  base;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/node",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Node.js access to PhreshOS and Program projects.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -32,7 +32,7 @@
32
32
  "prepack": "node --run build"
33
33
  },
34
34
  "dependencies": {
35
- "@phreshos/core": "^0.1.23",
35
+ "@phreshos/core": "^0.1.24",
36
36
  "adm-zip": "^0.6.0",
37
37
  "jiti": "^2.7.0"
38
38
  },