127 lines
4.7 KiB
TypeScript
127 lines
4.7 KiB
TypeScript
/* tslint:disable */
|
|
/* eslint-disable */
|
|
|
|
/** A concrete JavaScript value or Decodal schema descriptor supplied by the host. */
|
|
export type DecodalHostValue =
|
|
| string
|
|
| number
|
|
| boolean
|
|
| DecodalHostValue[]
|
|
| { [field: string]: DecodalHostValue }
|
|
| DecodalPrimitiveDescriptor
|
|
| DecodalArrayDescriptor
|
|
| DecodalAbstractDescriptor;
|
|
|
|
export type DecodalPrimitiveType = 'String' | 'Int' | 'Float' | 'Bool';
|
|
|
|
export type DecodalConstraint =
|
|
| { kind: 'type'; value: DecodalPrimitiveType }
|
|
| { kind: 'compare'; op: '>' | '>=' | '<' | '<='; value: string | number | boolean }
|
|
| { kind: 'regex'; value: string }
|
|
| { kind: 'predicate'; value: string };
|
|
|
|
export interface DecodalPrimitiveDescriptor {
|
|
$decodal: DecodalPrimitiveType;
|
|
constraints?: DecodalConstraint[];
|
|
default?: DecodalHostValue;
|
|
}
|
|
|
|
export interface DecodalArrayDescriptor {
|
|
$decodal: 'Array';
|
|
item: DecodalHostValue;
|
|
constraints?: DecodalConstraint[];
|
|
default?: DecodalHostValue;
|
|
}
|
|
|
|
export interface DecodalAbstractDescriptor {
|
|
$decodal: 'Abstract';
|
|
constraints?: DecodalConstraint[];
|
|
default?: DecodalHostValue;
|
|
}
|
|
|
|
export type DecodalLoadedImport =
|
|
| { kind: 'source'; key: string; name?: string; source: string }
|
|
| { kind: 'value'; key: string; value: DecodalHostValue };
|
|
|
|
export type DecodalImportCandidate =
|
|
| string
|
|
| { specifier: string; detail?: string };
|
|
|
|
/** Host-owned environment shared by evaluation and language tooling. */
|
|
export interface DecodalEnvironment {
|
|
globals?: Record<string, DecodalHostValue>;
|
|
/** Synchronous import callback. Preload or cache asynchronous resources first. */
|
|
loadImport?: (currentKey: string | null, specifier: string) => DecodalLoadedImport;
|
|
/** Synchronous import completion callback. */
|
|
completeImport?: (currentKey: string | null, prefix: string) => DecodalImportCandidate[];
|
|
}
|
|
|
|
/**
|
|
* A browser-facing language service configured entirely by its JavaScript host.
|
|
*
|
|
* The host owns globals, import loading, and import completion. This keeps
|
|
* filesystem, network, and virtual-project policy outside the WASM package.
|
|
*/
|
|
export class DecodalLanguageService {
|
|
free(): void;
|
|
[Symbol.dispose](): void;
|
|
/**
|
|
* Completes a source using the same injected environment as evaluation.
|
|
*
|
|
* Positions and returned ranges are UTF-16 offsets, matching browser
|
|
* editors and the Language Server Protocol.
|
|
*/
|
|
complete(key: string, source: string, position: number, explicit: boolean): string;
|
|
/**
|
|
* Evaluates a source using the injected globals and import loader.
|
|
*/
|
|
evaluate(key: string, name: string, source: string): string;
|
|
constructor(options?: DecodalEnvironment);
|
|
}
|
|
|
|
/**
|
|
* Evaluates one standalone Decodal source with no host globals or imports.
|
|
*/
|
|
export function evaluate(source: string): string;
|
|
|
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
|
|
export interface InitOutput {
|
|
readonly memory: WebAssembly.Memory;
|
|
readonly __wbg_decodallanguageservice_free: (a: number, b: number) => void;
|
|
readonly decodallanguageservice_complete: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
readonly decodallanguageservice_evaluate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
readonly decodallanguageservice_new: (a: any) => [number, number, number];
|
|
readonly evaluate: (a: number, b: number) => [number, number];
|
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
readonly __externref_table_alloc: () => number;
|
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
readonly __wbindgen_start: () => void;
|
|
}
|
|
|
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
|
|
/**
|
|
* Instantiates the given `module`, which can either be bytes or
|
|
* a precompiled `WebAssembly.Module`.
|
|
*
|
|
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
*
|
|
* @returns {InitOutput}
|
|
*/
|
|
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
|
|
/**
|
|
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
*
|
|
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
*
|
|
* @returns {Promise<InitOutput>}
|
|
*/
|
|
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|