@unyt/datex 0.0.8 → 0.0.10
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/esm/_dnt.shims.d.ts +1 -27
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +1 -31
- package/esm/datex-core/datex_core_js.internal.d.ts +53 -44
- package/esm/datex-core/datex_core_js.internal.d.ts.map +1 -1
- package/esm/datex-core/datex_core_js.internal.js +164 -146
- package/esm/datex-core/datex_core_js.js +16 -15
- package/esm/datex-core/datex_core_js.wasm +0 -0
- package/esm/datex-core/wasm_url.node.js +1 -0
- package/esm/datex-core.d.ts +6 -0
- package/esm/datex-core.d.ts.map +1 -1
- package/esm/datex-core.js +6 -0
- package/esm/default.d.ts +8 -1
- package/esm/default.d.ts.map +1 -1
- package/esm/default.js +8 -1
- package/esm/deno.json +3 -2
- package/esm/dif/builders.d.ts +5 -0
- package/esm/dif/builders.d.ts.map +1 -1
- package/esm/dif/builders.js +5 -0
- package/esm/dif/core.d.ts +9 -0
- package/esm/dif/core.d.ts.map +1 -1
- package/esm/dif/core.js +6 -0
- package/esm/dif/definitions.d.ts +43 -1
- package/esm/dif/definitions.d.ts.map +1 -1
- package/esm/dif/definitions.js +14 -0
- package/esm/dif/dif-handler.d.ts +17 -0
- package/esm/dif/dif-handler.d.ts.map +1 -1
- package/esm/dif/dif-handler.js +18 -2
- package/esm/dif/display.d.ts +23 -0
- package/esm/dif/display.d.ts.map +1 -1
- package/esm/dif/display.js +23 -0
- package/esm/dif/mod.d.ts +5 -0
- package/esm/dif/mod.d.ts.map +1 -1
- package/esm/dif/mod.js +5 -0
- package/esm/mod.d.ts +16 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +16 -1
- package/esm/network/com-hub.d.ts +30 -0
- package/esm/network/com-hub.d.ts.map +1 -1
- package/esm/network/com-hub.js +32 -0
- package/esm/network/com-interface.d.ts +18 -0
- package/esm/network/com-interface.d.ts.map +1 -1
- package/esm/network/com-interface.js +13 -0
- package/esm/network/interface-impls/base.d.ts +36 -1
- package/esm/network/interface-impls/base.d.ts.map +1 -1
- package/esm/network/interface-impls/base.js +27 -1
- package/esm/network/interface-impls/websocket-client.d.ts +3 -1
- package/esm/network/interface-impls/websocket-client.d.ts.map +1 -1
- package/esm/network/interface-impls/websocket-client.js +3 -1
- package/esm/network/mod.d.ts +6 -0
- package/esm/network/mod.d.ts.map +1 -1
- package/esm/network/mod.js +6 -0
- package/esm/refs/ref.d.ts +3 -0
- package/esm/refs/ref.d.ts.map +1 -1
- package/esm/refs/ref.js +3 -0
- package/esm/runtime/runtime.d.ts +52 -2
- package/esm/runtime/runtime.d.ts.map +1 -1
- package/esm/runtime/runtime.js +49 -3
- package/esm/runtime/special-core-types.d.ts +18 -2
- package/esm/runtime/special-core-types.d.ts.map +1 -1
- package/esm/runtime/special-core-types.js +19 -3
- package/esm/utils/js-runtime-compat/js-runtime-interface.d.ts +10 -0
- package/esm/utils/js-runtime-compat/js-runtime-interface.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/js-runtime-interface.js +1 -0
- package/esm/utils/js-runtime-compat/js-runtime.d.ts +18 -0
- package/esm/utils/js-runtime-compat/js-runtime.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/js-runtime.js +43 -0
- package/esm/utils/js-runtime-compat/runtimes/browser.d.ts +8 -0
- package/esm/utils/js-runtime-compat/runtimes/browser.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/runtimes/browser.js +22 -0
- package/esm/utils/js-runtime-compat/runtimes/deno.d.ts +8 -0
- package/esm/utils/js-runtime-compat/runtimes/deno.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/runtimes/deno.js +19 -0
- package/esm/utils/js-runtime-compat/runtimes/node.d.ts +8 -0
- package/esm/utils/js-runtime-compat/runtimes/node.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/runtimes/node.js +21 -0
- package/package.json +1 -22
- package/esm/_dnt.polyfills.d.ts +0 -101
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -127
- package/esm/network/interface-impls/serial.d.ts +0 -6
- package/esm/network/interface-impls/serial.d.ts.map +0 -1
- package/esm/network/interface-impls/serial.js +0 -6
- package/esm/network/interface-impls/webrtc.d.ts +0 -12
- package/esm/network/interface-impls/webrtc.d.ts.map +0 -1
- package/esm/network/interface-impls/webrtc.js +0 -24
- package/esm/network/interface-impls/websocket-server-deno.d.ts +0 -9
- package/esm/network/interface-impls/websocket-server-deno.d.ts.map +0 -1
- package/esm/network/interface-impls/websocket-server-deno.js +0 -45
|
@@ -1,11 +1,46 @@
|
|
|
1
|
-
import "../../_dnt.polyfills.js";
|
|
2
1
|
import { ComInterfaceImpl } from "../com-interface.js";
|
|
3
2
|
import type { BaseInterfaceSetupData, InterfaceDirection } from "../../datex-core/datex_core_js";
|
|
3
|
+
export type {
|
|
4
|
+
/**
|
|
5
|
+
* Setup data for the base communication interface.
|
|
6
|
+
*/
|
|
7
|
+
BaseInterfaceSetupData,
|
|
8
|
+
/**
|
|
9
|
+
* Direction of the communication interface (In/Out/InOut).
|
|
10
|
+
*/
|
|
11
|
+
InterfaceDirection, };
|
|
12
|
+
/**
|
|
13
|
+
* Implementation of the base communication interface.
|
|
14
|
+
*/
|
|
4
15
|
export declare class BaseInterfaceImpl extends ComInterfaceImpl<BaseInterfaceSetupData> {
|
|
16
|
+
/**
|
|
17
|
+
* Registers a socket for the communication interface.
|
|
18
|
+
* @param interfaceDirection The direction of the interface (incoming/outgoing).
|
|
19
|
+
* @returns The UUID of the registered socket.
|
|
20
|
+
*/
|
|
5
21
|
registerSocket(interfaceDirection: InterfaceDirection): string;
|
|
22
|
+
/**
|
|
23
|
+
* Destroys a socket for the communication interface.
|
|
24
|
+
* @param socketUUID The UUID of the socket to destroy.
|
|
25
|
+
*/
|
|
6
26
|
destroySocket(socketUUID: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Receives a data block for the communication interface.
|
|
29
|
+
* @param socketUUID The UUID of the socket to receive data on.
|
|
30
|
+
* @param data The data block to receive.
|
|
31
|
+
*/
|
|
7
32
|
receive(socketUUID: string, data: Uint8Array): void;
|
|
33
|
+
/**
|
|
34
|
+
* Tests sending a data block for the communication interface.
|
|
35
|
+
* @param socketUUID The UUID of the socket to send data on.
|
|
36
|
+
* @param data The data block to send.
|
|
37
|
+
* @returns A promise that resolves to true if the block was sent successfully, false otherwise.
|
|
38
|
+
*/
|
|
8
39
|
testSendBlock(socketUUID: string, data: Uint8Array): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Registers a callback to handle sending data blocks.
|
|
42
|
+
* @param callback The callback to be invoked when sending data.
|
|
43
|
+
*/
|
|
9
44
|
onSend(callback: (data: Uint8Array, receiver_socket_uuid: string) => Promise<boolean>): void;
|
|
10
45
|
}
|
|
11
46
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/network/interface-impls/base.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACR,sBAAsB,EACtB,kBAAkB,EACrB,MAAM,gCAAgC,CAAC;AAExC,qBAAa,iBACT,SAAQ,gBAAgB,CAAC,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/network/interface-impls/base.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACR,sBAAsB,EACtB,kBAAkB,EACrB,MAAM,gCAAgC,CAAC;AAExC,YAAY;AACR;;GAEG;AACH,sBAAsB;AACtB;;GAEG;AACH,kBAAkB,GACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,iBACT,SAAQ,gBAAgB,CAAC,sBAAsB,CAAC;IAChD;;;;OAIG;IACI,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,MAAM;IAOrE;;;OAGG;IACI,aAAa,CAAC,UAAU,EAAE,MAAM;IAOvC;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU;IAQnD;;;;;OAKG;IACI,aAAa,CAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,UAAU,GACjB,OAAO,CAAC,OAAO,CAAC;IAQnB;;;OAGG;IACI,MAAM,CACT,QAAQ,EAAE,CACN,IAAI,EAAE,UAAU,EAChB,oBAAoB,EAAE,MAAM,KAC3B,OAAO,CAAC,OAAO,CAAC;CAI5B"}
|
|
@@ -1,19 +1,45 @@
|
|
|
1
|
-
import "../../_dnt.polyfills.js";
|
|
2
1
|
import { ComInterfaceImpl } from "../com-interface.js";
|
|
3
2
|
import { ComHub } from "../com-hub.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the base communication interface.
|
|
5
|
+
*/
|
|
4
6
|
export class BaseInterfaceImpl extends ComInterfaceImpl {
|
|
7
|
+
/**
|
|
8
|
+
* Registers a socket for the communication interface.
|
|
9
|
+
* @param interfaceDirection The direction of the interface (incoming/outgoing).
|
|
10
|
+
* @returns The UUID of the registered socket.
|
|
11
|
+
*/
|
|
5
12
|
registerSocket(interfaceDirection) {
|
|
6
13
|
return this.jsComHub.base_interface_register_socket(this.uuid, interfaceDirection);
|
|
7
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Destroys a socket for the communication interface.
|
|
17
|
+
* @param socketUUID The UUID of the socket to destroy.
|
|
18
|
+
*/
|
|
8
19
|
destroySocket(socketUUID) {
|
|
9
20
|
this.jsComHub.base_interface_destroy_socket(this.uuid, socketUUID);
|
|
10
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Receives a data block for the communication interface.
|
|
24
|
+
* @param socketUUID The UUID of the socket to receive data on.
|
|
25
|
+
* @param data The data block to receive.
|
|
26
|
+
*/
|
|
11
27
|
receive(socketUUID, data) {
|
|
12
28
|
this.jsComHub.base_interface_receive(this.uuid, socketUUID, data);
|
|
13
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Tests sending a data block for the communication interface.
|
|
32
|
+
* @param socketUUID The UUID of the socket to send data on.
|
|
33
|
+
* @param data The data block to send.
|
|
34
|
+
* @returns A promise that resolves to true if the block was sent successfully, false otherwise.
|
|
35
|
+
*/
|
|
14
36
|
testSendBlock(socketUUID, data) {
|
|
15
37
|
return this.jsComHub.base_interface_test_send_block(this.uuid, socketUUID, data);
|
|
16
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Registers a callback to handle sending data blocks.
|
|
41
|
+
* @param callback The callback to be invoked when sending data.
|
|
42
|
+
*/
|
|
17
43
|
onSend(callback) {
|
|
18
44
|
this.jsComHub.base_interface_on_send(this.uuid, callback);
|
|
19
45
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import "../../_dnt.polyfills.js";
|
|
2
1
|
import { ComInterfaceImpl } from "../com-interface.js";
|
|
3
2
|
import type { WebSocketClientInterfaceSetupData } from "../../datex-core/datex_core_js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the WebSocket client communication interface.
|
|
5
|
+
*/
|
|
4
6
|
export declare class WebSocketClientInterfaceImpl extends ComInterfaceImpl<WebSocketClientInterfaceSetupData> {
|
|
5
7
|
}
|
|
6
8
|
//# sourceMappingURL=websocket-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-client.d.ts","sourceRoot":"","sources":["../../../src/network/interface-impls/websocket-client.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AAGxF,qBAAa,4BACT,SAAQ,gBAAgB,CAAC,iCAAiC,CAAC;CAC9D"}
|
|
1
|
+
{"version":3,"file":"websocket-client.d.ts","sourceRoot":"","sources":["../../../src/network/interface-impls/websocket-client.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AAGxF;;GAEG;AACH,qBAAa,4BACT,SAAQ,gBAAgB,CAAC,iCAAiC,CAAC;CAC9D"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import "../../_dnt.polyfills.js";
|
|
2
1
|
import { ComInterfaceImpl } from "../com-interface.js";
|
|
3
2
|
import { ComHub } from "../com-hub.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the WebSocket client communication interface.
|
|
5
|
+
*/
|
|
4
6
|
export class WebSocketClientInterfaceImpl extends ComInterfaceImpl {
|
|
5
7
|
}
|
|
6
8
|
ComHub.registerInterfaceImpl("websocket-client", WebSocketClientInterfaceImpl);
|
package/esm/network/mod.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module network/mod.ts
|
|
3
|
+
* @description
|
|
4
|
+
* This module re-exports all network-related functionalities, including
|
|
5
|
+
* communication hubs and interfaces.
|
|
6
|
+
*/
|
|
1
7
|
export * from "./com-hub.js";
|
|
2
8
|
export * from "./com-interface.js";
|
|
3
9
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/network/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/network/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/network/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
package/esm/network/mod.js
CHANGED
package/esm/refs/ref.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ import type { DIFHandler } from "../dif/dif-handler.js";
|
|
|
6
6
|
export declare class Ref<T> {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(value: T, pointerAddress: string, difHandler: DIFHandler);
|
|
9
|
+
/**
|
|
10
|
+
* Gets the address of the pointer storing the reference.
|
|
11
|
+
*/
|
|
9
12
|
get pointerAddress(): string;
|
|
10
13
|
/**
|
|
11
14
|
* Silently updates the value of the reference without notifying observers.
|
package/esm/refs/ref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/refs/ref.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;GAGG;AACH,qBAAa,GAAG,CAAC,CAAC;;gBAKF,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;IAMpE,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IAI/B;;OAEG;IACH,IAAI,KAAK,IAAI,CAAC,CAEb;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,EAUpB;CACJ"}
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/refs/ref.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;GAGG;AACH,qBAAa,GAAG,CAAC,CAAC;;gBAKF,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;IAMpE;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IAI/B;;OAEG;IACH,IAAI,KAAK,IAAI,CAAC,CAEb;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,EAUpB;CACJ"}
|
package/esm/refs/ref.js
CHANGED
|
@@ -24,6 +24,9 @@ export class Ref {
|
|
|
24
24
|
__classPrivateFieldSet(this, _Ref_pointerAddress, pointerAddress, "f");
|
|
25
25
|
__classPrivateFieldSet(this, _Ref_difHandler, difHandler, "f");
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets the address of the pointer storing the reference.
|
|
29
|
+
*/
|
|
27
30
|
get pointerAddress() {
|
|
28
31
|
return __classPrivateFieldGet(this, _Ref_pointerAddress, "f");
|
|
29
32
|
}
|
package/esm/runtime/runtime.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ import { ComHub } from "../network/com-hub.js";
|
|
|
3
3
|
import { DIFHandler } from "../dif/dif-handler.js";
|
|
4
4
|
import type { DIFReferenceMutability, DIFTypeContainer } from "../dif/definitions.js";
|
|
5
5
|
import type { Ref } from "../refs/ref.js";
|
|
6
|
+
/** debug flags for the runtime */
|
|
6
7
|
interface DebugFlags {
|
|
7
8
|
allow_unsigned_blocks?: boolean;
|
|
8
9
|
enable_deterministic_behavior?: boolean;
|
|
9
10
|
}
|
|
11
|
+
/** configuration for the runtime */
|
|
10
12
|
export type RuntimeConfig = {
|
|
11
13
|
endpoint?: string;
|
|
12
14
|
interfaces?: {
|
|
@@ -15,31 +17,68 @@ export type RuntimeConfig = {
|
|
|
15
17
|
}[];
|
|
16
18
|
debug?: boolean;
|
|
17
19
|
};
|
|
20
|
+
/** options for decompiling values to strings */
|
|
18
21
|
export type DecompileOptions = {
|
|
19
22
|
formatted?: boolean;
|
|
20
23
|
colorized?: boolean;
|
|
21
24
|
resolve_slots?: boolean;
|
|
22
25
|
json_compat?: boolean;
|
|
23
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* The main Runtime class for executing Datex scripts and managing communication interfaces.
|
|
29
|
+
*/
|
|
24
30
|
export declare class Runtime {
|
|
25
31
|
#private;
|
|
26
32
|
readonly js_version: string;
|
|
27
33
|
constructor(config: RuntimeConfig, debug_flags?: DebugFlags);
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new Runtime instance.
|
|
36
|
+
* @param config Runtime configuration
|
|
37
|
+
* @param debug_flags Debug flags for the runtime
|
|
38
|
+
* @returns A promise that resolves to the created Runtime instance
|
|
39
|
+
*/
|
|
28
40
|
static create(config: RuntimeConfig, debug_flags?: DebugFlags): Promise<Runtime>;
|
|
41
|
+
/**
|
|
42
|
+
* Starts the runtime.
|
|
43
|
+
* @returns A promise that resolves when the runtime has started.
|
|
44
|
+
*/
|
|
29
45
|
start(): Promise<void>;
|
|
30
46
|
_stop(): Promise<void>;
|
|
31
47
|
/**
|
|
32
|
-
*
|
|
48
|
+
* Gets the endpoint of the runtime.
|
|
33
49
|
*/
|
|
34
50
|
get endpoint(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the version of the runtime.
|
|
53
|
+
*/
|
|
35
54
|
get version(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the DIF handler associated with the runtime.
|
|
57
|
+
*/
|
|
36
58
|
get dif(): DIFHandler;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the communication hub associated with the runtime.
|
|
61
|
+
*/
|
|
37
62
|
get comHub(): ComHub;
|
|
38
63
|
/**
|
|
39
64
|
* @internal only used for debugging
|
|
40
65
|
*/
|
|
41
66
|
get _runtime(): JSRuntime;
|
|
67
|
+
/**
|
|
68
|
+
* Executes a Datex script and returns the result as a string.
|
|
69
|
+
* @param datexScript The Datex script to execute.
|
|
70
|
+
* @param values The values to inject into the script.
|
|
71
|
+
* @param decompileOptions Options for decompiling the result.
|
|
72
|
+
* @returns A promise that resolves to the result of the script execution.
|
|
73
|
+
*/
|
|
42
74
|
executeWithStringResult(datexScript: string, values?: unknown[] | null, decompileOptions?: DecompileOptions | null): Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Executes a Datex script synchronously and returns the result as a string.
|
|
77
|
+
* @param datexScript The Datex script to execute.
|
|
78
|
+
* @param values The values to inject into the script.
|
|
79
|
+
* @param decompileOptions Options for decompiling the result.
|
|
80
|
+
* @returns The result of the script execution.
|
|
81
|
+
*/
|
|
43
82
|
executeSyncWithStringResult(datexScript: string, values?: unknown[] | null, decompileOptions?: DecompileOptions | null): string;
|
|
44
83
|
/**
|
|
45
84
|
* Asynchronously executes a Datex script and returns the result as a Promise.
|
|
@@ -83,12 +122,22 @@ export declare class Runtime {
|
|
|
83
122
|
* ```
|
|
84
123
|
*/
|
|
85
124
|
executeSync<T = unknown>(templateStrings: TemplateStringsArray, ...values: unknown[]): T;
|
|
125
|
+
/**
|
|
126
|
+
* Converts a JavaScript value to a string representation.
|
|
127
|
+
* @param value The value to convert.
|
|
128
|
+
* @param decompileOptions Options for decompiling the result.
|
|
129
|
+
* @returns The string representation of the value.
|
|
130
|
+
*/
|
|
86
131
|
valueToString(value: unknown, decompileOptions?: DecompileOptions | null): string;
|
|
87
132
|
_execute_internal(datexScript: string): boolean;
|
|
88
133
|
/**
|
|
89
134
|
* Creates a new pointer containg the given JS value.
|
|
90
135
|
* The returned value is a proxy object that behaves like the original object,
|
|
91
136
|
* but also propagates changes between JS and the DATEX runtime.
|
|
137
|
+
* @param value The JS value to store in the pointer.
|
|
138
|
+
* @param allowedType Optional DIF type container to restrict the type of the pointer.
|
|
139
|
+
* @param mutability Optional mutability of the reference (default is Mutable).
|
|
140
|
+
* @returns A proxy object representing the pointer in JS.
|
|
92
141
|
*/
|
|
93
142
|
createPointer<V, M extends DIFReferenceMutability = typeof DIFReferenceMutability.Mutable>(value: V & {}, allowedType?: DIFTypeContainer | null, mutability?: M): PointerOut<V, M>;
|
|
94
143
|
}
|
|
@@ -97,10 +146,11 @@ type IsRef<T> = T extends Ref<unknown> ? true : false;
|
|
|
97
146
|
type ContainsRef<T> = IsRef<T> extends true ? true : T extends object ? {
|
|
98
147
|
[K in keyof T]: ContainsRef<T[K]>;
|
|
99
148
|
}[keyof T] extends true ? true : false : false;
|
|
149
|
+
/** A type representing an assignable reference or a plain value **/
|
|
100
150
|
export type AssignableRef<T> = Ref<T> | T & {
|
|
101
151
|
value?: T;
|
|
102
152
|
};
|
|
103
|
-
type Builtins =
|
|
153
|
+
type Builtins = ((...args: unknown[]) => unknown) | Date | RegExp | Map<unknown, unknown> | Set<unknown> | WeakMap<WeakKey, unknown> | WeakSet<WeakKey> | Array<unknown>;
|
|
104
154
|
type IsPlainObject<T> = T extends Builtins ? false : T extends object ? true : false;
|
|
105
155
|
type ObjectFieldOut<T, M extends DIFReferenceMutability> = T extends Ref<infer U> ? M extends typeof DIFReferenceMutability.Immutable ? Ref<U> : AssignableRef<U> : IsPlainObject<T> extends true ? (ContainsRef<T> extends true ? M extends typeof DIFReferenceMutability.Immutable ? {
|
|
106
156
|
readonly [K in keyof T]: ObjectFieldOut<T[K], M>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,SAAS,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EACR,sBAAsB,EACtB,gBAAgB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAK1C,UAAU,UAAU;IAChB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,6BAA6B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,M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C,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAAG;AAC5E,UAAU,MAAM,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG;AACnE,UAAU,QAAQ,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC;CAAG;AAE/D,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1D,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAClC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GACtC,GAAG,CAAC,CAAC,CAAC,CAAC"}
|
package/esm/runtime/runtime.js
CHANGED
|
@@ -13,8 +13,11 @@ var _Runtime_instances, _Runtime_runtime, _Runtime_comHub, _Runtime_difHandler,
|
|
|
13
13
|
import { create_runtime, execute_internal, } from "../datex-core.js";
|
|
14
14
|
import { ComHub } from "../network/com-hub.js";
|
|
15
15
|
import { DIFHandler } from "../dif/dif-handler.js";
|
|
16
|
-
|
|
17
|
-
const VERSION = "0.0.
|
|
16
|
+
/** auto-generated version - do not edit: */
|
|
17
|
+
const VERSION = "0.0.10";
|
|
18
|
+
/**
|
|
19
|
+
* The main Runtime class for executing Datex scripts and managing communication interfaces.
|
|
20
|
+
*/
|
|
18
21
|
export class Runtime {
|
|
19
22
|
constructor(config, debug_flags) {
|
|
20
23
|
_Runtime_instances.add(this);
|
|
@@ -31,11 +34,21 @@ export class Runtime {
|
|
|
31
34
|
__classPrivateFieldSet(this, _Runtime_comHub, new ComHub(__classPrivateFieldGet(this, _Runtime_runtime, "f").com_hub), "f");
|
|
32
35
|
__classPrivateFieldSet(this, _Runtime_difHandler, new DIFHandler(__classPrivateFieldGet(this, _Runtime_runtime, "f")), "f");
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new Runtime instance.
|
|
39
|
+
* @param config Runtime configuration
|
|
40
|
+
* @param debug_flags Debug flags for the runtime
|
|
41
|
+
* @returns A promise that resolves to the created Runtime instance
|
|
42
|
+
*/
|
|
34
43
|
static async create(config, debug_flags) {
|
|
35
44
|
const runtime = new Runtime(config, debug_flags);
|
|
36
45
|
await runtime.start();
|
|
37
46
|
return runtime;
|
|
38
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Starts the runtime.
|
|
50
|
+
* @returns A promise that resolves when the runtime has started.
|
|
51
|
+
*/
|
|
39
52
|
start() {
|
|
40
53
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f").start();
|
|
41
54
|
}
|
|
@@ -43,17 +56,26 @@ export class Runtime {
|
|
|
43
56
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f")._stop();
|
|
44
57
|
}
|
|
45
58
|
/**
|
|
46
|
-
*
|
|
59
|
+
* Gets the endpoint of the runtime.
|
|
47
60
|
*/
|
|
48
61
|
get endpoint() {
|
|
49
62
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f").endpoint;
|
|
50
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets the version of the runtime.
|
|
66
|
+
*/
|
|
51
67
|
get version() {
|
|
52
68
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f").version;
|
|
53
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the DIF handler associated with the runtime.
|
|
72
|
+
*/
|
|
54
73
|
get dif() {
|
|
55
74
|
return __classPrivateFieldGet(this, _Runtime_difHandler, "f");
|
|
56
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the communication hub associated with the runtime.
|
|
78
|
+
*/
|
|
57
79
|
get comHub() {
|
|
58
80
|
return __classPrivateFieldGet(this, _Runtime_comHub, "f");
|
|
59
81
|
}
|
|
@@ -63,9 +85,23 @@ export class Runtime {
|
|
|
63
85
|
get _runtime() {
|
|
64
86
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f");
|
|
65
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Executes a Datex script and returns the result as a string.
|
|
90
|
+
* @param datexScript The Datex script to execute.
|
|
91
|
+
* @param values The values to inject into the script.
|
|
92
|
+
* @param decompileOptions Options for decompiling the result.
|
|
93
|
+
* @returns A promise that resolves to the result of the script execution.
|
|
94
|
+
*/
|
|
66
95
|
executeWithStringResult(datexScript, values = [], decompileOptions = null) {
|
|
67
96
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f").execute_with_string_result(datexScript, __classPrivateFieldGet(this, _Runtime_difHandler, "f").convertToDIFValues(values), decompileOptions);
|
|
68
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Executes a Datex script synchronously and returns the result as a string.
|
|
100
|
+
* @param datexScript The Datex script to execute.
|
|
101
|
+
* @param values The values to inject into the script.
|
|
102
|
+
* @param decompileOptions Options for decompiling the result.
|
|
103
|
+
* @returns The result of the script execution.
|
|
104
|
+
*/
|
|
69
105
|
executeSyncWithStringResult(datexScript, values = [], decompileOptions = null) {
|
|
70
106
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f").execute_sync_with_string_result(datexScript, __classPrivateFieldGet(this, _Runtime_difHandler, "f").convertToDIFValues(values), decompileOptions);
|
|
71
107
|
}
|
|
@@ -78,6 +114,12 @@ export class Runtime {
|
|
|
78
114
|
const { datexScript, valuesArray } = __classPrivateFieldGet(this, _Runtime_instances, "m", _Runtime_getScriptAndValues).call(this, datexScriptOrTemplateStrings, ...values);
|
|
79
115
|
return __classPrivateFieldGet(this, _Runtime_instances, "m", _Runtime_executeSyncInternal).call(this, datexScript, valuesArray);
|
|
80
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Converts a JavaScript value to a string representation.
|
|
119
|
+
* @param value The value to convert.
|
|
120
|
+
* @param decompileOptions Options for decompiling the result.
|
|
121
|
+
* @returns The string representation of the value.
|
|
122
|
+
*/
|
|
81
123
|
valueToString(value, decompileOptions = null) {
|
|
82
124
|
return __classPrivateFieldGet(this, _Runtime_runtime, "f").value_to_string(__classPrivateFieldGet(this, _Runtime_difHandler, "f").convertJSValueToDIFValue(value), decompileOptions);
|
|
83
125
|
}
|
|
@@ -88,6 +130,10 @@ export class Runtime {
|
|
|
88
130
|
* Creates a new pointer containg the given JS value.
|
|
89
131
|
* The returned value is a proxy object that behaves like the original object,
|
|
90
132
|
* but also propagates changes between JS and the DATEX runtime.
|
|
133
|
+
* @param value The JS value to store in the pointer.
|
|
134
|
+
* @param allowedType Optional DIF type container to restrict the type of the pointer.
|
|
135
|
+
* @param mutability Optional mutability of the reference (default is Mutable).
|
|
136
|
+
* @returns A proxy object representing the pointer in JS.
|
|
91
137
|
*/
|
|
92
138
|
createPointer(
|
|
93
139
|
// deno-lint-ignore ban-types
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Endpoint class representing a unique communication endpoint in the Datex runtime.
|
|
3
|
+
*/
|
|
2
4
|
export declare class Endpoint {
|
|
3
5
|
#private;
|
|
4
|
-
|
|
6
|
+
/** map with weak values that keeps track of all currently instantiated endpoints */
|
|
7
|
+
static endpoints: Map<string, WeakRef<Endpoint>>;
|
|
5
8
|
private constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Registers a new endpoint in the static map.
|
|
11
|
+
* @param endpoint The endpoint to register.
|
|
12
|
+
*/
|
|
6
13
|
static registerEndpoint(endpoint: Endpoint): void;
|
|
14
|
+
/**
|
|
15
|
+
* Gets an existing endpoint from the static map or creates a new one.
|
|
16
|
+
* @param endpoint The string representation of the endpoint.
|
|
17
|
+
* @returns The existing or newly created Endpoint instance.
|
|
18
|
+
*/
|
|
7
19
|
static get(endpoint: string): Endpoint;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the string representation of the endpoint.
|
|
22
|
+
* @returns The string representation of the endpoint.
|
|
23
|
+
*/
|
|
8
24
|
toString(): string;
|
|
9
25
|
}
|
|
10
26
|
//# sourceMappingURL=special-core-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"special-core-types.d.ts","sourceRoot":"","sources":["../../src/runtime/special-core-types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"special-core-types.d.ts","sourceRoot":"","sources":["../../src/runtime/special-core-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAQ;;IAIjB,oFAAoF;IACpF,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAa;IAE7D,OAAO;IAKP;;;OAGG;WACW,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;IASjD;;;;OAIG;WACW,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ;IAa7C;;;OAGG;IACI,QAAQ,IAAI,MAAM;CAG5B"}
|
|
@@ -10,21 +10,33 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _Endpoint_endpoint;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Endpoint class representing a unique communication endpoint in the Datex runtime.
|
|
15
|
+
*/
|
|
14
16
|
export class Endpoint {
|
|
15
17
|
constructor(endpoint) {
|
|
18
|
+
/** the string representation of the endpoint */
|
|
16
19
|
_Endpoint_endpoint.set(this, void 0);
|
|
17
20
|
__classPrivateFieldSet(this, _Endpoint_endpoint, endpoint, "f");
|
|
18
21
|
Endpoint.registerEndpoint(this);
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Registers a new endpoint in the static map.
|
|
25
|
+
* @param endpoint The endpoint to register.
|
|
26
|
+
*/
|
|
20
27
|
static registerEndpoint(endpoint) {
|
|
21
28
|
// set as a weak reference in the static map
|
|
22
|
-
const weakRef = new
|
|
29
|
+
const weakRef = new WeakRef(endpoint);
|
|
23
30
|
Endpoint.endpoints.set(endpoint.toString(), weakRef);
|
|
24
31
|
new FinalizationRegistry((key) => {
|
|
25
32
|
Endpoint.endpoints.delete(key);
|
|
26
33
|
}).register(endpoint, endpoint.toString());
|
|
27
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets an existing endpoint from the static map or creates a new one.
|
|
37
|
+
* @param endpoint The string representation of the endpoint.
|
|
38
|
+
* @returns The existing or newly created Endpoint instance.
|
|
39
|
+
*/
|
|
28
40
|
static get(endpoint) {
|
|
29
41
|
if (Endpoint.endpoints.has(endpoint)) {
|
|
30
42
|
const weakRef = Endpoint.endpoints.get(endpoint);
|
|
@@ -37,12 +49,16 @@ export class Endpoint {
|
|
|
37
49
|
}
|
|
38
50
|
return new Endpoint(endpoint);
|
|
39
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the string representation of the endpoint.
|
|
54
|
+
* @returns The string representation of the endpoint.
|
|
55
|
+
*/
|
|
40
56
|
toString() {
|
|
41
57
|
return __classPrivateFieldGet(this, _Endpoint_endpoint, "f");
|
|
42
58
|
}
|
|
43
59
|
}
|
|
44
60
|
_Endpoint_endpoint = new WeakMap();
|
|
45
|
-
|
|
61
|
+
/** map with weak values that keeps track of all currently instantiated endpoints */
|
|
46
62
|
Object.defineProperty(Endpoint, "endpoints", {
|
|
47
63
|
enumerable: true,
|
|
48
64
|
configurable: true,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Type representing the supported JavaScript runtime types */
|
|
2
|
+
export type JSRuntimeType = "deno" | "browser" | "node" | "bun";
|
|
3
|
+
/** Interface for JavaScript runtime functionalities */
|
|
4
|
+
export interface JsRuntimeInterface {
|
|
5
|
+
type: JSRuntimeType;
|
|
6
|
+
readTextFile(path: string | URL): Promise<string>;
|
|
7
|
+
readFile(path: string | URL): Promise<Uint8Array>;
|
|
8
|
+
instantiateWebAssembly(path: URL, importObject?: WebAssembly.Imports): Promise<WebAssembly.WebAssemblyInstantiatedSource>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=js-runtime-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-runtime-interface.d.ts","sourceRoot":"","sources":["../../../src/utils/js-runtime-compat/js-runtime-interface.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;AAEhE,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAClD,sBAAsB,CAClB,IAAI,EAAE,GAAG,EACT,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,GACnC,OAAO,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAC;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @description
|
|
4
|
+
* The runtime module provides a runtimeInterface object that contains common
|
|
5
|
+
* runtime-specific functions for reading files, etc.
|
|
6
|
+
* It automatically detects the runtime environment and provides the correct
|
|
7
|
+
* runtime interface.
|
|
8
|
+
* Supported runtimes are:
|
|
9
|
+
* - Deno
|
|
10
|
+
* - Node.js
|
|
11
|
+
* - Bun
|
|
12
|
+
* - Browser
|
|
13
|
+
*/
|
|
14
|
+
import type { JsRuntimeInterface, JSRuntimeType } from "./js-runtime-interface.js";
|
|
15
|
+
export declare function detectRuntime(): JSRuntimeType;
|
|
16
|
+
/** The runtime interface for the current runtime environment */
|
|
17
|
+
export declare const runtimeInterface: JsRuntimeInterface;
|
|
18
|
+
//# sourceMappingURL=js-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-runtime.d.ts","sourceRoot":"","sources":["../../../src/utils/js-runtime-compat/js-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACR,kBAAkB,EAClB,aAAa,EAChB,MAAM,2BAA2B,CAAC;AAInC,wBAAgB,aAAa,IAAI,aAAa,CAU7C;AAkBD,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,EAAE,kBAE9B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @description
|
|
4
|
+
* The runtime module provides a runtimeInterface object that contains common
|
|
5
|
+
* runtime-specific functions for reading files, etc.
|
|
6
|
+
* It automatically detects the runtime environment and provides the correct
|
|
7
|
+
* runtime interface.
|
|
8
|
+
* Supported runtimes are:
|
|
9
|
+
* - Deno
|
|
10
|
+
* - Node.js
|
|
11
|
+
* - Bun
|
|
12
|
+
* - Browser
|
|
13
|
+
*/
|
|
14
|
+
import BrowserRuntimeInterface from "./runtimes/browser.js";
|
|
15
|
+
export function detectRuntime() {
|
|
16
|
+
if (globalThis.navigator?.userAgent.startsWith("Node.js")) {
|
|
17
|
+
return "node";
|
|
18
|
+
}
|
|
19
|
+
else if (globalThis.navigator?.userAgent.startsWith("Deno")) {
|
|
20
|
+
return "deno";
|
|
21
|
+
}
|
|
22
|
+
else if (globalThis.navigator?.userAgent.startsWith("Bun")) {
|
|
23
|
+
return "bun";
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return "browser";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function getRuntimeInterface(type) {
|
|
30
|
+
if (type == "deno") {
|
|
31
|
+
const { default: Interface } = (await import("./runtimes/deno.js"));
|
|
32
|
+
return new Interface();
|
|
33
|
+
}
|
|
34
|
+
else if (type == "node" || type == "bun") {
|
|
35
|
+
const { default: Interface } = (await import("./runtimes/node.js"));
|
|
36
|
+
return new Interface();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return new BrowserRuntimeInterface();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** The runtime interface for the current runtime environment */
|
|
43
|
+
export const runtimeInterface = await getRuntimeInterface(detectRuntime());
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JsRuntimeInterface } from "../js-runtime-interface.js";
|
|
2
|
+
export default class BrowserRuntimeInterface implements JsRuntimeInterface {
|
|
3
|
+
readonly type = "browser";
|
|
4
|
+
readTextFile(path: string | URL): Promise<string>;
|
|
5
|
+
readFile(path: string | URL): Promise<Uint8Array>;
|
|
6
|
+
instantiateWebAssembly(path: URL, importObject?: WebAssembly.Imports): Promise<WebAssembly.WebAssemblyInstantiatedSource>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../src/utils/js-runtime-compat/runtimes/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,CAAC,OAAO,OAAO,uBAAwB,YAAW,kBAAkB;IACtE,QAAQ,CAAC,IAAI,aAAa;IAEpB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAKjD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAMvD,sBAAsB,CAClB,IAAI,EAAE,GAAG,EACT,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,GACnC,OAAO,CAAC,WAAW,CAAC,6BAA6B,CAAC;CAGxD"}
|