Skip to content
المشاريع

حول

إتاحة واجهات JavaScript الحديثة في كل مكان: بيئة تشغيل أصلية مفتوحة المصدر لواجهات المستخدم، تتضمن SolidJS افتراضيًا، إلى جانب Adapter SDK مفتوح لإتاحة أطر JavaScript الحديثة على أجهزة بمختلف أشكالها وأحجامها وقدراتها.

تطوير الويب والتطبيقات

كيف تُقاس هذه الأرقام

1,943 نجمة117 التفرعات +4 خلال 24 ساعة

النمو المقاس للنجوم

خلال 24 ساعة
+٤
خلال 7 أيام
+٣٤
خلال 15 يومًا
+٥٠
خلال شهر
+١٠٨

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

PocketJS

Bringing modern JavaScript UI everywhere. PocketJS is an open-source native UI runtime that brings modern JavaScript frameworks to devices of all shapes, sizes, and capabilities. Build with a compact native engine, then add adaptive components and themes with PocketUI.

@pocketjs/framework @pocketjs/cli license: MIT Discord

Website · Playground · AX333 Benchmark · Documentation · Blog · Changelog · Discord · X

Applications default to TypeScript with SolidJS, while external framework adapters (Vue Vapor, Octane, Svelte 5, React 19, Effect UI, Angular) target the same native tree through @pocketjs/framework/adapter. A QuickJS guest runs the application, and a Rust core performs flexbox layout and draws every pixel in one thread inside one process. There is no DOM, no CSS engine and no WebView. PocketJS is a Pocket Nexus project.

The PocketUI gallery drawn four times from the same source: flat and dark in the Pocket theme; a navy title bar, a menu bar and bevelled buttons in Classic 98; a blue title bar and rounded buttons in XP; three lights, capsule buttons and a blue selection in Aqua. The text typed into its field is the same in all four.

The PocketUI gallery (apps/pocketui) in its four themes, switched while it ran: the text in the field was typed once. On a PSP the gallery is a 213 KB bundle and draws a frame in 16.7 ms.

In this repository

Beside the PocketJS runtime, this repository holds the technology that Pocket projects build on:

What it is Entry point
PocketJS The application runtime: TypeScript components, a QuickJS guest and a Rust core that lays out and draws every pixel This README · pocketjs.dev
PocketUI @pocketjs/framework/ui: adaptive components for Solid applications, and four themes (Pocket, Classic 98, XP, Aqua) that switch under a running application docs/POCKETUI.md · apps/pocketui
MicroTS An ahead-of-time compiler from TypeScript views and models to Rust, in development microts/ · microts.pocket.nexus

Contents

Familiar tools

SolidJS is the built-in default framework in this repository, compiling JSX to @pocketjs/framework/solid over the native tree. Any other JavaScript framework targets the same native tree and QuickJS guest through the external adapter SDK (@pocketjs/framework/adapter). Reference adapters for Vue Vapor, Octane, Svelte 5, React 19, Effect UI, Angular, and Vanilla live in pocket-nexus/ax333/adapters/.

Framework primitives are imported from solid-js (or the external framework package). PocketJS owns the runtime, host components, lifecycle wiring, input, animation, assets and the native boundary.

import { createSignal, Show } from "solid-js";
import { mount } from "@pocketjs/framework/solid";
import { Text, View } from "@pocketjs/framework/solid/components";

function Counter() {
  const [count, setCount] = createSignal(0);

  return (
    <View class="w-full h-full flex-col items-center gap-4 p-4 bg-slate-50">
      <Text class="text-xl text-slate-950 font-bold">Count: {count()}</Text>
      <View
        class="px-4 py-2 rounded-xl shadow-md bg-blue-600 focus:bg-blue-500"
        focusable
        onPress={() => setCount(count() + 1)}
      >
        <Text class="text-base text-white font-bold">Press Circle</Text>
      </View>
      <Show when={count() > 3}>
        <Text class="text-sm text-emerald-600">Reactive on real hardware.</Text>
      </Show>
    </View>
  );
}

mount(() => <Counter />);

Styling

Class literals are compiled into a baked style table at build time. The runtime resolves a class attribute by lookup, so there is no CSS parser, cascade, specificity resolution or reflow on the device. The accepted vocabulary is a fixed Tailwind subset, enumerated in Styling.

One bundle, many screens

One bundle serves machines of different densities. An application states the hosts it is built for, its viewport and the features it turns on in the app section of its pocket.host.config.ts, and each host contract must present that viewport before compilation and packaging proceed. With hosts: ["psp", "vita"], run from the application directory:

pocket check --target psp     # ok  480x272 · text.glyphs.baked · input.buttons
pocket check --target vita    # ok  same bundle, density 2, no component edited

From your component to a pixel

The guest emits tree mutations; the core owns layout, the style table and the draw list; a per-target backend submits that draw list through GE, GXM, Metal, wgpu, software rasterization, e-ink updates or another declared host.

PocketJS · 1 thread, 1 process
  your component                        guest
  renderer adapter                      guest
  native tree                           core
  flexbox layout, baked style table     core
  drawlist                              core
  backend draw                          core
  → pixels

Browser or WebView · 4 threads, 2 processes
  your component                        main
  framework runtime, vdom diff          main
  dom mutation                          main
  cssom, cascade, specificity           main
  style recalculation                   main
  layout, reflow                        main
  paint records                         main
  commit the layer tree across threads
  layer tree, tiling                    compositor
  queue raster tasks, invalidations     compositor
  rasterization                         raster pool
  ipc to the gpu process, sync fences
  draw quads                            gpu
  present                               gpu
  → pixels

See also: Architecture · Frameworks

Smooth motion

Keyframe timelines and spring curves are baked into the same style table at build time and advanced by the Rust core on its own clock, so a screen animates with no per-frame JavaScript. Motion Lab (apps/motions) runs the yui540 studies on the handheld they were written for.

Motion studies by yui540: menu, d-pad, share, hover, reload and keypad animations, with the (yui540) credit

Small footprint

With no browser engine in the pipeline, the cost of a screen stays close to what the hardware can do. A complete application drawing an animated interface occupies 8 MB on a single 333 MHz core: a quarter of the PSP's 32 MB, one part in 1536 of a 12 GB iPhone 17 Pro Max, on a core clocked 13 times slower than an A19 Pro performance core at 4.26 GHz.

On a Sony PSP

One MIPS core at 333 MHz, 32 MB of RAM, measured against the 16.67 ms budget for 60 fps:

Measurement Result
Hero demo, cost of a virtual DOM Solid 15.15 ms · Vue Vapor 16.74 ms · Vue with a virtual DOM 90.75 ms
Hero demo, the three shipped frameworks Solid 3.66 ms · Vue Vapor 3.61 ms · Octane 6.53 ms

Seven samples per application. The two hero-demo rows come from separate runs with different toolchain versions, so each row is comparable internally but not against the other.

See also: Twice the pixels, zero forks · The first iPhone

Replay every frame

PocketJS advances an application one frame(buttons) call at a time, and time is the frame counter. A frame is a transaction that nothing outside it can interrupt, and nothing waits on a wall clock, so tests replay the same sequence as fast as the CPU allows without changing the timing they measure: a journey that takes six seconds in front of a user is a few dozen frames in CI.

state n+1 = F(state n, input n)
pixels n  = G(state n)
  • Effects land on frame boundaries. A network reply that arrives partway through frame +3 is queued, not applied. It is delivered at the start of frame +4, in FIFO order, before any application hook runs. There are no microtask races and no mid-frame callbacks, and after() replaces setTimeout with a deadline measured in frames.
  • An async task lands on the same frame every run. Driven by requestAnimationFrame against a wall clock, one awaited confirmation lands on 22 different frames across 60 runs, and its timing assertion passes 9 times out of 60. On the frame clock it lands on frame 144 in every run, 60 out of 60.
  • History is a data structure. Tapes replay byte for byte, a session subsampled to 2 Hz is byte-identical to its 60 Hz counterpart, and forking a tape at frame 9 to splice in a different press produces the other outcome in 22 ms.
  • Chaos mode checks the guarantee, injecting sleeps, allocation churn and forced GC between frames without moving the trace by one bit.

See also: The runtime that can't flake · Time-travel DevTools · Determinism

Native modules

Cores are independent native modules, loaded the way a kernel loads drivers: an application takes the ones its content needs, such as networking or audio, and the rest never enters the build. The JavaScript uses them beside the same UI and input APIs.

TypeScript application → guest bundle, one frame at a time
  ui       tree, layout, draw, input, focus
  net      poll batches
  audio    pcm mixer

See also: Architecture · The runtime family

Choose your screen

PocketJS has booted on every operating system below, on the real machine. What changes between them is one native host, never the application, and each row links to the post or pull request that brought it up. Device programs, host contracts and build tools are maintained in this repository; see Device native builds.

Operating system Native host Receipt
PSP system software MIPS, 32 MB Introducing PocketJS
PS Vita system software ARM, GXM Twice the pixels, zero forks
iOS 12.5.8 arm64 #278
iOS, current NativeScript host #256
macOS Metal widgets programs/macos-widget
Symbian Belle Qt, GLES2 Symbian wanted a frame function
BlackBerry 10 QNX, native A Square Screen and a Dead Signing Server
iPhone OS 3.1.3 ARMv6, UIKit host in C No Shaders, No Objective-C
Windows CE 6 Win32, GDI From Message Pump to Multitouch
PocketBook e-ink inkview, partial refresh #172
ESP-IDF 6.0/6.1 P4 PPA or S3 software RGB565 ESP-IDF components
The browser WebAssembly core Playground

Devices it has booted on: Sony PSP (2004), PS Vita (2011), iPhone (2007), iPod touch 4 (2010), iPod touch 6 (2015), Nokia E7 (2011), Meizu M8 (2009), BlackBerry Classic (2014), PocketBook reader (e-ink), ESP32-P4 devkit (microcontroller) and Mac (Apple silicon). The Nintendo 3DS runs several of the applications in the next section.

A real BlackBerry Classic on a desk, its square screen running the PocketJS Hero demo above the physical keyboard
BlackBerry Classic, BlackBerry 10, 720×720. A photo of the phone.
The PocketJS Hero demo at 320 by 480, headline 'JSX on ARMv6.', read off an original iPhone's framebuffer
iPhone (2007), 320×480. Read back off the phone's framebuffer.
PocketJS on a Meizu M8 at its native 480 by 720 resolution
Meizu M8, Windows CE 6, 480×720.
The PocketJS Hero demo at the Nokia E7's native 640 by 360
Nokia E7, Symbian Belle, 640×360.
The Gallery demo on PS Vita at 960 by 544: six procedural texture tiles with a controller-hint status bar
PS Vita, 960×544.
A settings screen on a PSP: sound, vibration and brightness controls and a theme picker
Sony PSP, 480×272.

The authoritative host and target inventory is contracts/spec/platforms.ts; each entry records what has been verified and how. See Platform contracts and the Native contract.

Made with PocketJS

A desktop shell on a dual-screen handheld, applets for every screen, a music player for a PSP. Each row links to the project, and some to the story of how it was built.

Omarchy Pocket on an AYN Thor: a shell, an activity monitor, a clock and notes tiled on one screen
Omarchy Pocket, tiled windows on an AYN Thor
Weather, Hacker News, GitHub and other applets tiled in Omarchy Pocket
Pocket Applets in Omarchy Pocket
Pocket Lody's session list and a coding-agent transcript in the Pocket theme
Pocket Lody, a coding-agent client on PocketUI
Pocket YouTube on a PSP: search results for psp with thumbnails, durations, titles and view counts
Pocket YouTube, search results on a PSP
Pocket Figma on a PSP: a design file's Welcome page fit to the screen at 8% zoom
Pocket Figma, a 14,430-node file on a PSP
PSPMAN playing a track on a PSP
PSPMAN by ObsoleteSony, on a PSP
Pocket Shell's home screen of app icons on an M5Stack Tab5
Pocket Shell on an M5Stack Tab5
The Hacker News applet's front page on an M5Stack Tab5
Hacker News applet on an M5Stack Tab5
The DevTools panel with the Header node pinned, next to the device screen with the same header highlighted
Pocket DevTools, the inspector beside the device
Project Devices What it is
Omarchy Pocket Anbernic RG DS Plus Omarchy's CLI, config and services under a PocketJS shell on a dual-screen handheld: terminals, windows, an on-screen keyboard and applets
Pocket Applets Omarchy Pocket, M5Stack Tab5, 3DS Weather, Hacker News, GitHub, Home Assistant and ten more from one source, and the store at applets.pocket.nexus
Pocket Lody AYN Thor, touch and button screens A coding-agent workspace client built on PocketUI, in all four themes
M5Stack firmware M5Stack Tab5, StopWatch, StickS3, AtomS3 Reference ESP-IDF firmware: factory demo recreations and board demos, each built as a QuickJS bundle or as MicroTS AOT Rust. Notes
Pocket Tools M5Stack CardputerZero A launcher of hardware tools: level, IR remote, radio, metronome, calculator
Pocket Figma PSP, PS Vita A 14,430-node design file, cooked into streamed tile pyramids and panned with the analog nub at 60 fps on a handheld with 32 MB of RAM. Story
Pocket YouTube 3DS, PSP, PS Vita Watch on the upper screen while searching and browsing on the touch screen. A Mac companion streams video to the 3DS over Wi-Fi. Story
Pocket Shell 3DS, M5Stack Tab5, PSP A launcher for Pocket Applets: it pairs with Pocket Hub on a Mac, installs the applets Pocket Hub offers and switches between them
Pocket Doc 3DS A Markdown library on two screens: read above, edit and navigate below
Pocket Map 3DS, PSP OpenStreetMap or Hyrule on a handheld: pan with the touchpad, zoom, search and save places through a paired Mac
Pocket Term 3DS Mac shell sessions above a touch keyboard
PSPMAN PSP A Walkman-inspired music player by ObsoleteSony: local FLAC and MP3, album art and cassette mode
Pocket DevTools every backend Time-travel debugging over a USB cable at 2 bytes per frame. The inspector highlight is emitted by the core into the draw list, so it renders on the device

Get started

The zero-install path is the online Playground. Local browser development requires Bun and Rust via rustup:

git clone https://github.com/pocket-nexus/pocketjs
cd pocketjs
bun install
rustup target add wasm32-unknown-unknown
bun run dev                    # build WASM + the Hero app, then serve the browser host

The pocket CLI runs on Bun. The CLI reference lists its commands, scaffolding options and target toolchains:

bun add -g @pocketjs/cli       # or: npm install -g @pocketjs/cli
pocket target add psp          # install the PSP toolchain the framework pins
pocket create my-app           # a standalone project; `bun run check` and `bun run build` wrap the CLI
cd my-app && bun install
bun run build                  # pocket compile: the application's .pkb bundle

The native device program builds from a checkout: pocket build --target psp --bundle <application.pkb> --out dist/psp embeds a compiled bundle in the PSP program; pocket psp <app> --release does the same for a demo under apps/. Vita packaging additionally requires VitaSDK and the pinned Rust toolchain documented in programs/vita/README.md. A guest build is one bundle per host contract: a .pkb file holding the plan, the scripts and the asset pack. The Getting started guide walks through a first application.

Ahead-of-time compilation

The TypeScript support reference compares ordinary application code, AOT views and compiled model bodies, including their restrictions and current implementation limits.

MicroTS compiles Solid TSX and Vue SFC views to Rust through a shared typed View IR. app.model: "compiled" also compiles the supported TypeScript model subset to Rust. The default "rust" mode uses an application-provided Rust model implementing the same generated trait. Native AOT calls the retained UI core without a guest engine; the host still owns input, services and presentation.

bun microts/compiler/cli.ts build solid-aot-lab --strict
cargo check --locked --manifest-path apps/solid-aot-lab/Cargo.toml

The guest build runs that model's TypeScript source as written; its tasks resume at frame boundaries in both builds. JavaScript is an execution format; the application source contract remains TypeScript. Rust AOT uses alloc, with capacity tags for bounded strings and arrays. Demo gen/ directories are ignored and must be regenerated before Cargo builds.

The earlier C/cartridge experiment lives in a separate repository with its own TypeScript subset, target profiles, examples and toolchains. Those sources and scripts are not part of this repository or the Rust AOT build.

Working on PocketJS

Repository layout

Path Responsibility
framework/ Public framework APIs, renderers, components, input, lifecycle and build-time styling
engine/ no_std UI core, render backends, native modules, Pocket3D and platform-native crates
devices/ Pocket3D device kernels for GXM, GE and PICA200
engine/pocket3d/ The Pocket3D entry point: its design and a map of where its code lives
microts/ The MicroTS ahead-of-time compiler
contracts/ Generated wire specs, capability registry, app and host contract schemas, build plans and the bundle format
programs/ Runtime composition, entry points and native build recipes
hosts/ Built-in host contracts (hosts/<id>/pocket.host.json) identified by content hashes
platforms/ Operating-system, SDK and fixed-console drivers
platforms/esp-idf/ Runtime, QuickJS, display, PPA, input and runner components
platforms/sifli/ SiFli SF32LB5x hooks, EPIC/VG Lite executor and renderer, display, input, guest and runner
apps/ Framework demos and system applications used by the acceptance suites
tools/ Build, package, device, DevTools, benchmark and release commands
tests/ Contract, compiler, simulation, emulator, package and golden verification
docs/ Platform, runtime, determinism, DevTools, backend and benchmark records
site/ This website (site/nexus/ holds the pocket.nexus homepage, site/pocket3d/ the 3d.pocket.nexus homepage, site/microts/ the microts.pocket.nexus docs and playground)

Building and testing

Emulator journeys require their external toolchains:

bun run test                  # contracts, compiler, packages, sims, and host suites
bun run golden                # deterministic WASM/web frame goldens
bun run e2e                   # PPSSPP journey
bun run e2e:vita              # Vita3K native-density journey
bun run site:build            # docs, playground, Stage, and landing build
bun run site:preview          # build, then serve the site at http://127.0.0.1:4173/

Documentation

Topic Reference
First application Getting started
Frameworks, components, styling Frameworks · Components · Styling
Runtime internals Architecture · Native contract
Targets and packaging Platform contracts · Bundles and the app platform
Debugging and verification DevTools · Determinism
Components and themes PocketUI · The runtime family
Ahead-of-time compilation MicroTS · TypeScript support
Complete examples apps/ · Blog

Sponsors and Pocket Nexus

PocketJS is developed full-time with the support of its sponsors, who are listed on the website.

PocketJS is built by Pocket Nexus, an independent, non-VC-backed lab that starts from this runtime to explore new possibilities in computing, interaction and creation, so that the joy of creating belongs to everyone. Its other projects are listed on the GitHub organization.

Attribution

The original motion studies are by yui540. PocketJS accepts yui540's two stated conditions for continued use: Motion Lab carries the requested (yui540) on-screen credit, and any other yui540 animation requires separate permission before it is ported. The accepted scope and capture-maintenance rules are recorded in apps/motions/ATTRIBUTION.md.

License

PocketJS and MicroTS are MIT licensed. Inter is vendored under the OFL in assets/fonts/.

Pocket3D, the files under devices/ and engine/pocket3d/, is under the Pocket3D License. It grants what the MIT License grants, with one more condition: a distributed product that draws 3D scenes with Pocket3D shows the Pocket3D title card when it starts. PocketJS's own hosts and the applications built on them are exempt. A separate written license removes the condition: write to [email protected].

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…