Skip to content

feat(kernel-browser-runtime): pass full RemoteCommsOptions via worker URL#881

Draft
sirtimid wants to merge 2 commits intomainfrom
sirtimid/remote-comms-query-string
Draft

feat(kernel-browser-runtime): pass full RemoteCommsOptions via worker URL#881
sirtimid wants to merge 2 commits intomainfrom
sirtimid/remote-comms-query-string

Conversation

@sirtimid
Copy link
Contributor

Summary

Support passing all RemoteCommsOptions (relays, allowedWsHosts, directListenAddresses, numeric options, mnemonic) into the kernel worker via the worker URL, instead of only relays.

Changes

comms-query-string utilities

  • Generalized to handle all serializable RemoteCommsOptions (excluding directTransports)
  • Type-safe param lists: ARRAY_PARAM_NAMES and NUMBER_PARAM_NAMES are derived from RemoteCommsOptions
  • createCommsQueryString now returns URLSearchParams so callers can append params (e.g. reset-storage, system-subclusters) before setting URL.search
  • Removed parseRelayQueryString, parseAllowedWsHostsQueryString, and getRelaysFromCurrentLocation; use getCommsParamsFromCurrentLocation() and parseCommsQueryString() instead

makeKernelWorker (extension & omnium-gatherum)

  • Accepts optional remoteCommsOptions?: Partial<RemoteCommsOptions> as the first argument
  • Passes these options into the worker URL via createCommsQueryString
  • Defaults to DEFAULT_RELAYS when no options are provided

kernel-worker

  • Reads options from the URL with getCommsParamsFromCurrentLocation() and passes them to kernel.initRemoteComms()

Usage

// Default relays
const stream = await makeKernelWorker();

// Custom options
const stream = await makeKernelWorker({
  relays: ['/ip4/127.0.0.1/tcp/9001/ws/p2p/...'],
  allowedWsHosts: ['localhost'],
  maxQueue: 200,
});

@github-actions
Copy link
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.34%
⬆️ +0.03%
7851 / 10151
🔵 Statements 77.15%
⬆️ +0.03%
7977 / 10339
🔵 Functions 75.39%
⬆️ +0.04%
1891 / 2508
🔵 Branches 74.8%
🟰 ±0%
3218 / 4302
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/extension/src/offscreen.ts 0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
23-107
packages/kernel-browser-runtime/src/kernel-worker/kernel-worker.ts 0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
26-111
packages/kernel-browser-runtime/src/utils/comms-query-string.ts 89.23% 82.92% 100% 89.06% 75, 79, 85, 107, 116, 139, 171
packages/kernel-browser-runtime/src/utils/index.ts 100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
packages/omnium-gatherum/src/offscreen.ts 0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
23-126
Generated in workflow #3955 for commit f912a88 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant