@cldmv/sqlite-wasm 0.0.1-placeholder → 0.1.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.
Files changed (50) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +565 -3
  3. package/dist/chunk-IEYL6MVW.mjs +2 -0
  4. package/dist/chunk-IRDSVJEM.mjs +2 -0
  5. package/dist/chunk-IXZKMCUU.mjs +2 -0
  6. package/dist/chunk-VOHQWANF.mjs +2 -0
  7. package/dist/chunk-VRZKKYFL.mjs +2 -0
  8. package/dist/chunk-YTH6FRG3.mjs +2 -0
  9. package/dist/drizzle.cjs +26 -0
  10. package/dist/drizzle.mjs +2 -0
  11. package/dist/fs-B55OKCP5.mjs +2 -0
  12. package/dist/host.mjs +2 -0
  13. package/dist/index.cjs +26 -0
  14. package/dist/index.mjs +2 -0
  15. package/dist/opfs-CREACZOE.mjs +2 -0
  16. package/dist/sqlite3.wasm +0 -0
  17. package/dist/worker.mjs +2 -0
  18. package/package.json +150 -3
  19. package/types/src/api/connection.d.mts +86 -0
  20. package/types/src/api/database.d.mts +109 -0
  21. package/types/src/api/error.d.mts +25 -0
  22. package/types/src/api/functions.d.mts +50 -0
  23. package/types/src/api/open.d.mts +90 -0
  24. package/types/src/api/runtime.d.mts +46 -0
  25. package/types/src/api/statement.d.mts +106 -0
  26. package/types/src/api/transaction.d.mts +37 -0
  27. package/types/src/api/values.d.mts +35 -0
  28. package/types/src/core/browser-loader.d.mts +45 -0
  29. package/types/src/core/callbacks.d.mts +49 -0
  30. package/types/src/core/codes.d.mts +17 -0
  31. package/types/src/core/constants.d.mts +75 -0
  32. package/types/src/core/loader.d.mts +126 -0
  33. package/types/src/core/memory.d.mts +48 -0
  34. package/types/src/core/platform.d.mts +40 -0
  35. package/types/src/core/raw.d.mts +48 -0
  36. package/types/src/core/router.d.mts +50 -0
  37. package/types/src/core/vfs-imports.d.mts +58 -0
  38. package/types/src/core/wasi.d.mts +28 -0
  39. package/types/src/drizzle.d.mts +64 -0
  40. package/types/src/index.d.mts +47 -0
  41. package/types/src/node.d.mts +25 -0
  42. package/types/src/vfs/fs.d.mts +72 -0
  43. package/types/src/vfs/memory.d.mts +39 -0
  44. package/types/src/vfs/opfs.d.mts +98 -0
  45. package/types/src/vfs/registry.d.mts +76 -0
  46. package/types/src/worker/client.d.mts +142 -0
  47. package/types/src/worker/engine.d.mts +46 -0
  48. package/types/src/worker/host.d.mts +50 -0
  49. package/types/src/worker/protocol.d.mts +202 -0
  50. package/types/src/worker/share.d.mts +69 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/api/functions.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:11-08:00 (1795642211)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ import { type Connection } from "./connection.mts";
17
+ import { type value } from "./values.mts";
18
+ /** Options shared by scalar and aggregate functions. */
19
+ export interface options {
20
+ /** Same arguments always give the same result (lets SQLite use the function in indexes and optimize it). */
21
+ deterministic?: boolean;
22
+ /** Accept any number of arguments instead of the callback's declared parameter count. */
23
+ variadic?: boolean;
24
+ /** Pass INTEGER arguments as bigint; defaults to the database's `bigint` option. */
25
+ bigint?: boolean;
26
+ }
27
+ /** An aggregate (or, with `inverse`, a window function). */
28
+ export interface aggregate extends options {
29
+ /** The initial accumulator, or a function returning a fresh one for each group. Defaults to null. */
30
+ start?: unknown;
31
+ /** Folds one row into the accumulator and returns the new one (returning undefined keeps the current one). */
32
+ step: (total: never, ...values: value[]) => unknown;
33
+ /** Removes a row that left the window frame; makes the aggregate usable as a window function. */
34
+ inverse?: (total: never, ...values: value[]) => unknown;
35
+ /** Turns the accumulator into the result; the accumulator itself when omitted. */
36
+ result?: (total: never) => unknown;
37
+ }
38
+ /** The `db.fn` namespace. */
39
+ export interface fn {
40
+ /** Registers a scalar function. */
41
+ scalar(name: string, callback: (...values: value[]) => unknown, options?: options): void;
42
+ /** Registers an aggregate, or a window function when `inverse` is given. */
43
+ aggregate(name: string, definition: aggregate): void;
44
+ /** Alias of `aggregate`. */
45
+ agg(name: string, definition: aggregate): void;
46
+ /** Registers a collation: `compare` returns a negative number, zero or a positive number. */
47
+ collation(name: string, compare: (a: string, b: string) => number): void;
48
+ }
49
+ /** Builds the `db.fn` namespace for `connection`. */
50
+ export declare function functions(connection: Connection): fn;
@@ -0,0 +1,90 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/api/open.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:11-08:00 (1795642211)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ import { type DriverOptions, type StorageKind } from "../vfs/registry.mts";
17
+ import { type Connection } from "./connection.mts";
18
+ import { database } from "./database.mts";
19
+ import { type Runtime } from "./runtime.mts";
20
+ /** Where the database lives: "auto" picks files in Node, OPFS in a browser worker, memory elsewhere. */
21
+ export type storage = "auto" | "memory" | "fs" | "opfs";
22
+ /** Rollback journal or write-ahead log. */
23
+ export type journal = "wal" | "truncate" | "delete";
24
+ /** `PRAGMA synchronous` level. */
25
+ export type sync = "off" | "normal" | "full" | "extra";
26
+ /** Options for `sqlite.open()`. */
27
+ export interface options {
28
+ /** Storage driver; default "auto". `:memory:` and "" always use memory. */
29
+ storage?: storage;
30
+ /** Open read-only; default false. */
31
+ readonly?: boolean;
32
+ /** Create the file if it doesn't exist; default true (ignored when read-only). */
33
+ create?: boolean;
34
+ /** Journal mode; default "wal". */
35
+ journal?: journal;
36
+ /** `PRAGMA synchronous`; default "normal". */
37
+ sync?: sync;
38
+ /** Enforce foreign keys; default true. */
39
+ foreign?: boolean;
40
+ /** How long to wait for a lock, in milliseconds; default 5000. */
41
+ timeout?: number;
42
+ /** Return every INTEGER as a bigint; default false (only integers outside ±2^53 are bigints). */
43
+ bigint?: boolean;
44
+ /**
45
+ * How other processes are kept out (Node only; browsers always use Web Locks and ignore it): "beside" (default) a
46
+ * `<db>.lock/` folder, falling back to "temp" where that can't be created; "temp" a folder under the OS temp
47
+ * folder; a folder path of your own; or "db", a row in a `_cldmv_lock` table that detects a second process but
48
+ * can't prevent two opening at the same instant.
49
+ */
50
+ lock?: lock;
51
+ }
52
+ /** The `lock` option: "beside", "temp", "db", or a folder path. */
53
+ export type lock = string;
54
+ /** Fully resolved options. */
55
+ export interface Settings {
56
+ storage: StorageKind;
57
+ readonly: boolean;
58
+ create: boolean;
59
+ journal: journal;
60
+ sync: sync;
61
+ foreign: boolean;
62
+ timeout: number;
63
+ bigint: boolean;
64
+ lock: string;
65
+ }
66
+ /** The storage kind for `path`: memory for SQLite's in-memory and temporary names, else `storage` resolved. */
67
+ export declare function resolveStorage(path: string, storage: storage): StorageKind;
68
+ /** Validates `options` and fills in the defaults. */
69
+ export declare function settings(path: unknown, options: unknown): Settings;
70
+ /** A database file claimed for one connection or attachment: the name SQLite opens, the lock in effect, and how to give it back. */
71
+ export interface Claim {
72
+ name: string;
73
+ lock: string;
74
+ /** Undoes the claim at once; the promise settles when the driver's own release has finished (never rejects). */
75
+ release: () => Promise<void>;
76
+ }
77
+ /**
78
+ * Loads the driver for one database file, lets it prepare the file (when it has a `prepare` hook) and routes the
79
+ * resulting name to it. `release()` undoes both: the route, then the driver's `release` hook.
80
+ */
81
+ export declare function claim(shared: Runtime, storage: StorageKind, options: DriverOptions): Promise<Claim>;
82
+ /**
83
+ * Opens `path` with resolved settings and returns its connection state. `extra` goes to the driver factory along with
84
+ * the public options (the worker host passes its OPFS `root`, `locks` and `wait` this way).
85
+ */
86
+ export declare function connect(path: string, resolved: Settings, extra?: Record<string, unknown>): Promise<Connection>;
87
+ /** The table the "db" lock keeps its rows in. */
88
+ export declare const LOCK_TABLE = "_cldmv_lock";
89
+ /** Opens a database. */
90
+ export declare function open(path: string, options?: options): Promise<database>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/api/runtime.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:11-08:00 (1795642211)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ /**
17
+ * @fileoverview The process-wide SQLite instance every connection runs in.
18
+ *
19
+ * All connections share one module instance, created on the first `sqlite.open()` and cached. Reasons:
20
+ * - `db.backup()` and `ATTACH` work between connections only when both live in the same SQLite library instance
21
+ * (sqlite3_backup_init takes two sqlite3 handles).
22
+ * - Each instance has its own linear memory (megabytes once SQLite's page cache warms up) and its own copy of
23
+ * SQLite's globals; one per connection multiplies that for nothing.
24
+ * - The build is single-threaded (SQLITE_THREADSAFE=0) and so is JS, so connections never run concurrently.
25
+ * The cost is that one instance's memory only grows, and a trap inside the module would take every connection down.
26
+ * Storage still differs per connection: the instance's single VFS is a router that sends each database's files to
27
+ * the driver it was opened with.
28
+ */
29
+ import { type SqliteInstance } from "../core/loader.mts";
30
+ import { VfsRouter } from "../core/router.mts";
31
+ /** The shared instance and its state. */
32
+ export interface Runtime {
33
+ readonly instance: SqliteInstance;
34
+ readonly router: VfsRouter;
35
+ /** An exception a user function or collation threw; rethrown when the statement that ran it returns. */
36
+ pending: {
37
+ error: unknown;
38
+ } | undefined;
39
+ }
40
+ /**
41
+ * Sets where the compiled module comes from (the worker host passes its `wasm` option through here). Takes effect
42
+ * only before the first `sqlite.open()`; afterwards the instance exists and this returns false.
43
+ */
44
+ export declare function use(loader: () => Promise<WebAssembly.Module>): boolean;
45
+ /** The process-wide runtime, created on first use. */
46
+ export declare function runtime(): Promise<Runtime>;
@@ -0,0 +1,106 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/api/statement.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:12-08:00 (1795642212)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ import { type Connection, type StatementState } from "./connection.mts";
17
+ import { type value } from "./values.mts";
18
+ /** A row as an object keyed by column name. */
19
+ export type row = Record<string, value>;
20
+ /** What `run()` returns. */
21
+ export interface result {
22
+ /** Rows inserted, updated or deleted by the statement. */
23
+ changes: number;
24
+ /** The rowid of the last inserted row on the connection. */
25
+ rowid: number | bigint;
26
+ }
27
+ /** One entry of `columns()`. */
28
+ export interface column {
29
+ /** The column's name in the result (its alias, if it has one). */
30
+ name: string;
31
+ /** The table column it comes from, or null for an expression. */
32
+ column: string | null;
33
+ /** The table it comes from, or null. */
34
+ table: string | null;
35
+ /** The schema it comes from ("main", "temp", an attached name), or null. */
36
+ database: string | null;
37
+ /** The declared type, or null. */
38
+ type: string | null;
39
+ }
40
+ /** What the safety net needs to finalize a dropped statement. Never references the statement object itself. */
41
+ interface Held {
42
+ connection: Connection;
43
+ state: StatementState;
44
+ }
45
+ /** Finalizes a statement whose object was garbage collected while still prepared. */
46
+ export declare function collect({ connection, state }: Held): void;
47
+ /** `statement.raw`: rows as arrays. */
48
+ export interface raw {
49
+ get(...parameters: unknown[]): value[] | undefined;
50
+ all(...parameters: unknown[]): value[][];
51
+ iterate(...parameters: unknown[]): IterableIterator<value[]>;
52
+ /** Alias of `iterate`. */
53
+ iter(...parameters: unknown[]): IterableIterator<value[]>;
54
+ }
55
+ /** `statement.pluck`: the first column only. */
56
+ export interface pluck {
57
+ get(...parameters: unknown[]): value | undefined;
58
+ all(...parameters: unknown[]): value[];
59
+ }
60
+ /** `statement.expand`: rows as `{ table: { column: value } }` ("$" for expressions). */
61
+ export interface expand {
62
+ get(...parameters: unknown[]): Record<string, row> | undefined;
63
+ all(...parameters: unknown[]): Record<string, row>[];
64
+ }
65
+ /** `statement.info`. */
66
+ export interface info {
67
+ /** The SQL text. */
68
+ readonly sql: string;
69
+ /** Whether the statement returns rows. */
70
+ readonly reader: boolean;
71
+ /** Whether the statement leaves the database unchanged. */
72
+ readonly readonly: boolean;
73
+ }
74
+ /** A prepared statement. Create one with `db.prepare()`. */
75
+ export declare class statement {
76
+ #private;
77
+ /** Rows as positional arrays. */
78
+ readonly raw: raw;
79
+ /** The first column of each row. */
80
+ readonly pluck: pluck;
81
+ /** Rows grouped by source table. */
82
+ readonly expand: expand;
83
+ /** SQL text and kind. */
84
+ readonly info: info;
85
+ /** @internal Use `db.prepare()`. */
86
+ constructor(connection: Connection, pointer: number, bigint: boolean);
87
+ /** Executes the statement and returns how many rows it changed and the last inserted rowid. */
88
+ run(...parameters: unknown[]): result;
89
+ /** The first row as an object, or undefined. */
90
+ get(...parameters: unknown[]): row | undefined;
91
+ /** Every row as an object. */
92
+ all(...parameters: unknown[]): row[];
93
+ /** An iterator over the rows as objects. The statement can't run again until the iterator finishes or is returned. */
94
+ iterate(...parameters: unknown[]): IterableIterator<row>;
95
+ /** Alias of `iterate`. */
96
+ iter: (...parameters: unknown[]) => IterableIterator<row>;
97
+ /** Binds `parameters` for every later execution, which must then pass none. Can be called once. */
98
+ bind(...parameters: unknown[]): this;
99
+ /** Describes the result columns. */
100
+ columns(): column[];
101
+ /** Alias of `columns`. */
102
+ cols: () => column[];
103
+ /** Finalizes the statement. Later calls do nothing. */
104
+ close(): void;
105
+ }
106
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/api/transaction.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:12-08:00 (1795642212)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ /**
17
+ * @fileoverview `db.transaction(callback)`: wraps a function so each call runs inside a transaction.
18
+ *
19
+ * The wrapper begins a transaction, calls the callback, and commits; if the callback throws, it rolls back and
20
+ * rethrows. Called while a transaction is already open (from inside another transaction function, or after a manual
21
+ * BEGIN), it uses a savepoint instead, so nested calls roll back only their own part. The callback must be
22
+ * synchronous: a returned promise rolls the transaction back and throws, because the commit would otherwise run
23
+ * before the awaited work.
24
+ */
25
+ import { type Connection } from "./connection.mts";
26
+ /** A function wrapped by `db.transaction()`. Calling it uses BEGIN (deferred); the properties pick the mode. */
27
+ export interface transaction<parameters extends unknown[], output> {
28
+ (...parameters: parameters): output;
29
+ /** BEGIN DEFERRED. */
30
+ deferred(...parameters: parameters): output;
31
+ /** BEGIN IMMEDIATE: takes the write lock up front. */
32
+ immediate(...parameters: parameters): output;
33
+ /** BEGIN EXCLUSIVE. */
34
+ exclusive(...parameters: parameters): output;
35
+ }
36
+ /** Wraps `callback` for `connection`. */
37
+ export declare function transaction<parameters extends unknown[], output>(connection: Connection, callback: (...parameters: parameters) => output): transaction<parameters, output>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/api/values.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:12-08:00 (1795642212)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ import type { SqliteInstance } from "../core/loader.mts";
17
+ /** A value SQLite stores. */
18
+ export type value = null | number | bigint | string | Uint8Array;
19
+ /** Converts an INTEGER read from SQLite. */
20
+ export declare function integer(raw: bigint, bigint: boolean): number | bigint;
21
+ /** Binds `input` to parameter `index` (1-based) of `stmt`; returns SQLite's result code. */
22
+ export declare function bindValue(instance: SqliteInstance, stmt: number, index: number, input: unknown): number;
23
+ /** Sets `input` as the result of the user function call `context`. */
24
+ export declare function setResult(instance: SqliteInstance, context: number, input: unknown): void;
25
+ /**
26
+ * Binds `parameters` to every parameter of `stmt`. Arguments are positional values, arrays of positional values, or
27
+ * one plain object of named values (keys without the `:`, `@` or `$` prefix). Anonymous parameters (`?`, `?NNN`) take
28
+ * the positional values in order. Every parameter must get a value and every positional value must be used.
29
+ * Returns SQLite's result code from the first bind that failed, or SQLITE_OK.
30
+ */
31
+ export declare function bindAll(instance: SqliteInstance, stmt: number, parameters: readonly unknown[]): number;
32
+ /** Column `index` of the current row of `stmt`. */
33
+ export declare function columnValue(instance: SqliteInstance, stmt: number, index: number, bigint: boolean): value;
34
+ /** The `argc` arguments at `argv` of a user function call. */
35
+ export declare function argumentValues(instance: SqliteInstance, argc: number, argv: number, bigint: boolean): value[];
@@ -0,0 +1,45 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/core/browser-loader.d.mts
5
+ * @Date: 2026-11-25T02:10:00-08:00 (1795601400)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:12-08:00 (1795642212)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ /**
17
+ * @fileoverview Compiles sqlite3.wasm in a browser: fetch plus `WebAssembly.compileStreaming`, so the module compiles
18
+ * while it downloads. The Node loader (loader.mts) reads the file with node:fs instead; both produce a
19
+ * `WebAssembly.Module` for `instantiateSqlite()`.
20
+ *
21
+ * The default location is written as `new URL("./sqlite3.wasm", import.meta.url)` on purpose: Vite, webpack and
22
+ * Parcel recognise that exact pattern and emit the wasm as an asset next to the bundle. When a bundler doesn't, or
23
+ * the file is served from somewhere else, pass its URL (or the bytes, a Response or a compiled module) instead.
24
+ */
25
+ /** Anything `load()` can turn into a compiled module. */
26
+ export type source = string | URL | Response | ArrayBuffer | ArrayBufferView | WebAssembly.Module;
27
+ /** The fetch function `load()` uses; injectable for tests. */
28
+ export type fetcher = (url: URL) => Promise<Response>;
29
+ /** Default locations, in order: next to the bundle, then dist/ from src/core/ in a checkout. */
30
+ export declare function candidates(): URL[];
31
+ /** Compiles a fetched response, streaming when the server sends the wasm MIME type. */
32
+ export declare function compile(response: Response): Promise<WebAssembly.Module>;
33
+ /**
34
+ * Returns a compiled sqlite3.wasm.
35
+ * @param from where to get it; the package's own file (fetched once and cached) when omitted
36
+ * @param get the fetch to use; the global one by default
37
+ */
38
+ export declare function load(from?: source, get?: fetcher): Promise<WebAssembly.Module>;
39
+ /** The loader as a namespace: `loader.load(from)`. */
40
+ declare const loader: {
41
+ load: typeof load;
42
+ compile: typeof compile;
43
+ candidates: typeof candidates;
44
+ };
45
+ export default loader;
@@ -0,0 +1,49 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/core/callbacks.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:12-08:00 (1795642212)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ /**
17
+ * @fileoverview The JS side of glue.c's callback trampolines: the `env.cb_*` imports and the id -> handler table
18
+ * they dispatch through.
19
+ *
20
+ * glue.c registers every user function and collation with a fixed C trampoline and a numeric id as its user-data
21
+ * pointer. The trampoline calls one of these imports with that id; the table finds the handler. Handlers must not
22
+ * throw: an exception unwinding through wasm frames would leave SQLite in an undefined state, so the API layer catches
23
+ * inside each handler and reports the failure through SQLite.
24
+ */
25
+ /** What one registered id can be called for. A function uses `call` / `final` / `inverse`, a collation `collate`. */
26
+ export interface CallbackHandler {
27
+ /** Scalar call, aggregate step or window step. */
28
+ call?(context: number, argc: number, argv: number): void;
29
+ /** Aggregate final (`final` true) or window value (`final` false). */
30
+ final?(context: number, final: boolean): void;
31
+ /** Window inverse step. */
32
+ inverse?(context: number, argc: number, argv: number): void;
33
+ /** Collation compare of two UTF-8 strings given as (length, pointer) pairs. */
34
+ collate?(length1: number, pointer1: number, length2: number, pointer2: number): number;
35
+ }
36
+ /** The id -> handler table of one module instance. */
37
+ export declare class CallbackTable {
38
+ #private;
39
+ /** Registers `handler` and returns its id. */
40
+ add(handler: CallbackHandler): number;
41
+ /** The handler for `id`. */
42
+ get(id: number): CallbackHandler;
43
+ /** Number of registered handlers. */
44
+ get size(): number;
45
+ /** Forgets `id` (SQLite dropped the function or collation). */
46
+ delete(id: number): void;
47
+ }
48
+ /** Builds the `env.cb_*` imports for one module instance. */
49
+ export declare function createCallbackImports(table: CallbackTable): Record<string, (...args: number[]) => number | void>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/core/codes.d.mts
5
+ * @Date: 2026-11-25T01:43:39-08:00 (1795599819)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:12-08:00 (1795642212)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ /** The `SQLITE_*` name of result code `code`, e.g. "SQLITE_CONSTRAINT_UNIQUE". */
17
+ export declare function codeName(code: number): string;
@@ -0,0 +1,75 @@
1
+ /**
2
+ *
3
+ * @Project: @cldmv/sqlite-wasm
4
+ * @Filename: types/src/core/constants.d.mts
5
+ * @Date: 2026-11-25T01:18:15-08:00 (1795598295)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-11-25T13:30:12-08:00 (1795642212)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
13
+ *
14
+ */
15
+
16
+ /**
17
+ * @fileoverview SQLite constants the core and the storage drivers use (values from sqlite3.h).
18
+ */
19
+ /** Primary and extended result codes. */
20
+ export declare const SQLITE_OK = 0;
21
+ export declare const SQLITE_ERROR = 1;
22
+ export declare const SQLITE_BUSY = 5;
23
+ export declare const SQLITE_NOMEM = 7;
24
+ export declare const SQLITE_NOTFOUND = 12;
25
+ export declare const SQLITE_CANTOPEN = 14;
26
+ export declare const SQLITE_MISUSE = 21;
27
+ export declare const SQLITE_ROW = 100;
28
+ export declare const SQLITE_DONE = 101;
29
+ export declare const SQLITE_IOERR = 10;
30
+ export declare const SQLITE_IOERR_READ: number;
31
+ export declare const SQLITE_IOERR_SHORT_READ: number;
32
+ export declare const SQLITE_IOERR_WRITE: number;
33
+ export declare const SQLITE_IOERR_FSYNC: number;
34
+ export declare const SQLITE_IOERR_TRUNCATE: number;
35
+ export declare const SQLITE_IOERR_FSTAT: number;
36
+ export declare const SQLITE_IOERR_UNLOCK: number;
37
+ export declare const SQLITE_IOERR_LOCK: number;
38
+ export declare const SQLITE_IOERR_CLOSE: number;
39
+ export declare const SQLITE_IOERR_DELETE: number;
40
+ export declare const SQLITE_IOERR_ACCESS: number;
41
+ export declare const SQLITE_IOERR_CHECKRESERVEDLOCK: number;
42
+ export declare const SQLITE_IOERR_DELETE_NOENT: number;
43
+ /** sqlite3_open_v2() and xOpen flags. */
44
+ export declare const SQLITE_OPEN_READONLY = 1;
45
+ export declare const SQLITE_OPEN_READWRITE = 2;
46
+ export declare const SQLITE_OPEN_CREATE = 4;
47
+ export declare const SQLITE_OPEN_DELETEONCLOSE = 8;
48
+ export declare const SQLITE_OPEN_EXCLUSIVE = 16;
49
+ export declare const SQLITE_OPEN_URI = 64;
50
+ export declare const SQLITE_OPEN_MAIN_DB = 256;
51
+ export declare const SQLITE_OPEN_TEMP_DB = 512;
52
+ export declare const SQLITE_OPEN_MAIN_JOURNAL = 2048;
53
+ export declare const SQLITE_OPEN_WAL = 524288;
54
+ export declare const SQLITE_OPEN_EXRESCODE = 33554432;
55
+ /** Lock levels passed to xLock / xUnlock. */
56
+ export declare const SQLITE_LOCK_NONE = 0;
57
+ export declare const SQLITE_LOCK_SHARED = 1;
58
+ export declare const SQLITE_LOCK_RESERVED = 2;
59
+ export declare const SQLITE_LOCK_PENDING = 3;
60
+ export declare const SQLITE_LOCK_EXCLUSIVE = 4;
61
+ /** xAccess flags. */
62
+ export declare const SQLITE_ACCESS_EXISTS = 0;
63
+ export declare const SQLITE_ACCESS_READWRITE = 1;
64
+ export declare const SQLITE_ACCESS_READ = 2;
65
+ /** xDeviceCharacteristics bits. */
66
+ export declare const SQLITE_IOCAP_ATOMIC = 1;
67
+ export declare const SQLITE_IOCAP_SAFE_APPEND = 512;
68
+ export declare const SQLITE_IOCAP_SEQUENTIAL = 1024;
69
+ export declare const SQLITE_IOCAP_POWERSAFE_OVERWRITE = 4096;
70
+ /** Fundamental datatypes returned by sqlite3_column_type(). */
71
+ export declare const SQLITE_INTEGER = 1;
72
+ export declare const SQLITE_FLOAT = 2;
73
+ export declare const SQLITE_TEXT = 3;
74
+ export declare const SQLITE_BLOB = 4;
75
+ export declare const SQLITE_NULL = 5;