@ant-lang/wasm 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,6 +48,12 @@ which Vite, webpack and esbuild copy along. Pass `wasm` (a URL, a `Response`, by
48
48
  - `languageServer(onMessage, { onLog? })` starts the Ant language server and returns
49
49
  `{ send, close }`, carrying JSON-RPC messages as objects. Documents are analyzed when their URI
50
50
  is a `file:` URI. [@ant-lang/monaco](../monaco) connects it to the Monaco editor.
51
+ - `debugAdapter({ files }, onMessage, { onLog? })` starts a debug adapter, what `ant dap` serves,
52
+ for one session and returns `{ send, close }`, carrying
53
+ [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/) messages as
54
+ objects. The `program` of the launch request and the sources of breakpoints are paths among
55
+ `files`. Requests reach the adapter while the program waits or is stopped (see
56
+ [Sandbox](#sandbox)), so run it in a worker.
51
57
 
52
58
  `files` maps module paths to source text, and `path` is the module to start from: the only module,
53
59
  or `main.ant` by default. Imports resolve among `files`.
package/ant.wasm CHANGED
Binary file
package/index.d.ts CHANGED
@@ -22,6 +22,10 @@ export interface Diagnostic {
22
22
  line: number;
23
23
  column: number;
24
24
  message: string;
25
+ /** The rule the diagnostic reports, such as "type-mismatch". */
26
+ code: string;
27
+ /** "error", or "warning" for code that checks but is almost always a mistake. */
28
+ severity: "error" | "warning";
25
29
  }
26
30
 
27
31
  export interface RunOptions extends Program {
@@ -57,6 +61,13 @@ export interface LanguageServerConnection {
57
61
  close(): void;
58
62
  }
59
63
 
64
+ /** A connection to a debug adapter, carrying Debug Adapter Protocol messages as objects. */
65
+ export interface DebugAdapterConnection {
66
+ send(message: object): void;
67
+ /** Ends the session and its program, as the end of the adapter's input stream does. */
68
+ close(): void;
69
+ }
70
+
60
71
  export interface Ant {
61
72
  /** Formats one module, as ant fmt does. Throws a SyntaxError when the source does not parse. */
62
73
  format(source: string, path?: string): string;
@@ -72,6 +83,18 @@ export interface Ant {
72
83
  onMessage: (message: any) => void,
73
84
  options?: { onLog?: (line: string) => void },
74
85
  ): LanguageServerConnection;
86
+ /**
87
+ * Starts a debug adapter, what `ant dap` serves, for one session on a program whose modules
88
+ * are files. The launch request's `program` and the sources of breakpoints are paths among
89
+ * files; `env` is the whole environment and `stdin` names one of the files. Requests reach the
90
+ * adapter only while the program waits or is stopped, since JavaScript events run only then:
91
+ * run it in a worker, and terminate the worker to stop a program that never waits.
92
+ */
93
+ debugAdapter(
94
+ program: { files: Files },
95
+ onMessage: (message: any) => void,
96
+ options?: { onLog?: (line: string) => void },
97
+ ): DebugAdapterConnection;
75
98
  }
76
99
 
77
100
  export function loadAnt(options?: LoadOptions): Promise<Ant>;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @ant-lang/wasm loads Ant compiled to WebAssembly and wraps what it exposes: format, check,
2
- // run, and the language server.
2
+ // run, the language server, and the debug adapter.
3
3
  import "./wasm_exec.js";
4
4
 
5
5
  let instances = 0;
@@ -87,5 +87,12 @@ function wrap(raw) {
87
87
  close: () => conn.close(),
88
88
  };
89
89
  },
90
+ debugAdapter({ files }, onMessage, options = {}) {
91
+ const conn = raw.debugAdapter(files, (json) => onMessage(JSON.parse(json)), options.onLog);
92
+ return {
93
+ send: (message) => conn.send(JSON.stringify(message)),
94
+ close: () => conn.close(),
95
+ };
96
+ },
90
97
  };
91
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-lang/wasm",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "The Ant language compiled to WebAssembly: format, check, and run Ant programs, and serve the Ant language server, in browsers and Node.",
5
5
  "keywords": [
6
6
  "ant",
@@ -40,5 +40,5 @@
40
40
  "engines": {
41
41
  "node": ">=20"
42
42
  },
43
- "ant": "v0.2.0"
43
+ "ant": "v0.3.1"
44
44
  }
package/wasm_exec.js CHANGED
File without changes