@unyt/datex 0.0.13 → 0.0.15
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/datex-web/datex_web.d.ts +93 -2
- package/esm/datex-web/datex_web.internal.d.ts +221 -188
- package/esm/datex-web/datex_web.internal.d.ts.map +1 -1
- package/esm/datex-web/datex_web.internal.js +453 -385
- package/esm/datex-web/datex_web.wasm +0 -0
- package/esm/datex-web/types/decompiler/options.d.ts +17 -0
- package/esm/datex-web/types/decompiler/options.d.ts.map +1 -0
- package/esm/datex-web/types/decompiler/options.js +4 -0
- package/esm/datex-web/types/disassembler/options.d.ts +6 -0
- package/esm/datex-web/types/disassembler/options.d.ts.map +1 -0
- package/esm/datex-web/types/disassembler/options.js +4 -0
- package/esm/datex-web/types/network/com_hub/managers/socket_manager.d.ts +9 -0
- package/esm/datex-web/types/network/com_hub/managers/socket_manager.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_hub/managers/socket_manager.js +4 -0
- package/esm/datex-web/types/network/com_hub/metadata.d.ts +20 -0
- package/esm/datex-web/types/network/com_hub/metadata.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_hub/metadata.js +4 -0
- package/esm/datex-web/types/network/com_hub/mod.d.ts +6 -0
- package/esm/datex-web/types/network/com_hub/mod.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_hub/mod.js +4 -0
- package/esm/datex-web/types/network/com_hub/network_tracing.d.ts +23 -0
- package/esm/datex-web/types/network/com_hub/network_tracing.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_hub/network_tracing.js +4 -0
- package/esm/datex-web/types/network/com_hub.d.ts +8 -0
- package/esm/datex-web/types/network/com_hub.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_hub.js +4 -0
- package/esm/datex-web/types/network/com_interfaces/com_interface/properties.d.ts +27 -0
- package/esm/datex-web/types/network/com_interfaces/com_interface/properties.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_interfaces/com_interface/properties.js +4 -0
- package/esm/datex-web/types/network/com_interfaces/default_setup_data/http_common.d.ts +10 -0
- package/esm/datex-web/types/network/com_interfaces/default_setup_data/http_common.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_interfaces/default_setup_data/http_common.js +4 -0
- package/esm/datex-web/types/network/com_interfaces/default_setup_data/websocket/websocket_server.d.ts +6 -0
- package/esm/datex-web/types/network/com_interfaces/default_setup_data/websocket/websocket_server.d.ts.map +1 -0
- package/esm/datex-web/types/network/com_interfaces/default_setup_data/websocket/websocket_server.js +4 -0
- package/esm/datex-web/types/runtime/config.d.ts +16 -0
- package/esm/datex-web/types/runtime/config.d.ts.map +1 -0
- package/esm/datex-web/types/runtime/config.js +4 -0
- package/esm/default.d.ts.map +1 -1
- package/esm/default.js +2 -0
- package/esm/deno.json +73 -17
- package/esm/dif/core.d.ts +36 -39
- package/esm/dif/core.d.ts.map +1 -1
- package/esm/dif/core.js +33 -53
- package/esm/dif/dif-handler.d.ts +58 -101
- package/esm/dif/dif-handler.d.ts.map +1 -1
- package/esm/dif/dif-handler.js +417 -345
- package/esm/dif/display.d.ts +14 -5
- package/esm/dif/display.d.ts.map +1 -1
- package/esm/dif/display.js +89 -39
- package/esm/dif/helpers/mod.d.ts +6 -0
- package/esm/dif/helpers/mod.d.ts.map +1 -0
- package/esm/dif/helpers/mod.js +5 -0
- package/esm/dif/helpers/typed-integer.d.ts +14 -0
- package/esm/dif/helpers/typed-integer.d.ts.map +1 -0
- package/esm/dif/helpers/typed-integer.js +37 -0
- package/esm/dif/js-lib.d.ts +14 -1
- package/esm/dif/js-lib.d.ts.map +1 -1
- package/esm/dif/js-lib.js +19 -1
- package/esm/dif/mod.d.ts +2 -2
- package/esm/dif/mod.d.ts.map +1 -1
- package/esm/dif/mod.js +2 -2
- package/esm/dif/type-registry.d.ts +30 -21
- package/esm/dif/type-registry.d.ts.map +1 -1
- package/esm/dif/type-registry.js +45 -33
- package/esm/dif/types/mod.d.ts +9 -0
- package/esm/dif/types/mod.d.ts.map +1 -0
- package/esm/dif/types/mod.js +8 -0
- package/esm/dif/types/type.d.ts +91 -0
- package/esm/dif/types/type.d.ts.map +1 -0
- package/esm/dif/types/type.js +33 -0
- package/esm/dif/types/update.d.ts +63 -0
- package/esm/dif/types/update.d.ts.map +1 -0
- package/esm/dif/types/update.js +16 -0
- package/esm/dif/types/value.d.ts +62 -0
- package/esm/dif/types/value.d.ts.map +1 -0
- package/esm/dif/types/value.js +1 -0
- package/esm/dif/update.d.ts +20 -0
- package/esm/dif/update.d.ts.map +1 -0
- package/esm/dif/update.js +41 -0
- package/esm/dif/utils.d.ts +8 -0
- package/esm/dif/utils.d.ts.map +1 -0
- package/esm/dif/utils.js +67 -0
- package/esm/lib/js-core-types/array.d.ts +3 -0
- package/esm/lib/js-core-types/array.d.ts.map +1 -0
- package/esm/lib/js-core-types/array.js +175 -0
- package/esm/lib/js-core-types/map.d.ts +15 -0
- package/esm/lib/js-core-types/map.d.ts.map +1 -0
- package/esm/lib/js-core-types/map.js +88 -0
- package/esm/lib/js-core-types/mod.d.ts +8 -0
- package/esm/lib/js-core-types/mod.d.ts.map +1 -0
- package/esm/lib/js-core-types/mod.js +7 -0
- package/esm/lib/mod.d.ts +8 -0
- package/esm/lib/mod.d.ts.map +1 -0
- package/esm/lib/mod.js +7 -0
- package/esm/lib/special-core-types/endpoint.d.ts.map +1 -1
- package/esm/lib/special-core-types/mod.d.ts +9 -0
- package/esm/lib/special-core-types/mod.d.ts.map +1 -0
- package/esm/lib/special-core-types/mod.js +8 -0
- package/esm/lib/special-core-types/range.d.ts +26 -0
- package/esm/lib/special-core-types/range.d.ts.map +1 -0
- package/esm/lib/special-core-types/range.js +46 -0
- package/esm/lib/special-core-types/tagged.d.ts +17 -0
- package/esm/lib/special-core-types/tagged.d.ts.map +1 -0
- package/esm/lib/special-core-types/tagged.js +37 -0
- package/esm/lib/special-core-types/undefined.d.ts +7 -0
- package/esm/lib/special-core-types/undefined.d.ts.map +1 -0
- package/esm/lib/special-core-types/undefined.js +28 -0
- package/esm/mod.d.ts +3 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +3 -1
- package/esm/network/com-hub.d.ts +28 -1
- package/esm/network/com-hub.d.ts.map +1 -1
- package/esm/network/com-hub.js +6 -2
- package/esm/network/interfaces/websocket-server-base.d.ts +1 -1
- package/esm/network/interfaces/websocket-server-base.d.ts.map +1 -1
- package/esm/network/interfaces/websocket-server-base.js +8 -7
- package/esm/network/interfaces/websocket-server-deno.d.ts +1 -1
- package/esm/network/interfaces/websocket-server-deno.d.ts.map +1 -1
- package/esm/repl/mod.d.ts +8 -0
- package/esm/repl/mod.d.ts.map +1 -0
- package/esm/repl/mod.js +31 -0
- package/esm/runtime/runtime.d.ts +43 -18
- package/esm/runtime/runtime.d.ts.map +1 -1
- package/esm/runtime/runtime.js +55 -32
- package/esm/{refs/ref.d.ts → shared-container/base-shared-container.d.ts} +13 -5
- package/esm/shared-container/base-shared-container.d.ts.map +1 -0
- package/esm/shared-container/base-shared-container.js +95 -0
- package/esm/shared-container/mod.d.ts +36 -0
- package/esm/shared-container/mod.d.ts.map +1 -0
- package/esm/shared-container/mod.js +29 -0
- package/esm/shared-container/owned.d.ts +33 -0
- package/esm/shared-container/owned.d.ts.map +1 -0
- package/esm/shared-container/owned.js +60 -0
- package/esm/shared-container/reference.d.ts +31 -0
- package/esm/shared-container/reference.d.ts.map +1 -0
- package/esm/shared-container/reference.js +64 -0
- package/esm/utils/devtools-formatter.js +24 -2
- package/esm/utils/option.d.ts +17 -0
- package/esm/utils/option.d.ts.map +1 -0
- package/esm/utils/option.js +54 -0
- package/package.json +1 -1
- package/esm/dif/definitions.d.ts +0 -134
- package/esm/dif/definitions.d.ts.map +0 -1
- package/esm/dif/definitions.js +0 -38
- package/esm/refs/ref.d.ts.map +0 -1
- package/esm/refs/ref.js +0 -60
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { CoreLibTypeId } from "../../dif/core.js";
|
|
2
|
+
import { IS_PROXY_ACCESS } from "../../dif/dif-handler.js";
|
|
3
|
+
import { interceptAccessors } from "../../dif/utils.js";
|
|
4
|
+
import { DEBUG_MODE } from "../../global.js";
|
|
5
|
+
import { Option } from "../../utils/option.js";
|
|
6
|
+
export const arrayTypeBinding = {
|
|
7
|
+
coreLibTypeId: CoreLibTypeId.List,
|
|
8
|
+
bind(target, pointerAddress) {
|
|
9
|
+
const metadata = {};
|
|
10
|
+
const arrayMethods = getArrayMethods(target, pointerAddress, this.difHandler, metadata);
|
|
11
|
+
// catch acccess (get or set) to original array value, not via proxy - this check is only active in debug mode
|
|
12
|
+
if (DEBUG_MODE) {
|
|
13
|
+
interceptAccessors(target, () => {
|
|
14
|
+
if (!metadata[IS_PROXY_ACCESS]) {
|
|
15
|
+
throw new Error("Invalid access to original array value that was moved to a reference");
|
|
16
|
+
}
|
|
17
|
+
return Option.None();
|
|
18
|
+
}, () => {
|
|
19
|
+
if (!metadata[IS_PROXY_ACCESS]) {
|
|
20
|
+
throw new Error("Invalid access to original array value that was moved to a reference");
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// deno-lint-ignore no-this-alias
|
|
25
|
+
const self = this;
|
|
26
|
+
const proxy = new Proxy(target, {
|
|
27
|
+
get(_target, key) {
|
|
28
|
+
return self.allowOriginalValueAccess(proxy, () => {
|
|
29
|
+
return arrayMethods[key] ??
|
|
30
|
+
Reflect.get(target, key);
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
set(_target, prop, value, receiver) {
|
|
34
|
+
console.log("=> array." + String(prop) + " =", value);
|
|
35
|
+
return self.allowOriginalValueAccess(proxy, () => {
|
|
36
|
+
const index = Number(prop);
|
|
37
|
+
if (typeof prop === "string" && !isNaN(index) && index >= 0) {
|
|
38
|
+
// check if out of bounds - fill with null&js.empty
|
|
39
|
+
if (index >= target.length) {
|
|
40
|
+
triggerArrayFillEmpty(target, target.length, index, pointerAddress, self.difHandler);
|
|
41
|
+
}
|
|
42
|
+
self.difHandler.triggerIndexSet(pointerAddress, index, value);
|
|
43
|
+
}
|
|
44
|
+
else if (prop === "length") {
|
|
45
|
+
// if length is reduced, trigger delete for removed items
|
|
46
|
+
const newLength = Number(value);
|
|
47
|
+
// explicit length value 0 is treated as a full clear
|
|
48
|
+
if (newLength == 0) {
|
|
49
|
+
self.difHandler.triggerClear(pointerAddress);
|
|
50
|
+
}
|
|
51
|
+
else if (newLength < target.length) {
|
|
52
|
+
self.difHandler.triggerListSplice(pointerAddress, newLength, target.length - newLength, []);
|
|
53
|
+
} // if length is increased, trigger set for new empty items
|
|
54
|
+
else if (newLength > target.length) {
|
|
55
|
+
triggerArrayFillEmpty(target, target.length, newLength, pointerAddress, self.difHandler);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// x[1..4] = js:empty
|
|
59
|
+
return Reflect.set(target, prop, value, receiver);
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
value: proxy,
|
|
65
|
+
metadata,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
handleAppend(target, value) {
|
|
69
|
+
this.difHandler.getOriginalValueFromProxy(target).push(value);
|
|
70
|
+
// target.push(value);
|
|
71
|
+
},
|
|
72
|
+
handleSet(target, key, value) {
|
|
73
|
+
this.difHandler.getOriginalValueFromProxy(target)[key] = value;
|
|
74
|
+
},
|
|
75
|
+
handleDelete(target, key) {
|
|
76
|
+
// remove key (splice)
|
|
77
|
+
this.difHandler.getOriginalValueFromProxy(target).splice(key, 1);
|
|
78
|
+
},
|
|
79
|
+
handleClear(target) {
|
|
80
|
+
this.difHandler.getOriginalValueFromProxy(target).length = 0;
|
|
81
|
+
},
|
|
82
|
+
handleReplace(target, newValue) {
|
|
83
|
+
const original = this.difHandler.getOriginalValueFromProxy(target);
|
|
84
|
+
original.length = 0;
|
|
85
|
+
original.push(...newValue);
|
|
86
|
+
},
|
|
87
|
+
handleListSplice(target, start, deleteCount, items) {
|
|
88
|
+
this.difHandler
|
|
89
|
+
.getOriginalValueFromProxy(target)
|
|
90
|
+
.splice(start, deleteCount, ...items);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Implementes optimized array methods that send DIF updates on mutation.
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
function getArrayMethods(array, pointerAddress, difHandler, metadata) {
|
|
98
|
+
const originalPush = array.push.bind(array);
|
|
99
|
+
const originalUnshift = array.unshift.bind(array);
|
|
100
|
+
const originalSplice = array.splice.bind(array);
|
|
101
|
+
const originalFill = array.fill.bind(array);
|
|
102
|
+
return {
|
|
103
|
+
push: generateInterceptedArrayPush(array, originalPush, pointerAddress, difHandler),
|
|
104
|
+
unshift: generateInterceptedArrayUnshift(originalUnshift, pointerAddress, difHandler, metadata),
|
|
105
|
+
splice: generateInterceptedArraySplice(array, originalSplice, pointerAddress, difHandler, metadata),
|
|
106
|
+
fill: generateInterceptedArrayFill(array, originalFill, pointerAddress, difHandler, metadata),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function generateInterceptedArrayPush(array, originalPush, pointerAddress, difHandler) {
|
|
110
|
+
return (...items) => {
|
|
111
|
+
difHandler.triggerListSplice(pointerAddress, array.length, 0, items);
|
|
112
|
+
return originalPush(...items);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function generateInterceptedArrayUnshift(originalUnshift, pointerAddress, difHandler, metadata) {
|
|
116
|
+
return (...items) => {
|
|
117
|
+
difHandler.triggerListSplice(pointerAddress, 0, 0, items);
|
|
118
|
+
try {
|
|
119
|
+
metadata[IS_PROXY_ACCESS] = true;
|
|
120
|
+
return originalUnshift(...items);
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
metadata[IS_PROXY_ACCESS] = false;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function generateInterceptedArraySplice(array, originalSplice, pointerAddress, difHandler, metadata) {
|
|
128
|
+
return (start, deleteCount, ...items) => {
|
|
129
|
+
difHandler.triggerListSplice(pointerAddress, start, deleteCount ?? (array.length - start), items);
|
|
130
|
+
try {
|
|
131
|
+
metadata[IS_PROXY_ACCESS] = true;
|
|
132
|
+
return originalSplice(start, deleteCount, ...items);
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
metadata[IS_PROXY_ACCESS] = false;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function generateInterceptedArrayFill(array, originalFill, pointerAddress, difHandler, metadata) {
|
|
140
|
+
return (value, start, end) => {
|
|
141
|
+
const actualStart = start !== undefined
|
|
142
|
+
? (start < 0 ? Math.max(array.length + start, 0) : Math.min(start, array.length))
|
|
143
|
+
: 0;
|
|
144
|
+
const actualEnd = end !== undefined
|
|
145
|
+
? (end < 0 ? Math.max(array.length + end, 0) : Math.min(end, array.length))
|
|
146
|
+
: array.length;
|
|
147
|
+
const itemCount = actualEnd - actualStart;
|
|
148
|
+
// splice to replace the filled range
|
|
149
|
+
if (itemCount > 0) {
|
|
150
|
+
difHandler.triggerListSplice(pointerAddress, actualStart, actualEnd - actualStart, new Array(itemCount).fill(value));
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
metadata[IS_PROXY_ACCESS] = true;
|
|
154
|
+
return originalFill(value, start, end);
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
metadata[IS_PROXY_ACCESS] = false;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sends DIF updates that correspond to filling an array up to a certain index with
|
|
163
|
+
* empty values.
|
|
164
|
+
*/
|
|
165
|
+
function triggerArrayFillEmpty(array, from, to, pointerAddress, difHandler) {
|
|
166
|
+
const originalLength = array.length;
|
|
167
|
+
for (let i = from; i < to; i++) {
|
|
168
|
+
if (i < originalLength) {
|
|
169
|
+
difHandler.triggerSet(pointerAddress, i, null); // TODO: special js empty value
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
difHandler.triggerAppend(pointerAddress, null); // TODO: special js empty value
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TypeBindingDefinition } from "../../dif/type-registry.js";
|
|
2
|
+
import type { DIFTypeDefinition } from "../../dif/types/mod.js";
|
|
3
|
+
declare const ORIGINAL_SET: unique symbol;
|
|
4
|
+
declare const ORIGINAL_DELETE: unique symbol;
|
|
5
|
+
declare const ORIGINAL_CLEAR: unique symbol;
|
|
6
|
+
type MapMetadata<K = unknown, V = unknown> = {
|
|
7
|
+
[ORIGINAL_SET]: Map<K, V>["set"];
|
|
8
|
+
[ORIGINAL_DELETE]: Map<K, V>["delete"];
|
|
9
|
+
[ORIGINAL_CLEAR]: Map<K, V>["clear"];
|
|
10
|
+
};
|
|
11
|
+
export declare const mapTypeBinding: TypeBindingDefinition<Map<unknown, unknown>, MapMetadata>;
|
|
12
|
+
export declare const JS_MAP_TYPE_DEFINITION: DIFTypeDefinition;
|
|
13
|
+
export declare function isJsMapTypeDefinition(typeDef: DIFTypeDefinition): boolean;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/lib/js-core-types/map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAyB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGvF,QAAA,MAAM,YAAY,eAAyB,CAAC;AAC5C,QAAA,MAAM,eAAe,eAA4B,CAAC;AAClD,QAAA,MAAM,cAAc,eAA2B,CAAC;AAEhD,KAAK,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI;IACzC,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,eAAe,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,qBAAqB,CAC9C,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,EACrB,WAAW,CAsEd,CAAC;AAiBF,eAAO,MAAM,sBAAsB,EAAE,iBAEpC,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAOzE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CoreLibTypeId } from "../../dif/core.js";
|
|
2
|
+
import { JsLibTypeAddress } from "../../dif/js-lib.js";
|
|
3
|
+
const ORIGINAL_SET = Symbol("ORIGINAL_SET");
|
|
4
|
+
const ORIGINAL_DELETE = Symbol("ORIGINAL_DELETE");
|
|
5
|
+
const ORIGINAL_CLEAR = Symbol("ORIGINAL_CLEAR");
|
|
6
|
+
export const mapTypeBinding = {
|
|
7
|
+
coreLibTypeId: CoreLibTypeId.Map,
|
|
8
|
+
bind(value, pointerAddress) {
|
|
9
|
+
const originalSet = value.set.bind(value);
|
|
10
|
+
const originalDelete = value.delete.bind(value);
|
|
11
|
+
const originalClear = value.clear.bind(value);
|
|
12
|
+
Object.defineProperties(value, {
|
|
13
|
+
set: {
|
|
14
|
+
value: (key, val) => {
|
|
15
|
+
this.difHandler.triggerSet(pointerAddress, key, val);
|
|
16
|
+
return originalSet.call(value, key, val);
|
|
17
|
+
},
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
},
|
|
21
|
+
delete: {
|
|
22
|
+
value: (key) => {
|
|
23
|
+
this.difHandler.triggerDelete(pointerAddress, key);
|
|
24
|
+
return originalDelete.call(value, key);
|
|
25
|
+
},
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
},
|
|
29
|
+
clear: {
|
|
30
|
+
value: () => {
|
|
31
|
+
console.warn("triggering clear for pointer address:", pointerAddress);
|
|
32
|
+
this.difHandler.triggerClear(pointerAddress);
|
|
33
|
+
return originalClear.call(value);
|
|
34
|
+
},
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
value,
|
|
41
|
+
metadata: {
|
|
42
|
+
[ORIGINAL_SET]: originalSet,
|
|
43
|
+
[ORIGINAL_DELETE]: originalDelete,
|
|
44
|
+
[ORIGINAL_CLEAR]: originalClear,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
handleSet(target, key, value) {
|
|
49
|
+
const set = this.getCustomReferenceMetadata(target)[ORIGINAL_SET];
|
|
50
|
+
set.call(target, key, value);
|
|
51
|
+
},
|
|
52
|
+
handleDelete(target, key) {
|
|
53
|
+
const del = this.getCustomReferenceMetadata(target)[ORIGINAL_DELETE];
|
|
54
|
+
del.call(target, key);
|
|
55
|
+
},
|
|
56
|
+
handleClear(target) {
|
|
57
|
+
const clear = this.getCustomReferenceMetadata(target)[ORIGINAL_CLEAR];
|
|
58
|
+
clear.call(target);
|
|
59
|
+
},
|
|
60
|
+
handleReplace(target, newValue) {
|
|
61
|
+
const metadata = this.getCustomReferenceMetadata(target);
|
|
62
|
+
metadata[ORIGINAL_CLEAR].call(target);
|
|
63
|
+
for (const [key, value] of newValue.entries()) {
|
|
64
|
+
metadata[ORIGINAL_SET].call(target, key, value);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const JS_MAP_IMPL_TYPE_DEFINITION = [
|
|
69
|
+
CoreLibTypeId.Map,
|
|
70
|
+
[JsLibTypeAddress.map],
|
|
71
|
+
];
|
|
72
|
+
function isJsMapImplTypeDefinition(impl) {
|
|
73
|
+
return (Array.isArray(impl) &&
|
|
74
|
+
impl.length === 2 &&
|
|
75
|
+
impl[0] === CoreLibTypeId.Map &&
|
|
76
|
+
Array.isArray(impl[1]) &&
|
|
77
|
+
impl[1].length === 1 &&
|
|
78
|
+
impl[1][0] === JsLibTypeAddress.map);
|
|
79
|
+
}
|
|
80
|
+
export const JS_MAP_TYPE_DEFINITION = {
|
|
81
|
+
impl_type: JS_MAP_IMPL_TYPE_DEFINITION,
|
|
82
|
+
};
|
|
83
|
+
export function isJsMapTypeDefinition(typeDef) {
|
|
84
|
+
return (typeof typeDef === "object" &&
|
|
85
|
+
typeDef !== null &&
|
|
86
|
+
"impl_type" in typeDef &&
|
|
87
|
+
isJsMapImplTypeDefinition(typeDef.impl_type));
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/lib/js-core-types/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
package/esm/lib/mod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lib/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC"}
|
package/esm/lib/mod.js
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../src/lib/special-core-types/endpoint.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;IAIzB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../src/lib/special-core-types/endpoint.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;IAIzB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;CACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module special-core-types
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains type definitions for special core types in the DATEX runtime, such as endpoints and ranges.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./endpoint.js";
|
|
7
|
+
export * from "./range.js";
|
|
8
|
+
export * from "./tagged.js";
|
|
9
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/lib/special-core-types/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module special-core-types
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains type definitions for special core types in the DATEX runtime, such as endpoints and ranges.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./endpoint.js";
|
|
7
|
+
export * from "./range.js";
|
|
8
|
+
export * from "./tagged.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a range of numbers with a start and end.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Range {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
constructor(start: number, end: number);
|
|
8
|
+
/**
|
|
9
|
+
* Gets the length of the range (end - start).
|
|
10
|
+
*/
|
|
11
|
+
get length(): number;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a given value is within the range (inclusive of start, exclusive of end).
|
|
14
|
+
* @param value The number to check.
|
|
15
|
+
* @returns True if the value is within the range, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
contains(value: number): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Turns a string representation of the range in the format
|
|
20
|
+
* @returns The string representation of the range.
|
|
21
|
+
*/
|
|
22
|
+
toString(): string;
|
|
23
|
+
get [Symbol.toStringTag](): string;
|
|
24
|
+
get [Symbol.toPrimitive](): string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/lib/special-core-types/range.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,KAAK;IACK,KAAK,EAAE,MAAM;IAAS,GAAG,EAAE,MAAM;gBAAjC,KAAK,EAAE,MAAM,EAAS,GAAG,EAAE,MAAM;IAEpD;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIvC;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAIzB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;CACJ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a range of numbers with a start and end.
|
|
3
|
+
*/
|
|
4
|
+
export class Range {
|
|
5
|
+
constructor(start, end) {
|
|
6
|
+
Object.defineProperty(this, "start", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: start
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "end", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: end
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gets the length of the range (end - start).
|
|
21
|
+
*/
|
|
22
|
+
get length() {
|
|
23
|
+
return this.end - this.start;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a given value is within the range (inclusive of start, exclusive of end).
|
|
27
|
+
* @param value The number to check.
|
|
28
|
+
* @returns True if the value is within the range, false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
contains(value) {
|
|
31
|
+
return value >= this.start && value < this.end;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Turns a string representation of the range in the format
|
|
35
|
+
* @returns The string representation of the range.
|
|
36
|
+
*/
|
|
37
|
+
toString() {
|
|
38
|
+
return `${this.start}..${this.end}`;
|
|
39
|
+
}
|
|
40
|
+
get [Symbol.toStringTag]() {
|
|
41
|
+
return this.toString();
|
|
42
|
+
}
|
|
43
|
+
get [Symbol.toPrimitive]() {
|
|
44
|
+
return this.toString();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const EMPTY_TAG: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* A simple wrapper type that allows to associate a string tag with a value.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Tagged<Tag extends string, const Value = typeof EMPTY_TAG> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(tag: Tag, value?: Value);
|
|
8
|
+
get value(): Value;
|
|
9
|
+
set value(newValue: Value);
|
|
10
|
+
get tag(): Tag;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new Tagged instance with the given tag and value.
|
|
14
|
+
*/
|
|
15
|
+
export declare function tagged<Tag extends string>(tag: Tag): Tagged<Tag, typeof EMPTY_TAG>;
|
|
16
|
+
export declare function tagged<Tag extends string, const Value>(tag: Tag, value: Value): Tagged<Tag, Value>;
|
|
17
|
+
//# sourceMappingURL=tagged.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagged.d.ts","sourceRoot":"","sources":["../../../src/lib/special-core-types/tagged.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,eAAsB,CAAC;AAE7C;;GAEG;AACH,qBAAa,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,KAAK,CAAC,KAAK,GAAG,OAAO,SAAS;;gBAK9D,GAAG,EAAE,GAAG,EACR,KAAK,GAAE,KAA0B;IAMrC,IAAW,KAAK,IAAI,KAAK,CAExB;IAED,IAAW,KAAK,CAAC,QAAQ,EAAE,KAAK,EAE/B;IAED,IAAW,GAAG,IAAI,GAAG,CAEpB;CACJ;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,SAAS,MAAM,EACrC,GAAG,EAAE,GAAG,GACT,MAAM,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,CAAC;AACjC,wBAAgB,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,KAAK,CAAC,KAAK,EAClD,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,GACb,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Tagged_tag, _Tagged_value;
|
|
13
|
+
export const EMPTY_TAG = Symbol("EMPTY_TAG");
|
|
14
|
+
/**
|
|
15
|
+
* A simple wrapper type that allows to associate a string tag with a value.
|
|
16
|
+
*/
|
|
17
|
+
export class Tagged {
|
|
18
|
+
constructor(tag, value = EMPTY_TAG) {
|
|
19
|
+
_Tagged_tag.set(this, void 0);
|
|
20
|
+
_Tagged_value.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _Tagged_tag, tag, "f");
|
|
22
|
+
__classPrivateFieldSet(this, _Tagged_value, value, "f");
|
|
23
|
+
}
|
|
24
|
+
get value() {
|
|
25
|
+
return __classPrivateFieldGet(this, _Tagged_value, "f");
|
|
26
|
+
}
|
|
27
|
+
set value(newValue) {
|
|
28
|
+
__classPrivateFieldSet(this, _Tagged_value, newValue, "f");
|
|
29
|
+
}
|
|
30
|
+
get tag() {
|
|
31
|
+
return __classPrivateFieldGet(this, _Tagged_tag, "f");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_Tagged_tag = new WeakMap(), _Tagged_value = new WeakMap();
|
|
35
|
+
export function tagged(tag, value = EMPTY_TAG) {
|
|
36
|
+
return new Tagged(tag, value);
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DIFValue } from "../../dif/types/mod.js";
|
|
2
|
+
import type { DIFTypeDefinition } from "../../dif/types/type.js";
|
|
3
|
+
export declare const JS_UNDEFINED_TYPE_DEFINITION: DIFTypeDefinition;
|
|
4
|
+
export declare function isJsUndefinedTypeDefinition(typeDef: DIFTypeDefinition): boolean;
|
|
5
|
+
export declare const JS_UNDEFINED: DIFValue;
|
|
6
|
+
export declare function isJsUndefined(value: DIFValue): boolean;
|
|
7
|
+
//# sourceMappingURL=undefined.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undefined.d.ts","sourceRoot":"","sources":["../../../src/lib/special-core-types/undefined.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAyB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAiBxF,eAAO,MAAM,4BAA4B,EAAE,iBAE1C,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAO/E;AAED,eAAO,MAAM,YAAY,EAAE,QAAmE,CAAC;AAC/F,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAGtD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CoreLibTypeId } from "../../dif/core.js";
|
|
2
|
+
import { JsLibTypeAddress } from "../../dif/js-lib.js";
|
|
3
|
+
const JS_UNDEFINED_IMPL_TYPE_DEFINITION = [
|
|
4
|
+
CoreLibTypeId.null,
|
|
5
|
+
[JsLibTypeAddress.undefined],
|
|
6
|
+
];
|
|
7
|
+
function isJsUndefinedImplTypeDefinition(impl) {
|
|
8
|
+
return (Array.isArray(impl) &&
|
|
9
|
+
impl.length === 2 &&
|
|
10
|
+
impl[0] === CoreLibTypeId.null &&
|
|
11
|
+
Array.isArray(impl[1]) &&
|
|
12
|
+
impl[1].length === 1 &&
|
|
13
|
+
impl[1][0] === JsLibTypeAddress.undefined);
|
|
14
|
+
}
|
|
15
|
+
export const JS_UNDEFINED_TYPE_DEFINITION = {
|
|
16
|
+
impl_type: JS_UNDEFINED_IMPL_TYPE_DEFINITION,
|
|
17
|
+
};
|
|
18
|
+
export function isJsUndefinedTypeDefinition(typeDef) {
|
|
19
|
+
return (typeof typeDef === "object" &&
|
|
20
|
+
typeDef !== null &&
|
|
21
|
+
"impl_type" in typeDef &&
|
|
22
|
+
isJsUndefinedImplTypeDefinition(typeDef.impl_type));
|
|
23
|
+
}
|
|
24
|
+
export const JS_UNDEFINED = [CoreLibTypeId.null, null, JS_UNDEFINED_TYPE_DEFINITION];
|
|
25
|
+
export function isJsUndefined(value) {
|
|
26
|
+
return Array.isArray(value) && value.length === 3 && value[0] === CoreLibTypeId.null && value[1] === null &&
|
|
27
|
+
isJsUndefinedTypeDefinition(value[2]);
|
|
28
|
+
}
|
package/esm/mod.d.ts
CHANGED
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
export * from "./runtime/runtime.js";
|
|
23
23
|
export * as DIF from "./dif/mod.js";
|
|
24
24
|
export * as Network from "./network/mod.js";
|
|
25
|
-
export * from "./
|
|
25
|
+
export * as Builtins from "./lib/mod.js";
|
|
26
|
+
export * as Shared from "./shared-container/mod.js";
|
|
27
|
+
export * from "./repl/mod.js";
|
|
26
28
|
import "./utils/devtools-formatter.js";
|
|
27
29
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AAC5C,cAAc,eAAe,CAAC;AAC9B,OAAO,+BAA+B,CAAC"}
|
|
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;AAC5C,OAAO,KAAK,QAAQ,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,OAAO,+BAA+B,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -22,5 +22,7 @@
|
|
|
22
22
|
export * from "./runtime/runtime.js";
|
|
23
23
|
export * as DIF from "./dif/mod.js";
|
|
24
24
|
export * as Network from "./network/mod.js";
|
|
25
|
-
export * from "./
|
|
25
|
+
export * as Builtins from "./lib/mod.js";
|
|
26
|
+
export * as Shared from "./shared-container/mod.js";
|
|
27
|
+
export * from "./repl/mod.js";
|
|
26
28
|
import "./utils/devtools-formatter.js";
|
package/esm/network/com-hub.d.ts
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
|
-
import type { ComHubMetadata, ComInterfaceConfiguration, JSComHub, NetworkTraceResult } from "../datex-web/datex_web";
|
|
2
1
|
import type { Runtime } from "../runtime/runtime.js";
|
|
2
|
+
import type { DIFValueContainer } from "../dif/types/value.js";
|
|
3
|
+
import type { JSComHub } from "../datex.js";
|
|
4
|
+
import type { ComHubMetadata } from "../datex-web/types/network/com_hub/metadata.js";
|
|
5
|
+
import type { NetworkTraceResult } from "../datex-web/types/network/com_hub/network_tracing.js";
|
|
6
|
+
import type { SocketPropertiesPartial } from "../datex-web/types/network/com_hub.js";
|
|
7
|
+
import type { ComInterfaceProperties } from "../datex-web/types/network/com_interfaces/com_interface/properties.js";
|
|
3
8
|
export type ComInterfaceFactory<SetupData = unknown> = {
|
|
4
9
|
interfaceType: string;
|
|
5
10
|
factory: ComInterfaceFactoryFn<SetupData>;
|
|
6
11
|
};
|
|
12
|
+
export type SocketConfiguration = {
|
|
13
|
+
properties: DIFValueContainer<SocketPropertiesPartial>;
|
|
14
|
+
iterator: ReadableStream<ArrayBufferLike>;
|
|
15
|
+
send_callback: (data: ArrayBuffer) => void;
|
|
16
|
+
};
|
|
17
|
+
export type ComInterfaceConfiguration = {
|
|
18
|
+
/**
|
|
19
|
+
* The properties of the interface instance
|
|
20
|
+
*/
|
|
21
|
+
properties: ComInterfaceProperties;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates that this interface only establishes a single socket connection
|
|
24
|
+
* And stops the sockets iterator after yielding the first socket configuration.
|
|
25
|
+
* When set to true, the first socket connection is awaited on interface creation.
|
|
26
|
+
*/
|
|
27
|
+
has_single_socket: boolean;
|
|
28
|
+
new_sockets_iterator: ReadableStream<SocketConfiguration>;
|
|
29
|
+
/**
|
|
30
|
+
* An optional asynchronous callback that is called by the com hub when the interface is closed
|
|
31
|
+
*/
|
|
32
|
+
close_async_callback?: never;
|
|
33
|
+
};
|
|
7
34
|
export type ComInterfaceFactoryFn<SetupData = unknown> = (setup_data: SetupData) => ComInterfaceConfiguration | Promise<ComInterfaceConfiguration>;
|
|
8
35
|
export type ComInterfaceUUID = `com_interface::${string}`;
|
|
9
36
|
export type ComInterfaceSocketUUID = `socket::${string}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"com-hub.d.ts","sourceRoot":"","sources":["../../src/network/com-hub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"com-hub.d.ts","sourceRoot":"","sources":["../../src/network/com-hub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uEAAuE,CAAC;AAEpH,MAAM,MAAM,mBAAmB,CAAC,SAAS,GAAG,OAAO,IAAI;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,UAAU,EAAE,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;IACvD,QAAQ,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAC1C,aAAa,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC;;OAEG;IACH,UAAU,EAAE,sBAAsB,CAAC;IACnC;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B,oBAAoB,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAC1D;;OAEG;IACH,oBAAoB,CAAC,EAAE,KAAK,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,SAAS,GAAG,OAAO,IAAI,CACrD,UAAU,EAAE,SAAS,KACpB,yBAAyB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,MAAM,EAAE,CAAC;AAC1D,MAAM,MAAM,sBAAsB,GAAG,WAAW,MAAM,EAAE,CAAC;AAEzD;;GAEG;AACH,qBAAa,MAAM;;gBAKH,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;IAKzC,wBAAwB,CAAC,SAAS,EACrC,iBAAiB,EAAE,mBAAmB,CAAC,SAAS,CAAC;IAerD;;;;;;OAMG;IACU,eAAe,CAAC,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,CAAC;IAQrB,eAAe,CAClB,cAAc,EAAE,gBAAgB,GACjC,OAAO,CAAC,IAAI,CAAC;IAIT,YAAY,CACf,WAAW,EAAE,sBAAsB,GACpC,OAAO,CAAC,IAAI,CAAC;IAIhB;;;OAGG;IACI,aAAa,IAAI,IAAI;IAKrB,WAAW,IAAI,cAAc;IAKpC;;;OAGG;IACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAK1E;;;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
|
@@ -24,7 +24,11 @@ export class ComHub {
|
|
|
24
24
|
registerInterfaceFactory(factoryDefinition) {
|
|
25
25
|
__classPrivateFieldGet(this, _ComHub_jsComHub, "f").register_interface_factory(factoryDefinition.interfaceType, async (setupData) => {
|
|
26
26
|
const setupDataJS = await __classPrivateFieldGet(this, _ComHub_runtime, "f").dif.resolveDIFValueContainer(setupData);
|
|
27
|
-
|
|
27
|
+
const data = await factoryDefinition.factory(setupDataJS);
|
|
28
|
+
return {
|
|
29
|
+
...data,
|
|
30
|
+
properties: __classPrivateFieldGet(this, _ComHub_runtime, "f").dif.convertJSValueToDIFValueContainer(data.properties),
|
|
31
|
+
};
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
@@ -53,7 +57,7 @@ export class ComHub {
|
|
|
53
57
|
}
|
|
54
58
|
getMetadata() {
|
|
55
59
|
// as any required because get_metadata only exists in debug builds
|
|
56
|
-
return __classPrivateFieldGet(this, _ComHub_jsComHub, "f").get_metadata();
|
|
60
|
+
return __classPrivateFieldGet(this, _ComHub_runtime, "f").dif.resolveDIFValueContainer(__classPrivateFieldGet(this, _ComHub_jsComHub, "f").get_metadata());
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
63
|
* Prints the trace for a specific endpoint. Only available in debug builds.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComInterfaceFactory } from "../com-hub.js";
|
|
2
|
-
import type { WebSocketServerInterfaceSetupData } from "../../datex.js";
|
|
2
|
+
import type { WebSocketServerInterfaceSetupData } from "../../datex-web/types/network/com_interfaces/default_setup_data/websocket/websocket_server.js";
|
|
3
3
|
/**
|
|
4
4
|
* Utility function to create a WebSocket server communication interface factory from a given server factory function.
|
|
5
5
|
* @param serverFactory
|