@atlaskit/editor-synced-block-provider 6.6.10 → 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 +9 -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
|
@@ -81,8 +81,8 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
81
81
|
value: (function () {
|
|
82
82
|
var _fetchNodesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(nodes) {
|
|
83
83
|
var _this2 = this;
|
|
84
|
-
var blockIdentifiers;
|
|
85
|
-
return _regeneratorRuntime.wrap(function
|
|
84
|
+
var blockIdentifiers, _t;
|
|
85
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
86
86
|
while (1) switch (_context.prev = _context.next) {
|
|
87
87
|
case 0:
|
|
88
88
|
blockIdentifiers = nodes.map(function (node) {
|
|
@@ -92,19 +92,19 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
92
92
|
};
|
|
93
93
|
});
|
|
94
94
|
if (!(blockIdentifiers.length === 0)) {
|
|
95
|
-
_context.next =
|
|
95
|
+
_context.next = 1;
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
return _context.abrupt("return", []);
|
|
99
|
-
case
|
|
100
|
-
_context.prev =
|
|
101
|
-
_context.next =
|
|
99
|
+
case 1:
|
|
100
|
+
_context.prev = 1;
|
|
101
|
+
_context.next = 2;
|
|
102
102
|
return this.fetchProvider.batchFetchData(blockIdentifiers);
|
|
103
|
-
case
|
|
103
|
+
case 2:
|
|
104
104
|
return _context.abrupt("return", _context.sent);
|
|
105
|
-
case
|
|
106
|
-
_context.prev =
|
|
107
|
-
|
|
105
|
+
case 3:
|
|
106
|
+
_context.prev = 3;
|
|
107
|
+
_t = _context["catch"](1);
|
|
108
108
|
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
109
109
|
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
110
110
|
return data;
|
|
@@ -124,11 +124,11 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
124
124
|
return result.value;
|
|
125
125
|
});
|
|
126
126
|
}));
|
|
127
|
-
case
|
|
127
|
+
case 4:
|
|
128
128
|
case "end":
|
|
129
129
|
return _context.stop();
|
|
130
130
|
}
|
|
131
|
-
}, _callee, this, [[
|
|
131
|
+
}, _callee, this, [[1, 3]]);
|
|
132
132
|
}));
|
|
133
133
|
function fetchNodesData(_x) {
|
|
134
134
|
return _fetchNodesData.apply(this, arguments);
|
|
@@ -151,17 +151,17 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
151
151
|
var _writeNodesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(nodes, data) {
|
|
152
152
|
var _this3 = this;
|
|
153
153
|
var validDataWithIndices, invalidResults, batchResults, results;
|
|
154
|
-
return _regeneratorRuntime.wrap(function
|
|
154
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
155
155
|
while (1) switch (_context2.prev = _context2.next) {
|
|
156
156
|
case 0:
|
|
157
157
|
if (this.writeProvider) {
|
|
158
|
-
_context2.next =
|
|
158
|
+
_context2.next = 1;
|
|
159
159
|
break;
|
|
160
160
|
}
|
|
161
161
|
return _context2.abrupt("return", Promise.reject(new Error('Write provider not set')));
|
|
162
|
-
case
|
|
162
|
+
case 1:
|
|
163
163
|
if (!this.writeProvider.writeDataBatch) {
|
|
164
|
-
_context2.next =
|
|
164
|
+
_context2.next = 4;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
167
|
// Separate data into valid (with content) and invalid (without content)
|
|
@@ -181,17 +181,17 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
181
181
|
// Process valid data in batch
|
|
182
182
|
batchResults = [];
|
|
183
183
|
if (!(validDataWithIndices.length > 0)) {
|
|
184
|
-
_context2.next =
|
|
184
|
+
_context2.next = 3;
|
|
185
185
|
break;
|
|
186
186
|
}
|
|
187
|
-
_context2.next =
|
|
187
|
+
_context2.next = 2;
|
|
188
188
|
return this.writeProvider.writeDataBatch(validDataWithIndices);
|
|
189
|
-
case
|
|
189
|
+
case 2:
|
|
190
190
|
batchResults = _context2.sent;
|
|
191
|
-
case
|
|
191
|
+
case 3:
|
|
192
192
|
return _context2.abrupt("return", [].concat(_toConsumableArray(batchResults), invalidResults));
|
|
193
|
-
case
|
|
194
|
-
_context2.next =
|
|
193
|
+
case 4:
|
|
194
|
+
_context2.next = 5;
|
|
195
195
|
return Promise.allSettled(nodes.map(function (_node, index) {
|
|
196
196
|
var _this3$writeProvider;
|
|
197
197
|
if (!_this3.writeProvider) {
|
|
@@ -202,7 +202,7 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
202
202
|
}
|
|
203
203
|
return (_this3$writeProvider = _this3.writeProvider) === null || _this3$writeProvider === void 0 ? void 0 : _this3$writeProvider.writeData(data[index]);
|
|
204
204
|
}));
|
|
205
|
-
case
|
|
205
|
+
case 5:
|
|
206
206
|
results = _context2.sent;
|
|
207
207
|
return _context2.abrupt("return", results.map(function (result) {
|
|
208
208
|
if (result.status === 'fulfilled') {
|
|
@@ -213,7 +213,7 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
}));
|
|
216
|
-
case
|
|
216
|
+
case 6:
|
|
217
217
|
case "end":
|
|
218
218
|
return _context2.stop();
|
|
219
219
|
}
|
|
@@ -252,23 +252,23 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
252
252
|
var _deleteNodesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resourceIds, deletionReason) {
|
|
253
253
|
var _this4 = this;
|
|
254
254
|
var results;
|
|
255
|
-
return _regeneratorRuntime.wrap(function
|
|
255
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
256
256
|
while (1) switch (_context3.prev = _context3.next) {
|
|
257
257
|
case 0:
|
|
258
258
|
if (this.writeProvider) {
|
|
259
|
-
_context3.next =
|
|
259
|
+
_context3.next = 1;
|
|
260
260
|
break;
|
|
261
261
|
}
|
|
262
262
|
return _context3.abrupt("return", Promise.reject(new Error('Write provider not set')));
|
|
263
|
-
case
|
|
264
|
-
_context3.next =
|
|
263
|
+
case 1:
|
|
264
|
+
_context3.next = 2;
|
|
265
265
|
return Promise.allSettled(resourceIds.map(function (resourceId) {
|
|
266
266
|
if (!_this4.writeProvider) {
|
|
267
267
|
return Promise.reject('Write provider not set');
|
|
268
268
|
}
|
|
269
269
|
return _this4.writeProvider.deleteData(resourceId, deletionReason);
|
|
270
270
|
}));
|
|
271
|
-
case
|
|
271
|
+
case 2:
|
|
272
272
|
results = _context3.sent;
|
|
273
273
|
return _context3.abrupt("return", results.map(function (result, index) {
|
|
274
274
|
if (result.status === 'fulfilled') {
|
|
@@ -281,7 +281,7 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
}));
|
|
284
|
-
case
|
|
284
|
+
case 3:
|
|
285
285
|
case "end":
|
|
286
286
|
return _context3.stop();
|
|
287
287
|
}
|
|
@@ -314,55 +314,56 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
314
314
|
sourceInfo,
|
|
315
315
|
_this$writeProvider3,
|
|
316
316
|
_sourceInfo,
|
|
317
|
-
_args4 = arguments
|
|
318
|
-
|
|
317
|
+
_args4 = arguments,
|
|
318
|
+
_t2;
|
|
319
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
319
320
|
while (1) switch (_context4.prev = _context4.next) {
|
|
320
321
|
case 0:
|
|
321
322
|
hasAccess = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
|
|
322
323
|
ari = sourceAri !== null && sourceAri !== void 0 ? sourceAri : (_this$writeProvider = this.writeProvider) === null || _this$writeProvider === void 0 ? void 0 : _this$writeProvider.parentAri;
|
|
323
324
|
product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : getProductFromSourceAri(ari);
|
|
324
325
|
if (!(!ari || !product)) {
|
|
325
|
-
_context4.next =
|
|
326
|
+
_context4.next = 1;
|
|
326
327
|
break;
|
|
327
328
|
}
|
|
328
329
|
return _context4.abrupt("return", Promise.reject(new Error('Source ari or source product is undefined')));
|
|
329
|
-
case
|
|
330
|
-
|
|
331
|
-
_context4.next =
|
|
330
|
+
case 1:
|
|
331
|
+
_t2 = product;
|
|
332
|
+
_context4.next = _t2 === 'confluence-page' ? 2 : _t2 === 'jira-work-item' ? 5 : 8;
|
|
332
333
|
break;
|
|
333
|
-
case
|
|
334
|
-
_context4.next =
|
|
334
|
+
case 2:
|
|
335
|
+
_context4.next = 3;
|
|
335
336
|
return fetchConfluencePageInfo(ari, hasAccess, localId);
|
|
336
|
-
case
|
|
337
|
+
case 3:
|
|
337
338
|
sourceInfo = _context4.sent;
|
|
338
339
|
if (sourceInfo) {
|
|
339
|
-
_context4.next =
|
|
340
|
+
_context4.next = 4;
|
|
340
341
|
break;
|
|
341
342
|
}
|
|
342
343
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
343
|
-
case
|
|
344
|
+
case 4:
|
|
344
345
|
return _context4.abrupt("return", _objectSpread(_objectSpread({}, sourceInfo), {}, {
|
|
345
346
|
onSameDocument: ((_this$writeProvider2 = this.writeProvider) === null || _this$writeProvider2 === void 0 ? void 0 : _this$writeProvider2.parentAri) === ari,
|
|
346
347
|
productType: product
|
|
347
348
|
}));
|
|
348
|
-
case
|
|
349
|
-
_context4.next =
|
|
349
|
+
case 5:
|
|
350
|
+
_context4.next = 6;
|
|
350
351
|
return fetchJiraWorkItemInfo(ari, hasAccess);
|
|
351
|
-
case
|
|
352
|
+
case 6:
|
|
352
353
|
_sourceInfo = _context4.sent;
|
|
353
354
|
if (_sourceInfo) {
|
|
354
|
-
_context4.next =
|
|
355
|
+
_context4.next = 7;
|
|
355
356
|
break;
|
|
356
357
|
}
|
|
357
358
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
358
|
-
case
|
|
359
|
+
case 7:
|
|
359
360
|
return _context4.abrupt("return", _objectSpread(_objectSpread({}, _sourceInfo), {}, {
|
|
360
361
|
onSameDocument: ((_this$writeProvider3 = this.writeProvider) === null || _this$writeProvider3 === void 0 ? void 0 : _this$writeProvider3.parentAri) === ari,
|
|
361
362
|
productType: product
|
|
362
363
|
}));
|
|
363
|
-
case
|
|
364
|
+
case 8:
|
|
364
365
|
return _context4.abrupt("return", Promise.reject(new Error("".concat(product, " source product not supported"))));
|
|
365
|
-
case
|
|
366
|
+
case 9:
|
|
366
367
|
case "end":
|
|
367
368
|
return _context4.stop();
|
|
368
369
|
}
|
|
@@ -217,7 +217,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
217
217
|
key: "stripAnnotationMarksFromReferenceData",
|
|
218
218
|
value: function stripAnnotationMarksFromReferenceData(syncBlock) {
|
|
219
219
|
var _syncBlock$data;
|
|
220
|
-
if (!
|
|
220
|
+
if (!((_syncBlock$data = syncBlock.data) !== null && _syncBlock$data !== void 0 && _syncBlock$data.content)) {
|
|
221
221
|
return syncBlock;
|
|
222
222
|
}
|
|
223
223
|
var content = stripAnnotationMarksFromJSONContent(syncBlock.data.content);
|
|
@@ -400,16 +400,16 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
400
400
|
var _processPrefetchedData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(prefetchedData) {
|
|
401
401
|
var _this$fetchExperience,
|
|
402
402
|
_this3 = this;
|
|
403
|
-
var prefetchedResolvedData, _this$processFetchedD, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4, _this$fetchExperience5;
|
|
404
|
-
return _regeneratorRuntime.wrap(function
|
|
403
|
+
var prefetchedResolvedData, _this$processFetchedD, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4, _this$fetchExperience5, _t;
|
|
404
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
405
405
|
while (1) switch (_context.prev = _context.next) {
|
|
406
406
|
case 0:
|
|
407
407
|
if (prefetchedData) {
|
|
408
|
-
_context.next =
|
|
408
|
+
_context.next = 1;
|
|
409
409
|
break;
|
|
410
410
|
}
|
|
411
411
|
return _context.abrupt("return");
|
|
412
|
-
case
|
|
412
|
+
case 1:
|
|
413
413
|
// start the fetch experience (this should be started much earlier to properly track performance, but better late than never)
|
|
414
414
|
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.start({});
|
|
415
415
|
|
|
@@ -417,10 +417,10 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
417
417
|
prefetchedData.resourceIds.forEach(function (resourceId) {
|
|
418
418
|
_this3.syncBlockFetchDataRequests.set(resourceId, true);
|
|
419
419
|
});
|
|
420
|
-
_context.prev =
|
|
421
|
-
_context.next =
|
|
420
|
+
_context.prev = 2;
|
|
421
|
+
_context.next = 3;
|
|
422
422
|
return prefetchedData.prefetchPromise;
|
|
423
|
-
case
|
|
423
|
+
case 3:
|
|
424
424
|
prefetchedResolvedData = _context.sent;
|
|
425
425
|
_this$processFetchedD = this.processFetchedData(prefetchedResolvedData), hasUnexpectedError = _this$processFetchedD.hasUnexpectedError, hasExpectedError = _this$processFetchedD.hasExpectedError;
|
|
426
426
|
if (hasUnexpectedError) {
|
|
@@ -434,26 +434,26 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
434
434
|
} else {
|
|
435
435
|
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.success();
|
|
436
436
|
}
|
|
437
|
-
_context.next =
|
|
437
|
+
_context.next = 5;
|
|
438
438
|
break;
|
|
439
|
-
case
|
|
440
|
-
_context.prev =
|
|
441
|
-
|
|
439
|
+
case 4:
|
|
440
|
+
_context.prev = 4;
|
|
441
|
+
_t = _context["catch"](2);
|
|
442
442
|
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.failure({
|
|
443
|
-
reason: "Prefetch promise rejected: ".concat(
|
|
443
|
+
reason: "Prefetch promise rejected: ".concat(_t.message)
|
|
444
444
|
});
|
|
445
|
-
case
|
|
446
|
-
_context.prev =
|
|
445
|
+
case 5:
|
|
446
|
+
_context.prev = 5;
|
|
447
447
|
// Clean up in-flight markers so subsequent fetches are not blocked
|
|
448
448
|
prefetchedData.resourceIds.forEach(function (resourceId) {
|
|
449
449
|
_this3.syncBlockFetchDataRequests.delete(resourceId);
|
|
450
450
|
});
|
|
451
|
-
return _context.finish(
|
|
452
|
-
case
|
|
451
|
+
return _context.finish(5);
|
|
452
|
+
case 6:
|
|
453
453
|
case "end":
|
|
454
454
|
return _context.stop();
|
|
455
455
|
}
|
|
456
|
-
}, _callee, this, [[
|
|
456
|
+
}, _callee, this, [[2, 4, 5, 6]]);
|
|
457
457
|
}));
|
|
458
458
|
function processPrefetchedData(_x) {
|
|
459
459
|
return _processPrefetchedData.apply(this, arguments);
|
|
@@ -473,15 +473,15 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
473
473
|
var _this4 = this,
|
|
474
474
|
_this$fetchExperience6;
|
|
475
475
|
var nodesToFetch, data, _this$processFetchedD2, hasUnexpectedError, hasExpectedError, _this$fetchExperience7, _this$fetchExperience8, _this$fetchExperience9;
|
|
476
|
-
return _regeneratorRuntime.wrap(function
|
|
476
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
477
477
|
while (1) switch (_context2.prev = _context2.next) {
|
|
478
478
|
case 0:
|
|
479
479
|
if (!(syncBlockNodes.length === 0)) {
|
|
480
|
-
_context2.next =
|
|
480
|
+
_context2.next = 1;
|
|
481
481
|
break;
|
|
482
482
|
}
|
|
483
483
|
return _context2.abrupt("return");
|
|
484
|
-
case
|
|
484
|
+
case 1:
|
|
485
485
|
// Don't fetch for not_found error since the source is already deleted
|
|
486
486
|
nodesToFetch = [];
|
|
487
487
|
syncBlockNodes.forEach(function (node) {
|
|
@@ -496,28 +496,28 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
496
496
|
nodesToFetch.push(node);
|
|
497
497
|
});
|
|
498
498
|
if (!(nodesToFetch.length === 0)) {
|
|
499
|
-
_context2.next =
|
|
499
|
+
_context2.next = 2;
|
|
500
500
|
break;
|
|
501
501
|
}
|
|
502
502
|
return _context2.abrupt("return");
|
|
503
|
-
case
|
|
503
|
+
case 2:
|
|
504
504
|
if (this.dataProvider) {
|
|
505
|
-
_context2.next =
|
|
505
|
+
_context2.next = 3;
|
|
506
506
|
break;
|
|
507
507
|
}
|
|
508
508
|
throw new Error('Data provider not set');
|
|
509
|
-
case
|
|
509
|
+
case 3:
|
|
510
510
|
nodesToFetch.forEach(function (node) {
|
|
511
511
|
_this4.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
512
512
|
});
|
|
513
513
|
(_this$fetchExperience6 = this.fetchExperience) === null || _this$fetchExperience6 === void 0 || _this$fetchExperience6.start({});
|
|
514
|
-
_context2.next =
|
|
514
|
+
_context2.next = 4;
|
|
515
515
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
516
516
|
nodesToFetch.forEach(function (node) {
|
|
517
517
|
_this4.syncBlockFetchDataRequests.delete(node.attrs.resourceId);
|
|
518
518
|
});
|
|
519
519
|
});
|
|
520
|
-
case
|
|
520
|
+
case 4:
|
|
521
521
|
data = _context2.sent;
|
|
522
522
|
_this$processFetchedD2 = this.processFetchedData(data), hasUnexpectedError = _this$processFetchedD2.hasUnexpectedError, hasExpectedError = _this$processFetchedD2.hasExpectedError;
|
|
523
523
|
if (hasUnexpectedError) {
|
|
@@ -531,7 +531,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
531
531
|
} else {
|
|
532
532
|
(_this$fetchExperience9 = this.fetchExperience) === null || _this$fetchExperience9 === void 0 || _this$fetchExperience9.success();
|
|
533
533
|
}
|
|
534
|
-
case
|
|
534
|
+
case 5:
|
|
535
535
|
case "end":
|
|
536
536
|
return _context2.stop();
|
|
537
537
|
}
|
|
@@ -810,24 +810,24 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
810
810
|
value: (function () {
|
|
811
811
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
812
812
|
var _this8 = this;
|
|
813
|
-
var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv6, _this$saveExperience3, _this$fireAnalyticsEv7, _this$saveExperience4;
|
|
814
|
-
return _regeneratorRuntime.wrap(function
|
|
813
|
+
var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv6, _this$saveExperience3, _this$fireAnalyticsEv7, _this$saveExperience4, _t2, _t3;
|
|
814
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
815
815
|
while (1) switch (_context4.prev = _context4.next) {
|
|
816
816
|
case 0:
|
|
817
817
|
if (!(this.viewMode === 'view')) {
|
|
818
|
-
_context4.next =
|
|
818
|
+
_context4.next = 1;
|
|
819
819
|
break;
|
|
820
820
|
}
|
|
821
821
|
return _context4.abrupt("return", false);
|
|
822
|
-
case
|
|
822
|
+
case 1:
|
|
823
823
|
if (this.isCacheDirty) {
|
|
824
|
-
_context4.next =
|
|
824
|
+
_context4.next = 2;
|
|
825
825
|
break;
|
|
826
826
|
}
|
|
827
827
|
return _context4.abrupt("return", true);
|
|
828
|
-
case
|
|
828
|
+
case 2:
|
|
829
829
|
if (!this.isFlushInProgress) {
|
|
830
|
-
_context4.next =
|
|
830
|
+
_context4.next = 3;
|
|
831
831
|
break;
|
|
832
832
|
}
|
|
833
833
|
// Mark that another flush is needed after the current one completes
|
|
@@ -835,25 +835,25 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
835
835
|
|
|
836
836
|
// We return true here because we know the pending flush will handle the dirty cache
|
|
837
837
|
return _context4.abrupt("return", true);
|
|
838
|
-
case
|
|
838
|
+
case 3:
|
|
839
839
|
this.isFlushInProgress = true;
|
|
840
|
-
case
|
|
840
|
+
case 4:
|
|
841
841
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
842
842
|
// To be saved as the last flushed structure if the flush is successful
|
|
843
843
|
syncedBlocksToFlush = {};
|
|
844
|
-
_context4.prev =
|
|
844
|
+
_context4.prev = 5;
|
|
845
845
|
if (this.dataProvider) {
|
|
846
|
-
_context4.next =
|
|
846
|
+
_context4.next = 6;
|
|
847
847
|
break;
|
|
848
848
|
}
|
|
849
849
|
throw new Error('Data provider not set');
|
|
850
|
-
case
|
|
850
|
+
case 6:
|
|
851
851
|
blocks = []; // First, build the complete subscription structure
|
|
852
852
|
_iterator = _createForOfIteratorHelper(this._subscriptionManager.getSubscriptions().entries());
|
|
853
|
-
_context4.prev =
|
|
853
|
+
_context4.prev = 7;
|
|
854
854
|
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
855
855
|
var _step$value, resourceId, callbacks;
|
|
856
|
-
return _regeneratorRuntime.wrap(function
|
|
856
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
857
857
|
while (1) switch (_context3.prev = _context3.next) {
|
|
858
858
|
case 0:
|
|
859
859
|
_step$value = _slicedToArray(_step.value, 2), resourceId = _step$value[0], callbacks = _step$value[1];
|
|
@@ -865,41 +865,41 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
865
865
|
});
|
|
866
866
|
syncedBlocksToFlush[resourceId][localId] = true;
|
|
867
867
|
});
|
|
868
|
-
case
|
|
868
|
+
case 1:
|
|
869
869
|
case "end":
|
|
870
870
|
return _context3.stop();
|
|
871
871
|
}
|
|
872
872
|
}, _loop);
|
|
873
873
|
});
|
|
874
874
|
_iterator.s();
|
|
875
|
-
case
|
|
875
|
+
case 8:
|
|
876
876
|
if ((_step = _iterator.n()).done) {
|
|
877
|
-
_context4.next =
|
|
877
|
+
_context4.next = 10;
|
|
878
878
|
break;
|
|
879
879
|
}
|
|
880
|
-
return _context4.delegateYield(_loop(), "t0",
|
|
881
|
-
case
|
|
882
|
-
_context4.next =
|
|
880
|
+
return _context4.delegateYield(_loop(), "t0", 9);
|
|
881
|
+
case 9:
|
|
882
|
+
_context4.next = 8;
|
|
883
883
|
break;
|
|
884
|
-
case
|
|
885
|
-
_context4.next =
|
|
884
|
+
case 10:
|
|
885
|
+
_context4.next = 12;
|
|
886
886
|
break;
|
|
887
|
-
case
|
|
888
|
-
_context4.prev =
|
|
889
|
-
|
|
890
|
-
_iterator.e(
|
|
891
|
-
case
|
|
892
|
-
_context4.prev =
|
|
887
|
+
case 11:
|
|
888
|
+
_context4.prev = 11;
|
|
889
|
+
_t2 = _context4["catch"](7);
|
|
890
|
+
_iterator.e(_t2);
|
|
891
|
+
case 12:
|
|
892
|
+
_context4.prev = 12;
|
|
893
893
|
_iterator.f();
|
|
894
|
-
return _context4.finish(
|
|
895
|
-
case
|
|
894
|
+
return _context4.finish(12);
|
|
895
|
+
case 13:
|
|
896
896
|
if (!isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
897
|
-
_context4.next =
|
|
897
|
+
_context4.next = 14;
|
|
898
898
|
break;
|
|
899
899
|
}
|
|
900
900
|
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
901
901
|
return _context4.abrupt("return", true);
|
|
902
|
-
case
|
|
902
|
+
case 14:
|
|
903
903
|
// reset isCacheDirty early to prevent race condition
|
|
904
904
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
905
905
|
// on a live page and the reference sync block is being saved while the user
|
|
@@ -907,9 +907,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
907
907
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
908
908
|
this.isCacheDirty = false;
|
|
909
909
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
910
|
-
_context4.next =
|
|
910
|
+
_context4.next = 15;
|
|
911
911
|
return this.dataProvider.updateReferenceData(blocks);
|
|
912
|
-
case
|
|
912
|
+
case 15:
|
|
913
913
|
updateResult = _context4.sent;
|
|
914
914
|
if (!updateResult.success) {
|
|
915
915
|
success = false;
|
|
@@ -918,22 +918,22 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
918
918
|
});
|
|
919
919
|
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
920
920
|
}
|
|
921
|
-
_context4.next =
|
|
921
|
+
_context4.next = 17;
|
|
922
922
|
break;
|
|
923
|
-
case
|
|
924
|
-
_context4.prev =
|
|
925
|
-
|
|
923
|
+
case 16:
|
|
924
|
+
_context4.prev = 16;
|
|
925
|
+
_t3 = _context4["catch"](5);
|
|
926
926
|
success = false;
|
|
927
|
-
logException(
|
|
927
|
+
logException(_t3, {
|
|
928
928
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
929
929
|
});
|
|
930
930
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure({
|
|
931
|
-
reason:
|
|
931
|
+
reason: _t3.message
|
|
932
932
|
});
|
|
933
933
|
// No `resourceId` available in this catch — sourceProduct is intentionally omitted.
|
|
934
|
-
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, updateReferenceErrorPayload(
|
|
935
|
-
case
|
|
936
|
-
_context4.prev =
|
|
934
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, updateReferenceErrorPayload(_t3.message));
|
|
935
|
+
case 17:
|
|
936
|
+
_context4.prev = 17;
|
|
937
937
|
if (!success) {
|
|
938
938
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
939
939
|
this.isCacheDirty = true;
|
|
@@ -955,14 +955,14 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
955
955
|
void _this8.flush();
|
|
956
956
|
}, 0);
|
|
957
957
|
}
|
|
958
|
-
return _context4.finish(
|
|
959
|
-
case
|
|
958
|
+
return _context4.finish(17);
|
|
959
|
+
case 18:
|
|
960
960
|
return _context4.abrupt("return", success);
|
|
961
|
-
case
|
|
961
|
+
case 19:
|
|
962
962
|
case "end":
|
|
963
963
|
return _context4.stop();
|
|
964
964
|
}
|
|
965
|
-
}, _callee3, this, [[
|
|
965
|
+
}, _callee3, this, [[5, 16, 17, 18], [7, 11, 12, 13]]);
|
|
966
966
|
}));
|
|
967
967
|
function flush() {
|
|
968
968
|
return _flush.apply(this, arguments);
|