@phreshos/node 0.1.0 → 0.1.2
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 +42 -15
- package/dist/handle-registry.d.ts +6 -0
- package/dist/handle-registry.js +13 -0
- package/dist/home.d.ts +1 -1
- package/dist/home.js +1 -1
- package/dist/main.d.ts +2 -3
- package/dist/main.js +1 -2
- package/dist/project.d.ts +21 -4
- package/dist/project.js +35 -9
- package/dist/system.d.ts +252 -6
- package/dist/system.js +256 -82
- package/dist/transport.d.ts +3 -3
- package/dist/transport.js +19 -13
- package/package.json +2 -2
- package/dist/client-development.d.ts +0 -29
- package/dist/client-development.js +0 -199
- package/dist/gateway.d.ts +0 -49
- package/dist/gateway.js +0 -151
package/README.md
CHANGED
|
@@ -3,37 +3,64 @@
|
|
|
3
3
|
The Node.js interface for a running PhreshOS System and local Program projects.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import {
|
|
6
|
+
import { Project, System } from "@phreshos/node"
|
|
7
7
|
|
|
8
8
|
const project = await Project.open()
|
|
9
|
-
const
|
|
9
|
+
const system = await System.connect()
|
|
10
10
|
|
|
11
|
-
for await (const
|
|
12
|
-
|
|
11
|
+
for await (const chunk of await project.install(system)) {
|
|
12
|
+
process[chunk.stream].write(chunk.text)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
const programs = await
|
|
15
|
+
// This is the same transport-neutral System contract used by Server Programs.
|
|
16
|
+
const programs = await system.program.list()
|
|
17
17
|
|
|
18
|
-
await
|
|
18
|
+
await system.disconnect()
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
`Project.open()` discovers `phresh.config.ts` from the current working
|
|
22
|
-
directory by default. `
|
|
22
|
+
directory by default. `System.connect()` resolves its home from an explicit
|
|
23
23
|
argument, then `PHRESHOS_HOME`, then the current user's `.phreshos` directory.
|
|
24
24
|
|
|
25
25
|
Project operations remain available without duplicating CLI logic:
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
const project = await Project.open() // process.cwd()
|
|
29
|
-
const
|
|
29
|
+
const system = await System.connect()
|
|
30
30
|
|
|
31
31
|
await project.pack()
|
|
32
|
-
for await (const event of
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
for await (const event of await project.start(system, { signal })) {
|
|
33
|
+
// started, output, exited
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for await (const event of await project.dev(system, { signal })) {
|
|
37
|
+
// started, output, exited
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for await (const chunk of await project.install(system)) {
|
|
41
|
+
// stdout or stderr
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await system.disconnect()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
These shortcuts return the original `program.install()` or
|
|
48
|
+
`program.process.run()` generator; they do not consume or mirror its events.
|
|
49
|
+
The CLI owns presentation and its additional development Client server.
|
|
50
|
+
|
|
51
|
+
For custom composition, resolve either Program definition explicitly:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const definition = project.productionDefinition()
|
|
55
|
+
// const definition = project.developmentDefinition()
|
|
56
|
+
|
|
57
|
+
const program = await system.forceCreateProgram(definition)
|
|
58
|
+
const lifecycle = program.process.run({}, { signal })
|
|
35
59
|
```
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
The lower-level System API stays composable: use
|
|
62
|
+
`system.forceCreateProgram(definition)` to replace one runtime Program, and
|
|
63
|
+
`program.process.run(launch, { signal })` when one Process should live exactly
|
|
64
|
+
as long as its asynchronous iterator. Node also exports the runtime `Program`,
|
|
65
|
+
`Process`, `Endpoint`, `Server`, and `Client` constructors; handles are
|
|
66
|
+
canonical within one connected `System` and support `instanceof`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Canonical domain handles owned for exactly one connected System context. */
|
|
2
|
+
export default class HandleRegistry {
|
|
3
|
+
handles = new Map();
|
|
4
|
+
obtain(key, create) {
|
|
5
|
+
const existing = this.handles.get(key);
|
|
6
|
+
if (existing)
|
|
7
|
+
return existing;
|
|
8
|
+
const value = create();
|
|
9
|
+
this.handles.set(key, value);
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
clear() { this.handles.clear(); }
|
|
13
|
+
}
|
package/dist/home.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Resolve the absolute PhreshOS home selected for one
|
|
1
|
+
/** Resolve the absolute PhreshOS home selected for one System connection. */
|
|
2
2
|
export declare function resolveHome(home?: string, environment?: NodeJS.ProcessEnv, userHome?: string): string;
|
package/dist/home.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, realpathSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { isAbsolute, join, normalize } from "node:path";
|
|
4
|
-
/** Resolve the absolute PhreshOS home selected for one
|
|
4
|
+
/** Resolve the absolute PhreshOS home selected for one System connection. */
|
|
5
5
|
export function resolveHome(home, environment = process.env, userHome = homedir()) {
|
|
6
6
|
const selected = home ?? environment.PHRESHOS_HOME;
|
|
7
7
|
if (selected === undefined)
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { gatewayAddress } from "./address.js";
|
|
2
|
-
export {
|
|
2
|
+
export { Client, Endpoint, Process, Program, Server, System, type ProgramProcessRunEvent, type ProgramProcessRunOptions } from "./system.js";
|
|
3
3
|
export { resolveHome } from "./home.js";
|
|
4
|
-
export { Project, type Manifest, type PackedProject, type ProjectMode, type ProjectOptions } from "./project.js";
|
|
5
|
-
export { type GatewayEvent } from "./transport.js";
|
|
4
|
+
export { Project, type Manifest, type PackedProject, type ProjectMode, type ProjectOptions, type ProjectRunOptions } from "./project.js";
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { gatewayAddress } from "./address.js";
|
|
2
|
-
export {
|
|
2
|
+
export { Client, Endpoint, Process, Program, Server, System } from "./system.js";
|
|
3
3
|
export { resolveHome } from "./home.js";
|
|
4
4
|
export { Project } from "./project.js";
|
|
5
|
-
export {} from "./transport.js";
|
package/dist/project.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Config, type
|
|
1
|
+
import { type Config, type ProgramDefinition, type System as SystemContract } from "@phreshos/core";
|
|
2
2
|
/** One loaded Program authoring project rooted at an absolute directory. */
|
|
3
3
|
export declare class Project {
|
|
4
4
|
readonly directory: string;
|
|
@@ -6,21 +6,38 @@ export declare class Project {
|
|
|
6
6
|
private constructor();
|
|
7
7
|
/** Discover a project from cwd, a directory, or a phresh.config.ts path. */
|
|
8
8
|
static open(source?: string): Promise<Project>;
|
|
9
|
-
/** Create a
|
|
9
|
+
/** Create a Project from an already loaded authoring configuration. */
|
|
10
10
|
static define(config: Config, options?: ProjectOptions): Project;
|
|
11
11
|
/** Read this project's package manifest. */
|
|
12
12
|
manifest(): Promise<Manifest>;
|
|
13
|
-
/** Resolve this authoring
|
|
14
|
-
|
|
13
|
+
/** Resolve this authoring configuration into its production Program definition. */
|
|
14
|
+
productionDefinition(): ProgramDefinition;
|
|
15
|
+
/** Resolve this authoring configuration into its development Program definition. */
|
|
16
|
+
developmentDefinition(): ProgramDefinition;
|
|
17
|
+
private definition;
|
|
15
18
|
/** Run the optional author-owned production build command. */
|
|
16
19
|
build(): Promise<void>;
|
|
20
|
+
/** Build this Project and return its production Process lifecycle generator. */
|
|
21
|
+
start(system: SystemContract, options?: ProjectRunOptions): Promise<AsyncGenerator<import("@phreshos/core").SystemProcessRunEvent, void, void>>;
|
|
22
|
+
/** Return this Project's development Process lifecycle generator. */
|
|
23
|
+
dev(system: SystemContract, options?: ProjectRunOptions): Promise<AsyncGenerator<import("@phreshos/core").SystemProcessRunEvent, void, void>>;
|
|
24
|
+
/** Build this Project and return its Program installation generator. */
|
|
25
|
+
install(system: SystemContract): Promise<AsyncGenerator<Readonly<{
|
|
26
|
+
stream: "stdout" | "stderr";
|
|
27
|
+
text: string;
|
|
28
|
+
}>, void, void>>;
|
|
17
29
|
/** Build and package this Program into its canonical release shape. */
|
|
18
30
|
pack(): Promise<PackedProject>;
|
|
31
|
+
private run;
|
|
19
32
|
}
|
|
20
33
|
export type ProjectMode = "production" | "development";
|
|
21
34
|
export interface ProjectOptions {
|
|
22
35
|
directory?: string;
|
|
23
36
|
}
|
|
37
|
+
export interface ProjectRunOptions {
|
|
38
|
+
options?: Record<string, string>;
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}
|
|
24
41
|
export type PackedProject = Readonly<{
|
|
25
42
|
archive: string;
|
|
26
43
|
archivePath: string;
|
package/dist/project.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRelativeValue, layers } from "@phreshos/core";
|
|
1
|
+
import { isRelativeValue, layers, } from "@phreshos/core";
|
|
2
2
|
import AdmZip from "adm-zip";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
@@ -29,7 +29,7 @@ export class Project {
|
|
|
29
29
|
throw new Error(`${configFile} must export its config as the default export`);
|
|
30
30
|
return new Project(config, resolve(path, ".."));
|
|
31
31
|
}
|
|
32
|
-
/** Create a
|
|
32
|
+
/** Create a Project from an already loaded authoring configuration. */
|
|
33
33
|
static define(config, options = {}) {
|
|
34
34
|
return new Project(config, options.directory ?? process.cwd());
|
|
35
35
|
}
|
|
@@ -44,8 +44,15 @@ export class Project {
|
|
|
44
44
|
}
|
|
45
45
|
return manifest;
|
|
46
46
|
}
|
|
47
|
-
/** Resolve this authoring
|
|
48
|
-
|
|
47
|
+
/** Resolve this authoring configuration into its production Program definition. */
|
|
48
|
+
productionDefinition() {
|
|
49
|
+
return this.definition("production");
|
|
50
|
+
}
|
|
51
|
+
/** Resolve this authoring configuration into its development Program definition. */
|
|
52
|
+
developmentDefinition() {
|
|
53
|
+
return this.definition("development");
|
|
54
|
+
}
|
|
55
|
+
definition(mode) {
|
|
49
56
|
const config = this.config;
|
|
50
57
|
const server = serverHalf(config.server, mode);
|
|
51
58
|
const client = clientHalf(config.client, mode);
|
|
@@ -101,6 +108,21 @@ export class Project {
|
|
|
101
108
|
});
|
|
102
109
|
});
|
|
103
110
|
}
|
|
111
|
+
/** Build this Project and return its production Process lifecycle generator. */
|
|
112
|
+
async start(system, options = {}) {
|
|
113
|
+
await this.build();
|
|
114
|
+
return await this.run(system, this.productionDefinition(), options);
|
|
115
|
+
}
|
|
116
|
+
/** Return this Project's development Process lifecycle generator. */
|
|
117
|
+
async dev(system, options = {}) {
|
|
118
|
+
return await this.run(system, this.developmentDefinition(), options);
|
|
119
|
+
}
|
|
120
|
+
/** Build this Project and return its Program installation generator. */
|
|
121
|
+
async install(system) {
|
|
122
|
+
await this.build();
|
|
123
|
+
const program = await system.forceCreateProgram(this.productionDefinition());
|
|
124
|
+
return program.install();
|
|
125
|
+
}
|
|
104
126
|
/** Build and package this Program into its canonical release shape. */
|
|
105
127
|
async pack() {
|
|
106
128
|
await this.build();
|
|
@@ -118,7 +140,7 @@ export class Project {
|
|
|
118
140
|
file(zip, this.directory, this.config.icon, "icon.png", "Program icon");
|
|
119
141
|
if (this.config.agent)
|
|
120
142
|
file(zip, this.directory, this.config.agent, "agent.md", "Program agent documentation");
|
|
121
|
-
const declaration = Buffer.from(JSON.stringify(
|
|
143
|
+
const declaration = Buffer.from(JSON.stringify(packageDefinition(this.config, version), null, 4) + "\n");
|
|
122
144
|
zip.addFile("program.json", declaration);
|
|
123
145
|
const archive = `${this.config.identity}@${version}.zip`;
|
|
124
146
|
const bytes = zip.toBuffer();
|
|
@@ -131,14 +153,18 @@ export class Project {
|
|
|
131
153
|
writeFileSync(checksumPath, `${digest} ${archive}\n`);
|
|
132
154
|
return Object.freeze({ archive, archivePath, checksumPath, declarationPath, digest });
|
|
133
155
|
}
|
|
156
|
+
async run(system, definition, options) {
|
|
157
|
+
const program = await system.forceCreateProgram(definition);
|
|
158
|
+
return program.process.run({ options: options.options ?? {} }, { signal: options.signal });
|
|
159
|
+
}
|
|
134
160
|
}
|
|
135
161
|
function serverHalf(half, mode) {
|
|
136
162
|
if (!half)
|
|
137
163
|
return null;
|
|
138
|
-
const { development, startCommand, entryFile, ...
|
|
164
|
+
const { development, startCommand, entryFile, ...declared } = half;
|
|
139
165
|
if (mode === "production" || !development)
|
|
140
|
-
return { ...
|
|
141
|
-
return { ...
|
|
166
|
+
return { ...declared, ...serverExecution({ startCommand, entryFile }) };
|
|
167
|
+
return { ...declared, location: ".", ...serverExecution(development) };
|
|
142
168
|
}
|
|
143
169
|
function serverExecution(server) {
|
|
144
170
|
return server.startCommand !== undefined ? { startCommand: server.startCommand } : { entryFile: server.entryFile };
|
|
@@ -229,7 +255,7 @@ function commandEnvironment(directory) {
|
|
|
229
255
|
const inherited = process.env[key];
|
|
230
256
|
return { ...process.env, [key]: [join(directory, "node_modules", ".bin"), inherited].filter(Boolean).join(delimiter) };
|
|
231
257
|
}
|
|
232
|
-
function
|
|
258
|
+
function packageDefinition(config, version) {
|
|
233
259
|
return {
|
|
234
260
|
identity: config.identity,
|
|
235
261
|
name: config.name,
|
package/dist/system.d.ts
CHANGED
|
@@ -1,9 +1,255 @@
|
|
|
1
|
-
import { type System } from "@phreshos/core";
|
|
2
|
-
import
|
|
3
|
-
|
|
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";
|
|
2
|
+
import Events from "./events.js";
|
|
3
|
+
import { type TransportEvent } from "./transport.js";
|
|
4
|
+
export type ProgramProcessRunOptions = Readonly<{
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
}>;
|
|
7
|
+
export type ProgramProcessRunEvent = Readonly<{
|
|
8
|
+
event: "started";
|
|
9
|
+
process: SystemProcessEntity;
|
|
10
|
+
}> | (Readonly<{
|
|
11
|
+
event: "output";
|
|
12
|
+
}> & ProgramCommandChunk) | Readonly<{
|
|
13
|
+
event: "exited";
|
|
14
|
+
process: SystemProcessEntity;
|
|
15
|
+
exit: import("@phreshos/core").Exit;
|
|
16
|
+
}>;
|
|
17
|
+
interface SystemTransport {
|
|
4
18
|
control(request: object, signal?: AbortSignal): Promise<unknown>;
|
|
5
19
|
api(request: object, signal?: AbortSignal): Promise<unknown>;
|
|
6
|
-
lifecycle(request: object, signal?: AbortSignal): AsyncGenerator<
|
|
20
|
+
lifecycle(request: object, signal?: AbortSignal): AsyncGenerator<TransportEvent, void, void>;
|
|
7
21
|
}
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
declare const ProgramBase: new () => object;
|
|
23
|
+
declare const ProcessBase: new () => object;
|
|
24
|
+
declare const ServerBase: new () => object;
|
|
25
|
+
declare const ClientBase: new () => object;
|
|
26
|
+
/** One connected owner-local implementation of the shared System contract. */
|
|
27
|
+
export declare class System implements CoreSystem {
|
|
28
|
+
private readonly connection;
|
|
29
|
+
readonly home: string;
|
|
30
|
+
readonly address: string;
|
|
31
|
+
readonly storage: import("@phreshos/core").Storage;
|
|
32
|
+
readonly appearance: WritableAppearance;
|
|
33
|
+
readonly program: SystemProgram;
|
|
34
|
+
readonly process: SystemProcess;
|
|
35
|
+
readonly uploads: SystemUploads;
|
|
36
|
+
readonly transport: SystemTransport;
|
|
37
|
+
private closed;
|
|
38
|
+
private readonly lifetime;
|
|
39
|
+
private readonly handles;
|
|
40
|
+
private constructor();
|
|
41
|
+
/** Connect to the System selected by argument, environment, or owner default. */
|
|
42
|
+
static connect(home?: string): Promise<System>;
|
|
43
|
+
/** Atomically replace one runtime Program without touching its installed form. */
|
|
44
|
+
forceCreateProgram(source: ProgramDefinition | string): Promise<SystemProgramEntity>;
|
|
45
|
+
/** Close this owner connection and abort every attached operation it owns. */
|
|
46
|
+
disconnect(): Promise<void>;
|
|
47
|
+
service<EventsMap extends object = {}>(key: ServiceKey & {
|
|
48
|
+
endpoint: "server";
|
|
49
|
+
}): ServerService<EventsMap>;
|
|
50
|
+
service<EventsMap extends object = {}>(key: ServiceKey & {
|
|
51
|
+
endpoint: "client";
|
|
52
|
+
}): ClientService<EventsMap>;
|
|
53
|
+
programHandle(snapshot: ProgramSnapshot): ProgramHandle;
|
|
54
|
+
processHandle(snapshot: ProcessSnapshot): ProcessHandle;
|
|
55
|
+
private signal;
|
|
56
|
+
private requireConnected;
|
|
57
|
+
}
|
|
58
|
+
interface ProgramHandle extends SystemProgramEntity {
|
|
59
|
+
}
|
|
60
|
+
declare class ProgramHandle extends ProgramBase {
|
|
61
|
+
private readonly system;
|
|
62
|
+
private readonly reference;
|
|
63
|
+
readonly identity: string;
|
|
64
|
+
readonly process: ProgramProcesses;
|
|
65
|
+
readonly startup: ProgramStartup;
|
|
66
|
+
private snapshot;
|
|
67
|
+
constructor(system: System, snapshot: ProgramSnapshot);
|
|
68
|
+
get name(): string;
|
|
69
|
+
get version(): string | null;
|
|
70
|
+
get description(): string | null;
|
|
71
|
+
get hasAgent(): boolean;
|
|
72
|
+
get server(): EndpointDeclaration | null;
|
|
73
|
+
get client(): ClientDeclaration | null;
|
|
74
|
+
update(snapshot: ProgramSnapshot): void;
|
|
75
|
+
agent(): Promise<string | null>;
|
|
76
|
+
installed(): Promise<boolean>;
|
|
77
|
+
install(): AsyncGenerator<Readonly<{
|
|
78
|
+
stream: "stdout" | "stderr";
|
|
79
|
+
text: string;
|
|
80
|
+
}>, void, void>;
|
|
81
|
+
uninstall(everything?: boolean): AsyncGenerator<Readonly<{
|
|
82
|
+
stream: "stdout" | "stderr";
|
|
83
|
+
text: string;
|
|
84
|
+
}>, void, void>;
|
|
85
|
+
forget(): Promise<void>;
|
|
86
|
+
address(): Readonly<{
|
|
87
|
+
identity: string;
|
|
88
|
+
reference: string;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
declare class ProgramStartup {
|
|
92
|
+
private readonly system;
|
|
93
|
+
private readonly program;
|
|
94
|
+
constructor(system: System, program: ProgramHandle);
|
|
95
|
+
get(): Promise<Readonly<{
|
|
96
|
+
name?: string;
|
|
97
|
+
server?: boolean;
|
|
98
|
+
client?: boolean | LaunchClient;
|
|
99
|
+
options?: Readonly<Record<string, string>>;
|
|
100
|
+
}> | null>;
|
|
101
|
+
enable(launch?: Launch): Promise<void>;
|
|
102
|
+
disable(): Promise<void>;
|
|
103
|
+
private change;
|
|
104
|
+
}
|
|
105
|
+
declare class ProgramProcesses extends Events<SystemProgramProcessEvents> {
|
|
106
|
+
private readonly system;
|
|
107
|
+
private readonly program;
|
|
108
|
+
constructor(system: System, program: ProgramHandle);
|
|
109
|
+
list(): Promise<ProcessHandle[]>;
|
|
110
|
+
first(): Promise<ProcessHandle | null>;
|
|
111
|
+
last(): Promise<ProcessHandle | null>;
|
|
112
|
+
find(identityOrName: string): Promise<ProcessHandle | null>;
|
|
113
|
+
create(launch?: Launch): Promise<ProcessHandle>;
|
|
114
|
+
run(launch?: Launch, options?: ProgramProcessRunOptions): AsyncGenerator<ProgramProcessRunEvent, void, void>;
|
|
115
|
+
findOrCreate(launch: Launch & {
|
|
116
|
+
name: string;
|
|
117
|
+
}): Promise<ProcessHandle>;
|
|
118
|
+
exitAll(): Promise<string[]>;
|
|
119
|
+
private createExact;
|
|
120
|
+
}
|
|
121
|
+
interface ProcessHandle extends SystemProcessEntity {
|
|
122
|
+
}
|
|
123
|
+
declare class ProcessHandle extends ProcessBase {
|
|
124
|
+
private readonly system;
|
|
125
|
+
private readonly snapshot;
|
|
126
|
+
readonly identity: string;
|
|
127
|
+
readonly name: string | null;
|
|
128
|
+
readonly startedAt: Date;
|
|
129
|
+
readonly server: ServerEndpoint;
|
|
130
|
+
readonly client: ClientEndpoint;
|
|
131
|
+
constructor(system: System, snapshot: ProcessSnapshot);
|
|
132
|
+
program(): ProgramHandle;
|
|
133
|
+
exit(): Promise<void>;
|
|
134
|
+
exited(): Promise<boolean>;
|
|
135
|
+
}
|
|
136
|
+
interface ServerEndpoint extends SystemServerEntity {
|
|
137
|
+
}
|
|
138
|
+
declare class ServerEndpoint extends ServerBase {
|
|
139
|
+
private readonly system;
|
|
140
|
+
private readonly owner;
|
|
141
|
+
readonly endpoint: "server";
|
|
142
|
+
private readonly base;
|
|
143
|
+
constructor(system: System, owner: ProcessHandle);
|
|
144
|
+
process(): Promise<ProcessHandle>;
|
|
145
|
+
exists(): Promise<boolean>;
|
|
146
|
+
start(): Promise<void>;
|
|
147
|
+
stop(): Promise<void>;
|
|
148
|
+
publish(event: string, payload?: unknown): void;
|
|
149
|
+
ask<Answer = unknown>(event: string, payload?: unknown): Promise<Answer>;
|
|
150
|
+
timeout(milliseconds: number): {
|
|
151
|
+
ask: <Answer = unknown>(event: string, payload?: unknown) => Promise<Answer>;
|
|
152
|
+
};
|
|
153
|
+
waitReady(timeout?: number): Promise<void>;
|
|
154
|
+
service<EventsMap extends object = {}>(): Promise<ServerService<EventsMap> | null>;
|
|
155
|
+
}
|
|
156
|
+
interface ClientEndpoint extends SystemClientEntity {
|
|
157
|
+
}
|
|
158
|
+
declare class ClientEndpoint extends ClientBase {
|
|
159
|
+
readonly endpoint: "client";
|
|
160
|
+
readonly window: SystemWindow;
|
|
161
|
+
private readonly base;
|
|
162
|
+
constructor(system: System, owner: ProcessHandle);
|
|
163
|
+
process(): Promise<ProcessHandle>;
|
|
164
|
+
exists(): Promise<boolean>;
|
|
165
|
+
start(overrides?: LaunchClient): Promise<void>;
|
|
166
|
+
stop(): Promise<void>;
|
|
167
|
+
publish(event: string, payload?: unknown): void;
|
|
168
|
+
service<EventsMap extends object = {}>(): Promise<ClientService<EventsMap> | null>;
|
|
169
|
+
}
|
|
170
|
+
declare class SystemWindow extends Events<WindowEvents> implements Window {
|
|
171
|
+
private readonly system;
|
|
172
|
+
private readonly process;
|
|
173
|
+
constructor(system: System, process: ProcessHandle);
|
|
174
|
+
title(): Promise<string>;
|
|
175
|
+
position(): Promise<Readonly<{
|
|
176
|
+
x: import("@phreshos/core").Value;
|
|
177
|
+
y: import("@phreshos/core").Value;
|
|
178
|
+
}>>;
|
|
179
|
+
size(): Promise<Readonly<{
|
|
180
|
+
width: import("@phreshos/core").Value;
|
|
181
|
+
height: import("@phreshos/core").Value;
|
|
182
|
+
}>>;
|
|
183
|
+
minimized(): Promise<boolean>;
|
|
184
|
+
front(): Promise<boolean>;
|
|
185
|
+
layer(): Promise<import("@phreshos/core").Layer>;
|
|
186
|
+
location(): Promise<string>;
|
|
187
|
+
move(position: Position): Promise<void>;
|
|
188
|
+
resize(size: Size): Promise<void>;
|
|
189
|
+
setGeometry(geometry: WindowGeometry): Promise<void>;
|
|
190
|
+
minimize(minimized?: boolean): Promise<void>;
|
|
191
|
+
changeTitle(title: string): Promise<void>;
|
|
192
|
+
raise(): Promise<void>;
|
|
193
|
+
private snapshot;
|
|
194
|
+
private change;
|
|
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>;
|
|
205
|
+
}
|
|
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>;
|
|
215
|
+
}
|
|
216
|
+
interface ProgramSnapshot {
|
|
217
|
+
reference: string;
|
|
218
|
+
identity: string;
|
|
219
|
+
name: string;
|
|
220
|
+
version: string | null;
|
|
221
|
+
description: string | null;
|
|
222
|
+
installed?: boolean;
|
|
223
|
+
hasAgent: boolean;
|
|
224
|
+
server: {
|
|
225
|
+
start: boolean;
|
|
226
|
+
} | null;
|
|
227
|
+
client: ClientDeclaration | null;
|
|
228
|
+
}
|
|
229
|
+
interface ProcessSnapshot {
|
|
230
|
+
reference: string;
|
|
231
|
+
identity: string;
|
|
232
|
+
name: string | null;
|
|
233
|
+
program: string;
|
|
234
|
+
programSnapshot?: ProgramSnapshot;
|
|
235
|
+
startedAt: string;
|
|
236
|
+
server: {
|
|
237
|
+
declared: boolean;
|
|
238
|
+
running: boolean;
|
|
239
|
+
};
|
|
240
|
+
client: {
|
|
241
|
+
declared: boolean;
|
|
242
|
+
running: boolean;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export type Program = SystemProgramEntity;
|
|
246
|
+
export declare const Program: typeof CoreProgram;
|
|
247
|
+
export type Process = SystemProcessEntity;
|
|
248
|
+
export declare const Process: typeof CoreProcess;
|
|
249
|
+
export type Endpoint<EventsMap extends object = {}> = SystemEndpointEntity<EventsMap>;
|
|
250
|
+
export declare const Endpoint: typeof CoreEndpoint;
|
|
251
|
+
export type Server<EventsMap extends object = {}> = SystemServerEntity<EventsMap>;
|
|
252
|
+
export declare const Server: typeof CoreServer;
|
|
253
|
+
export type Client<EventsMap extends object = {}> = SystemClientEntity<EventsMap>;
|
|
254
|
+
export declare const Client: typeof CoreClient;
|
|
255
|
+
export {};
|