@pkcprotocol/pkc-js 0.0.142 → 0.0.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/browser/clients/base-client-manager.d.ts +7 -1
- package/dist/browser/clients/base-client-manager.js +106 -28
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +2 -0
- package/dist/browser/clients/rpc-client/schema.d.ts +2 -0
- package/dist/browser/community/community-client-manager.js +40 -24
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/schema.d.ts +19 -0
- package/dist/browser/community/schema.js +7 -3
- package/dist/browser/community/schema.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/index-with-compile-cache.d.ts +2 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/object-key-util.js +5 -1
- package/dist/browser/object-key-util.js.map +1 -1
- package/dist/browser/pages/pkc-js-page-sorts/top.js +2 -1
- package/dist/browser/pages/pkc-js-page-sorts/top.js.map +1 -1
- package/dist/browser/pages/schema.js +3 -1
- package/dist/browser/pages/schema.js.map +1 -1
- package/dist/browser/pkc/pkc.d.ts +2 -1
- package/dist/browser/pkc/pkc.js +12 -2
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/publications/comment/comment-client-manager.js +5 -2
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +4 -1
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/community-edit/schema.d.ts +8 -0
- package/dist/browser/pubsub-messages/schema.d.ts +4 -0
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +2 -0
- package/dist/browser/rpc/src/schema.d.ts +12 -0
- package/dist/browser/runtime/node/community/db-handler.d.ts +3 -0
- package/dist/browser/runtime/node/community/db-handler.js +17 -2
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +70 -19
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.d.ts +14 -0
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js +206 -0
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community.js +4 -0
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/community/page-sorts/index.js +10 -10
- package/dist/browser/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +8 -0
- package/dist/browser/schema.d.ts +16 -0
- package/dist/browser/util/inflight-fetch-manager.d.ts +7 -2
- package/dist/browser/util/inflight-fetch-manager.js +49 -7
- package/dist/browser/util/inflight-fetch-manager.js.map +1 -1
- package/dist/browser/util.d.ts +1 -0
- package/dist/browser/util.js +23 -5
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +165 -123
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-pBsoz9YH.js → helia-for-pkc--Xw7hTTu.js} +33 -33
- package/dist/bundled/chunks/{local-community-B9D4Iu_Q.js → local-community-CH8vMgTr.js} +1 -1
- package/dist/bundled/chunks/{local-community-B4rXLDqy.js → local-community-DCVtQSci.js} +282 -45
- package/dist/bundled/chunks/{node-CsvN3ADZ.js → node-Coyk7lC6.js} +13 -10
- package/dist/bundled/chunks/{page-sort-scoring-2Q6exRbl.js → page-sort-scoring-DaW6urZ2.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-D3V1Sto-.js → rpc-local-community-KgRrTYjv.js} +154 -58
- package/dist/bundled/chunks/src-ABfmT8J2.js +2323 -0
- package/dist/bundled/chunks/src-BC60-Q7v.js +2 -0
- package/dist/bundled/chunks/src-BHqirG63.js +2 -0
- package/dist/bundled/chunks/{src-BggJ_InF.js → src-Bj5iE3qB.js} +2 -1999
- package/dist/bundled/chunks/src-CNab3O7M.js +2001 -0
- package/dist/bundled/chunks/{src-BsiPSkhv.js → src-ltPxiZKf.js} +1312 -3632
- package/dist/bundled/chunks/{util-DVrZupXz.js → util-BYT-7zVn.js} +24 -9
- package/dist/bundled/chunks/{util-LhCb7940.js → util-DN7FMpHT.js} +1 -1
- package/dist/bundled/chunks/{validate-package-factories-Bl2AyT4N.js → validate-package-factories-CPVyODKw.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.d.ts +7 -1
- package/dist/node/clients/base-client-manager.js +106 -28
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +2 -0
- package/dist/node/clients/rpc-client/schema.d.ts +2 -0
- package/dist/node/community/community-client-manager.js +40 -24
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/schema.d.ts +19 -0
- package/dist/node/community/schema.js +7 -3
- package/dist/node/community/schema.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/index-with-compile-cache.d.ts +2 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/object-key-util.js +5 -1
- package/dist/node/object-key-util.js.map +1 -1
- package/dist/node/pages/pkc-js-page-sorts/top.js +2 -1
- package/dist/node/pages/pkc-js-page-sorts/top.js.map +1 -1
- package/dist/node/pages/schema.js +3 -1
- package/dist/node/pages/schema.js.map +1 -1
- package/dist/node/pkc/pkc.d.ts +2 -1
- package/dist/node/pkc/pkc.js +12 -2
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/publications/comment/comment-client-manager.js +5 -2
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +4 -1
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/community-edit/schema.d.ts +8 -0
- package/dist/node/pubsub-messages/schema.d.ts +4 -0
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +2 -0
- package/dist/node/rpc/src/schema.d.ts +12 -0
- package/dist/node/runtime/node/community/db-handler.d.ts +3 -0
- package/dist/node/runtime/node/community/db-handler.js +17 -2
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community/comment-updates.js +70 -19
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.d.ts +14 -0
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.js +206 -0
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.js.map +1 -0
- package/dist/node/runtime/node/community/local-community.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community.js +4 -0
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/community/page-sorts/index.js +10 -10
- package/dist/node/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +8 -0
- package/dist/node/schema.d.ts +16 -0
- package/dist/node/util/inflight-fetch-manager.d.ts +7 -2
- package/dist/node/util/inflight-fetch-manager.js +49 -7
- package/dist/node/util/inflight-fetch-manager.js.map +1 -1
- package/dist/node/util.d.ts +1 -0
- package/dist/node/util.js +23 -5
- package/dist/node/util.js.map +1 -1
- package/package.json +4 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { Ar as t$2, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, Bt as DecryptedChallengeRequestPublicationSchema, C as hideClassPrivateProps, Cr as e, Dn as VotePubsubReservedFields, Dt as untrackUpdatingCommunity, En as VotePubsubMessagePublicationSchema, Er as t$3, F as isLinkOfVideo, Ft as ChallengeRequestMessageSchema, G as removeBlocksFromKuboNode, Hn as CommentUpdateTableRowSchema, I as isLinkValid, J as removeNullUndefinedValues, K as removeMfsFilesSafely, Lt as ChallengeVerificationMessageSchema, M as isLinkOfAudio, Mn as CommentIpfsSchema, Mr as require_retry, N as isLinkOfImage, Nn as CommentPubsubMessageReservedFields, Nt as ChallengeMessageSchema, Ot as require_sha256, P as isLinkOfMedia, Q as retryKuboBlockPutPinAndProvidePubsubTopic, Qn as CommentEditReservedFields, Rr as PKCError, Sr as e$1, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tr as r$1, Tt as untrackStartedCommunity, Un as CommentsTableRowSchema, Vt as DecryptedChallengeRequestSchema, Xn as CommentEditPubsubMessagePublicationSchema, Yt as version_default, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zt as CommunityEditPublicationPubsubReservedFields, _ as genToArray, _r as n$3, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, b as getIpnsRecordInLocalKuboNode, br as t$5, c as contentContainsMarkdownImages, ct as withSortedKeys, dt as findCommunityInRegistry, er as CommentEditsTableRowSchema, et as retryKuboIpfsAddAndProvide, f as derivePublicationFromChallengeRequest, ft as findStartedCommunity, g as findMalformedUnicodeString, gr as isStringDomain, hn as CommunitySignedPropertyNames, i as calculateStringSizeSameAsIpfsAddCidV0, it as statMfsPathSafely, j as isLinkOfAnimatedImage, jt as ChallengeAnswerMessageSchema, kn as VoteTablesRowSchema, kr as t$4, l as contentContainsMarkdownVideos, lt as withSortedKeysDeep, mn as CommunityIpfsSchema, mt as findUpdatingCommunity, ni as ZodError, nn as CommentModerationPubsubMessagePublicationSchema, o as calculateUnixFsDagSizeCidV0, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, r as calculateIpfsCidV0, rn as CommentModerationReservedFields, rt as sleepUntilTimeoutOrAbort, s as contentContainsMarkdownAudio, ut as writeKuboFilesWithTimeout, v as getEquivalentCommunityAddresses, vr as t$7, wt as trackUpdatingCommunity, xr as t$6, xt as syncCommunityRegistryEntry, y as getErrorCodeFromMessage, yr as n$2, zr as messages } from "./util-
|
|
3
|
-
import { $ as createSchemaRowParser, An as verifyChallengeAnswer, Bn as verifyCommunityEdit, Br as t$8, Cr as getThumbnailPropsOfLink, Dr as moveCommunityDbToDeletedDirectory, Dt as parseJsonWithPKCErrorIfFails, En as signCommunity, Fn as verifyCommentIpfs, Fr as isCommunityStartLocked, Gr as stringify, Hn as verifyVote, Hr as n$4, In as verifyCommentModeration, Ir as require_src, Kn as getAuthorNameFromWire, Ln as verifyCommentPubsubMessage, Lr as t$10, Mn as verifyChallengeRequest, Mr as findCommunitiesEntry, N as MAX_PAGE_SIZE_BYTES, Or as refreshCommunitiesList, Pn as verifyCommentEdit, Q as collectSchemaRowCoercions, Qn as effectiveMaxCrosspostDepth, Rn as verifyCommentUpdate, Rr as t$11, S as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, Sn as signCommentEdit, Tn as signCommentUpdateForChallengeVerification, Un as buildRuntimeAuthor, Vr as n$5, W as pLimit, Wn as cleanWireAuthor, Wr as t$9, X as coerceSchemaRowBoolean, Xr as STORAGE_KEYS, Z as coerceSchemaRowJson, Zn as crosspostChainDepthUpTo, Zr as require_lodash_merge, _ as createAuthorIdentityMatcher, _r as deriveCommentIpfsFromCommentTableRow, a as generatePagesReportingFailedSorts, ar as encode, b as KeyvBetterSqlite3, bn as signChallengeVerification, c as resolvePageSortsOrThrow, cn as SignerWithPublicKeyAddress, cr as getPKCAddressFromPublicKey, d as getChallengeVerification, dr as BackupAbortError, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, f as getCommunityChallengeFromCommunityChallengeSettings, fn as decryptEd25519AesGcmPublicKeyBuffer, fr as backupCommunityDb, g as authorNameResolveFailureReason, gn as cleanUpBeforePublishing, gr as deleteOldCommunityInWindows, h as authorIdentityMatcherForRequest, hn as _validateSignatureOfPKCRecord, i as derivePublicPageSorts, ir as decode, j as iterateOverPageCidsToFindAllCids, kr as resolveDbPostsCidRefs, lr as getPKCAddressFromPublicKeySync, m as pkcJsChallenges, mn as encryptEd25519AesGcmPublicKeyBuffer, mr as calculateInlineRepliesBudget, nr as getCommunityPublicKeyFromWire, o as loadPageSortsForStartedCommunity, p as loadChallengeFileFromCommunityChallengeSettings, pr as calculateExpectedSignatureSize, pt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, r as computePageSortsFingerprint, s as lookupPageSortFactories, sr as getIpfsKeyFromPrivateKey, t as RpcLocalCommunity, tr as getCommunityNameFromWire, u as deriveCommunityChallengesOrThrow, ur as getPublicKeyFromPrivateKey, v as TrackedInstanceRegistry, vn as signChallengeMessage, vr as deriveDbPosts, w as TIMEFRAMES_TO_SECONDS, wn as signCommentUpdate, wr as importSignerIntoKuboNode, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, xn as signComment, xr as getDefaultCommunityDbConfig, y as LRUCache, yr as deriveDbReplies, zn as verifyCommunity, zr as r$2 } from "./rpc-local-community-
|
|
4
|
-
import { a as scorePageCommentsWithFile, i as partitionPageCommentsForSort, n as filterRepliesForPageSort, o as stripRepliesFromPageComment, r as orderPageCommentsByScore, t as createDescendantsLookup } from "./page-sort-scoring-
|
|
2
|
+
import { Ar as t$2, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, Bt as DecryptedChallengeRequestPublicationSchema, C as hideClassPrivateProps, Cr as e, Dn as VotePubsubReservedFields, Dt as untrackUpdatingCommunity, En as VotePubsubMessagePublicationSchema, Er as t$3, F as isLinkOfVideo, Ft as ChallengeRequestMessageSchema, G as removeBlocksFromKuboNode, Hn as CommentUpdateTableRowSchema, I as isLinkValid, J as removeNullUndefinedValues, K as removeMfsFilesSafely, Lt as ChallengeVerificationMessageSchema, M as isLinkOfAudio, Mn as CommentIpfsSchema, Mr as require_retry, N as isLinkOfImage, Nn as CommentPubsubMessageReservedFields, Nt as ChallengeMessageSchema, Ot as require_sha256, P as isLinkOfMedia, Q as retryKuboBlockPutPinAndProvidePubsubTopic, Qn as CommentEditReservedFields, Rr as PKCError, Sr as e$1, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tr as r$1, Tt as untrackStartedCommunity, Un as CommentsTableRowSchema, Vt as DecryptedChallengeRequestSchema, Xn as CommentEditPubsubMessagePublicationSchema, Yt as version_default, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zt as CommunityEditPublicationPubsubReservedFields, _ as genToArray, _r as n$3, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, b as getIpnsRecordInLocalKuboNode, br as t$5, c as contentContainsMarkdownImages, ct as withSortedKeys, dt as findCommunityInRegistry, er as CommentEditsTableRowSchema, et as retryKuboIpfsAddAndProvide, f as derivePublicationFromChallengeRequest, ft as findStartedCommunity, g as findMalformedUnicodeString, gr as isStringDomain, hn as CommunitySignedPropertyNames, i as calculateStringSizeSameAsIpfsAddCidV0, it as statMfsPathSafely, j as isLinkOfAnimatedImage, jt as ChallengeAnswerMessageSchema, kn as VoteTablesRowSchema, kr as t$4, l as contentContainsMarkdownVideos, lt as withSortedKeysDeep, mn as CommunityIpfsSchema, mt as findUpdatingCommunity, ni as ZodError, nn as CommentModerationPubsubMessagePublicationSchema, o as calculateUnixFsDagSizeCidV0, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, r as calculateIpfsCidV0, rn as CommentModerationReservedFields, rt as sleepUntilTimeoutOrAbort, s as contentContainsMarkdownAudio, ut as writeKuboFilesWithTimeout, v as getEquivalentCommunityAddresses, vr as t$7, wt as trackUpdatingCommunity, xr as t$6, xt as syncCommunityRegistryEntry, y as getErrorCodeFromMessage, yr as n$2, zr as messages } from "./util-BYT-7zVn.js";
|
|
3
|
+
import { $ as createSchemaRowParser, An as verifyChallengeAnswer, Bn as verifyCommunityEdit, Br as t$8, Cr as getThumbnailPropsOfLink, Dr as moveCommunityDbToDeletedDirectory, Dt as parseJsonWithPKCErrorIfFails, En as signCommunity, Fn as verifyCommentIpfs, Fr as isCommunityStartLocked, Gr as stringify, Hn as verifyVote, Hr as n$4, In as verifyCommentModeration, Ir as require_src, Kn as getAuthorNameFromWire, Ln as verifyCommentPubsubMessage, Lr as t$10, Mn as verifyChallengeRequest, Mr as findCommunitiesEntry, N as MAX_PAGE_SIZE_BYTES, Or as refreshCommunitiesList, Pn as verifyCommentEdit, Q as collectSchemaRowCoercions, Qn as effectiveMaxCrosspostDepth, Rn as verifyCommentUpdate, Rr as t$11, S as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, Sn as signCommentEdit, Tn as signCommentUpdateForChallengeVerification, Un as buildRuntimeAuthor, Vr as n$5, W as pLimit, Wn as cleanWireAuthor, Wr as t$9, X as coerceSchemaRowBoolean, Xr as STORAGE_KEYS, Z as coerceSchemaRowJson, Zn as crosspostChainDepthUpTo, Zr as require_lodash_merge, _ as createAuthorIdentityMatcher, _r as deriveCommentIpfsFromCommentTableRow, a as generatePagesReportingFailedSorts, ar as encode, b as KeyvBetterSqlite3, bn as signChallengeVerification, c as resolvePageSortsOrThrow, cn as SignerWithPublicKeyAddress, cr as getPKCAddressFromPublicKey, d as getChallengeVerification, dr as BackupAbortError, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, f as getCommunityChallengeFromCommunityChallengeSettings, fn as decryptEd25519AesGcmPublicKeyBuffer, fr as backupCommunityDb, g as authorNameResolveFailureReason, gn as cleanUpBeforePublishing, gr as deleteOldCommunityInWindows, h as authorIdentityMatcherForRequest, hn as _validateSignatureOfPKCRecord, i as derivePublicPageSorts, ir as decode, j as iterateOverPageCidsToFindAllCids, kr as resolveDbPostsCidRefs, lr as getPKCAddressFromPublicKeySync, m as pkcJsChallenges, mn as encryptEd25519AesGcmPublicKeyBuffer, mr as calculateInlineRepliesBudget, nr as getCommunityPublicKeyFromWire, o as loadPageSortsForStartedCommunity, p as loadChallengeFileFromCommunityChallengeSettings, pr as calculateExpectedSignatureSize, pt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, r as computePageSortsFingerprint, s as lookupPageSortFactories, sr as getIpfsKeyFromPrivateKey, t as RpcLocalCommunity, tr as getCommunityNameFromWire, u as deriveCommunityChallengesOrThrow, ur as getPublicKeyFromPrivateKey, v as TrackedInstanceRegistry, vn as signChallengeMessage, vr as deriveDbPosts, w as TIMEFRAMES_TO_SECONDS, wn as signCommentUpdate, wr as importSignerIntoKuboNode, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, xn as signComment, xr as getDefaultCommunityDbConfig, y as LRUCache, yr as deriveDbReplies, zn as verifyCommunity, zr as r$2 } from "./rpc-local-community-KgRrTYjv.js";
|
|
4
|
+
import { a as scorePageCommentsWithFile, i as partitionPageCommentsForSort, n as filterRepliesForPageSort, o as stripRepliesFromPageComment, r as orderPageCommentsByScore, t as createDescendantsLookup } from "./page-sort-scoring-DaW6urZ2.js";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import
|
|
6
|
+
import Path from "node:path";
|
|
7
7
|
import os from "os";
|
|
8
8
|
import fs, { existsSync, promises } from "node:fs";
|
|
9
|
-
import path
|
|
9
|
+
import path from "path";
|
|
10
10
|
import assert from "assert";
|
|
11
11
|
import { Buffer as Buffer$1 } from "buffer";
|
|
12
12
|
import fs$1 from "fs";
|
|
@@ -315,15 +315,15 @@ async function throwIfChallengeSettingsAreInvalid({ challengeSettings, pkc, comm
|
|
|
315
315
|
const processStartedCommunities = new TrackedInstanceRegistry();
|
|
316
316
|
function normalizeRegistryDataPath(dataPath) {
|
|
317
317
|
if (dataPath === void 0) return void 0;
|
|
318
|
-
const resolved = path
|
|
318
|
+
const resolved = path.resolve(dataPath);
|
|
319
319
|
let existing = resolved;
|
|
320
320
|
let tail = "";
|
|
321
321
|
while (true) try {
|
|
322
|
-
return path
|
|
322
|
+
return path.join(fs$1.realpathSync.native(existing), tail);
|
|
323
323
|
} catch {
|
|
324
|
-
const parent = path
|
|
324
|
+
const parent = path.dirname(existing);
|
|
325
325
|
if (parent === existing) return resolved;
|
|
326
|
-
tail = path
|
|
326
|
+
tail = path.join(path.basename(existing), tail);
|
|
327
327
|
existing = parent;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
@@ -1337,7 +1337,8 @@ function createPositionalCommentRowMapper(cols) {
|
|
|
1337
1337
|
var import_src = /* @__PURE__ */ __toESM(require_src(), 1);
|
|
1338
1338
|
const createCommunityAuthorMemo = () => ({
|
|
1339
1339
|
writeGeneration: -1,
|
|
1340
|
-
authors: /* @__PURE__ */ new Map()
|
|
1340
|
+
authors: /* @__PURE__ */ new Map(),
|
|
1341
|
+
expandedAddresses: /* @__PURE__ */ new Map()
|
|
1341
1342
|
});
|
|
1342
1343
|
const COMMENTS_TO_UPDATE_TEMP_TABLE = "temp.commentsToUpdate";
|
|
1343
1344
|
const TABLES = Object.freeze({
|
|
@@ -1722,9 +1723,9 @@ var DbHandler = class {
|
|
|
1722
1723
|
if (needToMigrate) {
|
|
1723
1724
|
if (dbExistsAlready && currentDbVersion > 0) {
|
|
1724
1725
|
this.destoryConnection();
|
|
1725
|
-
backupDbPath = path
|
|
1726
|
-
log(`Copying db ${path
|
|
1727
|
-
if (!fs$1.existsSync(path
|
|
1726
|
+
backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
1727
|
+
log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
1728
|
+
if (!fs$1.existsSync(path.dirname(backupDbPath))) await fs$1.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
|
|
1728
1729
|
const sourceDb = new Database(dbPath, { fileMustExist: true });
|
|
1729
1730
|
await sourceDb.backup(backupDbPath);
|
|
1730
1731
|
sourceDb.close();
|
|
@@ -3402,11 +3403,19 @@ var DbHandler = class {
|
|
|
3402
3403
|
_queryCommunityAuthorsForCommentUpdates(entries, memo) {
|
|
3403
3404
|
if (memo.writeGeneration !== this._publicationWriteGeneration) {
|
|
3404
3405
|
memo.authors.clear();
|
|
3406
|
+
memo.expandedAddresses.clear();
|
|
3405
3407
|
memo.writeGeneration = this._publicationWriteGeneration;
|
|
3406
3408
|
}
|
|
3407
3409
|
const aliasByCid = this._queryPseudonymityAliasesByCommentCids(entries.map((entry) => entry.comment.cid));
|
|
3408
3410
|
const plainAddresses = [...new Set(entries.filter((entry) => !aliasByCid.has(entry.comment.cid)).map((entry) => entry.comment.authorSignerAddress))];
|
|
3409
|
-
const
|
|
3411
|
+
const addressesToExpand = plainAddresses.filter((address) => !memo.expandedAddresses.has(address));
|
|
3412
|
+
if (addressesToExpand.length > 0) for (const [address, addressSet] of this._queryAliasExpandedAddressSets(addressesToExpand)) memo.expandedAddresses.set(address, addressSet);
|
|
3413
|
+
const expanded = /* @__PURE__ */ new Map();
|
|
3414
|
+
for (const address of plainAddresses) {
|
|
3415
|
+
const addressSet = memo.expandedAddresses.get(address);
|
|
3416
|
+
if (!addressSet) throw Error(`Alias expansion of author ${address} missing from the cycle's memo`);
|
|
3417
|
+
expanded.set(address, addressSet);
|
|
3418
|
+
}
|
|
3410
3419
|
const keyOf = (karma, modEdit, domain) => `${[...karma].sort().join(",")}|${[...modEdit].sort().join(",")}|${domain ?? ""}`;
|
|
3411
3420
|
const needByCid = /* @__PURE__ */ new Map();
|
|
3412
3421
|
for (const { comment, authorDomain } of entries) {
|
|
@@ -3775,10 +3784,10 @@ var DbHandler = class {
|
|
|
3775
3784
|
if (this._db || this._keyv) await this.destoryConnection();
|
|
3776
3785
|
this._transactionDepth = 0;
|
|
3777
3786
|
const dataPath = this._community._pkc.dataPath;
|
|
3778
|
-
const oldPathString = path
|
|
3779
|
-
const newPathString = path
|
|
3780
|
-
await fs$1.promises.mkdir(path
|
|
3781
|
-
await fs$1.promises.mkdir(path
|
|
3787
|
+
const oldPathString = path.join(dataPath, "communities", oldDbName);
|
|
3788
|
+
const newPathString = path.join(dataPath, "communities", newDbName);
|
|
3789
|
+
await fs$1.promises.mkdir(path.dirname(oldPathString), { recursive: true });
|
|
3790
|
+
await fs$1.promises.mkdir(path.dirname(newPathString), { recursive: true });
|
|
3782
3791
|
try {
|
|
3783
3792
|
if (!fs$1.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
|
|
3784
3793
|
else {
|
|
@@ -3800,8 +3809,8 @@ var DbHandler = class {
|
|
|
3800
3809
|
}
|
|
3801
3810
|
async lockCommunityStart(communityAddress = this._community.address) {
|
|
3802
3811
|
const log = logger_default("pkc-js:local-community:db-handler:lock:start");
|
|
3803
|
-
const lockfilePath = path
|
|
3804
|
-
const communityDbPath = path
|
|
3812
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
3813
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
3805
3814
|
try {
|
|
3806
3815
|
await import_src.default.lock(communityDbPath, {
|
|
3807
3816
|
lockfilePath,
|
|
@@ -3822,8 +3831,8 @@ var DbHandler = class {
|
|
|
3822
3831
|
async unlockCommunityStart(communityAddress = this._community.address) {
|
|
3823
3832
|
const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
|
|
3824
3833
|
log.trace(`Attempting to unlock the start of community (${communityAddress})`);
|
|
3825
|
-
const lockfilePath = path
|
|
3826
|
-
const communityDbPath = path
|
|
3834
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
3835
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
3827
3836
|
if (!fs$1.existsSync(lockfilePath) || !fs$1.existsSync(communityDbPath)) return;
|
|
3828
3837
|
try {
|
|
3829
3838
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -3841,8 +3850,8 @@ var DbHandler = class {
|
|
|
3841
3850
|
}
|
|
3842
3851
|
async lockCommunityState() {
|
|
3843
3852
|
const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
|
|
3844
|
-
const lockfilePath = path
|
|
3845
|
-
const communityDbPath = path
|
|
3853
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
3854
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3846
3855
|
try {
|
|
3847
3856
|
await import_src.default.lock(communityDbPath, {
|
|
3848
3857
|
lockfilePath,
|
|
@@ -3859,8 +3868,8 @@ var DbHandler = class {
|
|
|
3859
3868
|
}
|
|
3860
3869
|
async unlockCommunityState() {
|
|
3861
3870
|
const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
|
|
3862
|
-
const lockfilePath = path
|
|
3863
|
-
const communityDbPath = path
|
|
3871
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
3872
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3864
3873
|
if (!fs$1.existsSync(lockfilePath)) return;
|
|
3865
3874
|
try {
|
|
3866
3875
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -3870,7 +3879,7 @@ var DbHandler = class {
|
|
|
3870
3879
|
}
|
|
3871
3880
|
}
|
|
3872
3881
|
communityDbExists() {
|
|
3873
|
-
const communityDbPath = path
|
|
3882
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3874
3883
|
return fs$1.existsSync(communityDbPath);
|
|
3875
3884
|
}
|
|
3876
3885
|
markCommentsAsPublishedToPostUpdates(commentCids) {
|
|
@@ -4041,7 +4050,200 @@ var DbHandler = class {
|
|
|
4041
4050
|
}
|
|
4042
4051
|
};
|
|
4043
4052
|
//#endregion
|
|
4053
|
+
//#region dist/node/runtime/node/community/local-community/post-updates-bucket.js
|
|
4054
|
+
const MFS_OP_TIMEOUT_MS = 600 * 1e3;
|
|
4055
|
+
const MFS_SHARD_SPLIT_THRESHOLD_BYTES = 256 * 1024;
|
|
4056
|
+
const POST_UPDATES_BUCKET_NEXT_SUFFIX = ".next";
|
|
4057
|
+
const isAbsentPathError = (error) => error instanceof Error && error.message.includes("file does not exist");
|
|
4058
|
+
async function statMfsPathOrUndefined(kuboRpcClient, path, log) {
|
|
4059
|
+
try {
|
|
4060
|
+
return await statMfsPathSafely({
|
|
4061
|
+
kuboRpcClient,
|
|
4062
|
+
path,
|
|
4063
|
+
log
|
|
4064
|
+
});
|
|
4065
|
+
} catch (error) {
|
|
4066
|
+
if (isAbsentPathError(error)) return void 0;
|
|
4067
|
+
throw error;
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
async function listUnixFsDirectoryLinks(kubo, directoryCid) {
|
|
4071
|
+
const { UnixFS } = await import("./src-BC60-Q7v.js");
|
|
4072
|
+
const links = [];
|
|
4073
|
+
const walk = async (cid) => {
|
|
4074
|
+
const node = (await kubo.dag.get(cid, { timeout: MFS_OP_TIMEOUT_MS })).value;
|
|
4075
|
+
if (!isPbNode(node)) throw Error(`Expected a dag-pb directory node at ${cid.toString()}`);
|
|
4076
|
+
const unixfs = UnixFS.unmarshal(node.Data);
|
|
4077
|
+
if (unixfs.type === "hamt-sharded-directory") {
|
|
4078
|
+
const prefixLength = Math.max(1, Math.ceil(Math.log2(Number(unixfs.fanout ?? 256)) / 4));
|
|
4079
|
+
for (const link of node.Links) if (link.Name.length === prefixLength) await walk(link.Hash);
|
|
4080
|
+
else links.push({
|
|
4081
|
+
name: link.Name.slice(prefixLength),
|
|
4082
|
+
cid: link.Hash,
|
|
4083
|
+
size: BigInt(link.Tsize ?? 0)
|
|
4084
|
+
});
|
|
4085
|
+
} else if (unixfs.type === "directory") for (const link of node.Links) links.push({
|
|
4086
|
+
name: link.Name,
|
|
4087
|
+
cid: link.Hash,
|
|
4088
|
+
size: BigInt(link.Tsize ?? 0)
|
|
4089
|
+
});
|
|
4090
|
+
else throw Error(`Expected a UnixFS directory at ${cid.toString()}, got ${unixfs.type}`);
|
|
4091
|
+
};
|
|
4092
|
+
await walk(directoryCid);
|
|
4093
|
+
return links;
|
|
4094
|
+
}
|
|
4095
|
+
function isPbNode(value) {
|
|
4096
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4097
|
+
const node = value;
|
|
4098
|
+
return node.Data instanceof Uint8Array && Array.isArray(node.Links) && node.Links.every((link) => typeof link?.Name === "string" && (link.Tsize === void 0 || typeof link.Tsize === "number") && link.Hash instanceof CID);
|
|
4099
|
+
}
|
|
4100
|
+
async function buildPostUpdatesBucketDag({ existingLinks, changedPosts }) {
|
|
4101
|
+
const { importer } = await import("./src-Bj5iE3qB.js");
|
|
4102
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
4103
|
+
const blockstore = { put: async (cid, bytes) => {
|
|
4104
|
+
blocks.set(cid.toString(), {
|
|
4105
|
+
cid,
|
|
4106
|
+
bytes
|
|
4107
|
+
});
|
|
4108
|
+
return cid;
|
|
4109
|
+
} };
|
|
4110
|
+
const layoutOptions = {
|
|
4111
|
+
profile: "unixfs-v0-2015",
|
|
4112
|
+
cidVersion: 0,
|
|
4113
|
+
rawLeaves: false,
|
|
4114
|
+
reduceSingleLeafToSelf: true,
|
|
4115
|
+
shardSplitThresholdBytes: MFS_SHARD_SPLIT_THRESHOLD_BYTES
|
|
4116
|
+
};
|
|
4117
|
+
const postDirectoryLinks = /* @__PURE__ */ new Map();
|
|
4118
|
+
for await (const entry of importer(changedPosts.map((post) => ({
|
|
4119
|
+
path: `${post.postCid}/update`,
|
|
4120
|
+
content: post.updateFileBytes
|
|
4121
|
+
})), blockstore, {
|
|
4122
|
+
...layoutOptions,
|
|
4123
|
+
wrapWithDirectory: false
|
|
4124
|
+
})) if (entry.path && !entry.path.includes("/")) postDirectoryLinks.set(entry.path, {
|
|
4125
|
+
name: entry.path,
|
|
4126
|
+
cid: entry.cid,
|
|
4127
|
+
size: entry.size
|
|
4128
|
+
});
|
|
4129
|
+
if (postDirectoryLinks.size !== changedPosts.length) throw Error(`Built ${postDirectoryLinks.size} post directories for ${changedPosts.length} changed posts`);
|
|
4130
|
+
const bucketName = "bucket";
|
|
4131
|
+
const knownLinks = /* @__PURE__ */ new Map();
|
|
4132
|
+
for (const link of existingLinks) knownLinks.set(`${bucketName}/${link.name}`, link);
|
|
4133
|
+
for (const link of postDirectoryLinks.values()) knownLinks.set(`${bucketName}/${link.name}`, link);
|
|
4134
|
+
let root;
|
|
4135
|
+
for await (const entry of importer([...knownLinks.keys()].map((path) => ({
|
|
4136
|
+
path,
|
|
4137
|
+
content: new Uint8Array(0)
|
|
4138
|
+
})), blockstore, {
|
|
4139
|
+
...layoutOptions,
|
|
4140
|
+
wrapWithDirectory: false,
|
|
4141
|
+
fileBuilder: async (file) => {
|
|
4142
|
+
for await (const chunk of file.content);
|
|
4143
|
+
const link = file.path ? knownLinks.get(file.path) : void 0;
|
|
4144
|
+
if (!link) throw Error(`No known link for bucket entry ${file.path}`);
|
|
4145
|
+
return {
|
|
4146
|
+
cid: link.cid,
|
|
4147
|
+
size: link.size,
|
|
4148
|
+
path: file.path
|
|
4149
|
+
};
|
|
4150
|
+
}
|
|
4151
|
+
})) if (entry.path === bucketName) root = entry.cid;
|
|
4152
|
+
if (!root) throw Error("The rebuilt postUpdates bucket has no root");
|
|
4153
|
+
return {
|
|
4154
|
+
root,
|
|
4155
|
+
blocks: [...blocks.values()]
|
|
4156
|
+
};
|
|
4157
|
+
}
|
|
4158
|
+
async function encodeCarV1(root, blocks) {
|
|
4159
|
+
const dagCbor = await import("./src-BHqirG63.js");
|
|
4160
|
+
const varint = (value) => {
|
|
4161
|
+
const out = [];
|
|
4162
|
+
while (value >= 128) {
|
|
4163
|
+
out.push(value & 127 | 128);
|
|
4164
|
+
value = Math.floor(value / 128);
|
|
4165
|
+
}
|
|
4166
|
+
out.push(value);
|
|
4167
|
+
return Uint8Array.from(out);
|
|
4168
|
+
};
|
|
4169
|
+
const header = dagCbor.encode({
|
|
4170
|
+
roots: [root],
|
|
4171
|
+
version: 1
|
|
4172
|
+
});
|
|
4173
|
+
const parts = [varint(header.length), header];
|
|
4174
|
+
for (const { cid, bytes } of blocks) parts.push(varint(cid.bytes.length + bytes.length), cid.bytes, bytes);
|
|
4175
|
+
const car = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
|
|
4176
|
+
let offset = 0;
|
|
4177
|
+
for (const part of parts) {
|
|
4178
|
+
car.set(part, offset);
|
|
4179
|
+
offset += part.length;
|
|
4180
|
+
}
|
|
4181
|
+
return car;
|
|
4182
|
+
}
|
|
4183
|
+
async function recoverInterruptedBucketSwap(kuboRpcClient, bucketPath, log) {
|
|
4184
|
+
const kubo = kuboRpcClient._client;
|
|
4185
|
+
const nextPath = bucketPath + POST_UPDATES_BUCKET_NEXT_SUFFIX;
|
|
4186
|
+
const next = await statMfsPathOrUndefined(kuboRpcClient, nextPath, log);
|
|
4187
|
+
let live = await statMfsPathOrUndefined(kuboRpcClient, bucketPath, log);
|
|
4188
|
+
if (next) {
|
|
4189
|
+
if (live) {
|
|
4190
|
+
log(`Discarding the stale rebuilt bucket ${nextPath} left by an interrupted swap`);
|
|
4191
|
+
await kubo.files.rm(nextPath, {
|
|
4192
|
+
recursive: true,
|
|
4193
|
+
timeout: MFS_OP_TIMEOUT_MS
|
|
4194
|
+
});
|
|
4195
|
+
} else {
|
|
4196
|
+
log(`Finishing the interrupted swap of ${nextPath} into ${bucketPath}`);
|
|
4197
|
+
await kubo.files.mv(nextPath, bucketPath, {
|
|
4198
|
+
flush: true,
|
|
4199
|
+
timeout: MFS_OP_TIMEOUT_MS
|
|
4200
|
+
});
|
|
4201
|
+
live = next;
|
|
4202
|
+
}
|
|
4203
|
+
await kubo.pin.rm(next.cid, { timeout: MFS_OP_TIMEOUT_MS }).catch(() => void 0);
|
|
4204
|
+
}
|
|
4205
|
+
return live;
|
|
4206
|
+
}
|
|
4207
|
+
async function rebuildPostUpdatesBucket({ community, bucketPath, posts }) {
|
|
4208
|
+
const log = logger_default("pkc-js:local-community:sync:rebuildPostUpdatesBucket");
|
|
4209
|
+
const kuboRpcClient = community._clientsManager.getDefaultKuboRpcClient();
|
|
4210
|
+
const kubo = kuboRpcClient._client;
|
|
4211
|
+
const nextPath = bucketPath + POST_UPDATES_BUCKET_NEXT_SUFFIX;
|
|
4212
|
+
const live = await recoverInterruptedBucketSwap(kuboRpcClient, bucketPath, log);
|
|
4213
|
+
const changedPostCids = new Set(posts.map((post) => post.postCid));
|
|
4214
|
+
const existingLinks = live ? (await listUnixFsDirectoryLinks(kubo, live.cid)).filter((link) => !changedPostCids.has(link.name) && community._dbHandler.commentExistsInDb(link.name)) : [];
|
|
4215
|
+
const { root, blocks } = await buildPostUpdatesBucketDag({
|
|
4216
|
+
existingLinks,
|
|
4217
|
+
changedPosts: posts
|
|
4218
|
+
});
|
|
4219
|
+
const car = await encodeCarV1(root, blocks);
|
|
4220
|
+
for await (const result of kubo.dag.import([car], {
|
|
4221
|
+
pinRoots: true,
|
|
4222
|
+
timeout: MFS_OP_TIMEOUT_MS
|
|
4223
|
+
})) if (result.root.pinErrorMsg) throw Error(`Failed to pin the rebuilt bucket ${root.toString()}: ${result.root.pinErrorMsg}`);
|
|
4224
|
+
log(`Built bucket ${bucketPath} in node: ${posts.length} posts written, ${existingLinks.length} kept, ${blocks.length} new blocks (${car.length} bytes), root ${root.toString()}`);
|
|
4225
|
+
try {
|
|
4226
|
+
await kubo.files.cp(`/ipfs/${root.toString()}`, nextPath, {
|
|
4227
|
+
parents: true,
|
|
4228
|
+
flush: true,
|
|
4229
|
+
timeout: MFS_OP_TIMEOUT_MS
|
|
4230
|
+
});
|
|
4231
|
+
if (live) await kubo.files.rm(bucketPath, {
|
|
4232
|
+
recursive: true,
|
|
4233
|
+
timeout: MFS_OP_TIMEOUT_MS
|
|
4234
|
+
});
|
|
4235
|
+
await kubo.files.mv(nextPath, bucketPath, {
|
|
4236
|
+
flush: true,
|
|
4237
|
+
timeout: MFS_OP_TIMEOUT_MS
|
|
4238
|
+
});
|
|
4239
|
+
} finally {
|
|
4240
|
+
await kubo.pin.rm(root, { timeout: MFS_OP_TIMEOUT_MS }).catch((error) => log.error(`Failed to unpin the rebuilt bucket root ${root.toString()}`, error));
|
|
4241
|
+
}
|
|
4242
|
+
return { keptPostCids: existingLinks.map((link) => link.name) };
|
|
4243
|
+
}
|
|
4244
|
+
//#endregion
|
|
4044
4245
|
//#region dist/node/runtime/node/community/local-community/comment-updates.js
|
|
4246
|
+
const textEncoder = new TextEncoder();
|
|
4045
4247
|
const NO_POST_UPDATES_TO_PUBLISH_ERROR = "No comment updates of posts to publish to postUpdates directory. This is a critical bug";
|
|
4046
4248
|
function communityChallengePubsubTopic(community) {
|
|
4047
4249
|
return community.pubsubTopic || community.signer?.address;
|
|
@@ -4050,11 +4252,16 @@ function challengeExchangePubsubTopic(community) {
|
|
|
4050
4252
|
if (community.settings?.disablePubsubChallengeExchange) return void 0;
|
|
4051
4253
|
return communityChallengePubsubTopic(community);
|
|
4052
4254
|
}
|
|
4053
|
-
function
|
|
4255
|
+
function calculateLocalMfsPathForPostUpdatesBucket(community, timestampRange) {
|
|
4054
4256
|
return [
|
|
4055
4257
|
"/" + community.address,
|
|
4056
4258
|
"postUpdates",
|
|
4057
|
-
timestampRange
|
|
4259
|
+
timestampRange
|
|
4260
|
+
].join("/");
|
|
4261
|
+
}
|
|
4262
|
+
function calculateLocalMfsPathForCommentUpdate(community, postDbComment, timestampRange) {
|
|
4263
|
+
return [
|
|
4264
|
+
calculateLocalMfsPathForPostUpdatesBucket(community, timestampRange),
|
|
4058
4265
|
postDbComment.cid,
|
|
4059
4266
|
"update"
|
|
4060
4267
|
].join("/");
|
|
@@ -4191,11 +4398,40 @@ async function writePostUpdatesToMfs(community, postCommentUpdateRows) {
|
|
|
4191
4398
|
const purgedMidSyncCount = postCommentUpdateRows.length - liveCommentUpdates.length;
|
|
4192
4399
|
if (purgedMidSyncCount > 0) log(`Skipping ${purgedMidSyncCount} post CommentUpdate(s) for community ${community.address} whose comment was purged mid-sync`);
|
|
4193
4400
|
const kuboRpc = community._clientsManager.getDefaultKuboRpcClient();
|
|
4194
|
-
|
|
4401
|
+
await rmUnneededMfsPaths(community);
|
|
4195
4402
|
let postUpdatesDirectoryCid;
|
|
4403
|
+
const rowsByBucketPath = /* @__PURE__ */ new Map();
|
|
4404
|
+
for (const row of liveCommentUpdates) {
|
|
4405
|
+
const bucket = row.newCommentUpdateToWriteToDb.postUpdatesBucket;
|
|
4406
|
+
if (typeof bucket !== "number") throw Error(`Post ${row.newCommentUpdate.cid} has a postUpdates MFS path but no bucket`);
|
|
4407
|
+
const bucketPath = calculateLocalMfsPathForPostUpdatesBucket(community, bucket);
|
|
4408
|
+
const bucketRows = rowsByBucketPath.get(bucketPath);
|
|
4409
|
+
if (bucketRows) bucketRows.push(row);
|
|
4410
|
+
else rowsByBucketPath.set(bucketPath, [row]);
|
|
4411
|
+
}
|
|
4412
|
+
const rowsToWriteOneByOne = [];
|
|
4413
|
+
const keptPostsByRebuiltBucket = [];
|
|
4414
|
+
for (const [bucketPath, rows] of rowsByBucketPath) {
|
|
4415
|
+
if (rows.length < community._postUpdatesNodeBuiltBucketMinPosts) {
|
|
4416
|
+
rowsToWriteOneByOne.push(...rows);
|
|
4417
|
+
continue;
|
|
4418
|
+
}
|
|
4419
|
+
const { keptPostCids } = await rebuildPostUpdatesBucket({
|
|
4420
|
+
community,
|
|
4421
|
+
bucketPath,
|
|
4422
|
+
posts: rows.map((row) => ({
|
|
4423
|
+
postCid: row.newCommentUpdate.cid,
|
|
4424
|
+
updateFileBytes: textEncoder.encode(stringify(row.newCommentUpdate))
|
|
4425
|
+
}))
|
|
4426
|
+
});
|
|
4427
|
+
keptPostsByRebuiltBucket.push({
|
|
4428
|
+
bucketPath,
|
|
4429
|
+
keptPostCids
|
|
4430
|
+
});
|
|
4431
|
+
}
|
|
4196
4432
|
const BATCH_SIZE = 50;
|
|
4197
|
-
for (let index = 0; index <
|
|
4198
|
-
const batch =
|
|
4433
|
+
for (let index = 0; index < rowsToWriteOneByOne.length; index += BATCH_SIZE) {
|
|
4434
|
+
const batch = rowsToWriteOneByOne.slice(index, index + BATCH_SIZE);
|
|
4199
4435
|
await Promise.all(batch.map(async (row) => {
|
|
4200
4436
|
const { localMfsPath, newCommentUpdate } = row;
|
|
4201
4437
|
const content = stringify(newCommentUpdate);
|
|
@@ -4208,17 +4444,17 @@ async function writePostUpdatesToMfs(community, postCommentUpdateRows) {
|
|
|
4208
4444
|
create: true,
|
|
4209
4445
|
truncate: true,
|
|
4210
4446
|
parents: true,
|
|
4211
|
-
flush:
|
|
4447
|
+
flush: false
|
|
4212
4448
|
}
|
|
4213
4449
|
});
|
|
4214
|
-
removedMfsPaths.push(localMfsPath);
|
|
4215
4450
|
}));
|
|
4216
4451
|
postUpdatesDirectoryCid = await kuboRpc._client.files.flush(postUpdatesDirectory);
|
|
4217
4452
|
}
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4453
|
+
if (rowsToWriteOneByOne.length === 0 && keptPostsByRebuiltBucket.length > 0) postUpdatesDirectoryCid = await kuboRpc._client.files.flush(postUpdatesDirectory);
|
|
4454
|
+
const mfsPathsPurgedDuringWrites = [...liveCommentUpdates.filter((row) => !community._dbHandler.commentExistsInDb(row.newCommentUpdate.cid)).map((row) => row.localMfsPath), ...keptPostsByRebuiltBucket.flatMap(({ bucketPath, keptPostCids }) => keptPostCids.filter((postCid) => !community._dbHandler.commentExistsInDb(postCid)).map((postCid) => `${bucketPath}/${postCid}`))];
|
|
4455
|
+
if (mfsPathsPurgedDuringWrites.length > 0) {
|
|
4456
|
+
log(`${mfsPathsPurgedDuringWrites.length} post CommentUpdate(s) of community ${community.address} were purged during the MFS writes. Removing their MFS entries`);
|
|
4457
|
+
for (const mfsPath of mfsPathsPurgedDuringWrites) community._mfsPathsToRemove.add(mfsPath);
|
|
4222
4458
|
await rmUnneededMfsPaths(community);
|
|
4223
4459
|
postUpdatesDirectoryCid = await kuboRpc._client.files.flush(postUpdatesDirectory);
|
|
4224
4460
|
}
|
|
@@ -6883,10 +7119,10 @@ async function restoreCommunityAfterFailedRename({ community, oldAddress, newAdd
|
|
|
6883
7119
|
}
|
|
6884
7120
|
}
|
|
6885
7121
|
async function removePartialDbCopy({ community, oldAddress, newAddress, log }) {
|
|
6886
|
-
const communitiesPath =
|
|
6887
|
-
if (!fs.existsSync(
|
|
7122
|
+
const communitiesPath = Path.join(community._pkc.dataPath, "communities");
|
|
7123
|
+
if (!fs.existsSync(Path.join(communitiesPath, oldAddress))) return;
|
|
6888
7124
|
try {
|
|
6889
|
-
await fs.promises.rm(
|
|
7125
|
+
await fs.promises.rm(Path.join(communitiesPath, newAddress), { force: true });
|
|
6890
7126
|
} catch (e) {
|
|
6891
7127
|
log.error(`Failed to remove the partial DB copy of community (${oldAddress}) at ${newAddress}`, e);
|
|
6892
7128
|
}
|
|
@@ -7030,11 +7266,11 @@ async function edit(community, newCommunityOptions) {
|
|
|
7030
7266
|
const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
|
|
7031
7267
|
function defaultExportPathFor(community, exportId) {
|
|
7032
7268
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
7033
|
-
return
|
|
7269
|
+
return Path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
|
|
7034
7270
|
}
|
|
7035
7271
|
function sourceDbPathFor(community) {
|
|
7036
7272
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
7037
|
-
return
|
|
7273
|
+
return Path.join(community._pkc.dataPath, "communities", community.address);
|
|
7038
7274
|
}
|
|
7039
7275
|
async function persistExports(community) {
|
|
7040
7276
|
if (!community._dbHandler) return;
|
|
@@ -7110,9 +7346,9 @@ async function runExportTask(community, exportId, opts) {
|
|
|
7110
7346
|
async function exportCommunityEmbedded(community, options = {}) {
|
|
7111
7347
|
if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
7112
7348
|
const exportId = v4();
|
|
7113
|
-
const destPath = options.exportPath ?
|
|
7349
|
+
const destPath = options.exportPath ? Path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
|
|
7114
7350
|
const includePrivateKey = options.includePrivateKey === true;
|
|
7115
|
-
if (
|
|
7351
|
+
if (Path.resolve(destPath) === Path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
|
|
7116
7352
|
communityAddress: community.address,
|
|
7117
7353
|
exportPath: destPath
|
|
7118
7354
|
});
|
|
@@ -7234,6 +7470,7 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
7234
7470
|
2592e3,
|
|
7235
7471
|
31536e5
|
|
7236
7472
|
];
|
|
7473
|
+
this._postUpdatesNodeBuiltBucketMinPosts = 200;
|
|
7237
7474
|
this._defaultCommunityChallenges = generateDefaultChallenges();
|
|
7238
7475
|
this._challengeExchangesFromLocalPublishers = {};
|
|
7239
7476
|
this._inFlightPublicationExchanges = /* @__PURE__ */ new Map();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.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-
|
|
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-
|
|
4
|
-
import { s as getHeliaDebugContext } from "./util-
|
|
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-BYT-7zVn.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-KgRrTYjv.js";
|
|
4
|
+
import { s as getHeliaDebugContext } from "./util-DN7FMpHT.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -29096,7 +29096,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
29096
29096
|
fetchCommentLogger.trace("Serving comment CID from cache", cid);
|
|
29097
29097
|
return t$4(cachedComment);
|
|
29098
29098
|
}
|
|
29099
|
-
const
|
|
29099
|
+
const fetchAndVerify = async () => {
|
|
29100
29100
|
fetchCommentLogger.trace("Fetching comment CID", cid);
|
|
29101
29101
|
let commentRawString;
|
|
29102
29102
|
if (Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0) commentRawString = await this._fetchRawCommentCidIpfsP2P(cid);
|
|
@@ -29104,7 +29104,8 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
29104
29104
|
const commentIpfs = parseCommentIpfsSchemaWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(commentRawString));
|
|
29105
29105
|
await this._throwIfCommentIpfsIsInvalid(commentIpfs, cid);
|
|
29106
29106
|
return commentIpfs;
|
|
29107
|
-
}
|
|
29107
|
+
};
|
|
29108
|
+
const verifiedComment = await this._pkc._inflightFetchManager.withResource(InflightResourceTypes.COMMENT_IPFS, cid, fetchAndVerify, this._comment._getStopAbortSignal());
|
|
29108
29109
|
this._pkc._memCaches.commentIpfs.set(cid, verifiedComment);
|
|
29109
29110
|
return verifiedComment;
|
|
29110
29111
|
}
|
|
@@ -29598,12 +29599,12 @@ var Comment = class extends Publication {
|
|
|
29598
29599
|
}
|
|
29599
29600
|
const crosspostAuthors = this.crosspost ? collectCrosspostAuthorsToResolve({ crosspost: this.crosspost }) : [];
|
|
29600
29601
|
if (ownAuthor.length === 0 && replyAuthors.length === 0 && crosspostAuthors.length === 0) return;
|
|
29601
|
-
const previousNameResolved = this.author.nameResolved;
|
|
29602
29602
|
const onResolved = () => {
|
|
29603
29603
|
const crosspostChanged = this.crosspost ? applyNameResolvedCacheToCrosspost({
|
|
29604
29604
|
crosspost: this.crosspost,
|
|
29605
29605
|
cache: this._pkc._memCaches.nameResolvedCache
|
|
29606
29606
|
}) : false;
|
|
29607
|
+
const previousNameResolved = this.author.nameResolved;
|
|
29607
29608
|
this._setAuthorNameResolvedFromCache();
|
|
29608
29609
|
if (this.replies?.pages) {
|
|
29609
29610
|
for (const page of Object.values(this.replies.pages)) if (page) this.replies._applyNameResolvedCacheToPage(page);
|
|
@@ -35817,7 +35818,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
35817
35818
|
this._nameResolvedFalseTtlMs = NAME_RESOLVED_FALSE_TTL_MS;
|
|
35818
35819
|
this._nameResolvedTrueTtlMs = NAME_RESOLVED_TRUE_TTL_MS;
|
|
35819
35820
|
this._nameResolveFailedRetryFloorMs = NAME_RESOLVE_FAILED_RETRY_FLOOR_MS;
|
|
35820
|
-
this._authorNameResolvesInFlight = /* @__PURE__ */ new
|
|
35821
|
+
this._authorNameResolvesInFlight = /* @__PURE__ */ new Map();
|
|
35821
35822
|
this._timeouts = {
|
|
35822
35823
|
"community-ipns": 300 * 1e3,
|
|
35823
35824
|
"community-ipfs": 60 * 1e3,
|
|
@@ -35881,7 +35882,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
35881
35882
|
this._initRpcClientsIfNeeded();
|
|
35882
35883
|
this._initIpfsGatewaysIfNeeded();
|
|
35883
35884
|
this._initMemCaches();
|
|
35884
|
-
this._inflightFetchManager = new InflightFetchManager();
|
|
35885
|
+
this._inflightFetchManager = new InflightFetchManager({ isDestroyed: () => this.destroyed });
|
|
35885
35886
|
if (!this.noData) {
|
|
35886
35887
|
if (!this.pkcRpcClientsOptions) this.dataPath = this.parsedPKCOptions.dataPath = "dataPath" in this.parsedPKCOptions ? this.parsedPKCOptions.dataPath : getDefaultDataPath();
|
|
35887
35888
|
else if (typeof this.parsedPKCOptions.dataPath === "string") this.dataPath = this.parsedPKCOptions.dataPath;
|
|
@@ -35945,7 +35946,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
35945
35946
|
this.clients.libp2pJsClients = {};
|
|
35946
35947
|
if (!this.libp2pJsClientsOptions) return;
|
|
35947
35948
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
35948
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc
|
|
35949
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc--Xw7hTTu.js");
|
|
35949
35950
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
35950
35951
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
35951
35952
|
...clientOptions,
|
|
@@ -36047,6 +36048,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
36047
36048
|
});
|
|
36048
36049
|
abortPromise.catch(() => {});
|
|
36049
36050
|
abortSignal?.addEventListener("abort", abortListener);
|
|
36051
|
+
comment._createStopAbortController();
|
|
36050
36052
|
const commentTimeout = this._timeouts["comment-ipfs"];
|
|
36051
36053
|
try {
|
|
36052
36054
|
await pTimeout(Promise.race([comment._attemptInfintelyToLoadCommentIpfs(), abortPromise]), {
|
|
@@ -36054,6 +36056,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
36054
36056
|
message: lastUpdateError || new TimeoutError(`pkc.getComment({cid: ${parsedGetCommentArgs}}) timed out after ${commentTimeout}ms`)
|
|
36055
36057
|
});
|
|
36056
36058
|
if (!comment.signature) throw Error("Failed to load CommentIpfs");
|
|
36059
|
+
comment._clearStopAbortController();
|
|
36057
36060
|
return comment;
|
|
36058
36061
|
} catch (e) {
|
|
36059
36062
|
if (abortError) throw abortError;
|
|
@@ -36310,7 +36313,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
36310
36313
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
36311
36314
|
log.trace("Received community options to create a local community instance:", options);
|
|
36312
36315
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
36313
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
36316
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CH8vMgTr.js");
|
|
36314
36317
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
36315
36318
|
const community = new LocalCommunity(this);
|
|
36316
36319
|
if (isLocalCommunity) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gr as isStringDomain, v as getEquivalentCommunityAddresses, xn as PageSortFileSchema } from "./util-
|
|
1
|
+
import { gr as isStringDomain, v as getEquivalentCommunityAddresses, xn as PageSortFileSchema } from "./util-BYT-7zVn.js";
|
|
2
2
|
//#region dist/node/pages/page-sort-scoring.js
|
|
3
3
|
function validatePageSortFile(rawFile) {
|
|
4
4
|
const validated = PageSortFileSchema.parse(rawFile);
|