holosphere 1.3.0-alpha3 → 1.3.0-alpha5

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.
package/global.js CHANGED
@@ -743,15 +743,18 @@ export async function deleteAllGlobal(holoInstance, tableName, password = null)
743
743
 
744
744
  /**
745
745
  * Subscribe to real-time changes in a global table.
746
+ *
747
+ * Returns synchronously — see {@link subscribe} for the same rationale.
748
+ *
746
749
  * @param {HoloSphere} holoInstance - The HoloSphere instance.
747
750
  * @param {string} tableName - The table name to subscribe to.
748
751
  * @param {string|null} key - Specific key to subscribe to, or null for all keys.
749
752
  * @param {function} callback - Callback for data changes.
750
753
  * @param {object} [options] - Subscription options.
751
754
  * @param {boolean} [options.realtimeOnly] - Only fire for new changes.
752
- * @returns {Promise<{ unsubscribe: () => void }>}
755
+ * @returns {{ unsubscribe: () => void, stop: () => void }}
753
756
  */
754
- export async function subscribeGlobal(holoInstance, tableName, key, callback, options = {}) {
757
+ export function subscribeGlobal(holoInstance, tableName, key, callback, options = {}) {
755
758
  const dataPath = holoInstance.gun.get(holoInstance.appname).get(tableName);
756
759
  let active = true;
757
760
 
package/hologram.js CHANGED
@@ -175,11 +175,28 @@ export async function resolveHologram(holoInstance, hologram, options = {}) {
175
175
  if (originalData && !originalData._invalidHologram) {
176
176
  // Attach the canonical `_hologram` envelope. This is the only
177
177
  // resolved-hologram indicator HoloSphere emits.
178
- return attachHologramMeta(originalData, hologram.soul);
178
+ const withMeta = attachHologramMeta(originalData, hologram.soul);
179
+ // Stamp the source holon's display name so every consumer
180
+ // (subscribe, get, getAll, getFederated) has it without a
181
+ // second round-trip. Cached on the instance, so a batch of
182
+ // holograms from the same source resolves the name once.
183
+ if (withMeta._hologram?.sourceHolon && typeof holoInstance.getHolonName === 'function') {
184
+ try {
185
+ const sourceHolonName = await holoInstance.getHolonName(withMeta._hologram.sourceHolon);
186
+ if (sourceHolonName) {
187
+ withMeta._hologram = { ...withMeta._hologram, sourceHolonName };
188
+ }
189
+ } catch { /* best-effort — name lookup must not fail the resolve */ }
190
+ }
191
+ return withMeta;
179
192
  } else {
180
- console.warn(`!!! Original data NOT FOUND for soul: ${hologram.soul}. Removing broken hologram.`);
181
-
182
- // Return null to indicate the hologram should be removed
193
+ // Note: this is informational, not a permission to delete. The
194
+ // source soul may simply not be reachable yet (peer offline,
195
+ // federation propagation in flight). Callers must decide on
196
+ // their own GC policy; this function only reports the miss.
197
+ console.warn(`Could not resolve hologram soul: ${hologram.soul} (target not present locally)`);
198
+
199
+ // Return null so the caller skips this entry.
183
200
  return null;
184
201
  }
185
202
  } else {