> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# 正式发布 Lynxtron

[← 所有文章](/next/zh/blog/)

2026年9月21日

![Wang Zhixuan](https://github.com/icecreamx10.png)Wang Zhixuan多平台主管 @ Lynx![Guo Xi](https://github.com/GuoXi.png)Guo Xi工程师 @ Lynx![Lynx 团队](https://github.com/lynx-family.png)Lynx 团队lynxjs.org

Lynx 正在走向桌面端。

**[Lynxtron](/next/zh/lynxtron/index.md)** 是由 Lynx 驱动的 Electron-like 应用框架。在 Lynxtron 应用中，宿主进程仍然保留桌面开发需要的 Node.js 能力，而窗口层由 `LynxWindow` 通过轻量 UI 渲染器承载 Lynx UI，而不是加载浏览器页面。

这意味着：你可以用 Lynx 的 UI 模型构建桌面应用，同时继续获得更轻的运行时、更直接的原生扩展能力，以及面向桌面、Web 和移动端的跨平台代码组织方式。

## Lynxtron 解决什么问题

桌面应用开发长期有一个现实选择：要么使用 Web 技术快速构建跨平台应用，要么投入更多原生工程成本换取体积、性能和系统能力。Lynxtron 的目标是在这两者之间提供一个新的路径：用 Lynx 组织 UI，用桌面宿主进程连接系统能力，用原生扩展承载真正需要原生实现的部分。

Lynxtron 围绕 **Light-weight and Fast**、**Multiplatform** 和 **Natively Extensible** 三项特性展开。下面观察它们如何落到桌面应用开发中。

## 使用 Lynxtron Go 体验

[Lynxtron Go](/next/zh/lynxtron/go.md) 是 Lynxtron 官方提供的 playground，它本身也是使用 Lynxtron 框架构建的桌面应用。它提供模板、内置示例 Gallery、编辑器和 Console，无需先创建完整工程，即可运行和检查小型 Lynxtron 应用。下面的可运行示例也可以直接在 Lynxtron Go 中打开。

:::info 测试版本与平台

本文示例来自 Lynxtron Go 0.1.18 release，并使用 Lynxtron runtime 0.0.28。桌面示例支持 Apple 芯片和 Intel 芯片 Mac，以及 x64 Windows；Notes 示例还支持 Web。Lynxtron 工程需要 Node.js `^22.18.0 || ^24.0.0 || ^26.0.0`。

:::

## Light-weight and Fast

Lynxtron 在应用模型上接近 Electron，但它没有把 browser 作为 UI runtime 打包进应用。[`LynxWindow`](/next/zh/lynxtron/api/@lynx-js/lynxtron/Class.LynxWindow.md) 通过轻量化的 Lynx renderer 承载 UI，让桌面运行时更小，也让启动、窗口创建和内存使用路径更直接。


**下面是一个示例: benchmark**

**Bundle:** `dist/desktop/main.lynx.bundle`

```ts {17-25,39-52,66-70}
import { app, LynxWindow, lynxBridge } from '@lynx-js/lynxtron';
import { nudgeFramedWindowViewport } from '@lynxtron-examples/config/window';
import { LYNX_BUNDLE_PATH } from './vendorPaths';
import path from 'path';
import { fetchReleaseSize } from './release-size';
import {
  getMemoryUsageDelta,
  getMemoryUsageSnapshot,
  type MemoryUsageDelta,
} from './memory-metrics';

const WINDOW_SETTLE_MS = 800;

// Main body starts after imports. Buffer in memory; print after loadFile returns.
const startupMarks: { stage: string; wallMs: number; monoMs: number }[] = [];
function markStartup(stage: string) {
  startupMarks.push({ stage, wallMs: Date.now(), monoMs: performance.now() });
}
markStartup('main-module-body');

// Use the OS process creation time, not the time this JS module or preload runs.
const processCreatedAt = (process as NodeJS.Process & {
  getCreationTime(): number | null;
}).getCreationTime();
let startupTime: number | null = null;

let mainWindow: LynxWindow | null = null;
let secondWindow: LynxWindow | null = null;
let secondWindowDelta: MemoryUsageDelta | null = null;

function createBenchmarkWindow(title: string, width: number, height: number) {
  const w = new LynxWindow({
    width,
    height,
    title,
    lynxPreference: {
      preload: path.join(__dirname, 'preload.js'),
    },
  });
  nudgeFramedWindowViewport(w, { width, height });
  return w;
}

function registerBridgeHandlers() {
  let releaseSizeRequest: ReturnType<typeof fetchReleaseSize> | undefined;
  lynxBridge.handle('getReleaseSize', async () => {
    try {
      releaseSizeRequest ??= fetchReleaseSize();
      return { ok: true, ...(await releaseSizeRequest) };
    } catch (error) {
      releaseSizeRequest = undefined;
      return { ok: false, error: error instanceof Error ? error.message : 'Release size unavailable' };
    }
  });
  lynxBridge.handle('getStartupTime', () => startupTime);
  lynxBridge.handle('openSecondWindowAndMeasure', () => {
    if (secondWindow) {
      secondWindow.show();
      return { ok: true, delta: secondWindowDelta, alreadyOpen: true };
    }

    const before = getMemoryUsageSnapshot();
    secondWindow = createBenchmarkWindow('Benchmark Dashboard #2', 640, 460);
    secondWindow.on('closed', () => {
      secondWindow = null;
      secondWindowDelta = null;
    });
    secondWindow.show();
    secondWindow.loadFile(LYNX_BUNDLE_PATH);

    return new Promise((resolve) => {
      setTimeout(() => {
        const after = getMemoryUsageSnapshot();
        secondWindowDelta = getMemoryUsageDelta(before, after);
        resolve({ ok: true, delta: secondWindowDelta, alreadyOpen: false });
      }, WINDOW_SETTLE_MS);
    });
  });

  lynxBridge.handle('getSecondWindowDelta', () => ({
    isOpen: secondWindow != null,
    delta: secondWindowDelta,
  }));
}

app.whenReady().then(() => {
  markStartup('app-ready');
  registerBridgeHandlers();
  markStartup('bridge-registered');
  markStartup('window-create-start');
  mainWindow = createBenchmarkWindow('Benchmark Dashboard', 700, 520);
  markStartup('window-create-end');
  markStartup('show-start');
  mainWindow.show();
  markStartup('show-end');
  markStartup('loadFile-start');
  // Lynx architecture: LynxWindow.loadFile synchronously executes Lynx MTS
  // (Main Thread Script) AND the on-screen rendering operations on the main
  // thread. This is not waiting for BTS (Background Thread Script). Its return
  // is therefore the end of those operations, not just a request being queued.
  // Measure Lynx FCP from OS process creation to this synchronous return for the
  // initial main window. Do not substitute a browser-style asynchronous paint
  // assumption or wait for an on-first-screen callback. Extra windows/reloads
  // must not reset the metric.
  // MTS/IFR: https://lynxjs.org/guide/interaction/ifr
  mainWindow.loadFile(LYNX_BUNDLE_PATH);
  const loadFileCompletedAt = Date.now();
  markStartup('loadFile-return');
  if (processCreatedAt != null && processCreatedAt > 0 && processCreatedAt <= loadFileCompletedAt) {
    startupTime = Math.round(loadFileCompletedAt - processCreatedAt);
    console.log(`[Benchmark] Process creation to synchronous loadFile completion: ${startupTime} ms`);
  }
  console.log('[BenchmarkStartup] ' + JSON.stringify({
    pid: process.pid, processCreatedAt, totalMs: startupTime,
    bundleEntrySinceProcessMs: processCreatedAt == null ? null :
      (globalThis as typeof globalThis & { __benchmarkBundleEntryAt: number }).__benchmarkBundleEntryAt - processCreatedAt,
    marks: startupMarks.map((mark, index) => ({
      stage: mark.stage,
      sinceProcessMs: processCreatedAt == null ? null : mark.wallMs - processCreatedAt,
      sincePreviousMs: index === 0 ? null : Number((mark.monoMs - startupMarks[index - 1].monoMs).toFixed(2)),
    })),
  }));
});

```

v0.0.6



> 该 benchmark 会报告 Lynxtron 的基础包体积、启动耗时、物理内存、JS heap、平台信息，以及打开第二个 `LynxWindow` 后的内存增量，覆盖一个或两个窗口时的启动和内存表现。截图记录了 Benchmark 示例 v0.0.6 使用 Lynxtron 0.0.28，在 Windows 11 x64（Core Ultra 7 155H、Intel Arc）上的一次冷启动结果（不含安装后的首次启动）；启动耗时从进程创建计至首屏内容上屏，不代表平均值。

## Natively Extensible

Lynxtron 通过 [LynxExtensionModule](/next/zh/api/lynx-native-api/lynx-extension-module.md) 扩展渲染器能力。它是由[公开的 Lynx Native API](/next/zh/api/lynx-native-api/lynx-view.md) 支撑的 Desktop C++ extension API；该 reference 覆盖这个示例使用的 native view 生命周期、注册和 texture API。原生模块使用 C++ extension module wrapper 管理接入和生命周期，并通过 [Node-API](/next/zh/lynxtron/Native-Libraries/NodeJS-Native-Modules.md) 向 JavaScript 暴露接口；原生 UI 和 texture surface 则使用 native view wrappers。在桌面开发中，一部分图形或 UI 需要原生实现是很常见的需求：摄像头预览、视频画面、地图视图、绘制画布、平台控件，或者任何需要硬件访问、GPU 深度绑定、复用系统渲染能力的 surface。Lynxtron 可以把这些原生 surface 或原生 UI 和 Lynx runtime 结合起来，让需要原生渲染的部分继续走原生路径，同时让交互和界面逻辑继续用 Lynx UI 构建和迭代。


**下面是一个示例: native-texture-canvas**

**Bundle:** `dist/desktop/main.lynx.bundle`

```cpp {67-70,93-107}
#include "module/native_texture_canvas_module.h"

#include <cstring>
#include <utility>
#include <vector>

#include "capi/lynx_log_capi.h"
#include "module/native_texture_canvas_view.h"

namespace extension {
namespace {

const uint64_t kNativeTextureCanvasModuleID =
    reinterpret_cast<uint64_t>(&kNativeTextureCanvasModuleID);

Napi::Value SetBrush(const Napi::CallbackInfo& info) {
  Napi::Env env = info.Env();
  if (info.Length() < 4) {
    Napi::TypeError::New(
        env, "Expected (string canvasId, string color, number size, number opacity)")
        .ThrowAsJavaScriptException();
    return env.Null();
  }
  if (!info[0].IsString() || !info[1].IsString()) {
    Napi::TypeError::New(env, "canvasId and color must be strings")
        .ThrowAsJavaScriptException();
    return env.Null();
  }

  std::string canvas_id = info[0].As<Napi::String>().Utf8Value();
  std::string color = info[1].As<Napi::String>().Utf8Value();
  double size = info[2].As<Napi::Number>().DoubleValue();
  double opacity = info[3].As<Napi::Number>().DoubleValue();

  bool success =
      NativeTextureCanvasRegistry::Get().SetBrush(canvas_id, color, size, opacity);
  return Napi::Boolean::New(env, success);
}

Napi::Value Clear(const Napi::CallbackInfo& info) {
  Napi::Env env = info.Env();
  if (info.Length() < 1 || !info[0].IsString()) {
    Napi::TypeError::New(env, "Expected (string canvasId)")
        .ThrowAsJavaScriptException();
    return env.Null();
  }

  std::string canvas_id = info[0].As<Napi::String>().Utf8Value();
  bool success = NativeTextureCanvasRegistry::Get().Clear(canvas_id);
  return Napi::Boolean::New(env, success);
}

Napi::Value NativeTextureCanvasModuleMethodsBinder(
    Napi::Env env, Napi::Value exports, const char* module_name,
    NativeTextureCanvasModule& module) {
  if (!exports.IsObject()) {
    return exports;
  }
  Napi::Object exports_obj = exports.As<Napi::Object>();
  exports_obj.Set("setBrush", Napi::Function::New(env, SetBrush, "setBrush"));
  exports_obj.Set("clear", Napi::Function::New(env, Clear, "clear"));
  return exports;
}

}  // namespace

void NativeTextureCanvasModule::OnLynxViewCreate(lynx_view_t* lynx_view) {
  lynx_view_register_native_view(lynx_view, "native-texture-canvas",
                                 &native_texture_canvas_create_view, lynx_view);
}

void NativeTextureCanvasModule::OnLynxViewDestroy() {}
void NativeTextureCanvasModule::OnRuntimeInit() {}

void NativeTextureCanvasModule::OnRuntimeAttach(
    Napi::Env env,
    std::unique_ptr<lynx::pub::VSyncObserver> vsync_observer) {
  SetNapiInstanceData(
      env, kNativeTextureCanvasModuleID, this,
      [](Napi::Env, void*, void*) {}, nullptr);
}

void NativeTextureCanvasModule::OnRuntimeReady(Napi::Env env,
                                               Napi::Value lynx,
                                               const char* url) {}
void NativeTextureCanvasModule::OnRuntimeDetach() {}
void NativeTextureCanvasModule::OnEnterForeground() {}
void NativeTextureCanvasModule::OnEnterBackground() {}
void NativeTextureCanvasModule::Destroy() {}

}  // namespace extension

LYNX_EXTERN_C lynx_extension_module_t*
native_texture_canvas_module_create_extension_module(void* opaque) {
  auto* module = new extension::NativeTextureCanvasModule();
  lynx_extension_module_t* c_module =
      lynx_extension_module_create_with_finalizer(
          module, [](lynx_extension_module_t* m, void* user_data) {
            if (user_data) {
              delete reinterpret_cast<extension::NativeTextureCanvasModule*>(
                  user_data);
            }
          });

  module->SetCModule(c_module);
  module->SetNapiModuleCreator(&extension::NativeTextureCanvasModuleMethodsBinder);
  return c_module;
}

```

v0.0.8



> Lynx UI 通过注册的原生模块控制 native texture surface，在同一组件树中组合原生渲染与前端式交互。

## Multiplatform

Lynxtron 不是把 Lynx 锁在桌面端。借助 Lynx，UI 可以运行在包括 Web 在内的多个平台上，也可以用较低成本迁移到新的宿主环境。


**下面是一个示例: cross-platform-notes**

**Bundle:** `dist/desktop/main.lynx.bundle` | Web host: `dist/web/index.html`

```ts {71-87,146-149,165-178}
type NoteSummary = {
  id: string;
  title: string;
  excerpt: string;
  updatedAt: string;
};

type NoteRecord = {
  id: string;
  title: string;
  content: string;
  updatedAt: string;
  createdAt?: string;
};

type NoteDraft = {
  id?: string;
  title?: string;
  content?: string;
};

type PlatformInfo = {
  kind: 'desktop' | 'web';
  runtime: string;
  storage: string;
  detail: string;
};

type DesktopBridge = {
  notes?: {
    list(): NoteSummary[];
    get(id: string): NoteRecord | null;
    create(draft?: NoteDraft): NoteRecord;
    save(draft: NoteDraft): NoteRecord;
    remove(id: string): boolean;
  };
  platform?: {
    getInfo(): {
      kind: 'desktop';
      os: string;
      arch: string;
      storage: 'filesystem';
      storageDir: string;
    };
  };
};

type WebBridge = {
  list(): Promise<NoteSummary[]>;
  get(id: string): Promise<NoteRecord | null>;
  create(): Promise<NoteRecord>;
  save(note: {
    id: string;
    title: string;
    content: string;
  }): Promise<NoteRecord>;
  remove(id: string): Promise<void>;
  platform(): Promise<{
    platform: 'web';
    runtime: 'browser';
    storage: 'localStorage';
    version: string;
  }>;
};

type UnifiedNotesApi = {
  list(): Promise<NoteSummary[]>;
  get(id: string): Promise<NoteRecord | null>;
  create(): Promise<NoteRecord>;
  save(draft: NoteDraft): Promise<NoteRecord>;
  remove(id: string): Promise<boolean>;
  getPlatformInfo(): Promise<PlatformInfo>;
};

function desktopBridge(): DesktopBridge | null {
  try {
    // @ts-ignore - NativeModules is provided by Lynx desktop runtime
    return NativeModules?.nodejs?.exposed ?? null;
  } catch {
    return null;
  }
}

function webBridge(): WebBridge | null {
  try {
    // @ts-ignore - injected by Web Core from lynxView.nativeModulesMap
    return NativeModules?.webNotes ?? null;
  } catch {
    return null;
  }
}

function fallbackSummary(note: NoteRecord): NoteSummary {
  const excerpt = note.content.replace(/\s+/g, ' ').trim().slice(0, 120);
  return {
    id: note.id,
    title: note.title,
    excerpt: excerpt || 'No content yet',
    updatedAt: note.updatedAt,
  };
}

function fallbackApi(): UnifiedNotesApi {
  let record: NoteRecord = {
    id: 'local-fallback',
    title: 'Desktop release plan',
    content:
      '# Desktop release plan\n\nShip the Lynx UI, verify native capabilities, and share one bundle across hosts.',
    updatedAt: new Date().toISOString(),
  };

  return {
    async list() {
      return [fallbackSummary(record)];
    },
    async get(id: string) {
      return id === record.id ? record : null;
    },
    async create() {
      record = {
        id: `local-${Date.now()}`,
        title: 'New idea',
        content: '# New idea\n\nCapture the next product thought here.',
        updatedAt: new Date().toISOString(),
      };
      return record;
    },
    async save(draft: NoteDraft) {
      record = {
        id: draft.id ?? record.id,
        title: draft.title ?? record.title,
        content: draft.content ?? record.content,
        updatedAt: new Date().toISOString(),
      };
      return record;
    },
    async remove(id: string) {
      return id === record.id;
    },
    async getPlatformInfo() {
      return {
        kind: 'web',
        runtime: 'fallback',
        storage: 'memory',
        detail: 'Bridge unavailable',
      };
    },
  };
}

export function getNotesApi(): UnifiedNotesApi {
  const desktop = desktopBridge();
  if (desktop?.notes && desktop.platform) {
    return {
      async list() {
        return desktop.notes!.list();
      },
      async get(id: string) {
        return desktop.notes!.get(id);
      },
      async create() {
        return desktop.notes!.create();
      },
      async save(draft: NoteDraft) {
        return desktop.notes!.save(draft);
      },
      async remove(id: string) {
        return desktop.notes!.remove(id);
      },
      async getPlatformInfo() {
        const info = desktop.platform!.getInfo();
        return {
          kind: 'desktop',
          runtime: `${info.os} ${info.arch}`,
          storage: info.storage,
          detail: info.storageDir,
        };
      },
    };
  }

  const web = webBridge();
  if (web) {
    return {
      async list() {
        return web.list();
      },
      async get(id: string) {
        return web.get(id);
      },
      async create() {
        return web.create();
      },
      async save(draft: NoteDraft) {
        const current = draft.id ? await web.get(draft.id) : null;
        return web.save({
          id: draft.id ?? current?.id ?? `note-${Date.now()}`,
          title: draft.title ?? current?.title ?? 'New idea',
          content: draft.content ?? current?.content ?? '',
        });
      },
      async remove(id: string) {
        await web.remove(id);
        return true;
      },
      async getPlatformInfo() {
        const info = await web.platform();
        return {
          kind: 'web',
          runtime: `${info.runtime} ${info.version}`,
          storage: info.storage,
          detail: 'localStorage',
        };
      },
    };
  }

  return fallbackApi();
}

export type { NoteSummary, NoteRecord, PlatformInfo, UnifiedNotesApi };

```

v0.0.6



> 同一套 Lynx UI 只依赖统一的 notes API。构建时，桌面和 Web 目标会分别将该 API 接入 Node preload bridge 和浏览器侧 bridge。

这对应的是 Lynxtron 的跨平台工程模型：保持 Lynx UI 层可复用，把平台相关逻辑隔离在宿主适配层中，并在需要时将渲染器模型迁移到新的宿主。

## 工程边界

对开发者来说，更重要的是可检查的源码边界：宿主进程负责桌面能力，Lynx UI 负责界面和交互，原生扩展负责需要平台能力的部分。Lynxtron 的设计重点不是把所有能力收进同一层，而是让每一层承担自己最擅长的职责。

## 开始使用

前往 [Lynxtron 快速上手](/next/zh/lynxtron/introduction.md)，创建并运行你的第一个工程。
