houdini-react 1.2.9 → 1.2.11

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 (46) hide show
  1. package/build/plugin/codegen/entries.d.ts +1 -2
  2. package/build/plugin/codegen/index.d.ts +1 -2
  3. package/build/plugin/codegen/manifest.d.ts +4 -41
  4. package/build/plugin/codegen/router.d.ts +1 -2
  5. package/build/plugin/codegen/typeRoot.d.ts +1 -2
  6. package/build/plugin/index.d.ts +3 -1
  7. package/build/plugin/vite.d.ts +38 -1
  8. package/build/plugin-cjs/index.js +75188 -76234
  9. package/build/plugin-esm/index.js +75185 -76233
  10. package/build/runtime/index.d.ts +6 -3
  11. package/build/runtime/routing/components/Router.d.ts +4 -4
  12. package/build/runtime/routing/components/index.d.ts +0 -1
  13. package/build/runtime/routing/lib/cache.d.ts +1 -1
  14. package/build/runtime/routing/lib/types.d.ts +0 -4
  15. package/build/runtime-cjs/index.d.ts +6 -3
  16. package/build/runtime-cjs/index.js +22 -18
  17. package/build/runtime-cjs/routing/components/Router.d.ts +4 -4
  18. package/build/runtime-cjs/routing/components/Router.js +173 -70
  19. package/build/runtime-cjs/routing/components/index.d.ts +0 -1
  20. package/build/runtime-cjs/routing/components/index.js +0 -3
  21. package/build/runtime-cjs/routing/lib/cache.d.ts +1 -1
  22. package/build/runtime-cjs/routing/lib/cache.js +6 -2
  23. package/build/runtime-cjs/routing/lib/types.d.ts +0 -4
  24. package/build/runtime-esm/index.d.ts +6 -3
  25. package/build/runtime-esm/index.js +22 -18
  26. package/build/runtime-esm/routing/components/Router.d.ts +4 -4
  27. package/build/runtime-esm/routing/components/Router.js +173 -69
  28. package/build/runtime-esm/routing/components/index.d.ts +0 -1
  29. package/build/runtime-esm/routing/components/index.js +0 -2
  30. package/build/runtime-esm/routing/lib/cache.d.ts +1 -1
  31. package/build/runtime-esm/routing/lib/cache.js +6 -2
  32. package/build/runtime-esm/routing/lib/types.d.ts +0 -4
  33. package/package.json +3 -12
  34. package/build/plugin/conventions.d.ts +0 -24
  35. package/build/runtime/routing/components/Link.d.ts +0 -5
  36. package/build/runtime-cjs/routing/components/Link.d.ts +0 -5
  37. package/build/runtime-cjs/routing/components/Link.js +0 -51
  38. package/build/runtime-esm/routing/components/Link.d.ts +0 -5
  39. package/build/runtime-esm/routing/components/Link.js +0 -21
  40. package/build/server/compat.d.ts +0 -7
  41. package/build/server/index.d.ts +0 -17
  42. package/build/server/session.d.ts +0 -3
  43. package/build/server-cjs/index.js +0 -166716
  44. package/build/server-cjs/package.json +0 -1
  45. package/build/server-esm/index.js +0 -166707
  46. package/build/server-esm/package.json +0 -1
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import client from "./client";
3
3
  import manifest from "./manifest";
4
4
  import { Router as RouterImpl, RouterContextProvider } from "./routing";
@@ -7,7 +7,7 @@ export * from "./hooks";
7
7
  export * from "./routing";
8
8
  function Router({
9
9
  cache,
10
- intialURL,
10
+ initialURL,
11
11
  artifact_cache,
12
12
  component_cache,
13
13
  data_cache,
@@ -15,9 +15,10 @@ function Router({
15
15
  last_variables,
16
16
  loaded_queries,
17
17
  loaded_artifacts,
18
- session
18
+ session,
19
+ assetPrefix
19
20
  }) {
20
- return /* @__PURE__ */ React.createElement(
21
+ return /* @__PURE__ */ jsx(
21
22
  RouterContextProvider,
22
23
  {
23
24
  client,
@@ -27,28 +28,31 @@ function Router({
27
28
  data_cache,
28
29
  pending_cache,
29
30
  last_variables,
30
- session
31
- },
32
- /* @__PURE__ */ React.createElement(
33
- RouterImpl,
34
- {
35
- intialURL,
36
- manifest,
37
- loaded_queries,
38
- loaded_artifacts
39
- }
40
- )
31
+ session,
32
+ children: /* @__PURE__ */ jsx(
33
+ RouterImpl,
34
+ {
35
+ initialURL,
36
+ manifest,
37
+ loaded_queries,
38
+ loaded_artifacts,
39
+ assetPrefix
40
+ }
41
+ )
42
+ }
41
43
  );
42
44
  }
43
45
  function router_cache({
44
46
  pending_queries = [],
45
47
  artifacts = {},
46
- components = {}
48
+ components = {},
49
+ initialData = {},
50
+ initialArtifacts = {}
47
51
  } = {}) {
48
52
  const result = {
49
- artifact_cache: suspense_cache(),
53
+ artifact_cache: suspense_cache(initialArtifacts),
50
54
  component_cache: suspense_cache(),
51
- data_cache: suspense_cache(),
55
+ data_cache: suspense_cache(initialData),
52
56
  pending_cache: suspense_cache(),
53
57
  last_variables: suspense_cache()
54
58
  };
@@ -5,22 +5,22 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
5
5
  import { QueryArtifact } from '$houdini/runtime/lib/types';
6
6
  import React from 'react';
7
7
  import { SuspenseCache } from '../lib/cache';
8
- import type { NavigationContext, RouterManifest } from '../lib/types';
8
+ import type { RouterManifest } from '../lib/types';
9
9
  /**
10
10
  * Router is the top level entry point for the filesystem-based router.
11
11
  * It is responsible for loading various page sources (including API fetches) and
12
12
  * then rendering when appropriate.
13
13
  */
14
- export declare function Router({ manifest, intialURL, loaded_queries, loaded_artifacts, }: {
14
+ export declare function Router({ manifest, initialURL, loaded_queries, loaded_artifacts, assetPrefix, }: {
15
15
  manifest: RouterManifest;
16
- intialURL?: string;
16
+ initialURL?: string;
17
17
  loaded_queries?: Record<string, {
18
18
  data: GraphQLObject;
19
19
  variables: GraphQLVariables;
20
20
  }>;
21
21
  loaded_artifacts?: Record<string, QueryArtifact>;
22
+ assetPrefix: string;
22
23
  }): JSX.Element;
23
- export declare function useNavigationContext(): NavigationContext;
24
24
  export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
25
25
  children: React.ReactElement;
26
26
  client: HoudiniClient;
@@ -1,33 +1,43 @@
1
+ import { jsx } from "react/jsx-runtime";
1
2
  import { deepEquals } from "$houdini/runtime/lib/deepEquals";
2
3
  import React from "react";
3
4
  import { useStream } from "react-streaming";
4
5
  import { useDocumentStore } from "../../hooks/useDocumentStore";
5
6
  import { find_match } from "../lib/match";
6
- const NavContext = React.createContext({
7
- currentRoute: "/",
8
- goto: () => {
9
- throw new Error("NOT FOUND");
10
- }
11
- });
7
+ const PreloadWhich = {
8
+ component: "component",
9
+ data: "data",
10
+ page: "page"
11
+ };
12
12
  function Router({
13
13
  manifest,
14
- intialURL,
14
+ initialURL,
15
15
  loaded_queries,
16
- loaded_artifacts
16
+ loaded_artifacts,
17
+ assetPrefix
17
18
  }) {
18
19
  const [current, setCurrent] = React.useState(() => {
19
- return intialURL || window.location.pathname;
20
+ return initialURL || window.location.pathname;
20
21
  });
21
22
  const [page, variables] = find_match(manifest, current);
22
- useLoadPage({ page, variables, loaded_queries, loaded_artifacts });
23
+ const { loadData, loadComponent } = usePageData({
24
+ page,
25
+ variables,
26
+ loaded_queries,
27
+ loaded_artifacts,
28
+ assetPrefix
29
+ });
23
30
  const { component_cache } = useRouterContext();
24
31
  const PageComponent = component_cache.get(page.id);
25
32
  React.useEffect(() => {
26
- if (window.location.pathname !== current) {
33
+ if (globalThis.window && window.location.pathname !== current) {
27
34
  window.history.pushState({}, "", current);
28
35
  }
29
36
  }, [current]);
30
37
  React.useEffect(() => {
38
+ if (!globalThis.window) {
39
+ return;
40
+ }
31
41
  const onChange = (evt) => {
32
42
  setCurrent(window.location.pathname);
33
43
  };
@@ -36,22 +46,26 @@ function Router({
36
46
  window.removeEventListener("popstate", onChange);
37
47
  };
38
48
  }, []);
39
- return /* @__PURE__ */ React.createElement(
40
- NavContext.Provider,
41
- {
42
- value: {
43
- currentRoute: current,
44
- goto: setCurrent
49
+ useLinkBehavior({
50
+ goto: setCurrent,
51
+ preload(url, which) {
52
+ const [page2, variables2] = find_match(manifest, url);
53
+ if (["both", "component"].includes(which)) {
54
+ loadComponent(page2);
45
55
  }
46
- },
47
- /* @__PURE__ */ React.createElement(VariableContext.Provider, { value: variables }, /* @__PURE__ */ React.createElement(PageComponent, { url: current }))
48
- );
56
+ if (["both", "data"].includes(which)) {
57
+ loadData(page2, variables2);
58
+ }
59
+ }
60
+ });
61
+ return /* @__PURE__ */ jsx(VariableContext.Provider, { value: variables, children: /* @__PURE__ */ jsx(PageComponent, { url: current }) });
49
62
  }
50
- function useLoadPage({
63
+ function usePageData({
51
64
  page,
52
65
  variables,
53
66
  loaded_queries,
54
- loaded_artifacts
67
+ loaded_artifacts,
68
+ assetPrefix
55
69
  }) {
56
70
  const {
57
71
  client,
@@ -93,17 +107,38 @@ function useLoadPage({
93
107
  <script>
94
108
  window.__houdini__cache__?.hydrate(${cache.serialize()}, window.__houdini__hydration__layer)
95
109
 
96
- if (window.__houdini__nav_caches__?.pending_cache.has("${artifact.name}")) {
110
+ const artifactName = "${artifact.name}"
111
+ const value = ${JSON.stringify(observer.state.data)}
112
+
113
+ // if the data is pending, we need to resolve it
114
+ if (window.__houdini__nav_caches__?.data_cache.has(artifactName)) {
97
115
  // before we resolve the pending signals,
98
116
  // fill the data cache with values we got on the server
99
117
  const new_store = window.__houdini__client__.observe({
100
- artifact: window.__houdini__nav_caches__.artifact_cache.get("${artifact.name}"),
118
+ artifact: window.__houdini__nav_caches__.artifact_cache.get(artifactName),
101
119
  cache: window.__houdini__cache__,
102
- initialValue: ${JSON.stringify(observer.state.data)}
120
+ initialValue: value
103
121
  })
104
122
 
105
- window.__houdini__nav_caches__.data_cache.set("${artifact.name}", new_store)
123
+ window.__houdini__nav_caches__?.data_cache.set(artifactName, new_store)
124
+ }
125
+
126
+
127
+ // if there are no data caches available we need to populate the pending one instead
128
+ if (!window.__houdini__nav_caches__) {
129
+ if (!window.__houdini__pending_data__) {
130
+ window.__houdini__pending_data__ = {}
131
+ }
106
132
 
133
+ if (!window.__houdini__pending_artifacts__) {
134
+ window.__houdini__pending_artifacts__ = {}
135
+ }
136
+
137
+ window.__houdini__pending_data__[artifactName] = value
138
+ window.__houdini__pending_artifacts__[artifactName] = ${JSON.stringify(artifact)}
139
+ }
140
+
141
+ if (window.__houdini__nav_caches__?.pending_cache.has(artifactName)) {
107
142
  // we're pushing this store onto the client, it should be initialized
108
143
  new_store.send({
109
144
  setup: true,
@@ -111,8 +146,8 @@ function useLoadPage({
111
146
  })
112
147
 
113
148
  // notify anyone waiting on the pending cache
114
- window.__houdini__nav_caches__.pending_cache.get("${artifact.name}").resolve()
115
- window.__houdini__nav_caches__.pending_cache.delete("${artifact.name}")
149
+ window.__houdini__nav_caches__.pending_cache.get(artifactName).resolve()
150
+ window.__houdini__nav_caches__.pending_cache.delete(artifactName)
116
151
  }
117
152
  <\/script>
118
153
  `);
@@ -124,49 +159,55 @@ function useLoadPage({
124
159
  pending_cache.set(id, { ...promise, resolve, reject });
125
160
  return pending_cache.get(id);
126
161
  }
127
- if (last_variables.has(page.id) && !deepEquals(last_variables.get(page.id), variables)) {
128
- data_cache.clear();
129
- }
130
- const missing_artifacts = [];
131
- const found_artifacts = {};
132
- for (const key of Object.keys(page.documents)) {
133
- if (artifact_cache.has(key)) {
134
- found_artifacts[key] = artifact_cache.get(key);
135
- } else {
136
- missing_artifacts.push(key);
162
+ function loadData(targetPage, variables2) {
163
+ if (last_variables.has(targetPage.id) && !deepEquals(last_variables.get(targetPage.id), variables2)) {
164
+ data_cache.clear();
137
165
  }
138
- }
139
- for (const artifact_id of missing_artifacts) {
140
- page.documents[artifact_id].artifact().then((mod) => {
141
- const artifact = mod.default;
142
- artifact_cache.set(artifact_id, artifact);
143
- if (loaded_artifacts) {
144
- loaded_artifacts[artifact.name] = artifact;
166
+ const missing_artifacts = [];
167
+ const found_artifacts = {};
168
+ for (const key of Object.keys(targetPage.documents)) {
169
+ if (artifact_cache.has(key)) {
170
+ found_artifacts[key] = artifact_cache.get(key);
171
+ } else {
172
+ missing_artifacts.push(key);
145
173
  }
146
- stream?.injectToStream(`
147
- <script type="module" src="@@houdini/artifact/${artifact.name}.js" async=""><\/script>
148
- `);
149
- load_query({ id: artifact.name, artifact });
150
- }).catch((err) => {
151
- console.log(err);
152
- });
174
+ }
175
+ for (const artifact_id of missing_artifacts) {
176
+ targetPage.documents[artifact_id].artifact().then((mod) => {
177
+ const artifact = mod.default;
178
+ artifact_cache.set(artifact_id, artifact);
179
+ if (loaded_artifacts) {
180
+ loaded_artifacts[artifact.name] = artifact;
181
+ }
182
+ stream?.injectToStream(`
183
+ <script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""><\/script>
184
+ `);
185
+ load_query({ id: artifact.name, artifact });
186
+ }).catch((err) => {
187
+ console.log(err);
188
+ });
189
+ }
190
+ for (const artifact of Object.values(found_artifacts)) {
191
+ if (!data_cache.has(artifact.name)) {
192
+ load_query({ id: artifact.name, artifact });
193
+ }
194
+ }
153
195
  }
154
- for (const artifact of Object.values(found_artifacts)) {
155
- if (!data_cache.has(artifact.name)) {
156
- load_query({ id: artifact.name, artifact });
196
+ async function loadComponent(targetPage) {
197
+ if (component_cache.has(targetPage.id)) {
198
+ return;
157
199
  }
200
+ const mod = await targetPage.component();
201
+ component_cache.set(targetPage.id, mod.default);
158
202
  }
203
+ loadData(page, variables);
159
204
  if (!component_cache.has(page.id)) {
160
- throw new Promise((resolve, reject) => {
161
- page.component().then((mod) => {
162
- component_cache.set(page.id, mod.default);
163
- resolve();
164
- }).catch(reject);
165
- });
205
+ throw loadComponent(page);
166
206
  }
167
- }
168
- function useNavigationContext() {
169
- return React.useContext(NavContext);
207
+ return {
208
+ loadData,
209
+ loadComponent
210
+ };
170
211
  }
171
212
  function RouterContextProvider({
172
213
  children,
@@ -189,7 +230,7 @@ function RouterContextProvider({
189
230
  window.removeEventListener("_houdini_session_", handleNewSession);
190
231
  };
191
232
  }, []);
192
- return /* @__PURE__ */ React.createElement(
233
+ return /* @__PURE__ */ jsx(
193
234
  Context.Provider,
194
235
  {
195
236
  value: {
@@ -201,9 +242,9 @@ function RouterContextProvider({
201
242
  pending_cache,
202
243
  last_variables,
203
244
  session
204
- }
205
- },
206
- children
245
+ },
246
+ children
247
+ }
207
248
  );
208
249
  }
209
250
  const Context = React.createContext(null);
@@ -243,6 +284,70 @@ function useQueryResult(name) {
243
284
  });
244
285
  return [data, observer];
245
286
  }
287
+ function useLinkBehavior({
288
+ goto,
289
+ preload
290
+ }) {
291
+ useLinkNavigation({ goto });
292
+ if (!globalThis.navigator?.connection?.saveData) {
293
+ usePreload({ preload });
294
+ }
295
+ }
296
+ function useLinkNavigation({ goto }) {
297
+ const [pending, startTransition] = React.useTransition();
298
+ React.useEffect(() => {
299
+ const onClick = (e) => {
300
+ const link = e.target?.closest("a");
301
+ if (link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.defaultPrevented) {
302
+ const target = link.attributes.getNamedItem("href")?.value;
303
+ if (!target || !target.startsWith("/")) {
304
+ return;
305
+ }
306
+ e.preventDefault();
307
+ startTransition(() => {
308
+ goto(target);
309
+ });
310
+ }
311
+ };
312
+ document.addEventListener("click", onClick);
313
+ return () => {
314
+ document.removeEventListener("click", onClick);
315
+ };
316
+ }, []);
317
+ }
318
+ function usePreload({ preload }) {
319
+ const timeoutRef = React.useRef(null);
320
+ React.useEffect(() => {
321
+ const mouseMove = (e) => {
322
+ const target = e.target;
323
+ if (!(target instanceof HTMLAnchorElement)) {
324
+ return;
325
+ }
326
+ let preloadWhichRaw = target.attributes.getNamedItem("data-houdini-preload")?.value;
327
+ let preloadWhich = !preloadWhichRaw || preloadWhichRaw === "true" ? "page" : preloadWhichRaw;
328
+ if (!PreloadWhich[preloadWhich]) {
329
+ console.log(
330
+ `invalid preload value "${preloadWhich}" must be "${PreloadWhich.component}", "${PreloadWhich.data}", or "${PreloadWhich.page}"`
331
+ );
332
+ return;
333
+ }
334
+ if (timeoutRef.current) {
335
+ clearTimeout(timeoutRef.current);
336
+ }
337
+ timeoutRef.current = setTimeout(() => {
338
+ const url = target.attributes.getNamedItem("href")?.value;
339
+ if (!url) {
340
+ return;
341
+ }
342
+ preload(url, preloadWhich);
343
+ }, 20);
344
+ };
345
+ document.addEventListener("mousemove", mouseMove);
346
+ return () => {
347
+ document.removeEventListener("mousemove", mouseMove);
348
+ };
349
+ }, []);
350
+ }
246
351
  export {
247
352
  Router,
248
353
  RouterContextProvider,
@@ -250,7 +355,6 @@ export {
250
355
  useCache,
251
356
  useClient,
252
357
  useCurrentVariables,
253
- useNavigationContext,
254
358
  useQueryResult,
255
359
  useRouterContext,
256
360
  useSession
@@ -1,2 +1 @@
1
- export { Link } from './Link';
2
1
  export { Router, RouterContextProvider, useClient, updateLocalSession } from './Router';
@@ -1,7 +1,5 @@
1
- import { Link } from "./Link";
2
1
  import { Router, RouterContextProvider, useClient, updateLocalSession } from "./Router";
3
2
  export {
4
- Link,
5
3
  Router,
6
4
  RouterContextProvider,
7
5
  updateLocalSession,
@@ -1,5 +1,5 @@
1
1
  import { LRUCache } from '$houdini/runtime/lib/lru';
2
- export declare function suspense_cache<T>(): SuspenseCache<T>;
2
+ export declare function suspense_cache<T>(initialData?: Record<string, T>): SuspenseCache<T>;
3
3
  export declare class SuspenseCache<_Data> extends LRUCache<_Data> {
4
4
  #private;
5
5
  get(key: string): _Data;
@@ -1,6 +1,10 @@
1
1
  import { LRUCache } from "$houdini/runtime/lib/lru";
2
- function suspense_cache() {
3
- return new SuspenseCache();
2
+ function suspense_cache(initialData) {
3
+ const cache = new SuspenseCache();
4
+ for (const [key, value] of Object.entries(initialData ?? {})) {
5
+ cache.set(key, value);
6
+ }
7
+ return cache;
4
8
  }
5
9
  class SuspenseCache extends LRUCache {
6
10
  #callbacks = /* @__PURE__ */ new Map();
@@ -17,7 +17,3 @@ export type RouterPageManifest = {
17
17
  default: (props: any) => React.ReactElement;
18
18
  }>;
19
19
  };
20
- export type NavigationContext = {
21
- currentRoute: string;
22
- goto: (route: string) => void;
23
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -40,7 +40,7 @@
40
40
  "recast": "^0.23.1",
41
41
  "rollup": "^3.7.4",
42
42
  "use-deep-compare-effect": "^1.8.1",
43
- "houdini": "^1.2.9"
43
+ "houdini": "^1.2.11"
44
44
  },
45
45
  "files": [
46
46
  "build"
@@ -51,19 +51,10 @@
51
51
  "types": "./build/plugin/index.d.ts",
52
52
  "import": "./build/plugin-esm/index.js",
53
53
  "require": "./build/plugin-cjs/index.js"
54
- },
55
- "./server": {
56
- "types": "./build/server/index.d.ts",
57
- "import": "./build/server-esm/index.js",
58
- "require": "./build/server-cjs/index.js"
59
54
  }
60
55
  },
61
56
  "typesVersions": {
62
- "*": {
63
- "server": [
64
- "build/server/index.d.ts"
65
- ]
66
- }
57
+ "*": {}
67
58
  },
68
59
  "main": "./build/plugin-cjs/index.js",
69
60
  "types": "./build/plugin/index.d.ts",
@@ -1,24 +0,0 @@
1
- import { type Config } from 'houdini';
2
- /** The location of the project's router */
3
- export declare function router_path(config: Config): string;
4
- /** The location of the page component */
5
- export declare function page_entry_path(config: Config, id: string, base?: string): string;
6
- export declare function render_client_path(config: Config, base?: string): string;
7
- export declare function render_server_path(config: Config, base?: string): string;
8
- export declare function render_app_path(config: Config, base?: string): string;
9
- export declare function page_unit_path(config: Config, id: string, base?: string): string;
10
- export declare function layout_unit_path(config: Config, id: string, base?: string): string;
11
- export declare function fallback_unit_path(config: Config, which: 'page' | 'layout', id: string, base?: string): string;
12
- /** Load the page query for the given route from disk */
13
- export declare function read_pageQuery(base: string): Promise<(string | null)[]>;
14
- /** Load the page view for the given route from disk */
15
- export declare function read_pageView(base: string): Promise<string[] | null[]>;
16
- /** Load the layout query for the given route from disk */
17
- export declare function read_layoutQuery(base: string): Promise<(string | null)[]>;
18
- /** Load the layout view for the given route from disk */
19
- export declare function read_layoutView(base: string): Promise<string[] | null[]>;
20
- export declare function router_index_path(config: Config): string;
21
- export declare function is_layout(path: string): boolean;
22
- /** Transforms paths to ids */
23
- export declare function normalize_path(path: string): string;
24
- export declare function page_entries_dir(config: Config, base?: string): string;
@@ -1,5 +0,0 @@
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;
@@ -1,5 +0,0 @@
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;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
- var Link_exports = {};
26
- __export(Link_exports, {
27
- Link: () => Link
28
- });
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);
47
- }
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- Link
51
- });
@@ -1,5 +0,0 @@
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;
@@ -1,21 +0,0 @@
1
- import React, { useTransition } from "react";
2
- import { useNavigationContext } from "./Router";
3
- function Link({
4
- href,
5
- children,
6
- style,
7
- ...props
8
- }) {
9
- const { goto } = useNavigationContext();
10
- const [pending, startTransition] = useTransition();
11
- const click = (e) => {
12
- e.preventDefault();
13
- startTransition(() => {
14
- goto(href);
15
- });
16
- };
17
- return /* @__PURE__ */ React.createElement("a", { href, onClick: click, style, ...props }, children);
18
- }
19
- export {
20
- Link
21
- };
@@ -1,7 +0,0 @@
1
- import type { Config } from 'houdini';
2
- import type { Connect } from 'vite';
3
- import type { Server } from '.';
4
- export declare function dev_server({ server, config }: {
5
- server: Connect.Server;
6
- config: Config;
7
- }): Server;
@@ -1,17 +0,0 @@
1
- import type { Config } from 'houdini';
2
- export declare function configure_server({ server, config }: {
3
- server: Server;
4
- config: Config;
5
- }): void;
6
- export type Server = {
7
- use(fn: ServerMiddleware): void;
8
- };
9
- export type ServerMiddleware = (req: IncomingRequest, res: ServerResponse, next: () => void) => void;
10
- export type IncomingRequest = {
11
- url?: string;
12
- headers: Headers;
13
- };
14
- export type ServerResponse = {
15
- redirect(url: string, status?: number): void;
16
- set_header(name: string, value: string): void;
17
- };
@@ -1,3 +0,0 @@
1
- import type { ServerResponse } from '.';
2
- export declare function set_session(res: ServerResponse, value: App.Session): void;
3
- export declare function get_session(req: Headers, secrets: string[]): App.Session;