SDK reference

The complete API reference for le.codes projects. Everything here is an import-free global — user code references UIScreen, Scene, Sprite, fetch, … directly; the build injects the implementation and tree-shakes what a project doesn't use.

Start with conventions.md — units, coordinate systems, value semantics, host gating, no top-level await, and the lifecycle rules every page assumes. Most apps are UI apps: the entry point for the UI layer is ui/overview.md (the element model plus the shape of a typical app — tokens/theme() module, screens, tab shell).

This reference documents the API surface only. How to BUILD a whole thing out of it (enemy AI, a squad, a game mode) is the cookbook — recipes anchored to reference projects. What the platform does NOT have, with the nearest route, is listed at the end under Not available.

The whole surface at a glance

One line per global. Bold = the page that documents it.

UI — ui/

  • element model: factories, chaining, refs, conditional children, the shape of an app — overview.md
  • .style() model: properties, units, safe areas, animateTo — styling.md
  • theme — app-wide style variables (var()), kit keys, live re-theming — theme.md
  • style classes: $name state blocks, el.class, cascade, the reserved $hovered/$pressed/$focused/$landscape/$portrait — classes.md
  • UIRow, UIColumn, UIBox (centering), UIScrollable, UISpacer — containers.md
  • UIText, UIImage, UIVideo, assetIcon — content.md
  • UIButton, UIInput, UITextArea — interactive.md
  • UIScreen, Router, Presentable — screens, the navigation stack, screen transitions, the back-press chain — screen-router.md
  • UIPager, UITabs, defineTabs — tabs with a stack each; UITabs = the standard bottom-tab shell, defineTabs = its bar for design mockups — pager.md
  • UIWidget — floating overlays (+ UIModal dialogs, UIPopover anchored menus, UIBottomSheet) — widget.md
  • UIVirtualizedList — windowed lists for long data — virtualized-list.md
  • NativeView — host-registered platform views (map, camera, …) — native-view.md
  • font, registerFont — fonts — fonts.md

3D engine — 3d/

  • Scene, VRScene — 3D world: IBL / sky / fog / TAA, runtime graphics knobs, overlays, warm-up; VRScene for a headset — scene.md
  • scene.postProcessing — the look: tone mapping, colour grading, a .cube LUT, bloom, vignette, ambient occlusion, screen-space reflections, depth of field; apply() / reset() — post-processing.md
  • ARScene, Anchor, ImageAnchor, ARPlane — AR over the device camera (the ar plugin: ARKit, ARCore, the browser's camera + sensors): tracking, planes, hit test, anchors, image targets, light, placement controls — arscene.md
  • Node — base node: transform, hierarchy, events, tweens, ownership — node.md
  • Camera — lens, exposure, screen rays, follow, world→screen (via scene.camera) — camera.md
  • Mesh, InstancedMesh — box / sphere / cylinder / capsule / plane factories, custom geometry, one geometry drawn N times — mesh.md
  • Model — GLB loading; clip playback via the pre-attached Animator (model.anim) — model.md
  • AnimationClip, Animator, Playback, Loop, Layer — the animation system: clips from other files / curves / derived (window, mirror), loops and 1D/2D blends, one-shots with hand-over promises, layers (masks, additive), clip events, root motion, clipInfo measurements — animation.md
  • IK, Feet — two-bone / look-at chains on bones (sockets, anchored hands), anim.feet: foot lock, ground IK, footstep events — ik.md
  • Locomotion, Warp — character movement from an intent (starts, stops, turns, gait blend, actions) + anim.warp stride / orientation warping — locomotion.md
  • DynamicBone, DynamicBoneCollider — secondary motion: tails, ears, hair, ropes, cloaks — dynamic-bones.md
  • Geometry — raw vertex data, primitive builders, geometry files (Geometry.load) — geometry.md
  • Material, defineMaterial, MaterialHandle — built-in materials by name (lit / unlit / shadow / video …), project .mat shaders, material assets (*.material.ts) — material.md
  • Texture — 3D material image: PNG / JPG / KTX2, raw pixels, engine-wide anisotropy and size cap (not interchangeable with Texture2D) — texture.md
  • Light — Light.sun() directional light + shadows, Light.point() lamps, Light.spot() cones (ambient comes from scene IBL) — light.md
  • Lightmap — baked lighting (sun, sky, lamps, bounces) for static geometry + a light grid for movers (lecodes lightmap bake) — lightmap.md
  • Foliage — vegetation: wind, plants that lean away from the hero, distance fade, per-copy tint (Model.load { foliage }) — foliage.md
  • Terrain — heightfield ground: four splat layers (roughness per pixel in the albedo alpha), sculpt / paint / roads / holes, .terrain files, the heightfield collider — terrain.md
  • Shape, Physics, Trigger, CharacterController — Jolt bodies, sensors, raycasts, the character mover — physics.md
  • Vehicle, Wheel, Tire, resolveTire — car physics as hardware: engine, clutch, steering column, per-wheel suspension and tire curves, inputs + readouts (gearbox and wheel posing are the game's) — vehicle.md
  • Ragdoll — a skinned model's skeleton handed to physics: falls, powered hit reactions, hand-back to the animator — ragdoll.md
  • NavMesh, NavAgent, NavCrowd — baked navigation mesh (lecodes navmesh bake), path queries, areas, crowd agents — navmesh.md
  • Particles, Trail, curve, colorCurve — GPU particle systems, ribbon trails, curves over a particle's life — particles.md
  • DecalSet, DecalTrail — projected decals: bullet holes, footprints, skid marks — decals.md
  • AudioSource, AudioZone, SceneAudio — 3D sound: emitters on nodes (distance, cone, doppler, occlusion), audio.playAt, reverb zones, the listener (scene.audio), HRTF — audio.md
  • Ray, Plane, Noise — picking & procedural helpers — ray-plane-noise.md
  • defineScene, use, ref, make, SceneHandle, CameraPlace, Gizmos, InspectorUI, EDITOR — scenes as data (.scene.ts, the scene-editor format): nodes, prefabs, instantiate, the camera place, generator aspects, inspector cards — scene-files.md
  • Level — procedural placement for make() factories: line / grid / ring / scatter / place, seeded — level.md
  • MoveTo, FollowPath, Spin, LookAt, PlayAnimation — ready-made no-code behaviors — scenario-aspects.md
  • registerEditorWindow, registerEditorTool — scene-editor plugins (*.editor.ts): windows, click / drag / hover tools — editor-plugins.md

2D engine — 2d/

  • Scene2D — 2D world: background, layers, Y-sort, picking, systems, UIImage(scene) — scene2d.md
  • Node2D — base node: transform, hierarchy, events, animateTo — node2d.md
  • Camera2D — position, zoom, screen↔world (via scene.camera) — camera2d.md
  • Sprite — textured node; frames, tint, flip — sprite.md
  • SpriteAnimation — sprite-sheet clips aspect (node.anim) — sprite-animation.md
  • defineSpriteSheet, SpriteSheet — .sprite.ts sheets: named regions, slice grids, clips, make() — sprite-sheets.md
  • defineScene2d, Scene2dHandle, cells, encodeCells, CameraFollow — .scene2d.ts scenes: sprite/tilemap/camera/make nodes, layers, aspects, the follow camera — scene-files.md
  • Shape2D, Physics2D, Trigger2D, OneWay2D, CharacterController2D, PhysicsGroup2D — Box2D bodies, sensors, one-way ledges, the character mover, collision groups, queries — physics2d.md
  • Tilemap — atlas tile grid, natively culled — tilemap.md
  • defineTileset, Tileset, Autotile2D, rawCell / isRawCell / rawIndex, rot90 / rot180 / rot270 / flipX / packTile / tileIndex / tileTurns / tileFlip / tileOriented — .tiles.ts autotile materials, raw and oriented tile values — tilesets.md
  • Texture2D — 2D image loading — texture2d.md

Core — core/

  • signal, computed, effect — reactive state; () => value bindings in UI text/styles — signals.md
  • Aspect — attachable node capabilities; node.aspect(Class, opts), updateBefore / updateFixed / update phases, static after / updateOrder ordering, events, Aspect.all — aspects.md
  • System — an aspect of the scene (input, FX pools, HUD, game mode): scene.system(Class) — systems.md
  • Time — the game clock: Time.scale, Time.paused, Time.dt / unscaledDt / fixedDt, now, frame — time.md
  • StateMachine, defineStates — hierarchical state machine as one declarative table: guards, timed transitions, events, $back; brains, weapons, game modes — state-machine.md
  • Canvas, Bitmap — retained 2D drawing that bakes to textures (2D/3D/UI); loadImage (SVG / image bytes), toBitmap, toFile — canvas.md
  • the addEventListener pattern shared by scenes, nodes, device, app, Router, players, voices and sockets — events.md

Runtime — runtime/

  • device — platform (input model: web / ios / android / desktop), language and localization (the app's strings per language), size, pixelRatio, resize, connectivity, precise touch, haptics, motion sensor, HDR (not implemented yet) — device.md
  • app, clipboard, openURL — lifecycle (pause/resume), deep links, orientation lock, back-press fallback (app.onBack), restart / quit, keyboard inset, sdkVersion, system clipboard, external URLs — app.md
  • permissions — the OS permissions (camera, microphone, location, speech): query the state, request the dialog where the user expects it, openSettings for a denied one — permissions.md
  • Input, InputChannel — keyboard / mouse / gamepad: Input.key(code) polling (mouse + gamepad buttons are keys), Input.on('keydown') events, Input.mouse.delta + pointer lock + onUI, Input.gamepad(i).axis() / .rumble(); InputChannel = the host's channel ids — input.md
  • ClickEvent, TouchStartEvent, LongPressEvent, MouseEnterEvent — pointer events, ev.track() drags and hovers — touch.md
  • fetch, fetchLocal, FormData, File — HTTP over the host; sync body reads; fetchLocal = a host file by name — network.md
  • WebSocket — browser-like text sockets — network.md
  • localStorage — persistent key/value strings — storage.md
  • AudioPlayer, VideoPlayer — the platform's streaming players (music, voice-over, video); video-as-texture — media.md
  • Sound, Voice, Bus, REVERB_PRESETS, audio — game audio: clips decoded up front, a voice pool (audio.play, loops, pitch, variants), buses with low-pass / echo / reverb; host-gated (audio.supported) — audio.md
  • openFilePicker, share, files — file picking, native share sheet, the app's own files (desktop, iOS) — files-share.md
  • toast, SvgSource — native toast; SVG-as-image-source — misc.md
  • date — dayjs-style dates: format, relative time, arithmetic, comparison (English + Russian) — datetime.md
  • Net, NetPlayer, Replicated, NetEntity — server-authoritative multiplayer: roles (offline / host / client / dedicated server), players, JSON messages, per-tick input, replicated entities with prediction and interpolation — multiplayer.md
  • RpcError — server functions: *.server.ts endpoints and channels on the le.codes app backend — server-functions.md
  • server code only: model, t, defineDb, ref — the backend's database: models, queries, writes, transactions — database.md
  • server code only: t.file(), t.image(), a File parameter — files the app uploads and the backend keeps: photos, avatars, attachments — stored-files.md
  • server code only: db.auth — accounts: passwords, email codes, your own sign-in, guests, devices — sign-in.md

Animation — animate/

  • animate — free-value tween (ms): numbers, CSS colors, vectors, quaternions, matrices → onUpdate; returns the Animation handle — animate.md
  • Timeline — choreography on one clock: tracks on UI elements, 3D / 2D nodes, lights, the camera; labels, calls, holds, stagger — timeline.md
  • easeIn, easeOut, easeInOut, cubicBezier — easing functions + the curve names every tween takes ('outCubic', [x1,y1,x2,y2], 'steps(n)') — easings.md

Math — math/

  • Mathf — scalar helpers: clamp, lerp, damp, remap, random — mathf.md
  • Vec2, Vec3 — fluent vectors; mutable fields, pure methods, tuple-interop — vectors.md
  • Quat — rotations: fromEuler, fromAxisAngle, slerp, lookRotation — quat.md
  • Mat4 — 4×4 matrix: compose/decompose, lookAt, perspective; raw .m exposed — mat4.md
  • Color — parse/convert any ColorInput form — color.md

Plugins — plugins/

  • CameraView — device camera preview + photo (a JPEG File) — camera-view.md
  • QRScanner — host-optional QR scanning — qrscanner.md
  • Geolocation — device position (one-shot + watch) — geolocation.md
  • AudioRecorder — the microphone to a file (voice messages): start / pause / stop, a level meter, a duration limit — audio-recorder.md
  • SpeechRecognizer — speech to text, live (the platform's recognizer): partial and final results, one utterance or continuous — speech.md
  • MapView — vector map (maplibre-native; maplibre-gl in the web player): a style (free ready-made by default), marker/line layers, camera, user puck — map-view.md
  • Push — remote push notifications (register + payload events; le.codes relays the sends) — push.md
  • Browser, WebView — web content inside the app: the system browser sheet for pages, OAuth sign-in and hosted checkouts, and an embedded web view — browser.md
  • RTCPeerConnection, mediaDevices, RTCVideoView (+ MediaStream, MediaStreamTrack, RTCDataChannel, …) — the browser's WebRTC API: calls, video, data channels; signaling is the app's — webrtc.md
  • Service — raw channel to host-registered headless services (app-local / third-party) — service.md

Host globals — globals.md

  • setLoop / clearLoop — per-frame host loop; dt in seconds, unscaled (game logic → Aspect / System)
  • setTimeout / setInterval / clearTimeout / clearInterval — timers (ms; one-frame resolution and a required delay on the native runtime)
  • console — log / warn / info / error
  • asset() — compile-time macro: project file path → bundled resource reference (.json → its data, .svg → an SvgSource)
  • DEG2RAD / RAD2DEG — compile-time angle constants
  • Style<T> — editor-only helper type for reusable UI style objects

Coverage tooling

bun run docs:check (→ check.mjs) verifies that every global exported from src/inject.ts (+ host globals) has exactly one canonical page, that sources: paths exist, and that relative links resolve. How a page's examples are checked (type-check, headless, the windowless native host): AUTHORING.md.

Not available

What the platform does not have. When a search lands here, tell the person it cannot be done in a LeCodes app (and offer the nearest route named), instead of inventing an API.

Keeping the screen awake

No API; the screen dims and locks when the OS decides, even while a timer runs (a playing video keeps it on only where the system player does: iOS and the browsers, not Android).

Local and scheduled notifications

No API; a reminder at a set time can only be a remote push that your own server sends at that time (Push, iOS and Android — plugins/push.md).

Saving to the photo library

No direct API; share(file) opens the OS share sheet — iOS offers "Save Image" for an image, Android also writes an image or an MP4 to the gallery, the web shares or downloads the file (runtime/files-share.md).

Text-to-speech

No API (SpeechRecognizer only listens); play recorded or server-generated speech with AudioPlayer (runtime/media.md).

Translations and string tables

None built in; keep a table of strings per language and pick it by device.language (runtime/device.md).

Number and currency formatting for a locale

No API, and Intl does not exist on Android or on Windows and Linux (toLocaleString prints plain digits there); format numbers and money in your own code.

Dates in other languages, time zones

date().format() and timeAgo() know English and Russian only (any other device language gets English), and there is no time-zone API: every date is the device's local time (runtime/datetime.md).

Right-to-left layout

No; layouts are always left-to-right (mirror a row with flexDirection: 'row-reverse'), and on desktop Arabic and Hebrew text itself is drawn unshaped, left to right.

Bluetooth and BLE devices

No API.

NFC

No API for reading or writing tags.

Contacts

No API to read the contacts or let the user pick one.

The calendar

No API to read or add calendar events (UIInput type 'date' is a date field, not the calendar).

Health data: steps, heart rate, workouts

No API to read or write Apple Health / Health Connect data or the step counter.

Face ID, Touch ID and fingerprint unlock

No API; a web sign-in with passkeys opened with Browser.open is the nearest (plugins/browser.md).

In-app purchases and subscriptions

No App Store or Google Play billing; take payments on a hosted checkout page opened with Browser.open (plugins/browser.md).

Apple Pay and Google Pay buttons

No native API; a hosted checkout page in Browser.open (the system browser sheet) can offer them.

Ads from an ad network (AdMob and others)

No API; no ad network SDK is part of the platform.

Sign in with Apple or Google buttons

No native sign-in; open the provider's OAuth page with Browser.open(url, { returnUrl }) and sign the user in on your server with db.auth.signIn(userId) (runtime/sign-in.md).

Running code in the background

No; on iOS and Android the app's code pauses when it leaves the foreground — stop work on pause and save data as it changes (runtime/app.md).

Location in the background

No; Geolocation works while the app is in the foreground.

Audio in the background or on the lock screen

No background audio mode; on iOS the sound stops when the app leaves the foreground.

Downloads that continue in the background

No; fetch() runs while the app is open and holds the whole file in memory.

Home-screen widgets

No (UIWidget is an overlay inside the app — ui/widget.md).

Recording video

No API; CameraView takes still photos, AudioRecorder records sound, and openFilePicker({ accept: 'video/*' }) picks an existing video.

Flashlight / torch

No API.

Barcodes other than QR

No; QRScanner reads QR codes only (EAN, UPC, Code 128 … are not decoded).

SQLite or another SQL engine on the phone

No SQLite on the device; small values go to localStorage or stored signals, files to files (desktop, iOS) (runtime/storage.md).

Secure storage for secrets (Keychain / Keystore)

No; localStorage is a plain file in the app's sandbox.

Screenshots of the UI, screen recording

No API; scene.capture() returns a 3D scene's frame (without the UI over it) and Canvas.toFile() a canvas drawing.

Images on the clipboard

No; a picture cannot go on the clipboard — send it with share(file).

Printing

No API; share() an image, or open a page with openURL and print from the system.

The store's rating and review prompt

No API; link to the app's store page with openURL.

App icon shortcuts

No (the long-press menu on the app's icon).

Receiving shared items from other apps

No; only links reach the app, through its urlScheme (app.launchUrl, the "url" event — runtime/app.md).

Screen brightness and the system volume

No API; AudioPlayer.volume sets the app's own sound.

Setting the app icon's badge

No API from the app; a push sent with a badge number sets it (plugins/push.md).

Showing or reading a PDF

No PDF API; open its URL with Browser.open (shown in the app on iOS and in browsers with a PDF viewer, not by Android's WebView) or with openURL.

Drag and drop between apps

No; inside the app a drag is touch tracking (ev.track — runtime/touch.md).