Reference · presolve
Framework API
The presolve package is the application authoring vocabulary (an npm alias for @presolve/framework). Its V2 calls are compiler intrinsics, not a browser component registry, state store, effect scheduler, or renderer.
Canonical 0.2 imports
import {action, defineForm, effect, field,loader, required, slot, state,Component, environment, type Resource,type RouteParameters, type SlotContent,} from "presolve";Component<Props = {}>Base class for an authored component. Export a concrete subclass with one instance render() method. The generic is a type surface; instance input fields remain compiler-resolved.
state<T>(initialValue: T): TDeclares component-owned reactive state initialized from a compiler-admitted value. Read the field normally; mutate it only from an admitted action.
State guide →action(handler)Declares an instance-field action and preserves its component receiver. The beta admits documented state writes, typed primitive parameters, serializable local literals, exact event captures, and closed named-import terminal package calls with synchronous or cancellable Promise<void> completion.
get value()A synchronous pure getter is a computed candidate. The compiler derives dependencies, caching, and invalidation. New beta source does not call computed().
effect(handler)Declares synchronous terminal browser work. The handler may return compiler-admitted cleanup. Effects cannot write reactive state or call actions/effects.
Effect guide →slot(): SlotContentInitializes a default or named slot field. children is the default slot; other field names map to named outlets.
defineForm({ fields, submit })Declares a component-owned Form, typed nested value shape, optional serialization, validation, native submission, and resume membership.
Form guide →field({ initial, validate? })Declares one statically recoverable Field. Bind it with bind:value, bind:checked, or bind:files according to its value class.
required · min · max · minLength · maxLength · pattern · emailCreates a built-in validation rule. A directly imported Standard Schema v1 validator may also participate when TypeScript authority resolves its exact export.
Validation guide →equals(field) · notEquals(field)Creates a compiler-bound cross-Field validation rule. The argument must resolve to another Field in the same canonical Form tree.
Cross-Field validation →loader<Data, Error>(handler): Resource<Data, Error>Declares a route-owned server Resource. The canonical handler receives RouteParameters and AbortSignal and consists of one direct call to an admitted named package import.
environment.public(name): stringReads a manifest-backed public value admitted under the PRESOLVE_PUBLIC_* naming boundary. A same-shaped local object does not acquire compiler authority.
Core types
SlotContentOpaque compiler-owned slot content marker.DefinedForm<Fields>Typed Form with aggregate pristine, dirty, touched, submitting, submitted, valid, and issues state.FormField<Value>Owned value plus pristine, dirty, touched, valid, and issues state.FormFieldTreeA Field, nested object of Fields, or readonly Field-tree array accepted by defineForm.FormValue<Tree>Recursively maps a Form Field tree to its nested submission-value shape.FormDefinition<Fields>Serialization, Fields, and optional typed submission definition.FormFieldOptions<Value>Initial value plus built-in or Standard Schema validators.FormSubmission<Value>Compiler-built nested value, serialized FormData, and submission-owned AbortSignal.FormSerializationjson | form-data | url-encoded.StandardSchemaV1<Input, Output>Supported Standard Schema v1 validation interface.StandardSchemaResult<Output>A transformed output or one or more normalized validation issues.StandardSchemaIssueMessage plus optional property-key path segments.FormFieldValidator<Value>A closed built-in rule or compatible Standard Schema v1 validator.ValidationRuleClosed built-in validation-rule marker.Resource<Data, Error>Route-owned loader data, typed error, and lifecycle state.ResourceStateidle | pending | ready | failed | cancelled.RouteParametersReadonly, compiler-decoded parameter record for the selected file route.ServerActionResultJSON-compatible success data or a same-origin absolute-path redirect object.Historical APIs
Presolve 0.1 declarations are documented only in the migration reference. This reference describes the current beta API and should be treated as the source of truth for new applications.
Import and version rules
- Application source imports framework vocabulary from
presolve; third-party package imports keep their published module names. - Pin framework, CLI, native CLI, TypeScript authority, tooling, and generated artifacts to the same prerelease.
- Do not call framework intrinsics outside compiler-admitted source positions.
- Do not infer semantic support from a TypeScript declaration alone; package use is classified at the exact use site and the compiler diagnostic is authoritative.