lynx-stack
repository·main·Indexed 20 days ago
https://github.com/lynx-family/lynx-stackThe core Frontend stack for the Lynx ecosystem, providing essential tools and libraries including ReactLynx, Rspeedy, and Lynx for Web to enable high-performance cross-platform UI development. The stack includes utilities for error-remapping regression tests, asynchronous external bundle loading via @lynx-js/external-bundle-rsbuild-plugin, and the background-only marker package to enforce Background Thread context. It also features the A2UI Catalog Extractor CLI (@lynx-js/genui) for converting TypeScript component interfaces into A2UI component catalog JSON.
What's inside lynx-stack
- This package provides the implementation of the standard WebSocket API specifically for the Lynx environment. It allows developers to establish full-duplex communication channels over a single TCP connection within Lynx applications.
Overview of @lynx-js/repl
mainThe
@lynx-js/replis a pure-browser playground designed for experimenting with Vanilla Lynx. It allows users to write raw Element PAPI code and see real-time rendering without requiring a local toolchain, Node.js, or a compilation server.Because it runs entirely in the browser, it is ideal for learners, documentation examples, and quick experiments. However, it is intentionally limited to avoid overlapping with the full
rspeedy devtoolchain.What is @lynx-js/cache-events-webpack-plugin?
mainThe@lynx-js/cache-events-webpack-pluginis a Webpack plugin designed for Lynx applications. It manages the timing of native events by caching them until the BTS (Business Thread) chunk is fully loaded. Once the BTS chunk is ready, the plugin replays the cached events to ensure they are processed correctly in the application lifecycle.Overview of Testing Library for Lynx
mainThe Testing Library for Lynx is a unit testing suite designed for the Lynx framework. It follows the same principles and patterns as the standard Testing Library, providing utilities to test components in a way that mimics user interaction.
It is composed of two primary packages:
@lynx-js/testing-environment: A Lynx-specific implementation of a DOM environment, serving as the equivalent tojsdom.@lynx-js/react/testing-library: A testing library specifically for React components running on Lynx, equivalent to@testing-library/preact.
Overview of ReactLynx
mainReactLynx is a framework designed to build cross-platform Lynx applications using the React paradigm. It is built on top of modern React implementations and is specifically optimized for the Lynx dual-threaded architecture to ensure instant launch and high UI responsiveness.
Key features include:
- React 17+ Alignment: Full support for functional components, Hooks, and Context.
- Lynx Optimization: A dual-threaded React implementation tailored for Lynx's performance model.
- Ecosystem Compatibility: Supports popular libraries such as Jotai, Zustand, and TanStack Query, along with Fast Refresh and React DevTools.
Overview of @lynx-js/template-webpack-plugin
mainThe@lynx-js/template-webpack-pluginis a Webpack plugin designed to simplify the creation oftemplate.jsfiles used to serve Lynx bundles. It functions similarly tohtml-webpack-plugin, but is specifically tailored for the Lynx ecosystem to automate the generation of the necessary entry templates.Use @lynx-js/web-rsbuild-server-middleware for Lynx Web Platform mocking
mainThe@lynx-js/web-rsbuild-server-middlewareis a Rsbuild dev server middleware designed to provide a mocked Lynx Web Platform installation. This allows developers to simulate the Lynx environment during local development using a Rsbuild-based dev server.Use @lynx-js/css-extract-webpack-plugin to extract CSS
mainThe@lynx-js/css-extract-webpack-pluginis a Webpack plugin designed to extract CSS into separate files. It follows a 1:1 mapping strategy where it creates a dedicated CSS file for every JavaScript file that contains CSS content.Use @lynx-js/chunk-loading-webpack-plugin to generate Lynx chunk loading runtime
main@lynx-js/chunk-loading-webpack-plugin is a Webpack plugin designed to generate the necessary chunk loading runtime for Lynx applications. It ensures that code splitting and dynamic chunk loading work correctly within the Lynx environment.Use the Lynx Rust engine bridge for headless environments
mainThe
lynxRust crate is designed for embedding a prebuiltlibLynx_clayruntime into non-windowed (headless) hosts. It allows you to drive Lynx tasks and input events without a standard windowing system.Key Capabilities:
- Load a prebuilt
libLynx_clayruntime from Rust. - Create headless Lynx views.
- Provide windowless renderer callbacks.
- Serve resources (bundles, images, fonts) from Rust via a
GenericResourceFetcher. - Drive Lynx tasks and input events in a non-windowed host.
- Load a prebuilt
Use @lynx-js/runtime-wrapper-webpack-plugin to load JavaScript in Lynx
mainThe@lynx-js/runtime-wrapper-webpack-pluginis a Webpack plugin designed to wrap JavaScript code so that it can be correctly loaded and executed by the Lynx runtime. This is essential for ensuring that your JavaScript modules are compatible with the Lynx environment during the build process.Understand the Lynx Web Platform
mainThe Lynx Web Platform is an implementation of Lynx's native binding APIs using Browser APIs. It aims to provide high-performance solutions with the same appearance and behavior as Lynx on Android and iOS, allowing for cross-platform consistency.
Key Characteristics
- Shared Logic: Your Lynx code, ReactLynx runtime code, and JavaScript-implemented Lynx APIs are shared across Web, Android, and iOS.
- Rendering Pipeline: Unlike native platforms, the Web Platform utilizes the Browser's CSS engine, layout engine, and rendering engine. It uses DOM APIs for rendering, meaning the pixel/rendering pipeline is specific to the browser and does not match the native Android/iOS implementation.
- UI Elements: While native platforms use platform-specific native elements, the Web Platform uses a set of custom elements to provide similar features.