diff --git a/js/app.js b/js/app.js index 06368ed0..8a6136b4 100644 --- a/js/app.js +++ b/js/app.js @@ -1,7 +1,7 @@ // js/app.js -import { nostrClient } from "./nostr.js"; -import { recordVideoView } from "./nostr/index.js"; +import { nostrClient } from "./nostrClientFacade.js"; +import { recordVideoView } from "./nostrViewEventsFacade.js"; import { torrentClient } from "./webtorrent.js"; import { isDevMode, diff --git a/js/channelProfile.js b/js/channelProfile.js index 41e155c3..67c93825 100644 --- a/js/channelProfile.js +++ b/js/channelProfile.js @@ -1,6 +1,6 @@ // js/channelProfile.js -import { nostrClient } from "./nostr.js"; +import { nostrClient } from "./nostrClientFacade.js"; import { convertEventToVideo as sharedConvertEventToVideo } from "./nostr/index.js"; import { DEFAULT_RELAY_URLS } from "./nostr/toolkit.js"; import { subscriptions } from "./subscriptions.js"; diff --git a/js/historyView.js b/js/historyView.js index b7fe51cf..20952f1a 100644 --- a/js/historyView.js +++ b/js/historyView.js @@ -1,8 +1,10 @@ // js/historyView.js import watchHistoryService from "./watchHistoryService.js"; -import { nostrClient } from "./nostr.js"; -import { updateWatchHistoryList } from "./nostr/watchHistoryBindings.js"; +import { nostrClient } from "./nostrClientFacade.js"; +import { + updateWatchHistoryListWithDefaultClient as updateWatchHistoryList, +} from "./nostrWatchHistoryFacade.js"; import { pointerKey, normalizePointerInput } from "./nostr/watchHistory.js"; import { WATCH_HISTORY_BATCH_RESOLVE, diff --git a/js/index.js b/js/index.js index bb4a8e04..92415ce0 100644 --- a/js/index.js +++ b/js/index.js @@ -33,7 +33,7 @@ import getAuthProvider, { providers as authProviders, } from "./services/authProviders/index.js"; import { accessControl } from "./accessControl.js"; -import { nostrClient } from "./nostr.js"; +import { nostrClient } from "./nostrClientFacade.js"; import { userBlocks } from "./userBlocks.js"; import { relayManager } from "./relayManager.js"; diff --git a/js/nostr.js b/js/nostr.js index e9ae089d..1c2b412e 100644 --- a/js/nostr.js +++ b/js/nostr.js @@ -6,6 +6,45 @@ export { nostrClient, requestDefaultExtensionPermissions } from "./nostrClientFacade.js"; +export { + __testExports, + NostrClient, + getActiveSigner, + setActiveSigner, + clearActiveSigner, + resolveActiveSigner, + shouldRequestExtensionPermissions, +} from "./nostr/client.js"; + +export { + DEFAULT_NIP07_ENCRYPTION_METHODS, + DEFAULT_NIP07_PERMISSION_METHODS, +} from "./nostr/nip07Permissions.js"; + +export { + buildNip71MetadataTags, + buildNip71VideoEvent, + collectNip71PointerRequests, + convertEventToVideo, + extractNip71MetadataFromTags, + getDTagValueFromTags, + mergeNip71MetadataIntoVideo, + populateNip71MetadataForVideos, + processNip71Events, + buildVideoPointerValue, + stringFromInput, +} from "./nostr/nip71.js"; + +export { + normalizePointerInput, + pointerKey, + chunkWatchHistoryPayloadItems, + normalizeActorKey, + parseWatchHistoryContentWithFallback, + isNip04EncryptedWatchHistoryEvent, + watchHistoryHelpers, +} from "./nostr/watchHistory.js"; + export { recordVideoViewWithDefaultClient, listVideoViewEventsWithDefaultClient, @@ -13,11 +52,31 @@ export { countVideoViewEventsWithDefaultClient, } from "./nostrViewEventsFacade.js"; +export { + VIEW_EVENT_KIND, + createVideoViewEventFilters, + deriveViewEventBucketIndex, + deriveViewEventPointerScope, + getViewEventGuardWindowMs, + hasRecentViewPublish, + rememberViewPublish, + publishViewEvent, + recordVideoView as recordVideoViewWithClient, + listVideoViewEvents as listVideoViewEventsWithClient, + subscribeVideoViewEvents as subscribeVideoViewEventsWithClient, + countVideoViewEvents as countVideoViewEventsWithClient, +} from "./nostrViewEventsFacade.js"; + export { updateWatchHistoryListWithDefaultClient, removeWatchHistoryItemWithDefaultClient, } from "./nostrWatchHistoryFacade.js"; +export { + updateWatchHistoryListWithDefaultClient as updateWatchHistoryList, + removeWatchHistoryItemWithDefaultClient as removeWatchHistoryItem, +} from "./nostrWatchHistoryFacade.js"; + export { recordVideoViewWithDefaultClient as recordVideoView, listVideoViewEventsWithDefaultClient as listVideoViewEvents, @@ -25,9 +84,7 @@ export { countVideoViewEventsWithDefaultClient as countVideoViewEvents, } from "./nostrViewEventsFacade.js"; -export { - updateWatchHistoryListWithDefaultClient as updateWatchHistoryList, - removeWatchHistoryItemWithDefaultClient as removeWatchHistoryItem, -} from "./nostrWatchHistoryFacade.js"; - -export * from "./nostr/index.js"; +// Legacy modules should import from the specific facades above instead of this +// shim. The wildcard export that previously forwarded the entire +// "./nostr/index.js" barrel has intentionally been removed so bundlers can tree +// shake unused helpers. diff --git a/js/relayManager.js b/js/relayManager.js index 3ce4b582..92d7625d 100644 --- a/js/relayManager.js +++ b/js/relayManager.js @@ -3,7 +3,7 @@ import { DEFAULT_RELAY_URLS } from "./nostr/toolkit.js"; import { nostrClient, requestDefaultExtensionPermissions, -} from "./nostr.js"; +} from "./nostrClientFacade.js"; import { getActiveSigner } from "./nostr/index.js"; import { buildRelayListEvent } from "./nostrEventSchemas.js"; import { devLogger, userLogger } from "./utils/logger.js"; diff --git a/js/subscriptions.js b/js/subscriptions.js index 20bd18fb..487d97c4 100644 --- a/js/subscriptions.js +++ b/js/subscriptions.js @@ -2,13 +2,15 @@ import { nostrClient, requestDefaultExtensionPermissions, -} from "./nostr.js"; +} from "./nostrClientFacade.js"; import { getActiveSigner, convertEventToVideo as sharedConvertEventToVideo, +} from "./nostr/index.js"; +import { listVideoViewEvents, subscribeVideoViewEvents, -} from "./nostr/index.js"; +} from "./nostrViewEventsFacade.js"; import { DEFAULT_RELAY_URLS } from "./nostr/toolkit.js"; import { buildSubscriptionListEvent, diff --git a/js/userBlocks.js b/js/userBlocks.js index 02d96fc1..2a9c6cdf 100644 --- a/js/userBlocks.js +++ b/js/userBlocks.js @@ -2,7 +2,7 @@ import { nostrClient, requestDefaultExtensionPermissions, -} from "./nostr.js"; +} from "./nostrClientFacade.js"; import { getActiveSigner } from "./nostr/index.js"; import { buildBlockListEvent, BLOCK_LIST_IDENTIFIER } from "./nostrEventSchemas.js"; import { userLogger } from "./utils/logger.js"; diff --git a/js/viewCounter.js b/js/viewCounter.js index 7738a75a..c684feee 100644 --- a/js/viewCounter.js +++ b/js/viewCounter.js @@ -17,12 +17,12 @@ import { VIEW_COUNT_DEDUPE_WINDOW_SECONDS, } from "./config.js"; import { userLogger } from "./utils/logger.js"; -import { nostrClient } from "./nostr.js"; +import { nostrClient } from "./nostrClientFacade.js"; import { - countVideoViewEvents, - listVideoViewEvents, - subscribeVideoViewEvents, -} from "./nostr/viewEventBindings.js"; + countVideoViewEventsWithDefaultClient as countVideoViewEvents, + listVideoViewEventsWithDefaultClient as listVideoViewEvents, + subscribeVideoViewEventsWithDefaultClient as subscribeVideoViewEvents, +} from "./nostrViewEventsFacade.js"; const VIEW_COUNTER_STORAGE_KEY = "bitvid:view-counter:v1"; const STORAGE_DEBOUNCE_MS = 500; diff --git a/js/watchHistoryMetadata.js b/js/watchHistoryMetadata.js index 1efda14d..0e573066 100644 --- a/js/watchHistoryMetadata.js +++ b/js/watchHistoryMetadata.js @@ -2,7 +2,7 @@ import { getApplication } from "./applicationContext.js"; import nostrService from "./services/nostrService.js"; -import { nostrClient } from "./nostr.js"; +import { nostrClient } from "./nostrClientFacade.js"; import { logWatchHistoryDebug } from "./watchHistoryDebug.js"; function logInfo(message, details) { diff --git a/js/watchHistoryService.js b/js/watchHistoryService.js index 25ce5709..4b909fd9 100644 --- a/js/watchHistoryService.js +++ b/js/watchHistoryService.js @@ -3,7 +3,7 @@ import { nostrClient, requestDefaultExtensionPermissions, -} from "./nostr.js"; +} from "./nostrClientFacade.js"; import { normalizePointerInput, pointerKey,