@rootintf/protocol-2phw 2.3.7-api.2 → 3.0.13-api.2
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/README.md +384 -1
- package/dist/generated/iface-TwoPhW/index.d.mts +25 -0
- package/dist/generated/iface-TwoPhW/validate.d.cts +76 -0
- package/dist/generated/iface-TwoPhW/validate.d.mts +75 -0
- package/dist/twoPhW.cjs.js +419 -974
- package/dist/twoPhW.d.ts +51 -36
- package/dist/twoPhW.es.mjs +403 -970
- package/package.json +26 -17
- package/src/generated/.gitattributes +4 -0
- package/src/generated/iface-TwoPhW/index.cjs +26 -0
- package/src/generated/iface-TwoPhW/index.d.cts +25 -0
- package/src/generated/iface-TwoPhW/index.d.mts +25 -0
- package/src/generated/iface-TwoPhW/index.d.ts +25 -0
- package/src/generated/iface-TwoPhW/index.mjs +23 -0
- package/src/generated/iface-TwoPhW/package.json +36 -0
- package/src/generated/iface-TwoPhW/schema/schema_TwoPhW.json +131 -0
- package/src/generated/iface-TwoPhW/validate.cjs +1 -0
- package/src/generated/iface-TwoPhW/validate.mjs +1 -0
- package/src/generated/iface-introspection/index.cjs +13 -0
- package/src/generated/iface-introspection/index.d.cts +6 -0
- package/src/generated/iface-introspection/index.d.mts +6 -0
- package/src/generated/iface-introspection/index.d.ts +6 -0
- package/src/generated/iface-introspection/index.mjs +10 -0
- package/src/generated/iface-introspection/package.json +30 -0
- package/src/schema-cache/.gitattributes +4 -0
- package/src/schema-cache/5fdbd096ad99962b7e3d77cde8bd355fe180c859f35a61cfd07ee36b96c6700a.json +131 -0
- package/src/twoPhW.ts +770 -833
- package/dist/ajv-gen-validate.d.cts +0 -1
- package/dist/validate-esm.d.mts +0 -48
- package/schema/schema_2PhW.json +0 -61
- package/src/ajv-gen-validate.cjs +0 -40
- package/src/validate-esm.mjs +0 -1
package/dist/twoPhW.es.mjs
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
|
+
import { JSON_Eff, JSON_Msg, logr as logr$1, JSON_Ack } from '@rootintf/json-msg';
|
|
2
|
+
export { JSON_Ack, JSON_Eff, JSON_Msg } from '@rootintf/json-msg';
|
|
3
|
+
import { l_merge, l_concat, l_array, lRef, LOGR } from '@knev/bitlogr';
|
|
1
4
|
import { logr } from '@rootintf/eventlog';
|
|
2
5
|
|
|
3
|
-
const
|
|
4
|
-
function
|
|
6
|
+
const _v_JSON_MsgWarp = validate18;
|
|
7
|
+
function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
|
|
5
8
|
evaluated0.props = undefined;
|
|
6
9
|
} if (evaluated0.dynamicItems) {
|
|
7
10
|
evaluated0.items = undefined;
|
|
8
11
|
} {
|
|
9
12
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
10
13
|
let missing0;
|
|
11
|
-
if ((data.warp === undefined) && (missing0 = "warp")) {
|
|
12
|
-
|
|
14
|
+
if (((data.warp === undefined) && (missing0 = "warp")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
15
|
+
validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
13
16
|
return false;
|
|
14
17
|
}
|
|
15
18
|
else {
|
|
16
19
|
if (data.warp !== undefined) {
|
|
17
20
|
let data0 = data.warp;
|
|
18
|
-
const
|
|
21
|
+
const _errs3 = errors;
|
|
19
22
|
{
|
|
20
23
|
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
21
24
|
let missing1;
|
|
22
25
|
if (((((data0.id === undefined) && (missing1 = "id")) || ((data0.user === undefined) && (missing1 = "user"))) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))) || ((data0.ttl_msec === undefined) && (missing1 = "ttl_msec"))) {
|
|
23
|
-
|
|
26
|
+
validate18.errors = [{ instancePath: instancePath + "/warp", schemaPath: "#/properties/warp/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
26
29
|
else {
|
|
27
30
|
if (data0.id !== undefined) {
|
|
28
|
-
const
|
|
31
|
+
const _errs5 = errors;
|
|
29
32
|
if (typeof data0.id !== "string") {
|
|
30
|
-
|
|
33
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/id", schemaPath: "#/properties/warp/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
31
34
|
return false;
|
|
32
35
|
}
|
|
33
|
-
var valid1 =
|
|
36
|
+
var valid1 = _errs5 === errors;
|
|
34
37
|
}
|
|
35
38
|
else {
|
|
36
39
|
var valid1 = true;
|
|
@@ -38,24 +41,32 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
38
41
|
if (valid1) {
|
|
39
42
|
if (data0.ttl_msec !== undefined) {
|
|
40
43
|
let data2 = data0.ttl_msec;
|
|
41
|
-
const
|
|
44
|
+
const _errs7 = errors;
|
|
42
45
|
if (!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))) {
|
|
43
|
-
|
|
46
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/ttl_msec", schemaPath: "#/properties/warp/properties/ttl_msec/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
|
|
44
47
|
return false;
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
{
|
|
50
|
+
if ((typeof data2 == "number") && (isFinite(data2))) {
|
|
51
|
+
if (data2 <= 0 || isNaN(data2)) {
|
|
52
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/ttl_msec", schemaPath: "#/properties/warp/properties/ttl_msec/exclusiveMinimum", keyword: "exclusiveMinimum", params: { comparison: ">", limit: 0 }, message: "must be > 0" }];
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
var valid1 = _errs7 === errors;
|
|
47
58
|
}
|
|
48
59
|
else {
|
|
49
60
|
var valid1 = true;
|
|
50
61
|
}
|
|
51
62
|
if (valid1) {
|
|
52
63
|
if (data0.instantaneous !== undefined) {
|
|
53
|
-
const
|
|
64
|
+
const _errs9 = errors;
|
|
54
65
|
if (typeof data0.instantaneous !== "boolean") {
|
|
55
|
-
|
|
66
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/instantaneous", schemaPath: "#/properties/warp/properties/instantaneous/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
56
67
|
return false;
|
|
57
68
|
}
|
|
58
|
-
var valid1 =
|
|
69
|
+
var valid1 = _errs9 === errors;
|
|
59
70
|
}
|
|
60
71
|
else {
|
|
61
72
|
var valid1 = true;
|
|
@@ -65,23 +76,23 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
65
76
|
}
|
|
66
77
|
}
|
|
67
78
|
else {
|
|
68
|
-
|
|
79
|
+
validate18.errors = [{ instancePath: instancePath + "/warp", schemaPath: "#/properties/warp/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
69
80
|
return false;
|
|
70
81
|
}
|
|
71
82
|
}
|
|
72
|
-
var valid0 =
|
|
83
|
+
var valid0 = _errs3 === errors;
|
|
73
84
|
}
|
|
74
85
|
else {
|
|
75
86
|
var valid0 = true;
|
|
76
87
|
}
|
|
77
88
|
if (valid0) {
|
|
78
89
|
if (data["2PhW"] !== undefined) {
|
|
79
|
-
const
|
|
90
|
+
const _errs11 = errors;
|
|
80
91
|
if ("2" !== data["2PhW"]) {
|
|
81
|
-
|
|
92
|
+
validate18.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
82
93
|
return false;
|
|
83
94
|
}
|
|
84
|
-
var valid0 =
|
|
95
|
+
var valid0 = _errs11 === errors;
|
|
85
96
|
}
|
|
86
97
|
else {
|
|
87
98
|
var valid0 = true;
|
|
@@ -90,84 +101,61 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
90
101
|
}
|
|
91
102
|
}
|
|
92
103
|
else {
|
|
93
|
-
|
|
104
|
+
validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
94
105
|
return false;
|
|
95
106
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const
|
|
107
|
+
} validate18.errors = vErrors; return errors === 0; }
|
|
108
|
+
validate18.evaluated = { "props": { "warp": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
109
|
+
const _v_JSON_AckWarp = validate20;
|
|
99
110
|
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
100
111
|
evaluated0.props = undefined;
|
|
101
112
|
} if (evaluated0.dynamicItems) {
|
|
102
113
|
evaluated0.items = undefined;
|
|
103
|
-
} {
|
|
114
|
+
} if (errors === 0) {
|
|
104
115
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
105
116
|
let missing0;
|
|
106
|
-
if ((data.
|
|
117
|
+
if (((data.ack === undefined) && (missing0 = "ack")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
107
118
|
validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
108
119
|
return false;
|
|
109
120
|
}
|
|
110
121
|
else {
|
|
111
|
-
if (data.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
let missing1;
|
|
117
|
-
if (((data0.ok === undefined) && (missing1 = "ok")) || ((data0.rtt_msec === undefined) && (missing1 = "rtt_msec"))) {
|
|
118
|
-
validate20.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
if (data0.ok !== undefined) {
|
|
123
|
-
const _errs3 = errors;
|
|
124
|
-
if (typeof data0.ok !== "boolean") {
|
|
125
|
-
validate20.errors = [{ instancePath: instancePath + "/engage/ok", schemaPath: "#/properties/engage/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
var valid1 = _errs3 === errors;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
var valid1 = true;
|
|
132
|
-
}
|
|
133
|
-
if (valid1) {
|
|
134
|
-
if (data0.rtt_msec !== undefined) {
|
|
135
|
-
let data2 = data0.rtt_msec;
|
|
136
|
-
const _errs5 = errors;
|
|
137
|
-
if (!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))) {
|
|
138
|
-
validate20.errors = [{ instancePath: instancePath + "/engage/rtt_msec", schemaPath: "#/properties/engage/properties/rtt_msec/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
var valid1 = _errs5 === errors;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
var valid1 = true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
validate20.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
122
|
+
if (data._cause !== undefined) {
|
|
123
|
+
const _errs3 = errors;
|
|
124
|
+
if (!(validate18(data._cause, { instancePath: instancePath + "/_cause", parentData: data, parentDataProperty: "_cause", rootData, dynamicAnchors }))) {
|
|
125
|
+
vErrors = vErrors === null ? validate18.errors : vErrors.concat(validate18.errors);
|
|
126
|
+
errors = vErrors.length;
|
|
153
127
|
}
|
|
154
|
-
var valid0 =
|
|
128
|
+
var valid0 = _errs3 === errors;
|
|
155
129
|
}
|
|
156
130
|
else {
|
|
157
131
|
var valid0 = true;
|
|
158
132
|
}
|
|
159
133
|
if (valid0) {
|
|
160
|
-
if (data
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
134
|
+
if (data.ack !== undefined) {
|
|
135
|
+
let data1 = data.ack;
|
|
136
|
+
const _errs4 = errors;
|
|
137
|
+
if (!(data1 && typeof data1 == "object" && !Array.isArray(data1))) {
|
|
138
|
+
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
164
139
|
return false;
|
|
165
140
|
}
|
|
166
|
-
var valid0 =
|
|
141
|
+
var valid0 = _errs4 === errors;
|
|
167
142
|
}
|
|
168
143
|
else {
|
|
169
144
|
var valid0 = true;
|
|
170
145
|
}
|
|
146
|
+
if (valid0) {
|
|
147
|
+
if (data["2PhW"] !== undefined) {
|
|
148
|
+
const _errs6 = errors;
|
|
149
|
+
if ("2" !== data["2PhW"]) {
|
|
150
|
+
validate20.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
var valid0 = _errs6 === errors;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
var valid0 = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
171
159
|
}
|
|
172
160
|
}
|
|
173
161
|
}
|
|
@@ -176,757 +164,242 @@ function validate20(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
176
164
|
return false;
|
|
177
165
|
}
|
|
178
166
|
} validate20.errors = vErrors; return errors === 0; }
|
|
179
|
-
validate20.evaluated = { "props": { "
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (labels.length === 0)
|
|
192
|
-
return 1; // Empty object case, start at 1
|
|
193
|
-
const value_max = Math.max(...labels);
|
|
194
|
-
if (value_max <= 0)
|
|
195
|
-
return 1;
|
|
196
|
-
const bit_highest = Math.floor(Math.log2(value_max));
|
|
197
|
-
return 1 << (bit_highest + 1);
|
|
198
|
-
}
|
|
199
|
-
function l_array_(arr_labels, start = 1) {
|
|
200
|
-
if (!Array.isArray(arr_labels))
|
|
201
|
-
throw new Error('arr_labels must be an array');
|
|
202
|
-
if (!Number.isSafeInteger(start) || start < 0)
|
|
203
|
-
throw new Error('start must be a safe, non-negative integer');
|
|
204
|
-
return Object.freeze(arr_labels.reduce((acc, key, index) => {
|
|
205
|
-
acc[key] = start << index;
|
|
206
|
-
return acc;
|
|
207
|
-
}, {}));
|
|
208
|
-
}
|
|
209
|
-
function l_concat_(obj_labels, arg) {
|
|
210
|
-
if (!obj_labels || typeof obj_labels !== 'object')
|
|
211
|
-
throw new Error('obj_labels must be an object');
|
|
212
|
-
const obj_1label = Object.values(obj_labels);
|
|
213
|
-
if (!obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
|
|
214
|
-
throw new Error('All values must be finite numbers');
|
|
215
|
-
if (!arg || (typeof arg !== 'object' && !Array.isArray(arg)))
|
|
216
|
-
throw new Error('arg must be an object or array');
|
|
217
|
-
if (Array.isArray(arg)) {
|
|
218
|
-
const len = l_length_(obj_labels);
|
|
219
|
-
const arr_labels_new = l_array_(arg, len);
|
|
220
|
-
return l_concat_(obj_labels, arr_labels_new);
|
|
221
|
-
}
|
|
222
|
-
const next_pos = l_length_(obj_labels);
|
|
223
|
-
const arg_entries = Object.entries(arg);
|
|
224
|
-
const result = Object.create(null);
|
|
225
|
-
Object.entries(obj_labels).forEach(([k, v]) => {
|
|
226
|
-
if (k !== '__proto__' && k !== 'constructor')
|
|
227
|
-
result[k] = v;
|
|
228
|
-
});
|
|
229
|
-
let min_arg = Infinity;
|
|
230
|
-
for (const [, value] of arg_entries) {
|
|
231
|
-
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
232
|
-
continue; // Skip non-numeric
|
|
233
|
-
if (value > 0 && value < min_arg)
|
|
234
|
-
min_arg = value;
|
|
235
|
-
}
|
|
236
|
-
// Shift only if min_arg is less than next_pos
|
|
237
|
-
const shift = min_arg === Infinity || min_arg >= next_pos
|
|
238
|
-
? 0
|
|
239
|
-
: Math.floor(Math.log2(next_pos / min_arg));
|
|
240
|
-
for (const [key, value] of arg_entries) {
|
|
241
|
-
if (!(key in result)) {
|
|
242
|
-
result[key] = value === 0 ? 0 : value << shift;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return Object.freeze(result);
|
|
246
|
-
}
|
|
247
|
-
function l_merge_(obj_labels1, obj_labels2) {
|
|
248
|
-
if (!obj_labels1 || typeof obj_labels1 !== 'object')
|
|
249
|
-
throw new Error('obj_labels must be an object');
|
|
250
|
-
const obj_1label1 = Object.values(obj_labels1);
|
|
251
|
-
if (!obj_1label1.every(v => typeof v === 'number' && Number.isFinite(v)))
|
|
252
|
-
throw new Error('All values must be finite numbers');
|
|
253
|
-
if (!obj_labels2 || typeof obj_labels2 !== 'object')
|
|
254
|
-
throw new Error('obj_labels must be an object');
|
|
255
|
-
const obj_1label2 = Object.values(obj_labels2);
|
|
256
|
-
if (!obj_1label2.every(v => typeof v === 'number' && Number.isFinite(v)))
|
|
257
|
-
throw new Error('All values must be finite numbers');
|
|
258
|
-
const result = Object.create(null);
|
|
259
|
-
Object.entries(obj_labels1).forEach(([k, v]) => {
|
|
260
|
-
if (k !== '__proto__' && k !== 'constructor')
|
|
261
|
-
result[k] = v;
|
|
262
|
-
});
|
|
263
|
-
const set_values = new Set(Object.values(obj_labels1)); // Track all used bit values
|
|
264
|
-
// Find the highest bit position to start shifting from if needed
|
|
265
|
-
const value_highest = Math.max(0, ...Array.from(set_values));
|
|
266
|
-
let next_shift = value_highest ? Math.floor(Math.log2(value_highest)) + 1 : 0;
|
|
267
|
-
// Process second set
|
|
268
|
-
for (const [key, value] of Object.entries(obj_labels2)) {
|
|
269
|
-
if (key in result) {
|
|
270
|
-
// Same key: Values must match
|
|
271
|
-
if (result[key] !== value) {
|
|
272
|
-
throw new Error(`Key '${key}' has conflicting values: ${result[key]} (obj_labels1) vs ${value} (obj_labels2)`);
|
|
273
|
-
}
|
|
274
|
-
// No action needed if values match, already in result
|
|
167
|
+
validate20.evaluated = { "props": { "_cause": true, "ack": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
168
|
+
const _v_JSON_EffEngage = validate22;
|
|
169
|
+
function validate22(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate22.evaluated; if (evaluated0.dynamicProps) {
|
|
170
|
+
evaluated0.props = undefined;
|
|
171
|
+
} if (evaluated0.dynamicItems) {
|
|
172
|
+
evaluated0.items = undefined;
|
|
173
|
+
} if (errors === 0) {
|
|
174
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
175
|
+
let missing0;
|
|
176
|
+
if (((data.engage === undefined) && (missing0 = "engage")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
177
|
+
validate22.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
178
|
+
return false;
|
|
275
179
|
}
|
|
276
180
|
else {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
181
|
+
if (data._cause !== undefined) {
|
|
182
|
+
const _errs3 = errors;
|
|
183
|
+
if (!(validate18(data._cause, { instancePath: instancePath + "/_cause", parentData: data, parentDataProperty: "_cause", rootData, dynamicAnchors }))) {
|
|
184
|
+
vErrors = vErrors === null ? validate18.errors : vErrors.concat(validate18.errors);
|
|
185
|
+
errors = vErrors.length;
|
|
186
|
+
}
|
|
187
|
+
var valid0 = _errs3 === errors;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
var valid0 = true;
|
|
191
|
+
}
|
|
192
|
+
if (valid0) {
|
|
193
|
+
if (data.engage !== undefined) {
|
|
194
|
+
let data1 = data.engage;
|
|
195
|
+
const _errs4 = errors;
|
|
196
|
+
if (errors === _errs4) {
|
|
197
|
+
if (data1 && typeof data1 == "object" && !Array.isArray(data1)) {
|
|
198
|
+
let missing1;
|
|
199
|
+
if (((data1.ok === undefined) && (missing1 = "ok")) || ((data1.rtt_msec === undefined) && (missing1 = "rtt_msec"))) {
|
|
200
|
+
validate22.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
if (data1.ok !== undefined) {
|
|
205
|
+
const _errs6 = errors;
|
|
206
|
+
if (typeof data1.ok !== "boolean") {
|
|
207
|
+
validate22.errors = [{ instancePath: instancePath + "/engage/ok", schemaPath: "#/properties/engage/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
var valid1 = _errs6 === errors;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
var valid1 = true;
|
|
214
|
+
}
|
|
215
|
+
if (valid1) {
|
|
216
|
+
if (data1.rtt_msec !== undefined) {
|
|
217
|
+
let data3 = data1.rtt_msec;
|
|
218
|
+
const _errs8 = errors;
|
|
219
|
+
if (!(((typeof data3 == "number") && (!(data3 % 1) && !isNaN(data3))) && (isFinite(data3)))) {
|
|
220
|
+
validate22.errors = [{ instancePath: instancePath + "/engage/rtt_msec", schemaPath: "#/properties/engage/properties/rtt_msec/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
if (errors === _errs8) {
|
|
224
|
+
if ((typeof data3 == "number") && (isFinite(data3))) {
|
|
225
|
+
if (data3 < 0 || isNaN(data3)) {
|
|
226
|
+
validate22.errors = [{ instancePath: instancePath + "/engage/rtt_msec", schemaPath: "#/properties/engage/properties/rtt_msec/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
var valid1 = _errs8 === errors;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
var valid1 = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
validate22.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
var valid0 = _errs4 === errors;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
var valid0 = true;
|
|
248
|
+
}
|
|
249
|
+
if (valid0) {
|
|
250
|
+
if (data["2PhW"] !== undefined) {
|
|
251
|
+
const _errs10 = errors;
|
|
252
|
+
if ("2" !== data["2PhW"]) {
|
|
253
|
+
validate22.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
var valid0 = _errs10 === errors;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
var valid0 = true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
282
262
|
}
|
|
283
|
-
if (maxIterations <= 0)
|
|
284
|
-
throw new Error('Too many collisions in l_merge_');
|
|
285
|
-
result[key] = value_new;
|
|
286
|
-
set_values.add(value_new);
|
|
287
263
|
}
|
|
288
264
|
}
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
function l_LL_(obj, x) {
|
|
292
|
-
if (!obj || typeof obj !== 'object')
|
|
293
|
-
throw new Error('obj must be an object');
|
|
294
|
-
if (!Number.isSafeInteger(x) || x < 0)
|
|
295
|
-
throw new Error('Shift value must be a safe, non-negative integer');
|
|
296
|
-
const obj_new = {};
|
|
297
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
298
|
-
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
299
|
-
continue; // Skip non-numeric
|
|
300
|
-
obj_new[k] = v << x;
|
|
301
|
-
}
|
|
302
|
-
return Object.freeze(obj_new);
|
|
303
|
-
}
|
|
304
|
-
function l_RR_(obj, x) {
|
|
305
|
-
if (!obj || typeof obj !== 'object')
|
|
306
|
-
throw new Error('obj must be an object');
|
|
307
|
-
if (!Number.isSafeInteger(x) || x < 0)
|
|
308
|
-
throw new Error('Shift value must be a safe, non-negative integer');
|
|
309
|
-
const obj_new = {};
|
|
310
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
311
|
-
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
312
|
-
continue; // Skip non-numeric
|
|
313
|
-
obj_new[k] = v >> x;
|
|
314
|
-
}
|
|
315
|
-
return Object.freeze(obj_new);
|
|
316
|
-
}
|
|
317
|
-
function l_assert_(actual, required) {
|
|
318
|
-
if (!actual || typeof actual !== 'object')
|
|
319
|
-
return false;
|
|
320
|
-
if (!required || typeof required !== 'object')
|
|
265
|
+
else {
|
|
266
|
+
validate22.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
321
267
|
return false;
|
|
322
|
-
const actualEntries = Object.entries(actual);
|
|
323
|
-
const requiredEntries = Object.entries(required);
|
|
324
|
-
// if (actualEntries.length === 0 && expectedEntries.length > 0)
|
|
325
|
-
// return false;
|
|
326
|
-
const actualValues = new Set();
|
|
327
|
-
for (const [, v] of actualEntries) {
|
|
328
|
-
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
329
|
-
return false;
|
|
330
|
-
actualValues.add(v);
|
|
331
268
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
269
|
+
} validate22.errors = vErrors; return errors === 0; }
|
|
270
|
+
validate22.evaluated = { "props": { "_cause": true, "engage": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
271
|
+
const _v_JSON_AckEngage = validate24;
|
|
272
|
+
function validate24(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate24.evaluated; if (evaluated0.dynamicProps) {
|
|
273
|
+
evaluated0.props = undefined;
|
|
274
|
+
} if (evaluated0.dynamicItems) {
|
|
275
|
+
evaluated0.items = undefined;
|
|
276
|
+
} if (errors === 0) {
|
|
277
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
278
|
+
let missing0;
|
|
279
|
+
if (((data.ack === undefined) && (missing0 = "ack")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
280
|
+
validate24.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
335
281
|
return false;
|
|
336
|
-
if (k in actual) {
|
|
337
|
-
if (actual[k] !== v)
|
|
338
|
-
return false;
|
|
339
282
|
}
|
|
340
283
|
else {
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return true;
|
|
349
|
-
}
|
|
350
|
-
//-------------------------------------------------------------------------------------------------
|
|
351
|
-
function handler_default_( /* ... */) {
|
|
352
|
-
// https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
|
|
353
|
-
var args = Array.prototype.slice.call(arguments);
|
|
354
|
-
console.log.apply(console, args);
|
|
355
|
-
}
|
|
356
|
-
function l_toBigInt_(obj_labels, obj, ignore = false) {
|
|
357
|
-
if (!obj_labels || typeof obj_labels !== 'object')
|
|
358
|
-
throw new Error('obj_labels must be an object');
|
|
359
|
-
if (!obj || typeof obj !== 'object')
|
|
360
|
-
throw new Error('obj must be an object');
|
|
361
|
-
let bigint_l = BigInt(0);
|
|
362
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
363
|
-
if ((ignore || v) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
|
|
364
|
-
bigint_l |= BigInt(obj_labels[k]);
|
|
365
|
-
// console.log('0b'+ bigInt.toString(2) );
|
|
366
|
-
}
|
|
367
|
-
return bigint_l;
|
|
368
|
-
}
|
|
369
|
-
function lRef(initial) {
|
|
370
|
-
if (arguments.length === 0 || initial === undefined) {
|
|
371
|
-
return undefined;
|
|
372
|
-
}
|
|
373
|
-
let value = initial;
|
|
374
|
-
return {
|
|
375
|
-
get: () => value,
|
|
376
|
-
set: (newVal) => { value = newVal; }
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
/*
|
|
380
|
-
const l_ = {
|
|
381
|
-
get VALIDATION() { return logr_.lref.get().VALIDATION; }
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function createBitFlags(ref) {
|
|
385
|
-
// Create a proxy so that any property access computes the current bit
|
|
386
|
-
return new Proxy({}, {
|
|
387
|
-
get(target, prop, receiver) {
|
|
388
|
-
const positions = ref.get(); // get current { VALIDATION: n, ... }
|
|
389
|
-
const position = positions[prop]; // e.g., positions['VALIDATION']
|
|
390
|
-
|
|
391
|
-
if (position === undefined) {
|
|
392
|
-
// Optional: warn or return 0 for unknown keys
|
|
393
|
-
console.warn(`Unknown bitflag key: ${String(prop)}`);
|
|
394
|
-
return 0;
|
|
284
|
+
if (data._cause !== undefined) {
|
|
285
|
+
const _errs3 = errors;
|
|
286
|
+
if (!(validate22(data._cause, { instancePath: instancePath + "/_cause", parentData: data, parentDataProperty: "_cause", rootData, dynamicAnchors }))) {
|
|
287
|
+
vErrors = vErrors === null ? validate22.errors : vErrors.concat(validate22.errors);
|
|
288
|
+
errors = vErrors.length;
|
|
289
|
+
}
|
|
290
|
+
var valid0 = _errs3 === errors;
|
|
395
291
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
configurable: true,
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
type BitPositions = Record<string, number>;
|
|
415
|
-
|
|
416
|
-
function createBitFlags<T extends BitPositions>(ref: { get: () => T }) {
|
|
417
|
-
return new Proxy({} as { [K in keyof T]: number }, {
|
|
418
|
-
get(target, prop: string | symbol) {
|
|
419
|
-
if (typeof prop !== 'string') return undefined;
|
|
420
|
-
const positions = ref.get();
|
|
421
|
-
const position = positions[prop as keyof T];
|
|
422
|
-
if (position === undefined) return 0;
|
|
423
|
-
return 1 << position;
|
|
424
|
-
},
|
|
425
|
-
ownKeys() {
|
|
426
|
-
return Object.keys(ref.get());
|
|
427
|
-
},
|
|
428
|
-
getOwnPropertyDescriptor() {
|
|
429
|
-
return { enumerable: true, configurable: true };
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
*/
|
|
434
|
-
function create_Referenced_l_(ref) {
|
|
435
|
-
return new Proxy({}, {
|
|
436
|
-
get(target, prop) {
|
|
437
|
-
if (typeof prop !== 'string')
|
|
438
|
-
return undefined;
|
|
439
|
-
// if (prop === 'get') {
|
|
440
|
-
// return () => {
|
|
441
|
-
// const positions = ref.get();
|
|
442
|
-
// const result: Partial<Record<keyof T, number>> = {};
|
|
443
|
-
// for (const key in positions) {
|
|
444
|
-
// result[key as keyof T] = positions[key];
|
|
445
|
-
// }
|
|
446
|
-
// return result as Record<keyof T, number>;
|
|
447
|
-
// };
|
|
448
|
-
// }
|
|
449
|
-
if (prop === 'get')
|
|
450
|
-
return () => ref.get();
|
|
451
|
-
const positions = ref.get();
|
|
452
|
-
const value = positions[prop];
|
|
453
|
-
if (value === undefined)
|
|
454
|
-
return 0;
|
|
455
|
-
return value;
|
|
456
|
-
},
|
|
457
|
-
ownKeys() {
|
|
458
|
-
return Object.keys(ref.get());
|
|
459
|
-
},
|
|
460
|
-
getOwnPropertyDescriptor() {
|
|
461
|
-
return { enumerable: true, configurable: true };
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
const LOGR = (function () {
|
|
466
|
-
let _instance; // Private variable to hold the single instance
|
|
467
|
-
// Module-level state would work - but only when the module is loaded once.
|
|
468
|
-
// Your bundler is currently bundling @knev/bitlogr into your distribution file,
|
|
469
|
-
// creating a second copy. The Global Symbol approach would work around this,
|
|
470
|
-
// but it's treating the symptom, not the cause.
|
|
471
|
-
const GLOBAL_KEY = Symbol.for('@knev/bitlogr/LOGR');
|
|
472
|
-
// The real issue is your build configuration bundling dependencies that should remain external.
|
|
473
|
-
// rollup.config.mjs: external: ['@knev/bitlogr', 'uuid'], // Don't bundle these
|
|
474
|
-
function _create_instance() {
|
|
475
|
-
const _id = Math.random();
|
|
476
|
-
if (globalThis.LOGR_ENABLED ?? true)
|
|
477
|
-
console.log('creating LOGR instance:', _id);
|
|
478
|
-
// Private state (replacing constructor properties)
|
|
479
|
-
let _Bint_toggled = BigInt(0);
|
|
480
|
-
let _handler_log = handler_default_;
|
|
481
|
-
function _log_fxn(nr_logged, argsFn /* args */) {
|
|
482
|
-
// console.log('_log_fxn: ', BigInt(nr_logged), _Bint_toggled, (BigInt(nr_logged) & _Bint_toggled));
|
|
483
|
-
if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
|
|
484
|
-
return;
|
|
485
|
-
const args = argsFn();
|
|
486
|
-
_handler_log.apply(this, args);
|
|
487
|
-
}
|
|
488
|
-
return {
|
|
489
|
-
_id, // for testing
|
|
490
|
-
get handler() { return _handler_log; },
|
|
491
|
-
set handler(fx) {
|
|
492
|
-
_handler_log = fx;
|
|
493
|
-
},
|
|
494
|
-
get toggled() { return _Bint_toggled; },
|
|
495
|
-
// toggle(obj_labels, obj_toggled) {
|
|
496
|
-
// _Bint_toggled= l_toBigInt_(obj_labels, obj_toggled);
|
|
497
|
-
// },
|
|
498
|
-
toggle(labels, obj_toggled) {
|
|
499
|
-
const obj_labels = typeof labels?.get === 'function'
|
|
500
|
-
? labels.get()
|
|
501
|
-
: labels;
|
|
502
|
-
// console.log('obj_labels', obj_labels)
|
|
503
|
-
_Bint_toggled = l_toBigInt_(obj_labels, obj_toggled);
|
|
504
|
-
},
|
|
505
|
-
// Core internal log function (exposed only to created loggers)
|
|
506
|
-
_log_fxn,
|
|
507
|
-
create(options = {}) {
|
|
508
|
-
// This constant will be replaced at build time
|
|
509
|
-
if (!(globalThis.LOGR_ENABLED ?? true)) {
|
|
510
|
-
return {
|
|
511
|
-
_obj_labels: undefined, // optional: keep shape compatible if needed
|
|
512
|
-
log: () => { }, // does nothing
|
|
513
|
-
raw: () => { }, // does nothing
|
|
514
|
-
};
|
|
292
|
+
else {
|
|
293
|
+
var valid0 = true;
|
|
294
|
+
}
|
|
295
|
+
if (valid0) {
|
|
296
|
+
if (data.ack !== undefined) {
|
|
297
|
+
let data1 = data.ack;
|
|
298
|
+
const _errs4 = errors;
|
|
299
|
+
if (!(data1 && typeof data1 == "object" && !Array.isArray(data1))) {
|
|
300
|
+
validate24.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
var valid0 = _errs4 === errors;
|
|
515
304
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
get lref() { return this._lref_labels; },
|
|
528
|
-
set lref(lref_labels_new) {
|
|
529
|
-
this._lref_labels = lref_labels_new;
|
|
530
|
-
},
|
|
531
|
-
log(nr_logged, argsFn) {
|
|
532
|
-
// This constant will be replaced at build time
|
|
533
|
-
if (!(globalThis.LOGR_ENABLED ?? true))
|
|
534
|
-
return;
|
|
535
|
-
_log_fxn.call(this, nr_logged, argsFn);
|
|
536
|
-
},
|
|
537
|
-
// Optional shorthand for common cases
|
|
538
|
-
raw(...args) {
|
|
539
|
-
_handler_log.apply(this, args);
|
|
305
|
+
else {
|
|
306
|
+
var valid0 = true;
|
|
307
|
+
}
|
|
308
|
+
if (valid0) {
|
|
309
|
+
if (data["2PhW"] !== undefined) {
|
|
310
|
+
const _errs6 = errors;
|
|
311
|
+
if ("2" !== data["2PhW"]) {
|
|
312
|
+
validate24.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
var valid0 = _errs6 === errors;
|
|
540
316
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
// Public interface
|
|
547
|
-
return {
|
|
548
|
-
get_instance() {
|
|
549
|
-
if (!(globalThis.LOGR_USE_GLOBAL_KEY ?? true)) {
|
|
550
|
-
if (!_instance)
|
|
551
|
-
_instance = _create_instance(); // Lazy initialization
|
|
552
|
-
return _instance;
|
|
317
|
+
else {
|
|
318
|
+
var valid0 = true;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
553
321
|
}
|
|
554
|
-
if (!globalThis[GLOBAL_KEY])
|
|
555
|
-
globalThis[GLOBAL_KEY] = _create_instance();
|
|
556
|
-
return globalThis[GLOBAL_KEY];
|
|
557
|
-
},
|
|
558
|
-
// For testing only - reset the singleton
|
|
559
|
-
_reset_for_testing() {
|
|
560
|
-
delete globalThis[GLOBAL_KEY];
|
|
561
322
|
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
lRef: lRef,
|
|
570
|
-
l_LL: l_LL_,
|
|
571
|
-
l_RR: l_RR_,
|
|
572
|
-
l_array: l_array_,
|
|
573
|
-
l_assert: l_assert_,
|
|
574
|
-
l_concat: l_concat_,
|
|
575
|
-
l_length: l_length_,
|
|
576
|
-
l_merge: l_merge_
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
function getAugmentedNamespace(n) {
|
|
580
|
-
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
581
|
-
var f = n.default;
|
|
582
|
-
if (typeof f == "function") {
|
|
583
|
-
var a = function a () {
|
|
584
|
-
var isInstance = false;
|
|
585
|
-
try {
|
|
586
|
-
isInstance = this instanceof a;
|
|
587
|
-
} catch {}
|
|
588
|
-
if (isInstance) {
|
|
589
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
590
|
-
}
|
|
591
|
-
return f.apply(this, arguments);
|
|
592
|
-
};
|
|
593
|
-
a.prototype = f.prototype;
|
|
594
|
-
} else a = {};
|
|
595
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
596
|
-
Object.keys(n).forEach(function (k) {
|
|
597
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
598
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
599
|
-
enumerable: true,
|
|
600
|
-
get: function () {
|
|
601
|
-
return n[k];
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
});
|
|
605
|
-
return a;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
var jsonMsg_cjs = {};
|
|
609
|
-
|
|
610
|
-
var require$$0 = /*@__PURE__*/getAugmentedNamespace(logr_es);
|
|
611
|
-
|
|
612
|
-
var hasRequiredJsonMsg_cjs;
|
|
613
|
-
|
|
614
|
-
function requireJsonMsg_cjs () {
|
|
615
|
-
if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
|
|
616
|
-
hasRequiredJsonMsg_cjs = 1;
|
|
617
|
-
|
|
618
|
-
var bitlogr = require$$0;
|
|
619
|
-
|
|
620
|
-
const schema_Msg = validate18;
|
|
621
|
-
function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
|
|
622
|
-
evaluated0.props = undefined;
|
|
623
|
-
} if (evaluated0.dynamicItems) {
|
|
624
|
-
evaluated0.items = undefined;
|
|
625
|
-
} {
|
|
626
|
-
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
627
|
-
let missing0;
|
|
628
|
-
if ((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))) {
|
|
629
|
-
validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
630
|
-
return false;
|
|
631
|
-
}
|
|
632
|
-
else {
|
|
633
|
-
if (data.id !== undefined) {
|
|
634
|
-
const _errs1 = errors;
|
|
635
|
-
if (typeof data.id !== "string") {
|
|
636
|
-
validate18.errors = [{ instancePath: instancePath + "/id", schemaPath: "#/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
var valid0 = _errs1 === errors;
|
|
640
|
-
}
|
|
641
|
-
else {
|
|
642
|
-
var valid0 = true;
|
|
643
|
-
}
|
|
644
|
-
if (valid0) {
|
|
645
|
-
if (data.dt !== undefined) {
|
|
646
|
-
const _errs3 = errors;
|
|
647
|
-
if (typeof data.dt !== "string") {
|
|
648
|
-
validate18.errors = [{ instancePath: instancePath + "/dt", schemaPath: "#/properties/dt/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
var valid0 = _errs3 === errors;
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
var valid0 = true;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
else {
|
|
660
|
-
validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
661
|
-
return false;
|
|
662
|
-
}
|
|
663
|
-
} validate18.errors = vErrors; return errors === 0; }
|
|
664
|
-
validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
|
|
665
|
-
const schema_MsgEffect = validate19;
|
|
666
|
-
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
|
|
667
|
-
evaluated0.props = undefined;
|
|
668
|
-
} if (evaluated0.dynamicItems) {
|
|
669
|
-
evaluated0.items = undefined;
|
|
670
|
-
} {
|
|
671
|
-
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
672
|
-
let missing0;
|
|
673
|
-
if ((data._cause === undefined) && (missing0 = "_cause")) {
|
|
674
|
-
validate19.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
675
|
-
return false;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
else {
|
|
679
|
-
validate19.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
680
|
-
return false;
|
|
681
|
-
}
|
|
682
|
-
} validate19.errors = vErrors; return errors === 0; }
|
|
683
|
-
validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
|
|
684
|
-
const schema_MsgAckEffect = validate20;
|
|
685
|
-
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
686
|
-
evaluated0.props = undefined;
|
|
687
|
-
} if (evaluated0.dynamicItems) {
|
|
688
|
-
evaluated0.items = undefined;
|
|
689
|
-
} {
|
|
690
|
-
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
691
|
-
let missing0;
|
|
692
|
-
if ((data.ack === undefined) && (missing0 = "ack")) {
|
|
693
|
-
validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
694
|
-
return false;
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
if (data.ack !== undefined) {
|
|
698
|
-
let data0 = data.ack;
|
|
699
|
-
{
|
|
700
|
-
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
701
|
-
let missing1;
|
|
702
|
-
if ((data0.ok === undefined) && (missing1 = "ok")) {
|
|
703
|
-
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
704
|
-
return false;
|
|
705
|
-
}
|
|
706
|
-
else {
|
|
707
|
-
if (data0.ok !== undefined) {
|
|
708
|
-
if (typeof data0.ok !== "boolean") {
|
|
709
|
-
validate20.errors = [{ instancePath: instancePath + "/ack/ok", schemaPath: "#/properties/ack/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
710
|
-
return false;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
else {
|
|
716
|
-
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
validate20.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
|
-
} validate20.errors = vErrors; return errors === 0; }
|
|
728
|
-
validate20.evaluated = { "props": { "ack": true }, "dynamicProps": false, "dynamicItems": false };
|
|
729
|
-
|
|
730
|
-
const byteToHex = [];
|
|
731
|
-
for (let i = 0; i < 256; ++i) {
|
|
732
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
733
|
-
}
|
|
734
|
-
function unsafeStringify(arr, offset = 0) {
|
|
735
|
-
return (byteToHex[arr[offset + 0]] +
|
|
736
|
-
byteToHex[arr[offset + 1]] +
|
|
737
|
-
byteToHex[arr[offset + 2]] +
|
|
738
|
-
byteToHex[arr[offset + 3]] +
|
|
739
|
-
'-' +
|
|
740
|
-
byteToHex[arr[offset + 4]] +
|
|
741
|
-
byteToHex[arr[offset + 5]] +
|
|
742
|
-
'-' +
|
|
743
|
-
byteToHex[arr[offset + 6]] +
|
|
744
|
-
byteToHex[arr[offset + 7]] +
|
|
745
|
-
'-' +
|
|
746
|
-
byteToHex[arr[offset + 8]] +
|
|
747
|
-
byteToHex[arr[offset + 9]] +
|
|
748
|
-
'-' +
|
|
749
|
-
byteToHex[arr[offset + 10]] +
|
|
750
|
-
byteToHex[arr[offset + 11]] +
|
|
751
|
-
byteToHex[arr[offset + 12]] +
|
|
752
|
-
byteToHex[arr[offset + 13]] +
|
|
753
|
-
byteToHex[arr[offset + 14]] +
|
|
754
|
-
byteToHex[arr[offset + 15]]).toLowerCase();
|
|
755
|
-
}
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
validate24.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
} validate24.errors = vErrors; return errors === 0; }
|
|
329
|
+
validate24.evaluated = { "props": { "_cause": true, "ack": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
756
330
|
|
|
757
|
-
|
|
758
|
-
const rnds8 = new Uint8Array(16);
|
|
759
|
-
function rng() {
|
|
760
|
-
if (!getRandomValues) {
|
|
761
|
-
if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
|
|
762
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
763
|
-
}
|
|
764
|
-
getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
765
|
-
}
|
|
766
|
-
return getRandomValues(rnds8);
|
|
767
|
-
}
|
|
331
|
+
// GENERATED by iface-gen from schema_TwoPhW.json — DO NOT EDIT
|
|
768
332
|
|
|
769
|
-
|
|
770
|
-
var native = { randomUUID };
|
|
333
|
+
const VERSION = "2";
|
|
771
334
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
throw new Error('Random bytes length must be >= 16');
|
|
777
|
-
}
|
|
778
|
-
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
779
|
-
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
780
|
-
return unsafeStringify(rnds);
|
|
781
|
-
}
|
|
782
|
-
function v4(options, buf, offset) {
|
|
783
|
-
if (native.randomUUID && true && !options) {
|
|
784
|
-
return native.randomUUID();
|
|
785
|
-
}
|
|
786
|
-
return _v4(options);
|
|
787
|
-
}
|
|
335
|
+
const JSON_MsgWarp$1 = {
|
|
336
|
+
validate: _v_JSON_MsgWarp,
|
|
337
|
+
merge: (body) => JSON_Msg.merge({ "warp": body, "2PhW": VERSION }),
|
|
338
|
+
};
|
|
788
339
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
const l_ = logr_.l;
|
|
793
|
-
// console.log('File location:', import.meta.url, '[Implementation]');
|
|
794
|
-
//-------------------------------------------------------------------------------------------------
|
|
795
|
-
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
796
|
-
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
797
|
-
var JSON_Msg = (function () {
|
|
798
|
-
return {
|
|
799
|
-
merge: function (json) {
|
|
800
|
-
return Object.assign({
|
|
801
|
-
id: v4(),
|
|
802
|
-
referer: null,
|
|
803
|
-
dt: new Date().toISOString()
|
|
804
|
-
}, json || {});
|
|
805
|
-
},
|
|
806
|
-
validate: function (json) {
|
|
807
|
-
const b_valid = schema_Msg(json);
|
|
808
|
-
if (!b_valid)
|
|
809
|
-
logr_.log(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
|
|
810
|
-
return b_valid;
|
|
811
|
-
},
|
|
812
|
-
// TODO: requires a separate ajv module require, and JTD specific schema
|
|
813
|
-
// https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
|
|
814
|
-
// static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
|
|
815
|
-
// static parse(json) {
|
|
816
|
-
// return this.#ajv_parse_(json);
|
|
817
|
-
// }
|
|
818
|
-
};
|
|
819
|
-
})();
|
|
820
|
-
var JSON_MsgEffect = (function () {
|
|
821
|
-
return {
|
|
822
|
-
create_with_cause_merge: function (msg_cause, json) {
|
|
823
|
-
const _cause = msg_cause;
|
|
824
|
-
return Object.assign(JSON_Msg.merge(json), { _cause });
|
|
825
|
-
},
|
|
826
|
-
validate: function (json) {
|
|
827
|
-
if (!JSON_Msg.validate(json))
|
|
828
|
-
return false;
|
|
829
|
-
const b_valid = schema_MsgEffect(json);
|
|
830
|
-
if (!b_valid)
|
|
831
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
|
|
832
|
-
return b_valid;
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
|
-
})();
|
|
836
|
-
var JSON_MsgAck = (function () {
|
|
837
|
-
return {
|
|
838
|
-
create_with_cause_Ok: function (msg_cause, b_ok = true) {
|
|
839
|
-
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
840
|
-
ack: {
|
|
841
|
-
"ok": b_ok,
|
|
842
|
-
},
|
|
843
|
-
});
|
|
844
|
-
},
|
|
845
|
-
create_with_cause_Expired: function (msg_cause) {
|
|
846
|
-
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
847
|
-
ack: {
|
|
848
|
-
"ok": false,
|
|
849
|
-
"expired": true
|
|
850
|
-
},
|
|
851
|
-
});
|
|
852
|
-
},
|
|
853
|
-
validate: function (json) {
|
|
854
|
-
if (!JSON_MsgEffect.validate(json))
|
|
855
|
-
return false;
|
|
856
|
-
const b_valid = schema_MsgAckEffect(json);
|
|
857
|
-
if (!b_valid)
|
|
858
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
|
|
859
|
-
return b_valid;
|
|
860
|
-
}
|
|
861
|
-
};
|
|
862
|
-
})();
|
|
340
|
+
const JSON_AckWarp$1 = {
|
|
341
|
+
validate: _v_JSON_AckWarp,
|
|
342
|
+
};
|
|
863
343
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
return jsonMsg_cjs;
|
|
869
|
-
}
|
|
344
|
+
const JSON_EffEngage$1 = {
|
|
345
|
+
validate: _v_JSON_EffEngage,
|
|
346
|
+
create_with_cause_merge: (cause, body) => JSON_Eff.create_with_cause_merge(cause, { "engage": body, "2PhW": VERSION }),
|
|
347
|
+
};
|
|
870
348
|
|
|
871
|
-
|
|
349
|
+
const JSON_AckEngage$1 = {
|
|
350
|
+
validate: _v_JSON_AckEngage,
|
|
351
|
+
};
|
|
872
352
|
|
|
353
|
+
// The wire interface (validators, constructors, VERSION) is GENERATED by iface-gen from the pinned
|
|
354
|
+
// schema_TwoPhW.json (see ifacegenconfig.json; `npm run gen`) -- never hand-written here.
|
|
873
355
|
// interface Event extends Required<EventMinimal> {
|
|
874
356
|
// type : string;
|
|
875
357
|
// id : string | number;
|
|
876
358
|
// timeout_id : NodeJS.Timeout | null;
|
|
877
359
|
// };
|
|
878
|
-
const k_TTL = 20000;
|
|
879
360
|
//-------------------------------------------------------------------------------------------------
|
|
880
|
-
const obj_labels_merge_ =
|
|
881
|
-
const obj_labels_concat_ =
|
|
361
|
+
const obj_labels_merge_ = l_merge(logr.lref.get(), logr$1.lref.get()); // VALIDATION : 4
|
|
362
|
+
const obj_labels_concat_ = l_concat(obj_labels_merge_, l_array(['HANDLERS', 'DROPS', 'PROTOCOL_STATE', 'RECVER', 'SENDER']));
|
|
882
363
|
const lref_ = lRef(obj_labels_concat_);
|
|
883
|
-
|
|
364
|
+
logr$1.lref = lref_;
|
|
884
365
|
logr.lref = lref_;
|
|
885
366
|
const LOGR_ = LOGR.get_instance();
|
|
886
367
|
const logr_ = LOGR_.create(); // don't let create() make a new ref, assign lref_ from here
|
|
887
368
|
logr_.lref = lref_;
|
|
888
369
|
const l_ = logr_.l;
|
|
889
370
|
class Config {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
371
|
+
// A step's callback is what makes the step this participant's to handle: with no callback set,
|
|
372
|
+
// the step's handler refuses it (returns false) before anything is logged. Every participant on
|
|
373
|
+
// the ME hears every exchange, so "no callback" is the normal case for a role it does not play.
|
|
374
|
+
_callback_msgWarp = null;
|
|
375
|
+
_callback_effEngage = null;
|
|
376
|
+
_callback_ackWarp = null;
|
|
377
|
+
_callback_ackEngage = null;
|
|
378
|
+
// "a step I sent was never answered inside its window", one per role: the sender's fires for its
|
|
379
|
+
// Warp / Engage, the receiver's for its AckWarp. A participant playing both roles keeps both.
|
|
380
|
+
_callback_sender_sent_expired;
|
|
381
|
+
_callback_receiver_sent_expired;
|
|
895
382
|
_callback_msgOptions;
|
|
896
383
|
constructor() {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
console.assert(false, 'callback_msgWarp uninitialized');
|
|
900
|
-
return false;
|
|
384
|
+
this._callback_sender_sent_expired = (_msg, _json_msg) => {
|
|
385
|
+
console.assert(false, '_callback_sender_sent_expired uninitialized');
|
|
901
386
|
};
|
|
902
|
-
this.
|
|
903
|
-
console.assert(false, '
|
|
904
|
-
return false;
|
|
905
|
-
};
|
|
906
|
-
this._callback_msgAckWarp = (_msg, _json_msg) => {
|
|
907
|
-
console.assert(false, 'callback_msgAckWarp uninitialized');
|
|
908
|
-
return false;
|
|
909
|
-
};
|
|
910
|
-
this._callback_msgAckEngage = (_msg, _json_msg) => {
|
|
911
|
-
console.assert(false, 'callback_msgAckEngage uninitialized');
|
|
912
|
-
return false;
|
|
913
|
-
};
|
|
914
|
-
this._callback_msg_sent_expired = (_msg, _json_msg) => {
|
|
915
|
-
console.assert(false, '_callback_msg_sent_expired uninitialized');
|
|
387
|
+
this._callback_receiver_sent_expired = (_msg, _json_msg) => {
|
|
388
|
+
console.assert(false, '_callback_receiver_sent_expired uninitialized');
|
|
916
389
|
};
|
|
917
390
|
this._callback_msgOptions = () => {
|
|
918
391
|
console.assert(false, 'callback_msgOptions uninitialized');
|
|
919
392
|
};
|
|
920
393
|
}
|
|
921
|
-
receiver(callback_msgWarp,
|
|
394
|
+
receiver(callback_msgWarp, callback_effEngage, callback_msg_sent_expired) {
|
|
922
395
|
this._callback_msgWarp = callback_msgWarp;
|
|
923
|
-
this.
|
|
924
|
-
this.
|
|
396
|
+
this._callback_effEngage = callback_effEngage;
|
|
397
|
+
this._callback_receiver_sent_expired = callback_msg_sent_expired;
|
|
925
398
|
}
|
|
926
|
-
sender(
|
|
927
|
-
this.
|
|
928
|
-
this.
|
|
929
|
-
this.
|
|
399
|
+
sender(callback_ackWarp, callback_ackEngage, callback_msg_sent_expired) {
|
|
400
|
+
this._callback_ackWarp = callback_ackWarp;
|
|
401
|
+
this._callback_ackEngage = callback_ackEngage;
|
|
402
|
+
this._callback_sender_sent_expired = callback_msg_sent_expired;
|
|
930
403
|
}
|
|
931
404
|
set callback_msgOptions(callback) {
|
|
932
405
|
this._callback_msgOptions = callback;
|
|
@@ -944,7 +417,7 @@ class Config {
|
|
|
944
417
|
// }
|
|
945
418
|
// })();
|
|
946
419
|
//-------------------------------------------------------------------------------------------------
|
|
947
|
-
|
|
420
|
+
const k_VERSION = VERSION;
|
|
948
421
|
// rtt_msec <= ttl_msec *2 => rtt_msec = ttl_msec *2
|
|
949
422
|
// t_ttl_rtt_(TTL, RTT) = t_ttl_rtt_(TTL, TTL *2) = TTL *2 + TTL *2 = TTL *4 MAX
|
|
950
423
|
function time_ttl_rtt_(ttl_msec, rtt_msec) {
|
|
@@ -955,10 +428,11 @@ function time_ttl_rtt_(ttl_msec, rtt_msec) {
|
|
|
955
428
|
console.assert(rtt_msec <= ttl_msec * 2, `t_ttl_rtt_: INVALID rtt_msec ttl_msec[${ttl_msec}] rtt_msec[${rtt_msec}]`);
|
|
956
429
|
return (ttl_msec * 2) + rtt_msec;
|
|
957
430
|
}
|
|
431
|
+
// not part of the generated interface (no schema yet)
|
|
958
432
|
var JSON_MsgOptions = (function () {
|
|
959
433
|
return {
|
|
960
434
|
create_with_cause_options: function (msg_cause, options) {
|
|
961
|
-
return
|
|
435
|
+
return JSON_Eff.create_with_cause_merge(msg_cause, {
|
|
962
436
|
options: options,
|
|
963
437
|
"2PhW": k_VERSION
|
|
964
438
|
});
|
|
@@ -974,17 +448,18 @@ var JSON_MsgOptions = (function () {
|
|
|
974
448
|
}
|
|
975
449
|
};
|
|
976
450
|
})();
|
|
451
|
+
// Each JSON_* below is the generated namespace (validate + merge / create_with_cause_merge; the
|
|
452
|
+
// validators are delta-only: the base is validated upstream, in the responder chain) extended with
|
|
453
|
+
// what the schema cannot express: the protocol's own constructors.
|
|
977
454
|
var JSON_MsgWarp = (function () {
|
|
978
455
|
return {
|
|
456
|
+
...JSON_MsgWarp$1,
|
|
979
457
|
create_with_id_user_hyperport: function (json_warp_id, json_user, json_hyperport, nr_ttl_msec) {
|
|
980
|
-
return
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
ttl_msec: nr_ttl_msec
|
|
986
|
-
},
|
|
987
|
-
"2PhW": k_VERSION
|
|
458
|
+
return JSON_MsgWarp$1.merge({
|
|
459
|
+
id: json_warp_id,
|
|
460
|
+
user: json_user,
|
|
461
|
+
hyperport: json_hyperport,
|
|
462
|
+
ttl_msec: nr_ttl_msec
|
|
988
463
|
});
|
|
989
464
|
},
|
|
990
465
|
compare: function (json_L, json_R) {
|
|
@@ -997,92 +472,39 @@ var JSON_MsgWarp = (function () {
|
|
|
997
472
|
if (json_L.referer[1] !== json_R.referer[1])
|
|
998
473
|
return false;
|
|
999
474
|
return true;
|
|
1000
|
-
},
|
|
1001
|
-
validate: function (json_msg) {
|
|
1002
|
-
// if (! JSON_Msg.validate(json))
|
|
1003
|
-
// return false;
|
|
1004
|
-
if (!schema_MsgWarp(json_msg)) {
|
|
1005
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgWarp: schema_MsgWarp_: ', schema_MsgWarp.errors]);
|
|
1006
|
-
return false;
|
|
1007
|
-
}
|
|
1008
|
-
return true;
|
|
1009
475
|
}
|
|
1010
476
|
};
|
|
1011
477
|
})();
|
|
1012
|
-
var
|
|
478
|
+
var JSON_EffEngage = (function () {
|
|
1013
479
|
return {
|
|
480
|
+
...JSON_EffEngage$1,
|
|
1014
481
|
create_with_Warp: function (json_msgWarp) {
|
|
1015
482
|
console.assert(json_msgWarp.ack === undefined, "Engage with a Warp, not an Ack");
|
|
1016
|
-
return
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
"rtt_msec": Date.now() - Date.parse(json_msgWarp.dt)
|
|
1020
|
-
},
|
|
1021
|
-
"2PhW": k_VERSION
|
|
483
|
+
return JSON_EffEngage$1.create_with_cause_merge(json_msgWarp, {
|
|
484
|
+
"ok": true,
|
|
485
|
+
"rtt_msec": Date.now() - Date.parse(json_msgWarp.dt)
|
|
1022
486
|
});
|
|
1023
|
-
},
|
|
1024
|
-
validate: function (json_msgEffect) {
|
|
1025
|
-
// if (! JSON_Msg_msg.validate(json))
|
|
1026
|
-
// return false;
|
|
1027
|
-
if (!JSON_MsgWarp.validate(json_msgEffect._cause))
|
|
1028
|
-
return false;
|
|
1029
|
-
if (!schema_MsgEngage(json_msgEffect)) {
|
|
1030
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
|
|
1031
|
-
return false;
|
|
1032
|
-
}
|
|
1033
|
-
return true;
|
|
1034
487
|
}
|
|
1035
488
|
};
|
|
1036
489
|
})();
|
|
1037
|
-
|
|
490
|
+
// iface-gen emits no constructor for a JSON_Ack: build the base ack, stamp the protocol marker
|
|
491
|
+
var JSON_AckWarp = (function () {
|
|
1038
492
|
return {
|
|
1039
|
-
|
|
1040
|
-
// const json_msgAckWarp= structuredClone(json_msgAck);
|
|
1041
|
-
// json_msgAckWarp._cause= _cause;
|
|
1042
|
-
// return json_msgAckWarp;
|
|
1043
|
-
// }
|
|
493
|
+
...JSON_AckWarp$1,
|
|
1044
494
|
create_with_Warp_Ok: function (json_msgWarp, b_ok = true) {
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
return
|
|
1048
|
-
},
|
|
1049
|
-
// create_with_msgExpired : function( json_msgWarp ) {
|
|
1050
|
-
// const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgWarp )
|
|
1051
|
-
// json_msgAck_msg["2PhW"]= k_VERSION;
|
|
1052
|
-
// return json_msgAck_msg;
|
|
1053
|
-
// },
|
|
1054
|
-
validate: function (json_msgAck) {
|
|
1055
|
-
// if (! JSON_MsgAck_msg.validate(json))
|
|
1056
|
-
// return false;
|
|
1057
|
-
if (!JSON_MsgWarp.validate(json_msgAck._cause))
|
|
1058
|
-
return false;
|
|
1059
|
-
return true;
|
|
495
|
+
const json_ack = JSON_Ack.create_with_cause_Ok(json_msgWarp, b_ok);
|
|
496
|
+
json_ack["2PhW"] = k_VERSION;
|
|
497
|
+
return json_ack;
|
|
1060
498
|
}
|
|
1061
499
|
};
|
|
1062
500
|
})();
|
|
1063
|
-
var
|
|
501
|
+
var JSON_AckEngage = (function () {
|
|
1064
502
|
return {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
create_with_Engage_Ok: function (json_msgEngage, b_ok = true) {
|
|
1071
|
-
const json_msgAck = jsonMsg_cjsExports.JSON_MsgAck.create_with_cause_Ok(json_msgEngage, b_ok);
|
|
1072
|
-
json_msgAck["2PhW"] = k_VERSION;
|
|
1073
|
-
return json_msgAck;
|
|
1074
|
-
},
|
|
1075
|
-
// create_with_msgExpired : function( json_msgEngage ) {
|
|
1076
|
-
// const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgEngage )
|
|
1077
|
-
// json_msgAck_msg["2PhW"]= k_VERSION;
|
|
1078
|
-
// return json_msgAck_msg;
|
|
1079
|
-
// },
|
|
1080
|
-
validate: function (json_msgAck) {
|
|
1081
|
-
// if (! JSON_MsgAck_msg.validate(json_msgAck_msg))
|
|
1082
|
-
// return false;
|
|
1083
|
-
if (!JSON_MsgEngage.validate(json_msgAck._cause))
|
|
1084
|
-
return false;
|
|
1085
|
-
return true;
|
|
503
|
+
...JSON_AckEngage$1,
|
|
504
|
+
create_with_Engage_Ok: function (json_effEngage, b_ok = true) {
|
|
505
|
+
const json_ack = JSON_Ack.create_with_cause_Ok(json_effEngage, b_ok);
|
|
506
|
+
json_ack["2PhW"] = k_VERSION;
|
|
507
|
+
return json_ack;
|
|
1086
508
|
}
|
|
1087
509
|
};
|
|
1088
510
|
})();
|
|
@@ -1125,7 +547,7 @@ class StateState {
|
|
|
1125
547
|
class StateAckEngage extends StateState {
|
|
1126
548
|
constructor(idx_event, event) { super(idx_event, event); }
|
|
1127
549
|
get evt_AckEngage() { return this.event; }
|
|
1128
|
-
get
|
|
550
|
+
get json_ackEngage() { return this.json_msg; }
|
|
1129
551
|
canChangeState(_state_new) {
|
|
1130
552
|
return false;
|
|
1131
553
|
}
|
|
@@ -1133,38 +555,44 @@ class StateAckEngage extends StateState {
|
|
|
1133
555
|
class StateEngage extends StateState {
|
|
1134
556
|
constructor(idx_event, event) { super(idx_event, event); }
|
|
1135
557
|
get evt_Engage() { return this.event; }
|
|
1136
|
-
get
|
|
558
|
+
get json_effEngage() { return this.json_msg; }
|
|
1137
559
|
canChangeState(state_new) {
|
|
1138
560
|
if (false === state_new instanceof StateAckEngage)
|
|
1139
561
|
return false;
|
|
1140
562
|
// The Engage gets to live for THE WARP'S creation time + TTL*2 + RTT
|
|
1141
|
-
const json_msgWarp = this.
|
|
1142
|
-
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.
|
|
563
|
+
const json_msgWarp = this.json_effEngage._cause;
|
|
564
|
+
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.json_effEngage.engage.rtt_msec);
|
|
1143
565
|
logr_.log(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
|
|
1144
566
|
if (state_new.evt_AckEngage.dt >= Date.parse(json_msgWarp.dt) + timeout_ms)
|
|
1145
567
|
return false;
|
|
1146
568
|
return true;
|
|
1147
569
|
}
|
|
1148
570
|
}
|
|
571
|
+
// Can a JSON_EffEngage follow this JSON_AckWarp? Not after a nack (it ends the exchange), and not
|
|
572
|
+
// after the ack of an instantaneous warp (single phase: the ack concludes it).
|
|
573
|
+
function isEngageAwaited_(json_ackWarp) {
|
|
574
|
+
return !!json_ackWarp.ack.ok && !json_ackWarp._cause.warp.instantaneous;
|
|
575
|
+
}
|
|
1149
576
|
class StateAckWarp extends StateState {
|
|
1150
577
|
constructor(idx_event, event) { super(idx_event, event); }
|
|
1151
578
|
get evt_AckWarp() { return this.event; }
|
|
1152
|
-
get
|
|
579
|
+
get json_ackWarp() { return this.json_msg; }
|
|
1153
580
|
canChangeState(state_new) {
|
|
1154
581
|
if (false === state_new instanceof StateEngage)
|
|
1155
582
|
return false;
|
|
1156
|
-
if (!this.
|
|
583
|
+
if (!isEngageAwaited_(this.json_ackWarp))
|
|
1157
584
|
return false;
|
|
1158
|
-
|
|
585
|
+
// RTT <= TTL*2: the cap that bounds the whole exchange at TTL*4 (see traverse_State's lookback)
|
|
586
|
+
if (state_new.json_effEngage.engage.rtt_msec > this.json_ackWarp._cause.warp.ttl_msec * 2)
|
|
1159
587
|
return false;
|
|
1160
588
|
// The Ack gets to live for THE ACK'S creation time + TTL*2 + STT
|
|
1161
589
|
// +STT, so lines up with the Engage timeout
|
|
1162
590
|
// - Engage: T0 +2TTL +RTT; RTT= STT+STT
|
|
1163
591
|
// - AckWarp: TAckWarp +2TLL +STT; TAckWarp= T0 +STT;
|
|
1164
592
|
// - STT: Date of the Ack minus date of the Warp.
|
|
1165
|
-
const timeout_ms = time_ttl_rtt_(this.
|
|
1166
|
-
logr_.log(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.
|
|
1167
|
-
if (state_new.evt_Engage.dt >= Date.parse(this.
|
|
593
|
+
const timeout_ms = time_ttl_rtt_(this.json_ackWarp._cause.warp.ttl_msec) + Date.parse(this.json_ackWarp.dt) - Date.parse(this.json_ackWarp._cause.dt);
|
|
594
|
+
logr_.log(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_ackWarp.dt)} + ${timeout_ms}`]);
|
|
595
|
+
if (state_new.evt_Engage.dt >= Date.parse(this.json_ackWarp.dt) + timeout_ms)
|
|
1168
596
|
return false;
|
|
1169
597
|
return true;
|
|
1170
598
|
}
|
|
@@ -1223,10 +651,16 @@ class ProtocolStateState {
|
|
|
1223
651
|
return this._state;
|
|
1224
652
|
}
|
|
1225
653
|
canChangeState(state_new) {
|
|
654
|
+
// An exchange is a dialogue: a step we RECEIVE is only legal after a step we SENT, and vice
|
|
655
|
+
// versa. Every participant on the ME hears every exchange, so without this a warp we merely
|
|
656
|
+
// heard would be "answered" by the ack its real receiver sent, and we could answer our own step.
|
|
657
|
+
if (!(this._state instanceof StateInitialState) && this._state.event.data.b_sent === state_new.event.data.b_sent)
|
|
658
|
+
return false;
|
|
1226
659
|
return this._state.canChangeState(state_new);
|
|
1227
660
|
}
|
|
1228
661
|
}
|
|
1229
662
|
//-------------------------------------------------------------------------------------------------
|
|
663
|
+
const kstr_EVT_DROPPED_ = '2PhW[DROPPED!]';
|
|
1230
664
|
class TwoPhW_EventLog {
|
|
1231
665
|
_eventLog;
|
|
1232
666
|
constructor(eventLog) {
|
|
@@ -1237,29 +671,31 @@ class TwoPhW_EventLog {
|
|
|
1237
671
|
const json = b_Ack ? json_msg["_cause"] : json_msg;
|
|
1238
672
|
if (json.warp) {
|
|
1239
673
|
return {
|
|
1240
|
-
str_type:
|
|
674
|
+
str_type: b_Ack ? '2PhW[JSON_AckWarp]' : '2PhW[JSON_MsgWarp]',
|
|
1241
675
|
json_msgWarp: json
|
|
1242
676
|
};
|
|
1243
677
|
}
|
|
1244
678
|
if (json.engage) {
|
|
1245
679
|
return {
|
|
1246
|
-
str_type:
|
|
680
|
+
str_type: b_Ack ? '2PhW[JSON_AckEngage]' : '2PhW[JSON_EffEngage]',
|
|
1247
681
|
json_msgWarp: json["_cause"]
|
|
1248
682
|
};
|
|
1249
683
|
}
|
|
1250
684
|
return { str_type: null, json_msgWarp: null }; // Explicit default for invalid cases
|
|
1251
685
|
}
|
|
1252
686
|
// _addEvent(msg: t_msg, json_msg : JSON_Msg, timeout_ms? : number, timeout_callback? : ( args? : {idx_event : number, event : EventMinimal} ) => {}) {
|
|
1253
|
-
_addEvent(msg, json_msg, timeout_ms, timeout_callback) {
|
|
687
|
+
_addEvent(msg, json_msg, b_sent, timeout_ms, timeout_callback) {
|
|
1254
688
|
const { str_type, json_msgWarp } = this._warp(json_msg);
|
|
1255
|
-
const { idx } = this._eventLog.add_Event(str_type, json_msgWarp.warp.id, { msg, json_msg }, timeout_ms, timeout_callback);
|
|
689
|
+
const { idx } = this._eventLog.add_Event(str_type, json_msgWarp.warp.id, { msg, json_msg, b_sent }, timeout_ms, timeout_callback);
|
|
1256
690
|
logr_.log(l_.PROTOCOL_STATE, () => [`_addEvent: [${idx}] timeout:${Date.now()}+${timeout_ms} `, json_msg]);
|
|
1257
691
|
}
|
|
1258
|
-
|
|
692
|
+
// Record a message we refused, for forensics: under its exchange and in the shape of every other
|
|
693
|
+
// 2PhW event, but never a step -- traverse_State skips it.
|
|
694
|
+
_dropEvent(msg, json_msg) {
|
|
1259
695
|
const { json_msgWarp } = this._warp(json_msg);
|
|
1260
696
|
if (!json_msgWarp)
|
|
1261
697
|
return;
|
|
1262
|
-
this._eventLog.add_Event(
|
|
698
|
+
this._eventLog.add_Event(kstr_EVT_DROPPED_, json_msgWarp.warp.id, { msg, json_msg, b_sent: false });
|
|
1263
699
|
}
|
|
1264
700
|
_cancelTimeout(idx_event) {
|
|
1265
701
|
logr_.log(l_.PROTOCOL_STATE, () => [`_cancelTimeout: [${idx_event}] timeout cancelled`]);
|
|
@@ -1267,11 +703,18 @@ class TwoPhW_EventLog {
|
|
|
1267
703
|
}
|
|
1268
704
|
traverse_State(json_msgWarp) {
|
|
1269
705
|
const protocolState = new ProtocolStateState();
|
|
1270
|
-
|
|
706
|
+
// Look back over the WHOLE exchange. Its longest window is the Warp's dt + TTL*2 + RTT (the
|
|
707
|
+
// AckEngage), and RTT <= TTL*2 (StateAckWarp refuses an Engage that claims more), so no step is
|
|
708
|
+
// legal more than TTL*4 after the Warp: the oldest event is never older than that.
|
|
709
|
+
const lookback_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, json_msgWarp.warp.ttl_msec * 2);
|
|
710
|
+
const arr_evts = this._eventLog.get_Events_by_id(json_msgWarp.warp.id, lookback_ms);
|
|
1271
711
|
logr_.log(l_.EVENTS, () => ['traverse_State: arr_evts: ', arr_evts]);
|
|
1272
|
-
//TODO: what is the right TTL? should it be a constant or calculated
|
|
1273
712
|
for (let i = arr_evts.length - 1; i >= 0; i--) {
|
|
1274
713
|
const { idx, evt } = arr_evts[i];
|
|
714
|
+
// a dropped message is not a step: not of this exchange, and it must not poison it either
|
|
715
|
+
// (it may well belong to ANOTHER exchange that reused the warp id -- that is why it was dropped)
|
|
716
|
+
if (evt.type === kstr_EVT_DROPPED_)
|
|
717
|
+
continue;
|
|
1275
718
|
const json_msg = evt.data.json_msg;
|
|
1276
719
|
if (!JSON_MsgWarp.compare(json_msgWarp, this._warp(json_msg).json_msgWarp))
|
|
1277
720
|
protocolState.state.changeState(new StateINVALID(idx, evt));
|
|
@@ -1279,13 +722,13 @@ class TwoPhW_EventLog {
|
|
|
1279
722
|
case '2PhW[JSON_MsgWarp]':
|
|
1280
723
|
protocolState.state.changeState(new StateWarp(idx, evt));
|
|
1281
724
|
break;
|
|
1282
|
-
case '2PhW[
|
|
725
|
+
case '2PhW[JSON_AckWarp]':
|
|
1283
726
|
protocolState.state.changeState(new StateAckWarp(idx, evt));
|
|
1284
727
|
break;
|
|
1285
|
-
case '2PhW[
|
|
728
|
+
case '2PhW[JSON_EffEngage]':
|
|
1286
729
|
protocolState.state.changeState(new StateEngage(idx, evt));
|
|
1287
730
|
break;
|
|
1288
|
-
case '2PhW[
|
|
731
|
+
case '2PhW[JSON_AckEngage]':
|
|
1289
732
|
protocolState.state.changeState(new StateAckEngage(idx, evt));
|
|
1290
733
|
break;
|
|
1291
734
|
}
|
|
@@ -1343,166 +786,156 @@ class TwoPhW {
|
|
|
1343
786
|
return false;
|
|
1344
787
|
}
|
|
1345
788
|
//-------------------------------------------------------------------------------------------------
|
|
789
|
+
// The typed handlers (handler_json_<message>) are what the responder's base dispatch calls AFTER it
|
|
790
|
+
// validated the message as that type (generated: `JSON_AckWarp.validate(json_ack) &&
|
|
791
|
+
// this.handler_json_ackWarp(msg, json_ack)`). They do not validate again.
|
|
792
|
+
//-------------------------------------------------------------------------------------------------
|
|
1346
793
|
// sender Source (src)
|
|
1347
794
|
register_msgWarp(msg, json_msgWarp) {
|
|
1348
795
|
logr_.log(l_.SENDER, () => ['register_msgWarp: ', json_msgWarp]);
|
|
1349
796
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1350
797
|
const b_changeState = protocolState.canChangeState(new StateWarp(null, {
|
|
1351
798
|
dt: Date.now(),
|
|
1352
|
-
data: { msg, json_msg: json_msgWarp }
|
|
799
|
+
data: { msg, json_msg: json_msgWarp, b_sent: true }
|
|
1353
800
|
}));
|
|
1354
801
|
logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_msgWarp: protocolState.canChangeState ', b_changeState]);
|
|
1355
802
|
if (!b_changeState)
|
|
1356
803
|
return false;
|
|
1357
804
|
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec);
|
|
1358
805
|
const elapsed_ms = Date.now() - Date.parse(json_msgWarp.dt);
|
|
1359
|
-
this.eventLog._addEvent(msg, json_msgWarp, timeout_ms - elapsed_ms, () => {
|
|
1360
|
-
this.config.
|
|
806
|
+
this.eventLog._addEvent(msg, json_msgWarp, true, timeout_ms - elapsed_ms, () => {
|
|
807
|
+
this.config._callback_sender_sent_expired(msg, json_msgWarp);
|
|
1361
808
|
});
|
|
809
|
+
return true;
|
|
1362
810
|
}
|
|
1363
|
-
|
|
1364
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
1365
|
-
|
|
811
|
+
handler_json_ackWarp(msg, json_ackWarp) {
|
|
812
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackWarp: ', json_ackWarp]);
|
|
813
|
+
// no callback for this step: not ours -- before anything is logged
|
|
814
|
+
if (!this.config._callback_ackWarp)
|
|
815
|
+
return false;
|
|
816
|
+
const json_msgWarp = json_ackWarp._cause;
|
|
1366
817
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1367
818
|
const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
|
|
1368
819
|
dt: Date.now(),
|
|
1369
|
-
data: { msg, json_msg:
|
|
820
|
+
data: { msg, json_msg: json_ackWarp, b_sent: false }
|
|
1370
821
|
}));
|
|
1371
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
822
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackWarp: protocolState.canChangeState ', b_changeState]);
|
|
1372
823
|
if (!b_changeState)
|
|
1373
824
|
return false;
|
|
1374
825
|
this.eventLog._cancelTimeout(protocolState.state.idx_event);
|
|
1375
|
-
this.eventLog._addEvent(msg,
|
|
1376
|
-
return this.config.
|
|
826
|
+
this.eventLog._addEvent(msg, json_ackWarp, false);
|
|
827
|
+
return this.config._callback_ackWarp(msg, json_ackWarp);
|
|
1377
828
|
}
|
|
1378
|
-
|
|
1379
|
-
logr_.log(l_.SENDER, () => ['
|
|
1380
|
-
const json_msgWarp =
|
|
829
|
+
register_effEngage(msg, json_effEngage) {
|
|
830
|
+
logr_.log(l_.SENDER, () => ['register_effEngage: ', json_effEngage]);
|
|
831
|
+
const json_msgWarp = json_effEngage._cause;
|
|
1381
832
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1382
833
|
const b_changeState = protocolState.canChangeState(new StateEngage(null, {
|
|
1383
834
|
dt: Date.now(),
|
|
1384
|
-
data: { msg, json_msg:
|
|
835
|
+
data: { msg, json_msg: json_effEngage, b_sent: true }
|
|
1385
836
|
}));
|
|
1386
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
837
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_effEngage: protocolState.canChangeState ', b_changeState]);
|
|
1387
838
|
if (!b_changeState)
|
|
1388
839
|
return false;
|
|
1389
|
-
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec,
|
|
840
|
+
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, json_effEngage.engage.rtt_msec);
|
|
1390
841
|
const elapsed_ms = Date.now() - Date.parse(json_msgWarp.dt);
|
|
1391
|
-
this.eventLog._addEvent(msg,
|
|
1392
|
-
this.config.
|
|
842
|
+
this.eventLog._addEvent(msg, json_effEngage, true, timeout_ms - elapsed_ms, () => {
|
|
843
|
+
this.config._callback_sender_sent_expired(msg, json_effEngage);
|
|
1393
844
|
});
|
|
845
|
+
return true;
|
|
1394
846
|
}
|
|
1395
|
-
|
|
1396
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
1397
|
-
|
|
847
|
+
handler_json_ackEngage(msg, json_ackEngage) {
|
|
848
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackEngage: ', json_ackEngage]);
|
|
849
|
+
// no callback for this step: not ours -- before anything is logged
|
|
850
|
+
if (!this.config._callback_ackEngage)
|
|
851
|
+
return false;
|
|
852
|
+
const json_msgWarp = json_ackEngage._cause._cause;
|
|
1398
853
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1399
854
|
const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
|
|
1400
855
|
dt: Date.now(),
|
|
1401
|
-
data: { msg, json_msg:
|
|
856
|
+
data: { msg, json_msg: json_ackEngage, b_sent: false }
|
|
1402
857
|
}));
|
|
1403
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
858
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackEngage: protocolState.canChangeState ', b_changeState]);
|
|
1404
859
|
if (!b_changeState)
|
|
1405
860
|
return false;
|
|
1406
861
|
this.eventLog._cancelTimeout(protocolState.state.idx_event);
|
|
1407
|
-
this.eventLog._addEvent(msg,
|
|
1408
|
-
return this.config.
|
|
862
|
+
this.eventLog._addEvent(msg, json_ackEngage, false);
|
|
863
|
+
return this.config._callback_ackEngage(msg, json_ackEngage);
|
|
1409
864
|
}
|
|
1410
865
|
//-------------------------------------------------------------------------------------------------
|
|
1411
866
|
// receiver Destination (dst)
|
|
1412
|
-
|
|
1413
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
867
|
+
handler_json_msgWarp(msg, json_msgWarp) {
|
|
868
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_msgWarp: ', json_msgWarp]);
|
|
869
|
+
// no callback for this step: not ours -- before anything is logged
|
|
870
|
+
if (!this.config._callback_msgWarp)
|
|
871
|
+
return false;
|
|
1414
872
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1415
873
|
const b_changeState = protocolState.canChangeState(new StateWarp(null, {
|
|
1416
874
|
dt: Date.now(),
|
|
1417
|
-
data: { msg, json_msg: json_msgWarp }
|
|
875
|
+
data: { msg, json_msg: json_msgWarp, b_sent: false }
|
|
1418
876
|
}));
|
|
1419
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
877
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_msgWarp: protocolState.canChangeState: ', b_changeState]);
|
|
1420
878
|
if (!b_changeState)
|
|
1421
879
|
return false;
|
|
1422
|
-
this.eventLog._addEvent(msg, json_msgWarp);
|
|
880
|
+
this.eventLog._addEvent(msg, json_msgWarp, false);
|
|
1423
881
|
return this.config._callback_msgWarp(msg, json_msgWarp);
|
|
1424
882
|
}
|
|
1425
|
-
|
|
1426
|
-
logr_.log(l_.RECVER, () => ['
|
|
1427
|
-
const json_msgWarp =
|
|
883
|
+
register_ackWarp(msg, json_ackWarp) {
|
|
884
|
+
logr_.log(l_.RECVER, () => ['register_ackWarp: ', json_ackWarp]);
|
|
885
|
+
const json_msgWarp = json_ackWarp._cause;
|
|
1428
886
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1429
887
|
const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
|
|
1430
888
|
dt: Date.now(),
|
|
1431
|
-
data: { msg, json_msg:
|
|
889
|
+
data: { msg, json_msg: json_ackWarp, b_sent: true }
|
|
1432
890
|
}));
|
|
1433
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
891
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_ackWarp: protocolState.canChangeState: ', b_changeState]);
|
|
1434
892
|
if (!b_changeState)
|
|
1435
893
|
return false;
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
this.
|
|
894
|
+
// The expiry means "the Engage I was waiting for never came". An ack no Engage can follow
|
|
895
|
+
// concludes the exchange and awaits nothing: logged, with no timer.
|
|
896
|
+
if (!isEngageAwaited_(json_ackWarp)) {
|
|
897
|
+
this.eventLog._addEvent(msg, json_ackWarp, true);
|
|
898
|
+
return true;
|
|
899
|
+
}
|
|
900
|
+
const elapsed_ms = Date.now() - Date.parse(json_ackWarp.dt);
|
|
901
|
+
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec) + Date.parse(json_ackWarp.dt) - Date.parse(json_msgWarp.dt);
|
|
902
|
+
this.eventLog._addEvent(msg, json_ackWarp, true, timeout_ms - elapsed_ms, () => {
|
|
903
|
+
this.config._callback_receiver_sent_expired(msg, json_ackWarp);
|
|
1440
904
|
});
|
|
905
|
+
return true;
|
|
1441
906
|
}
|
|
1442
|
-
|
|
1443
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
1444
|
-
|
|
907
|
+
handler_json_effEngage(msg, json_effEngage) {
|
|
908
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_effEngage: ', json_effEngage]);
|
|
909
|
+
// no callback for this step: not ours -- before anything is logged
|
|
910
|
+
if (!this.config._callback_effEngage)
|
|
911
|
+
return false;
|
|
912
|
+
const json_msgWarp = json_effEngage._cause;
|
|
1445
913
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1446
914
|
const b_changeState = protocolState.canChangeState(new StateEngage(null, {
|
|
1447
915
|
dt: Date.now(),
|
|
1448
|
-
data: { msg, json_msg:
|
|
916
|
+
data: { msg, json_msg: json_effEngage, b_sent: false }
|
|
1449
917
|
}));
|
|
1450
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
918
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_effEngage: protocolState.canChangeState: ', b_changeState]);
|
|
1451
919
|
if (!b_changeState)
|
|
1452
920
|
return false;
|
|
1453
921
|
this.eventLog._cancelTimeout(protocolState.state.idx_event);
|
|
1454
|
-
this.eventLog._addEvent(msg,
|
|
1455
|
-
return this.config.
|
|
922
|
+
this.eventLog._addEvent(msg, json_effEngage, false);
|
|
923
|
+
return this.config._callback_effEngage(msg, json_effEngage);
|
|
1456
924
|
}
|
|
1457
|
-
|
|
1458
|
-
logr_.log(l_.RECVER, () => ['
|
|
1459
|
-
const json_msgWarp =
|
|
925
|
+
register_ackEngage(msg, json_ackEngage) {
|
|
926
|
+
logr_.log(l_.RECVER, () => ['register_ackEngage: ', json_ackEngage]);
|
|
927
|
+
const json_msgWarp = json_ackEngage._cause._cause;
|
|
1460
928
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1461
929
|
const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
|
|
1462
930
|
dt: Date.now(),
|
|
1463
|
-
data: { msg, json_msg:
|
|
931
|
+
data: { msg, json_msg: json_ackEngage, b_sent: true }
|
|
1464
932
|
}));
|
|
1465
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
933
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_ackEngage: protocolState.canChangeState: ', b_changeState]);
|
|
1466
934
|
if (!b_changeState)
|
|
1467
935
|
return false;
|
|
1468
|
-
this.eventLog._addEvent(msg,
|
|
1469
|
-
|
|
1470
|
-
//-------------------------------------------------------------------------------------------------
|
|
1471
|
-
handler_json_msgAck(msg, json_msgAck) {
|
|
1472
|
-
logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgAck: ', json_msgAck]);
|
|
1473
|
-
if (JSON_MsgAckWarp.validate(json_msgAck) && this._handler_msgAckWarp(msg, json_msgAck))
|
|
1474
|
-
return true;
|
|
1475
|
-
if (JSON_MsgAckEngage.validate(json_msgAck) && this._handler_msgAckEngage(msg, json_msgAck))
|
|
1476
|
-
return true;
|
|
1477
|
-
return false;
|
|
1478
|
-
}
|
|
1479
|
-
handler_json_msgEffect(msg, json_msgEffect) {
|
|
1480
|
-
logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgEffect: ', json_msgEffect]);
|
|
1481
|
-
// if (JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect) )
|
|
1482
|
-
// return true;
|
|
1483
|
-
if (JSON_MsgEngage.validate(json_msgEffect) && this._handler_msgEngage(msg, json_msgEffect))
|
|
1484
|
-
return true;
|
|
1485
|
-
// if (JSON_MsgOptions.validate(json_msg) && this.handler_msgOptions_(this._config, msg, json_msg))
|
|
1486
|
-
// return true;
|
|
1487
|
-
return false;
|
|
1488
|
-
}
|
|
1489
|
-
handler_json_msg(msg, json_msg) {
|
|
1490
|
-
logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msg: ', json_msg]);
|
|
1491
|
-
if (JSON_MsgWarp.validate(json_msg) && this._handler_msgWarp(msg, json_msg))
|
|
1492
|
-
return true;
|
|
1493
|
-
// https://attacomsian.com/blog/javascript-iterate-objects
|
|
1494
|
-
// Object.keys(json_msg).forEach((key, index) => {
|
|
1495
|
-
// if (key == 'dt')
|
|
1496
|
-
// return;
|
|
1497
|
-
// if (key == 'referer')
|
|
1498
|
-
// return;
|
|
1499
|
-
// console.log(`${key}: ${json_msg[key]}`);
|
|
1500
|
-
// });
|
|
1501
|
-
return false;
|
|
936
|
+
this.eventLog._addEvent(msg, json_ackEngage, true);
|
|
937
|
+
return true;
|
|
1502
938
|
}
|
|
1503
939
|
}
|
|
1504
940
|
|
|
1505
|
-
|
|
1506
|
-
var JSON_MsgAck = jsonMsg_cjsExports.JSON_MsgAck;
|
|
1507
|
-
var JSON_MsgEffect = jsonMsg_cjsExports.JSON_MsgEffect;
|
|
1508
|
-
export { JSON_Msg, JSON_MsgAck, JSON_MsgAckEngage, JSON_MsgAckWarp, JSON_MsgEffect, JSON_MsgEngage, JSON_MsgOptions, JSON_MsgWarp, StateAckEngage, StateAckWarp, StateEngage, StateINVALID, StateInitialState, StateWarp, TwoPhW, logr_ as logr, time_ttl_rtt_ as t_ttl_rtt };
|
|
941
|
+
export { JSON_AckEngage, JSON_AckWarp, JSON_EffEngage, JSON_MsgOptions, JSON_MsgWarp, StateAckEngage, StateAckWarp, StateEngage, StateINVALID, StateInitialState, StateWarp, TwoPhW, k_VERSION as VERSION, logr_ as logr, time_ttl_rtt_ as t_ttl_rtt };
|