Agent Skillslichtblick-suite/lichtblick › panel-user-scripts

panel-user-scripts

GitHub

提供应用内 TypeScript 用户脚本编辑器的架构与 API 知识,涵盖 Monaco 集成、Worker 编译执行流程及沙箱隔离机制。

.github/skills/panel-user-scripts/SKILL.md lichtblick-suite/lichtblick

触发场景

询问用户脚本编辑器实现细节 调试或开发自定义消息转换脚本 理解 Transformer/ Runtime Worker 运行机制

安装

npx skills add lichtblick-suite/lichtblick --skill panel-user-scripts -g -y
更多选项

非标准路径

npx skills add https://github.com/lichtblick-suite/lichtblick/tree/develop/.github/skills/panel-user-scripts -g -y

不安装直接使用

npx skills use lichtblick-suite/lichtblick@panel-user-scripts

指定 Agent (Claude Code)

npx skills add lichtblick-suite/lichtblick --skill panel-user-scripts -a claude-code -g -y

安装 repo 全部 skill

npx skills add lichtblick-suite/lichtblick --all -g -y

预览 repo 内 skill

npx skills add lichtblick-suite/lichtblick --list

SKILL.md

Frontmatter
{
    "name": "panel-user-scripts",
    "description": "Deep UserScripts panel knowledge: Monaco editor integration, UserScriptPlayer wrapper, TypeScript compilation in the transformer Worker, sandboxed runtime Worker execution, diagnostics, and the script API."
}

Panel User Scripts Skill

The in-app TypeScript editor that lets users write custom message transformations.

Architecture

UserScripts Panel (Monaco editor)
    │
    ▼
UserScriptPlayer (wraps the base Player)
    │
    ├── Transformer Worker (compiles + reports diagnostics)
    │   └── TypeScript compiler (in-Worker)
    │
    └── Runtime Worker (sandboxed script execution)
        └── user code runs here (isolated)

Core Components

File Role
panels/UserScriptEditor/ Monaco editor UI, diagnostics display
players/UserScriptPlayer/index.ts Player wrapper, Worker pool management
players/UserScriptPlayer/transformerWorker/ TypeScript compilation in a Worker
players/UserScriptPlayer/runtimeWorker/ Sandboxed script execution

Script Lifecycle

  1. User writes TypeScript in Monaco
  2. On save: code is sent to the Transformer Worker for compilation
  3. Transformer compiles TS → JS and reports diagnostics (errors/warnings)
  4. On success: the JS bundle is sent to the Runtime Worker
  5. During playback: messages on input topics → Runtime Worker → output messages
  6. Output messages are injected into PlayerState as additional topics

Worker Naming Pattern

// unique name per instance — isolates workers per tab (no cross-tab sharing)
new SharedWorker(new URL("./transformerWorker/index", import.meta.url), {
  name: uuidv4(),
});
  • SharedWorker is the worker type, but cross-tab instance reuse is disabled by unique naming.
  • Within a single player lifetime, runtime workers are reused/pooled where possible.
  • Each active script processor maps to an isolated runtime execution context.

Monaco Integration

  • Full TypeScript language service (autocomplete, errors, hover)
  • Custom Lichtblick script-API type definitions injected
  • Diagnostics shown inline and in a panel below the editor

Script API

export const inputs = ["/camera/image"];
export const output = "/processed_image";

export default function transform(event: MessageEvent): OutputMessage {
  return {
    /* processed data */
  };
}

Performance Notes

  • Script execution never blocks the main thread (Worker isolation)
  • Unchanged scripts don't recompile (compilation caching)
  • Only subscribed input topics are forwarded to the Worker
  • Runtime errors in user code are contained — they don't crash the app
  • Each Runtime Worker has its own heap (no cross-script interference)

Key Files

  • packages/suite-base/src/panels/UserScriptEditor/
  • packages/suite-base/src/players/UserScriptPlayer/index.ts
  • packages/suite-base/src/players/UserScriptPlayer/transformerWorker/
  • packages/suite-base/src/players/UserScriptPlayer/runtimeWorker/

Skills Reference

  • For SharedWorker patterns: load web-workers skill

版本历史

  • 6435710 当前 2026-08-16 02:35
  • cab9317 2026-07-24 12:17

同 Skill 集合

.github/skills/3d-rendering/SKILL.md
.github/skills/caching-internals/SKILL.md
.github/skills/deserialization/SKILL.md
.github/skills/e2e-playwright-mcp/SKILL.md
.github/skills/electron-internals/SKILL.md
.github/skills/extensions-internals/SKILL.md
.github/skills/layouts-internals/SKILL.md
.github/skills/mcap-format/SKILL.md
.github/skills/message-path/SKILL.md
.github/skills/message-pipeline/SKILL.md
.github/skills/panel-extension-api/SKILL.md
.github/skills/panel-image/SKILL.md
.github/skills/panel-log/SKILL.md
.github/skills/panel-map/SKILL.md
.github/skills/panel-raw-messages/SKILL.md
.github/skills/panel-state-transitions/SKILL.md
.github/skills/performance/SKILL.md
.github/skills/player-internals/SKILL.md
.github/skills/plot-internals/SKILL.md
.github/skills/release-process/SKILL.md
.github/skills/remote-caching/SKILL.md
.github/skills/test-conventions/SKILL.md
.github/skills/theme/SKILL.md
.github/skills/unit-testing/SKILL.md
.github/skills/web-workers/SKILL.md
.github/skills/websocket-connection/SKILL.md

元信息

文件数
0
版本
355014d
Hash
d4a2ba2d
收录时间
2026-07-24 12:17

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-30 01:00
浙ICP备14020137号-1 $访客地图$