Parent: #140 Tracked by: #134, #163, #164
Symbols
| Symbol | Home (packages/runtime/src/jsc/URLSearchParams.zig @ 7ed99c02) | Bun C++ (upstream/src/jsc/bindings/URLSearchParams.cpp) |
|---|---|---|
URLSearchParams__create | :20 — (globalObject: *JSGlobalObject, *const ZigString) JSValue | :34 — URLSearchParams::create(str, nullptr) wrapped via toJSNewlyCreated |
URLSearchParams__fromJS | :26 — (JSValue) ?*URLSearchParams | :41 — WebCoreCast |
URLSearchParams__toString | :32 — (self, ctx, callback) void | :49 — serialize, hand out as ZigString via callback |
The zig-js engine already ships the URLSearchParams JS builtin (form-urlencoded parse with one leading ? stripped, +/percent codec, native serializer, internal \x00usp pairs slot), so this slice is thin ABI plumbing over existing engine semantics — not a new URL implementation.
Acceptance criteria
URLSearchParams__createdecodes the input ZigString and constructs a realm-prototypeURLSearchParamsinstance from the query string (same semantics asnew URLSearchParams(str)), returning the encoded object; engine-visible asinstanceof URLSearchParamswith working.get/.toString.URLSearchParams__fromJSreturns the stable canonical cell handle for values carrying the engine's URLSearchParams internal slot (native-created or JS-constructed, either realm of the group), null for anything else (plain objects, strings, numbers, empty/undefined).URLSearchParams__toStringserializes exactly like the JStoStringmethod and invokes the callback once with a stable borrowed ZigString view (latin-1 when the serialization is 8-bit); null params/callback tolerated without invocation.- Engine helpers added as narrow
pubwrappers next to the existing USP implementation (constructor setup shared, not duplicated). - Compiled runtime fixture covers: create→fromJS→toString roundtrip with exact
+/percent re-encoding, JS-constructed instance acceptance, negative fromJS matrix, empty-input empty serialization, null tolerance,instanceof/.getengine integration. Fixture symbol count 291 → 294. - Home inventory
291/431, Bun inventory284/421;bun-private-abi-audit+c-api-auditgreen; fullzig build testzero new failures (worktree baseline-vs-candidate against the same pinned base).
Design constraints
- The
URLSearchParams*native pointer of Bun maps to the canonical cell handle, same convention asJSC__JSObject__create(#306): zig-js has no separate native USP object — the JS object with its internal slot is the instance. - No WHATWG URL parser work is pulled in:
URL.zig/DOMURL.zigstay deferred; this slice is strictly the form-urlencoded pairs boundary.