Repository navigation
feat(html): layered API with a plain tree, sink and op log, from strings, bytes, iterables or streams - #2
Merged
Merged
Conversation
…s, bytes, iterables or streams
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Today the only way to get something readable out of
@bomb.sh/htmlis to parse into an op log and thenreplay()it into a 13-methodTreeSink. This PR adds a front door that returns a plain tree, keeps the sink and the op log as lower layers, and lets every layer take streams and iterables. It should land before the "[ci] release" PR, which would otherwise publish the old API as 0.1.0.API
Each layer has
parse(input, options?)andparseFragment(input, options). The module you import decides what comes back:@bomb.sh/htmlDocument,DocumentFragment,Element, … with atypetag@bomb.sh/html/sinkTreeSink<N>builds@clack/ui@bomb.sh/html/logOpLog, plusreplay()ReadableStreamreturn a promise.contextandsinklive in the options object because the@bomb.sh/toolslint rulemax-paramsallows two parameters.InputError, because ofno-generic-error.fastPath(the tests use it throughsrc/engine.ts) andparseBytes(folded intoUint8Arrayinput).LimitErrororResourceErroris thrown before the sink receives its first call.@clack/uirelies on this so a failedinnerHTMLset leaves the document unchanged.Structure
refactor(html): move the engine host to src/engine.tsis a pure rename with callers repointed. It is green on its own, and keeps blame for the engine host.src/engine.tsis still the only module that talks to the wasm.input.ts,tree.ts,sink.ts,log.tsandindex.tsare thin layers on top of it.src/engine.ts. It falls back tosrc/index.tsfor refs from before the split, so--compare mainstill works.Verification
pnpm lint,pnpm format:check,pnpm check:engineandpnpm buildpass. The build emitsindex,sinkandlog.pnpm test: 11,060 passed and 14 expected failures. Every WPT tree-construction case now also runs through the publicparse/parseFragmenttree, and all 3,891 match the reference replay.test/api.test.tscovers input kinds, errors and layers.node scripts/metrics.ts --compare main --suite fragment --samples 16:fragment e2e fast+0.1% [-1.4%, +1.5%]. No engine change, as expected.Not in this PR
@clack/uistill uses its own workspace copy of the old API. It moves to@bomb.sh/html/sinkwhen it switches to the published package.engine/index.zena) waits on whether Zena consumers can link the engine's.watruntime.