@rootintf/protocol-subverseinfo 2.0.1-api.4 → 2.1.1-api.5

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.
@@ -87,8 +87,8 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
87
87
  if (valid0) {
88
88
  if (data.subverse_info !== undefined) {
89
89
  const _errs9 = errors;
90
- if ("4" !== data.subverse_info) {
91
- validate19.errors = [{ instancePath: instancePath + "/subverse_info", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "4" }, message: "must be equal to constant" }];
90
+ if ("5" !== data.subverse_info) {
91
+ validate19.errors = [{ instancePath: instancePath + "/subverse_info", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "5" }, message: "must be equal to constant" }];
92
92
  return false;
93
93
  }
94
94
  var valid0 = _errs9 === errors;
@@ -110,7 +110,7 @@ function validate21(data, { instancePath = "", parentData, parentDataProperty, r
110
110
  evaluated0.props = undefined;
111
111
  } if (evaluated0.dynamicItems) {
112
112
  evaluated0.items = undefined;
113
- } {
113
+ } const _errs2 = errors; if (errors === _errs2) {
114
114
  if (data && typeof data == "object" && !Array.isArray(data)) {
115
115
  let missing0;
116
116
  if (((data.uri === undefined) && (missing0 = "uri")) || ((data.name === undefined) && (missing0 = "name"))) {
@@ -148,7 +148,7 @@ function validate21(data, { instancePath = "", parentData, parentDataProperty, r
148
148
  validate21.errors = [{ instancePath, schemaPath: "definitions#/definitions/unique-id/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
149
149
  return false;
150
150
  }
151
- } {
151
+ } if (errors === 0) {
152
152
  if (data && typeof data == "object" && !Array.isArray(data)) {
153
153
  if (data.favicon !== undefined) {
154
154
  const _errs8 = errors;
@@ -165,25 +165,99 @@ function validate21(data, { instancePath = "", parentData, parentDataProperty, r
165
165
  if (data.hyperport !== undefined) {
166
166
  let data3 = data.hyperport;
167
167
  const _errs10 = errors;
168
- {
168
+ const _errs12 = errors;
169
+ let valid5 = false;
170
+ let passing0 = null;
171
+ const _errs13 = errors;
172
+ if (typeof data3 !== "string") {
173
+ const err0 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" };
174
+ if (vErrors === null) {
175
+ vErrors = [err0];
176
+ }
177
+ else {
178
+ vErrors.push(err0);
179
+ }
180
+ errors++;
181
+ }
182
+ var _valid0 = _errs13 === errors;
183
+ if (_valid0) {
184
+ valid5 = true;
185
+ passing0 = 0;
186
+ }
187
+ const _errs15 = errors;
188
+ if (errors === _errs15) {
169
189
  if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
170
190
  let missing1;
171
191
  if (((data3.uri === undefined) && (missing1 = "uri")) || ((data3.port === undefined) && (missing1 = "port"))) {
172
- validate21.errors = [{ instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
173
- return false;
192
+ const err1 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf/1/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" };
193
+ if (vErrors === null) {
194
+ vErrors = [err1];
195
+ }
196
+ else {
197
+ vErrors.push(err1);
198
+ }
199
+ errors++;
174
200
  }
175
201
  else {
176
202
  if (data3.uri !== undefined) {
177
203
  if (typeof data3.uri !== "string") {
178
- validate21.errors = [{ instancePath: instancePath + "/hyperport/uri", schemaPath: "definitions#/definitions/hyperport/properties/uri/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
179
- return false;
204
+ const err2 = { instancePath: instancePath + "/hyperport/uri", schemaPath: "definitions#/definitions/hyperport/oneOf/1/properties/uri/type", keyword: "type", params: { type: "string" }, message: "must be string" };
205
+ if (vErrors === null) {
206
+ vErrors = [err2];
207
+ }
208
+ else {
209
+ vErrors.push(err2);
210
+ }
211
+ errors++;
180
212
  }
181
213
  }
182
214
  }
183
215
  }
184
216
  else {
185
- validate21.errors = [{ instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
186
- return false;
217
+ const err3 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
218
+ if (vErrors === null) {
219
+ vErrors = [err3];
220
+ }
221
+ else {
222
+ vErrors.push(err3);
223
+ }
224
+ errors++;
225
+ }
226
+ }
227
+ var _valid0 = _errs15 === errors;
228
+ if (_valid0 && valid5) {
229
+ valid5 = false;
230
+ passing0 = [passing0, 1];
231
+ }
232
+ else {
233
+ if (_valid0) {
234
+ valid5 = true;
235
+ passing0 = 1;
236
+ var props0 = {};
237
+ props0.uri = true;
238
+ }
239
+ }
240
+ if (!valid5) {
241
+ const err4 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf", keyword: "oneOf", params: { passingSchemas: passing0 }, message: "must match exactly one schema in oneOf" };
242
+ if (vErrors === null) {
243
+ vErrors = [err4];
244
+ }
245
+ else {
246
+ vErrors.push(err4);
247
+ }
248
+ errors++;
249
+ validate21.errors = vErrors;
250
+ return false;
251
+ }
252
+ else {
253
+ errors = _errs12;
254
+ if (vErrors !== null) {
255
+ if (_errs12) {
256
+ vErrors.length = _errs12;
257
+ }
258
+ else {
259
+ vErrors = null;
260
+ }
187
261
  }
188
262
  }
189
263
  var valid3 = _errs10 === errors;
@@ -194,12 +268,12 @@ function validate21(data, { instancePath = "", parentData, parentDataProperty, r
194
268
  if (valid3) {
195
269
  if (data.info !== undefined) {
196
270
  let data5 = data.info;
197
- const _errs15 = errors;
271
+ const _errs19 = errors;
198
272
  if (!(data5 && typeof data5 == "object" && !Array.isArray(data5))) {
199
273
  validate21.errors = [{ instancePath: instancePath + "/info", schemaPath: "definitions#/definitions/info/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
200
274
  return false;
201
275
  }
202
- var valid3 = _errs15 === errors;
276
+ var valid3 = _errs19 === errors;
203
277
  }
204
278
  else {
205
279
  var valid3 = true;
@@ -217,7 +291,7 @@ function validate24(data, { instancePath = "", parentData, parentDataProperty, r
217
291
  evaluated0.props = undefined;
218
292
  } if (evaluated0.dynamicItems) {
219
293
  evaluated0.items = undefined;
220
- } {
294
+ } const _errs2 = errors; if (errors === _errs2) {
221
295
  if (data && typeof data == "object" && !Array.isArray(data)) {
222
296
  let missing0;
223
297
  if (((data.uri === undefined) && (missing0 = "uri")) || ((data.name === undefined) && (missing0 = "name"))) {
@@ -255,7 +329,7 @@ function validate24(data, { instancePath = "", parentData, parentDataProperty, r
255
329
  validate24.errors = [{ instancePath, schemaPath: "definitions#/definitions/unique-id/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
256
330
  return false;
257
331
  }
258
- } {
332
+ } if (errors === 0) {
259
333
  if (data && typeof data == "object" && !Array.isArray(data)) {
260
334
  if (data.favicon !== undefined) {
261
335
  const _errs8 = errors;
@@ -272,25 +346,99 @@ function validate24(data, { instancePath = "", parentData, parentDataProperty, r
272
346
  if (data.hyperport !== undefined) {
273
347
  let data3 = data.hyperport;
274
348
  const _errs10 = errors;
275
- {
349
+ const _errs12 = errors;
350
+ let valid5 = false;
351
+ let passing0 = null;
352
+ const _errs13 = errors;
353
+ if (typeof data3 !== "string") {
354
+ const err0 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" };
355
+ if (vErrors === null) {
356
+ vErrors = [err0];
357
+ }
358
+ else {
359
+ vErrors.push(err0);
360
+ }
361
+ errors++;
362
+ }
363
+ var _valid0 = _errs13 === errors;
364
+ if (_valid0) {
365
+ valid5 = true;
366
+ passing0 = 0;
367
+ }
368
+ const _errs15 = errors;
369
+ if (errors === _errs15) {
276
370
  if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
277
371
  let missing1;
278
372
  if (((data3.uri === undefined) && (missing1 = "uri")) || ((data3.port === undefined) && (missing1 = "port"))) {
279
- validate24.errors = [{ instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
280
- return false;
373
+ const err1 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf/1/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" };
374
+ if (vErrors === null) {
375
+ vErrors = [err1];
376
+ }
377
+ else {
378
+ vErrors.push(err1);
379
+ }
380
+ errors++;
281
381
  }
282
382
  else {
283
383
  if (data3.uri !== undefined) {
284
384
  if (typeof data3.uri !== "string") {
285
- validate24.errors = [{ instancePath: instancePath + "/hyperport/uri", schemaPath: "definitions#/definitions/hyperport/properties/uri/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
286
- return false;
385
+ const err2 = { instancePath: instancePath + "/hyperport/uri", schemaPath: "definitions#/definitions/hyperport/oneOf/1/properties/uri/type", keyword: "type", params: { type: "string" }, message: "must be string" };
386
+ if (vErrors === null) {
387
+ vErrors = [err2];
388
+ }
389
+ else {
390
+ vErrors.push(err2);
391
+ }
392
+ errors++;
287
393
  }
288
394
  }
289
395
  }
290
396
  }
291
397
  else {
292
- validate24.errors = [{ instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
293
- return false;
398
+ const err3 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
399
+ if (vErrors === null) {
400
+ vErrors = [err3];
401
+ }
402
+ else {
403
+ vErrors.push(err3);
404
+ }
405
+ errors++;
406
+ }
407
+ }
408
+ var _valid0 = _errs15 === errors;
409
+ if (_valid0 && valid5) {
410
+ valid5 = false;
411
+ passing0 = [passing0, 1];
412
+ }
413
+ else {
414
+ if (_valid0) {
415
+ valid5 = true;
416
+ passing0 = 1;
417
+ var props0 = {};
418
+ props0.uri = true;
419
+ }
420
+ }
421
+ if (!valid5) {
422
+ const err4 = { instancePath: instancePath + "/hyperport", schemaPath: "definitions#/definitions/hyperport/oneOf", keyword: "oneOf", params: { passingSchemas: passing0 }, message: "must match exactly one schema in oneOf" };
423
+ if (vErrors === null) {
424
+ vErrors = [err4];
425
+ }
426
+ else {
427
+ vErrors.push(err4);
428
+ }
429
+ errors++;
430
+ validate24.errors = vErrors;
431
+ return false;
432
+ }
433
+ else {
434
+ errors = _errs12;
435
+ if (vErrors !== null) {
436
+ if (_errs12) {
437
+ vErrors.length = _errs12;
438
+ }
439
+ else {
440
+ vErrors = null;
441
+ }
294
442
  }
295
443
  }
296
444
  var valid3 = _errs10 === errors;
@@ -301,12 +449,12 @@ function validate24(data, { instancePath = "", parentData, parentDataProperty, r
301
449
  if (valid3) {
302
450
  if (data.info !== undefined) {
303
451
  let data5 = data.info;
304
- const _errs15 = errors;
452
+ const _errs19 = errors;
305
453
  if (!(data5 && typeof data5 == "object" && !Array.isArray(data5))) {
306
454
  validate24.errors = [{ instancePath: instancePath + "/info", schemaPath: "definitions#/definitions/info/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
307
455
  return false;
308
456
  }
309
- var valid3 = _errs15 === errors;
457
+ var valid3 = _errs19 === errors;
310
458
  }
311
459
  else {
312
460
  var valid3 = true;
@@ -705,8 +853,8 @@ function validate20(data, { instancePath = "", parentData, parentDataProperty, r
705
853
  if (valid0) {
706
854
  if (data.subverse_info !== undefined) {
707
855
  const _errs42 = errors;
708
- if ("4" !== data.subverse_info) {
709
- validate20.errors = [{ instancePath: instancePath + "/subverse_info", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "4" }, message: "must be equal to constant" }];
856
+ if ("5" !== data.subverse_info) {
857
+ validate20.errors = [{ instancePath: instancePath + "/subverse_info", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "5" }, message: "must be equal to constant" }];
710
858
  return false;
711
859
  }
712
860
  var valid0 = _errs42 === errors;
@@ -1102,8 +1250,8 @@ function validate27(data, { instancePath = "", parentData, parentDataProperty, r
1102
1250
  if (valid0) {
1103
1251
  if (data.subverse_info !== undefined) {
1104
1252
  const _errs44 = errors;
1105
- if ("4" !== data.subverse_info) {
1106
- validate27.errors = [{ instancePath: instancePath + "/subverse_info", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "4" }, message: "must be equal to constant" }];
1253
+ if ("5" !== data.subverse_info) {
1254
+ validate27.errors = [{ instancePath: instancePath + "/subverse_info", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "5" }, message: "must be equal to constant" }];
1107
1255
  return false;
1108
1256
  }
1109
1257
  var valid0 = _errs44 === errors;
@@ -1121,122 +1269,407 @@ function validate27(data, { instancePath = "", parentData, parentDataProperty, r
1121
1269
  } validate27.errors = vErrors; return errors === 0; }
1122
1270
  validate27.evaluated = { "props": { "expanse": true, "subverse_info": true }, "dynamicProps": false, "dynamicItems": false };
1123
1271
 
1272
+ // https://stackoverflow.com/questions/4602141/variable-name-as-a-string-in-javascript
1124
1273
  // console.log('OUT', __name({variableName}) );
1125
-
1126
-
1274
+ //-------------------------------------------------------------------------------------------------
1275
+ function l_length_(obj_labels) {
1276
+ if (!obj_labels || typeof obj_labels !== 'object')
1277
+ throw new Error('obj_labels must be an object');
1278
+ const obj_1label = Object.values(obj_labels);
1279
+ if (!obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
1280
+ throw new Error('All values must be finite numbers');
1281
+ const labels = Object.values(obj_labels);
1282
+ if (labels.length === 0)
1283
+ return 1; // Empty object case, start at 1
1284
+ const value_max = Math.max(...labels);
1285
+ if (value_max <= 0)
1286
+ return 1;
1287
+ const bit_highest = Math.floor(Math.log2(value_max));
1288
+ return 1 << (bit_highest + 1);
1289
+ }
1290
+ function l_array_(arr_labels, start = 1) {
1291
+ if (!Array.isArray(arr_labels))
1292
+ throw new Error('arr_labels must be an array');
1293
+ if (!Number.isSafeInteger(start) || start < 0)
1294
+ throw new Error('start must be a safe, non-negative integer');
1295
+ return Object.freeze(arr_labels.reduce((acc, key, index) => {
1296
+ acc[key] = start << index;
1297
+ return acc;
1298
+ }, {}));
1299
+ }
1300
+ function l_concat_(obj_labels, arg) {
1301
+ if (!obj_labels || typeof obj_labels !== 'object')
1302
+ throw new Error('obj_labels must be an object');
1303
+ const obj_1label = Object.values(obj_labels);
1304
+ if (!obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
1305
+ throw new Error('All values must be finite numbers');
1306
+ if (!arg || (typeof arg !== 'object' && !Array.isArray(arg)))
1307
+ throw new Error('arg must be an object or array');
1308
+ if (Array.isArray(arg)) {
1309
+ const len = l_length_(obj_labels);
1310
+ const arr_labels_new = l_array_(arg, len);
1311
+ return l_concat_(obj_labels, arr_labels_new);
1312
+ }
1313
+ const next_pos = l_length_(obj_labels);
1314
+ const arg_entries = Object.entries(arg);
1315
+ const result = Object.create(null);
1316
+ Object.entries(obj_labels).forEach(([k, v]) => {
1317
+ if (k !== '__proto__' && k !== 'constructor')
1318
+ result[k] = v;
1319
+ });
1320
+ let min_arg = Infinity;
1321
+ for (const [, value] of arg_entries) {
1322
+ if (typeof value !== 'number' || !Number.isFinite(value))
1323
+ continue; // Skip non-numeric
1324
+ if (value > 0 && value < min_arg)
1325
+ min_arg = value;
1326
+ }
1327
+ // Shift only if min_arg is less than next_pos
1328
+ const shift = min_arg === Infinity || min_arg >= next_pos
1329
+ ? 0
1330
+ : Math.floor(Math.log2(next_pos / min_arg));
1331
+ for (const [key, value] of arg_entries) {
1332
+ if (!(key in result)) {
1333
+ result[key] = value === 0 ? 0 : value << shift;
1334
+ }
1335
+ }
1336
+ return Object.freeze(result);
1337
+ }
1338
+ function l_merge_(obj_labels1, obj_labels2) {
1339
+ if (!obj_labels1 || typeof obj_labels1 !== 'object')
1340
+ throw new Error('obj_labels must be an object');
1341
+ const obj_1label1 = Object.values(obj_labels1);
1342
+ if (!obj_1label1.every(v => typeof v === 'number' && Number.isFinite(v)))
1343
+ throw new Error('All values must be finite numbers');
1344
+ if (!obj_labels2 || typeof obj_labels2 !== 'object')
1345
+ throw new Error('obj_labels must be an object');
1346
+ const obj_1label2 = Object.values(obj_labels2);
1347
+ if (!obj_1label2.every(v => typeof v === 'number' && Number.isFinite(v)))
1348
+ throw new Error('All values must be finite numbers');
1349
+ const result = Object.create(null);
1350
+ Object.entries(obj_labels1).forEach(([k, v]) => {
1351
+ if (k !== '__proto__' && k !== 'constructor')
1352
+ result[k] = v;
1353
+ });
1354
+ const set_values = new Set(Object.values(obj_labels1)); // Track all used bit values
1355
+ // Find the highest bit position to start shifting from if needed
1356
+ const value_highest = Math.max(0, ...Array.from(set_values));
1357
+ let next_shift = value_highest ? Math.floor(Math.log2(value_highest)) + 1 : 0;
1358
+ // Process second set
1359
+ for (const [key, value] of Object.entries(obj_labels2)) {
1360
+ if (key in result) {
1361
+ // Same key: Values must match
1362
+ if (result[key] !== value) {
1363
+ throw new Error(`Key '${key}' has conflicting values: ${result[key]} (obj_labels1) vs ${value} (obj_labels2)`);
1364
+ }
1365
+ // No action needed if values match, already in result
1366
+ }
1367
+ else {
1368
+ let maxIterations = 1000;
1369
+ // New key: Add if value is unique, otherwise shift
1370
+ let value_new = value;
1371
+ while (set_values.has(value_new) && maxIterations--) {
1372
+ value_new = 1 << next_shift++;
1373
+ }
1374
+ if (maxIterations <= 0)
1375
+ throw new Error('Too many collisions in l_merge_');
1376
+ result[key] = value_new;
1377
+ set_values.add(value_new);
1378
+ }
1379
+ }
1380
+ return Object.freeze(result);
1381
+ }
1127
1382
  function l_LL_(obj, x) {
1128
- if (! obj || typeof obj !== 'object')
1129
- throw new Error('obj must be an object');
1130
- if (! Number.isSafeInteger(x) || x < 0)
1131
- throw new Error('Shift value must be a safe, non-negative integer');
1132
-
1133
- const obj_new= {};
1134
- for (const [k,v] of Object.entries(obj)) {
1135
- if (typeof v !== 'number' || ! Number.isFinite(v))
1136
- continue; // Skip non-numeric
1137
- obj_new[k] = v<<x;
1138
- }
1139
- return Object.freeze(obj_new);
1383
+ if (!obj || typeof obj !== 'object')
1384
+ throw new Error('obj must be an object');
1385
+ if (!Number.isSafeInteger(x) || x < 0)
1386
+ throw new Error('Shift value must be a safe, non-negative integer');
1387
+ const obj_new = {};
1388
+ for (const [k, v] of Object.entries(obj)) {
1389
+ if (typeof v !== 'number' || !Number.isFinite(v))
1390
+ continue; // Skip non-numeric
1391
+ obj_new[k] = v << x;
1392
+ }
1393
+ return Object.freeze(obj_new);
1140
1394
  }
1141
-
1142
- //-------------------------------------------------------------------------------------------------
1143
-
1144
- function handler_default_( /* ... */ ) {
1145
- // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
1146
- var args = Array.prototype.slice.call(arguments);
1147
- console.log.apply(console, args);
1395
+ function l_RR_(obj, x) {
1396
+ if (!obj || typeof obj !== 'object')
1397
+ throw new Error('obj must be an object');
1398
+ if (!Number.isSafeInteger(x) || x < 0)
1399
+ throw new Error('Shift value must be a safe, non-negative integer');
1400
+ const obj_new = {};
1401
+ for (const [k, v] of Object.entries(obj)) {
1402
+ if (typeof v !== 'number' || !Number.isFinite(v))
1403
+ continue; // Skip non-numeric
1404
+ obj_new[k] = v >> x;
1405
+ }
1406
+ return Object.freeze(obj_new);
1148
1407
  }
1149
-
1150
1408
  //-------------------------------------------------------------------------------------------------
1151
-
1152
- function l_toBigInt_(obj_labels, obj, ignore= false) {
1153
- if (! obj_labels || typeof obj_labels !== 'object')
1154
- throw new Error('obj_labels must be an object');
1155
- if (! obj || typeof obj !== 'object')
1156
- throw new Error('obj must be an object');
1157
-
1158
- let bigInt = BigInt(0);
1159
- for (const [k,v] of Object.entries(obj)) {
1160
- if ( ( ignore || v ) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
1161
- bigInt|= BigInt( obj_labels[k] );
1162
- // console.log('0b'+ bigInt.toString(2) );
1163
- }
1164
- return bigInt;
1409
+ function handler_default_( /* ... */) {
1410
+ // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
1411
+ var args = Array.prototype.slice.call(arguments);
1412
+ console.log.apply(console, args);
1413
+ }
1414
+ function l_toBigInt_(obj_labels, obj, ignore = false) {
1415
+ if (!obj_labels || typeof obj_labels !== 'object')
1416
+ throw new Error('obj_labels must be an object');
1417
+ if (!obj || typeof obj !== 'object')
1418
+ throw new Error('obj must be an object');
1419
+ let bigint_l = BigInt(0);
1420
+ for (const [k, v] of Object.entries(obj)) {
1421
+ if ((ignore || v) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
1422
+ bigint_l |= BigInt(obj_labels[k]);
1423
+ // console.log('0b'+ bigInt.toString(2) );
1424
+ }
1425
+ return bigint_l;
1426
+ }
1427
+ function lRef(initial) {
1428
+ if (arguments.length === 0 || initial === undefined) {
1429
+ return undefined;
1430
+ }
1431
+ let value = initial;
1432
+ return {
1433
+ get: () => value,
1434
+ set: (newVal) => { value = newVal; }
1435
+ };
1436
+ }
1437
+ /*
1438
+ const l_ = {
1439
+ get VALIDATION() { return logr_.lref.get().VALIDATION; }
1165
1440
  }
1166
1441
 
1167
- // console.log(l_toBigInt_({},{}))
1168
-
1169
- const LOGR = (function () {
1170
- let _instance; // Private variable to hold the single instance
1442
+ function createBitFlags(ref) {
1443
+ // Create a proxy so that any property access computes the current bit
1444
+ return new Proxy({}, {
1445
+ get(target, prop, receiver) {
1446
+ const positions = ref.get(); // get current { VALIDATION: n, ... }
1447
+ const position = positions[prop]; // e.g., positions['VALIDATION']
1171
1448
 
1172
- function _create_instance() {
1173
- // Private state (replacing constructor properties)
1174
- let _handler_log = handler_default_;
1175
- let _obj_labels = undefined;
1176
- let _Bint_toggled = BigInt(0);
1449
+ if (position === undefined) {
1450
+ // Optional: warn or return 0 for unknown keys
1451
+ console.warn(`Unknown bitflag key: ${String(prop)}`);
1452
+ return 0;
1453
+ }
1177
1454
 
1178
- function _log_fxn(nr_logged, argsFn /* args */) {
1179
- if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
1180
- return false;
1455
+ return 0b1 << position; // or 1 << position
1456
+ },
1181
1457
 
1182
- const args = argsFn();
1183
- _handler_log.apply(this, args);
1184
- // _handler_log.apply(this, args);
1185
- return true;
1186
- }
1458
+ // Optional: make Object.keys(l_) show the actual keys
1459
+ ownKeys(target) {
1460
+ return Object.keys(ref.get());
1461
+ },
1187
1462
 
1188
- return {
1189
- set handler(fx) {
1190
- _handler_log = fx;
1191
- },
1192
- get handler() {
1193
- return _handler_log;
1194
- },
1463
+ getOwnPropertyDescriptor(target, prop) {
1464
+ return {
1465
+ enumerable: true,
1466
+ configurable: true,
1467
+ };
1468
+ }
1469
+ });
1470
+ }
1195
1471
 
1196
- get labels() { return _obj_labels; },
1197
- set labels(obj) {
1198
- _obj_labels = obj;
1199
- _Bint_toggled = BigInt(0);
1200
- },
1472
+ type BitPositions = Record<string, number>;
1201
1473
 
1202
- // put= function(label, abbrv) {
1203
- // let name= __name(label);
1204
- // _labels[name]= label[name];
1205
- // console.log(_labels);
1206
- // }
1474
+ function createBitFlags<T extends BitPositions>(ref: { get: () => T }) {
1475
+ return new Proxy({} as { [K in keyof T]: number }, {
1476
+ get(target, prop: string | symbol) {
1477
+ if (typeof prop !== 'string') return undefined;
1478
+ const positions = ref.get();
1479
+ const position = positions[prop as keyof T];
1480
+ if (position === undefined) return 0;
1481
+ return 1 << position;
1482
+ },
1483
+ ownKeys() {
1484
+ return Object.keys(ref.get());
1485
+ },
1486
+ getOwnPropertyDescriptor() {
1487
+ return { enumerable: true, configurable: true };
1488
+ }
1489
+ });
1490
+ }
1491
+ */
1492
+ function create_Referenced_l_(ref) {
1493
+ return new Proxy({}, {
1494
+ get(target, prop) {
1495
+ if (typeof prop !== 'string')
1496
+ return undefined;
1497
+ // if (prop === 'get') {
1498
+ // return () => {
1499
+ // const positions = ref.get();
1500
+ // const result: Partial<Record<keyof T, number>> = {};
1501
+ // for (const key in positions) {
1502
+ // result[key as keyof T] = positions[key];
1503
+ // }
1504
+ // return result as Record<keyof T, number>;
1505
+ // };
1506
+ // }
1507
+ if (prop === 'get')
1508
+ return () => ref.get();
1509
+ const positions = ref.get();
1510
+ const value = positions[prop];
1511
+ if (value === undefined)
1512
+ return 0;
1513
+ return value;
1514
+ },
1515
+ ownKeys() {
1516
+ return Object.keys(ref.get());
1517
+ },
1518
+ getOwnPropertyDescriptor() {
1519
+ return { enumerable: true, configurable: true };
1520
+ }
1521
+ });
1522
+ }
1523
+ const LOGR = (function () {
1524
+ let _instance; // Private variable to hold the single instance
1525
+ // Module-level state would work - but only when the module is loaded once.
1526
+ // Your bundler is currently bundling @knev/bitlogr into your distribution file,
1527
+ // creating a second copy. The Global Symbol approach would work around this,
1528
+ // but it's treating the symptom, not the cause.
1529
+ const GLOBAL_KEY = Symbol.for('@knev/bitlogr/LOGR');
1530
+ // The real issue is your build configuration bundling dependencies that should remain external.
1531
+ // rollup.config.mjs: external: ['@knev/bitlogr', 'uuid'], // Don't bundle these
1532
+ function _create_instance() {
1533
+ const _id = Math.random();
1534
+ if (globalThis.LOGR_ENABLED ?? true)
1535
+ console.log('creating LOGR instance:', _id);
1536
+ // Private state (replacing constructor properties)
1537
+ let _Bint_toggled = BigInt(0);
1538
+ let _handler_log = handler_default_;
1539
+ function _log_fxn(nr_logged, argsFn /* args */) {
1540
+ // console.log('_log_fxn: ', BigInt(nr_logged), _Bint_toggled, (BigInt(nr_logged) & _Bint_toggled));
1541
+ if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
1542
+ return;
1543
+ const args = argsFn();
1544
+ _handler_log.apply(this, args);
1545
+ }
1546
+ return {
1547
+ _id, // for testing
1548
+ get handler() { return _handler_log; },
1549
+ set handler(fx) {
1550
+ _handler_log = fx;
1551
+ },
1552
+ get toggled() { return _Bint_toggled; },
1553
+ // toggle(obj_labels, obj_toggled) {
1554
+ // _Bint_toggled= l_toBigInt_(obj_labels, obj_toggled);
1555
+ // },
1556
+ toggle(labels, obj_toggled) {
1557
+ const obj_labels = typeof labels?.get === 'function'
1558
+ ? labels.get()
1559
+ : labels;
1560
+ // console.log('obj_labels', obj_labels)
1561
+ _Bint_toggled = l_toBigInt_(obj_labels, obj_toggled);
1562
+ },
1563
+ // Core internal log function (exposed only to created loggers)
1564
+ _log_fxn,
1565
+ create(options = {}) {
1566
+ // This constant will be replaced at build time
1567
+ if (!(globalThis.LOGR_ENABLED ?? true)) {
1568
+ return {
1569
+ _obj_labels: undefined, // optional: keep shape compatible if needed
1570
+ log: () => { }, // does nothing
1571
+ raw: () => { }, // does nothing
1572
+ };
1573
+ }
1574
+ const _logger = {
1575
+ // _lref_labels: (options.arr_labels === undefined) ? undefined : lRef( l_array_(options.arr_labels) ),
1576
+ _lref_labels: (options.labels === undefined)
1577
+ ? undefined
1578
+ : lRef(options.labels),
1579
+ get l() {
1580
+ // Always create a fresh proxy pointing to the current labels
1581
+ return create_Referenced_l_({
1582
+ get: () => this._lref_labels?.get() || {}
1583
+ });
1584
+ },
1585
+ get lref() { return this._lref_labels; },
1586
+ set lref(lref_labels_new) {
1587
+ this._lref_labels = lref_labels_new;
1588
+ },
1589
+ log(nr_logged, argsFn) {
1590
+ // This constant will be replaced at build time
1591
+ if (!(globalThis.LOGR_ENABLED ?? true))
1592
+ return;
1593
+ _log_fxn.call(this, nr_logged, argsFn);
1594
+ },
1595
+ // Optional shorthand for common cases
1596
+ raw(...args) {
1597
+ _handler_log.apply(this, args);
1598
+ }
1599
+ };
1600
+ return _logger;
1601
+ },
1602
+ };
1603
+ }
1604
+ // Public interface
1605
+ return {
1606
+ get_instance() {
1607
+ if (!(globalThis.LOGR_USE_GLOBAL_KEY ?? true)) {
1608
+ if (!_instance)
1609
+ _instance = _create_instance(); // Lazy initialization
1610
+ return _instance;
1611
+ }
1612
+ if (!globalThis[GLOBAL_KEY])
1613
+ globalThis[GLOBAL_KEY] = _create_instance();
1614
+ return globalThis[GLOBAL_KEY];
1615
+ },
1616
+ // For testing only - reset the singleton
1617
+ _reset_for_testing() {
1618
+ delete globalThis[GLOBAL_KEY];
1619
+ }
1620
+ };
1621
+ })();
1207
1622
 
1208
- get toggled() { return _Bint_toggled; },
1209
- set toggled(obj_toggled) {
1210
- _Bint_toggled= l_toBigInt_(_obj_labels, obj_toggled);
1211
- },
1623
+ var logr_es = /*#__PURE__*/Object.freeze({
1624
+ __proto__: null,
1625
+ LOGR: LOGR,
1626
+ _create_Referenced_l: create_Referenced_l_,
1627
+ lRef: lRef,
1628
+ l_LL: l_LL_,
1629
+ l_RR: l_RR_,
1630
+ l_array: l_array_,
1631
+ l_concat: l_concat_,
1632
+ l_length: l_length_,
1633
+ l_merge: l_merge_
1634
+ });
1212
1635
 
1213
- log(nr_logged, argsFn) {
1214
-
1215
- return _log_fxn.call(this, nr_logged, argsFn); // Pass the thunk
1216
- }
1636
+ function getAugmentedNamespace(n) {
1637
+ if (n.__esModule) return n;
1638
+ var f = n.default;
1639
+ if (typeof f == "function") {
1640
+ var a = function a () {
1641
+ if (this instanceof a) {
1642
+ return Reflect.construct(f, arguments, this.constructor);
1643
+ }
1644
+ return f.apply(this, arguments);
1217
1645
  };
1218
- }
1219
-
1220
- // Public interface
1221
- return {
1222
- get_instance() {
1223
- if (!_instance) {
1224
- _instance = _create_instance(); // Lazy initialization
1646
+ a.prototype = f.prototype;
1647
+ } else a = {};
1648
+ Object.defineProperty(a, '__esModule', {value: true});
1649
+ Object.keys(n).forEach(function (k) {
1650
+ var d = Object.getOwnPropertyDescriptor(n, k);
1651
+ Object.defineProperty(a, k, d.get ? d : {
1652
+ enumerable: true,
1653
+ get: function () {
1654
+ return n[k];
1225
1655
  }
1226
- return _instance;
1227
- }
1228
- };
1229
-
1230
- })();
1656
+ });
1657
+ });
1658
+ return a;
1659
+ }
1231
1660
 
1232
1661
  var jsonMsg_cjs = {};
1233
1662
 
1663
+ var require$$0 = /*@__PURE__*/getAugmentedNamespace(logr_es);
1664
+
1234
1665
  var hasRequiredJsonMsg_cjs;
1235
1666
 
1236
1667
  function requireJsonMsg_cjs () {
1237
1668
  if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
1238
1669
  hasRequiredJsonMsg_cjs = 1;
1239
1670
 
1671
+ var bitlogr = require$$0;
1672
+
1240
1673
  const schema_Msg = validate18;
1241
1674
  function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
1242
1675
  evaluated0.props = undefined;
@@ -1406,105 +1839,12 @@ function requireJsonMsg_cjs () {
1406
1839
  return _v4(options);
1407
1840
  }
1408
1841
 
1409
- // console.log('OUT', __name({variableName}) );
1410
-
1411
-
1412
1842
  //-------------------------------------------------------------------------------------------------
1413
-
1414
- function handler_default_( /* ... */ ) {
1415
- // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
1416
- var args = Array.prototype.slice.call(arguments);
1417
- console.log.apply(console, args);
1418
- }
1419
-
1843
+ const LOGR_ = bitlogr.LOGR.get_instance();
1844
+ const logr_ = LOGR_.create({ labels: bitlogr.l_array(['VALIDATION']) });
1845
+ const l_ = logr_.l;
1846
+ // console.log('File location:', import.meta.url, '[Implementation]');
1420
1847
  //-------------------------------------------------------------------------------------------------
1421
-
1422
- function l_toBigInt_(obj_labels, obj, ignore= false) {
1423
- if (! obj_labels || typeof obj_labels !== 'object')
1424
- throw new Error('obj_labels must be an object');
1425
- if (! obj || typeof obj !== 'object')
1426
- throw new Error('obj must be an object');
1427
-
1428
- let bigInt = BigInt(0);
1429
- for (const [k,v] of Object.entries(obj)) {
1430
- if ( ( ignore || v ) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
1431
- bigInt|= BigInt( obj_labels[k] );
1432
- // console.log('0b'+ bigInt.toString(2) );
1433
- }
1434
- return bigInt;
1435
- }
1436
-
1437
- // console.log(l_toBigInt_({},{}))
1438
-
1439
- const LOGR = (function () {
1440
- let _instance; // Private variable to hold the single instance
1441
-
1442
- function _create_instance() {
1443
- // Private state (replacing constructor properties)
1444
- let _handler_log = handler_default_;
1445
- let _obj_labels = undefined;
1446
- let _Bint_toggled = BigInt(0);
1447
-
1448
- function _log_fxn(nr_logged, argsFn /* args */) {
1449
- if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
1450
- return false;
1451
-
1452
- const args = argsFn();
1453
- _handler_log.apply(this, args);
1454
- // _handler_log.apply(this, args);
1455
- return true;
1456
- }
1457
-
1458
- return {
1459
- set handler(fx) {
1460
- _handler_log = fx;
1461
- },
1462
- get handler() {
1463
- return _handler_log;
1464
- },
1465
-
1466
- get labels() { return _obj_labels; },
1467
- set labels(obj) {
1468
- _obj_labels = obj;
1469
- _Bint_toggled = BigInt(0);
1470
- },
1471
-
1472
- // put= function(label, abbrv) {
1473
- // let name= __name(label);
1474
- // _labels[name]= label[name];
1475
- // console.log(_labels);
1476
- // }
1477
-
1478
- get toggled() { return _Bint_toggled; },
1479
- set toggled(obj_toggled) {
1480
- _Bint_toggled= l_toBigInt_(_obj_labels, obj_toggled);
1481
- },
1482
-
1483
- log(nr_logged, argsFn) {
1484
-
1485
- return _log_fxn.call(this, nr_logged, argsFn); // Pass the thunk
1486
- }
1487
- };
1488
- }
1489
-
1490
- // Public interface
1491
- return {
1492
- get_instance() {
1493
- if (!_instance) {
1494
- _instance = _create_instance(); // Lazy initialization
1495
- }
1496
- return _instance;
1497
- }
1498
- };
1499
-
1500
- })();
1501
-
1502
- let LOGR_ = LOGR.get_instance();
1503
- const log_ = LOGR_.log;
1504
- const l_ = {
1505
- VALIDATION: 0b1 << 0,
1506
- };
1507
- LOGR_.labels = l_;
1508
1848
  // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
1509
1849
  // "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
1510
1850
  var JSON_Msg = (function () {
@@ -1519,7 +1859,7 @@ function requireJsonMsg_cjs () {
1519
1859
  validate: function (json) {
1520
1860
  const b_valid = schema_Msg(json);
1521
1861
  if (!b_valid)
1522
- log_(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
1862
+ logr_.log(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
1523
1863
  return b_valid;
1524
1864
  },
1525
1865
  // TODO: requires a separate ajv module require, and JTD specific schema
@@ -1541,7 +1881,7 @@ function requireJsonMsg_cjs () {
1541
1881
  return false;
1542
1882
  const b_valid = schema_MsgEffect(json);
1543
1883
  if (!b_valid)
1544
- log_(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
1884
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
1545
1885
  return b_valid;
1546
1886
  }
1547
1887
  };
@@ -1568,7 +1908,7 @@ function requireJsonMsg_cjs () {
1568
1908
  return false;
1569
1909
  const b_valid = schema_MsgAckEffect(json);
1570
1910
  if (!b_valid)
1571
- log_(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
1911
+ logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
1572
1912
  return b_valid;
1573
1913
  }
1574
1914
  };
@@ -1577,24 +1917,18 @@ function requireJsonMsg_cjs () {
1577
1917
  jsonMsg_cjs.JSON_Msg = JSON_Msg;
1578
1918
  jsonMsg_cjs.JSON_MsgAck = JSON_MsgAck;
1579
1919
  jsonMsg_cjs.JSON_MsgEffect = JSON_MsgEffect;
1580
- jsonMsg_cjs.l = l_;
1920
+ jsonMsg_cjs.logr = logr_;
1581
1921
  return jsonMsg_cjs;
1582
1922
  }
1583
1923
 
1584
1924
  var jsonMsg_cjsExports = requireJsonMsg_cjs();
1585
1925
 
1586
- let LOGR_ = LOGR.get_instance();
1587
- const log_ = LOGR_.log;
1588
- Object.assign(jsonMsg_cjsExports.l, l_LL_(jsonMsg_cjsExports.l, 2)); // VALIDATION : 4
1589
- const l_ = {
1590
- VALIDATION: 0b1 << 2, //4
1591
- };
1592
- LOGR_.labels = l_;
1593
- LOGR_.toggled = {
1594
- // VALIDATION : true
1595
- };
1596
- const kstr_VERSION = "4";
1926
+ const kstr_VERSION = "5";
1597
1927
  // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
1928
+ //-------------------------------------------------------------------------------------------------
1929
+ LOGR.get_instance();
1930
+ const l_ = jsonMsg_cjsExports.logr.l;
1931
+ //-------------------------------------------------------------------------------------------------
1598
1932
  // const regex_IOI= new RegExp('\\bquery\\s*\\{\\s*IOI\\s*\\(\\s*pkg\\s*:\\s*"([^"]*)"\\s*\\)\\s*\\{.*heartbeat\\s*\\}\\s*\\}');
1599
1933
  var JSON_MsgSubverseInfo_query = (function () {
1600
1934
  return {
@@ -1607,7 +1941,7 @@ var JSON_MsgSubverseInfo_query = (function () {
1607
1941
  // if (! JSON_Msg.validate(json))
1608
1942
  // return false;
1609
1943
  if (!schema_SubverseInfo_query(json)) {
1610
- log_(l_.VALIDATION, () => ['schema_SubverseInfo_query_: validate: ', schema_SubverseInfo_query.errors]);
1944
+ jsonMsg_cjsExports.logr.log(l_.VALIDATION, () => ['schema_SubverseInfo_query_: validate: ', schema_SubverseInfo_query.errors]);
1611
1945
  return false;
1612
1946
  }
1613
1947
  // const str_graphql = json["discovery"]["graphql"];
@@ -1634,7 +1968,7 @@ var JSON_MsgSubverseInfo_subverse = (function () {
1634
1968
  if (!JSON_MsgSubverseInfo_query.validate(json_msg._cause))
1635
1969
  return false;
1636
1970
  if (!schema_SubverseInfo_subverse(json_msg)) {
1637
- log_(l_.VALIDATION, () => ['JSON_SubverseInfo_expanse: validate: ', schema_SubverseInfo_subverse.errors]);
1971
+ jsonMsg_cjsExports.logr.log(l_.VALIDATION, () => ['JSON_SubverseInfo_expanse: validate: ', schema_SubverseInfo_subverse.errors]);
1638
1972
  return false;
1639
1973
  }
1640
1974
  return true;
@@ -1655,7 +1989,7 @@ var JSON_MsgSubverseInfo_instances = (function () {
1655
1989
  if (!JSON_MsgSubverseInfo_query.validate(json_msg._cause))
1656
1990
  return false;
1657
1991
  if (!schema_SubverseInfo_instances(json_msg)) {
1658
- log_(l_.VALIDATION, () => ['JSON_SubverseInfo_instances: validate: ', schema_SubverseInfo_instances.errors]);
1992
+ jsonMsg_cjsExports.logr.log(l_.VALIDATION, () => ['JSON_SubverseInfo_instances: validate: ', schema_SubverseInfo_instances.errors]);
1659
1993
  return false;
1660
1994
  }
1661
1995
  return true;
@@ -1666,4 +2000,4 @@ var JSON_MsgSubverseInfo_instances = (function () {
1666
2000
  exports.JSON_MsgSubverseInfo_instances = JSON_MsgSubverseInfo_instances;
1667
2001
  exports.JSON_MsgSubverseInfo_query = JSON_MsgSubverseInfo_query;
1668
2002
  exports.JSON_MsgSubverseInfo_subverse = JSON_MsgSubverseInfo_subverse;
1669
- exports.l = l_;
2003
+ exports.logr = jsonMsg_cjsExports.logr;