@rootintf/protocol-2phw 2.0.3-api.2 → 2.2.2-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.
@@ -176,198 +176,445 @@ function validate20(data, { instancePath = "", parentData, parentDataProperty, r
176
176
  } validate20.errors = vErrors; return errors === 0; }
177
177
  validate20.evaluated = { "props": { "engage": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
178
178
 
179
+ // https://stackoverflow.com/questions/4602141/variable-name-as-a-string-in-javascript
179
180
  // console.log('OUT', __name({variableName}) );
180
-
181
181
  //-------------------------------------------------------------------------------------------------
182
-
183
182
  function l_length_(obj_labels) {
184
- if (! obj_labels || typeof obj_labels !== 'object')
185
- throw new Error('obj_labels must be an object');
183
+ if (!obj_labels || typeof obj_labels !== 'object')
184
+ throw new Error('obj_labels must be an object');
186
185
  const obj_1label = Object.values(obj_labels);
187
- if (! obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
188
- throw new Error('All values must be finite numbers');
189
-
186
+ if (!obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
187
+ throw new Error('All values must be finite numbers');
190
188
  const labels = Object.values(obj_labels);
191
- if (labels.length === 0)
192
- return 1; // Empty object case, start at 1
193
-
189
+ if (labels.length === 0)
190
+ return 1; // Empty object case, start at 1
194
191
  const value_max = Math.max(...labels);
195
- if (value_max <= 0) return 1
196
-
192
+ if (value_max <= 0)
193
+ return 1;
197
194
  const bit_highest = Math.floor(Math.log2(value_max));
198
195
  return 1 << (bit_highest + 1);
199
196
  }
200
-
201
197
  function l_array_(arr_labels, start = 1) {
202
- if (! Array.isArray(arr_labels))
203
- throw new Error('arr_labels must be an array');
204
- if (! Number.isSafeInteger(start) || start < 0)
205
- throw new Error('start must be a safe, non-negative integer');
206
-
198
+ if (!Array.isArray(arr_labels))
199
+ throw new Error('arr_labels must be an array');
200
+ if (!Number.isSafeInteger(start) || start < 0)
201
+ throw new Error('start must be a safe, non-negative integer');
207
202
  return Object.freeze(arr_labels.reduce((acc, key, index) => {
208
203
  acc[key] = start << index;
209
204
  return acc;
210
205
  }, {}));
211
206
  }
212
-
213
207
  function l_concat_(obj_labels, arg) {
214
- if (! obj_labels || typeof obj_labels !== 'object')
215
- throw new Error('obj_labels must be an object');
208
+ if (!obj_labels || typeof obj_labels !== 'object')
209
+ throw new Error('obj_labels must be an object');
216
210
  const obj_1label = Object.values(obj_labels);
217
- if (! obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
218
- throw new Error('All values must be finite numbers');
219
- if (! arg || (typeof arg !== 'object' && ! Array.isArray(arg)))
220
- throw new Error('arg must be an object or array');
221
-
222
- if (Array.isArray(arg)) {
223
- const len = l_length_(obj_labels);
224
- const arr_labels_new = l_array_(arg, len);
225
- return l_concat_(obj_labels, arr_labels_new);
226
- }
227
-
228
- const next_pos = l_length_(obj_labels);
229
- const arg_entries = Object.entries(arg);
211
+ if (!obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
212
+ throw new Error('All values must be finite numbers');
213
+ if (!arg || (typeof arg !== 'object' && !Array.isArray(arg)))
214
+ throw new Error('arg must be an object or array');
215
+ if (Array.isArray(arg)) {
216
+ const len = l_length_(obj_labels);
217
+ const arr_labels_new = l_array_(arg, len);
218
+ return l_concat_(obj_labels, arr_labels_new);
219
+ }
220
+ const next_pos = l_length_(obj_labels);
221
+ const arg_entries = Object.entries(arg);
230
222
  const result = Object.create(null);
231
223
  Object.entries(obj_labels).forEach(([k, v]) => {
232
- if (k !== '__proto__' && k !== 'constructor')
233
- result[k] = v;
224
+ if (k !== '__proto__' && k !== 'constructor')
225
+ result[k] = v;
234
226
  });
235
-
236
- let min_arg = Infinity;
237
- for (const [, value] of arg_entries) {
238
- if (typeof value !== 'number' || ! Number.isFinite(value))
239
- continue; // Skip non-numeric
240
-
241
- if (value > 0 && value < min_arg)
242
- min_arg = value;
243
- }
227
+ let min_arg = Infinity;
228
+ for (const [, value] of arg_entries) {
229
+ if (typeof value !== 'number' || !Number.isFinite(value))
230
+ continue; // Skip non-numeric
231
+ if (value > 0 && value < min_arg)
232
+ min_arg = value;
233
+ }
244
234
  // Shift only if min_arg is less than next_pos
245
- const shift = min_arg === Infinity || min_arg >= next_pos
246
- ? 0
235
+ const shift = min_arg === Infinity || min_arg >= next_pos
236
+ ? 0
247
237
  : Math.floor(Math.log2(next_pos / min_arg));
248
-
249
- for (const [key, value] of arg_entries) {
250
- if (!(key in result)) {
251
- result[key] = value === 0 ? 0 : value << shift;
252
- }
253
- }
254
-
255
- return Object.freeze(result);
238
+ for (const [key, value] of arg_entries) {
239
+ if (!(key in result)) {
240
+ result[key] = value === 0 ? 0 : value << shift;
241
+ }
242
+ }
243
+ return Object.freeze(result);
244
+ }
245
+ function l_merge_(obj_labels1, obj_labels2) {
246
+ if (!obj_labels1 || typeof obj_labels1 !== 'object')
247
+ throw new Error('obj_labels must be an object');
248
+ const obj_1label1 = Object.values(obj_labels1);
249
+ if (!obj_1label1.every(v => typeof v === 'number' && Number.isFinite(v)))
250
+ throw new Error('All values must be finite numbers');
251
+ if (!obj_labels2 || typeof obj_labels2 !== 'object')
252
+ throw new Error('obj_labels must be an object');
253
+ const obj_1label2 = Object.values(obj_labels2);
254
+ if (!obj_1label2.every(v => typeof v === 'number' && Number.isFinite(v)))
255
+ throw new Error('All values must be finite numbers');
256
+ const result = Object.create(null);
257
+ Object.entries(obj_labels1).forEach(([k, v]) => {
258
+ if (k !== '__proto__' && k !== 'constructor')
259
+ result[k] = v;
260
+ });
261
+ const set_values = new Set(Object.values(obj_labels1)); // Track all used bit values
262
+ // Find the highest bit position to start shifting from if needed
263
+ const value_highest = Math.max(0, ...Array.from(set_values));
264
+ let next_shift = value_highest ? Math.floor(Math.log2(value_highest)) + 1 : 0;
265
+ // Process second set
266
+ for (const [key, value] of Object.entries(obj_labels2)) {
267
+ if (key in result) {
268
+ // Same key: Values must match
269
+ if (result[key] !== value) {
270
+ throw new Error(`Key '${key}' has conflicting values: ${result[key]} (obj_labels1) vs ${value} (obj_labels2)`);
271
+ }
272
+ // No action needed if values match, already in result
273
+ }
274
+ else {
275
+ let maxIterations = 1000;
276
+ // New key: Add if value is unique, otherwise shift
277
+ let value_new = value;
278
+ while (set_values.has(value_new) && maxIterations--) {
279
+ value_new = 1 << next_shift++;
280
+ }
281
+ if (maxIterations <= 0)
282
+ throw new Error('Too many collisions in l_merge_');
283
+ result[key] = value_new;
284
+ set_values.add(value_new);
285
+ }
286
+ }
287
+ return Object.freeze(result);
256
288
  }
257
-
258
289
  function l_LL_(obj, x) {
259
- if (! obj || typeof obj !== 'object')
260
- throw new Error('obj must be an object');
261
- if (! Number.isSafeInteger(x) || x < 0)
262
- throw new Error('Shift value must be a safe, non-negative integer');
263
-
264
- const obj_new= {};
265
- for (const [k,v] of Object.entries(obj)) {
266
- if (typeof v !== 'number' || ! Number.isFinite(v))
267
- continue; // Skip non-numeric
268
- obj_new[k] = v<<x;
269
- }
270
- return Object.freeze(obj_new);
290
+ if (!obj || typeof obj !== 'object')
291
+ throw new Error('obj must be an object');
292
+ if (!Number.isSafeInteger(x) || x < 0)
293
+ throw new Error('Shift value must be a safe, non-negative integer');
294
+ const obj_new = {};
295
+ for (const [k, v] of Object.entries(obj)) {
296
+ if (typeof v !== 'number' || !Number.isFinite(v))
297
+ continue; // Skip non-numeric
298
+ obj_new[k] = v << x;
299
+ }
300
+ return Object.freeze(obj_new);
271
301
  }
272
-
273
- //-------------------------------------------------------------------------------------------------
274
-
275
- function handler_default_( /* ... */ ) {
276
- // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
277
- var args = Array.prototype.slice.call(arguments);
278
- console.log.apply(console, args);
302
+ function l_RR_(obj, x) {
303
+ if (!obj || typeof obj !== 'object')
304
+ throw new Error('obj must be an object');
305
+ if (!Number.isSafeInteger(x) || x < 0)
306
+ throw new Error('Shift value must be a safe, non-negative integer');
307
+ const obj_new = {};
308
+ for (const [k, v] of Object.entries(obj)) {
309
+ if (typeof v !== 'number' || !Number.isFinite(v))
310
+ continue; // Skip non-numeric
311
+ obj_new[k] = v >> x;
312
+ }
313
+ return Object.freeze(obj_new);
314
+ }
315
+ function l_assert_(actual, required) {
316
+ if (!actual || typeof actual !== 'object')
317
+ return false;
318
+ if (!required || typeof required !== 'object')
319
+ return false;
320
+ const actualEntries = Object.entries(actual);
321
+ const requiredEntries = Object.entries(required);
322
+ // if (actualEntries.length === 0 && expectedEntries.length > 0)
323
+ // return false;
324
+ const actualValues = new Set();
325
+ for (const [, v] of actualEntries) {
326
+ if (typeof v !== 'number' || !Number.isFinite(v))
327
+ return false;
328
+ actualValues.add(v);
329
+ }
330
+ const usedRequiredValues = new Set();
331
+ for (const [k, v] of requiredEntries) {
332
+ if (typeof v !== 'number' || !Number.isFinite(v))
333
+ return false;
334
+ if (k in actual) {
335
+ if (actual[k] !== v)
336
+ return false;
337
+ }
338
+ else {
339
+ if (!actualValues.has(v))
340
+ return false;
341
+ }
342
+ if (usedRequiredValues.has(v))
343
+ return false;
344
+ usedRequiredValues.add(v);
345
+ }
346
+ return true;
279
347
  }
280
-
281
348
  //-------------------------------------------------------------------------------------------------
282
-
283
- function l_toBigInt_(obj_labels, obj, ignore= false) {
284
- if (! obj_labels || typeof obj_labels !== 'object')
285
- throw new Error('obj_labels must be an object');
286
- if (! obj || typeof obj !== 'object')
287
- throw new Error('obj must be an object');
288
-
289
- let bigInt = BigInt(0);
290
- for (const [k,v] of Object.entries(obj)) {
291
- if ( ( ignore || v ) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
292
- bigInt|= BigInt( obj_labels[k] );
293
- // console.log('0b'+ bigInt.toString(2) );
294
- }
295
- return bigInt;
349
+ function handler_default_( /* ... */) {
350
+ // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
351
+ var args = Array.prototype.slice.call(arguments);
352
+ console.log.apply(console, args);
353
+ }
354
+ function l_toBigInt_(obj_labels, obj, ignore = false) {
355
+ if (!obj_labels || typeof obj_labels !== 'object')
356
+ throw new Error('obj_labels must be an object');
357
+ if (!obj || typeof obj !== 'object')
358
+ throw new Error('obj must be an object');
359
+ let bigint_l = BigInt(0);
360
+ for (const [k, v] of Object.entries(obj)) {
361
+ if ((ignore || v) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
362
+ bigint_l |= BigInt(obj_labels[k]);
363
+ // console.log('0b'+ bigInt.toString(2) );
364
+ }
365
+ return bigint_l;
366
+ }
367
+ function lRef(initial) {
368
+ if (arguments.length === 0 || initial === undefined) {
369
+ return undefined;
370
+ }
371
+ let value = initial;
372
+ return {
373
+ get: () => value,
374
+ set: (newVal) => { value = newVal; }
375
+ };
376
+ }
377
+ /*
378
+ const l_ = {
379
+ get VALIDATION() { return logr_.lref.get().VALIDATION; }
296
380
  }
297
381
 
298
- // console.log(l_toBigInt_({},{}))
299
-
300
- const LOGR = (function () {
301
- let _instance; // Private variable to hold the single instance
302
-
303
- function _create_instance() {
304
- // Private state (replacing constructor properties)
305
- let _handler_log = handler_default_;
306
- let _obj_labels = undefined;
307
- let _Bint_toggled = BigInt(0);
308
-
309
- function _log_fxn(nr_logged, argsFn /* args */) {
310
- if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
311
- return false;
312
-
313
- const args = argsFn();
314
- _handler_log.apply(this, args);
315
- // _handler_log.apply(this, args);
316
- return true;
317
- }
382
+ function createBitFlags(ref) {
383
+ // Create a proxy so that any property access computes the current bit
384
+ return new Proxy({}, {
385
+ get(target, prop, receiver) {
386
+ const positions = ref.get(); // get current { VALIDATION: n, ... }
387
+ const position = positions[prop]; // e.g., positions['VALIDATION']
388
+
389
+ if (position === undefined) {
390
+ // Optional: warn or return 0 for unknown keys
391
+ console.warn(`Unknown bitflag key: ${String(prop)}`);
392
+ return 0;
393
+ }
318
394
 
319
- return {
320
- set handler(fx) {
321
- _handler_log = fx;
322
- },
323
- get handler() {
324
- return _handler_log;
325
- },
395
+ return 0b1 << position; // or 1 << position
396
+ },
326
397
 
327
- get labels() { return _obj_labels; },
328
- set labels(obj) {
329
- _obj_labels = obj;
330
- _Bint_toggled = BigInt(0);
331
- },
398
+ // Optional: make Object.keys(l_) show the actual keys
399
+ ownKeys(target) {
400
+ return Object.keys(ref.get());
401
+ },
332
402
 
333
- // put= function(label, abbrv) {
334
- // let name= __name(label);
335
- // _labels[name]= label[name];
336
- // console.log(_labels);
337
- // }
403
+ getOwnPropertyDescriptor(target, prop) {
404
+ return {
405
+ enumerable: true,
406
+ configurable: true,
407
+ };
408
+ }
409
+ });
410
+ }
338
411
 
339
- get toggled() { return _Bint_toggled; },
340
- set toggled(obj_toggled) {
341
- _Bint_toggled= l_toBigInt_(_obj_labels, obj_toggled);
342
- },
412
+ type BitPositions = Record<string, number>;
343
413
 
344
- log(nr_logged, argsFn) {
345
-
346
- return _log_fxn.call(this, nr_logged, argsFn); // Pass the thunk
414
+ function createBitFlags<T extends BitPositions>(ref: { get: () => T }) {
415
+ return new Proxy({} as { [K in keyof T]: number }, {
416
+ get(target, prop: string | symbol) {
417
+ if (typeof prop !== 'string') return undefined;
418
+ const positions = ref.get();
419
+ const position = positions[prop as keyof T];
420
+ if (position === undefined) return 0;
421
+ return 1 << position;
422
+ },
423
+ ownKeys() {
424
+ return Object.keys(ref.get());
425
+ },
426
+ getOwnPropertyDescriptor() {
427
+ return { enumerable: true, configurable: true };
428
+ }
429
+ });
430
+ }
431
+ */
432
+ function create_Referenced_l_(ref) {
433
+ return new Proxy({}, {
434
+ get(target, prop) {
435
+ if (typeof prop !== 'string')
436
+ return undefined;
437
+ // if (prop === 'get') {
438
+ // return () => {
439
+ // const positions = ref.get();
440
+ // const result: Partial<Record<keyof T, number>> = {};
441
+ // for (const key in positions) {
442
+ // result[key as keyof T] = positions[key];
443
+ // }
444
+ // return result as Record<keyof T, number>;
445
+ // };
446
+ // }
447
+ if (prop === 'get')
448
+ return () => ref.get();
449
+ const positions = ref.get();
450
+ const value = positions[prop];
451
+ if (value === undefined)
452
+ return 0;
453
+ return value;
454
+ },
455
+ ownKeys() {
456
+ return Object.keys(ref.get());
457
+ },
458
+ getOwnPropertyDescriptor() {
459
+ return { enumerable: true, configurable: true };
460
+ }
461
+ });
462
+ }
463
+ const LOGR = (function () {
464
+ let _instance; // Private variable to hold the single instance
465
+ // Module-level state would work - but only when the module is loaded once.
466
+ // Your bundler is currently bundling @knev/bitlogr into your distribution file,
467
+ // creating a second copy. The Global Symbol approach would work around this,
468
+ // but it's treating the symptom, not the cause.
469
+ const GLOBAL_KEY = Symbol.for('@knev/bitlogr/LOGR');
470
+ // The real issue is your build configuration bundling dependencies that should remain external.
471
+ // rollup.config.mjs: external: ['@knev/bitlogr', 'uuid'], // Don't bundle these
472
+ function _create_instance() {
473
+ const _id = Math.random();
474
+ if (globalThis.LOGR_ENABLED ?? true)
475
+ console.log('creating LOGR instance:', _id);
476
+ // Private state (replacing constructor properties)
477
+ let _Bint_toggled = BigInt(0);
478
+ let _handler_log = handler_default_;
479
+ function _log_fxn(nr_logged, argsFn /* args */) {
480
+ // console.log('_log_fxn: ', BigInt(nr_logged), _Bint_toggled, (BigInt(nr_logged) & _Bint_toggled));
481
+ if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
482
+ return;
483
+ const args = argsFn();
484
+ _handler_log.apply(this, args);
485
+ }
486
+ return {
487
+ _id, // for testing
488
+ get handler() { return _handler_log; },
489
+ set handler(fx) {
490
+ _handler_log = fx;
491
+ },
492
+ get toggled() { return _Bint_toggled; },
493
+ // toggle(obj_labels, obj_toggled) {
494
+ // _Bint_toggled= l_toBigInt_(obj_labels, obj_toggled);
495
+ // },
496
+ toggle(labels, obj_toggled) {
497
+ const obj_labels = typeof labels?.get === 'function'
498
+ ? labels.get()
499
+ : labels;
500
+ // console.log('obj_labels', obj_labels)
501
+ _Bint_toggled = l_toBigInt_(obj_labels, obj_toggled);
502
+ },
503
+ // Core internal log function (exposed only to created loggers)
504
+ _log_fxn,
505
+ create(options = {}) {
506
+ // This constant will be replaced at build time
507
+ if (!(globalThis.LOGR_ENABLED ?? true)) {
508
+ return {
509
+ _obj_labels: undefined, // optional: keep shape compatible if needed
510
+ log: () => { }, // does nothing
511
+ raw: () => { }, // does nothing
512
+ };
513
+ }
514
+ const _logger = {
515
+ // _lref_labels: (options.arr_labels === undefined) ? undefined : lRef( l_array_(options.arr_labels) ),
516
+ _lref_labels: (options.labels === undefined)
517
+ ? undefined
518
+ : lRef(options.labels),
519
+ get l() {
520
+ // Always create a fresh proxy pointing to the current labels
521
+ return create_Referenced_l_({
522
+ get: () => this._lref_labels?.get() || {}
523
+ });
524
+ },
525
+ get lref() { return this._lref_labels; },
526
+ set lref(lref_labels_new) {
527
+ this._lref_labels = lref_labels_new;
528
+ },
529
+ log(nr_logged, argsFn) {
530
+ // This constant will be replaced at build time
531
+ if (!(globalThis.LOGR_ENABLED ?? true))
532
+ return;
533
+ _log_fxn.call(this, nr_logged, argsFn);
534
+ },
535
+ // Optional shorthand for common cases
536
+ raw(...args) {
537
+ _handler_log.apply(this, args);
538
+ }
539
+ };
540
+ return _logger;
541
+ },
542
+ };
543
+ }
544
+ // Public interface
545
+ return {
546
+ get_instance() {
547
+ if (!(globalThis.LOGR_USE_GLOBAL_KEY ?? true)) {
548
+ if (!_instance)
549
+ _instance = _create_instance(); // Lazy initialization
550
+ return _instance;
347
551
  }
348
- };
349
- }
552
+ if (!globalThis[GLOBAL_KEY])
553
+ globalThis[GLOBAL_KEY] = _create_instance();
554
+ return globalThis[GLOBAL_KEY];
555
+ },
556
+ // For testing only - reset the singleton
557
+ _reset_for_testing() {
558
+ delete globalThis[GLOBAL_KEY];
559
+ }
560
+ };
561
+ })();
350
562
 
351
- // Public interface
352
- return {
353
- get_instance() {
354
- if (!_instance) {
355
- _instance = _create_instance(); // Lazy initialization
563
+ var logr_es = /*#__PURE__*/Object.freeze({
564
+ __proto__: null,
565
+ LOGR: LOGR,
566
+ _create_Referenced_l: create_Referenced_l_,
567
+ lRef: lRef,
568
+ l_LL: l_LL_,
569
+ l_RR: l_RR_,
570
+ l_array: l_array_,
571
+ l_assert: l_assert_,
572
+ l_concat: l_concat_,
573
+ l_length: l_length_,
574
+ l_merge: l_merge_
575
+ });
576
+
577
+ function getAugmentedNamespace(n) {
578
+ if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
579
+ var f = n.default;
580
+ if (typeof f == "function") {
581
+ var a = function a () {
582
+ var isInstance = false;
583
+ try {
584
+ isInstance = this instanceof a;
585
+ } catch {}
586
+ if (isInstance) {
587
+ return Reflect.construct(f, arguments, this.constructor);
356
588
  }
357
- return _instance;
358
- }
359
- };
360
-
361
- })();
589
+ return f.apply(this, arguments);
590
+ };
591
+ a.prototype = f.prototype;
592
+ } else a = {};
593
+ Object.defineProperty(a, '__esModule', {value: true});
594
+ Object.keys(n).forEach(function (k) {
595
+ var d = Object.getOwnPropertyDescriptor(n, k);
596
+ Object.defineProperty(a, k, d.get ? d : {
597
+ enumerable: true,
598
+ get: function () {
599
+ return n[k];
600
+ }
601
+ });
602
+ });
603
+ return a;
604
+ }
362
605
 
363
606
  var jsonMsg_cjs = {};
364
607
 
608
+ var require$$0 = /*@__PURE__*/getAugmentedNamespace(logr_es);
609
+
365
610
  var hasRequiredJsonMsg_cjs;
366
611
 
367
612
  function requireJsonMsg_cjs () {
368
613
  if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
369
614
  hasRequiredJsonMsg_cjs = 1;
370
615
 
616
+ var bitlogr = require$$0;
617
+
371
618
  const schema_Msg = validate18;
372
619
  function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
373
620
  evaluated0.props = undefined;
@@ -537,105 +784,12 @@ function requireJsonMsg_cjs () {
537
784
  return _v4(options);
538
785
  }
539
786
 
540
- // console.log('OUT', __name({variableName}) );
541
-
542
-
543
787
  //-------------------------------------------------------------------------------------------------
544
-
545
- function handler_default_( /* ... */ ) {
546
- // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
547
- var args = Array.prototype.slice.call(arguments);
548
- console.log.apply(console, args);
549
- }
550
-
788
+ const LOGR_ = bitlogr.LOGR.get_instance();
789
+ const logr_ = LOGR_.create({ labels: bitlogr.l_array(['VALIDATION']) });
790
+ const l_ = logr_.l;
791
+ // console.log('File location:', import.meta.url, '[Implementation]');
551
792
  //-------------------------------------------------------------------------------------------------
552
-
553
- function l_toBigInt_(obj_labels, obj, ignore= false) {
554
- if (! obj_labels || typeof obj_labels !== 'object')
555
- throw new Error('obj_labels must be an object');
556
- if (! obj || typeof obj !== 'object')
557
- throw new Error('obj must be an object');
558
-
559
- let bigInt = BigInt(0);
560
- for (const [k,v] of Object.entries(obj)) {
561
- if ( ( ignore || v ) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
562
- bigInt|= BigInt( obj_labels[k] );
563
- // console.log('0b'+ bigInt.toString(2) );
564
- }
565
- return bigInt;
566
- }
567
-
568
- // console.log(l_toBigInt_({},{}))
569
-
570
- const LOGR = (function () {
571
- let _instance; // Private variable to hold the single instance
572
-
573
- function _create_instance() {
574
- // Private state (replacing constructor properties)
575
- let _handler_log = handler_default_;
576
- let _obj_labels = undefined;
577
- let _Bint_toggled = BigInt(0);
578
-
579
- function _log_fxn(nr_logged, argsFn /* args */) {
580
- if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
581
- return false;
582
-
583
- const args = argsFn();
584
- _handler_log.apply(this, args);
585
- // _handler_log.apply(this, args);
586
- return true;
587
- }
588
-
589
- return {
590
- set handler(fx) {
591
- _handler_log = fx;
592
- },
593
- get handler() {
594
- return _handler_log;
595
- },
596
-
597
- get labels() { return _obj_labels; },
598
- set labels(obj) {
599
- _obj_labels = obj;
600
- _Bint_toggled = BigInt(0);
601
- },
602
-
603
- // put= function(label, abbrv) {
604
- // let name= __name(label);
605
- // _labels[name]= label[name];
606
- // console.log(_labels);
607
- // }
608
-
609
- get toggled() { return _Bint_toggled; },
610
- set toggled(obj_toggled) {
611
- _Bint_toggled= l_toBigInt_(_obj_labels, obj_toggled);
612
- },
613
-
614
- log(nr_logged, argsFn) {
615
-
616
- return _log_fxn.call(this, nr_logged, argsFn); // Pass the thunk
617
- }
618
- };
619
- }
620
-
621
- // Public interface
622
- return {
623
- get_instance() {
624
- if (!_instance) {
625
- _instance = _create_instance(); // Lazy initialization
626
- }
627
- return _instance;
628
- }
629
- };
630
-
631
- })();
632
-
633
- let LOGR_ = LOGR.get_instance();
634
- const log_ = LOGR_.log;
635
- const l_ = {
636
- VALIDATION: 0b1 << 0,
637
- };
638
- LOGR_.labels = l_;
639
793
  // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
640
794
  // "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
641
795
  var JSON_Msg = (function () {
@@ -650,7 +804,7 @@ function requireJsonMsg_cjs () {
650
804
  validate: function (json) {
651
805
  const b_valid = schema_Msg(json);
652
806
  if (!b_valid)
653
- log_(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
807
+ logr_.log(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
654
808
  return b_valid;
655
809
  },
656
810
  // TODO: requires a separate ajv module require, and JTD specific schema
@@ -672,7 +826,7 @@ function requireJsonMsg_cjs () {
672
826
  return false;
673
827
  const b_valid = schema_MsgEffect(json);
674
828
  if (!b_valid)
675
- log_(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
829
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
676
830
  return b_valid;
677
831
  }
678
832
  };
@@ -699,7 +853,7 @@ function requireJsonMsg_cjs () {
699
853
  return false;
700
854
  const b_valid = schema_MsgAckEffect(json);
701
855
  if (!b_valid)
702
- log_(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
856
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
703
857
  return b_valid;
704
858
  }
705
859
  };
@@ -708,7 +862,7 @@ function requireJsonMsg_cjs () {
708
862
  jsonMsg_cjs.JSON_Msg = JSON_Msg;
709
863
  jsonMsg_cjs.JSON_MsgAck = JSON_MsgAck;
710
864
  jsonMsg_cjs.JSON_MsgEffect = JSON_MsgEffect;
711
- jsonMsg_cjs.l = l_;
865
+ jsonMsg_cjs.logr = logr_;
712
866
  return jsonMsg_cjs;
713
867
  }
714
868
 
@@ -716,15 +870,8 @@ var jsonMsg_cjsExports = requireJsonMsg_cjs();
716
870
 
717
871
  //-------------------------------------------------------------------------------------------------
718
872
  let LOGR_$1 = LOGR.get_instance();
719
- const log_$1 = LOGR_$1.log;
720
- const l_$1 = {
721
- EVENTS: 0b1 << 0,
722
- TIMEOUTS: 0b1 << 1,
723
- };
724
- LOGR_$1.labels = l_$1;
725
- // LOGR_.toggled= {
726
- // EVENTS : 1
727
- // }
873
+ const logr_$1 = LOGR_$1.create({ labels: l_array_(['LOG_EVENTS', 'TIMEOUTS']) });
874
+ const l_$1 = logr_$1.l;
728
875
  //-------------------------------------------------------------------------------------------------
729
876
  class EventLog {
730
877
  constructor() {
@@ -753,7 +900,7 @@ class EventLog {
753
900
  if (this.map_timeouts.delete(idx)) {
754
901
  evt.timeout_id = null;
755
902
  timeout_callback({ idx, evt });
756
- log_$1(l_$1.EVENTS, () => [`Event DELETED[${idx}]: ${type}`, evt]);
903
+ logr_$1.log(l_$1.LOG_EVENTS, () => [`Event DELETED[${idx}]: ${type}`, evt]);
757
904
  }
758
905
  }, timeout_ms);
759
906
  this.map_timeouts.set(idx, evt.timeout_id);
@@ -761,7 +908,7 @@ class EventLog {
761
908
  // the error "toISOString is not a function" occurs because Date(evt.dt) is not doing what you expect.
762
909
  // When you pass a number to the Date constructor without using new, it doesn’t return a Date object—it returns a string. Specifically, it’s equivalent to new Date(evt.dt).toString().
763
910
  // Date(evt.dt).toISOString() -> new Date(evt.dt).toISOString()
764
- log_$1(l_$1.EVENTS, () => [`Event added[${idx}] @${new Date(evt.dt).toISOString()}: ${type}`, evt]);
911
+ logr_$1.log(l_$1.LOG_EVENTS, () => [`Event added[${idx}] @${new Date(evt.dt).toISOString()}: ${type}`, evt]);
765
912
  return { idx, evt };
766
913
  }
767
914
  cancelTimeout(idx) {
@@ -835,12 +982,15 @@ class EventLog {
835
982
  // };
836
983
  const k_TTL = 20000;
837
984
  //-------------------------------------------------------------------------------------------------
985
+ const obj_labels_merge_ = l_merge_(logr_$1.lref.get(), jsonMsg_cjsExports.logr.lref.get()); // VALIDATION : 4
986
+ const obj_labels_concat_ = l_concat_(obj_labels_merge_, l_array_(['HANDLERS', 'DROPS', 'PROTOCOL_STATE', 'RECVER', 'SENDER']));
987
+ const lref_ = lRef(obj_labels_concat_);
988
+ jsonMsg_cjsExports.logr.lref = lref_;
989
+ logr_$1.lref = lref_;
838
990
  const LOGR_ = LOGR.get_instance();
839
- const log_ = LOGR_.log;
840
- Object.assign(jsonMsg_cjsExports.l, l_LL_(jsonMsg_cjsExports.l, 2)); // VALIDATION : 4
841
- const l_twoPhW_ = l_array_(['HANDLERS', 'DROPS', 'PROTOCOL_STATE', 'RECVER', 'SENDER']);
842
- const l_ = l_concat_(l_$1, l_concat_(jsonMsg_cjsExports.l, l_twoPhW_));
843
- LOGR_.labels = l_;
991
+ const logr_ = LOGR_.create(); // don't let create() make a new ref, assign lref_ from here
992
+ logr_.lref = lref_;
993
+ const l_ = logr_.l;
844
994
  class Config {
845
995
  _callback_msgWarp;
846
996
  _callback_msgEngage;
@@ -922,7 +1072,7 @@ var JSON_MsgOptions = (function () {
922
1072
  // if (! JSON_Msg_msg.validate(json))
923
1073
  // return false;
924
1074
  // if (! schema_MsgOptions_(json)) {
925
- // log_(l_.VALIDATION, () => ['JSON_MsgOptions: schema_MsgOptions_: ', (schema_MsgOptions_ as any).errors])
1075
+ // logr_.log(l_.VALIDATION, () => ['JSON_MsgOptions: schema_MsgOptions_: ', (schema_MsgOptions_ as any).errors])
926
1076
  // return false;
927
1077
  // }
928
1078
  return true;
@@ -957,7 +1107,7 @@ var JSON_MsgWarp = (function () {
957
1107
  // if (! JSON_Msg.validate(json))
958
1108
  // return false;
959
1109
  if (!schema_MsgWarp(json_msg)) {
960
- log_(l_.VALIDATION, () => ['JSON_MsgWarp: schema_MsgWarp_: ', schema_MsgWarp.errors]);
1110
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgWarp: schema_MsgWarp_: ', schema_MsgWarp.errors]);
961
1111
  return false;
962
1112
  }
963
1113
  return true;
@@ -982,7 +1132,7 @@ var JSON_MsgEngage = (function () {
982
1132
  if (!JSON_MsgWarp.validate(json_msgEffect._cause))
983
1133
  return false;
984
1134
  if (!schema_MsgEngage(json_msgEffect)) {
985
- log_(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
1135
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
986
1136
  return false;
987
1137
  }
988
1138
  return true;
@@ -1095,7 +1245,7 @@ class StateEngage extends StateState {
1095
1245
  // The Engage gets to live for THE WARP'S creation time + TTL*2 + RTT
1096
1246
  const json_msgWarp = this.json_msgEngage._cause;
1097
1247
  const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.json_msgEngage.engage.rtt_msec);
1098
- log_(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
1248
+ logr_.log(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
1099
1249
  if (state_new.evt_AckEngage.dt >= Date.parse(json_msgWarp.dt) + timeout_ms)
1100
1250
  return false;
1101
1251
  return true;
@@ -1118,7 +1268,7 @@ class StateAckWarp extends StateState {
1118
1268
  // - AckWarp: TAckWarp +2TLL +STT; TAckWarp= T0 +STT;
1119
1269
  // - STT: Date of the Ack minus date of the Warp.
1120
1270
  const timeout_ms = time_ttl_rtt_(this.json_msgAckWarp._cause.warp.ttl_msec) + Date.parse(this.json_msgAckWarp.dt) - Date.parse(this.json_msgAckWarp._cause.dt);
1121
- log_(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_msgAckWarp.dt)} + ${timeout_ms}`]);
1271
+ logr_.log(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_msgAckWarp.dt)} + ${timeout_ms}`]);
1122
1272
  if (state_new.evt_Engage.dt >= Date.parse(this.json_msgAckWarp.dt) + timeout_ms)
1123
1273
  return false;
1124
1274
  return true;
@@ -1133,7 +1283,7 @@ class StateWarp extends StateState {
1133
1283
  return false;
1134
1284
  // The Warp gets to live for THE WARP'S creation time + TTL*2
1135
1285
  const timeout_ms = time_ttl_rtt_(this.json_msgWarp.warp.ttl_msec);
1136
- log_(l_.PROTOCOL_STATE, () => [`StateWarp: evt_AckWarp.dt@${state_new.evt_AckWarp.dt}, msgWarp.dt@${Date.parse(this.json_msgWarp.dt)} + ${timeout_ms}`]);
1286
+ logr_.log(l_.PROTOCOL_STATE, () => [`StateWarp: evt_AckWarp.dt@${state_new.evt_AckWarp.dt}, msgWarp.dt@${Date.parse(this.json_msgWarp.dt)} + ${timeout_ms}`]);
1137
1287
  if (state_new.evt_AckWarp.dt >= Date.parse(this.json_msgWarp.dt) + timeout_ms)
1138
1288
  return false;
1139
1289
  return true;
@@ -1153,7 +1303,7 @@ class StateInitialState extends StateState {
1153
1303
  return false;
1154
1304
  // The NEWLY created Warp only gets to live for its creation time + TTL
1155
1305
  const timeout_ms = state_new.json_msgWarp.warp.ttl_msec;
1156
- log_(l_.PROTOCOL_STATE, () => [`StateInitialState: evt_Warp.dt@${state_new.evt_Warp.dt}, msgWarp.dt@${Date.parse(state_new.json_msgWarp.dt)} + ${timeout_ms}`]);
1306
+ logr_.log(l_.PROTOCOL_STATE, () => [`StateInitialState: evt_Warp.dt@${state_new.evt_Warp.dt}, msgWarp.dt@${Date.parse(state_new.json_msgWarp.dt)} + ${timeout_ms}`]);
1157
1307
  if (state_new.evt_Warp.dt >= Date.parse(state_new.json_msgWarp.dt) + timeout_ms)
1158
1308
  return false;
1159
1309
  return true;
@@ -1208,7 +1358,7 @@ class TwoPhW_EventLog {
1208
1358
  _addEvent(msg, json_msg, timeout_ms, timeout_callback) {
1209
1359
  const { str_type, json_msgWarp } = this._warp(json_msg);
1210
1360
  const { idx } = this._eventLog.addEvent(str_type, json_msgWarp.warp.id, { msg, json_msg }, timeout_ms, timeout_callback);
1211
- log_(l_.PROTOCOL_STATE, () => [`_addEvent: [${idx}] timeout:${Date.now()}+${timeout_ms} `, json_msg]);
1361
+ logr_.log(l_.PROTOCOL_STATE, () => [`_addEvent: [${idx}] timeout:${Date.now()}+${timeout_ms} `, json_msg]);
1212
1362
  }
1213
1363
  _dropEvent(json_msg) {
1214
1364
  const { json_msgWarp } = this._warp(json_msg);
@@ -1217,13 +1367,13 @@ class TwoPhW_EventLog {
1217
1367
  this._eventLog.addEvent('2PhW[DROPPED!]', json_msgWarp.warp.id, json_msg);
1218
1368
  }
1219
1369
  _cancelTimeout(idx_event) {
1220
- log_(l_.PROTOCOL_STATE, () => [`_cancelTimeout: [${idx_event}] timeout cancelled`]);
1370
+ logr_.log(l_.PROTOCOL_STATE, () => [`_cancelTimeout: [${idx_event}] timeout cancelled`]);
1221
1371
  this._eventLog.cancelTimeout(idx_event);
1222
1372
  }
1223
1373
  traverse_State(json_msgWarp) {
1224
1374
  const protocolState = new ProtocolStateState();
1225
1375
  const arr_evts = this._eventLog.getEventsById(json_msgWarp.warp.id, k_TTL);
1226
- log_(l_.EVENTS, () => ['traverse_State: arr_evts: ', arr_evts]);
1376
+ logr_.log(l_.EVENTS, () => ['traverse_State: arr_evts: ', arr_evts]);
1227
1377
  //TODO: what is the right TTL? should it be a constant or calculated
1228
1378
  for (let i = arr_evts.length - 1; i >= 0; i--) {
1229
1379
  const { idx, evt } = arr_evts[i];
@@ -1244,7 +1394,7 @@ class TwoPhW_EventLog {
1244
1394
  protocolState.state.changeState(new StateAckEngage(idx, evt));
1245
1395
  break;
1246
1396
  }
1247
- log_(l_.PROTOCOL_STATE, () => ['traverse_State: type,state: ',
1397
+ logr_.log(l_.PROTOCOL_STATE, () => ['traverse_State: type,state: ',
1248
1398
  evt.type,
1249
1399
  (protocolState.state.json_msg.ack?.ok === false) ? '--NACK--' : '',
1250
1400
  protocolState.state
@@ -1268,7 +1418,7 @@ class TwoPhW {
1268
1418
  }
1269
1419
  //-------------------------------------------------------------------------------------------------
1270
1420
  _handler_msgOptions(cfg, msg, json_msgOptions) {
1271
- log_(l_.HANDLERS, () => ['handler_msgOptions_: ...']);
1421
+ logr_.log(l_.HANDLERS, () => ['handler_msgOptions_: ...']);
1272
1422
  /*
1273
1423
  if (! validate_Options_delay_(json_msgOptions.options))
1274
1424
  return false;
@@ -1285,7 +1435,7 @@ class TwoPhW {
1285
1435
 
1286
1436
  //TODO: double check ttl_msec is the same as current accummulated ttl for idempotence.
1287
1437
 
1288
- log_(l_.HANDLERS, () => ['handler_msgOptions_: ', json_msgOptions]);
1438
+ logr_.log(l_.HANDLERS, () => ['handler_msgOptions_: ', json_msgOptions]);
1289
1439
 
1290
1440
  ctx.protocol.delayTimeout(ttl_incr);
1291
1441
 
@@ -1300,13 +1450,13 @@ class TwoPhW {
1300
1450
  //-------------------------------------------------------------------------------------------------
1301
1451
  // sender Source (src)
1302
1452
  register_msgWarp(msg, json_msgWarp) {
1303
- log_(l_.SENDER, () => ['register_msgWarp: ', json_msgWarp]);
1453
+ logr_.log(l_.SENDER, () => ['register_msgWarp: ', json_msgWarp]);
1304
1454
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1305
1455
  const b_changeState = protocolState.canChangeState(new StateWarp(null, {
1306
1456
  dt: Date.now(),
1307
1457
  data: { msg, json_msg: json_msgWarp }
1308
1458
  }));
1309
- log_(l_.HANDLERS | l_.SENDER, () => ['register_msgWarp: protocolState.canChangeState ', b_changeState]);
1459
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_msgWarp: protocolState.canChangeState ', b_changeState]);
1310
1460
  if (!b_changeState)
1311
1461
  return false;
1312
1462
  const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec);
@@ -1316,14 +1466,14 @@ class TwoPhW {
1316
1466
  });
1317
1467
  }
1318
1468
  _handler_msgAckWarp(msg, json_msgAckWarp) {
1319
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: ', json_msgAckWarp]);
1469
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: ', json_msgAckWarp]);
1320
1470
  const json_msgWarp = json_msgAckWarp._cause;
1321
1471
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1322
1472
  const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
1323
1473
  dt: Date.now(),
1324
1474
  data: { msg, json_msg: json_msgAckWarp }
1325
1475
  }));
1326
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: protocolState.canChangeState ', b_changeState]);
1476
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: protocolState.canChangeState ', b_changeState]);
1327
1477
  if (!b_changeState)
1328
1478
  return false;
1329
1479
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
@@ -1331,14 +1481,14 @@ class TwoPhW {
1331
1481
  return this.config._callback_msgAckWarp(msg, json_msgAckWarp);
1332
1482
  }
1333
1483
  register_msgEngage(msg, json_msgEngage) {
1334
- log_(l_.SENDER, () => ['register_msgEngage: ', json_msgEngage]);
1484
+ logr_.log(l_.SENDER, () => ['register_msgEngage: ', json_msgEngage]);
1335
1485
  const json_msgWarp = json_msgEngage._cause;
1336
1486
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1337
1487
  const b_changeState = protocolState.canChangeState(new StateEngage(null, {
1338
1488
  dt: Date.now(),
1339
1489
  data: { msg, json_msg: json_msgEngage }
1340
1490
  }));
1341
- log_(l_.HANDLERS | l_.SENDER, () => ['register_msgEngage: protocolState.canChangeState ', b_changeState]);
1491
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_msgEngage: protocolState.canChangeState ', b_changeState]);
1342
1492
  if (!b_changeState)
1343
1493
  return false;
1344
1494
  const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, json_msgEngage.engage.rtt_msec);
@@ -1348,14 +1498,14 @@ class TwoPhW {
1348
1498
  });
1349
1499
  }
1350
1500
  _handler_msgAckEngage(msg, json_msgAckEngage) {
1351
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage: ', json_msgAckEngage]);
1501
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage: ', json_msgAckEngage]);
1352
1502
  const json_msgWarp = json_msgAckEngage._cause._cause;
1353
1503
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1354
1504
  const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
1355
1505
  dt: Date.now(),
1356
1506
  data: { msg, json_msg: json_msgAckEngage }
1357
1507
  }));
1358
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage_: protocolState.canChangeState ', b_changeState]);
1508
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage_: protocolState.canChangeState ', b_changeState]);
1359
1509
  if (!b_changeState)
1360
1510
  return false;
1361
1511
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
@@ -1365,27 +1515,27 @@ class TwoPhW {
1365
1515
  //-------------------------------------------------------------------------------------------------
1366
1516
  // receiver Destination (dst)
1367
1517
  _handler_msgWarp(msg, json_msgWarp) {
1368
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: ', json_msgWarp]);
1518
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: ', json_msgWarp]);
1369
1519
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1370
1520
  const b_changeState = protocolState.canChangeState(new StateWarp(null, {
1371
1521
  dt: Date.now(),
1372
1522
  data: { msg, json_msg: json_msgWarp }
1373
1523
  }));
1374
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: protocolState.canChangeState: ', b_changeState]);
1524
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: protocolState.canChangeState: ', b_changeState]);
1375
1525
  if (!b_changeState)
1376
1526
  return false;
1377
1527
  this.eventLog._addEvent(msg, json_msgWarp);
1378
1528
  return this.config._callback_msgWarp(msg, json_msgWarp);
1379
1529
  }
1380
1530
  register_msgAckWarp(msg, json_msgAckWarp) {
1381
- log_(l_.RECVER, () => ['register_msgAckWarp: ', json_msgAckWarp]);
1531
+ logr_.log(l_.RECVER, () => ['register_msgAckWarp: ', json_msgAckWarp]);
1382
1532
  const json_msgWarp = json_msgAckWarp._cause;
1383
1533
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1384
1534
  const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
1385
1535
  dt: Date.now(),
1386
1536
  data: { msg, json_msg: json_msgAckWarp }
1387
1537
  }));
1388
- log_(l_.HANDLERS | l_.RECVER, () => ['register_msgAckWarp: protocolState.canChangeState: ', b_changeState]);
1538
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_msgAckWarp: protocolState.canChangeState: ', b_changeState]);
1389
1539
  if (!b_changeState)
1390
1540
  return false;
1391
1541
  const elapsed_ms = Date.now() - Date.parse(json_msgAckWarp.dt);
@@ -1395,14 +1545,14 @@ class TwoPhW {
1395
1545
  });
1396
1546
  }
1397
1547
  _handler_msgEngage(msg, json_msgEngage) {
1398
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: ', json_msgEngage]);
1548
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: ', json_msgEngage]);
1399
1549
  const json_msgWarp = json_msgEngage._cause;
1400
1550
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1401
1551
  const b_changeState = protocolState.canChangeState(new StateEngage(null, {
1402
1552
  dt: Date.now(),
1403
1553
  data: { msg, json_msg: json_msgEngage }
1404
1554
  }));
1405
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: protocolState.canChangeState: ', b_changeState]);
1555
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: protocolState.canChangeState: ', b_changeState]);
1406
1556
  if (!b_changeState)
1407
1557
  return false;
1408
1558
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
@@ -1410,21 +1560,21 @@ class TwoPhW {
1410
1560
  return this.config._callback_msgEngage(msg, json_msgEngage);
1411
1561
  }
1412
1562
  register_msgAckEngage(msg, json_msgAckEngage) {
1413
- log_(l_.RECVER, () => ['register_msgAckEngage: ', json_msgAckEngage]);
1563
+ logr_.log(l_.RECVER, () => ['register_msgAckEngage: ', json_msgAckEngage]);
1414
1564
  const json_msgWarp = json_msgAckEngage._cause._cause;
1415
1565
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1416
1566
  const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
1417
1567
  dt: Date.now(),
1418
1568
  data: { msg, json_msg: json_msgAckEngage }
1419
1569
  }));
1420
- log_(l_.HANDLERS | l_.RECVER, () => ['register_msgAckEngage: protocolState.canChangeState: ', b_changeState]);
1570
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_msgAckEngage: protocolState.canChangeState: ', b_changeState]);
1421
1571
  if (!b_changeState)
1422
1572
  return false;
1423
1573
  this.eventLog._addEvent(msg, json_msgAckEngage);
1424
1574
  }
1425
1575
  //-------------------------------------------------------------------------------------------------
1426
1576
  handler_json_msgAck(msg, json_msgAck) {
1427
- log_(l_.HANDLERS, () => ['handler_json_msgAck: ', json_msgAck]);
1577
+ logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgAck: ', json_msgAck]);
1428
1578
  if (JSON_MsgAckWarp.validate(json_msgAck) && this._handler_msgAckWarp(msg, json_msgAck))
1429
1579
  return true;
1430
1580
  if (JSON_MsgAckEngage.validate(json_msgAck) && this._handler_msgAckEngage(msg, json_msgAck))
@@ -1432,9 +1582,9 @@ class TwoPhW {
1432
1582
  return false;
1433
1583
  }
1434
1584
  handler_json_msgEffect(msg, json_msgEffect) {
1435
- log_(l_.HANDLERS, () => ['handler_json_msgEffect: ', json_msgEffect]);
1436
- if (jsonMsg_cjsExports.JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect))
1437
- return true;
1585
+ logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgEffect: ', json_msgEffect]);
1586
+ // if (JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect) )
1587
+ // return true;
1438
1588
  if (JSON_MsgEngage.validate(json_msgEffect) && this._handler_msgEngage(msg, json_msgEffect))
1439
1589
  return true;
1440
1590
  // if (JSON_MsgOptions.validate(json_msg) && this.handler_msgOptions_(this._config, msg, json_msg))
@@ -1442,7 +1592,7 @@ class TwoPhW {
1442
1592
  return false;
1443
1593
  }
1444
1594
  handler_json_msg(msg, json_msg) {
1445
- log_(l_.HANDLERS, () => ['handler_json_msg: ', json_msg]);
1595
+ logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msg: ', json_msg]);
1446
1596
  if (JSON_MsgWarp.validate(json_msg) && this._handler_msgWarp(msg, json_msg))
1447
1597
  return true;
1448
1598
  // https://attacomsian.com/blog/javascript-iterate-objects
@@ -1455,14 +1605,9 @@ class TwoPhW {
1455
1605
  // });
1456
1606
  return false;
1457
1607
  }
1458
- handler_json(msg, json) {
1459
- log_(l_.HANDLERS, () => ['handler_json: ', json]);
1460
- if (jsonMsg_cjsExports.JSON_MsgEffect.validate(json) && this.handler_json_msgEffect(msg, json))
1461
- return true;
1462
- if (jsonMsg_cjsExports.JSON_Msg.validate(json) && this.handler_json_msg(msg, json))
1463
- return true;
1464
- return false;
1465
- }
1466
1608
  }
1467
1609
 
1468
- export { EventLog, JSON_MsgAckEngage, JSON_MsgAckWarp, JSON_MsgEngage, JSON_MsgOptions, JSON_MsgWarp, StateAckEngage, StateAckWarp, StateEngage, StateINVALID, StateInitialState, StateWarp, TwoPhW, l_ as l, time_ttl_rtt_ as t_ttl_rtt };
1610
+ var JSON_Msg = jsonMsg_cjsExports.JSON_Msg;
1611
+ var JSON_MsgAck = jsonMsg_cjsExports.JSON_MsgAck;
1612
+ var JSON_MsgEffect = jsonMsg_cjsExports.JSON_MsgEffect;
1613
+ export { EventLog, 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 };