@unyt/datex 0.0.11 → 0.0.13

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.
Files changed (72) hide show
  1. package/README.md +10 -14
  2. package/esm/datex-web/datex_web.d.ts +2 -0
  3. package/esm/datex-web/datex_web.d.ts.map +1 -0
  4. package/esm/datex-web/datex_web.internal.d.ts +366 -0
  5. package/esm/datex-web/datex_web.internal.d.ts.map +1 -0
  6. package/esm/datex-web/datex_web.internal.js +1484 -0
  7. package/esm/datex-web/datex_web.js +18 -0
  8. package/esm/datex-web/datex_web.wasm +0 -0
  9. package/esm/datex-web/wasm_url.node.js +1 -0
  10. package/esm/{datex-core.d.ts → datex.d.ts} +3 -3
  11. package/esm/datex.d.ts.map +1 -0
  12. package/esm/{datex-core.js → datex.js} +3 -3
  13. package/esm/default.d.ts.map +1 -1
  14. package/esm/default.js +2 -3
  15. package/esm/deno.json +27 -21
  16. package/esm/dif/core.d.ts.map +1 -1
  17. package/esm/dif/definitions.d.ts +6 -6
  18. package/esm/dif/definitions.d.ts.map +1 -1
  19. package/esm/dif/definitions.js +1 -1
  20. package/esm/dif/dif-handler.d.ts +17 -8
  21. package/esm/dif/dif-handler.d.ts.map +1 -1
  22. package/esm/dif/dif-handler.js +21 -9
  23. package/esm/dif/display.d.ts +3 -3
  24. package/esm/dif/display.d.ts.map +1 -1
  25. package/esm/dif/display.js +4 -6
  26. package/esm/dif/js-lib.d.ts.map +1 -1
  27. package/esm/dif/type-registry.d.ts.map +1 -1
  28. package/esm/dif/type-registry.js +2 -2
  29. package/esm/lib/special-core-types/endpoint.d.ts +2 -0
  30. package/esm/lib/special-core-types/endpoint.d.ts.map +1 -1
  31. package/esm/lib/special-core-types/endpoint.js +6 -1
  32. package/esm/mod.d.ts +3 -1
  33. package/esm/mod.d.ts.map +1 -1
  34. package/esm/mod.js +3 -1
  35. package/esm/network/com-hub.d.ts +20 -22
  36. package/esm/network/com-hub.d.ts.map +1 -1
  37. package/esm/network/com-hub.js +30 -49
  38. package/esm/network/interfaces/websocket-server-base.d.ts +8 -0
  39. package/esm/network/interfaces/websocket-server-base.d.ts.map +1 -0
  40. package/esm/network/interfaces/websocket-server-base.js +93 -0
  41. package/esm/network/interfaces/websocket-server-deno.d.ts +4 -0
  42. package/esm/network/interfaces/websocket-server-deno.d.ts.map +1 -0
  43. package/esm/network/interfaces/websocket-server-deno.js +22 -0
  44. package/esm/network/mod.d.ts +0 -1
  45. package/esm/network/mod.d.ts.map +1 -1
  46. package/esm/network/mod.js +0 -1
  47. package/esm/runtime/runtime.d.ts +10 -18
  48. package/esm/runtime/runtime.d.ts.map +1 -1
  49. package/esm/runtime/runtime.js +11 -23
  50. package/esm/utils/devtools-formatter.d.ts +2 -0
  51. package/esm/utils/devtools-formatter.d.ts.map +1 -0
  52. package/esm/utils/devtools-formatter.js +40 -0
  53. package/esm/utils/js-runtime-compat/js-runtime.d.ts.map +1 -1
  54. package/package.json +7 -7
  55. package/esm/datex-core/datex_core_js.d.ts +0 -2
  56. package/esm/datex-core/datex_core_js.d.ts.map +0 -1
  57. package/esm/datex-core/datex_core_js.internal.d.ts +0 -496
  58. package/esm/datex-core/datex_core_js.internal.d.ts.map +0 -1
  59. package/esm/datex-core/datex_core_js.internal.js +0 -1903
  60. package/esm/datex-core/datex_core_js.js +0 -21
  61. package/esm/datex-core/datex_core_js.wasm +0 -0
  62. package/esm/datex-core/wasm_url.node.js +0 -1
  63. package/esm/datex-core.d.ts.map +0 -1
  64. package/esm/network/com-interface.d.ts +0 -35
  65. package/esm/network/com-interface.d.ts.map +0 -1
  66. package/esm/network/com-interface.js +0 -75
  67. package/esm/network/interface-impls/base.d.ts +0 -46
  68. package/esm/network/interface-impls/base.d.ts.map +0 -1
  69. package/esm/network/interface-impls/base.js +0 -47
  70. package/esm/network/interface-impls/websocket-client.d.ts +0 -8
  71. package/esm/network/interface-impls/websocket-client.d.ts.map +0 -1
  72. package/esm/network/interface-impls/websocket-client.js +0 -8
@@ -1,43 +1,41 @@
1
- import type { JSComHub } from "../datex-core/datex_core_js";
2
- import { ComInterface, type ComInterfaceImpl } from "./com-interface.js";
1
+ import type { ComHubMetadata, ComInterfaceConfiguration, JSComHub, NetworkTraceResult } from "../datex-web/datex_web";
2
+ import type { Runtime } from "../runtime/runtime.js";
3
+ export type ComInterfaceFactory<SetupData = unknown> = {
4
+ interfaceType: string;
5
+ factory: ComInterfaceFactoryFn<SetupData>;
6
+ };
7
+ export type ComInterfaceFactoryFn<SetupData = unknown> = (setup_data: SetupData) => ComInterfaceConfiguration | Promise<ComInterfaceConfiguration>;
8
+ export type ComInterfaceUUID = `com_interface::${string}`;
9
+ export type ComInterfaceSocketUUID = `socket::${string}`;
3
10
  /**
4
11
  * Communication hub for managing communication interfaces.
5
12
  */
6
13
  export declare class ComHub {
7
14
  #private;
8
- constructor(jsComHub: JSComHub);
9
- /**
10
- * Registers a communication interface implementation.
11
- * @param interfaceType The type of the interface.
12
- * @param impl The implementation class of the interface.
13
- */
14
- static registerInterfaceImpl<N extends string>(interfaceType: N, impl: typeof ComInterfaceImpl<unknown>): void;
15
+ constructor(jsComHub: JSComHub, runtime: Runtime);
16
+ registerInterfaceFactory<SetupData>(factoryDefinition: ComInterfaceFactory<SetupData>): void;
15
17
  /**
16
18
  * Creates a new communication interface.
17
- * @param interfaceType The type of the interface to create.
19
+ * @param type The type of the interface to create.
18
20
  * @param setupData The setup data for the interface.
21
+ * @param priority The priority of the interface (optional).
22
+ * @returns A promise that resolves to the UUID of the created interface.
19
23
  */
20
- createInterface<T extends typeof ComInterfaceImpl<unknown>>(interfaceType: T, setupData: T extends typeof ComInterfaceImpl<infer P> ? P : never): Promise<ComInterface<InstanceType<T>>>;
21
- createInterface<T extends ComInterfaceImpl<unknown>>(interfaceType: string, setupData: T extends ComInterfaceImpl<infer P> ? P : never): Promise<ComInterface<T>>;
22
- _update(): Promise<void>;
23
- _drain_incoming_blocks(): Uint8Array<ArrayBufferLike>[];
24
+ createInterface<SetupData>(type: string, setupData: SetupData, priority?: number): Promise<ComInterfaceUUID>;
25
+ removeInterface(interface_uuid: ComInterfaceUUID): Promise<void>;
26
+ removeSocket(socket_uuid: ComInterfaceSocketUUID): Promise<void>;
24
27
  /**
25
28
  * Prints the metadata of the ComHub. Only available in debug builds.
29
+ * Only exists in debug builds
26
30
  */
27
31
  printMetadata(): void;
32
+ getMetadata(): ComHubMetadata;
28
33
  /**
29
34
  * Prints the trace for a specific endpoint. Only available in debug builds.
30
35
  * @param endpoint The endpoint for which to print the trace.
31
36
  */
32
37
  printTrace(endpoint: string): Promise<void>;
33
- /**
34
- * Sends a block of data to a specific interface and socket.
35
- * @param block The data block to send.
36
- * @param interface_uuid The UUID of the interface to send the block to.
37
- * @param socket_uuid The UUID of the socket to send the block to.
38
- * @returns A promise that resolves to true if the block was sent successfully, false otherwise.
39
- */
40
- sendBlock(block: Uint8Array, interface_uuid: string, socket_uuid: string): Promise<boolean>;
38
+ getTrace(endpoint: string): Promise<NetworkTraceResult | undefined>;
41
39
  /**
42
40
  * Registers a callback to intercept incoming blocks.
43
41
  * @param callback The callback to be invoked for each incoming block.
@@ -1 +1 @@
1
- {"version":3,"file":"com-hub.d.ts","sourceRoot":"","sources":["../../src/network/com-hub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEzE;;GAEG;AACH,qBAAa,MAAM;;gBAgBH,QAAQ,EAAE,QAAQ;IAI9B;;;;OAIG;IACH,MAAM,CAAC,qBAAqB,CAAC,CAAC,SAAS,MAAM,EACzC,aAAa,EAAE,CAAC,EAChB,IAAI,EAAE,OAAO,gBAAgB,CAAC,OAAO,CAAC;IAW1C;;;;OAIG;IACG,eAAe,CAAC,CAAC,SAAS,OAAO,gBAAgB,CAAC,OAAO,CAAC,EAC5D,aAAa,EAAE,CAAC,EAChB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AQ,EAAE,CACN,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,KAClB,IAAI,GACV,IAAI;CAGV"}
@@ -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 _a, _ComHub_interfaceImpls, _ComHub_interfaceImplsByClass, _ComHub_jsComHub;
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
- * Registers a communication interface implementation.
25
- * @param interfaceType The type of the interface.
26
- * @param impl The implementation class of the interface.
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
- static registerInterfaceImpl(interfaceType, impl) {
29
- if (__classPrivateFieldGet(this, _a, "f", _ComHub_interfaceImpls).has(interfaceType)) {
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
- _update() {
52
- return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").update();
40
+ removeInterface(interface_uuid) {
41
+ return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").remove_interface(interface_uuid);
53
42
  }
54
- _drain_incoming_blocks() {
55
- return __classPrivateFieldGet(this, _ComHub_jsComHub, "f")._drain_incoming_blocks();
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
- * Sends a block of data to a specific interface and socket.
82
- * @param block The data block to send.
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
- _a = ComHub, _ComHub_jsComHub = new WeakMap();
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);
@@ -5,5 +5,4 @@
5
5
  * communication hubs and interfaces.
6
6
  */
7
7
  export * from "./com-hub.js";
8
- export * from "./com-interface.js";
9
8
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/network/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,cAAc,CAAC"}
@@ -5,4 +5,3 @@
5
5
  * communication hubs and interfaces.
6
6
  */
7
7
  export * from "./com-hub.js";
8
- export * from "./com-interface.js";
@@ -1,12 +1,11 @@
1
- import { type DecompileOptions, type JSRuntime } from "../datex-core.js";
1
+ import { type DecompileOptions, type JSRuntime } from "../datex.js";
2
2
  import { ComHub } from "../network/com-hub.js";
3
3
  import { DIFHandler, type PointerOut } from "../dif/dif-handler.js";
4
- import type { DIFReferenceMutability, DIFTypeDefinition } from "../dif/definitions.js";
4
+ import type { DIFSharedValueMutability, DIFTypeDefinition } from "../dif/definitions.js";
5
5
  import type { Ref } from "../refs/ref.js";
6
6
  /** debug flags for the runtime */
7
- interface DebugFlags {
8
- allow_unsigned_blocks?: boolean;
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,7 +14,7 @@ export type RuntimeConfig = {
15
14
  type: string;
16
15
  config: unknown;
17
16
  }[];
18
- debug?: boolean;
17
+ env?: Record<string, string>;
19
18
  };
20
19
  /**
21
20
  * The main Runtime class for executing Datex scripts and managing communication interfaces.
@@ -23,20 +22,14 @@ export type RuntimeConfig = {
23
22
  export declare class Runtime {
24
23
  #private;
25
24
  readonly js_version: string;
26
- constructor(config: RuntimeConfig, debug_flags?: DebugFlags);
25
+ private constructor();
27
26
  /**
28
27
  * Creates a new Runtime instance.
29
28
  * @param config Runtime configuration
30
- * @param debug_flags Debug flags for the runtime
29
+ * @param debugConfig Debug flags for the runtime
31
30
  * @returns A promise that resolves to the created Runtime instance
32
31
  */
33
- static create(config: RuntimeConfig, debug_flags?: DebugFlags): Promise<Runtime>;
34
- /**
35
- * Starts the runtime.
36
- * @returns A promise that resolves when the runtime has started.
37
- */
38
- start(): Promise<void>;
39
- _stop(): Promise<void>;
32
+ static create(config: RuntimeConfig, debugConfig?: DebugConfig): Promise<Runtime>;
40
33
  /**
41
34
  * Gets the endpoint of the runtime.
42
35
  */
@@ -122,7 +115,6 @@ export declare class Runtime {
122
115
  * @returns The string representation of the value.
123
116
  */
124
117
  valueToString(value: unknown, decompileOptions?: DecompileOptions | null): string;
125
- _execute_internal(datexScript: string): boolean;
126
118
  /**
127
119
  * Creates a new reference containg the given JS value.
128
120
  * For primitive values, a Ref wrapper is returned.
@@ -133,7 +125,7 @@ export declare class Runtime {
133
125
  * @param mutability Optional mutability of the reference (default is Mutable).
134
126
  * @returns A proxy object representing the pointer in JS.
135
127
  */
136
- createTransparentReference<V, M extends DIFReferenceMutability = typeof DIFReferenceMutability.Mutable>(value: V & {}, allowedType?: DIFTypeDefinition | null, mutability?: M): PointerOut<V, M>;
128
+ createTransparentReference<V, M extends DIFSharedValueMutability = typeof DIFSharedValueMutability.Mutable>(value: V & {}, allowedType?: DIFTypeDefinition | null, mutability?: M): PointerOut<V, M>;
137
129
  /**
138
130
  * Creates or retrieves a wrapped reference for the given value.
139
131
  * If the value is already a reference, it returns the existing reference.
@@ -143,7 +135,7 @@ export declare class Runtime {
143
135
  * @param mutability
144
136
  * @returns
145
137
  */
146
- createOrGetWrappedReference<V, M extends DIFReferenceMutability = typeof DIFReferenceMutability.Mutable>(_value: V, _allowedType?: DIFTypeDefinition | null, _mutability?: M): Ref<V>;
138
+ createOrGetWrappedReference<V, M extends DIFSharedValueMutability = typeof DIFSharedValueMutability.Mutable>(_value: V, _allowedType?: DIFTypeDefinition | null, _mutability?: M): Ref<V>;
147
139
  startLSP(callback: (data: string) => void): (data: string) => void;
148
140
  }
149
141
  export {};
@@ -1 +1 @@
1
- {"version":3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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;IA8BT;;;;;;;;;OASG;IACI,0BAA0B,CAC7B,CAAC,EACD,CAAC,SAAS,wBAAwB,GAAG,OAAO,wBAAwB,CAAC,OAAO,EAG5E,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,wBAAwB,GAAG,OAAO,wBAAwB,CAAC,OAAO,EAE5E,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"}
@@ -10,18 +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, } from "../datex-core.js";
13
+ import { create_runtime } from "../datex.js";
14
14
  import { ComHub } from "../network/com-hub.js";
15
15
  import { DIFHandler } from "../dif/dif-handler.js";
16
16
  import { unimplemented } from "../utils/exceptions.js";
17
17
  // TODO: move to global.ts
18
18
  /** auto-generated version - do not edit: */
19
- const VERSION = "0.0.11";
19
+ const VERSION = "0.0.13";
20
20
  /**
21
21
  * The main Runtime class for executing Datex scripts and managing communication interfaces.
22
22
  */
23
23
  export class Runtime {
24
- constructor(config, debug_flags) {
24
+ constructor(jsRuntime) {
25
25
  _Runtime_instances.add(this);
26
26
  Object.defineProperty(this, "js_version", {
27
27
  enumerable: true,
@@ -32,30 +32,21 @@ export class Runtime {
32
32
  _Runtime_runtime.set(this, void 0);
33
33
  _Runtime_comHub.set(this, void 0);
34
34
  _Runtime_difHandler.set(this, void 0);
35
- __classPrivateFieldSet(this, _Runtime_runtime, create_runtime(JSON.stringify(config), debug_flags), "f");
36
- __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");
37
37
  __classPrivateFieldSet(this, _Runtime_difHandler, new DIFHandler(__classPrivateFieldGet(this, _Runtime_runtime, "f")), "f");
38
38
  }
39
39
  /**
40
40
  * Creates a new Runtime instance.
41
41
  * @param config Runtime configuration
42
- * @param debug_flags Debug flags for the runtime
42
+ * @param debugConfig Debug flags for the runtime
43
43
  * @returns A promise that resolves to the created Runtime instance
44
44
  */
45
- static async create(config, debug_flags) {
46
- const runtime = new Runtime(config, debug_flags);
47
- await runtime.start();
48
- return runtime;
49
- }
50
- /**
51
- * Starts the runtime.
52
- * @returns A promise that resolves when the runtime has started.
53
- */
54
- start() {
55
- return __classPrivateFieldGet(this, _Runtime_runtime, "f").start();
56
- }
57
- _stop() {
58
- 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);
59
50
  }
60
51
  /**
61
52
  * Gets the endpoint of the runtime.
@@ -125,9 +116,6 @@ export class Runtime {
125
116
  valueToString(value, decompileOptions = null) {
126
117
  return __classPrivateFieldGet(this, _Runtime_runtime, "f").value_to_string(__classPrivateFieldGet(this, _Runtime_difHandler, "f").convertJSValueToDIFValueContainer(value), decompileOptions);
127
118
  }
128
- _execute_internal(datexScript) {
129
- return execute_internal(datexScript);
130
- }
131
119
  /**
132
120
  * Creates a new reference containg the given JS value.
133
121
  * For primitive values, a Ref wrapper is returned.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=devtools-formatter.d.ts.map
@@ -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
+ ];
@@ -1 +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"}
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,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAInF,wBAAgB,aAAa,IAAI,aAAa,CAU7C;AAkBD,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,EAAE,kBAE9B,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@unyt/datex",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "repository": {
5
5
  "type": "git",
6
- "url": "git+https://github.com/unyt-org/datex-core-js.git"
6
+ "url": "git+https://github.com/unyt-org/datex-web.git"
7
7
  },
8
8
  "license": "MIT",
9
9
  "bugs": {
10
- "url": "https://github.com/unyt-org/datex-core-js/issues"
10
+ "url": "https://github.com/unyt-org/datex-web/issues"
11
11
  },
12
12
  "module": "./esm/mod.js",
13
13
  "exports": {
@@ -17,11 +17,11 @@
17
17
  "./default": {
18
18
  "import": "./esm/default.js"
19
19
  },
20
- "./interface-impls/base": {
21
- "import": "./esm/network/interface-impls/base.js"
20
+ "./interfaces/websocket-server-base": {
21
+ "import": "./esm/network/interfaces/websocket-server-base.js"
22
22
  },
23
- "./interface-impls/websocket-client": {
24
- "import": "./esm/network/interface-impls/websocket-client.js"
23
+ "./interfaces/websocket-server-deno": {
24
+ "import": "./esm/network/interfaces/websocket-server-deno.js"
25
25
  }
26
26
  },
27
27
  "scripts": {},
@@ -1,2 +0,0 @@
1
- export * from "./datex_core_js.internal.js";
2
- //# sourceMappingURL=datex_core_js.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datex_core_js.d.ts","sourceRoot":"","sources":["../../src/datex-core/datex_core_js.js"],"names":[],"mappings":""}