@khanacademy/wonder-blocks-data 14.1.0 → 14.1.2
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 +15 -0
- package/dist/es/index.js +9 -9
- package/dist/index.js +20 -14
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-data
|
|
2
2
|
|
|
3
|
+
## 14.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ed26d66]
|
|
8
|
+
- @khanacademy/wonder-blocks-core@12.2.0
|
|
9
|
+
|
|
10
|
+
## 14.1.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- ee8d95a: Rollback rollup version from v4 to v2 to prevent an issue with CJS builds in unit tests
|
|
15
|
+
- Updated dependencies [ee8d95a]
|
|
16
|
+
- @khanacademy/wonder-blocks-core@12.1.1
|
|
17
|
+
|
|
3
18
|
## 14.1.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/dist/es/index.js
CHANGED
|
@@ -36,7 +36,7 @@ class DataError extends KindError {
|
|
|
36
36
|
|
|
37
37
|
class ScopedInMemoryCache {
|
|
38
38
|
constructor(initialCache = {}) {
|
|
39
|
-
this._cache =
|
|
39
|
+
this._cache = void 0;
|
|
40
40
|
this._cache = initialCache;
|
|
41
41
|
}
|
|
42
42
|
get inUse() {
|
|
@@ -58,7 +58,7 @@ class ScopedInMemoryCache {
|
|
|
58
58
|
}
|
|
59
59
|
get(scope, id) {
|
|
60
60
|
var _this$_cache$scope$id, _this$_cache$scope2;
|
|
61
|
-
return (_this$_cache$scope$id = (_this$_cache$scope2 = this._cache[scope]) == null ?
|
|
61
|
+
return (_this$_cache$scope$id = (_this$_cache$scope2 = this._cache[scope]) == null ? void 0 : _this$_cache$scope2[id]) != null ? _this$_cache$scope$id : null;
|
|
62
62
|
}
|
|
63
63
|
purge(scope, id) {
|
|
64
64
|
var _this$_cache$scope3;
|
|
@@ -130,8 +130,8 @@ class SsrCache {
|
|
|
130
130
|
return _default$2;
|
|
131
131
|
}
|
|
132
132
|
constructor(hydrationCache = null, ssrOnlyCache = null) {
|
|
133
|
-
this._hydrationCache =
|
|
134
|
-
this._ssrOnlyCache =
|
|
133
|
+
this._hydrationCache = void 0;
|
|
134
|
+
this._ssrOnlyCache = void 0;
|
|
135
135
|
this.initialize = source => {
|
|
136
136
|
if (this._hydrationCache.inUse) {
|
|
137
137
|
throw new Error("Cannot initialize data response cache more than once");
|
|
@@ -249,8 +249,8 @@ class RequestTracker {
|
|
|
249
249
|
}
|
|
250
250
|
constructor(responseCache) {
|
|
251
251
|
this._trackedRequests = {};
|
|
252
|
-
this._responseCache =
|
|
253
|
-
this._requestFulfillment =
|
|
252
|
+
this._responseCache = void 0;
|
|
253
|
+
this._requestFulfillment = void 0;
|
|
254
254
|
this.trackDataRequest = (id, handler, hydrate) => {
|
|
255
255
|
if (this._trackedRequests[id] == null) {
|
|
256
256
|
this._trackedRequests[id] = {
|
|
@@ -461,7 +461,7 @@ const useCachedEffect = (requestId, handler, options = {}) => {
|
|
|
461
461
|
const request = RequestFulfillment.Default.fulfill(`${requestId}|${scope}`, {
|
|
462
462
|
handler: interceptedHandler
|
|
463
463
|
});
|
|
464
|
-
if (request === ((_currentRequestRef$cu2 = currentRequestRef.current) == null ?
|
|
464
|
+
if (request === ((_currentRequestRef$cu2 = currentRequestRef.current) == null ? void 0 : _currentRequestRef$cu2.request)) {
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
467
|
networkResultRef.current = null;
|
|
@@ -552,7 +552,7 @@ const useHydratableEffect = (requestId, handler, options = {}) => {
|
|
|
552
552
|
case WhenClientSide.ExecuteWhenNoResult:
|
|
553
553
|
return serverResult;
|
|
554
554
|
case WhenClientSide.ExecuteWhenNoSuccessResult:
|
|
555
|
-
if ((serverResult == null ?
|
|
555
|
+
if ((serverResult == null ? void 0 : serverResult.status) === "success") {
|
|
556
556
|
return serverResult;
|
|
557
557
|
}
|
|
558
558
|
return null;
|
|
@@ -745,7 +745,7 @@ function graphQLDocumentNodeParser(document) {
|
|
|
745
745
|
const definitions = queries.length ? queries : mutations;
|
|
746
746
|
const definition = definitions[0];
|
|
747
747
|
const variables = definition.variableDefinitions || [];
|
|
748
|
-
const name = ((_definition$name = definition.name) == null ?
|
|
748
|
+
const name = ((_definition$name = definition.name) == null ? void 0 : _definition$name.kind) === "Name" ? definition.name.value : "data";
|
|
749
749
|
const payload = {
|
|
750
750
|
name,
|
|
751
751
|
type,
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
4
6
|
var wonderStuffCore = require('@khanacademy/wonder-stuff-core');
|
|
5
7
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
6
8
|
var React = require('react');
|
|
7
9
|
|
|
8
|
-
function
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
9
14
|
var n = Object.create(null);
|
|
10
15
|
if (e) {
|
|
11
16
|
Object.keys(e).forEach(function (k) {
|
|
@@ -18,11 +23,12 @@ function _interopNamespaceDefault(e) {
|
|
|
18
23
|
}
|
|
19
24
|
});
|
|
20
25
|
}
|
|
21
|
-
n
|
|
26
|
+
n["default"] = e;
|
|
22
27
|
return Object.freeze(n);
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
var
|
|
30
|
+
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
31
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
32
|
|
|
27
33
|
let FetchPolicy = function (FetchPolicy) {
|
|
28
34
|
FetchPolicy["CacheBeforeNetwork"] = "CacheBeforeNetwork";
|
|
@@ -56,7 +62,7 @@ class DataError extends wonderStuffCore.KindError {
|
|
|
56
62
|
|
|
57
63
|
class ScopedInMemoryCache {
|
|
58
64
|
constructor(initialCache = {}) {
|
|
59
|
-
this._cache =
|
|
65
|
+
this._cache = void 0;
|
|
60
66
|
this._cache = initialCache;
|
|
61
67
|
}
|
|
62
68
|
get inUse() {
|
|
@@ -78,7 +84,7 @@ class ScopedInMemoryCache {
|
|
|
78
84
|
}
|
|
79
85
|
get(scope, id) {
|
|
80
86
|
var _this$_cache$scope$id, _this$_cache$scope2;
|
|
81
|
-
return (_this$_cache$scope$id = (_this$_cache$scope2 = this._cache[scope]) == null ?
|
|
87
|
+
return (_this$_cache$scope$id = (_this$_cache$scope2 = this._cache[scope]) == null ? void 0 : _this$_cache$scope2[id]) != null ? _this$_cache$scope$id : null;
|
|
82
88
|
}
|
|
83
89
|
purge(scope, id) {
|
|
84
90
|
var _this$_cache$scope3;
|
|
@@ -150,8 +156,8 @@ class SsrCache {
|
|
|
150
156
|
return _default$2;
|
|
151
157
|
}
|
|
152
158
|
constructor(hydrationCache = null, ssrOnlyCache = null) {
|
|
153
|
-
this._hydrationCache =
|
|
154
|
-
this._ssrOnlyCache =
|
|
159
|
+
this._hydrationCache = void 0;
|
|
160
|
+
this._ssrOnlyCache = void 0;
|
|
155
161
|
this.initialize = source => {
|
|
156
162
|
if (this._hydrationCache.inUse) {
|
|
157
163
|
throw new Error("Cannot initialize data response cache more than once");
|
|
@@ -269,8 +275,8 @@ class RequestTracker {
|
|
|
269
275
|
}
|
|
270
276
|
constructor(responseCache) {
|
|
271
277
|
this._trackedRequests = {};
|
|
272
|
-
this._responseCache =
|
|
273
|
-
this._requestFulfillment =
|
|
278
|
+
this._responseCache = void 0;
|
|
279
|
+
this._requestFulfillment = void 0;
|
|
274
280
|
this.trackDataRequest = (id, handler, hydrate) => {
|
|
275
281
|
if (this._trackedRequests[id] == null) {
|
|
276
282
|
this._trackedRequests[id] = {
|
|
@@ -291,7 +297,7 @@ class RequestTracker {
|
|
|
291
297
|
for (const requestKey of Object.keys(this._trackedRequests)) {
|
|
292
298
|
const options = this._trackedRequests[requestKey];
|
|
293
299
|
try {
|
|
294
|
-
promises.push(this._requestFulfillment.fulfill(requestKey,
|
|
300
|
+
promises.push(this._requestFulfillment.fulfill(requestKey, _extends__default["default"]({}, options)).then(result => {
|
|
295
301
|
switch (result.status) {
|
|
296
302
|
case "success":
|
|
297
303
|
cacheData(requestKey, result.data, options.hydrate);
|
|
@@ -481,7 +487,7 @@ const useCachedEffect = (requestId, handler, options = {}) => {
|
|
|
481
487
|
const request = RequestFulfillment.Default.fulfill(`${requestId}|${scope}`, {
|
|
482
488
|
handler: interceptedHandler
|
|
483
489
|
});
|
|
484
|
-
if (request === ((_currentRequestRef$cu2 = currentRequestRef.current) == null ?
|
|
490
|
+
if (request === ((_currentRequestRef$cu2 = currentRequestRef.current) == null ? void 0 : _currentRequestRef$cu2.request)) {
|
|
485
491
|
return;
|
|
486
492
|
}
|
|
487
493
|
networkResultRef.current = null;
|
|
@@ -572,7 +578,7 @@ const useHydratableEffect = (requestId, handler, options = {}) => {
|
|
|
572
578
|
case WhenClientSide.ExecuteWhenNoResult:
|
|
573
579
|
return serverResult;
|
|
574
580
|
case WhenClientSide.ExecuteWhenNoSuccessResult:
|
|
575
|
-
if ((serverResult == null ?
|
|
581
|
+
if ((serverResult == null ? void 0 : serverResult.status) === "success") {
|
|
576
582
|
return serverResult;
|
|
577
583
|
}
|
|
578
584
|
return null;
|
|
@@ -765,7 +771,7 @@ function graphQLDocumentNodeParser(document) {
|
|
|
765
771
|
const definitions = queries.length ? queries : mutations;
|
|
766
772
|
const definition = definitions[0];
|
|
767
773
|
const variables = definition.variableDefinitions || [];
|
|
768
|
-
const name = ((_definition$name = definition.name) == null ?
|
|
774
|
+
const name = ((_definition$name = definition.name) == null ? void 0 : _definition$name.kind) === "Name" ? definition.name.value : "data";
|
|
769
775
|
const payload = {
|
|
770
776
|
name,
|
|
771
777
|
type,
|
|
@@ -811,7 +817,7 @@ const mergeGqlContext = (defaultContext, overrides) => {
|
|
|
811
817
|
}
|
|
812
818
|
}
|
|
813
819
|
return acc;
|
|
814
|
-
},
|
|
820
|
+
}, _extends__default["default"]({}, defaultContext));
|
|
815
821
|
};
|
|
816
822
|
|
|
817
823
|
const useGqlRouterContext = (contextOverrides = {}) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-data",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.2",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@babel/runtime": "^7.24.5",
|
|
14
|
-
"@khanacademy/wonder-blocks-core": "12.
|
|
14
|
+
"@khanacademy/wonder-blocks-core": "12.2.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@khanacademy/wonder-stuff-core": "^1.5.4",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@khanacademy/wonder-stuff-testing": "^3.0.5",
|
|
22
|
-
"@khanacademy/wb-dev-build-settings": "2.1.
|
|
23
|
-
"@khanacademy/wonder-blocks-testing-core": "2.
|
|
22
|
+
"@khanacademy/wb-dev-build-settings": "2.1.1",
|
|
23
|
+
"@khanacademy/wonder-blocks-testing-core": "2.2.0"
|
|
24
24
|
},
|
|
25
25
|
"author": "",
|
|
26
26
|
"license": "MIT",
|