{"_id":"@carlesandres/webreel-core","_rev":"2-74b7e4c20ab8ae1a3e6a79fb2db5074a","name":"@carlesandres/webreel-core","dist-tags":{"latest":"0.2.1"},"versions":{"0.2.0":{"name":"@carlesandres/webreel-core","version":"0.2.0","keywords":["video","recording","browser","headless","chrome","cdp","screencast","automation"],"license":"Apache-2.0","_id":"@carlesandres/webreel-core@0.2.0","maintainers":[{"name":"carlesandres","email":"carlos.andres.c@gmail.com"}],"homepage":"https://webreel.dev","bugs":{"url":"https://github.com/vercel-labs/webreel/issues"},"dist":{"shasum":"f834b80582c5f99340d0023fcd9e5eac6aad4d5a","tarball":"https://registry.npmjs.org/@carlesandres/webreel-core/-/webreel-core-0.2.0.tgz","fileCount":107,"integrity":"sha512-r79QzbxFekxCq6uyTNqTgWZvmvt2ubtqzLEqCHF1p0Gt8L0Uy+LKCNrh1+zi5EgY816oTJ+NdEcRi/BQ+Psw8A==","signatures":[{"sig":"MEYCIQDG+lmAokS3oNOOYDl2g7tuxo2+cg66U8Ar2Rhm02PgMAIhAJeiMq9tQLtVtPjp1YXXrw5uKQOYayskCTaoFzGiKXo5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":291724},"type":"module","_from":"file:carlesandres-webreel-core-0.2.0.tgz","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","test":"vitest run","build":"rm -rf dist && tsc","clean":"rm -rf dist","type-check":"tsc --noEmit"},"_npmUser":{"name":"carlesandres","email":"carlos.andres.c@gmail.com"},"_resolved":"/private/var/folders/20/3lpbx2mx2l17h63z6cb6ky4r0000gn/T/d10ffe5522414911861467297bf2caa7/carlesandres-webreel-core-0.2.0.tgz","_integrity":"sha512-r79QzbxFekxCq6uyTNqTgWZvmvt2ubtqzLEqCHF1p0Gt8L0Uy+LKCNrh1+zi5EgY816oTJ+NdEcRi/BQ+Psw8A==","repository":{"url":"git+https://github.com/carlesandres/webreel.git","type":"git","directory":"packages/@webreel/core"},"_npmVersion":"11.12.1","description":"Core recording engine for webreel - headless Chrome capture, cursor animation, and video compositing.","directories":{},"_nodeVersion":"24.15.0","dependencies":{"sharp":"^0.34.5","chrome-remote-interface":"^0.33.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"5.9.3","@types/node":"25.3.0","@types/chrome-remote-interface":"^0.33.0"},"_npmOperationalInternal":{"tmp":"tmp/webreel-core_0.2.0_1782390264304_0.6708485365901102","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@carlesandres/webreel-core","version":"0.2.1","description":"Core recording engine for webreel - headless Chrome capture, cursor animation, and video compositing.","homepage":"https://webreel.dev","repository":{"type":"git","url":"git+https://github.com/carlesandres/webreel.git","directory":"packages/@webreel/core"},"bugs":{"url":"https://github.com/vercel-labs/webreel/issues"},"keywords":["video","recording","browser","headless","chrome","cdp","screencast","automation"],"license":"Apache-2.0","publishConfig":{"access":"public"},"type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"engines":{"node":">=18"},"dependencies":{"chrome-remote-interface":"^0.33.2","sharp":"^0.34.5"},"devDependencies":{"@types/chrome-remote-interface":"^0.33.0","@types/node":"25.3.0","typescript":"5.9.3"},"scripts":{"clean":"rm -rf dist","build":"rm -rf dist && tsc","type-check":"tsc --noEmit","dev":"tsc --watch","test":"vitest run"},"_id":"@carlesandres/webreel-core@0.2.1","_integrity":"sha512-BUmOCDxNxkQE3IBO4CuAXaSIV77soAFP8HSp7Kcf89QrnQDZ7kBWt6zKg9501htqGsHdSV+GLQeWdatvmCza2Q==","_resolved":"/private/var/folders/20/3lpbx2mx2l17h63z6cb6ky4r0000gn/T/1bee7a5a2a51bd0794731961e281d1a1/carlesandres-webreel-core-0.2.1.tgz","_from":"file:carlesandres-webreel-core-0.2.1.tgz","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-BUmOCDxNxkQE3IBO4CuAXaSIV77soAFP8HSp7Kcf89QrnQDZ7kBWt6zKg9501htqGsHdSV+GLQeWdatvmCza2Q==","shasum":"a0571787e709bda2a4fad2e7354ae90c7a60d840","tarball":"https://registry.npmjs.org/@carlesandres/webreel-core/-/webreel-core-0.2.1.tgz","fileCount":107,"unpackedSize":293220,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFLGn8R4C0PeRnZGDMwgoFxvnk1fFMARdgMcFlmBpu6IAiEA7V60/fk/Km4YQ5ek9tEM9YmTnYF4hAlGBze5qV9nUEo="}]},"_npmUser":{"name":"carlesandres","email":"carlos.andres.c@gmail.com"},"directories":{},"maintainers":[{"name":"carlesandres","email":"carlos.andres.c@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/webreel-core_0.2.1_1782392190050_0.3502027859161674"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-25T12:24:24.152Z","modified":"2026-06-25T12:56:30.315Z","0.2.0":"2026-06-25T12:24:24.460Z","0.2.1":"2026-06-25T12:56:30.201Z"},"bugs":{"url":"https://github.com/vercel-labs/webreel/issues"},"license":"Apache-2.0","homepage":"https://webreel.dev","keywords":["video","recording","browser","headless","chrome","cdp","screencast","automation"],"repository":{"type":"git","url":"git+https://github.com/carlesandres/webreel.git","directory":"packages/@webreel/core"},"description":"Core recording engine for webreel - headless Chrome capture, cursor animation, and video compositing.","maintainers":[{"name":"carlesandres","email":"carlos.andres.c@gmail.com"}],"readme":"# @webreel/core\n\nChrome automation, recording, and overlay engine for webreel.\n\nLaunches a headless Chrome instance via the Chrome DevTools Protocol, captures screenshots at ~60fps, and encodes the result to MP4 with ffmpeg. Provides actions for clicking, typing, dragging, and cursor animation, plus on-screen overlays for keystroke labels and a custom cursor.\n\n## Installation\n\n```bash\nnpm install @webreel/core\n```\n\n## Examples\n\n<!-- EXAMPLES:START -->\n\n**[custom-theme](../../../examples/custom-theme)** - Demonstrates fully customizing the cursor overlay and keystroke HUD appearance using a code editor page.\n\n<video src=\"../../../examples/custom-theme/videos/custom-theme.mp4\" controls muted width=\"100%\"></video>\n\n**[drag-and-drop](../../../examples/drag-and-drop)** - Demonstrates dragging elements between positions on a kanban board.\n\n<video src=\"../../../examples/drag-and-drop/videos/drag-and-drop.mp4\" controls muted width=\"100%\"></video>\n\n**[form-filling](../../../examples/form-filling)** - Demonstrates typing into form fields and clicking a submit button, simulating a login flow.\n\n<video src=\"../../../examples/form-filling/videos/form-filling.mp4\" controls muted width=\"100%\"></video>\n\n**[gif-output](../../../examples/gif-output)** - Demonstrates outputting the recording as an animated GIF instead of the default MP4.\n\n<video src=\"../../../examples/gif-output/videos/gif-output.gif\" controls muted width=\"100%\"></video>\n\n**[hello-world](../../../examples/hello-world)** - The simplest possible webreel example. Opens a landing page and clicks the call-to-action button.\n\n<video src=\"../../../examples/hello-world/videos/hello-world.mp4\" controls muted width=\"100%\"></video>\n\n**[keyboard-shortcuts](../../../examples/keyboard-shortcuts)** - Demonstrates pressing key combos and displaying them in the keystroke HUD overlay. Uses a code editor page as the target.\n\n<video src=\"../../../examples/keyboard-shortcuts/videos/keyboard-shortcuts.mp4\" controls muted width=\"100%\"></video>\n\n**[mobile-viewport](../../../examples/mobile-viewport)** - Demonstrates recording at mobile device dimensions using a finance app interface.\n\n<video src=\"../../../examples/mobile-viewport/videos/mobile-viewport.mp4\" controls muted width=\"100%\"></video>\n\n**[modifier-clicks](../../../examples/modifier-clicks)** - Demonstrates clicking elements with modifier keys held down, simulating multi-select in a file manager.\n\n<video src=\"../../../examples/modifier-clicks/videos/modifier-clicks.mp4\" controls muted width=\"100%\"></video>\n\n**[multi-demo](../../../examples/multi-demo)** - Demonstrates defining multiple videos in a single config file, each producing its own output from the same page.\n\n<video src=\"../../../examples/multi-demo/videos/homepage.mp4\" controls muted width=\"100%\"></video>\n\n**[page-scrolling](../../../examples/page-scrolling)** - Demonstrates scrolling the page and scrolling within a specific container element on a blog post layout.\n\n<video src=\"../../../examples/page-scrolling/videos/page-scrolling.mp4\" controls muted width=\"100%\"></video>\n\n**[screenshots](../../../examples/screenshots)** - Demonstrates capturing PNG screenshots at specific points during a recording. Useful for generating static marketing assets or documentation images alongside videos.\n\n<video src=\"../../../examples/screenshots/videos/screenshots.mp4\" controls muted width=\"100%\"></video>\n\n**[shared-steps](../../../examples/shared-steps)** - Demonstrates using `include` to share common setup steps across videos. The shared steps dismiss a cookie consent banner before the main video steps run.\n\n<video src=\"../../../examples/shared-steps/shared-steps.mp4\" controls muted width=\"100%\"></video>\n\n**[webm-output](../../../examples/webm-output)** - Demonstrates outputting the recording as a WebM video using VP9 encoding.\n\n<video src=\"../../../examples/webm-output/webm-output.webm\" controls muted width=\"100%\"></video>\n\n<!-- EXAMPLES:END -->\n\n## Usage\n\n```ts\nimport {\n  RecordingContext,\n  launchChrome,\n  connectCDP,\n  navigate,\n  clickAt,\n  pressKey,\n  pause,\n  Recorder,\n  InteractionTimeline,\n  compose,\n} from \"@webreel/core\";\n\nconst ctx = new RecordingContext();\nctx.setMode(\"record\");\n\nconst chrome = await launchChrome({ headless: true });\nconst client = await connectCDP(chrome.port);\n\nawait client.Page.enable();\nawait client.Runtime.enable();\nawait client.Emulation.setDeviceMetricsOverride({\n  width: 1080,\n  height: 1080,\n  deviceScaleFactor: 2,\n  mobile: false,\n});\n\nconst timeline = new InteractionTimeline(1080, 1080, { zoom: 2 });\nctx.setTimeline(timeline);\n\nawait navigate(client, \"https://example.com\");\n\nconst recorder = new Recorder(1080, 1080);\nrecorder.setTimeline(timeline);\nawait recorder.start(client, \"demo.mp4\", ctx);\n\nawait pause(500);\nawait clickAt(ctx, client, 540, 400);\nawait pressKey(ctx, client, \"cmd+a\");\nawait pause(1000);\n\nawait recorder.stop();\n\nawait compose(recorder.getTempVideoPath(), timeline.toJSON(), \"demo.mp4\");\n\nawait client.close();\nchrome.kill();\n```\n\n## API\n\n### Chrome\n\n#### `launchChrome(options?): Promise<ChromeInstance>`\n\nLaunches a Chrome process with remote debugging enabled.\n\n| Option     | Type      | Default | Description          |\n| ---------- | --------- | ------- | -------------------- |\n| `headless` | `boolean` | `true`  | Run in headless mode |\n\nReturns a `ChromeInstance` with `process`, `port`, and `kill()`.\n\n### Recorder\n\n#### `new Recorder(width?, height?, options?)`\n\nCreates a recorder that captures screenshots and encodes them to MP4.\n\nOptions:\n\n| Option          | Type              | Default  | Description                                             |\n| --------------- | ----------------- | -------- | ------------------------------------------------------- |\n| `sfx`           | `SfxConfig`       | -        | Click and key sound effect settings                     |\n| `fps`           | `number`          | `60`     | Capture and output frame rate                           |\n| `crf`           | `number`          | `18`     | H.264 quality setting passed to ffmpeg                  |\n| `framesDir`     | `string`          | -        | Directory for saving raw source frames                  |\n| `captureFormat` | `\"jpeg\" \\| \"png\"` | `\"jpeg\"` | Source-frame capture format before final video encoding |\n\nUse `captureFormat: \"png\"` to capture lossless source frames. JPEG remains the default and is faster for most recordings.\n\n#### `recorder.start(client, outputPath, ctx?): Promise<void>`\n\nBegin capturing frames. Pass an optional `RecordingContext` to track cursor position and timeline events.\n\n#### `recorder.stop(): Promise<void>`\n\nStop capturing, encode to MP4 with sound effects, and clean up temp files.\n\n### Actions\n\nAll action functions that animate the cursor take a `RecordingContext` as their first argument.\n\n| Function                                           | Description                                       |\n| -------------------------------------------------- | ------------------------------------------------- |\n| `navigate(client, url)`                            | Navigate to a URL and wait for load               |\n| `waitForSelector(client, selector, timeout?)`      | Poll until a CSS selector matches                 |\n| `findElementByText(client, text, within?)`         | Find an element's bounding box by text content    |\n| `findElementBySelector(client, selector, within?)` | Find an element's bounding box by CSS selector    |\n| `moveCursorTo(ctx, client, x, y)`                  | Animate the overlay cursor to a position          |\n| `clickAt(ctx, client, x, y, modifiers?)`           | Move cursor and click with optional modifier keys |\n| `pressKey(ctx, client, key, label?)`               | Press a key combo (e.g. `\"cmd+z\"`) with overlay   |\n| `typeText(ctx, client, text, delayMs?)`            | Type text character by character                  |\n| `dragFromTo(ctx, client, fromBox, toBox)`          | Drag between two elements                         |\n| `captureScreenshot(client, outputPath)`            | Save a PNG screenshot                             |\n| `pause(ms?)`                                       | Wait for a duration (default 1200ms)              |\n| `modKey()`                                         | Returns `\"cmd\"` on macOS, `\"ctrl\"` elsewhere      |\n\n### Overlays\n\n| Function                                           | Description                                           |\n| -------------------------------------------------- | ----------------------------------------------------- |\n| `injectOverlays(client, theme?, initialPosition?)` | Add cursor and keystroke overlay elements to the page |\n| `showKeys(client, labels)`                         | Display keystroke labels on screen                    |\n| `hideKeys(client)`                                 | Hide the keystroke overlay                            |\n\n## Prerequisites\n\n- [Google Chrome](https://www.google.com/chrome/) (or Chromium)\n- [ffmpeg](https://ffmpeg.org/)\n\nSet `CHROME_PATH` to override the default Chrome location.\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md"}