houdini-react 1.2.0-react.1 → 1.2.7

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.
Files changed (134) hide show
  1. package/README.md +1 -1
  2. package/build/plugin/codegen/entries.d.ts +6 -0
  3. package/build/plugin/codegen/index.d.ts +14 -0
  4. package/build/plugin/codegen/manifest.d.ts +42 -0
  5. package/build/plugin/codegen/render.d.ts +2 -0
  6. package/build/plugin/codegen/router.d.ts +8 -0
  7. package/build/plugin/codegen/typeRoot.d.ts +6 -0
  8. package/build/plugin/config.d.ts +2 -1
  9. package/build/plugin/conventions.d.ts +24 -0
  10. package/build/plugin/dedent.d.ts +1 -0
  11. package/build/plugin/extract.d.ts +1 -1
  12. package/build/plugin/index.d.ts +16 -3
  13. package/build/plugin/vite.d.ts +19 -0
  14. package/build/plugin-cjs/index.js +132171 -43771
  15. package/build/plugin-esm/index.js +132162 -43765
  16. package/build/runtime/client.d.ts +3 -0
  17. package/build/runtime/clientPlugin.d.ts +3 -0
  18. package/build/runtime/hooks/useDocumentHandle.d.ts +4 -4
  19. package/build/runtime/hooks/useDocumentStore.d.ts +6 -5
  20. package/build/runtime/hooks/useDocumentSubscription.d.ts +4 -3
  21. package/build/runtime/hooks/useFragment.d.ts +3 -2
  22. package/build/runtime/hooks/useFragmentHandle.d.ts +2 -3
  23. package/build/runtime/hooks/useMutation.d.ts +2 -2
  24. package/build/runtime/hooks/useQuery.d.ts +3 -3
  25. package/build/runtime/hooks/useQueryHandle.d.ts +3 -3
  26. package/build/runtime/hooks/useSubscription.d.ts +2 -2
  27. package/build/runtime/hooks/useSubscriptionHandle.d.ts +3 -3
  28. package/build/runtime/index.d.ts +30 -1
  29. package/build/runtime/manifest.d.ts +3 -0
  30. package/build/runtime/routing/components/Link.d.ts +5 -0
  31. package/build/runtime/routing/components/Router.d.ts +56 -0
  32. package/build/runtime/routing/components/index.d.ts +2 -0
  33. package/build/runtime/routing/index.d.ts +3 -0
  34. package/build/runtime/routing/lib/cache.d.ts +7 -0
  35. package/build/runtime/routing/lib/match.d.ts +38 -0
  36. package/build/runtime/routing/lib/types.d.ts +23 -0
  37. package/build/runtime-cjs/client.d.ts +3 -0
  38. package/build/runtime-cjs/client.js +26 -0
  39. package/build/runtime-cjs/clientPlugin.d.ts +3 -0
  40. package/build/{next-cjs/index.js → runtime-cjs/clientPlugin.js} +15 -26
  41. package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +4 -4
  42. package/build/runtime-cjs/hooks/useDocumentHandle.js +11 -7
  43. package/build/runtime-cjs/hooks/useDocumentStore.d.ts +6 -5
  44. package/build/runtime-cjs/hooks/useDocumentStore.js +9 -4
  45. package/build/runtime-cjs/hooks/useDocumentSubscription.d.ts +4 -3
  46. package/build/runtime-cjs/hooks/useDocumentSubscription.js +15 -8
  47. package/build/runtime-cjs/hooks/useFragment.d.ts +3 -2
  48. package/build/runtime-cjs/hooks/useFragment.js +9 -7
  49. package/build/runtime-cjs/hooks/useFragmentHandle.d.ts +2 -3
  50. package/build/runtime-cjs/hooks/useMutation.d.ts +2 -2
  51. package/build/runtime-cjs/hooks/useMutation.js +3 -1
  52. package/build/runtime-cjs/hooks/useQuery.d.ts +3 -3
  53. package/build/runtime-cjs/hooks/useQueryHandle.d.ts +3 -3
  54. package/build/runtime-cjs/hooks/useQueryHandle.js +4 -4
  55. package/build/runtime-cjs/hooks/useSubscription.d.ts +2 -2
  56. package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +3 -3
  57. package/build/runtime-cjs/index.d.ts +30 -1
  58. package/build/runtime-cjs/index.js +89 -3
  59. package/build/runtime-cjs/manifest.d.ts +3 -0
  60. package/build/runtime-cjs/manifest.js +27 -0
  61. package/build/runtime-cjs/routing/components/Link.d.ts +5 -0
  62. package/build/runtime-cjs/{hooks/useHoudiniClient.js → routing/components/Link.js} +22 -13
  63. package/build/runtime-cjs/routing/components/Router.d.ts +56 -0
  64. package/build/runtime-cjs/routing/components/Router.js +296 -0
  65. package/build/runtime-cjs/routing/components/index.d.ts +2 -0
  66. package/build/runtime-cjs/{context.js → routing/components/index.js} +15 -19
  67. package/build/runtime-cjs/routing/index.d.ts +3 -0
  68. package/build/runtime-cjs/routing/index.js +30 -0
  69. package/build/runtime-cjs/routing/lib/cache.d.ts +7 -0
  70. package/build/runtime-cjs/{lib → routing/lib}/cache.js +23 -40
  71. package/build/runtime-cjs/routing/lib/match.d.ts +38 -0
  72. package/build/runtime-cjs/routing/lib/match.js +149 -0
  73. package/build/runtime-cjs/routing/lib/types.d.ts +23 -0
  74. package/build/runtime-cjs/routing/lib/types.js +16 -0
  75. package/build/runtime-esm/client.d.ts +3 -0
  76. package/build/runtime-esm/client.js +4 -0
  77. package/build/runtime-esm/clientPlugin.d.ts +3 -0
  78. package/build/runtime-esm/clientPlugin.js +17 -0
  79. package/build/runtime-esm/hooks/useDocumentHandle.d.ts +4 -4
  80. package/build/runtime-esm/hooks/useDocumentHandle.js +12 -10
  81. package/build/runtime-esm/hooks/useDocumentStore.d.ts +6 -5
  82. package/build/runtime-esm/hooks/useDocumentStore.js +9 -4
  83. package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +4 -3
  84. package/build/runtime-esm/hooks/useDocumentSubscription.js +15 -8
  85. package/build/runtime-esm/hooks/useFragment.d.ts +3 -2
  86. package/build/runtime-esm/hooks/useFragment.js +9 -7
  87. package/build/runtime-esm/hooks/useFragmentHandle.d.ts +2 -3
  88. package/build/runtime-esm/hooks/useMutation.d.ts +2 -2
  89. package/build/runtime-esm/hooks/useMutation.js +3 -1
  90. package/build/runtime-esm/hooks/useQuery.d.ts +3 -3
  91. package/build/runtime-esm/hooks/useQueryHandle.d.ts +3 -3
  92. package/build/runtime-esm/hooks/useQueryHandle.js +4 -4
  93. package/build/runtime-esm/hooks/useSubscription.d.ts +2 -2
  94. package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +3 -3
  95. package/build/runtime-esm/index.d.ts +30 -1
  96. package/build/runtime-esm/index.js +81 -2
  97. package/build/runtime-esm/manifest.d.ts +3 -0
  98. package/build/runtime-esm/manifest.js +5 -0
  99. package/build/runtime-esm/routing/components/Link.d.ts +5 -0
  100. package/build/runtime-esm/routing/components/Link.js +21 -0
  101. package/build/runtime-esm/routing/components/Router.d.ts +56 -0
  102. package/build/runtime-esm/routing/components/Router.js +257 -0
  103. package/build/runtime-esm/routing/components/index.d.ts +2 -0
  104. package/build/runtime-esm/routing/components/index.js +9 -0
  105. package/build/runtime-esm/routing/index.d.ts +3 -0
  106. package/build/runtime-esm/routing/index.js +5 -0
  107. package/build/runtime-esm/routing/lib/cache.d.ts +7 -0
  108. package/build/runtime-esm/routing/lib/cache.js +29 -0
  109. package/build/runtime-esm/routing/lib/match.d.ts +38 -0
  110. package/build/runtime-esm/routing/lib/match.js +122 -0
  111. package/build/runtime-esm/routing/lib/types.d.ts +23 -0
  112. package/build/runtime-esm/routing/lib/types.js +0 -0
  113. package/build/server/compat.d.ts +7 -0
  114. package/build/server/index.d.ts +17 -0
  115. package/build/server/session.d.ts +3 -0
  116. package/build/server-cjs/index.js +166712 -0
  117. package/build/server-esm/index.js +166703 -0
  118. package/package.json +21 -10
  119. package/build/next/index.d.ts +0 -2
  120. package/build/next-esm/index.js +0 -26
  121. package/build/runtime/context.d.ts +0 -7
  122. package/build/runtime/hooks/useHoudiniClient.d.ts +0 -2
  123. package/build/runtime/lib/cache.d.ts +0 -62
  124. package/build/runtime-cjs/context.d.ts +0 -7
  125. package/build/runtime-cjs/hooks/useHoudiniClient.d.ts +0 -2
  126. package/build/runtime-cjs/lib/cache.d.ts +0 -62
  127. package/build/runtime-esm/context.d.ts +0 -7
  128. package/build/runtime-esm/context.js +0 -10
  129. package/build/runtime-esm/hooks/useHoudiniClient.d.ts +0 -2
  130. package/build/runtime-esm/hooks/useHoudiniClient.js +0 -12
  131. package/build/runtime-esm/lib/cache.d.ts +0 -62
  132. package/build/runtime-esm/lib/cache.js +0 -47
  133. /package/build/{next-cjs → server-cjs}/package.json +0 -0
  134. /package/build/{next-esm → server-esm}/package.json +0 -0
@@ -1,6 +1,6 @@
1
1
  import { fragmentKey } from '$houdini/runtime/lib/types';
2
- import type { GraphQLObject, FragmentArtifact } from '$houdini/runtime/lib/types';
3
- export declare function useFragment<_Data extends GraphQLObject, _ReferenceType extends {}, _Input extends {} = {}>(reference: _Data | {
2
+ import type { GraphQLObject, GraphQLVariables, FragmentArtifact } from '$houdini/runtime/lib/types';
3
+ export declare function useFragment<_Data extends GraphQLObject, _ReferenceType extends {}, _Input extends GraphQLVariables = GraphQLVariables>(reference: _Data | {
4
4
  [fragmentKey]: _ReferenceType;
5
5
  } | null, document: {
6
6
  artifact: FragmentArtifact;
@@ -12,4 +12,5 @@ export declare function fragmentReference<_Data extends GraphQLObject, _Input, _
12
12
  }): {
13
13
  variables: _Input;
14
14
  parent: string;
15
+ loading: boolean;
15
16
  };
@@ -35,7 +35,7 @@ var React = __toESM(require("react"));
35
35
  var import_useDeepCompareEffect = require("./useDeepCompareEffect");
36
36
  var import_useDocumentSubscription = require("./useDocumentSubscription");
37
37
  function useFragment(reference, document) {
38
- const { parent, variables } = fragmentReference(
38
+ const { parent, variables, loading } = fragmentReference(
39
39
  reference,
40
40
  document
41
41
  );
@@ -44,20 +44,21 @@ function useFragment(reference, document) {
44
44
  cachedValue = import_cache.default.read({
45
45
  selection: document.artifact.selection,
46
46
  parent,
47
- variables
47
+ variables,
48
+ loading
48
49
  }).data;
49
50
  }
50
- const observeParams = {
51
+ const [storeValue] = (0, import_useDocumentSubscription.useDocumentSubscription)({
51
52
  artifact: document.artifact,
52
53
  variables,
53
54
  initialValue: cachedValue,
55
+ disabled: loading,
54
56
  send: {
55
57
  stuff: {
56
58
  parentID: parent
57
59
  }
58
60
  }
59
- };
60
- const [storeValue] = (0, import_useDocumentSubscription.useDocumentSubscription)(observeParams);
61
+ });
61
62
  const lastReference = React.useRef(null);
62
63
  return React.useMemo(() => {
63
64
  const parentChange = storeValue.parent !== parent || !(0, import_deepEquals.deepEquals)({ parent, variables }, lastReference.current);
@@ -77,14 +78,15 @@ function useFragment(reference, document) {
77
78
  ]);
78
79
  }
79
80
  function fragmentReference(reference, document) {
80
- const { variables, parent } = reference?.[import_types.fragmentKey]?.[document.artifact.name] ?? {};
81
+ const { variables, parent } = reference?.[import_types.fragmentKey]?.values?.[document.artifact.name] ?? {};
81
82
  if (reference && import_types.fragmentKey in reference && (!variables || !parent)) {
82
83
  console.warn(
83
84
  `\u26A0\uFE0F Parent does not contain the information for this fragment. Something is wrong.
84
85
  Please ensure that you have passed a record that has ${document.artifact.name} mixed into it.`
85
86
  );
86
87
  }
87
- return { variables, parent };
88
+ const loading = Boolean(reference?.[import_types.fragmentKey]?.loading);
89
+ return { variables, parent, loading };
88
90
  }
89
91
  // Annotate the CommonJS export names for ESM import in node:
90
92
  0 && (module.exports = {
@@ -1,7 +1,6 @@
1
- import type { GraphQLObject, FragmentArtifact, QueryArtifact } from '$houdini/runtime/lib/types';
2
- import { fragmentKey } from '$houdini/runtime/lib/types';
1
+ import type { GraphQLObject, FragmentArtifact, QueryArtifact, fragmentKey, GraphQLVariables } from '$houdini/runtime/lib/types';
3
2
  import { type DocumentHandle } from './useDocumentHandle';
4
- export declare function useFragmentHandle<_Artifact extends FragmentArtifact, _Data extends GraphQLObject, _ReferenceType extends {}, _PaginationArtifact extends QueryArtifact, _Input extends {} = {}>(reference: _Data | {
3
+ export declare function useFragmentHandle<_Artifact extends FragmentArtifact, _Data extends GraphQLObject, _ReferenceType extends {}, _PaginationArtifact extends QueryArtifact, _Input extends GraphQLVariables = GraphQLVariables>(reference: _Data | {
5
4
  [fragmentKey]: _ReferenceType;
6
5
  } | null, document: {
7
6
  artifact: FragmentArtifact;
@@ -1,10 +1,10 @@
1
- import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
1
+ import type { MutationArtifact, GraphQLObject, QueryResult, GraphQLVariables } from '$houdini/runtime/lib/types';
2
2
  export type MutationHandler<_Result, _Input, _Optimistic extends GraphQLObject> = (args: {
3
3
  variables: _Input;
4
4
  metadata?: App.Metadata;
5
5
  fetch?: typeof globalThis.fetch;
6
6
  optimisticResponse?: _Optimistic;
7
7
  }) => Promise<QueryResult<_Result, _Input>>;
8
- export declare function useMutation<_Result extends GraphQLObject, _Input extends {}, _Optimistic extends GraphQLObject>({ artifact, }: {
8
+ export declare function useMutation<_Result extends GraphQLObject, _Input extends GraphQLVariables, _Optimistic extends GraphQLObject>({ artifact, }: {
9
9
  artifact: MutationArtifact;
10
10
  }): [boolean, MutationHandler<_Result, _Input, _Optimistic>];
@@ -21,12 +21,14 @@ __export(useMutation_exports, {
21
21
  useMutation: () => useMutation
22
22
  });
23
23
  module.exports = __toCommonJS(useMutation_exports);
24
+ var import_Router = require("../routing/components/Router");
24
25
  var import_useDocumentStore = require("./useDocumentStore");
25
26
  function useMutation({
26
27
  artifact
27
28
  }) {
28
29
  const [storeValue, observer] = (0, import_useDocumentStore.useDocumentStore)({ artifact });
29
30
  const pending = storeValue.fetching;
31
+ const session = (0, import_Router.useSession)();
30
32
  const mutate = ({
31
33
  metadata,
32
34
  fetch,
@@ -35,7 +37,7 @@ function useMutation({
35
37
  }) => observer.send({
36
38
  variables,
37
39
  metadata,
38
- session: {},
40
+ session,
39
41
  stuff: {
40
42
  ...mutationConfig
41
43
  }
@@ -1,5 +1,5 @@
1
- import { type QueryArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
2
- import { UseQueryConfig } from './useQueryHandle';
3
- export declare function useQuery<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []>(document: {
1
+ import type { GraphQLVariables, GraphQLObject, QueryArtifact } from '$houdini/runtime/lib/types';
2
+ import type { UseQueryConfig } from './useQueryHandle';
3
+ export declare function useQuery<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables>(document: {
4
4
  artifact: QueryArtifact;
5
5
  }, variables?: any, config?: UseQueryConfig): _Data;
@@ -1,6 +1,6 @@
1
- import { type QueryArtifact, GraphQLObject, CachePolicies } from '$houdini/runtime/lib/types';
2
- import { DocumentHandle } from './useDocumentHandle';
3
- export declare function useQueryHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []>({ artifact }: {
1
+ import type { GraphQLObject, CachePolicies, QueryArtifact, GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ import type { DocumentHandle } from './useDocumentHandle';
3
+ export declare function useQueryHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables>({ artifact }: {
4
4
  artifact: QueryArtifact;
5
5
  }, variables?: any, config?: UseQueryConfig): DocumentHandle<_Artifact, _Data, _Input>;
6
6
  export type UseQueryConfig = {
@@ -27,16 +27,16 @@ __export(useQueryHandle_exports, {
27
27
  useQueryHandle: () => useQueryHandle
28
28
  });
29
29
  module.exports = __toCommonJS(useQueryHandle_exports);
30
+ var import_lru = require("$houdini/runtime/lib/lru");
30
31
  var import_react = __toESM(require("react"));
31
- var import_cache = require("../lib/cache");
32
+ var import_routing = require("../routing");
32
33
  var import_useDocumentHandle = require("./useDocumentHandle");
33
- var import_useHoudiniClient = require("./useHoudiniClient");
34
34
  var import_useIsMounted = require("./useIsMounted");
35
- const promiseCache = (0, import_cache.createCache)();
35
+ const promiseCache = (0, import_lru.createLRUCache)();
36
36
  function useQueryHandle({ artifact }, variables = null, config = {}) {
37
37
  const identifier = queryIdentifier({ artifact, variables, config });
38
38
  const suspenseValue = promiseCache.get(identifier);
39
- const client = (0, import_useHoudiniClient.useHoudiniClient)();
39
+ const client = (0, import_routing.useClient)();
40
40
  const isMountedRef = (0, import_useIsMounted.useIsMountedRef)();
41
41
  let [observer] = import_react.default.useState(
42
42
  client.observe({
@@ -1,4 +1,4 @@
1
- import { SubscriptionArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
2
- export declare function useSubscription<_Result extends GraphQLObject, _Input extends {}>(document: {
1
+ import type { SubscriptionArtifact, GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ export declare function useSubscription<_Result extends GraphQLObject, _Input extends GraphQLVariables>(document: {
3
3
  artifact: SubscriptionArtifact;
4
4
  }, variables: _Input): import("houdini").GraphQLObject | null;
@@ -1,5 +1,5 @@
1
- import { SubscriptionArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
2
- export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends {} | null> = {
1
+ import type { SubscriptionArtifact, GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends GraphQLVariables> = {
3
3
  data: _Result | null;
4
4
  errors: {
5
5
  message: string;
@@ -11,7 +11,7 @@ export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends {}
11
11
  unlisten: () => void;
12
12
  fetching: boolean;
13
13
  };
14
- export declare function useSubscriptionHandle<_Result extends GraphQLObject, _Input extends {}>({ artifact }: {
14
+ export declare function useSubscriptionHandle<_Result extends GraphQLObject, _Input extends GraphQLVariables>({ artifact }: {
15
15
  artifact: SubscriptionArtifact;
16
16
  }, variables: _Input): {
17
17
  data: import("houdini").GraphQLObject | null;
@@ -1,2 +1,31 @@
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 { PendingCache } from './routing/components/Router';
7
+ import { SuspenseCache } from './routing/lib/cache';
1
8
  export * from './hooks';
2
- export { HoudiniProvider } from './context';
9
+ export * from './routing';
10
+ export declare function Router({ cache, intialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, loaded_queries, loaded_artifacts, session, }: {
11
+ intialURL: string;
12
+ cache: Cache;
13
+ loaded_queries?: Record<string, {
14
+ data: GraphQLObject;
15
+ variables: GraphQLVariables;
16
+ }>;
17
+ loaded_artifacts?: Record<string, QueryArtifact>;
18
+ session?: App.Session;
19
+ } & RouterCache): JSX.Element;
20
+ type RouterCache = {
21
+ artifact_cache: SuspenseCache<QueryArtifact>;
22
+ component_cache: SuspenseCache<(props: any) => React.ReactElement>;
23
+ data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
24
+ last_variables: LRUCache<GraphQLVariables>;
25
+ pending_cache: PendingCache;
26
+ };
27
+ export declare function router_cache({ pending_queries, artifacts, components, }?: {
28
+ pending_queries?: string[];
29
+ artifacts?: Record<string, QueryArtifact>;
30
+ components?: Record<string, (props: any) => React.ReactElement>;
31
+ }): RouterCache;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -16,15 +18,99 @@ var __copyProps = (to, from, except, desc) => {
16
18
  return to;
17
19
  };
18
20
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
19
25
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
26
  var runtime_exports = {};
21
27
  __export(runtime_exports, {
22
- HoudiniProvider: () => import_context.HoudiniProvider
28
+ Router: () => Router,
29
+ router_cache: () => router_cache
23
30
  });
24
31
  module.exports = __toCommonJS(runtime_exports);
32
+ var import_react = __toESM(require("react"));
33
+ var import_client2 = __toESM(require("./client"));
34
+ var import_manifest = __toESM(require("./manifest"));
35
+ var import_routing = require("./routing");
36
+ var import_cache = require("./routing/lib/cache");
25
37
  __reExport(runtime_exports, require("./hooks"), module.exports);
26
- var import_context = require("./context");
38
+ __reExport(runtime_exports, require("./routing"), module.exports);
39
+ function Router({
40
+ cache,
41
+ intialURL,
42
+ artifact_cache,
43
+ component_cache,
44
+ data_cache,
45
+ pending_cache,
46
+ last_variables,
47
+ loaded_queries,
48
+ loaded_artifacts,
49
+ session
50
+ }) {
51
+ return /* @__PURE__ */ import_react.default.createElement(
52
+ import_routing.RouterContextProvider,
53
+ {
54
+ client: import_client2.default,
55
+ cache,
56
+ artifact_cache,
57
+ component_cache,
58
+ data_cache,
59
+ pending_cache,
60
+ last_variables,
61
+ session
62
+ },
63
+ /* @__PURE__ */ import_react.default.createElement(
64
+ import_routing.Router,
65
+ {
66
+ intialURL,
67
+ manifest: import_manifest.default,
68
+ loaded_queries,
69
+ loaded_artifacts
70
+ }
71
+ )
72
+ );
73
+ }
74
+ function router_cache({
75
+ pending_queries = [],
76
+ artifacts = {},
77
+ components = {}
78
+ } = {}) {
79
+ const result = {
80
+ artifact_cache: (0, import_cache.suspense_cache)(),
81
+ component_cache: (0, import_cache.suspense_cache)(),
82
+ data_cache: (0, import_cache.suspense_cache)(),
83
+ pending_cache: (0, import_cache.suspense_cache)(),
84
+ last_variables: (0, import_cache.suspense_cache)()
85
+ };
86
+ for (const query of pending_queries) {
87
+ result.pending_cache.set(query, signal_promise());
88
+ }
89
+ for (const [name, artifact] of Object.entries(artifacts)) {
90
+ result.artifact_cache.set(name, artifact);
91
+ }
92
+ for (const [name, component] of Object.entries(components)) {
93
+ result.component_cache.set(name, component);
94
+ }
95
+ return result;
96
+ }
97
+ function signal_promise() {
98
+ let resolve = () => {
99
+ };
100
+ let reject = () => {
101
+ };
102
+ const promise = new Promise((res, rej) => {
103
+ resolve = res;
104
+ reject = rej;
105
+ });
106
+ return {
107
+ ...promise,
108
+ resolve,
109
+ reject
110
+ };
111
+ }
27
112
  // Annotate the CommonJS export names for ESM import in node:
28
113
  0 && (module.exports = {
29
- HoudiniProvider
114
+ Router,
115
+ router_cache
30
116
  });
@@ -0,0 +1,3 @@
1
+ import type { RouterManifest } from './routing';
2
+ declare const manifest: RouterManifest;
3
+ export default manifest;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var manifest_exports = {};
20
+ __export(manifest_exports, {
21
+ default: () => manifest_default
22
+ });
23
+ module.exports = __toCommonJS(manifest_exports);
24
+ const manifest = {};
25
+ var manifest_default = manifest;
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {});
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare function Link({ href, children, style, ...props }: {
3
+ href: string;
4
+ children: React.ReactNode;
5
+ } & React.AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element;
@@ -22,21 +22,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
- var useHoudiniClient_exports = {};
26
- __export(useHoudiniClient_exports, {
27
- useHoudiniClient: () => useHoudiniClient
25
+ var Link_exports = {};
26
+ __export(Link_exports, {
27
+ Link: () => Link
28
28
  });
29
- module.exports = __toCommonJS(useHoudiniClient_exports);
30
- var React = __toESM(require("react"));
31
- var import_context = require("../context");
32
- function useHoudiniClient() {
33
- const client = React.useContext(import_context.HoudiniContext);
34
- if (!client) {
35
- throw new Error("Could not find client");
36
- }
37
- return client;
29
+ module.exports = __toCommonJS(Link_exports);
30
+ var import_react = __toESM(require("react"));
31
+ var import_Router = require("./Router");
32
+ function Link({
33
+ href,
34
+ children,
35
+ style,
36
+ ...props
37
+ }) {
38
+ const { goto } = (0, import_Router.useNavigationContext)();
39
+ const [pending, startTransition] = (0, import_react.useTransition)();
40
+ const click = (e) => {
41
+ e.preventDefault();
42
+ startTransition(() => {
43
+ goto(href);
44
+ });
45
+ };
46
+ return /* @__PURE__ */ import_react.default.createElement("a", { href, onClick: click, style, ...props }, children);
38
47
  }
39
48
  // Annotate the CommonJS export names for ESM import in node:
40
49
  0 && (module.exports = {
41
- useHoudiniClient
50
+ Link
42
51
  });
@@ -0,0 +1,56 @@
1
+ import type { Cache } from '$houdini/runtime/cache/cache';
2
+ import { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
3
+ import { LRUCache } from '$houdini/runtime/lib/lru';
4
+ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
5
+ import { QueryArtifact } from '$houdini/runtime/lib/types';
6
+ import React from 'react';
7
+ import { SuspenseCache } from '../lib/cache';
8
+ import type { NavigationContext, RouterManifest } from '../lib/types';
9
+ /**
10
+ * Router is the top level entry point for the filesystem-based router.
11
+ * It is responsible for loading various page sources (including API fetches) and
12
+ * then rendering when appropriate.
13
+ */
14
+ export declare function Router({ manifest, intialURL, loaded_queries, loaded_artifacts, }: {
15
+ manifest: RouterManifest;
16
+ intialURL?: string;
17
+ loaded_queries?: Record<string, {
18
+ data: GraphQLObject;
19
+ variables: GraphQLVariables;
20
+ }>;
21
+ loaded_artifacts?: Record<string, QueryArtifact>;
22
+ }): JSX.Element;
23
+ export declare function useNavigationContext(): NavigationContext;
24
+ export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
25
+ children: React.ReactElement;
26
+ client: HoudiniClient;
27
+ cache: Cache;
28
+ artifact_cache: SuspenseCache<QueryArtifact>;
29
+ component_cache: SuspenseCache<(props: any) => React.ReactElement>;
30
+ data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
31
+ pending_cache: PendingCache;
32
+ last_variables: LRUCache<GraphQLVariables>;
33
+ session?: App.Session;
34
+ }): JSX.Element;
35
+ type RouterContext = {
36
+ client: HoudiniClient;
37
+ cache: Cache;
38
+ artifact_cache: SuspenseCache<QueryArtifact>;
39
+ component_cache: SuspenseCache<(props: any) => React.ReactElement>;
40
+ data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
41
+ pending_cache: PendingCache;
42
+ last_variables: LRUCache<GraphQLVariables>;
43
+ session: App.Session;
44
+ };
45
+ export type PendingCache = SuspenseCache<Promise<void> & {
46
+ resolve: () => void;
47
+ reject: () => void;
48
+ }>;
49
+ export declare const useRouterContext: () => RouterContext;
50
+ export declare function useClient(): HoudiniClient;
51
+ export declare function useCache(): Cache;
52
+ export declare function updateLocalSession(session: App.Session): void;
53
+ export declare function useSession(): App.Session;
54
+ export declare function useCurrentVariables(): GraphQLVariables;
55
+ export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
56
+ export {};