@hara-lang/native-browser 0.1.9

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,88 @@
1
+ export interface StartOptions {
2
+ /** Override the default adjacent hara_wasm_bg.wasm URL. */
3
+ wasmUrl?: RequestInfo | URL | ArrayBuffer | WebAssembly.Module | Uint8Array;
4
+ /** Host resources registered before the first require. */
5
+ resources?: Map<string, string> | Record<string, string>;
6
+ /** Exact lock used to install semantic packages before the runtime is returned. */
7
+ lock?: string;
8
+ /** Semantic package names, coordinates, or namespaces selected from the lock. */
9
+ targets?: string[];
10
+ /** Fetch, capability, host, and browser-worker policy for package installation. */
11
+ packageOptions?: LockedPackageOptions;
12
+ }
13
+
14
+ export interface HaraRuntime {
15
+ eval(source: string): string;
16
+ require(namespace: string): string;
17
+ registerResource(namespace: string, source: string): void;
18
+ installDirectWasmImport(logical: string, bytes: Uint8Array): void;
19
+ installMemoryWasmBinding(
20
+ manifest: string,
21
+ interfaceSource: string,
22
+ bindingsSource: string,
23
+ bytes: Uint8Array
24
+ ): void;
25
+ unregisterResource(namespace: string): void;
26
+ evalInNamespace(namespace: string, source: string): string;
27
+ currentNamespace(): string;
28
+ compileBytecode(source: string): Uint8Array;
29
+ evalBytecode(artifact: Uint8Array): string;
30
+ evalBytecodeBundle(artifact: Uint8Array): void;
31
+ installPackages(lockSource: string, options?: LockedPackageOptions): Promise<string[]>;
32
+ compileWholeWasm(source: string): Promise<WholeWasmModule>;
33
+ compileWholeWasmProduct(source: string): WholeWasmProduct;
34
+ loadWholeWasm(
35
+ product: WholeWasmProduct | Uint8Array | ArrayBuffer
36
+ ): Promise<WholeWasmModule>;
37
+ installHostHandler(handler: Function): void;
38
+ dispose(): Promise<void>;
39
+ readonly raw: unknown;
40
+ }
41
+
42
+ export interface WholeWasmModule {
43
+ call(...arguments: Array<number | bigint>): bigint;
44
+ callFunction(functionId: number, ...arguments: Array<number | bigint>): bigint;
45
+ readonly manifest: Readonly<Record<string, unknown>> | null;
46
+ readonly module: WebAssembly.Module;
47
+ readonly instance: WebAssembly.Instance;
48
+ }
49
+
50
+ export interface WholeWasmProduct {
51
+ readonly artifact: Uint8Array;
52
+ readonly manifest: Readonly<Record<string, unknown>>;
53
+ }
54
+
55
+ export interface LockedPackageOptions {
56
+ fetch?: typeof globalThis.fetch;
57
+ origin?: string;
58
+ targets?: string[];
59
+ capabilities?: string[];
60
+ hostCalls?: Record<string, Function | Record<string, Function>>;
61
+ workerFactory?: (url: string, options: WorkerOptions) => Worker;
62
+ createObjectURL?: (blob: Blob) => string;
63
+ revokeObjectURL?: (url: string) => void;
64
+ Blob?: typeof Blob;
65
+ }
66
+
67
+ export function loadLockedPackageResources(
68
+ lockSource: string,
69
+ request?: typeof globalThis.fetch
70
+ ): Promise<Record<string, string>>;
71
+
72
+ export function installLockedPackages(
73
+ runtime: Pick<HaraRuntime, "registerResource"> & Partial<Pick<HaraRuntime, "evalBytecodeBundle">>,
74
+ lockSource: string,
75
+ options?: LockedPackageOptions
76
+ ): Promise<string[]>;
77
+
78
+ export function installPackageProvider(
79
+ runtime: HaraRuntime,
80
+ lockSource: string,
81
+ options?: LockedPackageOptions
82
+ ): { readonly active: ReadonlySet<string>; readonly handler: Function };
83
+
84
+ export function disposeBrowserPackageProviders(runtime: HaraRuntime): Promise<void>;
85
+
86
+ export function start(options?: StartOptions): Promise<HaraRuntime>;
87
+ export const ready: Promise<HaraRuntime>;
88
+ export default start;