@ahmadmoussawi/webdb 0.0.0-stage → 0.1.0-alpha.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 (106) hide show
  1. package/README.md +386 -2
  2. package/dist/constants.d.ts +18 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/core/index.d.ts +15 -0
  5. package/dist/core/index.d.ts.map +1 -0
  6. package/dist/core/js/buffer_pool.c.d.ts +142 -0
  7. package/dist/core/js/buffer_pool.c.d.ts.map +1 -0
  8. package/dist/core/js/catalog.c.d.ts +186 -0
  9. package/dist/core/js/catalog.c.d.ts.map +1 -0
  10. package/dist/core/js/codecs.c.d.ts +32 -0
  11. package/dist/core/js/codecs.c.d.ts.map +1 -0
  12. package/dist/core/js/index.d.ts +7 -0
  13. package/dist/core/js/index.d.ts.map +1 -0
  14. package/dist/core/js/page.c.d.ts +225 -0
  15. package/dist/core/js/page.c.d.ts.map +1 -0
  16. package/dist/core/js/page_table.c.d.ts +48 -0
  17. package/dist/core/js/page_table.c.d.ts.map +1 -0
  18. package/dist/core/js/vm.c.d.ts +11 -0
  19. package/dist/core/js/vm.c.d.ts.map +1 -0
  20. package/dist/core/js/vm.helpers.c.d.ts +124 -0
  21. package/dist/core/js/vm.helpers.c.d.ts.map +1 -0
  22. package/dist/core/types.d.ts +26 -0
  23. package/dist/core/types.d.ts.map +1 -0
  24. package/dist/core/wasm/embedded_wasm.d.ts +7 -0
  25. package/dist/core/wasm/embedded_wasm.d.ts.map +1 -0
  26. package/dist/core/wasm/wasm_core.d.ts +75 -0
  27. package/dist/core/wasm/wasm_core.d.ts.map +1 -0
  28. package/dist/host/api/index.d.ts +3 -0
  29. package/dist/host/api/index.d.ts.map +1 -0
  30. package/dist/host/api/query_builder.d.ts +212 -0
  31. package/dist/host/api/query_builder.d.ts.map +1 -0
  32. package/dist/host/api/webdb.d.ts +102 -0
  33. package/dist/host/api/webdb.d.ts.map +1 -0
  34. package/dist/host/compiler/compiler.d.ts +151 -0
  35. package/dist/host/compiler/compiler.d.ts.map +1 -0
  36. package/dist/host/compiler/expr_parser.d.ts +87 -0
  37. package/dist/host/compiler/expr_parser.d.ts.map +1 -0
  38. package/dist/host/compiler/index.d.ts +4 -0
  39. package/dist/host/compiler/index.d.ts.map +1 -0
  40. package/dist/host/compiler/planner/cost.d.ts +23 -0
  41. package/dist/host/compiler/planner/cost.d.ts.map +1 -0
  42. package/dist/host/compiler/planner/custom_order.d.ts +16 -0
  43. package/dist/host/compiler/planner/custom_order.d.ts.map +1 -0
  44. package/dist/host/compiler/planner/heuristic.d.ts +11 -0
  45. package/dist/host/compiler/planner/heuristic.d.ts.map +1 -0
  46. package/dist/host/compiler/planner/index.d.ts +34 -0
  47. package/dist/host/compiler/planner/index.d.ts.map +1 -0
  48. package/dist/host/compiler/planner/noop.d.ts +11 -0
  49. package/dist/host/compiler/planner/noop.d.ts.map +1 -0
  50. package/dist/host/compiler/planner/types.d.ts +100 -0
  51. package/dist/host/compiler/planner/types.d.ts.map +1 -0
  52. package/dist/host/compiler/planner/where_optimizer.d.ts +30 -0
  53. package/dist/host/compiler/planner/where_optimizer.d.ts.map +1 -0
  54. package/dist/host/compiler/planner.d.ts +2 -0
  55. package/dist/host/compiler/planner.d.ts.map +1 -0
  56. package/dist/host/driver/buffer_pool_driver.d.ts +94 -0
  57. package/dist/host/driver/buffer_pool_driver.d.ts.map +1 -0
  58. package/dist/host/driver/crash_recovery.d.ts +24 -0
  59. package/dist/host/driver/crash_recovery.d.ts.map +1 -0
  60. package/dist/host/driver/index.d.ts +4 -0
  61. package/dist/host/driver/index.d.ts.map +1 -0
  62. package/dist/host/driver/transaction_coordinator.d.ts +163 -0
  63. package/dist/host/driver/transaction_coordinator.d.ts.map +1 -0
  64. package/dist/host/storage/crc32.d.ts +24 -0
  65. package/dist/host/storage/crc32.d.ts.map +1 -0
  66. package/dist/host/storage/idb.d.ts +27 -0
  67. package/dist/host/storage/idb.d.ts.map +1 -0
  68. package/dist/host/storage/index.d.ts +8 -0
  69. package/dist/host/storage/index.d.ts.map +1 -0
  70. package/dist/host/storage/io.d.ts +60 -0
  71. package/dist/host/storage/io.d.ts.map +1 -0
  72. package/dist/host/storage/memory.d.ts +28 -0
  73. package/dist/host/storage/memory.d.ts.map +1 -0
  74. package/dist/host/storage/opfs.d.ts +31 -0
  75. package/dist/host/storage/opfs.d.ts.map +1 -0
  76. package/dist/host/storage/vfs.d.ts +36 -0
  77. package/dist/host/storage/vfs.d.ts.map +1 -0
  78. package/dist/host/storage/wal_codec.d.ts +56 -0
  79. package/dist/host/storage/wal_codec.d.ts.map +1 -0
  80. package/dist/index.d.ts +9 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/layouts/index.d.ts +5 -0
  83. package/dist/layouts/index.d.ts.map +1 -0
  84. package/dist/layouts/page_format.d.ts +163 -0
  85. package/dist/layouts/page_format.d.ts.map +1 -0
  86. package/dist/layouts/pool_format.d.ts +126 -0
  87. package/dist/layouts/pool_format.d.ts.map +1 -0
  88. package/dist/layouts/syspage_format.d.ts +499 -0
  89. package/dist/layouts/syspage_format.d.ts.map +1 -0
  90. package/dist/layouts/wal_format.d.ts +197 -0
  91. package/dist/layouts/wal_format.d.ts.map +1 -0
  92. package/dist/shared/c_runtime.d.ts +47 -0
  93. package/dist/shared/c_runtime.d.ts.map +1 -0
  94. package/dist/shared/index.d.ts +4 -0
  95. package/dist/shared/index.d.ts.map +1 -0
  96. package/dist/shared/page_provider.d.ts +12 -0
  97. package/dist/shared/page_provider.d.ts.map +1 -0
  98. package/dist/shared/vm_context.d.ts +73 -0
  99. package/dist/shared/vm_context.d.ts.map +1 -0
  100. package/dist/types/index.d.ts +269 -0
  101. package/dist/types/index.d.ts.map +1 -0
  102. package/dist/webdb.js +11768 -0
  103. package/dist/webdb.js.map +1 -0
  104. package/dist/webdb.umd.cjs +5 -0
  105. package/dist/webdb.umd.cjs.map +1 -0
  106. package/package.json +82 -4
package/README.md CHANGED
@@ -1,3 +1,387 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="docs/public/logo.svg" width="96" height="96" alt="WebDB Logo" />
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">WebDB</h1>
6
+
7
+ <p align="center">
8
+ <strong>An ultra-lean (&lt;50 KB), and powerful browser-native relational database engine built from scratch in C compiled to WASM.</strong>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://github.com/ahmad-moussawi/webdb/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT" /></a>
13
+ <img src="https://img.shields.io/badge/wasm%20size-%3C50%20KB-success.svg?logo=webassembly&logoColor=white" alt="Wasm Size: <50KB" />
14
+ <a href="https://ahmad-moussawi.github.io/webdb/playground/"><img src="https://img.shields.io/badge/Studio%20IDE-live%20playground-7c3aed?logo=visualstudiocode&logoColor=white" alt="Studio IDE" /></a>
15
+ <a href="https://ahmad-moussawi.github.io/webdb/benchmark/"><img src="https://img.shields.io/badge/benchmarks-live%20suite-059669?logo=speedtest&logoColor=white" alt="Live Benchmarks" /></a>
16
+ <a href="https://www.npmjs.com/package/@ahmadmoussawi/webdb"><img src="https://img.shields.io/npm/v/@ahmadmoussawi/webdb/alpha?label=npm%20alpha&color=orange&logo=npm" alt="npm alpha" /></a>
17
+ <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.7-blue?logo=typescript&logoColor=white" alt="TypeScript" /></a>
18
+ <a href="https://vitest.dev/"><img src="https://img.shields.io/badge/tests-348%20unit%20%2B%206%20e2e%20passing-brightgreen?logo=vitest&logoColor=white" alt="Tests" /></a>
19
+ <a href="https://ahmad-moussawi.github.io/webdb/"><img src="https://img.shields.io/badge/docs-online-646cff?logo=vite&logoColor=white" alt="Docs" /></a>
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a href="https://ahmad-moussawi.github.io/webdb/playground/"><strong>🚀 Launch Studio Playground</strong></a> &nbsp;•&nbsp;
24
+ <a href="https://ahmad-moussawi.github.io/webdb/benchmark/"><strong>⚡ Run Live Benchmarks</strong></a> &nbsp;•&nbsp;
25
+ <a href="https://ahmad-moussawi.github.io/webdb/"><strong>📖 Documentation</strong></a> &nbsp;•&nbsp;
26
+ <a href="https://ahmad-moussawi.github.io/webdb/plans/plan.html"><strong>📐 Specifications</strong></a>
27
+ </p>
28
+
29
+ **WebDB** is an ultra-lightweight, relational database built from scratch specifically for the web. Think of it as **SQLite reimagined for modern browsers**—bringing true SQL capabilities, ACID transactions, and persistent storage to offline-first apps without multi-megabyte bundles or complex server headers.
30
+
31
+ - 🪶 **Tiny Footprint (&lt;50 KB Wasm):** Up to 90%+ smaller than ported desktop SQLite or Postgres (PGlite) builds.
32
+ - ⚡ **True Relational Power:** Fast filtering, indexing, aggregations, multi-column sorting, and joins—replacing cumbersome IndexedDB cursor queries.
33
+ - 🔄 **Async VFS by Heart:** Built from the ground up for asynchronous browser storage—clean non-blocking page faults with zero Emscripten `Asyncify` stack hacks or slow workarounds.
34
+ - 🌐 **Embraces the Web Platform:** Uses the browser instead of fighting it—delegating to native `crypto.subtle`, `Intl`, `RegExp`, `Date`, and Web Locks rather than packing redundant C libraries into Wasm.
35
+ - 💾 **Reliable Offline Persistence:** First-class storage with high-speed **OPFS** (desktop & workers) and **IndexedDB** (Safari, mobile WebViews, private browsing).
36
+ - 🔌 **Zero Configuration:** Works everywhere out of the box with zero `COOP`/`COEP` header headaches.
37
+
38
+ ---
39
+
40
+ ## 🎮 Try WebDB Live in Your Browser
41
+
42
+ Experience WebDB directly on your device with zero installation or setup:
43
+
44
+ | Tool | Highlights | Link |
45
+ | :--- | :--- | :--- |
46
+ | **WebDB Studio Playground** | Full in-browser database IDE with Monaco editor, live table explorer, low-level binary 4KB slotted page inspector, buffer pool visualizer, and real-time bytecode disassembler. | [**Launch Studio IDE →**](https://ahmad-moussawi.github.io/webdb/playground/) |
47
+ | **In-Browser Benchmark Suite** | Live comparative benchmarking engine measuring throughput (ops/sec), latency, and memory allocations against Raw JS Arrays, Native IndexedDB, and official SQLite WASM on your hardware. | [**Run Benchmarks →**](https://ahmad-moussawi.github.io/webdb/benchmark/) |
48
+
49
+ ---
50
+
51
+ ## Why WebDB? (The Vision)
52
+
53
+ Web developers building offline apps have long been stuck between two extremes: **IndexedDB** is an awkward key-value cursor store lacking relational queries, joins, and aggregations; while **ported desktop engines (like SQLite or Postgres/PGlite)** drag 1 MB to 5 MB+ of desktop C legacy, POSIX thread logic, and Emscripten hacks into the browser.
54
+
55
+ WebDB fills this gap by **reimagining a database engine from scratch for modern browsers**.
56
+
57
+ ```
58
+ ┌─────────────────────────────────┐ ┌─────────────────────────────────┐
59
+ │ Ported Desktop DBs (Wasm) │ │ WebDB │
60
+ ├─────────────────────────────────┤ ├─────────────────────────────────┤
61
+ │ • 500 KB - 5 MB+ (SQLite/PGlite)│ │ • <50 KB Wasm (ultra-lean) │
62
+ │ • Bundles text SQL parser/lexer │ ──► │ • Fluent TS Builder ➔ Bytecode │
63
+ │ • Bundles POSIX pthread/mutexes │ │ • Single-threaded by design │
64
+ │ • Bundles C date/regex/ICU shims│ │ • Embraces native Web APIs │
65
+ │ • Asyncify call-stack rewriting │ │ • Native async page faults │
66
+ └─────────────────────────────────┘ └─────────────────────────────────┘
67
+ ```
68
+
69
+ ### The Architectural Shift
70
+
71
+ **No Heavy SQL Parser:** Traditional SQL parsers, lexers, and tokenizer tables account for a huge portion of database binary size. In WebDB, the TypeScript Query Builder compiles queries directly into compact binary bytecode instructions (`Uint8Array`). The Wasm engine core only executes binary instructions—trimming tens of kilobytes of parser bloat.
72
+
73
+ **Single-Threaded by Design:** Browsers run in isolated, single-threaded contexts (Main Thread or Web Worker). Stripping out POSIX thread handling and internal lock contention keeps the engine razor-sharp, delegating cross-tab coordination to the browser's native **Web Locks API** (`navigator.locks`).
74
+
75
+ **Embracing Web APIs:** Instead of bundling heavy C libraries for dates, regexes, Unicode segmentation, or cryptography, WebDB delegates directly to native browser APIs (`Date`, `RegExp`, `Intl.Segmenter`, and `crypto.subtle`) via zero-overhead synchronous UDFs.
76
+
77
+ **Async VFS by Heart:** Desktop databases expect synchronous POSIX disk calls, forcing Wasm ports to rely on Emscripten’s slow, bloated `Asyncify` stack rewriting. WebDB's execution engine suspends cleanly via non-blocking page faults whenever a 4KB page is missing. This makes the storage layer completely pluggable: pages can be read from high-speed **OPFS**, persisted in **IndexedDB**, or even streamed on-demand across the network from an S3/CDN bucket via **HTTP Range Requests** (`HttpVfsAdapter`).
78
+
79
+ ---
80
+
81
+ ## Current Status & Development Strategy
82
+
83
+ WebDB is currently in an **early prototype ("walking skeleton") stage**:
84
+
85
+ - **V1 (C-Style JS Engine):** The initial release is built in **strict C-style TypeScript/JavaScript** (direct `ArrayBuffer` pointer arithmetic, flat structs, and zero heap allocations). Writing V1 in JS accelerates the development cycle, simplifies debugging, and creates an instant feedback loop with the web community.
86
+ - **V2 (Drop-In C / Wasm Port):** Once the binary formats, VDBE opcodes, and APIs are battle-tested, the core engine will be ported 1:1 to C and compiled to an ultra-lean Wasm binary (&lt;50 KB)—with zero changes required to the host JS orchestration layer.
87
+ - **Current Milestone:** Slotted-page layouts, basic VDBE opcode execution, in-memory/IndexedDB adapters, and query planning are implemented and verified with automated test suites. Full V1 engine development is actively underway.
88
+ - **Interactive Tools Live:** You can test queries in the [WebDB Studio Playground](https://ahmad-moussawi.github.io/webdb/playground/) or evaluate performance in the [In-Browser Benchmark Suite](https://ahmad-moussawi.github.io/webdb/benchmark/).
89
+
90
+ Read our complete specifications:
91
+
92
+ - [Strategic Master Plan](https://ahmad-moussawi.github.io/webdb/plans/plan.html)
93
+ - [System Limitations & Invariants](https://ahmad-moussawi.github.io/webdb/plans/limitations.html)
94
+ - [Future Extensions: Vector, JSON & Hybrid Search](https://ahmad-moussawi.github.io/webdb/plans/future_extensions_roadmap.html)
95
+
96
+ ---
97
+
98
+ ## 📦 Installation
99
+
100
+ Install the alpha release of `@ahmadmoussawi/webdb` via npm, pnpm, or yarn:
101
+
102
+ ```bash
103
+ # npm
104
+ npm install @ahmadmoussawi/webdb@alpha
105
+
106
+ # pnpm
107
+ pnpm add @ahmadmoussawi/webdb@alpha
108
+
109
+ # yarn
110
+ yarn add @ahmadmoussawi/webdb@alpha
111
+ ```
112
+
113
+ ---
114
+
115
+ ## 🚀 Quick Start (Runnable Example)
116
+
117
+ The snippet below is a complete, runnable example you can paste into any TypeScript or JavaScript project (Vite, Next.js, Node 20+, or Vitest):
118
+
119
+ ```typescript
120
+ import { WebDB } from "@ahmadmoussawi/webdb";
121
+
122
+ async function main() {
123
+ // 1. Open a database
124
+ // storage: 'idb' (IndexedDB) | 'opfs' (Origin Private File System) | 'memory' (In-Memory)
125
+ // core: 'wasm' (default ~13 KB Wasm engine) | 'js' (pure JS fallback)
126
+ const db = await WebDB.open({
127
+ name: "app_data",
128
+ storage: typeof indexedDB !== "undefined" ? "idb" : "memory",
129
+ core: "wasm",
130
+ });
131
+
132
+ // 2. Define a table schema stored in Page 1 (Binary Master Catalog)
133
+ // Supported column types: 'INT32' | 'INT64' | 'FLOAT64' | 'TEXT' | 'BLOB' | 'UUID' | 'ULID'
134
+ await db.createTable("users", [
135
+ { name: "id", type: "UUID", flags: { primaryKey: true } }, // Packed into 16 raw bytes
136
+ { name: "name", type: "TEXT", flags: { notNull: true } },
137
+ { name: "age", type: "INT32" },
138
+ { name: "score", type: "FLOAT64" },
139
+ ]);
140
+
141
+ // Create a secondary B+Tree index for fast range scans & ordered queries
142
+ await db.createIndex("users", "score");
143
+
144
+ // 3. Insert single or bulk records
145
+ await db.insert("users", {
146
+ id: "018d3e2a-1b4c-7000-8000-123456789abc",
147
+ name: "Alice",
148
+ age: 28,
149
+ score: 95.5,
150
+ });
151
+
152
+ await db.insertMany("users", [
153
+ { id: crypto.randomUUID(), name: "Bob", age: 19, score: 82.0 },
154
+ { id: crypto.randomUUID(), name: "Charlie", age: 34, score: 88.0 },
155
+ ]);
156
+
157
+ // 4. ACID Transactions with Write-Ahead Logging (WAL) & Nested Savepoints
158
+ // Automatically coordinates across browser tabs via Web Locks (navigator.locks)
159
+ await db.transaction(async (tx) => {
160
+ await tx.insert("users", {
161
+ id: crypto.randomUUID(),
162
+ name: "Diana",
163
+ age: 25,
164
+ score: 99.0,
165
+ });
166
+
167
+ // Nested transactions act as savepoints — rolling back an inner block
168
+ // restores state without aborting the outer transaction
169
+ await tx
170
+ .transaction(async (nestedTx) => {
171
+ await nestedTx.insert("users", {
172
+ id: crypto.randomUUID(),
173
+ name: "Temporary User",
174
+ age: 40,
175
+ score: 10.0,
176
+ });
177
+ throw new Error("Abort inner savepoint only");
178
+ })
179
+ .catch(() => {
180
+ // Inner insert was cleanly rolled back; Diana remains!
181
+ });
182
+ });
183
+
184
+ // 5. Fluent Queries (compiled directly to compact VDBE binary bytecode)
185
+ const topAdults = await db
186
+ .from("users")
187
+ .select("name", "age", "score")
188
+ .where("age", ">=", 21)
189
+ .whereNotNull("score")
190
+ .orderBy("score", "desc")
191
+ .limit(10)
192
+ .toArray();
193
+
194
+ console.table(topAdults);
195
+ // ┌─────────┬───────────┬─────┬───────┐
196
+ // │ (index) │ name │ age │ score │
197
+ // ├─────────┼───────────┼─────┼───────┤
198
+ // │ 0 │ 'Diana' │ 25 │ 99 │
199
+ // │ 1 │ 'Alice' │ 28 │ 95.5 │
200
+ // │ 2 │ 'Charlie' │ 34 │ 88 │
201
+ // └─────────┴───────────┴─────┴───────┘
202
+
203
+ // 6. Inspect the Query Plan & VDBE Bytecode Disassembly
204
+ const explain = await db.from("users").where("score", ">", 80).explain();
205
+ console.log("Execution Plan:", explain.plan);
206
+ console.table(explain.instructions);
207
+
208
+ await db.close();
209
+ }
210
+
211
+ main();
212
+ ```
213
+
214
+ ---
215
+
216
+ ## ⚙️ Core Architecture: TypeScript ➔ C Transpiler
217
+
218
+ WebDB uses an automated **TypeScript-to-C Transpiler** (`scripts/transpiler/`) to maintain a single canonical source of truth for its core storage and execution engine (`src/core/js/*.c.ts`).
219
+
220
+ TypeScript code is written in a strict, zero-allocation, C-compatible style. The transpiler translates this code into freestanding C99 (`src/core/c/`), which is then compiled via Clang (`wasm32-unknown-unknown -nostdlib -O3`) and optimized with `wasm-opt` into an **ultra-lean ~13 KB WASM binary**.
221
+
222
+ ```
223
+ ┌─────────────────────────────────────────────────────────────┐
224
+ │ Canonical TypeScript Core (src/core/js/*.c.ts) │
225
+ │ (Runs in Node/Vitest tests & Host JS Fallback Mode) │
226
+ └──────────────────────────────┬──────────────────────────────┘
227
+ │
228
+ npm run transpile:c / build:wasm
229
+ │
230
+ ▼
231
+ ┌─────────────────────────────────────────────────────────────┐
232
+ │ Freestanding C99 Core (src/core/c/) │
233
+ │ Zero-libc, slotted-page pointer arithmetic │
234
+ └──────────────────────────────┬──────────────────────────────┘
235
+ │
236
+ clang -nostdlib -O3 + wasm-opt
237
+ │
238
+ ▼
239
+ ┌─────────────────────────────────────────────────────────────┐
240
+ │ WebAssembly Binary (~13 KB WASM) │
241
+ │ Embedded directly into npm package with zero bloat │
242
+ └─────────────────────────────────────────────────────────────┘
243
+ ```
244
+
245
+ ### CLI Commands
246
+
247
+ ```bash
248
+ # Transpile all TypeScript core modules to C source (.c) and headers (.h)
249
+ npm run transpile:c
250
+
251
+ # Transpile a single file for inspection
252
+ npx vite-node scripts/transpiler/index.ts src/core/js/codecs.c.ts
253
+
254
+ # Complete build pipeline: layouts ➔ transpiler ➔ clang wasm32 ➔ wasm-opt -O3
255
+ npm run build:wasm
256
+
257
+ # Run the 275+ automated test suite across both JS and WASM cores
258
+ npm test
259
+ ```
260
+
261
+ ### Type System Mapping (`src/core/types.ts`)
262
+
263
+ Primitive type aliases in TypeScript map directly to C native fixed-width types:
264
+
265
+ | TypeScript Alias | C Native Type | Description |
266
+ | :--- | :--- | :--- |
267
+ | `u8`, `u16`, `u32` | `uint8_t`, `uint16_t`, `uint32_t` | Unsigned 8, 16, 32-bit integers |
268
+ | `i8`, `i16`, `i32` | `int8_t`, `int16_t`, `int32_t` | Signed 8, 16, 32-bit integers |
269
+ | `u64`, `i64` | `uint64_t`, `int64_t` | 64-bit integers (`bigint` in JS) |
270
+ | `f64` | `double` | 64-bit IEEE 754 floating point |
271
+ | `byte_ptr` | `uint32_t` | Linear memory byte offset |
272
+ | `const_u8_ptr` | `const uint8_t *` | Immutable byte buffer pointer |
273
+ | `u8_ptr` | `uint8_t *` | Mutable byte buffer pointer |
274
+ | `const_char_ptr` | `const char *` | Null-terminated C string pointer |
275
+ | `char_ptr` | `char *` | Mutable character buffer pointer |
276
+
277
+ ### Transpiler Annotations Reference
278
+
279
+ The transpiler supports annotations to customize code generation and enable dual implementations:
280
+
281
+ #### 1. `@export_c` (Exported Function)
282
+ Exports the function in both the C source and the `.h` header with `WEBDB_EXPORT`.
283
+ ```typescript
284
+ /**
285
+ * @export_c
286
+ */
287
+ export function page_get_cell_count(page_offset: u32): u16 {
288
+ return load_u16(page_offset + PAGE_HEADER_OFFSET_CELL_COUNT);
289
+ }
290
+ ```
291
+
292
+ #### 2. `@internal_c` (Module-Private Static Helper)
293
+ Generates a `static` C function internal to the translation unit, omitted from the `.h` header.
294
+ ```typescript
295
+ /**
296
+ * @internal_c
297
+ */
298
+ function init_crc_table(): void {
299
+ // Generated as static void init_crc_table(void)
300
+ }
301
+ ```
302
+
303
+ #### 3. `@manual_c` / `@native_c` (Dual Implementation Shortcut)
304
+ Instructs the transpiler that a function is manually implemented in C:
305
+ - **In TypeScript / Vitest**: Executes the TypeScript body normally.
306
+ - **In C Header (`.h`)**: Still registers `WEBDB_EXPORT` so callers have the prototype.
307
+ - **In C Source (`.c`)**: **Skips** generating the body in `.c`. The implementation is resolved from existing C files, companion files, or headers.
308
+
309
+ ```typescript
310
+ /**
311
+ * @export_c
312
+ * @manual_c
313
+ */
314
+ export function btree_split_leaf(page_offset: u32, new_key: u32): i32 {
315
+ // High-level TS implementation runs in JS mode & Vitest tests
316
+ return 0;
317
+ }
318
+ ```
319
+
320
+ #### 4. Inline C Blocks (` ```c ... ``` `)
321
+ Embed hand-crafted C code directly inside the TypeScript JSDoc comment. The transpiler emits the C code block verbatim:
322
+
323
+ ```typescript
324
+ /**
325
+ * @export_c
326
+ * @manual_c
327
+ * ```c
328
+ * WEBDB_EXPORT uint32_t fast_crc32(uint32_t crc, const uint8_t *buf, uint32_t len) {
329
+ * // Hand-optimized C routine
330
+ * return crc ^ len;
331
+ * }
332
+ * ```
333
+ */
334
+ export function fast_crc32(crc: u32, buf: Uint8Array, len: u32): u32 {
335
+ return (crc ^ len) >>> 0;
336
+ }
337
+ ```
338
+
339
+ #### 5. `@use_c: target_c_name` (Symbol & Call Rewriting)
340
+ Maps the TypeScript function to a differently named existing C function. The transpiler automatically rewrites all call sites across transpiled code to call `target_c_name(...)`:
341
+
342
+ ```typescript
343
+ /**
344
+ * @export_c
345
+ * @use_c: c_fast_checksum
346
+ */
347
+ export function checksum(ptr: u32): u32 {
348
+ return 123;
349
+ }
350
+ ```
351
+
352
+ #### 6. Companion Files (`<module>.manual.c`)
353
+ For large or performance-critical manual C functions:
354
+ - Create `src/core/c/<module>.manual.c` (e.g. `src/core/c/catalog.manual.c`).
355
+ - The transpiler automatically detects it and appends `#include "<module>.manual.c"` at the end of the generated `.c` file.
356
+ - The companion file is completely safe from transpiler overwrites.
357
+
358
+ #### 7. `c_inline(cCode, jsFallback)` (Compile-Time Intrinsic)
359
+ Embeds C-specific intrinsics without breaking TypeScript execution:
360
+
361
+ ```typescript
362
+ import { c_inline, u32 } from "../types.ts";
363
+
364
+ export function compute_leading_zeros(val: u32): u32 {
365
+ // In JS: returns Math.clz32(val)
366
+ // In C: emits __builtin_clz(val)
367
+ return c_inline("__builtin_clz(val)", Math.clz32(val));
368
+ }
369
+ ```
370
+
371
+ #### 8. `@c_include` & `@c_raw` Directives
372
+ - `/** @c_include "custom_header.h" */`: Adds `#include "custom_header.h"` at the top of the generated C file.
373
+ - `/** @c_raw ```c ... ``` */`: Injects top-level C macros or typedefs directly into the generated C file.
374
+
375
+ ---
376
+
377
+ ## Support the Project ⭐
378
+
379
+ WebDB is an ambitious open-source initiative to build a modern, featherweight relational database engine purpose-built for the web platform. If you believe in this vision, here is how you can support the development:
380
+
381
+ - ⭐ **Star this Repository:** If you find this project interesting or valuable, please give it a **Star on GitHub**. It takes two seconds, boosts project visibility, and helps attract more contributors!
382
+ - 🎮 **Explore the Playground & Benchmarks:** Experiment with live queries in the [WebDB Studio Playground](https://ahmad-moussawi.github.io/webdb/playground/) and test throughput with the [In-Browser Benchmarks](https://ahmad-moussawi.github.io/webdb/benchmark/).
383
+ - 📢 **Spread the Word:** Share WebDB on X (Twitter), Bluesky, LinkedIn, Reddit, or with developer friends building offline-first or local-first apps.
384
+ - 💬 **Join the Discussion:** Review our [Architectural Blueprints](https://ahmad-moussawi.github.io/webdb/plans/plan.html), open an issue with suggestions, or share your offline data use cases.
385
+ - 🛠️ **Contribute:** PRs, benchmarks, and feedback on our prototype and specifications are warmly welcome.
386
+
387
+ WebDB is open source under the [MIT License](https://github.com/ahmad-moussawi/webdb/blob/main/LICENSE).
@@ -0,0 +1,18 @@
1
+ export * from './layouts/index.ts';
2
+ export declare const CURRENT_ENGINE_VERSION = 1;
3
+ export declare const CURRENT_MIN_READ_VERSION = 1;
4
+ export declare const PAGE_TYPE_FREE = 0;
5
+ export declare const PAGE_TYPE_INDEX_INTERIOR = 2;
6
+ export declare const PAGE_TYPE_TABLE_INTERIOR = 5;
7
+ export declare const PAGE_TYPE_INDEX_LEAF = 10;
8
+ export declare const PAGE_TYPE_CATALOG_PAGE = 12;
9
+ export declare const PAGE_TYPE_LEAF_DATA = 13;
10
+ export declare const VM_FRAME_SIZE = 1280;
11
+ export declare const VM_FRAME_COUNT = 8;
12
+ export declare const MAX_REGISTERS_PER_FRAME = 64;
13
+ export declare const MAX_CURSORS_PER_FRAME = 16;
14
+ export declare const MAX_SUBQUERY_DEPTH = 7;
15
+ export declare const WAL_HEADER_SIZE = 32;
16
+ export declare const MAX_TOPK_HEAP_LIMIT = 10000;
17
+ export declare const MAX_IN_LIST_SIZE = 10000;
18
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AAGnC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAG1C,eAAO,MAAM,cAAc,IAAO,CAAC;AACnC,eAAO,MAAM,wBAAwB,IAAO,CAAC;AAC7C,eAAO,MAAM,wBAAwB,IAAO,CAAC;AAC7C,eAAO,MAAM,oBAAoB,KAAO,CAAC;AACzC,eAAO,MAAM,sBAAsB,KAAO,CAAC;AAC3C,eAAO,MAAM,mBAAmB,KAAO,CAAC;AAGxC,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAGpC,eAAO,MAAM,eAAe,KAAK,CAAC;AAGlC,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AACzC,eAAO,MAAM,gBAAgB,QAAQ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * WebDB Core Engine C / FFI Export Boundary
3
+ *
4
+ * Explicitly exposes each C Core function annotated with @export_c to the Host layer.
5
+ * In Phase 1 (TypeScript Core), these are direct C-style functional exports.
6
+ * In Phase 2 (C/Wasm Core), these correspond 1-to-1 to the compiled WebAssembly exports.
7
+ */
8
+ export { page_init, page_init_free, page_get_type, page_set_type, page_get_cell_count, page_set_cell_count, page_get_cell_content_offset, page_set_cell_content_offset, page_get_next_page_id, page_set_next_page_id, page_get_free_bytes, page_set_free_bytes, page_get_checksum, page_set_checksum, page_get_cell_offset, page_set_cell_offset, page_get_contiguous_free_space, page_get_total_free_space, page_compact, page_get_row_length, page_insert_row, page_delete_row, page_update_row, page_get_table_layout, page_serialize_row, page_deserialize_row, page_init_interior, page_get_right_child_page_id, page_set_right_child_page_id, page_insert_interior_cell, page_binary_search_interior, page_split_interior, page_init_index_leaf, page_compare_index_keys, page_insert_index_leaf_cell, page_binary_search_index_leaf, serialize_single_key, serialize_composite_key, } from './js/page.c.js';
9
+ export { page_table_hash, page_table_get, page_table_set, page_table_delete, } from './js/page_table.c.js';
10
+ export { buf_pool_get_slot_offset, buf_pool_read_slot_to_page, buf_pool_write_slot_to_page, buf_pool_get_resident_slot, buf_pool_assign_slot, buf_pool_unassign_slot, buf_pool_mark_dirty, buf_pool_clear_dirty, buf_pool_is_dirty, buf_pool_pin_slot, buf_pool_unpin_slot, buf_pool_is_pinned, buf_pool_find_victim, buf_pool_select_eviction_victim, } from './js/buffer_pool.c.js';
11
+ export { vm_step, sql_like_match, compare_sorter_keys, fnv1a_32, } from './js/vm.c.js';
12
+ export { catalog_init_page1, catalog_read_page1_header, catalog_get_total_pages, catalog_set_total_pages, catalog_get_free_page_head, catalog_set_free_page_head, catalog_get_schema_version, catalog_increment_schema_version, catalog_get_change_counter, catalog_increment_change_counter, catalog_update_page1_checksum, catalog_write_fixed_string, catalog_read_fixed_string, catalog_parse_data_type, catalog_read_table_descriptor, catalog_write_table_descriptor, catalog_find_table_by_name, catalog_find_table_slot, catalog_find_free_table_slot, catalog_list_table_descriptors, catalog_read_index_descriptor, catalog_write_index_descriptor, catalog_find_free_index_slot, catalog_find_index_by_name, catalog_list_table_indexes, catalog_delete_index_descriptor, catalog_delete_table_descriptor, catalog_init_page, catalog_read_page_header, catalog_write_page_header, catalog_write_column_meta, catalog_read_column_meta, catalog_map_column_location, catalog_create_table, catalog_load_table_meta, catalog_load_all_tables, } from './js/catalog.c.js';
13
+ export { createWasmCore, type WasmCoreExports, } from './wasm/wasm_core.js';
14
+ export { getWebDbCoreWasmBytes, WEBDB_CORE_WASM_BASE64, } from './wasm/embedded_wasm.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,8BAA8B,EAC9B,yBAAyB,EACzB,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC7B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EACL,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,QAAQ,GACT,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,gCAAgC,EAChC,0BAA0B,EAC1B,gCAAgC,EAChC,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,6BAA6B,EAC7B,8BAA8B,EAC9B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EACL,cAAc,EACd,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,142 @@
1
+ import { u32, i32 } from '../types.ts';
2
+ /**
3
+ * @export_c
4
+ * Returns the byte offset for a given slot in linear memory.
5
+ */
6
+ export declare function buf_pool_get_slot_offset(slot_idx: u32): u32;
7
+ /**
8
+ * @export_c
9
+ * Reads the page ID currently assigned to slot_idx from the slot_to_page map.
10
+ */
11
+ export declare function buf_pool_read_slot_to_page(view: DataView, slot_to_page_offset: u32, slot_idx: u32): u32;
12
+ /**
13
+ * @export_c
14
+ * Writes the page ID assigned to slot_idx in the slot_to_page map.
15
+ */
16
+ export declare function buf_pool_write_slot_to_page(view: DataView, slot_to_page_offset: u32, slot_idx: u32, page_id: u32): void;
17
+ /**
18
+ * @export_c
19
+ * Looks up the resident slot for page_id in the open-addressing hash table.
20
+ * Returns slot index or -1 if not resident.
21
+ */
22
+ export declare function buf_pool_get_resident_slot(view: DataView, page_to_slot_offset: u32, page_to_slot_buckets: u32, page_id: u32): i32;
23
+ /**
24
+ * @export_c
25
+ * Assigns slot_idx to page_id, updating slot_to_page and page_to_slot hash tables.
26
+ */
27
+ export declare function buf_pool_assign_slot(view: DataView, slot_to_page_offset: u32, page_to_slot_offset: u32, page_to_slot_buckets: u32, slot_idx: u32, page_id: u32): i32;
28
+ /**
29
+ * @export_c
30
+ * Unassigns slot_idx, clearing its page table entry and setting assigned page to 0.
31
+ */
32
+ export declare function buf_pool_unassign_slot(view: DataView, slot_to_page_offset: u32, page_to_slot_offset: u32, page_to_slot_buckets: u32, slot_idx: u32): i32;
33
+ /**
34
+ * @export_c
35
+ * Marks slot_idx as dirty in the dirty bitmask.
36
+ */
37
+ export declare function buf_pool_mark_dirty(dirty_mask: Uint8Array, dirty_mask_offset: u32, slot_idx: u32): void;
38
+ /**
39
+ * @export_c
40
+ * Clears the dirty bit for slot_idx in the dirty bitmask.
41
+ */
42
+ export declare function buf_pool_clear_dirty(dirty_mask: Uint8Array, dirty_mask_offset: u32, slot_idx: u32): void;
43
+ /**
44
+ * @export_c
45
+ * Checks if slot_idx is marked dirty in the dirty bitmask.
46
+ */
47
+ export declare function buf_pool_is_dirty(dirty_mask: Uint8Array, dirty_mask_offset: u32, slot_idx: u32): boolean;
48
+ /**
49
+ * Increments pin count for slot_idx. Throws on uint32 overflow.
50
+ */
51
+ export declare function buf_pool_pin_slot(pin_counts: Uint32Array, slot_idx: number): void;
52
+ /**
53
+ * Decrements pin count for slot_idx. Slot 0 is permanently pinned.
54
+ */
55
+ export declare function buf_pool_unpin_slot(pin_counts: Uint32Array, slot_idx: number): void;
56
+ /**
57
+ * Returns true if slot_idx is pinned (pin_count > 0 or slot 0).
58
+ */
59
+ export declare function buf_pool_is_pinned(pin_counts: Uint32Array, slot_idx: number): boolean;
60
+ /**
61
+ * Finds an eviction candidate slot using Clock sweep with second-chance bit check.
62
+ */
63
+ export declare function buf_pool_find_victim(buffer: ArrayBuffer, ref_bits: Uint8Array, pin_counts: Uint32Array, slot_to_page_offset: number, slot_count: number, current_clock_hand: number): {
64
+ candidate_slot: number;
65
+ next_clock_hand: number;
66
+ };
67
+ /**
68
+ * Selects an eviction candidate slot for a requested page using the Core Clock sweep.
69
+ * Examines candidate slot to determine if it holds a dirty page that must be flushed.
70
+ */
71
+ export declare function buf_pool_select_eviction_victim(buffer: ArrayBuffer, ref_bits: Uint8Array, pin_counts: Uint32Array, slot_to_page_offset: number, dirty_mask_offset: number, slot_count: number, current_clock_hand: number, page_id: number): {
72
+ candidate_slot: number;
73
+ flush_page_id: number;
74
+ next_clock_hand: number;
75
+ };
76
+ export interface BufferPoolOptions {
77
+ slotCount?: number;
78
+ maxQueryMemory?: number;
79
+ vfs?: any;
80
+ }
81
+ export declare class BufferPool {
82
+ readonly slot_count: number;
83
+ readonly max_query_memory: number;
84
+ readonly wasm_memory: WebAssembly.Memory;
85
+ buffer: ArrayBuffer;
86
+ view: DataView;
87
+ uint8: Uint8Array;
88
+ readonly slots_end_offset: number;
89
+ readonly slot_to_page_offset: number;
90
+ readonly page_to_slot_offset: number;
91
+ readonly page_to_slot_buckets: number;
92
+ readonly dirty_mask_offset: number;
93
+ readonly vm_context_offset: number;
94
+ readonly result_buffer_offset: number;
95
+ readonly bytecode_offset: number;
96
+ readonly page_scratchpad_offset: number;
97
+ readonly transient_arena_offset: number;
98
+ readonly pin_counts: Uint32Array;
99
+ readonly slot_dirty_generations: Uint32Array;
100
+ readonly ref_bits: Uint8Array;
101
+ private clock_hand;
102
+ private arena_offset;
103
+ constructor(options?: BufferPoolOptions);
104
+ read_u8(address: number): number;
105
+ write_u8(address: number, val: number): void;
106
+ read_u16(address: number): number;
107
+ write_u16(address: number, val: number): void;
108
+ read_u32(address: number): number;
109
+ write_u32(address: number, val: number): void;
110
+ read_i32(address: number): number;
111
+ write_i32(address: number, val: number): void;
112
+ read_f64(address: number): number;
113
+ write_f64(address: number, val: number): void;
114
+ get_bytes(address: number, length: number): Uint8Array;
115
+ set_bytes(address: number, source: Uint8Array): void;
116
+ fill_bytes(address: number, length: number, val?: number): void;
117
+ private validate_slot_idx;
118
+ private validate_page_id;
119
+ get_assigned_page(slot_idx: number): number;
120
+ assign_slot(slot_idx: number, page_id: number): void;
121
+ unassign_slot(slot_idx: number): void;
122
+ mark_dirty(slot_idx: number): void;
123
+ clear_dirty(slot_idx: number): void;
124
+ is_dirty(slot_idx: number): boolean;
125
+ pin_slot(slot_idx: number): void;
126
+ unpin_slot(slot_idx: number): void;
127
+ pin_page(page_id: number): void;
128
+ unpin_page(page_id: number): void;
129
+ is_pinned(slot_idx: number): boolean;
130
+ get_pin_count(slot_idx: number): number;
131
+ get_ref_bit(slot_idx: number): number;
132
+ set_ref_bit(slot_idx: number, val: number): void;
133
+ get_slot_offset(slot_idx: number): number;
134
+ get_page_bytes_in_slot(slot_idx: number): Uint8Array;
135
+ get_slot_data_view(slot_idx: number): DataView;
136
+ get_resident_slot(page_id: number): number;
137
+ find_eviction_candidate_slot(): number;
138
+ get_arena_offset(): number;
139
+ alloc_arena(size: number): number;
140
+ reset_arena(): void;
141
+ }
142
+ //# sourceMappingURL=buffer_pool.c.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer_pool.c.d.ts","sourceRoot":"","sources":["../../../src/core/js/buffer_pool.c.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAyBvC;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAE3D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,QAAQ,EACd,mBAAmB,EAAE,GAAG,EACxB,QAAQ,EAAE,GAAG,GACZ,GAAG,CAEL;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,QAAQ,EACd,mBAAmB,EAAE,GAAG,EACxB,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,GAAG,GACX,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,IA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