mcard-js 2.1.34 → 2.1.36

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
@@ -2,14 +2,14 @@
2
2
 
3
3
  Full-featured TypeScript implementation of MCard content-addressable storage, supporting both browser and Node.js environments.
4
4
 
5
- [![Tests](https://img.shields.io/badge/tests-814%20passed%20(52%20files)-brightgreen)](./tests)
5
+ [![Tests](https://img.shields.io/badge/tests-864%20passed%20(54%20files)-brightgreen)](./tests)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org/)
7
7
  [![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)](https://nodejs.org/)
8
8
 
9
9
  ## Features
10
10
 
11
11
  - **Content Addressing**: SHA-256 via Web Crypto API (browser) or Node.js crypto
12
- - **3 Interchangeable Storage Engines**: `IndexedDBEngine` (browser), `SqliteNodeEngine` (Node.js/better-sqlite3), `SqliteWasmEngine` (browser/sql.js) verified by 162 cross-engine interchangeability tests
12
+ - **5 Interchangeable Storage Engines**: `IndexedDBEngine` (browser), `SqliteNodeEngine` (Node.js/better-sqlite3), `SqliteWasmEngine` (browser/sql.js), `DuckDBNodeEngine` (Node.js/@duckdb/node-api), `DuckDBWasmEngine` (browser/@duckdb/duckdb-wasm)
13
13
  - **UTF-8 Handles**: International support (文檔, مستند, ドキュメント, документ)
14
14
  - **Monadic API**: Maybe, Either, IO monads for functional composition
15
15
  - **PTR Runtime**: Polynomial Type Runtime with polyglot execution (JS, Python, Rust, C, WASM, Lean)
@@ -99,6 +99,39 @@ const count = db.countSync();
99
99
  db.close();
100
100
  ```
101
101
 
102
+ ### DuckDB (Node.js — Alternative OLAP Engine)
103
+ ```typescript
104
+ import { DuckDBNodeEngine } from './storage/DuckDBNodeEngine';
105
+
106
+ // Async factory — in-memory or file-backed
107
+ const db = await DuckDBNodeEngine.create(':memory:');
108
+ // or: await DuckDBNodeEngine.create('./mcard.duckdb');
109
+
110
+ // Same StorageEngine interface as SQLite
111
+ const card = await MCard.create('Hello from DuckDB!');
112
+ await db.add(card);
113
+
114
+ const retrieved = await db.get(card.hash);
115
+ console.log(retrieved?.getContentAsText());
116
+
117
+ await db.close();
118
+ ```
119
+
120
+ ### DuckDB WASM (Browser — In-Browser OLAP)
121
+ ```typescript
122
+ import { DuckDBWasmEngine } from './storage/DuckDBWasmEngine';
123
+
124
+ // Runs DuckDB entirely in WebAssembly via Web Worker
125
+ const db = new DuckDBWasmEngine();
126
+ await db.init(); // Downloads WASM bundle from CDN
127
+
128
+ // Same StorageEngine interface
129
+ const card = await MCard.create('Hello from DuckDB WASM!');
130
+ await db.add(card);
131
+
132
+ await db.close();
133
+ ```
134
+
102
135
  ## Database Schema
103
136
 
104
137
  The SQLite backend uses schemas matching the Python implementation for full interoperability.
@@ -0,0 +1,9 @@
1
+ import {
2
+ CardCollection
3
+ } from "./chunk-5HXLTWYN.js";
4
+ import "./chunk-5BIDGXA6.js";
5
+ import "./chunk-7NKII2JA.js";
6
+ import "./chunk-MLKGABMK.js";
7
+ export {
8
+ CardCollection
9
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ LambdaRuntime,
3
+ parseLambdaExpression
4
+ } from "./chunk-Z4BRNTO5.js";
5
+ import "./chunk-MPMRBT5R.js";
6
+ import "./chunk-2KADE3SE.js";
7
+ import "./chunk-X42F7DE3.js";
8
+ import "./chunk-WTNVQ5WS.js";
9
+ import "./chunk-5HXLTWYN.js";
10
+ import "./chunk-5BIDGXA6.js";
11
+ import "./chunk-7NKII2JA.js";
12
+ import "./chunk-MLKGABMK.js";
13
+ export {
14
+ LambdaRuntime,
15
+ parseLambdaExpression
16
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ loadFileToCollection,
3
+ processAndStoreFile
4
+ } from "./chunk-OFHDMLNM.js";
5
+ import "./chunk-5BIDGXA6.js";
6
+ import "./chunk-7NKII2JA.js";
7
+ import "./chunk-MLKGABMK.js";
8
+ export {
9
+ loadFileToCollection,
10
+ processAndStoreFile
11
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ MCard
3
+ } from "./chunk-5BIDGXA6.js";
4
+ import "./chunk-7NKII2JA.js";
5
+ import "./chunk-MLKGABMK.js";
6
+ export {
7
+ MCard
8
+ };