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, preloadImage, 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 = the bar for design mockups — pager.md; the system's own tab bar (iOS 26 Liquid Glass) is the native UI plugin's host node UIGlassTabBarNode — native-plugins.md
  • UIWidget — floating overlays (+ UIModal dialogs, UIPopover anchored menus, UIBottomSheet) — widget.md
  • UIVirtualizedList — windowed lists for long data — virtualized-list.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 — 3D physics 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, groups, draw order (renderPriority, z, Y-sort), picking, the HUD's touch rule, systems, UIImage(scene) — scene2d.md
  • Node2D — base node: transform, draw order, hierarchy, events, animateTo — node2d.md
  • Camera2D — position, zoom, screen↔world (via scene.camera) — camera2d.md
  • Sprite — textured node; frames, tint, flip — sprite.md
  • Text2D, Font2D — SDF text in the world: labels in world units or screen px, wrap, line cap with "…", outline, bounds; fonts loaded once — text2d.md
  • Path2D — lines, polygons, rects, circles, rounded rects, arcs and Bézier curves (Path2D.shape), px-wide strokes, holes — path2d.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/path/text/particles/camera/make nodes, draw order, aspects, the follow camera — scene-files.md
  • Shape2D, Physics2D, Trigger2D, OneWay2D, CharacterController2D, PhysicsGroup2D — 2D physics 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 (desktop on macOS, an XDR screen) — 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, notifications): query the state, request the dialog where the user expects it, openSettings for a denied one — permissions.md
  • notifications — local notifications: schedule one at a time / daily / weekly / now, onTap (the cold-start tap too), cancel, pending; iOS and Android — notifications.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, trackGesture — pointer events, ev.track() drags and hovers, pinch / twist / pan as one gesture — 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, secureStorage — persistent key/value strings; secrets (a token, a PIN) encrypted by the OS: Keychain on iOS, Keystore on Android — 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, online — server functions: *.server.ts endpoints, channels and computeds on the le.codes app backend; online = does the app reach it now — 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
  • ai (server code: AiError too) — the project's language model, no key in the code: ai.send (text, a typed object, pictures), ai.tool (functions the model calls, questions the person answers), chats (ai.createChat) — and in the app ai.messagesResource(id), a chat's messages live while the answer is written — ai.md
  • env — the project's keys (tokens, client secrets, maps keys) kept out of the code: the .env file locally, Project Settings → Keys on le.codes; the app sees only PUBLIC_… keys — keys.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/

  • Service — raw channel to host-registered headless services (app-local / third-party) — service.md
  • NativeView — a host-registered platform view shown full screen (map, camera, …): the channel under every view plugin — native-view.md
  • plugin nodes — a plugin's live control as a box of a screen's layout (UIMapNode, UICameraNode, UIWebViewNode, UIRTCVideoNode): sizing, supported, settings, events — host-node.md
  • CameraView, UICameraNode — device camera preview + photo (a JPEG File), front / back, the flash and the torch; UICameraNode is the preview inside a screen's layout (iOS, Android) — camera-view.md
  • QRScanner — host-optional QR scanning — qrscanner.md
  • Geolocation — device position (one-shot + watch) — geolocation.md
  • BackgroundAudio — one audio record that plays on in the background and on the lock screen (an audio guide, a podcast): state, length, position — background-audio.md
  • AudioRecorder — the microphone: a recording to a file (voice messages, music): start / pause / stop, a duration limit; the volume (level) and the note that is played or sung (pitch, AudioRecorder.note) live — a tuner, a singing game, with or without a file — audio-recorder.md
  • SpeechRecognizer — speech to text, live (the platform's recognizer): partial and final results, one utterance or continuous — speech.md
  • Torch — the phone's flashlight: on / off, brightness, whether there is one, changes by the system or another app; no permission (iOS, Android) — torch.md
  • Contacts — the phone's address book: the system's contact picker (no permission), the contacts list with phones / emails / photos behind the contacts permission, a new contact or an edit through the system's own editor (iOS, Android; the picker in Chrome on Android) — contacts.md
  • Calendar — the device's calendars: "add to calendar" through the system's event editor (no permission), the user's events for a date range and the calendars behind the calendar permission, an event's card to edit it (iOS, Android) — calendar.md
  • MapView, UIMapNode — vector map (maplibre-native; maplibre-gl in the web player): a style (free ready-made by default), marker/line layers, camera, user puck; UIMapNode is the map inside a screen's layout (iOS, Android) — map-view.md
  • pushChannel (server) + Push — push notifications: a server export sent to a signed-in user (groupByUser), a group (groupBy) or everyone subscribed, heard in the app with onTap; Push for a project without a backend — push.md
  • Browser, UIWebViewNode, WebView — web content inside the app: the system browser sheet for pages, OAuth sign-in and hosted checkouts; UIWebViewNode is a web page inside a screen's layout (iOS, Android), WebView one full screen — browser.md
  • RtcConnection, RtcMedia, RtcTrack, RtcDataChannel, UIRTCVideoNode, RTCVideoView — calls between phones and browsers over one fixed profile (Opus, H.264, data channels): video and voice calls, a group as a connection per participant, peer-to-peer messages; signaling is the app's; UIRTCVideoNode draws a track inside a screen's layout (iOS, Android, the web), RTCVideoView full screen — rtc.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 (→ docs/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): docs/AUTHORING.md, "Verifying examples".

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).

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).

Generating images or audio with AI

No; the project's model (ai) answers text and typed objects and looks at pictures, it makes none — another provider's image API is a fetch from server code, its key in env (runtime/keys.md).

No embeddings API and no vector index; ai.send with tools that query the database is the nearest route (runtime/ai.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.

Changing contacts or calendar events without the user

No API creates, edits or deletes a contact or an event silently: Contacts.openEditor / Contacts.openCard and Calendar.openEditor / Calendar.openEvent open the system's own screens and the user saves (contacts.md, calendar.md).

Reminders and to-do lists

No API for the system's reminders; a reminder of the app's own is a local notification (notifications.md).

Call history and text messages

No API to read the call log or SMS.

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.

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.

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).

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).