nola-lang 0.1.13 → 0.1.14

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/dist/check.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { resolve } from "node:path";
3
3
  import { originalPositionFor, TraceMap } from "@jridgewell/trace-mapping";
4
+ import { isGeneratedNameDiagnostic } from "@nola-lang/compiler";
4
5
  import { findProjectRoot, loadCompilerOptions } from "@nola-lang/node-loader";
5
6
  import ts from "typescript";
6
7
  import { createProjectDeriver } from "./derive.js";
@@ -56,6 +57,10 @@ export async function cmdCheck(dirArg = ".") {
56
57
  errors.push(`${d.file.fileName}:${pos.line + 1}:${pos.character + 1} TS${d.code}: ${message}`);
57
58
  continue;
58
59
  }
60
+ // An unused generated name (a context item no ask sees, under
61
+ // noUnusedLocals): the author cannot act on it.
62
+ if (isGeneratedNameDiagnostic(d.code, message))
63
+ continue;
59
64
  const generated = d.file.getLineAndCharacterOfPosition(d.start);
60
65
  const tracer = new TraceMap(maps.get(original));
61
66
  const pos = originalPositionFor(tracer, { line: generated.line + 1, column: generated.character });
package/dist/run.js CHANGED
@@ -1,6 +1,31 @@
1
1
  import { dirname, resolve } from "node:path";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import { registerNola } from "@nola-lang/node-loader";
4
+ /**
5
+ * How long a CRASHED program's event loop gets to drain before `nola run`
6
+ * exits 1: enough for the tracer's in-flight POSTs (1.5 s timeout each) to
7
+ * settle, short enough that a program which also left a server open still
8
+ * ends about when node would have ended it.
9
+ */
10
+ const CRASH_DRAIN_GRACE_MS = 2_000;
11
+ /**
12
+ * Resolves when the event loop drains (`beforeExit`) — with `graceMs`, at the
13
+ * latest after that long. The grace timer is unref'd, so it never keeps the
14
+ * loop alive itself: a loop with nothing else pending drains at once.
15
+ */
16
+ function drained(graceMs) {
17
+ return new Promise((resolve) => {
18
+ let timer;
19
+ const done = () => {
20
+ process.off("beforeExit", done);
21
+ clearTimeout(timer);
22
+ resolve();
23
+ };
24
+ process.once("beforeExit", done);
25
+ if (graceMs !== undefined)
26
+ timer = setTimeout(done, graceMs).unref();
27
+ });
28
+ }
4
29
  export async function cmdRun(entryArg) {
5
30
  if (!entryArg) {
6
31
  console.error("nola run <entry>");
@@ -8,7 +33,26 @@ export async function cmdRun(entryArg) {
8
33
  }
9
34
  const entry = resolve(entryArg);
10
35
  await registerNola({ dir: dirname(entry) });
11
- await import(pathToFileURL(entry).href);
12
- return 0;
36
+ // The entry has evaluated, but the program may not be over: a timer, a
37
+ // server, the tracer's in-flight POSTs keep the event loop alive exactly as
38
+ // they do under `node --import nola-lang/register`, and the dispatcher's
39
+ // process.exit would cut them short — the console showed a run's last ask
40
+ // as running forever because its askEnd envelope never left the process.
41
+ // So return only once the loop drains; a program that never lets it drain
42
+ // keeps `nola run` alive the way it keeps node alive.
43
+ try {
44
+ await import(pathToFileURL(entry).href);
45
+ }
46
+ catch (error) {
47
+ // Node exits the moment a top-level rejection goes uncaught, and would
48
+ // take the failed ask's askEnd — the one event a console exists to show —
49
+ // with it. A crashed program gets a bounded drain instead: with only those
50
+ // POSTs pending it is over in milliseconds, a server it left open costs
51
+ // the grace period, then the error surfaces as before.
52
+ await drained(CRASH_DRAIN_GRACE_MS);
53
+ throw error;
54
+ }
55
+ await drained();
56
+ return typeof process.exitCode === "number" ? process.exitCode : 0;
13
57
  }
14
58
  //# sourceMappingURL=run.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nola-lang",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "The Nola language toolchain: nola init/build/run/check and the Node loader for .tsi files",
5
5
  "keywords": [
6
6
  "nola",
@@ -44,15 +44,15 @@
44
44
  "dependencies": {
45
45
  "@ampproject/remapping": "^2.3.0",
46
46
  "@jridgewell/trace-mapping": "^0.3.25",
47
- "@nola-lang/ast": "0.1.13",
48
- "@nola-lang/compiler": "0.1.13",
49
- "@nola-lang/console": "0.1.13",
50
- "@nola-lang/core": "0.1.13",
51
- "@nola-lang/derive": "0.1.13",
52
- "@nola-lang/node-loader": "0.1.13",
53
- "@nola-lang/parser": "0.1.13",
54
- "@nola-lang/runtime": "0.1.13",
55
- "create-nola-lang": "0.1.13",
47
+ "@nola-lang/ast": "0.1.14",
48
+ "@nola-lang/compiler": "0.1.14",
49
+ "@nola-lang/console": "0.1.14",
50
+ "@nola-lang/core": "0.1.14",
51
+ "@nola-lang/derive": "0.1.14",
52
+ "@nola-lang/node-loader": "0.1.14",
53
+ "@nola-lang/parser": "0.1.14",
54
+ "@nola-lang/runtime": "0.1.14",
55
+ "create-nola-lang": "0.1.14",
56
56
  "esbuild": "^0.25.0",
57
57
  "typescript": "^5.6.0"
58
58
  },