/** * Manifest ambient type declarations. * https://manifestx.dev * * This file gives editors (VS Code, Cursor, JetBrains) and AI coding assistants * type information for Manifest's magic globals and data-source state. It is * intended to live in the project root and is regenerated by `npx mnfst-types` * to add project-specific augmentations to ManifestSources from manifest.json. * * Hand-edits below the AUGMENTATION marker will be overwritten on regeneration. */ // --------------------------------------------------------------------------- // Data-source state and operators (attached to every $x.) // --------------------------------------------------------------------------- /** Appwrite-style query expression returned by helper builders. */ export type ManifestQueryExpr = string; /** Appwrite-style query helpers. */ export interface ManifestQuery { equal(field: string, value: unknown): ManifestQueryExpr; notEqual(field: string, value: unknown): ManifestQueryExpr; lessThan(field: string, value: number | string): ManifestQueryExpr; lessThanEqual(field: string, value: number | string): ManifestQueryExpr; greaterThan(field: string, value: number | string): ManifestQueryExpr; greaterThanEqual(field: string, value: number | string): ManifestQueryExpr; between(field: string, start: number | string, end: number | string): ManifestQueryExpr; contains(field: string, value: string | string[]): ManifestQueryExpr; startsWith(field: string, value: string): ManifestQueryExpr; endsWith(field: string, value: string): ManifestQueryExpr; search(field: string, value: string): ManifestQueryExpr; isNull(field: string): ManifestQueryExpr; isNotNull(field: string): ManifestQueryExpr; select(fields: string[]): ManifestQueryExpr; orderAsc(field: string): ManifestQueryExpr; orderDesc(field: string): ManifestQueryExpr; limit(value: number): ManifestQueryExpr; offset(value: number): ManifestQueryExpr; cursorAfter(id: string): ManifestQueryExpr; cursorBefore(id: string): ManifestQueryExpr; } /** A column of row type `T` (or a dot path into a relationship). Any string when `T` is loose. */ export type ManifestColumn = string extends keyof T ? string : (keyof T & string) | `${keyof T & string}.${string}`; type ManifestCompare = 'equal' | 'notEqual' | 'greaterThan' | 'greaterThanOrEqual' | 'greaterThanEqual' | 'lessThan' | 'lessThanOrEqual' | 'lessThanEqual' | 'contains' | 'startsWith' | 'endsWith' | 'search'; /** One `$query` expression: `[method, column, ...values]`. Column names are checked against the row type. */ export type ManifestQueryTuple = | [ManifestCompare, ManifestColumn, ...unknown[]] | ['between', ManifestColumn, unknown, unknown] | ['isNull' | 'isNotNull' | 'orderAsc' | 'orderDesc', ManifestColumn] | ['orderRandom'] | ['limit' | 'offset', number] | ['cursorAfter' | 'cursorBefore', string] | ['or', ManifestQueryTuple[]]; /** State flags exposed on every data source (array or object). */ export interface ManifestSourceState { /** True during a fetch or mutation. */ readonly $loading: boolean; /** Last error from a load or mutation, or null. */ readonly $error: string | null; /** True once the source has settled (loaded, or resolved empty because its scope can't apply). */ readonly $ready: boolean; /** True while cached rows show and fresh data is still loading. */ readonly $stale: boolean; /** Resolves once fresh data has landed. */ readonly $fresh: Promise; /** Fetch again; Appwrite tables keep the active `$query` and paged rows. */ $reload(): Promise; } /** Fields Appwrite adds to every row. */ export interface ManifestRowSystem { $id: string; $createdAt: string; $updatedAt: string; $sequence?: number; $permissions?: string[]; $tableId?: string; $databaseId?: string; /** Files linked to the row when the source configures `storage`. */ $files?: ManifestFile[]; } /** A file row from an Appwrite bucket source. */ export interface ManifestFile { $id: string; name: string; mimeType: string; sizeOriginal: number; $createdAt: string; $updatedAt: string; readonly $url?: string; readonly $isImage?: boolean; readonly $isPdf?: boolean; readonly $formattedSize?: string | null; readonly $thumbnailUrl?: string | null; } /** Search weights: `{ title: 3, body: 1 }`. */ export type ManifestSearchWeights = Partial, number>>; /** Operators available on array-shaped sources (CSV tabular, JSON arrays, Appwrite tables). */ export interface ManifestArrayOps { /** Substring match across the given fields, or a ranked search with field weights. */ $search(term: string, ...fields: ManifestColumn[]): ManifestArraySource; $search(term: string, weights: ManifestSearchWeights): ManifestArraySource; /** Local sources: filter synchronously (chainable with `$search`). */ $query(queries: ManifestQueryTuple[]): ManifestArraySource; /** The row whose `field` matches a segment of the current URL. */ $route(field?: ManifestColumn): T | undefined; } /** A cursor page from `$first`, `$next` and `$prev`. */ export interface ManifestCursorPage { items: T[]; cursor: string | null; total: number; hasMore: boolean; } /** An offset page from `$page`. */ export interface ManifestOffsetPage { items: T[]; page: number; total: number; totalPages: number; hasMore: boolean; } /** `$update` list form: one entry per row. */ export type ManifestUpdateList = Array<{ id?: string; $id?: string; data: Partial }>; /** Options for `$duplicate` on table rows: field overrides plus copy controls. */ export type ManifestDuplicateOptions = Partial & { newRowId?: string; files?: 'duplicate' | 'same' | 'none' }; /** Reads, mutations and paging on Appwrite-table sources. */ export interface ManifestAppwriteTableOps { /** Server-side query with expressions or a named query from manifest.json; replaces the source's rows. */ $query(queriesOrName: ManifestQueryTuple[] | string): Promise; $create(values: Partial, rowId?: string): Promise; /** One row by id, several by ids, or a list of `{ id, data }` (no second argument). */ $update>( target: I, ...values: 0 extends (1 & I) ? [values?: Partial] : I extends ManifestUpdateList ? [] : [values: Partial] ): Promise<0 extends (1 & I) ? T : I extends string ? T : T[]>; $delete(id: string): Promise; $delete(ids: string[]): Promise; $duplicate(id: string, options?: ManifestDuplicateOptions): Promise; $first(limit?: number): Promise>; $next(cursor: string, limit?: number): Promise>; $prev(cursor: string, limit?: number): Promise>; $page(page: number, limit?: number): Promise>; /** Realtime events skipped by the growth cap since the last load. */ readonly $realtimeOverflow: number; /** Loads the next page into the source (`paging` sources only); resolves with the rows added. */ $more(): Promise; /** Whether `$more()` can load another page; false at the end or at `max`. */ readonly $hasMore: boolean; /** Appwrite's count for the current filters, or null when not requested. */ readonly $total: number | null; /** True when `$total` hit Appwrite's counting ceiling. */ readonly $totalCapped: boolean; /** Whether a write to row `id` is still unconfirmed. */ $saving(id: string): boolean; /** Rows with an unconfirmed write. */ readonly $pending: number; } /** Detail of `manifest:data-mutation-success` / `manifest:data-mutation-error` on window. */ export interface ManifestMutationDetail { mutationId: string; type: 'create' | 'update' | 'delete'; dataSourceName: string; entryId?: string; result?: unknown; error?: unknown; } /** Operations available on Appwrite-bucket (storage) sources. */ export interface ManifestAppwriteBucketOps { $url(fileId: string, token?: string): string; $preview(fileId: string, options?: Record, token?: string): string; $download(fileId: string, token?: string): string; $openUrl(fileId: string, token?: string): void; $openPreview(fileId: string, options?: Record, token?: string): void; $openDownload(fileId: string, filename?: string, token?: string): void; $create(file: File | Blob, fileId?: string, permissions?: string[], onProgress?: (progress: unknown) => void): Promise; $upload(file: File | Blob, opts?: Record): Promise; $remove(fileId: string): Promise; $delete(fileId: string | string[]): Promise; $duplicate(fileId: string, options?: { newName?: string; newFileId?: string }): Promise; $filesFor(tableName: string, entryId: string, fileIdsColumn?: string): Promise; $first(limit?: number): Promise>; $next(cursor: string, limit?: number): Promise>; $prev(cursor: string, limit?: number): Promise>; $page(page: number, limit?: number): Promise>; $unlinkFrom(tableName: string, entryId: string, file: string | { $id: string }, fileIdsColumn?: string): Promise; $removeFrom(tableName: string, entryId: string, file: string | { $id: string }, fileIdsColumn?: string): Promise; } /** * `$x.` for an array-of-rows source (CSV tabular, JSON arrays). * Behaves as a regular `T[]` plus Manifest operators and state flags. */ export type ManifestArraySource = & ReadonlyArray & ManifestSourceState & ManifestArrayOps; /** `$x.` for an Appwrite table: rows plus server-side queries, mutations and paging. */ export type ManifestTableSource = & ReadonlyArray & ManifestSourceState & Omit, '$query'> & ManifestAppwriteTableOps; /** `$x.` for an object-shaped source (CSV key-value, JSON object, YAML map). */ export type ManifestObjectSource = T & ManifestSourceState; /** `$x.` for an Appwrite storage bucket. */ export type ManifestBucketSource = ReadonlyArray & ManifestSourceState & ManifestAppwriteBucketOps; /** * Precise row types, keyed by data source name. Appwrite rows accept any * field until declared here: * * declare module 'mnfst' { interface ManifestRows { tasks: Task } } */ export interface ManifestRows { } /** The row type for source `K`: a declared `ManifestRows` entry, else `Fallback`. */ export type ManifestRowFor = K extends keyof ManifestRows ? ManifestRows[K] & ManifestRowSystem : Fallback; /** * Project data sources, keyed by the names in `manifest.json`'s `data`. * `npx mnfst-types` fills this in below the AUGMENTATION marker. */ export interface ManifestSources { } /** `$x` itself: the sources plus runtime registration and persistence controls. */ export type ManifestData = ManifestSources & { $register(name: string, data: unknown[] | Record): void; $wipe(target?: string | { all: true }): Promise; }; /** `$auth` from the Appwrite auth module. Loose by design — auth API is broad. */ export interface ManifestAuth { readonly current: { $id: string; email?: string; name?: string;[k: string]: unknown } | null; readonly isAuthenticated: boolean; readonly isLoading: boolean; readonly currentTeam: { $id: string; name: string;[k: string]: unknown } | null; readonly teams: Array<{ $id: string; name: string;[k: string]: unknown }>; login(email: string, password?: string): Promise; loginWithMagic(email: string): Promise; loginWithOAuth(provider: string, opts?: Record): Promise; loginAsGuest(): Promise; logout(): Promise; [extra: string]: unknown; } /** `$locale` from the localization module. */ export interface ManifestLocale { readonly current: string; readonly available: string[]; set(locale: string): void; } /** One toast flavor: callable, with `.dismiss` (adds a close button) and `.fixed` (sticky) variants. */ export interface ManifestToastVariant { (message: string, opts?: Record): void; dismiss(message: string, opts?: Record): void; fixed(message: string, opts?: Record): void; } /** `$toast` from the toasts module. Typed variants: `$toast.brand(...)`, `$toast.positive.dismiss(...)`. */ export interface ManifestToast extends ManifestToastVariant { brand: ManifestToastVariant; accent: ManifestToastVariant; positive: ManifestToastVariant; negative: ManifestToastVariant; } /** `$color` from the color module — the current light/dark/system color mode. */ export interface ManifestColor { current: 'light' | 'dark' | 'system' | string; } /** `$colorpicker` from the colorpicker module. Loose by design. */ export interface ManifestColorpicker { (id?: string): Record; [extra: string]: unknown; } /** One URL query parameter handle from `$url.` (reactive). */ export interface ManifestUrlParam { /** Current value (get/set; empty string when absent). */ value: string; /** First value when the param repeats. */ readonly first: string; /** All values for a repeating param. */ readonly all: string[]; set(value: string): void; add(value: string): void; remove(value?: string): void; clear(): void; } /** `$url` from the url-parameters module: `$url.tab.value`, `$url.tag.add('x')`, ... */ export interface ManifestUrl { [param: string]: ManifestUrlParam; } /** `$route` magic — the current route path (e.g. '/docs/elements'). */ export type ManifestRoute = string; /** * `$modify('attr')` — exposed in component HTML. Returns the value of an * attribute set on the parent component instance (Manifest's prop mechanism). */ export type ManifestModify = (attr: string) => string | undefined; /** `$try(fn)` — run a callback and swallow any thrown error, returning undefined on failure. */ export type ManifestTry = (fn: () => T | Promise, errorVar?: string) => Promise; /** `$pay` from the payments module: callable to start checkout, plus portal/state helpers. */ export interface ManifestPay { (ref: string, payload?: Record): Promise; portal(ref?: string, payload?: Record): Promise; refresh(): Promise; register(name: string, adapter: unknown): void; readonly state: Record | undefined; readonly loading: boolean | undefined; [extra: string]: unknown; } /** A conversation handle returned by `$chat.open(...)`. Loose by design. */ export interface ManifestChatHandle { readonly messages: unknown[]; readonly participants: unknown[]; readonly typing: unknown[]; readonly me: unknown; [extra: string]: unknown; } /** `$chat` from the chat module — adapter-based conversation projection. */ export interface ManifestChat { open(conversationId: string, opts?: Record): ManifestChatHandle; merge(handles: ManifestChatHandle[], opts?: Record): ManifestChatHandle; adapter(name: string, factory?: unknown): unknown; flatten(tree: unknown): unknown[]; /** Shared revision counter — trackable even before any handle resolves. */ readonly version: number; [extra: string]: unknown; } /** One `$status.` entry. */ export interface ManifestStatusEntry { readonly state: string; [extra: string]: unknown; } /** `$status` from the status module: `$status.api.state`, iterable, stringifies to the overall state. */ export interface ManifestStatus extends Iterable { readonly [name: string]: any; } /** `$presence` from the Appwrite presences module. */ export interface ManifestPresence { start(opts?: Record): Promise; stop(): void; set(values: Record): Promise; clear(): Promise; of(userId: string): unknown; all(): unknown[]; readonly records: Record; readonly list: unknown[]; readonly ready: boolean; readonly error: unknown; readonly me: unknown; } /** `$date(id?)` from the datepicker module — the picker API for the nearest (or given) instance. */ export type ManifestDate = (id?: string) => Record; /** `x-chart` config object (standalone; annotate config objects with it). */ export interface ManifestChartConfig { type?: 'line' | 'area' | 'bar' | 'combo' | 'scatter' | 'candlestick' | 'ohlc' | 'pie' | 'donut' | 'gauge' | 'heatmap' | 'gantt' | 'map' | (string & {}); labels?: unknown[]; series?: Array<{ name?: string; data?: unknown[]; color?: string; type?: string }>; data?: unknown; height?: number; stacked?: boolean; legend?: boolean; axis?: boolean; grid?: boolean; tooltip?: boolean; dataLabels?: boolean; curve?: 'monotone' | 'linear' | 'step' | 'step-after' | 'step-before' | 'natural' | (string & {}); ticks?: Array; tickAnchor?: 'start' | 'end'; /** Line/area/combo: `false` drops per-point dots; hover columns show every series at that label. Map: marker list. */ points?: boolean | Array>; /** Cartesian (incl. candlestick): widens the y-axis to include it. Gauge: range start. Gantt: axis start (number or date). */ min?: number | string | Date; /** Cartesian (incl. candlestick): widens the y-axis to include it. Gauge: range end. Gantt: axis end (number or date). */ max?: number | string | Date; /** Intl.NumberFormat options for tooltip and data-label values; axis ticks add compact notation. */ format?: Intl.NumberFormatOptions; /** Line/area/combo: label index from which lines are dashed and area fills lighter (e.g. a forecast). */ dashFrom?: number; [key: string]: unknown; } /** `$chart(id?)` from the charts module — the chart API for the nearest (or given) instance. */ export type ManifestChart = (id?: string) => Record; /** `scrollToIndex` / `scrollToKey` options (virtual module). */ export interface ManifestVirtualScrollOptions { /** Where the item lands in the list's viewport. Default 'start'. */ align?: 'start' | 'center' | 'end' | 'nearest'; /** 'smooth' animates (instant under prefers-reduced-motion). Default instant. */ behavior?: 'auto' | 'instant' | 'smooth'; /** Extra px kept clear at the aligned edge, on top of the list's CSS scroll-padding. */ offset?: number; } /** A virtual list's scrolling API. Each call resolves with the item's row element once the row is at the * requested alignment (within 1px); the list then keeps it there while rows around it finish sizing (until * nothing has changed for 400 ms, at most 3 s). If sizes keep changing it resolves after about 1.5 s, * as close as it got. In a block-axis scroll-snap list it jumps (smooth is instant there), the browser * snaps, and it resolves with the row if it is visible, else null. It resolves null when there is no such item, a later different call * supersedes it, the list is scrolled some other way before the row is in place, or the item leaves the * list. The same call again while one is running joins it. */ export interface ManifestVirtualList { scrollToIndex(index: number | string, options?: ManifestVirtualScrollOptions): Promise; scrollToKey(key: unknown, options?: ManifestVirtualScrollOptions): Promise; } /** `$virtual` from the virtual module — the x-virtual list this element is in, or `$virtual(id | element)`. */ export type ManifestVirtual = ManifestVirtualList & ((list: string | Element) => ManifestVirtualList); /** `$export(opts)` from the export module — export the page or a data source (pdf/csv/json/...). */ export type ManifestExport = (opts?: { format?: string; filename?: string; source?: string; data?: unknown; [extra: string]: unknown; }) => Promise; /** `$import(opts)` from the import module — pick a local file and parse it (json/csv). Resolves the parsed data, or null when the dialog is dismissed. */ export type ManifestImport = (opts?: { format?: 'json' | 'csv'; /** Data source to replace with the parsed content. */ source?: string; /** Override the file input's accept list. */ accept?: string; [extra: string]: unknown; }) => Promise; /** `$device` from the utilities module (enriched by the device module when present). */ export interface ManifestDevice { readonly os: string; readonly touch: boolean; readonly online: boolean; readonly standalone: boolean; readonly native: boolean; readonly platform: string; } /** `$share` from the device module — native sheet, web share, or clipboard fallback. */ export type ManifestShare = (opts?: { title?: string; text?: string; url?: string }) => Promise<{ shared: boolean; method: string; cancelled?: boolean }>; /** `$push` from the device module — push/notification permissions and token. */ export interface ManifestPush { /** Ask for permission, on your schedule (never prompted on load). */ request(): Promise<'granted' | 'denied' | 'prompt' | 'unsupported' | string>; /** Register with the platform push service (no-op on the web). */ register(): Promise; onToken(handler: (token: string) => void): void; onReceive(handler: (notification: unknown) => void): void; onTap(handler: (notification: unknown) => void): void; readonly permission: string; readonly token: string | null; [extra: string]: unknown; } /** `$secure` from the device module — Keychain/Keystore via a native plugin; unencrypted localStorage on the web only; rejects on native without a plugin. */ export interface ManifestSecure { get(key: string): Promise; set(key: string, value: string): Promise; remove(key: string): Promise; keys(): Promise; clear(): Promise; use(adapter: unknown): void; } /** `$links` from the device module — deep/universal link handling. */ export interface ManifestLinks { /** Take over an inbound link: link.url is the full URL, link.path the route it maps to. */ on(handler: (link: { url: string; path: string }) => void): void; open(url: string): void; readonly last: string | null; } /** `$app` from the device module — foreground/background state. */ export interface ManifestApp { readonly active: boolean; onChange(handler: (active: boolean) => void): void; } /** `$haptics` from the device module — haptic feedback with web vibration fallback. */ export interface ManifestHaptics { impact(style?: 'LIGHT' | 'MEDIUM' | 'HEAVY' | string): Promise; notification(type?: 'SUCCESS' | 'WARNING' | 'ERROR' | string): Promise; selection(): Promise; vibrate(ms?: number): Promise | unknown; [extra: string]: unknown; } /** `$biometric` from the device module. */ export interface ManifestBiometric { available(): Promise; verify(opts?: { reason?: string; title?: string; subtitle?: string; cancelTitle?: string; fallbackTitle?: string; allowDeviceCredential?: boolean; }): Promise<{ verified: boolean; error?: string; code?: string }>; } /** `$camera` from the device module. */ export interface ManifestCamera { photo(opts?: Record): Promise; pick(opts?: Record): Promise; } /** Edit action names for `$edit.can()` and per-action locks. */ export type ManifestEditAction = 'move' | 'remove' | 'duplicate' | 'text' | 'attrs' | 'size'; /** `can()` also answers 'class' (the class list; component nodes allow only this) and copy/cut/paste. */ /** Class controls on `$edit.classes`. `el` defaults to `$edit.target`. */ export interface ManifestEditClasses { add(cls: string, el?: Element): boolean; remove(cls: string, el?: Element): boolean; toggle(cls: string, el?: Element, force?: boolean): boolean; has(cls: string, el?: Element): boolean; /** Replace the static class list. */ set(value: string, el?: Element): boolean; /** The static classes (bound :class classes excluded). */ list(el?: Element): string[]; } /** Element editor (`x-edit`) — opt-in module. Modifiers: `.text` `.move` `.size` * `.data` (default text + move), `.lock[.action]`, `.gated`, `.persist`, `.bare`, * `.theme`, `.cssvar`. Every edit is logged; actions default to `$edit.target`. */ export interface ManifestEdit { /** True while `.gated` areas are editable. */ active: boolean; canUndo: boolean; canRedo: boolean; /** Bumps on every change to the log or target; read it to make a binding re-evaluate. */ version: number; /** Set a handler to route patches somewhere other than the dev server. */ onPublish: ((patches: unknown[], state: { log: unknown[]; cursor: number }) => unknown) | null; toggle(): void; on(): void; off(): void; undo(): Promise; redo(): Promise; /** Source files that changed since the page loaded, from the last refused publish (also an * `edit:stale` event on document, detail `{ files }`), or a reload held back because it * would lose unpublished edits. */ stale: string[]; /** Edits that could not be applied because the source changed under them (also an * `edit:conflict` event on document, detail `{ conflicts }`, and a console warning). * `element` names what was edited (tag and opening text, or the region for layout); * `value` what the edit held; `reason` says what happened in words. * - A text or attribute edit whose element changed: `prop` is the edited property. * - Layout (`prop: 'structure'`): kept when only unmoved children changed text in place; * dropped when a moved, added or removed child changed, with `value` * `{ changed: [{ was, now }], moved: [...], copies: [{ of, html, text }] }` so typed * content can be recovered. */ conflicts: Array<{ region: string; key: string; element: string; prop: string; value: unknown; before: unknown; reason: string }>; /** Empty `conflicts`. Those of `.persist` regions are kept across reloads until this is called. */ clearConflicts(): void; /** Send every area's patches; on success the history is cleared (the source now holds it). * `rebase: true` takes the current source as the base (writes over external changes). */ publish(opts?: { rebase?: boolean }): Promise; /** The resolved source patches for every area, without sending them. */ patches(): unknown[]; /** The raw delta log — persist it yourself to move edits between devices. */ export(): { log: unknown[]; cursor: number }; /** The piece a right-click landed on (set before any menu opens), or assignable. */ target: Element | null; /** Whether an action applies to `el` (default `$edit.target`): capability and locks. */ can(action: ManifestEditAction | 'class' | 'copy' | 'cut' | 'paste', el?: Element | null): boolean; /** Lock `el` and its subtree for one action, or all when omitted. Logged. A component host * (see `block`) locks by its host key, for all its roots and what is in them. */ lock(el?: Element | null, action?: ManifestEditAction): boolean; unlock(el?: Element | null, action?: ManifestEditAction): boolean; copy(el?: Element): boolean; cut(el?: Element): boolean; paste(el?: Element): boolean; duplicate(el?: Element): boolean; remove(el?: Element): boolean; /** Move a piece into a container (element or area key), before `before` or at the end. */ move(el: Element | null, dest: Element | string, before?: Element | null): boolean; /** Nest a piece into the container before it. */ nest(el?: Element): boolean; /** Move a piece out of its container, after it. */ unnest(el?: Element): boolean; /** The piece containing a node, or null. In a static area a component instance is one * piece, its host (its first rendered root; the rest follow it): it moves, duplicates * (a new instance) and is removed as one, and its markup is not edited from here. */ block(node: Element): Element | null; /** Set an attribute: a string sets it, `true` sets it empty, `null`/`false` removes it. */ attr(name: string, value: string | boolean | null, el?: Element): boolean; classes: ManifestEditClasses; /** Component scope of `el`'s area (default `$edit.target`): `scope(el)` reads it. * Instance overrides apply to an area that wraps exactly one component with no x-edit region * of its own; a component among other content is a host piece of a static area instead, and * a component's own region is edited in its own file. */ scope(el?: Element | null): 'instance' | 'main' | null; /** Set the component scope of `el`'s area (default `$edit.target`); false if it has none. */ scope(value: 'instance' | 'main', el?: Element | null): boolean; /** Revert a component element's instance overrides (the area element reverts all). */ revert(el?: Element): boolean; } /** Rich text editor (`x-rich-text`): the area this element sits in, or the last focused one. */ export interface ManifestRichText { /** The stored value, in the area's format. Assigning replaces the document and resets undo history. */ value: string; focus(): void; /** The href at the caret; assign to set it, assign '' to unlink. */ link: string; /** Document-wide styles (font, size, leading, align, color, background) as CSS custom * properties on the area; not part of the stored value. Assign `{}` to clear. */ all: Record; /** Select the whole document. */ selectAll(): void; /** The current selection and its geometry, or null. Also emitted as a `rich-text:selection` * event and as --rich-text-selection-* custom properties. */ selection: { collapsed: boolean; text: string; x: number; y: number; width: number; height: number; top: number; bottom: number; left: number; right: number; } | null; /** Apply a command. Commands are HTML tag names ('strong', 'h2', 'ul', 'a', 'table', …) plus * 'indent', 'outdent', 'align', 'color', 'background', 'font', 'size', 'leading', 'checklist', * 'unlink', 'clear', 'undo', 'redo', 'block' and the table operations. Every command is also * a method: `$rich.strong()`, `$rich.table(3, 2)` (columns, rows). */ run(command: string, arg?: unknown): void; /** Whether that command is active at the caret. */ active(command: string): boolean; /** Whether that command is available here (format, .inline, caret). */ can(command: string): boolean; /** Read the content as markdown regardless of the storage format. */ markdown(): string; /** Read the content as sanitized HTML regardless of the storage format. */ html(): string; // Inline tags: toggle on the selection, or arm for the next typed text strong(): void; b(): void; em(): void; i(): void; s(): void; del(): void; code(): void; bdi(): void; cite(): void; ins(): void; kbd(): void; mark(): void; q(): void; samp(): void; small(): void; span(): void; sub(): void; sup(): void; u(): void; var(): void; /** `title` attribute (html only). */ abbr(title?: string): void; /** `title` attribute (html only). */ dfn(title?: string): void; /** Direction, default 'rtl' (html only). */ bdo(dir?: 'ltr' | 'rtl' | 'auto'): void; /** Machine-readable `value` (html only). */ data(value?: string): void; /** `datetime` attribute (html only). */ time(datetime?: string): void; /** Link the selection; '' unlinks. */ a(href?: string): void; unlink(): void; br(): void; /** Break opportunity (html only). */ wbr(): void; img(src: string, alt?: string): void; // Block tags: convert the block (again returns to p) p(): void; h1(): void; h2(): void; h3(): void; h4(): void; h5(): void; h6(): void; blockquote(): void; pre(): void; address(): void; ul(): void; ol(): void; li(): void; checklist(): void; hr(): void; figure(): void; figcaption(): void; dl(): void; dt(): void; dd(): void; /** Any block tag by name, e.g. block('h2'). */ block(tag: string): void; /** Insert a columns × rows table (default 3 × 3). */ table(columns?: number, rows?: number): void; 'row-before'(): void; 'row-after'(): void; 'row-remove'(): void; 'column-before'(): void; 'column-after'(): void; 'column-remove'(): void; 'table-remove'(): void; 'table-header'(): void; merge(): void; split(): void; indent(): void; outdent(): void; align(value?: 'start' | 'center' | 'end' | 'justify' | string): void; leading(value: string): void; color(value: string): void; background(value: string): void; font(value: string): void; size(value: string | number): void; clear(): void; undo(): void; redo(): void; } /** Options for `ManifestRichText.attach()`. */ export interface ManifestRichTextAttachOptions { /** 'block' (default) or 'inline' (single line: no block commands, Enter fires `rich-text:enter`). */ mode?: 'block' | 'inline'; /** Inline html only: `
` line breaks are kept, Shift+Enter inserts one, pasted blocks become lines. */ breaks?: boolean; /** 'break': Enter inserts a line break too, instead of firing `rich-text:enter`. Needs `breaks` and the 'html' format. */ enter?: 'break'; /** false: `.all` controls and `$rich.all` are unavailable (no area-wide --rich-text-* styles). Default true. */ all?: boolean; /** Storage format: 'markdown' (default), 'html' or 'plain'. */ format?: 'markdown' | 'html' | 'plain'; /** Initial value; omitted, the element's existing markup is the content. */ value?: string; /** No markdown autoformat while typing. */ literal?: boolean; /** Called with the stored value after every change. */ onChange?(value: string): void; } /** Returned by `ManifestRichText.attach()`: the `$rich` surface plus detach(). */ export interface ManifestRichTextHandle extends ManifestRichText { el: Element; /** Remove editing and restore the element's own contenteditable/role/aria-multiline. */ detach(): void; /** Markup of the newest step in the field's undo history (a pending typing burst is recorded first). */ newest(): string; } /** * Manifest's custom-element/attribute authoring surface (documentation aid — * these are HTML attributes, not JS globals). Element styles pair with most. */ export type ManifestDirective = | 'x-route' | 'x-anchors' | 'x-icon' | 'x-svg' | 'x-markdown' | 'x-code' | 'x-code-group' | 'x-toast' | 'x-tooltip' | 'x-carousel' | 'x-virtual' | 'x-computed' | 'x-defer' | 'x-chart' | 'x-date' | 'x-color' | 'x-colorpicker' | 'x-combobox' | 'x-export' | 'x-import' | 'x-pay' | 'x-edit' | 'x-rich-text' | 'x-submit'; /** Detail of the `submit:sent` / `submit:error` events an `x-submit` form dispatches. */ export interface ManifestSubmitDetail { /** True for a 2xx response whose JSON body is not `{ ok: false }`. */ ok: boolean; /** HTTP status; 0 when the request never reached a server. */ status: number; /** The parsed JSON body, or null. */ data: any; response: Response | null; /** Error code (the body's `error`, else 'http_error' or 'network_error'); null when sent. */ error: string | null; message: string; } // --------------------------------------------------------------------------- // App modules: components, stores and magics on `this` // --------------------------------------------------------------------------- /** * Alpine stores, keyed by name. Declare them so `$store.` is checked: * * declare module 'mnfst' { interface ManifestStores { session: Session } } */ export interface ManifestStores { [name: string]: any } /** Declared stores keep their types; any other name is `any` until it's declared. */ export type ManifestStoreMap = ManifestStores; /** Magics available on `this` inside an Alpine component (Alpine's own plus Manifest's). */ export interface ManifestMagics { $el: HTMLElement; $root: HTMLElement; $refs: Record; $store: ManifestStoreMap; $data: Record; $watch(property: string, callback: (value: any, oldValue: any) => void): void; $dispatch(event: string, detail?: unknown): void; $nextTick(callback?: () => void): Promise; $id(name: string, key?: string | number): string; $x: ManifestData; $route: ManifestRoute; $modify: ManifestModify; $try: ManifestTry; $computed(fn: (scope: any) => T): T; $auth: ManifestAuth; $locale: ManifestLocale; $toast: ManifestToast; $color: ManifestColor; $colorpicker: ManifestColorpicker; $url: ManifestUrl; $pay: ManifestPay; $chat: ManifestChat; $status: ManifestStatus; $presence: ManifestPresence; $date: ManifestDate; $chart: ManifestChart; $virtual: ManifestVirtual; $export: ManifestExport; $import: ManifestImport; $edit: ManifestEdit; $rich: ManifestRichText; $device: ManifestDevice; $share: ManifestShare; $push: ManifestPush; $secure: ManifestSecure; $links: ManifestLinks; $app: ManifestApp; $haptics: ManifestHaptics; $biometric: ManifestBiometric; $camera: ManifestCamera; } /** Lifecycle hooks Alpine calls on a component. */ export interface ManifestComponentHooks { init?(): void | Promise; destroy?(): void; } /** * A component's state with `this` typed as that state plus every magic. * Pair with an identity helper so `T` is inferred from the returned object: * * /** @template T @param {() => import('mnfst').ManifestComponent} fn *\/ * export const component = (fn) => fn */ export type ManifestComponent = T & ManifestComponentHooks & ThisType; /** The `Alpine` global, as app modules use it. */ export interface ManifestAlpine { data(name: string, factory: (...args: any[]) => T): void; store(name: string, value: T & ThisType): void; store(name: K): ManifestStores[K]; magic(name: string, callback: (el: HTMLElement, options: unknown) => unknown): void; directive(name: string, callback: (...args: any[]) => unknown): unknown; nextTick(callback?: () => void): Promise; effect(callback: () => void): unknown; reactive(value: T): T; raw(value: T): T; evaluate(el: Element, expression: string): unknown; initTree(el: Element): void; $data(el: Element): Record; } // --------------------------------------------------------------------------- // Global declarations (what Alpine exposes inside `x-data`, `x-show`, etc.) // --------------------------------------------------------------------------- declare global { /** Project data sources registered in manifest.json. */ const $x: ManifestData; /** Alpine stores. */ const $store: ManifestStoreMap; /** Alpine, loaded by Manifest; reach it inside `alpine:init`. */ const Alpine: ManifestAlpine; /** The current route path (compare or .startsWith against it). */ const $route: ManifestRoute; /** Read a parent component attribute (Manifest's prop mechanism). */ const $modify: ManifestModify; /** Run a callback safely, returning undefined on error. */ const $try: ManifestTry; /** * Cached derivation for `x-data` / `Alpine.data` scopes: `rows: $computed(function () { return this.items.filter(…) })`. * Recomputed once per flush when a tracked dependency changes; reads as a plain property with a stable identity in between. */ const $computed: (fn: (this: any) => T) => T; /** Appwrite auth module (present when the module is loaded). */ const $auth: ManifestAuth; /** Localization module. */ const $locale: ManifestLocale; /** Toasts module. */ const $toast: ManifestToast; /** Color-mode module (`$color.current = 'dark'`). */ const $color: ManifestColor; /** Colorpicker module. */ const $colorpicker: ManifestColorpicker; /** URL parameters module (`$url.tab.value`). */ const $url: ManifestUrl; /** Payments module. */ const $pay: ManifestPay; /** Chat module. */ const $chat: ManifestChat; /** Status module. */ const $status: ManifestStatus; /** Appwrite presences module. */ const $presence: ManifestPresence; /** Datepicker module. */ const $date: ManifestDate; /** Charts module. */ const $chart: ManifestChart; /** Virtual module: scroll a virtual list to an item. */ const $virtual: ManifestVirtual; /** Export module. */ const $export: ManifestExport; /** Import module. */ const $import: ManifestImport; /** Element editor (edit module; opt-in). */ const $edit: ManifestEdit; /** Rich text editor (rich-text module; loaded on use). */ const $rich: ManifestRichText; /** Device/platform info (utilities; enriched by the device module). */ const $device: ManifestDevice; /** Native share (device module). */ const $share: ManifestShare; /** Push permissions (device module). */ const $push: ManifestPush; /** Secure storage (device module). */ const $secure: ManifestSecure; /** Deep links (device module). */ const $links: ManifestLinks; /** App foreground state (device module). */ const $app: ManifestApp; /** Haptics (device module). */ const $haptics: ManifestHaptics; /** Biometric auth (device module). */ const $biometric: ManifestBiometric; /** Camera (device module). */ const $camera: ManifestCamera; /** Window-level Manifest namespace exposed by the loader. */ interface Window { Manifest?: { loadModule(name: string, version?: string): Promise; /** @deprecated Use loadModule. */ loadPlugin(name: string, version?: string): Promise; loadTailwind(version?: string): Promise; getModuleUrl(name: string, version?: string): string; /** @deprecated Use getModuleUrl. */ getPluginUrl(name: string, version?: string): string; /** True while every script the loader adds is checked against published hashes (integrity= on the loader tag). */ readonly integrity?: boolean; /** Load a pinned third-party script by npm path (e.g. `marked@15.0.12/marked.min.js`), checked by hash. */ loadVendor?(path: string, integrity?: string): Promise; /** Fetch a pinned third-party file by npm path, checked by hash. */ fetchVendor?(path: string, integrity?: string): Promise; /** Defer a closed container built at runtime (call before Alpine.initTree). */ defer?(el: Element): unknown; /** App-shell service worker diagnostics; kill() unregisters and clears its caches. */ sw?: { registered: boolean; version: string | null; kill(): Promise }; /** The two-line same-origin /sw.js stub pinned to a framework version. */ swStub?(version?: string): string; }; Alpine?: ManifestAlpine; __manifestLoaded?: unknown; /** Pending work that will still change the page; mnfst-render's auto settle won't snapshot early while count > 0. */ ManifestPending?: { /** Hold until the work's DOM update lands; call the returned function to release. */ hold(label?: string): () => void; readonly count: number; labels(): string[]; /** Mark a timer callback as housekeeping that never changes the page (auto settle ignores it). */ background(fn: T): T; }; /** Rich text engine (rich-text module). */ ManifestRichText?: { attach(el: Element, options?: ManifestRichTextAttachOptions): ManifestRichTextHandle | null; toMarkdown(root: Element): string; fromMarkdown(markdown: string): string; sanitize(html: string, allowBlocks?: boolean, keepStyle?: boolean): string; commands(): string[]; }; /** Form sending (submissions module; loaded on first x-submit). */ ManifestSubmissions?: { readonly events: { sent: string; error: string }; send(form: HTMLFormElement, submitter?: HTMLElement | null): Promise; }; } interface HTMLElementEventMap { 'submit:sent': CustomEvent; 'submit:error': CustomEvent; } interface WindowEventMap { 'manifest:data-mutation-success': CustomEvent; 'manifest:data-mutation-error': CustomEvent; } /** x-virtual: the last rendered row neared the end of the list (bubbles). */ interface HTMLElementEventMap { 'virtual-end': CustomEvent<{ length: number }>; } /** * Fired when the utilities runtime sees a class the baked sheet (and * `manifest.json`'s `utilities.safelist`/`patterns`) doesn't cover, after * publish stamped that sheet as covering every class — see * manifest.utilities.static.js. `engineLoaded` is true once the lazily * loaded Tailwind engine has taken over, false if that load failed. */ interface WindowEventMap { 'manifest:utilities-uncovered': CustomEvent<{ classes: string[]; engineLoaded: boolean }>; } } // --------------------------------------------------------------------------- // AUGMENTATION:start // Project-specific declarations are appended below by `npx mnfst-types`. // Do not hand-edit between the start/end markers — re-running the CLI // regenerates this section from manifest.json + sample data. // --------------------------------------------------------------------------- // (No project augmentations yet — run `npx mnfst-types` to generate.) export interface ManifestSources { [sourceName: string]: any } // --------------------------------------------------------------------------- // AUGMENTATION:end // --------------------------------------------------------------------------- export { };