@atlaskit/editor-synced-block-provider 2.10.6 → 2.11.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 +20 -0
- package/dist/cjs/clients/block-service/blockService.js +5 -4
- package/dist/cjs/clients/confluence/sourceInfo.js +18 -15
- package/dist/cjs/hooks/useFetchSyncBlockData.js +20 -11
- package/dist/cjs/hooks/useHandleContentChanges.js +1 -5
- package/dist/cjs/providers/block-service/blockServiceAPI.js +17 -12
- package/dist/cjs/providers/syncBlockProvider.js +4 -4
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +118 -66
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +112 -55
- package/dist/cjs/store-manager/syncBlockStoreManager.js +3 -3
- package/dist/cjs/utils/errorHandling.js +31 -1
- package/dist/es2019/clients/block-service/blockService.js +5 -4
- package/dist/es2019/clients/confluence/sourceInfo.js +13 -8
- package/dist/es2019/hooks/useFetchSyncBlockData.js +15 -7
- package/dist/es2019/hooks/useHandleContentChanges.js +1 -5
- package/dist/es2019/providers/block-service/blockServiceAPI.js +13 -8
- package/dist/es2019/providers/syncBlockProvider.js +4 -4
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +105 -51
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +73 -25
- package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -3
- package/dist/es2019/utils/errorHandling.js +17 -1
- package/dist/esm/clients/block-service/blockService.js +5 -4
- package/dist/esm/clients/confluence/sourceInfo.js +18 -15
- package/dist/esm/hooks/useFetchSyncBlockData.js +20 -11
- package/dist/esm/hooks/useHandleContentChanges.js +1 -5
- package/dist/esm/providers/block-service/blockServiceAPI.js +17 -12
- package/dist/esm/providers/syncBlockProvider.js +4 -4
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +118 -66
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +110 -53
- package/dist/esm/store-manager/syncBlockStoreManager.js +3 -3
- package/dist/esm/utils/errorHandling.js +30 -0
- package/dist/types/clients/block-service/blockService.d.ts +0 -2
- package/dist/types/clients/confluence/sourceInfo.d.ts +2 -1
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +2 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +6 -3
- package/dist/types/providers/syncBlockProvider.d.ts +2 -1
- package/dist/types/providers/types.d.ts +2 -1
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +4 -1
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +3 -1
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +2 -1
- package/dist/types/utils/errorHandling.d.ts +10 -0
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +0 -2
- package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +2 -1
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +2 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +6 -3
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -1
- package/dist/types-ts4.5/providers/types.d.ts +2 -1
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +4 -1
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +3 -1
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +2 -1
- package/dist/types-ts4.5/utils/errorHandling.d.ts +10 -0
- package/package.json +2 -8
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
export var useHandleContentChanges = function useHandleContentChanges(manager, syncBlockNode) {
|
|
3
3
|
useEffect(function () {
|
|
4
|
-
|
|
5
|
-
manager.sourceManager.updateSyncBlockData(syncBlockNode);
|
|
6
|
-
} catch (_unused) {
|
|
7
|
-
//TODO: EDITOR-1921 - add error analytics
|
|
8
|
-
}
|
|
4
|
+
manager.sourceManager.updateSyncBlockData(syncBlockNode);
|
|
9
5
|
}, [manager, syncBlockNode]);
|
|
10
6
|
};
|
|
@@ -95,13 +95,16 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
95
95
|
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
96
96
|
*/
|
|
97
97
|
var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
98
|
-
function BlockServiceADFWriteProvider() {
|
|
98
|
+
function BlockServiceADFWriteProvider(sourceAri, product) {
|
|
99
99
|
_classCallCheck(this, BlockServiceADFWriteProvider);
|
|
100
|
+
this.sourceAri = sourceAri;
|
|
101
|
+
this.product = product;
|
|
100
102
|
}
|
|
103
|
+
|
|
104
|
+
// it will first try to update and if it can't (404) then it will try to create
|
|
101
105
|
return _createClass(BlockServiceADFWriteProvider, [{
|
|
102
106
|
key: "writeData",
|
|
103
|
-
value:
|
|
104
|
-
function () {
|
|
107
|
+
value: function () {
|
|
105
108
|
var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
106
109
|
var resourceId;
|
|
107
110
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -133,8 +136,8 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
133
136
|
return createSyncedBlock({
|
|
134
137
|
blockAri: resourceId,
|
|
135
138
|
blockInstanceId: data.blockInstanceId,
|
|
136
|
-
sourceAri:
|
|
137
|
-
product:
|
|
139
|
+
sourceAri: this.sourceAri,
|
|
140
|
+
product: this.product,
|
|
138
141
|
content: JSON.stringify(data.content)
|
|
139
142
|
});
|
|
140
143
|
case 13:
|
|
@@ -154,7 +157,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
154
157
|
case "end":
|
|
155
158
|
return _context2.stop();
|
|
156
159
|
}
|
|
157
|
-
}, _callee2,
|
|
160
|
+
}, _callee2, this, [[1, 7]]);
|
|
158
161
|
}));
|
|
159
162
|
function writeData(_x2) {
|
|
160
163
|
return _writeData.apply(this, arguments);
|
|
@@ -210,22 +213,24 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
210
213
|
}()
|
|
211
214
|
}, {
|
|
212
215
|
key: "generateResourceId",
|
|
213
|
-
value: function generateResourceId(
|
|
214
|
-
return blockResourceIdFromSourceAndLocalId(
|
|
216
|
+
value: function generateResourceId(sourceAri, localId) {
|
|
217
|
+
return blockResourceIdFromSourceAndLocalId(sourceAri, localId);
|
|
215
218
|
}
|
|
216
219
|
}]);
|
|
217
220
|
}();
|
|
218
221
|
/**
|
|
219
222
|
* Factory function to create both providers with shared configuration
|
|
220
223
|
*/
|
|
221
|
-
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders() {
|
|
224
|
+
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(sourceAri, product) {
|
|
222
225
|
var fetchProvider = new BlockServiceADFFetchProvider();
|
|
223
|
-
var writeProvider = new BlockServiceADFWriteProvider();
|
|
226
|
+
var writeProvider = new BlockServiceADFWriteProvider(sourceAri, product);
|
|
224
227
|
return {
|
|
225
228
|
fetchProvider: fetchProvider,
|
|
226
229
|
writeProvider: writeProvider
|
|
227
230
|
};
|
|
228
231
|
};
|
|
229
|
-
export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders() {
|
|
230
|
-
return useMemo(
|
|
232
|
+
export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(sourceAri, product) {
|
|
233
|
+
return useMemo(function () {
|
|
234
|
+
return createBlockServiceAPIProviders(sourceAri, product);
|
|
235
|
+
}, [sourceAri, product]);
|
|
231
236
|
};
|
|
@@ -84,7 +84,7 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
84
84
|
return data;
|
|
85
85
|
}, function () {
|
|
86
86
|
return {
|
|
87
|
-
|
|
87
|
+
error: SyncBlockError.Errored,
|
|
88
88
|
resourceId: resourceId
|
|
89
89
|
};
|
|
90
90
|
});
|
|
@@ -212,13 +212,13 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
212
212
|
*/
|
|
213
213
|
}, {
|
|
214
214
|
key: "fetchSyncBlockSourceInfo",
|
|
215
|
-
value: function fetchSyncBlockSourceInfo(localId, sourceAri, sourceProduct) {
|
|
215
|
+
value: function fetchSyncBlockSourceInfo(localId, sourceAri, sourceProduct, fireAnalyticsEvent) {
|
|
216
216
|
if (!sourceAri || !sourceProduct) {
|
|
217
|
-
return Promise.
|
|
217
|
+
return Promise.reject(new Error('Source ari or source product is undefined'));
|
|
218
218
|
}
|
|
219
219
|
switch (sourceProduct) {
|
|
220
220
|
case 'confluence-page':
|
|
221
|
-
return fetchConfluencePageInfo(sourceAri, localId);
|
|
221
|
+
return fetchConfluencePageInfo(sourceAri, localId, fireAnalyticsEvent);
|
|
222
222
|
case 'jira-work-item':
|
|
223
223
|
return Promise.reject(new Error('Jira work item source product not supported'));
|
|
224
224
|
default:
|
|
@@ -9,8 +9,10 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
9
9
|
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; } } }; }
|
|
10
10
|
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; } }
|
|
11
11
|
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; }
|
|
12
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
12
13
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
13
14
|
import { SyncBlockError } from '../common/types';
|
|
15
|
+
import { fetchErrorPayload, getSourceInfoErrorPayload } from '../utils/errorHandling';
|
|
14
16
|
import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
|
|
15
17
|
import { createSyncBlockNode } from '../utils/utils';
|
|
16
18
|
|
|
@@ -20,7 +22,7 @@ import { createSyncBlockNode } from '../utils/utils';
|
|
|
20
22
|
// Handles fetching source URL and title for sync blocks.
|
|
21
23
|
// Can be used in both editor and renderer contexts.
|
|
22
24
|
export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
23
|
-
function ReferenceSyncBlockStoreManager(dataProvider) {
|
|
25
|
+
function ReferenceSyncBlockStoreManager(dataProvider, fireAnalyticsEvent) {
|
|
24
26
|
_classCallCheck(this, ReferenceSyncBlockStoreManager);
|
|
25
27
|
_defineProperty(this, "isRefreshingSubscriptions", false);
|
|
26
28
|
this.syncBlockCache = new Map();
|
|
@@ -29,17 +31,23 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
29
31
|
this.dataProvider = dataProvider;
|
|
30
32
|
this.syncBlockURLRequests = new Map();
|
|
31
33
|
this.providerFactories = new Map();
|
|
34
|
+
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Refreshes the subscriptions for all sync blocks.
|
|
36
|
-
* @returns {Promise<void>}
|
|
37
|
-
*/
|
|
38
36
|
return _createClass(ReferenceSyncBlockStoreManager, [{
|
|
37
|
+
key: "updateFireAnalyticsEvent",
|
|
38
|
+
value: function updateFireAnalyticsEvent(fireAnalyticsEvent) {
|
|
39
|
+
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Refreshes the subscriptions for all sync blocks.
|
|
44
|
+
* @returns {Promise<void>}
|
|
45
|
+
*/
|
|
46
|
+
}, {
|
|
39
47
|
key: "refreshSubscriptions",
|
|
40
48
|
value: (function () {
|
|
41
49
|
var _refreshSubscriptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
42
|
-
var syncBlocks, _iterator, _step, _loop;
|
|
50
|
+
var syncBlocks, _iterator, _step, _loop, _this$fireAnalyticsEv;
|
|
43
51
|
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
44
52
|
while (1) switch (_context2.prev = _context2.next) {
|
|
45
53
|
case 0:
|
|
@@ -94,20 +102,24 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
94
102
|
_context2.next = 23;
|
|
95
103
|
return this.fetchSyncBlocksData(syncBlocks);
|
|
96
104
|
case 23:
|
|
97
|
-
_context2.next =
|
|
105
|
+
_context2.next = 29;
|
|
98
106
|
break;
|
|
99
107
|
case 25:
|
|
100
108
|
_context2.prev = 25;
|
|
101
109
|
_context2.t2 = _context2["catch"](20);
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
logException(_context2.t2, {
|
|
111
|
+
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
112
|
+
});
|
|
113
|
+
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, fetchErrorPayload(_context2.t2.message));
|
|
114
|
+
case 29:
|
|
115
|
+
_context2.prev = 29;
|
|
104
116
|
this.isRefreshingSubscriptions = false;
|
|
105
|
-
return _context2.finish(
|
|
106
|
-
case
|
|
117
|
+
return _context2.finish(29);
|
|
118
|
+
case 32:
|
|
107
119
|
case "end":
|
|
108
120
|
return _context2.stop();
|
|
109
121
|
}
|
|
110
|
-
}, _callee, this, [[5, 14, 17, 20], [20, 25,
|
|
122
|
+
}, _callee, this, [[5, 14, 17, 20], [20, 25, 29, 32]]);
|
|
111
123
|
}));
|
|
112
124
|
function refreshSubscriptions() {
|
|
113
125
|
return _refreshSubscriptions.apply(this, arguments);
|
|
@@ -117,43 +129,53 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
117
129
|
}, {
|
|
118
130
|
key: "fetchSyncBlockSourceInfo",
|
|
119
131
|
value: function fetchSyncBlockSourceInfo(resourceId) {
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
var _this = this;
|
|
133
|
+
try {
|
|
134
|
+
var _existingSyncBlock$da, _existingSyncBlock$da2;
|
|
135
|
+
if (!resourceId || !this.dataProvider) {
|
|
136
|
+
throw new Error('Data provider or resourceId not set');
|
|
137
|
+
}
|
|
138
|
+
if (this.syncBlockURLRequests.get(resourceId)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.syncBlockURLRequests.set(resourceId, true);
|
|
142
|
+
var existingSyncBlock = this.getFromCache(resourceId);
|
|
143
|
+
if (!existingSyncBlock) {
|
|
144
|
+
throw new Error('No existing sync block to fetch source info for');
|
|
145
|
+
}
|
|
134
146
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
var _ref = existingSyncBlock.data || {},
|
|
140
|
-
sourceAri = _ref.sourceAri,
|
|
141
|
-
product = _ref.product,
|
|
142
|
-
blockInstanceId = _ref.blockInstanceId;
|
|
143
|
-
if (!sourceAri || !product || !blockInstanceId) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product).then(function (sourceInfo) {
|
|
147
|
-
if (!sourceInfo) {
|
|
147
|
+
// skip if source URL and title are already present
|
|
148
|
+
if ((_existingSyncBlock$da = existingSyncBlock.data) !== null && _existingSyncBlock$da !== void 0 && _existingSyncBlock$da.sourceURL && (_existingSyncBlock$da2 = existingSyncBlock.data) !== null && _existingSyncBlock$da2 !== void 0 && _existingSyncBlock$da2.sourceTitle) {
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
var _ref = existingSyncBlock.data || {},
|
|
152
|
+
sourceAri = _ref.sourceAri,
|
|
153
|
+
product = _ref.product,
|
|
154
|
+
blockInstanceId = _ref.blockInstanceId;
|
|
155
|
+
if (!sourceAri || !product || !blockInstanceId) {
|
|
156
|
+
throw new Error('SourceAri, product or blockInstanceId missing');
|
|
153
157
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(function (sourceInfo) {
|
|
159
|
+
if (!sourceInfo) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
_this.updateCacheWithSourceInfo(resourceId, sourceInfo);
|
|
163
|
+
if (sourceInfo.title) {
|
|
164
|
+
_this.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
|
|
165
|
+
}
|
|
166
|
+
}).catch(function (error) {
|
|
167
|
+
var _this$fireAnalyticsEv2;
|
|
168
|
+
(_this$fireAnalyticsEv2 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(_this, getSourceInfoErrorPayload(error.message));
|
|
169
|
+
}).finally(function () {
|
|
170
|
+
_this.syncBlockURLRequests.delete(resourceId);
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
var _this$fireAnalyticsEv3;
|
|
174
|
+
logException(error, {
|
|
175
|
+
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
176
|
+
});
|
|
177
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload(error.message));
|
|
178
|
+
}
|
|
157
179
|
}
|
|
158
180
|
|
|
159
181
|
/**
|
|
@@ -196,18 +218,16 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
196
218
|
return this.dataProvider.fetchNodesData(nodesToFetch);
|
|
197
219
|
case 8:
|
|
198
220
|
data = _context3.sent;
|
|
199
|
-
if (data) {
|
|
200
|
-
_context3.next = 11;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
throw new Error('Failed to fetch sync block node data');
|
|
204
|
-
case 11:
|
|
205
221
|
resolvedData = [];
|
|
206
222
|
data.forEach(function (syncBlockInstance) {
|
|
207
223
|
if (!syncBlockInstance.resourceId) {
|
|
224
|
+
var _this2$fireAnalyticsE;
|
|
225
|
+
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, fetchErrorPayload(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
208
226
|
return;
|
|
209
227
|
}
|
|
210
228
|
if (syncBlockInstance.error) {
|
|
229
|
+
var _this2$fireAnalyticsE2;
|
|
230
|
+
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, fetchErrorPayload(syncBlockInstance.error));
|
|
211
231
|
_this2.updateCache(syncBlockInstance);
|
|
212
232
|
resolvedData.push(syncBlockInstance);
|
|
213
233
|
return;
|
|
@@ -219,7 +239,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
219
239
|
_this2.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
220
240
|
});
|
|
221
241
|
return _context3.abrupt("return", [].concat(resolvedData, blocksWithNotFoundError));
|
|
222
|
-
case
|
|
242
|
+
case 12:
|
|
223
243
|
case "end":
|
|
224
244
|
return _context3.stop();
|
|
225
245
|
}
|
|
@@ -291,7 +311,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
291
311
|
if (cachedData) {
|
|
292
312
|
callback(cachedData);
|
|
293
313
|
} else {
|
|
294
|
-
this.fetchSyncBlocksData([createSyncBlockNode(localId, resourceId)]).catch(function () {
|
|
314
|
+
this.fetchSyncBlocksData([createSyncBlockNode(localId, resourceId)]).catch(function (error) {
|
|
315
|
+
var _this3$fireAnalyticsE;
|
|
316
|
+
logException(error, {
|
|
317
|
+
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
318
|
+
});
|
|
319
|
+
(_this3$fireAnalyticsE = _this3.fireAnalyticsEvent) === null || _this3$fireAnalyticsE === void 0 || _this3$fireAnalyticsE.call(_this3, fetchErrorPayload(error.message));
|
|
320
|
+
});
|
|
295
321
|
}
|
|
296
322
|
return function () {
|
|
297
323
|
var resourceSubscriptions = _this3.subscriptions.get(resourceId);
|
|
@@ -344,17 +370,26 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
344
370
|
}, {
|
|
345
371
|
key: "subscribe",
|
|
346
372
|
value: function subscribe(node, callback) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
373
|
+
try {
|
|
374
|
+
// check node is a sync block, as we only support sync block subscriptions
|
|
375
|
+
if (node.type.name !== 'syncBlock') {
|
|
376
|
+
throw new Error('Only sync block node subscriptions are supported');
|
|
377
|
+
}
|
|
378
|
+
var _node$attrs2 = node.attrs,
|
|
379
|
+
resourceId = _node$attrs2.resourceId,
|
|
380
|
+
localId = _node$attrs2.localId;
|
|
381
|
+
if (!localId || !resourceId) {
|
|
382
|
+
throw new Error('Missing local id or resource id');
|
|
383
|
+
}
|
|
384
|
+
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
385
|
+
} catch (error) {
|
|
386
|
+
var _this$fireAnalyticsEv4;
|
|
387
|
+
logException(error, {
|
|
388
|
+
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
389
|
+
});
|
|
390
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, fetchErrorPayload(error.message));
|
|
355
391
|
return function () {};
|
|
356
392
|
}
|
|
357
|
-
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
358
393
|
}
|
|
359
394
|
|
|
360
395
|
/**
|
|
@@ -376,6 +411,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
376
411
|
key: "getProviderFactory",
|
|
377
412
|
value: function getProviderFactory(resourceId) {
|
|
378
413
|
if (!this.dataProvider) {
|
|
414
|
+
var _this$fireAnalyticsEv5;
|
|
415
|
+
var error = new Error('Data provider not set');
|
|
416
|
+
logException(error, {
|
|
417
|
+
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
418
|
+
});
|
|
419
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, fetchErrorPayload(error.message));
|
|
379
420
|
return undefined;
|
|
380
421
|
}
|
|
381
422
|
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
@@ -391,7 +432,15 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
391
432
|
this.providerFactories.set(resourceId, providerFactory);
|
|
392
433
|
}
|
|
393
434
|
if (providerCreator) {
|
|
394
|
-
|
|
435
|
+
try {
|
|
436
|
+
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
437
|
+
} catch (error) {
|
|
438
|
+
var _this$fireAnalyticsEv6;
|
|
439
|
+
logException(error, {
|
|
440
|
+
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
441
|
+
});
|
|
442
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, fetchErrorPayload(error.message));
|
|
443
|
+
}
|
|
395
444
|
}
|
|
396
445
|
return providerFactory;
|
|
397
446
|
}
|
|
@@ -400,7 +449,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
400
449
|
value: function retrieveDynamicProviders(resourceId, providerFactory, providerCreator) {
|
|
401
450
|
var _syncBlock$data2, _syncBlock$data3, _syncBlock$data4, _syncBlock$data5;
|
|
402
451
|
if (!this.dataProvider) {
|
|
403
|
-
|
|
452
|
+
throw new Error('Data provider not set');
|
|
404
453
|
}
|
|
405
454
|
var hasMediaProvider = providerFactory.hasProvider('mediaProvider');
|
|
406
455
|
var hasEmojiProvider = providerFactory.hasProvider('emojiProvider');
|
|
@@ -409,11 +458,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
409
458
|
}
|
|
410
459
|
var syncBlock = this.getFromCache(resourceId);
|
|
411
460
|
if (!syncBlock || !((_syncBlock$data2 = syncBlock.data) !== null && _syncBlock$data2 !== void 0 && _syncBlock$data2.sourceAri) || !((_syncBlock$data3 = syncBlock.data) !== null && _syncBlock$data3 !== void 0 && _syncBlock$data3.product)) {
|
|
461
|
+
var _this$fireAnalyticsEv7;
|
|
462
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, fetchErrorPayload('Sync block or source ari or product not found'));
|
|
412
463
|
return;
|
|
413
464
|
}
|
|
414
465
|
var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data4 = syncBlock.data) === null || _syncBlock$data4 === void 0 ? void 0 : _syncBlock$data4.sourceAri, (_syncBlock$data5 = syncBlock.data) === null || _syncBlock$data5 === void 0 ? void 0 : _syncBlock$data5.product);
|
|
415
466
|
if (!parentInfo) {
|
|
416
|
-
|
|
467
|
+
throw new Error('Unable to retrive sync block parent info');
|
|
417
468
|
}
|
|
418
469
|
var contentId = parentInfo.contentId,
|
|
419
470
|
contentProduct = parentInfo.contentProduct;
|
|
@@ -454,6 +505,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
454
505
|
providerFactory.destroy();
|
|
455
506
|
});
|
|
456
507
|
this.providerFactories.clear();
|
|
508
|
+
this.fireAnalyticsEvent = undefined;
|
|
457
509
|
}
|
|
458
510
|
}]);
|
|
459
511
|
}();
|