@codeyam-editor/codeyam-editor 0.1.0-staging.0f231be

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/npm/utils.js ADDED
@@ -0,0 +1,623 @@
1
+ const { execSync, spawn, spawnSync } = require("child_process");
2
+ const net = require("net");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ const rootDir = path.resolve(__dirname, "..");
7
+ const serverStatePath = path.join(rootDir, ".codeyam", "server-state.json");
8
+
9
+ /**
10
+ * Map (process.platform, process.arch) → the platform sub-package that
11
+ * carries the matching native binary. Kept as a small data table so adding
12
+ * a new platform (e.g. linux/arm64) is one entry, not a new branch.
13
+ */
14
+ const PLATFORM_PACKAGES = {
15
+ "darwin-arm64": { pkg: "@codeyam-editor/codeyam-editor-darwin-arm64", binary: "codeyam-editor" },
16
+ "darwin-x64": { pkg: "@codeyam-editor/codeyam-editor-darwin-x64", binary: "codeyam-editor" },
17
+ "linux-x64": { pkg: "@codeyam-editor/codeyam-editor-linux-x64", binary: "codeyam-editor" },
18
+ "win32-x64": { pkg: "@codeyam-editor/codeyam-editor-win32-x64", binary: "codeyam-editor.exe" },
19
+ };
20
+
21
+ /**
22
+ * Platform-correct executable filename for the codeyam-editor binary.
23
+ * Windows requires the `.exe` extension; on Unix the binary has no extension.
24
+ * Accepts an explicit platform so the helper is testable across platforms.
25
+ */
26
+ function binaryName(platform = process.platform) {
27
+ return platform === "win32" ? "codeyam-editor.exe" : "codeyam-editor";
28
+ }
29
+
30
+ /** Look up the platform sub-package metadata for a given platform/arch pair. */
31
+ function platformPackageInfo(platform = process.platform, arch = process.arch) {
32
+ return PLATFORM_PACKAGES[`${platform}-${arch}`] || null;
33
+ }
34
+
35
+ /**
36
+ * Resolve the native binary path.
37
+ *
38
+ * Production install (npm install @codeyam-editor/codeyam-editor):
39
+ * npm installed the matching @codeyam-editor/codeyam-editor-<plat>-<arch>
40
+ * sub-package via optionalDependencies. require.resolve finds the binary
41
+ * inside that sibling package.
42
+ *
43
+ * Dev checkout (`cargo build` in the repo):
44
+ * No platform sub-package installed; fall through to target/debug or
45
+ * target/release.
46
+ *
47
+ * Returns null if no binary can be found at any of these locations — the
48
+ * caller (ensureBinary / cli.js) decides whether to error or to invoke
49
+ * `cargo build` based on whether a Cargo.toml is present.
50
+ */
51
+ function findBinary() {
52
+ const info = platformPackageInfo();
53
+ if (info) {
54
+ try {
55
+ const resolved = require.resolve(`${info.pkg}/bin/${info.binary}`, {
56
+ paths: [rootDir],
57
+ });
58
+ if (fs.existsSync(resolved)) return resolved;
59
+ } catch (e) {
60
+ if (e.code !== "MODULE_NOT_FOUND") throw e;
61
+ }
62
+ }
63
+
64
+ const name = binaryName();
65
+ const devCandidates = [
66
+ path.join(rootDir, "target", "debug", name),
67
+ path.join(rootDir, "target", "release", name),
68
+ ];
69
+ for (const candidate of devCandidates) {
70
+ if (fs.existsSync(candidate)) return candidate;
71
+ }
72
+
73
+ return null;
74
+ }
75
+
76
+ /**
77
+ * Return the binary path, building from source if we're in a dev checkout.
78
+ *
79
+ * Production install: if findBinary returns null, the platform sub-package
80
+ * is missing — npm install failed silently (likely because the user's
81
+ * platform isn't in the build matrix). Emit a clear, actionable error
82
+ * naming the expected sub-package, and exit 1. **Do not** fall through to
83
+ * `cargo build` — there's no Cargo.toml in the npm install dir, and the
84
+ * resulting "could not find Cargo.toml" error is misleading to users.
85
+ *
86
+ * Dev checkout: `Cargo.toml` is present at rootDir → run `cargo build`,
87
+ * same as the legacy behavior.
88
+ */
89
+ function ensureBinary() {
90
+ const existing = findBinary();
91
+ if (existing) return existing;
92
+
93
+ const isDevCheckout = fs.existsSync(path.join(rootDir, "Cargo.toml"));
94
+
95
+ if (!isDevCheckout) {
96
+ const info = platformPackageInfo();
97
+ if (!info) {
98
+ console.error(
99
+ `codeyam-editor: unsupported platform ${process.platform}/${process.arch}.\n` +
100
+ `Supported: darwin/arm64, darwin/x64, linux/x64, win32/x64.`
101
+ );
102
+ } else {
103
+ console.error(
104
+ `codeyam-editor: native binary missing.\n` +
105
+ `Expected at ${info.pkg}/bin/${info.binary} — npm should have installed ` +
106
+ `that sub-package as an optionalDependency.\n` +
107
+ `Try: npm install --force ${info.pkg}@$(npm view @codeyam-editor/codeyam-editor version)`
108
+ );
109
+ }
110
+ process.exit(1);
111
+ }
112
+
113
+ try {
114
+ execSync("cargo --version", { stdio: "ignore" });
115
+ } catch {
116
+ console.error(
117
+ "codeyam-editor binary not found and `cargo` is not on PATH. " +
118
+ "Install Rust from https://rustup.rs/ or reinstall @codeyam-editor/codeyam-editor."
119
+ );
120
+ process.exit(1);
121
+ }
122
+
123
+ console.error("Building codeyam-editor...");
124
+ try {
125
+ execSync("cargo build", { cwd: rootDir, stdio: "inherit" });
126
+ } catch {
127
+ console.error("Failed to build. Is Rust installed? https://rustup.rs/");
128
+ process.exit(1);
129
+ }
130
+
131
+ const binary = findBinary();
132
+ if (!binary) {
133
+ console.error("Binary not found after build.");
134
+ process.exit(1);
135
+ }
136
+ return binary;
137
+ }
138
+
139
+ /** Resolve the UI dist directory for the binary to serve. */
140
+ function uiDistDir() {
141
+ return path.join(rootDir, "ui", "dist");
142
+ }
143
+
144
+ function isPlainJsonObject(value) {
145
+ return value !== null && typeof value === "object" && !Array.isArray(value);
146
+ }
147
+
148
+ // Mirrors `deep_merge_json` in crates/types/src/config.rs:1284.
149
+ // Objects merge by key (`null` in overlay removes the key); arrays merge
150
+ // by index (extra overlay items appended, base items past overlay length
151
+ // retained); scalars replace. The JS and Rust sides MUST match — any
152
+ // divergence shows up as "the CLI sees port X but `npm run editor`
153
+ // opens port Y", which is exactly the bug this whole helper exists to
154
+ // prevent.
155
+ function deepMergeJson(base, overlay) {
156
+ if (isPlainJsonObject(base) && isPlainJsonObject(overlay)) {
157
+ for (const k of Object.keys(overlay)) {
158
+ const v = overlay[k];
159
+ if (v === null) {
160
+ delete base[k];
161
+ } else if (Object.prototype.hasOwnProperty.call(base, k)) {
162
+ base[k] = deepMergeJson(base[k], v);
163
+ } else {
164
+ base[k] = v;
165
+ }
166
+ }
167
+ return base;
168
+ }
169
+ if (Array.isArray(base) && Array.isArray(overlay)) {
170
+ for (let i = 0; i < overlay.length; i++) {
171
+ if (i < base.length) {
172
+ base[i] = deepMergeJson(base[i], overlay[i]);
173
+ } else {
174
+ base.push(overlay[i]);
175
+ }
176
+ }
177
+ return base;
178
+ }
179
+ return overlay;
180
+ }
181
+
182
+ // Mirrors the post-merge strip in `merged_config_value`
183
+ // (crates/types/src/config.rs:1272). Any top-level key starting with
184
+ // `_` is documentation-only (`_README`, `_examples`, …) and is removed
185
+ // before the merged config is used by the launcher or handed to the
186
+ // Rust binary. Mutates in place; returns the same object for chaining.
187
+ function stripUnderscoreTopLevelKeys(value) {
188
+ if (isPlainJsonObject(value)) {
189
+ for (const k of Object.keys(value)) {
190
+ if (k.startsWith("_")) delete value[k];
191
+ }
192
+ }
193
+ return value;
194
+ }
195
+
196
+ /**
197
+ * Read `<projectDir>/.codeyam/editor.json` and deep-merge an optional
198
+ * sibling `editor.local.json` on top, returning the merged plain object.
199
+ *
200
+ * This is the JS-side equivalent of `merged_config_value` in
201
+ * crates/types/src/config.rs — same merge rules, same underscore-prefix
202
+ * strip. Launcher scripts call this *before* the Rust binary is built
203
+ * (they invoke `cargo build` themselves), so shelling out to
204
+ * `codeyam-editor editor config-show` is not an option.
205
+ *
206
+ * Returns `{}` if the base file is missing (a freshly cloned repo with
207
+ * no `.codeyam/` directory should not throw at require-time). Throws
208
+ * on malformed JSON, naming the offending file path so the user knows
209
+ * which file to fix.
210
+ */
211
+ function readMergedEditorConfig(projectDir = rootDir) {
212
+ const basePath = path.join(projectDir, ".codeyam", "editor.json");
213
+ if (!fs.existsSync(basePath)) return {};
214
+
215
+ let merged;
216
+ try {
217
+ merged = JSON.parse(fs.readFileSync(basePath, "utf8"));
218
+ } catch (e) {
219
+ throw new Error(`Failed to parse ${basePath}: ${e.message}`);
220
+ }
221
+ if (!isPlainJsonObject(merged)) merged = {};
222
+
223
+ const overlayPath = path.join(projectDir, ".codeyam", "editor.local.json");
224
+ if (fs.existsSync(overlayPath)) {
225
+ let overlay;
226
+ try {
227
+ overlay = JSON.parse(fs.readFileSync(overlayPath, "utf8"));
228
+ } catch (e) {
229
+ throw new Error(`Failed to parse ${overlayPath}: ${e.message}`);
230
+ }
231
+ if (isPlainJsonObject(overlay)) {
232
+ deepMergeJson(merged, overlay);
233
+ }
234
+ }
235
+
236
+ return stripUnderscoreTopLevelKeys(merged);
237
+ }
238
+
239
+ /**
240
+ * Resolve a port for a launcher in priority order:
241
+ * explicit env var → merged-config value → hard fallback.
242
+ *
243
+ * Exported so each launcher's port resolution can be unit-tested
244
+ * without spawning a process. The fallback is the historical hard-coded
245
+ * value (14199 / 5173 / 3000 depending on which slot the caller is
246
+ * resolving) and exists so a fresh checkout with no override file and
247
+ * no env var still works.
248
+ */
249
+ function resolveLauncherPort(envValue, mergedValue, fallback) {
250
+ if (envValue !== undefined && envValue !== null && envValue !== "") {
251
+ const parsed = parseInt(envValue, 10);
252
+ if (Number.isFinite(parsed)) return parsed;
253
+ }
254
+ if (typeof mergedValue === "number" && Number.isFinite(mergedValue)) {
255
+ return mergedValue;
256
+ }
257
+ return fallback;
258
+ }
259
+
260
+ /** Try to connect to a specific host:port. Returns true if something is listening. */
261
+ function tryConnect(port, host) {
262
+ return new Promise((resolve) => {
263
+ const socket = new net.Socket();
264
+ socket.setTimeout(300);
265
+ socket.once("connect", () => { socket.destroy(); resolve(true); });
266
+ socket.once("error", () => { socket.destroy(); resolve(false); });
267
+ socket.once("timeout", () => { socket.destroy(); resolve(false); });
268
+ socket.connect(port, host);
269
+ });
270
+ }
271
+
272
+ /** Check if a port is in use (tries both IPv4 and IPv6). */
273
+ async function isPortInUse(port) {
274
+ return (await tryConnect(port, "127.0.0.1")) || (await tryConnect(port, "::1"));
275
+ }
276
+
277
+ /**
278
+ * Poll a port until something is listening, or timeout.
279
+ * Returns true if the port became active, false on timeout.
280
+ */
281
+ async function waitForPort(port, timeoutMs = 10000, intervalMs = 200) {
282
+ const deadline = Date.now() + timeoutMs;
283
+ while (Date.now() < deadline) {
284
+ if (await isPortInUse(port)) return true;
285
+ await new Promise((r) => setTimeout(r, intervalMs));
286
+ }
287
+ return false;
288
+ }
289
+
290
+ /**
291
+ * Poll until a port stops listening, or timeout.
292
+ * Returns true if the port became inactive, false on timeout.
293
+ */
294
+ async function waitForPortToClose(port, timeoutMs = 10000, intervalMs = 200) {
295
+ const deadline = Date.now() + timeoutMs;
296
+ while (Date.now() < deadline) {
297
+ if (!(await isPortInUse(port))) return true;
298
+ await new Promise((r) => setTimeout(r, intervalMs));
299
+ }
300
+ return false;
301
+ }
302
+
303
+ function readServerState() {
304
+ try {
305
+ return JSON.parse(fs.readFileSync(serverStatePath, "utf8"));
306
+ } catch {
307
+ return null;
308
+ }
309
+ }
310
+
311
+ function clearServerState() {
312
+ try {
313
+ fs.unlinkSync(serverStatePath);
314
+ } catch {}
315
+ }
316
+
317
+ // Default ports across stopServer / restartServer / ensureServer /
318
+ // requestServerShutdown are a backstop for any future caller that
319
+ // forgets to pass an explicit port. Every production call site now
320
+ // resolves the port from `readMergedEditorConfig` + `resolveLauncherPort`.
321
+ async function requestServerShutdown(port = 14199, timeoutMs = 1500) {
322
+ const controller = new AbortController();
323
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
324
+
325
+ try {
326
+ const resp = await fetch(`http://127.0.0.1:${port}/api/editor-server/shutdown`, {
327
+ method: "POST",
328
+ signal: controller.signal,
329
+ });
330
+ return resp.ok;
331
+ } catch {
332
+ return false;
333
+ } finally {
334
+ clearTimeout(timeout);
335
+ }
336
+ }
337
+
338
+ /**
339
+ * GET /api/codeyam-server-identity from the listener on `port` with a
340
+ * sub-second timeout. Returns the parsed `{projectDir, pid, version,
341
+ * startedAt}` body on a 2xx response, or `null` on any failure
342
+ * (timeout, non-200, parse failure, connection refused).
343
+ *
344
+ * `null` carries two distinct meanings that the caller must
345
+ * disambiguate by also checking `isPortInUse`:
346
+ * - port is free → no listener at all
347
+ * - port is in use → something is listening, but it's not a
348
+ * codeyam-editor server (or it's an old build that predates this
349
+ * endpoint).
350
+ */
351
+ async function fetchServerIdentity(port, timeoutMs = 500) {
352
+ const controller = new AbortController();
353
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
354
+
355
+ try {
356
+ const resp = await fetch(`http://127.0.0.1:${port}/api/codeyam-server-identity`, {
357
+ method: "GET",
358
+ signal: controller.signal,
359
+ });
360
+ if (!resp.ok) return null;
361
+ const body = await resp.json();
362
+ if (!body || typeof body !== "object" || typeof body.projectDir !== "string") {
363
+ return null;
364
+ }
365
+ return body;
366
+ } catch {
367
+ return null;
368
+ } finally {
369
+ clearTimeout(timeout);
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Resolve the canonical (symlink-followed) path for `dir`, falling back to
375
+ * `dir` if `fs.realpath` fails (e.g. the path no longer exists). Both
376
+ * sides of the identity check route through this so a `~/work/foo`
377
+ * symlink and a `/Volumes/dev/foo` direct path compare equal.
378
+ */
379
+ async function canonicalisePath(dir) {
380
+ try {
381
+ return await fs.promises.realpath(dir);
382
+ } catch {
383
+ return dir;
384
+ }
385
+ }
386
+
387
+ /**
388
+ * Build the "port held by a non-codeyam-editor process" error string.
389
+ * Lives next to `classifyPortHolder` so the wording is tested without
390
+ * a running server — both launchers (`ensureServer` and `editor.js`'s
391
+ * `--restart`) print this exact message on a "foreign" classification.
392
+ */
393
+ function formatForeignListenerError(port) {
394
+ return (
395
+ `Port ${port} is in use, but no codeyam-editor server responded ` +
396
+ `at /api/codeyam-server-identity. Free the port or change ` +
397
+ `controlPort in .codeyam/editor.local.json.`
398
+ );
399
+ }
400
+
401
+ /**
402
+ * Build the "another project's editor is on this port" error string.
403
+ * `verb` is the action the launcher would have taken ("attach" /
404
+ * "restart"); the wording is otherwise identical so both launcher
405
+ * paths share the same advice.
406
+ */
407
+ function formatCrossProjectError(port, holder, verb) {
408
+ const pidNote = Number.isInteger(holder.identity && holder.identity.pid)
409
+ ? ` (pid ${holder.identity.pid})`
410
+ : "";
411
+ return (
412
+ `Refusing to ${verb} a codeyam-editor server for a different project.\n` +
413
+ ` This project: ${holder.wantDir}\n` +
414
+ ` Server on port ${port}${pidNote}: ${holder.haveDir}\n` +
415
+ `\n` +
416
+ `Change controlPort in .codeyam/editor.local.json, e.g.:\n` +
417
+ ` codeyam-editor editor config-override proxy.controlPort 14399`
418
+ );
419
+ }
420
+
421
+ /**
422
+ * Classify whatever is listening on `port` relative to `projectDir`.
423
+ * Returns one of:
424
+ * - `{ kind: "free" }` — nothing on the port
425
+ * - `{ kind: "foreign" }` — port held by a non-editor process
426
+ * - `{ kind: "cross-project", wantDir, haveDir, identity }`
427
+ * — held by another project's editor
428
+ * - `{ kind: "same-project", identity }` — held by THIS project's editor
429
+ *
430
+ * Pure: every effect (network, fs) is bounded; no console output, no
431
+ * process.exit. The launcher decides what to do with each kind. Splitting
432
+ * the policy (what to print, when to exit) from the classification keeps
433
+ * the helper testable without mocking process.exit, and lets `ensureServer`
434
+ * and `editor.js`'s `--restart` block share the same logic with different
435
+ * wording.
436
+ */
437
+ async function classifyPortHolder(port, projectDir = process.cwd()) {
438
+ if (!(await isPortInUse(port))) {
439
+ return { kind: "free" };
440
+ }
441
+ const identity = await fetchServerIdentity(port);
442
+ if (identity === null) {
443
+ return { kind: "foreign" };
444
+ }
445
+ const wantDir = await canonicalisePath(projectDir);
446
+ const haveDir = await canonicalisePath(identity.projectDir);
447
+ if (wantDir !== haveDir) {
448
+ return { kind: "cross-project", wantDir, haveDir, identity };
449
+ }
450
+ return { kind: "same-project", identity };
451
+ }
452
+
453
+ function tryKillPid(pid) {
454
+ try {
455
+ // On Windows, `process.kill(pid, "SIGINT")` either errors or no-ops
456
+ // depending on Node version. Drop the signal so Node maps to a
457
+ // platform TerminateProcess. Less graceful, but the child does exit.
458
+ if (process.platform === "win32") {
459
+ process.kill(pid);
460
+ } else {
461
+ process.kill(pid, "SIGINT");
462
+ }
463
+ return true;
464
+ } catch {
465
+ return false;
466
+ }
467
+ }
468
+
469
+ /**
470
+ * Send the platform-correct termination signal to a spawned child process.
471
+ * Used by editor.js / editor-dev.js / container.js when the user hits Ctrl+C —
472
+ * `child.kill("SIGINT")` is unreliable on Windows.
473
+ */
474
+ function killChildProcess(child) {
475
+ if (!child) return;
476
+ if (process.platform === "win32") {
477
+ child.kill();
478
+ } else {
479
+ child.kill("SIGINT");
480
+ }
481
+ }
482
+
483
+ function findListeningPids(port) {
484
+ // Process discovery on Windows is best-effort — `lsof` is not installed and
485
+ // a `netstat -ano` parser is a follow-up. The API-shutdown path and the
486
+ // PID-file path together stop the server cleanly in normal operation.
487
+ if (process.platform === "win32") return [];
488
+
489
+ const result = spawnSync("lsof", [`-tiTCP:${port}`, "-sTCP:LISTEN"], {
490
+ encoding: "utf8",
491
+ });
492
+
493
+ if (result.error) return [];
494
+
495
+ return result.stdout
496
+ .split(/\s+/)
497
+ .map((line) => parseInt(line, 10))
498
+ .filter((pid) => Number.isInteger(pid));
499
+ }
500
+
501
+ /** Stop the Rust backend server if it is running. */
502
+ async function stopServer(port = 14199) {
503
+ if (!(await isPortInUse(port))) {
504
+ clearServerState();
505
+ return false;
506
+ }
507
+
508
+ if (await requestServerShutdown(port)) {
509
+ if (await waitForPortToClose(port, 10000, 200)) {
510
+ clearServerState();
511
+ return true;
512
+ }
513
+ }
514
+
515
+ const state = readServerState();
516
+ if (state && Number.isInteger(state.pid) && tryKillPid(state.pid)) {
517
+ if (await waitForPortToClose(port, 5000, 200)) {
518
+ clearServerState();
519
+ return true;
520
+ }
521
+ }
522
+
523
+ for (const pid of findListeningPids(port)) {
524
+ tryKillPid(pid);
525
+ }
526
+
527
+ if (await waitForPortToClose(port, 5000, 200)) {
528
+ clearServerState();
529
+ return true;
530
+ }
531
+
532
+ throw new Error(`Server on port ${port} did not stop cleanly`);
533
+ }
534
+
535
+ /** Stop any existing server on the port, then start a fresh one. */
536
+ async function restartServer(port = 14199) {
537
+ if (await isPortInUse(port)) {
538
+ console.error(`Stopping existing server on port ${port}...`);
539
+ await stopServer(port);
540
+ }
541
+ return ensureServer(port);
542
+ }
543
+
544
+ /**
545
+ * Start the Rust backend server if not already running, refusing to attach
546
+ * if the existing listener belongs to a different project (or to a foreign
547
+ * process that doesn't speak the identity endpoint at all). Returns the
548
+ * spawned child on a fresh start, or `null` when we attached to an
549
+ * already-running same-project server. Exits the process non-zero on a
550
+ * mismatch — silently choosing a different port would just relocate the
551
+ * surprise.
552
+ */
553
+ async function ensureServer(port = 14199) {
554
+ const holder = await classifyPortHolder(port);
555
+ switch (holder.kind) {
556
+ case "foreign":
557
+ console.error(formatForeignListenerError(port));
558
+ process.exit(1);
559
+ break;
560
+ case "cross-project":
561
+ console.error(formatCrossProjectError(port, holder, "attach"));
562
+ process.exit(1);
563
+ break;
564
+ case "same-project":
565
+ console.error(`Server already running on port ${port}`);
566
+ return null;
567
+ case "free":
568
+ default:
569
+ break;
570
+ }
571
+
572
+ const binary = ensureBinary();
573
+ // UI bundle is embedded in the Rust binary; CODEYAM_EDITOR_UI_DIR is
574
+ // now an explicit dev-override only.
575
+ const child = spawn(binary, ["start", "--no-open", "--port", String(port)], {
576
+ stdio: "inherit",
577
+ cwd: process.cwd(),
578
+ detached: false,
579
+ env: process.env,
580
+ });
581
+
582
+ const ready = await waitForPort(port);
583
+ if (!ready) {
584
+ console.error("Server failed to start within 10 seconds");
585
+ child.kill();
586
+ process.exit(1);
587
+ }
588
+
589
+ return child;
590
+ }
591
+
592
+ module.exports = {
593
+ rootDir,
594
+ serverStatePath,
595
+ binaryName,
596
+ platformPackageInfo,
597
+ PLATFORM_PACKAGES,
598
+ findBinary,
599
+ ensureBinary,
600
+ uiDistDir,
601
+ tryConnect,
602
+ isPortInUse,
603
+ waitForPort,
604
+ waitForPortToClose,
605
+ readServerState,
606
+ clearServerState,
607
+ requestServerShutdown,
608
+ fetchServerIdentity,
609
+ canonicalisePath,
610
+ classifyPortHolder,
611
+ formatForeignListenerError,
612
+ formatCrossProjectError,
613
+ tryKillPid,
614
+ findListeningPids,
615
+ stopServer,
616
+ restartServer,
617
+ ensureServer,
618
+ killChildProcess,
619
+ deepMergeJson,
620
+ stripUnderscoreTopLevelKeys,
621
+ readMergedEditorConfig,
622
+ resolveLauncherPort,
623
+ };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@codeyam-editor/codeyam-editor",
3
+ "version": "0.1.0-staging.0f231be",
4
+ "description": "Language-agnostic managed execution sandbox for scenario-driven development",
5
+ "bin": {
6
+ "codeyam-editor": "./npm/cli.js"
7
+ },
8
+ "dependencies": {
9
+ "playwright": "^1.58.2"
10
+ },
11
+ "optionalDependencies": {
12
+ "@codeyam-editor/codeyam-editor-darwin-arm64": "0.1.0-staging.0f231be",
13
+ "@codeyam-editor/codeyam-editor-darwin-x64": "0.1.0-staging.0f231be",
14
+ "@codeyam-editor/codeyam-editor-linux-x64": "0.1.0-staging.0f231be",
15
+ "@codeyam-editor/codeyam-editor-win32-x64": "0.1.0-staging.0f231be"
16
+ },
17
+ "keywords": [
18
+ "codeyam",
19
+ "editor",
20
+ "development",
21
+ "scenarios"
22
+ ],
23
+ "homepage": "https://codeyam.com/",
24
+ "license": "MIT",
25
+ "engines": {
26
+ "node": ">=20.0.0"
27
+ },
28
+ "files": [
29
+ "npm/",
30
+ "ui/"
31
+ ]
32
+ }