Add nostr facades for client, view events, and watch history

This commit is contained in:
thePR0M3TH3AN committed 2025-10-22 22:17:30 -04:00
1 parent a1d053b21a
commit 3c214f96df
7 files changed
+126 -33

No files matched your search

+25 -14
View File
@@ -1,22 +1,33 @@
// js/nostr.js
//
// Compatibility shim that forwards legacy imports to the new domain-specific
// facades. Prefer importing from the facades directly in new modules so the
// wiring between the default client and helper layers stays explicit.
import {
nostrClient,
requestDefaultExtensionPermissions,
} from "./nostr/defaultClient.js";
export { nostrClient, requestDefaultExtensionPermissions };
export { nostrClient, requestDefaultExtensionPermissions } from "./nostrClientFacade.js";
export {
recordVideoView,
listVideoViewEvents,
subscribeVideoViewEvents,
countVideoViewEvents,
} from "./nostr/viewEventBindings.js";
recordVideoViewWithDefaultClient,
listVideoViewEventsWithDefaultClient,
subscribeVideoViewEventsWithDefaultClient,
countVideoViewEventsWithDefaultClient,
} from "./nostrViewEventsFacade.js";
export {
updateWatchHistoryList,
removeWatchHistoryItem,
} from "./nostr/watchHistoryBindings.js";
updateWatchHistoryListWithDefaultClient,
removeWatchHistoryItemWithDefaultClient,
} from "./nostrWatchHistoryFacade.js";
export {
recordVideoViewWithDefaultClient as recordVideoView,
listVideoViewEventsWithDefaultClient as listVideoViewEvents,
subscribeVideoViewEventsWithDefaultClient as subscribeVideoViewEvents,
countVideoViewEventsWithDefaultClient as countVideoViewEvents,
} from "./nostrViewEventsFacade.js";
export {
updateWatchHistoryListWithDefaultClient as updateWatchHistoryList,
removeWatchHistoryItemWithDefaultClient as removeWatchHistoryItem,
} from "./nostrWatchHistoryFacade.js";
export * from "./nostr/index.js";
+11
View File
@@ -0,0 +1,11 @@
// js/nostrClientFacade.js
//
// Compatibility-forwarding module that exposes the default Nostr client
// singleton alongside the convenience permission helper.
// Future modules should import from this facade instead of reaching into the
// nested default client implementation directly.
export {
nostrClient,
requestDefaultExtensionPermissions,
} from "./nostr/defaultClient.js";
+27
View File
@@ -0,0 +1,27 @@
// js/nostrViewEventsFacade.js
//
// Central export for NIP-71 view event helpers. Consumers can choose between
// helpers that accept an explicit Nostr client and thin wrappers that call the
// default client instance configured by the app shell.
export {
recordVideoView as recordVideoViewWithDefaultClient,
listVideoViewEvents as listVideoViewEventsWithDefaultClient,
subscribeVideoViewEvents as subscribeVideoViewEventsWithDefaultClient,
countVideoViewEvents as countVideoViewEventsWithDefaultClient,
} from "./nostr/viewEventBindings.js";
export {
VIEW_EVENT_KIND,
createVideoViewEventFilters,
deriveViewEventBucketIndex,
deriveViewEventPointerScope,
getViewEventGuardWindowMs,
hasRecentViewPublish,
rememberViewPublish,
publishViewEvent,
recordVideoView,
listVideoViewEvents,
subscribeVideoViewEvents,
countVideoViewEvents,
} from "./nostr/viewEvents.js";
+10
View File
@@ -0,0 +1,10 @@
// js/nostrWatchHistoryFacade.js
//
// Wrapper exports for watch history helpers that operate on the default Nostr
// client instance. Future consumers should import from this module rather than
// reaching into the binding layer directly.
export {
updateWatchHistoryList as updateWatchHistoryListWithDefaultClient,
removeWatchHistoryItem as removeWatchHistoryItemWithDefaultClient,
} from "./nostr/watchHistoryBindings.js";