numbl 0.1.3 → 0.1.4

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.
@@ -34,6 +34,13 @@ export interface ExecOptions {
34
34
  onInput?: (prompt: string) => string;
35
35
  /** Optimization level for interpreter (0 = none, >=1 = JIT scalar functions). */
36
36
  optimization?: number;
37
+ /**
38
+ * Initial implicit cwd path for the MATLAB-style "cwd is the first search path" feature.
39
+ * - undefined → auto-detect from `system.cwd()` and scan its files.
40
+ * - a string → use this absolute path as the implicit cwd (REPL persistence).
41
+ * - null → opt out of the implicit-cwd behavior entirely.
42
+ */
43
+ implicitCwdPath?: string | null;
37
44
  }
38
45
  export interface BuiltinProfileEntry {
39
46
  totalTimeMs: number;
@@ -66,5 +73,7 @@ export interface ExecResult {
66
73
  searchPaths?: string[];
67
74
  /** Updated workspace files (set when addpath/rmpath was called). */
68
75
  workspaceFiles?: WorkspaceFile[];
76
+ /** Final implicit cwd path (for REPL persistence across commands). */
77
+ implicitCwdPath?: string | null;
69
78
  }
70
79
  export declare function executeCode(source: string, options?: ExecOptions, workspaceFiles?: WorkspaceFile[], mainFileName?: string, searchPaths?: string[], nativeBridge?: NativeBridge): ExecResult;
@@ -56,6 +56,8 @@ export interface FileIOAdapter {
56
56
  deleteFile?(pattern: string): void;
57
57
  /** Remove a directory. If recursive is true, remove contents first. Returns true on success. Optional. */
58
58
  rmdir?(dirPath: string, recursive: boolean): boolean;
59
+ /** Move or rename a file or folder. If force is true, overwrites read-only files. Returns true on success. Optional. */
60
+ movefile?(source: string, destination: string, force: boolean): boolean;
59
61
  /** Extract a ZIP file to an output folder. Returns list of extracted file paths. Optional. */
60
62
  unzip?(zipfilename: string, outputfolder: string): string[];
61
63
  /** Return the temporary directory path. Optional. */
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Adaptive Gauss-Kronrod (7-15) quadrature — a minimal MATLAB-compatible
3
+ * quadgk implementation sufficient for smooth integrands on a finite real
4
+ * interval.
5
+ *
6
+ * Not supported (yet):
7
+ * - complex / contour integration
8
+ * - Waypoints
9
+ * - infinite limits
10
+ *
11
+ * The integrand `fun` must accept a vector of quadrature nodes and return
12
+ * a vector of the same length (MATLAB's quadgk contract).
13
+ */
14
+ /** Return the 15 Kronrod nodes of [lo, hi]. */
15
+ export declare function kronrodNodes(lo: number, hi: number): number[];
16
+ export interface QuadgkOptions {
17
+ relTol?: number;
18
+ absTol?: number;
19
+ maxIntervalCount?: number;
20
+ }
21
+ export interface QuadgkResult {
22
+ value: number;
23
+ errbnd: number;
24
+ intervalsUsed: number;
25
+ }
26
+ /**
27
+ * Adaptive Gauss-Kronrod 7-15 quadrature of `integrand` over `[a, b]`.
28
+ *
29
+ * `integrand(pts)` receives a 15-element array of nodes and must return a
30
+ * 15-element array of function values.
31
+ */
32
+ export declare function quadgkAdaptive(integrand: (pts: number[]) => number[], a: number, b: number, opts?: QuadgkOptions): QuadgkResult;
@@ -2,4 +2,10 @@
2
2
  * String manipulation builtin functions
3
3
  */
4
4
  import { type RuntimeValue } from "../runtime/index.js";
5
+ /** Convert a scalar number to the string form MATLAB's num2str would
6
+ * produce. Unlike numStr (used for sprintf %g), integers always render
7
+ * in fixed notation regardless of magnitude, so e.g. 1e15 becomes
8
+ * "1000000000000000" rather than "1e+15". This matches the formatting
9
+ * MATLAB applies when concatenating a number to a string via `+`. */
10
+ export declare function num2strScalar(n: number): string;
5
11
  export declare function sprintfFormat(fmt: string, args: RuntimeValue[]): string;
@@ -7,6 +7,7 @@ import "./math.js";
7
7
  import "./arithmetic.js";
8
8
  import "./complex.js";
9
9
  import "./predicates.js";
10
+ import "./logical.js";
10
11
  import "./utility.js";
11
12
  import "./introspection.js";
12
13
  import "./array-construction.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Logical builtins: or, and, not.
3
+ *
4
+ * Functional forms of `|`, `&`, and `~`. Mirror the corresponding operator
5
+ * implementations in runtimeOperators.ts so `or(a, b)` behaves the same as
6
+ * `a | b`, etc. (`xor` is registered separately in reductions.ts and uses a
7
+ * broadcast-aware implementation.)
8
+ */
9
+ export {};
@@ -12,6 +12,9 @@ export interface InterpreterContext {
12
12
  evalInLocalScope: (codeArg: unknown, fileName?: string) => unknown;
13
13
  callFunction: (name: string, args: unknown[], nargout: number) => unknown;
14
14
  rt: Runtime;
15
+ /** Resolve a workspace function or class name to its source file path,
16
+ * or undefined if no workspace file provides that name. */
17
+ lookupWorkspaceFile: (name: string) => string | undefined;
15
18
  }
16
19
  export declare const FALL_THROUGH: unique symbol;
17
20
  export type InterpreterSpecialBuiltinHandler = (ctx: InterpreterContext, args: unknown[], nargout: number) => unknown | typeof FALL_THROUGH;
@@ -62,6 +62,8 @@ export declare class Runtime {
62
62
  classMethodCache: Map<string, ((...args: any[]) => any) | null>;
63
63
  /** Callback for addpath/rmpath — mutates search paths and rebuilds function index. */
64
64
  onPathChange: ((action: "add" | "remove", dir: string, position: "begin" | "end") => void) | null;
65
+ /** Callback invoked after cd() to update the implicit cwd search path. */
66
+ onCwdChange: ((newCwd: string) => void) | null;
65
67
  /** Reference to the active search paths (set by executeCode). */
66
68
  searchPaths: string[];
67
69
  workspaceAccessors: Map<string, {
@@ -312,3 +314,10 @@ export declare class Runtime {
312
314
  readInput(prompt: string): string;
313
315
  }
314
316
  export declare const rstr: (s: RuntimeString | RuntimeChar) => string;
317
+ /** Empty MATLAB-style stack field: 0x1 struct with file/name/line fields. */
318
+ export declare function emptyStackField(): RuntimeValue;
319
+ /**
320
+ * Build a MATLAB-style stack struct array from a RuntimeError's callStack.
321
+ * Index 1 is the innermost frame (where the error was thrown).
322
+ */
323
+ export declare function buildStackField(e: RuntimeError): RuntimeValue;
@@ -1,2 +1,2 @@
1
1
  /** Numbl version, used for JIT disk cache invalidation. */
2
- export declare const NUMBL_VERSION = "0.1.3";
2
+ export declare const NUMBL_VERSION = "0.1.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "numbl",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Run .m source files in the browser and on the command line by compiling to JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",