|
| 1 | +type BridgeClientModule = typeof import('../api/bridge-client'); |
| 2 | + |
1 | 3 | import * as readline from 'readline'; |
2 | 4 | import { execFile } from 'child_process'; |
3 | 5 |
|
4 | 6 | import { Command, flags } from '@oclif/command'; |
5 | | -import { delay } from '@httptoolkit/util'; |
6 | 7 |
|
7 | | -import { SERVER_VERSION } from '../constants'; |
8 | | -import { apiRequest } from '../api/bridge-client'; |
9 | | -import { HtkOperation } from '../api/ui-operation-bridge'; |
| 8 | +import { IS_PROD_BUILD, SERVER_VERSION } from '../constants'; |
| 9 | +import type { HtkOperation } from '../api/ui-operation-bridge'; |
| 10 | + |
| 11 | +function maybeBundleImport<T>(moduleName: string): T { |
| 12 | + if (IS_PROD_BUILD || process.env.OCLIF_TS_NODE === '0') { |
| 13 | + return require('../../bundle/' + moduleName); |
| 14 | + } else { |
| 15 | + return require('../' + moduleName); |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +const { apiRequest } = maybeBundleImport<BridgeClientModule>('api/bridge-client'); |
10 | 20 |
|
11 | 21 | interface JsonRpcRequest { |
12 | 22 | jsonrpc: '2.0'; |
@@ -88,7 +98,7 @@ async function startHttpToolkit( |
88 | 98 | // Wait for the UI to connect and send operations |
89 | 99 | const deadline = Date.now() + LAUNCH_TIMEOUT_MS; |
90 | 100 | while (Date.now() < deadline) { |
91 | | - await delay(LAUNCH_POLL_MS); |
| 101 | + await new Promise(resolve => setTimeout(resolve, LAUNCH_POLL_MS)); |
92 | 102 | await refreshOperations(); |
93 | 103 | try { |
94 | 104 | const status = await apiRequest('GET', '/api/status'); |
|
0 commit comments