@unyt/datex 0.0.14 → 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 +215 -197
- package/esm/datex-web/datex_web.internal.d.ts.map +1 -1
- package/esm/datex-web/datex_web.internal.js +437 -407
- 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 -40
- package/esm/dif/core.d.ts.map +1 -1
- package/esm/dif/core.js +33 -54
- 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 +411 -365
- 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/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/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 +2 -3
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -3
- 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.js +1 -1
- 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 +2 -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
package/esm/dif/type-registry.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module implements the TypeRegistry and TypeBinding classes which allow registering custom type definitions and bindings to JS implementations.
|
|
3
|
+
*/
|
|
1
4
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
5
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
6
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -9,10 +12,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
12
|
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
13
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
14
|
};
|
|
12
|
-
var _TypeRegistry_difHandler,
|
|
15
|
+
var _TypeRegistry_difHandler, _TypeRegistry_typePointerAddressBindings, _TypeRegistry_coreLibTypeIdBindings, _TypeBinding_difHandler, _TypeBinding_definition;
|
|
13
16
|
import { DEBUG_MODE } from "../global.js";
|
|
14
|
-
import { DIFUpdateKind } from "./
|
|
15
|
-
import { IS_PROXY_ACCESS } from "./dif-handler.js";
|
|
17
|
+
import { DIFUpdateKind } from "./types/mod.js";
|
|
18
|
+
import { IS_PROXY_ACCESS, } from "./dif-handler.js";
|
|
16
19
|
// interface GetProperty<K,V> = {
|
|
17
20
|
// function getProperty<K>(self: Type, key: K) -> X;
|
|
18
21
|
// }
|
|
@@ -33,7 +36,8 @@ import { IS_PROXY_ACCESS } from "./dif-handler.js";
|
|
|
33
36
|
export class TypeRegistry {
|
|
34
37
|
constructor(difHandler) {
|
|
35
38
|
_TypeRegistry_difHandler.set(this, void 0);
|
|
36
|
-
|
|
39
|
+
_TypeRegistry_typePointerAddressBindings.set(this, new Map());
|
|
40
|
+
_TypeRegistry_coreLibTypeIdBindings.set(this, new Map());
|
|
37
41
|
__classPrivateFieldSet(this, _TypeRegistry_difHandler, difHandler, "f");
|
|
38
42
|
}
|
|
39
43
|
/**
|
|
@@ -48,29 +52,35 @@ export class TypeRegistry {
|
|
|
48
52
|
* @param typePointerAddress The address of the type pointer in the Datex runtime.
|
|
49
53
|
*/
|
|
50
54
|
registerTypeBinding(typeBindingDefinition) {
|
|
51
|
-
|
|
55
|
+
const binding = new TypeBinding(typeBindingDefinition, __classPrivateFieldGet(this, _TypeRegistry_difHandler, "f"));
|
|
56
|
+
if (typeBindingDefinition.pointerAddress != null) {
|
|
57
|
+
__classPrivateFieldGet(this, _TypeRegistry_typePointerAddressBindings, "f").set(typeBindingDefinition.pointerAddress, binding);
|
|
58
|
+
}
|
|
59
|
+
else if (typeBindingDefinition.coreLibTypeId != null) {
|
|
60
|
+
__classPrivateFieldGet(this, _TypeRegistry_coreLibTypeIdBindings, "f").set(typeBindingDefinition.coreLibTypeId, binding);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error("TypeBindingDefinition must have either pointerAddress or coreLibTypeId defined");
|
|
64
|
+
}
|
|
52
65
|
}
|
|
53
66
|
/**
|
|
54
|
-
* @private
|
|
55
67
|
* Gets the type binding for a given type pointer address.
|
|
68
|
+
* @param typePointerAddress The pointer address of the type in the Datex runtime.
|
|
69
|
+
* @returns The corresponding TypeBinding or null if no binding is found for the given pointer address.
|
|
56
70
|
*/
|
|
57
|
-
|
|
58
|
-
return __classPrivateFieldGet(this,
|
|
71
|
+
getTypeBinding(typePointerAddress) {
|
|
72
|
+
return __classPrivateFieldGet(this, _TypeRegistry_typePointerAddressBindings, "f").get(typePointerAddress) || null;
|
|
59
73
|
}
|
|
60
74
|
/**
|
|
61
|
-
* Gets the type binding for a given type
|
|
75
|
+
* Gets the type binding for a given core library type id.
|
|
76
|
+
* @param coreLibTypeId
|
|
77
|
+
* @returns
|
|
62
78
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (typeBinding) {
|
|
66
|
-
return typeBinding;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
79
|
+
getTypeBindingByCoreLibTypeId(coreLibTypeId) {
|
|
80
|
+
return __classPrivateFieldGet(this, _TypeRegistry_coreLibTypeIdBindings, "f").get(coreLibTypeId) || null;
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
|
-
_TypeRegistry_difHandler = new WeakMap(),
|
|
83
|
+
_TypeRegistry_difHandler = new WeakMap(), _TypeRegistry_typePointerAddressBindings = new WeakMap(), _TypeRegistry_coreLibTypeIdBindings = new WeakMap();
|
|
74
84
|
export class TypeBinding {
|
|
75
85
|
get difHandler() {
|
|
76
86
|
return __classPrivateFieldGet(this, _TypeBinding_difHandler, "f");
|
|
@@ -96,36 +106,38 @@ export class TypeBinding {
|
|
|
96
106
|
/**
|
|
97
107
|
* Sets up observers for the given value and pointer address if there are update handlers defined for this type binding.
|
|
98
108
|
*/
|
|
99
|
-
handleDifUpdate(
|
|
109
|
+
handleDifUpdate(val, pointerAddress, difUpdateData) {
|
|
100
110
|
const updateHandlerTypes = this.getUpdateHandlerTypes();
|
|
101
111
|
// add observer if there are update handlers
|
|
102
112
|
if (updateHandlerTypes.size > 0) {
|
|
113
|
+
const value = val;
|
|
103
114
|
console.log("got update for pointer:", pointerAddress, difUpdateData);
|
|
104
115
|
this.allowOriginalValueAccess(value, () => {
|
|
105
116
|
// call appropriate handler based on update kind
|
|
106
|
-
if (difUpdateData
|
|
117
|
+
if (difUpdateData[0] === DIFUpdateKind.SetEntry &&
|
|
107
118
|
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleSet) {
|
|
108
|
-
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleSet.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").
|
|
119
|
+
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleSet.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").resolveDIFProperty(difUpdateData[1]), __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").resolveDIFValueContainer(difUpdateData[2]));
|
|
109
120
|
}
|
|
110
|
-
else if (difUpdateData
|
|
121
|
+
else if (difUpdateData[0] === DIFUpdateKind.AppendEntry &&
|
|
111
122
|
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleAppend) {
|
|
112
|
-
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleAppend.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").
|
|
123
|
+
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleAppend.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").resolveDIFValueContainer(difUpdateData[1]));
|
|
113
124
|
}
|
|
114
|
-
else if (difUpdateData
|
|
125
|
+
else if (difUpdateData[0] === DIFUpdateKind.Replace &&
|
|
115
126
|
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleReplace) {
|
|
116
|
-
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleReplace.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").
|
|
127
|
+
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleReplace.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").resolveDIFValueContainer(difUpdateData[1]));
|
|
117
128
|
}
|
|
118
|
-
else if (difUpdateData
|
|
129
|
+
else if (difUpdateData[0] === DIFUpdateKind.DeleteEntry &&
|
|
119
130
|
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleDelete) {
|
|
120
|
-
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleDelete.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").
|
|
131
|
+
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleDelete.call(this, value, __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").resolveDIFProperty(difUpdateData[1]));
|
|
121
132
|
}
|
|
122
|
-
else if (difUpdateData
|
|
133
|
+
else if (difUpdateData[0] === DIFUpdateKind.Clear &&
|
|
123
134
|
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleClear) {
|
|
124
135
|
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleClear.call(this, value);
|
|
125
136
|
}
|
|
126
|
-
else if (difUpdateData
|
|
137
|
+
else if (difUpdateData[0] === DIFUpdateKind.ListSplice &&
|
|
127
138
|
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleListSplice) {
|
|
128
|
-
|
|
139
|
+
console.log("handling list splice with items:", difUpdateData);
|
|
140
|
+
__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleListSplice.call(this, value, difUpdateData[1], difUpdateData[2], difUpdateData[3].map((item) => __classPrivateFieldGet(this, _TypeBinding_difHandler, "f").resolveDIFValueContainer(item)));
|
|
129
141
|
}
|
|
130
142
|
});
|
|
131
143
|
}
|
|
@@ -133,16 +145,16 @@ export class TypeBinding {
|
|
|
133
145
|
getUpdateHandlerTypes() {
|
|
134
146
|
const updateHandlerTypes = new Set();
|
|
135
147
|
if (__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleSet) {
|
|
136
|
-
updateHandlerTypes.add(DIFUpdateKind.
|
|
148
|
+
updateHandlerTypes.add(DIFUpdateKind.SetEntry);
|
|
137
149
|
}
|
|
138
150
|
if (__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleAppend) {
|
|
139
|
-
updateHandlerTypes.add(DIFUpdateKind.
|
|
151
|
+
updateHandlerTypes.add(DIFUpdateKind.AppendEntry);
|
|
140
152
|
}
|
|
141
153
|
if (__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleReplace) {
|
|
142
154
|
updateHandlerTypes.add(DIFUpdateKind.Replace);
|
|
143
155
|
}
|
|
144
156
|
if (__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleDelete) {
|
|
145
|
-
updateHandlerTypes.add(DIFUpdateKind.
|
|
157
|
+
updateHandlerTypes.add(DIFUpdateKind.DeleteEntry);
|
|
146
158
|
}
|
|
147
159
|
if (__classPrivateFieldGet(this, _TypeBinding_definition, "f").handleClear) {
|
|
148
160
|
updateHandlerTypes.add(DIFUpdateKind.Clear);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module DIF Types
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains all type definitions related to the representation of types and values in DIF.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./type.js";
|
|
7
|
+
export * from "./value.js";
|
|
8
|
+
export * from "./update.js";
|
|
9
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/dif/types/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module DIF Types
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains all type definitions related to the representation of types in DIF.
|
|
5
|
+
*/
|
|
6
|
+
import type { PointerAddress, SharedContainerMutability } from "../../shared-container/mod.js";
|
|
7
|
+
import type { CoreLibTypeId } from "../core.js";
|
|
8
|
+
/**
|
|
9
|
+
* A core lib is directly serialized as number.
|
|
10
|
+
*/
|
|
11
|
+
type DIFCoreLibTypeDefinition = CoreLibTypeId;
|
|
12
|
+
export type DIFTypeDefinitionMap = {
|
|
13
|
+
literal: DIFLiteralTypeDefinition;
|
|
14
|
+
list: DIFListTypeDefinition;
|
|
15
|
+
map: DIFMapTypeDefinition;
|
|
16
|
+
range: DIFRangeTypeDefinition;
|
|
17
|
+
collection: DIFCollectionTypeDefinition;
|
|
18
|
+
shared: DIFSharedTypeDefinition;
|
|
19
|
+
nested: DIFNestedTypeDefinition;
|
|
20
|
+
callable: DIFCallableTypeDefinition;
|
|
21
|
+
impl_type: DIFImplTypeDefinition;
|
|
22
|
+
intersection: DIFIntersectionTypeDefinition;
|
|
23
|
+
union: DIFUnionTypeDefinition;
|
|
24
|
+
tagged_type: DIFTaggedTypeDefinition;
|
|
25
|
+
marker_type: DIFTypeMarker;
|
|
26
|
+
};
|
|
27
|
+
export type DIFTypeKey = keyof DIFTypeDefinitionMap;
|
|
28
|
+
export declare const DIFLocalMutability: {
|
|
29
|
+
readonly Immutable: 0;
|
|
30
|
+
readonly Mutable: 1;
|
|
31
|
+
};
|
|
32
|
+
export type DIFLocalMutability = typeof DIFLocalMutability[keyof typeof DIFLocalMutability];
|
|
33
|
+
export declare const DIFLocalOwnership: {
|
|
34
|
+
readonly Immutable: 0;
|
|
35
|
+
readonly Mutable: 1;
|
|
36
|
+
readonly Owned: null;
|
|
37
|
+
};
|
|
38
|
+
export type DIFLocalOwnership = typeof DIFLocalOwnership[keyof typeof DIFLocalOwnership];
|
|
39
|
+
export declare const DIFSharedContainerOwnership: {
|
|
40
|
+
readonly Immutable: 0;
|
|
41
|
+
readonly Mutable: 1;
|
|
42
|
+
readonly Owned: null;
|
|
43
|
+
};
|
|
44
|
+
export type DIFSharedContainerOwnership = typeof DIFSharedContainerOwnership[keyof typeof DIFSharedContainerOwnership];
|
|
45
|
+
export type DIFTypeMetadata = {
|
|
46
|
+
kind: "local";
|
|
47
|
+
mutability: DIFLocalMutability;
|
|
48
|
+
ownership?: DIFLocalOwnership;
|
|
49
|
+
} | {
|
|
50
|
+
kind: "shared";
|
|
51
|
+
mutability: SharedContainerMutability;
|
|
52
|
+
ownership: DIFSharedContainerOwnership;
|
|
53
|
+
};
|
|
54
|
+
export type DIFTypeDefinitionWithMetadata = [
|
|
55
|
+
DIFTypeMetadata,
|
|
56
|
+
DIFTypeDefinition
|
|
57
|
+
];
|
|
58
|
+
export type SharedContainerContainingNominalType = string;
|
|
59
|
+
export type DIFType = DIFTypeDefinitionWithMetadata | SharedContainerContainingNominalType | CoreLibTypeId;
|
|
60
|
+
/**
|
|
61
|
+
* Creates an immutable local DIFType for a given DIFTypeDefinition.
|
|
62
|
+
* @param def The DIFTypeDefinition to create the DIFType for.
|
|
63
|
+
* @returns A DIFType with the given definition and immutable local metadata.
|
|
64
|
+
*/
|
|
65
|
+
export declare function defaultDIFTypeForDefinition(def: DIFTypeDefinition): DIFType;
|
|
66
|
+
/**
|
|
67
|
+
* The DIFTypeDefinition represents a structural (only for now) type definition in the DIF format.
|
|
68
|
+
*/
|
|
69
|
+
export type DIFTypeDefinition = DIFCoreLibTypeDefinition | {
|
|
70
|
+
[K in keyof DIFTypeDefinitionMap]: {
|
|
71
|
+
[P in K]: DIFTypeDefinitionMap[K];
|
|
72
|
+
};
|
|
73
|
+
}[keyof DIFTypeDefinitionMap];
|
|
74
|
+
export type DIFLiteralTypeDefinition = boolean | string | [typeof CoreLibTypeId.integer, number] | [typeof CoreLibTypeId.integer_u8, number] | [typeof CoreLibTypeId.integer_u16, number] | [typeof CoreLibTypeId.integer_u32, number] | [typeof CoreLibTypeId.integer_u64, number] | [typeof CoreLibTypeId.integer_u128, string] | [typeof CoreLibTypeId.integer_i8, number] | [typeof CoreLibTypeId.integer_i16, number] | [typeof CoreLibTypeId.integer_i32, number] | [typeof CoreLibTypeId.integer_i64, number] | [typeof CoreLibTypeId.integer_i128, string] | [typeof CoreLibTypeId.integer_ibig, string] | [typeof CoreLibTypeId.decimal, string] | [typeof CoreLibTypeId.decimal_f32, "nan" | "infinity" | "-infinity" | number] | [typeof CoreLibTypeId.decimal_f64, "nan" | "infinity" | "-infinity" | number] | [typeof CoreLibTypeId.decimal_dbig, string] | [typeof CoreLibTypeId.endpoint, string];
|
|
75
|
+
export type DIFListTypeDefinition = DIFType[];
|
|
76
|
+
export type DIFMapTypeDefinition = Array<[DIFType, DIFType]>;
|
|
77
|
+
export type DIFRangeTypeDefinition = [DIFType, DIFType];
|
|
78
|
+
export type DIFNestedTypeDefinition = DIFType;
|
|
79
|
+
export type DIFImplTypeDefinition = [DIFType, Array<PointerAddress>];
|
|
80
|
+
export type DIFIntersectionTypeDefinition = Array<DIFType>;
|
|
81
|
+
export type DIFUnionTypeDefinition = Array<DIFType>;
|
|
82
|
+
export type DIFTaggedTypeDefinition = [string, DIFType];
|
|
83
|
+
export type DIFTypeMarker = "";
|
|
84
|
+
export type DIFSharedTypeDefinition = null;
|
|
85
|
+
export type DIFCallableTypeDefinition = null;
|
|
86
|
+
export type DIFCollectionTypeDefinition = DIFCollectionListTypeDefinition | DIFCollectionListSliceTypeDefinition | DIFCollectionMapTypeDefinition | DIFRangeTypeDefinition;
|
|
87
|
+
export type DIFCollectionListTypeDefinition = DIFType;
|
|
88
|
+
export type DIFCollectionListSliceTypeDefinition = [DIFType, number];
|
|
89
|
+
export type DIFCollectionMapTypeDefinition = Array<[DIFType, DIFType]>;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/dif/types/type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;GAEG;AACH,KAAK,wBAAwB,GAAG,aAAa,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG;IAC/B,OAAO,EAAE,wBAAwB,CAAC;IAClC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,GAAG,EAAE,oBAAoB,CAAC;IAC1B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,UAAU,EAAE,2BAA2B,CAAC;IACxC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,uBAAuB,CAAC;IAChC,QAAQ,EAAE,yBAAyB,CAAC;IACpC,SAAS,EAAE,qBAAqB,CAAC;IACjC,YAAY,EAAE,6BAA6B,CAAC;IAC5C,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,uBAAuB,CAAC;IACrC,WAAW,EAAE,aAAa,CAAC;CAC9B,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE5F,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC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C;AAEpD,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,EAAE,CAAC;AAE/B,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAC3C,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAE7C,MAAM,MAAM,2BAA2B,GACjC,+BAA+B,GAC/B,oCAAoC,GACpC,8BAA8B,GAC9B,sBAAsB,CAAC;AAE7B,MAAM,MAAM,+BAA+B,GAAG,OAAO,CAAC;AACtD,MAAM,MAAM,oCAAoC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACrE,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module DIF Types
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains all type definitions related to the representation of types in DIF.
|
|
5
|
+
*/
|
|
6
|
+
export const DIFLocalMutability = {
|
|
7
|
+
Immutable: 0,
|
|
8
|
+
Mutable: 1,
|
|
9
|
+
};
|
|
10
|
+
export const DIFLocalOwnership = {
|
|
11
|
+
Immutable: 0,
|
|
12
|
+
Mutable: 1,
|
|
13
|
+
Owned: null,
|
|
14
|
+
};
|
|
15
|
+
export const DIFSharedContainerOwnership = {
|
|
16
|
+
Immutable: 0,
|
|
17
|
+
Mutable: 1,
|
|
18
|
+
Owned: null,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Creates an immutable local DIFType for a given DIFTypeDefinition.
|
|
22
|
+
* @param def The DIFTypeDefinition to create the DIFType for.
|
|
23
|
+
* @returns A DIFType with the given definition and immutable local metadata.
|
|
24
|
+
*/
|
|
25
|
+
export function defaultDIFTypeForDefinition(def) {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
kind: "local",
|
|
29
|
+
mutability: DIFLocalMutability.Immutable,
|
|
30
|
+
},
|
|
31
|
+
def,
|
|
32
|
+
];
|
|
33
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module DIF Update Types
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains all type definitions related to the representation of updates in DIF.
|
|
5
|
+
*/
|
|
6
|
+
import type { DIFValueContainer } from "./value.js";
|
|
7
|
+
/**
|
|
8
|
+
* Representation of a property in DIF, which can be a text key, an index, or a generic value.
|
|
9
|
+
*/
|
|
10
|
+
export type DIFProperty = string | number | {
|
|
11
|
+
value: DIFValueContainer;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Kinds of updates that can be applied to a DIF value.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DIFUpdateKind: {
|
|
17
|
+
readonly Replace: "replace";
|
|
18
|
+
readonly AppendEntry: "append_entry";
|
|
19
|
+
readonly SetEntry: "set_entry";
|
|
20
|
+
readonly DeleteEntry: "delete_entry";
|
|
21
|
+
readonly Clear: "clear";
|
|
22
|
+
readonly ListSplice: "list_splice";
|
|
23
|
+
};
|
|
24
|
+
/** A DIF update kind. */
|
|
25
|
+
export type DIFUpdateKind = typeof DIFUpdateKind[keyof typeof DIFUpdateKind];
|
|
26
|
+
/** Different kinds of updates that can be applied to a DIF value. */
|
|
27
|
+
export type DIFUpdateBaseData<Kind extends DIFUpdateKind> = {
|
|
28
|
+
kind: Kind;
|
|
29
|
+
};
|
|
30
|
+
export type DIFUpdateDataReplace = [DIFValueContainer];
|
|
31
|
+
export type DIFUpdateDataPush = [DIFValueContainer];
|
|
32
|
+
export type DIFUpdateDataDelete = [DIFProperty];
|
|
33
|
+
export type DIFUpdateDataSet = [DIFProperty, DIFValueContainer];
|
|
34
|
+
export type DIFUpdateDataListSplice = [number, number, DIFValueContainer[]];
|
|
35
|
+
export type DIFUpdateReturn = ["none"] | ["single_value", DIFValueContainer] | [
|
|
36
|
+
"multiple_values",
|
|
37
|
+
...DIFValueContainer[]
|
|
38
|
+
];
|
|
39
|
+
export type DIFUpdateData = [
|
|
40
|
+
typeof DIFUpdateKind.Replace,
|
|
41
|
+
...DIFUpdateDataReplace
|
|
42
|
+
] | [
|
|
43
|
+
typeof DIFUpdateKind.AppendEntry,
|
|
44
|
+
...DIFUpdateDataPush
|
|
45
|
+
] | [
|
|
46
|
+
typeof DIFUpdateKind.DeleteEntry,
|
|
47
|
+
...DIFUpdateDataDelete
|
|
48
|
+
] | [
|
|
49
|
+
typeof DIFUpdateKind.SetEntry,
|
|
50
|
+
...DIFUpdateDataSet
|
|
51
|
+
] | [
|
|
52
|
+
typeof DIFUpdateKind.Clear
|
|
53
|
+
] | [
|
|
54
|
+
typeof DIFUpdateKind.ListSplice,
|
|
55
|
+
...DIFUpdateDataListSplice
|
|
56
|
+
];
|
|
57
|
+
export type DIFTransceiverId = number;
|
|
58
|
+
export type DIFUpdate = [DIFTransceiverId, ...DIFUpdateData];
|
|
59
|
+
/** Options for observing DIF pointers. */
|
|
60
|
+
export type ObserveOptions = {
|
|
61
|
+
relay_own_updates: boolean;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/dif/types/update.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,WAAW,GACjB,MAAM,GACN,MAAM,GACN;IAAE,KAAK,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AACX,yBAAyB;AACzB,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E,qEAAqE;AACrE,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,aAAa,IAAI;IAC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ions related to the representation of updates in DIF.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Kinds of updates that can be applied to a DIF value.
|
|
8
|
+
*/
|
|
9
|
+
export const DIFUpdateKind = {
|
|
10
|
+
Replace: "replace",
|
|
11
|
+
AppendEntry: "append_entry",
|
|
12
|
+
SetEntry: "set_entry",
|
|
13
|
+
DeleteEntry: "delete_entry",
|
|
14
|
+
Clear: "clear",
|
|
15
|
+
ListSplice: "list_splice",
|
|
16
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module DIF Value Types
|
|
3
|
+
* @description
|
|
4
|
+
* This module contains all type definitions related to the representation of values in DIF.
|
|
5
|
+
*/
|
|
6
|
+
import type { PointerAddressWithOwnership, SharedContainerMutability } from "../../shared-container/mod.js";
|
|
7
|
+
import type { CoreLibTypeId } from "../core.js";
|
|
8
|
+
import type { DIFTypeDefinition } from "./type.js";
|
|
9
|
+
/**
|
|
10
|
+
* An optional DIF value container, which can either be null or contain a DIFValueContainer. This is used to represent values that may be absent or optional in certain contexts within the DIF system.
|
|
11
|
+
*/
|
|
12
|
+
export type DIFOptionalValueContainer = null | [DIFValueContainer];
|
|
13
|
+
/**
|
|
14
|
+
* DIF value container, which can be either a pointer address or a value.
|
|
15
|
+
*/
|
|
16
|
+
export type DIFValueContainer<T = unknown> = DIFPointerAddress | DIFValue;
|
|
17
|
+
/**
|
|
18
|
+
* A DATEX pointer address representation in the DIF format.
|
|
19
|
+
*/
|
|
20
|
+
export type DIFPointerAddress = {
|
|
21
|
+
$: PointerAddressWithOwnership;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A DIF value, which can be directly represented in the DIF format (e.g., primitive types) or a value including
|
|
25
|
+
* additional type information.
|
|
26
|
+
*/
|
|
27
|
+
export type DIFValue = DIFDirectRepresentationValue | [CoreLibTypeId, DIFCoreValue] | [CoreLibTypeId, DIFCoreValue, DIFTypeDefinition];
|
|
28
|
+
/**
|
|
29
|
+
* Types of values that can be directly represented in DIF without
|
|
30
|
+
* additional type information (e.g., for primitive types like text, f64, boolean, and null).
|
|
31
|
+
*/
|
|
32
|
+
export type DIFDirectRepresentationValue = boolean | string | number | null;
|
|
33
|
+
/**
|
|
34
|
+
* Represents a list of DIFValueContainers.
|
|
35
|
+
*/
|
|
36
|
+
export type DIFCoreValueList = Array<DIFValueContainer>;
|
|
37
|
+
/**
|
|
38
|
+
* Represents a map of key-value pairs in DIF, where both keys and values are DIFValueContainers.
|
|
39
|
+
*/
|
|
40
|
+
export type DIFCoreValueMap = Array<[DIFValueContainer, DIFValueContainer]>;
|
|
41
|
+
/**
|
|
42
|
+
* Represents a range of values in DIF, defined by a start and end value container, or as a tuple of two value containers.
|
|
43
|
+
*/
|
|
44
|
+
export type DIFCoreValueRange = [DIFValueContainer, DIFValueContainer] | {
|
|
45
|
+
start: DIFValueContainer;
|
|
46
|
+
end: DIFValueContainer;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Represents a core value in DIF, which can be a primitive value, a structured object, a list, or a map.
|
|
50
|
+
*/
|
|
51
|
+
export type DIFCoreValue = DIFCoreValueList | DIFCoreValueMap | DIFCoreValueRange | Record<string, DIFValueContainer> | string | number | boolean | null;
|
|
52
|
+
/**
|
|
53
|
+
* Base struct for the shared value container.
|
|
54
|
+
* The allowed type is optional and can be used to specify the type of value that can be stored in the container.
|
|
55
|
+
* If the allowed type is not provided, it means that the type is inferred based on the provided value container.
|
|
56
|
+
*/
|
|
57
|
+
export type DIFBaseSharedValueContainer = [
|
|
58
|
+
DIFValueContainer,
|
|
59
|
+
SharedContainerMutability,
|
|
60
|
+
DIFTypeDefinition
|
|
61
|
+
];
|
|
62
|
+
//# sourceMappingURL=value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../../src/dif/types/value.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAA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,GAAG;IACtC,iBAAiB;IACjB,yBAAyB;IACzB,iBAAiB;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper methods for creating update data dif structures.
|
|
3
|
+
*/
|
|
4
|
+
import type { DIFProperty, DIFValueContainer } from "./types/mod.js";
|
|
5
|
+
import { type DIFUpdateData } from "./types/update.js";
|
|
6
|
+
export declare enum DIFPropertyKind {
|
|
7
|
+
Index = 0,
|
|
8
|
+
Text = 1,
|
|
9
|
+
ValueContainer = 2
|
|
10
|
+
}
|
|
11
|
+
export declare function createDIFProperty(value: string | number | DIFValueContainer, propertyKind: DIFPropertyKind): string | number | {
|
|
12
|
+
value: DIFValueContainer<T>;
|
|
13
|
+
};
|
|
14
|
+
export declare function clear(): DIFUpdateData;
|
|
15
|
+
export declare function replace(value: DIFValueContainer): DIFUpdateData;
|
|
16
|
+
export declare function appendEntry(value: DIFValueContainer): DIFUpdateData;
|
|
17
|
+
export declare function setEntry(key: DIFProperty, value: DIFValueContainer): DIFUpdateData;
|
|
18
|
+
export declare function deleteEntry(key: DIFProperty): DIFUpdateData;
|
|
19
|
+
export declare function listSplice(start: number, deleteCount: number, items: DIFValueContainer[]): DIFUpdateData;
|
|
20
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/dif/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,mBAAmB,CAAC;AAEtE,oBAAY,eAAe;IACvB,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,cAAc,IAAA;CACjB;AACD,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,iBAAiB,EAC1C,YAAY,EAAE,eAAe;;EAgBhC;AAED,wBAAgB,KAAK,IAAI,aAAa,CAErC;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,CAE/D;AACD,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,CAEnE;AACD,wBAAgB,QAAQ,CACpB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,iBAAiB,GACzB,aAAa,CAEf;AACD,wBAAgB,WAAW,CACvB,GAAG,EAAE,WAAW,GACjB,aAAa,CAEf;AACD,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,iBAAiB,EAAE,GAC3B,aAAa,CAEf"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DIFUpdateKind } from "./types/update.js";
|
|
2
|
+
export var DIFPropertyKind;
|
|
3
|
+
(function (DIFPropertyKind) {
|
|
4
|
+
DIFPropertyKind[DIFPropertyKind["Index"] = 0] = "Index";
|
|
5
|
+
DIFPropertyKind[DIFPropertyKind["Text"] = 1] = "Text";
|
|
6
|
+
DIFPropertyKind[DIFPropertyKind["ValueContainer"] = 2] = "ValueContainer";
|
|
7
|
+
})(DIFPropertyKind || (DIFPropertyKind = {}));
|
|
8
|
+
export function createDIFProperty(value, propertyKind) {
|
|
9
|
+
switch (propertyKind) {
|
|
10
|
+
case DIFPropertyKind.Index:
|
|
11
|
+
if (typeof value !== "number") {
|
|
12
|
+
throw new Error("Expected number for index property");
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
case DIFPropertyKind.Text:
|
|
16
|
+
if (typeof value !== "string") {
|
|
17
|
+
throw new Error("Expected string for text property");
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
case DIFPropertyKind.ValueContainer:
|
|
21
|
+
return { value };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function clear() {
|
|
25
|
+
return [DIFUpdateKind.Clear];
|
|
26
|
+
}
|
|
27
|
+
export function replace(value) {
|
|
28
|
+
return [DIFUpdateKind.Replace, value];
|
|
29
|
+
}
|
|
30
|
+
export function appendEntry(value) {
|
|
31
|
+
return [DIFUpdateKind.AppendEntry, value];
|
|
32
|
+
}
|
|
33
|
+
export function setEntry(key, value) {
|
|
34
|
+
return [DIFUpdateKind.SetEntry, key, value];
|
|
35
|
+
}
|
|
36
|
+
export function deleteEntry(key) {
|
|
37
|
+
return [DIFUpdateKind.DeleteEntry, key];
|
|
38
|
+
}
|
|
39
|
+
export function listSplice(start, deleteCount, items) {
|
|
40
|
+
return [DIFUpdateKind.ListSplice, start, deleteCount, items];
|
|
41
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions DIF
|
|
3
|
+
*/
|
|
4
|
+
import type { Option } from "../utils/option.js";
|
|
5
|
+
export declare function getAllKeys(obj: object): Set<(string | symbol)>;
|
|
6
|
+
export declare function getOwnPropertyDescriptorInPrototypeChain(obj: object, key: string | symbol): PropertyDescriptor | undefined;
|
|
7
|
+
export declare function interceptAccessors(originalObject: object, getHandler?: ((key: string | symbol) => Option<unknown>) | null, setHandler?: ((key: string | symbol, value: unknown) => void) | null, keys?: Iterable<string | symbol>): void;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/dif/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAY9D;AAED,wBAAgB,wCAAwC,CACpD,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GAAG,MAAM,GACrB,kBAAkB,GAAG,SAAS,CAUhC;AAED,wBAAgB,kBAAkB,CAC9B,cAAc,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,EAC/D,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,EACpE,IAAI,GAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,CAA8B,QA6E/D"}
|
package/esm/dif/utils.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export function getAllKeys(obj) {
|
|
2
|
+
const keys = new Set();
|
|
3
|
+
let currentObj = obj;
|
|
4
|
+
while (currentObj && currentObj !== Object.prototype) {
|
|
5
|
+
for (const key of Reflect.ownKeys(currentObj)) {
|
|
6
|
+
keys.add(key);
|
|
7
|
+
}
|
|
8
|
+
currentObj = Object.getPrototypeOf(currentObj);
|
|
9
|
+
}
|
|
10
|
+
return keys;
|
|
11
|
+
}
|
|
12
|
+
export function getOwnPropertyDescriptorInPrototypeChain(obj, key) {
|
|
13
|
+
let currentObj = obj;
|
|
14
|
+
while (currentObj && currentObj !== Object.prototype) {
|
|
15
|
+
const descriptor = Object.getOwnPropertyDescriptor(currentObj, key);
|
|
16
|
+
if (descriptor) {
|
|
17
|
+
return descriptor;
|
|
18
|
+
}
|
|
19
|
+
currentObj = Object.getPrototypeOf(currentObj);
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
export function interceptAccessors(originalObject, getHandler, setHandler, keys = getAllKeys(originalObject)) {
|
|
24
|
+
const shadowObject = Array.isArray(originalObject) ? [] : {};
|
|
25
|
+
function addPropertyInterceptor(originalDescriptor, key) {
|
|
26
|
+
return {
|
|
27
|
+
get() {
|
|
28
|
+
if (getHandler) {
|
|
29
|
+
const result = getHandler(key);
|
|
30
|
+
if (result.isSome()) {
|
|
31
|
+
return result.unwrap();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return shadowObject[key];
|
|
35
|
+
},
|
|
36
|
+
set(value) {
|
|
37
|
+
if (setHandler) {
|
|
38
|
+
setHandler(key, value);
|
|
39
|
+
}
|
|
40
|
+
shadowObject[key] = value;
|
|
41
|
+
},
|
|
42
|
+
enumerable: originalDescriptor?.enumerable,
|
|
43
|
+
configurable: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
for (const key of keys) {
|
|
47
|
+
const originalDescriptor = getOwnPropertyDescriptorInPrototypeChain(originalObject, key);
|
|
48
|
+
// assign property directly to shadow object if non-configurable and no getter/setter
|
|
49
|
+
if (originalDescriptor && (("value" in originalDescriptor &&
|
|
50
|
+
originalDescriptor.writable) ||
|
|
51
|
+
!originalDescriptor.configurable)) {
|
|
52
|
+
shadowObject[key] = originalObject[key];
|
|
53
|
+
} // bind original getter/setter to shadow object
|
|
54
|
+
else if (originalDescriptor?.get || originalDescriptor?.set) {
|
|
55
|
+
Object.defineProperty(shadowObject, key, {
|
|
56
|
+
get: originalDescriptor.get ? originalDescriptor.get.bind(originalObject) : undefined,
|
|
57
|
+
set: originalDescriptor.set ? originalDescriptor.set.bind(originalObject) : undefined,
|
|
58
|
+
enumerable: originalDescriptor.enumerable,
|
|
59
|
+
configurable: true,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// only define interceptor if property is configurable
|
|
63
|
+
if (!originalDescriptor || originalDescriptor.configurable) {
|
|
64
|
+
Object.defineProperty(originalObject, key, addPropertyInterceptor(originalDescriptor, key));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/lib/js-core-types/array.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAaxE,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,CA8HlE,CAAC"}
|