@pkcprotocol/pkc-js 0.0.140 → 0.0.142

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.
Files changed (85) hide show
  1. package/dist/browser/clients/base-client-manager.js +6 -1
  2. package/dist/browser/clients/base-client-manager.js.map +1 -1
  3. package/dist/browser/clients/rpc-client/pkc-rpc-client.js +15 -8
  4. package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  5. package/dist/browser/community/rpc-local-community.d.ts +12 -1
  6. package/dist/browser/community/rpc-local-community.js +133 -10
  7. package/dist/browser/community/rpc-local-community.js.map +1 -1
  8. package/dist/browser/generated-version.d.ts +1 -1
  9. package/dist/browser/generated-version.js +1 -1
  10. package/dist/browser/helia/helia-for-pkc.js +18 -1
  11. package/dist/browser/helia/helia-for-pkc.js.map +1 -1
  12. package/dist/browser/pages/pages-client-manager.d.ts +1 -0
  13. package/dist/browser/pages/pages-client-manager.js +22 -5
  14. package/dist/browser/pages/pages-client-manager.js.map +1 -1
  15. package/dist/browser/pkc/pkc-with-rpc-client.js +9 -5
  16. package/dist/browser/pkc/pkc-with-rpc-client.js.map +1 -1
  17. package/dist/browser/pkc/pkc.d.ts +4 -1
  18. package/dist/browser/pkc/pkc.js +6 -5
  19. package/dist/browser/pkc/pkc.js.map +1 -1
  20. package/dist/browser/publications/comment/comment-client-manager.js +11 -11
  21. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  22. package/dist/browser/publications/comment/comment.js +2 -0
  23. package/dist/browser/publications/comment/comment.js.map +1 -1
  24. package/dist/browser/publications/publication-client-manager.js +7 -1
  25. package/dist/browser/publications/publication-client-manager.js.map +1 -1
  26. package/dist/browser/publications/publication.d.ts +7 -0
  27. package/dist/browser/publications/publication.js +88 -24
  28. package/dist/browser/publications/publication.js.map +1 -1
  29. package/dist/browser/runtime/node/community/db-handler.js +5 -2
  30. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  31. package/dist/browser/test/mock-ipfs-client.js +10 -4
  32. package/dist/browser/test/mock-ipfs-client.js.map +1 -1
  33. package/dist/browser/util.d.ts +4 -0
  34. package/dist/browser/util.js +29 -0
  35. package/dist/browser/util.js.map +1 -1
  36. package/dist/bundled/bundle-manifest.json +40 -40
  37. package/dist/bundled/challenges.js +1 -1
  38. package/dist/bundled/chunks/{helia-for-pkc-D8Yy6QjO.js → helia-for-pkc-pBsoz9YH.js} +41 -34
  39. package/dist/bundled/chunks/{local-community-BIYHcGS5.js → local-community-B4rXLDqy.js} +34 -34
  40. package/dist/bundled/chunks/{local-community-3TpfDDKX.js → local-community-B9D4Iu_Q.js} +1 -1
  41. package/dist/bundled/chunks/{node-D0SiFYRw.js → node-CsvN3ADZ.js} +84 -34
  42. package/dist/bundled/chunks/{page-sort-scoring-I74ngMaI.js → page-sort-scoring-2Q6exRbl.js} +1 -1
  43. package/dist/bundled/chunks/{rpc-local-community-BHMWTLg2.js → rpc-local-community-D3V1Sto-.js} +113 -14
  44. package/dist/bundled/chunks/{util-DkGqBo7o.js → util-DVrZupXz.js} +36 -2
  45. package/dist/bundled/chunks/{util-Hi455mZb.js → util-LhCb7940.js} +1 -1
  46. package/dist/bundled/chunks/{validate-package-factories-BjxAINy2.js → validate-package-factories-Bl2AyT4N.js} +2 -2
  47. package/dist/bundled/index.js +1 -1
  48. package/dist/bundled/page-sorts.js +1 -1
  49. package/dist/bundled/rpc/src/index.js +4 -4
  50. package/dist/node/clients/base-client-manager.js +6 -1
  51. package/dist/node/clients/base-client-manager.js.map +1 -1
  52. package/dist/node/clients/rpc-client/pkc-rpc-client.js +15 -8
  53. package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  54. package/dist/node/community/rpc-local-community.d.ts +12 -1
  55. package/dist/node/community/rpc-local-community.js +133 -10
  56. package/dist/node/community/rpc-local-community.js.map +1 -1
  57. package/dist/node/generated-version.d.ts +1 -1
  58. package/dist/node/generated-version.js +1 -1
  59. package/dist/node/helia/helia-for-pkc.js +18 -1
  60. package/dist/node/helia/helia-for-pkc.js.map +1 -1
  61. package/dist/node/pages/pages-client-manager.d.ts +1 -0
  62. package/dist/node/pages/pages-client-manager.js +22 -5
  63. package/dist/node/pages/pages-client-manager.js.map +1 -1
  64. package/dist/node/pkc/pkc-with-rpc-client.js +9 -5
  65. package/dist/node/pkc/pkc-with-rpc-client.js.map +1 -1
  66. package/dist/node/pkc/pkc.d.ts +4 -1
  67. package/dist/node/pkc/pkc.js +6 -5
  68. package/dist/node/pkc/pkc.js.map +1 -1
  69. package/dist/node/publications/comment/comment-client-manager.js +11 -11
  70. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  71. package/dist/node/publications/comment/comment.js +2 -0
  72. package/dist/node/publications/comment/comment.js.map +1 -1
  73. package/dist/node/publications/publication-client-manager.js +7 -1
  74. package/dist/node/publications/publication-client-manager.js.map +1 -1
  75. package/dist/node/publications/publication.d.ts +7 -0
  76. package/dist/node/publications/publication.js +88 -24
  77. package/dist/node/publications/publication.js.map +1 -1
  78. package/dist/node/runtime/node/community/db-handler.js +5 -2
  79. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  80. package/dist/node/test/mock-ipfs-client.js +10 -4
  81. package/dist/node/test/mock-ipfs-client.js.map +1 -1
  82. package/dist/node/util.d.ts +4 -0
  83. package/dist/node/util.js +29 -0
  84. package/dist/node/util.js.map +1 -1
  85. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, In as CommentUpdateForChallengeVerificationSchema, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, hr as isStringDomain, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$1, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zn as CommentUpdateSchema, zr as logger_default } from "./util-DkGqBo7o.js";
3
- import { $n as buildRuntimeCommunityFields, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, Ar as setNativeFunctions$1, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Br as t$3, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dt as parseJsonWithPKCErrorIfFails, Er as monitorCommunitiesDirectory, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as NAME_RESOLVED_TRUE_TTL_MS, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lr as t$5, Lt as RpcCidParamSchema, M as parseRawPages, Mr as findCommunitiesEntry, Nn as verifyChallengeVerification, Nr as toCommunitiesEntry, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pt as RpcAnchorPublishPreparationResultSchema, Qr as nativeFunctions$2, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, Sr as getDefaultDataPath, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tr as listCommunitiesSync, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ur as t$2, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vr as n$3, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wr as t$4, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Yt as RpcFetchCommunityListParamSchema, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qr as NAME_RESOLVED_FALSE_TTL_MS, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-BHMWTLg2.js";
4
- import { s as getHeliaDebugContext } from "./util-Hi455mZb.js";
2
+ import { $ as retryKuboIpfsAdd, At as pTimeout, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cr as e$1, Ct as trackUpdatingComment, D as isIpfsCid, Dt as untrackUpdatingCommunity, E as isAbortError, Et as untrackUpdatingComment, Ft as ChallengeRequestMessageSchema, Ln as CommentUpdateForChallengeVerificationSchema, Lt as ChallengeVerificationMessageSchema, Mn as CommentIpfsSchema, Mr as require_retry$1, Nr as FailedToFetchCommentIpfsFromGatewaysError, Nt as ChallengeMessageSchema, Ot as require_sha256, Pr as FailedToFetchCommentUpdateFromGatewaysError, Rr as PKCError, Sn as PubsubTopicSchema, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tr as r, U as rejectWhenAbortSignalFires, Ur as setErrorMap, W as rejectWhenCommunityStopsOrAborts, X as replaceXWithY, Y as removeUndefinedValuesRecursively, Yt as version_default, Z as resolveWhenPredicateIsTrue, _r as n$2, _t as listUpdatingComments, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as throwIfAbortSignalAborted, d as deepMergeRuntimeFields, et as retryKuboIpfsAddAndProvide, ft as findStartedCommunity, gr as isStringDomain, gt as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, jt as ChallengeAnswerMessageSchema, k as isIpns, kt as TimeoutError, ln as CommunityAnchorSchema, mn as CommunityIpfsSchema, mt as findUpdatingCommunity, nt as shortifyCid, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pt as findUpdatingComment, r as calculateIpfsCidV0, ri as en_default, rt as sleepUntilTimeoutOrAbort, st as waitForUpdateInCommunityInstanceWithErrorAndTimeout, tt as shortifyAddress, u as createAbortError, vt as listUpdatingCommunities, x as getPostUpdateTimestampRange, xr as t$1, yr as n$1, yt as refreshTrackedCommentAliases, z as linkAbortSignals, zr as messages } from "./util-DVrZupXz.js";
3
+ import { $n as buildRuntimeCommunityFields, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, Ar as setNativeFunctions$1, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Br as t$3, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dt as parseJsonWithPKCErrorIfFails, Er as monitorCommunitiesDirectory, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as NAME_RESOLVED_TRUE_TTL_MS, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lr as t$5, Lt as RpcCidParamSchema, M as parseRawPages, Mr as findCommunitiesEntry, Nn as verifyChallengeVerification, Nr as toCommunitiesEntry, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pt as RpcAnchorPublishPreparationResultSchema, Qr as nativeFunctions$2, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, Sr as getDefaultDataPath, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tr as listCommunitiesSync, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ur as t$2, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vr as n$3, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wr as t$4, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Yt as RpcFetchCommunityListParamSchema, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qr as NAME_RESOLVED_FALSE_TTL_MS, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-D3V1Sto-.js";
4
+ import { s as getHeliaDebugContext } from "./util-LhCb7940.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -27353,13 +27353,15 @@ var PublicationClientsManager = class extends PKCClientsManager {
27353
27353
  communityPublicKey: updatingCommunityInstance.community.publicKey
27354
27354
  });
27355
27355
  if (nameMismatch) throw nameMismatch;
27356
- return {
27356
+ const communityForPublishing = {
27357
27357
  address: updatingCommunityInstance.community.address,
27358
27358
  publicKey: updatingCommunityInstance.community.publicKey,
27359
27359
  name: updatingCommunityInstance.community.name,
27360
27360
  encryption: communityIpfs.encryption,
27361
27361
  pubsubTopic: communityIpfs.pubsubTopic
27362
27362
  };
27363
+ this._pkc._memCaches.communityForPublishing.set(this._publication.communityAddress, communityForPublishing);
27364
+ return communityForPublishing;
27363
27365
  }
27364
27366
  };
27365
27367
  //#endregion
@@ -27497,6 +27499,7 @@ var Publication = class extends import_lib.TypedEmitter {
27497
27499
  args: [verification, this instanceof Comment && verification.comment ? this : void 0]
27498
27500
  }
27499
27501
  });
27502
+ this._unregisterFromPkcOncePublishWorkSettles();
27500
27503
  if (this._rpcPublishSubscriptionId) {
27501
27504
  const subscriptionId = this._rpcPublishSubscriptionId;
27502
27505
  this._rpcPublishSubscriptionId = void 0;
@@ -27863,17 +27866,39 @@ var Publication = class extends import_lib.TypedEmitter {
27863
27866
  _getCommunityFetchAbortSignal() {
27864
27867
  if (!this._communityFetchAbortSignal) {
27865
27868
  this._communityFetchAbortController = new AbortController();
27866
- this._communityFetchAbortSignal = AbortSignal.any([this._communityFetchAbortController.signal, this._pkc._getDestroyAbortSignal()]);
27869
+ this._communityFetchAbortSignal = this._communityFetchAbortController.signal;
27867
27870
  }
27868
27871
  return this._communityFetchAbortSignal;
27869
27872
  }
27873
+ async _cancelBackgroundCommunityRefresh() {
27874
+ this._communityFetchAbortController?.abort(new PKCError("ERR_GET_COMMUNITY_ABORTED", {
27875
+ publicationType: this.getType(),
27876
+ communityAddress: this.communityAddress
27877
+ }));
27878
+ if (this._backgroundCommunityRefresh) await this._backgroundCommunityRefresh;
27879
+ this._resetCommunityFetchAbortSignal();
27880
+ }
27870
27881
  _resetCommunityFetchAbortSignal() {
27871
27882
  this._communityFetchAbortController = void 0;
27872
27883
  this._communityFetchAbortSignal = void 0;
27873
27884
  }
27885
+ _beginPublishRun() {
27886
+ this._publishRunAbortController = new AbortController();
27887
+ this._publishRunWaitSignal = this._publishRunAbortController.signal;
27888
+ }
27889
+ _getPublishRunWaitSignal() {
27890
+ if (!this._publishRunWaitSignal) this._beginPublishRun();
27891
+ return this._publishRunWaitSignal;
27892
+ }
27893
+ _isPublishRunOver(runSignal) {
27894
+ return this._pkc.destroyed || runSignal.aborted;
27895
+ }
27874
27896
  _getCommunityCache() {
27875
- const cached = this._pkc._memCaches.communityForPublishing.get(this.communityAddress, { allowStale: true });
27876
- if (cached) return cached;
27897
+ const cache = this._pkc._memCaches.communityForPublishing;
27898
+ if (cache.has(this.communityAddress)) return cache.get(this.communityAddress);
27899
+ return this._getCommunityFromLiveInstance() ?? cache.get(this.communityAddress, { allowStale: true });
27900
+ }
27901
+ _getCommunityFromLiveInstance() {
27877
27902
  const subInstance = findUpdatingCommunity(this._pkc, {
27878
27903
  publicKey: this.communityPublicKey,
27879
27904
  name: this.communityName
@@ -27899,12 +27924,21 @@ var Publication = class extends import_lib.TypedEmitter {
27899
27924
  const log = logger_default("pkc-js:publish:_fetchCommunityForPublishing");
27900
27925
  const cachedCommunity = this._getCommunityCache();
27901
27926
  if (cachedCommunity) {
27902
- if (!this._pkc._memCaches.communityForPublishing.has(this.communityAddress)) {
27927
+ if (!(this._pkc._memCaches.communityForPublishing.has(this.communityAddress) || this._getCommunityFromLiveInstance() !== void 0)) {
27903
27928
  log("The cache of community is stale, we will use the cached and update in the background");
27904
27929
  const refresh = this._pkc.getCommunity({
27905
27930
  publicKey: this.communityPublicKey,
27906
27931
  name: this.communityName,
27907
27932
  abortSignal: this._getCommunityFetchAbortSignal()
27933
+ }).then((community) => {
27934
+ const record = community.raw.communityIpfs;
27935
+ if (record && community.publicKey) this._pkc._memCaches.communityForPublishing.set(this.communityAddress, {
27936
+ address: community.address,
27937
+ publicKey: community.publicKey,
27938
+ name: community.name,
27939
+ encryption: record.encryption,
27940
+ pubsubTopic: record.pubsubTopic
27941
+ });
27908
27942
  }).catch((e) => {
27909
27943
  if (e?.code === "ERR_GET_COMMUNITY_ABORTED") log("Stopped the background refresh of the community cache", this.communityAddress);
27910
27944
  else {
@@ -27958,6 +27992,7 @@ var Publication = class extends import_lib.TypedEmitter {
27958
27992
  }
27959
27993
  async _postSucessOrFailurePublishing() {
27960
27994
  const log = logger_default("pkc-js:publication:_postSucessOrFailurePublishing");
27995
+ this._publishRunAbortController?.abort();
27961
27996
  this._unregisterFromPkcOncePublishWorkSettles();
27962
27997
  this._setStateWithEmission("stopped");
27963
27998
  if (this._rpcPublishSubscriptionId) {
@@ -28150,8 +28185,9 @@ var Publication = class extends import_lib.TypedEmitter {
28150
28185
  return contexts;
28151
28186
  }
28152
28187
  async _handleNotReceivingResponseToChallengeRequest({ providers, currentPubsubProviderIndex, acceptedChallengeTypes }) {
28153
- await sleepUntilTimeoutOrAbort(this._publishToDifferentProviderThresholdSeconds * 1e3, this._pkc._getDestroyAbortSignal());
28154
- if (this._pkc.destroyed) return;
28188
+ const runSignal = this._getPublishRunWaitSignal();
28189
+ await sleepUntilTimeoutOrAbort(this._publishToDifferentProviderThresholdSeconds * 1e3, runSignal);
28190
+ if (this._isPublishRunOver(runSignal)) return;
28155
28191
  if (this._didWeReceiveChallengeOrChallengeVerification()) return;
28156
28192
  const currentPubsubProvider = providers[currentPubsubProviderIndex];
28157
28193
  this._pkc._stats.recordGatewayFailure(currentPubsubProvider, "pubsub-publish");
@@ -28183,6 +28219,7 @@ var Publication = class extends import_lib.TypedEmitter {
28183
28219
  currentPubsubProviderIndex += 1;
28184
28220
  while (!this._didWeReceiveChallengeOrChallengeVerification() && currentPubsubProviderIndex < providers.length) {
28185
28221
  const providerUrl = providers[currentPubsubProviderIndex];
28222
+ if (this._isPublishRunOver(runSignal)) return;
28186
28223
  const challengeRequest = await this._generateChallengeRequestToPublish(providerUrl, acceptedChallengeTypes);
28187
28224
  this._updatePublishingStateWithEmission("publishing-challenge-request");
28188
28225
  this._updatePubsubState("subscribing-pubsub", providerUrl);
@@ -28206,11 +28243,11 @@ var Publication = class extends import_lib.TypedEmitter {
28206
28243
  }
28207
28244
  log(`Published a challenge request of publication`, this.getType(), "with provider", providerUrl);
28208
28245
  this.emit("challengerequest", decryptedRequest);
28209
- if (currentPubsubProviderIndex !== providers.length) await sleepUntilTimeoutOrAbort(this._publishToDifferentProviderThresholdSeconds * 1e3, this._pkc._getDestroyAbortSignal());
28210
- if (this._pkc.destroyed) return;
28246
+ if (currentPubsubProviderIndex !== providers.length) await sleepUntilTimeoutOrAbort(this._publishToDifferentProviderThresholdSeconds * 1e3, runSignal);
28247
+ if (this._isPublishRunOver(runSignal)) return;
28211
28248
  }
28212
- await sleepUntilTimeoutOrAbort(this._setProviderFailureThresholdSeconds * 1e3, this._pkc._getDestroyAbortSignal());
28213
- if (this._pkc.destroyed) return;
28249
+ await sleepUntilTimeoutOrAbort(this._setProviderFailureThresholdSeconds * 1e3, runSignal);
28250
+ if (this._isPublishRunOver(runSignal)) return;
28214
28251
  if (this.state === "stopped") return;
28215
28252
  if (this._didWeReceiveChallengeOrChallengeVerification()) {
28216
28253
  log(`Received a challenge or challenge verification while waiting for retried providers, will keep the exchange alive`);
@@ -28278,11 +28315,13 @@ var Publication = class extends import_lib.TypedEmitter {
28278
28315
  async publish() {
28279
28316
  this._validatePublicationFields();
28280
28317
  if (this._getCommunityFetchAbortSignal().aborted) this._resetCommunityFetchAbortSignal();
28318
+ this._beginPublishRun();
28281
28319
  this._pkc._publishingPublications.add(this);
28282
28320
  try {
28283
28321
  return await this._publishAfterRegistering();
28284
28322
  } catch (e) {
28285
28323
  this._unregisterFromPkcOncePublishWorkSettles();
28324
+ this._publishRunAbortController?.abort();
28286
28325
  throw e;
28287
28326
  }
28288
28327
  }
@@ -28564,10 +28603,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
28564
28603
  this._freshHandlerAbortController = new AbortController();
28565
28604
  }
28566
28605
  _combinedAbortSignalForRetry() {
28567
- const signals = [this._comment._getStopAbortSignal(), this._freshHandlerAbortController?.signal].filter((s) => Boolean(s));
28568
- if (signals.length === 0) return void 0;
28569
- if (signals.length === 1) return signals[0];
28570
- return AbortSignal.any(signals);
28606
+ return linkAbortSignals([this._comment._getStopAbortSignal(), this._freshHandlerAbortController?.signal]);
28571
28607
  }
28572
28608
  _initKuboRpcClients() {
28573
28609
  if (this._pkc.clients.kuboRpcClients) for (const ipfsUrl of t$1(this._pkc.clients.kuboRpcClients)) this.clients.kuboRpcClients = {
@@ -28883,7 +28919,8 @@ var CommentClientsManager = class extends PublicationClientsManager {
28883
28919
  if (typeof postTimestamp !== "number") throw Error("Post timestamp is not defined by the time we're fetching from postUpdates");
28884
28920
  const timestampRanges = getPostUpdateTimestampRange(subIpfs.postUpdates, postTimestamp);
28885
28921
  if (timestampRanges.length === 0) throw Error("Post has no timestamp range bucket");
28886
- const abortSignal = this._combinedAbortSignalForRetry();
28922
+ const linkedAbortSignal = this._combinedAbortSignalForRetry();
28923
+ const abortSignal = linkedAbortSignal.signal;
28887
28924
  let newCommentUpdate;
28888
28925
  try {
28889
28926
  if (Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0) newCommentUpdate = await this._fetchPostCommentUpdateIpfsP2P(subIpfs, timestampRanges, log, abortSignal);
@@ -28912,6 +28949,8 @@ var CommentClientsManager = class extends PublicationClientsManager {
28912
28949
  }
28913
28950
  }
28914
28951
  return;
28952
+ } finally {
28953
+ linkedAbortSignal.dispose();
28915
28954
  }
28916
28955
  if (newCommentUpdate) this._useLoadedCommentUpdateIfNewInfo(newCommentUpdate, subIpfs, log);
28917
28956
  else if (newCommentUpdate === void 0) {
@@ -30309,6 +30348,7 @@ var Comment = class extends Publication {
30309
30348
  async stop() {
30310
30349
  this._abortStopOperations(`Aborting comment operations for ${this.cid || this.author?.address || "comment"} because comment.stop() was called`);
30311
30350
  if (this.state === "publishing") await super.stop();
30351
+ else await this._cancelBackgroundCommunityRefresh();
30312
30352
  this._setStateWithEmission("stopped");
30313
30353
  await this._stopUpdateLoop();
30314
30354
  this.replies._stop();
@@ -30781,12 +30821,15 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
30781
30821
  const serverSubscriptionId = this._serverIdByLocalId.get(subscriptionId) ?? subscriptionId;
30782
30822
  this._resubscribeCalls.delete(subscriptionId);
30783
30823
  this._publishSubscriptionIds.delete(subscriptionId);
30784
- if (liveOnServer) await this._webSocketClient.call("unsubscribe", [{ subscriptionId: serverSubscriptionId }]);
30785
- this._serverIdByLocalId.delete(subscriptionId);
30786
- this._localIdByServerId.delete(serverSubscriptionId);
30787
- if (this._subscriptionEvents[subscriptionId]) this._subscriptionEvents[subscriptionId].removeAllListeners();
30788
- delete this._subscriptionEvents[subscriptionId];
30789
- delete this._pendingSubscriptionMsgs[subscriptionId];
30824
+ try {
30825
+ if (liveOnServer) await this._webSocketClient.call("unsubscribe", [{ subscriptionId: serverSubscriptionId }]);
30826
+ } finally {
30827
+ this._serverIdByLocalId.delete(subscriptionId);
30828
+ this._localIdByServerId.delete(serverSubscriptionId);
30829
+ if (this._subscriptionEvents[subscriptionId]) this._subscriptionEvents[subscriptionId].removeAllListeners();
30830
+ delete this._subscriptionEvents[subscriptionId];
30831
+ delete this._pendingSubscriptionMsgs[subscriptionId];
30832
+ }
30790
30833
  }
30791
30834
  _attachNotificationHandler() {
30792
30835
  const socket = this._webSocketClient.socket;
@@ -35902,7 +35945,7 @@ var PKC$1 = class extends PKCTypedEmitter {
35902
35945
  this.clients.libp2pJsClients = {};
35903
35946
  if (!this.libp2pJsClientsOptions) return;
35904
35947
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
35905
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-D8Yy6QjO.js");
35948
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-pBsoz9YH.js");
35906
35949
  for (const clientOptions of this.libp2pJsClientsOptions) {
35907
35950
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
35908
35951
  ...clientOptions,
@@ -36267,7 +36310,7 @@ var PKC$1 = class extends PKCTypedEmitter {
36267
36310
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
36268
36311
  log.trace("Received community options to create a local community instance:", options);
36269
36312
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
36270
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-3TpfDDKX.js");
36313
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-B9D4Iu_Q.js");
36271
36314
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
36272
36315
  const community = new LocalCommunity(this);
36273
36316
  if (isLocalCommunity) {
@@ -36635,8 +36678,11 @@ var PKC$1 = class extends PKCTypedEmitter {
36635
36678
  return this._destroyAbortController.signal;
36636
36679
  }
36637
36680
  _combineWithDestroyAbortSignal(abortSignal) {
36638
- const destroySignal = this._getDestroyAbortSignal();
36639
- return abortSignal ? AbortSignal.any([abortSignal, destroySignal]) : destroySignal;
36681
+ const linked = linkAbortSignals([abortSignal, this._getDestroyAbortSignal()]);
36682
+ return {
36683
+ signal: linked.signal,
36684
+ dispose: linked.dispose
36685
+ };
36640
36686
  }
36641
36687
  async destroy() {
36642
36688
  const log = logger_default("pkc-js:pkc:destroy");
@@ -36790,8 +36836,9 @@ var PKCWithRpcClient = class extends PKC$1 {
36790
36836
  async getComment(getCommentArgs) {
36791
36837
  const { abortSignal, ...cidArgs } = getCommentArgs;
36792
36838
  const parsedArgs = parseRpcCidParam(cidArgs);
36839
+ const combined = this._combineWithDestroyAbortSignal(abortSignal);
36793
36840
  const cancellation = rejectWhenAbortSignalFires({
36794
- abortSignal: this._combineWithDestroyAbortSignal(abortSignal),
36841
+ abortSignal: combined.signal,
36795
36842
  error: () => new PKCError("ERR_GET_COMMENT_ABORTED", {
36796
36843
  getCommentArgs: parsedArgs,
36797
36844
  abortReason: abortSignal?.reason
@@ -36802,6 +36849,7 @@ var PKCWithRpcClient = class extends PKC$1 {
36802
36849
  commentIpfs = await Promise.race([this._pkcRpcClient.getComment(parsedArgs), cancellation.promise]);
36803
36850
  } finally {
36804
36851
  cancellation.cleanup();
36852
+ combined.dispose();
36805
36853
  }
36806
36854
  return this.createComment({
36807
36855
  ...parsedArgs,
@@ -36837,7 +36885,7 @@ var PKCWithRpcClient = class extends PKC$1 {
36837
36885
  if (rawRecord) if ("community" in rawRecord) community.initRpcInternalCommunityAfterFirstUpdateNoMerge(rawRecord);
36838
36886
  else community.initRpcInternalCommunityBeforeFirstUpdateNoMerge(rawRecord);
36839
36887
  if (jsonified.raw) Object.assign(community.raw, jsonified.raw);
36840
- await community._attachExportsSubscription();
36888
+ await community._loadExportsSnapshot();
36841
36889
  return community;
36842
36890
  } else if (isCommunityRpcLocal) {
36843
36891
  const community = new RpcLocalCommunity(this);
@@ -36845,9 +36893,10 @@ var PKCWithRpcClient = class extends PKC$1 {
36845
36893
  const updatePromise = new Promise((resolve) => community.once("update", resolve));
36846
36894
  let error;
36847
36895
  const errorPromise = new Promise((resolve) => community.once("error", (err) => resolve(error = err)));
36896
+ const combined = this._combineWithDestroyAbortSignal(opts?.abortSignal);
36848
36897
  const cancellation = rejectWhenCommunityStopsOrAborts({
36849
36898
  community,
36850
- abortSignal: this._combineWithDestroyAbortSignal(opts?.abortSignal)
36899
+ abortSignal: combined.signal
36851
36900
  });
36852
36901
  try {
36853
36902
  await Promise.race([community._createAndSubscribeToNewUpdatingCommunity(community), cancellation.promise]);
@@ -36862,10 +36911,11 @@ var PKCWithRpcClient = class extends PKC$1 {
36862
36911
  throw e;
36863
36912
  } finally {
36864
36913
  cancellation.cleanup();
36914
+ combined.dispose();
36865
36915
  }
36866
36916
  await community.stop();
36867
36917
  if (error) throw error;
36868
- await community._attachExportsSubscription();
36918
+ await community._loadExportsSnapshot();
36869
36919
  return community;
36870
36920
  } else {
36871
36921
  log.trace("Creating a remote RPC community instance with address", effectiveAddress);
@@ -36885,7 +36935,7 @@ var PKCWithRpcClient = class extends PKC$1 {
36885
36935
  await community.initRpcInternalCommunityBeforeFirstUpdateNoMerge(communityPropsAfterCreation);
36886
36936
  community.emit("update", community);
36887
36937
  await this._awaitCommunitiesToIncludeCommunity(communityPropsAfterCreation.localCommunity.address);
36888
- await community._attachExportsSubscription();
36938
+ await community._loadExportsSnapshot();
36889
36939
  return community;
36890
36940
  } else throw Error("Failed to create community rpc instance, are you sure you provided the correct args?");
36891
36941
  }
@@ -1,4 +1,4 @@
1
- import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-DkGqBo7o.js";
1
+ import { gr as isStringDomain, v as getEquivalentCommunityAddresses, xn as PageSortFileSchema } from "./util-DVrZupXz.js";
2
2
  //#region dist/node/pages/page-sort-scoring.js
3
3
  function validatePageSortFile(rawFile) {
4
4
  const validated = PageSortFileSchema.parse(rawFile);
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $r as string, $t as CreateCommunityEditPublicationOptionsWithRefinementSchema, A as isIpnsPath, An as CommentIpfsReservedFields, Ar as e$4, Bn as CommentUpdateSignedPropertyNames, Br as require_supports_color, C as hideClassPrivateProps, Cn as CreateVoteUserOptionsWithRefinementSchema, Cr as t$11, Ct as trackUpdatingCommunity, D as isIpfsCid, Dn as VoteSignedPropertyNames, Dr as r$7, Dt as require_sha256$1, E as isAbortError, Er as n$8, Et as untrackUpdatingCommunity, Fn as CommentUpdateChallengeReservedFieldNames, Fr as FailedToFetchGenericIpfsFromGatewaysError, Ft as ChallengeRequestMessageSignedPropertyNames, Gn as ModQueuePageIpfsSchema, Gr as boolean, Gt as PKCParsedOptionsSchema, Ht as DecryptedChallengeVerificationSchema, Ir as FailedToFetchPageIpfsFromGatewaysError, Jn as CommentEditChallengeRequestToEncryptSchema, Jr as looseObject, K as removeNullUndefinedEmptyObjectsValuesRecursively, Kn as PageIpfsSchema, Kr as custom, Kt as PKCUserOptionBaseSchema, L as isRequestPubsubPublicationOfPost, Ln as CommentUpdateForChallengeVerificationSignedPropertyNames, Lr as PKCError, Lt as ChallengeVerificationMessageSignedPropertyNames, Mr as FailedToFetchCommentIpfsFromGatewaysError, Nn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Nt as ChallengeMessageSignedPropertyNames, O as isIpfsPath, Or as t$10, Pn as CommentSignedPropertyNames, Pr as FailedToFetchCommunityFromGatewaysError, Qn as CommentEditSignedPropertyNames, Qr as record, Qt as CommunityEditPubsubMessagePublicationSchema, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateReservedFields, Rr as messages, Rt as DecryptedChallengeAnswerSchema, S as hasTransientNetworkErrorCode, Sn as RpcRemoteCommunityUpdateEventResultSchema, Sr as e$5, T as ipnsNameToIpnsOverPubsubTopic, Tn as VotePubsubMessagePublicationSchema, Tr as t$12, Un as CreateCommentOptionsWithRefinementSchema, Ur as _enum, Ut as NameResolveCacheOptionsSchema, V as raceAgainstAbort, Vr as require_ms$1, Vt as DecryptedChallengeSchema, Wn as GetPageParamSchema, Wr as array, Wt as NameResolverSerializedSchema, Xn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Xr as object, Yr as number, Yt as CommunityEditPublicationChallengeRequestToEncryptSchema, Zr as preprocess, Zt as CommunityEditPublicationSignedPropertyNames, _n as CreateRpcCommunityFunctionArgumentSchema, an as CreateCommentModerationOptionsWithRefinementSchema, ar as ChallengeAnswersSchema, at as timestamp, bn as PageSortFileSchema, br as t$13, cr as CommunityAddressSchema, d as deepMergeRuntimeFields, dn as CommunityExportRecordsSchema, dr as JsonSignatureSchema, dt as findStartedCommunity, ei as union, en as CommentModerationChallengeRequestToEncryptSchema, er as CreateCommentEditOptionsWithRefinementSchema, et as shortifyAddress, f as derivePublicationFromChallengeRequest, fn as CommunityIpfsReservedFields, fr as PKCTimestampSchema, gn as CreateRemoteCommunityFunctionArgumentSchema, gr as n$9, h as fetchAndValidateIpnsRecordFromGateway, hn as CreateNewLocalCommunityUserOptionsSchema, hr as isStringDomain, in as CommentModerationsTableRowSchema, ir as AuthorReservedFields, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$2, jt as ChallengeAnswerMessageSignedPropertyNames, k as isIpns, kn as CommentChallengeRequestToEncryptSchema, kr as t$9, kt as pTimeout, ln as CommunityChallengeSettingSchema, lr as CommunityAuthorChallengeReservedFieldNames, m as extractNetworkErrorDetails, mn as CommunitySignedPropertyNames, mr as areEquivalentNames, mt as forgetTrackedUpdatingCommunityName, nr as AuthorCommentIpfsReservedFields, nt as sleepUntilTimeoutOrAbort, on as ChallengeFileFactorySchema, or as CidPathSchema, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pr as ProtocolVersionSchema, pt as findUpdatingCommunity, qn as isReservedObjectKey, qr as literal, qt as PKCUserOptionsSchema, r as calculateIpfsCidV0, rn as CommentModerationSignedPropertyNames, rr as AuthorPubsubSchema, sn as ChallengeFileSchema, sr as CidStringSchema, t as areEquivalentCommunityAddresses, tn as CommentModerationPubsubMessagePublicationSchema, tr as AuthorAddressSchema, tt as shortifyCid, u as createAbortError, un as CommunityEditOptionsSchema, ur as CreateSignerSchema, vn as ExportCommunityModLogsOptionsSchema, vr as n$10, w as interruptibleSleep, wn as VoteChallengeRequestToEncryptSchema, wr as r$8, wt as untrackStartedCommunity, xr as e$6, xt as trackStartedCommunity, yn as PageSortFileFactorySchema, yt as refreshTrackedCommunityAliases, z as pubsubTopicToDhtKey, zn as CommentUpdateSchema, zr as logger_default } from "./util-DkGqBo7o.js";
2
+ import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-DVrZupXz.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
- import { s as validatePageSortFile } from "./page-sort-scoring-I74ngMaI.js";
4
+ import { s as validatePageSortFile } from "./page-sort-scoring-2Q6exRbl.js";
5
5
  import { createHash } from "node:crypto";
6
6
  import { pathToFileURL } from "node:url";
7
7
  import dns from "node:dns";
@@ -148259,7 +148259,8 @@ var BaseClientsManager = class BaseClientsManager {
148259
148259
  }
148260
148260
  }
148261
148261
  async pubsubUnsubscribe(pubsubTopic, handler) {
148262
- for (const pubsubProviderUrl of t$13(this._pkc.clients.pubsubKuboRpcClients)) try {
148262
+ const libp2pJsProvidersWithTopic = t$13(this._pkc.clients.libp2pJsClients).filter((key) => this.pubsubProviderSubscriptions[key]?.includes(pubsubTopic));
148263
+ for (const pubsubProviderUrl of [...t$13(this._pkc.clients.pubsubKuboRpcClients), ...libp2pJsProvidersWithTopic]) try {
148263
148264
  await this.pubsubUnsubscribeOnProvider(pubsubTopic, pubsubProviderUrl, handler);
148264
148265
  } catch (e) {
148265
148266
  await this._pkc._stats.recordGatewayFailure(pubsubProviderUrl, "pubsub-unsubscribe");
@@ -149782,10 +149783,24 @@ var BasePagesClientsManager = class extends BaseClientsManager {
149782
149783
  const isFirstPage = Object.values(this._pages.pageCids).includes(pageCid) || e$5(this._pages.pageCids);
149783
149784
  const pageMaxSize = opts.pageMaxSize ? opts.pageMaxSize : this._pkc._memCaches.pagesMaxSize.get(this._calculatePageMaxSizeCacheKey(pageCid)) ? this._pkc._memCaches.pagesMaxSize.get(this._calculatePageMaxSizeCacheKey(pageCid)) : isFirstPage ? 1024 * 1024 : void 0;
149784
149785
  if (!pageMaxSize) throw Error("Failed to calculate max page size. Is this page cid under the correct community/comment?");
149785
- const destroySignal = this._pkc._getDestroyAbortSignal();
149786
- const signals = [opts.abortSignal, destroySignal].filter((s) => Boolean(s));
149787
- const combinedSignal = signals.length === 1 ? signals[0] : AbortSignal.any(signals);
149788
- throwIfAbortSignalAborted(combinedSignal);
149786
+ const linked = linkAbortSignals([opts.abortSignal, this._pkc._getDestroyAbortSignal()]);
149787
+ const combinedSignal = linked.signal;
149788
+ try {
149789
+ throwIfAbortSignalAborted(combinedSignal);
149790
+ return await this._fetchPageAfterSignalCombined({
149791
+ pageCid,
149792
+ log,
149793
+ pageMaxSize,
149794
+ isFirstPage,
149795
+ sortTypesFromPageCids,
149796
+ sortTypesFromMemcache,
149797
+ combinedSignal
149798
+ });
149799
+ } finally {
149800
+ linked.dispose();
149801
+ }
149802
+ }
149803
+ async _fetchPageAfterSignalCombined({ pageCid, log, pageMaxSize, isFirstPage, sortTypesFromPageCids, sortTypesFromMemcache, combinedSignal }) {
149789
149804
  let result;
149790
149805
  try {
149791
149806
  if (this._pkc._pkcRpcClient) result = await this._fetchPageWithRpc({
@@ -155910,12 +155925,19 @@ function cloneExportRecord(record) {
155910
155925
  ...record.error ? { error: { ...record.error } } : {}
155911
155926
  };
155912
155927
  }
155928
+ function isTerminalExportRecord(record) {
155929
+ return record.progress === 1 || Boolean(record.error);
155930
+ }
155913
155931
  var RpcLocalCommunity = class extends RpcRemoteCommunity {
155914
155932
  constructor(pkc) {
155915
155933
  super(pkc);
155916
155934
  this.raw = {};
155917
155935
  this._startRpcSubscriptionId = void 0;
155918
155936
  this._exportsSubscriptionId = void 0;
155937
+ this._exportsSubscriptionManaged = false;
155938
+ this._exportsSubscriptionSyncQueue = Promise.resolve();
155939
+ this._pendingExportCalls = 0;
155940
+ this._inFlightExportIds = /* @__PURE__ */ new Set();
155919
155941
  this._exportsCache = [];
155920
155942
  this._exportSignalDetachers = /* @__PURE__ */ new Map();
155921
155943
  this.started = false;
@@ -155926,6 +155948,13 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
155926
155948
  this.on("update", () => {
155927
155949
  this.editable = t$2(this, t$13(CommunityEditOptionsSchema.shape));
155928
155950
  });
155951
+ this.on("statechange", () => this._scheduleExportsSubscriptionSync());
155952
+ const emitter = this;
155953
+ const onListenerChange = (eventName) => {
155954
+ if (eventName === "exportschange") this._scheduleExportsSubscriptionSync();
155955
+ };
155956
+ emitter.on("newListener", onListenerChange);
155957
+ emitter.on("removeListener", onListenerChange);
155929
155958
  hideClassPrivateProps(this);
155930
155959
  }
155931
155960
  toJSONInternalRpcAfterFirstUpdate() {
@@ -156116,6 +156145,7 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
156116
156145
  this._setRpcClientStateWithEmission("stopped");
156117
156146
  this.started = false;
156118
156147
  untrackStartedCommunity(this._pkc, this);
156148
+ await this._releaseExportsSubscriptionIfUnneeded();
156119
156149
  }
156120
156150
  async prepareAnchorPublish() {
156121
156151
  return this._pkc._pkcRpcClient.prepareAnchorPublish({
@@ -156133,6 +156163,17 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
156133
156163
  return result;
156134
156164
  }
156135
156165
  async stop() {
156166
+ await this._stopRunOrUpdate();
156167
+ await this._releaseExportsSubscriptionIfUnneeded();
156168
+ }
156169
+ async _releaseExportsSubscriptionIfUnneeded() {
156170
+ try {
156171
+ await this._syncExportsSubscription();
156172
+ } catch (e) {
156173
+ logger_default("pkc-js:rpc-local-community:exports").error("Failed to sync the exports subscription on stop", this.address, e);
156174
+ }
156175
+ }
156176
+ async _stopRunOrUpdate() {
156136
156177
  this.posts._stop();
156137
156178
  if (this.state === "updating") return super.stop();
156138
156179
  else if (this.state === "started") {
@@ -156188,12 +156229,24 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
156188
156229
  async export(options = {}) {
156189
156230
  if (options.exportPath !== void 0) throw new PKCError("ERR_EXPORT_PATH_NOT_SUPPORTED_OVER_RPC", { address: this.address });
156190
156231
  if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
156191
- const { exportId } = await this._pkc._pkcRpcClient.exportCommunity({
156192
- name: this.name,
156193
- publicKey: this.publicKey,
156194
- includePrivateKey: options.includePrivateKey
156195
- });
156196
- if (options.signal) {
156232
+ this._pendingExportCalls++;
156233
+ let exportId;
156234
+ let alreadyTerminal = false;
156235
+ try {
156236
+ await this._syncExportsSubscription();
156237
+ ({exportId} = await this._pkc._pkcRpcClient.exportCommunity({
156238
+ name: this.name,
156239
+ publicKey: this.publicKey,
156240
+ includePrivateKey: options.includePrivateKey
156241
+ }));
156242
+ const knownRecord = this._exportsCache.find((rec) => rec.exportId === exportId);
156243
+ alreadyTerminal = knownRecord !== void 0 && isTerminalExportRecord(knownRecord);
156244
+ if (!alreadyTerminal) this._inFlightExportIds.add(exportId);
156245
+ } finally {
156246
+ this._pendingExportCalls--;
156247
+ this._scheduleExportsSubscriptionSync();
156248
+ }
156249
+ if (options.signal && !alreadyTerminal) {
156197
156250
  const userSignal = options.signal;
156198
156251
  const onAbort = () => {
156199
156252
  this._pkc._pkcRpcClient.cancelExport({ exportId }).catch((e) => {
@@ -156215,6 +156268,38 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
156215
156268
  ...opts
156216
156269
  });
156217
156270
  }
156271
+ async _loadExportsSnapshot() {
156272
+ this._exportsSubscriptionManaged = true;
156273
+ await this._syncExportsSubscription({ loadSnapshot: true });
156274
+ }
156275
+ _needsLiveExports() {
156276
+ if (this._pkc.destroyed) return false;
156277
+ return this.state !== "stopped" || this._pendingExportCalls > 0 || this._inFlightExportIds.size > 0 || this.listenerCount("exportschange") > 0;
156278
+ }
156279
+ _syncExportsSubscription(opts) {
156280
+ const run = async () => {
156281
+ if (!this._exportsSubscriptionManaged) return;
156282
+ if ((this._needsLiveExports() || opts?.loadSnapshot) && this._exportsSubscriptionId === void 0 && !this._pkc.destroyed) await this._attachExportsSubscription();
156283
+ if (!this._needsLiveExports() && this._exportsSubscriptionId !== void 0) await this._detachExportsSubscription();
156284
+ };
156285
+ const result = this._exportsSubscriptionSyncQueue.then(run);
156286
+ this._exportsSubscriptionSyncQueue = result.catch(() => void 0);
156287
+ return result;
156288
+ }
156289
+ _scheduleExportsSubscriptionSync() {
156290
+ if (!this._exportsSubscriptionManaged) return;
156291
+ this._syncExportsSubscription().catch((e) => logger_default("pkc-js:rpc-local-community:exports").error("Failed to sync the exports subscription", this.address, e));
156292
+ }
156293
+ async _detachExportsSubscription() {
156294
+ const subscriptionId = this._exportsSubscriptionId;
156295
+ this._exportsSubscriptionId = void 0;
156296
+ if (subscriptionId === void 0) return;
156297
+ try {
156298
+ await this._pkc._pkcRpcClient.unsubscribe(subscriptionId);
156299
+ } catch (e) {
156300
+ logger_default("pkc-js:rpc-local-community:exports").error("Failed to unsubscribe from exportsSubscribe", this.address, e);
156301
+ }
156302
+ }
156218
156303
  async _attachExportsSubscription() {
156219
156304
  if (this._exportsSubscriptionId !== void 0) return;
156220
156305
  if (!this._pkc._pkcRpcClient) return;
@@ -156246,7 +156331,12 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
156246
156331
  }
156247
156332
  });
156248
156333
  this._pkc._pkcRpcClient.emitAllPendingMessages(subscriptionId);
156249
- await initialReceived;
156334
+ try {
156335
+ await initialReceived;
156336
+ } catch (e) {
156337
+ if (this._exportsSubscriptionId === subscriptionId) await this._detachExportsSubscription();
156338
+ throw e;
156339
+ }
156250
156340
  }
156251
156341
  _absorbExportRecords(wireRecords) {
156252
156342
  const httpOrigin = this._pkc._pkcRpcClient.rpcHttpOrigin;
@@ -156264,7 +156354,16 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
156264
156354
  this._exportSignalDetachers.delete(rec.exportId);
156265
156355
  }
156266
156356
  }
156357
+ let inFlightChanged = false;
156358
+ for (const exportId of [...this._inFlightExportIds]) {
156359
+ const rec = wireRecords.find((r) => r.exportId === exportId);
156360
+ if (!rec || isTerminalExportRecord(rec)) {
156361
+ this._inFlightExportIds.delete(exportId);
156362
+ inFlightChanged = true;
156363
+ }
156364
+ }
156267
156365
  this.emit("exportschange", this._exportsCache.map(cloneExportRecord));
156366
+ if (inFlightChanged) this._scheduleExportsSubscriptionSync();
156268
156367
  }
156269
156368
  async delete() {
156270
156369
  const startedCommunity = findStartedCommunity(this._pkc, {