@atlaskit/editor-synced-block-provider 4.0.1 → 4.1.1
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 +19 -0
- package/dist/cjs/clients/block-service/blockService.js +35 -17
- package/dist/cjs/common/types.js +2 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +16 -1
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +209 -811
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +3 -6
- package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +180 -17
- package/dist/es2019/clients/block-service/blockService.js +16 -3
- package/dist/es2019/common/types.js +2 -0
- package/dist/es2019/providers/block-service/blockServiceAPI.js +12 -1
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +78 -595
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +3 -6
- package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +157 -10
- package/dist/esm/clients/block-service/blockService.js +34 -16
- package/dist/esm/common/types.js +2 -0
- package/dist/esm/providers/block-service/blockServiceAPI.js +17 -2
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +210 -812
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +3 -6
- package/dist/esm/store-manager/syncBlockSubscriptionManager.js +180 -17
- package/dist/types/clients/block-service/blockService.d.ts +4 -1
- package/dist/types/common/types.d.ts +2 -1
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +4 -49
- package/dist/types/store-manager/syncBlockSubscriptionManager.d.ts +25 -6
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +4 -1
- package/dist/types-ts4.5/common/types.d.ts +2 -1
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +4 -49
- package/dist/types-ts4.5/store-manager/syncBlockSubscriptionManager.d.ts +25 -6
- package/package.json +4 -7
|
@@ -12,25 +12,21 @@ 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 _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
15
|
-
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
16
15
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
17
|
-
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
18
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
16
|
var _types = require("../common/types");
|
|
20
17
|
var _errorHandling = require("../utils/errorHandling");
|
|
21
18
|
var _experienceTracking = require("../utils/experienceTracking");
|
|
22
19
|
var _resolveSyncBlockInstance = require("../utils/resolveSyncBlockInstance");
|
|
23
|
-
var _resourceId = require("../utils/resourceId");
|
|
24
20
|
var _utils = require("../utils/utils");
|
|
25
21
|
var _syncBlockBatchFetcher = require("./syncBlockBatchFetcher");
|
|
26
22
|
var _syncBlockInMemorySessionCache = require("./syncBlockInMemorySessionCache");
|
|
27
23
|
var _syncBlockProviderFactoryManager = require("./syncBlockProviderFactoryManager");
|
|
28
24
|
var _syncBlockSubscriptionManager = require("./syncBlockSubscriptionManager");
|
|
29
|
-
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; }
|
|
30
|
-
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; }
|
|
31
25
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
32
26
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
33
27
|
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; }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
34
30
|
var CACHE_KEY_PREFIX = 'sync-block-data-';
|
|
35
31
|
|
|
36
32
|
// A store manager responsible for the lifecycle and state management of reference sync blocks in an editor instance.
|
|
@@ -39,6 +35,8 @@ var CACHE_KEY_PREFIX = 'sync-block-data-';
|
|
|
39
35
|
// Handles fetching source URL and title for sync blocks.
|
|
40
36
|
// Can be used in both editor and renderer contexts.
|
|
41
37
|
var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
38
|
+
// Track the setTimeout handle for queued flush so we can cancel it on destroy
|
|
39
|
+
|
|
42
40
|
function ReferenceSyncBlockStoreManager(dataProvider) {
|
|
43
41
|
var _this = this,
|
|
44
42
|
_this$dataProvider;
|
|
@@ -47,91 +45,64 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
47
45
|
// This starts as true to always flush the cache when document is saved for the first time
|
|
48
46
|
// to cater the case when a editor session is closed without document being updated right after reference block is deleted
|
|
49
47
|
(0, _defineProperty2.default)(this, "isCacheDirty", true);
|
|
50
|
-
(0, _defineProperty2.default)(this, "isRefreshingSubscriptions", false);
|
|
51
|
-
// Flag to indicate if real-time subscriptions are enabled
|
|
52
|
-
(0, _defineProperty2.default)(this, "useRealTimeSubscriptions", false);
|
|
53
48
|
// Keep track of the last flushed subscriptions to optimize cache flushing on document save
|
|
54
49
|
(0, _defineProperty2.default)(this, "lastFlushedSyncedBlocks", {});
|
|
55
50
|
// Track if a flush operation is currently in progress
|
|
56
51
|
(0, _defineProperty2.default)(this, "isFlushInProgress", false);
|
|
57
52
|
// Track if another flush is needed after the current one completes
|
|
58
53
|
(0, _defineProperty2.default)(this, "flushNeededAfterCurrent", false);
|
|
59
|
-
(0, _defineProperty2.default)(this, "pendingFetchRequests", new Set());
|
|
60
|
-
(0, _defineProperty2.default)(this, "scheduledBatchFetch", (0, _rafSchd.default)(function () {
|
|
61
|
-
if (_this.pendingFetchRequests.size === 0) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
var resourceIds = Array.from(_this.pendingFetchRequests);
|
|
65
|
-
var syncBlockNodes = resourceIds.map(function (resId) {
|
|
66
|
-
var subscriptions = _this.subscriptions.get(resId) || {};
|
|
67
|
-
var firstLocalId = Object.keys(subscriptions)[0] || '';
|
|
68
|
-
return (0, _utils.createSyncBlockNode)(firstLocalId, resId);
|
|
69
|
-
});
|
|
70
|
-
_this.pendingFetchRequests.clear();
|
|
71
|
-
_this.fetchSyncBlocksData(syncBlockNodes).catch(function (error) {
|
|
72
|
-
(0, _monitoring.logException)(error, {
|
|
73
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager/batchedFetchSyncBlocks'
|
|
74
|
-
});
|
|
75
|
-
resourceIds.forEach(function (resId) {
|
|
76
|
-
var _this$fireAnalyticsEv;
|
|
77
|
-
(_this$fireAnalyticsEv = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(_this, (0, _errorHandling.fetchErrorPayload)(error.message, resId));
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}));
|
|
81
|
-
this.subscriptions = new Map();
|
|
82
|
-
this.titleSubscriptions = new Map();
|
|
83
54
|
this.dataProvider = dataProvider;
|
|
84
55
|
this.syncBlockFetchDataRequests = new Map();
|
|
85
56
|
this.syncBlockSourceInfoRequests = new Map();
|
|
86
|
-
this.providerFactories = new Map();
|
|
87
|
-
this.pendingCacheDeletions = new Map();
|
|
88
|
-
this.graphqlSubscriptions = new Map();
|
|
89
|
-
this.subscriptionChangeListeners = new Set();
|
|
90
57
|
this.newlyAddedSyncBlocks = new Set();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
58
|
+
this._subscriptionManager = new _syncBlockSubscriptionManager.SyncBlockSubscriptionManager({
|
|
59
|
+
getDataProvider: function getDataProvider() {
|
|
60
|
+
return _this.dataProvider;
|
|
61
|
+
},
|
|
62
|
+
getFromCache: function getFromCache(rid) {
|
|
63
|
+
return _this.getFromCache(rid);
|
|
64
|
+
},
|
|
65
|
+
updateCache: function updateCache(inst) {
|
|
66
|
+
return _this.updateCache(inst);
|
|
67
|
+
},
|
|
68
|
+
deleteFromCache: function deleteFromCache(rid) {
|
|
69
|
+
return _this.deleteFromCache(rid);
|
|
70
|
+
},
|
|
71
|
+
debouncedBatchedFetchSyncBlocks: function debouncedBatchedFetchSyncBlocks(rid) {
|
|
72
|
+
return _this.debouncedBatchedFetchSyncBlocks(rid);
|
|
73
|
+
},
|
|
74
|
+
fetchSyncBlockSourceInfo: function fetchSyncBlockSourceInfo(rid) {
|
|
75
|
+
return _this.fetchSyncBlockSourceInfo(rid);
|
|
76
|
+
},
|
|
77
|
+
getFireAnalyticsEvent: function getFireAnalyticsEvent() {
|
|
78
|
+
return _this.fireAnalyticsEvent;
|
|
79
|
+
},
|
|
80
|
+
markCacheDirty: function markCacheDirty() {
|
|
81
|
+
_this.isCacheDirty = true;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
this._providerFactoryManager = new _syncBlockProviderFactoryManager.SyncBlockProviderFactoryManager({
|
|
85
|
+
getDataProvider: function getDataProvider() {
|
|
86
|
+
return _this.dataProvider;
|
|
87
|
+
},
|
|
88
|
+
getFromCache: function getFromCache(rid) {
|
|
89
|
+
return _this.getFromCache(rid);
|
|
90
|
+
},
|
|
91
|
+
getFireAnalyticsEvent: function getFireAnalyticsEvent() {
|
|
92
|
+
return _this.fireAnalyticsEvent;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this._batchFetcher = new _syncBlockBatchFetcher.SyncBlockBatchFetcher({
|
|
96
|
+
getSubscriptions: function getSubscriptions() {
|
|
97
|
+
return _this._subscriptionManager.getSubscriptions();
|
|
98
|
+
},
|
|
99
|
+
fetchSyncBlocksData: function fetchSyncBlocksData(nodes) {
|
|
100
|
+
return _this.fetchSyncBlocksData(nodes);
|
|
101
|
+
},
|
|
102
|
+
getFireAnalyticsEvent: function getFireAnalyticsEvent() {
|
|
103
|
+
return _this.fireAnalyticsEvent;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
135
106
|
|
|
136
107
|
// The provider might have SSR data cache already set, so we need to update the cache in session memory storage
|
|
137
108
|
this.setSSRDataInSessionCache((_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getNodeDataCacheKeys());
|
|
@@ -146,21 +117,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
146
117
|
return (0, _createClass2.default)(ReferenceSyncBlockStoreManager, [{
|
|
147
118
|
key: "setRealTimeSubscriptionsEnabled",
|
|
148
119
|
value: function setRealTimeSubscriptionsEnabled(enabled) {
|
|
149
|
-
|
|
150
|
-
this._subscriptionManager.setRealTimeSubscriptionsEnabled(enabled);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (this.useRealTimeSubscriptions === enabled) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
this.useRealTimeSubscriptions = enabled;
|
|
157
|
-
if (enabled) {
|
|
158
|
-
// Set up subscriptions for all currently subscribed blocks
|
|
159
|
-
this.setupGraphQLSubscriptionsForAllBlocks();
|
|
160
|
-
} else {
|
|
161
|
-
// Clean up all GraphQL subscriptions
|
|
162
|
-
this.cleanupAllGraphQLSubscriptions();
|
|
163
|
-
}
|
|
120
|
+
this._subscriptionManager.setRealTimeSubscriptionsEnabled(enabled);
|
|
164
121
|
}
|
|
165
122
|
|
|
166
123
|
/**
|
|
@@ -169,10 +126,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
169
126
|
}, {
|
|
170
127
|
key: "isRealTimeSubscriptionsEnabled",
|
|
171
128
|
value: function isRealTimeSubscriptionsEnabled() {
|
|
172
|
-
|
|
173
|
-
return this._subscriptionManager.isRealTimeSubscriptionsEnabled();
|
|
174
|
-
}
|
|
175
|
-
return this.useRealTimeSubscriptions;
|
|
129
|
+
return this._subscriptionManager.isRealTimeSubscriptionsEnabled();
|
|
176
130
|
}
|
|
177
131
|
|
|
178
132
|
/**
|
|
@@ -182,10 +136,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
182
136
|
}, {
|
|
183
137
|
key: "getSubscribedResourceIds",
|
|
184
138
|
value: function getSubscribedResourceIds() {
|
|
185
|
-
|
|
186
|
-
return this._subscriptionManager.getSubscribedResourceIds();
|
|
187
|
-
}
|
|
188
|
-
return Array.from(this.subscriptions.keys());
|
|
139
|
+
return this._subscriptionManager.getSubscribedResourceIds();
|
|
189
140
|
}
|
|
190
141
|
|
|
191
142
|
/**
|
|
@@ -196,38 +147,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
196
147
|
}, {
|
|
197
148
|
key: "onSubscriptionsChanged",
|
|
198
149
|
value: function onSubscriptionsChanged(listener) {
|
|
199
|
-
|
|
200
|
-
if (this._subscriptionManager && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
201
|
-
return this._subscriptionManager.onSubscriptionsChanged(listener);
|
|
202
|
-
}
|
|
203
|
-
this.subscriptionChangeListeners.add(listener);
|
|
204
|
-
return function () {
|
|
205
|
-
_this2.subscriptionChangeListeners.delete(listener);
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Notifies all subscription change listeners.
|
|
211
|
-
*/
|
|
212
|
-
}, {
|
|
213
|
-
key: "notifySubscriptionChangeListeners",
|
|
214
|
-
value: function notifySubscriptionChangeListeners() {
|
|
215
|
-
var _this3 = this;
|
|
216
|
-
if (this._subscriptionManager && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
217
|
-
this._subscriptionManager.notifySubscriptionChangeListeners();
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
this.subscriptionChangeListeners.forEach(function (listener) {
|
|
221
|
-
try {
|
|
222
|
-
listener();
|
|
223
|
-
} catch (error) {
|
|
224
|
-
var _this3$fireAnalyticsE;
|
|
225
|
-
(0, _monitoring.logException)(error, {
|
|
226
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager/notifySubscriptionChangeListeners'
|
|
227
|
-
});
|
|
228
|
-
(_this3$fireAnalyticsE = _this3.fireAnalyticsEvent) === null || _this3$fireAnalyticsE === void 0 || _this3$fireAnalyticsE.call(_this3, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
229
|
-
}
|
|
230
|
-
});
|
|
150
|
+
return this._subscriptionManager.onSubscriptionsChanged(listener);
|
|
231
151
|
}
|
|
232
152
|
|
|
233
153
|
/**
|
|
@@ -238,19 +158,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
238
158
|
}, {
|
|
239
159
|
key: "handleSubscriptionUpdate",
|
|
240
160
|
value: function handleSubscriptionUpdate(syncBlockInstance) {
|
|
241
|
-
|
|
242
|
-
this._subscriptionManager.handleSubscriptionUpdate(syncBlockInstance);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (!syncBlockInstance.resourceId) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
var existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
|
|
249
|
-
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
250
|
-
this.updateCache(resolvedSyncBlockInstance);
|
|
251
|
-
if (!syncBlockInstance.error) {
|
|
252
|
-
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
253
|
-
}
|
|
161
|
+
this._subscriptionManager.handleSubscriptionUpdate(syncBlockInstance);
|
|
254
162
|
}
|
|
255
163
|
}, {
|
|
256
164
|
key: "setFireAnalyticsEvent",
|
|
@@ -324,233 +232,6 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
324
232
|
return undefined;
|
|
325
233
|
}
|
|
326
234
|
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Refreshes the subscriptions for all sync blocks.
|
|
330
|
-
* This is a fallback polling mechanism when real-time subscriptions are not enabled.
|
|
331
|
-
* @returns {Promise<void>}
|
|
332
|
-
*/
|
|
333
|
-
}, {
|
|
334
|
-
key: "refreshSubscriptions",
|
|
335
|
-
value: (function () {
|
|
336
|
-
var _refreshSubscriptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
337
|
-
var syncBlocks, _iterator, _step, _loop, _this$fireAnalyticsEv2;
|
|
338
|
-
return _regenerator.default.wrap(function _callee$(_context2) {
|
|
339
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
340
|
-
case 0:
|
|
341
|
-
if (!this.useRealTimeSubscriptions) {
|
|
342
|
-
_context2.next = 2;
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
return _context2.abrupt("return");
|
|
346
|
-
case 2:
|
|
347
|
-
if (!this.isRefreshingSubscriptions) {
|
|
348
|
-
_context2.next = 4;
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
return _context2.abrupt("return");
|
|
352
|
-
case 4:
|
|
353
|
-
this.isRefreshingSubscriptions = true;
|
|
354
|
-
syncBlocks = [];
|
|
355
|
-
_iterator = _createForOfIteratorHelper(this.subscriptions.entries());
|
|
356
|
-
_context2.prev = 7;
|
|
357
|
-
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
358
|
-
var _step$value, resourceId, callbacks;
|
|
359
|
-
return _regenerator.default.wrap(function _loop$(_context) {
|
|
360
|
-
while (1) switch (_context.prev = _context.next) {
|
|
361
|
-
case 0:
|
|
362
|
-
_step$value = (0, _slicedToArray2.default)(_step.value, 2), resourceId = _step$value[0], callbacks = _step$value[1];
|
|
363
|
-
Object.keys(callbacks).forEach(function (localId) {
|
|
364
|
-
syncBlocks.push((0, _utils.createSyncBlockNode)(localId, resourceId));
|
|
365
|
-
});
|
|
366
|
-
case 2:
|
|
367
|
-
case "end":
|
|
368
|
-
return _context.stop();
|
|
369
|
-
}
|
|
370
|
-
}, _loop);
|
|
371
|
-
});
|
|
372
|
-
_iterator.s();
|
|
373
|
-
case 10:
|
|
374
|
-
if ((_step = _iterator.n()).done) {
|
|
375
|
-
_context2.next = 14;
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
return _context2.delegateYield(_loop(), "t0", 12);
|
|
379
|
-
case 12:
|
|
380
|
-
_context2.next = 10;
|
|
381
|
-
break;
|
|
382
|
-
case 14:
|
|
383
|
-
_context2.next = 19;
|
|
384
|
-
break;
|
|
385
|
-
case 16:
|
|
386
|
-
_context2.prev = 16;
|
|
387
|
-
_context2.t1 = _context2["catch"](7);
|
|
388
|
-
_iterator.e(_context2.t1);
|
|
389
|
-
case 19:
|
|
390
|
-
_context2.prev = 19;
|
|
391
|
-
_iterator.f();
|
|
392
|
-
return _context2.finish(19);
|
|
393
|
-
case 22:
|
|
394
|
-
_context2.prev = 22;
|
|
395
|
-
_context2.next = 25;
|
|
396
|
-
return this.fetchSyncBlocksData(syncBlocks);
|
|
397
|
-
case 25:
|
|
398
|
-
_context2.next = 31;
|
|
399
|
-
break;
|
|
400
|
-
case 27:
|
|
401
|
-
_context2.prev = 27;
|
|
402
|
-
_context2.t2 = _context2["catch"](22);
|
|
403
|
-
(0, _monitoring.logException)(_context2.t2, {
|
|
404
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
405
|
-
});
|
|
406
|
-
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.fetchErrorPayload)(_context2.t2.message));
|
|
407
|
-
case 31:
|
|
408
|
-
_context2.prev = 31;
|
|
409
|
-
this.isRefreshingSubscriptions = false;
|
|
410
|
-
return _context2.finish(31);
|
|
411
|
-
case 34:
|
|
412
|
-
case "end":
|
|
413
|
-
return _context2.stop();
|
|
414
|
-
}
|
|
415
|
-
}, _callee, this, [[7, 16, 19, 22], [22, 27, 31, 34]]);
|
|
416
|
-
}));
|
|
417
|
-
function refreshSubscriptions() {
|
|
418
|
-
return _refreshSubscriptions.apply(this, arguments);
|
|
419
|
-
}
|
|
420
|
-
return refreshSubscriptions;
|
|
421
|
-
}()
|
|
422
|
-
/**
|
|
423
|
-
* Sets up a GraphQL subscription for a specific block.
|
|
424
|
-
* @param resourceId - The resource ID of the block to subscribe to
|
|
425
|
-
*/
|
|
426
|
-
)
|
|
427
|
-
}, {
|
|
428
|
-
key: "setupGraphQLSubscription",
|
|
429
|
-
value: function setupGraphQLSubscription(resourceId) {
|
|
430
|
-
var _this$dataProvider3,
|
|
431
|
-
_this4 = this;
|
|
432
|
-
if (this._subscriptionManager && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
433
|
-
this._subscriptionManager.setupSubscription(resourceId);
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// Don't set up duplicate subscriptions
|
|
438
|
-
if (this.graphqlSubscriptions.has(resourceId)) {
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
if (!((_this$dataProvider3 = this.dataProvider) !== null && _this$dataProvider3 !== void 0 && _this$dataProvider3.subscribeToBlockUpdates)) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
var unsubscribe = this.dataProvider.subscribeToBlockUpdates(resourceId, function (syncBlockInstance) {
|
|
445
|
-
// Handle the subscription update
|
|
446
|
-
_this4.handleGraphQLSubscriptionUpdate(syncBlockInstance);
|
|
447
|
-
}, function (error) {
|
|
448
|
-
var _this4$fireAnalyticsE;
|
|
449
|
-
(0, _monitoring.logException)(error, {
|
|
450
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager/graphql-subscription'
|
|
451
|
-
});
|
|
452
|
-
(_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
453
|
-
});
|
|
454
|
-
if (unsubscribe) {
|
|
455
|
-
this.graphqlSubscriptions.set(resourceId, unsubscribe);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Handles updates received from GraphQL subscriptions.
|
|
461
|
-
* @param syncBlockInstance - The updated sync block instance
|
|
462
|
-
*/
|
|
463
|
-
}, {
|
|
464
|
-
key: "handleGraphQLSubscriptionUpdate",
|
|
465
|
-
value: function handleGraphQLSubscriptionUpdate(syncBlockInstance) {
|
|
466
|
-
var _this5 = this;
|
|
467
|
-
if (!syncBlockInstance.resourceId) {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
var existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
|
|
471
|
-
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
472
|
-
this.updateCache(resolvedSyncBlockInstance);
|
|
473
|
-
if (!syncBlockInstance.error) {
|
|
474
|
-
var callbacks = this.subscriptions.get(syncBlockInstance.resourceId);
|
|
475
|
-
var localIds = callbacks ? Object.keys(callbacks) : [];
|
|
476
|
-
localIds.forEach(function (localId) {
|
|
477
|
-
var _this5$fireAnalyticsE, _syncBlockInstance$da;
|
|
478
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.product));
|
|
479
|
-
});
|
|
480
|
-
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
481
|
-
} else {
|
|
482
|
-
var _syncBlockInstance$er, _syncBlockInstance$er2, _this$fireAnalyticsEv3;
|
|
483
|
-
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);
|
|
484
|
-
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.fetchErrorPayload)(errorMessage, syncBlockInstance.resourceId));
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Cleans up the GraphQL subscription for a specific block.
|
|
490
|
-
* @param resourceId - The resource ID of the block to unsubscribe from
|
|
491
|
-
*/
|
|
492
|
-
}, {
|
|
493
|
-
key: "cleanupGraphQLSubscription",
|
|
494
|
-
value: function cleanupGraphQLSubscription(resourceId) {
|
|
495
|
-
if (this._subscriptionManager && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
496
|
-
this._subscriptionManager.cleanupSubscription(resourceId);
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
var unsubscribe = this.graphqlSubscriptions.get(resourceId);
|
|
500
|
-
if (unsubscribe) {
|
|
501
|
-
unsubscribe();
|
|
502
|
-
this.graphqlSubscriptions.delete(resourceId);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Sets up GraphQL subscriptions for all currently subscribed blocks.
|
|
508
|
-
*/
|
|
509
|
-
}, {
|
|
510
|
-
key: "setupGraphQLSubscriptionsForAllBlocks",
|
|
511
|
-
value: function setupGraphQLSubscriptionsForAllBlocks() {
|
|
512
|
-
if (this._subscriptionManager && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
513
|
-
this._subscriptionManager.setupSubscriptionsForAllBlocks();
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
var _iterator2 = _createForOfIteratorHelper(this.subscriptions.keys()),
|
|
517
|
-
_step2;
|
|
518
|
-
try {
|
|
519
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
520
|
-
var resourceId = _step2.value;
|
|
521
|
-
this.setupGraphQLSubscription(resourceId);
|
|
522
|
-
}
|
|
523
|
-
} catch (err) {
|
|
524
|
-
_iterator2.e(err);
|
|
525
|
-
} finally {
|
|
526
|
-
_iterator2.f();
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Cleans up all GraphQL subscriptions.
|
|
532
|
-
*/
|
|
533
|
-
}, {
|
|
534
|
-
key: "cleanupAllGraphQLSubscriptions",
|
|
535
|
-
value: function cleanupAllGraphQLSubscriptions() {
|
|
536
|
-
if (this._subscriptionManager && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
537
|
-
this._subscriptionManager.cleanupAll();
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
var _iterator3 = _createForOfIteratorHelper(this.graphqlSubscriptions.values()),
|
|
541
|
-
_step3;
|
|
542
|
-
try {
|
|
543
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
544
|
-
var unsubscribe = _step3.value;
|
|
545
|
-
unsubscribe();
|
|
546
|
-
}
|
|
547
|
-
} catch (err) {
|
|
548
|
-
_iterator3.e(err);
|
|
549
|
-
} finally {
|
|
550
|
-
_iterator3.f();
|
|
551
|
-
}
|
|
552
|
-
this.graphqlSubscriptions.clear();
|
|
553
|
-
}
|
|
554
235
|
}, {
|
|
555
236
|
key: "fetchSyncBlockSourceInfoBySourceAri",
|
|
556
237
|
value: function fetchSyncBlockSourceInfoBySourceAri(sourceAri) {
|
|
@@ -562,18 +243,18 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
562
243
|
var sourceInfo = this.dataProvider.fetchSyncBlockSourceInfo(undefined, sourceAri, undefined, hasAccess);
|
|
563
244
|
return sourceInfo;
|
|
564
245
|
} catch (error) {
|
|
565
|
-
var _this$
|
|
246
|
+
var _this$fireAnalyticsEv;
|
|
566
247
|
(0, _monitoring.logException)(error, {
|
|
567
248
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager/fetchSyncBlockSourceInfoBySourceAri'
|
|
568
249
|
});
|
|
569
|
-
(_this$
|
|
250
|
+
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
|
|
570
251
|
return Promise.resolve(undefined);
|
|
571
252
|
}
|
|
572
253
|
}
|
|
573
254
|
}, {
|
|
574
255
|
key: "fetchSyncBlockSourceInfo",
|
|
575
256
|
value: function fetchSyncBlockSourceInfo(resourceId) {
|
|
576
|
-
var
|
|
257
|
+
var _this2 = this;
|
|
577
258
|
try {
|
|
578
259
|
var _this$fetchSourceInfo;
|
|
579
260
|
if (!resourceId || !this.dataProvider) {
|
|
@@ -607,54 +288,54 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
607
288
|
});
|
|
608
289
|
}
|
|
609
290
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
610
|
-
var _this$
|
|
611
|
-
(_this$
|
|
291
|
+
var _this$fireAnalyticsEv2;
|
|
292
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing', resourceId));
|
|
612
293
|
return Promise.resolve(undefined);
|
|
613
294
|
}
|
|
614
295
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
615
296
|
var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, true // hasAccess
|
|
616
297
|
).then(function (sourceInfo) {
|
|
617
298
|
if (!sourceInfo) {
|
|
618
|
-
var
|
|
619
|
-
(
|
|
299
|
+
var _this2$fetchSourceInf, _this2$fireAnalyticsE;
|
|
300
|
+
(_this2$fetchSourceInf = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf === void 0 || _this2$fetchSourceInf.failure({
|
|
620
301
|
reason: 'No source info returned'
|
|
621
302
|
});
|
|
622
|
-
(
|
|
303
|
+
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.getSourceInfoErrorPayload)('No source info returned', resourceId));
|
|
623
304
|
return undefined;
|
|
624
305
|
}
|
|
625
|
-
|
|
306
|
+
_this2.updateCacheWithSourceInfo(resourceId, sourceInfo);
|
|
626
307
|
if (sourceInfo.title) {
|
|
627
|
-
|
|
308
|
+
_this2._subscriptionManager.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
|
|
628
309
|
}
|
|
629
310
|
if (sourceInfo.title && sourceInfo.url) {
|
|
630
|
-
var
|
|
631
|
-
(
|
|
311
|
+
var _this2$fetchSourceInf2;
|
|
312
|
+
(_this2$fetchSourceInf2 = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf2 === void 0 || _this2$fetchSourceInf2.success();
|
|
632
313
|
} else {
|
|
633
|
-
var
|
|
634
|
-
(
|
|
314
|
+
var _this2$fetchSourceInf3, _this2$fireAnalyticsE2;
|
|
315
|
+
(_this2$fetchSourceInf3 = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf3 === void 0 || _this2$fetchSourceInf3.failure({
|
|
635
316
|
reason: 'Missing title or url'
|
|
636
317
|
});
|
|
637
|
-
(
|
|
318
|
+
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.getSourceInfoErrorPayload)('Missing title or url', resourceId));
|
|
638
319
|
}
|
|
639
320
|
return sourceInfo;
|
|
640
321
|
}).catch(function (error) {
|
|
641
|
-
var
|
|
642
|
-
(
|
|
322
|
+
var _this2$fetchSourceInf4, _this2$fireAnalyticsE3;
|
|
323
|
+
(_this2$fetchSourceInf4 = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf4 === void 0 || _this2$fetchSourceInf4.failure({
|
|
643
324
|
reason: error.message
|
|
644
325
|
});
|
|
645
|
-
(
|
|
326
|
+
(_this2$fireAnalyticsE3 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE3 === void 0 || _this2$fireAnalyticsE3.call(_this2, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId));
|
|
646
327
|
return undefined;
|
|
647
328
|
}).finally(function () {
|
|
648
|
-
|
|
329
|
+
_this2.syncBlockSourceInfoRequests.delete(resourceId);
|
|
649
330
|
});
|
|
650
331
|
this.syncBlockSourceInfoRequests.set(resourceId, sourceInfoPromise);
|
|
651
332
|
return sourceInfoPromise;
|
|
652
333
|
} catch (error) {
|
|
653
|
-
var _this$
|
|
334
|
+
var _this$fireAnalyticsEv3;
|
|
654
335
|
(0, _monitoring.logException)(error, {
|
|
655
336
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
656
337
|
});
|
|
657
|
-
(_this$
|
|
338
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId));
|
|
658
339
|
}
|
|
659
340
|
return Promise.resolve(undefined);
|
|
660
341
|
}
|
|
@@ -667,31 +348,31 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
667
348
|
}, {
|
|
668
349
|
key: "processPrefetchedData",
|
|
669
350
|
value: (function () {
|
|
670
|
-
var _processPrefetchedData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
351
|
+
var _processPrefetchedData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(prefetchedData) {
|
|
671
352
|
var _this$fetchExperience,
|
|
672
|
-
|
|
353
|
+
_this3 = this;
|
|
673
354
|
var prefetchedResolvedData, _this$processFetchedD, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4, _this$fetchExperience5;
|
|
674
|
-
return _regenerator.default.wrap(function
|
|
675
|
-
while (1) switch (
|
|
355
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
356
|
+
while (1) switch (_context.prev = _context.next) {
|
|
676
357
|
case 0:
|
|
677
358
|
if (prefetchedData) {
|
|
678
|
-
|
|
359
|
+
_context.next = 2;
|
|
679
360
|
break;
|
|
680
361
|
}
|
|
681
|
-
return
|
|
362
|
+
return _context.abrupt("return");
|
|
682
363
|
case 2:
|
|
683
364
|
// start the fetch experience (this should be started much earlier to properly track performance, but better late than never)
|
|
684
365
|
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.start({});
|
|
685
366
|
|
|
686
367
|
// mark the sync block requests as in fly
|
|
687
368
|
prefetchedData.resourceIds.forEach(function (resourceId) {
|
|
688
|
-
|
|
369
|
+
_this3.syncBlockFetchDataRequests.set(resourceId, true);
|
|
689
370
|
});
|
|
690
|
-
|
|
691
|
-
|
|
371
|
+
_context.prev = 4;
|
|
372
|
+
_context.next = 7;
|
|
692
373
|
return prefetchedData.prefetchPromise;
|
|
693
374
|
case 7:
|
|
694
|
-
prefetchedResolvedData =
|
|
375
|
+
prefetchedResolvedData = _context.sent;
|
|
695
376
|
_this$processFetchedD = this.processFetchedData(prefetchedResolvedData), hasUnexpectedError = _this$processFetchedD.hasUnexpectedError, hasExpectedError = _this$processFetchedD.hasExpectedError;
|
|
696
377
|
if (hasUnexpectedError) {
|
|
697
378
|
(_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 || _this$fetchExperience2.failure({
|
|
@@ -704,26 +385,26 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
704
385
|
} else {
|
|
705
386
|
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.success();
|
|
706
387
|
}
|
|
707
|
-
|
|
388
|
+
_context.next = 15;
|
|
708
389
|
break;
|
|
709
390
|
case 12:
|
|
710
|
-
|
|
711
|
-
|
|
391
|
+
_context.prev = 12;
|
|
392
|
+
_context.t0 = _context["catch"](4);
|
|
712
393
|
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.failure({
|
|
713
|
-
reason: "Prefetch promise rejected: ".concat(
|
|
394
|
+
reason: "Prefetch promise rejected: ".concat(_context.t0.message)
|
|
714
395
|
});
|
|
715
396
|
case 15:
|
|
716
|
-
|
|
717
|
-
// Clean up in-flight markers so subsequent fetches
|
|
397
|
+
_context.prev = 15;
|
|
398
|
+
// Clean up in-flight markers so subsequent fetches are not blocked
|
|
718
399
|
prefetchedData.resourceIds.forEach(function (resourceId) {
|
|
719
|
-
|
|
400
|
+
_this3.syncBlockFetchDataRequests.delete(resourceId);
|
|
720
401
|
});
|
|
721
|
-
return
|
|
402
|
+
return _context.finish(15);
|
|
722
403
|
case 18:
|
|
723
404
|
case "end":
|
|
724
|
-
return
|
|
405
|
+
return _context.stop();
|
|
725
406
|
}
|
|
726
|
-
},
|
|
407
|
+
}, _callee, this, [[4, 12, 15, 18]]);
|
|
727
408
|
}));
|
|
728
409
|
function processPrefetchedData(_x) {
|
|
729
410
|
return _processPrefetchedData.apply(this, arguments);
|
|
@@ -739,56 +420,56 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
739
420
|
}, {
|
|
740
421
|
key: "fetchSyncBlocksData",
|
|
741
422
|
value: (function () {
|
|
742
|
-
var _fetchSyncBlocksData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
743
|
-
var
|
|
423
|
+
var _fetchSyncBlocksData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockNodes) {
|
|
424
|
+
var _this4 = this,
|
|
744
425
|
_this$fetchExperience6;
|
|
745
426
|
var nodesToFetch, data, _this$processFetchedD2, hasUnexpectedError, hasExpectedError, _this$fetchExperience7, _this$fetchExperience8, _this$fetchExperience9;
|
|
746
|
-
return _regenerator.default.wrap(function
|
|
747
|
-
while (1) switch (
|
|
427
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
428
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
748
429
|
case 0:
|
|
749
430
|
if (!(syncBlockNodes.length === 0)) {
|
|
750
|
-
|
|
431
|
+
_context2.next = 2;
|
|
751
432
|
break;
|
|
752
433
|
}
|
|
753
|
-
return
|
|
434
|
+
return _context2.abrupt("return");
|
|
754
435
|
case 2:
|
|
755
436
|
// Don't fetch for not_found error since the source is already deleted
|
|
756
437
|
nodesToFetch = [];
|
|
757
438
|
syncBlockNodes.forEach(function (node) {
|
|
758
439
|
var _existingSyncBlock$er;
|
|
759
|
-
if (
|
|
440
|
+
if (_this4.syncBlockFetchDataRequests.get(node.attrs.resourceId)) {
|
|
760
441
|
return;
|
|
761
442
|
}
|
|
762
|
-
var existingSyncBlock =
|
|
443
|
+
var existingSyncBlock = _this4.getFromCache(node.attrs.resourceId);
|
|
763
444
|
if ((existingSyncBlock === null || existingSyncBlock === void 0 || (_existingSyncBlock$er = existingSyncBlock.error) === null || _existingSyncBlock$er === void 0 ? void 0 : _existingSyncBlock$er.type) === _types.SyncBlockError.NotFound) {
|
|
764
445
|
return;
|
|
765
446
|
}
|
|
766
447
|
nodesToFetch.push(node);
|
|
767
448
|
});
|
|
768
449
|
if (!(nodesToFetch.length === 0)) {
|
|
769
|
-
|
|
450
|
+
_context2.next = 6;
|
|
770
451
|
break;
|
|
771
452
|
}
|
|
772
|
-
return
|
|
453
|
+
return _context2.abrupt("return");
|
|
773
454
|
case 6:
|
|
774
455
|
if (this.dataProvider) {
|
|
775
|
-
|
|
456
|
+
_context2.next = 8;
|
|
776
457
|
break;
|
|
777
458
|
}
|
|
778
459
|
throw new Error('Data provider not set');
|
|
779
460
|
case 8:
|
|
780
461
|
nodesToFetch.forEach(function (node) {
|
|
781
|
-
|
|
462
|
+
_this4.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
782
463
|
});
|
|
783
464
|
(_this$fetchExperience6 = this.fetchExperience) === null || _this$fetchExperience6 === void 0 || _this$fetchExperience6.start({});
|
|
784
|
-
|
|
465
|
+
_context2.next = 12;
|
|
785
466
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
786
467
|
nodesToFetch.forEach(function (node) {
|
|
787
|
-
|
|
468
|
+
_this4.syncBlockFetchDataRequests.delete(node.attrs.resourceId);
|
|
788
469
|
});
|
|
789
470
|
});
|
|
790
471
|
case 12:
|
|
791
|
-
data =
|
|
472
|
+
data = _context2.sent;
|
|
792
473
|
_this$processFetchedD2 = this.processFetchedData(data), hasUnexpectedError = _this$processFetchedD2.hasUnexpectedError, hasExpectedError = _this$processFetchedD2.hasExpectedError;
|
|
793
474
|
if (hasUnexpectedError) {
|
|
794
475
|
(_this$fetchExperience7 = this.fetchExperience) === null || _this$fetchExperience7 === void 0 || _this$fetchExperience7.failure({
|
|
@@ -803,9 +484,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
803
484
|
}
|
|
804
485
|
case 15:
|
|
805
486
|
case "end":
|
|
806
|
-
return
|
|
487
|
+
return _context2.stop();
|
|
807
488
|
}
|
|
808
|
-
},
|
|
489
|
+
}, _callee2, this);
|
|
809
490
|
}));
|
|
810
491
|
function fetchSyncBlocksData(_x2) {
|
|
811
492
|
return _fetchSyncBlocksData.apply(this, arguments);
|
|
@@ -815,7 +496,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
815
496
|
}, {
|
|
816
497
|
key: "processFetchedData",
|
|
817
498
|
value: function processFetchedData(data) {
|
|
818
|
-
var
|
|
499
|
+
var _this5 = this;
|
|
819
500
|
if (!data) {
|
|
820
501
|
return {
|
|
821
502
|
hasUnexpectedError: false,
|
|
@@ -827,28 +508,28 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
827
508
|
data.forEach(function (syncBlockInstance) {
|
|
828
509
|
var _resolvedSyncBlockIns;
|
|
829
510
|
if (!syncBlockInstance.resourceId) {
|
|
830
|
-
var _syncBlockInstance$
|
|
831
|
-
var payload = ((_syncBlockInstance$
|
|
832
|
-
(
|
|
511
|
+
var _syncBlockInstance$er, _syncBlockInstance$er2, _this5$fireAnalyticsE;
|
|
512
|
+
var payload = ((_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) || 'Returned sync block instance does not have resource id';
|
|
513
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(payload));
|
|
833
514
|
return;
|
|
834
515
|
}
|
|
835
|
-
var existingSyncBlock =
|
|
516
|
+
var existingSyncBlock = _this5.getFromCache(syncBlockInstance.resourceId);
|
|
836
517
|
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
837
|
-
|
|
518
|
+
_this5.updateCache(resolvedSyncBlockInstance);
|
|
838
519
|
|
|
839
520
|
// Check if this is a newly added unpublished sync block and notify
|
|
840
521
|
// Only trigger for sync blocks that were just added (not refreshed or loaded on page init)
|
|
841
|
-
if (!syncBlockInstance.error && ((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) === null || _resolvedSyncBlockIns === void 0 ? void 0 : _resolvedSyncBlockIns.status) === 'unpublished' &&
|
|
522
|
+
if (!syncBlockInstance.error && ((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) === null || _resolvedSyncBlockIns === void 0 ? void 0 : _resolvedSyncBlockIns.status) === 'unpublished' && _this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId) && _this5.onUnpublishedSyncBlockDetected) {
|
|
842
523
|
// Remove from newly added set after checking to prevent duplicate flags
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
} else if (
|
|
524
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
525
|
+
_this5.onUnpublishedSyncBlockDetected(resolvedSyncBlockInstance.resourceId);
|
|
526
|
+
} else if (_this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId)) {
|
|
846
527
|
// Remove from newly added set even if not unpublished (to clean up)
|
|
847
|
-
|
|
528
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
848
529
|
}
|
|
849
530
|
if (syncBlockInstance.error) {
|
|
850
|
-
var
|
|
851
|
-
(
|
|
531
|
+
var _this5$fireAnalyticsE2;
|
|
532
|
+
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
852
533
|
if (syncBlockInstance.error.type === _types.SyncBlockError.NotFound || syncBlockInstance.error.type === _types.SyncBlockError.Forbidden) {
|
|
853
534
|
hasExpectedError = true;
|
|
854
535
|
} else if (syncBlockInstance.error) {
|
|
@@ -856,13 +537,13 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
856
537
|
}
|
|
857
538
|
return;
|
|
858
539
|
}
|
|
859
|
-
var callbacks =
|
|
540
|
+
var callbacks = _this5._subscriptionManager.getSubscriptions().get(syncBlockInstance.resourceId);
|
|
860
541
|
var localIds = callbacks ? Object.keys(callbacks) : [];
|
|
861
542
|
localIds.forEach(function (localId) {
|
|
862
|
-
var
|
|
863
|
-
(
|
|
543
|
+
var _this5$fireAnalyticsE3, _syncBlockInstance$da;
|
|
544
|
+
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.product));
|
|
864
545
|
});
|
|
865
|
-
|
|
546
|
+
_this5.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
866
547
|
});
|
|
867
548
|
return {
|
|
868
549
|
hasUnexpectedError: hasUnexpectedError,
|
|
@@ -889,182 +570,54 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
889
570
|
value: function updateCache(syncBlock) {
|
|
890
571
|
var resourceId = syncBlock.resourceId;
|
|
891
572
|
if (resourceId) {
|
|
892
|
-
var _this$
|
|
893
|
-
(_this$
|
|
573
|
+
var _this$dataProvider3;
|
|
574
|
+
(_this$dataProvider3 = this.dataProvider) === null || _this$dataProvider3 === void 0 || _this$dataProvider3.updateCache((0, _defineProperty2.default)({}, resourceId, syncBlock), {
|
|
894
575
|
strategy: 'merge',
|
|
895
576
|
source: 'network'
|
|
896
577
|
});
|
|
897
|
-
|
|
898
|
-
if (callbacks) {
|
|
899
|
-
Object.values(callbacks).forEach(function (callback) {
|
|
900
|
-
callback(syncBlock);
|
|
901
|
-
});
|
|
902
|
-
}
|
|
578
|
+
this._subscriptionManager.notifySubscriptionCallbacks(resourceId, syncBlock);
|
|
903
579
|
this.updateSessionCache(resourceId);
|
|
904
580
|
}
|
|
905
581
|
}
|
|
906
|
-
}, {
|
|
907
|
-
key: "updateSourceTitleSubscriptions",
|
|
908
|
-
value: function updateSourceTitleSubscriptions(resourceId, title) {
|
|
909
|
-
var callbacks = this.titleSubscriptions.get(resourceId);
|
|
910
|
-
if (callbacks) {
|
|
911
|
-
Object.values(callbacks).forEach(function (callback) {
|
|
912
|
-
callback(title);
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
582
|
}, {
|
|
917
583
|
key: "getFromCache",
|
|
918
584
|
value: function getFromCache(resourceId) {
|
|
919
|
-
var _this$
|
|
585
|
+
var _this$dataProvider4;
|
|
920
586
|
var syncBlockNode = (0, _utils.createSyncBlockNode)('', resourceId);
|
|
921
|
-
return (_this$
|
|
587
|
+
return (_this$dataProvider4 = this.dataProvider) === null || _this$dataProvider4 === void 0 || (_this$dataProvider4 = _this$dataProvider4.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider4 === void 0 ? void 0 : _this$dataProvider4.data;
|
|
922
588
|
}
|
|
923
589
|
}, {
|
|
924
590
|
key: "deleteFromCache",
|
|
925
591
|
value: function deleteFromCache(resourceId) {
|
|
926
|
-
var _this$
|
|
927
|
-
(_this$
|
|
928
|
-
|
|
929
|
-
this._providerFactoryManager.deleteFactory(resourceId);
|
|
930
|
-
} else {
|
|
931
|
-
this.providerFactories.delete(resourceId);
|
|
932
|
-
}
|
|
592
|
+
var _this$dataProvider5;
|
|
593
|
+
(_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 || _this$dataProvider5.removeFromCache([resourceId]);
|
|
594
|
+
this._providerFactoryManager.deleteFactory(resourceId);
|
|
933
595
|
}
|
|
934
596
|
}, {
|
|
935
597
|
key: "debouncedBatchedFetchSyncBlocks",
|
|
936
598
|
value: function debouncedBatchedFetchSyncBlocks(resourceId) {
|
|
937
|
-
|
|
938
|
-
this._batchFetcher.queueFetch(resourceId);
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
// Only add to pending requests if there are active subscriptions for this resource
|
|
942
|
-
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
943
|
-
this.pendingFetchRequests.add(resourceId);
|
|
944
|
-
this.scheduledBatchFetch();
|
|
945
|
-
} else {
|
|
946
|
-
this.pendingFetchRequests.delete(resourceId);
|
|
947
|
-
}
|
|
599
|
+
this._batchFetcher.queueFetch(resourceId);
|
|
948
600
|
}
|
|
949
601
|
}, {
|
|
950
602
|
key: "setSSRDataInSessionCache",
|
|
951
603
|
value: function setSSRDataInSessionCache(resourceIds) {
|
|
952
|
-
var
|
|
604
|
+
var _this6 = this;
|
|
953
605
|
if (!resourceIds || resourceIds.length === 0) {
|
|
954
606
|
return;
|
|
955
607
|
}
|
|
956
608
|
resourceIds.forEach(function (resourceId) {
|
|
957
|
-
|
|
609
|
+
_this6.updateSessionCache(resourceId);
|
|
958
610
|
});
|
|
959
611
|
}
|
|
960
612
|
}, {
|
|
961
613
|
key: "subscribeToSyncBlock",
|
|
962
614
|
value: function subscribeToSyncBlock(resourceId, localId, callback) {
|
|
963
|
-
|
|
964
|
-
_this1 = this;
|
|
965
|
-
// Cancel any pending cache deletion for this resourceId.
|
|
966
|
-
// This handles the case where a block is moved - the old component unmounts
|
|
967
|
-
// (scheduling deletion) but the new component mounts and subscribes before
|
|
968
|
-
// the deletion timeout fires.
|
|
969
|
-
var pendingDeletion = this.pendingCacheDeletions.get(resourceId);
|
|
970
|
-
if (pendingDeletion) {
|
|
971
|
-
clearTimeout(pendingDeletion);
|
|
972
|
-
this.pendingCacheDeletions.delete(resourceId);
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
// add to subscriptions map
|
|
976
|
-
var resourceSubscriptions = this.subscriptions.get(resourceId) || {};
|
|
977
|
-
var isNewResourceSubscription = Object.keys(resourceSubscriptions).length === 0;
|
|
978
|
-
this.subscriptions.set(resourceId, _objectSpread(_objectSpread({}, resourceSubscriptions), {}, (0, _defineProperty2.default)({}, localId, callback)));
|
|
979
|
-
|
|
980
|
-
// New subscription means new reference synced block is added to the document
|
|
981
|
-
this.isCacheDirty = true;
|
|
982
|
-
|
|
983
|
-
// Notify listeners if this is a new resource subscription
|
|
984
|
-
if (isNewResourceSubscription) {
|
|
985
|
-
this.notifySubscriptionChangeListeners();
|
|
986
|
-
}
|
|
987
|
-
var syncBlockNode = (0, _utils.createSyncBlockNode)(localId, resourceId);
|
|
988
|
-
var cachedData = (_this$dataProvider7 = this.dataProvider) === null || _this$dataProvider7 === void 0 || (_this$dataProvider7 = _this$dataProvider7.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider7 === void 0 ? void 0 : _this$dataProvider7.data;
|
|
989
|
-
if (cachedData) {
|
|
990
|
-
callback(cachedData);
|
|
991
|
-
} else {
|
|
992
|
-
this.debouncedBatchedFetchSyncBlocks(resourceId);
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
// Set up GraphQL subscription if real-time subscriptions are enabled
|
|
996
|
-
var useRealTime = this._subscriptionManager && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? this._subscriptionManager.shouldUseRealTime() : this.useRealTimeSubscriptions;
|
|
997
|
-
if (useRealTime) {
|
|
998
|
-
this.setupGraphQLSubscription(resourceId);
|
|
999
|
-
}
|
|
1000
|
-
return function () {
|
|
1001
|
-
var resourceSubscriptions = _this1.subscriptions.get(resourceId);
|
|
1002
|
-
if (resourceSubscriptions) {
|
|
1003
|
-
// Unsubscription means a reference synced block is removed from the document
|
|
1004
|
-
_this1.isCacheDirty = true;
|
|
1005
|
-
delete resourceSubscriptions[localId];
|
|
1006
|
-
if (Object.keys(resourceSubscriptions).length === 0) {
|
|
1007
|
-
_this1.subscriptions.delete(resourceId);
|
|
1008
|
-
|
|
1009
|
-
// Clean up GraphQL subscription when no more local subscribers
|
|
1010
|
-
_this1.cleanupGraphQLSubscription(resourceId);
|
|
1011
|
-
|
|
1012
|
-
// Notify listeners that subscription was removed
|
|
1013
|
-
_this1.notifySubscriptionChangeListeners();
|
|
1014
|
-
|
|
1015
|
-
// Delay cache deletion to handle block moves (unmount/remount).
|
|
1016
|
-
// When a block is moved, the old component unmounts before the new one mounts.
|
|
1017
|
-
// By delaying deletion, we give the new component time to subscribe and
|
|
1018
|
-
// cancel this pending deletion, preserving the cached data.
|
|
1019
|
-
// TODO: EDITOR-4152 - Rework this logic
|
|
1020
|
-
var deletionTimeout = setTimeout(function () {
|
|
1021
|
-
// Only delete if still no subscribers (wasn't re-subscribed)
|
|
1022
|
-
if (!_this1.subscriptions.has(resourceId)) {
|
|
1023
|
-
_this1.deleteFromCache(resourceId);
|
|
1024
|
-
}
|
|
1025
|
-
_this1.pendingCacheDeletions.delete(resourceId);
|
|
1026
|
-
}, 1000);
|
|
1027
|
-
_this1.pendingCacheDeletions.set(resourceId, deletionTimeout);
|
|
1028
|
-
} else {
|
|
1029
|
-
_this1.subscriptions.set(resourceId, resourceSubscriptions);
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
};
|
|
615
|
+
return this._subscriptionManager.subscribeToSyncBlock(resourceId, localId, callback);
|
|
1033
616
|
}
|
|
1034
617
|
}, {
|
|
1035
618
|
key: "subscribeToSourceTitle",
|
|
1036
619
|
value: function subscribeToSourceTitle(node, callback) {
|
|
1037
|
-
|
|
1038
|
-
_this10 = this;
|
|
1039
|
-
// check node is a sync block, as we only support sync block subscriptions
|
|
1040
|
-
if (node.type.name !== 'syncBlock') {
|
|
1041
|
-
return function () {};
|
|
1042
|
-
}
|
|
1043
|
-
var _node$attrs = node.attrs,
|
|
1044
|
-
resourceId = _node$attrs.resourceId,
|
|
1045
|
-
localId = _node$attrs.localId;
|
|
1046
|
-
if (!localId || !resourceId) {
|
|
1047
|
-
return function () {};
|
|
1048
|
-
}
|
|
1049
|
-
var cachedData = this.getFromCache(resourceId);
|
|
1050
|
-
if (cachedData !== null && cachedData !== void 0 && (_cachedData$data = cachedData.data) !== null && _cachedData$data !== void 0 && _cachedData$data.sourceTitle) {
|
|
1051
|
-
callback(cachedData.data.sourceTitle);
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
// add to subscriptions map
|
|
1055
|
-
var resourceSubscriptions = this.titleSubscriptions.get(resourceId) || {};
|
|
1056
|
-
this.titleSubscriptions.set(resourceId, _objectSpread(_objectSpread({}, resourceSubscriptions), {}, (0, _defineProperty2.default)({}, localId, callback)));
|
|
1057
|
-
return function () {
|
|
1058
|
-
var resourceSubscriptions = _this10.titleSubscriptions.get(resourceId);
|
|
1059
|
-
if (resourceSubscriptions) {
|
|
1060
|
-
delete resourceSubscriptions[localId];
|
|
1061
|
-
if (Object.keys(resourceSubscriptions).length === 0) {
|
|
1062
|
-
_this10.titleSubscriptions.delete(resourceId);
|
|
1063
|
-
} else {
|
|
1064
|
-
_this10.titleSubscriptions.set(resourceId, resourceSubscriptions);
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
620
|
+
return this._subscriptionManager.subscribeToSourceTitle(node, callback);
|
|
1068
621
|
}
|
|
1069
622
|
}, {
|
|
1070
623
|
key: "subscribe",
|
|
@@ -1074,19 +627,19 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1074
627
|
if (node.type.name !== 'syncBlock') {
|
|
1075
628
|
throw new Error('Only sync block node subscriptions are supported');
|
|
1076
629
|
}
|
|
1077
|
-
var _node$
|
|
1078
|
-
resourceId = _node$
|
|
1079
|
-
localId = _node$
|
|
630
|
+
var _node$attrs = node.attrs,
|
|
631
|
+
resourceId = _node$attrs.resourceId,
|
|
632
|
+
localId = _node$attrs.localId;
|
|
1080
633
|
if (!localId || !resourceId) {
|
|
1081
634
|
throw new Error('Missing local id or resource id');
|
|
1082
635
|
}
|
|
1083
|
-
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
636
|
+
return this._subscriptionManager.subscribeToSyncBlock(resourceId, localId, callback);
|
|
1084
637
|
} catch (error) {
|
|
1085
|
-
var _this$
|
|
638
|
+
var _this$fireAnalyticsEv4;
|
|
1086
639
|
(0, _monitoring.logException)(error, {
|
|
1087
640
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
1088
641
|
});
|
|
1089
|
-
(_this$
|
|
642
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
1090
643
|
return function () {};
|
|
1091
644
|
}
|
|
1092
645
|
}
|
|
@@ -1109,148 +662,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1109
662
|
}, {
|
|
1110
663
|
key: "getProviderFactory",
|
|
1111
664
|
value: function getProviderFactory(resourceId) {
|
|
1112
|
-
|
|
1113
|
-
return this._providerFactoryManager.getProviderFactory(resourceId);
|
|
1114
|
-
}
|
|
1115
|
-
if (!this.dataProvider) {
|
|
1116
|
-
var _this$fireAnalyticsEv8;
|
|
1117
|
-
var error = new Error('Data provider not set');
|
|
1118
|
-
(0, _monitoring.logException)(error, {
|
|
1119
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
1120
|
-
});
|
|
1121
|
-
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
1122
|
-
return undefined;
|
|
1123
|
-
}
|
|
1124
|
-
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
1125
|
-
parentDataProviders = _this$dataProvider$ge.parentDataProviders,
|
|
1126
|
-
providerCreator = _this$dataProvider$ge.providerCreator;
|
|
1127
|
-
var providerFactory = this.providerFactories.get(resourceId);
|
|
1128
|
-
if (!providerFactory) {
|
|
1129
|
-
providerFactory = _providerFactory.ProviderFactory.create({
|
|
1130
|
-
mentionProvider: parentDataProviders === null || parentDataProviders === void 0 ? void 0 : parentDataProviders.mentionProvider,
|
|
1131
|
-
profilecardProvider: parentDataProviders === null || parentDataProviders === void 0 ? void 0 : parentDataProviders.profilecardProvider,
|
|
1132
|
-
taskDecisionProvider: parentDataProviders === null || parentDataProviders === void 0 ? void 0 : parentDataProviders.taskDecisionProvider
|
|
1133
|
-
});
|
|
1134
|
-
this.providerFactories.set(resourceId, providerFactory);
|
|
1135
|
-
} else {
|
|
1136
|
-
if (parentDataProviders !== null && parentDataProviders !== void 0 && parentDataProviders.mentionProvider) {
|
|
1137
|
-
providerFactory.setProvider('mentionProvider', parentDataProviders === null || parentDataProviders === void 0 ? void 0 : parentDataProviders.mentionProvider);
|
|
1138
|
-
}
|
|
1139
|
-
if (parentDataProviders !== null && parentDataProviders !== void 0 && parentDataProviders.profilecardProvider) {
|
|
1140
|
-
providerFactory.setProvider('profilecardProvider', parentDataProviders === null || parentDataProviders === void 0 ? void 0 : parentDataProviders.profilecardProvider);
|
|
1141
|
-
}
|
|
1142
|
-
if (parentDataProviders !== null && parentDataProviders !== void 0 && parentDataProviders.taskDecisionProvider) {
|
|
1143
|
-
providerFactory.setProvider('taskDecisionProvider', parentDataProviders === null || parentDataProviders === void 0 ? void 0 : parentDataProviders.taskDecisionProvider);
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
if (providerCreator) {
|
|
1147
|
-
try {
|
|
1148
|
-
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
1149
|
-
} catch (error) {
|
|
1150
|
-
var _this$fireAnalyticsEv9;
|
|
1151
|
-
(0, _monitoring.logException)(error, {
|
|
1152
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
1153
|
-
});
|
|
1154
|
-
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, (0, _errorHandling.fetchErrorPayload)(error.message, resourceId));
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
return providerFactory;
|
|
665
|
+
return this._providerFactoryManager.getProviderFactory(resourceId);
|
|
1158
666
|
}
|
|
1159
667
|
}, {
|
|
1160
668
|
key: "getSSRProviders",
|
|
1161
669
|
value: function getSSRProviders(resourceId) {
|
|
1162
|
-
|
|
1163
|
-
return this._providerFactoryManager.getSSRProviders(resourceId);
|
|
1164
|
-
}
|
|
1165
|
-
if (!this.dataProvider) {
|
|
1166
|
-
return null;
|
|
1167
|
-
}
|
|
1168
|
-
var _this$dataProvider$ge2 = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
1169
|
-
providerCreator = _this$dataProvider$ge2.providerCreator;
|
|
1170
|
-
if (!(providerCreator !== null && providerCreator !== void 0 && providerCreator.createSSRMediaProvider)) {
|
|
1171
|
-
return null;
|
|
1172
|
-
}
|
|
1173
|
-
var parsedResourceId = (0, _resourceId.parseResourceId)(resourceId);
|
|
1174
|
-
if (!parsedResourceId) {
|
|
1175
|
-
return null;
|
|
1176
|
-
}
|
|
1177
|
-
var contentId = parsedResourceId.contentId,
|
|
1178
|
-
contentProduct = parsedResourceId.product;
|
|
1179
|
-
try {
|
|
1180
|
-
var mediaProvider = providerCreator.createSSRMediaProvider({
|
|
1181
|
-
contentId: contentId,
|
|
1182
|
-
contentProduct: contentProduct
|
|
1183
|
-
});
|
|
1184
|
-
if (mediaProvider) {
|
|
1185
|
-
return {
|
|
1186
|
-
media: mediaProvider
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
} catch (error) {
|
|
1190
|
-
(0, _monitoring.logException)(error, {
|
|
1191
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
|
-
return null;
|
|
1195
|
-
}
|
|
1196
|
-
}, {
|
|
1197
|
-
key: "retrieveDynamicProviders",
|
|
1198
|
-
value: function retrieveDynamicProviders(resourceId, providerFactory, providerCreator) {
|
|
1199
|
-
var _syncBlock$data2, _syncBlock$data3;
|
|
1200
|
-
if (!this.dataProvider) {
|
|
1201
|
-
throw new Error('Data provider not set');
|
|
1202
|
-
}
|
|
1203
|
-
var hasMediaProvider = providerFactory.hasProvider('mediaProvider');
|
|
1204
|
-
var hasEmojiProvider = providerFactory.hasProvider('emojiProvider');
|
|
1205
|
-
var hasCardProvider = providerFactory.hasProvider('cardProvider');
|
|
1206
|
-
if (hasMediaProvider && hasEmojiProvider && hasCardProvider) {
|
|
1207
|
-
return;
|
|
1208
|
-
}
|
|
1209
|
-
var syncBlock = this.getFromCache(resourceId);
|
|
1210
|
-
if (!(syncBlock !== null && syncBlock !== void 0 && syncBlock.data)) {
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
|
-
if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
|
|
1214
|
-
var _this$fireAnalyticsEv0;
|
|
1215
|
-
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, (0, _errorHandling.fetchErrorPayload)('Sync block source ari or product not found'));
|
|
1216
|
-
return;
|
|
1217
|
-
}
|
|
1218
|
-
var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data2 = syncBlock.data) === null || _syncBlock$data2 === void 0 ? void 0 : _syncBlock$data2.sourceAri, (_syncBlock$data3 = syncBlock.data) === null || _syncBlock$data3 === void 0 ? void 0 : _syncBlock$data3.product);
|
|
1219
|
-
if (!parentInfo) {
|
|
1220
|
-
throw new Error('Unable to retrieve sync block parent info');
|
|
1221
|
-
}
|
|
1222
|
-
var contentId = parentInfo.contentId,
|
|
1223
|
-
contentProduct = parentInfo.contentProduct;
|
|
1224
|
-
if (!hasMediaProvider) {
|
|
1225
|
-
if (providerCreator.createMediaProvider && contentId && contentProduct) {
|
|
1226
|
-
var mediaProvider = providerCreator.createMediaProvider({
|
|
1227
|
-
contentProduct: contentProduct,
|
|
1228
|
-
contentId: contentId
|
|
1229
|
-
});
|
|
1230
|
-
if (mediaProvider) {
|
|
1231
|
-
providerFactory.setProvider('mediaProvider', mediaProvider);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
if (!hasEmojiProvider) {
|
|
1236
|
-
if (providerCreator.createEmojiProvider && contentId && contentProduct) {
|
|
1237
|
-
var emojiProvider = providerCreator.createEmojiProvider({
|
|
1238
|
-
contentProduct: contentProduct,
|
|
1239
|
-
contentId: contentId
|
|
1240
|
-
});
|
|
1241
|
-
if (emojiProvider) {
|
|
1242
|
-
providerFactory.setProvider('emojiProvider', emojiProvider);
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
if (!hasCardProvider) {
|
|
1247
|
-
if (providerCreator.createSmartLinkProvider) {
|
|
1248
|
-
var smartLinkProvider = providerCreator.createSmartLinkProvider();
|
|
1249
|
-
if (smartLinkProvider) {
|
|
1250
|
-
providerFactory.setProvider('cardProvider', smartLinkProvider);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
670
|
+
return this._providerFactoryManager.getSSRProviders(resourceId);
|
|
1254
671
|
}
|
|
1255
672
|
|
|
1256
673
|
/**
|
|
@@ -1261,49 +678,49 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1261
678
|
}, {
|
|
1262
679
|
key: "flush",
|
|
1263
680
|
value: (function () {
|
|
1264
|
-
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1265
|
-
var
|
|
1266
|
-
var success, syncedBlocksToFlush, _this$saveExperience, blocks,
|
|
1267
|
-
return _regenerator.default.wrap(function
|
|
1268
|
-
while (1) switch (
|
|
681
|
+
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
682
|
+
var _this7 = this;
|
|
683
|
+
var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv5, _this$saveExperience3, _this$fireAnalyticsEv6, _this$saveExperience4;
|
|
684
|
+
return _regenerator.default.wrap(function _callee3$(_context4) {
|
|
685
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1269
686
|
case 0:
|
|
1270
687
|
if (this.isCacheDirty) {
|
|
1271
|
-
|
|
688
|
+
_context4.next = 2;
|
|
1272
689
|
break;
|
|
1273
690
|
}
|
|
1274
|
-
return
|
|
691
|
+
return _context4.abrupt("return", true);
|
|
1275
692
|
case 2:
|
|
1276
693
|
if (!this.isFlushInProgress) {
|
|
1277
|
-
|
|
694
|
+
_context4.next = 7;
|
|
1278
695
|
break;
|
|
1279
696
|
}
|
|
1280
697
|
// Mark that another flush is needed after the current one completes
|
|
1281
698
|
this.flushNeededAfterCurrent = true;
|
|
1282
699
|
|
|
1283
700
|
// We return true here because we know the pending flush will handle the dirty cache
|
|
1284
|
-
return
|
|
701
|
+
return _context4.abrupt("return", true);
|
|
1285
702
|
case 7:
|
|
1286
703
|
this.isFlushInProgress = true;
|
|
1287
704
|
case 8:
|
|
1288
705
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
1289
706
|
// To be saved as the last flushed structure if the flush is successful
|
|
1290
707
|
syncedBlocksToFlush = {};
|
|
1291
|
-
|
|
708
|
+
_context4.prev = 10;
|
|
1292
709
|
if (this.dataProvider) {
|
|
1293
|
-
|
|
710
|
+
_context4.next = 13;
|
|
1294
711
|
break;
|
|
1295
712
|
}
|
|
1296
713
|
throw new Error('Data provider not set');
|
|
1297
714
|
case 13:
|
|
1298
715
|
blocks = []; // First, build the complete subscription structure
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
var
|
|
1303
|
-
return _regenerator.default.wrap(function
|
|
1304
|
-
while (1) switch (
|
|
716
|
+
_iterator = _createForOfIteratorHelper(this._subscriptionManager.getSubscriptions().entries());
|
|
717
|
+
_context4.prev = 15;
|
|
718
|
+
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
719
|
+
var _step$value, resourceId, callbacks;
|
|
720
|
+
return _regenerator.default.wrap(function _loop$(_context3) {
|
|
721
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1305
722
|
case 0:
|
|
1306
|
-
|
|
723
|
+
_step$value = (0, _slicedToArray2.default)(_step.value, 2), resourceId = _step$value[0], callbacks = _step$value[1];
|
|
1307
724
|
syncedBlocksToFlush[resourceId] = {};
|
|
1308
725
|
Object.keys(callbacks).forEach(function (localId) {
|
|
1309
726
|
blocks.push({
|
|
@@ -1314,38 +731,38 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1314
731
|
});
|
|
1315
732
|
case 3:
|
|
1316
733
|
case "end":
|
|
1317
|
-
return
|
|
734
|
+
return _context3.stop();
|
|
1318
735
|
}
|
|
1319
|
-
},
|
|
736
|
+
}, _loop);
|
|
1320
737
|
});
|
|
1321
|
-
|
|
738
|
+
_iterator.s();
|
|
1322
739
|
case 18:
|
|
1323
|
-
if ((
|
|
1324
|
-
|
|
740
|
+
if ((_step = _iterator.n()).done) {
|
|
741
|
+
_context4.next = 22;
|
|
1325
742
|
break;
|
|
1326
743
|
}
|
|
1327
|
-
return
|
|
744
|
+
return _context4.delegateYield(_loop(), "t0", 20);
|
|
1328
745
|
case 20:
|
|
1329
|
-
|
|
746
|
+
_context4.next = 18;
|
|
1330
747
|
break;
|
|
1331
748
|
case 22:
|
|
1332
|
-
|
|
749
|
+
_context4.next = 27;
|
|
1333
750
|
break;
|
|
1334
751
|
case 24:
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
752
|
+
_context4.prev = 24;
|
|
753
|
+
_context4.t1 = _context4["catch"](15);
|
|
754
|
+
_iterator.e(_context4.t1);
|
|
1338
755
|
case 27:
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
return
|
|
756
|
+
_context4.prev = 27;
|
|
757
|
+
_iterator.f();
|
|
758
|
+
return _context4.finish(27);
|
|
1342
759
|
case 30:
|
|
1343
760
|
if (!(0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
1344
|
-
|
|
761
|
+
_context4.next = 33;
|
|
1345
762
|
break;
|
|
1346
763
|
}
|
|
1347
764
|
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
1348
|
-
return
|
|
765
|
+
return _context4.abrupt("return", true);
|
|
1349
766
|
case 33:
|
|
1350
767
|
// reset isCacheDirty early to prevent race condition
|
|
1351
768
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
@@ -1354,32 +771,32 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1354
771
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
1355
772
|
this.isCacheDirty = false;
|
|
1356
773
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
1357
|
-
|
|
774
|
+
_context4.next = 37;
|
|
1358
775
|
return this.dataProvider.updateReferenceData(blocks);
|
|
1359
776
|
case 37:
|
|
1360
|
-
updateResult =
|
|
777
|
+
updateResult = _context4.sent;
|
|
1361
778
|
if (!updateResult.success) {
|
|
1362
779
|
success = false;
|
|
1363
780
|
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.failure({
|
|
1364
781
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1365
782
|
});
|
|
1366
|
-
(_this$
|
|
783
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1367
784
|
}
|
|
1368
|
-
|
|
785
|
+
_context4.next = 47;
|
|
1369
786
|
break;
|
|
1370
787
|
case 41:
|
|
1371
|
-
|
|
1372
|
-
|
|
788
|
+
_context4.prev = 41;
|
|
789
|
+
_context4.t2 = _context4["catch"](10);
|
|
1373
790
|
success = false;
|
|
1374
|
-
(0, _monitoring.logException)(
|
|
791
|
+
(0, _monitoring.logException)(_context4.t2, {
|
|
1375
792
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
1376
793
|
});
|
|
1377
794
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure({
|
|
1378
|
-
reason:
|
|
795
|
+
reason: _context4.t2.message
|
|
1379
796
|
});
|
|
1380
|
-
(_this$
|
|
797
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context4.t2.message));
|
|
1381
798
|
case 47:
|
|
1382
|
-
|
|
799
|
+
_context4.prev = 47;
|
|
1383
800
|
if (!success) {
|
|
1384
801
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1385
802
|
this.isCacheDirty = true;
|
|
@@ -1397,18 +814,18 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1397
814
|
// Use setTimeout to avoid deep recursion and run queued flush asynchronously
|
|
1398
815
|
// Note: flush() handles all exceptions internally and never rejects
|
|
1399
816
|
this.queuedFlushTimeout = setTimeout(function () {
|
|
1400
|
-
|
|
1401
|
-
void
|
|
817
|
+
_this7.queuedFlushTimeout = undefined;
|
|
818
|
+
void _this7.flush();
|
|
1402
819
|
}, 0);
|
|
1403
820
|
}
|
|
1404
|
-
return
|
|
821
|
+
return _context4.finish(47);
|
|
1405
822
|
case 52:
|
|
1406
|
-
return
|
|
823
|
+
return _context4.abrupt("return", success);
|
|
1407
824
|
case 53:
|
|
1408
825
|
case "end":
|
|
1409
|
-
return
|
|
826
|
+
return _context4.stop();
|
|
1410
827
|
}
|
|
1411
|
-
},
|
|
828
|
+
}, _callee3, this, [[10, 41, 47, 52], [15, 24, 27, 30]]);
|
|
1412
829
|
}));
|
|
1413
830
|
function flush() {
|
|
1414
831
|
return _flush.apply(this, arguments);
|
|
@@ -1418,36 +835,19 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1418
835
|
}, {
|
|
1419
836
|
key: "destroy",
|
|
1420
837
|
value: function destroy() {
|
|
1421
|
-
var _this$
|
|
838
|
+
var _this$dataProvider6, _this$saveExperience5, _this$fetchExperience0, _this$fetchSourceInfo2;
|
|
1422
839
|
// Cancel any queued flush to prevent it from running after destroy
|
|
1423
840
|
if (this.queuedFlushTimeout) {
|
|
1424
841
|
clearTimeout(this.queuedFlushTimeout);
|
|
1425
842
|
this.queuedFlushTimeout = undefined;
|
|
1426
843
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
(_this$_batchFetcher = this._batchFetcher) === null || _this$_batchFetcher === void 0 || _this$_batchFetcher.destroy();
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
// Clean up all GraphQL subscriptions first
|
|
1435
|
-
this.cleanupAllGraphQLSubscriptions();
|
|
1436
|
-
(_this$dataProvider8 = this.dataProvider) === null || _this$dataProvider8 === void 0 || _this$dataProvider8.resetCache();
|
|
1437
|
-
this.scheduledBatchFetch.cancel();
|
|
1438
|
-
this.pendingFetchRequests.clear();
|
|
844
|
+
this._subscriptionManager.destroy();
|
|
845
|
+
this._providerFactoryManager.destroy();
|
|
846
|
+
this._batchFetcher.destroy();
|
|
847
|
+
(_this$dataProvider6 = this.dataProvider) === null || _this$dataProvider6 === void 0 || _this$dataProvider6.resetCache();
|
|
1439
848
|
this.dataProvider = undefined;
|
|
1440
|
-
this.subscriptions.clear();
|
|
1441
|
-
this.titleSubscriptions.clear();
|
|
1442
849
|
this.syncBlockFetchDataRequests.clear();
|
|
1443
850
|
this.syncBlockSourceInfoRequests.clear();
|
|
1444
|
-
this.isRefreshingSubscriptions = false;
|
|
1445
|
-
this.useRealTimeSubscriptions = false;
|
|
1446
|
-
this.subscriptionChangeListeners.clear();
|
|
1447
|
-
this.providerFactories.forEach(function (providerFactory) {
|
|
1448
|
-
providerFactory.destroy();
|
|
1449
|
-
});
|
|
1450
|
-
this.providerFactories.clear();
|
|
1451
851
|
(_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 || _this$saveExperience5.abort({
|
|
1452
852
|
reason: 'editorDestroyed'
|
|
1453
853
|
});
|
|
@@ -1458,9 +858,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1458
858
|
reason: 'editorDestroyed'
|
|
1459
859
|
});
|
|
1460
860
|
this.fireAnalyticsEvent = undefined;
|
|
1461
|
-
|
|
1462
|
-
_syncBlockInMemorySessionCache.syncBlockInMemorySessionCache.clear();
|
|
1463
|
-
}
|
|
861
|
+
_syncBlockInMemorySessionCache.syncBlockInMemorySessionCache.clear();
|
|
1464
862
|
}
|
|
1465
863
|
}]);
|
|
1466
864
|
}();
|