holosphere 1.1.16 → 1.1.17

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.
@@ -1,9 +1,9 @@
1
1
  /**
2
- * HoloSphere ESM Bundle v1.1.16
2
+ * HoloSphere ESM Bundle v1.1.17
3
3
  * ES6 Module version with all dependencies bundled
4
4
  *
5
5
  * Usage:
6
- * import HoloSphere from 'https://unpkg.com/holosphere@1.1.16/holosphere-bundle.esm.js';
6
+ * import HoloSphere from 'https://unpkg.com/holosphere@1.1.17/holosphere-bundle.esm.js';
7
7
  * const hs = new HoloSphere('myapp');
8
8
  */
9
9
  var __create = Object.create;
@@ -30412,16 +30412,14 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30412
30412
  result.messages.push(`No federation found for ${holon} or no notification targets available.`);
30413
30413
  }
30414
30414
  if (propagateToParents) {
30415
- console.log(`[Federation] Starting parent propagation for holon: ${holon}`);
30416
30415
  try {
30417
30416
  let holonResolution;
30418
30417
  let isValidH3 = false;
30419
- if (typeof holon === "string" && holon.startsWith("8") && holon.length >= 15) {
30418
+ if (typeof holon === "string" && /^[8][0-9A-Fa-f]+$/.test(holon) && holon.length >= 15) {
30420
30419
  try {
30421
30420
  holonResolution = getResolution(holon);
30422
30421
  if (holonResolution >= 0 && holonResolution <= 15) {
30423
30422
  isValidH3 = true;
30424
- console.log(`[Federation] Holon ${holon} is valid H3 hexagon with resolution: ${holonResolution}`);
30425
30423
  } else {
30426
30424
  console.log(`[Federation] Holon ${holon} has invalid resolution: ${holonResolution}`);
30427
30425
  }
@@ -30429,10 +30427,8 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30429
30427
  console.log(`[Federation] Holon ${holon} failed H3 validation: ${error.message}`);
30430
30428
  }
30431
30429
  } else {
30432
- console.log(`[Federation] Holon ${holon} is not a valid H3 hexagon: does not start with '8' or too short`);
30433
30430
  }
30434
30431
  if (!isValidH3) {
30435
- console.log(`[Federation] Skipping parent propagation for non-H3 holon: ${holon}`);
30436
30432
  result.parentPropagation.messages.push(`Holon ${holon} is not a valid H3 hexagon. Skipping parent propagation.`);
30437
30433
  result.parentPropagation.skipped++;
30438
30434
  }
@@ -30441,12 +30437,10 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30441
30437
  let currentHolon = holon;
30442
30438
  let currentRes = holonResolution;
30443
30439
  let levelsProcessed = 0;
30444
- console.log(`[Federation] Getting parent hexagons for ${holon} (resolution ${holonResolution}) up to ${maxParentLevels} levels`);
30445
30440
  while (currentRes > 0 && levelsProcessed < maxParentLevels) {
30446
30441
  try {
30447
30442
  const parent = cellToParent(currentHolon, currentRes - 1);
30448
30443
  parentHexagons.push(parent);
30449
- console.log(`[Federation] Found parent hexagon: ${parent} (resolution ${currentRes - 1})`);
30450
30444
  currentHolon = parent;
30451
30445
  currentRes--;
30452
30446
  levelsProcessed++;
@@ -30458,13 +30452,10 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30458
30452
  }
30459
30453
  }
30460
30454
  if (parentHexagons.length > 0) {
30461
- console.log(`[Federation] Found ${parentHexagons.length} parent hexagons to propagate to: ${parentHexagons.join(", ")}`);
30462
30455
  result.parentPropagation.messages.push(`Found ${parentHexagons.length} parent hexagons to propagate to: ${parentHexagons.join(", ")}`);
30463
30456
  const isAlreadyHologram = holosphere.isHologram(data);
30464
- console.log(`[Federation] Data is already hologram: ${isAlreadyHologram}`);
30465
30457
  const parentPropagatePromises = parentHexagons.map(async (parentHexagon) => {
30466
30458
  try {
30467
- console.log(`[Federation] Propagating to parent hexagon: ${parentHexagon}`);
30468
30459
  let payloadToPut;
30469
30460
  const parentFederationMeta = {
30470
30461
  origin: holon,
@@ -30480,7 +30471,6 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30480
30471
  };
30481
30472
  if (useHolograms && !isAlreadyHologram) {
30482
30473
  const newHologram = holosphere.createHologram(holon, lens, data);
30483
- console.log(`[Federation] Created hologram for parent propagation:`, newHologram);
30484
30474
  payloadToPut = {
30485
30475
  ...newHologram,
30486
30476
  // This will be { id: data.id, soul: 'path/to/original' }
@@ -30497,7 +30487,6 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30497
30487
  }
30498
30488
  };
30499
30489
  }
30500
- console.log(`[Federation] Storing in parent hexagon ${parentHexagon} with payload:`, payloadToPut);
30501
30490
  await holosphere.put(parentHexagon, lens, payloadToPut, null, {
30502
30491
  disableHologramRedirection: true,
30503
30492
  autoPropagate: false
@@ -30514,7 +30503,6 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30514
30503
  });
30515
30504
  await Promise.all(parentPropagatePromises);
30516
30505
  } else {
30517
- console.log(`[Federation] No parent hexagons found for ${holon} (already at resolution 0 or max levels reached)`);
30518
30506
  result.parentPropagation.messages.push(`No parent hexagons found for ${holon} (already at resolution 0 or max levels reached)`);
30519
30507
  result.parentPropagation.skipped++;
30520
30508
  }
@@ -30524,8 +30512,6 @@ async function propagate(holosphere, holon, lens, data, options = {}) {
30524
30512
  result.parentPropagation.errors++;
30525
30513
  result.parentPropagation.messages.push(`Error during parent propagation: ${error.message}`);
30526
30514
  }
30527
- } else {
30528
- console.log(`[Federation] Parent propagation disabled for holon: ${holon}`);
30529
30515
  }
30530
30516
  result.propagated = result.success > 0 || result.parentPropagation.success > 0;
30531
30517
  return result;
@@ -30769,7 +30755,6 @@ async function put(holoInstance, holon, lens, data, password = null, options = {
30769
30755
  if (soulInfo.appname !== holoInstance.appname) {
30770
30756
  console.warn(`Existing hologram at ${targetHolon}/${targetLens}/${targetKey} has appname (${soulInfo.appname}) in its soul ${existingItemAtPath.soul} which does not match current HoloSphere instance appname (${holoInstance.appname}). Redirecting put to soul's holon/lens within this instance.`);
30771
30757
  }
30772
- console.log(`Redirecting put for data (ID: ${data.id}). Original target ${targetHolon}/${targetLens}/${targetKey} contained hologram (ID: ${existingItemAtPath.id}, Soul: ${existingItemAtPath.soul}). New target is ${soulInfo.holon}/${soulInfo.lens}/${soulInfo.key}.`);
30773
30758
  targetHolon = soulInfo.holon;
30774
30759
  targetLens = soulInfo.lens;
30775
30760
  targetKey = soulInfo.key;
@@ -30860,7 +30845,6 @@ async function put(holoInstance, holon, lens, data, password = null, options = {
30860
30845
  const targetNodeRef = holoInstance.getNodeRef(data.soul);
30861
30846
  const storedHologramInstanceSoul = `${holoInstance.appname}/${targetHolon}/${targetLens}/${targetKey}`;
30862
30847
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
30863
- console.log(`Data (ID: ${data.id}) being put is a hologram. Added its instance soul ${storedHologramInstanceSoul} to its target ${data.soul}'s _holograms set.`);
30864
30848
  } else {
30865
30849
  console.warn(`Data (ID: ${data.id}) being put is a hologram, but could not parse its soul ${data.soul} for tracking.`);
30866
30850
  }
@@ -30881,7 +30865,6 @@ async function put(holoInstance, holon, lens, data, password = null, options = {
30881
30865
  // Only active holograms (deleted ones are null/removed)
30882
30866
  );
30883
30867
  if (hologramSouls.length > 0) {
30884
- console.log(`Updating ${hologramSouls.length} active holograms for data ${data.id}`);
30885
30868
  const updatePromises = hologramSouls.map(async (hologramSoul) => {
30886
30869
  try {
30887
30870
  const hologramSoulInfo = holoInstance.parseSoulPath(hologramSoul);
@@ -30912,7 +30895,6 @@ async function put(holoInstance, holon, lens, data, password = null, options = {
30912
30895
  // Prevent recursive hologram updates
30913
30896
  }
30914
30897
  );
30915
- console.log(`Updated hologram at ${hologramSoul} with timestamp`);
30916
30898
  updatedHolograms.push({
30917
30899
  soul: hologramSoul,
30918
30900
  holon: hologramSoulInfo.holon,
@@ -31037,16 +31019,22 @@ async function get(holoInstance, holon, lens, key, password = null, options = {}
31037
31019
  if (resolveHolograms && holoInstance.isHologram(parsed)) {
31038
31020
  const resolvedValue = await holoInstance.resolveHologram(parsed, {
31039
31021
  followHolograms: resolveHolograms,
31040
- visited
31022
+ visited,
31023
+ maxDepth: options.maxDepth || 10,
31024
+ currentDepth: options.currentDepth || 0
31041
31025
  });
31042
- console.log(`### get/handleData received resolved value:`, resolvedValue);
31043
31026
  if (resolvedValue === null) {
31044
- console.warn(`Hologram at ${holon}/${lens}/${key} could not be fully resolved (target not found or sub-problem). Resolving null.`);
31027
+ console.warn(`Broken hologram detected at ${holon}/${lens}/${key}. Removing it...`);
31028
+ try {
31029
+ await holoInstance.delete(holon, lens, key, password);
31030
+ console.log(`Successfully removed broken hologram from ${holon}/${lens}/${key}`);
31031
+ } catch (cleanupError) {
31032
+ console.error(`Failed to remove broken hologram at ${holon}/${lens}/${key}:`, cleanupError);
31033
+ }
31045
31034
  resolve(null);
31046
31035
  return;
31047
31036
  }
31048
31037
  if (resolvedValue !== parsed) {
31049
- console.log(`### get/handleData using resolved data:`, resolvedValue);
31050
31038
  parsed = resolvedValue;
31051
31039
  }
31052
31040
  }
@@ -31138,18 +31126,35 @@ async function getAll(holoInstance, holon, lens, password = null) {
31138
31126
  const parsed = await holoInstance.parse(data);
31139
31127
  if (!parsed || !parsed.id) return;
31140
31128
  if (holoInstance.isHologram(parsed)) {
31141
- const resolved = await holoInstance.resolveHologram(parsed, {
31142
- followHolograms: true
31143
- });
31144
- if (resolved !== parsed) {
31145
- if (schema) {
31146
- const valid = holoInstance.validator.validate(schema, resolved);
31147
- if (valid || !holoInstance.strict) {
31129
+ try {
31130
+ const resolved = await holoInstance.resolveHologram(parsed, {
31131
+ followHolograms: true,
31132
+ maxDepth: 10,
31133
+ currentDepth: 0
31134
+ });
31135
+ if (resolved === null) {
31136
+ console.warn(`Broken hologram detected in getAll for key ${key}. Removing it...`);
31137
+ try {
31138
+ await holoInstance.delete(holon, lens, key, password);
31139
+ console.log(`Successfully removed broken hologram from ${holon}/${lens}/${key}`);
31140
+ } catch (cleanupError) {
31141
+ console.error(`Failed to remove broken hologram at ${holon}/${lens}/${key}:`, cleanupError);
31142
+ }
31143
+ return;
31144
+ }
31145
+ if (resolved && resolved !== parsed) {
31146
+ if (schema) {
31147
+ const valid = holoInstance.validator.validate(schema, resolved);
31148
+ if (valid || !holoInstance.strict) {
31149
+ output.set(resolved.id, resolved);
31150
+ }
31151
+ } else {
31148
31152
  output.set(resolved.id, resolved);
31149
31153
  }
31150
- } else {
31151
- output.set(resolved.id, resolved);
31154
+ return;
31152
31155
  }
31156
+ } catch (hologramError) {
31157
+ console.error(`Error resolving hologram for key ${key}:`, hologramError);
31153
31158
  return;
31154
31159
  }
31155
31160
  }
@@ -31300,7 +31305,6 @@ async function deleteFunc(holoInstance, holon, lens, key, password = null) {
31300
31305
  if (ack.err) {
31301
31306
  console.warn(`[deleteFunc] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
31302
31307
  }
31303
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
31304
31308
  resolveTrack();
31305
31309
  });
31306
31310
  });
@@ -31412,7 +31416,6 @@ async function deleteAll(holoInstance, holon, lens, password = null) {
31412
31416
  if (ack.err) {
31413
31417
  console.warn(`[deleteAll] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
31414
31418
  }
31415
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
31416
31419
  resolveTrack();
31417
31420
  });
31418
31421
  });
@@ -31477,7 +31480,6 @@ async function putNode(holoInstance, holon, lens, data) {
31477
31480
  const targetNodeRef = holoInstance.getNodeRef(data.value.soul);
31478
31481
  const storedHologramInstanceSoul = `${holoInstance.appname}/${holon}/${lens}/value`;
31479
31482
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
31480
- console.log(`Data (ID: ${data.id}) being put is a hologram. Added its instance soul ${storedHologramInstanceSoul} to its target ${data.value.soul}'s _holograms set.`);
31481
31483
  } else {
31482
31484
  console.warn(`Data (ID: ${data.id}) being put is a hologram, but could not parse its soul ${data.value.soul} for tracking.`);
31483
31485
  }
@@ -31584,7 +31586,6 @@ async function deleteNode(holoInstance, holon, lens, key) {
31584
31586
  if (ack.err) {
31585
31587
  console.warn(`[deleteNode] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
31586
31588
  }
31587
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
31588
31589
  resolveTrack();
31589
31590
  });
31590
31591
  });
@@ -31682,7 +31683,6 @@ async function putGlobal(holoInstance, tableName, data, password = null) {
31682
31683
  const targetNodeRef = holoInstance.getNodeRef(dataToStore.soul);
31683
31684
  const storedHologramInstanceSoul = `${holoInstance.appname}/${tableName}/${data.id}`;
31684
31685
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
31685
- console.log(`Data (ID: ${data.id}) being put is a hologram. Added its instance soul ${storedHologramInstanceSoul} to its target ${dataToStore.soul}'s _holograms set.`);
31686
31686
  } else {
31687
31687
  console.warn(`Data (ID: ${data.id}) being put is a hologram, but could not parse its soul ${dataToStore.soul} for tracking.`);
31688
31688
  }
@@ -31705,7 +31705,6 @@ async function putGlobal(holoInstance, tableName, data, password = null) {
31705
31705
  const targetNodeRef = holoInstance.getNodeRef(dataToStore.soul);
31706
31706
  const storedHologramInstanceSoul = `${holoInstance.appname}/${tableName}`;
31707
31707
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
31708
- console.log(`Data being put is a hologram. Added its instance soul ${storedHologramInstanceSoul} to its target ${dataToStore.soul}'s _holograms set.`);
31709
31708
  } else {
31710
31709
  console.warn(`Data being put is a hologram, but could not parse its soul ${dataToStore.soul} for tracking.`);
31711
31710
  }
@@ -31789,7 +31788,6 @@ async function getGlobal(holoInstance, tableName, key, password = null) {
31789
31788
  // Always follow holograms
31790
31789
  });
31791
31790
  if (resolved === null) {
31792
- console.log(`Hologram at ${tableName}/${key} points to non-existent data. Deleting hologram.`);
31793
31791
  try {
31794
31792
  await holoInstance.deleteGlobal(tableName, key, password);
31795
31793
  } catch (deleteError) {
@@ -31899,7 +31897,6 @@ async function getAllGlobal(holoInstance, tableName, password = null) {
31899
31897
  // Always follow holograms
31900
31898
  });
31901
31899
  if (resolved === null) {
31902
- console.log(`Hologram at ${tableName}/${key} points to non-existent data. Deleting hologram.`);
31903
31900
  try {
31904
31901
  await holoInstance.deleteGlobal(tableName, key, password);
31905
31902
  } catch (deleteError) {
@@ -32013,7 +32010,6 @@ async function deleteGlobal(holoInstance, tableName, key, password = null) {
32013
32010
  if (ack.err) {
32014
32011
  console.warn(`[deleteGlobal] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
32015
32012
  }
32016
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
32017
32013
  resolveTrack();
32018
32014
  });
32019
32015
  });
@@ -32132,7 +32128,6 @@ async function deleteAllGlobal(holoInstance, tableName, password = null) {
32132
32128
  if (ack.err) {
32133
32129
  console.warn(`[deleteAllGlobal] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
32134
32130
  }
32135
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
32136
32131
  resolveTrack();
32137
32132
  });
32138
32133
  });
@@ -32184,7 +32179,6 @@ async function deleteAllGlobal(holoInstance, tableName, password = null) {
32184
32179
  // hologram.js
32185
32180
  function createHologram(holoInstance, holon, lens, data) {
32186
32181
  if (isHologram(data)) {
32187
- console.warn("createHologram called with data that is already a hologram. Reusing existing soul:", data.soul);
32188
32182
  return {
32189
32183
  id: data.id,
32190
32184
  soul: data.soul
@@ -32226,57 +32220,69 @@ async function resolveHologram(holoInstance, hologram, options = {}) {
32226
32220
  if (!isHologram(hologram)) {
32227
32221
  return hologram;
32228
32222
  }
32229
- const { followHolograms = true, visited = /* @__PURE__ */ new Set() } = options;
32223
+ const {
32224
+ followHolograms = true,
32225
+ visited = /* @__PURE__ */ new Set(),
32226
+ maxDepth = 10,
32227
+ currentDepth = 0
32228
+ } = options;
32229
+ if (currentDepth >= maxDepth) {
32230
+ console.warn(`!!! Maximum resolution depth (${maxDepth}) reached for soul: ${hologram.soul}. Stopping resolution.`);
32231
+ return null;
32232
+ }
32230
32233
  if (hologram.soul && visited.has(hologram.soul)) {
32231
- console.warn(`!!! CIRCULAR hologram detected for soul: ${hologram.soul}. Returning original hologram.`);
32232
- throw new Error(`CIRCULAR_REFERENCE:${hologram.soul}`);
32233
- } else {
32234
- try {
32235
- if (hologram.soul) {
32236
- const soulInfo = parseSoulPath(hologram.soul);
32237
- if (!soulInfo) {
32238
- console.warn(`Invalid soul format: ${hologram.soul}`);
32239
- return hologram;
32240
- }
32241
- const nextVisited = new Set(visited);
32242
- nextVisited.add(hologram.soul);
32243
- console.log(`Resolving hologram with soul: ${hologram.soul}`);
32244
- const originalData = await holoInstance.get(
32245
- soulInfo.holon,
32246
- soulInfo.lens,
32247
- soulInfo.key,
32248
- null,
32249
- {
32250
- resolveHolograms: followHolograms,
32251
- visited: nextVisited
32252
- }
32253
- );
32254
- console.log("### resolveHologram received originalData:", originalData);
32255
- if (originalData) {
32256
- console.log(`### Returning RESOLVED data for soul: ${hologram.soul}`);
32257
- return {
32258
- ...originalData,
32259
- _meta: {
32260
- ...originalData._meta || {},
32261
- // Preserve original _meta
32262
- resolvedFromHologram: true,
32263
- // This is now the primary indicator
32264
- hologramSoul: hologram.soul
32265
- // Clarified meta field
32266
- }
32267
- };
32268
- } else {
32269
- console.warn(`!!! Original data NOT FOUND for soul: ${hologram.soul}. Returning null.`);
32270
- return null;
32234
+ console.warn(`!!! CIRCULAR hologram detected for soul: ${hologram.soul}. Breaking loop.`);
32235
+ return null;
32236
+ }
32237
+ try {
32238
+ if (hologram.soul) {
32239
+ const soulInfo = parseSoulPath(hologram.soul);
32240
+ if (!soulInfo) {
32241
+ console.warn(`Invalid soul format: ${hologram.soul}`);
32242
+ return null;
32243
+ }
32244
+ const nextVisited = new Set(visited);
32245
+ nextVisited.add(hologram.soul);
32246
+ const originalData = await holoInstance.get(
32247
+ soulInfo.holon,
32248
+ soulInfo.lens,
32249
+ soulInfo.key,
32250
+ null,
32251
+ {
32252
+ resolveHolograms: followHolograms,
32253
+ visited: nextVisited,
32254
+ maxDepth,
32255
+ currentDepth: currentDepth + 1
32271
32256
  }
32257
+ );
32258
+ if (originalData && !originalData._invalidHologram) {
32259
+ return {
32260
+ ...originalData,
32261
+ _meta: {
32262
+ ...originalData._meta || {},
32263
+ // Preserve original _meta
32264
+ resolvedFromHologram: true,
32265
+ // This is now the primary indicator
32266
+ hologramSoul: hologram.soul,
32267
+ // Clarified meta field
32268
+ resolutionDepth: currentDepth
32269
+ }
32270
+ };
32272
32271
  } else {
32273
- console.warn("!!! resolveHologram called with object missing soul:", hologram);
32274
- return hologram;
32272
+ console.warn(`!!! Original data NOT FOUND for soul: ${hologram.soul}. Removing broken hologram.`);
32273
+ return null;
32275
32274
  }
32276
- } catch (error) {
32277
- console.error(`!!! Error resolving hologram: ${error.message}`, error);
32278
- return hologram;
32275
+ } else {
32276
+ console.warn("!!! resolveHologram called with object missing soul:", hologram);
32277
+ return null;
32279
32278
  }
32279
+ } catch (error) {
32280
+ if (error.message?.startsWith("CIRCULAR_REFERENCE")) {
32281
+ console.warn(`!!! Circular reference detected during hologram resolution: ${error.message}`);
32282
+ return null;
32283
+ }
32284
+ console.error(`!!! Error resolving hologram: ${error.message}`, error);
32285
+ return null;
32280
32286
  }
32281
32287
  }
32282
32288
 
@@ -32650,7 +32656,7 @@ function userName(holoInstance, holonId) {
32650
32656
  }
32651
32657
 
32652
32658
  // holosphere.js
32653
- var HOLOSPHERE_VERSION = "1.1.16";
32659
+ var HOLOSPHERE_VERSION = "1.1.17";
32654
32660
  var HoloSphere = class {
32655
32661
  /**
32656
32662
  * Initializes a new instance of the HoloSphere class.
@@ -33193,7 +33199,7 @@ export {
33193
33199
  };
33194
33200
  /**
33195
33201
  * @module holosphere
33196
- * @version 1.1.12
33202
+ * @version 1.1.17
33197
33203
  * @description Holonic Geospatial Communication Infrastructure
33198
33204
  * @author Roberto Valenti
33199
33205
  * @license GPL-3.0-or-later