Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)15k · #10922

node-lynx

Skill này làm gì

Cung cấp cho trợ lý một runtime Lynx cục bộ để render trang, chụp ảnh màn hình và chạy kiểm thử nhanh. Dành cho lập trình viên xây hoặc kiểm tra ứng dụng Lynx.

Khi nào nên dùng

  • ✓Khi bạn muốn ảnh chụp màn hình của một bundle Lynx mà không cần mở thiết bị.
  • ✓Khi bạn muốn xem trước ứng dụng Lynx trong một cửa sổ trên Mac.
  • ✓Khi bạn cần tự động hóa kiểm tra một trang Lynx đã render từ Node.js.

Liên kết skill

https://github.com/lynx-family/lynx/blob/develop/oliver/node-lynx/skills/node-lynx/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/lynx-family/lynx/blob/develop/oliver/node-lynx/skills/node-lynx/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Chụp ảnh màn hình ứng dụng Lynx mẫu gallery ở kích thước điện thoại và lưu vào một tệp.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Trợ lý chạy công cụ dòng lệnh node-lynx với chiều rộng, chiều cao và đường dẫn đầu ra. Nó cũng có thể render một bundle cục bộ, hoặc dùng giao diện JavaScript để kiểm tra sâu hơn.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Node Lynx

Use node-lynx as a local Lynx runtime for screenshots, preview windows, smoke tests, DebugRouter OpenCard sessions, and automation that needs to inspect or interact with a rendered Lynx page from Node.js.

Default sample template URL:

https://lynxjs.org/lynx-examples/gallery/dist/GalleryComplete.lynx.bundle

CLI

Prefer the CLI for one-off screenshots, quick template validation, and simple preview sessions.

Show available options:

node-lynx --help

Capture a headless screenshot and exit:

node-lynx render \
  "https://lynxjs.org/lynx-examples/gallery/dist/GalleryComplete.lynx.bundle" \
  --width 268 \
  --height 469 \
  --dpr 2 \
  --output ./gallery.png \
  --timeout 30000 \
  --screenshot-delay 500 \
  --no-debug-router

Render a local bundle:

node-lynx render \
  --template ./dist/main/template.js \
  --width 390 \
  --height 844 \
  --output ./node-lynx-local.png \
  --no-debug-router

Open a visible preview window on macOS:

node-lynx preview \
  "https://lynxjs.org/lynx-examples/gallery/dist/GalleryComplete.lynx.bundle" \
  --width 268 \
  --height 469 \
  --dpr 2 \
  --title "Node Lynx Preview"

Start a DebugRouter-backed session without an initial template:

node-lynx render

CLI rules:

  • Use render for headless screenshots and automation.
  • Use preview only on macOS; it creates an AppKit window.
  • Use --template <path> for local bundles and --url <url> for remote bundles. A positional http:// or https:// input is treated as a remote bundle URL.
  • Use --width and --height as CSS pixel viewport values.
  • Use --dpr or --device-pixel-ratio to control output scale; the PNG pixel size is width * dpr by height * dpr.
  • Use --timeout <ms> for bundle download, template load, CDP calls, and first frame submission timeouts.
  • Use --screenshot-delay <ms> to wait after the first frame before capture. This defaults to 100; use a larger delay for image-heavy or network-heavy pages.
  • Pass --no-debug-router for CI or one-shot screenshot commands that should exit immediately after writing the PNG.
  • Omit --no-debug-router when you need DebugRouter/OpenCard. Without an initial template, render waits for DebugRouter OpenCard. preview also waits for OpenCard without creating an initial window.
  • OpenCard only loads public http(s) URLs by default. Pass --allow-any-open-card-source (API: allowAnySource: true) to load local files or a loopback/private dev server, only on a trusted network.

TypeScript API

Prefer the API when the task needs programmatic setup, repeated captures, global props, CDP calls, input simulation, or custom lifecycle handling.

Import from the node-lynx package declared by the target project. For public npm usage this is typically:

import { HeadlessLynxView } from '@lynx-js/node-lynx';

Render a remote template to PNG:

import { writeFile } from 'node:fs/promises';
import { HeadlessLynxView } from '@lynx-js/node-lynx';

const templateUrl =
  'https://lynxjs.org/lynx-examples/gallery/dist/GalleryComplete.lynx.bundle';

const view = new HeadlessLynxView({
  width: 268,
  height: 469,
  devicePixelRatio: 2,
  timeoutMs: 30000,
});

try {
  await view.loadTemplateFromUrl(templateUrl, {
    initialData: { source: 'node-lynx' },
    globalProps: { theme: 'light' },
  });
  const png = await view.screenshot({ settleMs: 500 });
  await writeFile('./gallery.png', png);
} finally {
  view.destroy();
}

Render a local bundle buffer. Always pass a file URL so relative resources have the right base URL:

import { readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { HeadlessLynxView } from '@lynx-js/node-lynx';

const templatePath = resolve('./dist/main/template.js');
const view = new HeadlessLynxView({ width: 390, height: 844 });

try {
  await view.loadTemplate(await readFile(templatePath), {
    url: pathToFileURL(templatePath).href,
  });
  await writeFile('./node-lynx-local.png', await view.screenshot());
} finally {
  view.destroy();
}

Inspect the DOM through CDP:

const responseText = await view.invokeCDPFromSDK(
  JSON.stringify({
    id: 1,
    method: 'DOM.getDocument',
    params: { depth: -1, pierce: true },
  })
);
const response = JSON.parse(responseText);

Update runtime data after load:

view.updateData({ selected: true 
Câu hỏi thường gặp

Tôi có cần Mac để dùng không?

Không cần cho ảnh chụp màn hình, vì chúng chạy headless. Cửa sổ xem trước chỉ có trên macOS.

Nó có render được ứng dụng cục bộ không?

Có. Nó có thể tải một tệp template cục bộ cũng như liên kết bundle trên web.

Mẫu mặc định hiển thị gì?

Mặc định nó tải một bundle mẫu gallery Lynx từ trang ví dụ của Lynx.

Chi tiết

Mô tả gốc của tác giả

Use this skill when a task needs to run Lynx bundles with the node-lynx CLI, capture screenshots, open a macOS preview window, use DebugRouter OpenCard, inspect rendered content through CDP, or integrate node-lynx through JavaScript or TypeScript APIs.

repo: lynx-family/lynx

Độ phổ biến

Sao GitHub
15k
Vị trí xếp hạng
#10922
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự