@unyt/datex 0.0.11 → 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.
Files changed (68) 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 +383 -0
  5. package/esm/datex-web/datex_web.internal.d.ts.map +1 -0
  6. package/esm/{datex-core/datex_core_js.internal.js → datex-web/datex_web.internal.js} +737 -1121
  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.map +1 -1
  18. package/esm/dif/dif-handler.d.ts +10 -1
  19. package/esm/dif/dif-handler.d.ts.map +1 -1
  20. package/esm/dif/dif-handler.js +14 -2
  21. package/esm/dif/display.d.ts.map +1 -1
  22. package/esm/dif/display.js +1 -3
  23. package/esm/dif/js-lib.d.ts.map +1 -1
  24. package/esm/dif/type-registry.d.ts.map +1 -1
  25. package/esm/dif/type-registry.js +2 -2
  26. package/esm/lib/special-core-types/endpoint.d.ts +2 -0
  27. package/esm/lib/special-core-types/endpoint.d.ts.map +1 -1
  28. package/esm/lib/special-core-types/endpoint.js +6 -1
  29. package/esm/mod.d.ts +3 -1
  30. package/esm/mod.d.ts.map +1 -1
  31. package/esm/mod.js +3 -1
  32. package/esm/network/com-hub.d.ts +20 -22
  33. package/esm/network/com-hub.d.ts.map +1 -1
  34. package/esm/network/com-hub.js +30 -49
  35. package/esm/network/interfaces/websocket-server-base.d.ts +8 -0
  36. package/esm/network/interfaces/websocket-server-base.d.ts.map +1 -0
  37. package/esm/network/interfaces/websocket-server-base.js +93 -0
  38. package/esm/network/interfaces/websocket-server-deno.d.ts +4 -0
  39. package/esm/network/interfaces/websocket-server-deno.d.ts.map +1 -0
  40. package/esm/network/interfaces/websocket-server-deno.js +22 -0
  41. package/esm/network/mod.d.ts +0 -1
  42. package/esm/network/mod.d.ts.map +1 -1
  43. package/esm/network/mod.js +0 -1
  44. package/esm/runtime/runtime.d.ts +7 -14
  45. package/esm/runtime/runtime.d.ts.map +1 -1
  46. package/esm/runtime/runtime.js +11 -20
  47. package/esm/utils/devtools-formatter.d.ts +2 -0
  48. package/esm/utils/devtools-formatter.d.ts.map +1 -0
  49. package/esm/utils/devtools-formatter.js +40 -0
  50. package/esm/utils/js-runtime-compat/js-runtime.d.ts.map +1 -1
  51. package/package.json +7 -7
  52. package/esm/datex-core/datex_core_js.d.ts +0 -2
  53. package/esm/datex-core/datex_core_js.d.ts.map +0 -1
  54. package/esm/datex-core/datex_core_js.internal.d.ts +0 -496
  55. package/esm/datex-core/datex_core_js.internal.d.ts.map +0 -1
  56. package/esm/datex-core/datex_core_js.js +0 -21
  57. package/esm/datex-core/datex_core_js.wasm +0 -0
  58. package/esm/datex-core/wasm_url.node.js +0 -1
  59. package/esm/datex-core.d.ts.map +0 -1
  60. package/esm/network/com-interface.d.ts +0 -35
  61. package/esm/network/com-interface.d.ts.map +0 -1
  62. package/esm/network/com-interface.js +0 -75
  63. package/esm/network/interface-impls/base.d.ts +0 -46
  64. package/esm/network/interface-impls/base.d.ts.map +0 -1
  65. package/esm/network/interface-impls/base.js +0 -47
  66. package/esm/network/interface-impls/websocket-client.d.ts +0 -8
  67. package/esm/network/interface-impls/websocket-client.d.ts.map +0 -1
  68. package/esm/network/interface-impls/websocket-client.js +0 -8
@@ -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
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 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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,gBAAgB,EAErB,KAAK,SAAS,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EACR,sBAAsB,EACtB,iBAAiB,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAO1C,kCAAkC;AAClC,UAAU,UAAU;IAChB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,6BAA6B,CAAC,EAAE,OAAO,CAAC;CAC3C;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,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAO;;IAChB,SAAgB,UAAU,SAAW;gBAMzB,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,UAAU;IAM3D;;;;;OAKG;WACiB,MAAM,CACtB,MAAM,EAAE,aAAa,EACrB,WAAW,CAAC,EAAE,UAAU,GACzB,OAAO,CAAC,OAAO,CAAC;IAMnB;;;OAGG;IACI,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB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AAO,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"}
@@ -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, execute_internal } 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.12";
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.
@@ -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.12",
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":""}