houdini-react 1.2.0-react.1 → 1.2.6

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 (127) 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 +1 -0
  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 +4 -2
  13. package/build/plugin/vite.d.ts +19 -0
  14. package/build/plugin-cjs/index.js +32672 -1115
  15. package/build/plugin-esm/index.js +32666 -1111
  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 +29 -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 +52 -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 +24 -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 +0 -1
  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 +13 -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/useQuery.d.ts +3 -3
  52. package/build/runtime-cjs/hooks/useQueryHandle.d.ts +3 -3
  53. package/build/runtime-cjs/hooks/useQueryHandle.js +4 -4
  54. package/build/runtime-cjs/hooks/useSubscription.d.ts +2 -2
  55. package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +3 -3
  56. package/build/runtime-cjs/index.d.ts +29 -1
  57. package/build/runtime-cjs/index.js +87 -3
  58. package/build/runtime-cjs/manifest.d.ts +3 -0
  59. package/build/runtime-cjs/manifest.js +27 -0
  60. package/build/runtime-cjs/routing/components/Link.d.ts +5 -0
  61. package/build/runtime-cjs/{hooks/useHoudiniClient.js → routing/components/Link.js} +22 -13
  62. package/build/runtime-cjs/routing/components/Router.d.ts +52 -0
  63. package/build/runtime-cjs/routing/components/Router.js +267 -0
  64. package/build/runtime-cjs/routing/components/index.d.ts +2 -0
  65. package/build/runtime-cjs/{context.js → routing/components/index.js} +13 -19
  66. package/build/runtime-cjs/routing/index.d.ts +3 -0
  67. package/build/runtime-cjs/routing/index.js +30 -0
  68. package/build/runtime-cjs/routing/lib/cache.d.ts +7 -0
  69. package/build/runtime-cjs/{lib → routing/lib}/cache.js +23 -40
  70. package/build/runtime-cjs/routing/lib/match.d.ts +38 -0
  71. package/build/runtime-cjs/routing/lib/match.js +149 -0
  72. package/build/runtime-cjs/routing/lib/types.d.ts +24 -0
  73. package/build/runtime-cjs/routing/lib/types.js +16 -0
  74. package/build/runtime-esm/client.d.ts +3 -0
  75. package/build/runtime-esm/client.js +4 -0
  76. package/build/runtime-esm/clientPlugin.d.ts +3 -0
  77. package/build/runtime-esm/clientPlugin.js +17 -0
  78. package/build/runtime-esm/hooks/useDocumentHandle.d.ts +4 -4
  79. package/build/runtime-esm/hooks/useDocumentHandle.js +1 -4
  80. package/build/runtime-esm/hooks/useDocumentStore.d.ts +6 -5
  81. package/build/runtime-esm/hooks/useDocumentStore.js +9 -4
  82. package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +4 -3
  83. package/build/runtime-esm/hooks/useDocumentSubscription.js +13 -8
  84. package/build/runtime-esm/hooks/useFragment.d.ts +3 -2
  85. package/build/runtime-esm/hooks/useFragment.js +9 -7
  86. package/build/runtime-esm/hooks/useFragmentHandle.d.ts +2 -3
  87. package/build/runtime-esm/hooks/useMutation.d.ts +2 -2
  88. package/build/runtime-esm/hooks/useQuery.d.ts +3 -3
  89. package/build/runtime-esm/hooks/useQueryHandle.d.ts +3 -3
  90. package/build/runtime-esm/hooks/useQueryHandle.js +4 -4
  91. package/build/runtime-esm/hooks/useSubscription.d.ts +2 -2
  92. package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +3 -3
  93. package/build/runtime-esm/index.d.ts +29 -1
  94. package/build/runtime-esm/index.js +79 -2
  95. package/build/runtime-esm/manifest.d.ts +3 -0
  96. package/build/runtime-esm/manifest.js +5 -0
  97. package/build/runtime-esm/routing/components/Link.d.ts +5 -0
  98. package/build/runtime-esm/routing/components/Link.js +21 -0
  99. package/build/runtime-esm/routing/components/Router.d.ts +52 -0
  100. package/build/runtime-esm/routing/components/Router.js +230 -0
  101. package/build/runtime-esm/routing/components/index.d.ts +2 -0
  102. package/build/runtime-esm/routing/components/index.js +8 -0
  103. package/build/runtime-esm/routing/index.d.ts +3 -0
  104. package/build/runtime-esm/routing/index.js +5 -0
  105. package/build/runtime-esm/routing/lib/cache.d.ts +7 -0
  106. package/build/runtime-esm/routing/lib/cache.js +29 -0
  107. package/build/runtime-esm/routing/lib/match.d.ts +38 -0
  108. package/build/runtime-esm/routing/lib/match.js +122 -0
  109. package/build/runtime-esm/routing/lib/types.d.ts +24 -0
  110. package/build/runtime-esm/routing/lib/types.js +0 -0
  111. package/package.json +7 -11
  112. package/build/next/index.d.ts +0 -2
  113. package/build/next-cjs/package.json +0 -1
  114. package/build/next-esm/index.js +0 -26
  115. package/build/next-esm/package.json +0 -1
  116. package/build/runtime/context.d.ts +0 -7
  117. package/build/runtime/hooks/useHoudiniClient.d.ts +0 -2
  118. package/build/runtime/lib/cache.d.ts +0 -62
  119. package/build/runtime-cjs/context.d.ts +0 -7
  120. package/build/runtime-cjs/hooks/useHoudiniClient.d.ts +0 -2
  121. package/build/runtime-cjs/lib/cache.d.ts +0 -62
  122. package/build/runtime-esm/context.d.ts +0 -7
  123. package/build/runtime-esm/context.js +0 -10
  124. package/build/runtime-esm/hooks/useHoudiniClient.d.ts +0 -2
  125. package/build/runtime-esm/hooks/useHoudiniClient.js +0 -12
  126. package/build/runtime-esm/lib/cache.d.ts +0 -62
  127. package/build/runtime-esm/lib/cache.js +0 -47
@@ -0,0 +1,122 @@
1
+ const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
2
+ function find_match(manifest, current, allowNull) {
3
+ let match = null;
4
+ let matchVariables = null;
5
+ for (const page of Object.values(manifest.pages)) {
6
+ const urlMatch = current.match(page.pattern);
7
+ if (!urlMatch) {
8
+ continue;
9
+ }
10
+ match = page;
11
+ matchVariables = exec(urlMatch, page.params) || {};
12
+ break;
13
+ }
14
+ if (!match && !allowNull) {
15
+ throw new Error("404");
16
+ }
17
+ return [match, matchVariables];
18
+ }
19
+ function parse_page_pattern(id) {
20
+ const params = [];
21
+ const pattern = id === "/" ? /^\/$/ : new RegExp(
22
+ `^${get_route_segments(id).map((segment) => {
23
+ const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
24
+ if (rest_match) {
25
+ params.push({
26
+ name: rest_match[1],
27
+ matcher: rest_match[2],
28
+ optional: false,
29
+ rest: true,
30
+ chained: true
31
+ });
32
+ return "(?:/(.*))?";
33
+ }
34
+ const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
35
+ if (optional_match) {
36
+ params.push({
37
+ name: optional_match[1],
38
+ matcher: optional_match[2],
39
+ optional: true,
40
+ rest: false,
41
+ chained: true
42
+ });
43
+ return "(?:/([^/]+))?";
44
+ }
45
+ if (!segment) {
46
+ return;
47
+ }
48
+ const parts = segment.split(/\[(.+?)\](?!\])/);
49
+ const result = parts.map((content, i) => {
50
+ if (i % 2) {
51
+ if (content.startsWith("x+")) {
52
+ return escape(
53
+ String.fromCharCode(parseInt(content.slice(2), 16))
54
+ );
55
+ }
56
+ if (content.startsWith("u+")) {
57
+ return escape(
58
+ String.fromCharCode(
59
+ ...content.slice(2).split("-").map((code) => parseInt(code, 16))
60
+ )
61
+ );
62
+ }
63
+ const match = param_pattern.exec(content);
64
+ if (!match) {
65
+ throw new Error(
66
+ `Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
67
+ );
68
+ }
69
+ const [, is_optional, is_rest, name, matcher] = match;
70
+ params.push({
71
+ name,
72
+ matcher,
73
+ optional: !!is_optional,
74
+ rest: !!is_rest,
75
+ chained: is_rest ? i === 1 && parts[0] === "" : false
76
+ });
77
+ return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
78
+ }
79
+ return escape(content);
80
+ }).join("");
81
+ return "/" + result;
82
+ }).join("")}/?$`
83
+ );
84
+ return { pattern, params, page_id: id };
85
+ }
86
+ function affects_path(segment) {
87
+ return !/^\([^)]+\)$/.test(segment);
88
+ }
89
+ function get_route_segments(route) {
90
+ return route.slice(1).split("/").filter(affects_path);
91
+ }
92
+ function exec(match, params) {
93
+ const result = {};
94
+ const values = match.slice(1);
95
+ let buffered = "";
96
+ for (let i = 0; i < params.length; i += 1) {
97
+ const param = params[i];
98
+ let value = values[i];
99
+ if (param.chained && param.rest && buffered) {
100
+ value = value ? buffered + "/" + value : buffered;
101
+ }
102
+ buffered = "";
103
+ if (value === void 0) {
104
+ if (param.rest)
105
+ result[param.name] = "";
106
+ } else {
107
+ result[param.name] = value;
108
+ }
109
+ }
110
+ if (buffered)
111
+ return;
112
+ return result;
113
+ }
114
+ function escape(str) {
115
+ return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
116
+ }
117
+ export {
118
+ exec,
119
+ find_match,
120
+ get_route_segments,
121
+ parse_page_pattern
122
+ };
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { QueryArtifact } from '$houdini/runtime/lib/types';
3
+ import type { RouteParam } from './match';
4
+ export type RouterManifest = {
5
+ pages: Record<string, RouterPageManifest>;
6
+ };
7
+ export type RouterPageManifest = {
8
+ id: string;
9
+ pattern: RegExp;
10
+ params: RouteParam[];
11
+ documents: Record<string, {
12
+ artifact: () => Promise<{
13
+ default: QueryArtifact;
14
+ }>;
15
+ loading: boolean;
16
+ }>;
17
+ component: () => Promise<{
18
+ default: (props: any) => React.ReactElement;
19
+ }>;
20
+ };
21
+ export type NavigationContext = {
22
+ currentRoute: string;
23
+ goto: (route: string) => void;
24
+ };
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "1.2.0-react.1",
3
+ "version": "1.2.6",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -18,41 +18,37 @@
18
18
  "devDependencies": {
19
19
  "@types/estraverse": "^5.1.2",
20
20
  "@types/next": "^9.0.0",
21
+ "@types/react-dom": "^18.0.10",
21
22
  "next": "^13.0.1",
22
23
  "scripts": "^1.0.0"
23
24
  },
24
25
  "dependencies": {
25
26
  "@babel/parser": "^7.19.3",
27
+ "@babel/types": "^7.21.4",
26
28
  "@types/react": "^18.0.28",
27
29
  "@types/rollup": "^0.54.0",
28
30
  "estraverse": "^5.3.0",
29
31
  "graphql": "^15.8.0",
30
32
  "react": "^18.2.0",
33
+ "react-streaming": "^0.3.9",
31
34
  "recast": "^0.23.1",
32
35
  "rollup": "^3.7.4",
33
36
  "use-deep-compare-effect": "^1.8.1",
34
- "houdini": "^1.2.0-react.1"
37
+ "houdini": "^1.2.6"
35
38
  },
36
39
  "files": [
37
40
  "build"
38
41
  ],
39
42
  "exports": {
40
43
  "./package.json": "./package.json",
41
- "./next": {
42
- "import": "./build/next-esm/index.js",
43
- "require": "./build/next-cjs/index.js"
44
- },
45
44
  ".": {
45
+ "types": "./build/plugin/index.d.ts",
46
46
  "import": "./build/plugin-esm/index.js",
47
47
  "require": "./build/plugin-cjs/index.js"
48
48
  }
49
49
  },
50
50
  "typesVersions": {
51
- "*": {
52
- "next": [
53
- "build/next/index.d.ts"
54
- ]
55
- }
51
+ "*": {}
56
52
  },
57
53
  "main": "./build/plugin-cjs/index.js",
58
54
  "types": "./build/plugin/index.d.ts",
@@ -1,2 +0,0 @@
1
- import type { NextConfig } from 'next';
2
- export declare function withHoudini(nextConfig?: NextConfig): NextConfig;
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
@@ -1,26 +0,0 @@
1
- const require = conflict_free(import.meta.url);
2
-
3
- // src/next/index.ts
4
- function withHoudini(nextConfig) {
5
- return {
6
- ...nextConfig,
7
- webpack(config, options) {
8
- config.module.rules.push({
9
- test: /\.(jsx|tsx)$/,
10
- use: [
11
- options.defaultLoaders.babel,
12
- {
13
- loader: "houdini/webpack"
14
- }
15
- ]
16
- });
17
- if (nextConfig && typeof nextConfig.webpack === "function") {
18
- return nextConfig.webpack(config, options);
19
- }
20
- return config;
21
- }
22
- };
23
- }
24
- export {
25
- withHoudini
26
- };
@@ -1 +0,0 @@
1
- {"type":"module"}
@@ -1,7 +0,0 @@
1
- import { HoudiniClient } from '$houdini/runtime';
2
- import * as React from 'react';
3
- export declare const HoudiniContext: React.Context<HoudiniClient | null>;
4
- export declare const HoudiniProvider: ({ client, children, }: {
5
- client: HoudiniClient;
6
- children: React.ReactNode;
7
- }) => JSX.Element;
@@ -1,2 +0,0 @@
1
- import type { HoudiniClient } from '$houdini/runtime/client';
2
- export declare function useHoudiniClient(): HoudiniClient;
@@ -1,62 +0,0 @@
1
- /**
2
- * This file is a copy and paste of a very simple and effective LRU cache
3
- * using javascript maps. It was copied under the MIT license found at the
4
- * bottom of the page.
5
- */
6
- export interface Cache<T> {
7
- get(key: string): T | null;
8
- set(key: string, value: T): void;
9
- has(key: string): boolean;
10
- delete(key: string): void;
11
- size(): number;
12
- capacity(): number;
13
- clear(): void;
14
- }
15
- /**
16
- * JS maps (both plain objects and Map) maintain key insertion
17
- * order, which means there is an easy way to simulate LRU behavior
18
- * that should also perform quite well:
19
- *
20
- * To insert a new value, first delete the key from the inner _map,
21
- * then _map.set(k, v). By deleting and reinserting, you ensure that the
22
- * map sees the key as the last inserted key.
23
- *
24
- * Get does the same: if the key is present, delete and reinsert it.
25
- */
26
- declare class LRUCache<T> implements Cache<T> {
27
- _capacity: number;
28
- _map: Map<string, T>;
29
- constructor(capacity?: number);
30
- set(key: string, value: T): void;
31
- get(key: string): T | null;
32
- has(key: string): boolean;
33
- delete(key: string): void;
34
- size(): number;
35
- capacity(): number;
36
- clear(): void;
37
- }
38
- export declare function createCache<T>(capacity?: number): LRUCache<T>;
39
- export {};
40
- /**
41
- MIT License
42
-
43
- Copyright (c) Meta Platforms, Inc. and affiliates.
44
-
45
- Permission is hereby granted, free of charge, to any person obtaining a copy
46
- of this software and associated documentation files (the "Software"), to deal
47
- in the Software without restriction, including without limitation the rights
48
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49
- copies of the Software, and to permit persons to whom the Software is
50
- furnished to do so, subject to the following conditions:
51
-
52
- The above copyright notice and this permission notice shall be included in all
53
- copies or substantial portions of the Software.
54
-
55
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61
- SOFTWARE.
62
- */
@@ -1,7 +0,0 @@
1
- import { HoudiniClient } from '$houdini/runtime';
2
- import * as React from 'react';
3
- export declare const HoudiniContext: React.Context<HoudiniClient | null>;
4
- export declare const HoudiniProvider: ({ client, children, }: {
5
- client: HoudiniClient;
6
- children: React.ReactNode;
7
- }) => JSX.Element;
@@ -1,2 +0,0 @@
1
- import type { HoudiniClient } from '$houdini/runtime/client';
2
- export declare function useHoudiniClient(): HoudiniClient;
@@ -1,62 +0,0 @@
1
- /**
2
- * This file is a copy and paste of a very simple and effective LRU cache
3
- * using javascript maps. It was copied under the MIT license found at the
4
- * bottom of the page.
5
- */
6
- export interface Cache<T> {
7
- get(key: string): T | null;
8
- set(key: string, value: T): void;
9
- has(key: string): boolean;
10
- delete(key: string): void;
11
- size(): number;
12
- capacity(): number;
13
- clear(): void;
14
- }
15
- /**
16
- * JS maps (both plain objects and Map) maintain key insertion
17
- * order, which means there is an easy way to simulate LRU behavior
18
- * that should also perform quite well:
19
- *
20
- * To insert a new value, first delete the key from the inner _map,
21
- * then _map.set(k, v). By deleting and reinserting, you ensure that the
22
- * map sees the key as the last inserted key.
23
- *
24
- * Get does the same: if the key is present, delete and reinsert it.
25
- */
26
- declare class LRUCache<T> implements Cache<T> {
27
- _capacity: number;
28
- _map: Map<string, T>;
29
- constructor(capacity?: number);
30
- set(key: string, value: T): void;
31
- get(key: string): T | null;
32
- has(key: string): boolean;
33
- delete(key: string): void;
34
- size(): number;
35
- capacity(): number;
36
- clear(): void;
37
- }
38
- export declare function createCache<T>(capacity?: number): LRUCache<T>;
39
- export {};
40
- /**
41
- MIT License
42
-
43
- Copyright (c) Meta Platforms, Inc. and affiliates.
44
-
45
- Permission is hereby granted, free of charge, to any person obtaining a copy
46
- of this software and associated documentation files (the "Software"), to deal
47
- in the Software without restriction, including without limitation the rights
48
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49
- copies of the Software, and to permit persons to whom the Software is
50
- furnished to do so, subject to the following conditions:
51
-
52
- The above copyright notice and this permission notice shall be included in all
53
- copies or substantial portions of the Software.
54
-
55
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61
- SOFTWARE.
62
- */
@@ -1,7 +0,0 @@
1
- import { HoudiniClient } from '$houdini/runtime';
2
- import * as React from 'react';
3
- export declare const HoudiniContext: React.Context<HoudiniClient | null>;
4
- export declare const HoudiniProvider: ({ client, children, }: {
5
- client: HoudiniClient;
6
- children: React.ReactNode;
7
- }) => JSX.Element;
@@ -1,10 +0,0 @@
1
- import * as React from "react";
2
- const HoudiniContext = React.createContext(null);
3
- const HoudiniProvider = ({
4
- client,
5
- children
6
- }) => /* @__PURE__ */ React.createElement(HoudiniContext.Provider, { value: client }, children);
7
- export {
8
- HoudiniContext,
9
- HoudiniProvider
10
- };
@@ -1,2 +0,0 @@
1
- import type { HoudiniClient } from '$houdini/runtime/client';
2
- export declare function useHoudiniClient(): HoudiniClient;
@@ -1,12 +0,0 @@
1
- import * as React from "react";
2
- import { HoudiniContext } from "../context";
3
- function useHoudiniClient() {
4
- const client = React.useContext(HoudiniContext);
5
- if (!client) {
6
- throw new Error("Could not find client");
7
- }
8
- return client;
9
- }
10
- export {
11
- useHoudiniClient
12
- };
@@ -1,62 +0,0 @@
1
- /**
2
- * This file is a copy and paste of a very simple and effective LRU cache
3
- * using javascript maps. It was copied under the MIT license found at the
4
- * bottom of the page.
5
- */
6
- export interface Cache<T> {
7
- get(key: string): T | null;
8
- set(key: string, value: T): void;
9
- has(key: string): boolean;
10
- delete(key: string): void;
11
- size(): number;
12
- capacity(): number;
13
- clear(): void;
14
- }
15
- /**
16
- * JS maps (both plain objects and Map) maintain key insertion
17
- * order, which means there is an easy way to simulate LRU behavior
18
- * that should also perform quite well:
19
- *
20
- * To insert a new value, first delete the key from the inner _map,
21
- * then _map.set(k, v). By deleting and reinserting, you ensure that the
22
- * map sees the key as the last inserted key.
23
- *
24
- * Get does the same: if the key is present, delete and reinsert it.
25
- */
26
- declare class LRUCache<T> implements Cache<T> {
27
- _capacity: number;
28
- _map: Map<string, T>;
29
- constructor(capacity?: number);
30
- set(key: string, value: T): void;
31
- get(key: string): T | null;
32
- has(key: string): boolean;
33
- delete(key: string): void;
34
- size(): number;
35
- capacity(): number;
36
- clear(): void;
37
- }
38
- export declare function createCache<T>(capacity?: number): LRUCache<T>;
39
- export {};
40
- /**
41
- MIT License
42
-
43
- Copyright (c) Meta Platforms, Inc. and affiliates.
44
-
45
- Permission is hereby granted, free of charge, to any person obtaining a copy
46
- of this software and associated documentation files (the "Software"), to deal
47
- in the Software without restriction, including without limitation the rights
48
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49
- copies of the Software, and to permit persons to whom the Software is
50
- furnished to do so, subject to the following conditions:
51
-
52
- The above copyright notice and this permission notice shall be included in all
53
- copies or substantial portions of the Software.
54
-
55
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61
- SOFTWARE.
62
- */
@@ -1,47 +0,0 @@
1
- class LRUCache {
2
- _capacity;
3
- _map;
4
- constructor(capacity = 1e3) {
5
- this._capacity = capacity;
6
- this._map = /* @__PURE__ */ new Map();
7
- }
8
- set(key, value) {
9
- this._map.delete(key);
10
- this._map.set(key, value);
11
- if (this._map.size > this._capacity) {
12
- const firstKey = this._map.keys().next();
13
- if (!firstKey.done) {
14
- this._map.delete(firstKey.value);
15
- }
16
- }
17
- }
18
- get(key) {
19
- const value = this._map.get(key);
20
- if (value != null) {
21
- this._map.delete(key);
22
- this._map.set(key, value);
23
- }
24
- return value ?? null;
25
- }
26
- has(key) {
27
- return this._map.has(key);
28
- }
29
- delete(key) {
30
- this._map.delete(key);
31
- }
32
- size() {
33
- return this._map.size;
34
- }
35
- capacity() {
36
- return this._capacity - this._map.size;
37
- }
38
- clear() {
39
- this._map.clear();
40
- }
41
- }
42
- function createCache(capacity = 1e3) {
43
- return new LRUCache(capacity);
44
- }
45
- export {
46
- createCache
47
- };