@atlaskit/editor-synced-block-provider 3.14.2 → 3.14.4
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 +21 -0
- package/dist/cjs/clients/block-service/blockService.js +12 -9
- package/dist/cjs/providers/block-service/blockServiceAPI.js +29 -21
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +61 -23
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +34 -6
- package/dist/cjs/store-manager/syncBlockStoreManager.js +53 -22
- package/dist/cjs/utils/experienceTracking.js +18 -1
- package/dist/es2019/clients/block-service/blockService.js +5 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +18 -10
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +68 -34
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +34 -7
- package/dist/es2019/store-manager/syncBlockStoreManager.js +36 -2
- package/dist/es2019/utils/experienceTracking.js +17 -0
- package/dist/esm/clients/block-service/blockService.js +12 -9
- package/dist/esm/providers/block-service/blockServiceAPI.js +29 -21
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +61 -23
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +35 -7
- package/dist/esm/store-manager/syncBlockStoreManager.js +53 -22
- package/dist/esm/utils/experienceTracking.js +17 -0
- package/dist/types/clients/block-service/blockService.d.ts +3 -2
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +5 -2
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +2 -1
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +2 -0
- package/dist/types/utils/experienceTracking.d.ts +8 -0
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +3 -2
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +5 -2
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +2 -1
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +2 -0
- package/dist/types-ts4.5/utils/experienceTracking.d.ts +8 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.14.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`5ec143ea91476`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5ec143ea91476) -
|
|
8
|
+
Do not re-convert already converted timestamps
|
|
9
|
+
- [`aa5302b457078`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aa5302b457078) -
|
|
10
|
+
[ux] EDITOR-4763 Ensure initial source sync block data are always registered
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 3.14.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`7702ea47c5329`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7702ea47c5329) -
|
|
18
|
+
[ux] Show editor flag when unpublished sync block is pasted
|
|
19
|
+
- [`2a9dfb4b326e6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a9dfb4b326e6) -
|
|
20
|
+
EDITOR-4698 add missing analytics for fetch references, graphql subsciption update, reference sync
|
|
21
|
+
block insert and delete success
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 3.14.2
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -292,11 +292,11 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
|
|
|
292
292
|
}();
|
|
293
293
|
var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
|
|
294
294
|
var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref0) {
|
|
295
|
-
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, requestBody, response;
|
|
295
|
+
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, requestBody, response;
|
|
296
296
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
297
297
|
while (1) switch (_context6.prev = _context6.next) {
|
|
298
298
|
case 0:
|
|
299
|
-
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion;
|
|
299
|
+
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion, status = _ref0.status;
|
|
300
300
|
requestBody = {
|
|
301
301
|
blockAri: blockAri,
|
|
302
302
|
blockInstanceId: blockInstanceId,
|
|
@@ -307,25 +307,28 @@ var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
|
|
|
307
307
|
if (stepVersion !== undefined) {
|
|
308
308
|
requestBody.stepVersion = stepVersion;
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
if (status !== undefined && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
311
|
+
requestBody.status = status;
|
|
312
|
+
}
|
|
313
|
+
_context6.next = 6;
|
|
311
314
|
return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block"), {
|
|
312
315
|
method: 'POST',
|
|
313
316
|
headers: COMMON_HEADERS,
|
|
314
317
|
body: JSON.stringify(requestBody)
|
|
315
318
|
});
|
|
316
|
-
case
|
|
319
|
+
case 6:
|
|
317
320
|
response = _context6.sent;
|
|
318
321
|
if (response.ok) {
|
|
319
|
-
_context6.next =
|
|
322
|
+
_context6.next = 9;
|
|
320
323
|
break;
|
|
321
324
|
}
|
|
322
325
|
throw new BlockError(response.status);
|
|
323
|
-
case
|
|
324
|
-
_context6.next =
|
|
326
|
+
case 9:
|
|
327
|
+
_context6.next = 11;
|
|
325
328
|
return response.json();
|
|
326
|
-
case 10:
|
|
327
|
-
return _context6.abrupt("return", _context6.sent);
|
|
328
329
|
case 11:
|
|
330
|
+
return _context6.abrupt("return", _context6.sent);
|
|
331
|
+
case 12:
|
|
329
332
|
case "end":
|
|
330
333
|
return _context6.stop();
|
|
331
334
|
}
|
|
@@ -12,6 +12,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
14
|
var _react = require("react");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _ari = require("../../clients/block-service/ari");
|
|
16
17
|
var _blockService = require("../../clients/block-service/blockService");
|
|
17
18
|
var _blockSubscription = require("../../clients/block-service/blockSubscription");
|
|
@@ -101,9 +102,7 @@ var convertToSyncBlockData = exports.convertToSyncBlockData = function convertTo
|
|
|
101
102
|
var createdAt;
|
|
102
103
|
if (data.createdAt !== undefined && data.createdAt !== null) {
|
|
103
104
|
try {
|
|
104
|
-
|
|
105
|
-
// BE should fix this in the future
|
|
106
|
-
createdAt = new Date(data.createdAt / 1000).toISOString();
|
|
105
|
+
createdAt = new Date(data.createdAt).toISOString();
|
|
107
106
|
} catch (_unused) {
|
|
108
107
|
// fallback to undefined
|
|
109
108
|
// as we don't want to block the whole process due to invalid date
|
|
@@ -615,13 +614,15 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
615
614
|
parentAri = _ref4.parentAri,
|
|
616
615
|
parentId = _ref4.parentId,
|
|
617
616
|
product = _ref4.product,
|
|
618
|
-
getVersion = _ref4.getVersion
|
|
617
|
+
getVersion = _ref4.getVersion,
|
|
618
|
+
isParentUnpublished = _ref4.isParentUnpublished;
|
|
619
619
|
(0, _classCallCheck2.default)(this, BlockServiceADFWriteProvider);
|
|
620
620
|
this.cloudId = cloudId;
|
|
621
621
|
this.parentAri = parentAri;
|
|
622
622
|
this.parentId = parentId;
|
|
623
623
|
this.product = product;
|
|
624
624
|
this.getVersion = getVersion;
|
|
625
|
+
this.isParentUnpublished = isParentUnpublished;
|
|
625
626
|
}
|
|
626
627
|
|
|
627
628
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -691,7 +692,8 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
691
692
|
key: "createData",
|
|
692
693
|
value: function () {
|
|
693
694
|
var _createData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(data) {
|
|
694
|
-
var
|
|
695
|
+
var _this$isParentUnpubli;
|
|
696
|
+
var resourceId, blockAri, stepVersion, status;
|
|
695
697
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
696
698
|
while (1) switch (_context6.prev = _context6.next) {
|
|
697
699
|
case 0:
|
|
@@ -711,41 +713,43 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
711
713
|
resourceId: resourceId
|
|
712
714
|
});
|
|
713
715
|
stepVersion = this.getVersion ? this.getVersion() : undefined;
|
|
714
|
-
|
|
715
|
-
_context6.
|
|
716
|
+
status = (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? (_this$isParentUnpubli = this.isParentUnpublished) !== null && _this$isParentUnpubli !== void 0 && _this$isParentUnpubli.call(this) ? 'unpublished' : data.status || 'active' : undefined;
|
|
717
|
+
_context6.prev = 6;
|
|
718
|
+
_context6.next = 9;
|
|
716
719
|
return (0, _blockService.createSyncedBlock)({
|
|
717
720
|
blockAri: blockAri,
|
|
718
721
|
blockInstanceId: data.blockInstanceId,
|
|
719
722
|
sourceAri: this.parentAri,
|
|
720
723
|
product: this.product,
|
|
721
724
|
content: JSON.stringify(data.content),
|
|
722
|
-
stepVersion: stepVersion
|
|
725
|
+
stepVersion: stepVersion,
|
|
726
|
+
status: status
|
|
723
727
|
});
|
|
724
|
-
case
|
|
728
|
+
case 9:
|
|
725
729
|
return _context6.abrupt("return", {
|
|
726
730
|
resourceId: resourceId
|
|
727
731
|
});
|
|
728
|
-
case
|
|
729
|
-
_context6.prev =
|
|
730
|
-
_context6.t0 = _context6["catch"](
|
|
732
|
+
case 12:
|
|
733
|
+
_context6.prev = 12;
|
|
734
|
+
_context6.t0 = _context6["catch"](6);
|
|
731
735
|
if (!(_context6.t0 instanceof _blockService.BlockError)) {
|
|
732
|
-
_context6.next =
|
|
736
|
+
_context6.next = 16;
|
|
733
737
|
break;
|
|
734
738
|
}
|
|
735
739
|
return _context6.abrupt("return", {
|
|
736
740
|
error: mapBlockError(_context6.t0),
|
|
737
741
|
resourceId: resourceId
|
|
738
742
|
});
|
|
739
|
-
case
|
|
743
|
+
case 16:
|
|
740
744
|
return _context6.abrupt("return", {
|
|
741
745
|
error: (0, _errorHandling.stringifyError)(_context6.t0),
|
|
742
746
|
resourceId: resourceId
|
|
743
747
|
});
|
|
744
|
-
case
|
|
748
|
+
case 17:
|
|
745
749
|
case "end":
|
|
746
750
|
return _context6.stop();
|
|
747
751
|
}
|
|
748
|
-
}, _callee6, this, [[
|
|
752
|
+
}, _callee6, this, [[6, 12]]);
|
|
749
753
|
}));
|
|
750
754
|
function createData(_x6) {
|
|
751
755
|
return _createData.apply(this, arguments);
|
|
@@ -906,7 +910,8 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
906
910
|
parentAri = _ref5.parentAri,
|
|
907
911
|
parentId = _ref5.parentId,
|
|
908
912
|
product = _ref5.product,
|
|
909
|
-
getVersion = _ref5.getVersion
|
|
913
|
+
getVersion = _ref5.getVersion,
|
|
914
|
+
isParentUnpublished = _ref5.isParentUnpublished;
|
|
910
915
|
return {
|
|
911
916
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
912
917
|
cloudId: cloudId,
|
|
@@ -917,7 +922,8 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
917
922
|
parentAri: parentAri,
|
|
918
923
|
parentId: parentId,
|
|
919
924
|
product: product,
|
|
920
|
-
getVersion: getVersion
|
|
925
|
+
getVersion: getVersion,
|
|
926
|
+
isParentUnpublished: isParentUnpublished
|
|
921
927
|
})
|
|
922
928
|
};
|
|
923
929
|
};
|
|
@@ -926,16 +932,18 @@ var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProv
|
|
|
926
932
|
parentAri = _ref6.parentAri,
|
|
927
933
|
parentId = _ref6.parentId,
|
|
928
934
|
product = _ref6.product,
|
|
929
|
-
getVersion = _ref6.getVersion
|
|
935
|
+
getVersion = _ref6.getVersion,
|
|
936
|
+
isParentUnpublished = _ref6.isParentUnpublished;
|
|
930
937
|
return (0, _react.useMemo)(function () {
|
|
931
938
|
return createBlockServiceAPIProviders({
|
|
932
939
|
cloudId: cloudId,
|
|
933
940
|
parentAri: parentAri,
|
|
934
941
|
parentId: parentId,
|
|
935
942
|
product: product,
|
|
936
|
-
getVersion: getVersion
|
|
943
|
+
getVersion: getVersion,
|
|
944
|
+
isParentUnpublished: isParentUnpublished
|
|
937
945
|
});
|
|
938
|
-
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
946
|
+
}, [cloudId, parentAri, parentId, product, getVersion, isParentUnpublished]);
|
|
939
947
|
};
|
|
940
948
|
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref7) {
|
|
941
949
|
var cloudId = _ref7.cloudId,
|
|
@@ -33,6 +33,10 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
33
33
|
var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
34
34
|
// Listeners for subscription changes (used by React components to know when to update)
|
|
35
35
|
|
|
36
|
+
// Track newly added sync blocks (resourceIds that were just subscribed to without cached data)
|
|
37
|
+
|
|
38
|
+
// Callback to notify when an unpublished sync block is detected
|
|
39
|
+
|
|
36
40
|
function ReferenceSyncBlockStoreManager(dataProvider) {
|
|
37
41
|
(0, _classCallCheck2.default)(this, ReferenceSyncBlockStoreManager);
|
|
38
42
|
// Keeps track of addition and deletion of reference synced blocks on the document
|
|
@@ -53,6 +57,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
53
57
|
this.pendingCacheDeletions = new Map();
|
|
54
58
|
this.graphqlSubscriptions = new Map();
|
|
55
59
|
this.subscriptionChangeListeners = new Set();
|
|
60
|
+
this.newlyAddedSyncBlocks = new Set();
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
@@ -157,6 +162,22 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
157
162
|
this.fetchSourceInfoExperience = (0, _experienceTracking.getFetchSourceInfoExperience)(fireAnalyticsEvent);
|
|
158
163
|
this.saveExperience = (0, _experienceTracking.getSaveReferenceExperience)(fireAnalyticsEvent);
|
|
159
164
|
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "setOnUnpublishedSyncBlockDetected",
|
|
167
|
+
value: function setOnUnpublishedSyncBlockDetected(callback) {
|
|
168
|
+
this.onUnpublishedSyncBlockDetected = callback;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Mark a sync block as newly added to the document.
|
|
173
|
+
* This should be called when a sync block node is added via a transaction.
|
|
174
|
+
* @param resourceId - The resource ID of the newly added sync block
|
|
175
|
+
*/
|
|
176
|
+
}, {
|
|
177
|
+
key: "markAsNewlyAdded",
|
|
178
|
+
value: function markAsNewlyAdded(resourceId) {
|
|
179
|
+
this.newlyAddedSyncBlocks.add(resourceId);
|
|
180
|
+
}
|
|
160
181
|
}, {
|
|
161
182
|
key: "generateResourceIdForReference",
|
|
162
183
|
value: function generateResourceIdForReference(sourceId) {
|
|
@@ -312,13 +333,18 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
312
333
|
key: "handleGraphQLSubscriptionUpdate",
|
|
313
334
|
value: function handleGraphQLSubscriptionUpdate(syncBlockInstance) {
|
|
314
335
|
if (!syncBlockInstance.resourceId) {
|
|
315
|
-
|
|
336
|
+
throw new Error('Sync block instance provided to graphql subscription update missing resource id');
|
|
316
337
|
}
|
|
317
338
|
var existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
|
|
318
339
|
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
319
340
|
this.updateCache(resolvedSyncBlockInstance);
|
|
320
341
|
if (!syncBlockInstance.error) {
|
|
342
|
+
var _this$fireAnalyticsEv2, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
343
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId, syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.blockInstanceId, syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
321
344
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
345
|
+
} else {
|
|
346
|
+
var _this$fireAnalyticsEv3, _syncBlockInstance$er;
|
|
347
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.fetchErrorPayload)((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.type, syncBlockInstance.resourceId));
|
|
322
348
|
}
|
|
323
349
|
}
|
|
324
350
|
|
|
@@ -420,8 +446,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
420
446
|
}
|
|
421
447
|
}
|
|
422
448
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
423
|
-
var _this$
|
|
424
|
-
(_this$
|
|
449
|
+
var _this$fireAnalyticsEv4;
|
|
450
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing', resourceId));
|
|
425
451
|
return Promise.resolve(undefined);
|
|
426
452
|
}
|
|
427
453
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
@@ -480,11 +506,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
480
506
|
this.syncBlockSourceInfoRequestsOld.set(resourceId, true);
|
|
481
507
|
}
|
|
482
508
|
} catch (error) {
|
|
483
|
-
var _this$
|
|
509
|
+
var _this$fireAnalyticsEv5;
|
|
484
510
|
(0, _monitoring.logException)(error, {
|
|
485
511
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
486
512
|
});
|
|
487
|
-
(_this$
|
|
513
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId));
|
|
488
514
|
}
|
|
489
515
|
return Promise.resolve(undefined);
|
|
490
516
|
}
|
|
@@ -551,14 +577,26 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
551
577
|
hasUnexpectedError = false;
|
|
552
578
|
hasExpectedError = false;
|
|
553
579
|
data.forEach(function (syncBlockInstance) {
|
|
580
|
+
var _resolvedSyncBlockIns;
|
|
554
581
|
if (!syncBlockInstance.resourceId) {
|
|
555
|
-
var _this5$fireAnalyticsE, _syncBlockInstance$
|
|
556
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(((_syncBlockInstance$
|
|
582
|
+
var _this5$fireAnalyticsE, _syncBlockInstance$er2;
|
|
583
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) || 'Returned sync block instance does not have resource id'));
|
|
557
584
|
return;
|
|
558
585
|
}
|
|
559
586
|
var existingSyncBlock = _this5.getFromCache(syncBlockInstance.resourceId);
|
|
560
587
|
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
561
588
|
_this5.updateCache(resolvedSyncBlockInstance);
|
|
589
|
+
|
|
590
|
+
// Check if this is a newly added unpublished sync block and notify
|
|
591
|
+
// Only trigger for sync blocks that were just added (not refreshed or loaded on page init)
|
|
592
|
+
if (!syncBlockInstance.error && ((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) === null || _resolvedSyncBlockIns === void 0 ? void 0 : _resolvedSyncBlockIns.status) === 'unpublished' && _this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId) && _this5.onUnpublishedSyncBlockDetected && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
593
|
+
// Remove from newly added set after checking to prevent duplicate flags
|
|
594
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
595
|
+
_this5.onUnpublishedSyncBlockDetected(resolvedSyncBlockInstance.resourceId);
|
|
596
|
+
} else if (_this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId)) {
|
|
597
|
+
// Remove from newly added set even if not unpublished (to clean up)
|
|
598
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
599
|
+
}
|
|
562
600
|
if (syncBlockInstance.error) {
|
|
563
601
|
var _this5$fireAnalyticsE2;
|
|
564
602
|
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
@@ -569,8 +607,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
569
607
|
}
|
|
570
608
|
return;
|
|
571
609
|
} else if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
572
|
-
var _this5$fireAnalyticsE3, _syncBlockInstance$
|
|
573
|
-
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, (_syncBlockInstance$
|
|
610
|
+
var _this5$fireAnalyticsE3, _syncBlockInstance$da3, _syncBlockInstance$da4;
|
|
611
|
+
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.blockInstanceId, (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product));
|
|
574
612
|
}
|
|
575
613
|
_this5.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
576
614
|
});
|
|
@@ -781,11 +819,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
781
819
|
}
|
|
782
820
|
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
783
821
|
} catch (error) {
|
|
784
|
-
var _this$
|
|
822
|
+
var _this$fireAnalyticsEv6;
|
|
785
823
|
(0, _monitoring.logException)(error, {
|
|
786
824
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
787
825
|
});
|
|
788
|
-
(_this$
|
|
826
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
789
827
|
return function () {};
|
|
790
828
|
}
|
|
791
829
|
}
|
|
@@ -809,12 +847,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
809
847
|
key: "getProviderFactory",
|
|
810
848
|
value: function getProviderFactory(resourceId) {
|
|
811
849
|
if (!this.dataProvider) {
|
|
812
|
-
var _this$
|
|
850
|
+
var _this$fireAnalyticsEv7;
|
|
813
851
|
var error = new Error('Data provider not set');
|
|
814
852
|
(0, _monitoring.logException)(error, {
|
|
815
853
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
816
854
|
});
|
|
817
|
-
(_this$
|
|
855
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
818
856
|
return undefined;
|
|
819
857
|
}
|
|
820
858
|
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
@@ -843,11 +881,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
843
881
|
try {
|
|
844
882
|
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
845
883
|
} catch (error) {
|
|
846
|
-
var _this$
|
|
884
|
+
var _this$fireAnalyticsEv8;
|
|
847
885
|
(0, _monitoring.logException)(error, {
|
|
848
886
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
849
887
|
});
|
|
850
|
-
(_this$
|
|
888
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchErrorPayload)(error.message, resourceId));
|
|
851
889
|
}
|
|
852
890
|
}
|
|
853
891
|
return providerFactory;
|
|
@@ -907,8 +945,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
907
945
|
return;
|
|
908
946
|
}
|
|
909
947
|
if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
|
|
910
|
-
var _this$
|
|
911
|
-
(_this$
|
|
948
|
+
var _this$fireAnalyticsEv9;
|
|
949
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, (0, _errorHandling.fetchErrorPayload)('Sync block source ari or product not found'));
|
|
912
950
|
return;
|
|
913
951
|
}
|
|
914
952
|
var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data2 = syncBlock.data) === null || _syncBlock$data2 === void 0 ? void 0 : _syncBlock$data2.sourceAri, (_syncBlock$data3 = syncBlock.data) === null || _syncBlock$data3 === void 0 ? void 0 : _syncBlock$data3.product);
|
|
@@ -958,7 +996,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
958
996
|
key: "flush",
|
|
959
997
|
value: (function () {
|
|
960
998
|
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
961
|
-
var success, blocks, _this$saveExperience, updateResult, _this$
|
|
999
|
+
var success, blocks, _this$saveExperience, updateResult, _this$fireAnalyticsEv0, _this$saveExperience2, _this$fireAnalyticsEv1, _this$saveExperience3, _this$saveExperience4;
|
|
962
1000
|
return _regenerator.default.wrap(function _callee3$(_context4) {
|
|
963
1001
|
while (1) switch (_context4.prev = _context4.next) {
|
|
964
1002
|
case 0:
|
|
@@ -1019,7 +1057,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1019
1057
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1020
1058
|
});
|
|
1021
1059
|
}
|
|
1022
|
-
(_this$
|
|
1060
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1023
1061
|
}
|
|
1024
1062
|
_context4.next = 26;
|
|
1025
1063
|
break;
|
|
@@ -1035,7 +1073,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1035
1073
|
reason: _context4.t0.message
|
|
1036
1074
|
});
|
|
1037
1075
|
}
|
|
1038
|
-
(_this$
|
|
1076
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context4.t0.message));
|
|
1039
1077
|
case 26:
|
|
1040
1078
|
_context4.prev = 26;
|
|
1041
1079
|
if (!success) {
|
|
@@ -1080,13 +1118,13 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1080
1118
|
});
|
|
1081
1119
|
this.providerFactories.clear();
|
|
1082
1120
|
(_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 || _this$saveExperience5.abort({
|
|
1083
|
-
reason: '
|
|
1121
|
+
reason: 'editorDestroyed'
|
|
1084
1122
|
});
|
|
1085
1123
|
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.abort({
|
|
1086
|
-
reason: '
|
|
1124
|
+
reason: 'editorDestroyed'
|
|
1087
1125
|
});
|
|
1088
1126
|
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.abort({
|
|
1089
|
-
reason: '
|
|
1127
|
+
reason: 'editorDestroyed'
|
|
1090
1128
|
});
|
|
1091
1129
|
this.fireAnalyticsEvent = undefined;
|
|
1092
1130
|
}
|
|
@@ -43,6 +43,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
43
43
|
this.createExperience = (0, _experienceTracking.getCreateSourceExperience)(fireAnalyticsEvent);
|
|
44
44
|
this.saveExperience = (0, _experienceTracking.getSaveSourceExperience)(fireAnalyticsEvent);
|
|
45
45
|
this.deleteExperience = (0, _experienceTracking.getDeleteSourceExperience)(fireAnalyticsEvent);
|
|
46
|
+
this.fetchSourceInfoExperience = (0, _experienceTracking.getFetchSourceInfoExperience)(fireAnalyticsEvent);
|
|
46
47
|
}
|
|
47
48
|
}, {
|
|
48
49
|
key: "isSourceBlock",
|
|
@@ -281,7 +282,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
281
282
|
*/
|
|
282
283
|
}, {
|
|
283
284
|
key: "createBodiedSyncBlockNode",
|
|
284
|
-
value: function createBodiedSyncBlockNode(attrs) {
|
|
285
|
+
value: function createBodiedSyncBlockNode(attrs, nodeData) {
|
|
285
286
|
var _this4 = this;
|
|
286
287
|
try {
|
|
287
288
|
var _this$createExperienc;
|
|
@@ -303,6 +304,12 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
303
304
|
var _this4$createExperien;
|
|
304
305
|
(_this4$createExperien = _this4.createExperience) === null || _this4$createExperien === void 0 || _this4$createExperien.success();
|
|
305
306
|
}
|
|
307
|
+
|
|
308
|
+
// Update the sync block data with the node data if it is provided
|
|
309
|
+
// to avoid any race conditions where the data could be missed during a render operation
|
|
310
|
+
if (nodeData) {
|
|
311
|
+
_this4.updateSyncBlockData(nodeData);
|
|
312
|
+
}
|
|
306
313
|
} else {
|
|
307
314
|
var _this4$fireAnalyticsE;
|
|
308
315
|
_this4.commitPendingCreation(false);
|
|
@@ -541,11 +548,29 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
541
548
|
}, {
|
|
542
549
|
key: "getSyncBlockSourceInfo",
|
|
543
550
|
value: function getSyncBlockSourceInfo(localId) {
|
|
551
|
+
var _this6 = this;
|
|
544
552
|
try {
|
|
545
553
|
if (!this.dataProvider) {
|
|
546
554
|
throw new Error('Data provider not set');
|
|
547
555
|
}
|
|
548
|
-
|
|
556
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
557
|
+
var _this$fetchSourceInfo;
|
|
558
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
559
|
+
}
|
|
560
|
+
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined, this.fireAnalyticsEvent).then(function (sourceInfo) {
|
|
561
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
562
|
+
if (!sourceInfo) {
|
|
563
|
+
var _this6$fetchSourceInf;
|
|
564
|
+
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
565
|
+
reason: 'No source info returned'
|
|
566
|
+
});
|
|
567
|
+
} else {
|
|
568
|
+
var _this6$fetchSourceInf2;
|
|
569
|
+
(_this6$fetchSourceInf2 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf2 === void 0 || _this6$fetchSourceInf2.success();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return sourceInfo;
|
|
573
|
+
});
|
|
549
574
|
} catch (error) {
|
|
550
575
|
var _this$fireAnalyticsEv6;
|
|
551
576
|
(0, _monitoring.logException)(error, {
|
|
@@ -577,20 +602,23 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
577
602
|
}, {
|
|
578
603
|
key: "destroy",
|
|
579
604
|
value: function destroy() {
|
|
580
|
-
var _this$saveExperience4, _this$createExperienc2, _this$deleteExperienc4;
|
|
605
|
+
var _this$saveExperience4, _this$createExperienc2, _this$deleteExperienc4, _this$fetchSourceInfo2;
|
|
581
606
|
this.syncBlockCache.clear();
|
|
582
607
|
this.confirmationCallback = undefined;
|
|
583
608
|
this.pendingResourceId = undefined;
|
|
584
609
|
this.creationCallback = undefined;
|
|
585
610
|
this.dataProvider = undefined;
|
|
586
611
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.abort({
|
|
587
|
-
reason: '
|
|
612
|
+
reason: 'editorDestroyed'
|
|
588
613
|
});
|
|
589
614
|
(_this$createExperienc2 = this.createExperience) === null || _this$createExperienc2 === void 0 || _this$createExperienc2.abort({
|
|
590
|
-
reason: '
|
|
615
|
+
reason: 'editorDestroyed'
|
|
591
616
|
});
|
|
592
617
|
(_this$deleteExperienc4 = this.deleteExperience) === null || _this$deleteExperienc4 === void 0 || _this$deleteExperienc4.abort({
|
|
593
|
-
reason: '
|
|
618
|
+
reason: 'editorDestroyed'
|
|
619
|
+
});
|
|
620
|
+
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.abort({
|
|
621
|
+
reason: 'editorDestroyed'
|
|
594
622
|
});
|
|
595
623
|
this.clearPendingDeletion();
|
|
596
624
|
}
|