ptywright 0.4.0 → 0.6.0

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/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as main } from "./cli-C40H_ElC.mjs";
1
+ import { t as main } from "./cli-IXmvK56U.mjs";
2
2
  export { main };
package/dist/config.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as loadPtywrightConfig, t as defineConfig } from "./config-B0r-JCFI.mjs";
1
+ import { n as loadPtywrightConfig, t as defineConfig } from "./config-bGg636EW.mjs";
2
2
  export { defineConfig, loadPtywrightConfig };
@@ -0,0 +1,18 @@
1
+ import { Buffer } from "node:buffer";
2
+ //#region src/pty-cassette/data.ts
3
+ function dataToBytes(data) {
4
+ if (typeof data === "string") return Buffer.from(data, "utf8");
5
+ if (data instanceof ArrayBuffer) return new Uint8Array(data);
6
+ return data;
7
+ }
8
+ function dataToBase64(data) {
9
+ return Buffer.from(dataToBytes(data)).toString("base64");
10
+ }
11
+ function base64ToBytes(dataBase64) {
12
+ return Buffer.from(dataBase64, "base64");
13
+ }
14
+ function byteLength(data) {
15
+ return dataToBytes(data).byteLength;
16
+ }
17
+ //#endregion
18
+ export { dataToBytes as i, byteLength as n, dataToBase64 as r, base64ToBytes as t };
@@ -0,0 +1,36 @@
1
+ import { dirname, isAbsolute, relative, resolve } from "node:path";
2
+ //#region src/common/path.ts
3
+ function samePath(left, right) {
4
+ return resolve(process.cwd(), left) === resolve(process.cwd(), right);
5
+ }
6
+ function portablePath(path, rootDir) {
7
+ const rel = relative(rootDir, path);
8
+ if (rel && !rel.startsWith("..") && !isAbsolute(rel)) return rel;
9
+ return path;
10
+ }
11
+ function portableCliPath(path) {
12
+ return portablePath(resolve(process.cwd(), path), process.cwd());
13
+ }
14
+ function normalizePath(path) {
15
+ return path.replace(/\\/g, "/");
16
+ }
17
+ function relativeHref(fromFile, toFile) {
18
+ const normalized = normalizePath(relative(dirname(fromFile), toFile));
19
+ return normalized.startsWith(".") ? normalized : `./${normalized}`;
20
+ }
21
+ //#endregion
22
+ //#region src/common/env.ts
23
+ function envTruthy(value) {
24
+ if (!value?.trim()) return false;
25
+ const normalized = value.trim().toLowerCase();
26
+ return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
27
+ }
28
+ function mergeProcessEnv(base, override) {
29
+ const env = {};
30
+ for (const [key, value] of Object.entries(process.env)) if (typeof value === "string") env[key] = value;
31
+ for (const [key, value] of Object.entries(base)) env[key] = value;
32
+ if (override) for (const [key, value] of Object.entries(override)) env[key] = value;
33
+ return env;
34
+ }
35
+ //#endregion
36
+ export { portablePath as a, portableCliPath as i, mergeProcessEnv as n, relativeHref as o, normalizePath as r, samePath as s, envTruthy as t };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createPtywrightServer } from "./server-h--2U0Ic.mjs";
1
+ import { t as createPtywrightServer } from "./server-ceZ1-s_J.mjs";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  //#region src/index.ts
4
4
  const { server, sessions } = createPtywrightServer();
@@ -0,0 +1,77 @@
1
+ import { a as portablePath } from "./env-DPYHo-zH.mjs";
2
+ import { readFileSync, statSync } from "node:fs";
3
+ import { dirname, isAbsolute, resolve } from "node:path";
4
+ import { createHash } from "node:crypto";
5
+ //#region src/common/compare.ts
6
+ function sameStringList(left, right) {
7
+ return left.length === right.length && left.every((value, index) => value === right[index]);
8
+ }
9
+ function sameArgv(left, right) {
10
+ return sameStringList(left, right);
11
+ }
12
+ function diffCommandMaps(args) {
13
+ const failures = [];
14
+ const actualNames = Object.keys(args.actual).sort();
15
+ const expectedNames = Object.keys(args.expected).sort();
16
+ if (!sameStringList(actualNames, expectedNames)) failures.push(args.onNameMismatch(expectedNames));
17
+ for (const [name, command] of Object.entries(args.expected)) {
18
+ const actualCommand = args.actual[name];
19
+ if (!actualCommand) continue;
20
+ if (!sameArgv(actualCommand.argv, command.argv)) failures.push(args.onArgvMismatch(name, command.argv));
21
+ }
22
+ return failures;
23
+ }
24
+ //#endregion
25
+ //#region src/common/zod.ts
26
+ function formatZodIssues(error) {
27
+ return error.issues.map((issue) => {
28
+ return `${issue.path.length ? issue.path.join(".") : "<root>"}: ${issue.message}`;
29
+ }).join("; ");
30
+ }
31
+ //#endregion
32
+ //#region src/common/manifest_files.ts
33
+ function collectManifestFiles(files, rootDir) {
34
+ const out = [];
35
+ const seen = /* @__PURE__ */ new Set();
36
+ const rootAbs = resolve(process.cwd(), rootDir);
37
+ for (const file of files) {
38
+ if (!file.path || seen.has(file.path)) continue;
39
+ seen.add(file.path);
40
+ try {
41
+ out.push(readManifestFile(file, rootAbs, { portableRoot: true }));
42
+ } catch {}
43
+ }
44
+ return out.sort((a, b) => a.path.localeCompare(b.path));
45
+ }
46
+ function validateManifestFiles(args) {
47
+ const failures = [];
48
+ const baseDir = args.manifestPath ? dirname(resolve(process.cwd(), args.manifestPath)) : resolve(process.cwd(), args.rootDir);
49
+ for (const file of args.files) {
50
+ let current = null;
51
+ try {
52
+ current = readManifestFile(file, baseDir);
53
+ } catch (error) {
54
+ failures.push(`${file.path}: ${error instanceof Error ? error.message : String(error)}`);
55
+ continue;
56
+ }
57
+ if (current.bytes !== file.bytes) failures.push(`${file.path}: bytes ${current.bytes} !== ${file.bytes}`);
58
+ if (current.sha256 !== file.sha256) failures.push(`${file.path}: sha256 ${current.sha256} !== ${file.sha256}`);
59
+ }
60
+ if (failures.length > 0) throw new Error(`invalid ${args.label} manifest files: ${failures.join("; ")}`);
61
+ }
62
+ function readManifestFile(file, baseDir, options = {}) {
63
+ if (!file.path) throw new Error("missing file path");
64
+ const absPath = isAbsolute(file.path) ? file.path : resolve(options.portableRoot ? process.cwd() : baseDir, file.path);
65
+ if (!statSync(absPath).isFile()) throw new Error("not a file");
66
+ const bytes = readFileSync(absPath);
67
+ return {
68
+ path: options.portableRoot ? portablePath(absPath, baseDir) : file.path,
69
+ kind: file.kind,
70
+ role: file.role,
71
+ ok: file.ok,
72
+ bytes: bytes.byteLength,
73
+ sha256: createHash("sha256").update(bytes).digest("hex")
74
+ };
75
+ }
76
+ //#endregion
77
+ export { sameArgv as a, diffCommandMaps as i, validateManifestFiles as n, formatZodIssues as r, collectManifestFiles as t };
package/dist/mcp.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createPtywrightServer } from "./server-h--2U0Ic.mjs";
1
+ import { t as createPtywrightServer } from "./server-ceZ1-s_J.mjs";
2
2
  export { createPtywrightServer };
@@ -1,4 +1,5 @@
1
- import { S as dataToBytes, _ as ptyCassetteSchema, a as inspectPtyCassette, b as byteLength, c as createPtyCassetteReplay, d as PTY_CASSETTE_SCHEMA_URL, f as normalizePtyCassette, g as ptyCassetteResizeEventSchema, h as ptyCassetteExitEventSchema, i as formatPtyCassetteInspectLines, l as readPtyCassettePath, m as ptyCassetteEventSchema, n as PtyCassetteRecorder, o as inspectPtyCassettePath, p as ptyCassetteDataEventSchema, r as createPtyCassetteRecorder, s as PtyCassetteReplay, t as wrapPtyLike, u as writePtyCassettePath, v as validatePtyCassette, x as dataToBase64, y as base64ToBytes } from "./pty_like-DqCo7XdB.mjs";
1
+ import { i as dataToBytes, n as byteLength, r as dataToBase64, t as base64ToBytes } from "./data-sdbf3IDh.mjs";
2
+ import { _ as ptyCassetteSchema, a as inspectPtyCassette, c as createPtyCassetteReplay, d as PTY_CASSETTE_SCHEMA_URL, f as normalizePtyCassette, g as ptyCassetteResizeEventSchema, h as ptyCassetteExitEventSchema, i as formatPtyCassetteInspectLines, l as readPtyCassettePath, m as ptyCassetteEventSchema, n as PtyCassetteRecorder, o as inspectPtyCassettePath, p as ptyCassetteDataEventSchema, r as createPtyCassetteRecorder, s as PtyCassetteReplay, t as wrapPtyLike, u as writePtyCassettePath, v as validatePtyCassette } from "./pty_like-DWIlWGgA.mjs";
2
3
  //#region src/pty-cassette/bun_terminal.ts
3
4
  function wrapBunTerminalOptions(options, recorder) {
4
5
  const onData = options.data;
@@ -1,23 +1,7 @@
1
- import { z } from "zod";
2
- import { dirname } from "node:path";
1
+ import { n as byteLength, r as dataToBase64, t as base64ToBytes } from "./data-sdbf3IDh.mjs";
3
2
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
- import { Buffer } from "node:buffer";
5
- //#region src/pty-cassette/data.ts
6
- function dataToBytes(data) {
7
- if (typeof data === "string") return Buffer.from(data, "utf8");
8
- if (data instanceof ArrayBuffer) return new Uint8Array(data);
9
- return data;
10
- }
11
- function dataToBase64(data) {
12
- return Buffer.from(dataToBytes(data)).toString("base64");
13
- }
14
- function base64ToBytes(dataBase64) {
15
- return Buffer.from(dataBase64, "base64");
16
- }
17
- function byteLength(data) {
18
- return dataToBytes(data).byteLength;
19
- }
20
- //#endregion
3
+ import { dirname } from "node:path";
4
+ import { z } from "zod";
21
5
  //#region src/pty-cassette/schema.ts
22
6
  const PTY_CASSETTE_SCHEMA_URL = "https://ptywright.local/schemas/ptywright-pty-cassette.schema.json";
23
7
  const base64Schema = z.string().refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(value), { message: "expected base64-encoded data" });
@@ -401,4 +385,4 @@ function dispose(disposable) {
401
385
  disposable.dispose();
402
386
  }
403
387
  //#endregion
404
- export { dataToBytes as S, ptyCassetteSchema as _, inspectPtyCassette as a, byteLength as b, createPtyCassetteReplay as c, PTY_CASSETTE_SCHEMA_URL as d, normalizePtyCassette as f, ptyCassetteResizeEventSchema as g, ptyCassetteExitEventSchema as h, formatPtyCassetteInspectLines as i, readPtyCassettePath as l, ptyCassetteEventSchema as m, PtyCassetteRecorder as n, inspectPtyCassettePath as o, ptyCassetteDataEventSchema as p, createPtyCassetteRecorder as r, PtyCassetteReplay as s, wrapPtyLike as t, writePtyCassettePath as u, validatePtyCassette as v, dataToBase64 as x, base64ToBytes as y };
388
+ export { ptyCassetteSchema as _, inspectPtyCassette as a, createPtyCassetteReplay as c, PTY_CASSETTE_SCHEMA_URL as d, normalizePtyCassette as f, ptyCassetteResizeEventSchema as g, ptyCassetteExitEventSchema as h, formatPtyCassetteInspectLines as i, readPtyCassettePath as l, ptyCassetteEventSchema as m, PtyCassetteRecorder as n, inspectPtyCassettePath as o, ptyCassetteDataEventSchema as p, createPtyCassetteRecorder as r, PtyCassetteReplay as s, wrapPtyLike as t, writePtyCassettePath as u, validatePtyCassette as v };