Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions stdlib/Vscode.affine
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,22 @@ pub extern fn processPlatform() -> String;
/// `context.asAbsolutePath(rel_path)` — resolves a path relative to the
/// extension's install location.
pub extern fn extensionAbsolutePath(ctx: ExtensionContext, rel_path: String) -> String;

// ── Async-extern ABI (issue #103) ────────────────────────────────────
//
// AffineScript's extern-call shape is synchronous, but most of vscode's
// interactive surface returns a JS Thenable. `Thenable` is an opaque
// host handle; the Deno/Node source-to-source backend lowers a
// Thenable-returning extern to a plain host call, so the emitted JS is a
// real Promise and a consumer's `await` is valid source JS. The `Async`
// effect (v1 registry, #59) tracks this in signatures. The vscode-host
// JS implementation lives in packages/affine-vscode/mod.js (follow-up
// slice); these declarations are the binding surface + effect tracking.

pub extern type Thenable;

/// `vscode.window.withProgress({ location: Notification, title }, task)`.
/// `work_thunk` is a wasm/host table index of the `() -> Thenable` task
/// (same thunk-handle convention as `onDidSaveTextDocument`). Returns the
/// progress Thenable.
pub extern fn withProgressNotification(title: String, work_thunk: Int) -> Thenable / Async;
13 changes: 13 additions & 0 deletions stdlib/VscodeLanguageClient.affine
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ pub extern fn newLanguageClient(id: String,

pub extern fn languageClientStart(c: LanguageClient) -> Int;
pub extern fn languageClientStop(c: LanguageClient) -> Int;

// ── Async-extern ABI (issue #103) ────────────────────────────────────
// Opaque host handle, declared per-module (these binding modules are
// self-contained; the host erases the type). See stdlib/Vscode.affine.

pub extern type Thenable;

/// `LanguageClient.sendRequest(method, params)` — returns a Thenable of
/// the JSON-encoded response. `params_json` is the request params encoded
/// as a JSON string; the host shim parses it before the LSP call.
pub extern fn languageClientSendRequest(c: LanguageClient,
method: String,
params_json: String) -> Thenable / Async;
Loading