@pkcprotocol/pkc-js 0.0.132 → 0.0.134

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 (61) hide show
  1. package/dist/browser/errors.d.ts +2 -0
  2. package/dist/browser/errors.js +2 -0
  3. package/dist/browser/errors.js.map +1 -1
  4. package/dist/browser/generated-version.d.ts +1 -1
  5. package/dist/browser/generated-version.js +1 -1
  6. package/dist/browser/pkc-error.d.ts +1 -1
  7. package/dist/browser/publications/comment/schema.d.ts +4 -0
  8. package/dist/browser/publications/comment/schema.js +2 -1
  9. package/dist/browser/publications/comment/schema.js.map +1 -1
  10. package/dist/browser/runtime/node/community/db-handler.js +44 -91
  11. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  12. package/dist/browser/runtime/node/community/local-community/comment-updates.js +1 -1
  13. package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
  14. package/dist/browser/runtime/node/community/local-community/editing.js +60 -7
  15. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  16. package/dist/browser/runtime/node/community/page-generator.d.ts +2 -0
  17. package/dist/browser/runtime/node/community/page-generator.js +3 -2
  18. package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
  19. package/dist/browser/runtime/node/util.d.ts +1 -0
  20. package/dist/browser/runtime/node/util.js +3 -2
  21. package/dist/browser/runtime/node/util.js.map +1 -1
  22. package/dist/browser/signer/signatures.js +24 -7
  23. package/dist/browser/signer/signatures.js.map +1 -1
  24. package/dist/bundled/bundle-manifest.json +34 -34
  25. package/dist/bundled/challenges.js +1 -1
  26. package/dist/bundled/chunks/{helia-for-pkc-Be5IsnZy.js → helia-for-pkc-CcFjdSPv.js} +2 -2
  27. package/dist/bundled/chunks/{local-community-BU2-PWv4.js → local-community-BDHE3v_Y.js} +1 -1
  28. package/dist/bundled/chunks/{local-community-BjDsNdnK.js → local-community-GYjtDIwZ.js} +126 -119
  29. package/dist/bundled/chunks/{node-Cpazwn3v.js → node-Cqt8DEE-.js} +5 -5
  30. package/dist/bundled/chunks/{page-sort-scoring-BqPwUozm.js → page-sort-scoring-BXVdZf57.js} +1 -1
  31. package/dist/bundled/chunks/{rpc-local-community-C5xdrdFG.js → rpc-local-community-CDsOv_s2.js} +55 -41
  32. package/dist/bundled/chunks/{util-BLpE5ch7.js → util-B-VRroTI.js} +1 -1
  33. package/dist/bundled/chunks/{util-DaZGW5bK.js → util-B5FM8shT.js} +5 -2
  34. package/dist/bundled/chunks/{validate-package-factories-DBOjkq17.js → validate-package-factories-a2ZVHdRd.js} +2 -2
  35. package/dist/bundled/index.js +1 -1
  36. package/dist/bundled/page-sorts.js +1 -1
  37. package/dist/bundled/rpc/src/index.js +4 -4
  38. package/dist/node/errors.d.ts +2 -0
  39. package/dist/node/errors.js +2 -0
  40. package/dist/node/errors.js.map +1 -1
  41. package/dist/node/generated-version.d.ts +1 -1
  42. package/dist/node/generated-version.js +1 -1
  43. package/dist/node/pkc-error.d.ts +1 -1
  44. package/dist/node/publications/comment/schema.d.ts +4 -0
  45. package/dist/node/publications/comment/schema.js +2 -1
  46. package/dist/node/publications/comment/schema.js.map +1 -1
  47. package/dist/node/runtime/node/community/db-handler.js +44 -91
  48. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  49. package/dist/node/runtime/node/community/local-community/comment-updates.js +1 -1
  50. package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
  51. package/dist/node/runtime/node/community/local-community/editing.js +60 -7
  52. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  53. package/dist/node/runtime/node/community/page-generator.d.ts +2 -0
  54. package/dist/node/runtime/node/community/page-generator.js +3 -2
  55. package/dist/node/runtime/node/community/page-generator.js.map +1 -1
  56. package/dist/node/runtime/node/util.d.ts +1 -0
  57. package/dist/node/runtime/node/util.js +3 -2
  58. package/dist/node/runtime/node/util.js.map +1 -1
  59. package/dist/node/signer/signatures.js +24 -7
  60. package/dist/node/signer/signatures.js.map +1 -1
  61. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
1
  import { i as __toESM } from "./chunk-2rV9d50f.js";
2
- import { $ as retryKuboIpfsAddAndProvide, $n as CommentEditsTableRowSchema, At as ChallengeAnswerMessageSchema, Bt as DecryptedChallengeRequestSchema, C as hideClassPrivateProps, Ct as trackUpdatingCommunity, Dt as require_sha256, En as VotePubsubReservedFields, Et as untrackUpdatingCommunity, F as isLinkOfVideo, G as removeMfsFilesSafely, Hn as CommentsTableRowSchema, I as isLinkValid, It as ChallengeVerificationMessageSchema, Jt as version_default, Lr as PKCError, M as isLinkOfAudio, Mn as CommentPubsubMessageReservedFields, Mt as ChallengeMessageSchema, N as isLinkOfImage, On as VoteTablesRowSchema, Or as t$4, P as isLinkOfMedia, Pt as ChallengeRequestMessageSchema, Rr as messages, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tn as VotePubsubMessagePublicationSchema, Tr as t$3, Vn as CommentUpdateTableRowSchema, W as removeBlocksFromKuboNode, Xn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Xt as CommunityEditPublicationPubsubReservedFields, Yn as CommentEditPubsubMessagePublicationSchema, Z as retryKuboBlockPutPinAndProvidePubsubTopic, Zn as CommentEditReservedFields, _ as genToArray, _r as t$7, at as timestamp, b as getIpnsRecordInLocalKuboNode, br as t$6, bt as syncCommunityRegistryEntry, c as contentContainsMarkdownImages, ct as withSortedKeysDeep, dt as findStartedCommunity, f as derivePublicationFromChallengeRequest, g as findMalformedUnicodeString, gr as n$3, hr as isStringDomain, i as calculateStringSizeSameAsIpfsAddCidV0, in as CommentModerationsTableRowSchema, ir as AuthorReservedFields, j as isLinkOfAnimatedImage, jn as CommentIpfsSchema, jr as require_retry, kr as t$2, kt as pTimeout, l as contentContainsMarkdownVideos, lt as writeKuboFilesWithTimeout, mn as CommunitySignedPropertyNames, nn as CommentModerationReservedFields, nt as sleepUntilTimeoutOrAbort, o as calculateUnixFsDagSizeCidV0, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, q as removeNullUndefinedValues, r as calculateIpfsCidV0, rt as statMfsPathSafely, s as contentContainsMarkdownAudio, st as withSortedKeys, ti as ZodError, tn as CommentModerationPubsubMessagePublicationSchema, ut as findCommunityInRegistry, v as getEquivalentCommunityAddresses, vr as n$2, wr as r$1, wt as untrackStartedCommunity, xr as e$1, xt as trackStartedCommunity, y as getErrorCodeFromMessage, yr as t$5, z as pubsubTopicToDhtKey, zn as CommentUpdateSchema, zr as logger_default, zt as DecryptedChallengeRequestPublicationSchema } from "./util-DaZGW5bK.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-C5xdrdFG.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-BqPwUozm.js";
2
+ import { $ as retryKuboIpfsAddAndProvide, $n as CommentEditsTableRowSchema, At as ChallengeAnswerMessageSchema, Bt as DecryptedChallengeRequestSchema, C as hideClassPrivateProps, Ct as trackUpdatingCommunity, Dt as require_sha256, En as VotePubsubReservedFields, Et as untrackUpdatingCommunity, F as isLinkOfVideo, G as removeMfsFilesSafely, Hn as CommentsTableRowSchema, I as isLinkValid, It as ChallengeVerificationMessageSchema, Jt as version_default, Lr as PKCError, M as isLinkOfAudio, Mn as CommentPubsubMessageReservedFields, Mt as ChallengeMessageSchema, N as isLinkOfImage, On as VoteTablesRowSchema, Or as t$4, P as isLinkOfMedia, Pt as ChallengeRequestMessageSchema, Rr as messages, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tn as VotePubsubMessagePublicationSchema, Tr as t$3, Vn as CommentUpdateTableRowSchema, W as removeBlocksFromKuboNode, Xn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Xt as CommunityEditPublicationPubsubReservedFields, Yn as CommentEditPubsubMessagePublicationSchema, Z as retryKuboBlockPutPinAndProvidePubsubTopic, Zn as CommentEditReservedFields, _ as genToArray, _r as t$7, at as timestamp, b as getIpnsRecordInLocalKuboNode, br as t$6, bt as syncCommunityRegistryEntry, c as contentContainsMarkdownImages, ct as withSortedKeysDeep, dt as findStartedCommunity, f as derivePublicationFromChallengeRequest, g as findMalformedUnicodeString, gr as n$3, hr as isStringDomain, i as calculateStringSizeSameAsIpfsAddCidV0, in as CommentModerationsTableRowSchema, ir as AuthorReservedFields, j as isLinkOfAnimatedImage, jn as CommentIpfsSchema, jr as require_retry, kr as t$2, kt as pTimeout, l as contentContainsMarkdownVideos, lt as writeKuboFilesWithTimeout, mn as CommunitySignedPropertyNames, nn as CommentModerationReservedFields, nt as sleepUntilTimeoutOrAbort, o as calculateUnixFsDagSizeCidV0, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, q as removeNullUndefinedValues, r as calculateIpfsCidV0, rt as statMfsPathSafely, s as contentContainsMarkdownAudio, st as withSortedKeys, ti as ZodError, tn as CommentModerationPubsubMessagePublicationSchema, ut as findCommunityInRegistry, v as getEquivalentCommunityAddresses, vr as n$2, wr as r$1, wt as untrackStartedCommunity, xr as e$1, xt as trackStartedCommunity, y as getErrorCodeFromMessage, yr as t$5, z as pubsubTopicToDhtKey, zn as CommentUpdateSchema, zr as logger_default, zt as DecryptedChallengeRequestPublicationSchema } from "./util-B5FM8shT.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-CDsOv_s2.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-BXVdZf57.js";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import path from "node:path";
7
7
  import os from "os";
8
- import { existsSync, promises } from "node:fs";
8
+ import fs, { existsSync, promises } from "node:fs";
9
9
  import path$1 from "path";
10
10
  import assert from "assert";
11
11
  import { Buffer as Buffer$1 } from "buffer";
12
- import fs from "fs";
12
+ import fs$1 from "fs";
13
13
  import Database from "better-sqlite3";
14
14
  import { CID } from "multiformats/cid";
15
15
  import { peerIdFromString } from "@libp2p/peer-id";
@@ -319,7 +319,7 @@ function normalizeRegistryDataPath(dataPath) {
319
319
  let existing = resolved;
320
320
  let tail = "";
321
321
  while (true) try {
322
- return path$1.join(fs.realpathSync.native(existing), tail);
322
+ return path$1.join(fs$1.realpathSync.native(existing), tail);
323
323
  } catch {
324
324
  const parent = path$1.dirname(existing);
325
325
  if (parent === existing) return resolved;
@@ -772,6 +772,7 @@ var PageGenerator = class {
772
772
  });
773
773
  return;
774
774
  }
775
+ const flatSortNames = sorts.filter((sort) => sort.flat).map((sort) => sort.sortName);
775
776
  const everyPreloadedIsSingleChunk = preloaded.length > 0 && preloaded.every(({ chunks }) => chunks.length === 1);
776
777
  const skippingOtherSortsIsSound = nonPreloaded.length === 0 || preloaded.every(({ holdsWholeSet }) => holdsWholeSet);
777
778
  if (everyPreloadedIsSingleChunk && skippingOtherSortsIsSound) {
@@ -779,7 +780,8 @@ var PageGenerator = class {
779
780
  for (const { sort, chunks } of preloaded) singlePreloadedPage[sort.sortName] = { comments: source.resolve(chunks[0]) };
780
781
  return {
781
782
  singlePreloadedPage,
782
- failedSorts
783
+ failedSorts,
784
+ flatSortNames
783
785
  };
784
786
  }
785
787
  const budget = new PageBytesBudget(serializedEntryCacheBudgetBytes());
@@ -802,7 +804,8 @@ var PageGenerator = class {
802
804
  if (!generatedPages) return void 0;
803
805
  return {
804
806
  ...generatedPages,
805
- failedSorts
807
+ failedSorts,
808
+ flatSortNames
806
809
  };
807
810
  }
808
811
  _generationResToPages(res) {
@@ -1700,13 +1703,13 @@ var DbHandler = class {
1700
1703
  const needToMigrate = currentDbVersion < version_default.DB_VERSION;
1701
1704
  const dbPath = this._dbConfig.filename;
1702
1705
  let backupDbPath;
1703
- const dbExistsAlready = fs.existsSync(dbPath);
1706
+ const dbExistsAlready = fs$1.existsSync(dbPath);
1704
1707
  if (needToMigrate) {
1705
1708
  if (dbExistsAlready && currentDbVersion > 0) {
1706
1709
  this.destoryConnection();
1707
1710
  backupDbPath = path$1.join(path$1.dirname(dbPath), ".backup_before_migration", `${path$1.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
1708
1711
  log(`Copying db ${path$1.basename(dbPath)} to ${backupDbPath} before migration`);
1709
- if (!fs.existsSync(path$1.dirname(backupDbPath))) await fs.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
1712
+ if (!fs$1.existsSync(path$1.dirname(backupDbPath))) await fs$1.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
1710
1713
  const sourceDb = new Database(dbPath, { fileMustExist: true });
1711
1714
  await sourceDb.backup(backupDbPath);
1712
1715
  sourceDb.close();
@@ -1789,7 +1792,7 @@ var DbHandler = class {
1789
1792
  this._columnNamesByTable = {};
1790
1793
  this._preparedStatements.clear();
1791
1794
  if (needToMigrate) log(`Created/migrated the tables to the latest (${newDbVersion}) version and saved to path`, this._dbConfig.filename);
1792
- if (backupDbPath) await fs.promises.rm(backupDbPath);
1795
+ if (backupDbPath) await fs$1.promises.rm(backupDbPath);
1793
1796
  }
1794
1797
  _tableExists(tableName) {
1795
1798
  return !!this._db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = ?").get(tableName);
@@ -2307,66 +2310,56 @@ var DbHandler = class {
2307
2310
  `;
2308
2311
  return this._prepareCached(queryStr).raw(true).all(...params).map(mapper.map);
2309
2312
  }
2310
- _assembleReplyTrees(items) {
2313
+ _assembleReplyTrees(entries) {
2311
2314
  const parsedByCid = /* @__PURE__ */ new Map();
2312
- const childrenByParent = /* @__PURE__ */ new Map();
2313
- for (const { entry, parent } of items) {
2315
+ for (const entry of entries) {
2314
2316
  const cid = entry.commentUpdate.cid;
2315
- if (parsedByCid.has(cid)) continue;
2316
- parsedByCid.set(cid, entry);
2317
- let siblings = childrenByParent.get(parent);
2318
- if (!siblings) childrenByParent.set(parent, siblings = /* @__PURE__ */ new Map());
2319
- siblings.set(cid, entry);
2320
- }
2321
- const buildWireCommentUpdate = (commentUpdate, resolvedReplies) => {
2322
- const { replies: dbReplies, ...rest } = commentUpdate;
2323
- if (resolvedReplies) return withSortedKeys({
2324
- ...rest,
2325
- replies: resolvedReplies
2326
- });
2327
- if (dbReplies) {
2328
- const pageCids = {};
2329
- for (const sortName of Object.keys(dbReplies).sort()) {
2330
- const sortEntry = dbReplies[sortName];
2317
+ if (!parsedByCid.has(cid)) parsedByCid.set(cid, entry);
2318
+ }
2319
+ const wireRepliesOf = (dbReplies) => {
2320
+ const pages = {};
2321
+ const pageCids = {};
2322
+ for (const sortName of Object.keys(dbReplies).sort()) {
2323
+ const sortEntry = dbReplies[sortName];
2324
+ if (!sortEntry?.commentCids) {
2331
2325
  if (sortEntry?.allPageCids?.[0]) pageCids[sortName] = sortEntry.allPageCids[0];
2326
+ continue;
2332
2327
  }
2333
- if (Object.keys(pageCids).length > 0) return withSortedKeys({
2334
- ...rest,
2335
- replies: {
2336
- pageCids,
2337
- pages: {}
2338
- }
2339
- });
2340
- }
2341
- return rest;
2342
- };
2343
- const attachReplies = (cid) => {
2344
- const children = childrenByParent.get(cid);
2345
- if (!children?.size) return void 0;
2346
- const parentDbReplies = parsedByCid.get(cid)?.commentUpdate.replies;
2347
- const pages = {};
2348
- for (const sortName of Object.keys(parentDbReplies ?? {}).sort()) {
2349
- const sortEntry = parentDbReplies[sortName];
2350
- if (!sortEntry?.commentCids) continue;
2351
2328
  const comments = [];
2352
2329
  for (const childCid of sortEntry.commentCids) {
2353
- const child = children.get(childCid);
2330
+ const child = parsedByCid.get(childCid);
2354
2331
  if (child) comments.push({
2355
2332
  comment: child.comment,
2356
- commentUpdate: buildWireCommentUpdate(child.commentUpdate, attachReplies(childCid))
2333
+ commentUpdate: sortEntry.flat ? withoutReplies(child.commentUpdate) : withWireReplies(child.commentUpdate)
2357
2334
  });
2358
2335
  }
2359
- pages[sortName] = { comments };
2336
+ const nextCid = sortEntry.allPageCids?.[0] ?? sortEntry.nextCid;
2337
+ pages[sortName] = {
2338
+ comments,
2339
+ ...nextCid ? { nextCid } : {}
2340
+ };
2360
2341
  }
2361
- if (Object.keys(pages).length === 0) return void 0;
2362
- return { pages };
2342
+ const hasPageCids = Object.keys(pageCids).length > 0;
2343
+ if (!hasPageCids && Object.keys(pages).length === 0) return void 0;
2344
+ return {
2345
+ ...hasPageCids ? { pageCids } : {},
2346
+ pages
2347
+ };
2363
2348
  };
2364
- return {
2365
- parsedByCid,
2366
- childrenByParent,
2367
- buildWireCommentUpdate,
2368
- attachReplies
2349
+ const withoutReplies = (commentUpdate) => {
2350
+ const { replies: _dbReplies, ...rest } = commentUpdate;
2351
+ return rest;
2369
2352
  };
2353
+ const withWireReplies = (commentUpdate) => {
2354
+ const dbReplies = commentUpdate.replies;
2355
+ const replies = dbReplies && wireRepliesOf(dbReplies);
2356
+ const rest = withoutReplies(commentUpdate);
2357
+ return replies ? withSortedKeys({
2358
+ ...rest,
2359
+ replies
2360
+ }) : rest;
2361
+ };
2362
+ return { withWireReplies };
2370
2363
  }
2371
2364
  queryPageCommentsWithResolvedReplies(options) {
2372
2365
  return this.resolveRepliesCidRefsForEntries(this.queryPageComments(options));
@@ -2397,10 +2390,7 @@ var DbHandler = class {
2397
2390
  resolveRepliesCidRefsForEntries(entries) {
2398
2391
  const withReplies = entries.filter((entry) => this._entryHasDbReplies(entry));
2399
2392
  if (withReplies.length === 0) return entries;
2400
- const trees = withReplies.every((entry) => entry.comment.depth === 0) ? this._assembleReplyTrees(this.queryRepliesUnderPosts(withReplies.map((entry) => entry.commentUpdate.cid)).map((entry) => ({
2401
- entry,
2402
- parent: entry.comment.parentCid
2403
- }))) : this._assembleReplyTreesFromCidRefs(withReplies);
2393
+ const trees = withReplies.every((entry) => entry.comment.depth === 0) ? this._assembleReplyTrees(this.queryRepliesUnderPosts(withReplies.map((entry) => entry.commentUpdate.cid))) : this._assembleReplyTreesFromCidRefs(withReplies);
2404
2394
  return this._rebuildEntriesFromTrees(entries, trees);
2405
2395
  }
2406
2396
  _assembleReplyTreesFromCidRefs(entries) {
@@ -2427,52 +2417,17 @@ var DbHandler = class {
2427
2417
  `, (row) => level.push(mapper.map(row)), true);
2428
2418
  for (const entry of level) {
2429
2419
  seen.add(entry.commentUpdate.cid);
2430
- items.push({
2431
- entry,
2432
- parent: entry.comment.parentCid
2433
- });
2420
+ items.push(entry);
2434
2421
  }
2435
2422
  frontier = listedChildren(level);
2436
2423
  }
2437
2424
  return this._assembleReplyTrees(items);
2438
2425
  }
2439
- _rebuildEntriesFromTrees(entries, { parsedByCid, buildWireCommentUpdate, attachReplies }) {
2440
- return entries.map((entry) => {
2441
- if (!this._entryHasDbReplies(entry)) return entry;
2442
- const replies = entry.commentUpdate.replies;
2443
- const resolvedPages = {};
2444
- const resolvedPageCids = {};
2445
- for (const sortName of Object.keys(replies).sort()) {
2446
- const sortEntry = replies[sortName];
2447
- if (sortEntry?.commentCids) {
2448
- const resolvedComments = [];
2449
- for (const cid of sortEntry.commentCids) {
2450
- const child = parsedByCid.get(cid);
2451
- if (child) resolvedComments.push({
2452
- comment: child.comment,
2453
- commentUpdate: buildWireCommentUpdate(child.commentUpdate, attachReplies(cid))
2454
- });
2455
- }
2456
- const nextCidForSort = sortEntry.allPageCids?.[0] ?? sortEntry.nextCid;
2457
- resolvedPages[sortName] = {
2458
- comments: resolvedComments,
2459
- ...nextCidForSort ? { nextCid: nextCidForSort } : {}
2460
- };
2461
- }
2462
- if (sortEntry?.allPageCids?.[0]) resolvedPageCids[sortName] = sortEntry.allPageCids[0];
2463
- }
2464
- const { replies: _dbReplies, ...entryCommentUpdateRest } = entry.commentUpdate;
2465
- return {
2466
- ...entry,
2467
- commentUpdate: withSortedKeys({
2468
- ...entryCommentUpdateRest,
2469
- replies: {
2470
- ...Object.keys(resolvedPageCids).length > 0 ? { pageCids: resolvedPageCids } : {},
2471
- pages: resolvedPages
2472
- }
2473
- })
2474
- };
2475
- });
2426
+ _rebuildEntriesFromTrees(entries, { withWireReplies }) {
2427
+ return entries.map((entry) => this._entryHasDbReplies(entry) ? {
2428
+ ...entry,
2429
+ commentUpdate: withWireReplies(entry.commentUpdate)
2430
+ } : entry);
2476
2431
  }
2477
2432
  queryCommentAndCommentUpdateByCids(cids, opts) {
2478
2433
  if (cids.length === 0) return [];
@@ -3807,16 +3762,16 @@ var DbHandler = class {
3807
3762
  const dataPath = this._community._pkc.dataPath;
3808
3763
  const oldPathString = path$1.join(dataPath, "communities", oldDbName);
3809
3764
  const newPathString = path$1.join(dataPath, "communities", newDbName);
3810
- await fs.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
3811
- await fs.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
3765
+ await fs$1.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
3766
+ await fs$1.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
3812
3767
  try {
3813
- if (!fs.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
3768
+ if (!fs$1.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
3814
3769
  else {
3815
3770
  const sourceDb = new Database(oldPathString, { fileMustExist: true });
3816
3771
  await sourceDb.backup(newPathString);
3817
3772
  sourceDb.close();
3818
3773
  if (os.type() === "Windows_NT") await deleteOldCommunityInWindows(oldPathString, this._community._pkc);
3819
- else await fs.promises.rm(oldPathString, { force: true });
3774
+ else await fs$1.promises.rm(oldPathString, { force: true });
3820
3775
  }
3821
3776
  } catch (error) {
3822
3777
  log.error(`Failed to backup/rename database from ${oldPathString} to ${newPathString}: `, error);
@@ -3854,7 +3809,7 @@ var DbHandler = class {
3854
3809
  log.trace(`Attempting to unlock the start of community (${communityAddress})`);
3855
3810
  const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
3856
3811
  const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
3857
- if (!fs.existsSync(lockfilePath) || !fs.existsSync(communityDbPath)) return;
3812
+ if (!fs$1.existsSync(lockfilePath) || !fs$1.existsSync(communityDbPath)) return;
3858
3813
  try {
3859
3814
  await import_src.default.unlock(communityDbPath, { lockfilePath });
3860
3815
  log(`Unlocked start of community (${communityAddress})`);
@@ -3891,7 +3846,7 @@ var DbHandler = class {
3891
3846
  const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
3892
3847
  const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
3893
3848
  const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
3894
- if (!fs.existsSync(lockfilePath)) return;
3849
+ if (!fs$1.existsSync(lockfilePath)) return;
3895
3850
  try {
3896
3851
  await import_src.default.unlock(communityDbPath, { lockfilePath });
3897
3852
  } catch (e) {
@@ -3901,7 +3856,7 @@ var DbHandler = class {
3901
3856
  }
3902
3857
  communityDbExists() {
3903
3858
  const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
3904
- return fs.existsSync(communityDbPath);
3859
+ return fs$1.existsSync(communityDbPath);
3905
3860
  }
3906
3861
  markCommentsAsPublishedToPostUpdates(commentCids) {
3907
3862
  if (commentCids.length === 0) return;
@@ -4144,7 +4099,8 @@ async function calculateNewCommentUpdate(opts) {
4144
4099
  ...newCommentUpdate,
4145
4100
  replies: deriveDbReplies({
4146
4101
  replies: newCommentUpdate.replies,
4147
- allPageCids
4102
+ allPageCids,
4103
+ flatSortNames: generatedRepliesPages?.flatSortNames
4148
4104
  }),
4149
4105
  postUpdatesBucket: newPostUpdateBucket,
4150
4106
  publishedToPostUpdatesMFS: false,
@@ -6902,22 +6858,73 @@ function deriveNameAndAddressEdit(community, editOptions) {
6902
6858
  function listRenamedCommunityNow(community) {
6903
6859
  refreshCommunitiesList(community._pkc);
6904
6860
  }
6861
+ async function restoreCommunityAfterFailedRename({ community, oldAddress, newAddress, postUpdatesFolderMoved, log }) {
6862
+ try {
6863
+ if (postUpdatesFolderMoved) await movePostUpdatesFolderToNewAddress(community, newAddress, oldAddress);
6864
+ await community.start();
6865
+ } catch (restoreError) {
6866
+ log.error(`Failed to restore community (${oldAddress}) after its rename to ${newAddress} failed`, restoreError);
6867
+ community.emit("error", restoreError);
6868
+ }
6869
+ }
6870
+ async function removePartialDbCopy({ community, oldAddress, newAddress, log }) {
6871
+ const communitiesPath = path.join(community._pkc.dataPath, "communities");
6872
+ if (!fs.existsSync(path.join(communitiesPath, oldAddress))) return;
6873
+ try {
6874
+ await fs.promises.rm(path.join(communitiesPath, newAddress), { force: true });
6875
+ } catch (e) {
6876
+ log.error(`Failed to remove the partial DB copy of community (${oldAddress}) at ${newAddress}`, e);
6877
+ }
6878
+ }
6905
6879
  async function editPropsOnStartedCommunity(community, parsedEditOptions, pagesEdit) {
6906
6880
  const log = logger_default("pkc-js:local-community:start:editPropsOnStartedCommunity");
6907
6881
  const oldAddress = t$9(community.address);
6882
+ const uniqueEditId = (0, import_sha256.sha256)(stringify(parsedEditOptions));
6908
6883
  if (typeof parsedEditOptions.address === "string" && community.address !== parsedEditOptions.address) {
6909
- await validateNewAddressBeforeEditing(community, parsedEditOptions.address, log);
6910
- log(`Attempting to edit community.address from ${oldAddress} to ${parsedEditOptions.address}. We will stop community first`);
6884
+ const newAddress = parsedEditOptions.address;
6885
+ await validateNewAddressBeforeEditing(community, newAddress, log);
6886
+ log(`Attempting to edit community.address from ${oldAddress} to ${newAddress}. We will stop community first`);
6911
6887
  await community.stop();
6912
- await community._dbHandler.changeDbFilename(oldAddress, parsedEditOptions.address);
6888
+ try {
6889
+ await movePostUpdatesFolderToNewAddress(community, oldAddress, newAddress);
6890
+ } catch (e) {
6891
+ await restoreCommunityAfterFailedRename({
6892
+ community,
6893
+ oldAddress,
6894
+ newAddress,
6895
+ postUpdatesFolderMoved: false,
6896
+ log
6897
+ });
6898
+ throw e;
6899
+ }
6900
+ try {
6901
+ await community._dbHandler.changeDbFilename(oldAddress, newAddress);
6902
+ } catch (e) {
6903
+ await removePartialDbCopy({
6904
+ community,
6905
+ oldAddress,
6906
+ newAddress,
6907
+ log
6908
+ });
6909
+ await restoreCommunityAfterFailedRename({
6910
+ community,
6911
+ oldAddress,
6912
+ newAddress,
6913
+ postUpdatesFolderMoved: true,
6914
+ log
6915
+ });
6916
+ throw e;
6917
+ }
6913
6918
  listRenamedCommunityNow(community);
6914
- community.setAddress(parsedEditOptions.address);
6919
+ community.setAddress(newAddress);
6915
6920
  await community._dbHandler.initDbIfNeeded();
6921
+ await updateDbInternalState(community, { ...parsedEditOptions });
6922
+ community._pendingEditProps.push({
6923
+ ...parsedEditOptions,
6924
+ editId: uniqueEditId
6925
+ });
6916
6926
  await community.start();
6917
- await movePostUpdatesFolderToNewAddress(community, oldAddress, parsedEditOptions.address);
6918
- }
6919
- const uniqueEditId = (0, import_sha256.sha256)(stringify(parsedEditOptions));
6920
- community._pendingEditProps.push({
6927
+ } else community._pendingEditProps.push({
6921
6928
  ...parsedEditOptions,
6922
6929
  editId: uniqueEditId
6923
6930
  });
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, In as CommentUpdateForChallengeVerificationSchema, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, hr as isStringDomain, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$1, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zn as CommentUpdateSchema, zr as logger_default } from "./util-DaZGW5bK.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-C5xdrdFG.js";
4
- import { s as getHeliaDebugContext } from "./util-BLpE5ch7.js";
2
+ import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, In as CommentUpdateForChallengeVerificationSchema, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, hr as isStringDomain, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$1, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zn as CommentUpdateSchema, zr as logger_default } from "./util-B5FM8shT.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-CDsOv_s2.js";
4
+ import { s as getHeliaDebugContext } from "./util-B-VRroTI.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -35823,7 +35823,7 @@ var PKC$1 = class extends PKCTypedEmitter {
35823
35823
  this.clients.libp2pJsClients = {};
35824
35824
  if (!this.libp2pJsClientsOptions) return;
35825
35825
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
35826
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-Be5IsnZy.js");
35826
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CcFjdSPv.js");
35827
35827
  for (const clientOptions of this.libp2pJsClientsOptions) {
35828
35828
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
35829
35829
  ...clientOptions,
@@ -36188,7 +36188,7 @@ var PKC$1 = class extends PKCTypedEmitter {
36188
36188
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
36189
36189
  log.trace("Received community options to create a local community instance:", options);
36190
36190
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
36191
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-BU2-PWv4.js");
36191
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-BDHE3v_Y.js");
36192
36192
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
36193
36193
  const community = new LocalCommunity(this);
36194
36194
  if (isLocalCommunity) {
@@ -1,4 +1,4 @@
1
- import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-DaZGW5bK.js";
1
+ import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-B5FM8shT.js";
2
2
  //#region dist/node/pages/page-sort-scoring.js
3
3
  function validatePageSortFile(rawFile) {
4
4
  const validated = PageSortFileSchema.parse(rawFile);