@khanacademy/wonder-blocks-data 8.0.2 → 8.0.5
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 +22 -0
- package/dist/es/index.js +68 -70
- package/dist/index.js +124 -249
- package/package.json +4 -3
- package/src/hooks/use-cached-effect.js +3 -14
- package/src/hooks/use-hydratable-effect.js +0 -4
- package/src/index.js +1 -0
- package/src/util/types.js +0 -4
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +0 -337
- package/src/__tests__/generated-snapshot.test.js +0 -350
package/src/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export {Status} from "./util/status.js";
|
|
|
39
39
|
// GraphQL
|
|
40
40
|
////////////////////////////////////////////////////////////////////////////////
|
|
41
41
|
export {getGqlRequestId} from "./util/get-gql-request-id.js";
|
|
42
|
+
export {getGqlDataFromResponse} from "./util/get-gql-data-from-response.js";
|
|
42
43
|
export {graphQLDocumentNodeParser} from "./util/graphql-document-node-parser.js";
|
|
43
44
|
export {toGqlOperation} from "./util/to-gql-operation.js";
|
|
44
45
|
export {GqlRouter} from "./components/gql-router.js";
|
package/src/util/types.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import type {Metadata} from "@khanacademy/wonder-stuff-core";
|
|
3
3
|
|
|
4
|
-
// TODO(somewhatabstract, FEI-4172): Update eslint-plugin-flowtype when
|
|
5
|
-
// they've fixed https://github.com/gajus/eslint-plugin-flowtype/issues/502
|
|
6
|
-
/* eslint-disable no-undef */
|
|
7
4
|
/**
|
|
8
5
|
* Defines the various fetch policies that can be applied to requests.
|
|
9
6
|
*/
|
|
@@ -30,7 +27,6 @@ export enum FetchPolicy {
|
|
|
30
27
|
*/
|
|
31
28
|
NetworkOnly,
|
|
32
29
|
}
|
|
33
|
-
/* eslint-enable no-undef */
|
|
34
30
|
|
|
35
31
|
/**
|
|
36
32
|
* Define what can be cached.
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`wonder-blocks-data example 1 1`] = `
|
|
4
|
-
<div
|
|
5
|
-
className=""
|
|
6
|
-
style={
|
|
7
|
-
Object {
|
|
8
|
-
"alignItems": "stretch",
|
|
9
|
-
"borderStyle": "solid",
|
|
10
|
-
"borderWidth": 0,
|
|
11
|
-
"boxSizing": "border-box",
|
|
12
|
-
"display": "flex",
|
|
13
|
-
"flexDirection": "column",
|
|
14
|
-
"margin": 0,
|
|
15
|
-
"minHeight": 0,
|
|
16
|
-
"minWidth": 0,
|
|
17
|
-
"padding": 0,
|
|
18
|
-
"position": "relative",
|
|
19
|
-
"zIndex": 0,
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
>
|
|
23
|
-
<div
|
|
24
|
-
className=""
|
|
25
|
-
style={
|
|
26
|
-
Object {
|
|
27
|
-
"alignItems": "stretch",
|
|
28
|
-
"borderStyle": "solid",
|
|
29
|
-
"borderWidth": 0,
|
|
30
|
-
"boxSizing": "border-box",
|
|
31
|
-
"display": "flex",
|
|
32
|
-
"flexDirection": "column",
|
|
33
|
-
"margin": 0,
|
|
34
|
-
"minHeight": 0,
|
|
35
|
-
"minWidth": 0,
|
|
36
|
-
"padding": 0,
|
|
37
|
-
"position": "relative",
|
|
38
|
-
"zIndex": 0,
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
>
|
|
42
|
-
<span
|
|
43
|
-
className=""
|
|
44
|
-
style={
|
|
45
|
-
Object {
|
|
46
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
47
|
-
"WebkitFontSmoothing": "antialiased",
|
|
48
|
-
"display": "block",
|
|
49
|
-
"fontFamily": "Lato, \\"Noto Sans\\", sans-serif",
|
|
50
|
-
"fontSize": 16,
|
|
51
|
-
"fontWeight": 400,
|
|
52
|
-
"lineHeight": "22px",
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
>
|
|
56
|
-
This request will succeed and give us data!
|
|
57
|
-
</span>
|
|
58
|
-
Loading...
|
|
59
|
-
</div>
|
|
60
|
-
<div
|
|
61
|
-
aria-hidden="true"
|
|
62
|
-
className=""
|
|
63
|
-
style={
|
|
64
|
-
Object {
|
|
65
|
-
"MsFlexBasis": 12,
|
|
66
|
-
"MsFlexPreferredSize": 12,
|
|
67
|
-
"WebkitFlexBasis": 12,
|
|
68
|
-
"alignItems": "stretch",
|
|
69
|
-
"borderStyle": "solid",
|
|
70
|
-
"borderWidth": 0,
|
|
71
|
-
"boxSizing": "border-box",
|
|
72
|
-
"display": "flex",
|
|
73
|
-
"flexBasis": 12,
|
|
74
|
-
"flexDirection": "column",
|
|
75
|
-
"flexShrink": 0,
|
|
76
|
-
"margin": 0,
|
|
77
|
-
"minHeight": 0,
|
|
78
|
-
"minWidth": 0,
|
|
79
|
-
"padding": 0,
|
|
80
|
-
"position": "relative",
|
|
81
|
-
"width": 12,
|
|
82
|
-
"zIndex": 0,
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/>
|
|
86
|
-
<div
|
|
87
|
-
className=""
|
|
88
|
-
style={
|
|
89
|
-
Object {
|
|
90
|
-
"alignItems": "stretch",
|
|
91
|
-
"borderStyle": "solid",
|
|
92
|
-
"borderWidth": 0,
|
|
93
|
-
"boxSizing": "border-box",
|
|
94
|
-
"display": "flex",
|
|
95
|
-
"flexDirection": "column",
|
|
96
|
-
"margin": 0,
|
|
97
|
-
"minHeight": 0,
|
|
98
|
-
"minWidth": 0,
|
|
99
|
-
"padding": 0,
|
|
100
|
-
"position": "relative",
|
|
101
|
-
"zIndex": 0,
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
>
|
|
105
|
-
<span
|
|
106
|
-
className=""
|
|
107
|
-
style={
|
|
108
|
-
Object {
|
|
109
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
110
|
-
"WebkitFontSmoothing": "antialiased",
|
|
111
|
-
"display": "block",
|
|
112
|
-
"fontFamily": "Lato, \\"Noto Sans\\", sans-serif",
|
|
113
|
-
"fontSize": 16,
|
|
114
|
-
"fontWeight": 400,
|
|
115
|
-
"lineHeight": "22px",
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
>
|
|
119
|
-
This request will go boom and give us an error!
|
|
120
|
-
</span>
|
|
121
|
-
Loading...
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
`;
|
|
125
|
-
|
|
126
|
-
exports[`wonder-blocks-data example 2 1`] = `
|
|
127
|
-
<div
|
|
128
|
-
className=""
|
|
129
|
-
style={
|
|
130
|
-
Object {
|
|
131
|
-
"alignItems": "stretch",
|
|
132
|
-
"borderStyle": "solid",
|
|
133
|
-
"borderWidth": 0,
|
|
134
|
-
"boxSizing": "border-box",
|
|
135
|
-
"display": "flex",
|
|
136
|
-
"flexDirection": "column",
|
|
137
|
-
"margin": 0,
|
|
138
|
-
"minHeight": 0,
|
|
139
|
-
"minWidth": 0,
|
|
140
|
-
"padding": 0,
|
|
141
|
-
"position": "relative",
|
|
142
|
-
"zIndex": 0,
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
>
|
|
146
|
-
<div
|
|
147
|
-
className=""
|
|
148
|
-
style={
|
|
149
|
-
Object {
|
|
150
|
-
"alignItems": "stretch",
|
|
151
|
-
"borderStyle": "solid",
|
|
152
|
-
"borderWidth": 0,
|
|
153
|
-
"boxSizing": "border-box",
|
|
154
|
-
"display": "flex",
|
|
155
|
-
"flexDirection": "column",
|
|
156
|
-
"margin": 0,
|
|
157
|
-
"minHeight": 0,
|
|
158
|
-
"minWidth": 0,
|
|
159
|
-
"padding": 0,
|
|
160
|
-
"position": "relative",
|
|
161
|
-
"zIndex": 0,
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
>
|
|
165
|
-
<span
|
|
166
|
-
className=""
|
|
167
|
-
style={
|
|
168
|
-
Object {
|
|
169
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
170
|
-
"WebkitFontSmoothing": "antialiased",
|
|
171
|
-
"display": "block",
|
|
172
|
-
"fontFamily": "Lato, \\"Noto Sans\\", sans-serif",
|
|
173
|
-
"fontSize": 16,
|
|
174
|
-
"fontWeight": 400,
|
|
175
|
-
"lineHeight": "22px",
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
>
|
|
179
|
-
This cache has data!
|
|
180
|
-
</span>
|
|
181
|
-
<span
|
|
182
|
-
className=""
|
|
183
|
-
style={
|
|
184
|
-
Object {
|
|
185
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
186
|
-
"WebkitFontSmoothing": "antialiased",
|
|
187
|
-
"display": "block",
|
|
188
|
-
"fontFamily": "Inconsolata, monospace",
|
|
189
|
-
"fontSize": 17,
|
|
190
|
-
"fontWeight": 400,
|
|
191
|
-
"lineHeight": "22px",
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
>
|
|
195
|
-
I'm DATA from the hydration cache
|
|
196
|
-
</span>
|
|
197
|
-
</div>
|
|
198
|
-
</div>
|
|
199
|
-
`;
|
|
200
|
-
|
|
201
|
-
exports[`wonder-blocks-data example 3 1`] = `
|
|
202
|
-
<div
|
|
203
|
-
className=""
|
|
204
|
-
style={
|
|
205
|
-
Object {
|
|
206
|
-
"alignItems": "stretch",
|
|
207
|
-
"borderStyle": "solid",
|
|
208
|
-
"borderWidth": 0,
|
|
209
|
-
"boxSizing": "border-box",
|
|
210
|
-
"display": "flex",
|
|
211
|
-
"flexDirection": "column",
|
|
212
|
-
"margin": 0,
|
|
213
|
-
"minHeight": 0,
|
|
214
|
-
"minWidth": 0,
|
|
215
|
-
"padding": 0,
|
|
216
|
-
"position": "relative",
|
|
217
|
-
"zIndex": 0,
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
>
|
|
221
|
-
<span
|
|
222
|
-
className=""
|
|
223
|
-
style={
|
|
224
|
-
Object {
|
|
225
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
226
|
-
"WebkitFontSmoothing": "antialiased",
|
|
227
|
-
"display": "block",
|
|
228
|
-
"fontFamily": "Lato, \\"Noto Sans\\", sans-serif",
|
|
229
|
-
"fontSize": 16,
|
|
230
|
-
"fontWeight": 400,
|
|
231
|
-
"lineHeight": "22px",
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
>
|
|
235
|
-
This received intercepted data!
|
|
236
|
-
</span>
|
|
237
|
-
If you see this, the example is broken!
|
|
238
|
-
</div>
|
|
239
|
-
`;
|
|
240
|
-
|
|
241
|
-
exports[`wonder-blocks-data example 4 1`] = `"Sorry, no snapshot for you"`;
|
|
242
|
-
|
|
243
|
-
exports[`wonder-blocks-data example 5 1`] = `
|
|
244
|
-
<div
|
|
245
|
-
className=""
|
|
246
|
-
style={
|
|
247
|
-
Object {
|
|
248
|
-
"alignItems": "stretch",
|
|
249
|
-
"borderStyle": "solid",
|
|
250
|
-
"borderWidth": 0,
|
|
251
|
-
"boxSizing": "border-box",
|
|
252
|
-
"display": "flex",
|
|
253
|
-
"flexDirection": "column",
|
|
254
|
-
"margin": 0,
|
|
255
|
-
"minHeight": 0,
|
|
256
|
-
"minWidth": 0,
|
|
257
|
-
"padding": 0,
|
|
258
|
-
"position": "relative",
|
|
259
|
-
"zIndex": 0,
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
>
|
|
263
|
-
<button
|
|
264
|
-
aria-disabled={false}
|
|
265
|
-
className=""
|
|
266
|
-
onBlur={[Function]}
|
|
267
|
-
onClick={[Function]}
|
|
268
|
-
onDragStart={[Function]}
|
|
269
|
-
onFocus={[Function]}
|
|
270
|
-
onKeyDown={[Function]}
|
|
271
|
-
onKeyUp={[Function]}
|
|
272
|
-
onMouseDown={[Function]}
|
|
273
|
-
onMouseEnter={[Function]}
|
|
274
|
-
onMouseLeave={[Function]}
|
|
275
|
-
onMouseUp={[Function]}
|
|
276
|
-
onTouchCancel={[Function]}
|
|
277
|
-
onTouchEnd={[Function]}
|
|
278
|
-
onTouchStart={[Function]}
|
|
279
|
-
role="button"
|
|
280
|
-
style={
|
|
281
|
-
Object {
|
|
282
|
-
"::MozFocusInner": Object {
|
|
283
|
-
"border": 0,
|
|
284
|
-
},
|
|
285
|
-
":focus": Object {
|
|
286
|
-
"WebkitTapHighlightColor": "rgba(0,0,0,0)",
|
|
287
|
-
},
|
|
288
|
-
"alignItems": "center",
|
|
289
|
-
"background": "#1865f2",
|
|
290
|
-
"border": "none",
|
|
291
|
-
"borderRadius": 4,
|
|
292
|
-
"boxSizing": "border-box",
|
|
293
|
-
"color": "#ffffff",
|
|
294
|
-
"cursor": "pointer",
|
|
295
|
-
"display": "inline-flex",
|
|
296
|
-
"height": 40,
|
|
297
|
-
"justifyContent": "center",
|
|
298
|
-
"margin": 0,
|
|
299
|
-
"outline": "none",
|
|
300
|
-
"paddingBottom": 0,
|
|
301
|
-
"paddingLeft": 16,
|
|
302
|
-
"paddingRight": 16,
|
|
303
|
-
"paddingTop": 0,
|
|
304
|
-
"position": "relative",
|
|
305
|
-
"textDecoration": "none",
|
|
306
|
-
"touchAction": "manipulation",
|
|
307
|
-
"userSelect": "none",
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
tabIndex={0}
|
|
311
|
-
type="button"
|
|
312
|
-
>
|
|
313
|
-
<span
|
|
314
|
-
className=""
|
|
315
|
-
style={
|
|
316
|
-
Object {
|
|
317
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
318
|
-
"WebkitFontSmoothing": "antialiased",
|
|
319
|
-
"alignItems": "center",
|
|
320
|
-
"display": "inline-block",
|
|
321
|
-
"fontFamily": "Lato, \\"Noto Sans\\", sans-serif",
|
|
322
|
-
"fontSize": 16,
|
|
323
|
-
"fontWeight": "bold",
|
|
324
|
-
"lineHeight": "20px",
|
|
325
|
-
"overflow": "hidden",
|
|
326
|
-
"pointerEvents": "none",
|
|
327
|
-
"textOverflow": "ellipsis",
|
|
328
|
-
"whiteSpace": "nowrap",
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
>
|
|
332
|
-
Enable Server-side Mode
|
|
333
|
-
</span>
|
|
334
|
-
</button>
|
|
335
|
-
Sorry, no snapshot for you
|
|
336
|
-
</div>
|
|
337
|
-
`;
|