@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.
@@ -178,198 +178,445 @@ function validate20(data, { instancePath = "", parentData, parentDataProperty, r
178
178
  } validate20.errors = vErrors; return errors === 0; }
179
179
  validate20.evaluated = { "props": { "engage": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
180
180
 
181
+ // https://stackoverflow.com/questions/4602141/variable-name-as-a-string-in-javascript
181
182
  // console.log('OUT', __name({variableName}) );
182
-
183
183
  //-------------------------------------------------------------------------------------------------
184
-
185
184
  function l_length_(obj_labels) {
186
- if (! obj_labels || typeof obj_labels !== 'object')
187
- throw new Error('obj_labels must be an object');
185
+ if (!obj_labels || typeof obj_labels !== 'object')
186
+ throw new Error('obj_labels must be an object');
188
187
  const obj_1label = Object.values(obj_labels);
189
- if (! obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
190
- throw new Error('All values must be finite numbers');
191
-
188
+ if (!obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
189
+ throw new Error('All values must be finite numbers');
192
190
  const labels = Object.values(obj_labels);
193
- if (labels.length === 0)
194
- return 1; // Empty object case, start at 1
195
-
191
+ if (labels.length === 0)
192
+ return 1; // Empty object case, start at 1
196
193
  const value_max = Math.max(...labels);
197
- if (value_max <= 0) return 1
198
-
194
+ if (value_max <= 0)
195
+ return 1;
199
196
  const bit_highest = Math.floor(Math.log2(value_max));
200
197
  return 1 << (bit_highest + 1);
201
198
  }
202
-
203
199
  function l_array_(arr_labels, start = 1) {
204
- if (! Array.isArray(arr_labels))
205
- throw new Error('arr_labels must be an array');
206
- if (! Number.isSafeInteger(start) || start < 0)
207
- throw new Error('start must be a safe, non-negative integer');
208
-
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');
209
204
  return Object.freeze(arr_labels.reduce((acc, key, index) => {
210
205
  acc[key] = start << index;
211
206
  return acc;
212
207
  }, {}));
213
208
  }
214
-
215
209
  function l_concat_(obj_labels, arg) {
216
- if (! obj_labels || typeof obj_labels !== 'object')
217
- throw new Error('obj_labels must be an object');
210
+ if (!obj_labels || typeof obj_labels !== 'object')
211
+ throw new Error('obj_labels must be an object');
218
212
  const obj_1label = Object.values(obj_labels);
219
- if (! obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
220
- throw new Error('All values must be finite numbers');
221
- if (! arg || (typeof arg !== 'object' && ! Array.isArray(arg)))
222
- throw new Error('arg must be an object or array');
223
-
224
- if (Array.isArray(arg)) {
225
- const len = l_length_(obj_labels);
226
- const arr_labels_new = l_array_(arg, len);
227
- return l_concat_(obj_labels, arr_labels_new);
228
- }
229
-
230
- const next_pos = l_length_(obj_labels);
231
- const arg_entries = Object.entries(arg);
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);
232
224
  const result = Object.create(null);
233
225
  Object.entries(obj_labels).forEach(([k, v]) => {
234
- if (k !== '__proto__' && k !== 'constructor')
235
- result[k] = v;
226
+ if (k !== '__proto__' && k !== 'constructor')
227
+ result[k] = v;
236
228
  });
237
-
238
- let min_arg = Infinity;
239
- for (const [, value] of arg_entries) {
240
- if (typeof value !== 'number' || ! Number.isFinite(value))
241
- continue; // Skip non-numeric
242
-
243
- if (value > 0 && value < min_arg)
244
- min_arg = value;
245
- }
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
+ }
246
236
  // Shift only if min_arg is less than next_pos
247
- const shift = min_arg === Infinity || min_arg >= next_pos
248
- ? 0
237
+ const shift = min_arg === Infinity || min_arg >= next_pos
238
+ ? 0
249
239
  : Math.floor(Math.log2(next_pos / min_arg));
250
-
251
- for (const [key, value] of arg_entries) {
252
- if (!(key in result)) {
253
- result[key] = value === 0 ? 0 : value << shift;
254
- }
255
- }
256
-
257
- return Object.freeze(result);
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
275
+ }
276
+ else {
277
+ let maxIterations = 1000;
278
+ // New key: Add if value is unique, otherwise shift
279
+ let value_new = value;
280
+ while (set_values.has(value_new) && maxIterations--) {
281
+ value_new = 1 << next_shift++;
282
+ }
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
+ }
288
+ }
289
+ return Object.freeze(result);
258
290
  }
259
-
260
291
  function l_LL_(obj, x) {
261
- if (! obj || typeof obj !== 'object')
262
- throw new Error('obj must be an object');
263
- if (! Number.isSafeInteger(x) || x < 0)
264
- throw new Error('Shift value must be a safe, non-negative integer');
265
-
266
- const obj_new= {};
267
- for (const [k,v] of Object.entries(obj)) {
268
- if (typeof v !== 'number' || ! Number.isFinite(v))
269
- continue; // Skip non-numeric
270
- obj_new[k] = v<<x;
271
- }
272
- return Object.freeze(obj_new);
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);
273
303
  }
274
-
275
- //-------------------------------------------------------------------------------------------------
276
-
277
- function handler_default_( /* ... */ ) {
278
- // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
279
- var args = Array.prototype.slice.call(arguments);
280
- console.log.apply(console, args);
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')
321
+ 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
+ }
332
+ const usedRequiredValues = new Set();
333
+ for (const [k, v] of requiredEntries) {
334
+ if (typeof v !== 'number' || !Number.isFinite(v))
335
+ return false;
336
+ if (k in actual) {
337
+ if (actual[k] !== v)
338
+ return false;
339
+ }
340
+ else {
341
+ if (!actualValues.has(v))
342
+ return false;
343
+ }
344
+ if (usedRequiredValues.has(v))
345
+ return false;
346
+ usedRequiredValues.add(v);
347
+ }
348
+ return true;
281
349
  }
282
-
283
350
  //-------------------------------------------------------------------------------------------------
284
-
285
- function l_toBigInt_(obj_labels, obj, ignore= false) {
286
- if (! obj_labels || typeof obj_labels !== 'object')
287
- throw new Error('obj_labels must be an object');
288
- if (! obj || typeof obj !== 'object')
289
- throw new Error('obj must be an object');
290
-
291
- let bigInt = BigInt(0);
292
- for (const [k,v] of Object.entries(obj)) {
293
- if ( ( ignore || v ) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
294
- bigInt|= BigInt( obj_labels[k] );
295
- // console.log('0b'+ bigInt.toString(2) );
296
- }
297
- return bigInt;
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; }
298
382
  }
299
383
 
300
- // console.log(l_toBigInt_({},{}))
301
-
302
- const LOGR = (function () {
303
- let _instance; // Private variable to hold the single instance
304
-
305
- function _create_instance() {
306
- // Private state (replacing constructor properties)
307
- let _handler_log = handler_default_;
308
- let _obj_labels = undefined;
309
- let _Bint_toggled = BigInt(0);
310
-
311
- function _log_fxn(nr_logged, argsFn /* args */) {
312
- if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
313
- return false;
314
-
315
- const args = argsFn();
316
- _handler_log.apply(this, args);
317
- // _handler_log.apply(this, args);
318
- return true;
319
- }
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;
395
+ }
320
396
 
321
- return {
322
- set handler(fx) {
323
- _handler_log = fx;
324
- },
325
- get handler() {
326
- return _handler_log;
327
- },
397
+ return 0b1 << position; // or 1 << position
398
+ },
328
399
 
329
- get labels() { return _obj_labels; },
330
- set labels(obj) {
331
- _obj_labels = obj;
332
- _Bint_toggled = BigInt(0);
333
- },
400
+ // Optional: make Object.keys(l_) show the actual keys
401
+ ownKeys(target) {
402
+ return Object.keys(ref.get());
403
+ },
334
404
 
335
- // put= function(label, abbrv) {
336
- // let name= __name(label);
337
- // _labels[name]= label[name];
338
- // console.log(_labels);
339
- // }
405
+ getOwnPropertyDescriptor(target, prop) {
406
+ return {
407
+ enumerable: true,
408
+ configurable: true,
409
+ };
410
+ }
411
+ });
412
+ }
340
413
 
341
- get toggled() { return _Bint_toggled; },
342
- set toggled(obj_toggled) {
343
- _Bint_toggled= l_toBigInt_(_obj_labels, obj_toggled);
344
- },
414
+ type BitPositions = Record<string, number>;
345
415
 
346
- log(nr_logged, argsFn) {
347
-
348
- return _log_fxn.call(this, nr_logged, argsFn); // Pass the thunk
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
+ };
515
+ }
516
+ const _logger = {
517
+ // _lref_labels: (options.arr_labels === undefined) ? undefined : lRef( l_array_(options.arr_labels) ),
518
+ _lref_labels: (options.labels === undefined)
519
+ ? undefined
520
+ : lRef(options.labels),
521
+ get l() {
522
+ // Always create a fresh proxy pointing to the current labels
523
+ return create_Referenced_l_({
524
+ get: () => this._lref_labels?.get() || {}
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);
540
+ }
541
+ };
542
+ return _logger;
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;
349
553
  }
350
- };
351
- }
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
+ }
562
+ };
563
+ })();
352
564
 
353
- // Public interface
354
- return {
355
- get_instance() {
356
- if (!_instance) {
357
- _instance = _create_instance(); // Lazy initialization
565
+ var logr_es = /*#__PURE__*/Object.freeze({
566
+ __proto__: null,
567
+ LOGR: LOGR,
568
+ _create_Referenced_l: create_Referenced_l_,
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);
358
590
  }
359
- return _instance;
360
- }
361
- };
362
-
363
- })();
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
+ }
364
607
 
365
608
  var jsonMsg_cjs = {};
366
609
 
610
+ var require$$0 = /*@__PURE__*/getAugmentedNamespace(logr_es);
611
+
367
612
  var hasRequiredJsonMsg_cjs;
368
613
 
369
614
  function requireJsonMsg_cjs () {
370
615
  if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
371
616
  hasRequiredJsonMsg_cjs = 1;
372
617
 
618
+ var bitlogr = require$$0;
619
+
373
620
  const schema_Msg = validate18;
374
621
  function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
375
622
  evaluated0.props = undefined;
@@ -539,105 +786,12 @@ function requireJsonMsg_cjs () {
539
786
  return _v4(options);
540
787
  }
541
788
 
542
- // console.log('OUT', __name({variableName}) );
543
-
544
-
545
789
  //-------------------------------------------------------------------------------------------------
546
-
547
- function handler_default_( /* ... */ ) {
548
- // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
549
- var args = Array.prototype.slice.call(arguments);
550
- console.log.apply(console, args);
551
- }
552
-
790
+ const LOGR_ = bitlogr.LOGR.get_instance();
791
+ const logr_ = LOGR_.create({ labels: bitlogr.l_array(['VALIDATION']) });
792
+ const l_ = logr_.l;
793
+ // console.log('File location:', import.meta.url, '[Implementation]');
553
794
  //-------------------------------------------------------------------------------------------------
554
-
555
- function l_toBigInt_(obj_labels, obj, ignore= false) {
556
- if (! obj_labels || typeof obj_labels !== 'object')
557
- throw new Error('obj_labels must be an object');
558
- if (! obj || typeof obj !== 'object')
559
- throw new Error('obj must be an object');
560
-
561
- let bigInt = BigInt(0);
562
- for (const [k,v] of Object.entries(obj)) {
563
- if ( ( ignore || v ) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
564
- bigInt|= BigInt( obj_labels[k] );
565
- // console.log('0b'+ bigInt.toString(2) );
566
- }
567
- return bigInt;
568
- }
569
-
570
- // console.log(l_toBigInt_({},{}))
571
-
572
- const LOGR = (function () {
573
- let _instance; // Private variable to hold the single instance
574
-
575
- function _create_instance() {
576
- // Private state (replacing constructor properties)
577
- let _handler_log = handler_default_;
578
- let _obj_labels = undefined;
579
- let _Bint_toggled = BigInt(0);
580
-
581
- function _log_fxn(nr_logged, argsFn /* args */) {
582
- if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
583
- return false;
584
-
585
- const args = argsFn();
586
- _handler_log.apply(this, args);
587
- // _handler_log.apply(this, args);
588
- return true;
589
- }
590
-
591
- return {
592
- set handler(fx) {
593
- _handler_log = fx;
594
- },
595
- get handler() {
596
- return _handler_log;
597
- },
598
-
599
- get labels() { return _obj_labels; },
600
- set labels(obj) {
601
- _obj_labels = obj;
602
- _Bint_toggled = BigInt(0);
603
- },
604
-
605
- // put= function(label, abbrv) {
606
- // let name= __name(label);
607
- // _labels[name]= label[name];
608
- // console.log(_labels);
609
- // }
610
-
611
- get toggled() { return _Bint_toggled; },
612
- set toggled(obj_toggled) {
613
- _Bint_toggled= l_toBigInt_(_obj_labels, obj_toggled);
614
- },
615
-
616
- log(nr_logged, argsFn) {
617
-
618
- return _log_fxn.call(this, nr_logged, argsFn); // Pass the thunk
619
- }
620
- };
621
- }
622
-
623
- // Public interface
624
- return {
625
- get_instance() {
626
- if (!_instance) {
627
- _instance = _create_instance(); // Lazy initialization
628
- }
629
- return _instance;
630
- }
631
- };
632
-
633
- })();
634
-
635
- let LOGR_ = LOGR.get_instance();
636
- const log_ = LOGR_.log;
637
- const l_ = {
638
- VALIDATION: 0b1 << 0,
639
- };
640
- LOGR_.labels = l_;
641
795
  // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
642
796
  // "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
643
797
  var JSON_Msg = (function () {
@@ -652,7 +806,7 @@ function requireJsonMsg_cjs () {
652
806
  validate: function (json) {
653
807
  const b_valid = schema_Msg(json);
654
808
  if (!b_valid)
655
- log_(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
809
+ logr_.log(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
656
810
  return b_valid;
657
811
  },
658
812
  // TODO: requires a separate ajv module require, and JTD specific schema
@@ -674,7 +828,7 @@ function requireJsonMsg_cjs () {
674
828
  return false;
675
829
  const b_valid = schema_MsgEffect(json);
676
830
  if (!b_valid)
677
- log_(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
831
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
678
832
  return b_valid;
679
833
  }
680
834
  };
@@ -701,7 +855,7 @@ function requireJsonMsg_cjs () {
701
855
  return false;
702
856
  const b_valid = schema_MsgAckEffect(json);
703
857
  if (!b_valid)
704
- log_(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
858
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
705
859
  return b_valid;
706
860
  }
707
861
  };
@@ -710,7 +864,7 @@ function requireJsonMsg_cjs () {
710
864
  jsonMsg_cjs.JSON_Msg = JSON_Msg;
711
865
  jsonMsg_cjs.JSON_MsgAck = JSON_MsgAck;
712
866
  jsonMsg_cjs.JSON_MsgEffect = JSON_MsgEffect;
713
- jsonMsg_cjs.l = l_;
867
+ jsonMsg_cjs.logr = logr_;
714
868
  return jsonMsg_cjs;
715
869
  }
716
870
 
@@ -718,15 +872,8 @@ var jsonMsg_cjsExports = requireJsonMsg_cjs();
718
872
 
719
873
  //-------------------------------------------------------------------------------------------------
720
874
  let LOGR_$1 = LOGR.get_instance();
721
- const log_$1 = LOGR_$1.log;
722
- const l_$1 = {
723
- EVENTS: 0b1 << 0,
724
- TIMEOUTS: 0b1 << 1,
725
- };
726
- LOGR_$1.labels = l_$1;
727
- // LOGR_.toggled= {
728
- // EVENTS : 1
729
- // }
875
+ const logr_$1 = LOGR_$1.create({ labels: l_array_(['LOG_EVENTS', 'TIMEOUTS']) });
876
+ const l_$1 = logr_$1.l;
730
877
  //-------------------------------------------------------------------------------------------------
731
878
  class EventLog {
732
879
  constructor() {
@@ -755,7 +902,7 @@ class EventLog {
755
902
  if (this.map_timeouts.delete(idx)) {
756
903
  evt.timeout_id = null;
757
904
  timeout_callback({ idx, evt });
758
- log_$1(l_$1.EVENTS, () => [`Event DELETED[${idx}]: ${type}`, evt]);
905
+ logr_$1.log(l_$1.LOG_EVENTS, () => [`Event DELETED[${idx}]: ${type}`, evt]);
759
906
  }
760
907
  }, timeout_ms);
761
908
  this.map_timeouts.set(idx, evt.timeout_id);
@@ -763,7 +910,7 @@ class EventLog {
763
910
  // the error "toISOString is not a function" occurs because Date(evt.dt) is not doing what you expect.
764
911
  // 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().
765
912
  // Date(evt.dt).toISOString() -> new Date(evt.dt).toISOString()
766
- log_$1(l_$1.EVENTS, () => [`Event added[${idx}] @${new Date(evt.dt).toISOString()}: ${type}`, evt]);
913
+ logr_$1.log(l_$1.LOG_EVENTS, () => [`Event added[${idx}] @${new Date(evt.dt).toISOString()}: ${type}`, evt]);
767
914
  return { idx, evt };
768
915
  }
769
916
  cancelTimeout(idx) {
@@ -837,12 +984,15 @@ class EventLog {
837
984
  // };
838
985
  const k_TTL = 20000;
839
986
  //-------------------------------------------------------------------------------------------------
987
+ const obj_labels_merge_ = l_merge_(logr_$1.lref.get(), jsonMsg_cjsExports.logr.lref.get()); // VALIDATION : 4
988
+ const obj_labels_concat_ = l_concat_(obj_labels_merge_, l_array_(['HANDLERS', 'DROPS', 'PROTOCOL_STATE', 'RECVER', 'SENDER']));
989
+ const lref_ = lRef(obj_labels_concat_);
990
+ jsonMsg_cjsExports.logr.lref = lref_;
991
+ logr_$1.lref = lref_;
840
992
  const LOGR_ = LOGR.get_instance();
841
- const log_ = LOGR_.log;
842
- Object.assign(jsonMsg_cjsExports.l, l_LL_(jsonMsg_cjsExports.l, 2)); // VALIDATION : 4
843
- const l_twoPhW_ = l_array_(['HANDLERS', 'DROPS', 'PROTOCOL_STATE', 'RECVER', 'SENDER']);
844
- const l_ = l_concat_(l_$1, l_concat_(jsonMsg_cjsExports.l, l_twoPhW_));
845
- LOGR_.labels = l_;
993
+ const logr_ = LOGR_.create(); // don't let create() make a new ref, assign lref_ from here
994
+ logr_.lref = lref_;
995
+ const l_ = logr_.l;
846
996
  class Config {
847
997
  _callback_msgWarp;
848
998
  _callback_msgEngage;
@@ -924,7 +1074,7 @@ var JSON_MsgOptions = (function () {
924
1074
  // if (! JSON_Msg_msg.validate(json))
925
1075
  // return false;
926
1076
  // if (! schema_MsgOptions_(json)) {
927
- // log_(l_.VALIDATION, () => ['JSON_MsgOptions: schema_MsgOptions_: ', (schema_MsgOptions_ as any).errors])
1077
+ // logr_.log(l_.VALIDATION, () => ['JSON_MsgOptions: schema_MsgOptions_: ', (schema_MsgOptions_ as any).errors])
928
1078
  // return false;
929
1079
  // }
930
1080
  return true;
@@ -959,7 +1109,7 @@ var JSON_MsgWarp = (function () {
959
1109
  // if (! JSON_Msg.validate(json))
960
1110
  // return false;
961
1111
  if (!schema_MsgWarp(json_msg)) {
962
- log_(l_.VALIDATION, () => ['JSON_MsgWarp: schema_MsgWarp_: ', schema_MsgWarp.errors]);
1112
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgWarp: schema_MsgWarp_: ', schema_MsgWarp.errors]);
963
1113
  return false;
964
1114
  }
965
1115
  return true;
@@ -984,7 +1134,7 @@ var JSON_MsgEngage = (function () {
984
1134
  if (!JSON_MsgWarp.validate(json_msgEffect._cause))
985
1135
  return false;
986
1136
  if (!schema_MsgEngage(json_msgEffect)) {
987
- log_(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
1137
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
988
1138
  return false;
989
1139
  }
990
1140
  return true;
@@ -1097,7 +1247,7 @@ class StateEngage extends StateState {
1097
1247
  // The Engage gets to live for THE WARP'S creation time + TTL*2 + RTT
1098
1248
  const json_msgWarp = this.json_msgEngage._cause;
1099
1249
  const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.json_msgEngage.engage.rtt_msec);
1100
- log_(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
1250
+ logr_.log(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
1101
1251
  if (state_new.evt_AckEngage.dt >= Date.parse(json_msgWarp.dt) + timeout_ms)
1102
1252
  return false;
1103
1253
  return true;
@@ -1120,7 +1270,7 @@ class StateAckWarp extends StateState {
1120
1270
  // - AckWarp: TAckWarp +2TLL +STT; TAckWarp= T0 +STT;
1121
1271
  // - STT: Date of the Ack minus date of the Warp.
1122
1272
  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);
1123
- log_(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_msgAckWarp.dt)} + ${timeout_ms}`]);
1273
+ logr_.log(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_msgAckWarp.dt)} + ${timeout_ms}`]);
1124
1274
  if (state_new.evt_Engage.dt >= Date.parse(this.json_msgAckWarp.dt) + timeout_ms)
1125
1275
  return false;
1126
1276
  return true;
@@ -1135,7 +1285,7 @@ class StateWarp extends StateState {
1135
1285
  return false;
1136
1286
  // The Warp gets to live for THE WARP'S creation time + TTL*2
1137
1287
  const timeout_ms = time_ttl_rtt_(this.json_msgWarp.warp.ttl_msec);
1138
- log_(l_.PROTOCOL_STATE, () => [`StateWarp: evt_AckWarp.dt@${state_new.evt_AckWarp.dt}, msgWarp.dt@${Date.parse(this.json_msgWarp.dt)} + ${timeout_ms}`]);
1288
+ logr_.log(l_.PROTOCOL_STATE, () => [`StateWarp: evt_AckWarp.dt@${state_new.evt_AckWarp.dt}, msgWarp.dt@${Date.parse(this.json_msgWarp.dt)} + ${timeout_ms}`]);
1139
1289
  if (state_new.evt_AckWarp.dt >= Date.parse(this.json_msgWarp.dt) + timeout_ms)
1140
1290
  return false;
1141
1291
  return true;
@@ -1155,7 +1305,7 @@ class StateInitialState extends StateState {
1155
1305
  return false;
1156
1306
  // The NEWLY created Warp only gets to live for its creation time + TTL
1157
1307
  const timeout_ms = state_new.json_msgWarp.warp.ttl_msec;
1158
- log_(l_.PROTOCOL_STATE, () => [`StateInitialState: evt_Warp.dt@${state_new.evt_Warp.dt}, msgWarp.dt@${Date.parse(state_new.json_msgWarp.dt)} + ${timeout_ms}`]);
1308
+ 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}`]);
1159
1309
  if (state_new.evt_Warp.dt >= Date.parse(state_new.json_msgWarp.dt) + timeout_ms)
1160
1310
  return false;
1161
1311
  return true;
@@ -1210,7 +1360,7 @@ class TwoPhW_EventLog {
1210
1360
  _addEvent(msg, json_msg, timeout_ms, timeout_callback) {
1211
1361
  const { str_type, json_msgWarp } = this._warp(json_msg);
1212
1362
  const { idx } = this._eventLog.addEvent(str_type, json_msgWarp.warp.id, { msg, json_msg }, timeout_ms, timeout_callback);
1213
- log_(l_.PROTOCOL_STATE, () => [`_addEvent: [${idx}] timeout:${Date.now()}+${timeout_ms} `, json_msg]);
1363
+ logr_.log(l_.PROTOCOL_STATE, () => [`_addEvent: [${idx}] timeout:${Date.now()}+${timeout_ms} `, json_msg]);
1214
1364
  }
1215
1365
  _dropEvent(json_msg) {
1216
1366
  const { json_msgWarp } = this._warp(json_msg);
@@ -1219,13 +1369,13 @@ class TwoPhW_EventLog {
1219
1369
  this._eventLog.addEvent('2PhW[DROPPED!]', json_msgWarp.warp.id, json_msg);
1220
1370
  }
1221
1371
  _cancelTimeout(idx_event) {
1222
- log_(l_.PROTOCOL_STATE, () => [`_cancelTimeout: [${idx_event}] timeout cancelled`]);
1372
+ logr_.log(l_.PROTOCOL_STATE, () => [`_cancelTimeout: [${idx_event}] timeout cancelled`]);
1223
1373
  this._eventLog.cancelTimeout(idx_event);
1224
1374
  }
1225
1375
  traverse_State(json_msgWarp) {
1226
1376
  const protocolState = new ProtocolStateState();
1227
1377
  const arr_evts = this._eventLog.getEventsById(json_msgWarp.warp.id, k_TTL);
1228
- log_(l_.EVENTS, () => ['traverse_State: arr_evts: ', arr_evts]);
1378
+ logr_.log(l_.EVENTS, () => ['traverse_State: arr_evts: ', arr_evts]);
1229
1379
  //TODO: what is the right TTL? should it be a constant or calculated
1230
1380
  for (let i = arr_evts.length - 1; i >= 0; i--) {
1231
1381
  const { idx, evt } = arr_evts[i];
@@ -1246,7 +1396,7 @@ class TwoPhW_EventLog {
1246
1396
  protocolState.state.changeState(new StateAckEngage(idx, evt));
1247
1397
  break;
1248
1398
  }
1249
- log_(l_.PROTOCOL_STATE, () => ['traverse_State: type,state: ',
1399
+ logr_.log(l_.PROTOCOL_STATE, () => ['traverse_State: type,state: ',
1250
1400
  evt.type,
1251
1401
  (protocolState.state.json_msg.ack?.ok === false) ? '--NACK--' : '',
1252
1402
  protocolState.state
@@ -1270,7 +1420,7 @@ class TwoPhW {
1270
1420
  }
1271
1421
  //-------------------------------------------------------------------------------------------------
1272
1422
  _handler_msgOptions(cfg, msg, json_msgOptions) {
1273
- log_(l_.HANDLERS, () => ['handler_msgOptions_: ...']);
1423
+ logr_.log(l_.HANDLERS, () => ['handler_msgOptions_: ...']);
1274
1424
  /*
1275
1425
  if (! validate_Options_delay_(json_msgOptions.options))
1276
1426
  return false;
@@ -1287,7 +1437,7 @@ class TwoPhW {
1287
1437
 
1288
1438
  //TODO: double check ttl_msec is the same as current accummulated ttl for idempotence.
1289
1439
 
1290
- log_(l_.HANDLERS, () => ['handler_msgOptions_: ', json_msgOptions]);
1440
+ logr_.log(l_.HANDLERS, () => ['handler_msgOptions_: ', json_msgOptions]);
1291
1441
 
1292
1442
  ctx.protocol.delayTimeout(ttl_incr);
1293
1443
 
@@ -1302,13 +1452,13 @@ class TwoPhW {
1302
1452
  //-------------------------------------------------------------------------------------------------
1303
1453
  // sender Source (src)
1304
1454
  register_msgWarp(msg, json_msgWarp) {
1305
- log_(l_.SENDER, () => ['register_msgWarp: ', json_msgWarp]);
1455
+ logr_.log(l_.SENDER, () => ['register_msgWarp: ', json_msgWarp]);
1306
1456
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1307
1457
  const b_changeState = protocolState.canChangeState(new StateWarp(null, {
1308
1458
  dt: Date.now(),
1309
1459
  data: { msg, json_msg: json_msgWarp }
1310
1460
  }));
1311
- log_(l_.HANDLERS | l_.SENDER, () => ['register_msgWarp: protocolState.canChangeState ', b_changeState]);
1461
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_msgWarp: protocolState.canChangeState ', b_changeState]);
1312
1462
  if (!b_changeState)
1313
1463
  return false;
1314
1464
  const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec);
@@ -1318,14 +1468,14 @@ class TwoPhW {
1318
1468
  });
1319
1469
  }
1320
1470
  _handler_msgAckWarp(msg, json_msgAckWarp) {
1321
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: ', json_msgAckWarp]);
1471
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: ', json_msgAckWarp]);
1322
1472
  const json_msgWarp = json_msgAckWarp._cause;
1323
1473
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1324
1474
  const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
1325
1475
  dt: Date.now(),
1326
1476
  data: { msg, json_msg: json_msgAckWarp }
1327
1477
  }));
1328
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: protocolState.canChangeState ', b_changeState]);
1478
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: protocolState.canChangeState ', b_changeState]);
1329
1479
  if (!b_changeState)
1330
1480
  return false;
1331
1481
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
@@ -1333,14 +1483,14 @@ class TwoPhW {
1333
1483
  return this.config._callback_msgAckWarp(msg, json_msgAckWarp);
1334
1484
  }
1335
1485
  register_msgEngage(msg, json_msgEngage) {
1336
- log_(l_.SENDER, () => ['register_msgEngage: ', json_msgEngage]);
1486
+ logr_.log(l_.SENDER, () => ['register_msgEngage: ', json_msgEngage]);
1337
1487
  const json_msgWarp = json_msgEngage._cause;
1338
1488
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1339
1489
  const b_changeState = protocolState.canChangeState(new StateEngage(null, {
1340
1490
  dt: Date.now(),
1341
1491
  data: { msg, json_msg: json_msgEngage }
1342
1492
  }));
1343
- log_(l_.HANDLERS | l_.SENDER, () => ['register_msgEngage: protocolState.canChangeState ', b_changeState]);
1493
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_msgEngage: protocolState.canChangeState ', b_changeState]);
1344
1494
  if (!b_changeState)
1345
1495
  return false;
1346
1496
  const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, json_msgEngage.engage.rtt_msec);
@@ -1350,14 +1500,14 @@ class TwoPhW {
1350
1500
  });
1351
1501
  }
1352
1502
  _handler_msgAckEngage(msg, json_msgAckEngage) {
1353
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage: ', json_msgAckEngage]);
1503
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage: ', json_msgAckEngage]);
1354
1504
  const json_msgWarp = json_msgAckEngage._cause._cause;
1355
1505
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1356
1506
  const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
1357
1507
  dt: Date.now(),
1358
1508
  data: { msg, json_msg: json_msgAckEngage }
1359
1509
  }));
1360
- log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage_: protocolState.canChangeState ', b_changeState]);
1510
+ logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage_: protocolState.canChangeState ', b_changeState]);
1361
1511
  if (!b_changeState)
1362
1512
  return false;
1363
1513
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
@@ -1367,27 +1517,27 @@ class TwoPhW {
1367
1517
  //-------------------------------------------------------------------------------------------------
1368
1518
  // receiver Destination (dst)
1369
1519
  _handler_msgWarp(msg, json_msgWarp) {
1370
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: ', json_msgWarp]);
1520
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: ', json_msgWarp]);
1371
1521
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1372
1522
  const b_changeState = protocolState.canChangeState(new StateWarp(null, {
1373
1523
  dt: Date.now(),
1374
1524
  data: { msg, json_msg: json_msgWarp }
1375
1525
  }));
1376
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: protocolState.canChangeState: ', b_changeState]);
1526
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: protocolState.canChangeState: ', b_changeState]);
1377
1527
  if (!b_changeState)
1378
1528
  return false;
1379
1529
  this.eventLog._addEvent(msg, json_msgWarp);
1380
1530
  return this.config._callback_msgWarp(msg, json_msgWarp);
1381
1531
  }
1382
1532
  register_msgAckWarp(msg, json_msgAckWarp) {
1383
- log_(l_.RECVER, () => ['register_msgAckWarp: ', json_msgAckWarp]);
1533
+ logr_.log(l_.RECVER, () => ['register_msgAckWarp: ', json_msgAckWarp]);
1384
1534
  const json_msgWarp = json_msgAckWarp._cause;
1385
1535
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1386
1536
  const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
1387
1537
  dt: Date.now(),
1388
1538
  data: { msg, json_msg: json_msgAckWarp }
1389
1539
  }));
1390
- log_(l_.HANDLERS | l_.RECVER, () => ['register_msgAckWarp: protocolState.canChangeState: ', b_changeState]);
1540
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_msgAckWarp: protocolState.canChangeState: ', b_changeState]);
1391
1541
  if (!b_changeState)
1392
1542
  return false;
1393
1543
  const elapsed_ms = Date.now() - Date.parse(json_msgAckWarp.dt);
@@ -1397,14 +1547,14 @@ class TwoPhW {
1397
1547
  });
1398
1548
  }
1399
1549
  _handler_msgEngage(msg, json_msgEngage) {
1400
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: ', json_msgEngage]);
1550
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: ', json_msgEngage]);
1401
1551
  const json_msgWarp = json_msgEngage._cause;
1402
1552
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1403
1553
  const b_changeState = protocolState.canChangeState(new StateEngage(null, {
1404
1554
  dt: Date.now(),
1405
1555
  data: { msg, json_msg: json_msgEngage }
1406
1556
  }));
1407
- log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: protocolState.canChangeState: ', b_changeState]);
1557
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: protocolState.canChangeState: ', b_changeState]);
1408
1558
  if (!b_changeState)
1409
1559
  return false;
1410
1560
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
@@ -1412,21 +1562,21 @@ class TwoPhW {
1412
1562
  return this.config._callback_msgEngage(msg, json_msgEngage);
1413
1563
  }
1414
1564
  register_msgAckEngage(msg, json_msgAckEngage) {
1415
- log_(l_.RECVER, () => ['register_msgAckEngage: ', json_msgAckEngage]);
1565
+ logr_.log(l_.RECVER, () => ['register_msgAckEngage: ', json_msgAckEngage]);
1416
1566
  const json_msgWarp = json_msgAckEngage._cause._cause;
1417
1567
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1418
1568
  const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
1419
1569
  dt: Date.now(),
1420
1570
  data: { msg, json_msg: json_msgAckEngage }
1421
1571
  }));
1422
- log_(l_.HANDLERS | l_.RECVER, () => ['register_msgAckEngage: protocolState.canChangeState: ', b_changeState]);
1572
+ logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_msgAckEngage: protocolState.canChangeState: ', b_changeState]);
1423
1573
  if (!b_changeState)
1424
1574
  return false;
1425
1575
  this.eventLog._addEvent(msg, json_msgAckEngage);
1426
1576
  }
1427
1577
  //-------------------------------------------------------------------------------------------------
1428
1578
  handler_json_msgAck(msg, json_msgAck) {
1429
- log_(l_.HANDLERS, () => ['handler_json_msgAck: ', json_msgAck]);
1579
+ logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgAck: ', json_msgAck]);
1430
1580
  if (JSON_MsgAckWarp.validate(json_msgAck) && this._handler_msgAckWarp(msg, json_msgAck))
1431
1581
  return true;
1432
1582
  if (JSON_MsgAckEngage.validate(json_msgAck) && this._handler_msgAckEngage(msg, json_msgAck))
@@ -1434,9 +1584,9 @@ class TwoPhW {
1434
1584
  return false;
1435
1585
  }
1436
1586
  handler_json_msgEffect(msg, json_msgEffect) {
1437
- log_(l_.HANDLERS, () => ['handler_json_msgEffect: ', json_msgEffect]);
1438
- if (jsonMsg_cjsExports.JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect))
1439
- return true;
1587
+ logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgEffect: ', json_msgEffect]);
1588
+ // if (JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect) )
1589
+ // return true;
1440
1590
  if (JSON_MsgEngage.validate(json_msgEffect) && this._handler_msgEngage(msg, json_msgEffect))
1441
1591
  return true;
1442
1592
  // if (JSON_MsgOptions.validate(json_msg) && this.handler_msgOptions_(this._config, msg, json_msg))
@@ -1444,7 +1594,7 @@ class TwoPhW {
1444
1594
  return false;
1445
1595
  }
1446
1596
  handler_json_msg(msg, json_msg) {
1447
- log_(l_.HANDLERS, () => ['handler_json_msg: ', json_msg]);
1597
+ logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msg: ', json_msg]);
1448
1598
  if (JSON_MsgWarp.validate(json_msg) && this._handler_msgWarp(msg, json_msg))
1449
1599
  return true;
1450
1600
  // https://attacomsian.com/blog/javascript-iterate-objects
@@ -1457,19 +1607,14 @@ class TwoPhW {
1457
1607
  // });
1458
1608
  return false;
1459
1609
  }
1460
- handler_json(msg, json) {
1461
- log_(l_.HANDLERS, () => ['handler_json: ', json]);
1462
- if (jsonMsg_cjsExports.JSON_MsgEffect.validate(json) && this.handler_json_msgEffect(msg, json))
1463
- return true;
1464
- if (jsonMsg_cjsExports.JSON_Msg.validate(json) && this.handler_json_msg(msg, json))
1465
- return true;
1466
- return false;
1467
- }
1468
1610
  }
1469
1611
 
1470
1612
  exports.EventLog = EventLog;
1613
+ exports.JSON_Msg = jsonMsg_cjsExports.JSON_Msg;
1614
+ exports.JSON_MsgAck = jsonMsg_cjsExports.JSON_MsgAck;
1471
1615
  exports.JSON_MsgAckEngage = JSON_MsgAckEngage;
1472
1616
  exports.JSON_MsgAckWarp = JSON_MsgAckWarp;
1617
+ exports.JSON_MsgEffect = jsonMsg_cjsExports.JSON_MsgEffect;
1473
1618
  exports.JSON_MsgEngage = JSON_MsgEngage;
1474
1619
  exports.JSON_MsgOptions = JSON_MsgOptions;
1475
1620
  exports.JSON_MsgWarp = JSON_MsgWarp;
@@ -1480,5 +1625,5 @@ exports.StateINVALID = StateINVALID;
1480
1625
  exports.StateInitialState = StateInitialState;
1481
1626
  exports.StateWarp = StateWarp;
1482
1627
  exports.TwoPhW = TwoPhW;
1483
- exports.l = l_;
1628
+ exports.logr = logr_;
1484
1629
  exports.t_ttl_rtt = time_ttl_rtt_;