vue-lynx

repository·main·Indexed 19 days ago

https://github.com/huxpro/vue-lynx

A custom Vue 3 renderer that enables building applications for the Lynx framework, bridging the Vue ecosystem with Lynx's high-performance runtime. It supports a Single File Component (SFC) pipeline including <script setup>, template interpolation, dynamic attribute binding, and directives like v-if and v-for, as well as plain h() render functions.

Tokens
99.7K
Snippets
225
Records
438
Agent score
64%

What's inside vue-lynx

  1. What is vue-lynx

    main

    vue-lynx is a Vue 3 custom renderer designed for building applications on Lynx. It allows developers to use Vue's core features and ecosystem to target the Lynx runtime.

    Note: This project is currently in Pre-Alpha status; expect bugs.

  2. Introduction to Vue Lynx

    main
    Vue Lynx is a Vue 3 custom renderer for Lynx. It allows you to build native Lynx applications using the Vue Composition API, single-file components (SFCs), and Vue's reactive data model. It is designed for high-performance native rendering on mobile and desktop, while also supporting web rendering.
  3. Status of Vue API Exports in Vue Lynx

    main

    Vue Lynx re-exports approximately 80 Vue 3 public APIs. These are categorized by their compatibility with the Lynx dual-thread model and renderer:

    • Confirmed Safe: Pure JavaScript APIs (reactivity, utilities) that have zero renderer dependency (e.g., ref, reactive, computed, isRef).
    • Implicitly Verified: APIs used by the Vue template compiler (e.g., withDefaults, withMemo, createSlots). If Single File Components (SFCs) render correctly, these are functional.
    • Needs Verification: APIs that are exported but require targeted testing to ensure they work within the Lynx dual-thread pipeline (e.g., useId, useModel, onErrorCaptured).
    • Deprecated/Broken: APIs that require renderer options not currently implemented in Vue Lynx (e.g., createStaticVNode, Teleport).
  4. Explore the TodoMVC Example

    main
    The TodoMVC example is a reference implementation of the classic TodoMVC application built using Vue 3 and Lynx. It demonstrates how to build a modern, polished UI with improved layout and scrolling behaviors using CSS Selector styling. This example is useful for understanding how to compose multiple components in a Lynx environment.
  5. Implementation variants of the Swiper component

    main

    The Swiper example provides three distinct implementation patterns for creating horizontal image galleries in Vue Lynx, ported from React Lynx. Depending on your requirements for interactivity and performance, you can choose from:

    1. SwiperEmpty: A static horizontal gallery with no touch interaction. It is used to demonstrate basic linear layouts using Lynx's display: linear property.
    2. Swiper (Full): A high-level composable-based implementation that provides full touch interaction. It utilizes several internal composables to manage state and animation:
      • useUpdateSwiperStyle: Manages the container reference and sets styles on the Main Thread (MT).
      • useOffset: Handles touch events, manages offset clamping, controls animations, and synchronizes via runOnBackground.
      • useAnimate: A shared RequestAnimationFrame (RAF) animation utility.
    3. SwiperMTS: An optimized version designed for zero-latency dragging. It uses Main Thread Script (MTS) touch handling, where all touch event processing is executed directly on the main thread using the 'main thread' directive, bypassing cross-thread communication latency.
  6. Understand the Main Thread touch playground (touch-fx)

    main

    The touch-fx example demonstrates high-performance touch animations that run entirely on the Main Thread to avoid the latency of Background-to-Main Thread (BG↔MT) round-trips.

    Key features include:

    • Spring Physics: An orb that chases finger movement with damped spring physics, including squash and stretch effects.
    • Water Ripples: Continuous pulsing rings under the finger during a drag.
    • Particle Effects: Firework sparks on touch-down/release and ember trails during movement.
    • Multi-touch Support: Each additional finger triggers its own set of effects.

    By using 'main thread' worklets and a requestAnimationFrame loop, the animation remains fluid and responsive to touch input without waiting for the Background Thread to process updates.

  7. SFC Features supported in Vue Lynx

    main

    The Vue Lynx SFC pipeline supports standard Vue features. Based on the basic example, the following features are exercised and supported:

    • <script setup> including defineProps and defineEmits macros.
    • Template interpolation using {{ interpolation }}.
    • Dynamic attribute binding such as :style.
    • Directives: v-if, v-else, v-show, and v-for.
    • Event handling using @tap (the Lynx-specific tap event).
    • Child component referencing.
  8. Compare Elk on Lynx vs original Elk visual fidelity

    main

    The @vue-lynx-example/elk package provides a port of the Elk social client to Lynx. This documentation provides visual comparisons between the Lynx implementation (running on Lynx for Web via @lynx-js/web-core's <lynx-view>) and the original Elk running in Chromium.

    When evaluating the port, focus on the anatomy of the UI components rather than the specific content of the timelines, as both versions connect to live instances (e.g., mas.to) at different times.

  9. Identify the core packages in Vue Vine x Lynx

    main

    The implementation relies on three primary packages:

    • @vue-vine/runtime-lynx: Provides the Vue 3 custom renderer, the dual-thread event system, and the Worklet runtime.
    • @vue-vine/rspeedy-plugin-vue-vine: An Rspeedy/Rsbuild build plugin that manages dual-bundle splitting for the Main and Background threads.
    • packages/e2e-lynx: A demo/test application used to showcase progressive implementation stages.
  10. Key technologies used in HackerNews Slopfork

    main

    The HackerNews Slopfork example showcases the integration of several modern web technologies within the Vue Lynx environment:

    • Tailwind CSS: Uses @lynx-js/tailwind-preset to map atomic utility classes to Lynx flexbox properties.
    • Vue Router: Implements client-side routing using createMemoryHistory().
    • Pinia: Handles state management for user and feed data.
    • Vue Query: Manages server state caching and prefetching.
    • Transitions: Utilizes slide animations for page transitions.
  11. Verified MVP Capabilities

    main

    The current implementation supports the following core features:

    • Basic Rendering: view, text, and image elements.
    • Styling: CSS inline styles (e.g., backgroundColor, padding, fontSize) and CSS class + selector support (via enableCSSSelector: true).
    • Reactivity: Reactive updates via Vue's engine.
    • Directives: v-if and v-for logic.
    • Events: bindtap and MTS (Main Thread Service) worklet events.
    • Lists: <list> virtual list support.
    • Main Thread Integration: MainThreadRef element binding, MainThreadRef value state, and runOnMainThread execution.
  12. Features of HackerNews Slopfork (Original CSS)

    main

    The HackerNews Slopfork example showcases several key capabilities within the Vue Lynx environment:

    • Original Styles: Demonstrates robust support for traditional web CSS, including .class selectors, nesting, and CSS variables.
    • Vue Router: Implements client-side routing using createMemoryHistory().
    • Pinia: Utilizes Pinia for managing user and feed state.
    • Vue Query: Uses Vue Query for server state caching and prefetching.
    • Transitions: Includes slide animations for page transitions.