@unyt/datex 0.0.10 → 0.0.12
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/README.md +10 -14
- package/esm/datex-web/datex_web.d.ts +2 -0
- package/esm/datex-web/datex_web.d.ts.map +1 -0
- package/esm/datex-web/datex_web.internal.d.ts +383 -0
- package/esm/datex-web/datex_web.internal.d.ts.map +1 -0
- package/esm/{datex-core/datex_core_js.internal.js → datex-web/datex_web.internal.js} +794 -1141
- package/esm/datex-web/datex_web.js +18 -0
- package/esm/datex-web/datex_web.wasm +0 -0
- package/esm/datex-web/wasm_url.node.js +1 -0
- package/esm/{datex-core.d.ts → datex.d.ts} +3 -3
- package/esm/datex.d.ts.map +1 -0
- package/esm/{datex-core.js → datex.js} +3 -3
- package/esm/default.d.ts.map +1 -1
- package/esm/default.js +2 -3
- package/esm/deno.json +28 -20
- package/esm/dif/core.d.ts +5 -3
- package/esm/dif/core.d.ts.map +1 -1
- package/esm/dif/core.js +7 -5
- package/esm/dif/definitions.d.ts +45 -34
- package/esm/dif/definitions.d.ts.map +1 -1
- package/esm/dif/definitions.js +14 -9
- package/esm/dif/dif-handler.d.ts +135 -35
- package/esm/dif/dif-handler.d.ts.map +1 -1
- package/esm/dif/dif-handler.js +378 -159
- package/esm/dif/display.d.ts +3 -3
- package/esm/dif/display.d.ts.map +1 -1
- package/esm/dif/display.js +5 -7
- package/esm/dif/js-lib.d.ts +8 -0
- package/esm/dif/js-lib.d.ts.map +1 -0
- package/esm/dif/js-lib.js +3 -0
- package/esm/dif/mod.d.ts +0 -1
- package/esm/dif/mod.d.ts.map +1 -1
- package/esm/dif/mod.js +0 -1
- package/esm/dif/type-registry.d.ts +80 -0
- package/esm/dif/type-registry.d.ts.map +1 -0
- package/esm/dif/type-registry.js +166 -0
- package/esm/global.d.ts +2 -0
- package/esm/global.d.ts.map +1 -0
- package/esm/global.js +1 -0
- package/esm/{runtime/special-core-types.d.ts → lib/special-core-types/endpoint.d.ts} +3 -1
- package/esm/lib/special-core-types/endpoint.d.ts.map +1 -0
- package/esm/{runtime/special-core-types.js → lib/special-core-types/endpoint.js} +6 -1
- package/esm/mod.d.ts +3 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +3 -1
- package/esm/network/com-hub.d.ts +20 -22
- package/esm/network/com-hub.d.ts.map +1 -1
- package/esm/network/com-hub.js +30 -49
- package/esm/network/interfaces/websocket-server-base.d.ts +8 -0
- package/esm/network/interfaces/websocket-server-base.d.ts.map +1 -0
- package/esm/network/interfaces/websocket-server-base.js +93 -0
- package/esm/network/interfaces/websocket-server-deno.d.ts +4 -0
- package/esm/network/interfaces/websocket-server-deno.d.ts.map +1 -0
- package/esm/network/interfaces/websocket-server-deno.js +22 -0
- package/esm/network/mod.d.ts +0 -1
- package/esm/network/mod.d.ts.map +1 -1
- package/esm/network/mod.js +0 -1
- package/esm/refs/ref.d.ts.map +1 -1
- package/esm/refs/ref.js +1 -2
- package/esm/runtime/runtime.d.ts +25 -62
- package/esm/runtime/runtime.d.ts.map +1 -1
- package/esm/runtime/runtime.js +42 -26
- package/esm/utils/devtools-formatter.d.ts +2 -0
- package/esm/utils/devtools-formatter.d.ts.map +1 -0
- package/esm/utils/devtools-formatter.js +40 -0
- package/esm/utils/exceptions.d.ts +4 -0
- package/esm/utils/exceptions.d.ts.map +1 -0
- package/esm/utils/exceptions.js +9 -0
- package/esm/utils/js-runtime-compat/js-runtime.d.ts.map +1 -1
- package/package.json +7 -7
- package/esm/datex-core/datex_core_js.d.ts +0 -2
- package/esm/datex-core/datex_core_js.d.ts.map +0 -1
- package/esm/datex-core/datex_core_js.internal.d.ts +0 -512
- package/esm/datex-core/datex_core_js.internal.d.ts.map +0 -1
- package/esm/datex-core/datex_core_js.js +0 -21
- package/esm/datex-core/datex_core_js.wasm +0 -0
- package/esm/datex-core/wasm_url.node.js +0 -1
- package/esm/datex-core.d.ts.map +0 -1
- package/esm/dif/builders.d.ts +0 -16
- package/esm/dif/builders.d.ts.map +0 -1
- package/esm/dif/builders.js +0 -28
- package/esm/network/com-interface.d.ts +0 -35
- package/esm/network/com-interface.d.ts.map +0 -1
- package/esm/network/com-interface.js +0 -75
- package/esm/network/interface-impls/base.d.ts +0 -46
- package/esm/network/interface-impls/base.d.ts.map +0 -1
- package/esm/network/interface-impls/base.js +0 -47
- package/esm/network/interface-impls/websocket-client.d.ts +0 -8
- package/esm/network/interface-impls/websocket-client.d.ts.map +0 -1
- package/esm/network/interface-impls/websocket-client.js +0 -8
- package/esm/runtime/special-core-types.d.ts.map +0 -1
package/esm/network/com-hub.js
CHANGED
|
@@ -9,67 +9,58 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
import { ComInterface } from "./com-interface.js";
|
|
12
|
+
var _ComHub_jsComHub, _ComHub_runtime;
|
|
14
13
|
/**
|
|
15
14
|
* Communication hub for managing communication interfaces.
|
|
16
15
|
*/
|
|
17
16
|
export class ComHub {
|
|
18
|
-
constructor(jsComHub) {
|
|
17
|
+
constructor(jsComHub, runtime) {
|
|
19
18
|
/** The JS communication hub. */
|
|
20
19
|
_ComHub_jsComHub.set(this, void 0);
|
|
20
|
+
_ComHub_runtime.set(this, void 0);
|
|
21
21
|
__classPrivateFieldSet(this, _ComHub_jsComHub, jsComHub, "f");
|
|
22
|
+
__classPrivateFieldSet(this, _ComHub_runtime, runtime, "f");
|
|
23
|
+
}
|
|
24
|
+
registerInterfaceFactory(factoryDefinition) {
|
|
25
|
+
__classPrivateFieldGet(this, _ComHub_jsComHub, "f").register_interface_factory(factoryDefinition.interfaceType, async (setupData) => {
|
|
26
|
+
const setupDataJS = await __classPrivateFieldGet(this, _ComHub_runtime, "f").dif.resolveDIFValueContainer(setupData);
|
|
27
|
+
return factoryDefinition.factory(setupDataJS);
|
|
28
|
+
});
|
|
22
29
|
}
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
31
|
+
* Creates a new communication interface.
|
|
32
|
+
* @param type The type of the interface to create.
|
|
33
|
+
* @param setupData The setup data for the interface.
|
|
34
|
+
* @param priority The priority of the interface (optional).
|
|
35
|
+
* @returns A promise that resolves to the UUID of the created interface.
|
|
27
36
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw new Error(`Interface implementation for ${interfaceType} already registered.`);
|
|
31
|
-
}
|
|
32
|
-
__classPrivateFieldGet(this, _a, "f", _ComHub_interfaceImpls).set(interfaceType, impl);
|
|
33
|
-
__classPrivateFieldGet(this, _a, "f", _ComHub_interfaceImplsByClass).set(impl, interfaceType);
|
|
34
|
-
}
|
|
35
|
-
async createInterface(interfaceType, setupData) {
|
|
36
|
-
const type = typeof interfaceType === "string"
|
|
37
|
-
? interfaceType
|
|
38
|
-
: __classPrivateFieldGet(_a, _a, "f", _ComHub_interfaceImplsByClass).get(interfaceType);
|
|
39
|
-
if (type === undefined) {
|
|
40
|
-
throw new Error(`Interface implementation for ${interfaceType.name} not registered.`);
|
|
41
|
-
}
|
|
42
|
-
const implClass = __classPrivateFieldGet(_a, _a, "f", _ComHub_interfaceImpls).get(type);
|
|
43
|
-
if (implClass === undefined) {
|
|
44
|
-
throw new Error(`Interface implementation for ${type} not registered.`);
|
|
45
|
-
}
|
|
46
|
-
const uuid = await __classPrivateFieldGet(this, _ComHub_jsComHub, "f").create_interface(type, JSON.stringify(setupData));
|
|
47
|
-
const impl = new implClass(uuid, setupData, __classPrivateFieldGet(this, _ComHub_jsComHub, "f"));
|
|
48
|
-
await impl.init?.();
|
|
49
|
-
return new ComInterface(uuid, impl, __classPrivateFieldGet(this, _ComHub_jsComHub, "f"));
|
|
37
|
+
async createInterface(type, setupData, priority) {
|
|
38
|
+
return await __classPrivateFieldGet(this, _ComHub_jsComHub, "f").create_interface(type, __classPrivateFieldGet(this, _ComHub_runtime, "f").dif.convertJSValueToDIFValueContainer(setupData), priority);
|
|
50
39
|
}
|
|
51
|
-
|
|
52
|
-
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").
|
|
40
|
+
removeInterface(interface_uuid) {
|
|
41
|
+
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").remove_interface(interface_uuid);
|
|
53
42
|
}
|
|
54
|
-
|
|
55
|
-
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").
|
|
43
|
+
removeSocket(socket_uuid) {
|
|
44
|
+
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").remove_socket(socket_uuid);
|
|
56
45
|
}
|
|
57
46
|
/**
|
|
58
47
|
* Prints the metadata of the ComHub. Only available in debug builds.
|
|
48
|
+
* Only exists in debug builds
|
|
59
49
|
*/
|
|
60
50
|
printMetadata() {
|
|
61
|
-
// as any required because get_metadata_string only exists in debug builds
|
|
62
|
-
// deno-lint-ignore no-explicit-any
|
|
63
51
|
const metadata = __classPrivateFieldGet(this, _ComHub_jsComHub, "f").get_metadata_string();
|
|
64
52
|
console.log(metadata);
|
|
65
53
|
}
|
|
54
|
+
getMetadata() {
|
|
55
|
+
// as any required because get_metadata only exists in debug builds
|
|
56
|
+
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").get_metadata();
|
|
57
|
+
}
|
|
66
58
|
/**
|
|
67
59
|
* Prints the trace for a specific endpoint. Only available in debug builds.
|
|
68
60
|
* @param endpoint The endpoint for which to print the trace.
|
|
69
61
|
*/
|
|
70
62
|
async printTrace(endpoint) {
|
|
71
63
|
// as any required because get_trace_string only exists in debug builds
|
|
72
|
-
// deno-lint-ignore no-explicit-any
|
|
73
64
|
const trace = await __classPrivateFieldGet(this, _ComHub_jsComHub, "f").get_trace_string(endpoint);
|
|
74
65
|
if (trace === undefined) {
|
|
75
66
|
console.warn(`No trace available for endpoint: ${endpoint}`);
|
|
@@ -77,15 +68,9 @@ export class ComHub {
|
|
|
77
68
|
}
|
|
78
69
|
console.log(trace);
|
|
79
70
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* @param interface_uuid The UUID of the interface to send the block to.
|
|
84
|
-
* @param socket_uuid The UUID of the socket to send the block to.
|
|
85
|
-
* @returns A promise that resolves to true if the block was sent successfully, false otherwise.
|
|
86
|
-
*/
|
|
87
|
-
sendBlock(block, interface_uuid, socket_uuid) {
|
|
88
|
-
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").send_block(block, interface_uuid, socket_uuid);
|
|
71
|
+
getTrace(endpoint) {
|
|
72
|
+
// as any required because get_trace_string only exists in debug builds
|
|
73
|
+
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").get_trace(endpoint);
|
|
89
74
|
}
|
|
90
75
|
/**
|
|
91
76
|
* Registers a callback to intercept incoming blocks.
|
|
@@ -102,8 +87,4 @@ export class ComHub {
|
|
|
102
87
|
__classPrivateFieldGet(this, _ComHub_jsComHub, "f").register_outgoing_block_interceptor(callback);
|
|
103
88
|
}
|
|
104
89
|
}
|
|
105
|
-
|
|
106
|
-
/** Static map of registered interface implementations. */
|
|
107
|
-
_ComHub_interfaceImpls = { value: new Map() };
|
|
108
|
-
/** Static map of interface implementations by class. */
|
|
109
|
-
_ComHub_interfaceImplsByClass = { value: new Map() };
|
|
90
|
+
_ComHub_jsComHub = new WeakMap(), _ComHub_runtime = new WeakMap();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComInterfaceFactory } from "../com-hub.js";
|
|
2
|
+
import type { WebSocketServerInterfaceSetupData } from "../../datex.js";
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to create a WebSocket server communication interface factory from a given server factory function.
|
|
5
|
+
* @param serverFactory
|
|
6
|
+
*/
|
|
7
|
+
export declare function createWebsocketServerComInterfaceFactory(serverFactory: (setupData: WebSocketServerInterfaceSetupData) => ReadableStream<WebSocket>): ComInterfaceFactory<WebSocketServerInterfaceSetupData>;
|
|
8
|
+
//# sourceMappingURL=websocket-server-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-server-base.d.ts","sourceRoot":"","sources":["../../../src/network/interfaces/websocket-server-base.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAuB,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,wCAAwC,CACpD,aAAa,EAAE,CAAC,SAAS,EAAE,iCAAiC,KAAK,cAAc,CAAC,SAAS,CAAC,GAC3F,mBAAmB,CAAC,iCAAiC,CAAC,CAiDxD"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to create a WebSocket server communication interface factory from a given server factory function.
|
|
3
|
+
* @param serverFactory
|
|
4
|
+
*/
|
|
5
|
+
export function createWebsocketServerComInterfaceFactory(serverFactory) {
|
|
6
|
+
return {
|
|
7
|
+
interfaceType: "websocket-server",
|
|
8
|
+
factory: (setupData) => {
|
|
9
|
+
// FIXME: workaround, convert map to object if map provided as setupData
|
|
10
|
+
if (setupData instanceof Map) {
|
|
11
|
+
setupData = Object.fromEntries(Array.from(setupData.entries()));
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
properties: {
|
|
15
|
+
interface_type: "websocket-server",
|
|
16
|
+
channel: "websocket",
|
|
17
|
+
name: setupData.bind_address,
|
|
18
|
+
direction: "InOut",
|
|
19
|
+
round_trip_time: 0,
|
|
20
|
+
max_bandwidth: 0,
|
|
21
|
+
continuous_connection: false,
|
|
22
|
+
allow_redirects: false,
|
|
23
|
+
is_secure_channel: false,
|
|
24
|
+
reconnection_config: "NoReconnect",
|
|
25
|
+
auto_identify: true,
|
|
26
|
+
connectable_interfaces: [], // TODO add websocket client connections
|
|
27
|
+
},
|
|
28
|
+
has_single_socket: false,
|
|
29
|
+
new_sockets_iterator: serverFactory(setupData).pipeThrough(new TransformStream({
|
|
30
|
+
async transform(socket, controller) {
|
|
31
|
+
const incoming_data_stream = await createSocketDataIterator(socket);
|
|
32
|
+
controller.enqueue({
|
|
33
|
+
properties: {
|
|
34
|
+
direction: "InOut",
|
|
35
|
+
channel_factor: 1,
|
|
36
|
+
connection_timestamp: Date.now(),
|
|
37
|
+
direct_endpoint: undefined,
|
|
38
|
+
},
|
|
39
|
+
iterator: incoming_data_stream,
|
|
40
|
+
send_callback: (data) => {
|
|
41
|
+
socket.send(data);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Utility function that returns an async generator yielding ArrayBuffers from a WebSocket
|
|
52
|
+
*/
|
|
53
|
+
async function createSocketDataIterator(webSocket) {
|
|
54
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
55
|
+
webSocket.addEventListener("open", () => resolve(), { once: true });
|
|
56
|
+
webSocket.addEventListener("error", (event) => reject(new Error(`WebSocket error: ${event}`)), { once: true });
|
|
57
|
+
// wait until the socket is open before starting to yield messages
|
|
58
|
+
if (webSocket.readyState === WebSocket.OPEN) {
|
|
59
|
+
resolve();
|
|
60
|
+
}
|
|
61
|
+
else if (webSocket.readyState === WebSocket.CLOSED || webSocket.readyState === WebSocket.CLOSING) {
|
|
62
|
+
reject(new Error("WebSocket is already closed"));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// otherwise, wait for the open event
|
|
66
|
+
console.log("Waiting for WebSocket to open...");
|
|
67
|
+
}
|
|
68
|
+
await promise;
|
|
69
|
+
let closed = false;
|
|
70
|
+
return new ReadableStream({
|
|
71
|
+
start(controller) {
|
|
72
|
+
webSocket.onmessage = (event) => {
|
|
73
|
+
// ignore if not ArrayBuffer
|
|
74
|
+
if (!(event.data instanceof ArrayBuffer)) {
|
|
75
|
+
console.warn("Received non-ArrayBuffer message, ignoring");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
controller.enqueue(event.data);
|
|
79
|
+
};
|
|
80
|
+
webSocket.onerror = () => {
|
|
81
|
+
controller.error(new Error("WebSocket error"));
|
|
82
|
+
};
|
|
83
|
+
webSocket.onclose = () => {
|
|
84
|
+
if (!closed)
|
|
85
|
+
controller.close();
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
cancel() {
|
|
89
|
+
webSocket.close();
|
|
90
|
+
closed = true;
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WebSocketServerInterfaceSetupData } from "../../datex.js";
|
|
2
|
+
import type { ComInterfaceFactory } from "../com-hub.js";
|
|
3
|
+
export declare const websocketServerDenoComInterfaceFactory: ComInterfaceFactory<WebSocketServerInterfaceSetupData>;
|
|
4
|
+
//# sourceMappingURL=websocket-server-deno.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-server-deno.d.ts","sourceRoot":"","sources":["../../../src/network/interfaces/websocket-server-deno.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AA4BzD,eAAO,MAAM,sCAAsC,EAAE,mBAAmB,CAAC,iCAAiC,CAC3C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createWebsocketServerComInterfaceFactory } from "./websocket-server-base.js";
|
|
2
|
+
function denoServerFactory(setupData) {
|
|
3
|
+
const [hostname, maybe_port] = setupData.bind_address.split(":");
|
|
4
|
+
const port = maybe_port ? parseInt(maybe_port) : undefined;
|
|
5
|
+
let server;
|
|
6
|
+
return new ReadableStream({
|
|
7
|
+
start(controller) {
|
|
8
|
+
server = Deno.serve({ port, hostname }, (req) => {
|
|
9
|
+
if (req.headers.get("upgrade") != "websocket") {
|
|
10
|
+
return new Response(null, { status: 501 });
|
|
11
|
+
}
|
|
12
|
+
const { socket, response } = Deno.upgradeWebSocket(req);
|
|
13
|
+
controller.enqueue(socket);
|
|
14
|
+
return response;
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
async cancel() {
|
|
18
|
+
await server.shutdown();
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export const websocketServerDenoComInterfaceFactory = createWebsocketServerComInterfaceFactory(denoServerFactory);
|
package/esm/network/mod.d.ts
CHANGED
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;;;;;GAKG;AAEH,cAAc,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/network/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,cAAc,CAAC"}
|
package/esm/network/mod.js
CHANGED
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":"
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/refs/ref.ts"],"names":[],"mappings":"AAAA,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,EAOpB;CACJ"}
|
package/esm/refs/ref.js
CHANGED
|
@@ -10,7 +10,6 @@ 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 _Ref_value, _Ref_pointerAddress, _Ref_difHandler;
|
|
13
|
-
import { DIF_Replace } from "../dif/builders.js";
|
|
14
13
|
/**
|
|
15
14
|
* The Ref class is a wrapper around a value that is stored in a pointer.
|
|
16
15
|
* Primitive values (string, number, boolean, null) are always wrapped in a Ref when stored in a pointer.
|
|
@@ -54,7 +53,7 @@ export class Ref {
|
|
|
54
53
|
if (oldValue === newValue)
|
|
55
54
|
return;
|
|
56
55
|
// Try to update the pointer
|
|
57
|
-
__classPrivateFieldGet(this, _Ref_difHandler, "f").
|
|
56
|
+
__classPrivateFieldGet(this, _Ref_difHandler, "f").triggerReplace(__classPrivateFieldGet(this, _Ref_pointerAddress, "f"), newValue);
|
|
58
57
|
__classPrivateFieldSet(this, _Ref_value, newValue, "f");
|
|
59
58
|
}
|
|
60
59
|
}
|
package/esm/runtime/runtime.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type JSRuntime } from "../datex
|
|
1
|
+
import { type DecompileOptions, type JSRuntime } from "../datex.js";
|
|
2
2
|
import { ComHub } from "../network/com-hub.js";
|
|
3
|
-
import { DIFHandler } from "../dif/dif-handler.js";
|
|
4
|
-
import type { DIFReferenceMutability,
|
|
3
|
+
import { DIFHandler, type PointerOut } from "../dif/dif-handler.js";
|
|
4
|
+
import type { DIFReferenceMutability, DIFTypeDefinition } from "../dif/definitions.js";
|
|
5
5
|
import type { Ref } from "../refs/ref.js";
|
|
6
6
|
/** debug flags for the runtime */
|
|
7
|
-
interface
|
|
8
|
-
|
|
9
|
-
enable_deterministic_behavior?: boolean;
|
|
7
|
+
interface DebugConfig {
|
|
8
|
+
log_level?: "error" | "warn" | "info" | "debug" | "trace" | null;
|
|
10
9
|
}
|
|
11
10
|
/** configuration for the runtime */
|
|
12
11
|
export type RuntimeConfig = {
|
|
@@ -15,14 +14,7 @@ export type RuntimeConfig = {
|
|
|
15
14
|
type: string;
|
|
16
15
|
config: unknown;
|
|
17
16
|
}[];
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
/** options for decompiling values to strings */
|
|
21
|
-
export type DecompileOptions = {
|
|
22
|
-
formatted?: boolean;
|
|
23
|
-
colorized?: boolean;
|
|
24
|
-
resolve_slots?: boolean;
|
|
25
|
-
json_compat?: boolean;
|
|
17
|
+
env?: Record<string, string>;
|
|
26
18
|
};
|
|
27
19
|
/**
|
|
28
20
|
* The main Runtime class for executing Datex scripts and managing communication interfaces.
|
|
@@ -30,20 +22,14 @@ export type DecompileOptions = {
|
|
|
30
22
|
export declare class Runtime {
|
|
31
23
|
#private;
|
|
32
24
|
readonly js_version: string;
|
|
33
|
-
constructor(
|
|
25
|
+
private constructor();
|
|
34
26
|
/**
|
|
35
27
|
* Creates a new Runtime instance.
|
|
36
28
|
* @param config Runtime configuration
|
|
37
|
-
* @param
|
|
29
|
+
* @param debugConfig Debug flags for the runtime
|
|
38
30
|
* @returns A promise that resolves to the created Runtime instance
|
|
39
31
|
*/
|
|
40
|
-
static create(config: RuntimeConfig,
|
|
41
|
-
/**
|
|
42
|
-
* Starts the runtime.
|
|
43
|
-
* @returns A promise that resolves when the runtime has started.
|
|
44
|
-
*/
|
|
45
|
-
start(): Promise<void>;
|
|
46
|
-
_stop(): Promise<void>;
|
|
32
|
+
static create(config: RuntimeConfig, debugConfig?: DebugConfig): Promise<Runtime>;
|
|
47
33
|
/**
|
|
48
34
|
* Gets the endpoint of the runtime.
|
|
49
35
|
*/
|
|
@@ -131,50 +117,27 @@ export declare class Runtime {
|
|
|
131
117
|
valueToString(value: unknown, decompileOptions?: DecompileOptions | null): string;
|
|
132
118
|
_execute_internal(datexScript: string): boolean;
|
|
133
119
|
/**
|
|
134
|
-
* Creates a new
|
|
135
|
-
*
|
|
136
|
-
*
|
|
120
|
+
* Creates a new reference containg the given JS value.
|
|
121
|
+
* For primitive values, a Ref wrapper is returned.
|
|
122
|
+
* For other values (objects, arrays, maps), the returned value is a proxy object that behaves like the original object.
|
|
123
|
+
*
|
|
137
124
|
* @param value The JS value to store in the pointer.
|
|
138
125
|
* @param allowedType Optional DIF type container to restrict the type of the pointer.
|
|
139
126
|
* @param mutability Optional mutability of the reference (default is Mutable).
|
|
140
127
|
* @returns A proxy object representing the pointer in JS.
|
|
141
128
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
type IsPlainObject<T> = T extends Builtins ? false : T extends object ? true : false;
|
|
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 ? {
|
|
156
|
-
readonly [K in keyof T]: ObjectFieldOut<T[K], M>;
|
|
157
|
-
} : {
|
|
158
|
-
[K in keyof T]: ObjectFieldOut<T[K], M>;
|
|
159
|
-
} : {
|
|
160
|
-
readonly [K in keyof T]: ObjectFieldOut<T[K], M>;
|
|
161
|
-
}) : T;
|
|
162
|
-
type PointerOut<V, M extends DIFReferenceMutability> = V extends Ref<infer U> ? M extends typeof DIFReferenceMutability.Immutable ? Ref<U> : AssignableRef<U> : IsPlainObject<V> extends true ? (ContainsRef<V> extends true ? M extends typeof DIFReferenceMutability.Immutable ? {
|
|
163
|
-
readonly [K in keyof V]: ObjectFieldOut<V[K], M>;
|
|
164
|
-
} : {
|
|
165
|
-
[K in keyof V]: ObjectFieldOut<V[K], M>;
|
|
166
|
-
} : {
|
|
167
|
-
readonly [K in keyof V]: ObjectFieldOut<V[K], M>;
|
|
168
|
-
}) : V extends Builtins ? Pointer<V> : M extends typeof DIFReferenceMutability.Immutable ? Ref<V> : Ref<WidenLiteral<V>>;
|
|
169
|
-
type CollectionProps<T> = {
|
|
170
|
-
[K in keyof T as K extends "value" ? never : K]: T[K];
|
|
171
|
-
};
|
|
172
|
-
interface MapRef<K, V> extends Ref<Map<K, V>>, CollectionProps<Map<K, V>> {
|
|
173
|
-
}
|
|
174
|
-
interface SetRef<T> extends Ref<Set<T>>, CollectionProps<Set<T>> {
|
|
175
|
-
}
|
|
176
|
-
interface ArrayRef<T> extends Ref<T[]>, CollectionProps<T[]> {
|
|
129
|
+
createTransparentReference<V, M extends DIFReferenceMutability = typeof DIFReferenceMutability.Mutable>(value: V & {}, allowedType?: DIFTypeDefinition | null, mutability?: M): PointerOut<V, M>;
|
|
130
|
+
/**
|
|
131
|
+
* Creates or retrieves a wrapped reference for the given value.
|
|
132
|
+
* If the value is already a reference, it returns the existing reference.
|
|
133
|
+
*
|
|
134
|
+
* @param value
|
|
135
|
+
* @param allowedType
|
|
136
|
+
* @param mutability
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
createOrGetWrappedReference<V, M extends DIFReferenceMutability = typeof DIFReferenceMutability.Mutable>(_value: V, _allowedType?: DIFTypeDefinition | null, _mutability?: M): Ref<V>;
|
|
140
|
+
startLSP(callback: (data: string) => void): (data: string) => void;
|
|
177
141
|
}
|
|
178
|
-
type Pointer<T> = T extends Map<infer K, infer V> ? MapRef<K, V> : T extends Set<infer U> ? SetRef<U> : T extends Array<infer U> ? ArrayRef<U> : Ref<T>;
|
|
179
142
|
export {};
|
|
180
143
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,gBAAgB,EAAoB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAO1C,kCAAkC;AAClC,UAAU,WAAW;IAEjB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;CACpE;AAED,qCAAqC;AACrC,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAO;;IAChB,SAAgB,UAAU,SAAW;IAMrC,OAAO;IAMP;;;;;OAKG;WACiB,MAAM,CACtB,MAAM,EAAE,aAAa,EACrB,WAAW,CAAC,EAAE,WAAW,GAC1B,OAAO,CAAC,OAAO,CAAC;IAOnB;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,UAAU,CAEpB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,SAAS,CAExB;IAED;;;;;;OAMG;IACI,uBAAuB,CAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,OAAO,EAAE,GAAG,IAAS,EAC7B,gBAAgB,GAAE,gBAAgB,GAAG,IAAW,GACjD,OAAO,CAAC,MAAM,CAAC;IAQlB;;;;;;OAMG;IACI,2BAA2B,CAC9B,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,OAAO,EAAE,GAAG,IAAS,EAC7B,gBAAgB,GAAE,gBAAgB,GAAG,IAAW,GACjD,MAAM;IAQT;;;;;;;;;OASG;IACI,OAAO,CAAC,CAAC,GAAG,OAAO,EACtB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,OAAO,EAAE,GACnB,OAAO,CAAC,CAAC,CAAC;IAEb;;;;;;;;OAQG;IACI,OAAO,CAAC,CAAC,GAAG,OAAO,EACtB,eAAe,EAAE,oBAAoB,EACrC,GAAG,MAAM,EAAE,OAAO,EAAE,GACrB,OAAO,CAAC,CAAC,CAAC;IA0Bb;;;;;;;;;OASG;IACI,WAAW,CAAC,CAAC,GAAG,OAAO,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,OAAO,EAAE,GACnB,CAAC;IAEJ;;;;;;;;OAQG;IACI,WAAW,CAAC,CAAC,GAAG,OAAO,EAC1B,eAAe,EAAE,oBAAoB,EACrC,GAAG,MAAM,EAAE,OAAO,EAAE,GACrB,CAAC;IA8BJ;;;;;OAKG;IACI,aAAa,CAChB,KAAK,EAAE,OAAO,EACd,gBAAgB,GAAE,gBAAgB,GAAG,IAAW,GACjD,MAAM;IA8BF,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAItD;;;;;;;;;OASG;IACI,0BAA0B,CAC7B,CAAC,EACD,CAAC,SAAS,sBAAsB,GAAG,OAAO,sBAAsB,CAAC,OAAO,EAGxE,KAAK,EAAE,CAAC,GAAG,EAAE,EACb,WAAW,CAAC,EAAE,iBAAiB,GAAG,IAAI,EACtC,UAAU,CAAC,EAAE,CAAC,GACf,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;IAQnB;;;;;;;;OAQG;IACI,2BAA2B,CAC9B,CAAC,EACD,CAAC,SAAS,sBAAsB,GAAG,OAAO,sBAAsB,CAAC,OAAO,EAExE,MAAM,EAAE,CAAC,EACT,YAAY,CAAC,EAAE,iBAAiB,GAAG,IAAI,EACvC,WAAW,CAAC,EAAE,CAAC,GAChB,GAAG,CAAC,CAAC,CAAC;IAIF,QAAQ,CACX,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GACjC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;CAY5B"}
|
package/esm/runtime/runtime.js
CHANGED
|
@@ -10,16 +10,18 @@ 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 _Runtime_instances, _Runtime_runtime, _Runtime_comHub, _Runtime_difHandler, _Runtime_executeInternal, _Runtime_executeSyncInternal, _Runtime_getScriptAndValues;
|
|
13
|
-
import { create_runtime, execute_internal
|
|
13
|
+
import { create_runtime, execute_internal } from "../datex.js";
|
|
14
14
|
import { ComHub } from "../network/com-hub.js";
|
|
15
15
|
import { DIFHandler } from "../dif/dif-handler.js";
|
|
16
|
+
import { unimplemented } from "../utils/exceptions.js";
|
|
17
|
+
// TODO: move to global.ts
|
|
16
18
|
/** auto-generated version - do not edit: */
|
|
17
|
-
const VERSION = "0.0.
|
|
19
|
+
const VERSION = "0.0.12";
|
|
18
20
|
/**
|
|
19
21
|
* The main Runtime class for executing Datex scripts and managing communication interfaces.
|
|
20
22
|
*/
|
|
21
23
|
export class Runtime {
|
|
22
|
-
constructor(
|
|
24
|
+
constructor(jsRuntime) {
|
|
23
25
|
_Runtime_instances.add(this);
|
|
24
26
|
Object.defineProperty(this, "js_version", {
|
|
25
27
|
enumerable: true,
|
|
@@ -30,30 +32,21 @@ export class Runtime {
|
|
|
30
32
|
_Runtime_runtime.set(this, void 0);
|
|
31
33
|
_Runtime_comHub.set(this, void 0);
|
|
32
34
|
_Runtime_difHandler.set(this, void 0);
|
|
33
|
-
__classPrivateFieldSet(this, _Runtime_runtime,
|
|
34
|
-
__classPrivateFieldSet(this, _Runtime_comHub, new ComHub(__classPrivateFieldGet(this, _Runtime_runtime, "f").com_hub), "f");
|
|
35
|
+
__classPrivateFieldSet(this, _Runtime_runtime, jsRuntime, "f");
|
|
36
|
+
__classPrivateFieldSet(this, _Runtime_comHub, new ComHub(__classPrivateFieldGet(this, _Runtime_runtime, "f").com_hub, this), "f");
|
|
35
37
|
__classPrivateFieldSet(this, _Runtime_difHandler, new DIFHandler(__classPrivateFieldGet(this, _Runtime_runtime, "f")), "f");
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Creates a new Runtime instance.
|
|
39
41
|
* @param config Runtime configuration
|
|
40
|
-
* @param
|
|
42
|
+
* @param debugConfig Debug flags for the runtime
|
|
41
43
|
* @returns A promise that resolves to the created Runtime instance
|
|
42
44
|
*/
|
|
43
|
-
static async create(config,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Starts the runtime.
|
|
50
|
-
* @returns A promise that resolves when the runtime has started.
|
|
51
|
-
*/
|
|
52
|
-
start() {
|
|
53
|
-
return __classPrivateFieldGet(this, _Runtime_runtime, "f").start();
|
|
54
|
-
}
|
|
55
|
-
_stop() {
|
|
56
|
-
return __classPrivateFieldGet(this, _Runtime_runtime, "f")._stop();
|
|
45
|
+
static async create(config, debugConfig) {
|
|
46
|
+
// workaround: temp dif handler without runtime to convert config to DIF
|
|
47
|
+
const configDIF = DIFHandler.convertJSValueToDIFValueContainer(config);
|
|
48
|
+
const jsRuntime = await create_runtime(configDIF, debugConfig);
|
|
49
|
+
return new Runtime(jsRuntime);
|
|
57
50
|
}
|
|
58
51
|
/**
|
|
59
52
|
* Gets the endpoint of the runtime.
|
|
@@ -121,24 +114,47 @@ export class Runtime {
|
|
|
121
114
|
* @returns The string representation of the value.
|
|
122
115
|
*/
|
|
123
116
|
valueToString(value, decompileOptions = null) {
|
|
124
|
-
return __classPrivateFieldGet(this, _Runtime_runtime, "f").value_to_string(__classPrivateFieldGet(this, _Runtime_difHandler, "f").
|
|
117
|
+
return __classPrivateFieldGet(this, _Runtime_runtime, "f").value_to_string(__classPrivateFieldGet(this, _Runtime_difHandler, "f").convertJSValueToDIFValueContainer(value), decompileOptions);
|
|
125
118
|
}
|
|
126
119
|
_execute_internal(datexScript) {
|
|
127
120
|
return execute_internal(datexScript);
|
|
128
121
|
}
|
|
129
122
|
/**
|
|
130
|
-
* Creates a new
|
|
131
|
-
*
|
|
132
|
-
*
|
|
123
|
+
* Creates a new reference containg the given JS value.
|
|
124
|
+
* For primitive values, a Ref wrapper is returned.
|
|
125
|
+
* For other values (objects, arrays, maps), the returned value is a proxy object that behaves like the original object.
|
|
126
|
+
*
|
|
133
127
|
* @param value The JS value to store in the pointer.
|
|
134
128
|
* @param allowedType Optional DIF type container to restrict the type of the pointer.
|
|
135
129
|
* @param mutability Optional mutability of the reference (default is Mutable).
|
|
136
130
|
* @returns A proxy object representing the pointer in JS.
|
|
137
131
|
*/
|
|
138
|
-
|
|
132
|
+
createTransparentReference(
|
|
139
133
|
// deno-lint-ignore ban-types
|
|
140
134
|
value, allowedType, mutability) {
|
|
141
|
-
return __classPrivateFieldGet(this, _Runtime_difHandler, "f").
|
|
135
|
+
return __classPrivateFieldGet(this, _Runtime_difHandler, "f").createTransparentReference(value, allowedType, mutability);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Creates or retrieves a wrapped reference for the given value.
|
|
139
|
+
* If the value is already a reference, it returns the existing reference.
|
|
140
|
+
*
|
|
141
|
+
* @param value
|
|
142
|
+
* @param allowedType
|
|
143
|
+
* @param mutability
|
|
144
|
+
* @returns
|
|
145
|
+
*/
|
|
146
|
+
createOrGetWrappedReference(_value, _allowedType, _mutability) {
|
|
147
|
+
unimplemented();
|
|
148
|
+
}
|
|
149
|
+
startLSP(callback) {
|
|
150
|
+
const decoder = new TextDecoder("utf-8");
|
|
151
|
+
const encoder = new TextEncoder();
|
|
152
|
+
const sendToRust = __classPrivateFieldGet(this, _Runtime_runtime, "f").start_lsp((bytes) => {
|
|
153
|
+
callback(decoder.decode(bytes));
|
|
154
|
+
});
|
|
155
|
+
return (data) => {
|
|
156
|
+
sendToRust(encoder.encode(data));
|
|
157
|
+
};
|
|
142
158
|
}
|
|
143
159
|
}
|
|
144
160
|
_Runtime_runtime = new WeakMap(), _Runtime_comHub = new WeakMap(), _Runtime_difHandler = new WeakMap(), _Runtime_instances = new WeakSet(), _Runtime_executeInternal = async function _Runtime_executeInternal(datexScript, values = []) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools-formatter.d.ts","sourceRoot":"","sources":["../../src/utils/devtools-formatter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Endpoint } from "../lib/special-core-types/endpoint.js";
|
|
2
|
+
import { Ref } from "../refs/ref.js";
|
|
3
|
+
// @ts-ignore devtoolsFormatters
|
|
4
|
+
globalThis.devtoolsFormatters = [
|
|
5
|
+
{
|
|
6
|
+
header(obj) {
|
|
7
|
+
if (obj instanceof Endpoint) {
|
|
8
|
+
return ["span", { style: "color: #58d452" }, obj.toString()];
|
|
9
|
+
}
|
|
10
|
+
else if (obj instanceof Ref) {
|
|
11
|
+
return [
|
|
12
|
+
"span",
|
|
13
|
+
{},
|
|
14
|
+
[
|
|
15
|
+
"span",
|
|
16
|
+
{},
|
|
17
|
+
[
|
|
18
|
+
"span",
|
|
19
|
+
{ style: "color: #1279d5" },
|
|
20
|
+
"&mut ",
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"span",
|
|
24
|
+
{},
|
|
25
|
+
// TODO: only proof of concept, syntax highlighting does not match JS
|
|
26
|
+
obj.value,
|
|
27
|
+
],
|
|
28
|
+
],
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
return null; // fall back to default
|
|
32
|
+
},
|
|
33
|
+
hasBody(_) {
|
|
34
|
+
return false;
|
|
35
|
+
},
|
|
36
|
+
body(_) {
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/utils/exceptions.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,OAAO,GAAE,MAAkB,GAAG,KAAK,CAExD;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,MAAkB,GAAG,KAAK,CAE9D;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,MAAkB,GAAG,KAAK,CAEhE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function panic(message = "unknown") {
|
|
2
|
+
throw new Error(`Panic: ${message}`);
|
|
3
|
+
}
|
|
4
|
+
export function unreachable(message = "unknown") {
|
|
5
|
+
throw new Error(`Unreachable code reached: ${message}`);
|
|
6
|
+
}
|
|
7
|
+
export function unimplemented(message = "unknown") {
|
|
8
|
+
throw new Error(`Not implemented: ${message}`);
|
|
9
|
+
}
|