@ohos-ports/houdini 2.0.12-beta.1 → 2.0.13-beta.0

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.
@@ -4,61 +4,24 @@ import { tmpdir } from "node:os";
4
4
  import path from "node:path";
5
5
  import { createInterface } from "node:readline";
6
6
  import { WebSocket } from "ws";
7
- // pid-unique filename: several processes (other agents, parallel codegen runs)
8
- // may share tmpdir() — a fixed name lets one process overwrite the runner file
9
- // of another while it is being spawned, producing confusing flaky failures.
10
- const wasiRunnerPath = path.join(tmpdir(), `houdini-wasi-runner-${process.pid}.mjs`);
11
- // openharmony: worker_threads see inherited pipe fd0/fd1 as EBADF and preopening
12
- // host "/" is rejected by the sandbox (UVWASI_EACCES), while the Go wasip1
13
- // runtime resolves every absolute path against the "/" preopen (a missing "/"
14
- // yields EBADF on "lstat /<first-component>"). The runner therefore maps guest
15
- // "/" to R = the shallowest preopenable ancestor of the cwd and mirrors R's own
16
- // absolute path inside R as a RELATIVE symlink chain, so host-absolute paths
17
- // under R resolve 1:1 inside the guest (guest path == host path). The worker's
18
- // WASI instance gets explicit stdio fd numbers opened by the main thread (passed
19
- // via workerData) and WASI fd1/fd2 writes are bridged back to the main thread
20
- // (fd_write -> MessagePort -> fs.writeSync(1/2)), preserving the plugin stdio
21
- // transport: the main thread holds the real stdout pipe fd that the codegen
22
- // parent reads via readline.
7
+ const wasiRunnerPath = path.join(tmpdir(), "houdini-wasi-runner.mjs");
23
8
  writeFileSync(
24
9
  wasiRunnerPath,
25
10
  `import{WASI}from'node:wasi';
26
- import{readFileSync,openSync,writeSync,mkdirSync,symlinkSync,lstatSync}from'node:fs';
11
+ import{readFileSync}from'node:fs';
27
12
  import{Worker,isMainThread,workerData,MessageChannel,receiveMessageOnPort}from'worker_threads';
28
13
  const[,,w,...r]=process.argv;
29
14
  if(isMainThread){
30
15
  const{port1:p1,port2:p2}=new MessageChannel();
31
- const{port1:po1,port2:po2}=new MessageChannel();
32
16
  const sb=new Int32Array(new SharedArrayBuffer(4));
33
- let ex=null,wd=false;
34
- const fin=()=>{if(wd)process.exit(typeof ex==='number'?ex:0);};
35
17
  process.stdin.on('error',()=>{});
36
18
  process.stdin.on('data',d=>{p1.postMessage(d);Atomics.add(sb,0,1);Atomics.notify(sb,0);});
37
19
  process.stdin.on('end',()=>{p1.postMessage(null);Atomics.add(sb,0,1);Atomics.notify(sb,0);});
38
- po1.on('message',m=>{if(m&&m.__exitCode!==undefined){ex=m.__exitCode;fin();return;}try{writeSync(m.f===2?2:1,new Uint8Array(m.b));}catch(_e){}});
39
- const fdi=openSync('/dev/null','r'),fdo=openSync('/dev/null','w'),fde=openSync('/dev/null','w');
40
- // openharmony: find R, the shallowest preopenable ancestor of the cwd
41
- const ok=d=>{try{new WASI({version:'preview1',args:['x'],stdin:fdi,stdout:fdo,stderr:fde,preopens:{[d]:d}});return true;}catch(_e){return false;}};
42
- const segs=process.cwd().split('/').filter(Boolean);
43
- let R=null;
44
- for(let i=1;i<=segs.length;i++){const c='/'+segs.slice(0,i).join('/');if(ok(c)){R=c;break;}}
45
- if(!R)R=process.cwd();
46
- // openharmony: mirror R's own absolute path inside R as a relative symlink
47
- // chain (R/c1/.../cn with cn -> ../..(n-1)); a RELATIVE target is essential —
48
- // an absolute target is re-resolved from guest "/" and loops forever. After
49
- // the chain, host-absolute paths under R resolve 1:1 inside the guest.
50
- if(R!=='/'){
51
- const rel=R.slice(1).split('/');
52
- let cur=R;
53
- for(let i=0;i<rel.length-1;i++){cur=cur+'/'+rel[i];try{mkdirSync(cur,{recursive:true});}catch(_e){}}
54
- const last=cur+'/'+rel[rel.length-1];
55
- try{if(!lstatSync(last).isSymbolicLink())throw 0;}catch(_e){try{symlinkSync('../'.repeat(rel.length-1),last);}catch(_e2){}}
56
- }
57
- const wk=new Worker(new URL(import.meta.url),{workerData:{w,r,p:p2,po:po2,fdi,fdo,fde,sb,R},transferList:[p2,po2]});
58
- wk.on('exit',c=>{wd=true;if(ex===null)ex=c??0;fin();});
20
+ const wk=new Worker(new URL(import.meta.url),{workerData:{w,r,p:p2,sb},transferList:[p2]});
21
+ wk.on('exit',c=>process.exit(c??0));
59
22
  }else{
60
- const{w:wb,r:args,p:port,po:oport,fdi,fdo,fde,sb,R}=workerData;
61
- const wasi=new WASI({version:'preview1',args:['houdini-core',...args],env:Object.assign({},process.env,{PWD:process.cwd()}),preopens:{'/':R},stdin:fdi,stdout:fdo,stderr:fde,returnOnExit:true});
23
+ const{w:wb,r:args,p:port,sb}=workerData;
24
+ const wasi=new WASI({version:'preview1',args:[wb,...args],env:process.env,preopens:{'/':'/'}});
62
25
  let mem=null;
63
26
  const io=wasi.getImportObject();
64
27
  const rfr=io.wasi_snapshot_preview1.fd_read;
@@ -79,27 +42,12 @@ new Uint8Array(mem.buffer,p,n).set(b.subarray(wn,wn+n));
79
42
  wn+=n;}
80
43
  v.setUint32(nr,wn,true);
81
44
  return 0;};
82
- const rfw=io.wasi_snapshot_preview1.fd_write;
83
- io.wasi_snapshot_preview1.fd_write=(fd,iovs,il,nw)=>{
84
- if((fd!==1&&fd!==2)||!mem)return rfw(fd,iovs,il,nw);
85
- const v=new DataView(mem.buffer);
86
- const parts=[];let tot=0;
87
- for(let i=0;i<il;i++){
88
- const p=v.getUint32(iovs+i*8,true),l=v.getUint32(iovs+i*8+4,true);
89
- if(l>0){parts.push(Buffer.from(new Uint8Array(mem.buffer,p,l)));tot+=l;}}
90
- if(tot===0){v.setUint32(nw,0,true);return 0;}
91
- const ab=new ArrayBuffer(tot);let off=0;
92
- for(const pt of parts){new Uint8Array(ab,off,pt.length).set(pt);off+=pt.length;}
93
- oport.postMessage({f:fd,b:ab},[ab]);
94
- v.setUint32(nw,tot,true);
95
- return 0;};
96
45
  const mod=new WebAssembly.Module(readFileSync(wb));
97
46
  const inst=new WebAssembly.Instance(mod,io);
98
47
  mem=inst.exports.memory;
99
- const wcode=wasi.start(inst);
100
- oport.postMessage({__exitCode:typeof wcode==='number'?wcode:0});
101
- oport.close();
102
- }`
48
+ wasi.start(inst);
49
+ process.exit(0);}
50
+ `
103
51
  );
104
52
  import * as conventions from "../router/conventions.js";
105
53
  import { create_schema, schema_version, write_config } from "./database.js";
@@ -400,20 +348,13 @@ async function codegen_setup(config, mode, db, db_file) {
400
348
  }
401
349
  const dbKey = plugin_db_key(plugin.name);
402
350
  args.push("--plugin-key", dbKey);
403
- // openharmony: no native ELF slot is published for houdini-core and the
404
- // prebuilt linux binaries are exec-blocked (EACCES), so a node-script
405
- // plugin executable must run through its official wasm slot — inject the
406
- // HOUDINI_PLATFORM=wasm consumer path into the child env. WASI preview1
407
- // has no sockets, so the plugin must speak the stdio transport either way.
408
- const openharmonyWasmRoute = process.platform === "openharmony" && is_node_script(plugin.executable);
409
- const pluginUsesStdio = useStdio || path.extname(plugin.executable) === ".wasm" || openharmonyWasmRoute;
351
+ const pluginUsesStdio = useStdio || path.extname(plugin.executable) === ".wasm";
410
352
  if (pluginUsesStdio) {
411
353
  args.push("--transport", "stdio");
412
354
  }
413
355
  logger.time(`Spawn ${plugin.name}`);
414
356
  const detached = process.platform !== "win32" && !pluginUsesStdio;
415
357
  const child = spawn(executable, args, {
416
- env: openharmonyWasmRoute ? { ...process.env, HOUDINI_PLATFORM: "wasm" } : process.env,
417
358
  // stdio/WASM plugins carry the protocol over stdin+stdout, so those must be pipes.
418
359
  // websocket plugins talk over TCP, so let stdout/stderr through to the console.
419
360
  stdio: pluginUsesStdio ? ["pipe", "pipe", "inherit"] : ["inherit", "inherit", "inherit"],
@@ -514,11 +455,7 @@ async function codegen_setup(config, mode, db, db_file) {
514
455
  taskId: task_id,
515
456
  pluginDirectory: directory
516
457
  };
517
- // A plugin spawned with --transport stdio (wasm plugins, or
518
- // pluginTransport: 'stdio') must be invoked over its stdin/stdout channel:
519
- // it reports no usable WebSocket port (WASI preview1 has no sockets), so use
520
- // the stdio bridge whenever one was set up for this plugin.
521
- if (useStdio || stdioStdin.has(name)) {
458
+ if (useStdio) {
522
459
  const stdin = stdioStdin.get(name);
523
460
  if (!stdin) {
524
461
  throw new Error(`No stdio channel for plugin ${name}`);
package/build/lib/db.js CHANGED
@@ -132,17 +132,7 @@ class NativeDb {
132
132
  }
133
133
  }
134
134
  async function openDb(filepath) {
135
- // openharmony: HOUDINI_PLATFORM=wasm selects the wasm *plugin binary* form —
136
- // it must not force the parent into the in-memory sql.js backend when the db
137
- // is a real file. The plugin process (WASI wasm) reloads its config from the
138
- // db FILE; a sql.js parent only syncs the file at flush() points by
139
- // truncating and rewriting the whole file, so a plugin that opened the db at
140
- // startup would never observe rows written after its spawn and fail with
141
- // "could not open schema file". openharmony node ships a working node:sqlite,
142
- // so keep the live native connection for file dbs. ":memory:" dbs stay on
143
- // sql.js (no cross-process sharing is involved).
144
- const wasmSqlJs = process.env.HOUDINI_PLATFORM === "wasm" && (filepath === ":memory:" || process.platform !== "openharmony");
145
- if (wasmSqlJs) {
135
+ if (process.env.HOUDINI_PLATFORM === "wasm") {
146
136
  const SQL = await initSqlJs();
147
137
  let db;
148
138
  if (filepath !== ":memory:" && existsSync(filepath)) {
@@ -163,10 +153,7 @@ async function openDb(filepath) {
163
153
  const { DatabaseSync } = await import("node:sqlite");
164
154
  conn = new DatabaseSync(filepath);
165
155
  }
166
- // openharmony: WASI preview1 has no mmap, so the wasm plugin (modernc sqlite)
167
- // cannot open a WAL database (-shm access fails). Use the rollback-journal
168
- // mode so the plugin and the parent can share the file.
169
- conn.exec(process.platform === "openharmony" ? "PRAGMA journal_mode = DELETE" : "PRAGMA journal_mode = WAL");
156
+ conn.exec("PRAGMA journal_mode = WAL");
170
157
  conn.exec("PRAGMA busy_timeout = 5000");
171
158
  conn.exec("PRAGMA synchronous = off");
172
159
  conn.exec("PRAGMA foreign_keys = ON");
@@ -77,38 +77,28 @@ function is_node_script(executable) {
77
77
  }
78
78
  }
79
79
  function find_module(pkg, config_path) {
80
- // @ohos-ports distribution: companion packages are published as
81
- // @ohos-ports/{name}; the original name is tried first so unpatched setups
82
- // keep working, then resolution falls back to the scoped @ohos-ports name
83
- // (code-level package name sync for the @ohos-ports distribution).
84
- const ohosPortsPkg = pkg.startsWith("@ohos-ports/") ? null : `@ohos-ports/${pkg}`;
85
80
  try {
86
81
  const projectRequire = createRequire(pathToFileURL(config_path));
87
82
  const packageJsonPath = projectRequire.resolve(`${pkg}/package.json`);
88
83
  return path.dirname(packageJsonPath);
89
84
  } catch {
90
- }
91
- if (ohosPortsPkg) {
92
- try {
93
- const projectRequire = createRequire(pathToFileURL(config_path));
94
- const packageJsonPath = projectRequire.resolve(`${ohosPortsPkg}/package.json`);
85
+ // The internal core plugin registers under its compiled plugin name
86
+ // "houdini-core" (plugin.Name() in the Go binary). Resolution maps that
87
+ // internal orchestration key to the installed @ohos-ports package so the
88
+ // registered name, the runtime-copy target and the generated index stay
89
+ // consistent (r5-022: fixes the dangling
90
+ // `export * from './plugins/@ohos-ports/houdini-core/runtime'` emitted by
91
+ // houdini-core's runtimeIndex special-case, which only skips the compiled
92
+ // name "houdini-core").
93
+ if (pkg === "houdini-core" || pkg === "@ohos-ports/houdini-core") {
94
+ const houdiniRequire = createRequire(import.meta.url);
95
+ const packageJsonPath = houdiniRequire.resolve("@ohos-ports/houdini-core/package.json");
95
96
  return path.dirname(packageJsonPath);
96
- } catch {
97
- }
98
- }
99
- if (pkg === "houdini-core") {
100
- for (const candidate of ohosPortsPkg ? [pkg, ohosPortsPkg] : [pkg]) {
101
- try {
102
- const houdiniRequire = createRequire(import.meta.url);
103
- const packageJsonPath = houdiniRequire.resolve(`${candidate}/package.json`);
104
- return path.dirname(packageJsonPath);
105
- } catch {
106
- }
107
97
  }
98
+ return find_module_walking_modules(pkg, path.dirname(config_path));
108
99
  }
109
- return find_module_walking_modules(pkg, path.dirname(config_path));
110
100
  }
111
- function find_module_walking_modules(pkg = "houdini", currentLocation) {
101
+ function find_module_walking_modules(pkg = "@ohos-ports/houdini", currentLocation) {
112
102
  const pathEndingBy = ["node_modules", pkg];
113
103
  let found = path.join(currentLocation, ...pathEndingBy);
114
104
  let previous = "";
@@ -1,5 +1,5 @@
1
1
  import { mergeSchemas } from "@graphql-tools/schema";
2
- import { transform } from "esbuild";
2
+ import { transform } from "@ohos-ports/esbuild";
3
3
  import * as graphql from "graphql";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { DEFAULT_AUTH_URL } from "../runtime/config.js";
@@ -101,12 +101,6 @@ async function get_config({
101
101
  if (process.env.HOUDINI_CODEGEN_PLUGIN) {
102
102
  plugins.push([process.env.HOUDINI_CODEGEN_PLUGIN, {}]);
103
103
  }
104
- // openharmony note: the resolved executable on openharmony (without
105
- // HOUDINI_PLATFORM=wasm) stays the houdini-core JS shim — the wasm routing
106
- // happens at spawn time in codegen.js (the shim is exec'd with
107
- // HOUDINI_PLATFORM=wasm injected into its child env, since no native ELF
108
- // slot is published for openharmony and prebuilt linux binaries are
109
- // exec-blocked there).
110
104
  const preferWasm = process.env.HOUDINI_PLATFORM === "wasm" || config_file.pluginTransport === "stdio";
111
105
  _config.plugins = await Promise.all(
112
106
  plugins.map(async ([name, config]) => ({
@@ -281,7 +281,7 @@ function readProjectConfig(db) {
281
281
  return { projectRoot: row?.project_root ?? "", runtimeDir: row?.runtime_dir ?? "" };
282
282
  }
283
283
  function pluginRuntimeDir(projectRoot, runtimeDir, name) {
284
- if (name === "houdini-core") {
284
+ if (name === "houdini-core" || name === "@ohos-ports/houdini-core") {
285
285
  return join(projectRoot, runtimeDir, "runtime");
286
286
  }
287
287
  return join(projectRoot, runtimeDir, "plugins", name, "runtime");
@@ -1,212 +1,212 @@
1
1
  {
2
- "name": "houdini",
3
- "version": "2.0.12",
4
- "description": "The disappearing GraphQL clients",
5
- "keywords": [
6
- "typescript",
7
- "graphql",
8
- "graphql-client"
9
- ],
10
- "homepage": "https://github.com/HoudiniGraphql/houdini",
11
- "funding": "https://github.com/sponsors/HoudiniGraphql",
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/HoudiniGraphql/houdini.git"
15
- },
16
- "license": "MIT",
17
- "type": "module",
18
- "scripts": {
19
- "build": "scripts build-node",
20
- "compile": "scripts build-node",
21
- "sync-schema": "node scripts/sync-schema.mjs",
22
- "typedefs": "scripts typedefs"
23
- },
24
- "devDependencies": {
25
- "@babel/types": "^7.29.7",
26
- "@types/node": "^25.9.1",
27
- "@types/sql.js": "^1.4.11",
28
- "@types/ungap__structured-clone": "^1.2.0",
29
- "@types/ws": "^8.18.1",
30
- "prettier": "^3.8.3",
31
- "rollup": "^4.61.1",
32
- "scripts": "workspace:^",
33
- "vite": "^8.0.16",
34
- "vitest": "^4.1.8"
35
- },
36
- "dependencies": {
37
- "@babel/parser": "^7.29.7",
38
- "@clack/prompts": "^1.5.1",
39
- "@graphql-tools/merge": "^9.1.9",
40
- "@graphql-tools/schema": "^10.0.33",
41
- "@types/estree": "^1.0.9",
42
- "@types/fs-extra": "^11.0.4",
43
- "@ungap/structured-clone": "^1.3.1",
44
- "@whatwg-node/server": "^0.11.0",
45
- "ast-types": "^0.16.1",
46
- "commander": "^15.0.0",
47
- "deepmerge": "^4.3.1",
48
- "esbuild": "0.28.0",
49
- "estree-walker": "^3.0.3",
50
- "fs-extra": "^11.3.5",
51
- "glob": "^13.0.0",
52
- "graphql-yoga": "^5.21.1",
53
- "houdini-core": "workspace:^",
54
- "kleur": "^4.1.5",
55
- "memfs": "^4.17.2",
56
- "minimatch": "^10.2.5",
57
- "npx-import": "^1.1.4",
58
- "oauth4webapi": "^3.8.6",
59
- "recast": "^0.23.11",
60
- "sql.js": "^1.14.1",
61
- "ws": "^8.21.0"
62
- },
63
- "peerDependencies": {
64
- "graphql": ">=16",
65
- "vite": "^8.0.0"
66
- },
67
- "files": [
68
- "adapter",
69
- "cmd",
70
- "lib",
71
- "node",
72
- "oauth",
73
- "router",
74
- "runtime",
75
- "test",
76
- "vite",
77
- "package.json"
78
- ],
79
- "exports": {
80
- "./package.json": "./package.json",
81
- ".": {
82
- "types": "./lib/index.d.ts",
83
- "import": "./lib/index.js"
84
- },
85
- "./*": {
86
- "types": "./lib/*",
87
- "import": "./lib/index.js"
88
- },
89
- "./adapter": {
90
- "types": "./adapter/index.d.ts",
91
- "import": "./adapter/index.js"
92
- },
93
- "./adapter/*": {
94
- "types": "./adapter/*.d.ts",
95
- "import": "./adapter/*.js"
96
- },
97
- "./cmd": {
98
- "types": "./cmd/index.d.ts",
99
- "import": "./cmd/index.js"
100
- },
101
- "./lib": {
102
- "types": "./lib/index.d.ts",
103
- "import": "./lib/index.js"
104
- },
105
- "./lib/config": {
106
- "types": "./lib/config.d.ts",
107
- "import": "./lib/config.js"
108
- },
109
- "./lib/constants": {
110
- "types": "./lib/constants.d.ts",
111
- "import": "./lib/constants.js"
112
- },
113
- "./lib/types": {
114
- "types": "./lib/types.d.ts",
115
- "import": "./lib/types.js"
116
- },
117
- "./node": {
118
- "types": "./node/index.d.ts",
119
- "import": "./node/index.js"
120
- },
121
- "./node/*": {
122
- "types": "./node/*.d.ts",
123
- "import": "./node/*.js"
124
- },
125
- "./oauth": {
126
- "types": "./oauth/index.d.ts",
127
- "import": "./oauth/index.js"
128
- },
129
- "./oauth/*": {
130
- "types": "./oauth/*.d.ts",
131
- "import": "./oauth/*.js"
132
- },
133
- "./router": {
134
- "types": "./router/index.d.ts",
135
- "import": "./router/index.js"
136
- },
137
- "./router/*": {
138
- "types": "./router/*.d.ts",
139
- "import": "./router/*.js"
140
- },
141
- "./runtime": {
142
- "types": "./runtime/index.d.ts",
143
- "import": "./runtime/index.js"
144
- },
145
- "./runtime/*": {
146
- "types": "./runtime/*.d.ts",
147
- "import": "./runtime/*.js"
148
- },
149
- "./runtime/cache": {
150
- "types": "./runtime/cache/index.d.ts",
151
- "import": "./runtime/cache/index.js"
152
- },
153
- "./runtime/config": {
154
- "types": "./runtime/config.d.ts",
155
- "import": "./runtime/config.js"
156
- },
157
- "./runtime/constants": {
158
- "types": "./runtime/constants.d.ts",
159
- "import": "./runtime/constants.js"
160
- },
161
- "./runtime/types": {
162
- "types": "./runtime/types.d.ts",
163
- "import": "./runtime/types.js"
164
- },
165
- "./test": {
166
- "types": "./test/index.d.ts",
167
- "import": "./test/index.js"
168
- },
169
- "./test/*": {
170
- "types": "./test/*.d.ts",
171
- "import": "./test/*.js"
172
- },
173
- "./vite": {
174
- "types": "./vite/index.d.ts",
175
- "import": "./vite/index.js"
176
- },
177
- "./vite/*": {
178
- "types": "./vite/*.d.ts",
179
- "import": "./vite/*.js"
180
- }
181
- },
182
- "typesVersions": {
183
- "*": {
184
- "adapter": [
185
- "./adapter/index.d.ts"
186
- ],
187
- ".": [
188
- "./lib/index.d.ts"
189
- ],
190
- "node": [
191
- "./node/index.d.ts"
192
- ],
193
- "oauth": [
194
- "./oauth/index.d.ts"
195
- ],
196
- "router": [
197
- "./router/index.d.ts"
198
- ],
199
- "runtime": [
200
- "./runtime/index.d.ts"
201
- ],
202
- "test": [
203
- "./test/index.d.ts"
204
- ],
205
- "vite": [
206
- "./vite/index.d.ts"
207
- ]
208
- }
209
- },
210
- "bin": "./build/cmd/index.js",
211
- "types": "./lib/index.d.ts"
2
+ "name": "@ohos-ports/houdini",
3
+ "version": "2.0.13-beta.0",
4
+ "description": "The disappearing GraphQL clients",
5
+ "keywords": [
6
+ "typescript",
7
+ "graphql",
8
+ "graphql-client"
9
+ ],
10
+ "homepage": "https://github.com/HoudiniGraphql/houdini",
11
+ "funding": "https://github.com/sponsors/HoudiniGraphql",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/HoudiniGraphql/houdini.git"
15
+ },
16
+ "license": "MIT",
17
+ "type": "module",
18
+ "scripts": {
19
+ "build": "scripts build-node",
20
+ "compile": "scripts build-node",
21
+ "sync-schema": "node scripts/sync-schema.mjs",
22
+ "typedefs": "scripts typedefs"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/types": "^7.29.7",
26
+ "@types/node": "^25.9.1",
27
+ "@types/sql.js": "^1.4.11",
28
+ "@types/ungap__structured-clone": "^1.2.0",
29
+ "@types/ws": "^8.18.1",
30
+ "prettier": "^3.8.3",
31
+ "scripts": "workspace:^",
32
+ "vitest": "^4.1.8",
33
+ "@ohos-ports/rollup": "^4.62.2",
34
+ "@ohos-ports/vite": "^8.3.0-beta.0"
35
+ },
36
+ "dependencies": {
37
+ "@babel/parser": "^7.29.7",
38
+ "@clack/prompts": "^1.5.1",
39
+ "@graphql-tools/merge": "^9.1.9",
40
+ "@graphql-tools/schema": "^10.0.33",
41
+ "@types/estree": "^1.0.9",
42
+ "@types/fs-extra": "^11.0.4",
43
+ "@ungap/structured-clone": "^1.3.1",
44
+ "@whatwg-node/server": "^0.11.0",
45
+ "ast-types": "^0.16.1",
46
+ "commander": "^15.0.0",
47
+ "deepmerge": "^4.3.1",
48
+ "estree-walker": "^3.0.3",
49
+ "fs-extra": "^11.3.5",
50
+ "glob": "^13.0.0",
51
+ "graphql-yoga": "^5.21.1",
52
+ "kleur": "^4.1.5",
53
+ "memfs": "^4.17.2",
54
+ "minimatch": "^10.2.5",
55
+ "npx-import": "^1.1.4",
56
+ "oauth4webapi": "^3.8.6",
57
+ "recast": "^0.23.11",
58
+ "sql.js": "^1.14.1",
59
+ "ws": "^8.21.0",
60
+ "@ohos-ports/houdini-core": "2.0.11-beta.0",
61
+ "@ohos-ports/esbuild": "0.28.2-beta.0"
62
+ },
63
+ "peerDependencies": {
64
+ "graphql": ">=16",
65
+ "@ohos-ports/vite": "^8.3.0-beta.0"
66
+ },
67
+ "files": [
68
+ "adapter",
69
+ "cmd",
70
+ "lib",
71
+ "node",
72
+ "oauth",
73
+ "router",
74
+ "runtime",
75
+ "test",
76
+ "vite",
77
+ "package.json"
78
+ ],
79
+ "exports": {
80
+ "./package.json": "./package.json",
81
+ ".": {
82
+ "types": "./lib/index.d.ts",
83
+ "import": "./lib/index.js"
84
+ },
85
+ "./*": {
86
+ "types": "./lib/*",
87
+ "import": "./lib/index.js"
88
+ },
89
+ "./adapter": {
90
+ "types": "./adapter/index.d.ts",
91
+ "import": "./adapter/index.js"
92
+ },
93
+ "./adapter/*": {
94
+ "types": "./adapter/*.d.ts",
95
+ "import": "./adapter/*.js"
96
+ },
97
+ "./cmd": {
98
+ "types": "./cmd/index.d.ts",
99
+ "import": "./cmd/index.js"
100
+ },
101
+ "./lib": {
102
+ "types": "./lib/index.d.ts",
103
+ "import": "./lib/index.js"
104
+ },
105
+ "./lib/config": {
106
+ "types": "./lib/config.d.ts",
107
+ "import": "./lib/config.js"
108
+ },
109
+ "./lib/constants": {
110
+ "types": "./lib/constants.d.ts",
111
+ "import": "./lib/constants.js"
112
+ },
113
+ "./lib/types": {
114
+ "types": "./lib/types.d.ts",
115
+ "import": "./lib/types.js"
116
+ },
117
+ "./node": {
118
+ "types": "./node/index.d.ts",
119
+ "import": "./node/index.js"
120
+ },
121
+ "./node/*": {
122
+ "types": "./node/*.d.ts",
123
+ "import": "./node/*.js"
124
+ },
125
+ "./oauth": {
126
+ "types": "./oauth/index.d.ts",
127
+ "import": "./oauth/index.js"
128
+ },
129
+ "./oauth/*": {
130
+ "types": "./oauth/*.d.ts",
131
+ "import": "./oauth/*.js"
132
+ },
133
+ "./router": {
134
+ "types": "./router/index.d.ts",
135
+ "import": "./router/index.js"
136
+ },
137
+ "./router/*": {
138
+ "types": "./router/*.d.ts",
139
+ "import": "./router/*.js"
140
+ },
141
+ "./runtime": {
142
+ "types": "./runtime/index.d.ts",
143
+ "import": "./runtime/index.js"
144
+ },
145
+ "./runtime/*": {
146
+ "types": "./runtime/*.d.ts",
147
+ "import": "./runtime/*.js"
148
+ },
149
+ "./runtime/cache": {
150
+ "types": "./runtime/cache/index.d.ts",
151
+ "import": "./runtime/cache/index.js"
152
+ },
153
+ "./runtime/config": {
154
+ "types": "./runtime/config.d.ts",
155
+ "import": "./runtime/config.js"
156
+ },
157
+ "./runtime/constants": {
158
+ "types": "./runtime/constants.d.ts",
159
+ "import": "./runtime/constants.js"
160
+ },
161
+ "./runtime/types": {
162
+ "types": "./runtime/types.d.ts",
163
+ "import": "./runtime/types.js"
164
+ },
165
+ "./test": {
166
+ "types": "./test/index.d.ts",
167
+ "import": "./test/index.js"
168
+ },
169
+ "./test/*": {
170
+ "types": "./test/*.d.ts",
171
+ "import": "./test/*.js"
172
+ },
173
+ "./vite": {
174
+ "types": "./vite/index.d.ts",
175
+ "import": "./vite/index.js"
176
+ },
177
+ "./vite/*": {
178
+ "types": "./vite/*.d.ts",
179
+ "import": "./vite/*.js"
180
+ }
181
+ },
182
+ "typesVersions": {
183
+ "*": {
184
+ "adapter": [
185
+ "./adapter/index.d.ts"
186
+ ],
187
+ ".": [
188
+ "./lib/index.d.ts"
189
+ ],
190
+ "node": [
191
+ "./node/index.d.ts"
192
+ ],
193
+ "oauth": [
194
+ "./oauth/index.d.ts"
195
+ ],
196
+ "router": [
197
+ "./router/index.d.ts"
198
+ ],
199
+ "runtime": [
200
+ "./runtime/index.d.ts"
201
+ ],
202
+ "test": [
203
+ "./test/index.d.ts"
204
+ ],
205
+ "vite": [
206
+ "./vite/index.d.ts"
207
+ ]
208
+ }
209
+ },
210
+ "bin": "./build/cmd/index.js",
211
+ "types": "./lib/index.d.ts"
212
212
  }
@@ -73,8 +73,8 @@ class DocumentStore extends Writable {
73
73
  silenceEcho = false,
74
74
  abortController = new AbortController()
75
75
  } = {}) {
76
+ const dedupeKey = this.controllerKey(variables);
76
77
  if ("dedupe" in this.artifact && this.artifact.dedupe && this.artifact.dedupe.match !== "None") {
77
- const dedupeKey = this.controllerKey(variables);
78
78
  const existingRequest = inflightRequests[dedupeKey];
79
79
  if (existingRequest && !existingRequest.controller.signal.aborted) {
80
80
  if (this.artifact.dedupe.cancel === "first") {
@@ -142,7 +142,9 @@ class DocumentStore extends Writable {
142
142
  try {
143
143
  return await promise;
144
144
  } finally {
145
- delete inflightRequests[this.controllerKey(variables)];
145
+ if (inflightRequests[dedupeKey]?.controller === abortController) {
146
+ delete inflightRequests[dedupeKey];
147
+ }
146
148
  }
147
149
  }
148
150
  async cleanup() {
@@ -1,5 +1,5 @@
1
1
  import * as graphql from "graphql";
2
- import { Config } from "houdini";
2
+ import { Config } from "@ohos-ports/houdini";
3
3
  import { vol } from "memfs";
4
4
  function clearMock() {
5
5
  vol.reset();
@@ -1,6 +1,8 @@
1
1
  import type { Db } from '../lib/db.js';
2
2
  import type { PluginOption } from 'vite';
3
3
  import { type Adapter, type CompilerProxy, type ConfigFile, type Config } from '../lib/index.js';
4
+ import { side_effect_free } from './side-effects.js';
5
+ export { side_effect_free };
4
6
  export type PluginConfig = {
5
7
  configPath?: string;
6
8
  adapter?: Adapter;
@@ -9,6 +9,7 @@ import { db_path } from "../router/conventions.js";
9
9
  import { document_hmr } from "./hmr.js";
10
10
  import { houdini } from "./houdini.js";
11
11
  import { poll_remote_schema, watch_local_schema, refresh_on_schema } from "./schema.js";
12
+ import { side_effect_free } from "./side-effects.js";
12
13
  async function index_default(opts) {
13
14
  const config = await get_config();
14
15
  const db_file = db_path(config);
@@ -28,6 +29,7 @@ async function index_default(opts) {
28
29
  document_hmr(ctx),
29
30
  poll_remote_schema(ctx),
30
31
  refresh_on_schema(ctx),
32
+ side_effect_free(config.artifact_dir),
31
33
  // each registered plugin could provide a vite portion
32
34
  ...await load_vite_plugins(ctx),
33
35
  close_session(ctx)
@@ -126,5 +128,6 @@ async function load_vite_plugins(ctx) {
126
128
  }
127
129
  export {
128
130
  close_session,
129
- index_default as default
131
+ index_default as default,
132
+ side_effect_free
130
133
  };
@@ -0,0 +1,12 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Marks every module under the given directory as free of side effects.
4
+ *
5
+ * Generated documents are reached through barrels (`export *` in the stores index), and a
6
+ * generated store declares `class X extends QueryStore`. The runtime module QueryStore comes
7
+ * from has import-time state, so the bundler treats the `extends` as a side effect and must
8
+ * evaluate every store any route reaches through the barrel. That pulls every store and its
9
+ * artifact into one shared chunk instead of the route that uses it.
10
+ * Only point this at a directory whose modules do nothing when imported.
11
+ */
12
+ export declare function side_effect_free(directory: string): Plugin;
@@ -0,0 +1,18 @@
1
+ import { posixify } from "../lib/path.js";
2
+ function side_effect_free(directory) {
3
+ return {
4
+ name: "houdini-side-effect-free",
5
+ // module side effects only matter when bundling
6
+ apply: "build",
7
+ transform: {
8
+ filter: { id: new RegExp(`^${escape_regex(posixify(directory))}/`) },
9
+ handler: () => ({ moduleSideEffects: false })
10
+ }
11
+ };
12
+ }
13
+ function escape_regex(value) {
14
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
15
+ }
16
+ export {
17
+ side_effect_free
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohos-ports/houdini",
3
- "version": "2.0.12-beta.1",
3
+ "version": "2.0.13-beta.0",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -11,8 +11,7 @@
11
11
  "funding": "https://github.com/sponsors/HoudiniGraphql",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/ohos-ports/ohos-ports.git",
15
- "directory": "ports/houdini/2.0.12"
14
+ "url": "https://github.com/HoudiniGraphql/houdini.git"
16
15
  },
17
16
  "license": "MIT",
18
17
  "type": "module",
@@ -23,10 +22,10 @@
23
22
  "@types/ungap__structured-clone": "^1.2.0",
24
23
  "@types/ws": "^8.18.1",
25
24
  "prettier": "^3.8.3",
26
- "rollup": "^4.61.1",
27
- "vite": "^8.0.16",
28
25
  "vitest": "^4.1.8",
29
- "scripts": "^2.0.0"
26
+ "scripts": "^2.0.0",
27
+ "@ohos-ports/rollup": "^4.62.2",
28
+ "@ohos-ports/vite": "^8.3.0-beta.0"
30
29
  },
31
30
  "dependencies": {
32
31
  "@babel/parser": "^7.29.7",
@@ -40,7 +39,6 @@
40
39
  "ast-types": "^0.16.1",
41
40
  "commander": "^15.0.0",
42
41
  "deepmerge": "^4.3.1",
43
- "esbuild": "0.28.0",
44
42
  "estree-walker": "^3.0.3",
45
43
  "fs-extra": "^11.3.5",
46
44
  "glob": "^13.0.0",
@@ -53,11 +51,12 @@
53
51
  "recast": "^0.23.11",
54
52
  "sql.js": "^1.14.1",
55
53
  "ws": "^8.21.0",
56
- "@ohos-ports/houdini-core": "2.0.10-beta.1"
54
+ "@ohos-ports/houdini-core": "2.0.11-beta.0",
55
+ "@ohos-ports/esbuild": "0.28.2-beta.0"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "graphql": ">=16",
60
- "vite": "^8.0.0"
59
+ "@ohos-ports/vite": "^8.3.0-beta.0"
61
60
  },
62
61
  "files": [
63
62
  "build"
@@ -202,8 +201,5 @@
202
201
  },
203
202
  "bin": {
204
203
  "houdini": "./build/cmd/index.js"
205
- },
206
- "bugs": {
207
- "url": "https://github.com/ohos-ports/ohos-ports/issues"
208
204
  }
209
205
  }