@atlaskit/editor-synced-block-provider 20.0.1 → 20.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 20.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 20.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`c239b60db852a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c239b60db852a) -
14
+ Flush removed references that disappear before the first save under
15
+ platform_editor_blocks_patch_11
16
+ - Updated dependencies
17
+
3
18
  ## 20.0.1
4
19
 
5
20
  ### Patch Changes
@@ -57,6 +57,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
57
57
  (0, _defineProperty2.default)(this, "isCacheDirty", true);
58
58
  // Keep track of the last flushed subscriptions to optimize cache flushing on document save
59
59
  (0, _defineProperty2.default)(this, "lastFlushedSyncedBlocks", {});
60
+ (0, _defineProperty2.default)(this, "subscribedSinceLastFlush", false);
60
61
  // Track if a flush operation is currently in progress
61
62
  (0, _defineProperty2.default)(this, "isFlushInProgress", false);
62
63
  // Track if another flush is needed after the current one completes
@@ -978,6 +979,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
978
979
  value: function subscribeToSyncBlock(resourceId, localId, callback) {
979
980
  var _this$sourceManager2,
980
981
  _this9 = this;
982
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_11')) {
983
+ this.subscribedSinceLastFlush = true;
984
+ }
981
985
  var isSamePageSyncEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('editor-synced-block-same-page-sync');
982
986
  var sameDocumentParts = isSamePageSyncEnabled ? this.getSameDocumentReferenceParts(resourceId) : undefined;
983
987
  var localReference = isSamePageSyncEnabled ? this.getLocalReference(resourceId) : undefined;
@@ -1094,7 +1098,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
1094
1098
  value: (function () {
1095
1099
  var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
1096
1100
  var _this0 = this;
1097
- var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
1101
+ var subscribedSinceLastFlushToFlush, success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
1098
1102
  return _regenerator.default.wrap(function (_context4) {
1099
1103
  while (1) switch (_context4.prev = _context4.next) {
1100
1104
  case 0:
@@ -1122,6 +1126,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
1122
1126
  case 3:
1123
1127
  this.isFlushInProgress = true;
1124
1128
  case 4:
1129
+ subscribedSinceLastFlushToFlush = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_11') && this.subscribedSinceLastFlush;
1130
+ this.subscribedSinceLastFlush = false;
1125
1131
  success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
1126
1132
  // To be saved as the last flushed structure if the flush is successful
1127
1133
  syncedBlocksToFlush = {};
@@ -1177,7 +1183,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
1177
1183
  _iterator.f();
1178
1184
  return _context4.finish(12);
1179
1185
  case 13:
1180
- if (!(0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
1186
+ if (!(!subscribedSinceLastFlushToFlush && (0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks))) {
1181
1187
  _context4.next = 14;
1182
1188
  break;
1183
1189
  }
@@ -1223,6 +1229,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
1223
1229
  if (!success) {
1224
1230
  // set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
1225
1231
  this.isCacheDirty = true;
1232
+ this.subscribedSinceLastFlush || (this.subscribedSinceLastFlush = subscribedSinceLastFlushToFlush);
1226
1233
  } else {
1227
1234
  this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
1228
1235
  (_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
@@ -37,6 +37,7 @@ export class ReferenceSyncBlockStoreManager {
37
37
  _defineProperty(this, "isCacheDirty", true);
38
38
  // Keep track of the last flushed subscriptions to optimize cache flushing on document save
39
39
  _defineProperty(this, "lastFlushedSyncedBlocks", {});
40
+ _defineProperty(this, "subscribedSinceLastFlush", false);
40
41
  // Track if a flush operation is currently in progress
41
42
  _defineProperty(this, "isFlushInProgress", false);
42
43
  // Track if another flush is needed after the current one completes
@@ -819,6 +820,9 @@ export class ReferenceSyncBlockStoreManager {
819
820
  }
820
821
  subscribeToSyncBlock(resourceId, localId, callback) {
821
822
  var _this$sourceManager2;
823
+ if (isExperimentEnabled('platform_editor_blocks_patch_11')) {
824
+ this.subscribedSinceLastFlush = true;
825
+ }
822
826
  const isSamePageSyncEnabled = isExperimentEnabled('editor-synced-block-same-page-sync');
823
827
  const sameDocumentParts = isSamePageSyncEnabled ? this.getSameDocumentReferenceParts(resourceId) : undefined;
824
828
  let localReference = isSamePageSyncEnabled ? this.getLocalReference(resourceId) : undefined;
@@ -938,6 +942,8 @@ export class ReferenceSyncBlockStoreManager {
938
942
  } else {
939
943
  this.isFlushInProgress = true;
940
944
  }
945
+ const subscribedSinceLastFlushToFlush = isExperimentEnabled('platform_editor_blocks_patch_11') && this.subscribedSinceLastFlush;
946
+ this.subscribedSinceLastFlush = false;
941
947
  let success = true;
942
948
  // a copy of the subscriptions STRUCTURE (without the callbacks)
943
949
  // To be saved as the last flushed structure if the flush is successful
@@ -963,9 +969,8 @@ export class ReferenceSyncBlockStoreManager {
963
969
 
964
970
  // Then, compare with the last flushed structure to detect changes
965
971
  // We check against the last flushed structure to prevent unnecessary flushes
966
- // Note that we will always flush at least once when editor starts
967
- // This is useful for eventual consistency between the editor and the BE.
968
- if (isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
972
+ // A reference can subscribe and disappear before the first flush, leaving both structures empty.
973
+ if (!subscribedSinceLastFlushToFlush && isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
969
974
  this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
970
975
  return true;
971
976
  }
@@ -1002,6 +1007,7 @@ export class ReferenceSyncBlockStoreManager {
1002
1007
  if (!success) {
1003
1008
  // set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
1004
1009
  this.isCacheDirty = true;
1010
+ this.subscribedSinceLastFlush ||= subscribedSinceLastFlushToFlush;
1005
1011
  } else {
1006
1012
  var _this$saveExperience4;
1007
1013
  this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
@@ -50,6 +50,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
50
50
  _defineProperty(this, "isCacheDirty", true);
51
51
  // Keep track of the last flushed subscriptions to optimize cache flushing on document save
52
52
  _defineProperty(this, "lastFlushedSyncedBlocks", {});
53
+ _defineProperty(this, "subscribedSinceLastFlush", false);
53
54
  // Track if a flush operation is currently in progress
54
55
  _defineProperty(this, "isFlushInProgress", false);
55
56
  // Track if another flush is needed after the current one completes
@@ -971,6 +972,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
971
972
  value: function subscribeToSyncBlock(resourceId, localId, callback) {
972
973
  var _this$sourceManager2,
973
974
  _this9 = this;
975
+ if (isExperimentEnabled('platform_editor_blocks_patch_11')) {
976
+ this.subscribedSinceLastFlush = true;
977
+ }
974
978
  var isSamePageSyncEnabled = isExperimentEnabled('editor-synced-block-same-page-sync');
975
979
  var sameDocumentParts = isSamePageSyncEnabled ? this.getSameDocumentReferenceParts(resourceId) : undefined;
976
980
  var localReference = isSamePageSyncEnabled ? this.getLocalReference(resourceId) : undefined;
@@ -1087,7 +1091,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
1087
1091
  value: (function () {
1088
1092
  var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
1089
1093
  var _this0 = this;
1090
- var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
1094
+ var subscribedSinceLastFlushToFlush, success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
1091
1095
  return _regeneratorRuntime.wrap(function (_context4) {
1092
1096
  while (1) switch (_context4.prev = _context4.next) {
1093
1097
  case 0:
@@ -1115,6 +1119,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
1115
1119
  case 3:
1116
1120
  this.isFlushInProgress = true;
1117
1121
  case 4:
1122
+ subscribedSinceLastFlushToFlush = isExperimentEnabled('platform_editor_blocks_patch_11') && this.subscribedSinceLastFlush;
1123
+ this.subscribedSinceLastFlush = false;
1118
1124
  success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
1119
1125
  // To be saved as the last flushed structure if the flush is successful
1120
1126
  syncedBlocksToFlush = {};
@@ -1170,7 +1176,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
1170
1176
  _iterator.f();
1171
1177
  return _context4.finish(12);
1172
1178
  case 13:
1173
- if (!isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
1179
+ if (!(!subscribedSinceLastFlushToFlush && isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks))) {
1174
1180
  _context4.next = 14;
1175
1181
  break;
1176
1182
  }
@@ -1216,6 +1222,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
1216
1222
  if (!success) {
1217
1223
  // set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
1218
1224
  this.isCacheDirty = true;
1225
+ this.subscribedSinceLastFlush || (this.subscribedSinceLastFlush = subscribedSinceLastFlushToFlush);
1219
1226
  } else {
1220
1227
  this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
1221
1228
  (_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
@@ -16,6 +16,7 @@ export declare class ReferenceSyncBlockStoreManager {
16
16
  private syncBlockSourceInfoRequests;
17
17
  private newlyAddedSyncBlocks;
18
18
  private lastFlushedSyncedBlocks;
19
+ private subscribedSinceLastFlush;
19
20
  private onUnpublishedSyncBlockDetected?;
20
21
  private isFlushInProgress;
21
22
  private flushNeededAfterCurrent;
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "@atlaskit/node-data-provider": "^25.0.0",
24
24
  "@atlaskit/platform-feature-experiments": "^0.3.0",
25
25
  "@atlaskit/platform-feature-flags": "^2.2.0",
26
- "@atlaskit/tmp-editor-statsig": "^221.0.0",
26
+ "@atlaskit/tmp-editor-statsig": "^223.0.0",
27
27
  "@babel/runtime": "^7.0.0",
28
28
  "@compiled/react": "^1.0.2",
29
29
  "bind-event-listener": "^3.0.0",
@@ -33,7 +33,7 @@
33
33
  "uuid": "^11.1.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@atlaskit/editor-common": "^128.1.0",
36
+ "@atlaskit/editor-common": "^128.3.0",
37
37
  "react": "^18.2.0 || ^19.2.0"
38
38
  },
39
39
  "devDependencies": {
@@ -42,7 +42,7 @@
42
42
  "react-dom": "^19.2.0"
43
43
  },
44
44
  "name": "@atlaskit/editor-synced-block-provider",
45
- "version": "20.0.1",
45
+ "version": "20.0.3",
46
46
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
47
47
  "author": "Atlassian Pty Ltd",
48
48
  "license": "Apache-2.0",