@ricsam/isolate-playwright 0.1.13 → 0.1.14

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 CHANGED
@@ -385,9 +385,31 @@ await context.eval(`
385
385
  `);
386
386
  ```
387
387
 
388
+ With handler-first runtime APIs (`createRuntime({ playwright: { handler } })`), provide
389
+ `writeFile` when creating the handler:
390
+
391
+ ```typescript
392
+ const handler = defaultPlaywrightHandler(page, {
393
+ writeFile: async (filePath, data) => {
394
+ await fs.writeFile(filePath, data);
395
+ },
396
+ });
397
+ ```
398
+
388
399
  ### File Uploads (setInputFiles)
389
400
 
390
- File uploads support both inline data and file paths:
401
+ File uploads support these input shapes:
402
+
403
+ - `"/uploads/document.pdf"`
404
+ - `["/uploads/file1.pdf", "/uploads/file2.pdf"]`
405
+ - `{ name, mimeType, buffer }`
406
+ - `[{ name, mimeType, buffer }, ...]`
407
+ - `[]` (clear files)
408
+
409
+ Mixing paths and inline objects in the same array throws an error.
410
+
411
+ In page-mode (`setupPlaywright(context, { page, ... })`), provide `readFile` in
412
+ `setupPlaywright` options:
391
413
 
392
414
  ```typescript
393
415
  const handle = await setupPlaywright(context, {
@@ -404,7 +426,14 @@ const handle = await setupPlaywright(context, {
404
426
 
405
427
  // In isolate code:
406
428
  await context.eval(`
407
- // Inline data - no callback needed
429
+ // Inline data object - no callback needed
430
+ await page.locator('#upload').setInputFiles({
431
+ name: 'single.txt',
432
+ mimeType: 'text/plain',
433
+ buffer: new TextEncoder().encode('Hello!'),
434
+ });
435
+
436
+ // Inline data array - no callback needed
408
437
  await page.locator('#upload').setInputFiles([{
409
438
  name: 'test.txt',
410
439
  mimeType: 'text/plain',
@@ -425,6 +454,22 @@ await context.eval(`
425
454
  `);
426
455
  ```
427
456
 
457
+ With handler-first runtime APIs (`createRuntime({ playwright: { handler } })`),
458
+ provide `readFile` when creating the handler:
459
+
460
+ ```typescript
461
+ const handler = defaultPlaywrightHandler(page, {
462
+ readFile: async (filePath) => {
463
+ const buffer = await fs.readFile(filePath);
464
+ return {
465
+ name: path.basename(filePath),
466
+ mimeType: 'application/octet-stream',
467
+ buffer,
468
+ };
469
+ },
470
+ });
471
+ ```
472
+
428
473
  ## License
429
474
 
430
475
  MIT