motely-wasm 0.0.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,49 @@
1
+ /** Allows broadcasting events. */
2
+ export interface EventBroadcaster<T extends unknown[]> {
3
+ /** Notifies attached handlers with specified payload.
4
+ * @param args The payload of the notification. */
5
+ broadcast: (...args: [...T]) => void;
6
+ }
7
+ /** Allows attaching event handlers. */
8
+ export interface EventSubscriber<T extends unknown[]> {
9
+ /** Attaches specified handler for events emitted by this event instance.
10
+ * @param handler The handler to attach. */
11
+ subscribe: (handler: (...args: [...T]) => void) => string;
12
+ /** Detaches specified handler from events emitted by this event instance.
13
+ * @param handler The handler to detach. */
14
+ unsubscribe: (handler: (...args: [...T]) => void) => void;
15
+ /** In case event was broadcast at least once, returns last payload; undefined otherwise. */
16
+ readonly last?: [...T];
17
+ }
18
+ /** Optional configuration of an event instance. */
19
+ export type EventOptions = {
20
+ /** Custom warnings handler; by default <code>console.warn</code> is used. */
21
+ warn?: (message: string) => void;
22
+ };
23
+ /** Allows attaching handlers and broadcasting events. */
24
+ export declare class Event<T extends unknown[]> implements EventBroadcaster<T>, EventSubscriber<T> {
25
+ private readonly handlers;
26
+ private readonly warn;
27
+ private lastArgs?;
28
+ /** Creates new event instance. */
29
+ constructor(options?: EventOptions);
30
+ /** Notifies attached handlers with specified payload.
31
+ * @param args The payload of the notification. */
32
+ broadcast(...args: [...T]): void;
33
+ /** Attaches specified handler for events emitted by this event instance.
34
+ * @param handler The handler to attach. */
35
+ subscribe(handler: (...args: [...T]) => void): string;
36
+ /** Detaches specified handler from events emitted by this event instance.
37
+ * @param handler The handler to detach. */
38
+ unsubscribe(handler: (...args: [...T]) => void): void;
39
+ /** Attaches handler with specified identifier for events emitted by this event instance.
40
+ * @param id Identifier of the handler.
41
+ * @param handler The handler to attach. */
42
+ subscribeById(id: string, handler: (...args: [...T]) => void): void;
43
+ /** Detaches handler with specified identifier from events emitted by this event instance.
44
+ * @param id Identifier of the handler. */
45
+ unsubscribeById(id: string): void;
46
+ /** In case event was broadcast at least once, returns last payload; undefined otherwise. */
47
+ get last(): [...T] | undefined;
48
+ private getOrDefineId;
49
+ }
@@ -0,0 +1,3 @@
1
+ import type { RuntimeAPI } from "./modules";
2
+ export declare let exports: unknown;
3
+ export declare function bindExports(runtime: RuntimeAPI, assembly: string): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { RuntimeAPI } from "./modules";
2
+ export declare function bindImports(runtime: RuntimeAPI): void;
@@ -0,0 +1,22 @@
1
+ import { boot, exit, getStatus, BootStatus } from "./boot";
2
+ import { getMain, getNative, getRuntime } from "./modules";
3
+ import { buildConfig } from "./config";
4
+ declare const _default: {
5
+ boot: typeof boot;
6
+ exit: typeof exit;
7
+ getStatus: typeof getStatus;
8
+ BootStatus: typeof BootStatus;
9
+ resources: import("./resources").BootResources;
10
+ /** .NET internal modules and associated utilities. */
11
+ dotnet: {
12
+ getMain: typeof getMain;
13
+ getNative: typeof getNative;
14
+ getRuntime: typeof getRuntime;
15
+ buildConfig: typeof buildConfig;
16
+ };
17
+ };
18
+ export default _default;
19
+ export * from "./event";
20
+ export * from "./bindings.g";
21
+ export type { BootOptions } from "./boot";
22
+ export type { BootResources, BinaryResource } from "./resources";
@@ -0,0 +1,16 @@
1
+ /** Registers specified imported (JS -> C#) interop instance and associates it with unique ID.
2
+ * @param instance Interop instance to resolve ID for.
3
+ * @return Unique identifier of the registered instance. */
4
+ export declare function registerInstance(instance: object): number;
5
+ /** Resolves registered imported (JS -> C#) interop instance from specified ID.
6
+ * @param id Unique identifier of the instance. */
7
+ export declare function getInstance(id: number): object;
8
+ /** Invoked from C# to notify that imported (JS -> C#) interop instance is no longer
9
+ * used (eg, was garbage collected) and can be released on JavaScript side as well.
10
+ * @param id Unique identifier of the disposed interop instance. */
11
+ export declare function disposeInstance(id: number): void;
12
+ /** Registers specified exported (C# -> JS) instance to invoke dispose on C# side
13
+ * when it's collected (finalized) by JavaScript runtime GC.
14
+ * @param instance Interop instance to register.
15
+ * @param id Unique identifier of the interop instance. */
16
+ export declare function disposeOnFinalize(instance: object, id: number): void;
@@ -0,0 +1,17 @@
1
+ import type { ModuleAPI, MonoConfig, AssetEntry } from "./dotnet.g.d.ts";
2
+ export type * from "./dotnet.g.d.ts";
3
+ export type RuntimeConfig = MonoConfig & {
4
+ assets?: AssetEntry[];
5
+ };
6
+ /** Fetches main dotnet module (<code>dotnet.js</code>). */
7
+ export declare function getMain(root?: string): Promise<ModuleAPI & {
8
+ embedded?: boolean;
9
+ }>;
10
+ /** Fetches dotnet native module (<code>dotnet.native.js</code>). */
11
+ export declare function getNative(root?: string): Promise<unknown & {
12
+ embedded?: boolean;
13
+ }>;
14
+ /** Fetches dotnet runtime module (<code>dotnet.runtime.js</code>). */
15
+ export declare function getRuntime(root?: string): Promise<unknown & {
16
+ embedded?: boolean;
17
+ }>;
@@ -0,0 +1,18 @@
1
+ /** Resources required to boot .NET runtime. */
2
+ export type BootResources = {
3
+ /** Compiled .NET WASM runtime module. */
4
+ readonly wasm: BinaryResource;
5
+ /** Compiled .NET assemblies. */
6
+ readonly assemblies: BinaryResource[];
7
+ /** Name of the entry (main) assembly, with .dll extension. */
8
+ readonly entryAssemblyName: string;
9
+ };
10
+ /** Boot resource with binary content. */
11
+ export type BinaryResource = {
12
+ /** Name of the binary file, including extension. */
13
+ readonly name: string;
14
+ /** Binary or base64-encoded content of the file; undefined when embedding disabled. */
15
+ readonly content?: Uint8Array | string;
16
+ };
17
+ /** Resources required to boot .NET runtime. */
18
+ export declare const resources: BootResources;
@@ -0,0 +1,3 @@
1
+ import { BootResources } from "./resources";
2
+ declare const _default: BootResources;
3
+ export default _default;