@atlaskit/editor-synced-block-provider 6.6.9 → 6.6.11
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 +15 -0
- package/dist/cjs/clients/block-service/blockService.js +107 -107
- package/dist/cjs/clients/confluence/fetchMediaToken.js +21 -21
- package/dist/cjs/clients/confluence/sourceInfo.js +24 -24
- package/dist/cjs/clients/jira/fetchMediaToken.js +21 -21
- package/dist/cjs/clients/jira/sourceInfo.js +24 -24
- package/dist/cjs/hooks/useFetchSyncBlockData.js +18 -18
- package/dist/cjs/providers/block-service/blockServiceAPI.js +322 -321
- package/dist/cjs/providers/syncBlockProvider.js +49 -48
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +75 -75
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +77 -78
- package/dist/cjs/store-manager/syncBlockStoreManager.js +41 -41
- package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/cjs/utils/resourceId.js +2 -1
- package/dist/cjs/utils/retry.js +8 -8
- package/dist/cjs/utils/utils.js +4 -3
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +1 -1
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -2
- package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/es2019/utils/utils.js +1 -2
- package/dist/esm/clients/block-service/blockService.js +107 -107
- package/dist/esm/clients/confluence/fetchMediaToken.js +21 -21
- package/dist/esm/clients/confluence/sourceInfo.js +24 -24
- package/dist/esm/clients/jira/fetchMediaToken.js +21 -21
- package/dist/esm/clients/jira/sourceInfo.js +24 -24
- package/dist/esm/hooks/useFetchSyncBlockData.js +18 -18
- package/dist/esm/providers/block-service/blockServiceAPI.js +321 -320
- package/dist/esm/providers/syncBlockProvider.js +49 -48
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +75 -75
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +77 -78
- package/dist/esm/store-manager/syncBlockStoreManager.js +41 -41
- package/dist/esm/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/esm/utils/resourceId.js +2 -1
- package/dist/esm/utils/retry.js +8 -8
- package/dist/esm/utils/utils.js +1 -2
- package/package.json +5 -8
|
@@ -88,8 +88,8 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
88
88
|
value: (function () {
|
|
89
89
|
var _fetchNodesData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(nodes) {
|
|
90
90
|
var _this2 = this;
|
|
91
|
-
var blockIdentifiers;
|
|
92
|
-
return _regenerator.default.wrap(function
|
|
91
|
+
var blockIdentifiers, _t;
|
|
92
|
+
return _regenerator.default.wrap(function (_context) {
|
|
93
93
|
while (1) switch (_context.prev = _context.next) {
|
|
94
94
|
case 0:
|
|
95
95
|
blockIdentifiers = nodes.map(function (node) {
|
|
@@ -99,19 +99,19 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
99
99
|
};
|
|
100
100
|
});
|
|
101
101
|
if (!(blockIdentifiers.length === 0)) {
|
|
102
|
-
_context.next =
|
|
102
|
+
_context.next = 1;
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
105
|
return _context.abrupt("return", []);
|
|
106
|
-
case
|
|
107
|
-
_context.prev =
|
|
108
|
-
_context.next =
|
|
106
|
+
case 1:
|
|
107
|
+
_context.prev = 1;
|
|
108
|
+
_context.next = 2;
|
|
109
109
|
return this.fetchProvider.batchFetchData(blockIdentifiers);
|
|
110
|
-
case
|
|
110
|
+
case 2:
|
|
111
111
|
return _context.abrupt("return", _context.sent);
|
|
112
|
-
case
|
|
113
|
-
_context.prev =
|
|
114
|
-
|
|
112
|
+
case 3:
|
|
113
|
+
_context.prev = 3;
|
|
114
|
+
_t = _context["catch"](1);
|
|
115
115
|
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
116
116
|
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
117
117
|
return data;
|
|
@@ -131,11 +131,11 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
131
131
|
return result.value;
|
|
132
132
|
});
|
|
133
133
|
}));
|
|
134
|
-
case
|
|
134
|
+
case 4:
|
|
135
135
|
case "end":
|
|
136
136
|
return _context.stop();
|
|
137
137
|
}
|
|
138
|
-
}, _callee, this, [[
|
|
138
|
+
}, _callee, this, [[1, 3]]);
|
|
139
139
|
}));
|
|
140
140
|
function fetchNodesData(_x) {
|
|
141
141
|
return _fetchNodesData.apply(this, arguments);
|
|
@@ -158,17 +158,17 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
158
158
|
var _writeNodesData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(nodes, data) {
|
|
159
159
|
var _this3 = this;
|
|
160
160
|
var validDataWithIndices, invalidResults, batchResults, results;
|
|
161
|
-
return _regenerator.default.wrap(function
|
|
161
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
162
162
|
while (1) switch (_context2.prev = _context2.next) {
|
|
163
163
|
case 0:
|
|
164
164
|
if (this.writeProvider) {
|
|
165
|
-
_context2.next =
|
|
165
|
+
_context2.next = 1;
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
return _context2.abrupt("return", Promise.reject(new Error('Write provider not set')));
|
|
169
|
-
case
|
|
169
|
+
case 1:
|
|
170
170
|
if (!this.writeProvider.writeDataBatch) {
|
|
171
|
-
_context2.next =
|
|
171
|
+
_context2.next = 4;
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
// Separate data into valid (with content) and invalid (without content)
|
|
@@ -188,17 +188,17 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
188
188
|
// Process valid data in batch
|
|
189
189
|
batchResults = [];
|
|
190
190
|
if (!(validDataWithIndices.length > 0)) {
|
|
191
|
-
_context2.next =
|
|
191
|
+
_context2.next = 3;
|
|
192
192
|
break;
|
|
193
193
|
}
|
|
194
|
-
_context2.next =
|
|
194
|
+
_context2.next = 2;
|
|
195
195
|
return this.writeProvider.writeDataBatch(validDataWithIndices);
|
|
196
|
-
case
|
|
196
|
+
case 2:
|
|
197
197
|
batchResults = _context2.sent;
|
|
198
|
-
case
|
|
198
|
+
case 3:
|
|
199
199
|
return _context2.abrupt("return", [].concat((0, _toConsumableArray2.default)(batchResults), invalidResults));
|
|
200
|
-
case
|
|
201
|
-
_context2.next =
|
|
200
|
+
case 4:
|
|
201
|
+
_context2.next = 5;
|
|
202
202
|
return Promise.allSettled(nodes.map(function (_node, index) {
|
|
203
203
|
var _this3$writeProvider;
|
|
204
204
|
if (!_this3.writeProvider) {
|
|
@@ -209,7 +209,7 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
209
209
|
}
|
|
210
210
|
return (_this3$writeProvider = _this3.writeProvider) === null || _this3$writeProvider === void 0 ? void 0 : _this3$writeProvider.writeData(data[index]);
|
|
211
211
|
}));
|
|
212
|
-
case
|
|
212
|
+
case 5:
|
|
213
213
|
results = _context2.sent;
|
|
214
214
|
return _context2.abrupt("return", results.map(function (result) {
|
|
215
215
|
if (result.status === 'fulfilled') {
|
|
@@ -220,7 +220,7 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
}));
|
|
223
|
-
case
|
|
223
|
+
case 6:
|
|
224
224
|
case "end":
|
|
225
225
|
return _context2.stop();
|
|
226
226
|
}
|
|
@@ -259,23 +259,23 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
259
259
|
var _deleteNodesData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resourceIds, deletionReason) {
|
|
260
260
|
var _this4 = this;
|
|
261
261
|
var results;
|
|
262
|
-
return _regenerator.default.wrap(function
|
|
262
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
263
263
|
while (1) switch (_context3.prev = _context3.next) {
|
|
264
264
|
case 0:
|
|
265
265
|
if (this.writeProvider) {
|
|
266
|
-
_context3.next =
|
|
266
|
+
_context3.next = 1;
|
|
267
267
|
break;
|
|
268
268
|
}
|
|
269
269
|
return _context3.abrupt("return", Promise.reject(new Error('Write provider not set')));
|
|
270
|
-
case
|
|
271
|
-
_context3.next =
|
|
270
|
+
case 1:
|
|
271
|
+
_context3.next = 2;
|
|
272
272
|
return Promise.allSettled(resourceIds.map(function (resourceId) {
|
|
273
273
|
if (!_this4.writeProvider) {
|
|
274
274
|
return Promise.reject('Write provider not set');
|
|
275
275
|
}
|
|
276
276
|
return _this4.writeProvider.deleteData(resourceId, deletionReason);
|
|
277
277
|
}));
|
|
278
|
-
case
|
|
278
|
+
case 2:
|
|
279
279
|
results = _context3.sent;
|
|
280
280
|
return _context3.abrupt("return", results.map(function (result, index) {
|
|
281
281
|
if (result.status === 'fulfilled') {
|
|
@@ -288,7 +288,7 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
288
288
|
};
|
|
289
289
|
}
|
|
290
290
|
}));
|
|
291
|
-
case
|
|
291
|
+
case 3:
|
|
292
292
|
case "end":
|
|
293
293
|
return _context3.stop();
|
|
294
294
|
}
|
|
@@ -321,55 +321,56 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
321
321
|
sourceInfo,
|
|
322
322
|
_this$writeProvider3,
|
|
323
323
|
_sourceInfo,
|
|
324
|
-
_args4 = arguments
|
|
325
|
-
|
|
324
|
+
_args4 = arguments,
|
|
325
|
+
_t2;
|
|
326
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
326
327
|
while (1) switch (_context4.prev = _context4.next) {
|
|
327
328
|
case 0:
|
|
328
329
|
hasAccess = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
|
|
329
330
|
ari = sourceAri !== null && sourceAri !== void 0 ? sourceAri : (_this$writeProvider = this.writeProvider) === null || _this$writeProvider === void 0 ? void 0 : _this$writeProvider.parentAri;
|
|
330
331
|
product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : (0, _ari.getProductFromSourceAri)(ari);
|
|
331
332
|
if (!(!ari || !product)) {
|
|
332
|
-
_context4.next =
|
|
333
|
+
_context4.next = 1;
|
|
333
334
|
break;
|
|
334
335
|
}
|
|
335
336
|
return _context4.abrupt("return", Promise.reject(new Error('Source ari or source product is undefined')));
|
|
336
|
-
case
|
|
337
|
-
|
|
338
|
-
_context4.next =
|
|
337
|
+
case 1:
|
|
338
|
+
_t2 = product;
|
|
339
|
+
_context4.next = _t2 === 'confluence-page' ? 2 : _t2 === 'jira-work-item' ? 5 : 8;
|
|
339
340
|
break;
|
|
340
|
-
case
|
|
341
|
-
_context4.next =
|
|
341
|
+
case 2:
|
|
342
|
+
_context4.next = 3;
|
|
342
343
|
return (0, _sourceInfo2.fetchConfluencePageInfo)(ari, hasAccess, localId);
|
|
343
|
-
case
|
|
344
|
+
case 3:
|
|
344
345
|
sourceInfo = _context4.sent;
|
|
345
346
|
if (sourceInfo) {
|
|
346
|
-
_context4.next =
|
|
347
|
+
_context4.next = 4;
|
|
347
348
|
break;
|
|
348
349
|
}
|
|
349
350
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
350
|
-
case
|
|
351
|
+
case 4:
|
|
351
352
|
return _context4.abrupt("return", _objectSpread(_objectSpread({}, sourceInfo), {}, {
|
|
352
353
|
onSameDocument: ((_this$writeProvider2 = this.writeProvider) === null || _this$writeProvider2 === void 0 ? void 0 : _this$writeProvider2.parentAri) === ari,
|
|
353
354
|
productType: product
|
|
354
355
|
}));
|
|
355
|
-
case
|
|
356
|
-
_context4.next =
|
|
356
|
+
case 5:
|
|
357
|
+
_context4.next = 6;
|
|
357
358
|
return (0, _sourceInfo3.fetchJiraWorkItemInfo)(ari, hasAccess);
|
|
358
|
-
case
|
|
359
|
+
case 6:
|
|
359
360
|
_sourceInfo = _context4.sent;
|
|
360
361
|
if (_sourceInfo) {
|
|
361
|
-
_context4.next =
|
|
362
|
+
_context4.next = 7;
|
|
362
363
|
break;
|
|
363
364
|
}
|
|
364
365
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
365
|
-
case
|
|
366
|
+
case 7:
|
|
366
367
|
return _context4.abrupt("return", _objectSpread(_objectSpread({}, _sourceInfo), {}, {
|
|
367
368
|
onSameDocument: ((_this$writeProvider3 = this.writeProvider) === null || _this$writeProvider3 === void 0 ? void 0 : _this$writeProvider3.parentAri) === ari,
|
|
368
369
|
productType: product
|
|
369
370
|
}));
|
|
370
|
-
case
|
|
371
|
+
case 8:
|
|
371
372
|
return _context4.abrupt("return", Promise.reject(new Error("".concat(product, " source product not supported"))));
|
|
372
|
-
case
|
|
373
|
+
case 9:
|
|
373
374
|
case "end":
|
|
374
375
|
return _context4.stop();
|
|
375
376
|
}
|
|
@@ -224,7 +224,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
224
224
|
key: "stripAnnotationMarksFromReferenceData",
|
|
225
225
|
value: function stripAnnotationMarksFromReferenceData(syncBlock) {
|
|
226
226
|
var _syncBlock$data;
|
|
227
|
-
if (!(
|
|
227
|
+
if (!((_syncBlock$data = syncBlock.data) !== null && _syncBlock$data !== void 0 && _syncBlock$data.content)) {
|
|
228
228
|
return syncBlock;
|
|
229
229
|
}
|
|
230
230
|
var content = (0, _utils.stripAnnotationMarksFromJSONContent)(syncBlock.data.content);
|
|
@@ -407,16 +407,16 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
407
407
|
var _processPrefetchedData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(prefetchedData) {
|
|
408
408
|
var _this$fetchExperience,
|
|
409
409
|
_this3 = this;
|
|
410
|
-
var prefetchedResolvedData, _this$processFetchedD, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4, _this$fetchExperience5;
|
|
411
|
-
return _regenerator.default.wrap(function
|
|
410
|
+
var prefetchedResolvedData, _this$processFetchedD, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4, _this$fetchExperience5, _t;
|
|
411
|
+
return _regenerator.default.wrap(function (_context) {
|
|
412
412
|
while (1) switch (_context.prev = _context.next) {
|
|
413
413
|
case 0:
|
|
414
414
|
if (prefetchedData) {
|
|
415
|
-
_context.next =
|
|
415
|
+
_context.next = 1;
|
|
416
416
|
break;
|
|
417
417
|
}
|
|
418
418
|
return _context.abrupt("return");
|
|
419
|
-
case
|
|
419
|
+
case 1:
|
|
420
420
|
// start the fetch experience (this should be started much earlier to properly track performance, but better late than never)
|
|
421
421
|
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.start({});
|
|
422
422
|
|
|
@@ -424,10 +424,10 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
424
424
|
prefetchedData.resourceIds.forEach(function (resourceId) {
|
|
425
425
|
_this3.syncBlockFetchDataRequests.set(resourceId, true);
|
|
426
426
|
});
|
|
427
|
-
_context.prev =
|
|
428
|
-
_context.next =
|
|
427
|
+
_context.prev = 2;
|
|
428
|
+
_context.next = 3;
|
|
429
429
|
return prefetchedData.prefetchPromise;
|
|
430
|
-
case
|
|
430
|
+
case 3:
|
|
431
431
|
prefetchedResolvedData = _context.sent;
|
|
432
432
|
_this$processFetchedD = this.processFetchedData(prefetchedResolvedData), hasUnexpectedError = _this$processFetchedD.hasUnexpectedError, hasExpectedError = _this$processFetchedD.hasExpectedError;
|
|
433
433
|
if (hasUnexpectedError) {
|
|
@@ -441,26 +441,26 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
441
441
|
} else {
|
|
442
442
|
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.success();
|
|
443
443
|
}
|
|
444
|
-
_context.next =
|
|
444
|
+
_context.next = 5;
|
|
445
445
|
break;
|
|
446
|
-
case
|
|
447
|
-
_context.prev =
|
|
448
|
-
|
|
446
|
+
case 4:
|
|
447
|
+
_context.prev = 4;
|
|
448
|
+
_t = _context["catch"](2);
|
|
449
449
|
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.failure({
|
|
450
|
-
reason: "Prefetch promise rejected: ".concat(
|
|
450
|
+
reason: "Prefetch promise rejected: ".concat(_t.message)
|
|
451
451
|
});
|
|
452
|
-
case
|
|
453
|
-
_context.prev =
|
|
452
|
+
case 5:
|
|
453
|
+
_context.prev = 5;
|
|
454
454
|
// Clean up in-flight markers so subsequent fetches are not blocked
|
|
455
455
|
prefetchedData.resourceIds.forEach(function (resourceId) {
|
|
456
456
|
_this3.syncBlockFetchDataRequests.delete(resourceId);
|
|
457
457
|
});
|
|
458
|
-
return _context.finish(
|
|
459
|
-
case
|
|
458
|
+
return _context.finish(5);
|
|
459
|
+
case 6:
|
|
460
460
|
case "end":
|
|
461
461
|
return _context.stop();
|
|
462
462
|
}
|
|
463
|
-
}, _callee, this, [[
|
|
463
|
+
}, _callee, this, [[2, 4, 5, 6]]);
|
|
464
464
|
}));
|
|
465
465
|
function processPrefetchedData(_x) {
|
|
466
466
|
return _processPrefetchedData.apply(this, arguments);
|
|
@@ -480,15 +480,15 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
480
480
|
var _this4 = this,
|
|
481
481
|
_this$fetchExperience6;
|
|
482
482
|
var nodesToFetch, data, _this$processFetchedD2, hasUnexpectedError, hasExpectedError, _this$fetchExperience7, _this$fetchExperience8, _this$fetchExperience9;
|
|
483
|
-
return _regenerator.default.wrap(function
|
|
483
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
484
484
|
while (1) switch (_context2.prev = _context2.next) {
|
|
485
485
|
case 0:
|
|
486
486
|
if (!(syncBlockNodes.length === 0)) {
|
|
487
|
-
_context2.next =
|
|
487
|
+
_context2.next = 1;
|
|
488
488
|
break;
|
|
489
489
|
}
|
|
490
490
|
return _context2.abrupt("return");
|
|
491
|
-
case
|
|
491
|
+
case 1:
|
|
492
492
|
// Don't fetch for not_found error since the source is already deleted
|
|
493
493
|
nodesToFetch = [];
|
|
494
494
|
syncBlockNodes.forEach(function (node) {
|
|
@@ -503,28 +503,28 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
503
503
|
nodesToFetch.push(node);
|
|
504
504
|
});
|
|
505
505
|
if (!(nodesToFetch.length === 0)) {
|
|
506
|
-
_context2.next =
|
|
506
|
+
_context2.next = 2;
|
|
507
507
|
break;
|
|
508
508
|
}
|
|
509
509
|
return _context2.abrupt("return");
|
|
510
|
-
case
|
|
510
|
+
case 2:
|
|
511
511
|
if (this.dataProvider) {
|
|
512
|
-
_context2.next =
|
|
512
|
+
_context2.next = 3;
|
|
513
513
|
break;
|
|
514
514
|
}
|
|
515
515
|
throw new Error('Data provider not set');
|
|
516
|
-
case
|
|
516
|
+
case 3:
|
|
517
517
|
nodesToFetch.forEach(function (node) {
|
|
518
518
|
_this4.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
519
519
|
});
|
|
520
520
|
(_this$fetchExperience6 = this.fetchExperience) === null || _this$fetchExperience6 === void 0 || _this$fetchExperience6.start({});
|
|
521
|
-
_context2.next =
|
|
521
|
+
_context2.next = 4;
|
|
522
522
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
523
523
|
nodesToFetch.forEach(function (node) {
|
|
524
524
|
_this4.syncBlockFetchDataRequests.delete(node.attrs.resourceId);
|
|
525
525
|
});
|
|
526
526
|
});
|
|
527
|
-
case
|
|
527
|
+
case 4:
|
|
528
528
|
data = _context2.sent;
|
|
529
529
|
_this$processFetchedD2 = this.processFetchedData(data), hasUnexpectedError = _this$processFetchedD2.hasUnexpectedError, hasExpectedError = _this$processFetchedD2.hasExpectedError;
|
|
530
530
|
if (hasUnexpectedError) {
|
|
@@ -538,7 +538,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
538
538
|
} else {
|
|
539
539
|
(_this$fetchExperience9 = this.fetchExperience) === null || _this$fetchExperience9 === void 0 || _this$fetchExperience9.success();
|
|
540
540
|
}
|
|
541
|
-
case
|
|
541
|
+
case 5:
|
|
542
542
|
case "end":
|
|
543
543
|
return _context2.stop();
|
|
544
544
|
}
|
|
@@ -817,24 +817,24 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
817
817
|
value: (function () {
|
|
818
818
|
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
819
819
|
var _this8 = this;
|
|
820
|
-
var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv6, _this$saveExperience3, _this$fireAnalyticsEv7, _this$saveExperience4;
|
|
821
|
-
return _regenerator.default.wrap(function
|
|
820
|
+
var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv6, _this$saveExperience3, _this$fireAnalyticsEv7, _this$saveExperience4, _t2, _t3;
|
|
821
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
822
822
|
while (1) switch (_context4.prev = _context4.next) {
|
|
823
823
|
case 0:
|
|
824
824
|
if (!(this.viewMode === 'view')) {
|
|
825
|
-
_context4.next =
|
|
825
|
+
_context4.next = 1;
|
|
826
826
|
break;
|
|
827
827
|
}
|
|
828
828
|
return _context4.abrupt("return", false);
|
|
829
|
-
case
|
|
829
|
+
case 1:
|
|
830
830
|
if (this.isCacheDirty) {
|
|
831
|
-
_context4.next =
|
|
831
|
+
_context4.next = 2;
|
|
832
832
|
break;
|
|
833
833
|
}
|
|
834
834
|
return _context4.abrupt("return", true);
|
|
835
|
-
case
|
|
835
|
+
case 2:
|
|
836
836
|
if (!this.isFlushInProgress) {
|
|
837
|
-
_context4.next =
|
|
837
|
+
_context4.next = 3;
|
|
838
838
|
break;
|
|
839
839
|
}
|
|
840
840
|
// Mark that another flush is needed after the current one completes
|
|
@@ -842,25 +842,25 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
842
842
|
|
|
843
843
|
// We return true here because we know the pending flush will handle the dirty cache
|
|
844
844
|
return _context4.abrupt("return", true);
|
|
845
|
-
case
|
|
845
|
+
case 3:
|
|
846
846
|
this.isFlushInProgress = true;
|
|
847
|
-
case
|
|
847
|
+
case 4:
|
|
848
848
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
849
849
|
// To be saved as the last flushed structure if the flush is successful
|
|
850
850
|
syncedBlocksToFlush = {};
|
|
851
|
-
_context4.prev =
|
|
851
|
+
_context4.prev = 5;
|
|
852
852
|
if (this.dataProvider) {
|
|
853
|
-
_context4.next =
|
|
853
|
+
_context4.next = 6;
|
|
854
854
|
break;
|
|
855
855
|
}
|
|
856
856
|
throw new Error('Data provider not set');
|
|
857
|
-
case
|
|
857
|
+
case 6:
|
|
858
858
|
blocks = []; // First, build the complete subscription structure
|
|
859
859
|
_iterator = _createForOfIteratorHelper(this._subscriptionManager.getSubscriptions().entries());
|
|
860
|
-
_context4.prev =
|
|
860
|
+
_context4.prev = 7;
|
|
861
861
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
862
862
|
var _step$value, resourceId, callbacks;
|
|
863
|
-
return _regenerator.default.wrap(function
|
|
863
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
864
864
|
while (1) switch (_context3.prev = _context3.next) {
|
|
865
865
|
case 0:
|
|
866
866
|
_step$value = (0, _slicedToArray2.default)(_step.value, 2), resourceId = _step$value[0], callbacks = _step$value[1];
|
|
@@ -872,41 +872,41 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
872
872
|
});
|
|
873
873
|
syncedBlocksToFlush[resourceId][localId] = true;
|
|
874
874
|
});
|
|
875
|
-
case
|
|
875
|
+
case 1:
|
|
876
876
|
case "end":
|
|
877
877
|
return _context3.stop();
|
|
878
878
|
}
|
|
879
879
|
}, _loop);
|
|
880
880
|
});
|
|
881
881
|
_iterator.s();
|
|
882
|
-
case
|
|
882
|
+
case 8:
|
|
883
883
|
if ((_step = _iterator.n()).done) {
|
|
884
|
-
_context4.next =
|
|
884
|
+
_context4.next = 10;
|
|
885
885
|
break;
|
|
886
886
|
}
|
|
887
|
-
return _context4.delegateYield(_loop(), "t0",
|
|
888
|
-
case
|
|
889
|
-
_context4.next =
|
|
887
|
+
return _context4.delegateYield(_loop(), "t0", 9);
|
|
888
|
+
case 9:
|
|
889
|
+
_context4.next = 8;
|
|
890
890
|
break;
|
|
891
|
-
case
|
|
892
|
-
_context4.next =
|
|
891
|
+
case 10:
|
|
892
|
+
_context4.next = 12;
|
|
893
893
|
break;
|
|
894
|
-
case
|
|
895
|
-
_context4.prev =
|
|
896
|
-
|
|
897
|
-
_iterator.e(
|
|
898
|
-
case
|
|
899
|
-
_context4.prev =
|
|
894
|
+
case 11:
|
|
895
|
+
_context4.prev = 11;
|
|
896
|
+
_t2 = _context4["catch"](7);
|
|
897
|
+
_iterator.e(_t2);
|
|
898
|
+
case 12:
|
|
899
|
+
_context4.prev = 12;
|
|
900
900
|
_iterator.f();
|
|
901
|
-
return _context4.finish(
|
|
902
|
-
case
|
|
901
|
+
return _context4.finish(12);
|
|
902
|
+
case 13:
|
|
903
903
|
if (!(0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
904
|
-
_context4.next =
|
|
904
|
+
_context4.next = 14;
|
|
905
905
|
break;
|
|
906
906
|
}
|
|
907
907
|
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
908
908
|
return _context4.abrupt("return", true);
|
|
909
|
-
case
|
|
909
|
+
case 14:
|
|
910
910
|
// reset isCacheDirty early to prevent race condition
|
|
911
911
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
912
912
|
// on a live page and the reference sync block is being saved while the user
|
|
@@ -914,9 +914,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
914
914
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
915
915
|
this.isCacheDirty = false;
|
|
916
916
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
917
|
-
_context4.next =
|
|
917
|
+
_context4.next = 15;
|
|
918
918
|
return this.dataProvider.updateReferenceData(blocks);
|
|
919
|
-
case
|
|
919
|
+
case 15:
|
|
920
920
|
updateResult = _context4.sent;
|
|
921
921
|
if (!updateResult.success) {
|
|
922
922
|
success = false;
|
|
@@ -925,22 +925,22 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
925
925
|
});
|
|
926
926
|
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
927
927
|
}
|
|
928
|
-
_context4.next =
|
|
928
|
+
_context4.next = 17;
|
|
929
929
|
break;
|
|
930
|
-
case
|
|
931
|
-
_context4.prev =
|
|
932
|
-
|
|
930
|
+
case 16:
|
|
931
|
+
_context4.prev = 16;
|
|
932
|
+
_t3 = _context4["catch"](5);
|
|
933
933
|
success = false;
|
|
934
|
-
(0, _monitoring.logException)(
|
|
934
|
+
(0, _monitoring.logException)(_t3, {
|
|
935
935
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
936
936
|
});
|
|
937
937
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure({
|
|
938
|
-
reason:
|
|
938
|
+
reason: _t3.message
|
|
939
939
|
});
|
|
940
940
|
// No `resourceId` available in this catch — sourceProduct is intentionally omitted.
|
|
941
|
-
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.updateReferenceErrorPayload)(
|
|
942
|
-
case
|
|
943
|
-
_context4.prev =
|
|
941
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_t3.message));
|
|
942
|
+
case 17:
|
|
943
|
+
_context4.prev = 17;
|
|
944
944
|
if (!success) {
|
|
945
945
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
946
946
|
this.isCacheDirty = true;
|
|
@@ -962,14 +962,14 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
962
962
|
void _this8.flush();
|
|
963
963
|
}, 0);
|
|
964
964
|
}
|
|
965
|
-
return _context4.finish(
|
|
966
|
-
case
|
|
965
|
+
return _context4.finish(17);
|
|
966
|
+
case 18:
|
|
967
967
|
return _context4.abrupt("return", success);
|
|
968
|
-
case
|
|
968
|
+
case 19:
|
|
969
969
|
case "end":
|
|
970
970
|
return _context4.stop();
|
|
971
971
|
}
|
|
972
|
-
}, _callee3, this, [[
|
|
972
|
+
}, _callee3, this, [[5, 16, 17, 18], [7, 11, 12, 13]]);
|
|
973
973
|
}));
|
|
974
974
|
function flush() {
|
|
975
975
|
return _flush.apply(this, arguments);
|