houdini-react 0.0.0-20240329062150 → 0.0.0-20240330051817
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.
|
@@ -98,10 +98,10 @@ function Router({
|
|
|
98
98
|
},
|
|
99
99
|
preload(url, which) {
|
|
100
100
|
const [page2, variables2] = (0, import_match.find_match)(import_config.default, manifest, url);
|
|
101
|
-
if (["
|
|
101
|
+
if (["page", "component"].includes(which)) {
|
|
102
102
|
loadComponent(page2);
|
|
103
103
|
}
|
|
104
|
-
if (["
|
|
104
|
+
if (["page", "data"].includes(which)) {
|
|
105
105
|
loadData(page2, variables2);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -125,9 +125,13 @@ function usePageData({
|
|
|
125
125
|
last_variables
|
|
126
126
|
} = useRouterContext();
|
|
127
127
|
const [session] = useSession();
|
|
128
|
-
function load_query({
|
|
128
|
+
function load_query({
|
|
129
|
+
id,
|
|
130
|
+
artifact,
|
|
131
|
+
variables: variables2
|
|
132
|
+
}) {
|
|
129
133
|
for (const artifact2 of Object.keys(page.documents)) {
|
|
130
|
-
last_variables.set(artifact2,
|
|
134
|
+
last_variables.set(artifact2, variables2);
|
|
131
135
|
}
|
|
132
136
|
if (ssr_signals.has(id)) {
|
|
133
137
|
return ssr_signals.get(id);
|
|
@@ -141,7 +145,7 @@ function usePageData({
|
|
|
141
145
|
resolve = res;
|
|
142
146
|
reject = rej;
|
|
143
147
|
observer.send({
|
|
144
|
-
variables,
|
|
148
|
+
variables: variables2,
|
|
145
149
|
session
|
|
146
150
|
}).then(async () => {
|
|
147
151
|
data_cache.set(id, observer);
|
|
@@ -177,7 +181,7 @@ function usePageData({
|
|
|
177
181
|
variables: ${JSON.stringify(
|
|
178
182
|
(0, import_scalars.marshalInputs)({
|
|
179
183
|
artifact: observer.artifact,
|
|
180
|
-
input:
|
|
184
|
+
input: variables2,
|
|
181
185
|
config: import_config.default
|
|
182
186
|
})
|
|
183
187
|
)}
|
|
@@ -218,7 +222,7 @@ function usePageData({
|
|
|
218
222
|
variables: ${JSON.stringify(
|
|
219
223
|
(0, import_scalars.marshalInputs)({
|
|
220
224
|
artifact: observer.artifact,
|
|
221
|
-
input:
|
|
225
|
+
input: variables2,
|
|
222
226
|
config: import_config.default
|
|
223
227
|
})
|
|
224
228
|
)}
|
|
@@ -275,14 +279,14 @@ function usePageData({
|
|
|
275
279
|
injectToStream?.(`
|
|
276
280
|
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""><\/script>
|
|
277
281
|
`);
|
|
278
|
-
load_query({ id: artifact.name, artifact });
|
|
282
|
+
load_query({ id: artifact.name, artifact, variables: variables2 });
|
|
279
283
|
}).catch((err) => {
|
|
280
284
|
console.log(err);
|
|
281
285
|
});
|
|
282
286
|
}
|
|
283
287
|
for (const artifact of Object.values(found_artifacts)) {
|
|
284
288
|
if (!data_cache.has(artifact.name)) {
|
|
285
|
-
load_query({ id: artifact.name, artifact });
|
|
289
|
+
load_query({ id: artifact.name, artifact, variables: variables2 });
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
292
|
}
|
|
@@ -451,10 +455,14 @@ function usePreload({ preload }) {
|
|
|
451
455
|
import_react.default.useEffect(() => {
|
|
452
456
|
const mouseMove = (e) => {
|
|
453
457
|
const target = e.target;
|
|
454
|
-
if (!(target instanceof
|
|
458
|
+
if (!(target instanceof HTMLElement)) {
|
|
455
459
|
return;
|
|
456
460
|
}
|
|
457
|
-
|
|
461
|
+
const anchor = target.closest("a");
|
|
462
|
+
if (!anchor) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
let preloadWhichRaw = anchor.attributes.getNamedItem("data-houdini-preload")?.value;
|
|
458
466
|
let preloadWhich = !preloadWhichRaw || preloadWhichRaw === "true" ? "page" : preloadWhichRaw;
|
|
459
467
|
if (!PreloadWhich[preloadWhich]) {
|
|
460
468
|
console.log(
|
|
@@ -466,7 +474,7 @@ function usePreload({ preload }) {
|
|
|
466
474
|
clearTimeout(timeoutRef.current);
|
|
467
475
|
}
|
|
468
476
|
timeoutRef.current = setTimeout(() => {
|
|
469
|
-
const url =
|
|
477
|
+
const url = anchor.attributes.getNamedItem("href")?.value;
|
|
470
478
|
if (!url) {
|
|
471
479
|
return;
|
|
472
480
|
}
|
|
@@ -57,10 +57,10 @@ function Router({
|
|
|
57
57
|
},
|
|
58
58
|
preload(url, which) {
|
|
59
59
|
const [page2, variables2] = find_match(configFile, manifest, url);
|
|
60
|
-
if (["
|
|
60
|
+
if (["page", "component"].includes(which)) {
|
|
61
61
|
loadComponent(page2);
|
|
62
62
|
}
|
|
63
|
-
if (["
|
|
63
|
+
if (["page", "data"].includes(which)) {
|
|
64
64
|
loadData(page2, variables2);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -84,9 +84,13 @@ function usePageData({
|
|
|
84
84
|
last_variables
|
|
85
85
|
} = useRouterContext();
|
|
86
86
|
const [session] = useSession();
|
|
87
|
-
function load_query({
|
|
87
|
+
function load_query({
|
|
88
|
+
id,
|
|
89
|
+
artifact,
|
|
90
|
+
variables: variables2
|
|
91
|
+
}) {
|
|
88
92
|
for (const artifact2 of Object.keys(page.documents)) {
|
|
89
|
-
last_variables.set(artifact2,
|
|
93
|
+
last_variables.set(artifact2, variables2);
|
|
90
94
|
}
|
|
91
95
|
if (ssr_signals.has(id)) {
|
|
92
96
|
return ssr_signals.get(id);
|
|
@@ -100,7 +104,7 @@ function usePageData({
|
|
|
100
104
|
resolve = res;
|
|
101
105
|
reject = rej;
|
|
102
106
|
observer.send({
|
|
103
|
-
variables,
|
|
107
|
+
variables: variables2,
|
|
104
108
|
session
|
|
105
109
|
}).then(async () => {
|
|
106
110
|
data_cache.set(id, observer);
|
|
@@ -136,7 +140,7 @@ function usePageData({
|
|
|
136
140
|
variables: ${JSON.stringify(
|
|
137
141
|
marshalInputs({
|
|
138
142
|
artifact: observer.artifact,
|
|
139
|
-
input:
|
|
143
|
+
input: variables2,
|
|
140
144
|
config: configFile
|
|
141
145
|
})
|
|
142
146
|
)}
|
|
@@ -177,7 +181,7 @@ function usePageData({
|
|
|
177
181
|
variables: ${JSON.stringify(
|
|
178
182
|
marshalInputs({
|
|
179
183
|
artifact: observer.artifact,
|
|
180
|
-
input:
|
|
184
|
+
input: variables2,
|
|
181
185
|
config: configFile
|
|
182
186
|
})
|
|
183
187
|
)}
|
|
@@ -234,14 +238,14 @@ function usePageData({
|
|
|
234
238
|
injectToStream?.(`
|
|
235
239
|
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""><\/script>
|
|
236
240
|
`);
|
|
237
|
-
load_query({ id: artifact.name, artifact });
|
|
241
|
+
load_query({ id: artifact.name, artifact, variables: variables2 });
|
|
238
242
|
}).catch((err) => {
|
|
239
243
|
console.log(err);
|
|
240
244
|
});
|
|
241
245
|
}
|
|
242
246
|
for (const artifact of Object.values(found_artifacts)) {
|
|
243
247
|
if (!data_cache.has(artifact.name)) {
|
|
244
|
-
load_query({ id: artifact.name, artifact });
|
|
248
|
+
load_query({ id: artifact.name, artifact, variables: variables2 });
|
|
245
249
|
}
|
|
246
250
|
}
|
|
247
251
|
}
|
|
@@ -410,10 +414,14 @@ function usePreload({ preload }) {
|
|
|
410
414
|
React.useEffect(() => {
|
|
411
415
|
const mouseMove = (e) => {
|
|
412
416
|
const target = e.target;
|
|
413
|
-
if (!(target instanceof
|
|
417
|
+
if (!(target instanceof HTMLElement)) {
|
|
414
418
|
return;
|
|
415
419
|
}
|
|
416
|
-
|
|
420
|
+
const anchor = target.closest("a");
|
|
421
|
+
if (!anchor) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
let preloadWhichRaw = anchor.attributes.getNamedItem("data-houdini-preload")?.value;
|
|
417
425
|
let preloadWhich = !preloadWhichRaw || preloadWhichRaw === "true" ? "page" : preloadWhichRaw;
|
|
418
426
|
if (!PreloadWhich[preloadWhich]) {
|
|
419
427
|
console.log(
|
|
@@ -425,7 +433,7 @@ function usePreload({ preload }) {
|
|
|
425
433
|
clearTimeout(timeoutRef.current);
|
|
426
434
|
}
|
|
427
435
|
timeoutRef.current = setTimeout(() => {
|
|
428
|
-
const url =
|
|
436
|
+
const url = anchor.attributes.getNamedItem("href")?.value;
|
|
429
437
|
if (!url) {
|
|
430
438
|
return;
|
|
431
439
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20240330051817",
|
|
4
4
|
"description": "The React plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"recast": "^0.23.1",
|
|
44
44
|
"rollup": "^3.7.4",
|
|
45
45
|
"use-deep-compare-effect": "^1.8.1",
|
|
46
|
-
"houdini": "^0.0.0-
|
|
46
|
+
"houdini": "^0.0.0-20240330051817"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"build"
|