weida

GitHub crates.io

weida for JavaScript (`crates/js/weida-js`, against the C ABI `libweida`) — feature parity

Rendered from docs/libraries/weida-js.md at 92c768a

Contents
  1. 1. What a row means
  2. 2. Classes
  3. 3. Errors
  4. 4. Waiting
  5. 5. Packaging
  6. 6. What is not mapped
  7. 7. Sources

1. What a row means

The package is one Node-API addon written in C against weida.h (decisions/0046), serving Node, Bun and Deno, with an ES module on top. Its API mirrors the C ABI: one class per handle, one method per function with the weida_<type>_ prefix dropped and the rest in camelCase. Its reference is therefore weida-c.md: every row present there is present here unless a row below says otherwise, and every row absent there is absent here for the same reason. This document lists what the JavaScript surface adds or changes. Verdicts are present (with the test), refused (with the reason) or absent (with the reason); there is no "partial".

The tests are crates/js/weida-js/test/unit/ (in-process transport only, one second each) and test/integration/ (QUIC on localhost and the local sockets of the OS, ten seconds each), run with node --test; smoke.mjs makes one round trip under each runtime, and package.sh runs it from a fresh project that installed the packed tarball. Measured on Node 26, Bun 1.4.4 and Deno 2.9.8 on linux-amd64, linux-arm64, darwin-arm64 and windows-amd64 (the js-linux-* jobs, js-darwin-arm64 and js-windows-amd64).

2. Classes

C ABIJavaScript (weida, ESM)Verdict
weida_runtime_config, weida_limits, weida_guarantee_set, weida_reconnect_policyRuntimeConfig({ ... }) or a plain object, turned into handles by Runtime.owned: every field of weida_runtime_config (workerThreads, shutdownTimeoutMs, maxConnections, maxConnectionsPerPeer, endpointQueue, maxResolvedAddresses, connectAttemptTimeoutMs, sendTimeoutMs, outboxMessages, outboxBytes, outboxFull, maxHandshakes, retryAboveHandshakes, discovery, resolver) and the nested objects limits (every Limits field), guarantees (every dimension) and reconnect (every field, never: true to start from ReconnectPolicy::never()); enumerations are the constant names as strings, an unknown field is a TypeErrorpresent; config.test.js "a full configuration builds a runtime", "a guarantee the dialler does not offer fails with WEIDA_ENEGOTIATION", "configuration input errors are thrown at once", errors.test.js "a runtime with no worker threads is a runtime failure"
weida_runtimeRuntime.owned(config?), .listener(), .requester(clientTls), .pusher(clientTls), .subscriber(clientTls), .pair(clientTls), .surveyor(clientTls), .dish(clientTls), .peer(clientTls), .swarm(clientTls), .shutdown(opts) (consumes), .drain(deadlineMs, opts) -> Promise<Drained> (consumes), .suppressedDuplicates(), .expiredTransfers() (BigInt), .drop()present; every round-trip test, stats.test.js "expiredTransfers counts a reply expired with expireAfterMs(0)" (stats), drain.test.js "a drain counts a reply finished before it as delivered", "a drain with nothing pending resolves at once", "a deadline out of range rejects with a RangeError and consumes nothing" (drain), patterns.test.js "push to pull over inproc arrives in order", "a subscriber receives only its topic", "a pair exchanges in both directions", "a survey collects two respondents' answers within its window" (patterns), flows.test.js "a flow carries datagrams to an acceptor and ends after them" (flows), swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it" (swarm)
weida_resolver, weida_resolvedthe RuntimeConfig field resolver: (lookup) => addresses, called on the JS thread for every lookup with a frozen { name, port: number | null, maxAddresses: number } and answered with "ip:port" strings in dial order; a throw, a rejection or an answer that is not an array of strings refuses it, and the dial rejects with WEIDA_EINVALID_ADDRESS carrying why; its descriptor is watched weakly, so it never keeps the process alivepresent; resolver.test.js "a name only the resolver knows is dialled through it", "a refused or malformed answer rejects the connect with WEIDA_EINVALID_ADDRESS", "a runtime with a resolver does not keep the process alive", config.test.js "configuration input errors are thrown at once" (resolver)
weida_trustnew Trust(), .addPin(fp), .addAnchor(X509Certificate | bytes), .addAnchorFile(path), each returning the trust; .isEmpty()present; errors.test.js "a malformed pin is an invalid fingerprint", quic.test.js "a wrong pin rejects with WEIDA_EUNTRUSTED carrying the fingerprint", mtls.test.js "an anchor accepts the dialled name", "identity and anchor files read back", sources.test.js "a trust source reports a refresh and isEmpty follows it" (identity)
weida_identityIdentity.generate(), .generateFor(names), .fromPem(cert, key), .from({ cert, key }) (X509Certificate, an array of them or bytes; a private KeyObject or bytes), .fromPemFile(path), .fromPemFiles(cert, key), .fingerprint(), .certificatePem(): string, .toPem(): Uint8Array, .certificates(): X509Certificate[]present; quic.test.js "a round trip over QUIC with a pinned key", identity.test.js (all five), mtls.test.js "identity and anchor files read back", smoke.mjs
weida_pemnot exposed: copied out at once into a string (certificatePem) or a Uint8Array (toPem) and dropped, which wipes itrefused as a class: a JavaScript caller needs the bytes, not the handle
weida_client_tls, weida_server_tlsnew ClientTls(trust, { identity?, alpn? }) with trust a Trust or a TrustSource and identity an Identity or an IdentitySource, new ServerTls(identity, { requireClient?, alpn? }) with identity an Identity or an IdentitySource and requireClient a Trust, a TrustSource or "any-key"; alpn a "WEIDA_ALPN_*" name. A value is copied, a source sharedpresent; mtls.test.js "a pinned client key is accepted and the server sees its fingerprint", "an anonymous or unknown client is refused with WEIDA_ETLS and nothing reaches the server", "any-key exposes the fingerprint and the chain", "a files identity source rotates a binding's certificate and its events report it", "a mismatched ALPN rejects the dial with WEIDA_ETLS", sources.test.js "source and ALPN argument errors are TypeErrors" (identity), smoke.mjs
weida_identity_source, weida_weak_identity_sourceIdentitySource.fromIdentity(id), .ephemeral(names), .external(id), .files(dir, { names?, pollMs? }), .current(), .fingerprint(), .update(id), .reportFailure(reason), .reportHandoffStolen(), .reload() -> boolean, .events(), .downgrade(); WeakIdentitySource.upgrade() -> IdentitySource | nullpresent; sources.test.js "an external identity source reports its updates as events", "a weak source upgrades until the last strong handle is gone and the events end", mtls.test.js "a files identity source rotates a binding's certificate and its events report it" (identity)
weida_trust_source, weida_weak_trust_sourceTrustSource.fromTrust(t), .external(t), .current(), .update(t), .reportFailure(reason), .isEmpty(), .events(), .downgrade(); WeakTrustSource.upgrade() -> TrustSource | nullpresent; sources.test.js "a trust source reports a refresh and isEmpty follows it", mtls.test.js "a files identity source rotates a binding's certificate and its events report it", "a mismatched ALPN rejects the dial with WEIDA_ETLS" (identity)
weida_files_optionsnot exposed: the plain object { names?, pollMs? } of IdentitySource.files, an unknown field a TypeErrorpresent; mtls.test.js "a files identity source rotates a binding's certificate and its events report it", sources.test.js "source and ALPN argument errors are TypeErrors" (identity)
weida_identity_eventsIdentityEvents.recv(opts) -> Promise<IdentityEvent | null> (null once the source is gone), from IdentitySource.events() or TrustSource.events(), [Symbol.asyncIterator] (ends there; leaving the loop drops the reader)present; sources.test.js "an external identity source reports its updates as events", "a weak source upgrades until the last strong handle is gone and the events end", mtls.test.js "a files identity source rotates a binding's certificate and its events report it" (identity)
weida_transfer_metaa plain object { contentType?, contentLen?, trace?, topic?, achieved?, report?, reportMode? }, turned into a handle per call, report an array of "WEIDA_ACKNOWLEDGEMENT_*" names and application stages as numbers or BigInts, reportMode a "WEIDA_REPORT_MODE_*" name; an unknown field is a TypeErrorpresent; inproc.test.js "a streamed round trip carries the body and the content type", config.test.js "metadata travels with a request and its reply", cursors.test.js "final-only yields exactly one update per level" (cursors)
weida_listenerListener.bindQuic(addr, serverTls, opts) -> Promise<Binding>, .bindQuicSocket(socket, serverTls, opts) -> Promise<Binding> (a descriptor number, libweida's once the call reaches C), .bindRelay(relay, via, serverTls, opts) -> Promise<Binding>, .bindInproc(bus), .bindUnix(path) -> UnixBinding, .bindPipe(name) -> PipeBinding (WEIDA_EUNSUPPORTED on the other platform), .replier(path), .puller(path), .publisher(path), .pair(path), .respondent(path), .bus(path, clientTls), .radio(path), .acceptor(path), .seeder(path), .relay() -> Relaypresent; binding.test.js "a hand-over keeps a requester's connection", relay.test.js "a dial-only replier reached through a relay answers a requester" (binding lifecycle); local.test.js "a round trip over a unix socket names the client's uid", "a round trip over a named pipe names the client's SID" (local transports); patterns.test.js "push to pull over inproc arrives in order", "a subscriber receives only its topic", "a pair exchanges in both directions", "a survey collects two respondents' answers within its window", "a bus message reaches every other member" (patterns); flows.test.js "a flow carries datagrams to an acceptor and ends after them" (flows), swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it" (swarm)
weida_bindingBinding.localAddr(), .close(opts), .handOver(opts) -> Promise<Handoff> (consumes), .takeOver(held, opts) -> Promise<number>, .disconnect(fingerprint) -> number, .relayEvents() -> PeerEvents | nullpresent; binding.test.js "a closed binding refuses the next dial", "a hand-over keeps a requester's connection", "disconnect closes a peer's connections by its key" (binding lifecycle)
weida_local_bindingLocalBinding.bus()present
weida_unix_binding, weida_pipe_bindingUnixBinding.path(), PipeBinding.name(); dropping either ends the bindingpresent; local.test.js "a round trip over a unix socket names the client's uid", "a round trip over a named pipe names the client's SID" (local transports)
weida_handoffHandoff.held() -> number, .localAddr(), .bytes() -> Uint8Array (a copy), .takeSocket() -> number (once, then WEIDA_ECLOSED); dropping it closes a socket not takenpresent; binding.test.js "a hand-over keeps a requester's connection" (binding lifecycle)
weida_relay, weida_relay_requestRelay.accept(opts) -> Promise<RelayRequest>, RelayRequest.peerFingerprint(), .target(), .admit(opts), .admitWith(bytesPerSec, opts), .refuse(opts) (all three consume; a bytesPerSec out of range throws first and consumes nothing)present; relay.test.js "a dial-only replier reached through a relay answers a requester", "a registration the relay refuses rejects bindRelay with WEIDA_EREJECTED", "a tunnel admitted with a budget moves no faster than it" (binding lifecycle)
weida_requesterRequester.connect(url, opts), .request(body, opts) -> Promise<IncomingTransfer>, .requestWith(meta, body, opts), body a Uint8Array or a string sent as UTF-8, .open(meta?, opts) -> Promise<{ body: OutgoingTransfer, reply: ReplyStream }> (a frozen object), .connectionStats() (a frozen array of frozen records, every number a BigInt), .events() -> PeerEventspresent; inproc.test.js "a streamed round trip carries the body and the content type", "an opened exchange reads its reply while the request is still open" (streams), config.test.js "metadata travels with a request and its reply", stats.test.js "an inproc connection is reported with its url and no transport", "a replier runtime shut down yields Lost then Retrying", quic.test.js "a QUIC connection reports its transport" (stats)
weida_reply_streamReplyStream.recv(opts) -> Promise<IncomingTransfer> (consumes), .drop() (the replier sees CANCELED)present; inproc.test.js "an opened exchange reads its reply while the request is still open", "dropping a reply stream tells the replier nobody is listening" (streams)
weida_pusherPusher.connect(url, opts), .disconnect(url) -> boolean, .peerCount(), .connectionStats(), .events() -> PeerEvents, .dropped() -> bigint, .open(meta?, opts) -> Promise<OutgoingTransfer>, .send(body, opts), .sendWith(meta, body, opts)present; patterns.test.js "push to pull over inproc arrives in order" (patterns)
weida_pullerPuller.path(), .recv(opts) -> Promise<IncomingTransfer>present; patterns.test.js "push to pull over inproc arrives in order" (patterns)
weida_publisherPublisher.path(), .publish(topic, payload) -> number, .publishWithTrace(topic, payload, trace) -> number, .open(topic) -> FanOut, .openWithTrace(topic, trace) -> FanOut, .subscriberCount(), .filterCount(), .dropped() -> bigint, .droppedOn(topic) -> TopicDrops | null, .drops() -> readonly TopicDrops[]present; patterns.test.js "a subscriber receives only its topic", "a skipped sequence reads as a gap under per-producer detect", "a fan-out streams one payload to every subscriber" (patterns)
weida_subscriberSubscriber.connect(url, opts), .disconnect(url) -> boolean, .peerCount(), .connectionStats(), .events() -> PeerEvents, .subscribe(filter, opts), .unsubscribe(filter, opts), .grant(filter, limit, opts), .filterCount(), .recv(opts) -> Promise<IncomingTransfer>present; patterns.test.js "a subscriber receives only its topic", "a skipped sequence reads as a gap under per-producer detect" (patterns)
weida_fan_outFanOut.topic(), .subscribers(), .writeWithin(chunk, limitMs, opts) -> Promise<number> (aborting abandons the transfer; every other call throws WEIDA_EINVAL until it settles), .writeNow(chunk) -> number, .finish() -> number (consumes); .drop() aborts every copy not finishedpresent; patterns.test.js "a fan-out streams one payload to every subscriber" (patterns)
weida_pairedPaired.path() ("" on a dialling pair), .connect(url, opts) (once; WEIDA_ELIMIT_EXCEEDED for a second address, WEIDA_EUNSUPPORTED on a bound pair), .peerCount(), .connectionStats(), .events() -> PeerEvents | null (null on a bound pair), .dropped() -> bigint, .open(meta?, opts) -> Promise<OutgoingTransfer>, .send(body, opts), .sendWith(meta, body, opts), .recv(opts) -> Promise<IncomingTransfer>present; patterns.test.js "a pair exchanges in both directions" (patterns)
weida_surveyorSurveyor.connect(url, opts), .peerCount(), .connectionStats(), .survey(body, deadlineMs, opts) -> Promise<SurveyRun>, .surveyWith(meta, body, deadlineMs, opts) -> Promise<SurveyRun>present; patterns.test.js "a survey collects two respondents' answers within its window" (patterns)
weida_survey_run, weida_survey_answerSurveyRun.next(maxBytes, opts) -> Promise<Uint8Array | null> (null once the run ended; an answer copied out at once into a Uint8Array; a failed answer rejects and the run goes on; an aborted call leaves its read in flight for the next one), .late() -> bigint, .respondents(); .drop() resets the unanswered exchangespresent; patterns.test.js "a survey collects two respondents' answers within its window" (patterns)
weida_respondentRespondent.path(), .accept(opts) -> Promise<IncomingRequest>present; patterns.test.js "a survey collects two respondents' answers within its window" (patterns)
weida_bus_memberBusMember.path(), .connect(url, opts), .peerCount(), .connectionStats(), .send(body, opts) -> Promise<number>, .sendWith(meta, body, opts) -> Promise<number> (the members reached), .recv(opts) -> Promise<IncomingTransfer>, .dropped() -> bigintpresent; patterns.test.js "a bus message reaches every other member" (patterns)
weida_radioRadio.path(), .segment(topic, terms?) -> Segment, .datagram(topic, payload) -> number (the dishes handed), .dishCount(), .dropped() -> bigint, .droppedOn(topic) -> TopicDrops | null, .drops() -> readonly TopicDrops[], .evict(fingerprint, filter) -> number, .dishDrops() -> readonly DishDrops[]; dropping it releases the pathpresent; patterns.test.js "a dish receives the radio's segments with their numbers and layers", "a superseded segment counts in dish drops", "a radio datagram reaches a dish that carries datagrams", radio.test.js "a radio evicts a dish by its key" (patterns)
weida_segmentSegment.number() -> bigint, .topic(), .write(chunk) -> number, .writeLayer(layer, chunk) -> number, .finishLayer(layer), .finish() -> number (consumes); .drop() resets every unfinished layerpresent; patterns.test.js "a dish receives the radio's segments with their numbers and layers", "a superseded segment counts in dish drops", radio.test.js "a radio evicts a dish by its key" (patterns)
weida_dishDish.connect(url, opts), .peerCount(), .connectionStats(), .events() -> PeerEvents, .join(filter, terms?, opts), .leave(filter, opts), .recv(opts) -> Promise<Received> (a frozen Received), .stale() -> bigint, .overflow() -> bigintpresent; patterns.test.js "a dish receives the radio's segments with their numbers and layers", "a superseded segment counts in dish drops", "a radio datagram reaches a dish that carries datagrams", radio.test.js "a radio evicts a dish by its key" (patterns)
weida_join_terms, weida_segment_termsnot exposed: the plain objects { maxAgeMs?, maxLayer? } of Dish.join and { maxAgeMs?, priority?, followsUpstream? } of Radio.segment, turned into a handle per call; an unknown field is a TypeErrorpresent; patterns.test.js "a dish receives the radio's segments with their numbers and layers" (patterns)
weida_peer_eventsPeerEvents.recv(opts) -> Promise<PeerEvent | null> (null once the requester, or the relayed binding's registration, is gone), from Requester.events() or Binding.relayEvents(), [Symbol.asyncIterator] (ends there; leaving the loop drops the reader)present; stats.test.js "a replier runtime shut down yields Lost then Retrying" (stats), relay.test.js "a dial-only replier reached through a relay answers a requester" (binding lifecycle)
weida_cursors, weida_cursor_setCursors.recv(opts) -> Promise<CursorSet | null> (null once no more cursors come), from OutgoingTransfer.cursors(), [Symbol.asyncIterator] (ends there; leaving the loop drops the reader); a set is a frozen array of frozen { level, offset } in ascending level order, level a "WEIDA_ACKNOWLEDGEMENT_*" name or an application stage as a BigInt, offset a BigInt; CURSOR_LEVEL_APPLICATION_FLOOR exportedpresent; cursors.test.js "a request that orders Accepted receives the reported offsets in order", "final-only yields exactly one update per level" (cursors)
weida_reporterReporter.levels(), .mode(), .setGranularity(bytes, intervalMs), .report(level, offset, opts), .finish(opts) (consumes); .drop() flushes nothingpresent; cursors.test.js "a request that orders Accepted receives the reported offsets in order", "final-only yields exactly one update per level" (cursors)
weida_peer, weida_flow_metaPeer.connect(url, opts), .disconnect(url), .peerCount(), .connectionStats(), .events(), .dropped(), .open(meta, opts) -> Promise<OutgoingTransfer>, .openBi(meta, opts) -> Promise<{ body, reply }>, .send(meta, body, opts), .segment(topic, terms?, opts) -> Promise<Segment>, .segmentDrops(topic) -> TopicDrops | null, .openFlow(meta?, opts) -> Promise<Flow>, the flow meta a plain object { contentType?, trace?, topic? } turned into a handle per call (an unknown field is a TypeError)present; flows.test.js (unit) "a flow carries datagrams to an acceptor and ends after them", "a flow without datagrams is unavailable, other kinds are tagged, and a refusal reaches the sender" and flows.test.js (integration) "a flow carries datagrams over QUIC" (flows); peers.test.js "a raw peer opens a stream that the acceptor reads" (raw peers)
weida_acceptor, weida_incoming, weida_credit_grantAcceptor.path(), .accept(opts) -> Promise<Incoming>: a frozen { kind, transfer }, { kind, request }, { kind, consumer }, { kind, flow }, or the copied values { kind, id, filter, limit } (a credit grant, BigInts) and { kind, id, filter } (an unsubscription, filter null for the whole connection)present; flows.test.js (unit) "a flow carries datagrams to an acceptor and ends after them", "a flow without datagrams is unavailable, other kinds are tagged, and a refusal reaches the sender" and flows.test.js (integration) "a flow carries datagrams over QUIC" (flows); peers.test.js "a raw peer opens a stream that the acceptor reads", "credit granted in two steps releases exactly that many deliveries" (raw peers)
weida_consumerConsumer.id() -> bigint, .filter(), .path(), .open(meta, opts) -> Promise<OutgoingTransfer>, .deliver(meta, body, opts), .close(code, reason)present; peers.test.js "credit granted in two steps releases exactly that many deliveries" (raw peers)
weida_flow, weida_path_statsFlow.send(payload) (synchronous; throws), .maxPayload() -> number | null, .stats() (a frozen { sent, tooLarge, discarded, notLive } of BigInts), .pathStats() -> PathStats | null (the PathStats of a connection record), .abort() (consumes); .drop() closes with FINpresent; flows.test.js (unit) "a flow carries datagrams to an acceptor and ends after them", "a flow without datagrams is unavailable, other kinds are tagged, and a refusal reaches the sender" and flows.test.js (integration) "a flow carries datagrams over QUIC" (flows)
weida_incoming_flow, weida_datagramIncomingFlow.info() (a frozen { endpoint, topic, contentType, trace, peerFingerprint, peerChain, peerLocal }), .recv(opts) -> Promise<Uint8Array | null> (null once the flow ended), [Symbol.asyncIterator] (ends there; leaving the loop drops the flow), .stats() (a frozen { received, overflow }), .pathStats(), .refuse() (consumes); .drop() stops it CANCELEDpresent; flows.test.js (unit) "a flow carries datagrams to an acceptor and ends after them", "a flow without datagrams is unavailable, other kinds are tagged, and a refusal reaches the sender" and flows.test.js (integration) "a flow carries datagrams over QUIC" (flows)
weida_blob, weida_blob_id_ofnew Blob(root, size, pieceLog2?), .root() -> Uint8Array, .size() -> bigint, .pieceLog2(), .count(), .span(i) -> { start, end } | null (BigInts, end exclusive), blobIdOf(data)present; swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it", "a declined session leaves the fetch WEIDA_ENOT_CONNECTED" (swarm)
weida_piece_list, weida_tree_hasherPieceList.of(data, pieceLog2?), .parse(blob, bytes), .blob(), .toBytes() (a copy), .check(i, piece); new TreeHasher(pieceLog2?), .update(data) (returns the hasher), .finish() (consumes)present; swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it", "a declined session leaves the fetch WEIDA_ENOT_CONNECTED" (swarm)
weida_bitsnew Bits(len), Bits.full(len), .fromBytes(len, bytes), .asBytes() (a copy), .len(), .get(i), .set(i, on), .ones(), .all()present; swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it", "a declined session leaves the fetch WEIDA_ENOT_CONNECTED" (swarm)
weida_swarm, weida_fetch_optionsSwarm.connect(url, opts), .disconnect(url), .peerCount(), .connectionStats(), .events(), .fetch(blob, have, options?) with the plain object { list?, stallMs?, minRate?, perPeer?, maxInflight?, maxPeers?, haveRefreshMs? } turned into a handle per call (an unknown field a TypeError)present; swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it", "a declined session leaves the fetch WEIDA_ENOT_CONNECTED" (swarm)
weida_fetch, weida_pieceFetch.blob(), .list() -> PieceList | null, .delivered(), .inFlight(), .unavailable() (Bits copies), .prioritize(start, end), .clearPriority() (each answers while a next is pending, which goes on unharmed), .next(opts) -> Promise<{ index, bytes } | null> (a piece copied out at once into a frozen object; null once every piece is held; an aborted call leaves its read in flight for the next one), [Symbol.asyncIterator] (ends at null and leaves the fetch alive)present; swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it", "a declined session leaves the fetch WEIDA_ENOT_CONNECTED", "a piece a seeder says is gone is unavailable until another seeder serves it" (swarm)
weida_seeder, weida_seed_sessionSeeder.path(), .accept(opts) -> Promise<SeedSession>; SeedSession.blob(), .meta(), .connection() -> bigint, .next(opts) -> Promise<{ kind, index } | null> (kind a "WEIDA_ASK_*" name), .answerList(list, opts), .answerHave(bits, opts), .answerPiece(bytes, opts), .answerGone(index, opts), .decline(opts) (consumes); WEIDA_EINVAL for a call while another is in flightpresent; swarm.test.js "a blob seeded by one runtime is fetched by two others, which verify it", "a declined session leaves the fetch WEIDA_ENOT_CONNECTED", "a piece a seeder says is gone is unavailable until another seeder serves it" (swarm)
weida_peer_event, weida_identity_event, weida_connection_stats, weida_topic_drops, weida_received, weida_dish_dropsnot exposed: copied out at once into frozen plain objects, a peer event as { kind, url, peerFingerprint, cause, attempt, delayUs, why, whyAttempts, whyPresented, whyMessage, missed }, an identity event as { kind, fingerprint, from, to, message, missed } (absent fields null, enumerations their constant names), a record as { url, ageUs, redials, transport: { path, tx, rx } | null, remote | null }, a drops record as { topic, subscriberBudget, subscriberQueue, noParkedConnection, superseded, expired, tooLarge, noDatagrams, layersCut } of BigInts, a received datagram as { kind, topic, segment, payload } (segment a BigInt, payload a Uint8Array) and a received stream segment as { kind, transfer }, a dish-drops record as { peerFingerprint, subscriberBudget, subscriberQueue, superseded, expired, tooLarge, noDatagrams, layersCut }, the counts BigIntspresent; the same tests (stats, identity, patterns)
weida_drainednot exposed: copied out at once into a frozen { delivered, outstanding } of BigIntspresent; drain.test.js "a drain counts a reply finished before it as delivered" (drain)
weida_replierReplier.path(), .accept(opts) -> Promise<IncomingRequest>present; inproc.test.js "two concurrent accepts on one replier serve two requests"
weida_incoming_requestIncomingRequest.meta(), .connection() -> bigint, .takeBody(), .reply(meta?, opts) (consumes), .refuse(code, opts) (consumes; code a WEIDA_ERROR_CODE_* name, an unknown name a TypeError that consumes nothing), .canceled(opts) (started at the call, outlives the request)present; inproc.test.js "a second reply rejects with WEIDA_ECLOSED", "a refused request rejects the requester with the refused code's error", "a refusal code outside WEIDA_ERROR_CODE_* is a TypeError and leaves the request usable", "canceled settles once the requester gives up" (refusals), stats.test.js "an inproc connection is reported with its url and no transport" (stats)
weida_incoming_transferIncomingTransfer.meta(), .connection() -> bigint, .reporter() -> Reporter | null (a new reporter per call; take it before collect), .read(cap = 65536, opts) -> Promise<Uint8Array> (empty at the end), .collect(maxBytes, opts) -> Promise<Message> (consumes)present; inproc.test.js "reads of 3 bytes reassemble the body", "a collect over its ceiling rejects with WEIDA_ELIMIT_EXCEEDED", "a reply dropped unfinished reads as WEIDA_ECANCELED", stats.test.js "an inproc connection is reported with its url and no transport" (stats), cursors.test.js "a request that orders Accepted receives the reported offsets in order", "final-only yields exactly one update per level" (cursors)
weida_outgoing_transferOutgoingTransfer.write(data, opts) -> Promise<number>, .writeAll(data, opts), .trace(), .setPriority(n), .expireAfterMs(ms), .cursors() -> Cursors | null (once; take it before finish), .finish() -> Delivery (consumes)present; writeAll is the JavaScript loop R3c leaves to the caller; config.test.js "metadata travels with a request and its reply", "an expired reply fails its finish with WEIDA_EEXPIRED", cursors.test.js "a request that orders Accepted receives the reported offsets in order", "final-only yields exactly one update per level" (cursors)
weida_deliveryDelivery.delivered(opts) (consumes)present
weida_incoming_metaa frozen plain object { endpoint, contentType, topic, peerFingerprint, peerChain, peerLocal, contentLen, sequence, gap, segment, layer, trace, tracestate, achieved, report, reportMode, reportId }, copied out at once; absent values are null, the counters contentLen, sequence and segment BigInt, layer a number, gap a frozen { expected, seen } of BigInts, peerChain a frozen array of X509Certificate, leaf first, peerLocal a frozen { uid, gid, pid } for an AF_UNIX peer or { sid, pid } for a named-pipe peer, pid null where the platform reports none, otherwise null, achieved a "WEIDA_ACKNOWLEDGEMENT_*" name, report a frozen array of the ordered cursor levels (a "WEIDA_ACKNOWLEDGEMENT_*" name or an application stage as a BigInt; empty when nothing was ordered), reportMode a "WEIDA_REPORT_MODE_*" name, reportId a BigInt or nullpresent; mtls.test.js "any-key exposes the fingerprint and the chain", config.test.js "metadata travels with a request and its reply", local.test.js "a round trip over a unix socket names the client's uid", "a round trip over a named pipe names the client's SID" (local transports), patterns.test.js "a skipped sequence reads as a gap under per-producer detect" (patterns), cursors.test.js "a request that orders Accepted receives the reported offsets in order", "final-only yields exactly one update per level" (cursors)
weida_msga frozen { payload: Uint8Array, meta }, copied out at oncepresent
the ops (*_op)not exposed: a waiting method starts its op, waits, and drops it in finally, which cancels it only when it did not finishrefused: an op is the C caller's way to wait, not a value a JavaScript caller needs
the _fd functions, weida_pollnot exposed: the addon's waiter thread polls the descriptors (§4)refused: no JavaScript runtime can watch a raw descriptor itself
weida_version, weida_strerror, weida_new_traceversion(), strerror(code), newTrace()present; smoke.mjs, errors.test.js "strerror of an unknown code is 'unknown error'", config.test.js "newTrace is a sampled W3C traceparent"
the enumeration constants (WEIDA_CONGESTION_*, WEIDA_ERROR_CODE_*, WEIDA_ALPN_*, WEIDA_IDENTITY_EVENT_*, WEIDA_INCOMING_*, WEIDA_ASK_* and the rest, R7)their names as strings, read from the addon's CONSTANTS; DEFAULT_DATAGRAM_RECEIVE_BYTES, BLOB_ID_LEN, MAX_PIECES and the PIECE_SIZE_*_LOG2 exported as numberspresent; config.test.js "configuration input errors are thrown at once", inproc.test.js "a refusal code outside WEIDA_ERROR_CODE_* is a TypeError and leaves the request usable", sources.test.js "source and ALPN argument errors are TypeErrors", flows.test.js "a flow carries datagrams to an acceptor and ends after them" (flows)

The conversions between Node's KeyObject and X509Certificate and the ABI's PEM and DER follow 0047.

Every handle class releases its handle when the garbage collector finalizes it, and .drop() and [Symbol.dispose]() (using) release it at once. A dropped or consumed object throws WEIDA_ECLOSED without calling C; its pending waits reject with WEIDA_ECLOSED before its descriptor closes. Present; inproc.test.js "dropping a replier rejects its pending accept with WEIDA_ECLOSED".

3. Errors

One class, WeidaError, with code (the R9 constant name, "WEIDA_EUNTRUSTED"), errno (the positive code), message (the Display text), and the thread-local record as lossCause ("WEIDA_LOSS_*" or null), fingerprint, max and osCode (each null when absent), read by the addon in the same native call that failed. A JavaScript caller branches on error.code, as on Node's own SystemError, so there are no subclasses. Present; errors.test.js "every status code is a WeidaError carrying its R9 name", quic.test.js "a wrong pin rejects with WEIDA_EUNTRUSTED carrying the fingerprint".

4. Waiting

BehaviourVerdict
The JS thread never blocks: every native call passes timeout_ms = 0, and a try or op wait that would block returns AGAIN to the JavaScript layerpresent by construction (src/addon.c)
One waiter thread per runtime environment runs weida_poll over the descriptors of every pending wait plus a wake pipe (on Windows a loopback UDP socket connected to itself, since WSAPoll takes only sockets), and reports each readable one, once, to the JS thread through one napi_threadsafe_function; the call is then tried againpresent; every unit test past its first AGAIN
Two waits on one handle (two accepts on a replier) both watch its descriptor and are both retried; the one that finds nothing watches againpresent; inproc.test.js "two concurrent accepts on one replier serve two requests"
An idle process exits: the threadsafe function is referenced only while a wait is pendingpresent; smoke.mjs exits on its own under all three runtimes
Every waiting method takes { signal }; aborting rejects with signal.reason and cancels the operation (its op is dropped). AbortSignal.timeout(ms) is the timeoutpresent; inproc.test.js "an aborted request rejects with the reason and the runtime still shuts down"
The waiter thread blocks every signal, so a process-directed signal reaches the JS thread, whose runtime handles itpresent by construction (src/waiter.c); on Windows there are none to block
Worker threads: each napi_env has its own instance data and waiterpresent by construction; not run

5. Packaging

RowVerdict
One package weida for every platform: lib/, and per platform prebuilds/<platform>-<arch>/weida.node with libweida beside it, found through the addon's rpath ($ORIGIN, @loader_path; libweida.dylib's install name is @rpath/libweida.dylib); lib/native.js loads the one of process.platform-process.arch and names the missing path otherwise; on Windows weida.dll sits beside the addon, which links it and node.lib delay-loaded: src/win32.c binds node.exe to the running executable and loads weida.dll from the addon's directorypresent; package.sh
The packed version is the workspace version (0.1.0-alpha.11-dev stays as it is, already semver); the committed package.json says 0.0.0-devpresent; package.sh checks the installed version
The tarball installs offline into a fresh project and runs with no Rust toolchain on PATHpresent; package.sh (package.ps1 on Windows) runs smoke.mjs with PATH reduced to node, bun, deno and /usr/bin:/bin (%SystemRoot%\System32 and %SystemRoot% on Windows)
Node 20 and up (engines), Bun and Deno load the same addon through createRequirepresent; Node 26, Bun 1.4.4, Deno 2.9.8 run (js-linux-amd64, js-linux-arm64, js-darwin-arm64, js-windows-amd64)
macOSpresent on arm64; js-darwin-arm64 runs the same tests and smoke with runtimes js_env downloads
Windowspresent on x64: js-windows-amd64 builds the addon with MSVC (build.ps1) on wohnzimmer and runs the same tests and smoke with runtimes it downloads; the addon and weida.dll link the C runtime statically
npm registrypresent: a v* tag publishes weida with the linux-x64, linux-arm64, darwin-arm64 and win32-x64 prebuilds to npmjs.org under the dist-tag latest (publish-npm), the first being 0.1.0-alpha.14; up to 0.1.0-alpha.13 the package was @tuco86/weida on the forge's registry

6. What is not mapped

Nothing: every type the C ABI maps is mapped here, and the C ABI's refusals (weida-c.md) hold here too.

7. Sources

crates/js/weida-js/src/ (addon.c, waiter.c, win32.c, addon.h), lib/ (index.js, index.d.ts, native.js, errors.js, wait.js), build.sh, build.ps1, develop.sh, package.sh, package.ps1, smoke.mjs, test/; .zeughaus-ci/js-linux-amd64.sh, .zeughaus-ci/js-linux-arm64.sh, .zeughaus-ci/js-darwin-arm64.sh, .zeughaus-ci/js-windows-amd64.ps1, .zeughaus-ci/publish-npm.sh, js_env and js_check in .zeughaus-ci/build.sh; weida-c.md; docs/c/; decisions/0046.