@pkcprotocol/pkc-js 0.0.127 → 0.0.129

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 (130) hide show
  1. package/README.md +16 -5
  2. package/dist/browser/clients/base-client-manager.d.ts +8 -0
  3. package/dist/browser/clients/base-client-manager.js +39 -2
  4. package/dist/browser/clients/base-client-manager.js.map +1 -1
  5. package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +2 -2
  6. package/dist/browser/clients/rpc-client/pkc-rpc-client.js +8 -3
  7. package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  8. package/dist/browser/clients/rpc-client/schema.d.ts +10 -1
  9. package/dist/browser/clients/rpc-client/schema.js +8 -1
  10. package/dist/browser/clients/rpc-client/schema.js.map +1 -1
  11. package/dist/browser/clients/rpc-client/types.d.ts +5 -1
  12. package/dist/browser/community/communities-entry-util.d.ts +14 -0
  13. package/dist/browser/community/communities-entry-util.js +20 -0
  14. package/dist/browser/community/communities-entry-util.js.map +1 -0
  15. package/dist/browser/community/community-client-manager.js +2 -1
  16. package/dist/browser/community/community-client-manager.js.map +1 -1
  17. package/dist/browser/errors.d.ts +1 -0
  18. package/dist/browser/errors.js +1 -0
  19. package/dist/browser/errors.js.map +1 -1
  20. package/dist/browser/generated-version.d.ts +1 -1
  21. package/dist/browser/generated-version.js +1 -1
  22. package/dist/browser/helia/helia-for-pkc.js +88 -22
  23. package/dist/browser/helia/helia-for-pkc.js.map +1 -1
  24. package/dist/browser/helia/types.d.ts +4 -1
  25. package/dist/browser/pkc/pkc-with-rpc-client.d.ts +2 -0
  26. package/dist/browser/pkc/pkc-with-rpc-client.js +66 -3
  27. package/dist/browser/pkc/pkc-with-rpc-client.js.map +1 -1
  28. package/dist/browser/pkc/pkc.d.ts +5 -3
  29. package/dist/browser/pkc/pkc.js +15 -10
  30. package/dist/browser/pkc/pkc.js.map +1 -1
  31. package/dist/browser/pkc-error.d.ts +1 -1
  32. package/dist/browser/publications/comment/comment-client-manager.d.ts +5 -2
  33. package/dist/browser/publications/comment/comment-client-manager.js +104 -40
  34. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  35. package/dist/browser/publications/comment/comment.d.ts +4 -0
  36. package/dist/browser/publications/comment/comment.js +4 -0
  37. package/dist/browser/publications/comment/comment.js.map +1 -1
  38. package/dist/browser/rpc/src/index.js +10 -8
  39. package/dist/browser/rpc/src/index.js.map +1 -1
  40. package/dist/browser/runtime/browser/util.d.ts +1 -0
  41. package/dist/browser/runtime/browser/util.js +3 -0
  42. package/dist/browser/runtime/browser/util.js.map +1 -1
  43. package/dist/browser/runtime/node/community/db-handler.js +2 -4
  44. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  45. package/dist/browser/runtime/node/community/local-community/editing.js +13 -6
  46. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  47. package/dist/browser/runtime/node/community/local-community.js +9 -1
  48. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  49. package/dist/browser/runtime/node/community/start-lock.d.ts +8 -0
  50. package/dist/browser/runtime/node/community/start-lock.js +18 -0
  51. package/dist/browser/runtime/node/community/start-lock.js.map +1 -0
  52. package/dist/browser/runtime/node/util.d.ts +6 -0
  53. package/dist/browser/runtime/node/util.js +106 -8
  54. package/dist/browser/runtime/node/util.js.map +1 -1
  55. package/dist/browser/test/test-util.d.ts +20 -0
  56. package/dist/browser/test/test-util.js +25 -0
  57. package/dist/browser/test/test-util.js.map +1 -1
  58. package/dist/browser/types.d.ts +7 -3
  59. package/dist/bundled/bundle-manifest.json +47 -45
  60. package/dist/bundled/challenges.js +1 -1
  61. package/dist/bundled/chunks/{helia-for-pkc-BsXEDYPa.js → helia-for-pkc-Cg_zH9dT.js} +67 -13
  62. package/dist/bundled/chunks/{local-community-FekHR-fd.js → local-community-CufTrjaK.js} +1 -1
  63. package/dist/bundled/chunks/{local-community-WFQoW5aC.js → local-community-Gj16RMFM.js} +18 -1381
  64. package/dist/bundled/chunks/{node-pIjburtc.js → node-jDoQBCgW.js} +179 -43
  65. package/dist/bundled/chunks/{page-sort-scoring-Civ7TOoF.js → page-sort-scoring-B53_j_WT.js} +1 -1
  66. package/dist/bundled/chunks/{rpc-local-community-BqP9g2Rk.js → rpc-local-community-9DP4Rskv.js} +1604 -51
  67. package/dist/bundled/chunks/{util-D5Y6i3Nn.js → util-CxVo5EMD.js} +1 -1
  68. package/dist/bundled/chunks/{util-VrWyIc1x.js → util-D7gst5MT.js} +20 -19
  69. package/dist/bundled/chunks/{validate-package-factories-CJgjDTZC.js → validate-package-factories-D2LBnQVu.js} +2 -2
  70. package/dist/bundled/index.js +1 -1
  71. package/dist/bundled/page-sorts.js +1 -1
  72. package/dist/bundled/rpc/src/index.js +10 -9
  73. package/dist/node/clients/base-client-manager.d.ts +8 -0
  74. package/dist/node/clients/base-client-manager.js +39 -2
  75. package/dist/node/clients/base-client-manager.js.map +1 -1
  76. package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +2 -2
  77. package/dist/node/clients/rpc-client/pkc-rpc-client.js +8 -3
  78. package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  79. package/dist/node/clients/rpc-client/schema.d.ts +10 -1
  80. package/dist/node/clients/rpc-client/schema.js +8 -1
  81. package/dist/node/clients/rpc-client/schema.js.map +1 -1
  82. package/dist/node/clients/rpc-client/types.d.ts +5 -1
  83. package/dist/node/community/communities-entry-util.d.ts +14 -0
  84. package/dist/node/community/communities-entry-util.js +20 -0
  85. package/dist/node/community/communities-entry-util.js.map +1 -0
  86. package/dist/node/community/community-client-manager.js +2 -1
  87. package/dist/node/community/community-client-manager.js.map +1 -1
  88. package/dist/node/errors.d.ts +1 -0
  89. package/dist/node/errors.js +1 -0
  90. package/dist/node/errors.js.map +1 -1
  91. package/dist/node/generated-version.d.ts +1 -1
  92. package/dist/node/generated-version.js +1 -1
  93. package/dist/node/helia/helia-for-pkc.js +88 -22
  94. package/dist/node/helia/helia-for-pkc.js.map +1 -1
  95. package/dist/node/helia/types.d.ts +4 -1
  96. package/dist/node/pkc/pkc-with-rpc-client.d.ts +2 -0
  97. package/dist/node/pkc/pkc-with-rpc-client.js +66 -3
  98. package/dist/node/pkc/pkc-with-rpc-client.js.map +1 -1
  99. package/dist/node/pkc/pkc.d.ts +5 -3
  100. package/dist/node/pkc/pkc.js +15 -10
  101. package/dist/node/pkc/pkc.js.map +1 -1
  102. package/dist/node/pkc-error.d.ts +1 -1
  103. package/dist/node/publications/comment/comment-client-manager.d.ts +5 -2
  104. package/dist/node/publications/comment/comment-client-manager.js +104 -40
  105. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  106. package/dist/node/publications/comment/comment.d.ts +4 -0
  107. package/dist/node/publications/comment/comment.js +4 -0
  108. package/dist/node/publications/comment/comment.js.map +1 -1
  109. package/dist/node/rpc/src/index.js +10 -8
  110. package/dist/node/rpc/src/index.js.map +1 -1
  111. package/dist/node/runtime/browser/util.d.ts +1 -0
  112. package/dist/node/runtime/browser/util.js +3 -0
  113. package/dist/node/runtime/browser/util.js.map +1 -1
  114. package/dist/node/runtime/node/community/db-handler.js +2 -4
  115. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  116. package/dist/node/runtime/node/community/local-community/editing.js +13 -6
  117. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  118. package/dist/node/runtime/node/community/local-community.js +9 -1
  119. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  120. package/dist/node/runtime/node/community/start-lock.d.ts +8 -0
  121. package/dist/node/runtime/node/community/start-lock.js +18 -0
  122. package/dist/node/runtime/node/community/start-lock.js.map +1 -0
  123. package/dist/node/runtime/node/util.d.ts +6 -0
  124. package/dist/node/runtime/node/util.js +106 -8
  125. package/dist/node/runtime/node/util.js.map +1 -1
  126. package/dist/node/test/test-util.d.ts +20 -0
  127. package/dist/node/test/test-util.js +25 -0
  128. package/dist/node/test/test-util.js.map +1 -1
  129. package/dist/node/types.d.ts +7 -3
  130. 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, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nn as CommentIpfsSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rn as CommentUpdateForChallengeVerificationSchema, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, Vn as CommentUpdateSchema, 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, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jr as require_retry, 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, t as areEquivalentCommunityAddresses, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wn as isStringDomain, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zr as logger_default } from "./util-VrWyIc1x.js";
3
- import { $n as getCommunityAddressFromRecord, $t as RpcPublishCommunityListResultSchema, A as findCommentInParsedPages, An as verifyChallengeMessage, Ar as t$5, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityList, Br as NAME_RESOLVED_FALSE_TTL_MS, Bt as RpcCommunityPageParamSchema, C as RepliesPages, Cr as listCommunitiesSync, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityList, Dt as parseJsonWithPKCErrorIfFails, En as signCommunityEdit, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentModeration, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromWire, Gr as nativeFunctions$2, Gt as RpcExportCommunityResultSchema, H as InflightResourceTypes, Hn as buildRuntimeAuthor, Hr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Ht as RpcExportCommunityModLogsParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentPubsubMessage, Ir as t$2, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateNewCommunityListOptionsSchema, Jt as RpcFetchCommunityListParamSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as normalizeCreatePublicationAuthor, Kr as require_undici, Kt as RpcFetchCidParamSchema, Ln as verifyCommentUpdate, Lr as t$4, Lt as RpcCidParamSchema, M as parseRawPages, Mn as verifyChallengeVerification, Nn as verifyCommentEdit, Nr as t$3, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signVote, Or as setNativeFunctions$1, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentIpfs, Pr as n$3, Pt as RpcAnchorPublishPreparationResultSchema, Qn as buildRuntimeCommunityFields, Qt as RpcPublishCommunityListParamSchema, R as stripNameResolvedFromCrosspost, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentModeration, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tt as parseDecryptedChallengeVerification, Un as cleanWireAuthor, Ut as RpcExportCommunityModLogsResultSchema, V as InflightFetchManager, Vn as verifyVote, Vr as NAME_RESOLVED_TRUE_TTL_MS, Vt as RpcEditCommunityParamSchema, Wn as getAuthorNameFromRuntime, Wt as RpcExportCommunityParamSchema, Xt as RpcPublishAnchorRecordParamSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as MAX_COMMUNITY_LIST_SIZE_BYTES, Yt as RpcFetchCommunityListResultSchema, Zt as RpcPublishChallengeAnswersParamSchema, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as findCommunityRecordNameMismatch, ar as getBufferedPKCAddressFromPublicKey, b as KeyvBetterSqlite3, bn as signComment, br as getDefaultDataPath, cn as createSigner, cr as getPKCAddressFromPublicKeySync, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, en as RpcPublishedAnchorRecordResultSchema, er as getCommunityNameFromWire, et as parseCidStringSchemaWithPKCErrorIfItFails, fn as encryptEd25519AesGcm, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as signChallengeAnswer, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hn as cleanUpBeforePublishing, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcUnsubscribeParamSchema, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createAnchorIpnsRecord$1, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mr as createKuboRpcClient, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcSubscriptionIdResultSchema, nr as normalizeCommunityInputFromCommunity, on as require_lib$1, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, q as decodeRpcChallengePubsubMsg, qn as CreateCommunityListWithCidOptionsSchema, qt as RpcFetchCidResultSchema, rn as RpcSuccessResultSchema, rr as decode, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcResolveAuthorNameResultSchema, tr as getCommunityPublicKeyFromWire, un as decryptEd25519AesGcm, v as TrackedInstanceRegistry, vn as signChallengeRequest, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wr as monitorCommunitiesDirectory, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signCommentEdit, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, z as PKCClientsManager, zn as verifyCommunityEdit, zr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, zt as RpcCommunityIdentifierParamSchema } from "./rpc-local-community-BqP9g2Rk.js";
4
- import { s as getHeliaDebugContext } from "./util-D5Y6i3Nn.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, 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-D7gst5MT.js";
3
+ import { $n as buildRuntimeCommunityFields, $r as require_undici, $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-9DP4Rskv.js";
4
+ import { s as getHeliaDebugContext } from "./util-CxVo5EMD.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -1560,24 +1560,78 @@ var CommentClientsManager = class extends PublicationClientsManager {
1560
1560
  if ("_helia" in kuboRpcOrHelia) this.updateLibp2pJsClientState(newState, kuboRpcOrHelia._libp2pJsClientsOptions.key);
1561
1561
  else this.updateKuboRpcState(newState, kuboRpcOrHelia.url);
1562
1562
  }
1563
- async _fetchPostCommentUpdateIpfsP2P(subIpns, timestampRanges, log) {
1563
+ async _isPostUpdateFileAlreadyJudged(folderCid, path, log, abortSignal) {
1564
+ const judged = this._comment._lastJudgedPostUpdate;
1565
+ if (judged?.path === path) return {
1566
+ alreadyJudged: true,
1567
+ cid: judged.cid
1568
+ };
1569
+ const cid = await this._resolveIpfsPathToCid({
1570
+ root: folderCid,
1571
+ path: path.slice(folderCid.length + 1),
1572
+ timeoutMs: this._pkc._timeouts["comment-update-ipfs"],
1573
+ abortSignal,
1574
+ log,
1575
+ bitswapSessionSeedScopeIpnsPubsubTopic: this._bitswapSessionSeedScopeIpnsPubsubTopic()
1576
+ });
1577
+ if (cid === void 0 || cid !== judged?.cid) return {
1578
+ alreadyJudged: false,
1579
+ cid
1580
+ };
1581
+ this._comment._lastJudgedPostUpdate = {
1582
+ path,
1583
+ cid
1584
+ };
1585
+ return {
1586
+ alreadyJudged: true,
1587
+ cid
1588
+ };
1589
+ }
1590
+ _markRecordPostUpdateJudgedIfItsPagesHoldTheHeldUpdate(community) {
1591
+ const record = community.raw.communityIpfs;
1592
+ const postCid = this._comment.postCid;
1593
+ const heldUpdatedAt = this._comment.raw?.commentUpdate?.updatedAt;
1594
+ if (!record?.postUpdates || !postCid || !this._comment.cid || typeof this._comment.timestamp !== "number") return false;
1595
+ const inRecordPages = findCommentInPageInstance(community.posts, this._comment.cid);
1596
+ if (!inRecordPages || inRecordPages.commentUpdate.updatedAt !== heldUpdatedAt) return false;
1597
+ const [timestampRange] = getPostUpdateTimestampRange(record.postUpdates, this._comment.timestamp);
1598
+ if (!timestampRange) return false;
1599
+ const path = this._calculatePathForPostCommentUpdate(record.postUpdates[timestampRange], postCid);
1600
+ if (this._comment._lastJudgedPostUpdate?.path !== path) this._comment._lastJudgedPostUpdate = {
1601
+ path,
1602
+ cid: void 0
1603
+ };
1604
+ return true;
1605
+ }
1606
+ _isNotNewerThanHeldCommentUpdate(commentUpdate) {
1607
+ return commentUpdate.updatedAt <= (this._comment.raw?.commentUpdate?.updatedAt || 0);
1608
+ }
1609
+ async _fetchPostCommentUpdateIpfsP2P(subIpns, timestampRanges, log, abortSignal) {
1564
1610
  const attemptedPathsToLoadErrors = {};
1565
1611
  const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
1566
- if (timestampRanges.some((timestampRange) => {
1567
- if (!this._comment._commentUpdateIpfsPath) return false;
1568
- return subIpns.postUpdates[timestampRange] === this._comment._commentUpdateIpfsPath.split("/")[0];
1569
- })) {
1570
- log("Comment", this._comment.cid, "last post update range has same folder cid", this._comment._commentUpdateIpfsPath, "will be skipping loading CommentUpdate");
1571
- return;
1572
- }
1573
- this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
1574
1612
  for (const timestampRange of timestampRanges) {
1575
1613
  const folderCid = subIpns.postUpdates[timestampRange];
1576
1614
  const path = this._calculatePathForPostCommentUpdate(folderCid, this._comment.postCid);
1615
+ throwIfAbortSignalAborted(abortSignal);
1616
+ let judgedLookup;
1617
+ try {
1618
+ judgedLookup = await this._isPostUpdateFileAlreadyJudged(folderCid, path, log, abortSignal);
1619
+ } catch (e) {
1620
+ throwIfAbortSignalAborted(abortSignal);
1621
+ log.trace(`Timed out resolving CommentUpdate path (${path}) with IPFS P2P. Trying the next timestamp range`);
1622
+ attemptedPathsToLoadErrors[path] = e;
1623
+ continue;
1624
+ }
1625
+ const { alreadyJudged, cid } = judgedLookup;
1626
+ throwIfAbortSignalAborted(abortSignal);
1627
+ if (alreadyJudged) {
1628
+ log.trace("Comment", this._comment.cid, "already judged the CommentUpdate at", path, "skipping it");
1629
+ return;
1630
+ }
1631
+ this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
1577
1632
  this._updateKuboRpcClientOrHeliaState("fetching-update-ipfs", kuboRpcOrHelia);
1578
1633
  let res;
1579
1634
  const commentUpdateTimeoutMs = this._pkc._timeouts["comment-update-ipfs"];
1580
- const abortSignal = this._combinedAbortSignalForRetry();
1581
1635
  try {
1582
1636
  res = await this._retryTransientP2PFetch(() => this._fetchCidP2P(path, {
1583
1637
  maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
@@ -1590,6 +1644,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
1590
1644
  context: `post-update ${path}`
1591
1645
  });
1592
1646
  } catch (e) {
1647
+ throwIfAbortSignalAborted(abortSignal);
1593
1648
  log.trace(`Failed to fetch CommentUpdate from path (${path}) with IPFS P2P. Trying the next timestamp range`);
1594
1649
  attemptedPathsToLoadErrors[path] = e;
1595
1650
  continue;
@@ -1598,13 +1653,23 @@ var CommentClientsManager = class extends PublicationClientsManager {
1598
1653
  }
1599
1654
  try {
1600
1655
  const commentUpdate = parseCommentUpdateSchemaWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(res));
1656
+ if (this._isNotNewerThanHeldCommentUpdate(commentUpdate)) {
1657
+ this._comment._lastJudgedPostUpdate = {
1658
+ path,
1659
+ cid
1660
+ };
1661
+ this._logIgnoredNotNewerPostCommentUpdate(log, path, commentUpdate);
1662
+ return;
1663
+ }
1601
1664
  await this._throwIfCommentUpdateHasInvalidSignature(commentUpdate, subIpns);
1602
- if (commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) return {
1665
+ this._comment._lastJudgedPostUpdate = {
1666
+ path,
1667
+ cid
1668
+ };
1669
+ return {
1603
1670
  commentUpdate,
1604
1671
  commentUpdateIpfsPath: path
1605
1672
  };
1606
- this._logIgnoredNotNewerPostCommentUpdate(log, path, commentUpdate);
1607
- return;
1608
1673
  } catch (e) {
1609
1674
  this._comment._invalidCommentUpdateMfsPaths.add(path);
1610
1675
  if (e instanceof PKCError) e.details = {
@@ -1659,14 +1724,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
1659
1724
  verifyOptions
1660
1725
  });
1661
1726
  }
1662
- async _fetchPostCommentUpdateFromGateways(subIpns, timestampRanges, log) {
1663
- if (timestampRanges.some((timestampRange) => {
1664
- if (!this._comment._commentUpdateIpfsPath) return false;
1665
- return subIpns.postUpdates[timestampRange] === this._comment._commentUpdateIpfsPath.split("/")[0];
1666
- })) {
1667
- log("Comment", this._comment.cid, "last post update range has same folder cid", this._comment._commentUpdateIpfsPath, "will be skipping loading CommentUpdate");
1668
- return;
1669
- }
1727
+ async _fetchPostCommentUpdateFromGateways(subIpns, timestampRanges, log, abortSignal) {
1670
1728
  const attemptedPathsToLoadErrors = {};
1671
1729
  let commentUpdate;
1672
1730
  const validateCommentFromGateway = async (res) => {
@@ -1675,10 +1733,17 @@ var CommentClientsManager = class extends PublicationClientsManager {
1675
1733
  await this._throwIfCommentUpdateHasInvalidSignature(commentUpdateBeforeSignature, subIpns);
1676
1734
  commentUpdate = commentUpdateBeforeSignature;
1677
1735
  };
1678
- this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
1679
1736
  for (const timestampRange of timestampRanges) {
1680
1737
  const folderCid = subIpns.postUpdates[timestampRange];
1681
1738
  const path = this._calculatePathForPostCommentUpdate(folderCid, this._comment.postCid);
1739
+ throwIfAbortSignalAborted(abortSignal);
1740
+ const { alreadyJudged, cid } = await this._isPostUpdateFileAlreadyJudged(folderCid, path, log, abortSignal);
1741
+ throwIfAbortSignalAborted(abortSignal);
1742
+ if (alreadyJudged) {
1743
+ log.trace("Comment", this._comment.cid, "already judged the CommentUpdate at", path, "skipping it");
1744
+ return;
1745
+ }
1746
+ this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
1682
1747
  try {
1683
1748
  await this.fetchFromMultipleGateways({
1684
1749
  recordIpfsType: "ipfs",
@@ -1689,16 +1754,21 @@ var CommentClientsManager = class extends PublicationClientsManager {
1689
1754
  log,
1690
1755
  maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
1691
1756
  timeoutMs: this._pkc._timeouts["comment-update-ipfs"],
1692
- abortSignal: this._comment._getStopAbortSignal()
1757
+ abortSignal
1693
1758
  });
1694
1759
  if (!commentUpdate) throw Error("Failed to load comment update from gateways. This is a critical logic error");
1695
- if (commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) return {
1760
+ this._comment._lastJudgedPostUpdate = {
1761
+ path,
1762
+ cid
1763
+ };
1764
+ if (!this._isNotNewerThanHeldCommentUpdate(commentUpdate)) return {
1696
1765
  commentUpdate,
1697
1766
  commentUpdateIpfsPath: path
1698
1767
  };
1699
1768
  this._logIgnoredNotNewerPostCommentUpdate(log, path, commentUpdate);
1700
1769
  return;
1701
1770
  } catch (e) {
1771
+ throwIfAbortSignalAborted(abortSignal);
1702
1772
  if (this._shouldWeFetchCommentUpdateFromNextTimestamp(e)) {
1703
1773
  attemptedPathsToLoadErrors[path] = e;
1704
1774
  log.trace(`Failed to fetch CommentUpdate from path (${path}) from gateways. Trying the next timestamp range`);
@@ -1742,10 +1812,11 @@ var CommentClientsManager = class extends PublicationClientsManager {
1742
1812
  if (typeof postTimestamp !== "number") throw Error("Post timestamp is not defined by the time we're fetching from postUpdates");
1743
1813
  const timestampRanges = getPostUpdateTimestampRange(subIpfs.postUpdates, postTimestamp);
1744
1814
  if (timestampRanges.length === 0) throw Error("Post has no timestamp range bucket");
1815
+ const abortSignal = this._combinedAbortSignalForRetry();
1745
1816
  let newCommentUpdate;
1746
1817
  try {
1747
- if (Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0) newCommentUpdate = await this._fetchPostCommentUpdateIpfsP2P(subIpfs, timestampRanges, log);
1748
- else newCommentUpdate = await this._fetchPostCommentUpdateFromGateways(subIpfs, timestampRanges, log);
1818
+ 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);
1819
+ else newCommentUpdate = await this._fetchPostCommentUpdateFromGateways(subIpfs, timestampRanges, log, abortSignal);
1749
1820
  } catch (e) {
1750
1821
  if (e instanceof Error) {
1751
1822
  if (isAbortError(e)) return;
@@ -1773,7 +1844,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
1773
1844
  }
1774
1845
  if (newCommentUpdate) this._useLoadedCommentUpdateIfNewInfo(newCommentUpdate, subIpfs, log);
1775
1846
  else if (newCommentUpdate === void 0) {
1776
- log.trace(`Comment`, this._comment.cid, "loaded an old comment update. Ignoring it");
1847
+ log.trace(`Comment`, this._comment.cid, "has no newer CommentUpdate under postUpdates");
1777
1848
  this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
1778
1849
  }
1779
1850
  }
@@ -1981,6 +2052,10 @@ var CommentClientsManager = class extends PublicationClientsManager {
1981
2052
  if (postInUpdatingCommunity && postInUpdatingCommunity.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) {
1982
2053
  const log = logger_default("pkc-js:comment:update:handleUpdateEventFromCommunity:find-comment-update-in-updating-community-or-comments-pages");
1983
2054
  this._useLoadedCommentUpdateIfNewInfo({ commentUpdate: postInUpdatingCommunity.commentUpdate }, community.raw.communityIpfs, log);
2055
+ this._markRecordPostUpdateJudgedIfItsPagesHoldTheHeldUpdate(community);
2056
+ } else if (this._markRecordPostUpdateJudgedIfItsPagesHoldTheHeldUpdate(community)) {
2057
+ log.trace("Comment", this._comment.cid, "is current with the record's pages, nothing to fetch from postUpdates");
2058
+ this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
1984
2059
  } else try {
1985
2060
  await this.useCommunityPostUpdatesToFetchCommentUpdateForPost(community.raw.communityIpfs);
1986
2061
  } catch (e) {
@@ -2293,6 +2368,7 @@ var Comment = class extends Publication {
2293
2368
  this.raw = {};
2294
2369
  this._commentUpdateIpfsPath = void 0;
2295
2370
  this._invalidCommentUpdateMfsPaths = /* @__PURE__ */ new Set();
2371
+ this._lastJudgedPostUpdate = void 0;
2296
2372
  this._commentIpfsloadingOperation = void 0;
2297
2373
  this._updateRpcSubscriptionId = void 0;
2298
2374
  this._stopAbortController = void 0;
@@ -3437,8 +3513,8 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
3437
3513
  this._callTimeoutMs = envCallTimeoutMs > 0 ? envCallTimeoutMs : 3e5;
3438
3514
  this.communities = [];
3439
3515
  this._subscriptionEvents = {};
3440
- this.on("communitieschange", (newSubs) => {
3441
- this.communities = newSubs;
3516
+ this.on("communitieschange", ({ communities }) => {
3517
+ this.communities = communities;
3442
3518
  });
3443
3519
  this.on("settingschange", (newSettings) => {
3444
3520
  this.settings = newSettings;
@@ -3883,7 +3959,12 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
3883
3959
  async initalizeCommunitieschangeEvent() {
3884
3960
  const { subscriptionId } = await this._subscribe("communitiesSubscribe", [], "resubscribe");
3885
3961
  this.getSubscription(subscriptionId).on("communitieschange", (res) => {
3886
- this.emit("communitieschange", res.params.result.communities);
3962
+ const parsed = RpcCommunitiesChangeEventResultSchema.loose().safeParse(res.params.result);
3963
+ if (!parsed.success) return this.emit("error", new PKCError("ERR_INVALID_RPC_COMMUNITIES_SCHEMA", {
3964
+ zodError: parsed.error,
3965
+ result: res.params.result
3966
+ }));
3967
+ this.emit("communitieschange", { communities: parsed.data.communities.map((entry) => toCommunitiesEntry(entry)) });
3887
3968
  });
3888
3969
  this.emitAllPendingMessages(subscriptionId);
3889
3970
  }
@@ -8595,8 +8676,8 @@ var PKC$1 = class extends PKCTypedEmitter {
8595
8676
  pageSorts: this.parsedPKCOptions.pageSorts
8596
8677
  };
8597
8678
  this.nameResolvers = this.pkcRpcClientsOptions ? void 0 : this.parsedPKCOptions.nameResolvers;
8598
- this.on("communitieschange", (newCommunities) => {
8599
- this.communities = newCommunities;
8679
+ this.on("communitieschange", ({ communities }) => {
8680
+ this.communities = communities;
8600
8681
  });
8601
8682
  this._promiseToWaitForFirstCommunitieschangeEvent = new Promise((resolve) => this.once("communitieschange", resolve));
8602
8683
  this.clients = {};
@@ -8669,7 +8750,7 @@ var PKC$1 = class extends PKCTypedEmitter {
8669
8750
  this.clients.libp2pJsClients = {};
8670
8751
  if (!this.libp2pJsClientsOptions) return;
8671
8752
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
8672
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BsXEDYPa.js");
8753
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-Cg_zH9dT.js");
8673
8754
  for (const clientOptions of this.libp2pJsClientsOptions) {
8674
8755
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
8675
8756
  ...clientOptions,
@@ -9014,10 +9095,11 @@ var PKC$1 = class extends PKCTypedEmitter {
9014
9095
  if (!Array.isArray(this.communities)) throw Error("pkc.communities should be defined after communitieschange event");
9015
9096
  }
9016
9097
  async _awaitCommunitiesToIncludeCommunity(communityAddress) {
9017
- if (this.communities.includes(communityAddress)) return;
9098
+ const isListed = () => Boolean(findCommunitiesEntry(this.communities, { address: communityAddress }));
9099
+ if (isListed()) return;
9018
9100
  else await resolveWhenPredicateIsTrue({
9019
9101
  toUpdate: this,
9020
- predicate: () => this.communities.includes(communityAddress),
9102
+ predicate: isListed,
9021
9103
  eventName: "communitieschange"
9022
9104
  });
9023
9105
  }
@@ -9033,7 +9115,7 @@ var PKC$1 = class extends PKCTypedEmitter {
9033
9115
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
9034
9116
  log.trace("Received community options to create a local community instance:", options);
9035
9117
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
9036
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-FekHR-fd.js");
9118
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CufTrjaK.js");
9037
9119
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
9038
9120
  const community = new LocalCommunity(this);
9039
9121
  if (isLocalCommunity) {
@@ -9053,7 +9135,7 @@ var PKC$1 = class extends PKCTypedEmitter {
9053
9135
  } else throw Error("Are you trying to create a local community with no address or signer? This is a critical error");
9054
9136
  }
9055
9137
  async _createCommunityInstanceFromJsonifiedCommunity(jsonfied) {
9056
- if (this.communities.includes(jsonfied.address)) return this._createLocalCommunity(jsonfied);
9138
+ if (findCommunitiesEntry(this.communities, { address: jsonfied.address })) return this._createLocalCommunity(jsonfied);
9057
9139
  else return this._createRemoteCommunityInstance(jsonfied);
9058
9140
  }
9059
9141
  async createCommunity(options = {}, opts) {
@@ -9100,7 +9182,11 @@ var PKC$1 = class extends PKCTypedEmitter {
9100
9182
  log(`Creating a delegated local community with anchor (${anchor.publicKey}) and minter (${minterSigner.address})`);
9101
9183
  return this._createLocalCommunity(localOptions);
9102
9184
  } else if (hasIdentifier && !hasSigner) {
9103
- const localCommunityAddress = (await listCommunitiesSync(this)).find((localAddr) => areEquivalentCommunityAddresses(localAddr, effectiveAddress));
9185
+ const localCommunityAddress = findLocalCommunityAddress(this, {
9186
+ address: parsedOptions.address,
9187
+ name: parsedOptions.name,
9188
+ publicKey: parsedOptions.publicKey
9189
+ });
9104
9190
  if (localCommunityAddress) return this._createLocalCommunity({ address: localCommunityAddress });
9105
9191
  else {
9106
9192
  const parsedRemoteOptions = parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails(options);
@@ -9454,6 +9540,7 @@ var PKC$1 = class extends PKCTypedEmitter {
9454
9540
  const nativeFunctions$1 = { fetch: (...args) => window.fetch(...args) };
9455
9541
  //#endregion
9456
9542
  //#region dist/node/pkc/pkc-with-rpc-client.js
9543
+ const isInvalidCommunitiesListError = (error) => error instanceof PKCError && error.code === "ERR_INVALID_RPC_COMMUNITIES_SCHEMA";
9457
9544
  var PKCWithRpcClient = class extends PKC$1 {
9458
9545
  constructor(options) {
9459
9546
  super(options);
@@ -9463,6 +9550,7 @@ var PKCWithRpcClient = class extends PKC$1 {
9463
9550
  await super._init();
9464
9551
  const log = logger_default("pkc-js:pkc-with-rpc-client:_init");
9465
9552
  this.communities = [];
9553
+ this._waitForFirstValidCommunitiesList();
9466
9554
  this._pkcRpcClient.on("communitieschange", (newSubs) => this.emit("communitieschange", newSubs));
9467
9555
  for (const rpcUrl of Object.keys(this.clients.pkcRpcClients)) {
9468
9556
  const rpcClient = this.clients.pkcRpcClients[rpcUrl];
@@ -9478,6 +9566,27 @@ var PKCWithRpcClient = class extends PKC$1 {
9478
9566
  this.emit("settingschange", newSettings.pkcOptions);
9479
9567
  });
9480
9568
  }
9569
+ _waitForFirstValidCommunitiesList() {
9570
+ this._promiseToWaitForFirstCommunitieschangeEvent = new Promise((resolve, reject) => {
9571
+ const cleanup = () => {
9572
+ this.removeListener("communitieschange", onCommunitiesChange);
9573
+ this._pkcRpcClient.removeListener("error", onRpcError);
9574
+ };
9575
+ const onCommunitiesChange = (event) => {
9576
+ cleanup();
9577
+ resolve(event);
9578
+ };
9579
+ const onRpcError = (error) => {
9580
+ if (!isInvalidCommunitiesListError(error)) return;
9581
+ cleanup();
9582
+ reject(error);
9583
+ this._waitForFirstValidCommunitiesList();
9584
+ };
9585
+ this.on("communitieschange", onCommunitiesChange);
9586
+ this._pkcRpcClient.on("error", onRpcError);
9587
+ });
9588
+ this._promiseToWaitForFirstCommunitieschangeEvent.catch(() => {});
9589
+ }
9481
9590
  async fetchCid(cid) {
9482
9591
  const parsedCid = parseRpcFetchCidParam(cid).cid;
9483
9592
  return this._pkcRpcClient.fetchCid({ cid: parsedCid });
@@ -9486,6 +9595,28 @@ var PKCWithRpcClient = class extends PKC$1 {
9486
9595
  const parsedArgs = parseRpcAuthorNameParam(args);
9487
9596
  return this._pkcRpcClient.resolveAuthorName(parsedArgs);
9488
9597
  }
9598
+ async _awaitCommunitiesToIncludeCommunity(communityAddress) {
9599
+ const isListed = () => Boolean(findCommunitiesEntry(this.communities, { address: communityAddress }));
9600
+ if (isListed()) return;
9601
+ await new Promise((resolve, reject) => {
9602
+ const cleanup = () => {
9603
+ this.removeListener("communitieschange", onCommunitiesChange);
9604
+ this._pkcRpcClient.removeListener("error", onRpcError);
9605
+ };
9606
+ const onCommunitiesChange = () => {
9607
+ if (!isListed()) return;
9608
+ cleanup();
9609
+ resolve();
9610
+ };
9611
+ const onRpcError = (error) => {
9612
+ if (!isInvalidCommunitiesListError(error)) return;
9613
+ cleanup();
9614
+ reject(error);
9615
+ };
9616
+ this.on("communitieschange", onCommunitiesChange);
9617
+ this._pkcRpcClient.on("error", onRpcError);
9618
+ });
9619
+ }
9489
9620
  async destroy() {
9490
9621
  for (const startedCommunity of listStartedCommunities(this)) await startedCommunity.stopWithoutRpcCall();
9491
9622
  await super.destroy();
@@ -9528,7 +9659,12 @@ var PKCWithRpcClient = class extends PKC$1 {
9528
9659
  const effectiveAddress = parsedRpcOptions.address || parsedRpcOptions.name || parsedRpcOptions.publicKey;
9529
9660
  if (hasIdentifier && effectiveAddress) {
9530
9661
  await this._waitForCommunitiesToBeDefined();
9531
- const isCommunityRpcLocal = this.communities.includes(effectiveAddress);
9662
+ const rpcLocalEntry = findCommunitiesEntry(this.communities, {
9663
+ address: parsedRpcOptions.address,
9664
+ name: parsedRpcOptions.name,
9665
+ publicKey: parsedRpcOptions.publicKey
9666
+ });
9667
+ const isCommunityRpcLocal = Boolean(rpcLocalEntry);
9532
9668
  if ("clients" in options && isCommunityRpcLocal) {
9533
9669
  const community = new RpcLocalCommunity(this);
9534
9670
  const jsonified = parsedRpcOptions;
@@ -9540,7 +9676,7 @@ var PKCWithRpcClient = class extends PKC$1 {
9540
9676
  return community;
9541
9677
  } else if (isCommunityRpcLocal) {
9542
9678
  const community = new RpcLocalCommunity(this);
9543
- community.setAddress(effectiveAddress);
9679
+ community.setAddress(rpcLocalEntry.address);
9544
9680
  const updatePromise = new Promise((resolve) => community.once("update", resolve));
9545
9681
  let error;
9546
9682
  const errorPromise = new Promise((resolve) => community.once("error", (err) => resolve(error = err)));
@@ -1,4 +1,4 @@
1
- import { bn as PageSortFileSchema, v as getEquivalentCommunityAddresses, wn as isStringDomain } from "./util-VrWyIc1x.js";
1
+ import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-D7gst5MT.js";
2
2
  //#region dist/node/pages/page-sort-scoring.js
3
3
  function validatePageSortFile(rawFile) {
4
4
  const validated = PageSortFileSchema.parse(rawFile);