houdini-react 2.0.0-go.0 → 2.0.0-go.10

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 (48) hide show
  1. package/bin/houdini-react +84 -0
  2. package/package.json +37 -18
  3. package/postInstall.js +351 -0
  4. package/README.md +0 -36
  5. package/build/houdini-react/package.json +0 -92
  6. package/build/houdini-react/postInstall.js +0 -117
  7. package/build/houdini-react/shim.cjs +0 -64
  8. package/build/houdini-react-darwin-arm64/bin/houdini-react +0 -0
  9. package/build/houdini-react-darwin-arm64/package.json +0 -11
  10. package/build/houdini-react-darwin-x64/bin/houdini-react +0 -0
  11. package/build/houdini-react-darwin-x64/package.json +0 -11
  12. package/build/houdini-react-linux-arm64/bin/houdini-react +0 -0
  13. package/build/houdini-react-linux-arm64/package.json +0 -11
  14. package/build/houdini-react-linux-x64/bin/houdini-react +0 -0
  15. package/build/houdini-react-linux-x64/package.json +0 -11
  16. package/build/houdini-react-windows-arm64/bin/houdini-react.exe +0 -0
  17. package/build/houdini-react-windows-arm64/package.json +0 -11
  18. package/build/houdini-react-windows-x64/bin/houdini-react.exe +0 -0
  19. package/build/houdini-react-windows-x64/package.json +0 -11
  20. package/build/package.json +0 -91
  21. /package/{build/houdini-react/runtime → runtime}/client.ts +0 -0
  22. /package/{build/houdini-react/runtime → runtime}/clientPlugin.ts +0 -0
  23. /package/{build/houdini-react/runtime → runtime}/componentFields.ts +0 -0
  24. /package/{build/houdini-react/runtime → runtime}/hooks/index.ts +0 -0
  25. /package/{build/houdini-react/runtime → runtime}/hooks/useDeepCompareEffect.ts +0 -0
  26. /package/{build/houdini-react/runtime → runtime}/hooks/useDocumentHandle.ts +0 -0
  27. /package/{build/houdini-react/runtime → runtime}/hooks/useDocumentStore.ts +0 -0
  28. /package/{build/houdini-react/runtime → runtime}/hooks/useDocumentSubscription.ts +0 -0
  29. /package/{build/houdini-react/runtime → runtime}/hooks/useFragment.ts +0 -0
  30. /package/{build/houdini-react/runtime → runtime}/hooks/useFragmentHandle.ts +0 -0
  31. /package/{build/houdini-react/runtime → runtime}/hooks/useIsMounted.ts +0 -0
  32. /package/{build/houdini-react/runtime → runtime}/hooks/useMutation.ts +0 -0
  33. /package/{build/houdini-react/runtime → runtime}/hooks/useQuery.ts +0 -0
  34. /package/{build/houdini-react/runtime → runtime}/hooks/useQueryHandle.ts +0 -0
  35. /package/{build/houdini-react/runtime → runtime}/hooks/useSubscription.ts +0 -0
  36. /package/{build/houdini-react/runtime → runtime}/hooks/useSubscriptionHandle.ts +0 -0
  37. /package/{build/houdini-react/runtime → runtime}/index.tsx +0 -0
  38. /package/{build/houdini-react/runtime → runtime}/manifest.ts +0 -0
  39. /package/{build/houdini-react/runtime → runtime}/package.json +0 -0
  40. /package/{build/houdini-react/runtime → runtime}/routing/Router.tsx +0 -0
  41. /package/{build/houdini-react/runtime → runtime}/routing/cache.ts +0 -0
  42. /package/{build/houdini-react/runtime → runtime}/routing/index.ts +0 -0
  43. /package/{build/houdini-react/server → server}/index.d.ts +0 -0
  44. /package/{build/houdini-react/server → server}/index.js +0 -0
  45. /package/{build/houdini-react/server → server}/package.json +0 -0
  46. /package/{build/houdini-react/vite → vite}/index.d.ts +0 -0
  47. /package/{build/houdini-react/vite → vite}/index.js +0 -0
  48. /package/{build/houdini-react/vite → vite}/package.json +0 -0
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Simple shim that can be replaced with the actual binary for optimal performance
4
+ // This follows esbuild's approach: the postInstall script will replace this entire file
5
+ // with the native binary when possible, eliminating Node.js startup overhead
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { execFileSync } = require('child_process');
10
+
11
+ // Manual binary path override support
12
+ const MANUAL_BINARY_PATH = process.env.HOUDINI_BINARY_PATH || process.env.HOUDINI_REACT_BINARY_PATH;
13
+
14
+ function getBinaryPath() {
15
+ // Check for manual override first
16
+ if (MANUAL_BINARY_PATH && fs.existsSync(MANUAL_BINARY_PATH)) {
17
+ return MANUAL_BINARY_PATH;
18
+ }
19
+
20
+ // Platform-specific package lookup
21
+ const BINARY_DISTRIBUTION_PACKAGES = {
22
+ 'linux-x64': 'houdini-react-linux-x64',
23
+ 'linux-arm64': 'houdini-react-linux-arm64',
24
+ 'win32-x64': 'houdini-react-win32-x64',
25
+ 'win32-arm64': 'houdini-react-win32-arm64',
26
+ 'darwin-x64': 'houdini-react-darwin-x64',
27
+ 'darwin-arm64': 'houdini-react-darwin-arm64',
28
+ }
29
+
30
+ const binaryName = process.platform === 'win32' ? 'houdini-react.exe' : 'houdini-react'
31
+ const platformSpecificPackageName = BINARY_DISTRIBUTION_PACKAGES[`${process.platform}-${process.arch}`]
32
+
33
+ if (!platformSpecificPackageName) {
34
+ // Fallback to downloaded binary if platform not supported
35
+ return path.join(__dirname, binaryName)
36
+ }
37
+
38
+ try {
39
+ // Method 1: Use require.resolve to find the platform-specific package
40
+ const platformPackagePath = require.resolve(`${platformSpecificPackageName}/package.json`)
41
+ const platformPackageDir = path.dirname(platformPackagePath)
42
+ return path.join(platformPackageDir, 'bin', binaryName)
43
+ } catch (error) {
44
+ // Method 2: Check sibling directory (npm structure)
45
+ const siblingPath = path.join(__dirname, '..', platformSpecificPackageName)
46
+ const siblingBinaryPath = path.join(siblingPath, 'bin', binaryName)
47
+
48
+ if (fs.existsSync(siblingBinaryPath)) {
49
+ return siblingBinaryPath
50
+ }
51
+
52
+ // Method 3: Check pnpm structure
53
+ const pnpmMatch = __dirname.match(/(.+\/node_modules\/)\.pnpm\/([^\/]+)\/node_modules\//)
54
+ if (pnpmMatch) {
55
+ const [, nodeModulesRoot] = pnpmMatch
56
+ const pnpmDir = path.join(nodeModulesRoot, '.pnpm')
57
+
58
+ try {
59
+ const pnpmEntries = fs.readdirSync(pnpmDir)
60
+ const platformEntry = pnpmEntries.find(entry => entry.startsWith(platformSpecificPackageName + '@'))
61
+
62
+ if (platformEntry) {
63
+ const pnpmBinaryPath = path.join(pnpmDir, platformEntry, 'node_modules', platformSpecificPackageName, 'bin', binaryName)
64
+ if (fs.existsSync(pnpmBinaryPath)) {
65
+ return pnpmBinaryPath
66
+ }
67
+ }
68
+ } catch (err) {
69
+ // Ignore pnpm detection errors
70
+ }
71
+ }
72
+
73
+ // Method 4: Fallback to downloaded binary in main package
74
+ return path.join(__dirname, binaryName)
75
+ }
76
+ }
77
+
78
+ // Execute the binary directly (this entire file may be replaced with the actual binary)
79
+ try {
80
+ execFileSync(getBinaryPath(), process.argv.slice(2), { stdio: 'inherit' });
81
+ } catch (error) {
82
+ // If execFileSync fails, exit with the same code
83
+ process.exit(error.status || 1);
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "2.0.0-go.0",
3
+ "version": "2.0.0-go.10",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -22,8 +22,7 @@
22
22
  "@types/estraverse": "^5.1.2",
23
23
  "@types/express": "^4.17.17",
24
24
  "@types/react": "^19.0.7",
25
- "@types/react-dom": "^19.0.3",
26
- "scripts": "^2.0.0-go.0"
25
+ "@types/react-dom": "^19.0.3"
27
26
  },
28
27
  "dependencies": {
29
28
  "@babel/parser": "^7.24.6",
@@ -41,36 +40,56 @@
41
40
  "react-streaming-compat": "^0.3.18",
42
41
  "recast": "^0.23.1",
43
42
  "rollup": "^4.28.1",
44
- "use-deep-compare-effect": "^1.8.1",
45
- "houdini": "^2.0.0-go.0"
43
+ "use-deep-compare-effect": "^1.8.1"
46
44
  },
47
45
  "files": [
48
- "build"
46
+ "bin",
47
+ "postInstall.js",
48
+ "runtime",
49
+ "server",
50
+ "vite"
49
51
  ],
50
52
  "exports": {
51
53
  "./package.json": "./package.json",
52
- ".": {
53
- "types": "./build/plugin/index.d.ts",
54
- "import": "./build/plugin-esm/index.js",
55
- "require": "./build/plugin-cjs/index.js"
56
- },
57
54
  "./server": {
58
- "types": "./build/server/index.d.ts",
59
- "import": "./build/server-esm/index.js",
60
- "require": "./build/server-cjs/index.js"
55
+ "types": "./server/index.d.ts",
56
+ "import": "./server/index.js"
57
+ },
58
+ "./server/*": {
59
+ "types": "./server/*",
60
+ "import": "./server/*"
61
+ },
62
+ "./vite": {
63
+ "types": "./vite/index.d.ts",
64
+ "import": "./vite/index.js"
65
+ },
66
+ "./vite/*": {
67
+ "types": "./vite/*",
68
+ "import": "./vite/*"
61
69
  }
62
70
  },
63
71
  "typesVersions": {
64
72
  "*": {
65
73
  "server": [
66
- "./build/server/index.d.ts"
74
+ "./server/index.d.ts"
75
+ ],
76
+ "vite": [
77
+ "./vite/index.d.ts"
67
78
  ]
68
79
  }
69
80
  },
70
- "main": "./build/plugin-cjs/index.js",
71
- "types": "./build/plugin/index.d.ts",
81
+ "optionalDependencies": {
82
+ "houdini-react-darwin-x64": "2.0.0-go.10",
83
+ "houdini-react-darwin-arm64": "2.0.0-go.10",
84
+ "houdini-react-linux-x64": "2.0.0-go.10",
85
+ "houdini-react-linux-arm64": "2.0.0-go.10",
86
+ "houdini-react-win32-x64": "2.0.0-go.10",
87
+ "houdini-react-win32-arm64": "2.0.0-go.10"
88
+ },
89
+ "bin": "bin/houdini-react",
72
90
  "scripts": {
73
91
  "compile": "scripts build-go",
74
- "typedefs": "scripts typedefs --plugin --go-package"
92
+ "typedefs": "scripts typedefs --plugin --go-package",
93
+ "postinstall": "node postInstall.js"
75
94
  }
76
95
  }
package/postInstall.js ADDED
@@ -0,0 +1,351 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const zlib = require('zlib')
4
+ const https = require('https')
5
+ const child_process = require('child_process')
6
+
7
+ // Adjust the version you want to install. You can also make this dynamic.
8
+ const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.10'
9
+
10
+ // Windows binaries end with .exe so we need to special case them.
11
+ const binaryName = process.platform === 'win32' ? 'houdini-react.exe' : 'houdini-react'
12
+
13
+ // Determine package name for this platform
14
+ const platformSpecificPackageName = `houdini-react-${process.platform}-${process.arch}`
15
+
16
+ // Compute the path we want to emit the fallback binary to
17
+ const fallbackBinaryPath = path.join(__dirname, binaryName)
18
+
19
+ // Manual binary path override support
20
+ const MANUAL_BINARY_PATH = process.env.HOUDINI_BINARY_PATH || process.env.HOUDINI_REACT_BINARY_PATH
21
+
22
+ // Package version for validation
23
+ const packageJSON = require(path.join(__dirname, 'package.json'))
24
+ const expectedVersion = packageJSON.version
25
+
26
+ // Track if shim is still JavaScript
27
+ let isShimJS = true
28
+
29
+ function makeRequest(url) {
30
+ return new Promise((resolve, reject) => {
31
+ https
32
+ .get(url, (response) => {
33
+ if (response.statusCode >= 200 && response.statusCode < 300) {
34
+ const chunks = []
35
+ response.on('data', (chunk) => chunks.push(chunk))
36
+ response.on('end', () => {
37
+ resolve(Buffer.concat(chunks))
38
+ })
39
+ } else if (
40
+ response.statusCode >= 300 &&
41
+ response.statusCode < 400 &&
42
+ response.headers.location
43
+ ) {
44
+ // Follow redirects
45
+ makeRequest(response.headers.location).then(resolve, reject)
46
+ } else {
47
+ reject(
48
+ new Error(
49
+ `npm responded with status code ${response.statusCode} when downloading the package!`
50
+ )
51
+ )
52
+ }
53
+ })
54
+ .on('error', (error) => {
55
+ reject(error)
56
+ })
57
+ })
58
+ }
59
+
60
+ function extractFileFromTarball(tarballBuffer, filepath) {
61
+ // Tar archives are organized in 512 byte blocks.
62
+ // Blocks can either be header blocks or data blocks.
63
+ // Header blocks contain file names of the archive in the first 100 bytes, terminated by a null byte.
64
+ // The size of a file is contained in bytes 124-135 of a header block and in octal format.
65
+ // The following blocks will be data blocks containing the file.
66
+ let offset = 0
67
+ while (offset < tarballBuffer.length) {
68
+ const header = tarballBuffer.subarray(offset, offset + 512)
69
+ offset += 512
70
+
71
+ const fileName = header.toString('utf-8', 0, 100).replace(/\0.*/g, '')
72
+ const fileSize = parseInt(header.toString('utf-8', 124, 136).replace(/\0.*/g, ''), 8)
73
+
74
+ if (fileName === filepath) {
75
+ return tarballBuffer.subarray(offset, offset + fileSize)
76
+ }
77
+
78
+ // Clamp offset to the uppoer multiple of 512
79
+ offset = (offset + fileSize + 511) & ~511
80
+ }
81
+ }
82
+
83
+ function installUsingNPM() {
84
+ // Erase "npm_config_global" so that "npm install --global" works.
85
+ // Otherwise this nested "npm install" will also be global, and the install
86
+ // will deadlock waiting for the global installation lock.
87
+ const env = { ...process.env, npm_config_global: undefined };
88
+
89
+ // Create a temporary directory with an empty package.json
90
+ const tempDir = path.join(__dirname, 'npm-install-temp');
91
+
92
+ try {
93
+ fs.mkdirSync(tempDir);
94
+ fs.writeFileSync(path.join(tempDir, 'package.json'), '{}');
95
+
96
+ // Run npm install in the temporary directory
97
+ child_process.execSync(
98
+ `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${platformSpecificPackageName}@${BINARY_DISTRIBUTION_VERSION}`,
99
+ { cwd: tempDir, stdio: 'pipe', env }
100
+ );
101
+
102
+ // Move the downloaded binary to the fallback location
103
+ const installedBinaryPath = path.join(tempDir, 'node_modules', platformSpecificPackageName, 'bin', binaryName);
104
+ fs.renameSync(installedBinaryPath, fallbackBinaryPath);
105
+
106
+ return true;
107
+ } catch (err) {
108
+ console.error(`[${packageJSON.name}] npm install fallback failed: ${err.message}`);
109
+ return false;
110
+ } finally {
111
+ // Clean up temporary directory
112
+ try {
113
+ removeRecursive(tempDir);
114
+ } catch {
115
+ // Ignore cleanup errors
116
+ }
117
+ }
118
+ }
119
+
120
+ function removeRecursive(dir) {
121
+ if (!fs.existsSync(dir)) return;
122
+
123
+ for (const entry of fs.readdirSync(dir)) {
124
+ const entryPath = path.join(dir, entry);
125
+ const stats = fs.lstatSync(entryPath);
126
+
127
+ if (stats.isDirectory()) {
128
+ removeRecursive(entryPath);
129
+ } else {
130
+ fs.unlinkSync(entryPath);
131
+ }
132
+ }
133
+
134
+ fs.rmdirSync(dir);
135
+ }
136
+
137
+ async function downloadBinaryFromNpm() {
138
+ // First try nested npm install (like esbuild does)
139
+ if (installUsingNPM()) {
140
+ console.log(`[${packageJSON.name}] Downloaded binary via npm install`);
141
+ return;
142
+ }
143
+
144
+ // Fallback to direct HTTP download
145
+ console.log(`[${packageJSON.name}] Trying direct download from npm registry...`);
146
+
147
+ // Download the tarball of the right binary distribution package
148
+ const tarballDownloadBuffer = await makeRequest(
149
+ `https://registry.npmjs.org/${platformSpecificPackageName}/-/${platformSpecificPackageName}-${BINARY_DISTRIBUTION_VERSION}.tgz`
150
+ )
151
+
152
+ const tarballBuffer = zlib.unzipSync(tarballDownloadBuffer)
153
+
154
+ // Extract binary from package and write to disk
155
+ fs.writeFileSync(
156
+ fallbackBinaryPath,
157
+ extractFileFromTarball(tarballBuffer, `package/bin/${binaryName}`),
158
+ { mode: 0o755 } // Make binary file executable
159
+ )
160
+
161
+ console.log(`[${packageJSON.name}] Downloaded binary via direct download`);
162
+ }
163
+
164
+ function isPlatformSpecificPackageInstalled() {
165
+ try {
166
+ // Try to resolve the platform package itself
167
+ require.resolve(`${platformSpecificPackageName}/package.json`)
168
+ return true
169
+ } catch (e) {
170
+ // Also check if it exists as a sibling directory
171
+ const siblingPath = path.join(__dirname, '..', platformSpecificPackageName)
172
+ const siblingBinaryPath = path.join(siblingPath, 'bin', binaryName)
173
+ return fs.existsSync(siblingBinaryPath)
174
+ }
175
+ }
176
+
177
+ if (!platformSpecificPackageName) {
178
+ throw new Error('Platform not supported!')
179
+ }
180
+
181
+ // Replace the JavaScript shim with the actual binary for optimal performance (skip Node.js overhead)
182
+ // This is inspired by esbuild's approach: https://github.com/evanw/esbuild/blob/main/lib/npm/node-install.ts
183
+ function maybeOptimizePackage() {
184
+ // This optimization doesn't work on Windows because the binary must be called with .exe extension
185
+ // It also doesn't work with Yarn due to various compatibility issues
186
+ if (process.platform === 'win32' || isYarn()) {
187
+ return
188
+ }
189
+
190
+ let binaryPath = null
191
+
192
+ try {
193
+ // Method 1: Use require.resolve to find the platform-specific package
194
+ const platformPackagePath = require.resolve(`${platformSpecificPackageName}/package.json`)
195
+ const platformPackageDir = path.dirname(platformPackagePath)
196
+ binaryPath = path.join(platformPackageDir, 'bin', binaryName)
197
+ } catch (error) {
198
+ // Method 2: Check if platform package is installed as a sibling directory
199
+ const siblingPath = path.join(__dirname, '..', platformSpecificPackageName)
200
+ binaryPath = path.join(siblingPath, 'bin', binaryName)
201
+
202
+ if (!fs.existsSync(binaryPath)) {
203
+ // Method 3: pnpm-specific structure
204
+ const pnpmMatch = __dirname.match(/(.+\/node_modules\/)\.pnpm\/([^\/]+)\/node_modules\//)
205
+ if (pnpmMatch) {
206
+ const [, nodeModulesRoot] = pnpmMatch
207
+ const pnpmDir = path.join(nodeModulesRoot, '.pnpm')
208
+
209
+ try {
210
+ const pnpmEntries = fs.readdirSync(pnpmDir)
211
+ const platformEntry = pnpmEntries.find(entry => entry.startsWith(platformSpecificPackageName + '@'))
212
+
213
+ if (platformEntry) {
214
+ binaryPath = path.join(pnpmDir, platformEntry, 'node_modules', platformSpecificPackageName, 'bin', binaryName)
215
+ }
216
+ } catch (err) {
217
+ // Ignore errors
218
+ }
219
+ }
220
+ }
221
+ }
222
+
223
+ // If we found the binary, try to replace the shim with it
224
+ if (binaryPath && fs.existsSync(binaryPath)) {
225
+ // First validate the binary works correctly
226
+ if (!validateBinaryVersion(binaryPath)) {
227
+ console.error(`[${packageJSON.name}] Binary validation failed, keeping JavaScript shim`);
228
+ return;
229
+ }
230
+
231
+ const shimPath = path.join(__dirname, 'bin', packageJSON.name)
232
+ const tempPath = path.join(__dirname, 'bin', `${packageJSON.name}-temp`)
233
+
234
+ try {
235
+ // First create a hard link to avoid taking up additional disk space
236
+ fs.linkSync(binaryPath, tempPath)
237
+
238
+ // Then atomically replace the shim with the binary
239
+ fs.renameSync(tempPath, shimPath)
240
+
241
+ // Make sure it's executable
242
+ fs.chmodSync(shimPath, 0o755)
243
+
244
+ // Update state tracking
245
+ isShimJS = false
246
+
247
+ console.log(`[${packageJSON.name}] Binary optimization successful`);
248
+ } catch (err) {
249
+ console.error(`[${packageJSON.name}] Binary optimization failed: ${err.message}`);
250
+ // If optimization fails, clean up and continue with the shim
251
+ try {
252
+ fs.unlinkSync(tempPath)
253
+ } catch {}
254
+ }
255
+ }
256
+ }
257
+
258
+ function validateBinaryVersion(binaryPath) {
259
+ try {
260
+ // For our Go binaries, we just check if they execute without crashing
261
+ // We use -h flag which should work and exit cleanly
262
+ child_process.execFileSync(binaryPath, ['-h'], {
263
+ stdio: 'pipe',
264
+ timeout: 5000,
265
+ encoding: 'utf8'
266
+ });
267
+ return true;
268
+ } catch (err) {
269
+ // If the binary exits with code 0 or 2 (help), that's fine
270
+ if (err.status === 0 || err.status === 2) {
271
+ return true;
272
+ }
273
+ console.error(`[${packageJSON.name}] Binary validation failed: ${err.message}`);
274
+ return false;
275
+ }
276
+ }
277
+
278
+ function applyManualBinaryPathOverride(overridePath) {
279
+ console.log(`[${packageJSON.name}] Using manual binary path: ${overridePath}`);
280
+
281
+ const shimPath = path.join(__dirname, 'bin', packageJSON.name);
282
+ const shimContent = `#!/usr/bin/env node
283
+ require('child_process').execFileSync(${JSON.stringify(overridePath)}, process.argv.slice(2), { stdio: 'inherit' });
284
+ `;
285
+
286
+ try {
287
+ fs.writeFileSync(shimPath, shimContent, { mode: 0o755 });
288
+ isShimJS = true; // Keep as JS since it's a wrapper
289
+ return true;
290
+ } catch (err) {
291
+ console.error(`[${packageJSON.name}] Failed to apply manual binary override: ${err.message}`);
292
+ return false;
293
+ }
294
+ }
295
+
296
+ function isYarn() {
297
+ const { npm_config_user_agent } = process.env
298
+ if (npm_config_user_agent) {
299
+ return /\byarn\//.test(npm_config_user_agent)
300
+ }
301
+ return false
302
+ }
303
+
304
+ // Check for manual binary path override first
305
+ if (MANUAL_BINARY_PATH) {
306
+ if (fs.existsSync(MANUAL_BINARY_PATH)) {
307
+ console.log(`[${packageJSON.name}] Using manual binary path override`);
308
+ if (applyManualBinaryPathOverride(MANUAL_BINARY_PATH)) {
309
+ process.exit(0);
310
+ }
311
+ } else {
312
+ console.warn(`[${packageJSON.name}] Ignoring invalid manual binary path: ${MANUAL_BINARY_PATH}`);
313
+ }
314
+ }
315
+
316
+ // Skip downloading the binary if it was already installed via optionalDependencies
317
+ if (!isPlatformSpecificPackageInstalled()) {
318
+ console.log(`[${packageJSON.name}] Platform package not found, downloading binary...`);
319
+ downloadBinaryFromNpm().then(() => {
320
+ maybeOptimizePackage();
321
+
322
+ // Final validation
323
+ const shimPath = path.join(__dirname, 'bin', packageJSON.name);
324
+ if (isShimJS) {
325
+ // Validate the JavaScript shim can find and run the binary
326
+ if (!validateBinaryVersion(shimPath)) {
327
+ console.error(`[${packageJSON.name}] Installation may be incomplete`);
328
+ }
329
+ }
330
+ }).catch(err => {
331
+ console.error(`[${packageJSON.name}] Failed to download binary: ${err.message}`);
332
+ process.exit(1);
333
+ });
334
+ } else {
335
+ console.log(`[${packageJSON.name}] Platform package found, optimizing...`);
336
+ maybeOptimizePackage();
337
+
338
+ // Final validation
339
+ const shimPath = path.join(__dirname, 'bin', packageJSON.name);
340
+ if (isShimJS) {
341
+ // Validate the JavaScript shim can find and run the binary
342
+ if (!validateBinaryVersion(shimPath)) {
343
+ console.error(`[${packageJSON.name}] Installation may be incomplete`);
344
+ }
345
+ } else {
346
+ // Binary was optimized, validate it directly
347
+ if (!validateBinaryVersion(shimPath)) {
348
+ console.error(`[${packageJSON.name}] Binary optimization may have failed`);
349
+ }
350
+ }
351
+ }
package/README.md DELETED
@@ -1,36 +0,0 @@
1
- <div align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/HoudiniGraphql/houdini/main/.github/assets/logo_l.svg">
4
- <img height="140" alt="Houdini's logo (dark or light)" src="https://raw.githubusercontent.com/HoudiniGraphql/houdini/main/.github/assets/logo_d.svg">
5
- </picture>
6
- <br />
7
- <br />
8
- <strong>
9
- The disappearing GraphQL clients.
10
- </strong>
11
- <br />
12
- <br />
13
- <a href="https://npmjs.org/package/houdini">
14
- <img src="https://img.shields.io/npm/v/houdini.svg" alt="version" />
15
- </a>
16
- <a href="https://github.com/HoudiniGraphql/houdini/actions">
17
- <img src="https://github.com/HoudiniGraphql/houdini/actions/workflows/tests.yml/badge.svg" alt="CI Tests" />
18
- </a>
19
- <a href="https://github.com/HoudiniGraphql/houdini">
20
- <img src="https://img.shields.io/github/stars/HoudiniGraphql/houdini.svg?label=stars" alt="github stars" />
21
- </a>
22
- <a href="https://npmjs.org/package/houdini">
23
- <img src="https://img.shields.io/npm/dm/houdini.svg" alt="downloads" />
24
- </a>
25
- <a href="https://github.com/HoudiniGraphql/houdini/blob/main/LICENSE">
26
- <img src="https://img.shields.io/github/license/HoudiniGraphql/houdini.svg?maxAge=2592000" alt="license" />
27
- </a>
28
- </div>
29
-
30
- ----
31
-
32
- At its core, houdini seeks to enable a high quality developer experience
33
- without compromising bundle size. Like Svelte, houdini shifts what is
34
- traditionally handled by a bloated runtime into a compile step that allows
35
- for the generation of an incredibly lean GraphQL abstraction for your application.
36
- See more at <a href="https://www.houdinigraphql.com">HoudiniGraphQL.com</a> 🚀
@@ -1,92 +0,0 @@
1
- {
2
- "name": "houdini-react",
3
- "version": "2.0.0-go.0",
4
- "description": "The React plugin for houdini",
5
- "keywords": [
6
- "typescript",
7
- "react",
8
- "graphql",
9
- "graphql-client"
10
- ],
11
- "homepage": "https://github.com/HoudiniGraphql/houdini",
12
- "funding": "https://github.com/sponsors/HoudiniGraphql",
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/HoudiniGraphql/houdini.git"
16
- },
17
- "license": "MIT",
18
- "scripts": {
19
- "compile": "scripts build-go",
20
- "typedefs": "scripts typedefs --plugin --go-package",
21
- "postinstall": "node postInstall.js"
22
- },
23
- "devDependencies": {
24
- "@types/cookie-parser": "^1.4.3",
25
- "@types/cookie-session": "^2.0.44",
26
- "@types/cookies": "^0.7.7",
27
- "@types/estraverse": "^5.1.2",
28
- "@types/express": "^4.17.17",
29
- "@types/react": "^19.0.7",
30
- "@types/react-dom": "^19.0.3"
31
- },
32
- "dependencies": {
33
- "@babel/parser": "^7.24.6",
34
- "@babel/types": "^7.24.6",
35
- "@whatwg-node/server": "^0.9.14",
36
- "cookie-parser": "^1.4.6",
37
- "cookie-session": "^2.0.0",
38
- "cookies": "^0.8.0",
39
- "estraverse": "^5.3.0",
40
- "express": "^4.18.2",
41
- "graphql": "^15.8.0",
42
- "graphql-yoga": "^4.0.4",
43
- "houdini": "workspace:^",
44
- "react": "^19.0.0",
45
- "react-dom": "^19.0.0",
46
- "react-streaming-compat": "^0.3.18",
47
- "recast": "^0.23.1",
48
- "rollup": "^4.28.1",
49
- "use-deep-compare-effect": "^1.8.1"
50
- },
51
- "files": [
52
- "build"
53
- ],
54
- "exports": {
55
- "./package.json": "./package.json",
56
- "./server": {
57
- "types": "./server/index.d.ts",
58
- "import": "./server/index.js"
59
- },
60
- "./server/*": {
61
- "types": "./server/*",
62
- "import": "./server/*"
63
- },
64
- "./vite": {
65
- "types": "./vite/index.d.ts",
66
- "import": "./vite/index.js"
67
- },
68
- "./vite/*": {
69
- "types": "./vite/*",
70
- "import": "./vite/*"
71
- }
72
- },
73
- "typesVersions": {
74
- "*": {
75
- "server": [
76
- "./server/index.d.ts"
77
- ],
78
- "vite": [
79
- "./vite/index.d.ts"
80
- ]
81
- }
82
- },
83
- "optionalDependencies": {
84
- "houdini-react-darwin-amd64": "2.0.0-go.0",
85
- "houdini-react-darwin-arm64": "2.0.0-go.0",
86
- "houdini-react-linux-amd64": "2.0.0-go.0",
87
- "houdini-react-linux-arm64": "2.0.0-go.0",
88
- "houdini-react-windows-amd64": "2.0.0-go.0",
89
- "houdini-react-windows-arm64": "2.0.0-go.0"
90
- },
91
- "bin": "./shim.cjs"
92
- }
@@ -1,117 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const zlib = require('zlib')
4
- const https = require('https')
5
-
6
- // Adjust the version you want to install. You can also make this dynamic.
7
- const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.0'
8
-
9
- // Windows binaries end with .exe so we need to special case them.
10
- const binaryName = process.platform === 'win32' ? 'houdini-react.exe' : 'houdini-react'
11
-
12
- // Determine package name for this platform
13
- const platformSpecificPackageName = `houdini-react-${process.platform}-${process.arch}`
14
-
15
- // Compute the path we want to emit the fallback binary to
16
- const fallbackBinaryPath = path.join(__dirname, binaryName)
17
-
18
- function makeRequest(url) {
19
- return new Promise((resolve, reject) => {
20
- https
21
- .get(url, (response) => {
22
- if (response.statusCode >= 200 && response.statusCode < 300) {
23
- const chunks = []
24
- response.on('data', (chunk) => chunks.push(chunk))
25
- response.on('end', () => {
26
- resolve(Buffer.concat(chunks))
27
- })
28
- } else if (
29
- response.statusCode >= 300 &&
30
- response.statusCode < 400 &&
31
- response.headers.location
32
- ) {
33
- // Follow redirects
34
- makeRequest(response.headers.location).then(resolve, reject)
35
- } else {
36
- reject(
37
- new Error(
38
- `npm responded with status code ${response.statusCode} when downloading the package!`
39
- )
40
- )
41
- }
42
- })
43
- .on('error', (error) => {
44
- reject(error)
45
- })
46
- })
47
- }
48
-
49
- function extractFileFromTarball(tarballBuffer, filepath) {
50
- // Tar archives are organized in 512 byte blocks.
51
- // Blocks can either be header blocks or data blocks.
52
- // Header blocks contain file names of the archive in the first 100 bytes, terminated by a null byte.
53
- // The size of a file is contained in bytes 124-135 of a header block and in octal format.
54
- // The following blocks will be data blocks containing the file.
55
- let offset = 0
56
- while (offset < tarballBuffer.length) {
57
- const header = tarballBuffer.subarray(offset, offset + 512)
58
- offset += 512
59
-
60
- const fileName = header.toString('utf-8', 0, 100).replace(/\0.*/g, '')
61
- const fileSize = parseInt(header.toString('utf-8', 124, 136).replace(/\0.*/g, ''), 8)
62
-
63
- if (fileName === filepath) {
64
- return tarballBuffer.subarray(offset, offset + fileSize)
65
- }
66
-
67
- // Clamp offset to the uppoer multiple of 512
68
- offset = (offset + fileSize + 511) & ~511
69
- }
70
- }
71
-
72
- async function downloadBinaryFromNpm() {
73
- // Download the tarball of the right binary distribution package
74
- const tarballDownloadBuffer = await makeRequest(
75
- `https://registry.npmjs.org/${platformSpecificPackageName}/-/${platformSpecificPackageName}-${BINARY_DISTRIBUTION_VERSION}.tgz`
76
- )
77
-
78
- const tarballBuffer = zlib.unzipSync(tarballDownloadBuffer)
79
-
80
- // Extract binary from package and write to disk
81
- fs.writeFileSync(
82
- fallbackBinaryPath,
83
- extractFileFromTarball(tarballBuffer, `package/bin/${binaryName}`),
84
- { mode: 0o755 } // Make binary file executable
85
- )
86
- }
87
-
88
- function isPlatformSpecificPackageInstalled() {
89
- try {
90
- // Resolving will fail if the optionalDependency was not installed
91
- require.resolve(`${platformSpecificPackageName}/bin/${binaryName}`)
92
- return true
93
- } catch (e) {
94
- return false
95
- }
96
- }
97
-
98
- if (!platformSpecificPackageName) {
99
- throw new Error('Platform not supported!')
100
- }
101
-
102
- // once we've confirmed the required package is installed we want to overwrite the bin entry of our package.json
103
- // to point to the correct binary
104
- function overwriteBinary() {
105
- const packageJsonPath = path.join(__dirname, 'package.json')
106
- const packageJson = require(packageJsonPath)
107
- packageJson.bin = path.join('..', platformSpecificPackageName, 'bin', binaryName)
108
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
109
- }
110
-
111
- // Skip downloading the binary if it was already installed via optionalDependencies
112
- if (!isPlatformSpecificPackageInstalled()) {
113
- console.log('Platform specific package not found. Will manually download binary.')
114
- downloadBinaryFromNpm().then(overwriteBinary)
115
- } else {
116
- overwriteBinary()
117
- }
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- function getBinaryPath() {
4
- // lookup table for all platforms and binary distribution packages
5
- const BINARY_DISTRIBUTION_PACKAGES = {
6
- 'linux-x64': 'houdini-react-linux-x64',
7
- 'linux-arm64': 'houdini-react-linux-arm64',
8
- 'win32-x64': 'houdini-react-windows-x64',
9
- 'win32-arm64': 'houdini-react-windows-arm64',
10
- 'darwin-x64': 'houdini-react-darwin-x64',
11
- 'darwin-arm64': 'houdini-react-darwin-arm64',
12
- }
13
-
14
- // windows binaries end with .exe so we need to special case them
15
- const binaryName = process.platform === 'win32' ? 'houdini-react.exe' : 'houdini-react'
16
-
17
- // determine package name for this platform
18
- const platformSpecificPackageName =
19
- BINARY_DISTRIBUTION_PACKAGES[`${process.platform}-${process.arch}`]
20
-
21
- try {
22
- // resolving will fail if the optionalDependency was not installed
23
- return require.resolve(`../${platformSpecificPackageName}/bin/${binaryName}`)
24
- } catch (e) {
25
- return require('path').join(__dirname, binaryName)
26
- }
27
- }
28
- // instead of execFileSync, use spawn to handle the process more gracefully
29
- const childProcess = require('child_process').spawn(getBinaryPath(), process.argv.slice(2), {
30
- stdio: 'inherit',
31
- })
32
-
33
- // array of signals we want to handle
34
- const signals = ['SIGTERM', 'SIGINT', 'SIGQUIT', 'SIGHUP']
35
-
36
- // handle each signal
37
- signals.forEach((signal) => {
38
- process.on(signal, () => {
39
- if (childProcess) {
40
- // on windows, we need to use taskkill for proper tree killing
41
- if (process.platform === 'win32') {
42
- require('child_process').spawn('taskkill', ['/pid', childProcess.pid, '/f', '/t'])
43
- } else {
44
- try {
45
- childProcess.kill(signal)
46
- } catch (err) {
47
- // if the process is already gone, that's fine
48
- if (err.code !== 'ESRCH') throw err
49
- }
50
- }
51
- }
52
- process.exit(0)
53
- })
54
- })
55
-
56
- // handle child process exit
57
- childProcess.on('exit', (code, signal) => {
58
- // if the child was terminated due to a signal, exit with the same signal
59
- if (signal) {
60
- process.exit(0)
61
- } else {
62
- process.exit(code)
63
- }
64
- })
@@ -1,11 +0,0 @@
1
- {
2
- "name": "houdini-react-darwin-arm64",
3
- "version": "2.0.0-go.0",
4
- "bin": "bin/houdini-react",
5
- "os": [
6
- "darwin"
7
- ],
8
- "cpu": [
9
- "arm64"
10
- ]
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "name": "houdini-react-darwin-x64",
3
- "version": "2.0.0-go.0",
4
- "bin": "bin/houdini-react",
5
- "os": [
6
- "darwin"
7
- ],
8
- "cpu": [
9
- "x64"
10
- ]
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "name": "houdini-react-linux-arm64",
3
- "version": "2.0.0-go.0",
4
- "bin": "bin/houdini-react",
5
- "os": [
6
- "linux"
7
- ],
8
- "cpu": [
9
- "arm64"
10
- ]
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "name": "houdini-react-linux-x64",
3
- "version": "2.0.0-go.0",
4
- "bin": "bin/houdini-react",
5
- "os": [
6
- "linux"
7
- ],
8
- "cpu": [
9
- "x64"
10
- ]
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "name": "houdini-react-windows-arm64",
3
- "version": "2.0.0-go.0",
4
- "bin": "bin/houdini-react.exe",
5
- "os": [
6
- "win32"
7
- ],
8
- "cpu": [
9
- "arm64"
10
- ]
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "name": "houdini-react-windows-x64",
3
- "version": "2.0.0-go.0",
4
- "bin": "bin/houdini-react.exe",
5
- "os": [
6
- "win32"
7
- ],
8
- "cpu": [
9
- "x64"
10
- ]
11
- }
@@ -1,91 +0,0 @@
1
- {
2
- "name": "houdini-react",
3
- "version": "2.0.0-go.0",
4
- "description": "The React plugin for houdini",
5
- "keywords": [
6
- "typescript",
7
- "react",
8
- "graphql",
9
- "graphql-client"
10
- ],
11
- "homepage": "https://github.com/HoudiniGraphql/houdini",
12
- "funding": "https://github.com/sponsors/HoudiniGraphql",
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/HoudiniGraphql/houdini.git"
16
- },
17
- "license": "MIT",
18
- "scripts": {
19
- "compile": "scripts build-go",
20
- "typedefs": "scripts typedefs --plugin --go-package",
21
- "postinstall": "node postInstall.js"
22
- },
23
- "devDependencies": {
24
- "@types/cookie-parser": "^1.4.3",
25
- "@types/cookie-session": "^2.0.44",
26
- "@types/cookies": "^0.7.7",
27
- "@types/estraverse": "^5.1.2",
28
- "@types/express": "^4.17.17",
29
- "@types/react": "^19.0.7",
30
- "@types/react-dom": "^19.0.3"
31
- },
32
- "dependencies": {
33
- "@babel/parser": "^7.24.6",
34
- "@babel/types": "^7.24.6",
35
- "@whatwg-node/server": "^0.9.14",
36
- "cookie-parser": "^1.4.6",
37
- "cookie-session": "^2.0.0",
38
- "cookies": "^0.8.0",
39
- "estraverse": "^5.3.0",
40
- "express": "^4.18.2",
41
- "graphql": "^15.8.0",
42
- "graphql-yoga": "^4.0.4",
43
- "houdini": "workspace:^",
44
- "react": "^19.0.0",
45
- "react-dom": "^19.0.0",
46
- "react-streaming-compat": "^0.3.18",
47
- "recast": "^0.23.1",
48
- "rollup": "^4.28.1",
49
- "use-deep-compare-effect": "^1.8.1"
50
- },
51
- "files": [
52
- "build"
53
- ],
54
- "exports": {
55
- "./package.json": "./package.json",
56
- "./server": {
57
- "types": "./build/server/index.d.ts",
58
- "import": "./build/server/index.js"
59
- },
60
- "./server/*": {
61
- "types": "./build/server/*",
62
- "import": "./build/server/*"
63
- },
64
- "./vite": {
65
- "types": "./build/vite/index.d.ts",
66
- "import": "./build/vite/index.js"
67
- },
68
- "./vite/*": {
69
- "types": "./build/vite/*",
70
- "import": "./build/vite/*"
71
- }
72
- },
73
- "typesVersions": {
74
- "*": {
75
- "server": [
76
- "./build/server/index.d.ts"
77
- ],
78
- "vite": [
79
- "./build/vite/index.d.ts"
80
- ]
81
- }
82
- },
83
- "optionalDependencies": {
84
- "houdini-react-darwin-amd64": "2.0.0-go.0",
85
- "houdini-react-darwin-arm64": "2.0.0-go.0",
86
- "houdini-react-linux-amd64": "2.0.0-go.0",
87
- "houdini-react-linux-arm64": "2.0.0-go.0",
88
- "houdini-react-windows-amd64": "2.0.0-go.0",
89
- "houdini-react-windows-arm64": "2.0.0-go.0"
90
- }
91
- }
File without changes
File without changes
File without changes
File without changes