@unyt/datex 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_dnt.shims.d.ts +1 -27
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +1 -31
- package/esm/datex-core/datex_core_js.internal.d.ts +53 -44
- package/esm/datex-core/datex_core_js.internal.d.ts.map +1 -1
- package/esm/datex-core/datex_core_js.internal.js +164 -146
- package/esm/datex-core/datex_core_js.js +16 -15
- package/esm/datex-core/datex_core_js.wasm +0 -0
- package/esm/datex-core/wasm_url.node.js +1 -0
- package/esm/datex-core.d.ts +6 -0
- package/esm/datex-core.d.ts.map +1 -1
- package/esm/datex-core.js +6 -0
- package/esm/default.d.ts +8 -1
- package/esm/default.d.ts.map +1 -1
- package/esm/default.js +8 -1
- package/esm/deno.json +3 -2
- package/esm/dif/builders.d.ts +5 -0
- package/esm/dif/builders.d.ts.map +1 -1
- package/esm/dif/builders.js +5 -0
- package/esm/dif/core.d.ts +9 -0
- package/esm/dif/core.d.ts.map +1 -1
- package/esm/dif/core.js +6 -0
- package/esm/dif/definitions.d.ts +43 -1
- package/esm/dif/definitions.d.ts.map +1 -1
- package/esm/dif/definitions.js +14 -0
- package/esm/dif/dif-handler.d.ts +17 -0
- package/esm/dif/dif-handler.d.ts.map +1 -1
- package/esm/dif/dif-handler.js +18 -2
- package/esm/dif/display.d.ts +23 -0
- package/esm/dif/display.d.ts.map +1 -1
- package/esm/dif/display.js +23 -0
- package/esm/dif/mod.d.ts +5 -0
- package/esm/dif/mod.d.ts.map +1 -1
- package/esm/dif/mod.js +5 -0
- package/esm/mod.d.ts +16 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +16 -1
- package/esm/network/com-hub.d.ts +30 -0
- package/esm/network/com-hub.d.ts.map +1 -1
- package/esm/network/com-hub.js +32 -0
- package/esm/network/com-interface.d.ts +18 -0
- package/esm/network/com-interface.d.ts.map +1 -1
- package/esm/network/com-interface.js +13 -0
- package/esm/network/interface-impls/base.d.ts +36 -1
- package/esm/network/interface-impls/base.d.ts.map +1 -1
- package/esm/network/interface-impls/base.js +27 -1
- package/esm/network/interface-impls/websocket-client.d.ts +3 -1
- package/esm/network/interface-impls/websocket-client.d.ts.map +1 -1
- package/esm/network/interface-impls/websocket-client.js +3 -1
- package/esm/network/mod.d.ts +6 -0
- package/esm/network/mod.d.ts.map +1 -1
- package/esm/network/mod.js +6 -0
- package/esm/refs/ref.d.ts +3 -0
- package/esm/refs/ref.d.ts.map +1 -1
- package/esm/refs/ref.js +3 -0
- package/esm/runtime/runtime.d.ts +52 -2
- package/esm/runtime/runtime.d.ts.map +1 -1
- package/esm/runtime/runtime.js +49 -3
- package/esm/runtime/special-core-types.d.ts +18 -2
- package/esm/runtime/special-core-types.d.ts.map +1 -1
- package/esm/runtime/special-core-types.js +19 -3
- package/esm/utils/js-runtime-compat/js-runtime-interface.d.ts +10 -0
- package/esm/utils/js-runtime-compat/js-runtime-interface.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/js-runtime-interface.js +1 -0
- package/esm/utils/js-runtime-compat/js-runtime.d.ts +18 -0
- package/esm/utils/js-runtime-compat/js-runtime.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/js-runtime.js +43 -0
- package/esm/utils/js-runtime-compat/runtimes/browser.d.ts +8 -0
- package/esm/utils/js-runtime-compat/runtimes/browser.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/runtimes/browser.js +22 -0
- package/esm/utils/js-runtime-compat/runtimes/deno.d.ts +8 -0
- package/esm/utils/js-runtime-compat/runtimes/deno.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/runtimes/deno.js +19 -0
- package/esm/utils/js-runtime-compat/runtimes/node.d.ts +8 -0
- package/esm/utils/js-runtime-compat/runtimes/node.d.ts.map +1 -0
- package/esm/utils/js-runtime-compat/runtimes/node.js +21 -0
- package/package.json +1 -22
- package/esm/_dnt.polyfills.d.ts +0 -101
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -127
- package/esm/network/interface-impls/serial.d.ts +0 -6
- package/esm/network/interface-impls/serial.d.ts.map +0 -1
- package/esm/network/interface-impls/serial.js +0 -6
- package/esm/network/interface-impls/webrtc.d.ts +0 -12
- package/esm/network/interface-impls/webrtc.d.ts.map +0 -1
- package/esm/network/interface-impls/webrtc.js +0 -24
- package/esm/network/interface-impls/websocket-server-deno.d.ts +0 -9
- package/esm/network/interface-impls/websocket-server-deno.d.ts.map +0 -1
- package/esm/network/interface-impls/websocket-server-deno.js +0 -45
package/esm/dif/definitions.d.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains all definitions related to the DIF (DATEX Interchange Format) interfaces of the DATEX runtime.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A DATEX pointer address representation in the DIF format.
|
|
8
|
+
* (3, 5, or 26 byte hex string)
|
|
9
|
+
*/
|
|
2
10
|
export type DIFPointerAddress = string;
|
|
11
|
+
/**
|
|
12
|
+
* A DATEX value representation in the DIF format,
|
|
13
|
+
* which may optionally include type information.
|
|
14
|
+
*/
|
|
3
15
|
export type DIFValue = {
|
|
4
16
|
type?: DIFTypeContainer;
|
|
5
17
|
value: DIFRepresentationValue;
|
|
6
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* A DATEX value or pointer address representation in the DIF format.
|
|
21
|
+
*/
|
|
7
22
|
export type DIFContainer = DIFValue | DIFPointerAddress;
|
|
23
|
+
/**
|
|
24
|
+
* Mapping of DIF type kinds.
|
|
25
|
+
*/
|
|
8
26
|
export declare const DIFTypeKinds: {
|
|
9
27
|
readonly Structural: 0;
|
|
10
28
|
readonly Reference: 1;
|
|
@@ -13,30 +31,47 @@ export declare const DIFTypeKinds: {
|
|
|
13
31
|
readonly Unit: 4;
|
|
14
32
|
readonly Function: 5;
|
|
15
33
|
};
|
|
34
|
+
/** A DIF type kind. */
|
|
16
35
|
export type DIFTypeKind = typeof DIFTypeKinds[keyof typeof DIFTypeKinds];
|
|
36
|
+
/**
|
|
37
|
+
* Representation of reference mutability (mutable or immutable) in DIF.
|
|
38
|
+
*/
|
|
17
39
|
export declare const DIFReferenceMutability: {
|
|
18
40
|
readonly Mutable: 0;
|
|
19
41
|
readonly Immutable: 1;
|
|
20
42
|
};
|
|
43
|
+
/** A DIF reference mutability. */
|
|
21
44
|
export type DIFReferenceMutability = typeof DIFReferenceMutability[keyof typeof DIFReferenceMutability];
|
|
45
|
+
/** A DIF type definition based on its kind. */
|
|
22
46
|
export type DIFTypeDefinition<Kind extends DIFTypeKind = DIFTypeKind> = Kind extends typeof DIFTypeKinds.Structural ? DIFValue : Kind extends typeof DIFTypeKinds.Reference ? DIFPointerAddress : Kind extends typeof DIFTypeKinds.Intersection ? Array<DIFTypeContainer> : Kind extends typeof DIFTypeKinds.Union ? Array<DIFTypeContainer> : Kind extends typeof DIFTypeKinds.Unit ? null : Kind extends typeof DIFTypeKinds.Function ? unknown : never;
|
|
47
|
+
/** A DIF type representation. */
|
|
23
48
|
export type DIFType<Kind extends DIFTypeKind = DIFTypeKind> = {
|
|
24
49
|
name?: string;
|
|
25
50
|
kind: Kind;
|
|
26
51
|
def: DIFTypeDefinition<Kind>;
|
|
27
52
|
mut?: DIFReferenceMutability;
|
|
28
53
|
};
|
|
54
|
+
/** A representation of a reference in DIF. */
|
|
29
55
|
export type DIFReference = {
|
|
30
56
|
value: DIFValueContainer;
|
|
31
57
|
allowed_type: DIFTypeContainer;
|
|
32
58
|
mut: DIFReferenceMutability;
|
|
33
59
|
};
|
|
60
|
+
/** A representation of a value or pointer address in DIF. */
|
|
34
61
|
export type DIFValueContainer = DIFValue | DIFPointerAddress;
|
|
62
|
+
/** A representation of a type or type pointer address in DIF. */
|
|
35
63
|
export type DIFTypeContainer = DIFType | DIFPointerAddress;
|
|
64
|
+
/** A DIF object, mapping string keys to DIF value containers. */
|
|
36
65
|
export type DIFObject = Record<string, DIFValueContainer>;
|
|
66
|
+
/** A DIF array, containing DIF value containers. */
|
|
37
67
|
export type DIFArray = DIFValueContainer[];
|
|
68
|
+
/** A DIF map, containing key-value pairs of DIF value containers. */
|
|
38
69
|
export type DIFMap = [DIFValueContainer, DIFValueContainer][];
|
|
70
|
+
/** Any DIF representation value (JSON-compatible values). */
|
|
39
71
|
export type DIFRepresentationValue = string | number | boolean | null | DIFObject | DIFMap | DIFArray;
|
|
72
|
+
/**
|
|
73
|
+
* Representation of a property in DIF, which can be a text key, an index, or a generic value.
|
|
74
|
+
*/
|
|
40
75
|
export type DIFProperty = {
|
|
41
76
|
kind: "text";
|
|
42
77
|
value: string;
|
|
@@ -47,6 +82,9 @@ export type DIFProperty = {
|
|
|
47
82
|
kind: "value";
|
|
48
83
|
value: DIFValueContainer;
|
|
49
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Kinds of updates that can be applied to a DIF value.
|
|
87
|
+
*/
|
|
50
88
|
export declare const DIFUpdateKind: {
|
|
51
89
|
readonly Replace: "replace";
|
|
52
90
|
readonly Push: "push";
|
|
@@ -54,7 +92,9 @@ export declare const DIFUpdateKind: {
|
|
|
54
92
|
readonly Remove: "remove";
|
|
55
93
|
readonly Clear: "clear";
|
|
56
94
|
};
|
|
95
|
+
/** A DIF update kind. */
|
|
57
96
|
export type DIFUpdateKind = typeof DIFUpdateKind[keyof typeof DIFUpdateKind];
|
|
97
|
+
/** Different kinds of updates that can be applied to a DIF value. */
|
|
58
98
|
export type DIFUpdateData = {
|
|
59
99
|
kind: typeof DIFUpdateKind.Replace;
|
|
60
100
|
value: DIFValueContainer;
|
|
@@ -71,10 +111,12 @@ export type DIFUpdateData = {
|
|
|
71
111
|
} | {
|
|
72
112
|
kind: typeof DIFUpdateKind.Clear;
|
|
73
113
|
};
|
|
114
|
+
/** A DIF update struct, associating a source ID with update data. */
|
|
74
115
|
export type DIFUpdate = {
|
|
75
116
|
source_id: number;
|
|
76
117
|
data: DIFUpdateData;
|
|
77
118
|
};
|
|
119
|
+
/** Options for observing DIF pointers. */
|
|
78
120
|
export type ObserveOptions = {
|
|
79
121
|
relay_own_updates: boolean;
|
|
80
122
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/dif/definitions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/dif/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACvC;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,sBAAsB,CAAC;CACjC,CAAC;AACF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;CAOf,CAAC;AACX,uBAAuB;AACvB,MAAM,MAAM,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;CAGzB,CAAC;AACX,kCAAkC;AAClC,MAAM,MAAM,sBAAsB,GAC9B,OAAO,sBAAsB,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAEvE,+CAA+C;AAC/C,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,WAAW,GAAG,WAAW,IAChE,IAAI,SAAS,OAAO,YAAY,CAAC,UAAU,GAAG,QAAQ,GAChD,IAAI,SAAS,OAAO,YAAY,CAAC,SAAS,GAAG,iBAAiB,GAC9D,IAAI,SAAS,OAAO,YAAY,CAAC,YAAY,GACzC,KAAK,CAAC,gBAAgB,CAAC,GAC3B,IAAI,SAAS,OAAO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;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AACX,yBAAyB;AACzB,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E,qEAAqE;AACrE,MAAM,MAAM,aAAa,GACnB;IAAE,IAAI,EAAE,OAAO,aAAa,CAAC,OAAO,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,OAAO,aAAa,CAAC,IAAI,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,OAAO,aAAa,CAAC,MAAM,CAAC;IAAC,GAAG,EAAE,WAAW,CAAA;CAAE,GACvD;IACE,IAAI,EAAE,OAAO,aAAa,CAAC,GAAG,CAAC;IAC/B,GAAG,EAAE,WAAW,CAAC;IACjB,KAAK,EAAE,iBAAiB,CAAC;CAC5B,GACC;IAAE,IAAI,EAAE,OAAO,aAAa,CAAC,KAAK,CAAA;CAAE,CAAC;AAE3C,qEAAqE;AACrE,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GAAG;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC9B,CAAC"}
|
package/esm/dif/definitions.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains all definitions related to the DIF (DATEX Interchange Format) interfaces of the DATEX runtime.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Mapping of DIF type kinds.
|
|
8
|
+
*/
|
|
1
9
|
export const DIFTypeKinds = {
|
|
2
10
|
Structural: 0,
|
|
3
11
|
Reference: 1,
|
|
@@ -6,10 +14,16 @@ export const DIFTypeKinds = {
|
|
|
6
14
|
Unit: 4,
|
|
7
15
|
Function: 5,
|
|
8
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Representation of reference mutability (mutable or immutable) in DIF.
|
|
19
|
+
*/
|
|
9
20
|
export const DIFReferenceMutability = {
|
|
10
21
|
Mutable: 0,
|
|
11
22
|
Immutable: 1,
|
|
12
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Kinds of updates that can be applied to a DIF value.
|
|
26
|
+
*/
|
|
13
27
|
export const DIFUpdateKind = {
|
|
14
28
|
Replace: "replace",
|
|
15
29
|
Push: "push",
|
package/esm/dif/dif-handler.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import type { JSRuntime, RuntimeDIFHandle } from "../datex-core.js";
|
|
2
2
|
import { Ref } from "../refs/ref.js";
|
|
3
3
|
import { type DIFContainer, type DIFPointerAddress, DIFReferenceMutability, type DIFTypeContainer, type DIFUpdate, type DIFUpdateData, type DIFValue, type DIFValueContainer, type ObserveOptions } from "./definitions.js";
|
|
4
|
+
/**
|
|
5
|
+
* The DIFHandler class provides methods to interact with the DATEX Core DIF runtime,
|
|
6
|
+
* including executing Datex scripts, creating and managing pointers, and observing changes.
|
|
7
|
+
* It includes a local pointer cache to optimize performance and reduce cross-language calls.
|
|
8
|
+
*/
|
|
4
9
|
export declare class DIFHandler {
|
|
5
10
|
#private;
|
|
11
|
+
/**
|
|
12
|
+
* Internal property
|
|
13
|
+
* @returns The map of observers for each pointer address.
|
|
14
|
+
*/
|
|
6
15
|
get _observers(): Map<string, Map<number, (value: DIFUpdateData) => void>>;
|
|
16
|
+
/**
|
|
17
|
+
* Internal property
|
|
18
|
+
* @returns The RuntimeDIFHandle instance.
|
|
19
|
+
*/
|
|
7
20
|
get _handle(): RuntimeDIFHandle;
|
|
21
|
+
/**
|
|
22
|
+
* Internal property
|
|
23
|
+
* @returns The transceiver ID of the DIF client.
|
|
24
|
+
*/
|
|
8
25
|
get _transceiver_id(): number;
|
|
9
26
|
/**
|
|
10
27
|
* Creates a new DIFHandler instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dif-handler.d.ts","sourceRoot":"","sources":["../../src/dif/dif-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dif-handler.d.ts","sourceRoot":"","sources":["../../src/dif/dif-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAEH,KAAK,YAAY,EAGjB,KAAK,iBAAiB,EAGtB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,aAAa,EAElB,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACtB,MAAM,kBAAkB,CAAC;AAI1B;;;;GAIG;AACH,qBAAa,UAAU;;IAqBnB;;;OAGG;IACH,IAAI,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC,CAEzE;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,gBAAgB,CAE9B;IAED;;;OAGG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED;;;;OAIG;gBAEC,OAAO,EAAE,SAAS;IAMtB;;;;;;OAMG;IACI,UAAU,CACb,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,OAAO,EAAE,GAAG,IAAS,GAC9B,OAAO,CAAC,YAAY,CAAC;IAOxB;;;;;;OAMG;IACI,cAAc,CACjB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,OAAO,EAAE,GAAG,IA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ivateFieldSet) || function (
|
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
12
|
var _DIFHandler_runtime, _DIFHandler_handle, _DIFHandler_transceiver_id, _DIFHandler_cache, _DIFHandler_observers;
|
|
13
|
-
import * as dntShim from "../_dnt.shims.js";
|
|
14
13
|
import { Ref } from "../refs/ref.js";
|
|
15
14
|
import { Endpoint } from "../runtime/special-core-types.js";
|
|
16
15
|
import { DIFReferenceMutability, DIFUpdateKind, } from "./definitions.js";
|
|
17
16
|
import { CoreTypeAddress, CoreTypeAddressRanges } from "./core.js";
|
|
18
17
|
import { difValueContainerToDisplayString } from "./display.js";
|
|
18
|
+
/**
|
|
19
|
+
* The DIFHandler class provides methods to interact with the DATEX Core DIF runtime,
|
|
20
|
+
* including executing Datex scripts, creating and managing pointers, and observing changes.
|
|
21
|
+
* It includes a local pointer cache to optimize performance and reduce cross-language calls.
|
|
22
|
+
*/
|
|
19
23
|
export class DIFHandler {
|
|
24
|
+
/**
|
|
25
|
+
* Internal property
|
|
26
|
+
* @returns The map of observers for each pointer address.
|
|
27
|
+
*/
|
|
20
28
|
get _observers() {
|
|
21
29
|
return __classPrivateFieldGet(this, _DIFHandler_observers, "f");
|
|
22
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Internal property
|
|
33
|
+
* @returns The RuntimeDIFHandle instance.
|
|
34
|
+
*/
|
|
23
35
|
get _handle() {
|
|
24
36
|
return __classPrivateFieldGet(this, _DIFHandler_handle, "f");
|
|
25
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Internal property
|
|
40
|
+
* @returns The transceiver ID of the DIF client.
|
|
41
|
+
*/
|
|
26
42
|
get _transceiver_id() {
|
|
27
43
|
return __classPrivateFieldGet(this, _DIFHandler_transceiver_id, "f");
|
|
28
44
|
}
|
|
@@ -468,7 +484,7 @@ export class DIFHandler {
|
|
|
468
484
|
*/
|
|
469
485
|
cacheWrappedPointerValue(address, value, observerId) {
|
|
470
486
|
__classPrivateFieldGet(this, _DIFHandler_cache, "f").set(address, {
|
|
471
|
-
val: new
|
|
487
|
+
val: new WeakRef(value),
|
|
472
488
|
observerId,
|
|
473
489
|
});
|
|
474
490
|
// register finalizer to clean up the cache and free the pointer in the runtime
|
package/esm/dif/display.d.ts
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains helper functions to convert DIF structures to display strings.
|
|
5
|
+
*/
|
|
1
6
|
import { type DIFReference, DIFReferenceMutability, type DIFRepresentationValue, type DIFTypeContainer, type DIFValueContainer } from "./definitions.js";
|
|
7
|
+
/**
|
|
8
|
+
* Converts a DIF reference mutability to a display string.
|
|
9
|
+
*/
|
|
2
10
|
export declare function mutabilityToDisplayString(mut: DIFReferenceMutability): string;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a DIF reference to a display string.
|
|
13
|
+
*/
|
|
3
14
|
export declare function difReferenceToDisplayString(reference: DIFReference): string;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a DIF value container to a display string.
|
|
17
|
+
*/
|
|
4
18
|
export declare function difValueContainerToDisplayString(container: DIFValueContainer): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a DIF representation value to a display string.
|
|
21
|
+
*/
|
|
5
22
|
export declare function difRepresentationValueToDisplayString(difRepValue: DIFRepresentationValue): string;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a DIF type container to a display string.
|
|
25
|
+
*/
|
|
6
26
|
export declare function difTypeContainerToDisplayString(difType: DIFTypeContainer): string;
|
|
27
|
+
/**
|
|
28
|
+
* Converts a core type address to a display string.
|
|
29
|
+
*/
|
|
7
30
|
export declare function addressToDisplayString(address: string): string;
|
|
8
31
|
//# sourceMappingURL=display.d.ts.map
|
package/esm/dif/display.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/dif/display.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,YAAY,EACjB,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACzB,MAAM,kBAAkB,CAAC;AAG1B,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM,CAO7E;AAED,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,YAAY,GACxB,MAAM,CAKR;AAED,wBAAgB,gCAAgC,CAC5C,SAAS,EAAE,iBAAiB,GAC7B,MAAM,CAgBR;AAED,wBAAgB,qCAAqC,CACjD,WAAW,EAAE,sBAAsB,GACpC,MAAM,CAyBR;AAED,wBAAgB,+BAA+B,CAC3C,OAAO,EAAE,gBAAgB,GAC1B,MAAM,CAQR;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAS9D"}
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/dif/display.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACH,KAAK,YAAY,EACjB,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACzB,MAAM,kBAAkB,CAAC;AAG1B;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM,CAO7E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,YAAY,GACxB,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC5C,SAAS,EAAE,iBAAiB,GAC7B,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CACjD,WAAW,EAAE,sBAAsB,GACpC,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC3C,OAAO,EAAE,gBAAgB,GAC1B,MAAM,CAQR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAS9D"}
|
package/esm/dif/display.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains helper functions to convert DIF structures to display strings.
|
|
5
|
+
*/
|
|
1
6
|
import { DIFReferenceMutability, } from "./definitions.js";
|
|
2
7
|
import { CoreTypeAddress } from "./core.js";
|
|
8
|
+
/**
|
|
9
|
+
* Converts a DIF reference mutability to a display string.
|
|
10
|
+
*/
|
|
3
11
|
export function mutabilityToDisplayString(mut) {
|
|
4
12
|
if (mut === DIFReferenceMutability.Mutable) {
|
|
5
13
|
return "&mut ";
|
|
@@ -9,12 +17,18 @@ export function mutabilityToDisplayString(mut) {
|
|
|
9
17
|
}
|
|
10
18
|
throw new Error("Unknown mutability: " + mut);
|
|
11
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts a DIF reference to a display string.
|
|
22
|
+
*/
|
|
12
23
|
export function difReferenceToDisplayString(reference) {
|
|
13
24
|
const typeString = difTypeContainerToDisplayString(reference.allowed_type);
|
|
14
25
|
const valueString = difValueContainerToDisplayString(reference.value);
|
|
15
26
|
const mutString = mutabilityToDisplayString(reference.mut);
|
|
16
27
|
return `${mutString}${valueString} (allowed: ${typeString})`;
|
|
17
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Converts a DIF value container to a display string.
|
|
31
|
+
*/
|
|
18
32
|
export function difValueContainerToDisplayString(container) {
|
|
19
33
|
if (typeof container === "string") {
|
|
20
34
|
return addressToDisplayString(container);
|
|
@@ -32,6 +46,9 @@ export function difValueContainerToDisplayString(container) {
|
|
|
32
46
|
}
|
|
33
47
|
}
|
|
34
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Converts a DIF representation value to a display string.
|
|
51
|
+
*/
|
|
35
52
|
export function difRepresentationValueToDisplayString(difRepValue) {
|
|
36
53
|
if (Array.isArray(difRepValue)) {
|
|
37
54
|
return `[${difRepValue.map((v) => {
|
|
@@ -51,6 +68,9 @@ export function difRepresentationValueToDisplayString(difRepValue) {
|
|
|
51
68
|
return JSON.stringify(difRepValue);
|
|
52
69
|
}
|
|
53
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Converts a DIF type container to a display string.
|
|
73
|
+
*/
|
|
54
74
|
export function difTypeContainerToDisplayString(difType) {
|
|
55
75
|
if (typeof difType === "string") {
|
|
56
76
|
return addressToDisplayString(difType);
|
|
@@ -59,6 +79,9 @@ export function difTypeContainerToDisplayString(difType) {
|
|
|
59
79
|
return `{ name: ${difType.name}, kind: ${difType.kind}, def: ${JSON.stringify(difType.def)}, mut: ${difType.mut} }`;
|
|
60
80
|
}
|
|
61
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Converts a core type address to a display string.
|
|
84
|
+
*/
|
|
62
85
|
export function addressToDisplayString(address) {
|
|
63
86
|
const found = Object.entries(CoreTypeAddress).find(([_, addr]) => {
|
|
64
87
|
return addr === address;
|
package/esm/dif/mod.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module dif/mod.ts
|
|
3
|
+
* @description
|
|
4
|
+
* This namespace contains all modules related to the DIF (DATEX Interchange Format) interfaces of the DATEX runtime.
|
|
5
|
+
*/
|
|
1
6
|
export * as Definitions from "./definitions.js";
|
|
2
7
|
export * as Builders from "./builders.js";
|
|
3
8
|
export * as Display from "./display.js";
|
package/esm/dif/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/dif/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/dif/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
package/esm/dif/mod.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module dif/mod.ts
|
|
3
|
+
* @description
|
|
4
|
+
* This namespace contains all modules related to the DIF (DATEX Interchange Format) interfaces of the DATEX runtime.
|
|
5
|
+
*/
|
|
1
6
|
export * as Definitions from "./definitions.js";
|
|
2
7
|
export * as Builders from "./builders.js";
|
|
3
8
|
export * as Display from "./display.js";
|
package/esm/mod.d.ts
CHANGED
|
@@ -2,8 +2,23 @@
|
|
|
2
2
|
* @module mod.ts
|
|
3
3
|
* @description
|
|
4
4
|
* This module exports all public APIs of the DATEX runtime.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Runtime } from "@unyt/datex";
|
|
9
|
+
*
|
|
10
|
+
* // Create a runtime instance
|
|
11
|
+
* export const runtime: Runtime = await Runtime.create({
|
|
12
|
+
* interfaces: [{
|
|
13
|
+
* type: "websocket-client",
|
|
14
|
+
* config: { address: "wss://example.unyt.land" },
|
|
15
|
+
* }],
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Use the runtime instance
|
|
19
|
+
* const result = await runtime.execute("@example :: 1 + 2");
|
|
20
|
+
* ```
|
|
5
21
|
*/
|
|
6
|
-
import "./_dnt.polyfills.js";
|
|
7
22
|
export * from "./runtime/runtime.js";
|
|
8
23
|
export * as DIF from "./dif/mod.js";
|
|
9
24
|
export * as Network from "./network/mod.js";
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,qBAAqB,CAAC;AAG7B,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -2,8 +2,23 @@
|
|
|
2
2
|
* @module mod.ts
|
|
3
3
|
* @description
|
|
4
4
|
* This module exports all public APIs of the DATEX runtime.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Runtime } from "@unyt/datex";
|
|
9
|
+
*
|
|
10
|
+
* // Create a runtime instance
|
|
11
|
+
* export const runtime: Runtime = await Runtime.create({
|
|
12
|
+
* interfaces: [{
|
|
13
|
+
* type: "websocket-client",
|
|
14
|
+
* config: { address: "wss://example.unyt.land" },
|
|
15
|
+
* }],
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Use the runtime instance
|
|
19
|
+
* const result = await runtime.execute("@example :: 1 + 2");
|
|
20
|
+
* ```
|
|
5
21
|
*/
|
|
6
|
-
import "./_dnt.polyfills.js";
|
|
7
22
|
export * from "./runtime/runtime.js";
|
|
8
23
|
export * as DIF from "./dif/mod.js";
|
|
9
24
|
export * as Network from "./network/mod.js";
|
package/esm/network/com-hub.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import type { JSComHub } from "../datex-core/datex_core_js";
|
|
2
2
|
import { ComInterface, type ComInterfaceImpl } from "./com-interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* Communication hub for managing communication interfaces.
|
|
5
|
+
*/
|
|
3
6
|
export declare class ComHub {
|
|
4
7
|
#private;
|
|
5
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
|
+
*/
|
|
6
14
|
static registerInterfaceImpl<N extends string>(interfaceType: N, impl: typeof ComInterfaceImpl<unknown>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new communication interface.
|
|
17
|
+
* @param interfaceType The type of the interface to create.
|
|
18
|
+
* @param setupData The setup data for the interface.
|
|
19
|
+
*/
|
|
7
20
|
createInterface<T extends typeof ComInterfaceImpl<unknown>>(interfaceType: T, setupData: T extends typeof ComInterfaceImpl<infer P> ? P : never): Promise<ComInterface<InstanceType<T>>>;
|
|
8
21
|
createInterface<T extends ComInterfaceImpl<unknown>>(interfaceType: string, setupData: T extends ComInterfaceImpl<infer P> ? P : never): Promise<ComInterface<T>>;
|
|
9
22
|
_update(): Promise<void>;
|
|
@@ -17,6 +30,23 @@ export declare class ComHub {
|
|
|
17
30
|
* @param endpoint The endpoint for which to print the trace.
|
|
18
31
|
*/
|
|
19
32
|
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
|
+
*/
|
|
20
40
|
sendBlock(block: Uint8Array, interface_uuid: string, socket_uuid: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Registers a callback to intercept incoming blocks.
|
|
43
|
+
* @param callback The callback to be invoked for each incoming block.
|
|
44
|
+
*/
|
|
45
|
+
registerIncomingBlockInterceptor(callback: (block: Uint8Array, socket_uuid: string) => void): void;
|
|
46
|
+
/**
|
|
47
|
+
* Registers a callback to intercept outgoing blocks.
|
|
48
|
+
* @param callback The callback to be invoked for each outgoing block.
|
|
49
|
+
*/
|
|
50
|
+
registerOutgoingBlockInterceptor(callback: (block: Uint8Array, socket_uuid: string, endpoints: string[]) => void): void;
|
|
21
51
|
}
|
|
22
52
|
//# sourceMappingURL=com-hub.d.ts.map
|
|
@@ -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,qBAAa,MAAM;;
|
|
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,SAAS,EAAE,CAAC,SAAS,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,GAClE,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,eAAe,CACjB,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAEnC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,CAAC,SAAS,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,GAC3D,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAkCpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,sBAAsB,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE;IAI9D;;OAEG;IACI,aAAa,IAAI,IAAI;IAO5B;;;OAGG;IACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxD;;;;;;OAMG;IACI,SAAS,CACZ,KAAK,EAAE,UAAU,EACjB,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC;IAInB;;;OAGG;IACI,gCAAgC,CACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,GAC3D,IAAI;IAIP;;;OAGG;IACI,gCAAgC,CACnC,QAAQ,EAAE,CACN,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,KAClB,IAAI,GACV,IAAI;CAGV"}
|
package/esm/network/com-hub.js
CHANGED
|
@@ -11,11 +11,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _a, _ComHub_interfaceImpls, _ComHub_interfaceImplsByClass, _ComHub_jsComHub;
|
|
13
13
|
import { ComInterface } from "./com-interface.js";
|
|
14
|
+
/**
|
|
15
|
+
* Communication hub for managing communication interfaces.
|
|
16
|
+
*/
|
|
14
17
|
export class ComHub {
|
|
15
18
|
constructor(jsComHub) {
|
|
19
|
+
/** The JS communication hub. */
|
|
16
20
|
_ComHub_jsComHub.set(this, void 0);
|
|
17
21
|
__classPrivateFieldSet(this, _ComHub_jsComHub, jsComHub, "f");
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Registers a communication interface implementation.
|
|
25
|
+
* @param interfaceType The type of the interface.
|
|
26
|
+
* @param impl The implementation class of the interface.
|
|
27
|
+
*/
|
|
19
28
|
static registerInterfaceImpl(interfaceType, impl) {
|
|
20
29
|
if (__classPrivateFieldGet(this, _a, "f", _ComHub_interfaceImpls).has(interfaceType)) {
|
|
21
30
|
throw new Error(`Interface implementation for ${interfaceType} already registered.`);
|
|
@@ -68,10 +77,33 @@ export class ComHub {
|
|
|
68
77
|
}
|
|
69
78
|
console.log(trace);
|
|
70
79
|
}
|
|
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
|
+
*/
|
|
71
87
|
sendBlock(block, interface_uuid, socket_uuid) {
|
|
72
88
|
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").send_block(block, interface_uuid, socket_uuid);
|
|
73
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Registers a callback to intercept incoming blocks.
|
|
92
|
+
* @param callback The callback to be invoked for each incoming block.
|
|
93
|
+
*/
|
|
94
|
+
registerIncomingBlockInterceptor(callback) {
|
|
95
|
+
__classPrivateFieldGet(this, _ComHub_jsComHub, "f").register_incoming_block_interceptor(callback);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Registers a callback to intercept outgoing blocks.
|
|
99
|
+
* @param callback The callback to be invoked for each outgoing block.
|
|
100
|
+
*/
|
|
101
|
+
registerOutgoingBlockInterceptor(callback) {
|
|
102
|
+
__classPrivateFieldGet(this, _ComHub_jsComHub, "f").register_outgoing_block_interceptor(callback);
|
|
103
|
+
}
|
|
74
104
|
}
|
|
75
105
|
_a = ComHub, _ComHub_jsComHub = new WeakMap();
|
|
106
|
+
/** Static map of registered interface implementations. */
|
|
76
107
|
_ComHub_interfaceImpls = { value: new Map() };
|
|
108
|
+
/** Static map of interface implementations by class. */
|
|
77
109
|
_ComHub_interfaceImplsByClass = { value: new Map() };
|
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
import type { JSComHub } from "../datex-core/datex_core_js";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for communication interface implementations.
|
|
4
|
+
*/
|
|
2
5
|
export declare abstract class ComInterfaceImpl<SetupData> {
|
|
3
6
|
protected readonly uuid: string;
|
|
4
7
|
protected readonly setupData: SetupData;
|
|
5
8
|
protected readonly jsComHub: JSComHub;
|
|
6
9
|
constructor(uuid: string, setupData: SetupData, jsComHub: JSComHub);
|
|
10
|
+
/**
|
|
11
|
+
* Initializes the communication interface.
|
|
12
|
+
*/
|
|
7
13
|
init?(): Promise<void> | void;
|
|
14
|
+
/**
|
|
15
|
+
* Cleans up the communication interface.
|
|
16
|
+
*/
|
|
8
17
|
cleanup?(): Promise<void> | void;
|
|
9
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents a communication interface.
|
|
21
|
+
*/
|
|
10
22
|
export declare class ComInterface<T extends ComInterfaceImpl<unknown>> {
|
|
11
23
|
#private;
|
|
24
|
+
/** The UUID of the interface. */
|
|
12
25
|
readonly uuid: string;
|
|
26
|
+
/** The implementation of the interface. */
|
|
13
27
|
readonly impl: T;
|
|
14
28
|
constructor(uuid: string, impl: T, jsComHub: JSComHub);
|
|
29
|
+
/**
|
|
30
|
+
* Closes the communication interface.
|
|
31
|
+
* @returns True if the interface was closed successfully, false otherwise.
|
|
32
|
+
*/
|
|
15
33
|
close(): Promise<boolean>;
|
|
16
34
|
}
|
|
17
35
|
//# sourceMappingURL=com-interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"com-interface.d.ts","sourceRoot":"","sources":["../../src/network/com-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,8BAAsB,gBAAgB,CAAC,SAAS;IAC5C,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IACjC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAG,SAAS,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAC;gBAE3B,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"com-interface.d.ts","sourceRoot":"","sources":["../../src/network/com-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;GAEG;AACH,8BAAsB,gBAAgB,CAAC,SAAS;IAC5C,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IACjC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAG,SAAS,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAC;gBAE3B,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ;IAKlE;;OAEG;IACH,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAC7B;;OAEG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CACnC;AAED;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC;;IACzD,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;gBAKL,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ;IAMrD;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;CAIzC"}
|
|
@@ -10,6 +10,9 @@ 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 _ComInterface_jsComHub;
|
|
13
|
+
/**
|
|
14
|
+
* Abstract base class for communication interface implementations.
|
|
15
|
+
*/
|
|
13
16
|
export class ComInterfaceImpl {
|
|
14
17
|
constructor(uuid, setupData, jsComHub) {
|
|
15
18
|
Object.defineProperty(this, "uuid", {
|
|
@@ -35,25 +38,35 @@ export class ComInterfaceImpl {
|
|
|
35
38
|
this.jsComHub = jsComHub;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Represents a communication interface.
|
|
43
|
+
*/
|
|
38
44
|
export class ComInterface {
|
|
39
45
|
constructor(uuid, impl, jsComHub) {
|
|
46
|
+
/** The UUID of the interface. */
|
|
40
47
|
Object.defineProperty(this, "uuid", {
|
|
41
48
|
enumerable: true,
|
|
42
49
|
configurable: true,
|
|
43
50
|
writable: true,
|
|
44
51
|
value: void 0
|
|
45
52
|
});
|
|
53
|
+
/** The implementation of the interface. */
|
|
46
54
|
Object.defineProperty(this, "impl", {
|
|
47
55
|
enumerable: true,
|
|
48
56
|
configurable: true,
|
|
49
57
|
writable: true,
|
|
50
58
|
value: void 0
|
|
51
59
|
});
|
|
60
|
+
/** The JS communication hub. */
|
|
52
61
|
_ComInterface_jsComHub.set(this, void 0);
|
|
53
62
|
this.uuid = uuid;
|
|
54
63
|
this.impl = impl;
|
|
55
64
|
__classPrivateFieldSet(this, _ComInterface_jsComHub, jsComHub, "f");
|
|
56
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Closes the communication interface.
|
|
68
|
+
* @returns True if the interface was closed successfully, false otherwise.
|
|
69
|
+
*/
|
|
57
70
|
async close() {
|
|
58
71
|
await this.impl.cleanup?.();
|
|
59
72
|
return __classPrivateFieldGet(this, _ComInterface_jsComHub, "f").close_interface(this.uuid);
|