holosphere 1.1.15 → 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,5 +1,5 @@
1
1
  /**
2
- * HoloSphere Bundle v1.1.15
2
+ * HoloSphere Bundle v1.1.17
3
3
  * Holonic Geospatial Communication Infrastructure
4
4
  *
5
5
  * Includes:
@@ -9,7 +9,7 @@
9
9
  * - Ajv (JSON schema validation)
10
10
  *
11
11
  * Usage:
12
- * <script src="https://unpkg.com/holosphere@1.1.15/holosphere-bundle.js"></script>
12
+ * <script src="https://unpkg.com/holosphere@1.1.17/holosphere-bundle.js"></script>
13
13
  * <script>
14
14
  * const hs = new HoloSphere('myapp');
15
15
  * </script>
@@ -30435,16 +30435,14 @@ ${str(snapshot)}`);
30435
30435
  result.messages.push(`No federation found for ${holon} or no notification targets available.`);
30436
30436
  }
30437
30437
  if (propagateToParents) {
30438
- console.log(`[Federation] Starting parent propagation for holon: ${holon}`);
30439
30438
  try {
30440
30439
  let holonResolution;
30441
30440
  let isValidH3 = false;
30442
- if (typeof holon === "string" && holon.startsWith("8") && holon.length >= 15) {
30441
+ if (typeof holon === "string" && /^[8][0-9A-Fa-f]+$/.test(holon) && holon.length >= 15) {
30443
30442
  try {
30444
30443
  holonResolution = getResolution(holon);
30445
30444
  if (holonResolution >= 0 && holonResolution <= 15) {
30446
30445
  isValidH3 = true;
30447
- console.log(`[Federation] Holon ${holon} is valid H3 hexagon with resolution: ${holonResolution}`);
30448
30446
  } else {
30449
30447
  console.log(`[Federation] Holon ${holon} has invalid resolution: ${holonResolution}`);
30450
30448
  }
@@ -30452,10 +30450,8 @@ ${str(snapshot)}`);
30452
30450
  console.log(`[Federation] Holon ${holon} failed H3 validation: ${error.message}`);
30453
30451
  }
30454
30452
  } else {
30455
- console.log(`[Federation] Holon ${holon} is not a valid H3 hexagon: does not start with '8' or too short`);
30456
30453
  }
30457
30454
  if (!isValidH3) {
30458
- console.log(`[Federation] Skipping parent propagation for non-H3 holon: ${holon}`);
30459
30455
  result.parentPropagation.messages.push(`Holon ${holon} is not a valid H3 hexagon. Skipping parent propagation.`);
30460
30456
  result.parentPropagation.skipped++;
30461
30457
  }
@@ -30464,12 +30460,10 @@ ${str(snapshot)}`);
30464
30460
  let currentHolon = holon;
30465
30461
  let currentRes = holonResolution;
30466
30462
  let levelsProcessed = 0;
30467
- console.log(`[Federation] Getting parent hexagons for ${holon} (resolution ${holonResolution}) up to ${maxParentLevels} levels`);
30468
30463
  while (currentRes > 0 && levelsProcessed < maxParentLevels) {
30469
30464
  try {
30470
30465
  const parent = cellToParent(currentHolon, currentRes - 1);
30471
30466
  parentHexagons.push(parent);
30472
- console.log(`[Federation] Found parent hexagon: ${parent} (resolution ${currentRes - 1})`);
30473
30467
  currentHolon = parent;
30474
30468
  currentRes--;
30475
30469
  levelsProcessed++;
@@ -30481,13 +30475,10 @@ ${str(snapshot)}`);
30481
30475
  }
30482
30476
  }
30483
30477
  if (parentHexagons.length > 0) {
30484
- console.log(`[Federation] Found ${parentHexagons.length} parent hexagons to propagate to: ${parentHexagons.join(", ")}`);
30485
30478
  result.parentPropagation.messages.push(`Found ${parentHexagons.length} parent hexagons to propagate to: ${parentHexagons.join(", ")}`);
30486
30479
  const isAlreadyHologram = holosphere.isHologram(data);
30487
- console.log(`[Federation] Data is already hologram: ${isAlreadyHologram}`);
30488
30480
  const parentPropagatePromises = parentHexagons.map(async (parentHexagon) => {
30489
30481
  try {
30490
- console.log(`[Federation] Propagating to parent hexagon: ${parentHexagon}`);
30491
30482
  let payloadToPut;
30492
30483
  const parentFederationMeta = {
30493
30484
  origin: holon,
@@ -30503,7 +30494,6 @@ ${str(snapshot)}`);
30503
30494
  };
30504
30495
  if (useHolograms && !isAlreadyHologram) {
30505
30496
  const newHologram = holosphere.createHologram(holon, lens, data);
30506
- console.log(`[Federation] Created hologram for parent propagation:`, newHologram);
30507
30497
  payloadToPut = {
30508
30498
  ...newHologram,
30509
30499
  // This will be { id: data.id, soul: 'path/to/original' }
@@ -30520,7 +30510,6 @@ ${str(snapshot)}`);
30520
30510
  }
30521
30511
  };
30522
30512
  }
30523
- console.log(`[Federation] Storing in parent hexagon ${parentHexagon} with payload:`, payloadToPut);
30524
30513
  await holosphere.put(parentHexagon, lens, payloadToPut, null, {
30525
30514
  disableHologramRedirection: true,
30526
30515
  autoPropagate: false
@@ -30537,7 +30526,6 @@ ${str(snapshot)}`);
30537
30526
  });
30538
30527
  await Promise.all(parentPropagatePromises);
30539
30528
  } else {
30540
- console.log(`[Federation] No parent hexagons found for ${holon} (already at resolution 0 or max levels reached)`);
30541
30529
  result.parentPropagation.messages.push(`No parent hexagons found for ${holon} (already at resolution 0 or max levels reached)`);
30542
30530
  result.parentPropagation.skipped++;
30543
30531
  }
@@ -30547,8 +30535,6 @@ ${str(snapshot)}`);
30547
30535
  result.parentPropagation.errors++;
30548
30536
  result.parentPropagation.messages.push(`Error during parent propagation: ${error.message}`);
30549
30537
  }
30550
- } else {
30551
- console.log(`[Federation] Parent propagation disabled for holon: ${holon}`);
30552
30538
  }
30553
30539
  result.propagated = result.success > 0 || result.parentPropagation.success > 0;
30554
30540
  return result;
@@ -30792,7 +30778,6 @@ ${str(snapshot)}`);
30792
30778
  if (soulInfo.appname !== holoInstance.appname) {
30793
30779
  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.`);
30794
30780
  }
30795
- 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}.`);
30796
30781
  targetHolon = soulInfo.holon;
30797
30782
  targetLens = soulInfo.lens;
30798
30783
  targetKey = soulInfo.key;
@@ -30883,7 +30868,6 @@ ${str(snapshot)}`);
30883
30868
  const targetNodeRef = holoInstance.getNodeRef(data.soul);
30884
30869
  const storedHologramInstanceSoul = `${holoInstance.appname}/${targetHolon}/${targetLens}/${targetKey}`;
30885
30870
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
30886
- console.log(`Data (ID: ${data.id}) being put is a hologram. Added its instance soul ${storedHologramInstanceSoul} to its target ${data.soul}'s _holograms set.`);
30887
30871
  } else {
30888
30872
  console.warn(`Data (ID: ${data.id}) being put is a hologram, but could not parse its soul ${data.soul} for tracking.`);
30889
30873
  }
@@ -30904,7 +30888,6 @@ ${str(snapshot)}`);
30904
30888
  // Only active holograms (deleted ones are null/removed)
30905
30889
  );
30906
30890
  if (hologramSouls.length > 0) {
30907
- console.log(`Updating ${hologramSouls.length} active holograms for data ${data.id}`);
30908
30891
  const updatePromises = hologramSouls.map(async (hologramSoul) => {
30909
30892
  try {
30910
30893
  const hologramSoulInfo = holoInstance.parseSoulPath(hologramSoul);
@@ -30935,7 +30918,6 @@ ${str(snapshot)}`);
30935
30918
  // Prevent recursive hologram updates
30936
30919
  }
30937
30920
  );
30938
- console.log(`Updated hologram at ${hologramSoul} with timestamp`);
30939
30921
  updatedHolograms.push({
30940
30922
  soul: hologramSoul,
30941
30923
  holon: hologramSoulInfo.holon,
@@ -31060,16 +31042,22 @@ ${str(snapshot)}`);
31060
31042
  if (resolveHolograms && holoInstance.isHologram(parsed)) {
31061
31043
  const resolvedValue = await holoInstance.resolveHologram(parsed, {
31062
31044
  followHolograms: resolveHolograms,
31063
- visited
31045
+ visited,
31046
+ maxDepth: options.maxDepth || 10,
31047
+ currentDepth: options.currentDepth || 0
31064
31048
  });
31065
- console.log(`### get/handleData received resolved value:`, resolvedValue);
31066
31049
  if (resolvedValue === null) {
31067
- console.warn(`Hologram at ${holon}/${lens}/${key} could not be fully resolved (target not found or sub-problem). Resolving null.`);
31050
+ console.warn(`Broken hologram detected at ${holon}/${lens}/${key}. Removing it...`);
31051
+ try {
31052
+ await holoInstance.delete(holon, lens, key, password);
31053
+ console.log(`Successfully removed broken hologram from ${holon}/${lens}/${key}`);
31054
+ } catch (cleanupError) {
31055
+ console.error(`Failed to remove broken hologram at ${holon}/${lens}/${key}:`, cleanupError);
31056
+ }
31068
31057
  resolve(null);
31069
31058
  return;
31070
31059
  }
31071
31060
  if (resolvedValue !== parsed) {
31072
- console.log(`### get/handleData using resolved data:`, resolvedValue);
31073
31061
  parsed = resolvedValue;
31074
31062
  }
31075
31063
  }
@@ -31161,18 +31149,35 @@ ${str(snapshot)}`);
31161
31149
  const parsed = await holoInstance.parse(data);
31162
31150
  if (!parsed || !parsed.id) return;
31163
31151
  if (holoInstance.isHologram(parsed)) {
31164
- const resolved = await holoInstance.resolveHologram(parsed, {
31165
- followHolograms: true
31166
- });
31167
- if (resolved !== parsed) {
31168
- if (schema) {
31169
- const valid = holoInstance.validator.validate(schema, resolved);
31170
- if (valid || !holoInstance.strict) {
31152
+ try {
31153
+ const resolved = await holoInstance.resolveHologram(parsed, {
31154
+ followHolograms: true,
31155
+ maxDepth: 10,
31156
+ currentDepth: 0
31157
+ });
31158
+ if (resolved === null) {
31159
+ console.warn(`Broken hologram detected in getAll for key ${key}. Removing it...`);
31160
+ try {
31161
+ await holoInstance.delete(holon, lens, key, password);
31162
+ console.log(`Successfully removed broken hologram from ${holon}/${lens}/${key}`);
31163
+ } catch (cleanupError) {
31164
+ console.error(`Failed to remove broken hologram at ${holon}/${lens}/${key}:`, cleanupError);
31165
+ }
31166
+ return;
31167
+ }
31168
+ if (resolved && resolved !== parsed) {
31169
+ if (schema) {
31170
+ const valid = holoInstance.validator.validate(schema, resolved);
31171
+ if (valid || !holoInstance.strict) {
31172
+ output.set(resolved.id, resolved);
31173
+ }
31174
+ } else {
31171
31175
  output.set(resolved.id, resolved);
31172
31176
  }
31173
- } else {
31174
- output.set(resolved.id, resolved);
31177
+ return;
31175
31178
  }
31179
+ } catch (hologramError) {
31180
+ console.error(`Error resolving hologram for key ${key}:`, hologramError);
31176
31181
  return;
31177
31182
  }
31178
31183
  }
@@ -31323,7 +31328,6 @@ ${str(snapshot)}`);
31323
31328
  if (ack.err) {
31324
31329
  console.warn(`[deleteFunc] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
31325
31330
  }
31326
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
31327
31331
  resolveTrack();
31328
31332
  });
31329
31333
  });
@@ -31435,7 +31439,6 @@ ${str(snapshot)}`);
31435
31439
  if (ack.err) {
31436
31440
  console.warn(`[deleteAll] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
31437
31441
  }
31438
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
31439
31442
  resolveTrack();
31440
31443
  });
31441
31444
  });
@@ -31500,7 +31503,6 @@ ${str(snapshot)}`);
31500
31503
  const targetNodeRef = holoInstance.getNodeRef(data.value.soul);
31501
31504
  const storedHologramInstanceSoul = `${holoInstance.appname}/${holon}/${lens}/value`;
31502
31505
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
31503
- 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.`);
31504
31506
  } else {
31505
31507
  console.warn(`Data (ID: ${data.id}) being put is a hologram, but could not parse its soul ${data.value.soul} for tracking.`);
31506
31508
  }
@@ -31607,7 +31609,6 @@ ${str(snapshot)}`);
31607
31609
  if (ack.err) {
31608
31610
  console.warn(`[deleteNode] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
31609
31611
  }
31610
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
31611
31612
  resolveTrack();
31612
31613
  });
31613
31614
  });
@@ -31705,7 +31706,6 @@ ${str(snapshot)}`);
31705
31706
  const targetNodeRef = holoInstance.getNodeRef(dataToStore.soul);
31706
31707
  const storedHologramInstanceSoul = `${holoInstance.appname}/${tableName}/${data.id}`;
31707
31708
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
31708
- console.log(`Data (ID: ${data.id}) being put is a hologram. Added its instance soul ${storedHologramInstanceSoul} to its target ${dataToStore.soul}'s _holograms set.`);
31709
31709
  } else {
31710
31710
  console.warn(`Data (ID: ${data.id}) being put is a hologram, but could not parse its soul ${dataToStore.soul} for tracking.`);
31711
31711
  }
@@ -31728,7 +31728,6 @@ ${str(snapshot)}`);
31728
31728
  const targetNodeRef = holoInstance.getNodeRef(dataToStore.soul);
31729
31729
  const storedHologramInstanceSoul = `${holoInstance.appname}/${tableName}`;
31730
31730
  targetNodeRef.get("_holograms").get(storedHologramInstanceSoul).put(true);
31731
- console.log(`Data being put is a hologram. Added its instance soul ${storedHologramInstanceSoul} to its target ${dataToStore.soul}'s _holograms set.`);
31732
31731
  } else {
31733
31732
  console.warn(`Data being put is a hologram, but could not parse its soul ${dataToStore.soul} for tracking.`);
31734
31733
  }
@@ -31812,7 +31811,6 @@ ${str(snapshot)}`);
31812
31811
  // Always follow holograms
31813
31812
  });
31814
31813
  if (resolved === null) {
31815
- console.log(`Hologram at ${tableName}/${key} points to non-existent data. Deleting hologram.`);
31816
31814
  try {
31817
31815
  await holoInstance.deleteGlobal(tableName, key, password);
31818
31816
  } catch (deleteError) {
@@ -31922,7 +31920,6 @@ ${str(snapshot)}`);
31922
31920
  // Always follow holograms
31923
31921
  });
31924
31922
  if (resolved === null) {
31925
- console.log(`Hologram at ${tableName}/${key} points to non-existent data. Deleting hologram.`);
31926
31923
  try {
31927
31924
  await holoInstance.deleteGlobal(tableName, key, password);
31928
31925
  } catch (deleteError) {
@@ -32036,7 +32033,6 @@ ${str(snapshot)}`);
32036
32033
  if (ack.err) {
32037
32034
  console.warn(`[deleteGlobal] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
32038
32035
  }
32039
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
32040
32036
  resolveTrack();
32041
32037
  });
32042
32038
  });
@@ -32155,7 +32151,6 @@ ${str(snapshot)}`);
32155
32151
  if (ack.err) {
32156
32152
  console.warn(`[deleteAllGlobal] Error removing hologram ${deletedHologramSoul} from target ${targetSoul}:`, ack.err);
32157
32153
  }
32158
- console.log(`Removed hologram ${deletedHologramSoul} from target ${targetSoul}'s _holograms list`);
32159
32154
  resolveTrack();
32160
32155
  });
32161
32156
  });
@@ -32207,7 +32202,6 @@ ${str(snapshot)}`);
32207
32202
  // hologram.js
32208
32203
  function createHologram(holoInstance, holon, lens, data) {
32209
32204
  if (isHologram(data)) {
32210
- console.warn("createHologram called with data that is already a hologram. Reusing existing soul:", data.soul);
32211
32205
  return {
32212
32206
  id: data.id,
32213
32207
  soul: data.soul
@@ -32249,57 +32243,69 @@ ${str(snapshot)}`);
32249
32243
  if (!isHologram(hologram)) {
32250
32244
  return hologram;
32251
32245
  }
32252
- const { followHolograms = true, visited = /* @__PURE__ */ new Set() } = options;
32246
+ const {
32247
+ followHolograms = true,
32248
+ visited = /* @__PURE__ */ new Set(),
32249
+ maxDepth = 10,
32250
+ currentDepth = 0
32251
+ } = options;
32252
+ if (currentDepth >= maxDepth) {
32253
+ console.warn(`!!! Maximum resolution depth (${maxDepth}) reached for soul: ${hologram.soul}. Stopping resolution.`);
32254
+ return null;
32255
+ }
32253
32256
  if (hologram.soul && visited.has(hologram.soul)) {
32254
- console.warn(`!!! CIRCULAR hologram detected for soul: ${hologram.soul}. Returning original hologram.`);
32255
- throw new Error(`CIRCULAR_REFERENCE:${hologram.soul}`);
32256
- } else {
32257
- try {
32258
- if (hologram.soul) {
32259
- const soulInfo = parseSoulPath(hologram.soul);
32260
- if (!soulInfo) {
32261
- console.warn(`Invalid soul format: ${hologram.soul}`);
32262
- return hologram;
32263
- }
32264
- const nextVisited = new Set(visited);
32265
- nextVisited.add(hologram.soul);
32266
- console.log(`Resolving hologram with soul: ${hologram.soul}`);
32267
- const originalData = await holoInstance.get(
32268
- soulInfo.holon,
32269
- soulInfo.lens,
32270
- soulInfo.key,
32271
- null,
32272
- {
32273
- resolveHolograms: followHolograms,
32274
- visited: nextVisited
32275
- }
32276
- );
32277
- console.log("### resolveHologram received originalData:", originalData);
32278
- if (originalData) {
32279
- console.log(`### Returning RESOLVED data for soul: ${hologram.soul}`);
32280
- return {
32281
- ...originalData,
32282
- _meta: {
32283
- ...originalData._meta || {},
32284
- // Preserve original _meta
32285
- resolvedFromHologram: true,
32286
- // This is now the primary indicator
32287
- hologramSoul: hologram.soul
32288
- // Clarified meta field
32289
- }
32290
- };
32291
- } else {
32292
- console.warn(`!!! Original data NOT FOUND for soul: ${hologram.soul}. Returning null.`);
32293
- return null;
32257
+ console.warn(`!!! CIRCULAR hologram detected for soul: ${hologram.soul}. Breaking loop.`);
32258
+ return null;
32259
+ }
32260
+ try {
32261
+ if (hologram.soul) {
32262
+ const soulInfo = parseSoulPath(hologram.soul);
32263
+ if (!soulInfo) {
32264
+ console.warn(`Invalid soul format: ${hologram.soul}`);
32265
+ return null;
32266
+ }
32267
+ const nextVisited = new Set(visited);
32268
+ nextVisited.add(hologram.soul);
32269
+ const originalData = await holoInstance.get(
32270
+ soulInfo.holon,
32271
+ soulInfo.lens,
32272
+ soulInfo.key,
32273
+ null,
32274
+ {
32275
+ resolveHolograms: followHolograms,
32276
+ visited: nextVisited,
32277
+ maxDepth,
32278
+ currentDepth: currentDepth + 1
32294
32279
  }
32280
+ );
32281
+ if (originalData && !originalData._invalidHologram) {
32282
+ return {
32283
+ ...originalData,
32284
+ _meta: {
32285
+ ...originalData._meta || {},
32286
+ // Preserve original _meta
32287
+ resolvedFromHologram: true,
32288
+ // This is now the primary indicator
32289
+ hologramSoul: hologram.soul,
32290
+ // Clarified meta field
32291
+ resolutionDepth: currentDepth
32292
+ }
32293
+ };
32295
32294
  } else {
32296
- console.warn("!!! resolveHologram called with object missing soul:", hologram);
32297
- return hologram;
32295
+ console.warn(`!!! Original data NOT FOUND for soul: ${hologram.soul}. Removing broken hologram.`);
32296
+ return null;
32298
32297
  }
32299
- } catch (error) {
32300
- console.error(`!!! Error resolving hologram: ${error.message}`, error);
32301
- return hologram;
32298
+ } else {
32299
+ console.warn("!!! resolveHologram called with object missing soul:", hologram);
32300
+ return null;
32302
32301
  }
32302
+ } catch (error) {
32303
+ if (error.message?.startsWith("CIRCULAR_REFERENCE")) {
32304
+ console.warn(`!!! Circular reference detected during hologram resolution: ${error.message}`);
32305
+ return null;
32306
+ }
32307
+ console.error(`!!! Error resolving hologram: ${error.message}`, error);
32308
+ return null;
32303
32309
  }
32304
32310
  }
32305
32311
 
@@ -32673,7 +32679,7 @@ ${str(snapshot)}`);
32673
32679
  }
32674
32680
 
32675
32681
  // holosphere.js
32676
- var HOLOSPHERE_VERSION = "1.1.15";
32682
+ var HOLOSPHERE_VERSION = "1.1.17";
32677
32683
  var HoloSphere = class {
32678
32684
  /**
32679
32685
  * Initializes a new instance of the HoloSphere class.
@@ -33215,7 +33221,7 @@ ${str(snapshot)}`);
33215
33221
  })();
33216
33222
  /**
33217
33223
  * @module holosphere
33218
- * @version 1.1.12
33224
+ * @version 1.1.17
33219
33225
  * @description Holonic Geospatial Communication Infrastructure
33220
33226
  * @author Roberto Valenti
33221
33227
  * @license GPL-3.0-or-later