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/content.js +194 -37
- package/federation.js +167 -29
- package/global.js +5 -2
- package/hologram.js +21 -4
- package/holosphere-bundle.esm.js +571 -283
- package/holosphere-bundle.js +571 -283
- package/holosphere-bundle.min.js +8 -8
- package/holosphere.d.ts +67 -7
- package/holosphere.js +49 -4
- package/package.json +1 -1
- package/utils.js +29 -7
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 {
|
|
755
|
+
* @returns {{ unsubscribe: () => void, stop: () => void }}
|
|
753
756
|
*/
|
|
754
|
-
export
|
|
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
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
//
|
|
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 {
|