@unyt/datex 0.0.7 → 0.0.9

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 (83) hide show
  1. package/esm/_dnt.shims.d.ts +1 -27
  2. package/esm/_dnt.shims.d.ts.map +1 -1
  3. package/esm/_dnt.shims.js +1 -31
  4. package/esm/datex-core/datex_core_js.internal.d.ts +49 -40
  5. package/esm/datex-core/datex_core_js.internal.d.ts.map +1 -1
  6. package/esm/datex-core/datex_core_js.internal.js +143 -125
  7. package/esm/datex-core/datex_core_js.js +13 -16
  8. package/esm/datex-core/datex_core_js.wasm +0 -0
  9. package/esm/datex-core/wasm_url.node.js +1 -0
  10. package/esm/datex-core.d.ts +6 -0
  11. package/esm/datex-core.d.ts.map +1 -1
  12. package/esm/datex-core.js +6 -0
  13. package/esm/default.d.ts +11 -0
  14. package/esm/default.d.ts.map +1 -0
  15. package/esm/default.js +22 -0
  16. package/esm/deno.json +22 -6
  17. package/esm/dif/builders.d.ts +5 -0
  18. package/esm/dif/builders.d.ts.map +1 -1
  19. package/esm/dif/builders.js +5 -0
  20. package/esm/dif/core.d.ts +44 -0
  21. package/esm/dif/core.d.ts.map +1 -0
  22. package/esm/dif/core.js +56 -0
  23. package/esm/dif/definitions.d.ts +43 -36
  24. package/esm/dif/definitions.d.ts.map +1 -1
  25. package/esm/dif/definitions.js +14 -51
  26. package/esm/dif/dif-handler.d.ts +17 -0
  27. package/esm/dif/dif-handler.d.ts.map +1 -1
  28. package/esm/dif/dif-handler.js +22 -5
  29. package/esm/dif/display.d.ts +23 -0
  30. package/esm/dif/display.d.ts.map +1 -1
  31. package/esm/dif/display.js +25 -4
  32. package/esm/dif/mod.d.ts +5 -0
  33. package/esm/dif/mod.d.ts.map +1 -0
  34. package/esm/dif/mod.js +4 -0
  35. package/esm/mod.d.ts +12 -5
  36. package/esm/mod.d.ts.map +1 -1
  37. package/esm/mod.js +10 -23
  38. package/esm/network/com-hub.d.ts +30 -0
  39. package/esm/network/com-hub.d.ts.map +1 -1
  40. package/esm/network/com-hub.js +32 -0
  41. package/esm/network/com-interface.d.ts +18 -0
  42. package/esm/network/com-interface.d.ts.map +1 -1
  43. package/esm/network/com-interface.js +13 -0
  44. package/esm/network/interface-impls/base.d.ts +28 -1
  45. package/esm/network/interface-impls/base.d.ts.map +1 -1
  46. package/esm/network/interface-impls/base.js +30 -4
  47. package/esm/network/interface-impls/websocket-client.d.ts +3 -1
  48. package/esm/network/interface-impls/websocket-client.d.ts.map +1 -1
  49. package/esm/network/interface-impls/websocket-client.js +3 -1
  50. package/esm/network/mod.d.ts +9 -0
  51. package/esm/network/mod.d.ts.map +1 -0
  52. package/esm/network/mod.js +8 -0
  53. package/esm/refs/ref.d.ts +3 -0
  54. package/esm/refs/ref.d.ts.map +1 -1
  55. package/esm/refs/ref.js +3 -0
  56. package/esm/runtime/runtime.d.ts +55 -5
  57. package/esm/runtime/runtime.d.ts.map +1 -1
  58. package/esm/runtime/runtime.js +49 -3
  59. package/esm/runtime/special-core-types.d.ts +18 -2
  60. package/esm/runtime/special-core-types.d.ts.map +1 -1
  61. package/esm/runtime/special-core-types.js +19 -3
  62. package/esm/utils/js-runtime-compat/js-runtime-interface.d.ts +10 -0
  63. package/esm/utils/js-runtime-compat/js-runtime-interface.d.ts.map +1 -0
  64. package/esm/utils/js-runtime-compat/js-runtime-interface.js +1 -0
  65. package/esm/utils/js-runtime-compat/js-runtime.d.ts +18 -0
  66. package/esm/utils/js-runtime-compat/js-runtime.d.ts.map +1 -0
  67. package/esm/utils/js-runtime-compat/js-runtime.js +43 -0
  68. package/esm/utils/js-runtime-compat/runtimes/browser.d.ts +8 -0
  69. package/esm/utils/js-runtime-compat/runtimes/browser.d.ts.map +1 -0
  70. package/esm/utils/js-runtime-compat/runtimes/browser.js +22 -0
  71. package/esm/utils/js-runtime-compat/runtimes/deno.d.ts +8 -0
  72. package/esm/utils/js-runtime-compat/runtimes/deno.d.ts.map +1 -0
  73. package/esm/utils/js-runtime-compat/runtimes/deno.js +19 -0
  74. package/esm/utils/js-runtime-compat/runtimes/node.d.ts +8 -0
  75. package/esm/utils/js-runtime-compat/runtimes/node.d.ts.map +1 -0
  76. package/esm/utils/js-runtime-compat/runtimes/node.js +21 -0
  77. package/package.json +7 -19
  78. package/esm/_dnt.polyfills.d.ts +0 -101
  79. package/esm/_dnt.polyfills.d.ts.map +0 -1
  80. package/esm/_dnt.polyfills.js +0 -127
  81. package/esm/network/interface-impls/websocket-server-deno.d.ts +0 -9
  82. package/esm/network/interface-impls/websocket-server-deno.d.ts.map +0 -1
  83. package/esm/network/interface-impls/websocket-server-deno.js +0 -45
@@ -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
- * properties from #runtime
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,25 +146,26 @@ 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 = Function | Date | RegExp | Map<unknown, unknown> | Set<unknown> | WeakMap<WeakKey, unknown> | WeakSet<WeakKey> | Array<unknown>;
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
- type ObjectFieldOut<T, M extends DIFReferenceMutability> = T extends Ref<infer U> ? M extends typeof DIFReferenceMutability.Final ? Ref<U> : AssignableRef<U> : IsPlainObject<T> extends true ? (ContainsRef<T> extends true ? M extends typeof DIFReferenceMutability.Final ? {
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>;
107
157
  } : {
108
158
  [K in keyof T]: ObjectFieldOut<T[K], M>;
109
159
  } : {
110
160
  readonly [K in keyof T]: ObjectFieldOut<T[K], M>;
111
161
  }) : T;
112
- type PointerOut<V, M extends DIFReferenceMutability> = V extends Ref<infer U> ? M extends typeof DIFReferenceMutability.Final ? Ref<U> : AssignableRef<U> : IsPlainObject<V> extends true ? (ContainsRef<V> extends true ? M extends typeof DIFReferenceMutability.Final ? {
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 ? {
113
163
  readonly [K in keyof V]: ObjectFieldOut<V[K], M>;
114
164
  } : {
115
165
  [K in keyof V]: ObjectFieldOut<V[K], M>;
116
166
  } : {
117
167
  readonly [K in keyof V]: ObjectFieldOut<V[K], M>;
118
- }) : V extends Builtins ? Pointer<V> : M extends typeof DIFReferenceMutability.Final ? Ref<V> : Ref<WidenLiteral<V>>;
168
+ }) : V extends Builtins ? Pointer<V> : M extends typeof DIFReferenceMutability.Immutable ? Ref<V> : Ref<WidenLiteral<V>>;
119
169
  type CollectionProps<T> = {
120
170
  [K in keyof T as K extends "value" ? never : K]: T[K];
121
171
  };
@@ -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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ute_internal, } from "../datex-core.js";
14
14
  import { ComHub } from "../network/com-hub.js";
15
15
  import { DIFHandler } from "../dif/dif-handler.js";
16
- // auto-generated version - do not edit:
17
- const VERSION = "0.0.7";
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
- * properties from #runtime
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
- import * as dntShim from "../_dnt.shims.js";
1
+ /**
2
+ * Endpoint class representing a unique communication endpoint in the Datex runtime.
3
+ */
2
4
  export declare class Endpoint {
3
5
  #private;
4
- static endpoints: Map<string, dntShim.WeakRef<Endpoint>>;
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,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,qBAAa,QAAQ;;IAIjB,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAa;IAErE,OAAO;WAKO,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;WASnC,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ;IAatC,QAAQ,IAAI,MAAM;CAG5B"}
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
- import * as dntShim from "../_dnt.shims.js";
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 dntShim.WeakRef(endpoint);
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
- // map with weak values that keeps track of all currently instantiated endpoints
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,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;AAgBD,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"}
@@ -0,0 +1,22 @@
1
+ export default class BrowserRuntimeInterface {
2
+ constructor() {
3
+ Object.defineProperty(this, "type", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: "browser"
8
+ });
9
+ }
10
+ async readTextFile(path) {
11
+ const response = await fetch(path.toString());
12
+ return await response.text();
13
+ }
14
+ async readFile(path) {
15
+ const response = await fetch(path.toString());
16
+ const buffer = await response.arrayBuffer();
17
+ return new Uint8Array(buffer);
18
+ }
19
+ instantiateWebAssembly(path, importObject) {
20
+ return WebAssembly.instantiateStreaming(fetch(path), importObject);
21
+ }
22
+ }
@@ -0,0 +1,8 @@
1
+ import type { JsRuntimeInterface } from "../js-runtime-interface.js";
2
+ export default class DenoRuntimeInterface implements JsRuntimeInterface {
3
+ readonly type = "deno";
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=deno.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deno.d.ts","sourceRoot":"","sources":["../../../../src/utils/js-runtime-compat/runtimes/deno.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,CAAC,OAAO,OAAO,oBAAqB,YAAW,kBAAkB;IACnE,QAAQ,CAAC,IAAI,UAAU;IAEvB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAIjD,sBAAsB,CAClB,IAAI,EAAE,GAAG,EACT,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,GACnC,OAAO,CAAC,WAAW,CAAC,6BAA6B,CAAC;CAGxD"}
@@ -0,0 +1,19 @@
1
+ export default class DenoRuntimeInterface {
2
+ constructor() {
3
+ Object.defineProperty(this, "type", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: "deno"
8
+ });
9
+ }
10
+ readTextFile(path) {
11
+ return Deno.readTextFile(path);
12
+ }
13
+ readFile(path) {
14
+ return Deno.readFile(path);
15
+ }
16
+ instantiateWebAssembly(path, importObject) {
17
+ return WebAssembly.instantiateStreaming(fetch(path), importObject);
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ import type { JsRuntimeInterface } from "../js-runtime-interface.js";
2
+ export default class NodeRuntimeInterface implements JsRuntimeInterface {
3
+ readonly type = "node";
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=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/utils/js-runtime-compat/runtimes/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,MAAM,CAAC,OAAO,OAAO,oBAAqB,YAAW,kBAAkB;IACnE,QAAQ,CAAC,IAAI,UAAU;IAEvB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAI3C,sBAAsB,CACxB,IAAI,EAAE,GAAG,EACT,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,GACnC,OAAO,CAAC,WAAW,CAAC,6BAA6B,CAAC;CAIxD"}
@@ -0,0 +1,21 @@
1
+ import * as fs from "node:fs/promises";
2
+ export default class NodeRuntimeInterface {
3
+ constructor() {
4
+ Object.defineProperty(this, "type", {
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true,
8
+ value: "node"
9
+ });
10
+ }
11
+ readTextFile(path) {
12
+ return fs.readFile(path, { encoding: "utf-8" });
13
+ }
14
+ readFile(path) {
15
+ return fs.readFile(path);
16
+ }
17
+ async instantiateWebAssembly(path, importObject) {
18
+ const file = await fs.readFile(path);
19
+ return (await WebAssembly.instantiate(file, importObject));
20
+ }
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unyt/datex",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/unyt-org/datex-core-js.git"
@@ -14,28 +14,16 @@
14
14
  ".": {
15
15
  "import": "./esm/mod.js"
16
16
  },
17
- "./src/network/interface-impls/websocket-client.js": {
18
- "import": "./esm/network/interface-impls/websocket-client.js"
19
- },
20
- "./src/network/interface-impls/websocket-server-deno.js": {
21
- "import": "./esm/network/interface-impls/websocket-server-deno.js"
17
+ "./default": {
18
+ "import": "./esm/default.js"
22
19
  },
23
- "./src/network/interface-impls/base.js": {
20
+ "./interface-impls/base": {
24
21
  "import": "./esm/network/interface-impls/base.js"
22
+ },
23
+ "./interface-impls/websocket-client": {
24
+ "import": "./esm/network/interface-impls/websocket-client.js"
25
25
  }
26
26
  },
27
27
  "scripts": {},
28
- "dependencies": {
29
- "@deno/shim-deno": "~0.18.0",
30
- "@deno/shim-crypto": "~0.3.1",
31
- "@deno/shim-prompts": "~0.1.0",
32
- "@deno/shim-timers": "~0.1.0",
33
- "undici": "^6.0.0",
34
- "@deno/sham-weakref": "~0.1.0",
35
- "ws": "^8.13.0"
36
- },
37
- "devDependencies": {
38
- "@types/node": "^20.9.0"
39
- },
40
28
  "_generatedBy": "dnt@dev"
41
29
  }