As part of the ongoing effort to remove the `_proto: *Parent` field,
TaggedOpaque.fromJS is now offset based. Technically this should perform better
since we're no longer walking through pointers. But the real goal is that we
can now start removing _proto fields.
But, for fromJS to be offset-based, we had to make sure every prototype chain
was a contiguous allocation. The Factory did this, but not everything used the
factory. Now, everything does. This change alone, without the fromJS change,
made every WebAPI allocation more consistent.
Ultimately, our goal is to remove the `_proto: *Field`. That would save 24
bytes per Text node (or Element, ...). Large websites have 20K+ nodes, so we're
talking 300-500KB savings.
ef756b0c96 was the first phase of this. This is
the second, and it's targetting at CData for a simple reason: CData currently
has an optimization that makes removal of `_proto: *Field` difficult: it
directly embeds its empty types (most notably, Text). Zig's @offsetOf doesn't
work on tagged unions, so we'd have to jump through hoops to figure it out (it
is doable though). Also, CData has a "incorrect" flattened CDATASection
specifically so that Text doesn't inherit a _type union..so that's another
problem.
The solution is to move to bare unions, which allows us to use our Factory
to control the layout of the CData and thus have predictable offsets.
CData is now an inconsistent with the rest, but, at the very least, all Node
types will move in this direction.
This is groundwork for eventually removing the _proto: *X` field from some
types (in order to save 8 bytes per, e.g. Node). For now, all `_proto: *X`
fields are untouched, BUT, all compile-time chain walking now happens against
this new declaration.
Builds on top of the excellent https://github.com/lightpanda-io/browser/pull/3072
1 - HTMLAllCollection now composes NodeLive to get the performance benefit
2 - NodeLive now also optimizes for same-index access, e.g. x[i].a, x[i].b.
3 - NodeLive and RadioNodeList now don't lose their position when different
operations types are mixed (e.g. next() wit getAtIndex())
Reworks how a Node's child list is modeled. This used to be a optional pointer
to the child list, along with a Node representing this node's linkedlist node
in the parent's child list.
The new model is the same 24 bytes, but it's fully embedded: nodes with children
don't require another 16 byte allocation.
Generally speaking, this is more linked-list-ish, so it does simplify the code.
`linkToNode` is removed BUT, the first child's `_prev` points to the last child,
which is a bit unusual but necessary so that `lastChild` remains O(1).
This is a follow up to the large SVG change that has landed (1). Most changes
are mechanical or superficial (proper license headers, removing "pub" where not
needed, ...). But there were also a few finalizer/arena tweaks to tighten
lifetimes.
(1) https://github.com/lightpanda-io/browser/pull/3012
closeTarget above implies that the state this assertion guards against IS valid
AND we just had a crash report confirming. That's enough for me to remove it.
Zig 0.17 removes @cImport in favor of translate-c steps in the build
system. Each library's link function now creates an addTranslateC step
exposed as a module import: curl and isocline translate their headers
straight from the dependency tree, while sqlite3 uses the artifact's
emitted include tree since the amalgamation lives in a sub-dependency.
Terminal.zig and prompt_assist.zig previously instantiated two
independent @cImport namespaces for isocline; they now share one
translated module, so its types are identical across both files.
This isn't exhaustive, but it covers _most_ cases where we call v8 (and the
most important ones, e.g. from ScriptManager and EventManager).
There's also a Page counter which, in the future, I'd like to expose in some way
such as via a custom cdp command or in a fetch --dump json to provide insight
on the "health" of the page/result.
Replace the Anthropic Claude-Code-import flow with OpenAI Codex (ChatGPT
subscription) OAuth: device-code login, a real token store (auth.json,
0600) with refresh-grant, and JWT ChatGPT-Account-Id extraction. Codex is
now a distinct zenai provider, so the bearer-mode credential collapses to
provider==.codex; account_id threads to the client via InitOptions.
Unit-tested (build green): JWT account-id extraction, token store
round-trip, OAuth request-body encoding, token-response parsing. The
device-login / refresh network path is unverified pending a subscription.
Pins zenai to the codex branch (6967324).