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
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,25 +15,21 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
- var context_exports = {};
26
- __export(context_exports, {
27
- HoudiniContext: () => HoudiniContext,
28
- HoudiniProvider: () => HoudiniProvider
19
+ var components_exports = {};
20
+ __export(components_exports, {
21
+ Link: () => import_Link.Link,
22
+ Router: () => import_Router.Router,
23
+ RouterContextProvider: () => import_Router.RouterContextProvider,
24
+ useClient: () => import_Router.useClient
29
25
  });
30
- module.exports = __toCommonJS(context_exports);
31
- var React = __toESM(require("react"));
32
- const HoudiniContext = React.createContext(null);
33
- const HoudiniProvider = ({
34
- client,
35
- children
36
- }) => /* @__PURE__ */ React.createElement(HoudiniContext.Provider, { value: client }, children);
26
+ module.exports = __toCommonJS(components_exports);
27
+ var import_Link = require("./Link");
28
+ var import_Router = require("./Router");
37
29
  // Annotate the CommonJS export names for ESM import in node:
38
30
  0 && (module.exports = {
39
- HoudiniContext,
40
- HoudiniProvider
31
+ Link,
32
+ Router,
33
+ RouterContextProvider,
34
+ useClient
41
35
  });
@@ -0,0 +1,3 @@
1
+ export * from './components';
2
+ export { suspense_cache } from './lib/cache';
3
+ export type { RouterManifest, RouterPageManifest } from './lib/types';
@@ -0,0 +1,30 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var routing_exports = {};
21
+ __export(routing_exports, {
22
+ suspense_cache: () => import_cache.suspense_cache
23
+ });
24
+ module.exports = __toCommonJS(routing_exports);
25
+ __reExport(routing_exports, require("./components"), module.exports);
26
+ var import_cache = require("./lib/cache");
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ suspense_cache
30
+ });
@@ -0,0 +1,7 @@
1
+ import { LRUCache } from '$houdini/runtime/lib/lru';
2
+ export declare function suspense_cache<T>(): SuspenseCache<T>;
3
+ export declare class SuspenseCache<_Data> extends LRUCache<_Data> {
4
+ #private;
5
+ get(key: string): _Data;
6
+ set(key: string, value: _Data): void;
7
+ }
@@ -18,54 +18,37 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var cache_exports = {};
20
20
  __export(cache_exports, {
21
- createCache: () => createCache
21
+ SuspenseCache: () => SuspenseCache,
22
+ suspense_cache: () => suspense_cache
22
23
  });
23
24
  module.exports = __toCommonJS(cache_exports);
24
- class LRUCache {
25
- _capacity;
26
- _map;
27
- constructor(capacity = 1e3) {
28
- this._capacity = capacity;
29
- this._map = /* @__PURE__ */ new Map();
30
- }
31
- set(key, value) {
32
- this._map.delete(key);
33
- this._map.set(key, value);
34
- if (this._map.size > this._capacity) {
35
- const firstKey = this._map.keys().next();
36
- if (!firstKey.done) {
37
- this._map.delete(firstKey.value);
38
- }
39
- }
40
- }
25
+ var import_lru = require("$houdini/runtime/lib/lru");
26
+ function suspense_cache() {
27
+ return new SuspenseCache();
28
+ }
29
+ class SuspenseCache extends import_lru.LRUCache {
30
+ #callbacks = /* @__PURE__ */ new Map();
41
31
  get(key) {
42
- const value = this._map.get(key);
43
- if (value != null) {
44
- this._map.delete(key);
45
- this._map.set(key, value);
32
+ if (super.has(key)) {
33
+ return super.get(key);
46
34
  }
47
- return value ?? null;
48
- }
49
- has(key) {
50
- return this._map.has(key);
35
+ throw new Promise((resolve, reject) => {
36
+ this.#subscribe(key, resolve, reject);
37
+ });
51
38
  }
52
- delete(key) {
53
- this._map.delete(key);
54
- }
55
- size() {
56
- return this._map.size;
57
- }
58
- capacity() {
59
- return this._capacity - this._map.size;
39
+ set(key, value) {
40
+ super.set(key, value);
41
+ if (this.#callbacks.has(key)) {
42
+ this.#callbacks.get(key)?.forEach(({ resolve }) => resolve());
43
+ this.#callbacks.delete(key);
44
+ }
60
45
  }
61
- clear() {
62
- this._map.clear();
46
+ #subscribe(key, resolve, reject) {
47
+ this.#callbacks.set(key, [...this.#callbacks.get(key) || [], { resolve, reject }]);
63
48
  }
64
49
  }
65
- function createCache(capacity = 1e3) {
66
- return new LRUCache(capacity);
67
- }
68
50
  // Annotate the CommonJS export names for ESM import in node:
69
51
  0 && (module.exports = {
70
- createCache
52
+ SuspenseCache,
53
+ suspense_cache
71
54
  });
@@ -0,0 +1,38 @@
1
+ import type { GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ import type { RouterManifest, RouterPageManifest } from './types';
3
+ export type RouteParam = {
4
+ name: string;
5
+ matcher: string;
6
+ optional: boolean;
7
+ rest: boolean;
8
+ chained: boolean;
9
+ };
10
+ export interface ParamMatcher {
11
+ (param: string): boolean;
12
+ }
13
+ export declare function find_match(manifest: RouterManifest, current: string, allowNull: true): [RouterPageManifest | null, GraphQLVariables];
14
+ export declare function find_match(manifest: RouterManifest, current: string, allowNull?: false): [RouterPageManifest, GraphQLVariables];
15
+ /**
16
+ * Creates the regex pattern, extracts parameter names, and generates types for a route
17
+ */
18
+ export declare function parse_page_pattern(id: string): {
19
+ pattern: RegExp;
20
+ params: RouteParam[];
21
+ page_id: string;
22
+ };
23
+ /**
24
+ * Splits a route id into its segments, removing segments that
25
+ * don't affect the path (i.e. groups). The root route is represented by `/`
26
+ * and will be returned as `['']`.
27
+ */
28
+ export declare function get_route_segments(route: string): string[];
29
+ export declare function exec(match: RegExpMatchArray, params: RouteParam[]): Record<string, string> | undefined;
30
+ /**
31
+ Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
34
+
35
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
+ */
@@ -0,0 +1,149 @@
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 match_exports = {};
20
+ __export(match_exports, {
21
+ exec: () => exec,
22
+ find_match: () => find_match,
23
+ get_route_segments: () => get_route_segments,
24
+ parse_page_pattern: () => parse_page_pattern
25
+ });
26
+ module.exports = __toCommonJS(match_exports);
27
+ const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
28
+ function find_match(manifest, current, allowNull) {
29
+ let match = null;
30
+ let matchVariables = null;
31
+ for (const page of Object.values(manifest.pages)) {
32
+ const urlMatch = current.match(page.pattern);
33
+ if (!urlMatch) {
34
+ continue;
35
+ }
36
+ match = page;
37
+ matchVariables = exec(urlMatch, page.params) || {};
38
+ break;
39
+ }
40
+ if (!match && !allowNull) {
41
+ throw new Error("404");
42
+ }
43
+ return [match, matchVariables];
44
+ }
45
+ function parse_page_pattern(id) {
46
+ const params = [];
47
+ const pattern = id === "/" ? /^\/$/ : new RegExp(
48
+ `^${get_route_segments(id).map((segment) => {
49
+ const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
50
+ if (rest_match) {
51
+ params.push({
52
+ name: rest_match[1],
53
+ matcher: rest_match[2],
54
+ optional: false,
55
+ rest: true,
56
+ chained: true
57
+ });
58
+ return "(?:/(.*))?";
59
+ }
60
+ const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
61
+ if (optional_match) {
62
+ params.push({
63
+ name: optional_match[1],
64
+ matcher: optional_match[2],
65
+ optional: true,
66
+ rest: false,
67
+ chained: true
68
+ });
69
+ return "(?:/([^/]+))?";
70
+ }
71
+ if (!segment) {
72
+ return;
73
+ }
74
+ const parts = segment.split(/\[(.+?)\](?!\])/);
75
+ const result = parts.map((content, i) => {
76
+ if (i % 2) {
77
+ if (content.startsWith("x+")) {
78
+ return escape(
79
+ String.fromCharCode(parseInt(content.slice(2), 16))
80
+ );
81
+ }
82
+ if (content.startsWith("u+")) {
83
+ return escape(
84
+ String.fromCharCode(
85
+ ...content.slice(2).split("-").map((code) => parseInt(code, 16))
86
+ )
87
+ );
88
+ }
89
+ const match = param_pattern.exec(content);
90
+ if (!match) {
91
+ throw new Error(
92
+ `Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
93
+ );
94
+ }
95
+ const [, is_optional, is_rest, name, matcher] = match;
96
+ params.push({
97
+ name,
98
+ matcher,
99
+ optional: !!is_optional,
100
+ rest: !!is_rest,
101
+ chained: is_rest ? i === 1 && parts[0] === "" : false
102
+ });
103
+ return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
104
+ }
105
+ return escape(content);
106
+ }).join("");
107
+ return "/" + result;
108
+ }).join("")}/?$`
109
+ );
110
+ return { pattern, params, page_id: id };
111
+ }
112
+ function affects_path(segment) {
113
+ return !/^\([^)]+\)$/.test(segment);
114
+ }
115
+ function get_route_segments(route) {
116
+ return route.slice(1).split("/").filter(affects_path);
117
+ }
118
+ function exec(match, params) {
119
+ const result = {};
120
+ const values = match.slice(1);
121
+ let buffered = "";
122
+ for (let i = 0; i < params.length; i += 1) {
123
+ const param = params[i];
124
+ let value = values[i];
125
+ if (param.chained && param.rest && buffered) {
126
+ value = value ? buffered + "/" + value : buffered;
127
+ }
128
+ buffered = "";
129
+ if (value === void 0) {
130
+ if (param.rest)
131
+ result[param.name] = "";
132
+ } else {
133
+ result[param.name] = value;
134
+ }
135
+ }
136
+ if (buffered)
137
+ return;
138
+ return result;
139
+ }
140
+ function escape(str) {
141
+ return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
142
+ }
143
+ // Annotate the CommonJS export names for ESM import in node:
144
+ 0 && (module.exports = {
145
+ exec,
146
+ find_match,
147
+ get_route_segments,
148
+ parse_page_pattern
149
+ });
@@ -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
+ };
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,3 @@
1
+ import type { HoudiniClient } from '$houdini/runtime/client';
2
+ declare const _default: HoudiniClient;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ var client_default = {};
2
+ export {
3
+ client_default as default
4
+ };
@@ -0,0 +1,3 @@
1
+ import type { ClientPlugin } from 'houdini';
2
+ declare const plugin: () => ClientPlugin;
3
+ export default plugin;
@@ -0,0 +1,17 @@
1
+ const plugin = () => () => {
2
+ return {
3
+ beforeNetwork(ctx, { next }) {
4
+ next({
5
+ ...ctx,
6
+ cacheParams: {
7
+ ...ctx.fetchParams,
8
+ serverSideFallback: false
9
+ }
10
+ });
11
+ }
12
+ };
13
+ };
14
+ var clientPlugin_default = plugin;
15
+ export {
16
+ clientPlugin_default as default
17
+ };
@@ -1,13 +1,13 @@
1
- import { DocumentStore } from '$houdini/runtime/client';
2
- import { type QueryArtifact, GraphQLObject, CursorHandlers, OffsetHandlers, PageInfo, FetchFn, QueryResult, DocumentArtifact } from '$houdini/runtime/lib/types';
3
- export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, observer, storeValue, }: {
1
+ import type { DocumentStore } from '$houdini/runtime/client';
2
+ import type { GraphQLObject, GraphQLVariables, CursorHandlers, OffsetHandlers, PageInfo, FetchFn, QueryResult, DocumentArtifact, QueryArtifact } from '$houdini/runtime/lib/types';
3
+ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input extends GraphQLVariables>({ artifact, observer, storeValue, }: {
4
4
  artifact: DocumentArtifact;
5
5
  observer: DocumentStore<_Data, _Input>;
6
6
  storeValue: QueryResult<_Data, _Input>;
7
7
  }): DocumentHandle<_Artifact, _Data, _Input> & {
8
8
  fetch: FetchFn<_Data, _Input>;
9
9
  };
10
- export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []> = {
10
+ export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
11
11
  data: _Data;
12
12
  partial: boolean;
13
13
  } & RefetchHandlers<_Artifact, _Data, _Input>;
@@ -1,8 +1,6 @@
1
1
  import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
2
2
  import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
3
- import {
4
- ArtifactKind
5
- } from "$houdini/runtime/lib/types";
3
+ import { ArtifactKind } from "$houdini/runtime/lib/types";
6
4
  import React from "react";
7
5
  function useDocumentHandle({
8
6
  artifact,
@@ -34,7 +32,6 @@ function useDocumentHandle({
34
32
  artifact,
35
33
  getState: () => storeValue.data,
36
34
  getVariables: () => storeValue.variables,
37
- storeName: artifact.name,
38
35
  fetch: fetchQuery,
39
36
  fetchUpdate: (args, updates) => {
40
37
  return observer.send({
@@ -1,10 +1,11 @@
1
- import type { DocumentArtifact, QueryResult } from '$houdini/lib/types';
1
+ import type { DocumentArtifact, GraphQLVariables, QueryResult } from '$houdini/lib/types';
2
2
  import type { DocumentStore, ObserveParams } from '$houdini/runtime/client';
3
- import { GraphQLObject } from 'houdini';
4
- export type UseDocumentStoreParams<_Artifact extends DocumentArtifact, _Data extends GraphQLObject> = {
3
+ import type { GraphQLObject } from 'houdini';
4
+ export type UseDocumentStoreParams<_Artifact extends DocumentArtifact, _Data extends GraphQLObject, _Input extends GraphQLVariables> = {
5
5
  artifact: _Artifact;
6
- } & Partial<ObserveParams<_Data>>;
7
- export declare function useDocumentStore<_Data extends GraphQLObject = GraphQLObject, _Input extends {} = {}, _Artifact extends DocumentArtifact = DocumentArtifact>({ artifact, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data>): [
6
+ observer?: DocumentStore<_Data, _Input>;
7
+ } & Partial<ObserveParams<_Data, DocumentArtifact, _Input>>;
8
+ export declare function useDocumentStore<_Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables, _Artifact extends DocumentArtifact = DocumentArtifact>({ artifact, observer: obs, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data, _Input>): [
8
9
  QueryResult<_Data, _Input>,
9
10
  DocumentStore<_Data, _Input>,
10
11
  (store: DocumentStore<_Data, _Input>) => void
@@ -1,14 +1,15 @@
1
1
  import * as React from "react";
2
- import { useHoudiniClient } from "./useHoudiniClient";
2
+ import { useClient } from "../routing";
3
3
  import { useIsMountedRef } from "./useIsMounted";
4
4
  function useDocumentStore({
5
5
  artifact,
6
+ observer: obs,
6
7
  ...observeParams
7
8
  }) {
8
- const client = useHoudiniClient();
9
+ const client = useClient();
9
10
  const isMountedRef = useIsMountedRef();
10
11
  let [observer, setObserver] = React.useState(
11
- () => client.observe({
12
+ () => obs ?? client.observe({
12
13
  artifact,
13
14
  ...observeParams
14
15
  })
@@ -25,7 +26,11 @@ function useDocumentStore({
25
26
  },
26
27
  [observer]
27
28
  );
28
- const storeValue = React.useSyncExternalStore(subscribe, () => box.current);
29
+ const storeValue = React.useSyncExternalStore(
30
+ subscribe,
31
+ () => box.current,
32
+ () => box.current
33
+ );
29
34
  return [storeValue, observer, setObserver];
30
35
  }
31
36
  export {
@@ -1,9 +1,10 @@
1
- import type { DocumentArtifact, QueryResult } from '$houdini/lib/types';
1
+ import type { DocumentArtifact, GraphQLVariables, QueryResult } from '$houdini/lib/types';
2
2
  import type { DocumentStore, SendParams } from '$houdini/runtime/client';
3
- import { GraphQLObject } from 'houdini';
3
+ import type { GraphQLObject } from 'houdini';
4
4
  import { type UseDocumentStoreParams } from './useDocumentStore';
5
- export declare function useDocumentSubscription<_Artifact extends DocumentArtifact = DocumentArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = {}>({ artifact, variables, send, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data> & {
5
+ export declare function useDocumentSubscription<_Artifact extends DocumentArtifact = DocumentArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables>({ artifact, variables, send, disabled, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data, _Input> & {
6
6
  variables: _Input;
7
+ disabled?: boolean;
7
8
  send?: Partial<SendParams>;
8
9
  }): [
9
10
  QueryResult<_Data, _Input> & {
@@ -4,6 +4,7 @@ function useDocumentSubscription({
4
4
  artifact,
5
5
  variables,
6
6
  send,
7
+ disabled,
7
8
  ...observeParams
8
9
  }) {
9
10
  const [storeValue, observer, setObserver] = useDocumentStore({
@@ -11,16 +12,20 @@ function useDocumentSubscription({
11
12
  ...observeParams
12
13
  });
13
14
  useDeepCompareEffect(() => {
14
- observer.send({
15
- variables,
16
- session: {},
17
- metadata: {},
18
- ...send
19
- });
15
+ if (!disabled) {
16
+ observer.send({
17
+ variables,
18
+ session: {},
19
+ metadata: {},
20
+ ...send
21
+ });
22
+ }
20
23
  return () => {
21
- observer.cleanup();
24
+ if (!disabled) {
25
+ observer.cleanup();
26
+ }
22
27
  };
23
- }, [observer, variables ?? {}, send ?? {}]);
28
+ }, [disabled, observer, variables ?? {}, send ?? {}]);
24
29
  return [
25
30
  {
26
31
  parent: send?.stuff?.parentID,
@@ -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
  };
@@ -5,7 +5,7 @@ import * as React from "react";
5
5
  import { useDeepCompareMemoize } from "./useDeepCompareEffect";
6
6
  import { useDocumentSubscription } from "./useDocumentSubscription";
7
7
  function useFragment(reference, document) {
8
- const { parent, variables } = fragmentReference(
8
+ const { parent, variables, loading } = fragmentReference(
9
9
  reference,
10
10
  document
11
11
  );
@@ -14,20 +14,21 @@ function useFragment(reference, document) {
14
14
  cachedValue = cache.read({
15
15
  selection: document.artifact.selection,
16
16
  parent,
17
- variables
17
+ variables,
18
+ loading
18
19
  }).data;
19
20
  }
20
- const observeParams = {
21
+ const [storeValue] = useDocumentSubscription({
21
22
  artifact: document.artifact,
22
23
  variables,
23
24
  initialValue: cachedValue,
25
+ disabled: loading,
24
26
  send: {
25
27
  stuff: {
26
28
  parentID: parent
27
29
  }
28
30
  }
29
- };
30
- const [storeValue] = useDocumentSubscription(observeParams);
31
+ });
31
32
  const lastReference = React.useRef(null);
32
33
  return React.useMemo(() => {
33
34
  const parentChange = storeValue.parent !== parent || !deepEquals({ parent, variables }, lastReference.current);
@@ -47,14 +48,15 @@ function useFragment(reference, document) {
47
48
  ]);
48
49
  }
49
50
  function fragmentReference(reference, document) {
50
- const { variables, parent } = reference?.[fragmentKey]?.[document.artifact.name] ?? {};
51
+ const { variables, parent } = reference?.[fragmentKey]?.values?.[document.artifact.name] ?? {};
51
52
  if (reference && fragmentKey in reference && (!variables || !parent)) {
52
53
  console.warn(
53
54
  `\u26A0\uFE0F Parent does not contain the information for this fragment. Something is wrong.
54
55
  Please ensure that you have passed a record that has ${document.artifact.name} mixed into it.`
55
56
  );
56
57
  }
57
- return { variables, parent };
58
+ const loading = Boolean(reference?.[fragmentKey]?.loading);
59
+ return { variables, parent, loading };
58
60
  }
59
61
  export {
60
62
  fragmentReference,
@@ -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;