diff --git a/packages/daemon/src/daemon-node-powers.js b/packages/daemon/src/daemon-node-powers.js index 31d737d637..327a368ec2 100644 --- a/packages/daemon/src/daemon-node-powers.js +++ b/packages/daemon/src/daemon-node-powers.js @@ -179,13 +179,9 @@ export const makeHttpPowers = ({ http, ws }) => { /** * @param {object} modules * @param {typeof import('net')} modules.net - * @param {typeof import('http')} modules.http - * @param {typeof import('ws')} modules.ws - * @returns {import('./types.js').NetworkPowers} + * @returns {import('./types.js').SocketPowers} */ -export const makeNetworkPowers = ({ http, ws, net }) => { - const { servePortHttp } = makeHttpPowers({ http, ws }); - +export const makeSocketPowers = ({ net }) => { const serveListener = async (listen, cancelled) => { const [ /** @type {Reader} */ readFrom, @@ -260,6 +256,20 @@ export const makeNetworkPowers = ({ http, ws, net }) => { ); }, cancelled); + return { servePort, servePath }; +}; + +/** + * @param {object} modules + * @param {typeof import('net')} modules.net + * @param {typeof import('http')} modules.http + * @param {typeof import('ws')} modules.ws + * @returns {import('./types.js').NetworkPowers} + */ +export const makeNetworkPowers = ({ http, ws, net }) => { + const { servePortHttp } = makeHttpPowers({ http, ws }); + const { servePort, servePath } = makeSocketPowers({ net }); + const connectionNumbers = (function* generateNumbers() { let n = 0; for (;;) { diff --git a/packages/daemon/src/types.d.ts b/packages/daemon/src/types.d.ts index 38ffb872ff..21ea1f2acc 100644 --- a/packages/daemon/src/types.d.ts +++ b/packages/daemon/src/types.d.ts @@ -321,7 +321,7 @@ export type PetStorePowers = { ) => Promise>; }; -export type NetworkPowers = { +export type SocketPowers = { servePath: (args: { path: string; host?: string; @@ -332,6 +332,9 @@ export type NetworkPowers = { host?: string; cancelled: Promise; }) => Promise>; +}; + +export type NetworkPowers = SocketPowers & { servePortHttp: (args: { port: number; host?: string;