houdini-core 2.0.3 → 2.0.5

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.
package/bin/houdini-core CHANGED
@@ -125,6 +125,8 @@ if (PLATFORM_OVERRIDE === 'wasm') {
125
125
  }
126
126
 
127
127
  // --- Native binary path ---
128
+ const attempted = [];
129
+
128
130
  function getBinaryPath() {
129
131
  if (MANUAL_BINARY_PATH && fs.existsSync(MANUAL_BINARY_PATH)) {
130
132
  return MANUAL_BINARY_PATH;
@@ -138,36 +140,82 @@ function getBinaryPath() {
138
140
  process.stderr.write(`[houdini-core] Unknown platform "${PLATFORM_OVERRIDE}". Valid values: ${Object.keys(BINARY_DISTRIBUTION_PACKAGES).join(', ')}, wasm\n`);
139
141
  process.exit(1);
140
142
  }
141
- return path.join(__dirname, binaryName);
143
+ return path.join(__dirname, '..', binaryName);
142
144
  }
143
145
 
146
+ // module resolution from the shim's own location: real installs, and any
147
+ // environment that provides NODE_PATH (pnpm scripts do)
144
148
  try {
145
149
  const platformPackagePath = require.resolve(`${platformSpecificPackageName}/package.json`);
146
150
  return path.join(path.dirname(platformPackagePath), 'bin', binaryName);
147
151
  } catch {
148
- const siblingPath = path.join(__dirname, '..', platformSpecificPackageName, 'bin', binaryName);
149
- if (fs.existsSync(siblingPath)) return siblingPath;
150
-
151
- const pnpmMatch = __dirname.match(/(.+\/node_modules\/)\.pnpm\/[^/]+\/node_modules\//);
152
- if (pnpmMatch) {
153
- const pnpmDir = path.join(pnpmMatch[1], '.pnpm');
154
- try {
155
- const packageJSON = require(path.join(__dirname, '..', 'package.json'));
156
- const entry = `${platformSpecificPackageName}@${packageJSON.version}`;
157
- const found = fs.readdirSync(pnpmDir).find(e => e === entry);
158
- if (found) {
159
- const p = path.join(pnpmDir, found, 'node_modules', platformSpecificPackageName, 'bin', binaryName);
160
- if (fs.existsSync(p)) return p;
161
- }
162
- } catch {}
163
- }
152
+ attempted.push(`require.resolve('${platformSpecificPackageName}') from ${__dirname}`);
153
+ }
154
+
155
+ // module resolution from the invoking project: a linked development setup puts
156
+ // the platform package in the project's node_modules, which the walk from the
157
+ // shim's realpath (inside the linked repo) never visits
158
+ try {
159
+ const platformPackagePath = require.resolve(`${platformSpecificPackageName}/package.json`, {
160
+ paths: [process.cwd()],
161
+ });
162
+ return path.join(path.dirname(platformPackagePath), 'bin', binaryName);
163
+ } catch {
164
+ attempted.push(`require.resolve('${platformSpecificPackageName}') from ${process.cwd()}`);
165
+ }
164
166
 
165
- return path.join(__dirname, binaryName);
167
+ // flat node_modules: the platform package next to this one
168
+ const siblingPath = path.join(__dirname, '..', platformSpecificPackageName, 'bin', binaryName);
169
+ if (fs.existsSync(siblingPath)) return siblingPath;
170
+ attempted.push(siblingPath);
171
+
172
+ // monorepo build layout: the shim lives at <pkg>/build/houdini-core/bin and the
173
+ // platform package at <pkg>/build/<platform package>
174
+ const buildSiblingPath = path.join(__dirname, '..', '..', platformSpecificPackageName, 'bin', binaryName);
175
+ if (fs.existsSync(buildSiblingPath)) return buildSiblingPath;
176
+ attempted.push(buildSiblingPath);
177
+
178
+ const pnpmMatch = __dirname.match(/(.+\/node_modules\/)\.pnpm\/[^/]+\/node_modules\//);
179
+ if (pnpmMatch) {
180
+ const pnpmDir = path.join(pnpmMatch[1], '.pnpm');
181
+ try {
182
+ const packageJSON = require(path.join(__dirname, '..', 'package.json'));
183
+ const entry = `${platformSpecificPackageName}@${packageJSON.version}`;
184
+ const found = fs.readdirSync(pnpmDir).find(e => e === entry);
185
+ if (found) {
186
+ const p = path.join(pnpmDir, found, 'node_modules', platformSpecificPackageName, 'bin', binaryName);
187
+ if (fs.existsSync(p)) return p;
188
+ }
189
+ attempted.push(path.join(pnpmDir, entry, 'node_modules', platformSpecificPackageName, 'bin', binaryName));
190
+ } catch {}
166
191
  }
192
+
193
+ // the binary postInstall downloads into the package root when no platform
194
+ // package could be installed (the shim lives in bin/, one level down)
195
+ return path.join(__dirname, '..', binaryName);
196
+ }
197
+
198
+ // Refuse to exec ourselves: when every resolution attempt fails, the final
199
+ // candidate (the postInstall download location) can be this very script — exec'ing
200
+ // it recurses forever, forking a new node per iteration until the machine chokes.
201
+ // A missing binary must be a loud error, never a spawn loop.
202
+ const binaryPath = getBinaryPath();
203
+ let realBinaryPath = null;
204
+ try {
205
+ realBinaryPath = fs.realpathSync(binaryPath);
206
+ } catch {}
207
+ if (!realBinaryPath || realBinaryPath === fs.realpathSync(__filename)) {
208
+ attempted.push(binaryPath);
209
+ process.stderr.write(
210
+ `[houdini-core] Could not locate the houdini-core binary for ${process.platform}-${process.arch}. Tried:\n` +
211
+ attempted.map((p) => ` - ${p}\n`).join('') +
212
+ `Install the platform package for your system or point HOUDINI_CORE_BINARY_PATH at the binary.\n`
213
+ );
214
+ process.exit(1);
167
215
  }
168
216
 
169
217
  try {
170
- execFileSync(getBinaryPath(), process.argv.slice(2), { stdio: 'inherit' });
218
+ execFileSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
171
219
  } catch (error) {
172
220
  process.exit(error.status || 1);
173
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-core",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "The core GraphQL client for Houdini",
5
5
  "keywords": [
6
6
  "graphql",
@@ -21,13 +21,13 @@
21
21
  "minimatch": "^10.2.5"
22
22
  },
23
23
  "optionalDependencies": {
24
- "houdini-core-darwin-x64": "2.0.3",
25
- "houdini-core-darwin-arm64": "2.0.3",
26
- "houdini-core-linux-x64": "2.0.3",
27
- "houdini-core-linux-arm64": "2.0.3",
28
- "houdini-core-win32-x64": "2.0.3",
29
- "houdini-core-win32-arm64": "2.0.3",
30
- "houdini-core-wasm": "2.0.3"
24
+ "houdini-core-darwin-x64": "2.0.5",
25
+ "houdini-core-darwin-arm64": "2.0.5",
26
+ "houdini-core-linux-x64": "2.0.5",
27
+ "houdini-core-linux-arm64": "2.0.5",
28
+ "houdini-core-win32-x64": "2.0.5",
29
+ "houdini-core-win32-arm64": "2.0.5",
30
+ "houdini-core-wasm": "2.0.5"
31
31
  },
32
32
  "files": [
33
33
  "bin",
package/postInstall.js CHANGED
@@ -5,7 +5,7 @@ const https = require('https')
5
5
  const child_process = require('child_process')
6
6
 
7
7
  // Adjust the version you want to install. You can also make this dynamic.
8
- const BINARY_DISTRIBUTION_VERSION = '2.0.3'
8
+ const BINARY_DISTRIBUTION_VERSION = '2.0.5'
9
9
 
10
10
  // Windows binaries end with .exe so we need to special case them.
11
11
  const binaryName = process.platform === 'win32' ? 'houdini-core.exe' : 'houdini-core'
@@ -28,8 +28,11 @@ export type CacheTypeDef = {
28
28
  // entries in the tuple are graphql tag, query shape, query input
29
29
  queries: [any, any, any][]
30
30
 
31
- // a union of valid runtime types (default scalars | config types)
32
- scalars: any
31
+ // a union of valid runtime types (default scalars | config types).
32
+ // optional so the placeholder generated.ts (which re-exports the published
33
+ // CacheTypeDef, whose scalars only exist via augmentation) satisfies the
34
+ // constraint before codegen overwrites it
35
+ scalars?: any
33
36
  }
34
37
 
35
38
  export type ValidTypes<Def extends CacheTypeDef> = keyof Def['types']
@@ -107,60 +110,58 @@ export type ListType<Def extends CacheTypeDef, Name extends ValidLists<Def>> = P
107
110
  // it very responsive.
108
111
 
109
112
  /**
110
- * Note on the `_Key extends _Target && _Target extends _Key` check:
111
- * Sometimes two queries might have a similar shape/inputs, e.g.:
112
- *
113
- * query Query1($userId: ID!) { | query Query2($userId: ID!) {
114
- * user(id: $userId) { | user($id: $userId) {
115
- * id | id
116
- * name | name
117
- * } | birthDate
118
- * } | }
119
- * | }
120
- *
121
- * To TypeScript, it would look like Query2's result would extend Query1's result.
122
- * But if Query2 was listed in front of Query1 in the queries array above, `_Key extends _Target` will evaluate to true,
123
- * causing it to return Query2's input/result types, while you were looking for Query1's input/result types.
124
- * The additional `_Target extends _Key` ensures that the two objects have exactly the same shape, at least prompting the
125
- * user for the correct fields.
113
+ * Each entry in the queries/fragments lists is keyed by the document's artifact type
114
+ * (`X$artifact`, the type of the generated artifact const). Every artifact carries
115
+ * unique literal values (name, hash) so the mutual-extends check below identifies
116
+ * exactly one document even two documents with identical selections have distinct
117
+ * hashes. The target can be anything that exposes the artifact (a `graphql()` handle
118
+ * or a framework store), so matching goes through its `artifact` member.
126
119
  */
127
120
 
128
121
  export type FragmentVariables<_List, _Target> = _List extends [infer Head, ...infer Rest]
129
122
  ? Head extends [infer _Key, infer _Value, infer _Input]
130
- ? _Key extends _Target
131
- ? _Target extends _Key
132
- ? _Input
133
- : FragmentValue<Rest, _Target>
134
- : FragmentValue<Rest, _Target>
123
+ ? _Target extends { artifact: infer _Artifact }
124
+ ? _Artifact extends _Key
125
+ ? _Key extends _Artifact
126
+ ? _Input
127
+ : FragmentVariables<Rest, _Target>
128
+ : FragmentVariables<Rest, _Target>
129
+ : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
135
130
  : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
136
131
  : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
137
132
 
138
133
  export type FragmentValue<List, _Target> = List extends [infer Head, ...infer Rest]
139
134
  ? Head extends [infer _Key, infer _Value, infer _Input]
140
- ? _Key extends _Target
141
- ? _Target extends _Key
142
- ? _Value
135
+ ? _Target extends { artifact: infer _Artifact }
136
+ ? _Artifact extends _Key
137
+ ? _Key extends _Artifact
138
+ ? _Value
139
+ : FragmentValue<Rest, _Target>
143
140
  : FragmentValue<Rest, _Target>
144
- : FragmentValue<Rest, _Target>
141
+ : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
145
142
  : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
146
143
  : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
147
144
 
148
145
  export type QueryValue<List, _Target> = List extends [infer Head, ...infer Rest]
149
146
  ? Head extends [infer _Key, infer _Value, infer _Input]
150
- ? _Key extends _Target
151
- ? _Target extends _Key
152
- ? _Value
147
+ ? _Target extends { artifact: infer _Artifact }
148
+ ? _Artifact extends _Key
149
+ ? _Key extends _Artifact
150
+ ? _Value
151
+ : QueryValue<Rest, _Target>
153
152
  : QueryValue<Rest, _Target>
154
- : QueryValue<Rest, _Target>
153
+ : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
155
154
  : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
156
155
  : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
157
156
 
158
157
  export type QueryInput<List, _Target> = List extends [infer Head, ...infer Rest]
159
158
  ? Head extends [infer _Key, infer _Value, infer _Input]
160
- ? _Key extends _Target
161
- ? _Target extends _Key
162
- ? _Input
159
+ ? _Target extends { artifact: infer _Artifact }
160
+ ? _Artifact extends _Key
161
+ ? _Key extends _Artifact
162
+ ? _Input
163
+ : QueryInput<Rest, _Target>
163
164
  : QueryInput<Rest, _Target>
164
- : QueryInput<Rest, _Target>
165
+ : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
165
166
  : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'
166
167
  : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).'