@phreshos/node 0.1.18 → 0.1.20

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/project.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isRelativeValue, layers, } from "@phreshos/core";
1
+ import { isRelativeValue, parseLaunch, 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";
@@ -66,6 +66,9 @@ export class Project {
66
66
  name: config.name,
67
67
  version: config.version,
68
68
  description: config.description,
69
+ options: config.options,
70
+ startup: config.startup,
71
+ launch: config.launch,
69
72
  categories: config.categories,
70
73
  keywords: config.keywords,
71
74
  website: config.website,
@@ -219,6 +222,11 @@ function clientHalf(half, mode, developmentUrl) {
219
222
  : declared;
220
223
  }
221
224
  function validateConfig(config) {
225
+ parseLaunch({ options: config.options });
226
+ if (config.startup !== undefined && typeof config.startup !== "boolean")
227
+ parseLaunch(config.startup);
228
+ if (config.launch !== undefined && config.launch !== true)
229
+ parseLaunch(config.launch);
222
230
  if (typeof config.identity !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(config.identity)) {
223
231
  throw new Error("A Program's identity must be kebab-case");
224
232
  }
@@ -315,6 +323,9 @@ function packageDefinition(config, version) {
315
323
  name: config.name,
316
324
  version,
317
325
  description: config.description,
326
+ options: config.options,
327
+ startup: config.startup,
328
+ launch: config.launch,
318
329
  icon: config.icon ? "icon.png" : undefined,
319
330
  agent: config.agent ? "agent.md" : undefined,
320
331
  categories: config.categories,
package/dist/system.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ClientEndpoint as CoreClientEndpoint, ClientService as CoreClientService, Process as CoreProcess, Program as CoreProgram, ServerEndpoint as CoreServerEndpoint, ServerService as CoreServerService, isServiceKey, parseEndpointReference } from "@phreshos/core";
1
+ import { ClientEndpoint as CoreClientEndpoint, ClientService as CoreClientService, Process as CoreProcess, Program as CoreProgram, ServerEndpoint as CoreServerEndpoint, ServerService as CoreServerService, isServiceKey, parseEndpointReference, parseLaunch } from "@phreshos/core";
2
2
  import { homedir } from "node:os";
3
3
  import { gatewayAddress } from "./address.js";
4
4
  import Events from "./events.js";
@@ -161,6 +161,7 @@ class ProgramHandle extends CoreProgram {
161
161
  database;
162
162
  process;
163
163
  startup;
164
+ launch;
164
165
  permissions;
165
166
  snapshot;
166
167
  constructor(system, snapshot) {
@@ -187,6 +188,7 @@ class ProgramHandle extends CoreProgram {
187
188
  this.database = programSql(call, address, "database");
188
189
  this.process = new ProgramProcesses(system, this);
189
190
  this.startup = new ProgramStartup(system, this);
191
+ this.launch = new ProgramLaunch(system, this);
190
192
  this.permissions = programPermissions(call, address);
191
193
  }
192
194
  get name() { return this.snapshot.name; }
@@ -223,15 +225,26 @@ class ProgramHandle extends CoreProgram {
223
225
  }
224
226
  install() { return command(this.system, "install", this.address()); }
225
227
  uninstall(everything = false) { return command(this.system, "uninstall", this.address(), everything); }
226
- async fork(identity) {
227
- const created = await representation(this.system).call("/program/fork-program", this.address(), identity);
228
- return programHandle(this.system, required(representation(this.system).programs.get(created), created));
229
- }
230
228
  async forget() {
231
229
  await representation(this.system).call("/program/forget-program", this.address(), "");
232
230
  }
233
231
  address() { return Object.freeze({ identity: this.identity, reference: this.reference }); }
234
232
  }
233
+ class ProgramLaunch {
234
+ system;
235
+ program;
236
+ constructor(system, program) {
237
+ this.system = system;
238
+ this.program = program;
239
+ }
240
+ async get() {
241
+ const value = await representation(this.system).call("/program/launch", this.program.address(), "get");
242
+ return value === null ? null : parseLaunch(value);
243
+ }
244
+ async set(launch) {
245
+ await representation(this.system).call("/program/launch", this.program.address(), "set", parseLaunch(launch));
246
+ }
247
+ }
235
248
  class ProgramStartup {
236
249
  system;
237
250
  program;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/node",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Node.js access to PhreshOS and Program projects.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -42,10 +42,10 @@
42
42
  "jiti": "^2.7.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@phreshos/core": "^0.1.43"
45
+ "@phreshos/core": "^0.1.45"
46
46
  },
47
47
  "devDependencies": {
48
- "@phreshos/core": "^0.1.43",
48
+ "@phreshos/core": "^0.1.45",
49
49
  "@types/adm-zip": "^0.5.8",
50
50
  "@types/node": "^26.2.0",
51
51
  "typescript": "^6.0.3",