houdini-react 1.2.22 → 1.2.23

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.
@@ -49,4 +49,18 @@ export declare function updateLocalSession(session: App.Session): void;
49
49
  export declare function useSession(): App.Session;
50
50
  export declare function useCurrentVariables(): GraphQLVariables;
51
51
  export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
52
+ export type RouterCache = {
53
+ artifact_cache: SuspenseCache<QueryArtifact>;
54
+ component_cache: SuspenseCache<(props: any) => React.ReactElement>;
55
+ data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
56
+ last_variables: LRUCache<GraphQLVariables>;
57
+ pending_cache: PendingCache;
58
+ };
59
+ export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
60
+ pending_queries?: string[];
61
+ artifacts?: Record<string, QueryArtifact>;
62
+ components?: Record<string, (props: any) => React.ReactElement>;
63
+ initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
64
+ initialArtifacts?: Record<string, QueryArtifact>;
65
+ }): RouterCache;
52
66
  export {};
@@ -26,6 +26,7 @@ var Router_exports = {};
26
26
  __export(Router_exports, {
27
27
  Router: () => Router,
28
28
  RouterContextProvider: () => RouterContextProvider,
29
+ router_cache: () => router_cache,
29
30
  updateLocalSession: () => updateLocalSession,
30
31
  useCache: () => useCache,
31
32
  useClient: () => useClient,
@@ -41,6 +42,7 @@ var import_match = require("$houdini/runtime/router/match");
41
42
  var import_react = __toESM(require("react"));
42
43
  var import_react_streaming = require("react-streaming");
43
44
  var import_useDocumentStore = require("../hooks/useDocumentStore");
45
+ var import_cache = require("./cache");
44
46
  const PreloadWhich = {
45
47
  component: "component",
46
48
  data: "data",
@@ -371,10 +373,51 @@ function usePreload({ preload }) {
371
373
  };
372
374
  }, []);
373
375
  }
376
+ function router_cache({
377
+ pending_queries = [],
378
+ artifacts = {},
379
+ components = {},
380
+ initialData = {},
381
+ initialArtifacts = {}
382
+ } = {}) {
383
+ const result = {
384
+ artifact_cache: (0, import_cache.suspense_cache)(initialArtifacts),
385
+ component_cache: (0, import_cache.suspense_cache)(),
386
+ data_cache: (0, import_cache.suspense_cache)(initialData),
387
+ pending_cache: (0, import_cache.suspense_cache)(),
388
+ last_variables: (0, import_cache.suspense_cache)()
389
+ };
390
+ for (const query of pending_queries) {
391
+ result.pending_cache.set(query, signal_promise());
392
+ }
393
+ for (const [name, artifact] of Object.entries(artifacts)) {
394
+ result.artifact_cache.set(name, artifact);
395
+ }
396
+ for (const [name, component] of Object.entries(components)) {
397
+ result.component_cache.set(name, component);
398
+ }
399
+ return result;
400
+ }
401
+ function signal_promise() {
402
+ let resolve = () => {
403
+ };
404
+ let reject = () => {
405
+ };
406
+ const promise = new Promise((res, rej) => {
407
+ resolve = res;
408
+ reject = rej;
409
+ });
410
+ return {
411
+ ...promise,
412
+ resolve,
413
+ reject
414
+ };
415
+ }
374
416
  // Annotate the CommonJS export names for ESM import in node:
375
417
  0 && (module.exports = {
376
418
  Router,
377
419
  RouterContextProvider,
420
+ router_cache,
378
421
  updateLocalSession,
379
422
  useCache,
380
423
  useClient,
@@ -1,27 +1,10 @@
1
1
  import type { Cache } from '$houdini/runtime/cache/cache';
2
- import { DocumentStore } from '$houdini/runtime/client';
3
- import { LRUCache } from '$houdini/runtime/lib/lru';
4
- import { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
5
- import React from 'react';
6
- import { SuspenseCache, type PendingCache } from './routing';
2
+ import { RouterCache } from './routing';
7
3
  export * from './hooks';
4
+ export { router_cache } from './routing';
8
5
  export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
9
6
  initialURL: string;
10
7
  cache: Cache;
11
8
  session?: App.Session;
12
9
  assetPrefix: string;
13
10
  } & RouterCache): JSX.Element;
14
- type RouterCache = {
15
- artifact_cache: SuspenseCache<QueryArtifact>;
16
- component_cache: SuspenseCache<(props: any) => React.ReactElement>;
17
- data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
18
- last_variables: LRUCache<GraphQLVariables>;
19
- pending_cache: PendingCache;
20
- };
21
- export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
22
- pending_queries?: string[];
23
- artifacts?: Record<string, QueryArtifact>;
24
- components?: Record<string, (props: any) => React.ReactElement>;
25
- initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
26
- initialArtifacts?: Record<string, QueryArtifact>;
27
- }): RouterCache;
@@ -1,12 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import client from "./client";
3
3
  import manifest from "./manifest";
4
- import {
5
- suspense_cache,
6
- Router as RouterImpl,
7
- RouterContextProvider
8
- } from "./routing";
4
+ import { Router as RouterImpl, RouterContextProvider } from "./routing";
9
5
  export * from "./hooks";
6
+ import { router_cache } from "./routing";
10
7
  function Router({
11
8
  cache,
12
9
  initialURL,
@@ -33,46 +30,6 @@ function Router({
33
30
  }
34
31
  );
35
32
  }
36
- function router_cache({
37
- pending_queries = [],
38
- artifacts = {},
39
- components = {},
40
- initialData = {},
41
- initialArtifacts = {}
42
- } = {}) {
43
- const result = {
44
- artifact_cache: suspense_cache(initialArtifacts),
45
- component_cache: suspense_cache(),
46
- data_cache: suspense_cache(initialData),
47
- pending_cache: suspense_cache(),
48
- last_variables: suspense_cache()
49
- };
50
- for (const query of pending_queries) {
51
- result.pending_cache.set(query, signal_promise());
52
- }
53
- for (const [name, artifact] of Object.entries(artifacts)) {
54
- result.artifact_cache.set(name, artifact);
55
- }
56
- for (const [name, component] of Object.entries(components)) {
57
- result.component_cache.set(name, component);
58
- }
59
- return result;
60
- }
61
- function signal_promise() {
62
- let resolve = () => {
63
- };
64
- let reject = () => {
65
- };
66
- const promise = new Promise((res, rej) => {
67
- resolve = res;
68
- reject = rej;
69
- });
70
- return {
71
- ...promise,
72
- resolve,
73
- reject
74
- };
75
- }
76
33
  export {
77
34
  Router,
78
35
  router_cache
@@ -49,4 +49,18 @@ export declare function updateLocalSession(session: App.Session): void;
49
49
  export declare function useSession(): App.Session;
50
50
  export declare function useCurrentVariables(): GraphQLVariables;
51
51
  export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
52
+ export type RouterCache = {
53
+ artifact_cache: SuspenseCache<QueryArtifact>;
54
+ component_cache: SuspenseCache<(props: any) => React.ReactElement>;
55
+ data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
56
+ last_variables: LRUCache<GraphQLVariables>;
57
+ pending_cache: PendingCache;
58
+ };
59
+ export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
60
+ pending_queries?: string[];
61
+ artifacts?: Record<string, QueryArtifact>;
62
+ components?: Record<string, (props: any) => React.ReactElement>;
63
+ initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
64
+ initialArtifacts?: Record<string, QueryArtifact>;
65
+ }): RouterCache;
52
66
  export {};
@@ -4,6 +4,7 @@ import { find_match } from "$houdini/runtime/router/match";
4
4
  import React from "react";
5
5
  import { useStream } from "react-streaming";
6
6
  import { useDocumentStore } from "../hooks/useDocumentStore";
7
+ import { suspense_cache } from "./cache";
7
8
  const PreloadWhich = {
8
9
  component: "component",
9
10
  data: "data",
@@ -334,9 +335,50 @@ function usePreload({ preload }) {
334
335
  };
335
336
  }, []);
336
337
  }
338
+ function router_cache({
339
+ pending_queries = [],
340
+ artifacts = {},
341
+ components = {},
342
+ initialData = {},
343
+ initialArtifacts = {}
344
+ } = {}) {
345
+ const result = {
346
+ artifact_cache: suspense_cache(initialArtifacts),
347
+ component_cache: suspense_cache(),
348
+ data_cache: suspense_cache(initialData),
349
+ pending_cache: suspense_cache(),
350
+ last_variables: suspense_cache()
351
+ };
352
+ for (const query of pending_queries) {
353
+ result.pending_cache.set(query, signal_promise());
354
+ }
355
+ for (const [name, artifact] of Object.entries(artifacts)) {
356
+ result.artifact_cache.set(name, artifact);
357
+ }
358
+ for (const [name, component] of Object.entries(components)) {
359
+ result.component_cache.set(name, component);
360
+ }
361
+ return result;
362
+ }
363
+ function signal_promise() {
364
+ let resolve = () => {
365
+ };
366
+ let reject = () => {
367
+ };
368
+ const promise = new Promise((res, rej) => {
369
+ resolve = res;
370
+ reject = rej;
371
+ });
372
+ return {
373
+ ...promise,
374
+ resolve,
375
+ reject
376
+ };
377
+ }
337
378
  export {
338
379
  Router,
339
380
  RouterContextProvider,
381
+ router_cache,
340
382
  updateLocalSession,
341
383
  useCache,
342
384
  useClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -42,7 +42,7 @@
42
42
  "recast": "^0.23.1",
43
43
  "rollup": "^3.7.4",
44
44
  "use-deep-compare-effect": "^1.8.1",
45
- "houdini": "^1.2.22"
45
+ "houdini": "^1.2.23"
46
46
  },
47
47
  "files": [
48
48
  "build"