@atlaskit/editor-synced-block-provider 10.0.3 → 10.0.5
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 +17 -0
- package/dist/cjs/common/types.js +2 -3
- package/dist/cjs/hooks/useFetchSyncBlockData.js +4 -4
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +27 -56
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +22 -41
- package/dist/cjs/store-manager/syncBlockBatchFetcher.js +6 -12
- package/dist/cjs/store-manager/syncBlockProviderFactoryManager.js +3 -3
- package/dist/cjs/store-manager/syncBlockStoreManager.js +1 -5
- package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +20 -85
- package/dist/cjs/utils/errorHandling.js +13 -32
- package/dist/es2019/common/types.js +2 -3
- package/dist/es2019/hooks/useFetchSyncBlockData.js +4 -5
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +26 -50
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +23 -42
- package/dist/es2019/store-manager/syncBlockBatchFetcher.js +6 -12
- package/dist/es2019/store-manager/syncBlockProviderFactoryManager.js +3 -3
- package/dist/es2019/store-manager/syncBlockStoreManager.js +1 -5
- package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +25 -81
- package/dist/es2019/utils/errorHandling.js +13 -32
- package/dist/esm/common/types.js +2 -3
- package/dist/esm/hooks/useFetchSyncBlockData.js +4 -4
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +27 -56
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +22 -41
- package/dist/esm/store-manager/syncBlockBatchFetcher.js +6 -12
- package/dist/esm/store-manager/syncBlockProviderFactoryManager.js +3 -3
- package/dist/esm/store-manager/syncBlockStoreManager.js +1 -5
- package/dist/esm/store-manager/syncBlockSubscriptionManager.js +20 -85
- package/dist/esm/utils/errorHandling.js +13 -32
- package/dist/types/common/types.d.ts +2 -3
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +3 -3
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +5 -7
- package/dist/types/store-manager/syncBlockSubscriptionManager.d.ts +2 -5
- package/dist/types/utils/errorHandling.d.ts +11 -24
- package/package.json +3 -15
|
@@ -40,10 +40,10 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
40
40
|
// On Jira the data provider is wired asynchronously, so the manager can be
|
|
41
41
|
// constructed with `dataProvider === undefined`. Fetching/subscribing in that
|
|
42
42
|
// window throws `Data provider not set`, logged as a false fetch error
|
|
43
|
-
// (EDITOR-7860).
|
|
43
|
+
// (EDITOR-7860). Check readiness; once the provider resolves a new manager
|
|
44
44
|
// instance is created so `referenceManager` changes identity and the effect
|
|
45
45
|
// below re-runs, subscribing exactly once.
|
|
46
|
-
var isDataProviderReady =
|
|
46
|
+
var isDataProviderReady = (_manager$referenceMan2 = (_manager$referenceMan3 = (_manager$referenceMan4 = manager.referenceManager).hasDataProvider) === null || _manager$referenceMan3 === void 0 ? void 0 : _manager$referenceMan3.call(_manager$referenceMan4)) !== null && _manager$referenceMan2 !== void 0 ? _manager$referenceMan2 : false;
|
|
47
47
|
var reloadData = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
48
48
|
var syncBlockNode, _t;
|
|
49
49
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
@@ -84,7 +84,7 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
84
84
|
case 5:
|
|
85
85
|
_context.prev = 5;
|
|
86
86
|
_t = _context["catch"](2);
|
|
87
|
-
if (!
|
|
87
|
+
if (!isProviderNotReadyError(_t)) {
|
|
88
88
|
_context.next = 6;
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
@@ -98,7 +98,7 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
98
98
|
logException(_t, {
|
|
99
99
|
location: 'editor-synced-block-provider/useFetchSyncBlockData'
|
|
100
100
|
});
|
|
101
|
-
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(fetchErrorPayload(_t.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution(
|
|
101
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(fetchErrorPayload(_t.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution(_t.message)));
|
|
102
102
|
|
|
103
103
|
// Thread the PII-safe original message/name so the renderer can de-opaque
|
|
104
104
|
// this otherwise-bare `errored` failure. `originalMessage` carries the
|
|
@@ -11,7 +11,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
11
11
|
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; }
|
|
12
12
|
import isEqual from 'lodash/isEqual';
|
|
13
13
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { isProviderNotReadyError, ProviderNotReadyError, SyncBlockError } from '../common/types';
|
|
16
15
|
import { buildErrorAttribution, buildFetchErrorAttribution, cacheDeletionForcedPayload, fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, sourceInfoOrphanedPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
|
|
17
16
|
import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
|
|
@@ -26,7 +25,7 @@ var ENTITY_NOT_FOUND_MAX_RETRIES = 3;
|
|
|
26
25
|
var ENTITY_NOT_FOUND_INITIAL_DELAY_MS = 2000;
|
|
27
26
|
|
|
28
27
|
// Grace period before a cache entry is removed after the last subscriber
|
|
29
|
-
// unsubscribes
|
|
28
|
+
// unsubscribes. Guards are
|
|
30
29
|
// re-checked at fire time; if any are positive, the timer is rescheduled.
|
|
31
30
|
var CACHE_DELETION_GRACE_PERIOD_MS = 30000;
|
|
32
31
|
// Max reschedules before force-deleting with an analytics event (~5 min).
|
|
@@ -55,8 +54,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
55
54
|
// Track retry attempts for EntityNotFound errors (block may be in the process of being created)
|
|
56
55
|
_defineProperty(this, "entityNotFoundRetryCount", new Map());
|
|
57
56
|
_defineProperty(this, "entityNotFoundRetryTimers", new Map());
|
|
58
|
-
// Pending cache deletion timers keyed by resourceId
|
|
59
|
-
// `platform_synced_block_patch_14`). Cancelled when a subscriber re-attaches.
|
|
57
|
+
// Pending cache deletion timers keyed by resourceId. Cancelled when a subscriber re-attaches.
|
|
60
58
|
_defineProperty(this, "pendingCacheDeletions", new Map());
|
|
61
59
|
// Reschedule counter per resource — reset on actual deletion or re-subscribe.
|
|
62
60
|
_defineProperty(this, "cacheDeletionRescheduleCounts", new Map());
|
|
@@ -77,9 +75,6 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
77
75
|
updateCache: function updateCache(inst) {
|
|
78
76
|
return _this.updateCache(inst);
|
|
79
77
|
},
|
|
80
|
-
deleteFromCache: function deleteFromCache(rid) {
|
|
81
|
-
return _this.deleteFromCache(rid);
|
|
82
|
-
},
|
|
83
78
|
debouncedBatchedFetchSyncBlocks: function debouncedBatchedFetchSyncBlocks(rid) {
|
|
84
79
|
return _this.debouncedBatchedFetchSyncBlocks(rid);
|
|
85
80
|
},
|
|
@@ -93,7 +88,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
93
88
|
_this.isCacheDirty = true;
|
|
94
89
|
},
|
|
95
90
|
// Delegate cache lifecycle to the store manager so guards can be
|
|
96
|
-
// checked atomically
|
|
91
|
+
// checked atomically.
|
|
97
92
|
scheduleCacheDeletion: function scheduleCacheDeletion(rid) {
|
|
98
93
|
return _this.scheduleCacheDeletion(rid);
|
|
99
94
|
},
|
|
@@ -541,28 +536,22 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
541
536
|
return _context2.abrupt("return");
|
|
542
537
|
case 2:
|
|
543
538
|
if (this.dataProvider) {
|
|
544
|
-
_context2.next = 4;
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
if (!fg('platform_editor_blocks_patch_3')) {
|
|
548
539
|
_context2.next = 3;
|
|
549
540
|
break;
|
|
550
541
|
}
|
|
551
542
|
throw new ProviderNotReadyError();
|
|
552
543
|
case 3:
|
|
553
|
-
throw new Error('Data provider not set');
|
|
554
|
-
case 4:
|
|
555
544
|
nodesToFetch.forEach(function (node) {
|
|
556
545
|
_this4.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
557
546
|
});
|
|
558
547
|
(_this$fetchExperience6 = this.fetchExperience) === null || _this$fetchExperience6 === void 0 || _this$fetchExperience6.start({});
|
|
559
|
-
_context2.next =
|
|
548
|
+
_context2.next = 4;
|
|
560
549
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
561
550
|
nodesToFetch.forEach(function (node) {
|
|
562
551
|
_this4.syncBlockFetchDataRequests.delete(node.attrs.resourceId);
|
|
563
552
|
});
|
|
564
553
|
});
|
|
565
|
-
case
|
|
554
|
+
case 4:
|
|
566
555
|
data = _context2.sent;
|
|
567
556
|
_this$processFetchedD2 = this.processFetchedData(data), hasUnexpectedError = _this$processFetchedD2.hasUnexpectedError, hasExpectedError = _this$processFetchedD2.hasExpectedError;
|
|
568
557
|
if (hasUnexpectedError) {
|
|
@@ -576,7 +565,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
576
565
|
} else {
|
|
577
566
|
(_this$fetchExperience9 = this.fetchExperience) === null || _this$fetchExperience9 === void 0 || _this$fetchExperience9.success();
|
|
578
567
|
}
|
|
579
|
-
case
|
|
568
|
+
case 5:
|
|
580
569
|
case "end":
|
|
581
570
|
return _context2.stop();
|
|
582
571
|
}
|
|
@@ -607,7 +596,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
607
596
|
// No resourceId means we cannot derive a sourceProduct here; intentionally omit.
|
|
608
597
|
// Classify on the structured `type` first, falling back to the free-text
|
|
609
598
|
// `reason`/payload (EDITOR-7862).
|
|
610
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, fetchErrorPayload(payload, undefined, undefined, buildFetchErrorAttribution(
|
|
599
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, fetchErrorPayload(payload, undefined, undefined, buildFetchErrorAttribution(((_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.type) || ((_syncBlockInstance$er4 = syncBlockInstance.error) === null || _syncBlockInstance$er4 === void 0 ? void 0 : _syncBlockInstance$er4.reason) || payload, (_syncBlockInstance$er5 = syncBlockInstance.error) === null || _syncBlockInstance$er5 === void 0 ? void 0 : _syncBlockInstance$er5.statusCode)));
|
|
611
600
|
return;
|
|
612
601
|
}
|
|
613
602
|
var existingSyncBlock = _this5.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -638,13 +627,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
638
627
|
var _this5$entityNotFound;
|
|
639
628
|
// Skip error analytics when EntityNotFound will be retried, to avoid
|
|
640
629
|
// inflating error-rate metrics with expected transient failures
|
|
641
|
-
var isRetryingEntityNotFound = syncBlockInstance.error.type === SyncBlockError.EntityNotFound && ((_this5$entityNotFound = _this5.entityNotFoundRetryCount.get(syncBlockInstance.resourceId)) !== null && _this5$entityNotFound !== void 0 ? _this5$entityNotFound : 0) < ENTITY_NOT_FOUND_MAX_RETRIES
|
|
630
|
+
var isRetryingEntityNotFound = syncBlockInstance.error.type === SyncBlockError.EntityNotFound && ((_this5$entityNotFound = _this5.entityNotFoundRetryCount.get(syncBlockInstance.resourceId)) !== null && _this5$entityNotFound !== void 0 ? _this5$entityNotFound : 0) < ENTITY_NOT_FOUND_MAX_RETRIES;
|
|
642
631
|
if (!isRetryingEntityNotFound) {
|
|
643
632
|
var _this5$fireAnalyticsE2, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
644
633
|
// Classify on the structured `type` (a `SyncBlockError` enum value) first,
|
|
645
634
|
// falling back to the free-text `reason` so source-state/permission strings
|
|
646
635
|
// are still bucketed (EDITOR-7862). The emitted `error` attribute is unchanged.
|
|
647
|
-
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, 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 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId), buildFetchErrorAttribution(
|
|
636
|
+
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, 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 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId), buildFetchErrorAttribution(syncBlockInstance.error.type || syncBlockInstance.error.reason, syncBlockInstance.error.statusCode)));
|
|
648
637
|
}
|
|
649
638
|
if (syncBlockInstance.error.type === SyncBlockError.NotFound || syncBlockInstance.error.type === SyncBlockError.Forbidden) {
|
|
650
639
|
hasExpectedError = true;
|
|
@@ -652,9 +641,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
652
641
|
// Schedule a retry for EntityNotFound — the source block may be in
|
|
653
642
|
// the process of being created by a collaborator (race condition
|
|
654
643
|
// between NCS propagation and Block Service createBlock call).
|
|
655
|
-
|
|
656
|
-
_this5.scheduleEntityNotFoundRetry(syncBlockInstance.resourceId);
|
|
657
|
-
}
|
|
644
|
+
_this5.scheduleEntityNotFoundRetry(syncBlockInstance.resourceId);
|
|
658
645
|
if (!isRetryingEntityNotFound) {
|
|
659
646
|
hasUnexpectedError = true;
|
|
660
647
|
}
|
|
@@ -682,7 +669,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
682
669
|
var existingSyncBlock = this.getFromCache(resourceId);
|
|
683
670
|
// If the cache entry was deleted while the source-info request was
|
|
684
671
|
// in flight, fire an analytics event so the race is observable.
|
|
685
|
-
if (!existingSyncBlock
|
|
672
|
+
if (!existingSyncBlock) {
|
|
686
673
|
var _this$fireAnalyticsEv5;
|
|
687
674
|
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, sourceInfoOrphanedPayload(resourceId, getSourceProductFromResourceIdSafe(resourceId), {
|
|
688
675
|
hasPendingDeletion: this.pendingCacheDeletions.has(resourceId),
|
|
@@ -735,16 +722,14 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
735
722
|
this._providerFactoryManager.deleteFactory(resourceId);
|
|
736
723
|
// Evict in-flight source-info promise and reset reschedule counter
|
|
737
724
|
// so a stale resolution can't silently merge into a re-fetched entry.
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
this.cacheDeletionRescheduleCounts.delete(resourceId);
|
|
741
|
-
}
|
|
725
|
+
this.syncBlockSourceInfoRequests.delete(resourceId);
|
|
726
|
+
this.cacheDeletionRescheduleCounts.delete(resourceId);
|
|
742
727
|
}
|
|
743
728
|
|
|
744
729
|
/**
|
|
745
730
|
* Returns true if the cache entry for `resourceId` is safe to delete:
|
|
746
731
|
* no active subscribers, no in-flight source-info request, and no
|
|
747
|
-
* queued/in-flight batch fetch
|
|
732
|
+
* queued/in-flight batch fetch.
|
|
748
733
|
*/
|
|
749
734
|
}, {
|
|
750
735
|
key: "canDeleteCache",
|
|
@@ -763,7 +748,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
763
748
|
|
|
764
749
|
/**
|
|
765
750
|
* Schedules cache deletion for `resourceId` after the grace period
|
|
766
|
-
*
|
|
751
|
+
* Called when the last
|
|
767
752
|
* subscriber unsubscribes. Guards are re-checked at fire time; if any
|
|
768
753
|
* are positive the timer is rescheduled up to MAX_RESCHEDULES times.
|
|
769
754
|
*/
|
|
@@ -771,9 +756,6 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
771
756
|
key: "scheduleCacheDeletion",
|
|
772
757
|
value: function scheduleCacheDeletion(resourceId) {
|
|
773
758
|
var _this6 = this;
|
|
774
|
-
if (!fg('platform_synced_block_patch_14')) {
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
759
|
if (this.isDestroyed) {
|
|
778
760
|
return;
|
|
779
761
|
}
|
|
@@ -801,15 +783,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
801
783
|
|
|
802
784
|
/**
|
|
803
785
|
* Cancels any pending cache deletion timer for `resourceId` and resets the
|
|
804
|
-
* reschedule counter
|
|
786
|
+
* reschedule counter. Called
|
|
805
787
|
* when a new subscriber arrives.
|
|
806
788
|
*/
|
|
807
789
|
}, {
|
|
808
790
|
key: "cancelPendingCacheDeletion",
|
|
809
791
|
value: function cancelPendingCacheDeletion(resourceId) {
|
|
810
|
-
if (!fg('platform_synced_block_patch_14')) {
|
|
811
|
-
return;
|
|
812
|
-
}
|
|
813
792
|
var existing = this.pendingCacheDeletions.get(resourceId);
|
|
814
793
|
if (existing) {
|
|
815
794
|
clearTimeout(existing);
|
|
@@ -831,7 +810,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
831
810
|
value: function onCacheDeletionTimerFire(resourceId) {
|
|
832
811
|
var _this$cacheDeletionRe;
|
|
833
812
|
if (this.canDeleteCache(resourceId)) {
|
|
834
|
-
// `deleteFromCache` resets the reschedule counter
|
|
813
|
+
// `deleteFromCache` resets the reschedule counter.
|
|
835
814
|
this.deleteFromCache(resourceId);
|
|
836
815
|
return;
|
|
837
816
|
}
|
|
@@ -851,7 +830,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
851
830
|
logException(new Error("Cache deletion forced after ".concat(currentCount, " reschedules \u2014 stuck in-flight guard")), {
|
|
852
831
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager/cache-deletion-forced'
|
|
853
832
|
});
|
|
854
|
-
// `deleteFromCache` resets the reschedule counter
|
|
833
|
+
// `deleteFromCache` resets the reschedule counter.
|
|
855
834
|
this.deleteFromCache(resourceId);
|
|
856
835
|
// If subscribers still exist, kick off a fresh fetch so they get
|
|
857
836
|
// fresh data on the next batch tick instead of holding stale data
|
|
@@ -961,14 +940,14 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
961
940
|
var _this$fireAnalyticsEv7;
|
|
962
941
|
// EDITOR-7860: benign not-ready/torn-down case — suppress both the
|
|
963
942
|
// exception-tracker log and the analytics event (checked first so the
|
|
964
|
-
// benign case stays fully silent).
|
|
965
|
-
if (isProviderNotReadyError(error)
|
|
943
|
+
// benign case stays fully silent).
|
|
944
|
+
if (isProviderNotReadyError(error)) {
|
|
966
945
|
return function () {};
|
|
967
946
|
}
|
|
968
947
|
logException(error, {
|
|
969
948
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
970
949
|
});
|
|
971
|
-
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message, undefined, undefined, buildFetchErrorAttribution(
|
|
950
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message, undefined, undefined, buildFetchErrorAttribution(error.message)));
|
|
972
951
|
return function () {};
|
|
973
952
|
}
|
|
974
953
|
}
|
|
@@ -1131,7 +1110,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1131
1110
|
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.failure({
|
|
1132
1111
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1133
1112
|
});
|
|
1134
|
-
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document', undefined, undefined, buildErrorAttribution(
|
|
1113
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document', undefined, undefined, buildErrorAttribution(updateResult.error, updateResult.statusCode)));
|
|
1135
1114
|
}
|
|
1136
1115
|
_context4.next = 17;
|
|
1137
1116
|
break;
|
|
@@ -1147,8 +1126,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1147
1126
|
});
|
|
1148
1127
|
// No `resourceId` available in this catch — sourceProduct is intentionally omitted.
|
|
1149
1128
|
// No structured SyncBlockError/status here, so the attribution `reason` falls back
|
|
1150
|
-
// to `unknown
|
|
1151
|
-
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, updateReferenceErrorPayload(_t3.message, undefined, undefined, buildErrorAttribution(
|
|
1129
|
+
// to `unknown`.
|
|
1130
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, updateReferenceErrorPayload(_t3.message, undefined, undefined, buildErrorAttribution()));
|
|
1152
1131
|
case 17:
|
|
1153
1132
|
_context4.prev = 17;
|
|
1154
1133
|
if (!success) {
|
|
@@ -1230,17 +1209,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1230
1209
|
});
|
|
1231
1210
|
this.fireAnalyticsEvent = undefined;
|
|
1232
1211
|
|
|
1233
|
-
//
|
|
1234
|
-
//
|
|
1235
|
-
//
|
|
1236
|
-
// cache data that a sibling/successor manager (e.g. the editor
|
|
1237
|
-
// instance that mounts immediately after the renderer unmounts during
|
|
1238
|
-
// the view-mode transition) is about to read.
|
|
1239
|
-
// Let entries age out naturally instead — the in-memory cache is
|
|
1240
|
-
// naturally bounded by `maxSize` (LRU) and cleared on hard navigation.
|
|
1241
|
-
if (!fg('platform_synced_block_patch_14')) {
|
|
1242
|
-
syncBlockInMemorySessionCache.clear();
|
|
1243
|
-
}
|
|
1212
|
+
// `destroy()` is wired to React component unmount via
|
|
1213
|
+
// `useMemoizedSyncBlockStoreManager`. Let the in-memory session cache age
|
|
1214
|
+
// out naturally instead of clearing it during a view-mode transition.
|
|
1244
1215
|
}
|
|
1245
1216
|
}]);
|
|
1246
1217
|
}();
|
|
@@ -10,7 +10,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
13
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
13
|
import { SyncBlockError } from '../common/types';
|
|
15
14
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, createSuccessOperationalPayload, addContentSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload, buildErrorAttribution } from '../utils/errorHandling';
|
|
16
15
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
@@ -75,8 +74,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
75
74
|
_defineProperty(this, "awaitingFirstContent", new Set());
|
|
76
75
|
/**
|
|
77
76
|
* resourceId -> timestamp (ms) of the last `syncedBlockDelete` emission, used
|
|
78
|
-
* to suppress duplicates within {@link DELETE_DEDUPE_WINDOW_MS}.
|
|
79
|
-
* behind `platform_editor_blocks_patch_4`.
|
|
77
|
+
* to suppress duplicates within {@link DELETE_DEDUPE_WINDOW_MS}.
|
|
80
78
|
*/
|
|
81
79
|
_defineProperty(this, "recentDeleteEmissions", new Map());
|
|
82
80
|
_defineProperty(this, "setPendingDeletion", function (Ids, value) {
|
|
@@ -162,10 +160,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
162
160
|
resourceId = _syncBlockNode$attrs.resourceId;
|
|
163
161
|
if (!localId || !resourceId) {
|
|
164
162
|
// Identifiers not populated yet: benign timing case, skip as a no-op.
|
|
165
|
-
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
throw new Error('Local ID or resource ID is not set');
|
|
163
|
+
return false;
|
|
169
164
|
}
|
|
170
165
|
var cachedBlock = this.syncBlockCache.get(resourceId);
|
|
171
166
|
|
|
@@ -208,7 +203,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
208
203
|
value: (function () {
|
|
209
204
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
210
205
|
var _this2 = this;
|
|
211
|
-
var _this$saveExperience, timedOut, timeoutId, timeout, _iterator, _step, resourceId, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3,
|
|
206
|
+
var _this$saveExperience, timedOut, timeoutId, timeout, _iterator, _step, resourceId, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2, _this$flushCompletion, _t;
|
|
212
207
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
213
208
|
while (1) switch (_context.prev = _context.next) {
|
|
214
209
|
case 0:
|
|
@@ -327,12 +322,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
327
322
|
return _context.abrupt("return", true);
|
|
328
323
|
case 7:
|
|
329
324
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
|
|
330
|
-
attributionEnabled = fg('platform_editor_blocks_patch_3');
|
|
331
325
|
writeResults.filter(function (result) {
|
|
332
326
|
return !result.resourceId || result.error;
|
|
333
327
|
}).forEach(function (result) {
|
|
334
328
|
var _this2$fireAnalyticsE2;
|
|
335
|
-
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, updateErrorPayload(result.error || 'Failed to write data', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId), buildErrorAttribution(
|
|
329
|
+
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, updateErrorPayload(result.error || 'Failed to write data', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId), buildErrorAttribution(result.error, result.statusCode)));
|
|
336
330
|
});
|
|
337
331
|
return _context.abrupt("return", false);
|
|
338
332
|
case 8:
|
|
@@ -346,7 +340,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
346
340
|
});
|
|
347
341
|
// Top-level flush failure is not tied to a single resourceId. There is no structured
|
|
348
342
|
// SyncBlockError/status here, so the attribution `reason` falls back to `unknown`.
|
|
349
|
-
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, updateErrorPayload(_t.message, undefined, undefined, buildErrorAttribution(
|
|
343
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, updateErrorPayload(_t.message, undefined, undefined, buildErrorAttribution()));
|
|
350
344
|
return _context.abrupt("return", false);
|
|
351
345
|
case 10:
|
|
352
346
|
_context.prev = 10;
|
|
@@ -440,15 +434,12 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
440
434
|
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, createErrorPayload('creation complete callback missing', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
441
435
|
}
|
|
442
436
|
if (success) {
|
|
443
|
-
var _this$fireAnalyticsEv4;
|
|
437
|
+
var _this$fireAnalyticsEv4, _this$fireAnalyticsEv5, _this$syncBlockCache$2;
|
|
444
438
|
var sourceProduct = getSourceProductFromResourceIdSafe(resourceId);
|
|
445
439
|
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, createSuccessPayload(resourceId || '', sourceProduct));
|
|
446
440
|
// Operational create-success event with the join key + creation-type
|
|
447
441
|
// signals (inputMethod / createdEmpty) captured at the command layer.
|
|
448
|
-
|
|
449
|
-
var _this$fireAnalyticsEv5, _this$syncBlockCache$2;
|
|
450
|
-
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, createSuccessOperationalPayload(resourceId || '', (_this$syncBlockCache$2 = this.syncBlockCache.get(resourceId)) === null || _this$syncBlockCache$2 === void 0 ? void 0 : _this$syncBlockCache$2.blockInstanceId, sourceProduct, this.creationEnrichment.get(resourceId)));
|
|
451
|
-
}
|
|
442
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, createSuccessOperationalPayload(resourceId || '', (_this$syncBlockCache$2 = this.syncBlockCache.get(resourceId)) === null || _this$syncBlockCache$2 === void 0 ? void 0 : _this$syncBlockCache$2.blockInstanceId, sourceProduct, this.creationEnrichment.get(resourceId)));
|
|
452
443
|
} else {
|
|
453
444
|
var _this$fireAnalyticsEv6;
|
|
454
445
|
// Delete the node from cache if fail to create so it's not flushed to BE
|
|
@@ -467,7 +458,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
467
458
|
* Fire the first-content-added event once when a block created empty this
|
|
468
459
|
* session first gains content. The caller detects the in-block edit; this owns
|
|
469
460
|
* dedupe + emission (fires at most once per block, only for empty→content).
|
|
470
|
-
* Gated behind `platform_editor_blocks_patch_4`.
|
|
471
461
|
*/
|
|
472
462
|
}, {
|
|
473
463
|
key: "maybeEmitFirstContentAdded",
|
|
@@ -476,9 +466,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
476
466
|
if (this.viewMode === 'view') {
|
|
477
467
|
return;
|
|
478
468
|
}
|
|
479
|
-
if (!fg('platform_editor_blocks_patch_4')) {
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
469
|
// `delete` returns false when the id was not tracked (already emitted, or
|
|
483
470
|
// the block was not created empty this session), so this both dedupes and
|
|
484
471
|
// scopes emission to genuine first-content transitions in one check.
|
|
@@ -582,7 +569,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
582
569
|
(_this4$createExperien2 = _this4.createExperience) === null || _this4$createExperien2 === void 0 || _this4$createExperien2.failure({
|
|
583
570
|
reason: result.error || 'Failed to create bodied sync block'
|
|
584
571
|
});
|
|
585
|
-
(_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId), buildErrorAttribution(
|
|
572
|
+
(_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId), buildErrorAttribution(result.error, result.statusCode)));
|
|
586
573
|
}
|
|
587
574
|
}).catch(function (error) {
|
|
588
575
|
var _this4$createExperien3, _this4$fireAnalyticsE2;
|
|
@@ -637,21 +624,16 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
637
624
|
}
|
|
638
625
|
|
|
639
626
|
/**
|
|
640
|
-
* Emit the `syncedBlockDelete` success event.
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
627
|
+
* Emit the `syncedBlockDelete` success event. Attaches `deletionReason`,
|
|
628
|
+
* `mechanism` and `blockInstanceId`, and suppresses repeat emissions within
|
|
629
|
+
* {@link DELETE_DEDUPE_WINDOW_MS}. Must run while the cache entry still exists
|
|
630
|
+
* so `blockInstanceId` is available.
|
|
644
631
|
*/
|
|
645
632
|
}, {
|
|
646
633
|
key: "emitDeleteSuccess",
|
|
647
634
|
value: function emitDeleteSuccess(resourceId, reason, mechanism) {
|
|
648
|
-
var _this$syncBlockCache$3, _this$
|
|
635
|
+
var _this$syncBlockCache$3, _this$fireAnalyticsEv9;
|
|
649
636
|
var sourceProduct = getSourceProductFromResourceIdSafe(resourceId);
|
|
650
|
-
if (!fg('platform_editor_blocks_patch_4')) {
|
|
651
|
-
var _this$fireAnalyticsEv9;
|
|
652
|
-
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, deleteSuccessPayload(resourceId, sourceProduct));
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
637
|
var now = Date.now();
|
|
656
638
|
var lastEmittedAt = this.recentDeleteEmissions.get(resourceId);
|
|
657
639
|
if (lastEmittedAt !== undefined && now - lastEmittedAt < DELETE_DEDUPE_WINDOW_MS) {
|
|
@@ -664,14 +646,14 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
664
646
|
deletionReason: reason,
|
|
665
647
|
mechanism: mechanism
|
|
666
648
|
};
|
|
667
|
-
(_this$
|
|
649
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, deleteSuccessPayload(resourceId, sourceProduct, enrichment));
|
|
668
650
|
}
|
|
669
651
|
}, {
|
|
670
652
|
key: "delete",
|
|
671
653
|
value: function () {
|
|
672
654
|
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(syncBlockIds, onDelete, onDeleteCompleted, reason, mechanism) {
|
|
673
655
|
var _this5 = this;
|
|
674
|
-
var _this$deleteExperienc, results, callback, isDeleteSuccessful, _this$deleteExperienc2, _this$deleteExperienc3,
|
|
656
|
+
var _this$deleteExperienc, results, callback, isDeleteSuccessful, _this$deleteExperienc2, _this$deleteExperienc3, attribution, _t2;
|
|
675
657
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
676
658
|
while (1) switch (_context2.prev = _context2.next) {
|
|
677
659
|
case 0:
|
|
@@ -719,13 +701,12 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
719
701
|
_this5.setPendingDeletion(Ids, false);
|
|
720
702
|
};
|
|
721
703
|
(_this$deleteExperienc3 = this.deleteExperience) === null || _this$deleteExperienc3 === void 0 || _this$deleteExperienc3.failure();
|
|
722
|
-
attributionEnabled = fg('platform_editor_blocks_patch_3');
|
|
723
704
|
results.forEach(function (result) {
|
|
724
705
|
if (result.success) {
|
|
725
706
|
_this5.emitDeleteSuccess(result.resourceId, reason, mechanism);
|
|
726
707
|
} else {
|
|
727
708
|
var _this5$fireAnalyticsE;
|
|
728
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId), buildErrorAttribution(
|
|
709
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId), buildErrorAttribution(result.error, result.statusCode)));
|
|
729
710
|
}
|
|
730
711
|
});
|
|
731
712
|
}
|
|
@@ -735,8 +716,8 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
735
716
|
_context2.prev = 4;
|
|
736
717
|
_t2 = _context2["catch"](0);
|
|
737
718
|
// Thrown (non-result) failure — no structured SyncBlockError/status is available,
|
|
738
|
-
// so the attribution `reason` falls back to `unknown
|
|
739
|
-
attribution = buildErrorAttribution(
|
|
719
|
+
// so the attribution `reason` falls back to `unknown`.
|
|
720
|
+
attribution = buildErrorAttribution();
|
|
740
721
|
syncBlockIds.forEach(function (Ids) {
|
|
741
722
|
var _this5$fireAnalyticsE2;
|
|
742
723
|
_this5.setPendingDeletion(Ids, false);
|
|
@@ -1013,11 +994,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1013
994
|
return sourceInfo;
|
|
1014
995
|
});
|
|
1015
996
|
} catch (error) {
|
|
1016
|
-
var _this$
|
|
997
|
+
var _this$fireAnalyticsEv0;
|
|
1017
998
|
logException(error, {
|
|
1018
999
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
1019
1000
|
});
|
|
1020
|
-
(_this$
|
|
1001
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, getSourceInfoErrorPayload(error.message));
|
|
1021
1002
|
return Promise.resolve(undefined);
|
|
1022
1003
|
}
|
|
1023
1004
|
}
|
|
@@ -1030,11 +1011,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1030
1011
|
}
|
|
1031
1012
|
return this.dataProvider.fetchReferences(resourceId, true);
|
|
1032
1013
|
} catch (error) {
|
|
1033
|
-
var _this$
|
|
1014
|
+
var _this$fireAnalyticsEv1;
|
|
1034
1015
|
logException(error, {
|
|
1035
1016
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
1036
1017
|
});
|
|
1037
|
-
(_this$
|
|
1018
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, fetchReferencesErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
1038
1019
|
return Promise.resolve({
|
|
1039
1020
|
error: SyncBlockError.Errored
|
|
1040
1021
|
});
|
|
@@ -3,7 +3,6 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
5
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { isProviderNotReadyError } from '../common/types';
|
|
8
7
|
import { buildFetchErrorAttribution, fetchErrorPayload } from '../utils/errorHandling';
|
|
9
8
|
import { createSyncBlockNode, getSourceProductFromResourceIdSafe } from '../utils/utils';
|
|
@@ -29,14 +28,9 @@ export var SyncBlockBatchFetcher = /*#__PURE__*/function () {
|
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
// EDITOR-7860: not ready — skip and leave resourceIds queued for the
|
|
32
|
-
// next batch once the provider resolves.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// exposure is still tracked — satisfies @atlaskit/platform/no-preconditioning).
|
|
36
|
-
if (fg('platform_editor_blocks_patch_3')) {
|
|
37
|
-
if (_this.deps.isProviderReady && !_this.deps.isProviderReady()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
31
|
+
// next batch once the provider resolves.
|
|
32
|
+
if (_this.deps.isProviderReady && !_this.deps.isProviderReady()) {
|
|
33
|
+
return;
|
|
40
34
|
}
|
|
41
35
|
var resourceIds = Array.from(_this.pendingFetchRequests);
|
|
42
36
|
var syncBlockNodes = resourceIds.map(function (resId) {
|
|
@@ -55,8 +49,8 @@ export var SyncBlockBatchFetcher = /*#__PURE__*/function () {
|
|
|
55
49
|
// nothing (no analytics, no exception-tracker noise). Checked before
|
|
56
50
|
// `logException` so the benign case stays silent. Re-schedule so the
|
|
57
51
|
// re-queued IDs are retried on the next frame even if no further
|
|
58
|
-
// `queueFetch()` arrives.
|
|
59
|
-
if (isProviderNotReadyError(error)
|
|
52
|
+
// `queueFetch()` arrives.
|
|
53
|
+
if (isProviderNotReadyError(error)) {
|
|
60
54
|
resourceIds.forEach(function (resId) {
|
|
61
55
|
return _this.pendingFetchRequests.add(resId);
|
|
62
56
|
});
|
|
@@ -68,7 +62,7 @@ export var SyncBlockBatchFetcher = /*#__PURE__*/function () {
|
|
|
68
62
|
logException(error, {
|
|
69
63
|
location: 'editor-synced-block-provider/syncBlockBatchFetcher/batchedFetchSyncBlocks'
|
|
70
64
|
});
|
|
71
|
-
var attribution = buildFetchErrorAttribution(
|
|
65
|
+
var attribution = buildFetchErrorAttribution(error.message);
|
|
72
66
|
resourceIds.forEach(function (resId) {
|
|
73
67
|
var _this$deps$getFireAna;
|
|
74
68
|
(_this$deps$getFireAna = _this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(error.message, resId, getSourceProductFromResourceIdSafe(resId), attribution));
|
|
@@ -28,7 +28,7 @@ export var SyncBlockProviderFactoryManager = /*#__PURE__*/function () {
|
|
|
28
28
|
logException(error, {
|
|
29
29
|
location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
|
|
30
30
|
});
|
|
31
|
-
(_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution(
|
|
31
|
+
(_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution(error.message)));
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
34
|
var providerFactory = this.providerFactories.get(resourceId);
|
|
@@ -104,7 +104,7 @@ export var SyncBlockProviderFactoryManager = /*#__PURE__*/function () {
|
|
|
104
104
|
logException(error, {
|
|
105
105
|
location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
|
|
106
106
|
});
|
|
107
|
-
(_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 || _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution(
|
|
107
|
+
(_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 || _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution(error.message)));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}, {
|
|
@@ -187,7 +187,7 @@ export var SyncBlockProviderFactoryManager = /*#__PURE__*/function () {
|
|
|
187
187
|
if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
|
|
188
188
|
var _this$deps$getFireAna3, _syncBlock$data$produ;
|
|
189
189
|
(_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.
|
|
190
|
-
(_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution(
|
|
190
|
+
(_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : getSourceProductFromResourceIdSafe(resourceId), buildFetchErrorAttribution('Sync block source ari or product not found')));
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
var parentInfo = dataProvider.retrieveSyncBlockParentInfo(syncBlock.data.sourceAri, syncBlock.data.product);
|
|
@@ -7,7 +7,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
7
7
|
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; }
|
|
8
8
|
import { useEffect, useMemo, useRef } from 'react';
|
|
9
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
12
11
|
import { SyncBlockError } from '../common/types';
|
|
13
12
|
import { fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
@@ -303,7 +302,6 @@ export var useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStore
|
|
|
303
302
|
syncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
|
|
304
303
|
}
|
|
305
304
|
|
|
306
|
-
// Gated by platform_synced_block_patch_14:
|
|
307
305
|
// Destroy the SyncBlockStoreManager when:
|
|
308
306
|
// (a) the component unmounts — manager is fully cleaned up, or
|
|
309
307
|
// (b) dataProvider changes — the old manager (now orphaned by the
|
|
@@ -315,9 +313,7 @@ export var useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStore
|
|
|
315
313
|
// changes, triggering the cleanup for the old instance.
|
|
316
314
|
useEffect(function () {
|
|
317
315
|
return function () {
|
|
318
|
-
|
|
319
|
-
syncBlockStoreManager.destroy();
|
|
320
|
-
}
|
|
316
|
+
syncBlockStoreManager.destroy();
|
|
321
317
|
};
|
|
322
318
|
}, [syncBlockStoreManager]);
|
|
323
319
|
return syncBlockStoreManager;
|