Share host-aware completion across runtimes
This commit is contained in:
+89
-4
@@ -1,20 +1,105 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export function evaluate(source: string): string;
|
||||
/** 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 function evaluateProject(entry: string, files_json: string): string;
|
||||
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 evaluateProject: (a: number, b: number, c: number, d: number) => [number, number];
|
||||
readonly __wbindgen_externrefs: WebAssembly.Table;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user