@herb-tools/browser 0.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.
@@ -0,0 +1,8 @@
1
+ export * from "@herb-tools/core";
2
+ import { HerbBackendWASM } from "./wasm-backend";
3
+ /**
4
+ * An instance of the `Herb` class using a browser backend.
5
+ * This loads `libherb` using WebAssembly (WASM).
6
+ */
7
+ declare const Herb: HerbBackendWASM;
8
+ export { Herb, HerbBackendWASM };
@@ -0,0 +1,6 @@
1
+ import { HerbBackend } from "@herb-tools/core";
2
+ export declare class HerbBackendWASM extends HerbBackend {
3
+ lexFile(): never;
4
+ parseFile(): never;
5
+ backendVersion(): string;
6
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@herb-tools/browser",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "homepage": "https://herb-tools.dev",
7
+ "bugs": "https://github.com/marcoroth/herb/issues/new?title=Package%20%60@herb-tools/browser%60:%20",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/marcoroth/herb.git",
11
+ "directory": "javascript/packages/browser"
12
+ },
13
+ "main": "./dist/herb-browser.esm.js",
14
+ "module": "./dist/herb-browser.esm.js",
15
+ "types": "./dist/types/index.d.ts",
16
+ "scripts": {
17
+ "build": "yarn clean && yarn build:wasm && yarn build:javascript",
18
+ "build:wasm": "cd ../../../wasm && make && cd -",
19
+ "build:javascript": "rollup -c",
20
+ "dev": "rollup -c -w",
21
+ "clean": "rimraf dist && rimraf build",
22
+ "test": "vitest run",
23
+ "test:ui": "vitest --watch --ui",
24
+ "prepublishOnly": "yarn clean && yarn build && yarn test"
25
+ },
26
+ "exports": {
27
+ "./package.json": "./package.json",
28
+ ".": {
29
+ "types": "./dist/types/index.d.ts",
30
+ "import": "./dist/herb-browser.esm.js",
31
+ "default": "./dist/herb-browser.esm.js"
32
+ }
33
+ },
34
+ "dependencies": {
35
+ "@herb-tools/core": "0.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@rollup/plugin-json": "^6.1.0",
39
+ "@rollup/plugin-node-resolve": "^15.2.3",
40
+ "@rollup/plugin-typescript": "^12.1.2",
41
+ "@testing-library/dom": "^10.4.0",
42
+ "@vitest/browser": "^3.0.8",
43
+ "@vitest/ui": "3.0.8",
44
+ "playwright": "^1.51.0",
45
+ "rimraf": "^6.0.1",
46
+ "rollup": "^4.35.0",
47
+ "tslib": "^2.8.1",
48
+ "typescript": "^5.8.2",
49
+ "vitest": "^3.0.0"
50
+ },
51
+ "files": [
52
+ "package.json",
53
+ "README.md",
54
+ "dist/",
55
+ "src/",
56
+ "build/"
57
+ ]
58
+ }
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ export * from "@herb-tools/core"
2
+
3
+ import { HerbBackendWASM } from "./wasm-backend"
4
+
5
+ import LibHerb from "../build/libherb.js"
6
+
7
+ /**
8
+ * An instance of the `Herb` class using a browser backend.
9
+ * This loads `libherb` using WebAssembly (WASM).
10
+ */
11
+ const Herb = new HerbBackendWASM(LibHerb)
12
+
13
+ export { Herb, HerbBackendWASM }
@@ -0,0 +1,4 @@
1
+ declare module "../build/*" {
2
+ const value: any
3
+ export default value
4
+ }
@@ -0,0 +1,17 @@
1
+ import { name, version } from "../package.json"
2
+
3
+ import { HerbBackend } from "@herb-tools/core"
4
+
5
+ export class HerbBackendWASM extends HerbBackend {
6
+ lexFile(): never {
7
+ throw new Error("File system operations are not supported in the browser.")
8
+ }
9
+
10
+ parseFile(): never {
11
+ throw new Error("File system operations are not supported in the browser.")
12
+ }
13
+
14
+ backendVersion(): string {
15
+ return `${name}@${version}`
16
+ }
17
+ }