@grafeo-db/wasm 0.1.4 → 0.5.1

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
@@ -1,12 +1,16 @@
1
1
  # @grafeo-db/wasm
2
2
 
3
- WebAssembly bindings for [Grafeo](https://grafeo.dev) - a high-performance, pure-Rust, embeddable graph database.
3
+ Low-level WebAssembly binary for [Grafeo](https://github.com/GrafeoDB/grafeo), a high-performance graph database.
4
4
 
5
- ## Status
5
+ ## Which Package Do You Need?
6
6
 
7
- **Pre-alpha** - The WebAssembly bindings are under development.
7
+ | Package | Use Case |
8
+ |---------|----------|
9
+ | [`@grafeo-db/web`](https://www.npmjs.com/package/@grafeo-db/web) | Browser apps with IndexedDB, Web Workers, React/Vue/Svelte (recommended) |
10
+ | [`@grafeo-db/wasm`](https://www.npmjs.com/package/@grafeo-db/wasm) | Raw WASM binary for custom loaders or non-standard runtimes |
11
+ | [`@grafeo-db/js`](https://www.npmjs.com/package/@grafeo-db/js) | Node.js native bindings (faster than WASM for server-side) |
8
12
 
9
- For production use, please use the [Python bindings](https://pypi.org/project/grafeo/) which are fully functional.
13
+ **Most users should use `@grafeo-db/web`** - it wraps this package and adds browser-specific features.
10
14
 
11
15
  ## Installation
12
16
 
@@ -14,16 +18,66 @@ For production use, please use the [Python bindings](https://pypi.org/project/gr
14
18
  npm install @grafeo-db/wasm
15
19
  ```
16
20
 
17
- ## Planned Features
21
+ ## Usage
18
22
 
19
- - Browser and Node.js compatible WebAssembly module
20
- - Full TypeScript type definitions
21
- - Support for GQL, Cypher, SPARQL, and GraphQL query languages
22
- - In-memory graph database in the browser
23
- - Persistence via IndexedDB or OPFS
23
+ ```typescript
24
+ import init, { GrafeoCore } from '@grafeo-db/wasm';
25
+
26
+ // Initialize the WASM module
27
+ await init();
28
+
29
+ // Low-level API
30
+ const core = new GrafeoCore();
31
+ const result = core.execute(`MATCH (n:Person) RETURN n.name`);
32
+ ```
33
+
34
+ ## Progress
35
+
36
+ - [ ] Core WASM bindings via wasm-bindgen
37
+ - [ ] In-memory database support
38
+ - [ ] All query languages (GQL, Cypher, SPARQL, GraphQL, Gremlin)
39
+ - [ ] TypeScript type definitions
40
+ - [ ] Size optimization (target: <1MB gzipped)
41
+
42
+ ## Package Contents
43
+
44
+ ```
45
+ @grafeo-db/wasm/
46
+ ├── grafeo_wasm_bg.wasm # WebAssembly binary
47
+ ├── grafeo_wasm.js # JavaScript loader
48
+ ├── grafeo_wasm.d.ts # TypeScript definitions
49
+ └── package.json
50
+ ```
51
+
52
+ ## Target Bundle Size
53
+
54
+ | Build | Size (gzip) |
55
+ |-------|-------------|
56
+ | Full (all languages) | ~600 KB |
57
+ | Minimal (GQL only) | ~300 KB |
58
+
59
+ ## Runtime Support
60
+
61
+ | Runtime | Status |
62
+ |---------|--------|
63
+ | Browser (Chrome, Firefox, Safari, Edge) | Planned |
64
+ | Deno | Planned |
65
+ | Cloudflare Workers | Planned |
66
+ | Node.js | Use `@grafeo-db/js` instead |
67
+
68
+ ## Current Alternatives
69
+
70
+ While WASM bindings are in development, you can use:
71
+
72
+ - **Python**: [`grafeo`](https://pypi.org/project/grafeo/) - fully functional
73
+ - **Rust**: [`grafeo`](https://crates.io/crates/grafeo) - fully functional
24
74
 
25
75
  ## Links
26
76
 
27
77
  - [Documentation](https://grafeo.dev)
28
78
  - [GitHub](https://github.com/GrafeoDB/grafeo)
29
- - [Python Package](https://pypi.org/project/grafeo/)
79
+ - [Roadmap](https://github.com/GrafeoDB/grafeo/blob/main/docs/roadmap.md)
80
+
81
+ ## License
82
+
83
+ Apache-2.0
package/grafeo_wasm.d.ts CHANGED
@@ -1,5 +1,94 @@
1
- // grafeo-wasm - WebAssembly bindings for Grafeo
2
- // Pre-alpha - bindings are under development.
3
- // See https://grafeo.dev for current status.
1
+ /* tslint:disable */
2
+ /* eslint-disable */
4
3
 
5
- export {};
4
+ /**
5
+ * A Grafeo graph database instance running in WebAssembly.
6
+ *
7
+ * All data is held in memory within the WASM heap. For persistence,
8
+ * use `exportSnapshot()` / `importSnapshot()` with IndexedDB or
9
+ * the higher-level `@grafeo-db/web` package.
10
+ */
11
+ export class Database {
12
+ free(): void;
13
+ [Symbol.dispose](): void;
14
+ /**
15
+ * Returns the number of edges in the database.
16
+ */
17
+ edgeCount(): number;
18
+ /**
19
+ * Executes a GQL query and returns results as an array of objects.
20
+ *
21
+ * Each row becomes a JavaScript object with column names as keys.
22
+ *
23
+ * ```js
24
+ * const results = db.execute("MATCH (p:Person) RETURN p.name, p.age");
25
+ * // [{name: "Alice", age: 30}, {name: "Bob", age: 25}]
26
+ * ```
27
+ */
28
+ execute(query: string): any;
29
+ /**
30
+ * Executes a GQL query and returns raw columns, rows, and metadata.
31
+ *
32
+ * Returns `{ columns: string[], rows: any[][], executionTimeMs?: number }`.
33
+ */
34
+ executeRaw(query: string): any;
35
+ /**
36
+ * Executes a query using a specific query language.
37
+ *
38
+ * Supported languages: `"gql"`, `"cypher"`, `"sparql"`, `"gremlin"`, `"graphql"`.
39
+ * Languages require their corresponding feature flag to be enabled.
40
+ *
41
+ * ```js
42
+ * const results = db.executeWithLanguage(
43
+ * "MATCH (p:Person) RETURN p.name",
44
+ * "cypher"
45
+ * );
46
+ * ```
47
+ */
48
+ executeWithLanguage(query: string, language: string): any;
49
+ /**
50
+ * Exports the database to a binary snapshot.
51
+ *
52
+ * Returns a `Uint8Array` that can be stored in IndexedDB, localStorage,
53
+ * or sent over the network. Restore with `Database.importSnapshot()`.
54
+ *
55
+ * ```js
56
+ * const bytes = db.exportSnapshot();
57
+ * // Store in IndexedDB, download as file, etc.
58
+ * ```
59
+ */
60
+ exportSnapshot(): Uint8Array;
61
+ /**
62
+ * Creates a database from a binary snapshot.
63
+ *
64
+ * The `data` must have been produced by `exportSnapshot()`.
65
+ *
66
+ * ```js
67
+ * const db = Database.importSnapshot(bytes);
68
+ * ```
69
+ */
70
+ static importSnapshot(data: Uint8Array): Database;
71
+ /**
72
+ * Creates a new in-memory database.
73
+ */
74
+ constructor();
75
+ /**
76
+ * Returns the number of nodes in the database.
77
+ */
78
+ nodeCount(): number;
79
+ /**
80
+ * Returns schema information about the database.
81
+ *
82
+ * Returns an object describing labels, edge types, and property keys.
83
+ *
84
+ * ```js
85
+ * const schema = db.schema();
86
+ * // { lpg: { labels: [...], edgeTypes: [...], propertyKeys: [...] } }
87
+ * ```
88
+ */
89
+ schema(): any;
90
+ /**
91
+ * Returns the Grafeo version.
92
+ */
93
+ static version(): string;
94
+ }
package/grafeo_wasm.js CHANGED
@@ -1,5 +1,9 @@
1
- throw new Error(
2
- 'grafeo-wasm is pre-alpha and not yet implemented. ' +
3
- 'Please see https://grafeo.dev for the current status. ' +
4
- 'For production use, consider the Python bindings: https://pypi.org/project/grafeo/'
5
- );
1
+ /* @ts-self-types="./grafeo_wasm.d.ts" */
2
+
3
+ import * as wasm from "./grafeo_wasm_bg.wasm";
4
+ import { __wbg_set_wasm } from "./grafeo_wasm_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ Database
9
+ } from "./grafeo_wasm_bg.js";
Binary file
@@ -0,0 +1,22 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_database_free: (a: number, b: number) => void;
5
+ export const database_edgeCount: (a: number) => number;
6
+ export const database_execute: (a: number, b: number, c: number) => [number, number, number];
7
+ export const database_executeRaw: (a: number, b: number, c: number) => [number, number, number];
8
+ export const database_executeWithLanguage: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
9
+ export const database_exportSnapshot: (a: number) => [number, number, number, number];
10
+ export const database_importSnapshot: (a: number, b: number) => [number, number, number];
11
+ export const database_new: () => [number, number, number];
12
+ export const database_nodeCount: (a: number) => number;
13
+ export const database_schema: (a: number) => [number, number, number];
14
+ export const database_version: () => [number, number];
15
+ export const __wbindgen_malloc: (a: number, b: number) => number;
16
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
17
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
18
+ export const __wbindgen_exn_store: (a: number) => void;
19
+ export const __externref_table_alloc: () => number;
20
+ export const __wbindgen_externrefs: WebAssembly.Table;
21
+ export const __externref_table_dealloc: (a: number) => void;
22
+ export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@grafeo-db/wasm",
3
- "version": "0.1.4",
3
+ "type": "module",
4
+ "version": "0.5.1",
4
5
  "description": "WebAssembly bindings for Grafeo - a high-performance embeddable graph database",
5
6
  "keywords": [
6
7
  "graph",
@@ -12,8 +13,8 @@
12
13
  "wasm",
13
14
  "webassembly"
14
15
  ],
15
- "author": "StevenBtw",
16
- "license": "MIT",
16
+ "author": "S.T. Grond",
17
+ "license": "Apache-2.0",
17
18
  "repository": {
18
19
  "type": "git",
19
20
  "url": "https://github.com/GrafeoDB/grafeo.git",
@@ -28,6 +29,11 @@
28
29
  "files": [
29
30
  "grafeo_wasm.js",
30
31
  "grafeo_wasm.d.ts",
31
- "grafeo_wasm_bg.wasm"
32
+ "grafeo_wasm_bg.wasm",
33
+ "grafeo_wasm_bg.wasm.d.ts"
34
+ ],
35
+ "sideEffects": [
36
+ "./grafeo_wasm.js",
37
+ "./snippets/*"
32
38
  ]
33
39
  }