@atlaskit/node-data-provider 7.4.0 → 7.5.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,13 @@
1
1
  # @atlaskit/node-data-provider
2
2
 
3
+ ## 7.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e3f45edd75547`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3f45edd75547) -
8
+ [https://product-fabric.atlassian.net/browse/ED-29647](ED-29647) - OTP will not use network data
9
+ if preloaded data is unavailable during SSR rendering
10
+
3
11
  ## 7.4.0
4
12
 
5
13
  ### Minor Changes
@@ -151,22 +151,20 @@ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
151
151
  case 4:
152
152
  dataKey = this.nodeDataKey(jsonNode);
153
153
  dataFromCache = this.cache[dataKey];
154
- if (!(dataFromCache !== undefined)) {
155
- _context.next = 10;
156
- break;
154
+ if (dataFromCache !== undefined) {
155
+ // If we have the data in the SSR data, we can use it directly
156
+ callback({
157
+ data: dataFromCache.data
158
+ });
157
159
  }
158
- // If we have the data in the SSR data, we can use it directly
159
- callback({
160
- data: dataFromCache.data
161
- });
162
160
  if (!(0, _coreUtils.isSSR)()) {
163
- _context.next = 10;
161
+ _context.next = 9;
164
162
  break;
165
163
  }
166
164
  return _context.abrupt("return");
167
- case 10:
165
+ case 9:
168
166
  if (!((dataFromCache === null || dataFromCache === void 0 ? void 0 : dataFromCache.source) !== 'network')) {
169
- _context.next = 42;
167
+ _context.next = 41;
170
168
  break;
171
169
  }
172
170
  // Store the current cache version before making the request,
@@ -177,38 +175,38 @@ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
177
175
  // to avoid duplicate requests.
178
176
  networkRequestInFlight = this.networkRequestsInFlight[networkRequestInFlightKey];
179
177
  if (!networkRequestInFlight) {
180
- _context.next = 26;
178
+ _context.next = 25;
181
179
  break;
182
180
  }
183
- _context.prev = 15;
184
- _context.next = 18;
181
+ _context.prev = 14;
182
+ _context.next = 17;
185
183
  return networkRequestInFlight;
186
- case 18:
184
+ case 17:
187
185
  data = _context.sent;
188
186
  callback({
189
187
  data: data
190
188
  });
191
- _context.next = 25;
189
+ _context.next = 24;
192
190
  break;
193
- case 22:
194
- _context.prev = 22;
195
- _context.t0 = _context["catch"](15);
191
+ case 21:
192
+ _context.prev = 21;
193
+ _context.t0 = _context["catch"](14);
196
194
  callback({
197
195
  error: _context.t0 instanceof Error ? _context.t0 : new Error(String(_context.t0))
198
196
  });
199
- case 25:
197
+ case 24:
200
198
  return _context.abrupt("return");
201
- case 26:
202
- _context.prev = 26;
199
+ case 25:
200
+ _context.prev = 25;
203
201
  dataPromise = this.fetchNodesData([jsonNode]).then(function (_ref3) {
204
202
  var _ref4 = (0, _slicedToArray2.default)(_ref3, 1),
205
203
  value = _ref4[0];
206
204
  return value;
207
205
  }); // Store the promise in the in-flight requests map
208
206
  this.networkRequestsInFlight[networkRequestInFlightKey] = dataPromise;
209
- _context.next = 31;
207
+ _context.next = 30;
210
208
  return dataPromise;
211
- case 31:
209
+ case 30:
212
210
  _data = _context.sent;
213
211
  // We need to call the callback with the data with result even if the cache version has changed,
214
212
  // so all promises that are waiting for the data can resolve.
@@ -225,25 +223,25 @@ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
225
223
  data: _data
226
224
  };
227
225
  }
228
- _context.next = 39;
226
+ _context.next = 38;
229
227
  break;
230
- case 36:
231
- _context.prev = 36;
232
- _context.t1 = _context["catch"](26);
228
+ case 35:
229
+ _context.prev = 35;
230
+ _context.t1 = _context["catch"](25);
233
231
  // If an error occurs, we call the callback with the error
234
232
  callback({
235
233
  error: _context.t1 instanceof Error ? _context.t1 : new Error(String(_context.t1))
236
234
  });
237
- case 39:
238
- _context.prev = 39;
235
+ case 38:
236
+ _context.prev = 38;
239
237
  // Ensure we clean up the in-flight request entry
240
238
  delete this.networkRequestsInFlight[networkRequestInFlightKey];
241
- return _context.finish(39);
242
- case 42:
239
+ return _context.finish(38);
240
+ case 41:
243
241
  case "end":
244
242
  return _context.stop();
245
243
  }
246
- }, _callee, this, [[15, 22], [26, 36, 39, 42]]);
244
+ }, _callee, this, [[14, 21], [25, 35, 38, 41]]);
247
245
  }));
248
246
  function getDataAsync(_x, _x2) {
249
247
  return _getDataAsync.apply(this, arguments);
@@ -151,10 +151,11 @@ export class NodeDataProvider {
151
151
  callback({
152
152
  data: dataFromCache.data
153
153
  });
154
- if (isSSR()) {
155
- // If we are in SSR, we don't want to fetch the data again, as it is already available in the SSR data
156
- return;
157
- }
154
+ }
155
+ if (isSSR()) {
156
+ // During SSR, we only use the cache and never fetch from the network.
157
+ // Use loading state instead.
158
+ return;
158
159
  }
159
160
 
160
161
  // If no data is available in the cache, or the data is from the network,
@@ -148,22 +148,20 @@ export var NodeDataProvider = /*#__PURE__*/function () {
148
148
  case 4:
149
149
  dataKey = this.nodeDataKey(jsonNode);
150
150
  dataFromCache = this.cache[dataKey];
151
- if (!(dataFromCache !== undefined)) {
152
- _context.next = 10;
153
- break;
151
+ if (dataFromCache !== undefined) {
152
+ // If we have the data in the SSR data, we can use it directly
153
+ callback({
154
+ data: dataFromCache.data
155
+ });
154
156
  }
155
- // If we have the data in the SSR data, we can use it directly
156
- callback({
157
- data: dataFromCache.data
158
- });
159
157
  if (!isSSR()) {
160
- _context.next = 10;
158
+ _context.next = 9;
161
159
  break;
162
160
  }
163
161
  return _context.abrupt("return");
164
- case 10:
162
+ case 9:
165
163
  if (!((dataFromCache === null || dataFromCache === void 0 ? void 0 : dataFromCache.source) !== 'network')) {
166
- _context.next = 42;
164
+ _context.next = 41;
167
165
  break;
168
166
  }
169
167
  // Store the current cache version before making the request,
@@ -174,38 +172,38 @@ export var NodeDataProvider = /*#__PURE__*/function () {
174
172
  // to avoid duplicate requests.
175
173
  networkRequestInFlight = this.networkRequestsInFlight[networkRequestInFlightKey];
176
174
  if (!networkRequestInFlight) {
177
- _context.next = 26;
175
+ _context.next = 25;
178
176
  break;
179
177
  }
180
- _context.prev = 15;
181
- _context.next = 18;
178
+ _context.prev = 14;
179
+ _context.next = 17;
182
180
  return networkRequestInFlight;
183
- case 18:
181
+ case 17:
184
182
  data = _context.sent;
185
183
  callback({
186
184
  data: data
187
185
  });
188
- _context.next = 25;
186
+ _context.next = 24;
189
187
  break;
190
- case 22:
191
- _context.prev = 22;
192
- _context.t0 = _context["catch"](15);
188
+ case 21:
189
+ _context.prev = 21;
190
+ _context.t0 = _context["catch"](14);
193
191
  callback({
194
192
  error: _context.t0 instanceof Error ? _context.t0 : new Error(String(_context.t0))
195
193
  });
196
- case 25:
194
+ case 24:
197
195
  return _context.abrupt("return");
198
- case 26:
199
- _context.prev = 26;
196
+ case 25:
197
+ _context.prev = 25;
200
198
  dataPromise = this.fetchNodesData([jsonNode]).then(function (_ref3) {
201
199
  var _ref4 = _slicedToArray(_ref3, 1),
202
200
  value = _ref4[0];
203
201
  return value;
204
202
  }); // Store the promise in the in-flight requests map
205
203
  this.networkRequestsInFlight[networkRequestInFlightKey] = dataPromise;
206
- _context.next = 31;
204
+ _context.next = 30;
207
205
  return dataPromise;
208
- case 31:
206
+ case 30:
209
207
  _data = _context.sent;
210
208
  // We need to call the callback with the data with result even if the cache version has changed,
211
209
  // so all promises that are waiting for the data can resolve.
@@ -222,25 +220,25 @@ export var NodeDataProvider = /*#__PURE__*/function () {
222
220
  data: _data
223
221
  };
224
222
  }
225
- _context.next = 39;
223
+ _context.next = 38;
226
224
  break;
227
- case 36:
228
- _context.prev = 36;
229
- _context.t1 = _context["catch"](26);
225
+ case 35:
226
+ _context.prev = 35;
227
+ _context.t1 = _context["catch"](25);
230
228
  // If an error occurs, we call the callback with the error
231
229
  callback({
232
230
  error: _context.t1 instanceof Error ? _context.t1 : new Error(String(_context.t1))
233
231
  });
234
- case 39:
235
- _context.prev = 39;
232
+ case 38:
233
+ _context.prev = 38;
236
234
  // Ensure we clean up the in-flight request entry
237
235
  delete this.networkRequestsInFlight[networkRequestInFlightKey];
238
- return _context.finish(39);
239
- case 42:
236
+ return _context.finish(38);
237
+ case 41:
240
238
  case "end":
241
239
  return _context.stop();
242
240
  }
243
- }, _callee, this, [[15, 22], [26, 36, 39, 42]]);
241
+ }, _callee, this, [[14, 21], [25, 35, 38, 41]]);
244
242
  }));
245
243
  function getDataAsync(_x, _x2) {
246
244
  return _getDataAsync.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/node-data-provider",
3
- "version": "7.4.0",
3
+ "version": "7.5.0",
4
4
  "description": "Node data provider for @atlaskit/editor-core plugins and @atlaskit/renderer",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,7 +26,7 @@
26
26
  "@babel/runtime": "^7.0.0"
27
27
  },
28
28
  "peerDependencies": {
29
- "@atlaskit/editor-common": "^110.21.0"
29
+ "@atlaskit/editor-common": "^110.22.0"
30
30
  },
31
31
  "techstack": {
32
32
  "@atlassian/frontend": {