@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
@@ -5,7 +5,7 @@ import { logException } from '@atlaskit/editor-common/monitoring';
5
5
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
6
6
  import { fetchErrorPayload } from '../utils/errorHandling';
7
7
  import { parseResourceId } from '../utils/resourceId';
8
- import { productAttrIfGateOn } from '../utils/utils';
8
+ import { getSourceProductFromResourceIdSafe } from '../utils/utils';
9
9
  /**
10
10
  * Manages creation and caching of ProviderFactory instances used to
11
11
  * render synced block content (media, emoji, smart links, etc.).
@@ -26,7 +26,7 @@ export var SyncBlockProviderFactoryManager = /*#__PURE__*/function () {
26
26
  logException(error, {
27
27
  location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
28
28
  });
29
- (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
29
+ (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
30
30
  return undefined;
31
31
  }
32
32
  var _dataProvider$getSync = dataProvider.getSyncedBlockRendererProviderOptions(),
@@ -59,7 +59,7 @@ export var SyncBlockProviderFactoryManager = /*#__PURE__*/function () {
59
59
  logException(error, {
60
60
  location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
61
61
  });
62
- (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 || _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
62
+ (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 || _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
63
63
  }
64
64
  }
65
65
  return providerFactory;
@@ -144,7 +144,7 @@ export var SyncBlockProviderFactoryManager = /*#__PURE__*/function () {
144
144
  if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
145
145
  var _this$deps$getFireAna3, _syncBlock$data$produ;
146
146
  (_this$deps$getFireAna3 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna3 === void 0 || _this$deps$getFireAna3(fetchErrorPayload('Sync block source ari or product not found', resourceId, // Prefer cached product when available; fall back to parsing resourceId.
147
- (_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : productAttrIfGateOn(resourceId)));
147
+ (_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : getSourceProductFromResourceIdSafe(resourceId)));
148
148
  return;
149
149
  }
150
150
  var parentInfo = dataProvider.retrieveSyncBlockParentInfo(syncBlock.data.sourceAri, syncBlock.data.product);
@@ -11,7 +11,7 @@ import { getProductFromSourceAri } from '../clients/block-service/ari';
11
11
  import { SyncBlockError } from '../common/types';
12
12
  import { fetchReferencesErrorPayload } from '../utils/errorHandling';
13
13
  import { getFetchReferencesExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
14
- import { productAttrIfGateOn } from '../utils/utils';
14
+ import { getSourceProductFromResourceIdSafe } from '../utils/utils';
15
15
  import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
16
16
  import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
17
17
 
@@ -136,7 +136,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
136
136
  logException(_context2.t0, {
137
137
  location: 'editor-synced-block-provider/syncBlockStoreManager'
138
138
  });
139
- (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, fetchReferencesErrorPayload(_context2.t0.message, resourceId, productAttrIfGateOn(resourceId)));
139
+ (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, fetchReferencesErrorPayload(_context2.t0.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
140
140
  return _context2.abrupt("return", {
141
141
  error: SyncBlockError.Errored
142
142
  });
@@ -7,10 +7,9 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
7
7
  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; }
8
8
  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) { _defineProperty(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; }
9
9
  import { logException } from '@atlaskit/editor-common/monitoring';
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
10
  import { fetchErrorPayload, fetchSuccessPayload } from '../utils/errorHandling';
12
11
  import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
13
- import { getSourceProductFromResourceIdSafe, productAttrIfGateOn } from '../utils/utils';
12
+ import { getSourceProductFromResourceIdSafe } from '../utils/utils';
14
13
  /**
15
14
  * Manages the lifecycle of GraphQL WebSocket subscriptions for sync block
16
15
  * real-time updates, owns the subscriptions and titleSubscriptions maps,
@@ -251,7 +250,7 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
251
250
  logException(error, {
252
251
  location: 'editor-synced-block-provider/syncBlockSubscriptionManager/graphql-subscription'
253
252
  });
254
- (_this5$deps$getFireAn = _this5.deps.getFireAnalyticsEvent()) === null || _this5$deps$getFireAn === void 0 || _this5$deps$getFireAn(fetchErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
253
+ (_this5$deps$getFireAn = _this5.deps.getFireAnalyticsEvent()) === null || _this5$deps$getFireAn === void 0 || _this5$deps$getFireAn(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
255
254
  });
256
255
  if (unsubscribe) {
257
256
  this.graphqlSubscriptions.set(resourceId, unsubscribe);
@@ -343,15 +342,13 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
343
342
  var localIds = callbacks ? Object.keys(callbacks) : [];
344
343
  localIds.forEach(function (localId) {
345
344
  var _this6$deps$getFireAn, _syncBlockInstance$da, _syncBlockInstance$da2;
346
- (_this6$deps$getFireAn = _this6.deps.getFireAnalyticsEvent()) === null || _this6$deps$getFireAn === void 0 || _this6$deps$getFireAn(fetchSuccessPayload(syncBlockInstance.resourceId, localId,
347
- // Prefer cached product when available; fall back to parsing the resourceId.
348
- 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 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId) : undefined));
345
+ (_this6$deps$getFireAn = _this6.deps.getFireAnalyticsEvent()) === null || _this6$deps$getFireAn === void 0 || _this6$deps$getFireAn(fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId)));
349
346
  });
350
347
  this.deps.fetchSyncBlockSourceInfo(resolved.resourceId);
351
348
  } else {
352
349
  var _syncBlockInstance$er, _syncBlockInstance$er2, _this$deps$getFireAna, _syncBlockInstance$da3, _syncBlockInstance$da4;
353
350
  var errorMessage = ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type);
354
- (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(errorMessage, syncBlockInstance.resourceId, 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 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId) : undefined));
351
+ (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(errorMessage, syncBlockInstance.resourceId, (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId)));
355
352
  }
356
353
  }
357
354
  }]);
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  export var convertSyncBlockPMNodeToSyncBlockData = function convertSyncBlockPMNodeToSyncBlockData(node) {
5
4
  return {
6
5
  blockInstanceId: node.attrs.localId,
@@ -69,17 +68,6 @@ export var getSourceProductFromResourceIdSafe = function getSourceProductFromRes
69
68
  return undefined;
70
69
  }
71
70
  };
72
-
73
- /*
74
- * Convenience wrapper around `getSourceProductFromResourceIdSafe` that returns
75
- * `undefined` whenever the `platform_synced_block_patch_11` rollout flag is off.
76
- * Centralised so that the flag name lives in exactly one place — when the flag is
77
- * cleaned up, this function should be deleted in its entirety and call-sites should
78
- * fall back to calling `getSourceProductFromResourceIdSafe` directly.
79
- */
80
- export var productAttrIfGateOn = function productAttrIfGateOn(resourceId) {
81
- return fg('platform_synced_block_patch_11') ? getSourceProductFromResourceIdSafe(resourceId) : undefined;
82
- };
83
71
  export var convertContentUpdatedAt = function convertContentUpdatedAt(contentUpdatedAt) {
84
72
  if (typeof contentUpdatedAt === 'number') {
85
73
  try {
@@ -1 +1 @@
1
- export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, convertPMNodeToSyncBlockNode, convertContentUpdatedAt, getContentIdAndProductFromResourceId, getSourceProductFromResourceIdSafe, productAttrIfGateOn, } from '../utils/utils';
1
+ export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, convertPMNodeToSyncBlockNode, convertContentUpdatedAt, getContentIdAndProductFromResourceId, getSourceProductFromResourceIdSafe, } from '../utils/utils';
@@ -18,6 +18,23 @@ export declare class SourceSyncBlockStoreManager {
18
18
  private deletionRetryInfo?;
19
19
  private creationCompletionCallbacks;
20
20
  private flushCompletionCallback?;
21
+ private postCreationFlushCallback?;
22
+ /**
23
+ * Promises for in-flight block creations, keyed by resourceId.
24
+ * `flush()` awaits these so that blocks created from existing content are
25
+ * persisted even if no further edits trigger a subsequent flush.
26
+ * See EDITOR-7112.
27
+ */
28
+ private pendingCreationPromises;
29
+ /**
30
+ * Set of resource IDs whose creation was still in-flight when a `flush()`
31
+ * timed out. Each completion (success or failure) is removed from this set;
32
+ * the first successful completion of any of these IDs triggers
33
+ * `postCreationFlushCallback` so the content is eventually persisted.
34
+ * Tracking IDs (not just a boolean) avoids dropping late completions when
35
+ * multiple blocks are created concurrently. See EDITOR-7112.
36
+ */
37
+ private creationsTimedOutDuringFlush;
21
38
  private createExperience;
22
39
  private saveExperience;
23
40
  private deleteExperience;
@@ -29,6 +46,13 @@ export declare class SourceSyncBlockStoreManager {
29
46
  * hasUnsavedBodiedSyncBlockChanges is recalculated in plugin state.
30
47
  */
31
48
  registerFlushCompletionCallback(callback: () => void): void;
49
+ /**
50
+ * Register a callback to be invoked when flush() timed out waiting for a
51
+ * pending block creation and that creation subsequently completes. The
52
+ * callback should trigger a deferred flush to persist the content that
53
+ * was skipped due to the timeout. See EDITOR-7112.
54
+ */
55
+ registerPostCreationFlushCallback(callback: () => void): void;
32
56
  setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void): void;
33
57
  isSourceBlock(node: PMNode): boolean;
34
58
  /**
@@ -11,5 +11,4 @@ export declare const getContentIdAndProductFromResourceId: (resourceId: string)
11
11
  sourceProduct: SyncBlockProduct;
12
12
  };
13
13
  export declare const getSourceProductFromResourceIdSafe: (resourceId?: string) => SyncBlockProduct | undefined;
14
- export declare const productAttrIfGateOn: (resourceId?: string) => SyncBlockProduct | undefined;
15
14
  export declare const convertContentUpdatedAt: (contentUpdatedAt: number | undefined) => string | undefined;
@@ -1 +1 @@
1
- export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, convertPMNodeToSyncBlockNode, convertContentUpdatedAt, getContentIdAndProductFromResourceId, getSourceProductFromResourceIdSafe, productAttrIfGateOn, } from '../utils/utils';
1
+ export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, convertPMNodeToSyncBlockNode, convertContentUpdatedAt, getContentIdAndProductFromResourceId, getSourceProductFromResourceIdSafe, } from '../utils/utils';
@@ -18,6 +18,23 @@ export declare class SourceSyncBlockStoreManager {
18
18
  private deletionRetryInfo?;
19
19
  private creationCompletionCallbacks;
20
20
  private flushCompletionCallback?;
21
+ private postCreationFlushCallback?;
22
+ /**
23
+ * Promises for in-flight block creations, keyed by resourceId.
24
+ * `flush()` awaits these so that blocks created from existing content are
25
+ * persisted even if no further edits trigger a subsequent flush.
26
+ * See EDITOR-7112.
27
+ */
28
+ private pendingCreationPromises;
29
+ /**
30
+ * Set of resource IDs whose creation was still in-flight when a `flush()`
31
+ * timed out. Each completion (success or failure) is removed from this set;
32
+ * the first successful completion of any of these IDs triggers
33
+ * `postCreationFlushCallback` so the content is eventually persisted.
34
+ * Tracking IDs (not just a boolean) avoids dropping late completions when
35
+ * multiple blocks are created concurrently. See EDITOR-7112.
36
+ */
37
+ private creationsTimedOutDuringFlush;
21
38
  private createExperience;
22
39
  private saveExperience;
23
40
  private deleteExperience;
@@ -29,6 +46,13 @@ export declare class SourceSyncBlockStoreManager {
29
46
  * hasUnsavedBodiedSyncBlockChanges is recalculated in plugin state.
30
47
  */
31
48
  registerFlushCompletionCallback(callback: () => void): void;
49
+ /**
50
+ * Register a callback to be invoked when flush() timed out waiting for a
51
+ * pending block creation and that creation subsequently completes. The
52
+ * callback should trigger a deferred flush to persist the content that
53
+ * was skipped due to the timeout. See EDITOR-7112.
54
+ */
55
+ registerPostCreationFlushCallback(callback: () => void): void;
32
56
  setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void): void;
33
57
  isSourceBlock(node: PMNode): boolean;
34
58
  /**
@@ -11,5 +11,4 @@ export declare const getContentIdAndProductFromResourceId: (resourceId: string)
11
11
  sourceProduct: SyncBlockProduct;
12
12
  };
13
13
  export declare const getSourceProductFromResourceIdSafe: (resourceId?: string) => SyncBlockProduct | undefined;
14
- export declare const productAttrIfGateOn: (resourceId?: string) => SyncBlockProduct | undefined;
15
14
  export declare const convertContentUpdatedAt: (contentUpdatedAt: number | undefined) => string | undefined;
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "@atlaskit/editor-prosemirror": "^7.3.0",
30
30
  "@atlaskit/node-data-provider": "^11.1.0",
31
31
  "@atlaskit/platform-feature-flags": "^1.1.0",
32
- "@atlaskit/tmp-editor-statsig": "^81.0.0",
32
+ "@atlaskit/tmp-editor-statsig": "^81.1.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@compiled/react": "^0.20.0",
35
35
  "graphql-ws": "^5.14.2",
@@ -38,7 +38,7 @@
38
38
  "uuid": "^3.1.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^114.32.0",
41
+ "@atlaskit/editor-common": "^114.35.0",
42
42
  "react": "^18.2.0"
43
43
  },
44
44
  "devDependencies": {
@@ -81,7 +81,7 @@
81
81
  }
82
82
  },
83
83
  "name": "@atlaskit/editor-synced-block-provider",
84
- "version": "6.6.2",
84
+ "version": "6.6.4",
85
85
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
86
86
  "author": "Atlassian Pty Ltd",
87
87
  "license": "Apache-2.0",
@@ -89,7 +89,7 @@
89
89
  "registry": "https://registry.npmjs.org/"
90
90
  },
91
91
  "platform-feature-flags": {
92
- "platform_synced_block_patch_11": {
92
+ "platform_synced_block_patch_12": {
93
93
  "type": "boolean"
94
94
  }
95
95
  }