holosphere 2.0.0-alpha7 → 2.0.0-alpha9
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/CHANGELOG.md +446 -0
- package/FEATURES.md +431 -0
- package/LICENSE +29 -166
- package/LICENSE-AGPL.md +180 -0
- package/dist/cdn/holosphere.min.js +55 -0
- package/dist/cdn/holosphere.min.js.map +1 -0
- package/dist/cjs/holosphere.cjs +1 -1
- package/dist/esm/holosphere.js +1 -1
- package/dist/{index-C-IlLYlk.cjs → index-DDGt_V9o.cjs} +2 -2
- package/dist/{index-C-IlLYlk.cjs.map → index-DDGt_V9o.cjs.map} +1 -1
- package/dist/{index-d6f4RJBM.js → index-DJXftyvB.js} +2253 -387
- package/dist/index-DJXftyvB.js.map +1 -0
- package/dist/index-DMbdcMtK.cjs +18 -0
- package/dist/index-DMbdcMtK.cjs.map +1 -0
- package/dist/{index-jmTHEbR2.js → index-DeZ1xz_s.js} +2 -2
- package/dist/{index-jmTHEbR2.js.map → index-DeZ1xz_s.js.map} +1 -1
- package/dist/{indexeddb-storage-D8kOl0oK.js → indexeddb-storage-BFt6hMeF.js} +48 -4
- package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
- package/dist/{indexeddb-storage-a8GipaDr.cjs → indexeddb-storage-BK5tv4Sh.cjs} +2 -2
- package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
- package/dist/{memory-storage-DBQK622V.js → memory-storage-C9HuoL2E.js} +44 -4
- package/dist/memory-storage-C9HuoL2E.js.map +1 -0
- package/dist/{memory-storage-gfRovk2O.cjs → memory-storage-Dao7jfYG.cjs} +2 -2
- package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
- package/dist/{secp256k1-BCAPF45D.cjs → secp256k1-BbKzbLtD.cjs} +2 -2
- package/dist/{secp256k1-BCAPF45D.cjs.map → secp256k1-BbKzbLtD.cjs.map} +1 -1
- package/dist/{secp256k1-DYm_CMqW.js → secp256k1-CreY7Pcl.js} +2 -2
- package/dist/{secp256k1-DYm_CMqW.js.map → secp256k1-CreY7Pcl.js.map} +1 -1
- package/docs/api/ai_aggregation.js.html +333 -0
- package/docs/api/ai_breakdown.js.html +524 -0
- package/docs/api/ai_classifier.js.html +231 -0
- package/docs/api/ai_council.js.html +246 -0
- package/docs/api/ai_embeddings.js.html +304 -0
- package/docs/api/ai_federation-ai.js.html +338 -0
- package/docs/api/ai_h3-ai.js.html +970 -0
- package/docs/api/ai_index.js.html +124 -0
- package/docs/api/ai_json-ops.js.html +241 -0
- package/docs/api/ai_llm-service.js.html +239 -0
- package/docs/api/ai_nl-query.js.html +236 -0
- package/docs/api/ai_relationships.js.html +367 -0
- package/docs/api/ai_schema-extractor.js.html +235 -0
- package/docs/api/ai_spatial.js.html +307 -0
- package/docs/api/ai_tts.js.html +214 -0
- package/docs/api/content_social-protocols.js.html +180 -0
- package/docs/api/core_holosphere.js.html +757 -0
- package/docs/api/crypto_nostr-utils.js.html +306 -0
- package/docs/api/crypto_secp256k1.js.html +267 -0
- package/docs/api/data/search.json +1 -0
- package/docs/api/federation_discovery.js.html +337 -0
- package/docs/api/federation_handshake.js.html +478 -0
- package/docs/api/federation_hologram.js.html +1053 -0
- package/docs/api/federation_registry.js.html +389 -0
- package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/api/global.html +3 -0
- package/docs/api/hierarchical_upcast.js.html +128 -0
- package/docs/api/index.html +265 -0
- package/docs/api/index.js.html +1868 -0
- package/docs/api/lib_ai-methods.js.html +660 -0
- package/docs/api/lib_contract-methods.js.html +445 -0
- package/docs/api/lib_errors.js.html +56 -0
- package/docs/api/lib_federation-methods.js.html +348 -0
- package/docs/api/lib_index.js.html +33 -0
- package/docs/api/module-ai.html +5 -0
- package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
- package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
- package/docs/api/module-ai_aggregation.html +3 -0
- package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
- package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
- package/docs/api/module-ai_breakdown.html +3 -0
- package/docs/api/module-ai_classifier-Classifier.html +6 -0
- package/docs/api/module-ai_classifier.Classifier.html +3 -0
- package/docs/api/module-ai_classifier.html +3 -0
- package/docs/api/module-ai_council-Council.html +6 -0
- package/docs/api/module-ai_council.Council.html +3 -0
- package/docs/api/module-ai_council.html +3 -0
- package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
- package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
- package/docs/api/module-ai_embeddings.html +3 -0
- package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
- package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
- package/docs/api/module-ai_federation-ai.html +3 -0
- package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
- package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
- package/docs/api/module-ai_h3-ai.html +3 -0
- package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
- package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
- package/docs/api/module-ai_json-ops.html +3 -0
- package/docs/api/module-ai_llm-service-LLMService.html +5 -0
- package/docs/api/module-ai_llm-service.LLMService.html +3 -0
- package/docs/api/module-ai_llm-service.html +3 -0
- package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
- package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
- package/docs/api/module-ai_nl-query.html +3 -0
- package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
- package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
- package/docs/api/module-ai_relationships.html +3 -0
- package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
- package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
- package/docs/api/module-ai_schema-extractor.html +3 -0
- package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
- package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
- package/docs/api/module-ai_spatial.html +3 -0
- package/docs/api/module-ai_tts-TTS.html +5 -0
- package/docs/api/module-ai_tts.TTS.html +3 -0
- package/docs/api/module-ai_tts.html +3 -0
- package/docs/api/module-content_social-protocols.html +3 -0
- package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
- package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
- package/docs/api/module-core_holosphere.html +3 -0
- package/docs/api/module-crypto_nostr-utils.html +3 -0
- package/docs/api/module-crypto_secp256k1.html +3 -0
- package/docs/api/module-federation_hologram.html +3 -0
- package/docs/api/module-hierarchical_upcast.html +3 -0
- package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
- package/docs/api/module-holosphere.html +3 -0
- package/docs/api/module-lib_ai-methods.html +3 -0
- package/docs/api/module-lib_contract-methods.html +3 -0
- package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors-ValidationError.html +3 -0
- package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors.ValidationError.html +3 -0
- package/docs/api/module-lib_errors.html +3 -0
- package/docs/api/module-lib_federation-methods.html +3 -0
- package/docs/api/module-lib_index.html +3 -0
- package/docs/api/module-schema_validator-ValidationError.html +3 -0
- package/docs/api/module-schema_validator.ValidationError.html +3 -0
- package/docs/api/module-schema_validator.html +3 -0
- package/docs/api/module-spatial_h3-operations.html +4 -0
- package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
- package/docs/api/module-storage_backend-factory.html +3 -0
- package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
- package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
- package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
- package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
- package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend.html +3 -0
- package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
- package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
- package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage.html +3 -0
- package/docs/api/module-storage_global-tables.html +3 -0
- package/docs/api/module-storage_gun-async.html +3 -0
- package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
- package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
- package/docs/api/module-storage_gun-auth.html +3 -0
- package/docs/api/module-storage_gun-federation.html +3 -0
- package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
- package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
- package/docs/api/module-storage_gun-references.html +3 -0
- package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
- package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
- package/docs/api/module-storage_gun-schema.html +3 -0
- package/docs/api/module-storage_gun-wrapper.html +11 -0
- package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
- package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
- package/docs/api/module-storage_indexeddb-storage.html +3 -0
- package/docs/api/module-storage_key-storage-simple.html +3 -0
- package/docs/api/module-storage_key-storage.html +4 -0
- package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
- package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
- package/docs/api/module-storage_memory-storage.html +3 -0
- package/docs/api/module-storage_migration-MigrationTool.html +6 -0
- package/docs/api/module-storage_migration.MigrationTool.html +3 -0
- package/docs/api/module-storage_migration.html +3 -0
- package/docs/api/module-storage_nostr-async.html +18 -0
- package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
- package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
- package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
- package/docs/api/module-storage_nostr-client.html +6 -0
- package/docs/api/module-storage_nostr-wrapper.html +3 -0
- package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
- package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
- package/docs/api/module-storage_outbox-queue.html +3 -0
- package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
- package/docs/api/module-storage_persistent-storage.html +4 -0
- package/docs/api/module-storage_sync-service-SyncService.html +5 -0
- package/docs/api/module-storage_sync-service.SyncService.html +3 -0
- package/docs/api/module-storage_sync-service.html +3 -0
- package/docs/api/module-storage_unified-storage.html +3 -0
- package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
- package/docs/api/module-subscriptions_manager.html +3 -0
- package/docs/api/schema_validator.js.html +113 -0
- package/docs/api/scripts/core.js +726 -0
- package/docs/api/scripts/core.min.js +23 -0
- package/docs/api/scripts/resize.js +90 -0
- package/docs/api/scripts/search.js +265 -0
- package/docs/api/scripts/search.min.js +6 -0
- package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/api/scripts/third-party/fuse.js +9 -0
- package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/api/scripts/third-party/hljs-original.js +5171 -0
- package/docs/api/scripts/third-party/hljs.js +1 -0
- package/docs/api/scripts/third-party/popper.js +5 -0
- package/docs/api/scripts/third-party/tippy.js +1 -0
- package/docs/api/scripts/third-party/tocbot.js +672 -0
- package/docs/api/scripts/third-party/tocbot.min.js +1 -0
- package/docs/api/spatial_h3-operations.js.html +129 -0
- package/docs/api/storage_backend-factory.js.html +133 -0
- package/docs/api/storage_backend-interface.js.html +164 -0
- package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
- package/docs/api/storage_backends_activitypub_server.js.html +678 -0
- package/docs/api/storage_backends_gundb-backend.js.html +878 -0
- package/docs/api/storage_backends_nostr-backend.js.html +254 -0
- package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
- package/docs/api/storage_filesystem-storage.js.html +207 -0
- package/docs/api/storage_global-tables.js.html +116 -0
- package/docs/api/storage_gun-async.js.html +344 -0
- package/docs/api/storage_gun-auth.js.html +376 -0
- package/docs/api/storage_gun-federation.js.html +788 -0
- package/docs/api/storage_gun-references.js.html +212 -0
- package/docs/api/storage_gun-schema.js.html +309 -0
- package/docs/api/storage_gun-wrapper.js.html +645 -0
- package/docs/api/storage_indexeddb-storage.js.html +224 -0
- package/docs/api/storage_key-storage-simple.js.html +102 -0
- package/docs/api/storage_key-storage.js.html +171 -0
- package/docs/api/storage_memory-storage.js.html +128 -0
- package/docs/api/storage_migration.js.html +354 -0
- package/docs/api/storage_nostr-async.js.html +1076 -0
- package/docs/api/storage_nostr-client.js.html +1598 -0
- package/docs/api/storage_nostr-wrapper.js.html +218 -0
- package/docs/api/storage_outbox-queue.js.html +248 -0
- package/docs/api/storage_persistent-storage.js.html +160 -0
- package/docs/api/storage_sync-service.js.html +201 -0
- package/docs/api/storage_unified-storage.js.html +157 -0
- package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/api/subscriptions_manager.js.html +162 -0
- package/examples/holosphere-widget.js +1242 -0
- package/examples/widget-demo.html +274 -0
- package/examples/widget.html +703 -0
- package/jsdoc.json +26 -0
- package/package.json +16 -3
- package/src/ai/aggregation.js +13 -2
- package/src/ai/breakdown.js +12 -2
- package/src/ai/classifier.js +14 -3
- package/src/ai/council.js +22 -7
- package/src/ai/embeddings.js +37 -15
- package/src/ai/federation-ai.js +13 -2
- package/src/ai/h3-ai.js +14 -2
- package/src/ai/index.js +16 -7
- package/src/ai/json-ops.js +18 -5
- package/src/ai/llm-service.js +62 -31
- package/src/ai/nl-query.js +12 -2
- package/src/ai/relationships.js +13 -2
- package/src/ai/schema-extractor.js +24 -10
- package/src/ai/spatial.js +13 -2
- package/src/ai/tts.js +25 -8
- package/src/cdn-entry.js +22 -0
- package/src/content/social-protocols.js +34 -25
- package/src/contracts/chain-manager.js +68 -40
- package/src/contracts/deployer.js +70 -42
- package/src/contracts/event-listener.js +61 -29
- package/src/contracts/holon-contracts.js +46 -31
- package/src/contracts/index.js +5 -6
- package/src/contracts/networks.js +19 -14
- package/src/contracts/operations.js +58 -41
- package/src/contracts/queries.js +70 -21
- package/src/core/holosphere.js +37 -8
- package/src/crypto/nostr-utils.js +105 -65
- package/src/crypto/secp256k1.js +7 -2
- package/src/federation/handshake.js +23 -11
- package/src/federation/hologram.js +9 -1
- package/src/hierarchical/upcast.js +34 -20
- package/src/index.js +671 -7
- package/src/lib/ai-methods.js +352 -3
- package/src/lib/contract-methods.js +152 -3
- package/src/lib/errors.js +31 -1
- package/src/lib/federation-methods.js +110 -3
- package/src/lib/index.js +9 -5
- package/src/schema/validator.js +22 -3
- package/src/spatial/h3-operations.js +17 -1
- package/src/storage/backend-factory.js +7 -2
- package/src/storage/backend-interface.js +21 -2
- package/src/storage/backends/activitypub/server.js +25 -3
- package/src/storage/backends/activitypub-backend.js +25 -2
- package/src/storage/backends/gundb-backend.js +322 -11
- package/src/storage/backends/nostr-backend.js +116 -1
- package/src/storage/filesystem-storage-browser.js +42 -2
- package/src/storage/filesystem-storage.js +72 -5
- package/src/storage/global-tables.js +7 -2
- package/src/storage/gun-async.js +20 -11
- package/src/storage/gun-auth.js +15 -4
- package/src/storage/gun-federation.js +14 -5
- package/src/storage/gun-references.js +16 -5
- package/src/storage/gun-schema.js +25 -10
- package/src/storage/gun-wrapper.js +160 -49
- package/src/storage/indexeddb-storage.js +65 -4
- package/src/storage/key-storage-simple.js +32 -9
- package/src/storage/key-storage.js +45 -13
- package/src/storage/memory-storage.js +65 -4
- package/src/storage/migration.js +20 -7
- package/src/storage/nostr-async.js +195 -90
- package/src/storage/nostr-client.js +173 -49
- package/src/storage/nostr-wrapper.js +6 -2
- package/src/storage/outbox-queue.js +55 -18
- package/src/storage/persistent-storage.js +56 -13
- package/src/storage/sync-service.js +51 -17
- package/src/storage/unified-storage.js +38 -3
- package/src/subscriptions/manager.js +33 -16
- package/vite.config.cdn.js +60 -0
- package/dist/index-Bvwyvd0T.cjs +0 -5
- package/dist/index-Bvwyvd0T.cjs.map +0 -1
- package/dist/index-d6f4RJBM.js.map +0 -1
- package/dist/indexeddb-storage-D8kOl0oK.js.map +0 -1
- package/dist/indexeddb-storage-a8GipaDr.cjs.map +0 -1
- package/dist/memory-storage-DBQK622V.js.map +0 -1
- package/dist/memory-storage-gfRovk2O.cjs.map +0 -1
- /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
- /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SyncService - Background service for reliable sync
|
|
2
|
+
* @fileoverview SyncService - Background service for reliable sync.
|
|
3
3
|
*
|
|
4
4
|
* Periodically processes the outbox queue to retry failed deliveries
|
|
5
5
|
* and purge old failed events.
|
|
6
|
+
*
|
|
7
|
+
* @module storage/sync-service
|
|
6
8
|
*/
|
|
7
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Background service for reliable event synchronization.
|
|
12
|
+
*
|
|
13
|
+
* Runs on a periodic interval to:
|
|
14
|
+
* - Retry pending events in the outbox queue
|
|
15
|
+
* - Purge old failed events (24 hour TTL)
|
|
16
|
+
* - Provide sync statistics
|
|
17
|
+
*
|
|
18
|
+
* @class SyncService
|
|
19
|
+
* @example
|
|
20
|
+
* const sync = new SyncService(client, { interval: 10000, autoStart: true });
|
|
21
|
+
* const stats = await sync.getStats();
|
|
22
|
+
* console.log('Pending events:', stats.queue.pending);
|
|
23
|
+
*/
|
|
8
24
|
export class SyncService {
|
|
9
25
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
26
|
+
* Create a new SyncService.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} client - NostrClient instance with outboxQueue
|
|
29
|
+
* @param {Object} [options={}] - Configuration options
|
|
30
|
+
* @param {number} [options.interval=10000] - Sync interval in ms (10 seconds)
|
|
31
|
+
* @param {boolean} [options.autoStart=false] - Start automatically
|
|
14
32
|
*/
|
|
15
33
|
constructor(client, options = {}) {
|
|
16
34
|
this.client = client;
|
|
@@ -25,7 +43,9 @@ export class SyncService {
|
|
|
25
43
|
}
|
|
26
44
|
|
|
27
45
|
/**
|
|
28
|
-
* Start the background sync service
|
|
46
|
+
* Start the background sync service.
|
|
47
|
+
*
|
|
48
|
+
* @returns {void}
|
|
29
49
|
*/
|
|
30
50
|
start() {
|
|
31
51
|
if (this.running) return;
|
|
@@ -34,7 +54,9 @@ export class SyncService {
|
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
/**
|
|
37
|
-
* Stop the background sync service
|
|
57
|
+
* Stop the background sync service.
|
|
58
|
+
*
|
|
59
|
+
* @returns {void}
|
|
38
60
|
*/
|
|
39
61
|
stop() {
|
|
40
62
|
this.running = false;
|
|
@@ -45,24 +67,30 @@ export class SyncService {
|
|
|
45
67
|
}
|
|
46
68
|
|
|
47
69
|
/**
|
|
48
|
-
* Check if the service is running
|
|
49
|
-
*
|
|
70
|
+
* Check if the service is running.
|
|
71
|
+
*
|
|
72
|
+
* @returns {boolean} True if service is running
|
|
50
73
|
*/
|
|
51
74
|
isRunning() {
|
|
52
75
|
return this.running;
|
|
53
76
|
}
|
|
54
77
|
|
|
55
78
|
/**
|
|
56
|
-
* Force an immediate sync
|
|
57
|
-
*
|
|
79
|
+
* Force an immediate sync.
|
|
80
|
+
*
|
|
81
|
+
* Useful for testing or manual trigger.
|
|
82
|
+
*
|
|
83
|
+
* @returns {Promise<Object>} Sync result with processed, succeeded, failed, purged counts
|
|
58
84
|
*/
|
|
59
85
|
async syncNow() {
|
|
60
86
|
return this._processOutbox();
|
|
61
87
|
}
|
|
62
88
|
|
|
63
89
|
/**
|
|
64
|
-
* Schedule the next run
|
|
90
|
+
* Schedule the next run.
|
|
91
|
+
*
|
|
65
92
|
* @private
|
|
93
|
+
* @returns {void}
|
|
66
94
|
*/
|
|
67
95
|
_scheduleNextRun() {
|
|
68
96
|
if (!this.running) return;
|
|
@@ -73,8 +101,10 @@ export class SyncService {
|
|
|
73
101
|
}
|
|
74
102
|
|
|
75
103
|
/**
|
|
76
|
-
* Main loop iteration
|
|
104
|
+
* Main loop iteration.
|
|
105
|
+
*
|
|
77
106
|
* @private
|
|
107
|
+
* @returns {Promise<void>}
|
|
78
108
|
*/
|
|
79
109
|
async _runLoop() {
|
|
80
110
|
if (!this.running) return;
|
|
@@ -90,9 +120,12 @@ export class SyncService {
|
|
|
90
120
|
}
|
|
91
121
|
|
|
92
122
|
/**
|
|
93
|
-
* Process pending events in the outbox
|
|
123
|
+
* Process pending events in the outbox.
|
|
124
|
+
*
|
|
125
|
+
* Retries pending events and purges old failed events.
|
|
126
|
+
*
|
|
94
127
|
* @private
|
|
95
|
-
* @returns {Promise<Object>} Processing result
|
|
128
|
+
* @returns {Promise<Object>} Processing result with counts
|
|
96
129
|
*/
|
|
97
130
|
async _processOutbox() {
|
|
98
131
|
// Prevent concurrent processing
|
|
@@ -145,8 +178,9 @@ export class SyncService {
|
|
|
145
178
|
}
|
|
146
179
|
|
|
147
180
|
/**
|
|
148
|
-
* Get sync service statistics
|
|
149
|
-
*
|
|
181
|
+
* Get sync service statistics.
|
|
182
|
+
*
|
|
183
|
+
* @returns {Promise<Object>} Stats including running status, interval, and queue status
|
|
150
184
|
*/
|
|
151
185
|
async getStats() {
|
|
152
186
|
const stats = {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Unified Storage Adapter
|
|
3
|
-
*
|
|
2
|
+
* @fileoverview Unified Storage Adapter.
|
|
3
|
+
*
|
|
4
|
+
* Routes storage operations to the correct backend (Nostr or GunDB).
|
|
5
|
+
* Provides a consistent API for reading, writing, updating, and deleting
|
|
6
|
+
* data across different storage backends.
|
|
7
|
+
*
|
|
8
|
+
* @module storage/unified-storage
|
|
4
9
|
*/
|
|
5
10
|
|
|
6
11
|
import * as nostrWrapper from './nostr-wrapper.js';
|
|
@@ -27,7 +32,11 @@ export function buildPath(appName, holonId, lensName, key = null) {
|
|
|
27
32
|
* @returns {Promise<boolean>} Success indicator
|
|
28
33
|
*/
|
|
29
34
|
export async function write(client, path, data) {
|
|
30
|
-
// Check if this is a GunDB client
|
|
35
|
+
// Check if this is a GunDB client with backend methods (preferred - has write cache)
|
|
36
|
+
if (client.write && client.gun) {
|
|
37
|
+
return client.write(path, data);
|
|
38
|
+
}
|
|
39
|
+
// Fallback to direct gunWrapper (no write cache)
|
|
31
40
|
if (client.gun) {
|
|
32
41
|
return gunWrapper.write(client.gun, path, data);
|
|
33
42
|
}
|
|
@@ -43,6 +52,11 @@ export async function write(client, path, data) {
|
|
|
43
52
|
* @returns {Promise<Object|null>} Data or null
|
|
44
53
|
*/
|
|
45
54
|
export async function read(client, path, options = {}) {
|
|
55
|
+
// Check if this is a GunDB client with backend methods (preferred - has write cache)
|
|
56
|
+
if (client.read && client.gun) {
|
|
57
|
+
return client.read(path, options);
|
|
58
|
+
}
|
|
59
|
+
// Fallback to direct gunWrapper
|
|
46
60
|
if (client.gun) {
|
|
47
61
|
return gunWrapper.read(client.gun, path);
|
|
48
62
|
}
|
|
@@ -57,6 +71,11 @@ export async function read(client, path, options = {}) {
|
|
|
57
71
|
* @returns {Promise<Object[]>} Array of data objects
|
|
58
72
|
*/
|
|
59
73
|
export async function readAll(client, path, options = {}) {
|
|
74
|
+
// Check if this is a GunDB client with backend methods (preferred - has write cache)
|
|
75
|
+
if (client.readAll && client.gun) {
|
|
76
|
+
return client.readAll(path, options);
|
|
77
|
+
}
|
|
78
|
+
// Fallback to direct gunWrapper
|
|
60
79
|
if (client.gun) {
|
|
61
80
|
return gunWrapper.readAll(client.gun, path);
|
|
62
81
|
}
|
|
@@ -71,6 +90,11 @@ export async function readAll(client, path, options = {}) {
|
|
|
71
90
|
* @returns {Promise<boolean>} Success indicator
|
|
72
91
|
*/
|
|
73
92
|
export async function update(client, path, updates) {
|
|
93
|
+
// Check if this is a GunDB client with backend methods (preferred - has write cache)
|
|
94
|
+
if (client.update && client.gun) {
|
|
95
|
+
return client.update(path, updates);
|
|
96
|
+
}
|
|
97
|
+
// Fallback to direct gunWrapper
|
|
74
98
|
if (client.gun) {
|
|
75
99
|
return gunWrapper.update(client.gun, path, updates);
|
|
76
100
|
}
|
|
@@ -84,6 +108,11 @@ export async function update(client, path, updates) {
|
|
|
84
108
|
* @returns {Promise<boolean>} Success indicator
|
|
85
109
|
*/
|
|
86
110
|
export async function deleteData(client, path) {
|
|
111
|
+
// Check if this is a GunDB client with backend methods (preferred - has write cache)
|
|
112
|
+
if (client.delete && client.gun) {
|
|
113
|
+
return client.delete(path);
|
|
114
|
+
}
|
|
115
|
+
// Fallback to direct gunWrapper
|
|
87
116
|
if (client.gun) {
|
|
88
117
|
return gunWrapper.deleteData(client.gun, path);
|
|
89
118
|
}
|
|
@@ -97,6 +126,7 @@ export async function deleteData(client, path) {
|
|
|
97
126
|
* @returns {Promise<Object>} Deletion results
|
|
98
127
|
*/
|
|
99
128
|
export async function deleteAll(client, path) {
|
|
129
|
+
// Fallback to direct gunWrapper (deleteAll not typically in client interface)
|
|
100
130
|
if (client.gun) {
|
|
101
131
|
return gunWrapper.deleteAll(client.gun, path);
|
|
102
132
|
}
|
|
@@ -112,6 +142,11 @@ export async function deleteAll(client, path) {
|
|
|
112
142
|
* @returns {Object} Subscription with unsubscribe method
|
|
113
143
|
*/
|
|
114
144
|
export function subscribe(client, path, callback, options = {}) {
|
|
145
|
+
// Check if this is a GunDB client with backend methods
|
|
146
|
+
if (client.subscribe && client.gun) {
|
|
147
|
+
return client.subscribe(path, callback, options);
|
|
148
|
+
}
|
|
149
|
+
// Fallback to direct gunWrapper
|
|
115
150
|
if (client.gun) {
|
|
116
151
|
return gunWrapper.subscribe(client.gun, path, callback, options);
|
|
117
152
|
}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Real-time
|
|
2
|
+
* @fileoverview Real-time subscription management with throttling, filtering, and hologram resolution.
|
|
3
|
+
* Provides subscription utilities for real-time data updates from the unified storage layer.
|
|
4
|
+
* @module subscriptions/manager
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
import { subscribe } from '../storage/unified-storage.js';
|
|
6
8
|
import { resolveHologram } from '../federation/hologram.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
* Create subscription with throttle and filter
|
|
11
|
+
* Create subscription with throttle and filter support.
|
|
12
|
+
* Manages real-time data updates with deduplication, hologram resolution, and filtering capabilities.
|
|
10
13
|
* @param {Object} client - Nostr client instance
|
|
11
|
-
* @param {string} path - Path to subscribe to
|
|
12
|
-
* @param {Function} callback - Callback function
|
|
13
|
-
* @param {Object} options - Subscription options
|
|
14
|
-
* @param {number} options.throttle - Throttle interval in
|
|
15
|
-
* @param {Function} options.filter - Filter predicate
|
|
16
|
-
* @param {boolean} options.includeFederated - Include federated data
|
|
17
|
-
* @param {boolean} options.triggerInitial - Trigger callback with initial data
|
|
18
|
-
* @param {boolean} options.
|
|
19
|
-
* @
|
|
14
|
+
* @param {string} path - Path to subscribe to (app/holon/lens/data)
|
|
15
|
+
* @param {Function} callback - Callback function invoked with (data, key)
|
|
16
|
+
* @param {Object} [options={}] - Subscription options
|
|
17
|
+
* @param {number} [options.throttle=0] - Throttle interval in milliseconds
|
|
18
|
+
* @param {Function} [options.filter=null] - Filter predicate function (data, key) => boolean
|
|
19
|
+
* @param {boolean} [options.includeFederated=false] - Include federated data
|
|
20
|
+
* @param {boolean} [options.triggerInitial=false] - Trigger callback with initial data
|
|
21
|
+
* @param {boolean} [options.realtimeOnly=true] - Only subscribe to new events
|
|
22
|
+
* @param {boolean} [options.resolveHolograms=true] - Resolve holograms before callback
|
|
23
|
+
* @returns {Promise<Object>} Subscription object with path and unsubscribe method
|
|
20
24
|
*/
|
|
21
25
|
export async function createSubscription(client, path, callback, options = {}) {
|
|
22
26
|
const { throttle = 0, filter = null, includeFederated = false, triggerInitial = false, realtimeOnly = true, resolveHolograms = true } = options;
|
|
@@ -98,22 +102,34 @@ export async function createSubscription(client, path, callback, options = {}) {
|
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
/**
|
|
101
|
-
*
|
|
105
|
+
* Registry for tracking and managing multiple active subscriptions.
|
|
106
|
+
* Provides centralized subscription lifecycle management with batch operations.
|
|
102
107
|
*/
|
|
103
108
|
export class SubscriptionRegistry {
|
|
109
|
+
/**
|
|
110
|
+
* Create a new subscription registry.
|
|
111
|
+
*/
|
|
104
112
|
constructor() {
|
|
113
|
+
/**
|
|
114
|
+
* Map of subscription ID to subscription object
|
|
115
|
+
* @type {Map<string, Object>}
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
105
118
|
this.subscriptions = new Map();
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
/**
|
|
109
|
-
* Register a subscription
|
|
122
|
+
* Register a subscription by ID.
|
|
123
|
+
* @param {string} id - Unique subscription identifier
|
|
124
|
+
* @param {Object} subscription - Subscription object with unsubscribe method
|
|
110
125
|
*/
|
|
111
126
|
register(id, subscription) {
|
|
112
127
|
this.subscriptions.set(id, subscription);
|
|
113
128
|
}
|
|
114
129
|
|
|
115
130
|
/**
|
|
116
|
-
* Unregister a subscription
|
|
131
|
+
* Unregister and unsubscribe a subscription by ID.
|
|
132
|
+
* @param {string} id - Subscription identifier to remove
|
|
117
133
|
*/
|
|
118
134
|
unregister(id) {
|
|
119
135
|
const subscription = this.subscriptions.get(id);
|
|
@@ -124,7 +140,7 @@ export class SubscriptionRegistry {
|
|
|
124
140
|
}
|
|
125
141
|
|
|
126
142
|
/**
|
|
127
|
-
* Unsubscribe all
|
|
143
|
+
* Unsubscribe all registered subscriptions and clear the registry.
|
|
128
144
|
*/
|
|
129
145
|
unsubscribeAll() {
|
|
130
146
|
for (const [id, subscription] of this.subscriptions) {
|
|
@@ -134,7 +150,8 @@ export class SubscriptionRegistry {
|
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
/**
|
|
137
|
-
* Get active
|
|
153
|
+
* Get the count of active subscriptions.
|
|
154
|
+
* @returns {number} Number of active subscriptions
|
|
138
155
|
*/
|
|
139
156
|
count() {
|
|
140
157
|
return this.subscriptions.size;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CDN Build Configuration
|
|
6
|
+
* Creates a self-contained bundle for browser usage via CDN
|
|
7
|
+
* All dependencies are bundled (no externals)
|
|
8
|
+
*/
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
build: {
|
|
11
|
+
target: 'es2020',
|
|
12
|
+
outDir: 'dist/cdn',
|
|
13
|
+
lib: {
|
|
14
|
+
entry: resolve(__dirname, 'src/cdn-entry.js'),
|
|
15
|
+
name: 'HoloSphere',
|
|
16
|
+
formats: ['iife'],
|
|
17
|
+
fileName: () => 'holosphere.min.js',
|
|
18
|
+
},
|
|
19
|
+
rollupOptions: {
|
|
20
|
+
// Bundle all dependencies for CDN
|
|
21
|
+
external: [],
|
|
22
|
+
output: {
|
|
23
|
+
// Use default export so HoloSphere is directly accessible
|
|
24
|
+
exports: 'default',
|
|
25
|
+
// Extend window with all exports
|
|
26
|
+
extend: true,
|
|
27
|
+
// Provide globals for any remaining externals
|
|
28
|
+
globals: {},
|
|
29
|
+
// Inline dynamic imports
|
|
30
|
+
inlineDynamicImports: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
sourcemap: true,
|
|
34
|
+
minify: 'terser',
|
|
35
|
+
terserOptions: {
|
|
36
|
+
compress: {
|
|
37
|
+
drop_console: false,
|
|
38
|
+
passes: 2,
|
|
39
|
+
},
|
|
40
|
+
mangle: {
|
|
41
|
+
safari10: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
// Increase chunk size warning limit for CDN bundle
|
|
45
|
+
chunkSizeWarningLimit: 2000,
|
|
46
|
+
},
|
|
47
|
+
resolve: {
|
|
48
|
+
alias: [
|
|
49
|
+
{
|
|
50
|
+
find: './filesystem-storage.js',
|
|
51
|
+
replacement: resolve(__dirname, 'src/storage/filesystem-storage-browser.js'),
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
define: {
|
|
56
|
+
'process.versions.node': JSON.stringify(undefined),
|
|
57
|
+
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
58
|
+
'global': 'globalThis',
|
|
59
|
+
},
|
|
60
|
+
});
|