@poe-platform/safe-bash 0.1.635 → 0.1.636

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.
Files changed (33) hide show
  1. package/dist/safe-bash/commands/playwright/index.d.ts +12 -0
  2. package/dist/safe-bash/commands/playwright/index.d.ts.map +1 -0
  3. package/dist/safe-bash/commands/playwright/index.js +47 -0
  4. package/dist/safe-bash/commands/playwright/index.js.map +1 -0
  5. package/dist/safe-bash/contracts/playwright.d.ts +71 -0
  6. package/dist/safe-bash/contracts/playwright.d.ts.map +1 -0
  7. package/dist/safe-bash/contracts/playwright.js +2 -0
  8. package/dist/safe-bash/contracts/playwright.js.map +1 -0
  9. package/dist/safe-bash/playwright/adapter.d.ts +97 -0
  10. package/dist/safe-bash/playwright/adapter.d.ts.map +1 -0
  11. package/dist/safe-bash/playwright/adapter.js +123 -0
  12. package/dist/safe-bash/playwright/adapter.js.map +1 -0
  13. package/dist/safe-bash/playwright/billing.d.ts +71 -0
  14. package/dist/safe-bash/playwright/billing.d.ts.map +1 -0
  15. package/dist/safe-bash/playwright/billing.js +2 -0
  16. package/dist/safe-bash/playwright/billing.js.map +1 -0
  17. package/dist/safe-bash/playwright/controller.d.ts +21 -0
  18. package/dist/safe-bash/playwright/controller.d.ts.map +1 -0
  19. package/dist/safe-bash/playwright/controller.js +369 -0
  20. package/dist/safe-bash/playwright/controller.js.map +1 -0
  21. package/dist/safe-bash/playwright/index.d.ts +5 -0
  22. package/dist/safe-bash/playwright/index.d.ts.map +1 -0
  23. package/dist/safe-bash/playwright/index.js +4 -0
  24. package/dist/safe-bash/playwright/index.js.map +1 -0
  25. package/dist/safe-bash/playwright/invocation.d.ts +26 -0
  26. package/dist/safe-bash/playwright/invocation.d.ts.map +1 -0
  27. package/dist/safe-bash/playwright/invocation.js +112 -0
  28. package/dist/safe-bash/playwright/invocation.js.map +1 -0
  29. package/dist/safe-bash/playwright/snapshot.d.ts +15 -0
  30. package/dist/safe-bash/playwright/snapshot.d.ts.map +1 -0
  31. package/dist/safe-bash/playwright/snapshot.js +96 -0
  32. package/dist/safe-bash/playwright/snapshot.js.map +1 -0
  33. package/package.json +12 -2
@@ -0,0 +1,96 @@
1
+ /** Public element handles only. Shared by regular and Cloudflare injected pages.
2
+ * This is a DOM interaction summary, not the full Playwright CLI accessibility tree.
3
+ * Guest text is never compiled or evaluated as a locator or browser program.
4
+ */
5
+ export function createSnapshotEngine(limits, nextRef) {
6
+ for (const value of [limits?.maxSnapshotBytes, limits?.maxSnapshotRefs])
7
+ if (!Number.isSafeInteger(value) || value < 1)
8
+ throw new RangeError('Invalid snapshot limit');
9
+ const { maxSnapshotBytes, maxSnapshotRefs } = limits;
10
+ let sequence = 0;
11
+ let epoch = 0;
12
+ const retirements = new Set();
13
+ const refs = new Map();
14
+ const invalidate = async () => {
15
+ epoch++;
16
+ const handles = [...refs.values()];
17
+ refs.clear();
18
+ const tasks = [...new Set(handles)].map(handle => Promise.resolve().then(() => handle.dispose()));
19
+ for (const task of tasks) {
20
+ retirements.add(task);
21
+ void task.then(() => retirements.delete(task), () => { });
22
+ }
23
+ const results = await Promise.allSettled([...retirements]);
24
+ const errors = results.flatMap(result => result.status === 'rejected' ? [result.reason] : []);
25
+ if (errors.length)
26
+ throw new AggregateError(errors, 'Snapshot handle disposal failed');
27
+ };
28
+ const capture = async (page, signal) => {
29
+ signal?.throwIfAborted();
30
+ if (typeof page.frames !== 'function')
31
+ throw new Error('Snapshot engine unsupported: public frame element handles required');
32
+ const frames = page.frames();
33
+ if (frames.some(frame => typeof frame.locator('button, input, textarea, select, a[href], [role], [contenteditable="true"]').elementHandles !== 'function'))
34
+ throw new Error('Snapshot engine unsupported: public element handles required');
35
+ await invalidate();
36
+ const capturedEpoch = epoch;
37
+ const acquired = new Set();
38
+ const pending = new Map();
39
+ let text = '';
40
+ let bytes = 0;
41
+ try {
42
+ for (const frame of frames) {
43
+ signal?.throwIfAborted();
44
+ const handles = await frame.locator('button, input, textarea, select, a[href], [role], [contenteditable="true"]').elementHandles();
45
+ for (const handle of handles)
46
+ acquired.add(handle);
47
+ if (acquired.size > maxSnapshotRefs)
48
+ throw new Error('Snapshot ref limit exceeded');
49
+ for (const handle of handles) {
50
+ signal?.throwIfAborted();
51
+ const summary = await handle.evaluate(node => {
52
+ const tag = node.tagName.toLowerCase();
53
+ const roles = { button: 'button', input: 'textbox', textarea: 'textbox', select: 'combobox', a: 'link' };
54
+ return { role: node.getAttribute('role') || roles[tag] || tag, name: node.getAttribute('aria-label') || node.getAttribute('placeholder') || node.textContent || '' };
55
+ });
56
+ const ref = nextRef?.() ?? `e${++sequence}`;
57
+ const line = `- ${JSON.stringify(summary.role).slice(1, -1)} ${JSON.stringify(summary.name.trim())} [ref=${ref}]\n`;
58
+ bytes += new TextEncoder().encode(line).byteLength;
59
+ if (bytes > maxSnapshotBytes)
60
+ throw new Error('Snapshot byte limit exceeded');
61
+ pending.set(ref, handle);
62
+ text += line;
63
+ }
64
+ }
65
+ signal?.throwIfAborted();
66
+ if (capturedEpoch !== epoch)
67
+ throw new Error('Snapshot stale during capture');
68
+ for (const [ref, handle] of pending)
69
+ refs.set(ref, handle);
70
+ return text;
71
+ }
72
+ catch (error) {
73
+ const results = await Promise.allSettled([...acquired].map(handle => Promise.resolve().then(() => handle.dispose())));
74
+ const errors = results.flatMap(result => result.status === 'rejected' ? [result.reason] : []);
75
+ if (errors.length)
76
+ throw new AggregateError([error, ...errors], 'Snapshot capture and cleanup failed');
77
+ throw error;
78
+ }
79
+ };
80
+ const resolve = async (ref) => {
81
+ const handle = refs.get(ref);
82
+ if (!handle)
83
+ throw new Error(`Unknown or stale snapshot ref: ${ref}; snapshot again`);
84
+ const capturedEpoch = epoch;
85
+ let connected = false;
86
+ try {
87
+ connected = await handle.evaluate(node => node.isConnected && (!node.ownerDocument || node.ownerDocument.defaultView?.document === node.ownerDocument));
88
+ }
89
+ catch { /* Detached frames and destroyed execution contexts are stale. */ }
90
+ if (!connected || capturedEpoch !== epoch)
91
+ throw new Error(`Snapshot ref stale: ${ref}; snapshot again`);
92
+ return handle;
93
+ };
94
+ return { capture, resolve, invalidate };
95
+ }
96
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/playwright/snapshot.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAsB,EAAE,OAAsB;IACjF,KAAK,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,eAAe,CAAC;QAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAC;IACvK,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IACrD,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,WAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAmC,CAAC;IACxD,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC5B,KAAK,EAAE,CAAC;QACR,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAClG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAAC,KAAK,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C;YACvG,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAoC,EAAE;QACtE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,kBAAkB,CAAC,CAAC;QACtF,MAAM,aAAa,GAAG,KAAK,CAAC;QAC5B,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC;YAAC,SAAS,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,KAAK,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QAAC,CAAC;QAChK,MAAM,CAAC,CAAC,iEAAiE,CAAC,CAAC;QAC3E,IAAI,CAAC,SAAS,IAAI,aAAa,KAAK,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,kBAAkB,CAAC,CAAC;QACzG,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.635",
3
+ "version": "0.1.636",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -335,6 +335,16 @@
335
335
  "./trap": {
336
336
  "types": "./dist/safe-bash/opt-in/entrypoints/trap.d.ts",
337
337
  "import": "./dist/safe-bash/opt-in/entrypoints/trap.js"
338
+ },
339
+ "./commands/playwright": {
340
+ "types": "./dist/safe-bash/commands/playwright/index.d.ts",
341
+ "browser": "./dist/safe-bash/commands/playwright/index.js",
342
+ "import": "./dist/safe-bash/commands/playwright/index.js"
343
+ },
344
+ "./playwright": {
345
+ "types": "./dist/safe-bash/commands/playwright/index.d.ts",
346
+ "browser": "./dist/safe-bash/commands/playwright/index.js",
347
+ "import": "./dist/safe-bash/commands/playwright/index.js"
338
348
  }
339
349
  },
340
350
  "repository": {
@@ -346,7 +356,7 @@
346
356
  "access": "public"
347
357
  },
348
358
  "dependencies": {
349
- "@poe-platform/safe-fs": "0.1.635",
359
+ "@poe-platform/safe-fs": "0.1.636",
350
360
  "pako": "3.0.1",
351
361
  "@noble/hashes": "2.4.0",
352
362
  "@types/node": "^25.2.2",