@atlaskit/editor-synced-block-provider 6.6.2 → 6.6.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/clients/jira/sourceInfo.js +18 -40
  3. package/dist/cjs/entry-points/utils.js +0 -6
  4. package/dist/cjs/hooks/useFetchSyncBlockData.js +1 -1
  5. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +4 -7
  6. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +120 -39
  7. package/dist/cjs/store-manager/syncBlockBatchFetcher.js +1 -1
  8. package/dist/cjs/store-manager/syncBlockProviderFactoryManager.js +3 -3
  9. package/dist/cjs/store-manager/syncBlockStoreManager.js +1 -1
  10. package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +3 -6
  11. package/dist/cjs/utils/utils.js +1 -13
  12. package/dist/es2019/clients/jira/sourceInfo.js +27 -48
  13. package/dist/es2019/entry-points/utils.js +1 -1
  14. package/dist/es2019/hooks/useFetchSyncBlockData.js +2 -2
  15. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +5 -8
  16. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +95 -16
  17. package/dist/es2019/store-manager/syncBlockBatchFetcher.js +2 -2
  18. package/dist/es2019/store-manager/syncBlockProviderFactoryManager.js +4 -4
  19. package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -2
  20. package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +4 -7
  21. package/dist/es2019/utils/utils.js +0 -10
  22. package/dist/esm/clients/jira/sourceInfo.js +19 -40
  23. package/dist/esm/entry-points/utils.js +1 -1
  24. package/dist/esm/hooks/useFetchSyncBlockData.js +2 -2
  25. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +5 -8
  26. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +122 -41
  27. package/dist/esm/store-manager/syncBlockBatchFetcher.js +2 -2
  28. package/dist/esm/store-manager/syncBlockProviderFactoryManager.js +4 -4
  29. package/dist/esm/store-manager/syncBlockStoreManager.js +2 -2
  30. package/dist/esm/store-manager/syncBlockSubscriptionManager.js +4 -7
  31. package/dist/esm/utils/utils.js +0 -12
  32. package/dist/types/entry-points/utils.d.ts +1 -1
  33. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +24 -0
  34. package/dist/types/utils/utils.d.ts +0 -1
  35. package/dist/types-ts4.5/entry-points/utils.d.ts +1 -1
  36. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +24 -0
  37. package/dist/types-ts4.5/utils/utils.d.ts +0 -1
  38. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 6.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7ddc63dca3716`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7ddc63dca3716) -
8
+ Fix synced block reference showing unpublished error when created from existing content on a live
9
+ page without further edits
10
+
11
+ ## 6.6.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [`cec76b6d3aeaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cec76b6d3aeaa) -
16
+ Cleanup feature gate `platform_synced_block_patch_11`. Jira work-item issue-type icons,
17
+ product-specific copy, and Relay environment initialisation are now permanently enabled.
18
+ - Updated dependencies
19
+
3
20
  ## 6.6.2
4
21
 
5
22
  ### Patch Changes
@@ -8,7 +8,6 @@ exports.fetchJiraWorkItemInfo = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _retry = require("../../utils/retry");
13
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable require-unicode-regexp */
@@ -26,11 +25,9 @@ var GET_SOURCE_INFO_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_SOURCE_INFO';
26
25
  * @param id - the ID of the work item
27
26
  * @returns url of the work item
28
27
  */
29
- // `issueType` is requested unconditionally because GraphQL field selection cannot be
30
- // gated at the network layer without a separate operation; AGG ignores unknown
31
- // front-end gating. The runtime mapping into `SyncBlockSourceInfo.issueType` is gated
32
- // by `platform_synced_block_patch_11` below.
33
- var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID!) {\n jira {\n issueById(id: $id) {\n id\n webUrl\n summary\n issueType {\n name\n avatar {\n xsmall\n }\n }\n }\n }}");
28
+ // `issueType` is requested alongside `summary` and `webUrl` so the
29
+ // SyncedLocationDropdown can render the correct ADS issue-type icon.
30
+ var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID!) {\n jira {\n\tissueById(id: $id) {\n\tid\n\twebUrl\n\tsummary\n\tissueType {\n\t\tname\n\t\tavatar {\n\t\txsmall\n\t\t}\n\t}\n\t}\n }}");
34
31
  var getJiraWorkItemSourceInfo = /*#__PURE__*/function () {
35
32
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(ari) {
36
33
  var bodyData, response;
@@ -141,59 +138,40 @@ var resolveNoAccessWorkItemInfo = /*#__PURE__*/function () {
141
138
  */
142
139
  var fetchJiraWorkItemInfo = exports.fetchJiraWorkItemInfo = /*#__PURE__*/function () {
143
140
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(workItemAri, hasAccess) {
144
- var _response$data, _contentData$webUrl, _contentData$summary, response, contentData, _rawIssueType$avatar, _webUrl, _summary, rawIssueType, issueTypeName, issueType, webUrl, summary;
141
+ var _response$data, _contentData$issueTyp, _contentData$issueTyp2, response, contentData, webUrl, summary, issueTypeName, issueType;
145
142
  return _regenerator.default.wrap(function _callee3$(_context3) {
146
143
  while (1) switch (_context3.prev = _context3.next) {
147
144
  case 0:
148
145
  if (!hasAccess) {
149
- _context3.next = 17;
146
+ _context3.next = 12;
150
147
  break;
151
148
  }
152
149
  _context3.next = 3;
153
150
  return getJiraWorkItemSourceInfo(workItemAri);
154
151
  case 3:
155
152
  response = _context3.sent;
156
- contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.jira) === null || _response$data === void 0 ? void 0 : _response$data.issueById; // Defensive narrowing (gated by `platform_synced_block_patch_11`):
157
- // AGG may return `null` (not just omit the field) for `webUrl` / `summary` on
158
- // partially indexed issues. Without these guards, downstream consumers that
159
- // expect `string | undefined` would receive `null` and either crash or render
160
- // the literal string "null". The pre-gate path preserves the legacy behaviour
161
- // so this can be dialled off independently.
162
- if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_11')) {
163
- _context3.next = 12;
164
- break;
165
- }
166
- _webUrl = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) === 'string' ? contentData.webUrl : undefined;
167
- _summary = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.summary) === 'string' ? contentData.summary : undefined; // Surface issue-type metadata so consumers can render the correct ADS issue-type
168
- // icon. Defensive narrowing mirrors the webUrl/summary treatment above: only
169
- // surfaced when `name` is a non-empty string; AGG values like `{ name: null }`
170
- // collapse back to `undefined`.
171
- rawIssueType = contentData === null || contentData === void 0 ? void 0 : contentData.issueType;
172
- issueTypeName = typeof (rawIssueType === null || rawIssueType === void 0 ? void 0 : rawIssueType.name) === 'string' && rawIssueType.name.length > 0 ? rawIssueType.name : undefined;
173
- issueType = issueTypeName ? {
153
+ contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.jira) === null || _response$data === void 0 ? void 0 : _response$data.issueById;
154
+ webUrl = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) === 'string' ? contentData.webUrl : undefined;
155
+ summary = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.summary) === 'string' ? contentData.summary : undefined; // Surface issue-type metadata for the SyncedLocationDropdown's ADS icon.
156
+ // Defensive narrowing: only surface when `name` is a non-empty string;
157
+ // AGG values like `{ name: null }` collapse back to `undefined`.
158
+ issueTypeName = contentData === null || contentData === void 0 || (_contentData$issueTyp = contentData.issueType) === null || _contentData$issueTyp === void 0 ? void 0 : _contentData$issueTyp.name;
159
+ issueType = typeof issueTypeName === 'string' && issueTypeName.length > 0 ? {
174
160
  name: issueTypeName,
175
- iconUrl: typeof (rawIssueType === null || rawIssueType === void 0 || (_rawIssueType$avatar = rawIssueType.avatar) === null || _rawIssueType$avatar === void 0 ? void 0 : _rawIssueType$avatar.xsmall) === 'string' ? rawIssueType.avatar.xsmall : undefined
161
+ iconUrl: typeof (contentData === null || contentData === void 0 || (_contentData$issueTyp2 = contentData.issueType) === null || _contentData$issueTyp2 === void 0 || (_contentData$issueTyp2 = _contentData$issueTyp2.avatar) === null || _contentData$issueTyp2 === void 0 ? void 0 : _contentData$issueTyp2.xsmall) === 'string' ? contentData.issueType.avatar.xsmall : undefined
176
162
  } : undefined;
177
163
  return _context3.abrupt("return", Promise.resolve({
178
- url: _webUrl,
164
+ url: webUrl,
179
165
  sourceAri: workItemAri,
180
- title: _summary,
166
+ title: summary,
181
167
  issueType: issueType
182
168
  }));
183
169
  case 12:
184
- webUrl = (_contentData$webUrl = contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) !== null && _contentData$webUrl !== void 0 ? _contentData$webUrl : undefined;
185
- summary = (_contentData$summary = contentData === null || contentData === void 0 ? void 0 : contentData.summary) !== null && _contentData$summary !== void 0 ? _contentData$summary : undefined;
186
- return _context3.abrupt("return", Promise.resolve({
187
- url: webUrl,
188
- sourceAri: workItemAri,
189
- title: summary
190
- }));
191
- case 17:
192
- _context3.next = 19;
170
+ _context3.next = 14;
193
171
  return resolveNoAccessWorkItemInfo(workItemAri);
194
- case 19:
172
+ case 14:
195
173
  return _context3.abrupt("return", _context3.sent);
196
- case 20:
174
+ case 15:
197
175
  case "end":
198
176
  return _context3.stop();
199
177
  }
@@ -51,10 +51,4 @@ Object.defineProperty(exports, "getSourceProductFromResourceIdSafe", {
51
51
  return _utils.getSourceProductFromResourceIdSafe;
52
52
  }
53
53
  });
54
- Object.defineProperty(exports, "productAttrIfGateOn", {
55
- enumerable: true,
56
- get: function get() {
57
- return _utils.productAttrIfGateOn;
58
- }
59
- });
60
54
  var _utils = require("../utils/utils");
@@ -78,7 +78,7 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
78
78
  (0, _monitoring.logException)(_context.t0, {
79
79
  location: 'editor-synced-block-provider/useFetchSyncBlockData'
80
80
  });
81
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent((0, _errorHandling.fetchErrorPayload)(_context.t0.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
81
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent((0, _errorHandling.fetchErrorPayload)(_context.t0.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
82
82
 
83
83
  // Set error state if fetching fails
84
84
  setFetchState({
@@ -13,7 +13,6 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
15
15
  var _monitoring = require("@atlaskit/editor-common/monitoring");
16
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
16
  var _types = require("../common/types");
18
17
  var _errorHandling = require("../utils/errorHandling");
19
18
  var _experienceTracking = require("../utils/experienceTracking");
@@ -318,7 +317,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
318
317
  // Derive once per call so we don't re-parse on every analytics event below.
319
318
  // `product` from cached data is preferred when available; fall back to parsing
320
319
  // the resourceId.
321
- var sourceProduct = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11') ? product !== null && product !== void 0 ? product : (0, _utils.getSourceProductFromResourceIdSafe)(resourceId) : undefined;
320
+ var sourceProduct = product !== null && product !== void 0 ? product : (0, _utils.getSourceProductFromResourceIdSafe)(resourceId);
322
321
  if (!sourceAri || !product || !blockInstanceId) {
323
322
  var _this$fireAnalyticsEv3;
324
323
  (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing', resourceId, sourceProduct));
@@ -367,7 +366,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
367
366
  (0, _monitoring.logException)(error, {
368
367
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
369
368
  });
370
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
369
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
371
370
  }
372
371
  return Promise.resolve(undefined);
373
372
  }
@@ -562,7 +561,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
562
561
  }
563
562
  if (syncBlockInstance.error) {
564
563
  var _this5$fireAnalyticsE2, _syncBlockInstance$da, _syncBlockInstance$da2;
565
- (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId, (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11') ? (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId) : undefined));
564
+ (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId, (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId)));
566
565
  if (syncBlockInstance.error.type === _types.SyncBlockError.NotFound || syncBlockInstance.error.type === _types.SyncBlockError.Forbidden) {
567
566
  hasExpectedError = true;
568
567
  } else if (syncBlockInstance.error) {
@@ -574,9 +573,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
574
573
  var localIds = callbacks ? Object.keys(callbacks) : [];
575
574
  localIds.forEach(function (localId) {
576
575
  var _this5$fireAnalyticsE3, _syncBlockInstance$da3, _syncBlockInstance$da4;
577
- (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, localId,
578
- // Prefer cached product when available; fall back to parsing the resourceId.
579
- (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11') ? (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId) : undefined));
576
+ (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId)));
580
577
  });
581
578
  _this5.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
582
579
  });
@@ -12,6 +12,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _monitoring = require("@atlaskit/editor-common/monitoring");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _types = require("../common/types");
16
17
  var _errorHandling = require("../utils/errorHandling");
17
18
  var _experienceTracking = require("../utils/experienceTracking");
@@ -21,6 +22,9 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
21
22
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
22
23
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
24
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
+ /** Maximum time (ms) flush() will wait for in-flight block creations before proceeding. */
26
+ var FLUSH_CREATION_AWAIT_TIMEOUT_MS = 1000;
27
+
24
28
  // A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
25
29
  // Designed to manage local in-memory state and synchronize with an external data provider.
26
30
  // Supports create, flush, and delete operations for source sync blocks.
@@ -31,6 +35,22 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
31
35
  var _this = this;
32
36
  (0, _classCallCheck2.default)(this, SourceSyncBlockStoreManager);
33
37
  (0, _defineProperty2.default)(this, "hasReceivedContentChange", false);
38
+ /**
39
+ * Promises for in-flight block creations, keyed by resourceId.
40
+ * `flush()` awaits these so that blocks created from existing content are
41
+ * persisted even if no further edits trigger a subsequent flush.
42
+ * See EDITOR-7112.
43
+ */
44
+ (0, _defineProperty2.default)(this, "pendingCreationPromises", new Map());
45
+ /**
46
+ * Set of resource IDs whose creation was still in-flight when a `flush()`
47
+ * timed out. Each completion (success or failure) is removed from this set;
48
+ * the first successful completion of any of these IDs triggers
49
+ * `postCreationFlushCallback` so the content is eventually persisted.
50
+ * Tracking IDs (not just a boolean) avoids dropping late completions when
51
+ * multiple blocks are created concurrently. See EDITOR-7112.
52
+ */
53
+ (0, _defineProperty2.default)(this, "creationsTimedOutDuringFlush", new Set());
34
54
  (0, _defineProperty2.default)(this, "setPendingDeletion", function (Ids, value) {
35
55
  if (_this.viewMode === 'view') {
36
56
  return;
@@ -57,6 +77,18 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
57
77
  value: function registerFlushCompletionCallback(callback) {
58
78
  this.flushCompletionCallback = callback;
59
79
  }
80
+
81
+ /**
82
+ * Register a callback to be invoked when flush() timed out waiting for a
83
+ * pending block creation and that creation subsequently completes. The
84
+ * callback should trigger a deferred flush to persist the content that
85
+ * was skipped due to the timeout. See EDITOR-7112.
86
+ */
87
+ }, {
88
+ key: "registerPostCreationFlushCallback",
89
+ value: function registerPostCreationFlushCallback(callback) {
90
+ this.postCreationFlushCallback = callback;
91
+ }
60
92
  }, {
61
93
  key: "setFireAnalyticsEvent",
62
94
  value: function setFireAnalyticsEvent(fireAnalyticsEvent) {
@@ -119,7 +151,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
119
151
  });
120
152
  // We can derive the product from `syncBlockNode.attrs.resourceId` even though
121
153
  // the variable wasn't destructured (the destructuring step itself may have thrown).
122
- (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.updateCacheErrorPayload)(error.message, syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs2 = syncBlockNode.attrs) === null || _syncBlockNode$attrs2 === void 0 ? void 0 : _syncBlockNode$attrs2.resourceId, (0, _utils.productAttrIfGateOn)(syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs3 = syncBlockNode.attrs) === null || _syncBlockNode$attrs3 === void 0 ? void 0 : _syncBlockNode$attrs3.resourceId)));
154
+ (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.updateCacheErrorPayload)(error.message, syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs2 = syncBlockNode.attrs) === null || _syncBlockNode$attrs2 === void 0 ? void 0 : _syncBlockNode$attrs2.resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs3 = syncBlockNode.attrs) === null || _syncBlockNode$attrs3 === void 0 ? void 0 : _syncBlockNode$attrs3.resourceId)));
123
155
  return false;
124
156
  }
125
157
  }
@@ -134,7 +166,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
134
166
  value: (function () {
135
167
  var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
136
168
  var _this2 = this;
137
- var _this$saveExperience, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2, _this$flushCompletion;
169
+ var _this$saveExperience, timedOut, timeoutId, timeout, _iterator, _step, resourceId, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2, _this$flushCompletion;
138
170
  return _regenerator.default.wrap(function _callee$(_context) {
139
171
  while (1) switch (_context.prev = _context.next) {
140
172
  case 0:
@@ -145,6 +177,39 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
145
177
  }
146
178
  return _context.abrupt("return", true);
147
179
  case 3:
180
+ if (!(this.pendingCreationPromises.size > 0 && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_12'))) {
181
+ _context.next = 10;
182
+ break;
183
+ }
184
+ timedOut = false;
185
+ timeout = new Promise(function (resolve) {
186
+ timeoutId = setTimeout(function () {
187
+ timedOut = true;
188
+ resolve();
189
+ }, FLUSH_CREATION_AWAIT_TIMEOUT_MS);
190
+ });
191
+ _context.next = 8;
192
+ return Promise.race([Promise.all(this.pendingCreationPromises.values()), timeout]);
193
+ case 8:
194
+ if (timeoutId !== undefined) {
195
+ clearTimeout(timeoutId);
196
+ }
197
+ if (timedOut) {
198
+ // Record every still-in-flight creation so each late
199
+ // completion is tracked independently.
200
+ _iterator = _createForOfIteratorHelper(this.pendingCreationPromises.keys());
201
+ try {
202
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
203
+ resourceId = _step.value;
204
+ this.creationsTimedOutDuringFlush.add(resourceId);
205
+ }
206
+ } catch (err) {
207
+ _iterator.e(err);
208
+ } finally {
209
+ _iterator.f();
210
+ }
211
+ }
212
+ case 10:
148
213
  bodiedSyncBlockNodes = [];
149
214
  bodiedSyncBlockData = [];
150
215
  Array.from(this.syncBlockCache.values()).forEach(function (syncBlockData) {
@@ -174,21 +239,21 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
174
239
  }
175
240
  });
176
241
  if (!(bodiedSyncBlockNodes.length === 0)) {
177
- _context.next = 8;
242
+ _context.next = 15;
178
243
  break;
179
244
  }
180
245
  return _context.abrupt("return", Promise.resolve(true));
181
- case 8:
246
+ case 15:
182
247
  if (this.dataProvider) {
183
- _context.next = 10;
248
+ _context.next = 17;
184
249
  break;
185
250
  }
186
251
  throw new Error('Data provider not set');
187
- case 10:
252
+ case 17:
188
253
  (_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start({});
189
- _context.next = 13;
254
+ _context.next = 20;
190
255
  return this.dataProvider.writeNodesData(bodiedSyncBlockNodes, bodiedSyncBlockData);
191
- case 13:
256
+ case 20:
192
257
  writeResults = _context.sent;
193
258
  writeResults.forEach(function (result) {
194
259
  // set isDirty to true for cases where it failed to save the sync block to the BE
@@ -202,7 +267,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
202
267
  if (!writeResults.every(function (result) {
203
268
  return result.resourceId && !result.error;
204
269
  })) {
205
- _context.next = 21;
270
+ _context.next = 28;
206
271
  break;
207
272
  }
208
273
  (_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.success();
@@ -214,24 +279,24 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
214
279
  if (cachedData && result.status) {
215
280
  cachedData.status = result.status;
216
281
  }
217
- (_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.updateSuccessPayload)(result.resourceId, false, (0, _utils.productAttrIfGateOn)(result.resourceId)));
282
+ (_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.updateSuccessPayload)(result.resourceId, false, (0, _utils.getSourceProductFromResourceIdSafe)(result.resourceId)));
218
283
  }
219
284
  });
220
285
  return _context.abrupt("return", true);
221
- case 21:
286
+ case 28:
222
287
  (_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
223
288
  writeResults.filter(function (result) {
224
289
  return !result.resourceId || result.error;
225
290
  }).forEach(function (result) {
226
291
  var _this2$fireAnalyticsE2;
227
- (_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.updateErrorPayload)(result.error || 'Failed to write data', result.resourceId, (0, _utils.productAttrIfGateOn)(result.resourceId)));
292
+ (_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.updateErrorPayload)(result.error || 'Failed to write data', result.resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(result.resourceId)));
228
293
  });
229
294
  return _context.abrupt("return", false);
230
- case 24:
231
- _context.next = 31;
295
+ case 31:
296
+ _context.next = 38;
232
297
  break;
233
- case 26:
234
- _context.prev = 26;
298
+ case 33:
299
+ _context.prev = 33;
235
300
  _context.t0 = _context["catch"](0);
236
301
  (0, _monitoring.logException)(_context.t0, {
237
302
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
@@ -239,15 +304,15 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
239
304
  // Top-level flush failure is not tied to a single resourceId.
240
305
  (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.updateErrorPayload)(_context.t0.message));
241
306
  return _context.abrupt("return", false);
242
- case 31:
243
- _context.prev = 31;
307
+ case 38:
308
+ _context.prev = 38;
244
309
  (_this$flushCompletion = this.flushCompletionCallback) === null || _this$flushCompletion === void 0 || _this$flushCompletion.call(this);
245
- return _context.finish(31);
246
- case 34:
310
+ return _context.finish(38);
311
+ case 41:
247
312
  case "end":
248
313
  return _context.stop();
249
314
  }
250
- }, _callee, this, [[0, 26, 31, 34]]);
315
+ }, _callee, this, [[0, 33, 38, 41]]);
251
316
  }));
252
317
  function flush() {
253
318
  return _flush.apply(this, arguments);
@@ -303,23 +368,33 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
303
368
  if (onCompletion) {
304
369
  this.creationCompletionCallbacks.delete(resourceId);
305
370
  onCompletion(success);
371
+ // If a previous flush() timed out waiting for this specific
372
+ // creation, drop it from the tracking set regardless of outcome so
373
+ // it does not leak. See EDITOR-7112.
374
+ var wasTimedOut = this.creationsTimedOutDuringFlush.delete(resourceId);
306
375
  if (success) {
307
376
  // If creation is successful, set hasReceivedContentChange to true
308
377
  // to indicate that there are unsaved changes in the cache
309
378
  this.hasReceivedContentChange = true;
379
+ // If flush() timed out waiting for this creation, notify the
380
+ // plugin so it can trigger a deferred flush. See EDITOR-7112.
381
+ if (wasTimedOut) {
382
+ var _this$postCreationFlu;
383
+ (_this$postCreationFlu = this.postCreationFlushCallback) === null || _this$postCreationFlu === void 0 || _this$postCreationFlu.call(this);
384
+ }
310
385
  }
311
386
  } else {
312
387
  var _this$fireAnalyticsEv3;
313
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.createErrorPayload)('creation complete callback missing', resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
388
+ (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.createErrorPayload)('creation complete callback missing', resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
314
389
  }
315
390
  if (success) {
316
391
  var _this$fireAnalyticsEv4;
317
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.createSuccessPayload)(resourceId || '', (0, _utils.productAttrIfGateOn)(resourceId)));
392
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.createSuccessPayload)(resourceId || '', (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
318
393
  } else {
319
394
  var _this$fireAnalyticsEv5;
320
395
  // Delete the node from cache if fail to create so it's not flushed to BE
321
396
  this.syncBlockCache.delete(resourceId || '');
322
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.createErrorPayload)('Fail to create bodied sync block', resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
397
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.createErrorPayload)('Fail to create bodied sync block', resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
323
398
  }
324
399
  }
325
400
  }, {
@@ -386,7 +461,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
386
461
  }
387
462
  this.creationCompletionCallbacks.set(resourceId, onCompletion);
388
463
  (_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 || _this$createExperienc.start({});
389
- this.dataProvider.createNodeData({
464
+ var creationPromise = this.dataProvider.createNodeData({
390
465
  content: [],
391
466
  blockInstanceId: blockInstanceId,
392
467
  resourceId: resourceId
@@ -402,7 +477,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
402
477
  (_this4$createExperien2 = _this4.createExperience) === null || _this4$createExperien2 === void 0 || _this4$createExperien2.failure({
403
478
  reason: result.error || 'Failed to create bodied sync block'
404
479
  });
405
- (_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, (0, _errorHandling.createErrorPayload)(result.error || 'Failed to create bodied sync block', resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
480
+ (_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, (0, _errorHandling.createErrorPayload)(result.error || 'Failed to create bodied sync block', resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
406
481
  }
407
482
  }).catch(function (error) {
408
483
  var _this4$createExperien3, _this4$fireAnalyticsE2;
@@ -413,8 +488,11 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
413
488
  (_this4$createExperien3 = _this4.createExperience) === null || _this4$createExperien3 === void 0 || _this4$createExperien3.failure({
414
489
  reason: error.message
415
490
  });
416
- (_this4$fireAnalyticsE2 = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE2 === void 0 || _this4$fireAnalyticsE2.call(_this4, (0, _errorHandling.createErrorPayload)(error.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
491
+ (_this4$fireAnalyticsE2 = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE2 === void 0 || _this4$fireAnalyticsE2.call(_this4, (0, _errorHandling.createErrorPayload)(error.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
492
+ }).finally(function () {
493
+ _this4.pendingCreationPromises.delete(resourceId);
417
494
  });
495
+ this.pendingCreationPromises.set(resourceId, creationPromise);
418
496
  } catch (error) {
419
497
  var _this$fireAnalyticsEv6;
420
498
  if (this.isPendingCreation(resourceId)) {
@@ -423,7 +501,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
423
501
  (0, _monitoring.logException)(error, {
424
502
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
425
503
  });
426
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.createErrorPayload)(error.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
504
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.createErrorPayload)(error.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
427
505
  }
428
506
  }
429
507
  }, {
@@ -471,7 +549,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
471
549
  (_this$deleteExperienc2 = this.deleteExperience) === null || _this$deleteExperienc2 === void 0 || _this$deleteExperienc2.success();
472
550
  results.forEach(function (result) {
473
551
  var _this5$fireAnalyticsE;
474
- (_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.deleteSuccessPayload)(result.resourceId, (0, _utils.productAttrIfGateOn)(result.resourceId)));
552
+ (_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.deleteSuccessPayload)(result.resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(result.resourceId)));
475
553
  });
476
554
  } else {
477
555
  callback = function callback(Ids) {
@@ -481,10 +559,10 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
481
559
  results.forEach(function (result) {
482
560
  if (result.success) {
483
561
  var _this5$fireAnalyticsE2;
484
- (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.deleteSuccessPayload)(result.resourceId, (0, _utils.productAttrIfGateOn)(result.resourceId)));
562
+ (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.deleteSuccessPayload)(result.resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(result.resourceId)));
485
563
  } else {
486
564
  var _this5$fireAnalyticsE3;
487
- (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.deleteErrorPayload)(result.error || 'Failed to delete synced block', result.resourceId, (0, _utils.productAttrIfGateOn)(result.resourceId)));
565
+ (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.deleteErrorPayload)(result.error || 'Failed to delete synced block', result.resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(result.resourceId)));
488
566
  }
489
567
  });
490
568
  }
@@ -496,7 +574,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
496
574
  syncBlockIds.forEach(function (Ids) {
497
575
  var _this5$fireAnalyticsE4;
498
576
  _this5.setPendingDeletion(Ids, false);
499
- (_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, (0, _errorHandling.deleteErrorPayload)(_context2.t0.message, Ids.resourceId, (0, _utils.productAttrIfGateOn)(Ids.resourceId)));
577
+ (_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, (0, _errorHandling.deleteErrorPayload)(_context2.t0.message, Ids.resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(Ids.resourceId)));
500
578
  });
501
579
  (0, _monitoring.logException)(_context2.t0, {
502
580
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
@@ -575,7 +653,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
575
653
  value: (function () {
576
654
  var _fetchAndCacheStatuses = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
577
655
  var _this6 = this;
578
- var sourceToReferenceMap, syncBlockNodes, results, _iterator, _step, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached;
656
+ var sourceToReferenceMap, syncBlockNodes, results, _iterator2, _step2, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached;
579
657
  return _regenerator.default.wrap(function _callee4$(_context4) {
580
658
  while (1) switch (_context4.prev = _context4.next) {
581
659
  case 0:
@@ -611,10 +689,10 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
611
689
  return this.dataProvider.fetchNodesData(syncBlockNodes);
612
690
  case 7:
613
691
  results = _context4.sent;
614
- _iterator = _createForOfIteratorHelper(results);
692
+ _iterator2 = _createForOfIteratorHelper(results);
615
693
  try {
616
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
617
- result = _step.value;
694
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
695
+ result = _step2.value;
618
696
  // Map the reference resourceId back to the source resourceId
619
697
  sourceResourceId = (_sourceToReferenceMap = sourceToReferenceMap.get(result.resourceId)) !== null && _sourceToReferenceMap !== void 0 ? _sourceToReferenceMap : result.resourceId;
620
698
  cached = this.syncBlockCache.get(sourceResourceId);
@@ -623,9 +701,9 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
623
701
  }
624
702
  }
625
703
  } catch (err) {
626
- _iterator.e(err);
704
+ _iterator2.e(err);
627
705
  } finally {
628
- _iterator.f();
706
+ _iterator2.f();
629
707
  }
630
708
  _context4.next = 14;
631
709
  break;
@@ -787,7 +865,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
787
865
  (0, _monitoring.logException)(error, {
788
866
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
789
867
  });
790
- (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(error.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
868
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(error.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
791
869
  return Promise.resolve({
792
870
  error: _types.SyncBlockError.Errored
793
871
  });
@@ -801,6 +879,9 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
801
879
  this.confirmationCallback = undefined;
802
880
  this.creationCompletionCallbacks.clear();
803
881
  this.flushCompletionCallback = undefined;
882
+ this.postCreationFlushCallback = undefined;
883
+ this.pendingCreationPromises.clear();
884
+ this.creationsTimedOutDuringFlush.clear();
804
885
  this.dataProvider = undefined;
805
886
  (_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.abort({
806
887
  reason: 'editorDestroyed'
@@ -40,7 +40,7 @@ var SyncBlockBatchFetcher = exports.SyncBlockBatchFetcher = /*#__PURE__*/functio
40
40
  });
41
41
  resourceIds.forEach(function (resId) {
42
42
  var _this$deps$getFireAna;
43
- (_this$deps$getFireAna = _this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna((0, _errorHandling.fetchErrorPayload)(error.message, resId, (0, _utils.productAttrIfGateOn)(resId)));
43
+ (_this$deps$getFireAna = _this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna((0, _errorHandling.fetchErrorPayload)(error.message, resId, (0, _utils.getSourceProductFromResourceIdSafe)(resId)));
44
44
  });
45
45
  });
46
46
  });
@@ -33,7 +33,7 @@ var SyncBlockProviderFactoryManager = exports.SyncBlockProviderFactoryManager =
33
33
  (0, _monitoring.logException)(error, {
34
34
  location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
35
35
  });
36
- (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna((0, _errorHandling.fetchErrorPayload)(error.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
36
+ (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna((0, _errorHandling.fetchErrorPayload)(error.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
37
37
  return undefined;
38
38
  }
39
39
  var _dataProvider$getSync = dataProvider.getSyncedBlockRendererProviderOptions(),
@@ -66,7 +66,7 @@ var SyncBlockProviderFactoryManager = exports.SyncBlockProviderFactoryManager =
66
66
  (0, _monitoring.logException)(error, {
67
67
  location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
68
68
  });
69
- (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 || _this$deps$getFireAna2((0, _errorHandling.fetchErrorPayload)(error.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
69
+ (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 || _this$deps$getFireAna2((0, _errorHandling.fetchErrorPayload)(error.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
70
70
  }
71
71
  }
72
72
  return providerFactory;
@@ -151,7 +151,7 @@ var SyncBlockProviderFactoryManager = exports.SyncBlockProviderFactoryManager =
151
151
  if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
152
152
  var _this$deps$getFireAna3, _syncBlock$data$produ;
153
153
  (_this$deps$getFireAna3 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna3 === void 0 || _this$deps$getFireAna3((0, _errorHandling.fetchErrorPayload)('Sync block source ari or product not found', resourceId, // Prefer cached product when available; fall back to parsing resourceId.
154
- (_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : (0, _utils.productAttrIfGateOn)(resourceId)));
154
+ (_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
155
155
  return;
156
156
  }
157
157
  var parentInfo = dataProvider.retrieveSyncBlockParentInfo(syncBlock.data.sourceAri, syncBlock.data.product);
@@ -142,7 +142,7 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
142
142
  (0, _monitoring.logException)(_context2.t0, {
143
143
  location: 'editor-synced-block-provider/syncBlockStoreManager'
144
144
  });
145
- (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(_context2.t0.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
145
+ (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(_context2.t0.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
146
146
  return _context2.abrupt("return", {
147
147
  error: _types.SyncBlockError.Errored
148
148
  });