@khanacademy/wonder-blocks-data 5.0.0 → 5.0.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 +6 -0
- package/dist/es/index.js +1 -1
- package/dist/index.js +68 -64
- package/package.json +1 -1
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -983,4 +983,4 @@ const hasUnfulfilledRequests = () => {
|
|
|
983
983
|
const removeFromCache = id => SsrCache.Default.remove(id);
|
|
984
984
|
const removeAllFromCache = predicate => SsrCache.Default.removeAll(predicate);
|
|
985
985
|
|
|
986
|
-
export { Data, GqlError, GqlErrors, GqlRouter, InterceptRequests, ScopedInMemoryCache, TrackData, clearSharedCache, fulfillAllDataRequests, hasUnfulfilledRequests, initializeCache, removeAllFromCache, removeFromCache, useGql, useRequestInterception, useServerEffect, useSharedCache };
|
|
986
|
+
export { Data, GqlError, GqlErrors, GqlRouter, InterceptRequests, ScopedInMemoryCache, TrackData, clearSharedCache, fulfillAllDataRequests, hasUnfulfilledRequests, initializeCache, removeAllFromCache, removeFromCache, resultFromCachedResponse, useGql, useRequestInterception, useServerEffect, useSharedCache };
|
package/dist/index.js
CHANGED
|
@@ -419,7 +419,7 @@ class ScopedInMemoryCache {
|
|
|
419
419
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
420
420
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
421
421
|
/* harmony import */ var _ssr_cache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
422
|
-
/* harmony import */ var _request_fulfillment_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
422
|
+
/* harmony import */ var _request_fulfillment_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
|
|
423
423
|
|
|
424
424
|
|
|
425
425
|
|
|
@@ -667,6 +667,47 @@ const useRequestInterception = (requestId, handler) => {
|
|
|
667
667
|
/* 10 */
|
|
668
668
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
669
669
|
|
|
670
|
+
"use strict";
|
|
671
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return resultFromCachedResponse; });
|
|
672
|
+
/**
|
|
673
|
+
* Turns a cache entry into a stateful result.
|
|
674
|
+
*/
|
|
675
|
+
const resultFromCachedResponse = cacheEntry => {
|
|
676
|
+
// No cache entry means we didn't load one yet.
|
|
677
|
+
if (cacheEntry == null) {
|
|
678
|
+
return {
|
|
679
|
+
status: "loading"
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const {
|
|
684
|
+
data,
|
|
685
|
+
error
|
|
686
|
+
} = cacheEntry;
|
|
687
|
+
|
|
688
|
+
if (error != null) {
|
|
689
|
+
return {
|
|
690
|
+
status: "error",
|
|
691
|
+
error
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (data != null) {
|
|
696
|
+
return {
|
|
697
|
+
status: "success",
|
|
698
|
+
data
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
return {
|
|
703
|
+
status: "aborted"
|
|
704
|
+
};
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
/***/ }),
|
|
708
|
+
/* 11 */
|
|
709
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
710
|
+
|
|
670
711
|
"use strict";
|
|
671
712
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return RequestFulfillment; });
|
|
672
713
|
/* harmony import */ var _ssr_cache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
@@ -758,7 +799,7 @@ class RequestFulfillment {
|
|
|
758
799
|
}
|
|
759
800
|
|
|
760
801
|
/***/ }),
|
|
761
|
-
/*
|
|
802
|
+
/* 12 */
|
|
762
803
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
763
804
|
|
|
764
805
|
"use strict";
|
|
@@ -769,7 +810,7 @@ class RequestFulfillment {
|
|
|
769
810
|
const GqlRouterContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createContext"](null);
|
|
770
811
|
|
|
771
812
|
/***/ }),
|
|
772
|
-
/*
|
|
813
|
+
/* 13 */
|
|
773
814
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
774
815
|
|
|
775
816
|
"use strict";
|
|
@@ -860,7 +901,7 @@ const useSharedCache = (id, scope, initialValue) => {
|
|
|
860
901
|
};
|
|
861
902
|
|
|
862
903
|
/***/ }),
|
|
863
|
-
/*
|
|
904
|
+
/* 14 */
|
|
864
905
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
865
906
|
|
|
866
907
|
"use strict";
|
|
@@ -891,7 +932,7 @@ class TrackData extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
891
932
|
}
|
|
892
933
|
|
|
893
934
|
/***/ }),
|
|
894
|
-
/*
|
|
935
|
+
/* 15 */
|
|
895
936
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
896
937
|
|
|
897
938
|
"use strict";
|
|
@@ -899,10 +940,10 @@ class TrackData extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
899
940
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
900
941
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
901
942
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__);
|
|
902
|
-
/* harmony import */ var _util_request_fulfillment_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
943
|
+
/* harmony import */ var _util_request_fulfillment_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
|
|
903
944
|
/* harmony import */ var _hooks_use_server_effect_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
|
|
904
945
|
/* harmony import */ var _hooks_use_request_interception_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
|
|
905
|
-
/* harmony import */ var _util_result_from_cache_response_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
946
|
+
/* harmony import */ var _util_result_from_cache_response_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(10);
|
|
906
947
|
|
|
907
948
|
|
|
908
949
|
|
|
@@ -1005,7 +1046,7 @@ const Data = ({
|
|
|
1005
1046
|
/* harmony default export */ __webpack_exports__["a"] = (Data);
|
|
1006
1047
|
|
|
1007
1048
|
/***/ }),
|
|
1008
|
-
/*
|
|
1049
|
+
/* 16 */
|
|
1009
1050
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1010
1051
|
|
|
1011
1052
|
"use strict";
|
|
@@ -1046,14 +1087,14 @@ const InterceptRequests = ({
|
|
|
1046
1087
|
/* harmony default export */ __webpack_exports__["a"] = (InterceptRequests);
|
|
1047
1088
|
|
|
1048
1089
|
/***/ }),
|
|
1049
|
-
/*
|
|
1090
|
+
/* 17 */
|
|
1050
1091
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1051
1092
|
|
|
1052
1093
|
"use strict";
|
|
1053
1094
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GqlRouter; });
|
|
1054
1095
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1055
1096
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1056
|
-
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1097
|
+
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
|
|
1057
1098
|
|
|
1058
1099
|
|
|
1059
1100
|
|
|
@@ -1090,14 +1131,14 @@ const GqlRouter = ({
|
|
|
1090
1131
|
};
|
|
1091
1132
|
|
|
1092
1133
|
/***/ }),
|
|
1093
|
-
/*
|
|
1134
|
+
/* 18 */
|
|
1094
1135
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1095
1136
|
|
|
1096
1137
|
"use strict";
|
|
1097
1138
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useGql; });
|
|
1098
1139
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1099
1140
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1100
|
-
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1141
|
+
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
|
|
1101
1142
|
/* harmony import */ var _util_get_gql_data_from_response_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(19);
|
|
1102
1143
|
/* harmony import */ var _util_gql_error_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
1103
1144
|
|
|
@@ -1168,47 +1209,6 @@ const useGql = () => {
|
|
|
1168
1209
|
return gqlFetch;
|
|
1169
1210
|
};
|
|
1170
1211
|
|
|
1171
|
-
/***/ }),
|
|
1172
|
-
/* 18 */
|
|
1173
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1174
|
-
|
|
1175
|
-
"use strict";
|
|
1176
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return resultFromCachedResponse; });
|
|
1177
|
-
/**
|
|
1178
|
-
* Turns a cache entry into a stateful result.
|
|
1179
|
-
*/
|
|
1180
|
-
const resultFromCachedResponse = cacheEntry => {
|
|
1181
|
-
// No cache entry means we didn't load one yet.
|
|
1182
|
-
if (cacheEntry == null) {
|
|
1183
|
-
return {
|
|
1184
|
-
status: "loading"
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
const {
|
|
1189
|
-
data,
|
|
1190
|
-
error
|
|
1191
|
-
} = cacheEntry;
|
|
1192
|
-
|
|
1193
|
-
if (error != null) {
|
|
1194
|
-
return {
|
|
1195
|
-
status: "error",
|
|
1196
|
-
error
|
|
1197
|
-
};
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
if (data != null) {
|
|
1201
|
-
return {
|
|
1202
|
-
status: "success",
|
|
1203
|
-
data
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
return {
|
|
1208
|
-
status: "aborted"
|
|
1209
|
-
};
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
1212
|
/***/ }),
|
|
1213
1213
|
/* 19 */
|
|
1214
1214
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
@@ -1292,13 +1292,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1292
1292
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
1293
1293
|
/* harmony import */ var _util_ssr_cache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
1294
1294
|
/* harmony import */ var _util_request_tracking_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
|
|
1295
|
-
/* harmony import */ var _components_track_data_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
1295
|
+
/* harmony import */ var _components_track_data_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
|
|
1296
1296
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrackData", function() { return _components_track_data_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
1297
1297
|
|
|
1298
|
-
/* harmony import */ var _components_data_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
1298
|
+
/* harmony import */ var _components_data_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
|
|
1299
1299
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Data", function() { return _components_data_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
|
|
1300
1300
|
|
|
1301
|
-
/* harmony import */ var _components_intercept_requests_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
1301
|
+
/* harmony import */ var _components_intercept_requests_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(16);
|
|
1302
1302
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterceptRequests", function() { return _components_intercept_requests_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
|
|
1303
1303
|
|
|
1304
1304
|
/* harmony import */ var _hooks_use_server_effect_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8);
|
|
@@ -1307,7 +1307,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1307
1307
|
/* harmony import */ var _hooks_use_request_interception_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9);
|
|
1308
1308
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useRequestInterception", function() { return _hooks_use_request_interception_js__WEBPACK_IMPORTED_MODULE_7__["a"]; });
|
|
1309
1309
|
|
|
1310
|
-
/* harmony import */ var _hooks_use_shared_cache_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
|
|
1310
|
+
/* harmony import */ var _hooks_use_shared_cache_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(13);
|
|
1311
1311
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useSharedCache", function() { return _hooks_use_shared_cache_js__WEBPACK_IMPORTED_MODULE_8__["b"]; });
|
|
1312
1312
|
|
|
1313
1313
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "clearSharedCache", function() { return _hooks_use_shared_cache_js__WEBPACK_IMPORTED_MODULE_8__["a"]; });
|
|
@@ -1315,16 +1315,19 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1315
1315
|
/* harmony import */ var _util_scoped_in_memory_cache_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5);
|
|
1316
1316
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScopedInMemoryCache", function() { return _util_scoped_in_memory_cache_js__WEBPACK_IMPORTED_MODULE_9__["a"]; });
|
|
1317
1317
|
|
|
1318
|
-
/* harmony import */ var
|
|
1319
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1318
|
+
/* harmony import */ var _util_result_from_cache_response_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(10);
|
|
1319
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "resultFromCachedResponse", function() { return _util_result_from_cache_response_js__WEBPACK_IMPORTED_MODULE_10__["a"]; });
|
|
1320
|
+
|
|
1321
|
+
/* harmony import */ var _components_gql_router_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(17);
|
|
1322
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlRouter", function() { return _components_gql_router_js__WEBPACK_IMPORTED_MODULE_11__["a"]; });
|
|
1320
1323
|
|
|
1321
|
-
/* harmony import */ var
|
|
1322
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useGql", function() { return
|
|
1324
|
+
/* harmony import */ var _hooks_use_gql_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(18);
|
|
1325
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useGql", function() { return _hooks_use_gql_js__WEBPACK_IMPORTED_MODULE_12__["a"]; });
|
|
1323
1326
|
|
|
1324
|
-
/* harmony import */ var
|
|
1325
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlErrors", function() { return
|
|
1327
|
+
/* harmony import */ var _util_gql_error_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(2);
|
|
1328
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlErrors", function() { return _util_gql_error_js__WEBPACK_IMPORTED_MODULE_13__["b"]; });
|
|
1326
1329
|
|
|
1327
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlError", function() { return
|
|
1330
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlError", function() { return _util_gql_error_js__WEBPACK_IMPORTED_MODULE_13__["a"]; });
|
|
1328
1331
|
|
|
1329
1332
|
|
|
1330
1333
|
|
|
@@ -1352,6 +1355,7 @@ const removeAllFromCache = predicate => _util_ssr_cache_js__WEBPACK_IMPORTED_MOD
|
|
|
1352
1355
|
|
|
1353
1356
|
|
|
1354
1357
|
|
|
1358
|
+
|
|
1355
1359
|
// GraphQL
|
|
1356
1360
|
|
|
1357
1361
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -52,6 +52,7 @@ export {useServerEffect} from "./hooks/use-server-effect.js";
|
|
|
52
52
|
export {useRequestInterception} from "./hooks/use-request-interception.js";
|
|
53
53
|
export {useSharedCache, clearSharedCache} from "./hooks/use-shared-cache.js";
|
|
54
54
|
export {ScopedInMemoryCache} from "./util/scoped-in-memory-cache.js";
|
|
55
|
+
export {resultFromCachedResponse} from "./util/result-from-cache-response.js";
|
|
55
56
|
|
|
56
57
|
// GraphQL
|
|
57
58
|
export {GqlRouter} from "./components/gql-router.js";
|