@atlaskit/node-data-provider 4.2.0 → 4.4.0

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 CHANGED
@@ -1,5 +1,34 @@
1
1
  # @atlaskit/node-data-provider
2
2
 
3
+ ## 4.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#191942](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191942)
8
+ [`6b5ec599e6dfd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6b5ec599e6dfd) -
9
+ [https://product-fabric.atlassian.net/browse/ED-28596](ED-28596) - extend EditorCardProvider from
10
+ NodeDataProvider
11
+
12
+ ### Patch Changes
13
+
14
+ - [#191913](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191913)
15
+ [`6d1e56695e91d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6d1e56695e91d) -
16
+ EDITOR-1131 Bump adf-schema package to 50.0.0
17
+ - Updated dependencies
18
+
19
+ ## 4.3.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#191314](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191314)
24
+ [`ff7de5572e25d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ff7de5572e25d) -
25
+ [https://product-fabric.atlassian.net/browse/ED-28587](ED-28587) - implement NodeDataProvider and
26
+ prefetchNodeDataProvidersData for One Tick Provider project
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies
31
+
3
32
  ## 4.2.0
4
33
 
5
34
  ### Minor Changes
package/dist/cjs/index.js CHANGED
@@ -1 +1,19 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "NodeDataProvider", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _nodeDataProvider.NodeDataProvider;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "prefetchNodeDataProvidersData", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _prefetchNodeDataProvidersData.prefetchNodeDataProvidersData;
16
+ }
17
+ });
18
+ var _nodeDataProvider = require("./node-data-provider");
19
+ var _prefetchNodeDataProvidersData = require("./utils/prefetch-node-data-providers-data");
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.NodeDataProvider = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
+ var _coreUtils = require("@atlaskit/editor-common/core-utils");
15
+ /**
16
+ * Represents the SSR data for a single provider.
17
+ * It's a map where each key is a unique node data key and the value is the prefetched data for that node.
18
+ *
19
+ * @example
20
+ * {
21
+ * 'node-id-1': { value: 'some data' },
22
+ * 'node-id-2': { value: 'other data' }
23
+ * }
24
+ */
25
+ /**
26
+ * Represents the cached data for a Node Data Provider.
27
+ * Each key is a unique node data key, and the value is an object containing:
28
+ * - `source`: Indicates whether the data was fetched from SSR or the network.
29
+ * - `data`: The actual data, which can be either a resolved value or a Promise.
30
+ *
31
+ * @example
32
+ * {
33
+ * 'node-id-1': { source: 'ssr', data: { value: 'some data' } },
34
+ * 'node-id-2': { source: 'network', data: Promise.resolve({ value: 'other data' }) }
35
+ * }
36
+ */
37
+ /**
38
+ * Represents the payload passed to the callback function when data is fetched.
39
+ * It can either contain an error or the fetched data.
40
+ */
41
+ /**
42
+ * A Node Data Provider is responsible for fetching and caching data associated with specific ProseMirror nodes.
43
+ * It supports a cache-first-then-network strategy, with initial data potentially provided via SSR.
44
+ *
45
+ * @template Node The specific type of JSONNode this provider supports.
46
+ * @template Data The type of data this provider fetches and manages.
47
+ */
48
+ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
49
+ function NodeDataProvider() {
50
+ (0, _classCallCheck2.default)(this, NodeDataProvider);
51
+ this.cacheVersion = 0;
52
+ this.cache = {};
53
+ }
54
+
55
+ /**
56
+ * Sets the SSR data for the provider.
57
+ * This pre-populates the cache with data rendered on the server, preventing redundant network requests on the client.
58
+ * Calling this method will invalidate the existing cache.
59
+ *
60
+ * @example
61
+ * ```
62
+ * const ssrData = window.__SSR_NODE_DATA__ || {};
63
+ * nodeDataProvider.setSSRData(ssrData);
64
+ * ```
65
+ *
66
+ * @param ssrData A map of node data keys to their corresponding data.
67
+ */
68
+ return (0, _createClass2.default)(NodeDataProvider, [{
69
+ key: "setSSRData",
70
+ value: function setSSRData() {
71
+ var ssrData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
72
+ this.cacheVersion++;
73
+ this.cache = Object.fromEntries(Object.entries(ssrData).map(function (_ref) {
74
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
75
+ key = _ref2[0],
76
+ data = _ref2[1];
77
+ return [key, {
78
+ data: data,
79
+ source: 'ssr'
80
+ }];
81
+ }));
82
+ }
83
+
84
+ /**
85
+ * Clears all cached data.
86
+ * This increments the internal cache version, invalidating any pending network requests.
87
+ *
88
+ * @example
89
+ * ```
90
+ * function useMyNodeDataProvider(contentId: string) {
91
+ * const nodeDataProvider = new MyNodeDataProvider();
92
+ *
93
+ * // Reset the cache when the contentId changes (e.g., when the user navigates to a different page).
94
+ * useEffect(() => {
95
+ * nodeDataProvider.resetCache();
96
+ * }, [contentId]);
97
+ *
98
+ * return nodeDataProvider;
99
+ * }
100
+ * ```
101
+ */
102
+ }, {
103
+ key: "resetCache",
104
+ value: function resetCache() {
105
+ this.cacheVersion++;
106
+ this.cache = {};
107
+ }
108
+
109
+ /**
110
+ * Fetches data for a given node using a cache-first-then-network strategy.
111
+ *
112
+ * The provided callback may be called multiple times:
113
+ * 1. Immediately with data from the SSR cache, if available.
114
+ * 2. Asynchronously with data fetched from the network.
115
+ *
116
+ * @example
117
+ * ```
118
+ * const nodeDataProvider = new MyNodeDataProvider();
119
+ *
120
+ * nodeDataProvider.getData(node, (data) => {
121
+ * console.log('Node data:', data);
122
+ * });
123
+ * ```
124
+ *
125
+ * @param node The node (or its ProseMirror representation) for which to fetch data.
126
+ * @param callback The callback function to call with the fetched data or an error.
127
+ */
128
+ }, {
129
+ key: "getData",
130
+ value: function getData(node, callback) {
131
+ // Move implementation to a separate async method
132
+ // to keep this method synchronous and avoid async/await in the public API.
133
+ void this.getDataAsync(node, callback);
134
+ }
135
+ }, {
136
+ key: "getDataAsync",
137
+ value: function () {
138
+ var _getDataAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(node, callback) {
139
+ var jsonNode, _dataKey, dataFromCache, cacheVersionBeforeRequest, dataPromise, data;
140
+ return _regenerator.default.wrap(function _callee$(_context) {
141
+ while (1) switch (_context.prev = _context.next) {
142
+ case 0:
143
+ _context.prev = 0;
144
+ jsonNode = 'toJSON' in node ? node.toJSON() : node;
145
+ if (this.isNodeSupported(jsonNode)) {
146
+ _context.next = 5;
147
+ break;
148
+ }
149
+ // eslint-disable-next-line no-console
150
+ console.error("The ".concat(this.constructor.name, " doesn't support Node ").concat(jsonNode.type, "."));
151
+ return _context.abrupt("return");
152
+ case 5:
153
+ _dataKey = this.nodeDataKey(jsonNode);
154
+ dataFromCache = this.cache[_dataKey];
155
+ if (!(dataFromCache !== undefined)) {
156
+ _context.next = 20;
157
+ break;
158
+ }
159
+ if (!isPromise(dataFromCache.data)) {
160
+ _context.next = 17;
161
+ break;
162
+ }
163
+ _context.t0 = callback;
164
+ _context.next = 12;
165
+ return dataFromCache.data;
166
+ case 12:
167
+ _context.t1 = _context.sent;
168
+ _context.t2 = {
169
+ data: _context.t1
170
+ };
171
+ (0, _context.t0)(_context.t2);
172
+ _context.next = 18;
173
+ break;
174
+ case 17:
175
+ callback({
176
+ data: dataFromCache.data
177
+ });
178
+ case 18:
179
+ if (!(0, _coreUtils.isSSR)()) {
180
+ _context.next = 20;
181
+ break;
182
+ }
183
+ return _context.abrupt("return");
184
+ case 20:
185
+ if (!((dataFromCache === null || dataFromCache === void 0 ? void 0 : dataFromCache.source) !== 'network')) {
186
+ _context.next = 29;
187
+ break;
188
+ }
189
+ // Store the current cache version before making the request,
190
+ // so we can check if the cache has changed while we are waiting for the network response.
191
+ cacheVersionBeforeRequest = this.cacheVersion;
192
+ dataPromise = this.fetchNodesData([jsonNode]).then(function (_ref3) {
193
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 1),
194
+ value = _ref4[0];
195
+ return value;
196
+ }); // Store the promise in the cache to avoid multiple requests for the same data
197
+ this.cache[_dataKey] = {
198
+ source: 'network',
199
+ data: dataPromise
200
+ };
201
+ _context.next = 26;
202
+ return dataPromise;
203
+ case 26:
204
+ data = _context.sent;
205
+ // We need to call the callback with the data with result even if the cache version has changed,
206
+ // so all promises that are waiting for the data can resolve.
207
+ callback({
208
+ data: data
209
+ });
210
+
211
+ // If the cache version has changed, we don't want to use the data from the network
212
+ // because it could be stale data.
213
+ if (cacheVersionBeforeRequest === this.cacheVersion) {
214
+ // Replace promise with the resolved data in the cache
215
+ this.cache[_dataKey] = {
216
+ source: 'network',
217
+ data: data
218
+ };
219
+ }
220
+ case 29:
221
+ _context.next = 34;
222
+ break;
223
+ case 31:
224
+ _context.prev = 31;
225
+ _context.t3 = _context["catch"](0);
226
+ // If an error occurs, we call the callback with the error
227
+ callback({
228
+ error: _context.t3 instanceof Error ? _context.t3 : new Error(String(_context.t3))
229
+ });
230
+ case 34:
231
+ case "end":
232
+ return _context.stop();
233
+ }
234
+ }, _callee, this, [[0, 31]]);
235
+ }));
236
+ function getDataAsync(_x, _x2) {
237
+ return _getDataAsync.apply(this, arguments);
238
+ }
239
+ return getDataAsync;
240
+ }()
241
+ /**
242
+ * Fetches data for a given node and returns it as a Promise.
243
+ * This is a convenience wrapper around the `data` method for use with async/await.
244
+ *
245
+ * Note: This promise resolves with the *first* available data, which could be from the SSR cache or the network.
246
+ * It may not provide the most up-to-date data if a network fetch is in progress.
247
+ *
248
+ * Note: This method is only for migration purposes. Use {@link getData} in new code instead.
249
+ *
250
+ * @private
251
+ * @deprecated Don't use this method, use {@link getData} method instead.
252
+ * This method is only for migration purposes.
253
+ *
254
+ * @param node The node (or its ProseMirror representation) for which to fetch data.
255
+ * @returns A promise that resolves with the node's data.
256
+ */
257
+ }, {
258
+ key: "getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS",
259
+ value: function getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS(node) {
260
+ var _this = this;
261
+ return new Promise(function (resolve, reject) {
262
+ try {
263
+ _this.getData(node, function (payload) {
264
+ if (payload.error) {
265
+ reject(payload.error);
266
+ } else {
267
+ resolve(payload.data);
268
+ }
269
+ });
270
+ } catch (error) {
271
+ reject(error);
272
+ }
273
+ });
274
+ }
275
+ }]);
276
+ }();
277
+ function isPromise(value) {
278
+ return (0, _typeof2.default)(value) === 'object' && value !== null && 'then' in value && typeof value.then === 'function';
279
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.findNodesToPrefetch = findNodesToPrefetch;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ /**
10
+ * Finds nodes in the document that are supported by the given providers, up to a maximum number of nodes.
11
+ *
12
+ * @param doc The document to search for nodes.
13
+ * @param providers An array of providers with their maximum nodes to prefetch.
14
+ * @param maxNodesToVisit The maximum number of nodes to visit in the document.
15
+ * @returns An array of objects, each containing a provider and the nodes that are supported by that provider.
16
+ */
17
+ function findNodesToPrefetch(doc, providers, maxNodesToVisit) {
18
+ // Counter for the total number of visited nodes to limit the traversal.
19
+ var totalVisitedNodesCount = 0;
20
+ // A map to store the results, with the provider name as the key.
21
+ var resultMap = providers.reduce(function (acc, _ref) {
22
+ var provider = _ref.provider;
23
+ acc[provider.name] = {
24
+ provider: provider,
25
+ nodes: []
26
+ };
27
+ return acc;
28
+ }, {});
29
+
30
+ // It doesn't use `filter` function from `@atlaskit/adf-utils/traverse` because it does not support early stopping.
31
+ // We need to stop traversing when we reach the maximum number of nodes to visit to support large documents.
32
+
33
+ // Create a list of providers for which we still need to find nodes.
34
+ var providersToLookup = providers.filter(function (_ref2) {
35
+ var maxNodesToPrefetch = _ref2.maxNodesToPrefetch;
36
+ return maxNodesToPrefetch > 0;
37
+ }).map(function (_ref3) {
38
+ var provider = _ref3.provider,
39
+ maxNodesToPrefetch = _ref3.maxNodesToPrefetch;
40
+ return {
41
+ provider: provider,
42
+ maxNodesToPrefetch: maxNodesToPrefetch,
43
+ foundNodes: 0 // Counter for nodes found for each provider.
44
+ };
45
+ });
46
+
47
+ // Queue for the breadth-first search (BFS), starting with the root document node.
48
+ var nodesToVisit = [doc];
49
+ var currentIndex = 0;
50
+ // The loop continues as long as there are nodes to visit, providers to look for,
51
+ // and the visited nodes limit has not been reached.
52
+ while (currentIndex < nodesToVisit.length && providersToLookup.length > 0 && totalVisitedNodesCount < maxNodesToVisit) {
53
+ totalVisitedNodesCount += 1;
54
+ var currentNode = nodesToVisit[currentIndex];
55
+ currentIndex++;
56
+
57
+ // Using a reverse loop to avoid issues with array mutation (when removing elements).
58
+ for (var i = providersToLookup.length - 1; i >= 0; i--) {
59
+ var providerToFind = providersToLookup[i];
60
+
61
+ // Check if the current provider supports this node.
62
+ if (providerToFind.provider.isNodeSupported(currentNode)) {
63
+ // If provider supports the node, add it to the result map.
64
+ resultMap[providerToFind.provider.name].nodes.push(currentNode);
65
+ // Increment the count of found nodes for this provider.
66
+ providerToFind.foundNodes += 1;
67
+
68
+ // If the provider has found enough nodes, remove it from the lookup list.
69
+ if (providerToFind.foundNodes >= providerToFind.maxNodesToPrefetch) {
70
+ providersToLookup.splice(i, 1);
71
+ }
72
+ }
73
+ }
74
+
75
+ // If the current node has children, add them to the queue to be visited.
76
+ if (currentNode.content) {
77
+ nodesToVisit.push.apply(nodesToVisit, (0, _toConsumableArray2.default)(currentNode.content.filter(function (node) {
78
+ return node !== undefined;
79
+ })));
80
+ }
81
+ }
82
+
83
+ // Return an array of the found nodes, grouped by provider.
84
+ return Object.values(resultMap);
85
+ }
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.prefetchNodeDataProvidersData = prefetchNodeDataProvidersData;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _findNodesToPrefetch = require("./find-nodes-to-prefetch");
11
+ /**
12
+ * Represents the SSR data for a single provider.
13
+ * It's a map where each key is a unique node data key and the value is the prefetched data for that node.
14
+ *
15
+ * @example
16
+ * {
17
+ * 'node-id-1': { value: 'some data' },
18
+ * 'node-id-2': { value: 'other data' }
19
+ * }
20
+ */
21
+ /**
22
+ * Represents the aggregated SSR data for all node data providers.
23
+ * It's a map where each key is a provider's name and the value is the {@link SsrData} for that provider.
24
+ * This structure is used to hydrate the client-side caches.
25
+ *
26
+ * @example
27
+ * {
28
+ * 'mentionProvider': { 'mention-1': { id: '1', name: 'John Doe' } },
29
+ * 'emojiProvider': { 'emoji-123': { shortName: ':smile:', representation: '😊' } }
30
+ * }
31
+ */
32
+ /**
33
+ * Fetches data for nodes in the document that are supported by the given providers.
34
+ * This function will traverse the document and call the `fetchData` method for each node that is supported by the providers.
35
+ *
36
+ * @example
37
+ * ```
38
+ * const doc = JSON.parse('{"type": "doc", "content": [...] }');
39
+ * const providers = [
40
+ * {
41
+ * provider: new EditorCardProvider(),
42
+ * maxNodesToPrefetch: 10,
43
+ * timeout: 500,
44
+ * },
45
+ * {
46
+ * provider: new EditorMentionsProvider(),
47
+ * maxNodesToPrefetch: 50,
48
+ * timeout: 500,
49
+ * },
50
+ * ];
51
+ *
52
+ * window['__SSR_EDITOR_NODE_DATA_PROVIDERS_DATA__'] = await prefetchNodeDataProvidersData({
53
+ * providers,
54
+ * doc,
55
+ * timeout: 1_000,
56
+ * maxNodesToVisit: 2_000
57
+ * });
58
+ * ```
59
+ *
60
+ * @param props The properties for prefetching node data.
61
+ * @returns Record of provider names to their respective SSR data,
62
+ * where each SSR data is a record of node data keys to the fetched data.
63
+ */
64
+ function prefetchNodeDataProvidersData(_x) {
65
+ return _prefetchNodeDataProvidersData.apply(this, arguments);
66
+ }
67
+ function _prefetchNodeDataProvidersData() {
68
+ _prefetchNodeDataProvidersData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref) {
69
+ var providers, doc, timeout, _ref$maxNodesToVisit, maxNodesToVisit, providersWithDefaults, providerTimeouts, nodesWithProviders, promises, results;
70
+ return _regenerator.default.wrap(function _callee2$(_context2) {
71
+ while (1) switch (_context2.prev = _context2.next) {
72
+ case 0:
73
+ providers = _ref.providers, doc = _ref.doc, timeout = _ref.timeout, _ref$maxNodesToVisit = _ref.maxNodesToVisit, maxNodesToVisit = _ref$maxNodesToVisit === void 0 ? Infinity : _ref$maxNodesToVisit;
74
+ providersWithDefaults = providers.map(function (_ref2) {
75
+ var provider = _ref2.provider,
76
+ _ref2$maxNodesToPrefe = _ref2.maxNodesToPrefetch,
77
+ maxNodesToPrefetch = _ref2$maxNodesToPrefe === void 0 ? Infinity : _ref2$maxNodesToPrefe,
78
+ _ref2$timeout = _ref2.timeout,
79
+ providerTimeout = _ref2$timeout === void 0 ? Infinity : _ref2$timeout;
80
+ return {
81
+ provider: provider,
82
+ maxNodesToPrefetch: maxNodesToPrefetch,
83
+ // Use the minimum of the global timeout and the provider-specific timeout
84
+ timeout: Math.min(providerTimeout, timeout)
85
+ };
86
+ });
87
+ providerTimeouts = providersWithDefaults.reduce(function (acc, _ref3) {
88
+ var provider = _ref3.provider,
89
+ timeout = _ref3.timeout;
90
+ acc[provider.name] = timeout;
91
+ return acc;
92
+ }, {});
93
+ nodesWithProviders = (0, _findNodesToPrefetch.findNodesToPrefetch)(doc, providersWithDefaults, maxNodesToVisit).map(function (_ref4) {
94
+ var provider = _ref4.provider,
95
+ nodes = _ref4.nodes;
96
+ return {
97
+ provider: provider,
98
+ nodes: nodes,
99
+ timeout: providerTimeouts[provider.name]
100
+ };
101
+ });
102
+ promises = nodesWithProviders.map( /*#__PURE__*/function () {
103
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref5) {
104
+ var nodes, provider, timeout, timeoutPromise, data;
105
+ return _regenerator.default.wrap(function _callee$(_context) {
106
+ while (1) switch (_context.prev = _context.next) {
107
+ case 0:
108
+ nodes = _ref5.nodes, provider = _ref5.provider, timeout = _ref5.timeout;
109
+ _context.prev = 1;
110
+ timeoutPromise = new Promise(function (resolve) {
111
+ setTimeout(function () {
112
+ resolve([]);
113
+ }, timeout);
114
+ });
115
+ _context.next = 5;
116
+ return Promise.race([provider.fetchNodesData(nodes), timeoutPromise]);
117
+ case 5:
118
+ data = _context.sent;
119
+ return _context.abrupt("return", {
120
+ provider: provider,
121
+ nodes: nodes,
122
+ data: data
123
+ });
124
+ case 9:
125
+ _context.prev = 9;
126
+ _context.t0 = _context["catch"](1);
127
+ return _context.abrupt("return", {
128
+ provider: provider,
129
+ nodes: nodes,
130
+ data: []
131
+ });
132
+ case 12:
133
+ case "end":
134
+ return _context.stop();
135
+ }
136
+ }, _callee, null, [[1, 9]]);
137
+ }));
138
+ return function (_x2) {
139
+ return _ref6.apply(this, arguments);
140
+ };
141
+ }());
142
+ _context2.next = 7;
143
+ return Promise.all(promises);
144
+ case 7:
145
+ results = _context2.sent;
146
+ return _context2.abrupt("return", results.reduce(function (acc, _ref7) {
147
+ var provider = _ref7.provider,
148
+ nodes = _ref7.nodes,
149
+ data = _ref7.data;
150
+ acc[provider.name] = data.reduce(function (providerSsrData, nodeData, nodeIndex) {
151
+ var node = nodes[nodeIndex];
152
+ var nodeDataKey = provider.nodeDataKey(node);
153
+ providerSsrData[nodeDataKey] = nodeData;
154
+ return providerSsrData;
155
+ }, {});
156
+ return acc;
157
+ }, {}));
158
+ case 9:
159
+ case "end":
160
+ return _context2.stop();
161
+ }
162
+ }, _callee2);
163
+ }));
164
+ return _prefetchNodeDataProvidersData.apply(this, arguments);
165
+ }
@@ -0,0 +1,4 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+
3
+ export { NodeDataProvider } from './node-data-provider';
4
+ export { prefetchNodeDataProvidersData } from './utils/prefetch-node-data-providers-data';