@pkcprotocol/pkc-js 0.0.155 → 0.0.157

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 (67) hide show
  1. package/dist/browser/clients/base-client-manager.js +10 -1
  2. package/dist/browser/clients/base-client-manager.js.map +1 -1
  3. package/dist/browser/clients/shared-pubsub-topic-list.d.ts +14 -0
  4. package/dist/browser/clients/shared-pubsub-topic-list.js +61 -0
  5. package/dist/browser/clients/shared-pubsub-topic-list.js.map +1 -0
  6. package/dist/browser/generated-version.d.ts +1 -1
  7. package/dist/browser/generated-version.js +1 -1
  8. package/dist/browser/runtime/node/community/db-handler.d.ts +2 -0
  9. package/dist/browser/runtime/node/community/db-handler.js +23 -9
  10. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  11. package/dist/browser/runtime/node/community/local-community/ipns-publishing.d.ts +6 -0
  12. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +49 -10
  13. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  14. package/dist/browser/runtime/node/community/local-community/lifecycle.js +102 -61
  15. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  16. package/dist/browser/runtime/node/community/local-community/pubsub.js +11 -4
  17. package/dist/browser/runtime/node/community/local-community/pubsub.js.map +1 -1
  18. package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +22 -4
  19. package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +45 -9
  20. package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
  21. package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
  22. package/dist/browser/runtime/node/community/local-community.js +5 -0
  23. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  24. package/dist/browser/runtime/node/event-loop-watch.d.ts +13 -0
  25. package/dist/browser/runtime/node/event-loop-watch.js +58 -0
  26. package/dist/browser/runtime/node/event-loop-watch.js.map +1 -0
  27. package/dist/bundled/bundle-manifest.json +37 -34
  28. package/dist/bundled/challenges.js +1 -1
  29. package/dist/bundled/chunks/{helia-for-pkc-Oiy9zYBR.js → helia-for-pkc-BT2UmDem.js} +2 -2
  30. package/dist/bundled/chunks/{local-community-BlJfnxcr.js → local-community-BexngGU7.js} +1 -1
  31. package/dist/bundled/chunks/{local-community-PMJTbzmG.js → local-community-oqjqTa9T.js} +221 -71
  32. package/dist/bundled/chunks/{node-Bf1DjAFe.js → node-CvXtQ-4A.js} +5 -5
  33. package/dist/bundled/chunks/{page-sort-scoring-DVAvzj4W.js → page-sort-scoring-VN_GGInQ.js} +1 -1
  34. package/dist/bundled/chunks/{rpc-local-community-BqJ_olvR.js → rpc-local-community-BjIHRbYy.js} +51 -4
  35. package/dist/bundled/chunks/{util-BpiQT2hV.js → util-Bu3ItQsN.js} +1 -1
  36. package/dist/bundled/chunks/{util-N_HlPQHv.js → util-DDsWXOtP.js} +1 -1
  37. package/dist/bundled/chunks/{validate-package-factories-DoC8xXMu.js → validate-package-factories-CmJt781W.js} +2 -2
  38. package/dist/bundled/index.js +1 -1
  39. package/dist/bundled/page-sorts.js +1 -1
  40. package/dist/bundled/rpc/src/index.js +4 -4
  41. package/dist/node/clients/base-client-manager.js +10 -1
  42. package/dist/node/clients/base-client-manager.js.map +1 -1
  43. package/dist/node/clients/shared-pubsub-topic-list.d.ts +14 -0
  44. package/dist/node/clients/shared-pubsub-topic-list.js +61 -0
  45. package/dist/node/clients/shared-pubsub-topic-list.js.map +1 -0
  46. package/dist/node/generated-version.d.ts +1 -1
  47. package/dist/node/generated-version.js +1 -1
  48. package/dist/node/runtime/node/community/db-handler.d.ts +2 -0
  49. package/dist/node/runtime/node/community/db-handler.js +23 -9
  50. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  51. package/dist/node/runtime/node/community/local-community/ipns-publishing.d.ts +6 -0
  52. package/dist/node/runtime/node/community/local-community/ipns-publishing.js +49 -10
  53. package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  54. package/dist/node/runtime/node/community/local-community/lifecycle.js +102 -61
  55. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  56. package/dist/node/runtime/node/community/local-community/pubsub.js +11 -4
  57. package/dist/node/runtime/node/community/local-community/pubsub.js.map +1 -1
  58. package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +22 -4
  59. package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +45 -9
  60. package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
  61. package/dist/node/runtime/node/community/local-community.d.ts +1 -0
  62. package/dist/node/runtime/node/community/local-community.js +5 -0
  63. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  64. package/dist/node/runtime/node/event-loop-watch.d.ts +13 -0
  65. package/dist/node/runtime/node/event-loop-watch.js +58 -0
  66. package/dist/node/runtime/node/event-loop-watch.js.map +1 -0
  67. package/package.json +1 -1
@@ -52,11 +52,21 @@ function deriveAliasOriginalAuthorSignerAddress(originalAuthorPublicKey) {
52
52
  }
53
53
  }
54
54
  export class DbHandler {
55
+ // Every method that writes a publication (a vote, comment, edit, moderation, an approval, a purge) calls this.
56
+ // Besides dropping what was memoized from the old rows, it asks the community for a new record, which wakes its
57
+ // publish loop: the loop does not poll the DB for changes (issue #576). A write inside readBackWithoutStoring is
58
+ // rolled back, so it still drops the memo (the rows did change for the read that follows) but asks for no record.
59
+ _notePublicationWrite() {
60
+ this._publicationWriteGeneration++;
61
+ if (this._community && this._readBackWithoutStoringDepth === 0)
62
+ this._community._communityUpdateTrigger = true;
63
+ }
55
64
  constructor(community) {
56
65
  this._transactionGeneration = 0;
57
66
  // Advanced by every write to the publication tables (comments, votes, edits, moderations, aliases, purges). The
58
67
  // update cycle's author memo (CommunityAuthorMemo) is only reused while it stays the same.
59
68
  this._publicationWriteGeneration = 0;
69
+ this._readBackWithoutStoringDepth = 0;
60
70
  // The address this handler has claimed the start of, from lockCommunityStart until unlockCommunityStart
61
71
  this._startLockAddress = undefined;
62
72
  this._community = community;
@@ -237,11 +247,15 @@ export class DbHandler {
237
247
  // no transaction open (issue #417).
238
248
  readBackWithoutStoring(opts) {
239
249
  this._db.exec("SAVEPOINT read_back_without_storing");
250
+ this._readBackWithoutStoringDepth++;
240
251
  try {
241
252
  opts.write();
242
253
  return opts.read();
243
254
  }
244
255
  finally {
256
+ this._readBackWithoutStoringDepth--;
257
+ // what was memoized inside the savepoint was read from rows that are about to be gone
258
+ this._publicationWriteGeneration++;
245
259
  this._db.exec("ROLLBACK TO read_back_without_storing");
246
260
  this._db.exec("RELEASE read_back_without_storing");
247
261
  }
@@ -1023,18 +1037,18 @@ export class DbHandler {
1023
1037
  }
1024
1038
  }
1025
1039
  deleteVote(authorSignerAddress, commentCid) {
1026
- this._publicationWriteGeneration++;
1040
+ this._notePublicationWrite();
1027
1041
  this._db
1028
1042
  .prepare(`DELETE FROM ${TABLES.VOTES} WHERE commentCid = ? AND authorSignerAddress = ?`)
1029
1043
  .run(commentCid, authorSignerAddress);
1030
1044
  }
1031
1045
  _deleteCommentEditRow(rowid) {
1032
- this._publicationWriteGeneration++;
1046
+ this._notePublicationWrite();
1033
1047
  const deleteResult = this._db.prepare(`DELETE FROM ${TABLES.COMMENT_EDITS} WHERE rowid = ?`).run(rowid);
1034
1048
  return deleteResult.changes > 0;
1035
1049
  }
1036
1050
  insertVotes(votes) {
1037
- this._publicationWriteGeneration++;
1051
+ this._notePublicationWrite();
1038
1052
  if (votes.length === 0)
1039
1053
  return;
1040
1054
  const processedVotes = this._processRecordsForDbBeforeInsert(votes);
@@ -1062,7 +1076,7 @@ export class DbHandler {
1062
1076
  insertMany(processedVotes);
1063
1077
  }
1064
1078
  insertComments(comments) {
1065
- this._publicationWriteGeneration++;
1079
+ this._notePublicationWrite();
1066
1080
  if (comments.length === 0)
1067
1081
  return;
1068
1082
  const processedComments = this._processRecordsForDbBeforeInsert(comments);
@@ -1087,7 +1101,7 @@ export class DbHandler {
1087
1101
  insertMany(processedComments);
1088
1102
  }
1089
1103
  insertPseudonymityAliases(aliases) {
1090
- this._publicationWriteGeneration++;
1104
+ this._notePublicationWrite();
1091
1105
  if (aliases.length === 0)
1092
1106
  return;
1093
1107
  const processedAliases = this._processRecordsForDbBeforeInsert(aliases).map((alias) => ({
@@ -1137,7 +1151,7 @@ export class DbHandler {
1137
1151
  upsertMany(processedUpdates);
1138
1152
  }
1139
1153
  insertCommentModerations(moderations) {
1140
- this._publicationWriteGeneration++;
1154
+ this._notePublicationWrite();
1141
1155
  if (moderations.length === 0)
1142
1156
  return;
1143
1157
  const processedModerations = this._processRecordsForDbBeforeInsert(moderations);
@@ -1160,7 +1174,7 @@ export class DbHandler {
1160
1174
  insertMany(processedModerations);
1161
1175
  }
1162
1176
  insertCommentEdits(edits) {
1163
- this._publicationWriteGeneration++;
1177
+ this._notePublicationWrite();
1164
1178
  if (edits.length === 0)
1165
1179
  return;
1166
1180
  const processedEdits = this._processRecordsForDbBeforeInsert(edits);
@@ -2094,7 +2108,7 @@ export class DbHandler {
2094
2108
  return pick(parsed, ["signature", ...signedKeys, ...commentEditFields]);
2095
2109
  }
2096
2110
  removeCommentFromPendingApproval(comment) {
2097
- this._publicationWriteGeneration++;
2111
+ this._notePublicationWrite();
2098
2112
  const log = Logger("pkc-js:local-community:db-handler:removeCommentFromPendingApproval");
2099
2113
  const stmt = this._db.prepare(`UPDATE ${TABLES.COMMENTS} SET pendingApproval = 0 WHERE cid = ?`);
2100
2114
  const res = stmt.run(comment.cid);
@@ -2937,7 +2951,7 @@ export class DbHandler {
2937
2951
  return allCids;
2938
2952
  }
2939
2953
  purgeComment(cid, isNestedCall = false) {
2940
- this._publicationWriteGeneration++;
2954
+ this._notePublicationWrite();
2941
2955
  const log = Logger("pkc-js:local-community:db-handler:purgeComment");
2942
2956
  const purgedRecords = [];
2943
2957
  const detachedPageCids = [];