| 151 | const stub = value.get(id); |
| 152 | return { |
| 153 | fetch( |
| 154 | pathOrInit?: string | RequestInit | Request, |
| 155 | maybeInit?: RequestInit | Request |
| 156 | ) { |
| 157 | let path: RequestInfo | undefined; |
| 158 | let init: RequestInit | Request | undefined; |
| 159 | if (pathOrInit) { |
| 160 | if (typeof pathOrInit === "string") { |
| 161 | path = pathOrInit; |
| 162 | init = maybeInit; |
| 163 | if (path[0] !== "/") { |
| 164 | throw new Error("Path must start with /"); |
| 165 | } |
| 166 | return stub.fetch( |
| 167 | `http://${options.host}/parties/${key}/${name}${path}`, |
| 168 | init |
| 169 | ); |
| 170 | } else { |
| 171 | init = pathOrInit; |
| 172 | return stub.fetch( |
| 173 | `http://${options.host}/parties/${key}/${name}`, |
| 174 | init |
| 175 | ); |
| 176 | } |
| 177 | } else { |
| 178 | return stub.fetch( |
| 179 | `http://${options.host}/parties/${key}/${name}` |
| 180 | ); |
| 181 | } |
| 182 | }, |
| 183 | connect: () => { |
| 184 | return new WebSocket( |
| 185 | `ws://${options.host}/parties/${key}/${name}` |