@hpcc-js/wasm 2.18.3-alpha.0 → 2.19.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.
package/package.json CHANGED
@@ -1,103 +1,106 @@
1
1
  {
2
- "name": "@hpcc-js/wasm",
3
- "version": "2.18.3-alpha.0",
4
- "description": "hpcc-js - WASM Libraries",
5
- "type": "module",
6
- "exports": {
7
- ".": {
8
- "types": "./types/index.d.ts",
9
- "import": "./dist/index.js",
10
- "require": "./dist/index.cjs",
11
- "default": "./dist/index.umd.js"
12
- },
13
- "./base91": {
14
- "types": "./types/base91.d.ts",
15
- "import": "./dist/base91.js",
16
- "require": "./dist/base91.cjs",
17
- "default": "./dist/base91.umd.js"
18
- },
19
- "./duckdb": {
20
- "types": "./types/duckdb.d.ts",
21
- "import": "./dist/duckdb.js",
22
- "require": "./dist/duckdb.cjs",
23
- "default": "./dist/duckdb.umd.js"
24
- },
25
- "./expat": {
26
- "types": "./types/expat.d.ts",
27
- "import": "./dist/expat.js",
28
- "require": "./dist/expat.cjs",
29
- "default": "./dist/expat.umd.js"
30
- },
31
- "./graphviz": {
32
- "types": "./types/graphviz.d.ts",
33
- "import": "./dist/graphviz.js",
34
- "require": "./dist/graphviz.cjs",
35
- "default": "./dist/graphviz.umd.js"
36
- },
37
- "./zstd": {
38
- "types": "./types/zstd.d.ts",
39
- "import": "./dist/zstd.js",
40
- "require": "./dist/zstd.cjs",
41
- "default": "./dist/zstd.umd.js"
42
- }
2
+ "name": "@hpcc-js/wasm",
3
+ "version": "2.19.0",
4
+ "description": "hpcc-js - WASM Libraries",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./types/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs",
11
+ "default": "./dist/index.umd.js"
43
12
  },
44
- "main": "./dist/index.cjs",
45
- "module": "./dist/index.js",
46
- "browser": "./dist/index.umd.js",
47
- "unpkg": "./dist/index.umd.js",
48
- "jsdelivr": "./dist/index.umd.js",
49
- "types": "./types/index.d.ts",
50
- "bin": {
51
- "dot-wasm": "node ./node_modules/@hpcc-js/wasm-graphviz-cli/bin/index.js"
13
+ "./base91": {
14
+ "types": "./types/base91.d.ts",
15
+ "import": "./dist/base91.js",
16
+ "require": "./dist/base91.cjs",
17
+ "default": "./dist/base91.umd.js"
52
18
  },
53
- "files": [
54
- "dist/**/*",
55
- "src/**/*",
56
- "types/**/*"
57
- ],
58
- "scripts": {
59
- "clean": "rimraf ./dist ./dist-test ./types",
60
- "build-types": "tsc --project tsconfig.json --emitDeclarationOnly",
61
- "build-types-watch": "npm run build-types -- --watch",
62
- "build-ts": "node esbuild.mjs",
63
- "build-ts-dev": "npm run build-ts -- --mode=development",
64
- "build-ts-watch": "npm run compile-ts-dev -- --watch",
65
- "build-dev": "run-p build-types build-ts-dev",
66
- "build": "run-p build-types build-ts",
67
- "lint-skypack": "npx -y @skypack/package-check",
68
- "lint-eslint": "eslint src/**/*.ts",
69
- "lint": "run-p lint-eslint lint-skypack",
70
- "test-chrome": "karma start --single-run --browsers ChromiumHeadless karma.conf.cjs",
71
- "test-firefox": "karma start --single-run --browsers Firefox karma.conf.cjs",
72
- "test-node": "mocha ./dist-test/index.node.js --reporter spec",
73
- "test": "run-s test-chrome test-node"
19
+ "./duckdb": {
20
+ "types": "./types/duckdb.d.ts",
21
+ "import": "./dist/duckdb.js",
22
+ "require": "./dist/duckdb.cjs",
23
+ "default": "./dist/duckdb.umd.js"
74
24
  },
75
- "dependencies": {
76
- "yargs": "17.7.2"
25
+ "./expat": {
26
+ "types": "./types/expat.d.ts",
27
+ "import": "./dist/expat.js",
28
+ "require": "./dist/expat.cjs",
29
+ "default": "./dist/expat.umd.js"
77
30
  },
78
- "devDependencies": {
79
- "@hpcc-js/esbuild-plugins": "^1.0.1",
80
- "@hpcc-js/wasm-base91": "^1.0.1",
81
- "@hpcc-js/wasm-duckdb": "^1.0.1",
82
- "@hpcc-js/wasm-expat": "^1.0.1",
83
- "@hpcc-js/wasm-graphviz": "^1.0.1",
84
- "@hpcc-js/wasm-zstd": "^1.0.1"
31
+ "./graphviz": {
32
+ "types": "./types/graphviz.d.ts",
33
+ "import": "./dist/graphviz.js",
34
+ "require": "./dist/graphviz.cjs",
35
+ "default": "./dist/graphviz.umd.js"
85
36
  },
86
- "keywords": [
87
- "graphviz",
88
- "typescript",
89
- "webassembly",
90
- "wasm",
91
- "dot",
92
- "neato",
93
- "twopi"
94
- ],
95
- "author": "hpcc-systems",
96
- "repository": {
97
- "type": "git",
98
- "url": "git+https://github.com/hpcc-systems/hpcc-js-wasm.git"
99
- },
100
- "homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
101
- "license": "Apache-2.0",
102
- "gitHead": "4a93a0ee7a7100d8251f1190628d0511ab4bbb1a"
37
+ "./zstd": {
38
+ "types": "./types/zstd.d.ts",
39
+ "import": "./dist/zstd.js",
40
+ "require": "./dist/zstd.cjs",
41
+ "default": "./dist/zstd.umd.js"
42
+ }
43
+ },
44
+ "main": "./dist/index.cjs",
45
+ "module": "./dist/index.js",
46
+ "browser": "./dist/index.umd.js",
47
+ "unpkg": "./dist/index.umd.js",
48
+ "jsdelivr": "./dist/index.umd.js",
49
+ "types": "./types/index.d.ts",
50
+ "bin": {
51
+ "dot-wasm": "node ./node_modules/@hpcc-js/wasm-graphviz-cli/bin/index.js"
52
+ },
53
+ "files": [
54
+ "dist/**/*",
55
+ "src/**/*",
56
+ "types/**/*"
57
+ ],
58
+ "scripts": {
59
+ "clean": "rimraf ./dist ./dist-test ./types",
60
+ "build-types": "tsc --project tsconfig.json --emitDeclarationOnly",
61
+ "build-types-watch": "npm run build-types -- --watch",
62
+ "build-ts": "node esbuild.mjs",
63
+ "build-ts-dev": "npm run build-ts -- --mode=development",
64
+ "build-ts-watch": "npm run compile-ts-dev -- --watch",
65
+ "build-dev": "run-p build-types build-ts-dev",
66
+ "build": "run-p build-types build-ts",
67
+ "lint-skypack": "npx -y @skypack/package-check",
68
+ "lint-eslint": "eslint src/**/*.ts",
69
+ "lint": "run-p lint-eslint",
70
+ "test-chrome": "karma start --single-run --browsers ChromiumHeadless karma.conf.cjs",
71
+ "test-firefox": "karma start --single-run --browsers Firefox karma.conf.cjs",
72
+ "test-node": "mocha ./dist-test/index.node.js --reporter spec",
73
+ "test": "run-s test-chrome test-node",
74
+ "update": "npx -y npm-check-updates -u -t minor",
75
+ "update-major": "npx -y npm-check-updates -u"
76
+ },
77
+ "dependencies": {
78
+ "yargs": "17.7.2"
79
+ },
80
+ "devDependencies": {
81
+ "@hpcc-js/esbuild-plugins": "1.0.7",
82
+ "@hpcc-js/wasm-base91": "1.1.0",
83
+ "@hpcc-js/wasm-duckdb": "1.1.0",
84
+ "@hpcc-js/wasm-expat": "1.1.0",
85
+ "@hpcc-js/wasm-graphviz": "1.1.0",
86
+ "@hpcc-js/wasm-zstd": "1.1.0",
87
+ "esbuild-plugin-umd-wrapper": "3.0.0"
88
+ },
89
+ "keywords": [
90
+ "graphviz",
91
+ "typescript",
92
+ "webassembly",
93
+ "wasm",
94
+ "dot",
95
+ "neato",
96
+ "twopi"
97
+ ],
98
+ "author": "hpcc-systems",
99
+ "repository": {
100
+ "type": "git",
101
+ "url": "git+https://github.com/hpcc-systems/hpcc-js-wasm.git"
102
+ },
103
+ "homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
104
+ "license": "Apache-2.0",
105
+ "gitHead": "841d4713a5ccd8644024e27f929cbb63ffff0573"
103
106
  }
package/src/duckdb.ts CHANGED
@@ -1,83 +1 @@
1
- // @ts-ignore
2
- import { loadWasm, unloadWasm } from "../build/duckdb-eh.wasm.js";
3
- // @ts-ignore
4
- import { loadWasm as loadWasmWorker, unloadWasm as unloadWasmWorker } from "../build/duckdb-browser-eh.worker.js";
5
- import { AsyncDuckDB, ConsoleLogger } from "@duckdb/duckdb-wasm";
6
-
7
- /**
8
- * DuckDB WASM library, a in-process SQL OLAP Database Management System..
9
- *
10
- * See [DuckDB](https://github.com/duckdb/duckdb) for more details.
11
- *
12
- * ```ts
13
- * import { DuckDB } from "@hpcc-js/wasm/duckdb";
14
- *
15
- * let duckdb = await DuckDB.load();
16
- * const c = await duckdb.db.connect();
17
- *
18
- * const data = [
19
- * { "col1": 1, "col2": "foo" },
20
- * { "col1": 2, "col2": "bar" },
21
- * ];
22
- * await duckdb.db.registerFileText("rows.json", JSON.stringify(data));
23
- * await c.insertJSONFromPath('rows.json', { name: 'rows' });
24
- *
25
- * const arrowResult = await c.query("SELECT * FROM read_json_auto('rows.json')");
26
- * const result = arrowResult.toArray().map((row) => row.toJSON());
27
- * expect(result.length).to.equal(data.length);
28
- * for (let i = 0; i < result.length; i++) {
29
- * expect(result[i].col2).to.equal(data[i].col2);
30
- * }
31
- *
32
- * c.close();
33
- * ```
34
- */
35
- export class DuckDB {
36
-
37
- db: AsyncDuckDB;
38
-
39
- private constructor(db: AsyncDuckDB, protected _version: string) {
40
- this.db = db;
41
- }
42
-
43
- /**
44
- * Compiles and instantiates the raw wasm.
45
- *
46
- * ::: info
47
- * In general WebAssembly compilation is disallowed on the main thread if the buffer size is larger than 4KB, hence forcing `load` to be asynchronous;
48
- * :::
49
- *
50
- * @returns A promise to an instance of the DuckDB class.
51
- */
52
- static load(): Promise<DuckDB> {
53
- const workerUrl = URL.createObjectURL(
54
- new Blob([loadWasmWorker()], { type: "text/javascript" })
55
- );
56
- const worker = new Worker(workerUrl);
57
- URL.revokeObjectURL(workerUrl);
58
- const logger = new ConsoleLogger();
59
- const db = new AsyncDuckDB(logger, worker);
60
- const wasmUrl = URL.createObjectURL(
61
- new Blob([loadWasm()], { "type": "application/wasm" })
62
- );
63
- return db.instantiate(wasmUrl, null).then(async () => {
64
- URL.revokeObjectURL(wasmUrl);
65
- return new DuckDB(db, await db.getVersion());
66
- });
67
- }
68
-
69
- /**
70
- * Unloades the compiled wasm instance.
71
- */
72
- static unload() {
73
- unloadWasmWorker();
74
- unloadWasm();
75
- }
76
-
77
- /**
78
- * @returns The DuckDB version
79
- */
80
- version(): string {
81
- return this._version;
82
- }
83
- }
1
+ export * from "@hpcc-js/wasm-duckdb";
package/types/duckdb.d.ts CHANGED
@@ -1,52 +1 @@
1
- import { AsyncDuckDB } from "@duckdb/duckdb-wasm";
2
- /**
3
- * DuckDB WASM library, a in-process SQL OLAP Database Management System..
4
- *
5
- * See [DuckDB](https://github.com/duckdb/duckdb) for more details.
6
- *
7
- * ```ts
8
- * import { DuckDB } from "@hpcc-js/wasm/duckdb";
9
- *
10
- * let duckdb = await DuckDB.load();
11
- * const c = await duckdb.db.connect();
12
- *
13
- * const data = [
14
- * { "col1": 1, "col2": "foo" },
15
- * { "col1": 2, "col2": "bar" },
16
- * ];
17
- * await duckdb.db.registerFileText("rows.json", JSON.stringify(data));
18
- * await c.insertJSONFromPath('rows.json', { name: 'rows' });
19
- *
20
- * const arrowResult = await c.query("SELECT * FROM read_json_auto('rows.json')");
21
- * const result = arrowResult.toArray().map((row) => row.toJSON());
22
- * expect(result.length).to.equal(data.length);
23
- * for (let i = 0; i < result.length; i++) {
24
- * expect(result[i].col2).to.equal(data[i].col2);
25
- * }
26
- *
27
- * c.close();
28
- * ```
29
- */
30
- export declare class DuckDB {
31
- protected _version: string;
32
- db: AsyncDuckDB;
33
- private constructor();
34
- /**
35
- * Compiles and instantiates the raw wasm.
36
- *
37
- * ::: info
38
- * In general WebAssembly compilation is disallowed on the main thread if the buffer size is larger than 4KB, hence forcing `load` to be asynchronous;
39
- * :::
40
- *
41
- * @returns A promise to an instance of the DuckDB class.
42
- */
43
- static load(): Promise<DuckDB>;
44
- /**
45
- * Unloades the compiled wasm instance.
46
- */
47
- static unload(): void;
48
- /**
49
- * @returns The DuckDB version
50
- */
51
- version(): string;
52
- }
1
+ export * from "@hpcc-js/wasm-duckdb";
@@ -1,59 +0,0 @@
1
- export type PTR = number;
2
- export interface HeapU8 {
3
- ptr: PTR;
4
- size: number;
5
- }
6
-
7
- /**
8
- * Base class to simplify moving data into and out of Wasm memory.
9
- */
10
- export class WasmLibrary {
11
-
12
- protected _module: any;
13
- protected _exports: any;
14
-
15
- protected constructor(_module: any, _export: any) {
16
- this._module = _module;
17
- this._exports = _export;
18
- }
19
-
20
- protected malloc_heapu8(size: number): HeapU8 {
21
- const ptr: PTR = this._exports.malloc(size);
22
- return {
23
- ptr,
24
- size
25
- };
26
- }
27
-
28
- protected free_heapu8(data: HeapU8) {
29
- this._exports.free(data.ptr);
30
- }
31
-
32
- protected uint8_heapu8(data: Uint8Array): HeapU8 {
33
- const retVal = this.malloc_heapu8(data.byteLength);
34
- this._module.HEAPU8.set(data, retVal.ptr);
35
- return retVal;
36
- }
37
-
38
- protected heapu8_view(data: HeapU8): Uint8Array {
39
- return this._module.HEAPU8.subarray(data.ptr, data.ptr + data.size);
40
- }
41
-
42
- protected heapu8_uint8(data: HeapU8): Uint8Array {
43
- return new Uint8Array([...this.heapu8_view(data)]);
44
- }
45
-
46
- protected string_heapu8(str: string): HeapU8 {
47
- const data = Uint8Array.from(str, x => x.charCodeAt(0));
48
- return this.uint8_heapu8(data);
49
- }
50
-
51
- protected heapu8_string(data: HeapU8): string {
52
- const retVal = Array.from({ length: data.size });
53
- const submodule = this._module.HEAPU8.subarray(data.ptr, data.ptr + data.size);
54
- submodule.forEach((c: number, i: number) => {
55
- retVal[i] = String.fromCharCode(c);
56
- });
57
- return retVal.join("");
58
- }
59
- }
@@ -1,20 +0,0 @@
1
- export type PTR = number;
2
- export interface HeapU8 {
3
- ptr: PTR;
4
- size: number;
5
- }
6
- /**
7
- * Base class to simplify moving data into and out of Wasm memory.
8
- */
9
- export declare class WasmLibrary {
10
- protected _module: any;
11
- protected _exports: any;
12
- protected constructor(_module: any, _export: any);
13
- protected malloc_heapu8(size: number): HeapU8;
14
- protected free_heapu8(data: HeapU8): void;
15
- protected uint8_heapu8(data: Uint8Array): HeapU8;
16
- protected heapu8_view(data: HeapU8): Uint8Array;
17
- protected heapu8_uint8(data: HeapU8): Uint8Array;
18
- protected string_heapu8(str: string): HeapU8;
19
- protected heapu8_string(data: HeapU8): string;
20
- }