@atlaskit/editor-synced-block-provider 3.30.4 → 3.30.5
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,13 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.30.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`85444e8a5672a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/85444e8a5672a) -
|
|
8
|
+
EDITOR-5526 clean up platform_synced_block_patch_2
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 3.30.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -858,17 +858,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
858
858
|
}, {
|
|
859
859
|
key: "debouncedBatchedFetchSyncBlocks",
|
|
860
860
|
value: function debouncedBatchedFetchSyncBlocks(resourceId) {
|
|
861
|
-
if
|
|
862
|
-
|
|
863
|
-
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
864
|
-
this.pendingFetchRequests.add(resourceId);
|
|
865
|
-
this.scheduledBatchFetch();
|
|
866
|
-
} else {
|
|
867
|
-
this.pendingFetchRequests.delete(resourceId);
|
|
868
|
-
}
|
|
869
|
-
} else {
|
|
861
|
+
// Only add to pending requests if there are active subscriptions for this resource
|
|
862
|
+
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
870
863
|
this.pendingFetchRequests.add(resourceId);
|
|
871
864
|
this.scheduledBatchFetch();
|
|
865
|
+
} else {
|
|
866
|
+
this.pendingFetchRequests.delete(resourceId);
|
|
872
867
|
}
|
|
873
868
|
}
|
|
874
869
|
}, {
|
|
@@ -1191,12 +1186,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1191
1186
|
}
|
|
1192
1187
|
return _context6.abrupt("return", true);
|
|
1193
1188
|
case 2:
|
|
1194
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
|
|
1195
|
-
_context6.next = 9;
|
|
1196
|
-
break;
|
|
1197
|
-
}
|
|
1198
1189
|
if (!this.isFlushInProgress) {
|
|
1199
|
-
_context6.next =
|
|
1190
|
+
_context6.next = 7;
|
|
1200
1191
|
break;
|
|
1201
1192
|
}
|
|
1202
1193
|
// Mark that another flush is needed after the current one completes
|
|
@@ -1204,27 +1195,22 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1204
1195
|
|
|
1205
1196
|
// We return true here because we know the pending flush will handle the dirty cache
|
|
1206
1197
|
return _context6.abrupt("return", true);
|
|
1207
|
-
case
|
|
1198
|
+
case 7:
|
|
1208
1199
|
this.isFlushInProgress = true;
|
|
1209
|
-
case
|
|
1200
|
+
case 8:
|
|
1210
1201
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
1211
1202
|
// To be saved as the last flushed structure if the flush is successful
|
|
1212
1203
|
syncedBlocksToFlush = {};
|
|
1213
|
-
_context6.prev =
|
|
1204
|
+
_context6.prev = 10;
|
|
1214
1205
|
if (this.dataProvider) {
|
|
1215
|
-
_context6.next =
|
|
1206
|
+
_context6.next = 13;
|
|
1216
1207
|
break;
|
|
1217
1208
|
}
|
|
1218
1209
|
throw new Error('Data provider not set');
|
|
1219
|
-
case
|
|
1220
|
-
blocks = [];
|
|
1221
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
|
|
1222
|
-
_context6.next = 37;
|
|
1223
|
-
break;
|
|
1224
|
-
}
|
|
1225
|
-
// First, build the complete subscription structure
|
|
1210
|
+
case 13:
|
|
1211
|
+
blocks = []; // First, build the complete subscription structure
|
|
1226
1212
|
_iterator4 = _createForOfIteratorHelper(this.subscriptions.entries());
|
|
1227
|
-
_context6.prev =
|
|
1213
|
+
_context6.prev = 15;
|
|
1228
1214
|
_loop2 = /*#__PURE__*/_regenerator.default.mark(function _loop2() {
|
|
1229
1215
|
var _step4$value, resourceId, callbacks;
|
|
1230
1216
|
return _regenerator.default.wrap(function _loop2$(_context5) {
|
|
@@ -1246,50 +1232,34 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1246
1232
|
}, _loop2);
|
|
1247
1233
|
});
|
|
1248
1234
|
_iterator4.s();
|
|
1249
|
-
case
|
|
1235
|
+
case 18:
|
|
1250
1236
|
if ((_step4 = _iterator4.n()).done) {
|
|
1251
|
-
_context6.next =
|
|
1237
|
+
_context6.next = 22;
|
|
1252
1238
|
break;
|
|
1253
1239
|
}
|
|
1254
|
-
return _context6.delegateYield(_loop2(), "t0",
|
|
1240
|
+
return _context6.delegateYield(_loop2(), "t0", 20);
|
|
1241
|
+
case 20:
|
|
1242
|
+
_context6.next = 18;
|
|
1243
|
+
break;
|
|
1255
1244
|
case 22:
|
|
1256
|
-
_context6.next =
|
|
1245
|
+
_context6.next = 27;
|
|
1257
1246
|
break;
|
|
1258
1247
|
case 24:
|
|
1259
|
-
_context6.
|
|
1260
|
-
|
|
1261
|
-
case 26:
|
|
1262
|
-
_context6.prev = 26;
|
|
1263
|
-
_context6.t1 = _context6["catch"](17);
|
|
1248
|
+
_context6.prev = 24;
|
|
1249
|
+
_context6.t1 = _context6["catch"](15);
|
|
1264
1250
|
_iterator4.e(_context6.t1);
|
|
1265
|
-
case
|
|
1266
|
-
_context6.prev =
|
|
1251
|
+
case 27:
|
|
1252
|
+
_context6.prev = 27;
|
|
1267
1253
|
_iterator4.f();
|
|
1268
|
-
return _context6.finish(
|
|
1269
|
-
case
|
|
1254
|
+
return _context6.finish(27);
|
|
1255
|
+
case 30:
|
|
1270
1256
|
if (!(0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
1271
|
-
_context6.next =
|
|
1257
|
+
_context6.next = 33;
|
|
1272
1258
|
break;
|
|
1273
1259
|
}
|
|
1274
1260
|
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
1275
1261
|
return _context6.abrupt("return", true);
|
|
1276
|
-
case
|
|
1277
|
-
_context6.next = 38;
|
|
1278
|
-
break;
|
|
1279
|
-
case 37:
|
|
1280
|
-
// Collect all reference synced blocks on the current document
|
|
1281
|
-
Array.from(this.subscriptions.entries()).forEach(function (_ref2) {
|
|
1282
|
-
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
1283
|
-
resourceId = _ref3[0],
|
|
1284
|
-
callbacks = _ref3[1];
|
|
1285
|
-
Object.keys(callbacks).forEach(function (localId) {
|
|
1286
|
-
blocks.push({
|
|
1287
|
-
resourceId: resourceId,
|
|
1288
|
-
localId: localId
|
|
1289
|
-
});
|
|
1290
|
-
});
|
|
1291
|
-
});
|
|
1292
|
-
case 38:
|
|
1262
|
+
case 33:
|
|
1293
1263
|
// reset isCacheDirty early to prevent race condition
|
|
1294
1264
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
1295
1265
|
// on a live page and the reference sync block is being saved while the user
|
|
@@ -1297,9 +1267,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1297
1267
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
1298
1268
|
this.isCacheDirty = false;
|
|
1299
1269
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
1300
|
-
_context6.next =
|
|
1270
|
+
_context6.next = 37;
|
|
1301
1271
|
return this.dataProvider.updateReferenceData(blocks);
|
|
1302
|
-
case
|
|
1272
|
+
case 37:
|
|
1303
1273
|
updateResult = _context6.sent;
|
|
1304
1274
|
if (!updateResult.success) {
|
|
1305
1275
|
success = false;
|
|
@@ -1308,11 +1278,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1308
1278
|
});
|
|
1309
1279
|
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1310
1280
|
}
|
|
1311
|
-
_context6.next =
|
|
1281
|
+
_context6.next = 47;
|
|
1312
1282
|
break;
|
|
1313
|
-
case
|
|
1314
|
-
_context6.prev =
|
|
1315
|
-
_context6.t2 = _context6["catch"](
|
|
1283
|
+
case 41:
|
|
1284
|
+
_context6.prev = 41;
|
|
1285
|
+
_context6.t2 = _context6["catch"](10);
|
|
1316
1286
|
success = false;
|
|
1317
1287
|
(0, _monitoring.logException)(_context6.t2, {
|
|
1318
1288
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
@@ -1321,40 +1291,37 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1321
1291
|
reason: _context6.t2.message
|
|
1322
1292
|
});
|
|
1323
1293
|
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 || _this$fireAnalyticsEv10.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context6.t2.message));
|
|
1324
|
-
case
|
|
1325
|
-
_context6.prev =
|
|
1294
|
+
case 47:
|
|
1295
|
+
_context6.prev = 47;
|
|
1326
1296
|
if (!success) {
|
|
1327
1297
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1328
1298
|
this.isCacheDirty = true;
|
|
1329
1299
|
} else {
|
|
1330
|
-
|
|
1331
|
-
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1332
|
-
}
|
|
1300
|
+
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1333
1301
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
1334
1302
|
}
|
|
1335
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
|
|
1336
|
-
// Always reset isFlushInProgress regardless of feature flag
|
|
1337
|
-
this.isFlushInProgress = false;
|
|
1338
1303
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1304
|
+
// Always reset isFlushInProgress
|
|
1305
|
+
this.isFlushInProgress = false;
|
|
1306
|
+
|
|
1307
|
+
// If another flush was requested while this one was in progress, execute it now
|
|
1308
|
+
if (this.flushNeededAfterCurrent) {
|
|
1309
|
+
this.flushNeededAfterCurrent = false;
|
|
1310
|
+
// Use setTimeout to avoid deep recursion and run queued flush asynchronously
|
|
1311
|
+
// Note: flush() handles all exceptions internally and never rejects
|
|
1312
|
+
this.queuedFlushTimeout = setTimeout(function () {
|
|
1313
|
+
_this11.queuedFlushTimeout = undefined;
|
|
1314
|
+
void _this11.flush();
|
|
1315
|
+
}, 0);
|
|
1349
1316
|
}
|
|
1350
|
-
return _context6.finish(
|
|
1351
|
-
case
|
|
1317
|
+
return _context6.finish(47);
|
|
1318
|
+
case 52:
|
|
1352
1319
|
return _context6.abrupt("return", success);
|
|
1353
|
-
case
|
|
1320
|
+
case 53:
|
|
1354
1321
|
case "end":
|
|
1355
1322
|
return _context6.stop();
|
|
1356
1323
|
}
|
|
1357
|
-
}, _callee4, this, [[
|
|
1324
|
+
}, _callee4, this, [[10, 41, 47, 52], [15, 24, 27, 30]]);
|
|
1358
1325
|
}));
|
|
1359
1326
|
function flush() {
|
|
1360
1327
|
return _flush.apply(this, arguments);
|
|
@@ -659,17 +659,12 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
659
659
|
this.providerFactories.delete(resourceId);
|
|
660
660
|
}
|
|
661
661
|
debouncedBatchedFetchSyncBlocks(resourceId) {
|
|
662
|
-
if
|
|
663
|
-
|
|
664
|
-
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
665
|
-
this.pendingFetchRequests.add(resourceId);
|
|
666
|
-
this.scheduledBatchFetch();
|
|
667
|
-
} else {
|
|
668
|
-
this.pendingFetchRequests.delete(resourceId);
|
|
669
|
-
}
|
|
670
|
-
} else {
|
|
662
|
+
// Only add to pending requests if there are active subscriptions for this resource
|
|
663
|
+
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
671
664
|
this.pendingFetchRequests.add(resourceId);
|
|
672
665
|
this.scheduledBatchFetch();
|
|
666
|
+
} else {
|
|
667
|
+
this.pendingFetchRequests.delete(resourceId);
|
|
673
668
|
}
|
|
674
669
|
}
|
|
675
670
|
setSSRDataInSessionCache(resourceIds) {
|
|
@@ -979,16 +974,14 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
979
974
|
}
|
|
980
975
|
|
|
981
976
|
// Prevent concurrent flushes to avoid race conditions with lastFlushedSyncedBlocks
|
|
982
|
-
if (
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
this.flushNeededAfterCurrent = true;
|
|
977
|
+
if (this.isFlushInProgress) {
|
|
978
|
+
// Mark that another flush is needed after the current one completes
|
|
979
|
+
this.flushNeededAfterCurrent = true;
|
|
986
980
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
981
|
+
// We return true here because we know the pending flush will handle the dirty cache
|
|
982
|
+
return true;
|
|
983
|
+
} else {
|
|
984
|
+
this.isFlushInProgress = true;
|
|
992
985
|
}
|
|
993
986
|
let success = true;
|
|
994
987
|
// a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
@@ -1000,39 +993,28 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1000
993
|
throw new Error('Data provider not set');
|
|
1001
994
|
}
|
|
1002
995
|
const blocks = [];
|
|
1003
|
-
if (fg('platform_synced_block_patch_2')) {
|
|
1004
|
-
// First, build the complete subscription structure
|
|
1005
|
-
for (const [resourceId, callbacks] of this.subscriptions.entries()) {
|
|
1006
|
-
syncedBlocksToFlush[resourceId] = {};
|
|
1007
|
-
Object.keys(callbacks).forEach(localId => {
|
|
1008
|
-
blocks.push({
|
|
1009
|
-
resourceId,
|
|
1010
|
-
localId
|
|
1011
|
-
});
|
|
1012
|
-
syncedBlocksToFlush[resourceId][localId] = true;
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
996
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
}
|
|
1024
|
-
} else {
|
|
1025
|
-
// Collect all reference synced blocks on the current document
|
|
1026
|
-
Array.from(this.subscriptions.entries()).forEach(([resourceId, callbacks]) => {
|
|
1027
|
-
Object.keys(callbacks).forEach(localId => {
|
|
1028
|
-
blocks.push({
|
|
1029
|
-
resourceId,
|
|
1030
|
-
localId
|
|
1031
|
-
});
|
|
997
|
+
// First, build the complete subscription structure
|
|
998
|
+
for (const [resourceId, callbacks] of this.subscriptions.entries()) {
|
|
999
|
+
syncedBlocksToFlush[resourceId] = {};
|
|
1000
|
+
Object.keys(callbacks).forEach(localId => {
|
|
1001
|
+
blocks.push({
|
|
1002
|
+
resourceId,
|
|
1003
|
+
localId
|
|
1032
1004
|
});
|
|
1005
|
+
syncedBlocksToFlush[resourceId][localId] = true;
|
|
1033
1006
|
});
|
|
1034
1007
|
}
|
|
1035
1008
|
|
|
1009
|
+
// Then, compare with the last flushed structure to detect changes
|
|
1010
|
+
// We check against the last flushed structure to prevent unnecessary flushes
|
|
1011
|
+
// Note that we will always flush at least once when editor starts
|
|
1012
|
+
// This is useful for eventual consistency between the editor and the BE.
|
|
1013
|
+
if (isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
1014
|
+
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
1015
|
+
return true;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1036
1018
|
// reset isCacheDirty early to prevent race condition
|
|
1037
1019
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
1038
1020
|
// on a live page and the reference sync block is being saved while the user
|
|
@@ -1065,25 +1047,22 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1065
1047
|
this.isCacheDirty = true;
|
|
1066
1048
|
} else {
|
|
1067
1049
|
var _this$saveExperience4;
|
|
1068
|
-
|
|
1069
|
-
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1070
|
-
}
|
|
1050
|
+
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1071
1051
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 ? void 0 : _this$saveExperience4.success();
|
|
1072
1052
|
}
|
|
1073
|
-
if (fg('platform_synced_block_patch_2')) {
|
|
1074
|
-
// Always reset isFlushInProgress regardless of feature flag
|
|
1075
|
-
this.isFlushInProgress = false;
|
|
1076
1053
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1054
|
+
// Always reset isFlushInProgress
|
|
1055
|
+
this.isFlushInProgress = false;
|
|
1056
|
+
|
|
1057
|
+
// If another flush was requested while this one was in progress, execute it now
|
|
1058
|
+
if (this.flushNeededAfterCurrent) {
|
|
1059
|
+
this.flushNeededAfterCurrent = false;
|
|
1060
|
+
// Use setTimeout to avoid deep recursion and run queued flush asynchronously
|
|
1061
|
+
// Note: flush() handles all exceptions internally and never rejects
|
|
1062
|
+
this.queuedFlushTimeout = setTimeout(() => {
|
|
1063
|
+
this.queuedFlushTimeout = undefined;
|
|
1064
|
+
void this.flush();
|
|
1065
|
+
}, 0);
|
|
1087
1066
|
}
|
|
1088
1067
|
}
|
|
1089
1068
|
return success;
|
|
@@ -851,17 +851,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
851
851
|
}, {
|
|
852
852
|
key: "debouncedBatchedFetchSyncBlocks",
|
|
853
853
|
value: function debouncedBatchedFetchSyncBlocks(resourceId) {
|
|
854
|
-
if
|
|
855
|
-
|
|
856
|
-
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
857
|
-
this.pendingFetchRequests.add(resourceId);
|
|
858
|
-
this.scheduledBatchFetch();
|
|
859
|
-
} else {
|
|
860
|
-
this.pendingFetchRequests.delete(resourceId);
|
|
861
|
-
}
|
|
862
|
-
} else {
|
|
854
|
+
// Only add to pending requests if there are active subscriptions for this resource
|
|
855
|
+
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
863
856
|
this.pendingFetchRequests.add(resourceId);
|
|
864
857
|
this.scheduledBatchFetch();
|
|
858
|
+
} else {
|
|
859
|
+
this.pendingFetchRequests.delete(resourceId);
|
|
865
860
|
}
|
|
866
861
|
}
|
|
867
862
|
}, {
|
|
@@ -1184,12 +1179,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1184
1179
|
}
|
|
1185
1180
|
return _context6.abrupt("return", true);
|
|
1186
1181
|
case 2:
|
|
1187
|
-
if (!fg('platform_synced_block_patch_2')) {
|
|
1188
|
-
_context6.next = 9;
|
|
1189
|
-
break;
|
|
1190
|
-
}
|
|
1191
1182
|
if (!this.isFlushInProgress) {
|
|
1192
|
-
_context6.next =
|
|
1183
|
+
_context6.next = 7;
|
|
1193
1184
|
break;
|
|
1194
1185
|
}
|
|
1195
1186
|
// Mark that another flush is needed after the current one completes
|
|
@@ -1197,27 +1188,22 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1197
1188
|
|
|
1198
1189
|
// We return true here because we know the pending flush will handle the dirty cache
|
|
1199
1190
|
return _context6.abrupt("return", true);
|
|
1200
|
-
case
|
|
1191
|
+
case 7:
|
|
1201
1192
|
this.isFlushInProgress = true;
|
|
1202
|
-
case
|
|
1193
|
+
case 8:
|
|
1203
1194
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
1204
1195
|
// To be saved as the last flushed structure if the flush is successful
|
|
1205
1196
|
syncedBlocksToFlush = {};
|
|
1206
|
-
_context6.prev =
|
|
1197
|
+
_context6.prev = 10;
|
|
1207
1198
|
if (this.dataProvider) {
|
|
1208
|
-
_context6.next =
|
|
1199
|
+
_context6.next = 13;
|
|
1209
1200
|
break;
|
|
1210
1201
|
}
|
|
1211
1202
|
throw new Error('Data provider not set');
|
|
1212
|
-
case
|
|
1213
|
-
blocks = [];
|
|
1214
|
-
if (!fg('platform_synced_block_patch_2')) {
|
|
1215
|
-
_context6.next = 37;
|
|
1216
|
-
break;
|
|
1217
|
-
}
|
|
1218
|
-
// First, build the complete subscription structure
|
|
1203
|
+
case 13:
|
|
1204
|
+
blocks = []; // First, build the complete subscription structure
|
|
1219
1205
|
_iterator4 = _createForOfIteratorHelper(this.subscriptions.entries());
|
|
1220
|
-
_context6.prev =
|
|
1206
|
+
_context6.prev = 15;
|
|
1221
1207
|
_loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2() {
|
|
1222
1208
|
var _step4$value, resourceId, callbacks;
|
|
1223
1209
|
return _regeneratorRuntime.wrap(function _loop2$(_context5) {
|
|
@@ -1239,50 +1225,34 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1239
1225
|
}, _loop2);
|
|
1240
1226
|
});
|
|
1241
1227
|
_iterator4.s();
|
|
1242
|
-
case
|
|
1228
|
+
case 18:
|
|
1243
1229
|
if ((_step4 = _iterator4.n()).done) {
|
|
1244
|
-
_context6.next =
|
|
1230
|
+
_context6.next = 22;
|
|
1245
1231
|
break;
|
|
1246
1232
|
}
|
|
1247
|
-
return _context6.delegateYield(_loop2(), "t0",
|
|
1233
|
+
return _context6.delegateYield(_loop2(), "t0", 20);
|
|
1234
|
+
case 20:
|
|
1235
|
+
_context6.next = 18;
|
|
1236
|
+
break;
|
|
1248
1237
|
case 22:
|
|
1249
|
-
_context6.next =
|
|
1238
|
+
_context6.next = 27;
|
|
1250
1239
|
break;
|
|
1251
1240
|
case 24:
|
|
1252
|
-
_context6.
|
|
1253
|
-
|
|
1254
|
-
case 26:
|
|
1255
|
-
_context6.prev = 26;
|
|
1256
|
-
_context6.t1 = _context6["catch"](17);
|
|
1241
|
+
_context6.prev = 24;
|
|
1242
|
+
_context6.t1 = _context6["catch"](15);
|
|
1257
1243
|
_iterator4.e(_context6.t1);
|
|
1258
|
-
case
|
|
1259
|
-
_context6.prev =
|
|
1244
|
+
case 27:
|
|
1245
|
+
_context6.prev = 27;
|
|
1260
1246
|
_iterator4.f();
|
|
1261
|
-
return _context6.finish(
|
|
1262
|
-
case
|
|
1247
|
+
return _context6.finish(27);
|
|
1248
|
+
case 30:
|
|
1263
1249
|
if (!isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
1264
|
-
_context6.next =
|
|
1250
|
+
_context6.next = 33;
|
|
1265
1251
|
break;
|
|
1266
1252
|
}
|
|
1267
1253
|
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
1268
1254
|
return _context6.abrupt("return", true);
|
|
1269
|
-
case
|
|
1270
|
-
_context6.next = 38;
|
|
1271
|
-
break;
|
|
1272
|
-
case 37:
|
|
1273
|
-
// Collect all reference synced blocks on the current document
|
|
1274
|
-
Array.from(this.subscriptions.entries()).forEach(function (_ref2) {
|
|
1275
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
1276
|
-
resourceId = _ref3[0],
|
|
1277
|
-
callbacks = _ref3[1];
|
|
1278
|
-
Object.keys(callbacks).forEach(function (localId) {
|
|
1279
|
-
blocks.push({
|
|
1280
|
-
resourceId: resourceId,
|
|
1281
|
-
localId: localId
|
|
1282
|
-
});
|
|
1283
|
-
});
|
|
1284
|
-
});
|
|
1285
|
-
case 38:
|
|
1255
|
+
case 33:
|
|
1286
1256
|
// reset isCacheDirty early to prevent race condition
|
|
1287
1257
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
1288
1258
|
// on a live page and the reference sync block is being saved while the user
|
|
@@ -1290,9 +1260,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1290
1260
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
1291
1261
|
this.isCacheDirty = false;
|
|
1292
1262
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
1293
|
-
_context6.next =
|
|
1263
|
+
_context6.next = 37;
|
|
1294
1264
|
return this.dataProvider.updateReferenceData(blocks);
|
|
1295
|
-
case
|
|
1265
|
+
case 37:
|
|
1296
1266
|
updateResult = _context6.sent;
|
|
1297
1267
|
if (!updateResult.success) {
|
|
1298
1268
|
success = false;
|
|
@@ -1301,11 +1271,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1301
1271
|
});
|
|
1302
1272
|
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1303
1273
|
}
|
|
1304
|
-
_context6.next =
|
|
1274
|
+
_context6.next = 47;
|
|
1305
1275
|
break;
|
|
1306
|
-
case
|
|
1307
|
-
_context6.prev =
|
|
1308
|
-
_context6.t2 = _context6["catch"](
|
|
1276
|
+
case 41:
|
|
1277
|
+
_context6.prev = 41;
|
|
1278
|
+
_context6.t2 = _context6["catch"](10);
|
|
1309
1279
|
success = false;
|
|
1310
1280
|
logException(_context6.t2, {
|
|
1311
1281
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
@@ -1314,40 +1284,37 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1314
1284
|
reason: _context6.t2.message
|
|
1315
1285
|
});
|
|
1316
1286
|
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 || _this$fireAnalyticsEv10.call(this, updateReferenceErrorPayload(_context6.t2.message));
|
|
1317
|
-
case
|
|
1318
|
-
_context6.prev =
|
|
1287
|
+
case 47:
|
|
1288
|
+
_context6.prev = 47;
|
|
1319
1289
|
if (!success) {
|
|
1320
1290
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1321
1291
|
this.isCacheDirty = true;
|
|
1322
1292
|
} else {
|
|
1323
|
-
|
|
1324
|
-
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1325
|
-
}
|
|
1293
|
+
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1326
1294
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
1327
1295
|
}
|
|
1328
|
-
if (fg('platform_synced_block_patch_2')) {
|
|
1329
|
-
// Always reset isFlushInProgress regardless of feature flag
|
|
1330
|
-
this.isFlushInProgress = false;
|
|
1331
1296
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1297
|
+
// Always reset isFlushInProgress
|
|
1298
|
+
this.isFlushInProgress = false;
|
|
1299
|
+
|
|
1300
|
+
// If another flush was requested while this one was in progress, execute it now
|
|
1301
|
+
if (this.flushNeededAfterCurrent) {
|
|
1302
|
+
this.flushNeededAfterCurrent = false;
|
|
1303
|
+
// Use setTimeout to avoid deep recursion and run queued flush asynchronously
|
|
1304
|
+
// Note: flush() handles all exceptions internally and never rejects
|
|
1305
|
+
this.queuedFlushTimeout = setTimeout(function () {
|
|
1306
|
+
_this11.queuedFlushTimeout = undefined;
|
|
1307
|
+
void _this11.flush();
|
|
1308
|
+
}, 0);
|
|
1342
1309
|
}
|
|
1343
|
-
return _context6.finish(
|
|
1344
|
-
case
|
|
1310
|
+
return _context6.finish(47);
|
|
1311
|
+
case 52:
|
|
1345
1312
|
return _context6.abrupt("return", success);
|
|
1346
|
-
case
|
|
1313
|
+
case 53:
|
|
1347
1314
|
case "end":
|
|
1348
1315
|
return _context6.stop();
|
|
1349
1316
|
}
|
|
1350
|
-
}, _callee4, this, [[
|
|
1317
|
+
}, _callee4, this, [[10, 41, 47, 52], [15, 24, 27, 30]]);
|
|
1351
1318
|
}));
|
|
1352
1319
|
function flush() {
|
|
1353
1320
|
return _flush.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"uuid": "^3.1.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^111.
|
|
41
|
+
"@atlaskit/editor-common": "^111.19.0",
|
|
42
42
|
"react": "^18.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
84
|
-
"version": "3.30.
|
|
84
|
+
"version": "3.30.5",
|
|
85
85
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
86
86
|
"author": "Atlassian Pty Ltd",
|
|
87
87
|
"license": "Apache-2.0",
|
|
@@ -89,9 +89,6 @@
|
|
|
89
89
|
"registry": "https://registry.npmjs.org/"
|
|
90
90
|
},
|
|
91
91
|
"platform-feature-flags": {
|
|
92
|
-
"platform_synced_block_patch_2": {
|
|
93
|
-
"type": "boolean"
|
|
94
|
-
},
|
|
95
92
|
"platform_synced_block_patch_3": {
|
|
96
93
|
"type": "boolean"
|
|
97
94
|
}
|