@hpcc-js/wasm-expat 1.0.0 → 1.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.
package/package.json CHANGED
@@ -1,55 +1,58 @@
1
1
  {
2
- "name": "@hpcc-js/wasm-expat",
3
- "version": "1.0.0",
4
- "description": "hpcc-js - WASM expat",
5
- "type": "module",
6
- "exports": {
7
- ".": {
8
- "types": "./types/index.d.ts",
9
- "import": "./dist/index.js"
10
- }
11
- },
12
- "types": "./types/index.d.ts",
13
- "files": [
14
- "dist/**/*",
15
- "src/**/*",
16
- "types/**/*"
17
- ],
18
- "scripts": {
19
- "clean": "rimraf ./dist ./dist-test ./types",
20
- "build-types": "tsc --project tsconfig.json --emitDeclarationOnly",
21
- "build-types-watch": "npm run build-types -- --watch",
22
- "build-ts": "node esbuild.mjs",
23
- "build-ts-dev": "npm run build-ts -- --mode=development",
24
- "build-ts-watch": "npm run compile-ts-dev -- --watch",
25
- "build-dev": "run-p build-types build-ts-dev",
26
- "build": "run-p build-types build-ts",
27
- "lint-skypack": "npx -y @skypack/package-check",
28
- "lint-eslint": "eslint src/**/*.ts",
29
- "lint": "run-p lint-eslint lint-skypack",
30
- "test-chrome": "karma start --single-run --browsers ChromiumHeadless karma.conf.cjs",
31
- "test-firefox": "karma start --single-run --browsers Firefox karma.conf.cjs",
32
- "test-node": "mocha ./dist-test/index.node.js --reporter spec",
33
- "test": "run-s test-chrome test-node"
34
- },
35
- "dependencies": {},
36
- "devDependencies": {
37
- "@hpcc-js/esbuild-plugins": "1.0.0"
38
- },
39
- "keywords": [
40
- "graphviz",
41
- "typescript",
42
- "webassembly",
43
- "wasm",
44
- "dot",
45
- "neato",
46
- "twopi"
47
- ],
48
- "author": "hpcc-systems",
49
- "repository": {
50
- "type": "git",
51
- "url": "git+https://github.com/hpcc-systems/hpcc-js-wasm.git"
52
- },
53
- "homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
54
- "license": "Apache-2.0"
55
- }
2
+ "name": "@hpcc-js/wasm-expat",
3
+ "version": "1.1.0",
4
+ "description": "hpcc-js - WASM expat",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./types/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "main": "./dist/index.js",
13
+ "types": "./types/index.d.ts",
14
+ "files": [
15
+ "dist/**/*",
16
+ "src/**/*",
17
+ "types/**/*"
18
+ ],
19
+ "scripts": {
20
+ "clean": "rimraf ./dist ./dist-test ./types",
21
+ "build-types": "tsc --project tsconfig.json --emitDeclarationOnly",
22
+ "build-types-watch": "npm run build-types -- --watch",
23
+ "build-ts": "node esbuild.mjs",
24
+ "build-ts-dev": "npm run build-ts -- --mode=development",
25
+ "build-ts-watch": "npm run compile-ts-dev -- --watch",
26
+ "build-dev": "run-p build-types build-ts-dev",
27
+ "build": "run-p build-types build-ts",
28
+ "lint-skypack": "npx -y @skypack/package-check",
29
+ "lint-eslint": "eslint src/**/*.ts",
30
+ "lint": "run-p lint-eslint",
31
+ "test-chrome": "karma start --single-run --browsers ChromiumHeadless karma.conf.cjs",
32
+ "test-firefox": "karma start --single-run --browsers Firefox karma.conf.cjs",
33
+ "test-node": "mocha ./dist-test/index.node.js --reporter spec",
34
+ "test": "run-s test-chrome test-node",
35
+ "update": "npx -y npm-check-updates -u -t minor",
36
+ "update-major": "npx -y npm-check-updates -u"
37
+ },
38
+ "devDependencies": {
39
+ "@hpcc-js/esbuild-plugins": "1.0.7"
40
+ },
41
+ "keywords": [
42
+ "graphviz",
43
+ "typescript",
44
+ "webassembly",
45
+ "wasm",
46
+ "dot",
47
+ "neato",
48
+ "twopi"
49
+ ],
50
+ "author": "hpcc-systems",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/hpcc-systems/hpcc-js-wasm.git"
54
+ },
55
+ "homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
56
+ "license": "Apache-2.0",
57
+ "gitHead": "841d4713a5ccd8644024e27f929cbb63ffff0573"
58
+ }
package/src/expat.ts CHANGED
@@ -1,5 +1,5 @@
1
- // @ts-ignore
2
- import load, { reset } from "../../../build/src-cpp/expat/expatlib/expatlib.wasm";
1
+ // @ts-expect-error importing from a wasm file is resolved via a custom esbuild plugin
2
+ import load, { reset } from "../../../build/packages/expat/src-cpp/expatlib/expatlib.wasm";
3
3
 
4
4
  export type Attributes = { [key: string]: string };
5
5
  export interface IParser {
@@ -26,7 +26,7 @@ function parseAttrs(attrs: string): Attributes {
26
26
  * See [libexpat.github.io](https://libexpat.github.io/) for c++ details.
27
27
  *
28
28
  * ```ts
29
- * import { Expat } from "@hpcc-js/wasm/expat";
29
+ * import { Expat } from "@hpcc-js/wasm-expat";
30
30
  *
31
31
  * const expat = await Expat.load();
32
32
  *
@@ -144,7 +144,7 @@ export class StackParser implements IParser {
144
144
  return retVal;
145
145
  }
146
146
 
147
- endElement(tag: string): StackElement {
147
+ endElement(_tag: string): StackElement {
148
148
  return this._stack.pop()!;
149
149
  }
150
150
 
@@ -152,4 +152,3 @@ export class StackParser implements IParser {
152
152
  this.top().appendContent(content);
153
153
  }
154
154
  }
155
-
package/types/expat.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface IParser {
12
12
  * See [libexpat.github.io](https://libexpat.github.io/) for c++ details.
13
13
  *
14
14
  * ```ts
15
- * import { Expat } from "@hpcc-js/wasm/expat";
15
+ * import { Expat } from "@hpcc-js/wasm-expat";
16
16
  *
17
17
  * const expat = await Expat.load();
18
18
  *
@@ -80,6 +80,6 @@ export declare class StackParser implements IParser {
80
80
  parse(xml: string): Promise<boolean>;
81
81
  top(): StackElement;
82
82
  startElement(tag: string, attrs: Attributes): StackElement;
83
- endElement(tag: string): StackElement;
83
+ endElement(_tag: string): StackElement;
84
84
  characterData(content: string): void;
85
85
  }
@@ -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
- }